List of usage examples for io.netty.handler.traffic TrafficCounter currentWrittenBytes
AtomicLong currentWrittenBytes
To view the source code for io.netty.handler.traffic TrafficCounter currentWrittenBytes.
Click Source Link
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: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 ww. j av a 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 v a 2 s .com 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.waarp.openr66.protocol.utils.ChannelUtils.java
License:Open Source License
/** * Compute Wait for Traffic in Write (ugly turn around) * /*from w w w. ja v a2s .co m*/ * @param cts * @param size * @return the wait in ms */ public static final long willBeWaitingWriting(ChannelTrafficShapingHandler cts, int size) { long currentTime = System.currentTimeMillis(); if (cts != null && Configuration.configuration.getServerChannelWriteLimit() > 0) { TrafficCounter tc = cts.trafficCounter(); if (tc != null) { long wait = waitTraffic(Configuration.configuration.getServerChannelWriteLimit(), tc.currentWrittenBytes() + size, tc.lastTime(), currentTime); if (wait > 0) { return wait; } } } if (Configuration.configuration.getServerGlobalWriteLimit() > 0) { GlobalTrafficHandler gts = Configuration.configuration.getGlobalTrafficShapingHandler(); if (gts != null) { TrafficCounter tc = gts.trafficCounter(); if (tc != null) { long wait = waitTraffic(Configuration.configuration.getServerGlobalWriteLimit(), tc.currentWrittenBytes() + size, tc.lastTime(), currentTime); if (wait > 0) { return wait; } } } } return 0; }