Package org.apache.hadoop.fs.impl
Class WeakRefMetricsSource
java.lang.Object
org.apache.hadoop.fs.impl.WeakRefMetricsSource
- All Implemented Interfaces:
MetricsSource
A weak referenced metrics source which avoids hanging on to large objects
if somehow they don't get fully closed/cleaned up.
The JVM may clean up all objects which are only weakly referenced whenever
it does a GC, even if there is no memory pressure.
To avoid these refs being removed, always keep a strong reference around
somewhere.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgetMetrics(MetricsCollector collector, boolean all) If the weak reference is non null, update the metrics.getName()Name to know when unregistering.Get the source, will be null if the reference has been GC'dtoString()
-
Constructor Details
-
WeakRefMetricsSource
Constructor.- Parameters:
name- Name to know when unregistering.source- metrics source
-
-
Method Details
-
getMetrics
If the weak reference is non null, update the metrics.- Specified by:
getMetricsin interfaceMetricsSource- Parameters:
collector- to contain the resulting metrics snapshotall- if true, return all metrics even if unchanged.
-
getName
Name to know when unregistering.- Returns:
- the name passed in during construction.
-
getSource
Get the source, will be null if the reference has been GC'd- Returns:
- the source reference
-
toString
-