当前位置: 首页>>代码示例>>Java>>正文


Java MetricsAsserts.assertQuantileGauges方法代码示例

本文整理汇总了Java中org.apache.hadoop.test.MetricsAsserts.assertQuantileGauges方法的典型用法代码示例。如果您正苦于以下问题:Java MetricsAsserts.assertQuantileGauges方法的具体用法?Java MetricsAsserts.assertQuantileGauges怎么用?Java MetricsAsserts.assertQuantileGauges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.test.MetricsAsserts的用法示例。


在下文中一共展示了MetricsAsserts.assertQuantileGauges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRpcMetrics

import org.apache.hadoop.test.MetricsAsserts; //导入方法依赖的package包/类
@Test
public void testRpcMetrics() throws Exception {
  Server server;
  TestRpcService proxy = null;

  final int interval = 1;
  conf.setBoolean(CommonConfigurationKeys.
      RPC_METRICS_QUANTILE_ENABLE, true);
  conf.set(CommonConfigurationKeys.
      RPC_METRICS_PERCENTILES_INTERVALS_KEY, "" + interval);

  server = setupTestServer(conf, 5);

  try {
    proxy = getClient(addr, conf);

    for (int i = 0; i < 1000; i++) {
      proxy.ping(null, newEmptyRequest());

      proxy.echo(null, newEchoRequest("" + i));
    }
    MetricsRecordBuilder rpcMetrics =
        getMetrics(server.getRpcMetrics().name());
    assertTrue("Expected non-zero rpc queue time",
        getLongCounter("RpcQueueTimeNumOps", rpcMetrics) > 0);
    assertTrue("Expected non-zero rpc processing time",
        getLongCounter("RpcProcessingTimeNumOps", rpcMetrics) > 0);
    MetricsAsserts.assertQuantileGauges("RpcQueueTime" + interval + "s",
        rpcMetrics);
    MetricsAsserts.assertQuantileGauges("RpcProcessingTime" + interval + "s",
        rpcMetrics);
  } finally {
    stop(server, proxy);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:36,代码来源:TestRPC.java

示例2: testRpcMetrics

import org.apache.hadoop.test.MetricsAsserts; //导入方法依赖的package包/类
@Test
public void testRpcMetrics() throws Exception {
  Configuration configuration = new Configuration();
  final int interval = 1;
  configuration.setBoolean(CommonConfigurationKeys.
      RPC_METRICS_QUANTILE_ENABLE, true);
  configuration.set(CommonConfigurationKeys.
      RPC_METRICS_PERCENTILES_INTERVALS_KEY, "" + interval);
  final Server server = new RPC.Builder(configuration)
      .setProtocol(TestProtocol.class).setInstance(new TestImpl())
      .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
      .build();
  server.start();
  final TestProtocol proxy = RPC.getProxy(TestProtocol.class,
      TestProtocol.versionID, server.getListenerAddress(), configuration);
  try {
    for (int i=0; i<1000; i++) {
      proxy.ping();
      proxy.echo("" + i);
    }
    MetricsRecordBuilder rpcMetrics =
        getMetrics(server.getRpcMetrics().name());
    assertTrue("Expected non-zero rpc queue time",
        getLongCounter("RpcQueueTimeNumOps", rpcMetrics) > 0);
    assertTrue("Expected non-zero rpc processing time",
        getLongCounter("RpcProcessingTimeNumOps", rpcMetrics) > 0);
    MetricsAsserts.assertQuantileGauges("RpcQueueTime" + interval + "s",
        rpcMetrics);
    MetricsAsserts.assertQuantileGauges("RpcProcessingTime" + interval + "s",
        rpcMetrics);
  } finally {
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
    server.stop();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:TestRPC.java

示例3: testRpcMetrics

import org.apache.hadoop.test.MetricsAsserts; //导入方法依赖的package包/类
@Test
public void testRpcMetrics() throws Exception {
  final Server server;
  TestRpcService proxy = null;

  final int interval = 1;
  conf.setBoolean(CommonConfigurationKeys.
      RPC_METRICS_QUANTILE_ENABLE, true);
  conf.set(CommonConfigurationKeys.
      RPC_METRICS_PERCENTILES_INTERVALS_KEY, "" + interval);

  server = setupTestServer(conf, 5);
  String testUser = "testUser";
  UserGroupInformation anotherUser =
      UserGroupInformation.createRemoteUser(testUser);
  TestRpcService proxy2 =
      anotherUser.doAs(new PrivilegedAction<TestRpcService>() {
        public TestRpcService run() {
          try {
            return RPC.getProxy(TestRpcService.class, 0,
                server.getListenerAddress(), conf);
          } catch (IOException e) {
            e.printStackTrace();
          }
          return null;
        }
      });
  try {
    proxy = getClient(addr, conf);

    for (int i = 0; i < 1000; i++) {
      proxy.ping(null, newEmptyRequest());

      proxy.echo(null, newEchoRequest("" + i));
      proxy2.echo(null, newEchoRequest("" + i));
    }
    MetricsRecordBuilder rpcMetrics =
        getMetrics(server.getRpcMetrics().name());
    assertTrue("Expected non-zero rpc queue time",
        getLongCounter("RpcQueueTimeNumOps", rpcMetrics) > 0);
    assertTrue("Expected non-zero rpc processing time",
        getLongCounter("RpcProcessingTimeNumOps", rpcMetrics) > 0);
    MetricsAsserts.assertQuantileGauges("RpcQueueTime" + interval + "s",
        rpcMetrics);
    MetricsAsserts.assertQuantileGauges("RpcProcessingTime" + interval + "s",
        rpcMetrics);
    String actualUserVsCon = MetricsAsserts
        .getStringMetric("NumOpenConnectionsPerUser", rpcMetrics);
    String proxyUser =
        UserGroupInformation.getCurrentUser().getShortUserName();
    assertTrue(actualUserVsCon.contains("\"" + proxyUser + "\":1"));
    assertTrue(actualUserVsCon.contains("\"" + testUser + "\":1"));
  } finally {
    if (proxy2 != null) {
      RPC.stopProxy(proxy2);
    }
    stop(server, proxy);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:60,代码来源:TestRPC.java


注:本文中的org.apache.hadoop.test.MetricsAsserts.assertQuantileGauges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。