Class LocalDirsHandlerService
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service,HealthReporter
public class LocalDirsHandlerService
extends org.apache.hadoop.service.AbstractService
implements HealthReporter
The class which provides functionality of checking the health of the local
directories of a node. This specifically manages nodemanager-local-dirs and
nodemanager-log-dirs by periodically checking their health.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanThe minimum fraction of number of disks needed to be healthy for a node to be considered healthy in terms of disks is configured usingYarnConfiguration.NM_MIN_HEALTHY_DISKS_FRACTION, with a default value ofYarnConfiguration.DEFAULT_NM_MIN_HEALTHY_DISKS_FRACTION.voidvoidvoidIterable<org.apache.hadoop.fs.Path>getAllLocalPathsForRead(String pathStr) getDisksHealthReport(boolean listGoodDirs) Function to generate a report on the state of the disks.Returns output from health check.longlongReturns time stamp when node health check was last run.Function to get the local dirs which should be considered when cleaning up resources.Function to get the local dirs which should be considered for reading existing files on disk.org.apache.hadoop.fs.PathgetLocalPathForRead(String pathStr) org.apache.hadoop.fs.PathgetLocalPathForWrite(String pathStr) org.apache.hadoop.fs.PathgetLocalPathForWrite(String pathStr, long size, boolean checkWrite) Function to get the log dirs which should be considered when cleaning up resources.Function to get the log dirs which should be considered for reading existing files on disk.org.apache.hadoop.fs.PathgetLogPathForWrite(String pathStr, boolean checkWrite) org.apache.hadoop.fs.PathgetLogPathToRead(String pathStr) booleanisGoodLocalDir(String path) booleanisGoodLogDir(String path) booleanGets whether the node is healthy or not.voidvoidprotected voidserviceInit(org.apache.hadoop.conf.Configuration config) Method which initializes the timertask and its interval time.protected voidMethod used to start the disk health monitoring, if enabled.protected voidMethod used to terminate the disk health monitoring service.protected voidstatic String[]validatePaths(String[] paths) Methods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
-
Constructor Details
-
LocalDirsHandlerService
public LocalDirsHandlerService() -
LocalDirsHandlerService
-
-
Method Details
-
serviceInit
Method which initializes the timertask and its interval time.- Overrides:
serviceInitin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStart
Method used to start the disk health monitoring, if enabled.- Overrides:
serviceStartin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStop
Method used to terminate the disk health monitoring service.- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
registerLocalDirsChangeListener
-
registerLogDirsChangeListener
-
deregisterLocalDirsChangeListener
-
deregisterLogDirsChangeListener
-
getLocalDirs
- Returns:
- the good/valid local directories based on disks' health
-
getLogDirs
- Returns:
- the good/valid log directories based on disks' health
-
getDiskFullLocalDirs
- Returns:
- the local directories which have no disk space
-
getDiskFullLogDirs
- Returns:
- the log directories that have no disk space
-
getLocalDirsForRead
Function to get the local dirs which should be considered for reading existing files on disk. Contains the good local dirs and the local dirs that have reached the disk space limit- Returns:
- the local dirs which should be considered for reading
-
getLocalDirsForCleanup
Function to get the local dirs which should be considered when cleaning up resources. Contains the good local dirs and the local dirs that have reached the disk space limit- Returns:
- the local dirs which should be considered for cleaning up
-
getLogDirsForRead
Function to get the log dirs which should be considered for reading existing files on disk. Contains the good log dirs and the log dirs that have reached the disk space limit- Returns:
- the log dirs which should be considered for reading
-
getLogDirsForCleanup
Function to get the log dirs which should be considered when cleaning up resources. Contains the good log dirs and the log dirs that have reached the disk space limit- Returns:
- the log dirs which should be considered for cleaning up
-
getDisksHealthReport
Function to generate a report on the state of the disks.- Parameters:
listGoodDirs- flag to determine whether the report should report the state of good dirs or failed dirs- Returns:
- the health report of nm-local-dirs and nm-log-dirs
-
getHealthReport
Description copied from interface:HealthReporterReturns output from health check. If node is healthy then an empty string is returned.- Specified by:
getHealthReportin interfaceHealthReporter- Returns:
- output from health check
-
areDisksHealthy
public boolean areDisksHealthy()The minimum fraction of number of disks needed to be healthy for a node to be considered healthy in terms of disks is configured usingYarnConfiguration.NM_MIN_HEALTHY_DISKS_FRACTION, with a default value ofYarnConfiguration.DEFAULT_NM_MIN_HEALTHY_DISKS_FRACTION.- Returns:
- false if either (a) more than the allowed percentage of nm-local-dirs failed or (b) more than the allowed percentage of nm-log-dirs failed.
-
isHealthy
public boolean isHealthy()Description copied from interface:HealthReporterGets whether the node is healthy or not.- Specified by:
isHealthyin interfaceHealthReporter- Returns:
- true if node is healthy
-
getLastDisksCheckTime
public long getLastDisksCheckTime() -
getLastHealthReportTime
public long getLastHealthReportTime()Description copied from interface:HealthReporterReturns time stamp when node health check was last run.- Specified by:
getLastHealthReportTimein interfaceHealthReporter- Returns:
- timestamp when node health script was last run
-
isGoodLocalDir
-
isGoodLogDir
-
checkDirs
@VisibleForTesting public void checkDirs() -
getLocalPathForWrite
- Throws:
IOException
-
getLocalPathForWrite
public org.apache.hadoop.fs.Path getLocalPathForWrite(String pathStr, long size, boolean checkWrite) throws IOException - Throws:
IOException
-
getLocalPathForRead
- Throws:
IOException
-
getAllLocalPathsForRead
public Iterable<org.apache.hadoop.fs.Path> getAllLocalPathsForRead(String pathStr) throws IOException - Throws:
IOException
-
getLogPathForWrite
public org.apache.hadoop.fs.Path getLogPathForWrite(String pathStr, boolean checkWrite) throws IOException - Throws:
IOException
-
getLogPathToRead
- Throws:
IOException
-
validatePaths
-
updateMetrics
protected void updateMetrics()
-