use of org.apache.hadoop.metrics2.MetricsRecordBuilder in project hadoop by apache.
the class TestTopMetrics method testPresence.
@Test
public void testPresence() {
Configuration conf = new Configuration();
TopConf topConf = new TopConf(conf);
TopMetrics topMetrics = new TopMetrics(conf, topConf.nntopReportingPeriodsMs);
// Dummy command
topMetrics.report("test", "listStatus");
topMetrics.report("test", "listStatus");
topMetrics.report("test", "listStatus");
MetricsRecordBuilder rb = getMetrics(topMetrics);
MetricsCollector mc = rb.parent();
verify(mc).addRecord(TOPMETRICS_METRICS_SOURCE_NAME + ".windowMs=60000");
verify(mc).addRecord(TOPMETRICS_METRICS_SOURCE_NAME + ".windowMs=300000");
verify(mc).addRecord(TOPMETRICS_METRICS_SOURCE_NAME + ".windowMs=1500000");
verify(rb, times(3)).addCounter(Interns.info("op=listStatus.TotalCount", "Total operation count"), 3L);
verify(rb, times(3)).addCounter(Interns.info("op=*.TotalCount", "Total operation count"), 3L);
verify(rb, times(3)).addCounter(Interns.info("op=listStatus." + "user=test.count", "Total operations performed by user"), 3L);
}
use of org.apache.hadoop.metrics2.MetricsRecordBuilder in project hadoop by apache.
the class TestMRAppMetrics method checkMetrics.
private void checkMetrics(int jobsSubmitted, int jobsCompleted, int jobsFailed, int jobsKilled, int jobsPreparing, int jobsRunning, int mapsLaunched, int mapsCompleted, int mapsFailed, int mapsKilled, int mapsRunning, int mapsWaiting, int reducesLaunched, int reducesCompleted, int reducesFailed, int reducesKilled, int reducesRunning, int reducesWaiting) {
MetricsRecordBuilder rb = getMetrics("MRAppMetrics");
assertCounter("JobsSubmitted", jobsSubmitted, rb);
assertCounter("JobsCompleted", jobsCompleted, rb);
assertCounter("JobsFailed", jobsFailed, rb);
assertCounter("JobsKilled", jobsKilled, rb);
assertGauge("JobsPreparing", jobsPreparing, rb);
assertGauge("JobsRunning", jobsRunning, rb);
assertCounter("MapsLaunched", mapsLaunched, rb);
assertCounter("MapsCompleted", mapsCompleted, rb);
assertCounter("MapsFailed", mapsFailed, rb);
assertCounter("MapsKilled", mapsKilled, rb);
assertGauge("MapsRunning", mapsRunning, rb);
assertGauge("MapsWaiting", mapsWaiting, rb);
assertCounter("ReducesLaunched", reducesLaunched, rb);
assertCounter("ReducesCompleted", reducesCompleted, rb);
assertCounter("ReducesFailed", reducesFailed, rb);
assertCounter("ReducesKilled", reducesKilled, rb);
assertGauge("ReducesRunning", reducesRunning, rb);
assertGauge("ReducesWaiting", reducesWaiting, rb);
}
use of org.apache.hadoop.metrics2.MetricsRecordBuilder in project hadoop by apache.
the class TestRPC method doRPCs.
private void doRPCs(Configuration myConf, boolean expectFailure) throws Exception {
Server server;
TestRpcService proxy = null;
server = setupTestServer(myConf, 5);
server.refreshServiceAcl(myConf, new TestPolicyProvider());
TestProtos.EmptyRequestProto emptyRequestProto = TestProtos.EmptyRequestProto.newBuilder().build();
try {
proxy = getClient(addr, conf);
proxy.ping(null, emptyRequestProto);
if (expectFailure) {
fail("Expect RPC.getProxy to fail with AuthorizationException!");
}
} catch (ServiceException e) {
if (expectFailure) {
RemoteException re = (RemoteException) e.getCause();
assertTrue(re.unwrapRemoteException() instanceof AuthorizationException);
assertEquals("RPC error code should be UNAUTHORIZED", RpcErrorCodeProto.FATAL_UNAUTHORIZED, re.getErrorCode());
} else {
throw e;
}
} finally {
MetricsRecordBuilder rb = getMetrics(server.rpcMetrics.name());
if (expectFailure) {
assertCounter("RpcAuthorizationFailures", 1L, rb);
} else {
assertCounter("RpcAuthorizationSuccesses", 1L, rb);
}
//since we don't have authentication turned ON, we should see
// 0 for the authentication successes and 0 for failure
assertCounter("RpcAuthenticationFailures", 0L, rb);
assertCounter("RpcAuthenticationSuccesses", 0L, rb);
stop(server, proxy);
}
}
use of org.apache.hadoop.metrics2.MetricsRecordBuilder in project hadoop by apache.
the class TestRetryCacheMetrics method checkMetrics.
private void checkMetrics(long hit, long cleared, long updated) {
MetricsRecordBuilder rb = getMetrics("RetryCache." + cacheName);
assertCounter("CacheHit", hit, rb);
assertCounter("CacheCleared", cleared, rb);
assertCounter("CacheUpdated", updated, rb);
}
use of org.apache.hadoop.metrics2.MetricsRecordBuilder in project hadoop by apache.
the class TestMetricsAnnotations method testMethods.
@Test
public void testMethods() {
MyMetrics2 metrics = new MyMetrics2();
MetricsSource source = MetricsAnnotations.makeSource(metrics);
MetricsRecordBuilder rb = getMetrics(source);
verify(rb).addGauge(info("G1", "G1"), 1);
verify(rb).addGauge(info("G2", "G2"), 2L);
verify(rb).addGauge(info("G3", "G3"), 3.0f);
verify(rb).addGauge(info("G4", "G4"), 4.0);
verify(rb).addCounter(info("C1", "C1"), 1);
verify(rb).addCounter(info("C2", "C2"), 2L);
verify(rb).tag(info("T1", "T1"), "t1");
}
Aggregations