org.jboss.netty.util.Timeout类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(225)

本文整理了Java中org.jboss.netty.util.Timeout类的一些代码示例,展示了Timeout类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timeout类的具体详情如下:
包路径:org.jboss.netty.util.Timeout
类名称:Timeout

Timeout介绍

[英]A handle associated with a TimerTask that is returned by a Timer.
[中]与计时器返回的计时器任务相关联的句柄。

代码示例

代码示例来源:origin: twitter/distributedlog

@Override
  public BoxedUnit apply() {
    timeout.cancel();
    return null;
  }
});

代码示例来源:origin: twitter/distributedlog

@Override
public void run(Timeout timeout) throws Exception {
  if (timeout.isCancelled()) {
    return;
  }
  logger.info("Ownership cache : {} streams cached, {} hosts cached",
      stream2Addresses.size(), address2Streams.size());
  logger.info("Cached streams : {}", stream2Addresses);
  scheduleDumpOwnershipCache();
}

代码示例来源:origin: com.facebook.nifty/nifty-client

private void cancelRequestTimeouts(Request request)
{
  Timeout sendTimeout = request.getSendTimeout();
  if (sendTimeout != null && !sendTimeout.isCancelled()) {
    sendTimeout.cancel();
  }
  Timeout receiveTimeout = request.getReceiveTimeout();
  if (receiveTimeout != null && !receiveTimeout.isCancelled()) {
    receiveTimeout.cancel();
  }
  Timeout readTimeout = request.getReadTimeout();
  if (readTimeout != null && !readTimeout.isCancelled()) {
    readTimeout.cancel();
  }
}

代码示例来源:origin: com.ning/async-http-client

public void cancel() {
    if (cancelled.compareAndSet(false, true)) {
      if (requestTimeout != null) {
        requestTimeout.cancel();
        RequestTimeoutTimerTask.class.cast(requestTimeout.getTask()).clean();
        requestTimeout = null;
      }
      if (readTimeout != null) {
        readTimeout.cancel();
        ReadTimeoutTimerTask.class.cast(readTimeout.getTask()).clean();
        readTimeout = null;
      }
    }
  }
}

代码示例来源:origin: cgbystrom/netty-tools

public void run(Timeout timeout) throws Exception {
  if (timeout.isCancelled())
    return;
  final long timestamp = System.currentTimeMillis();
  final long deltaTime = timestamp - lastTimestamp;
  long sent = bytesSent.get() - lastBytesSent;
  long received = bytesReceived.get() - lastBytesReceived;
  lastBytesSent = bytesSent.get();
  lastBytesReceived = bytesReceived.get();
  if (sent < 0)
    sent = 0;
  if (received < 0)
    received = 0;
  sentHistory.add(sent / deltaTime);
  receivedHistory.add(received / deltaTime);
  if (sentHistory.size() > HISTORY_SIZE)
    sentHistory.removeFirst();
  if (receivedHistory.size() > HISTORY_SIZE)
    receivedHistory.removeFirst();
  
  bytesSentPerSecond.set(average(sentHistory) * 1000);
  bytesReceivedPerSecond.set(average(receivedHistory) * 1000);
  lastTimestamp = timestamp;
  timeout.getTimer().newTimeout(timeout.getTask(), RESOLUTION, TimeUnit.MILLISECONDS);
}

代码示例来源:origin: org.onosproject/onos-pcep-provider-tunnel

@Override
public void run(Timeout timeout) throws Exception {
  if (stopped || timeout.isCancelled()) {
    return;
  }
  log.trace("Collecting stats for {}", pcepTunnelId);
  sendTunnelStatistic();
  if (!stopped && !timeout.isCancelled()) {
    log.trace("Scheduling stats collection in {} seconds for {}",
         this.refreshInterval, pcepTunnelId);
    timeout.getTimer().newTimeout(this, refreshInterval, TimeUnit.SECONDS);
  }
}

代码示例来源:origin: com.ning/async-http-client

scheduleNewIdleChannelDetector(timeout.getTask());

代码示例来源:origin: org.onosproject/onos-of-provider-group

@Override
public void run(Timeout timeout) throws Exception {
  log.trace("Collecting stats for {}", sw.getStringId());
  sendGroupStatistic();
  if (!this.stopTimer) {
    log.trace("Scheduling stats collection in {} seconds for {}",
        this.refreshInterval, this.sw.getStringId());
    timeout.getTimer().newTimeout(this, refreshInterval,
        TimeUnit.SECONDS);
  }
}

代码示例来源:origin: org.asynchttpclient/async-http-client-netty3

public void cancel() {
    if (cancelled.compareAndSet(false, true)) {
      if (requestTimeout != null) {
        requestTimeout.cancel();
        RequestTimeoutTimerTask.class.cast(requestTimeout.getTask()).clean();
        requestTimeout = null;
      }
      if (readTimeout != null) {
        readTimeout.cancel();
        ReadTimeoutTimerTask.class.cast(readTimeout.getTask()).clean();
        readTimeout = null;
      }
    }
  }
}

代码示例来源:origin: org.onosproject/onos-of-provider-device

