ServerLogMetricForwarderUnitTest.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:NeverwinterDP-Commons 作者:
@Test
public void testBasic() throws Exception {
  FileUtil.removeIfExist("build/ServerLogMetricPlugin", false);

  YaraServiceImpl yaraService = new YaraServiceImpl() ;
  server.getServiceRegistry().register(YaraService.newReflectiveBlockingService(yaraService));

  MetricRegistry server1 = createMetricRegistry("server1") ;
  MetricRegistry server2 = createMetricRegistry("server2") ;

  Random rand = new Random() ;
  for(int i = 0; i < 100000; i++) {
    long timestamp = Clock.defaultClock().getTick() ;

    server1.counter("counter").incr() ;
    server1.timer("timer").update(timestamp, rand.nextInt(1000)) ;

    server2.counter("counter").incr() ;
    server2.timer("timer").update(timestamp, rand.nextInt(1000)) ;
  }
  Thread.sleep(6000);
  new ClusterMetricPrinter().print(yaraService.getClusterMetricRegistry()); 
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号