@InterfaceAudience.Private @InterfaceStability.Evolving public class S3AInstrumentation extends Object implements Closeable, org.apache.hadoop.metrics2.MetricsSource, CountersAndGauges, org.apache.hadoop.fs.statistics.IOStatisticsSource
History
AzureFileSystemInstrumentation
.
Counters and metrics are generally addressed in code by their name or
Statistic
key. There may be some Statistics which do
not have an entry here. To avoid attempts to access such counters failing,
the operations to increment/query metric values are designed to handle
lookup failures.
S3AFileSystem StorageStatistics are dynamically derived from the IOStatistics.
The toString() operation includes the entire IOStatistics when this class's log is set to DEBUG. This keeps the logs somewhat manageable on normal runs, but allows for more reporting.
Modifier and Type | Field and Description |
---|---|
static String |
CONTEXT
"s3aFileSystem" Currently all s3a metrics are placed in a single
"context".
|
static String |
METRIC_TAG_BUCKET
"bucket" The name of a field added to metrics records
that indicates the hostname portion of the FS URL.
|
static String |
METRIC_TAG_FILESYSTEM_ID
"s3aFileSystemId" The name of a field added to metrics
records that uniquely identifies a specific FileSystem instance.
|
static String |
METRICS_SYSTEM_NAME
"s3a-file-system" The name of the s3a-specific metrics
system instance used for s3a metrics.
|
Constructor and Description |
---|
S3AInstrumentation(URI name)
Construct the instrumentation for a filesystem.
|
Modifier and Type | Method and Description |
---|---|
void |
addValueToQuantiles(Statistic op,
long value)
Add a value to a quantiles statistic.
|
void |
close() |
protected org.apache.hadoop.metrics2.lib.MutableCounterLong |
counter(Statistic op)
Create a counter in the registry.
|
protected org.apache.hadoop.metrics2.lib.MutableCounterLong |
counter(String name,
String desc)
Create a counter in the registry.
|
org.apache.hadoop.fs.statistics.impl.IOStatisticsStore |
createMetricsUpdatingStore()
Create an IOStatistics store which updates FS metrics
as well as IOStatistics.
|
void |
decrementGauge(Statistic op,
long count)
Decrement a specific gauge.
|
void |
directoryCreated()
Indicate that S3A created a directory.
|
void |
directoryDeleted()
Indicate that S3A just deleted a directory.
|
String |
dump(String prefix,
String separator,
String suffix,
boolean all)
Dump all the metrics to a string.
|
protected void |
duration(Statistic op)
Registering a duration adds the success and failure counters.
|
void |
errorIgnored()
Note that an error was ignored.
|
void |
fakeDirsDeleted(int count)
Indicate that fake directory request was made.
|
void |
fileCreated()
Indicate that S3A created a file.
|
void |
fileDeleted(int count)
Indicate that S3A deleted one or more files.
|
void |
filesCopied(int files,
long size)
Indicate that S3A copied some files within the store.
|
protected org.apache.hadoop.metrics2.lib.MutableGaugeLong |
gauge(Statistic op)
Create a gauge in the registry.
|
protected org.apache.hadoop.metrics2.lib.MutableGaugeLong |
gauge(String name,
String desc)
Create a gauge in the registry.
|
long |
getCounterValue(Statistic statistic)
Get the value of a counter.
|
long |
getCounterValue(String name)
Get the value of a counter.
|
org.apache.hadoop.fs.statistics.DurationTrackerFactory |
getDurationTrackerFactory()
Get the duration tracker factory.
|
org.apache.hadoop.fs.statistics.impl.IOStatisticsStore |
getIOStatistics()
Get the instance IO Statistics.
|
void |
getMetrics(org.apache.hadoop.metrics2.MetricsCollector collector,
boolean all) |
String |
getMetricSourceName()
if registered with the metrics, return the
name of the source.
|
org.apache.hadoop.metrics2.lib.MetricsRegistry |
getRegistry()
Get the metrics registry.
|
void |
incrementCounter(Statistic op,
AtomicLong count)
Increments a mutable counter and the matching
instance IOStatistics counter with the value of
the atomic long.
|
void |
incrementCounter(Statistic op,
long count)
Increments a mutable counter and the matching
instance IOStatistics counter.
|
void |
incrementGauge(Statistic op,
long count)
Increment a specific gauge.
|
org.apache.hadoop.metrics2.lib.MutableGaugeLong |
lookupGauge(String name)
Look up a gauge.
|
org.apache.hadoop.metrics2.lib.MutableMetric |
lookupMetric(String name)
Look up a metric from both the registered set and the lighter weight
stream entries.
|
org.apache.hadoop.metrics2.lib.MutableQuantiles |
lookupQuantiles(String name)
Look up a quantiles.
|
CommitterStatistics |
newCommitterStatistics()
Create a new instance of the committer statistics.
|
DelegationTokenStatistics |
newDelegationTokenStatistics()
Create a delegation token statistics instance.
|
S3AInputStreamStatistics |
newInputStreamStatistics(org.apache.hadoop.fs.FileSystem.Statistics filesystemStatistics)
Create a stream input statistics instance.
|
BlockOutputStreamStatistics |
newOutputStreamStatistics(org.apache.hadoop.fs.FileSystem.Statistics filesystemStatistics)
Create a stream output statistics instance.
|
protected org.apache.hadoop.metrics2.lib.MutableQuantiles |
quantiles(Statistic op,
String sampleName,
String valueName,
int interval)
Create a quantiles in the registry.
|
void |
recordDuration(Statistic op,
boolean success,
Duration duration)
Add the duration as a timed statistic, deriving
statistic name from the operation symbol and the outcome.
|
Map<String,Long> |
toMap()
Copy all the metrics to a map of (name, long-value).
|
String |
toString()
String representation.
|
org.apache.hadoop.fs.statistics.DurationTracker |
trackDuration(String key,
long count)
The duration tracker updates the metrics with the count
and IOStatistics will full duration information.
|
public static final String METRICS_SYSTEM_NAME
public static final String CONTEXT
public static final String METRIC_TAG_FILESYSTEM_ID
public static final String METRIC_TAG_BUCKET
public S3AInstrumentation(URI name)
name
- URI of filesystem.protected final org.apache.hadoop.metrics2.lib.MutableCounterLong counter(String name, String desc)
name
- counter namedesc
- counter descriptionprotected final org.apache.hadoop.metrics2.lib.MutableCounterLong counter(Statistic op)
op
- statistic to countprotected final void duration(Statistic op)
op
- statistic to trackprotected final org.apache.hadoop.metrics2.lib.MutableGaugeLong gauge(String name, String desc)
name
- name gauge namedesc
- descriptionprotected final org.apache.hadoop.metrics2.lib.MutableGaugeLong gauge(Statistic op)
op
- statistic to countprotected final org.apache.hadoop.metrics2.lib.MutableQuantiles quantiles(Statistic op, String sampleName, String valueName, int interval)
op
- statistic to collectsampleName
- sample name of the quantilesvalueName
- value name of the quantilesinterval
- interval of the quantiles in secondspublic org.apache.hadoop.metrics2.lib.MetricsRegistry getRegistry()
public String dump(String prefix, String separator, String suffix, boolean all)
prefix
- prefix before every entryseparator
- separator between name and valuesuffix
- suffixall
- get all the metrics even if the values are not changed.public long getCounterValue(Statistic statistic)
statistic
- the operationpublic long getCounterValue(String name)
name
- the name of the counterpublic org.apache.hadoop.metrics2.lib.MutableGaugeLong lookupGauge(String name)
name
- gauge nameClassCastException
- if the metric is not a Gauge.public org.apache.hadoop.metrics2.lib.MutableQuantiles lookupQuantiles(String name)
name
- quantiles nameClassCastException
- if the metric is not a Quantiles.public org.apache.hadoop.metrics2.lib.MutableMetric lookupMetric(String name)
name
- metric namepublic org.apache.hadoop.fs.statistics.impl.IOStatisticsStore getIOStatistics()
getIOStatistics
in interface org.apache.hadoop.fs.statistics.IOStatisticsSource
public org.apache.hadoop.fs.statistics.DurationTrackerFactory getDurationTrackerFactory()
public org.apache.hadoop.fs.statistics.DurationTracker trackDuration(String key, long count)
trackDuration
in interface org.apache.hadoop.fs.statistics.DurationTrackerFactory
key
- statistic key prefixcount
- #of times to increment the matching counter in this
operation.public org.apache.hadoop.fs.statistics.impl.IOStatisticsStore createMetricsUpdatingStore()
public String toString()
public void fileCreated()
public void fileDeleted(int count)
count
- number of files.public void fakeDirsDeleted(int count)
count
- number of directory entries included in the delete request.public void directoryCreated()
public void directoryDeleted()
public void filesCopied(int files, long size)
files
- number of filessize
- total size in bytespublic void errorIgnored()
public void incrementCounter(Statistic op, long count)
incrementCounter
in interface CountersAndGauges
op
- operationcount
- increment valuepublic void addValueToQuantiles(Statistic op, long value)
addValueToQuantiles
in interface CountersAndGauges
op
- operation to look up.value
- value to add.ClassCastException
- if the metric is not a Quantiles.public void incrementCounter(Statistic op, AtomicLong count)
op
- operationcount
- atomic long containing valuepublic void incrementGauge(Statistic op, long count)
incrementGauge
in interface CountersAndGauges
op
- operationcount
- increment valueClassCastException
- if the metric is of the wrong typepublic void decrementGauge(Statistic op, long count)
decrementGauge
in interface CountersAndGauges
op
- operationcount
- increment valueClassCastException
- if the metric is of the wrong typepublic void recordDuration(Statistic op, boolean success, Duration duration)
recordDuration
in interface CountersAndGauges
op
- operationsuccess
- was the operation a success?duration
- how long did it takepublic S3AInputStreamStatistics newInputStreamStatistics(@Nullable org.apache.hadoop.fs.FileSystem.Statistics filesystemStatistics)
filesystemStatistics
- FS Statistics to update in close().public CommitterStatistics newCommitterStatistics()
public void getMetrics(org.apache.hadoop.metrics2.MetricsCollector collector, boolean all)
getMetrics
in interface org.apache.hadoop.metrics2.MetricsSource
public String getMetricSourceName()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public BlockOutputStreamStatistics newOutputStreamStatistics(org.apache.hadoop.fs.FileSystem.Statistics filesystemStatistics)
filesystemStatistics
- thread-local FS statistics.public DelegationTokenStatistics newDelegationTokenStatistics()
Copyright © 2008–2024 Apache Software Foundation. All rights reserved.