@Override
public void run(Timeout to) throws Exception {
  if (stopped || timeout.isCancelled()) {
    return;
  }
  log.trace("Collecting stats for {}", sw.getStringId());
  sendPortStatistic();
  if (!stopped && !timeout.isCancelled()) {
    log.trace("Scheduling stats collection in {} seconds for {}",
        this.refreshInterval, this.sw.getStringId());
    timeout.getTimer().newTimeout(this, refreshInterval, TimeUnit.SECONDS);
  }
}

代码示例来源:origin: org.onosproject/onos-netconf-provider-flow

@Override
  public void run(Timeout to) throws Exception {
    for (DeviceId devId : flowTable.keySet()) {
      providerService.pushFlowMetrics(devId, flowTable
          .getOrDefault(devId, Collections.emptySet()));
    }
    timeout = timer.newTimeout(to.getTask(), 5, TimeUnit.SECONDS);
  }
}

代码示例来源:origin: os-libera/OpenVirteX

@Override
public void run(Timeout timeout) throws Exception {
  log.debug("Collecting stats for {}", this.sw.getSwitchName());
  sendPortStatistics();
  sendFlowStatistics(0, (short) 0);
  if (!this.stopTimer) {
    log.debug("Scheduling stats collection in {} seconds for {}",
        this.refreshInterval, this.sw.getSwitchName());
    timeout.getTimer().newTimeout(this, refreshInterval,
        TimeUnit.SECONDS);
  }
}

代码示例来源:origin: io.netty/netty

private void cancelHandshakeTimeout() {
  if (handshakeTimeout != null) {
    // cancel the task as we will fail the handshake future now
    handshakeTimeout.cancel();
  }
}

代码示例来源:origin: twitter/distributedlog

@Override
  public void run(Timeout timeout) throws Exception {
    if (!timeout.isCancelled()) {
      serviceTimeout.inc();
      handleServiceTimeout("Operation " + op.getClass().getName() + " timeout");
    }
  }
}, serviceTimeoutMs, TimeUnit.MILLISECONDS);

代码示例来源:origin: org.asynchttpclient/async-http-client-netty3-provider

public void cancel() {
    if (cancelled.compareAndSet(false, true)) {
      if (requestTimeout != null) {
        requestTimeout.cancel();
        RequestTimeoutTimerTask.class.cast(requestTimeout.getTask()).clean();
        requestTimeout = null;
      }
      if (readTimeout != null) {
        readTimeout.cancel();
        ReadTimeoutTimerTask.class.cast(readTimeout.getTask()).clean();
        readTimeout = null;
      }
    }
  }
}

代码示例来源:origin: io.gatling/async-http-client

public void run(Timeout timeout) throws Exception {
    if (isClosed.get())
      return;
    try {
      if (LOGGER.isDebugEnabled())
        for (String key : poolsPerKey.keySet()) {
          LOGGER.debug("Entry count for : {} : {}", key, poolsPerKey.get(key).size());
        }
      long start = millisTime();
      int closedCount = 0;
      int totalCount = 0;
      for (ConcurrentLinkedQueue<IdleChannel> pool : poolsPerKey.values()) {
        // store in intermediate unsynchronized lists to minimize the impact on the ConcurrentLinkedQueue
        if (LOGGER.isDebugEnabled())
          totalCount += pool.size();
        List<IdleChannel> closedChannels = closeChannels(expiredChannels(pool, start));
        pool.removeAll(closedChannels);
        int poolClosedCount = closedChannels.size();
        closedCount += poolClosedCount;
      }
      long duration = millisTime() - start;
      LOGGER.debug("Closed {} connections out of {} in {}ms", closedCount, totalCount, duration);
    } catch (Throwable t) {
      LOGGER.error("uncaught exception!", t);
    }
    scheduleNewIdleChannelDetector(timeout.getTask());
  }
}

代码示例来源:origin: io.netty/netty

public void operationComplete(ChannelFuture future) throws Exception {
    timeout.cancel();
  }
}

代码示例来源:origin: twitter/distributedlog

@Override
  synchronized public void run(Timeout timeout) throws Exception {
    if (!timeout.isCancelled() && null != nextAddressToSend) {
      doSend(nextAddressToSend);
    } else {
      fail(null, new CancelledRequestException());
    }
  }
}

代码示例来源:origin: org.asynchttpclient/async-http-client-netty3-provider

scheduleNewIdleChannelDetector(timeout.getTask());

代码示例来源:origin: io.netty/netty

private static void destroy(ChannelHandlerContext ctx) {
  State state = state(ctx);
  synchronized (state) {
    if (state.state != 1) {
      return;
    }
    state.state = 2;
  }
  if (state.readerIdleTimeout != null) {
    state.readerIdleTimeout.cancel();
    state.readerIdleTimeout = null;
  }
  if (state.writerIdleTimeout != null) {
    state.writerIdleTimeout.cancel();
    state.writerIdleTimeout = null;
  }
  if (state.allIdleTimeout != null) {
    state.allIdleTimeout.cancel();
    state.allIdleTimeout = null;
  }
}

相关文章