Package org.apache.hadoop.fs.s3a
Class S3AInstrumentation
java.lang.Object
org.apache.hadoop.fs.s3a.S3AInstrumentation
- All Implemented Interfaces:
Closeable,AutoCloseable,CountersAndGauges,org.apache.hadoop.fs.statistics.DurationTrackerFactory,org.apache.hadoop.fs.statistics.IOStatisticsSource,org.apache.hadoop.metrics2.MetricsSource
@Private
@Evolving
public class S3AInstrumentation
extends Object
implements Closeable, org.apache.hadoop.metrics2.MetricsSource, CountersAndGauges, org.apache.hadoop.fs.statistics.IOStatisticsSource
Instrumentation of S3A.
History
-
HADOOP-13028. Initial implementation.
Derived from the
AzureFileSystemInstrumentation. - Broadly (and directly) used in S3A. The use of direct references causes "problems" in mocking tests.
- HADOOP-16830. IOStatistics. Move to an interface and implementation design for the different inner classes.
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String"s3aFileSystem" Currently all s3a metrics are placed in a single "context".static final String"bucket" The name of a field added to metrics records that indicates the hostname portion of the FS URL.static final String"s3aFileSystemId" The name of a field added to metrics records that uniquely identifies a specific FileSystem instance.static final String"s3a-file-system" The name of the s3a-specific metrics system instance used for s3a metrics. -
Constructor Summary
ConstructorsConstructorDescriptionS3AInstrumentation(URI name) Construct the instrumentation for a filesystem. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddValueToQuantiles(Statistic op, long value) Add a value to a quantiles statistic.voidclose()protected final org.apache.hadoop.metrics2.lib.MutableCounterLongCreate a counter in the registry.protected final org.apache.hadoop.metrics2.lib.MutableCounterLongCreate a counter in the registry.org.apache.hadoop.fs.statistics.impl.IOStatisticsStoreCreate an IOStatistics store which updates FS metrics as well as IOStatistics.voiddecrementGauge(Statistic op, long count) Decrement a specific gauge.voidIndicate that S3A created a directory.voidIndicate that S3A just deleted a directory.Dump all the metrics to a string.protected final voidRegistering a duration adds the success and failure counters.voidNote that an error was ignored.voidfakeDirsDeleted(int count) Indicate that fake directory request was made.voidIndicate that S3A created a file.voidfileDeleted(int count) Indicate that S3A deleted one or more files.voidfilesCopied(int files, long size) Indicate that S3A copied some files within the store.protected final org.apache.hadoop.metrics2.lib.MutableGaugeLongCreate a gauge in the registry.protected final org.apache.hadoop.metrics2.lib.MutableGaugeLongCreate a gauge in the registry.longgetCounterValue(String name) Get the value of a counter.longgetCounterValue(Statistic statistic) Get the value of a counter.org.apache.hadoop.fs.statistics.DurationTrackerFactoryGet the duration tracker factory.org.apache.hadoop.fs.statistics.impl.IOStatisticsStoreGet the instance IO Statistics.voidgetMetrics(org.apache.hadoop.metrics2.MetricsCollector collector, boolean all) if registered with the metrics, return the name of the source.org.apache.hadoop.metrics2.lib.MetricsRegistryGet the metrics registry.voidincrementCounter(Statistic op, long count) Increments a mutable counter and the matching instance IOStatistics counter.voidincrementCounter(Statistic op, AtomicLong count) Increments a mutable counter and the matching instance IOStatistics counter with the value of the atomic long.voidincrementGauge(Statistic op, long count) Increment a specific gauge.org.apache.hadoop.metrics2.lib.MutableGaugeLonglookupGauge(String name) Look up a gauge.org.apache.hadoop.metrics2.lib.MutableMetriclookupMetric(String name) Look up a metric from both the registered set and the lighter weight stream entries.org.apache.hadoop.metrics2.lib.MutableQuantileslookupQuantiles(String name) Look up a quantiles.Create a new instance of the committer statistics.Create a delegation token statistics instance.newInputStreamStatistics(org.apache.hadoop.fs.FileSystem.Statistics filesystemStatistics) Create a stream input statistics instance.newOutputStreamStatistics(org.apache.hadoop.fs.FileSystem.Statistics filesystemStatistics) Create a stream output statistics instance.protected final org.apache.hadoop.metrics2.lib.MutableQuantilesCreate a quantiles in the registry.voidrecordDuration(Statistic op, boolean success, Duration duration) Add the duration as a timed statistic, deriving statistic name from the operation symbol and the outcome.toMap()Copy all the metrics to a map of (name, long-value).toString()String representation.org.apache.hadoop.fs.statistics.DurationTrackertrackDuration(String key, long count) The duration tracker updates the metrics with the count and IOStatistics will full duration information.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.fs.statistics.DurationTrackerFactory
trackDuration
-
Field Details
-
METRICS_SYSTEM_NAME
"s3a-file-system" The name of the s3a-specific metrics system instance used for s3a metrics.- See Also:
-
CONTEXT
"s3aFileSystem" Currently all s3a metrics are placed in a single "context". Distinct contexts may be used in the future.- See Also:
-
METRIC_TAG_FILESYSTEM_ID
"s3aFileSystemId" The name of a field added to metrics records that uniquely identifies a specific FileSystem instance.- See Also:
-
METRIC_TAG_BUCKET
"bucket" The name of a field added to metrics records that indicates the hostname portion of the FS URL.- See Also:
-
-
Constructor Details
-
S3AInstrumentation
Construct the instrumentation for a filesystem.- Parameters:
name- URI of filesystem.
-
-
Method Details
-
counter
Create a counter in the registry.- Parameters:
name- counter namedesc- counter description- Returns:
- a new counter
-
counter
Create a counter in the registry.- Parameters:
op- statistic to count- Returns:
- a new counter
-
duration
Registering a duration adds the success and failure counters.- Parameters:
op- statistic to track
-
gauge
Create a gauge in the registry.- Parameters:
name- name gauge namedesc- description- Returns:
- the gauge
-
gauge
Create a gauge in the registry.- Parameters:
op- statistic to count- Returns:
- the gauge
-
quantiles
protected final org.apache.hadoop.metrics2.lib.MutableQuantiles quantiles(Statistic op, String sampleName, String valueName, int interval) Create a quantiles in the registry.- Parameters:
op- statistic to collectsampleName- sample name of the quantilesvalueName- value name of the quantilesinterval- interval of the quantiles in seconds- Returns:
- the created quantiles metric
-
getRegistry
public org.apache.hadoop.metrics2.lib.MetricsRegistry getRegistry()Get the metrics registry.- Returns:
- the registry
-
dump
Dump all the metrics to a string.- Parameters:
prefix- prefix before every entryseparator- separator between name and valuesuffix- suffixall- get all the metrics even if the values are not changed.- Returns:
- a string dump of the metrics
-
getCounterValue
Get the value of a counter.- Parameters:
statistic- the operation- Returns:
- its value, or 0 if not found.
-
getCounterValue
Get the value of a counter. If the counter is null, return 0.- Parameters:
name- the name of the counter- Returns:
- its value.
-
lookupGauge
Look up a gauge.- Parameters:
name- gauge name- Returns:
- the gauge or null
- Throws:
ClassCastException- if the metric is not a Gauge.
-
lookupQuantiles
Look up a quantiles.- Parameters:
name- quantiles name- Returns:
- the quantiles or null
- Throws:
ClassCastException- if the metric is not a Quantiles.
-
lookupMetric
Look up a metric from both the registered set and the lighter weight stream entries.- Parameters:
name- metric name- Returns:
- the metric or null
-
getIOStatistics
public org.apache.hadoop.fs.statistics.impl.IOStatisticsStore getIOStatistics()Get the instance IO Statistics.- Specified by:
getIOStatisticsin interfaceorg.apache.hadoop.fs.statistics.IOStatisticsSource- Returns:
- statistics.
-
getDurationTrackerFactory
public org.apache.hadoop.fs.statistics.DurationTrackerFactory getDurationTrackerFactory()Get the duration tracker factory.- Returns:
- duration tracking for the instrumentation.
-
trackDuration
The duration tracker updates the metrics with the count and IOStatistics will full duration information.- Specified by:
trackDurationin interfaceorg.apache.hadoop.fs.statistics.DurationTrackerFactory- Parameters:
key- statistic key prefixcount- #of times to increment the matching counter in this operation.- Returns:
- a duration tracker.
-
createMetricsUpdatingStore
public org.apache.hadoop.fs.statistics.impl.IOStatisticsStore createMetricsUpdatingStore()Create an IOStatistics store which updates FS metrics as well as IOStatistics.- Returns:
- instance of the store.
-
toString
String representation. Includes the IOStatistics when logging is at DEBUG. -
fileCreated
public void fileCreated()Indicate that S3A created a file. -
fileDeleted
public void fileDeleted(int count) Indicate that S3A deleted one or more files.- Parameters:
count- number of files.
-
fakeDirsDeleted
public void fakeDirsDeleted(int count) Indicate that fake directory request was made.- Parameters:
count- number of directory entries included in the delete request.
-
directoryCreated
public void directoryCreated()Indicate that S3A created a directory. -
directoryDeleted
public void directoryDeleted()Indicate that S3A just deleted a directory. -
filesCopied
public void filesCopied(int files, long size) Indicate that S3A copied some files within the store.- Parameters:
files- number of filessize- total size in bytes
-
errorIgnored
public void errorIgnored()Note that an error was ignored. -
incrementCounter
Increments a mutable counter and the matching instance IOStatistics counter. No-op if the counter is not defined, or the count == 0.- Specified by:
incrementCounterin interfaceCountersAndGauges- Parameters:
op- operationcount- increment value
-
addValueToQuantiles
Add a value to a quantiles statistic. No-op if the quantile isn't found.- Specified by:
addValueToQuantilesin interfaceCountersAndGauges- Parameters:
op- operation to look up.value- value to add.- Throws:
ClassCastException- if the metric is not a Quantiles.
-
incrementCounter
Increments a mutable counter and the matching instance IOStatistics counter with the value of the atomic long. No-op if the counter is not defined, or the count == 0.- Parameters:
op- operationcount- atomic long containing value
-
incrementGauge
Increment a specific gauge. No-op if not defined.- Specified by:
incrementGaugein interfaceCountersAndGauges- Parameters:
op- operationcount- increment value- Throws:
ClassCastException- if the metric is of the wrong type
-
decrementGauge
Decrement a specific gauge. No-op if not defined.- Specified by:
decrementGaugein interfaceCountersAndGauges- Parameters:
op- operationcount- increment value- Throws:
ClassCastException- if the metric is of the wrong type
-
recordDuration
Add the duration as a timed statistic, deriving statistic name from the operation symbol and the outcome.- Specified by:
recordDurationin interfaceCountersAndGauges- Parameters:
op- operationsuccess- was the operation a success?duration- how long did it take
-
newInputStreamStatistics
public S3AInputStreamStatistics newInputStreamStatistics(@Nullable org.apache.hadoop.fs.FileSystem.Statistics filesystemStatistics) Create a stream input statistics instance.- Parameters:
filesystemStatistics- FS Statistics to update in close().- Returns:
- the new instance
-
newCommitterStatistics
Create a new instance of the committer statistics.- Returns:
- a new committer statistics instance
-
getMetrics
public void getMetrics(org.apache.hadoop.metrics2.MetricsCollector collector, boolean all) - Specified by:
getMetricsin interfaceorg.apache.hadoop.metrics2.MetricsSource
-
getMetricSourceName
if registered with the metrics, return the name of the source.- Returns:
- the name of the metrics, or null if this instance is not bonded.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
newOutputStreamStatistics
public BlockOutputStreamStatistics newOutputStreamStatistics(org.apache.hadoop.fs.FileSystem.Statistics filesystemStatistics) Create a stream output statistics instance.- Parameters:
filesystemStatistics- thread-local FS statistics.- Returns:
- the new instance
-
newDelegationTokenStatistics
Create a delegation token statistics instance.- Returns:
- an instance of delegation token statistics
-
toMap
Copy all the metrics to a map of (name, long-value).- Returns:
- a map of the metrics
-