RpcMetrics { public String name() { return name; } RpcMetrics(Server server, Configuration conf); String name(); static RpcMetrics create(Server server, Configuration conf); @Metric("Number of open connections") int numOpenConnections(); @Metric("Number of open connections per user") String numOpenConnectionsPerUser(); @Metric("Length of the call queue") int callQueueLength(); @Metric("Number of dropped connections") long numDroppedConnections(); void incrAuthenticationFailures(); void incrAuthenticationSuccesses(); void incrAuthorizationSuccesses(); void incrAuthorizationFailures(); void shutdown(); void incrSentBytes(int count); void incrReceivedBytes(int count); void addRpcQueueTime(long qTime); void addRpcLockWaitTime(long waitTime); void addRpcProcessingTime(long processingTime); void addDeferredRpcProcessingTime(long processingTime); void incrClientBackoff(); void incrSlowRpc(); MutableRate getRpcProcessingTime(); long getProcessingSampleCount(); double getProcessingMean(); double getProcessingStdDev(); long getRpcSlowCalls(); MutableRate getDeferredRpcProcessingTime(); long getDeferredRpcProcessingSampleCount(); double getDeferredRpcProcessingMean(); double getDeferredRpcProcessingStdDev(); @VisibleForTesting MetricsTag getTag(String tagName); final static TimeUnit TIMEUNIT; }
@Test public void metricsAreUnregistered() throws Exception { Configuration conf = new Configuration(); Server server = new Server("0.0.0.0", 0, LongWritable.class, 1, conf) { @Override public Writable call( RPC.RpcKind rpcKind, String protocol, Writable param, long receiveTime) throws Exception { return null; } }; MetricsSystem metricsSystem = DefaultMetricsSystem.instance(); RpcMetrics rpcMetrics = server.getRpcMetrics(); RpcDetailedMetrics rpcDetailedMetrics = server.getRpcDetailedMetrics(); assertNotNull(metricsSystem.getSource(rpcMetrics.name())); assertNotNull(metricsSystem.getSource(rpcDetailedMetrics.name())); server.stop(); assertNull(metricsSystem.getSource(rpcMetrics.name())); assertNull(metricsSystem.getSource(rpcDetailedMetrics.name())); }