Package com.google.cloud.hadoop.fs.gcs
Class GhfsInstrumentation
java.lang.Object
com.google.cloud.hadoop.fs.gcs.GhfsInstrumentation
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.fs.statistics.DurationTrackerFactory,org.apache.hadoop.fs.statistics.IOStatisticsSource,org.apache.hadoop.metrics2.MetricsSource
public class GhfsInstrumentation
extends Object
implements Closeable, org.apache.hadoop.metrics2.MetricsSource, org.apache.hadoop.fs.statistics.IOStatisticsSource, org.apache.hadoop.fs.statistics.DurationTrackerFactory
Instrumentation of GCS.
Counters and metrics are generally addressed in code by their name or GhfsStatistic
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.
GoogleHadoopFileSystem StorageStatistics are dynamically derived from the IOStatistics.
-
Constructor Summary
ConstructorsConstructorDescriptionGhfsInstrumentation(URI name) Construct the instrumentation for a filesystem. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected final org.apache.hadoop.metrics2.lib.MutableCounterLongcounter(GhfsStatistic op) Create a counter in the registry for metrics in GhfsStatistic.protected final org.apache.hadoop.metrics2.lib.MutableCounterLongCreate a counter in the registry.protected final voidRegistering a duration adds the success and failure counters.protected final org.apache.hadoop.metrics2.lib.MutableGaugeLonggauge(GhfsStatistic op) Create a gauge in the registry.protected final org.apache.hadoop.metrics2.lib.MutableGaugeLongCreate a gauge in the registry.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 metricsCollector, boolean b) org.apache.hadoop.metrics2.MetricsSystemGet the metrics system.org.apache.hadoop.metrics2.lib.MetricsRegistryGet the metrics registry.voidincrementCounter(GhfsStatistic op, long count) Increments a mutable counter and the matching instance IOStatistics counter.org.apache.hadoop.metrics2.lib.MutableMetriclookupMetric(String name) Look up a metric from both the registered set and the lighter weight stream entries.Create a delegation token statistics instance.com.google.cloud.hadoop.fs.gcs.GhfsInputStreamStatisticsnewInputStreamStatistics(org.apache.hadoop.fs.FileSystem.Statistics filesystemStatistics) Create a stream input statistics instance.com.google.cloud.hadoop.fs.gcs.GhfsOutputStreamStatisticsnewOutputStreamStatistics(org.apache.hadoop.fs.FileSystem.Statistics filesystemStatistics) Create a stream output statistics instance.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, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.fs.statistics.DurationTrackerFactory
trackDuration
-
Constructor Details
-
GhfsInstrumentation
Construct the instrumentation for a filesystem.- Parameters:
name- URI of filesystem.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
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.
-
incrementCounter
Increments a mutable counter and the matching instance IOStatistics counter. No-op if the counter is not defined, or the count == 0.- Parameters:
op- operationcount- increment value
-
getMetricsSystem
public org.apache.hadoop.metrics2.MetricsSystem getMetricsSystem()Get the metrics system.- Returns:
- metricsSystem
-
counter
Create a counter in the registry.- Parameters:
name- counter namedesc- counter description- Returns:
- a new counter
-
counter
Create a counter in the registry for metrics in GhfsStatistic.- 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
-
getRegistry
public org.apache.hadoop.metrics2.lib.MetricsRegistry getRegistry()Get the metrics registry.- Returns:
- the registry
-
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
-
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.
-
getMetrics
public void getMetrics(org.apache.hadoop.metrics2.MetricsCollector metricsCollector, boolean b) - Specified by:
getMetricsin interfaceorg.apache.hadoop.metrics2.MetricsSource
-
newInputStreamStatistics
public com.google.cloud.hadoop.fs.gcs.GhfsInputStreamStatistics 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
-
newOutputStreamStatistics
public com.google.cloud.hadoop.fs.gcs.GhfsOutputStreamStatistics 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
-