Package org.apache.hadoop.fs
Class CachingGetSpaceUsed
java.lang.Object
org.apache.hadoop.fs.CachingGetSpaceUsed
- All Implemented Interfaces:
Closeable,AutoCloseable,GetSpaceUsed
- Direct Known Subclasses:
DFCachingGetSpaceUsed,DU,WindowsGetSpaceUsed
@LimitedPrivate({"HDFS","MapReduce"})
@Evolving
public abstract class CachingGetSpaceUsed
extends Object
implements Closeable, GetSpaceUsed
Interface for class that can tell estimate much space
is used in a directory.
The implementor is fee to cache space used. As such there are methods to update the cached value with any known changes.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.fs.GetSpaceUsed
GetSpaceUsed.Builder -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCachingGetSpaceUsed(GetSpaceUsed.Builder builder) This is the constructor used by the builder. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longRandomize the refresh interval timing by this amount, the actual interval will be chosen uniformly betweeninterval-jitterandinterval+jitter.longHow long in between runs of the background refresh.longgetUsed()voidincDfsUsed(long value) Increment the cached value of used space.protected abstract voidrefresh()protected voidsetShouldFirstRefresh(boolean shouldFirstRefresh) Reset that if we need to do the first refresh.protected voidsetUsed(long usedValue) Reset the current used data amount.
-
Field Details
-
used
-
-
Constructor Details
-
CachingGetSpaceUsed
This is the constructor used by the builder. All overriding classes should implement this.- Parameters:
builder- builder.- Throws:
IOException- raised on errors performing I/O.
-
-
Method Details
-
refresh
protected abstract void refresh() -
setShouldFirstRefresh
protected void setShouldFirstRefresh(boolean shouldFirstRefresh) Reset that if we need to do the first refresh.- Parameters:
shouldFirstRefresh- The flag value to set.
-
getUsed
- Specified by:
getUsedin interfaceGetSpaceUsed- Returns:
- an estimate of space used in the directory path.
- Throws:
IOException
-
getDirPath
- Returns:
- The directory path being monitored.
-
incDfsUsed
public void incDfsUsed(long value) Increment the cached value of used space.- Parameters:
value- dfs used value.
-
getRefreshInterval
@VisibleForTesting public long getRefreshInterval()How long in between runs of the background refresh.- Returns:
- refresh interval.
-
getJitter
@VisibleForTesting public long getJitter()Randomize the refresh interval timing by this amount, the actual interval will be chosen uniformly betweeninterval-jitterandinterval+jitter.- Returns:
- between interval-jitter and interval+jitter.
-
setUsed
protected void setUsed(long usedValue) Reset the current used data amount. This should be called when the cached value is re-computed.- Parameters:
usedValue- new value that should be the disk usage.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-