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

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

Introduction

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

Prototype

AtomicLong cumulativeWrittenBytes

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

Click Source Link

Document

Long life written bytes

Usage

From source file:cc.agentx.ui.app.XConsole.java

License:Apache License

public String[] getTraffic(String uri, Map<String, String> params) {
    TrafficCounter counter = Status.TRAFFIC_HANDLER.trafficCounter();
    return new String[] { "text",
            "{\"readSum\":" + counter.cumulativeReadBytes() + ",\"read\":" + counter.currentReadBytes()
                    + ",\"writeSum\":" + counter.cumulativeWrittenBytes() + ",\"write\":"
                    + counter.currentWrittenBytes() + "}" };
}

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()));
    /*/*  www  . j  a v a2 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();
    }
}

From source file:de.jackwhite20.apex.command.impl.StatsCommand.java

License:Open Source License

@Override
public boolean execute(String[] args) {

    logger.info("Connections: {}", Apex.getChannelGroup().size());
    if (Apex.getInstance().getConnectionsPerSecondTask() != null) {
        logger.info("Connections per second: {}",
                Apex.getInstance().getConnectionsPerSecondTask().getPerSecond());
    }/*from   w  w w.  java 2  s .co m*/
    logger.info("Online backend servers: {}", Apex.getBalancingStrategy().size());

    GlobalTrafficShapingHandler trafficShapingHandler = Apex.getInstance().getTrafficShapingHandler();
    if (trafficShapingHandler != null) {
        TrafficCounter trafficCounter = trafficShapingHandler.trafficCounter();

        logger.info("Current bytes read: {}", trafficCounter.currentReadBytes());
        logger.info("Current bytes written: {}", trafficCounter.currentWrittenBytes());
        logger.info("Last read throughput: {}", trafficCounter.lastReadThroughput());
        logger.info("Last write throughput: {}", trafficCounter.lastWrittenBytes());
        logger.info("Total bytes read: {}", trafficCounter.cumulativeReadBytes());
        logger.info("Total bytes written: {}", trafficCounter.cumulativeWrittenBytes());
    }

    return true;
}

From source file:de.jackwhite20.apex.rest.resource.ApexResource.java

License:Open Source License

@GET
@Path("/stats")
@Produces(ContentType.APPLICATION_JSON)/*from  w  w  w  .ja va2 s  . c  o m*/
public Response stats(Request httpRequest) {

    if (trafficShapingHandler != null) {
        TrafficCounter trafficCounter = trafficShapingHandler.trafficCounter();

        return Response.ok()
                .content(gson.toJson(new ApexStatsResponse(ApexResponse.Status.OK, "OK",
                        Apex.getChannelGroup().size(), connectionsPerSecondTask.getPerSecond(),
                        Apex.getBalancingStrategy().getBackend().size(), trafficCounter.currentReadBytes(),
                        trafficCounter.currentWrittenBytes(), trafficCounter.lastReadThroughput(),
                        trafficCounter.lastWriteThroughput(), trafficCounter.cumulativeReadBytes(),
                        trafficCounter.cumulativeWrittenBytes())))
                .build();
    } else {
        return STATS_DISABLED;
    }
}

From source file:org.graylog2.plugin.inputs.util.ThroughputCounter.java

License:Open Source License

public Map<String, Gauge<Long>> gauges() {
    Map<String, Gauge<Long>> gauges = new HashMap<>();

    final TrafficCounter tc = trafficCounter();

    gauges.put(READ_BYTES_1_SEC, new Gauge<Long>() {
        @Override// w  ww. j ava2  s  . c o  m
        public Long getValue() {
            return tc.lastReadBytes();
        }
    });
    gauges.put(WRITTEN_BYTES_1_SEC, new Gauge<Long>() {
        @Override
        public Long getValue() {
            return tc.lastWrittenBytes();
        }
    });
    gauges.put(READ_BYTES_TOTAL, new Gauge<Long>() {
        @Override
        public Long getValue() {
            return tc.cumulativeReadBytes();
        }
    });
    gauges.put(WRITTEN_BYTES_TOTAL, new Gauge<Long>() {
        @Override
        public Long getValue() {
            return tc.cumulativeWrittenBytes();
        }
    });

    return gauges;
}

From source file:testserver.StatisticHandler.java

License:Apache License

@Override
public void close(ChannelHandlerContext ctx, ChannelPromise future) throws Exception {
    TrafficCounter tc = this.trafficCounter();
    requestInfo.add((Long) tc.cumulativeReadBytes());
    requestInfo.add((Long) tc.cumulativeWrittenBytes());
    requestInfo.add((Long) (tc.cumulativeReadBytes() + tc.cumulativeWrittenBytes()) * 1000
            / (System.currentTimeMillis() - tc.lastCumulativeTime()));
    Statistic.addFullQuery(requestInfo);
    Statistic.opened -= 1;/*from ww w.ja v a2 s  .c  o m*/
    super.close(ctx, future);
}