Example usage for io.netty.handler.traffic TrafficCounter checkInterval

List of usage examples for io.netty.handler.traffic TrafficCounter checkInterval

Introduction

In this page you can find the example usage for io.netty.handler.traffic TrafficCounter checkInterval.

Prototype

AtomicLong checkInterval

To view the source code for io.netty.handler.traffic TrafficCounter checkInterval.

Click Source Link

Document

Delay between two captures

Usage

From source file:com.nettyhttpserver.server.NettyChannelTrafficShapingHandler.java

private void trafficAccounting() {
    TrafficCounter tc = trafficCounter();
    connectionInfo.setRecivedBytes(Math.abs(tc.cumulativeReadBytes()));
    connectionInfo.setSentBytes(tc.cumulativeWrittenBytes());
    connectionInfo.setSpeed(tc.lastWrittenBytes() * 1000 / (tc.checkInterval()));
    connectionInfo.setTimestamp(new Timestamp(System.currentTimeMillis()));
    /*//from w  ww .j  a va 2 s .  c  o  m
     * Instance is added to List on last place (the last the newest)
     */
    if (serverConnectionList.contains(connectionInfo)) {
        serverConnectionList.remove(connectionInfo);
        addToConnectionList();
    } else {
        addToConnectionList();
    }
}