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); }
@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); } }
@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); } }
@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); } }
@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); } }