本文整理汇总了Java中io.netty.handler.traffic.TrafficCounter类的典型用法代码示例。如果您正苦于以下问题:Java TrafficCounter类的具体用法?Java TrafficCounter怎么用?Java TrafficCounter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TrafficCounter类属于io.netty.handler.traffic包,在下文中一共展示了TrafficCounter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: stats
import io.netty.handler.traffic.TrafficCounter; //导入依赖的package包/类
@GET
@Path("/stats")
@Produces(ContentType.APPLICATION_JSON)
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;
}
}
开发者ID:JackWhite20,项目名称:Apex,代码行数:24,代码来源:ApexResource.java
示例2: execute
import io.netty.handler.traffic.TrafficCounter; //导入依赖的package包/类
@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());
}
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;
}
开发者ID:JackWhite20,项目名称:Apex,代码行数:24,代码来源:StatsCommand.java
示例3: getTraffic
import io.netty.handler.traffic.TrafficCounter; //导入依赖的package包/类
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() + "}"};
}
开发者ID:ZhangJiupeng,项目名称:AgentX,代码行数:8,代码来源:XConsole.java
示例4: doAccounting
import io.netty.handler.traffic.TrafficCounter; //导入依赖的package包/类
@Override
protected void doAccounting(TrafficCounter counter) {
long currentTime = System.currentTimeMillis();
long interval = currentTime - lastChacked.getAndSet(currentTime);
if (interval == 0) {
return;
}
this.lastReads = currentReads.getAndSet(0L);
this.lastWrites = currentWrites.getAndSet(0L);
long readsPerSec = (lastReads / interval) * 1000;
long writesPerSec = (lastWrites / interval) * 1000;
metrics.setLastReads(readsPerSec);
metrics.setLastWrites(writesPerSec);
TrafficCounter traffic = trafficCounter();
long readThroughput = traffic.lastReadThroughput();
long writeThroughput = traffic.lastWriteThroughput();
metrics.setReadThroughput(readThroughput);
metrics.setWriteThroughput(writeThroughput);
if (logger.isInfoEnabled()) {
if (lastReads > 0 || lastWrites > 0) {
logger.info(toString());
}
}
}
开发者ID:apache,项目名称:incubator-hivemall,代码行数:28,代码来源:ThroughputCounter.java
示例5: toString
import io.netty.handler.traffic.TrafficCounter; //导入依赖的package包/类
@Override
public String toString() {
TrafficCounter traffic = trafficCounter();
final StringBuilder buf = new StringBuilder(512);
long readThroughput = traffic.lastReadThroughput();
buf.append("Read Throughput: ").append(readThroughput / 1024L).append(" KB/sec, ");
buf.append(lastReads).append(" msg/sec\n");
long writeThroughput = traffic.lastWriteThroughput();
buf.append("Write Throughput: ").append(writeThroughput / 1024).append(" KB/sec, ");
buf.append(lastWrites).append(" msg/sec");
return buf.toString();
}
开发者ID:apache,项目名称:incubator-hivemall,代码行数:13,代码来源:ThroughputCounter.java
示例6: doAccounting
import io.netty.handler.traffic.TrafficCounter; //导入依赖的package包/类
@Override
protected void doAccounting(TrafficCounter counter) {
long read = counter.lastReadBytes();
long write = counter.lastWrittenBytes();
for(BandwidthHandler handler : bandwidthHandlers.values()) {
handler.update(read, write);
}
}
开发者ID:samcday,项目名称:jnntp,代码行数:9,代码来源:DefaultNntpClient.java
示例7: init
import io.netty.handler.traffic.TrafficCounter; //导入依赖的package包/类
private void init(Channel channel, HandshakeRequest request, HandlerRegistration handlerReg) {
NettyServerHandlerConfig<Object> cfg = handlerReg.config();
if (cfg.getLoggerCategory() != null) {
log = LoggerFactory.getLogger(cfg.getLoggerCategory());
debug = log.isDebugEnabled();
trace = log.isTraceEnabled();
}
if (debug) {
log.debug("Initialized connection [from={}, protocol={}]", address(), cfg.getProtocol());
}
this.eventLoop = channel.eventLoop();
this.serverHandler = cfg.getHandler();
this.handlerReg = handlerReg;
this.metrics = handlerReg.metrics();
this.codec = request.codec();
// Register this client.
handlerReg.add(this);
if (metrics != null) {
channel.pipeline().addFirst(new ChannelTrafficShapingHandler(0, 0, NettyClient.TRAFFIC_SHAPING_INTERVAL) {
@Override
protected void doAccounting(TrafficCounter counter) {
metrics.onBytesReceived(counter.lastReadBytes());
metrics.onBytesSent(counter.lastWrittenBytes());
}
});
metrics.onConnect();
}
// Accept handshake.
HandshakeAccept accepted = new HandshakeAccept(hbInterval, hbLossThreshold, hbDisabled);
channel.writeAndFlush(accepted).addListener(future -> {
if (channel.isOpen()) {
connectNotified = true;
// Notify on connect.
serverHandler.onConnect(request.payload(), this);
}
}
);
}
开发者ID:hekate-io,项目名称:hekate,代码行数:49,代码来源:NettyServerClient.java
示例8: getTrafficCounter
import io.netty.handler.traffic.TrafficCounter; //导入依赖的package包/类
public TrafficCounter getTrafficCounter() {
return trafficHandler.trafficCounter();
}
开发者ID:breakEval13,项目名称:NSS,代码行数:4,代码来源:SocksServer.java
注:本文中的io.netty.handler.traffic.TrafficCounter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论