Class MetricsSource
java.lang.Object
org.apache.hadoop.hbase.replication.regionserver.MetricsSource
- All Implemented Interfaces:
BaseSource
This class is for maintaining the various replication statistics for a source and publishing them
through the metrics interfaces.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MetricsReplicationGlobalSourceSourceprivate Stringprivate longprivate static final org.slf4j.Loggerprivate final MetricsReplicationSourceSourceprivate Map<String,MetricsReplicationTableSource> private longFields inherited from interface org.apache.hadoop.hbase.metrics.BaseSource
HBASE_METRICS_SYSTEM_NAME -
Constructor Summary
ConstructorsConstructorDescriptionMetricsSource(String id) Constructor used to register the metricsMetricsSource(String id, MetricsReplicationSourceSource singleSourceSource, MetricsReplicationGlobalSourceSource globalSourceSource, Map<String, MetricsReplicationTableSource> singleSourceSourceByTable) Constructor for injecting custom (or test) MetricsReplicationSourceSources -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all metrics about this Source.voidSubtract some amount from a gauge.voiddecrSizeOfHFileRefsQueue(int size) voidvoidDecrement the count for initializing sourcesGet AgeOfLastShippedOplonggetAgeOfLastShippedOp(String walGroup) get age of last shipped op of given wal group.longGets the number of edits not eligible for replication this source queue logs so far.Get the metrics context.Get the description of what this source exposes.Get the name of the context in JMX that this source will be exposed through.Get the name of the metrics that are being exported by this source.longlongGets the number of OPs shipped by this source queue to target cluster.Get the slave peer IDlongGets the number of edits eligible for replication read from this source queue logs so far.longintGet the sizeOfLogQueueintGet the source initializing countslongTimeStamp of next edit to be replicated.longGet the timestampsOfLastShippedOp, if there are multiple groups, return the latest onelongDeprecated.Since 2.0.0.longGet the value of uncleanlyClosedWAL counterlongReturns the amount of memory in bytes used in this RegionServer by edits pending replication.voidincCounters(String counterName, long delta) Add some amount to a counter.voidAdd some amount to a gauge.voidincrBytesSkippedInUncleanlyClosedWALs(long bytes) voidvoidvoidConvenience method to update metrics when batch of operations has failed.voidvoidThe number of log edits filtered out.voidincrLogEditsFiltered(long delta) Add on the number of log edits filteredvoidIncrement the number of log edits read by one.private voidincrLogEditsRead(long delta) Add on the the number of log edits readvoidincrLogReadInBytes(long readInBytes) increase the byte number read by source from log filevoidincrRepeatedFileBytes(long bytes) voidvoidincrSizeOfHFileRefsQueue(long size) voidIncrement size of the log queue.voidIncrement the count for initializing sourcesvoidvoidvoidinit()Clear out the metrics and re-prepare the source.voidrefreshAgeOfLastShippedOp(String walGroupId) Convenience method to use the last given timestamp to refresh the age of the last edit.voidremoveMetric(String key) Remove a metric and no longer announce it.voidsetAgeOfLastShippedOp(long timestamp, String walGroup) Set the age of the last edit that was shippedvoidsetAgeOfLastShippedOpByTable(long timestamp, String tableName) Set the age of the last edit that was shipped group by tablevoidSet a gauge to a specific value.voidsetOldestWalAge(long age) voidsetTimeStampNextToReplicate(long timeStampNextToReplicate) TimeStamp of next edit targeted for replication.voidsetWALReaderEditsBufferUsage(long usageInBytes) Sets the amount of memory in bytes used in this RegionServer by edits pending replication.voidshipBatch(long batchSize, int sizeInBytes) Convience method to apply changes to metrics do to shipping a batch of logs.voidshipBatch(long batchSize, int sizeInBytes, long hfiles) Convience method to apply changes to metrics do to shipping a batch of logs.voidvoidupdateHistogram(String name, long value) Add some value to a histogram.voidupdateTableLevelMetrics(List<Pair<WAL.Entry, Long>> walEntries) Update the table level replication metrics per tableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.metrics.BaseSource
getMetricRegistryInfo
-
Field Details
-
LOG
-
lastShippedTimeStamps
-
ageOfLastShippedOp
-
lastHFileRefsQueueSize
-
id
-
timeStampNextToReplicate
-
singleSourceSource
-
globalSourceSource
-
singleSourceSourceByTable
-
-
Constructor Details
-
MetricsSource
Constructor used to register the metrics- Parameters:
id- Name of the source this class is monitoring
-
MetricsSource
public MetricsSource(String id, MetricsReplicationSourceSource singleSourceSource, MetricsReplicationGlobalSourceSource globalSourceSource, Map<String, MetricsReplicationTableSource> singleSourceSourceByTable) Constructor for injecting custom (or test) MetricsReplicationSourceSources- Parameters:
id- Name of the source this class is monitoringsingleSourceSource- Class to monitor id-scoped metricsglobalSourceSource- Class to monitor global-scoped metrics
-
-
Method Details
-
setAgeOfLastShippedOp
Set the age of the last edit that was shipped- Parameters:
timestamp- target write time of the editwalGroup- which group we are setting
-
updateTableLevelMetrics
Update the table level replication metrics per table- Parameters:
walEntries- List of pairs of WAL entry and it's size
-
setAgeOfLastShippedOpByTable
Set the age of the last edit that was shipped group by table- Parameters:
timestamp- write time of the edittableName- String as group and tableName
-
getAgeOfLastShippedOp
get age of last shipped op of given wal group. If the walGroup is null, return 0- Parameters:
walGroup- which group we are getting
-
refreshAgeOfLastShippedOp
Convenience method to use the last given timestamp to refresh the age of the last edit. Used when replication fails and need to keep that metric accurate.- Parameters:
walGroupId- id of the group to update
-
incrSizeOfLogQueue
Increment size of the log queue. -
decrSizeOfLogQueue
-
incrSourceInitializing
Increment the count for initializing sources -
decrSourceInitializing
Decrement the count for initializing sources -
incrLogEditsRead
Add on the the number of log edits read- Parameters:
delta- the number of log edits read.
-
incrLogEditsRead
Increment the number of log edits read by one. -
incrLogEditsFiltered
Add on the number of log edits filtered- Parameters:
delta- the number filtered.
-
incrLogEditsFiltered
The number of log edits filtered out. -
shipBatch
Convience method to apply changes to metrics do to shipping a batch of logs.- Parameters:
batchSize- the size of the batch that was shipped to sinks.
-
incrementFailedBatches
Convenience method to update metrics when batch of operations has failed. -
getEditsFiltered
Gets the number of edits not eligible for replication this source queue logs so far.- Returns:
- logEditsFiltered non-replicable edits filtered from this queue logs.
-
getReplicableEdits
Gets the number of edits eligible for replication read from this source queue logs so far.- Returns:
- replicableEdits total number of replicable edits read from this queue logs.
-
getOpsShipped
Gets the number of OPs shipped by this source queue to target cluster.- Returns:
- oPsShipped total number of OPs shipped by this source.
-
shipBatch
Convience method to apply changes to metrics do to shipping a batch of logs.- Parameters:
batchSize- the size of the batch that was shipped to sinks.hfiles- total number of hfiles shipped to sinks.
-
incrLogReadInBytes
increase the byte number read by source from log file -
clear
Removes all metrics about this Source. -
terminate
-
getAgeOfLastShippedOp
Get AgeOfLastShippedOp -
getSizeOfLogQueue
Get the sizeOfLogQueue -
getTimeStampOfLastShippedOp
Deprecated.Since 2.0.0. Removed in 3.0.0.Get the timeStampsOfLastShippedOp, if there are multiple groups, return the latest one- See Also:
-
getUncleanlyClosedWALs
Get the value of uncleanlyClosedWAL counter -
getTimestampOfLastShippedOp
Get the timestampsOfLastShippedOp, if there are multiple groups, return the latest one -
getTimeStampNextToReplicate
TimeStamp of next edit to be replicated.- Returns:
- timeStampNextToReplicate - TimeStamp of next edit to be replicated.
-
setTimeStampNextToReplicate
TimeStamp of next edit targeted for replication. Used for calculating lag, as if this timestamp is greater than timestamp of last shipped, it means there's at least one edit pending replication.- Parameters:
timeStampNextToReplicate- timestamp of next edit in the queue that should be replicated.
-
getReplicationDelay
-
getSourceInitializing
Get the source initializing counts- Returns:
- number of replication sources getting initialized
-
getPeerID
Get the slave peer ID -
incrSizeOfHFileRefsQueue
-
decrSizeOfHFileRefsQueue
-
incrUnknownFileLengthForClosedWAL
-
incrUncleanlyClosedWALs
-
incrBytesSkippedInUncleanlyClosedWALs
-
incrRestartedWALReading
-
incrRepeatedFileBytes
-
incrCompletedWAL
-
incrCompletedRecoveryQueue
-
incrFailedRecoveryQueue
-
setOldestWalAge
-
getOldestWalAge
-
init
Description copied from interface:BaseSourceClear out the metrics and re-prepare the source.- Specified by:
initin interfaceBaseSource
-
setGauge
Description copied from interface:BaseSourceSet a gauge to a specific value.- Specified by:
setGaugein interfaceBaseSource- Parameters:
gaugeName- the name of the gaugevalue- the value
-
incGauge
Description copied from interface:BaseSourceAdd some amount to a gauge.- Specified by:
incGaugein interfaceBaseSource- Parameters:
gaugeName- the name of the gaugedelta- the amount to change the gauge by.
-
decGauge
Description copied from interface:BaseSourceSubtract some amount from a gauge.- Specified by:
decGaugein interfaceBaseSource- Parameters:
gaugeName- the name of the gaugedelta- the amount to change the gauge by.
-
removeMetric
Description copied from interface:BaseSourceRemove a metric and no longer announce it.- Specified by:
removeMetricin interfaceBaseSource- Parameters:
key- Name of the gauge to remove.
-
incCounters
Description copied from interface:BaseSourceAdd some amount to a counter.- Specified by:
incCountersin interfaceBaseSource- Parameters:
counterName- the name of the counterdelta- the amount to change the counter by.
-
updateHistogram
Description copied from interface:BaseSourceAdd some value to a histogram.- Specified by:
updateHistogramin interfaceBaseSource- Parameters:
name- the name of the histogramvalue- the value to add to the histogram
-
getMetricsContext
Description copied from interface:BaseSourceGet the metrics context. For hadoop metrics2 system this is usually an all lowercased string. eg. regionserver, master, thriftserver- Specified by:
getMetricsContextin interfaceBaseSource- Returns:
- The string context used to register this source to hadoop's metrics2 system.
-
getMetricsDescription
Description copied from interface:BaseSourceGet the description of what this source exposes.- Specified by:
getMetricsDescriptionin interfaceBaseSource
-
getMetricsJmxContext
Description copied from interface:BaseSourceGet the name of the context in JMX that this source will be exposed through. This is in ObjectName format. With the default context being Hadoop -> HBase- Specified by:
getMetricsJmxContextin interfaceBaseSource
-
getMetricsName
Description copied from interface:BaseSourceGet the name of the metrics that are being exported by this source. Eg. IPC, GC, WAL- Specified by:
getMetricsNamein interfaceBaseSource
-
getSingleSourceSourceByTable
-
setWALReaderEditsBufferUsage
Sets the amount of memory in bytes used in this RegionServer by edits pending replication. -
getWALReaderEditsBufferUsage
Returns the amount of memory in bytes used in this RegionServer by edits pending replication.
-