@InterfaceAudience.Private public final class MetricsConnection extends Object implements StatisticTrackable
MetricRegistry
and JmxReporter
so
as to not conflict with other uses of Yammer Metrics within the client application. Calling
getMetricsConnection(String, Supplier, Supplier)
implicitly creates and "starts"
instances of these classes; be sure to call deleteMetricsConnection(String)
to terminate
the thread pools they allocate. The metrics reporter will be shutdown shutdown()
when
all connections within this metrics instances are closed.Modifier and Type | Class and Description |
---|---|
static class |
MetricsConnection.CallStats
A container class for collecting details about the RPC call as it percolates.
|
protected static class |
MetricsConnection.CallTracker |
private static interface |
MetricsConnection.NewMetric<T>
A lambda for dispatching to the appropriate metric factory method
|
protected static class |
MetricsConnection.RegionStats |
protected static class |
MetricsConnection.RunnerStats |
Modifier and Type | Field and Description |
---|---|
private MetricsConnection.CallTracker |
appendTracker |
private List<Supplier<ThreadPoolExecutor>> |
batchPools |
private static String |
CACHE_BASE |
private ConcurrentMap<String,com.codahale.metrics.Counter> |
cacheDroppingExceptions |
private static int |
CAPACITY
Anticipated number of metric entries
|
static String |
CLIENT_SIDE_METRICS_ENABLED_KEY
Set this key to
true to enable metrics collection of client requests. |
private static String |
CLIENT_SVC |
private static String |
CNT_BASE |
private static int |
CONCURRENCY_LEVEL
Anticipated number of concurrent accessor threads
|
private com.codahale.metrics.Histogram |
concurrentCallsPerServerHist |
private com.codahale.metrics.Counter |
connectionCount |
private MetricsConnection.NewMetric<com.codahale.metrics.Counter> |
counterFactory |
private MetricsConnection.CallTracker |
deleteTracker |
private static String |
DRTN_BASE |
private static String |
FAILURE_CNT_BASE |
private MetricsConnection.CallTracker |
getTracker |
private static String |
HEAP_BASE |
private com.codahale.metrics.Counter |
hedgedReadOps |
private com.codahale.metrics.Counter |
hedgedReadWin |
private MetricsConnection.NewMetric<com.codahale.metrics.Histogram> |
histogramFactory |
private MetricsConnection.CallTracker |
incrementTracker |
private static float |
LOAD_FACTOR
Default load factor from
HashMap.DEFAULT_LOAD_FACTOR |
private static String |
LOCAL_EXCEPTION_CNT_BASE |
private static String |
MEMLOAD_BASE |
private com.codahale.metrics.Counter |
metaCacheHits |
private com.codahale.metrics.Counter |
metaCacheMisses |
private com.codahale.metrics.Counter |
metaCacheNumClearRegion |
private com.codahale.metrics.Counter |
metaCacheNumClearServer |
private List<Supplier<ThreadPoolExecutor>> |
metaPools |
private static ConcurrentMap<String,MetricsConnection> |
METRICS_INSTANCES |
static String |
METRICS_SCOPE_KEY
Set to specify a custom scope for the metrics published through
MetricsConnection . |
private MetricsConnection.CallTracker |
multiTracker |
private static String |
NS_LOOKUPS |
private static String |
NS_LOOKUPS_FAILED |
private com.codahale.metrics.Counter |
nsLookups |
private com.codahale.metrics.Counter |
nsLookupsFailed |
private com.codahale.metrics.Histogram |
numActionsPerServerHist |
private com.codahale.metrics.Timer |
overloadedBackoffTimer |
private MetricsConnection.CallTracker |
putTracker |
private com.codahale.metrics.MetricRegistry |
registry |
private static String |
REMOTE_EXCEPTION_CNT_BASE |
private com.codahale.metrics.JmxReporter |
reporter |
private static String |
REQ_BASE |
private static String |
RESP_BASE |
private ConcurrentMap<String,com.codahale.metrics.Counter> |
rpcCounters |
private ConcurrentMap<String,com.codahale.metrics.Histogram> |
rpcHistograms |
private ConcurrentMap<String,com.codahale.metrics.Timer> |
rpcTimers |
private MetricsConnection.RunnerStats |
runnerStats |
private MetricsConnection.CallTracker |
scanTracker |
private String |
scope |
private ConcurrentHashMap<ServerName,ConcurrentMap<byte[],MetricsConnection.RegionStats>> |
serverStats |
private MetricsConnection.NewMetric<com.codahale.metrics.Timer> |
timerFactory |
private static String |
TOTAL_EXCEPTION_CNT |
private static String |
UNKNOWN_EXCEPTION |
Modifier | Constructor and Description |
---|---|
private |
MetricsConnection(String scope,
Supplier<ThreadPoolExecutor> batchPool,
Supplier<ThreadPoolExecutor> metaPool) |
Modifier and Type | Method and Description |
---|---|
private void |
addThreadPools(Supplier<ThreadPoolExecutor> batchPool,
Supplier<ThreadPoolExecutor> metaPool)
Add thread pools of additional connections to the metrics
|
private void |
decrConnectionCount()
Decrement the connection count of the metrics within a scope
|
(package private) static void |
deleteMetricsConnection(String scope) |
MetricsConnection.CallTracker |
getAppendTracker()
appendTracker metric
|
long |
getConnectionCount()
Return the connection count of the metrics within a scope
|
MetricsConnection.CallTracker |
getDeleteTracker()
deleteTracker metric
|
(package private) String |
getExecutorPoolName() |
MetricsConnection.CallTracker |
getGetTracker()
getTracker metric
|
com.codahale.metrics.Counter |
getHedgedReadOps()
hedgedReadOps metric
|
com.codahale.metrics.Counter |
getHedgedReadWin()
hedgedReadWin metric
|
MetricsConnection.CallTracker |
getIncrementTracker()
incrementTracker metric
|
long |
getMetaCacheMisses() |
com.codahale.metrics.Counter |
getMetaCacheNumClearRegion()
metaCacheNumClearRegion metric
|
com.codahale.metrics.Counter |
getMetaCacheNumClearServer()
metaCacheNumClearServer metric
|
(package private) String |
getMetaPoolName() |
private <T> T |
getMetric(String key,
ConcurrentMap<String,T> map,
MetricsConnection.NewMetric<T> factory)
Get a metric for
key from map , or create it with factory . |
(package private) com.codahale.metrics.MetricRegistry |
getMetricRegistry() |
(package private) static MetricsConnection |
getMetricsConnection(String scope,
Supplier<ThreadPoolExecutor> batchPool,
Supplier<ThreadPoolExecutor> metaPool) |
String |
getMetricScope()
scope of the metrics object
|
MetricsConnection.CallTracker |
getMultiTracker()
multiTracker metric
|
com.codahale.metrics.Histogram |
getNumActionsPerServerHist()
numActionsPerServerHist metric
|
MetricsConnection.CallTracker |
getPutTracker()
putTracker metric
|
ConcurrentMap<String,com.codahale.metrics.Counter> |
getRpcCounters()
rpcCounters metric
|
MetricsConnection.RunnerStats |
getRunnerStats()
runnerStats metric
|
MetricsConnection.CallTracker |
getScanTracker()
scanTracker metric
|
(package private) static String |
getScope(org.apache.hadoop.conf.Configuration conf,
String clusterId,
Object connectionObj)
Returns the scope for a MetricsConnection based on the configured
METRICS_SCOPE_KEY or
by generating a default from the passed clusterId and connectionObj's hashCode. |
ConcurrentHashMap<ServerName,ConcurrentMap<byte[],MetricsConnection.RegionStats>> |
getServerStats()
serverStats metric
|
void |
incrCacheDroppingExceptions(Object exception) |
private void |
incrConnectionCount()
Increment the connection count of the metrics within a scope
|
void |
incrDelayRunnersAndUpdateDelayInterval(long interval)
Increment the number of delay runner counts and update delay interval of delay runner.
|
void |
incrementServerOverloadedBackoffTime(long time,
TimeUnit timeUnit)
Update the overloaded backoff time
|
void |
incrHedgedReadOps()
Increment the number of hedged read that have occurred.
|
void |
incrHedgedReadWin()
Increment the number of hedged read returned faster than the original read.
|
void |
incrMetaCacheHit()
Increment the number of meta cache hits.
|
void |
incrMetaCacheMiss()
Increment the number of meta cache misses.
|
void |
incrMetaCacheNumClearRegion()
Increment the number of meta cache drops requested for individual region.
|
void |
incrMetaCacheNumClearRegion(int count)
Increment the number of meta cache drops requested for individual region.
|
void |
incrMetaCacheNumClearServer()
Increment the number of meta cache drops requested for entire RegionServer.
|
void |
incrNormalRunners()
Increment the number of normal runner counts.
|
void |
incrNsLookups() |
void |
incrNsLookupsFailed() |
static MetricsConnection.CallStats |
newCallStats()
Produce an instance of
MetricsConnection.CallStats for clients to attach to RPCs. |
private void |
shutdown() |
void |
updateRegionStats(ServerName serverName,
byte[] regionName,
RegionLoadStats stats)
Update stats per region.
|
void |
updateRpc(org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor method,
org.apache.hbase.thirdparty.com.google.protobuf.Message param,
MetricsConnection.CallStats stats,
Throwable e)
Report RPC context to metrics system.
|
private void |
updateRpcGeneric(String methodName,
MetricsConnection.CallStats stats)
Update call stats for non-critical-path methods
|
void |
updateServerStats(ServerName serverName,
byte[] regionName,
Object r) |
private static final ConcurrentMap<String,MetricsConnection> METRICS_INSTANCES
public static final String CLIENT_SIDE_METRICS_ENABLED_KEY
true
to enable metrics collection of client requests.public static final String METRICS_SCOPE_KEY
MetricsConnection
. The
scope is added to JMX MBean objectName, and defaults to a combination of the Connection's
clusterId and hashCode. For example, a default value for a connection to cluster "foo" might be
"foo-7d9d0818", where "7d9d0818" is the hashCode of the underlying AsyncConnectionImpl. Users
may set this key to give a more contextual name for this scope. For example, one might want to
differentiate a read connection from a write connection by setting the scopes to "foo-read" and
"foo-write" respectively. Scope is the only thing that lends any uniqueness to the metrics.
Care should be taken to avoid using the same scope for multiple Connections, otherwise the
metrics may aggregate in unforeseen ways.private static final String CNT_BASE
private static final String FAILURE_CNT_BASE
private static final String TOTAL_EXCEPTION_CNT
private static final String LOCAL_EXCEPTION_CNT_BASE
private static final String REMOTE_EXCEPTION_CNT_BASE
private static final String DRTN_BASE
private static final String REQ_BASE
private static final String RESP_BASE
private static final String MEMLOAD_BASE
private static final String HEAP_BASE
private static final String CACHE_BASE
private static final String UNKNOWN_EXCEPTION
private static final String NS_LOOKUPS
private static final String NS_LOOKUPS_FAILED
private static final String CLIENT_SVC
private ConcurrentHashMap<ServerName,ConcurrentMap<byte[],MetricsConnection.RegionStats>> serverStats
private static final int CAPACITY
private static final float LOAD_FACTOR
HashMap.DEFAULT_LOAD_FACTOR
private static final int CONCURRENCY_LEVEL
private final com.codahale.metrics.MetricRegistry registry
private final com.codahale.metrics.JmxReporter reporter
private final MetricsConnection.NewMetric<com.codahale.metrics.Timer> timerFactory
private final MetricsConnection.NewMetric<com.codahale.metrics.Histogram> histogramFactory
private final MetricsConnection.NewMetric<com.codahale.metrics.Counter> counterFactory
private final List<Supplier<ThreadPoolExecutor>> batchPools
private final List<Supplier<ThreadPoolExecutor>> metaPools
private final com.codahale.metrics.Counter connectionCount
private final com.codahale.metrics.Counter metaCacheHits
private final com.codahale.metrics.Counter metaCacheMisses
private final MetricsConnection.CallTracker getTracker
private final MetricsConnection.CallTracker scanTracker
private final MetricsConnection.CallTracker appendTracker
private final MetricsConnection.CallTracker deleteTracker
private final MetricsConnection.CallTracker incrementTracker
private final MetricsConnection.CallTracker putTracker
private final MetricsConnection.CallTracker multiTracker
private final MetricsConnection.RunnerStats runnerStats
private final com.codahale.metrics.Counter metaCacheNumClearServer
private final com.codahale.metrics.Counter metaCacheNumClearRegion
private final com.codahale.metrics.Counter hedgedReadOps
private final com.codahale.metrics.Counter hedgedReadWin
private final com.codahale.metrics.Histogram concurrentCallsPerServerHist
private final com.codahale.metrics.Histogram numActionsPerServerHist
private final com.codahale.metrics.Counter nsLookups
private final com.codahale.metrics.Counter nsLookupsFailed
private final com.codahale.metrics.Timer overloadedBackoffTimer
private final ConcurrentMap<String,com.codahale.metrics.Timer> rpcTimers
private final ConcurrentMap<String,com.codahale.metrics.Histogram> rpcHistograms
private final ConcurrentMap<String,com.codahale.metrics.Counter> cacheDroppingExceptions
private final ConcurrentMap<String,com.codahale.metrics.Counter> rpcCounters
private MetricsConnection(String scope, Supplier<ThreadPoolExecutor> batchPool, Supplier<ThreadPoolExecutor> metaPool)
static MetricsConnection getMetricsConnection(String scope, Supplier<ThreadPoolExecutor> batchPool, Supplier<ThreadPoolExecutor> metaPool)
static void deleteMetricsConnection(String scope)
static String getScope(org.apache.hadoop.conf.Configuration conf, String clusterId, Object connectionObj)
METRICS_SCOPE_KEY
or
by generating a default from the passed clusterId and connectionObj's hashCode.conf
- configuration for the connectionclusterId
- clusterId for the connectionconnectionObj
- either a Connection or AsyncConnectionImpl, the instance creating this
MetricsConnection.public void updateServerStats(ServerName serverName, byte[] regionName, Object r)
public void updateRegionStats(ServerName serverName, byte[] regionName, RegionLoadStats stats)
StatisticTrackable
updateRegionStats
in interface StatisticTrackable
final String getExecutorPoolName()
final String getMetaPoolName()
com.codahale.metrics.MetricRegistry getMetricRegistry()
public String getMetricScope()
public ConcurrentHashMap<ServerName,ConcurrentMap<byte[],MetricsConnection.RegionStats>> getServerStats()
public MetricsConnection.RunnerStats getRunnerStats()
public com.codahale.metrics.Counter getMetaCacheNumClearServer()
public com.codahale.metrics.Counter getMetaCacheNumClearRegion()
public com.codahale.metrics.Counter getHedgedReadOps()
public com.codahale.metrics.Counter getHedgedReadWin()
public com.codahale.metrics.Histogram getNumActionsPerServerHist()
public ConcurrentMap<String,com.codahale.metrics.Counter> getRpcCounters()
public MetricsConnection.CallTracker getGetTracker()
public MetricsConnection.CallTracker getScanTracker()
public MetricsConnection.CallTracker getMultiTracker()
public MetricsConnection.CallTracker getAppendTracker()
public MetricsConnection.CallTracker getDeleteTracker()
public MetricsConnection.CallTracker getIncrementTracker()
public MetricsConnection.CallTracker getPutTracker()
public static MetricsConnection.CallStats newCallStats()
MetricsConnection.CallStats
for clients to attach to RPCs.public void incrMetaCacheHit()
public void incrMetaCacheMiss()
public long getMetaCacheMisses()
public void incrMetaCacheNumClearServer()
public void incrMetaCacheNumClearRegion()
public void incrMetaCacheNumClearRegion(int count)
public void incrHedgedReadOps()
public void incrHedgedReadWin()
public void incrNormalRunners()
public void incrDelayRunnersAndUpdateDelayInterval(long interval)
public void incrementServerOverloadedBackoffTime(long time, TimeUnit timeUnit)
public long getConnectionCount()
private void incrConnectionCount()
private void decrConnectionCount()
private void addThreadPools(Supplier<ThreadPoolExecutor> batchPool, Supplier<ThreadPoolExecutor> metaPool)
private <T> T getMetric(String key, ConcurrentMap<String,T> map, MetricsConnection.NewMetric<T> factory)
key
from map
, or create it with factory
.private void updateRpcGeneric(String methodName, MetricsConnection.CallStats stats)
private void shutdown()
public void updateRpc(org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor method, org.apache.hbase.thirdparty.com.google.protobuf.Message param, MetricsConnection.CallStats stats, Throwable e)
public void incrCacheDroppingExceptions(Object exception)
public void incrNsLookups()
public void incrNsLookupsFailed()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.