Class AbstractNodeDescriptorsProvider<T>
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.server.nodemanager.nodelabels.AbstractNodeDescriptorsProvider<T>
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service,NodeDescriptorsProvider<T>
- Direct Known Subclasses:
NodeAttributesProvider,NodeLabelsProvider
public abstract class AbstractNodeDescriptorsProvider<T>
extends org.apache.hadoop.service.AbstractService
implements NodeDescriptorsProvider<T>
Provides base implementation of NodeDescriptorsProvider with Timer and
expects subclass to provide TimerTask which can fetch node descriptors.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidcleanUp()method for subclasses to cleanup.abstract TimerTaskCreates a timer task which be scheduled periodically by the provider, and the task is responsible to update node descriptors to the provider.Provides the descriptors.longprotected voidserviceInit(org.apache.hadoop.conf.Configuration conf) protected voidprotected voidterminate the timervoidsetDescriptors(Set<T> descriptorsSet) Sets a set of descriptors to the provider.voidsetIntervalTime(long intervalMS) protected voidverifyConfiguredScript(String scriptPath) Method used to determine if or not node descriptors fetching script is configured and whether it is fit to run.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
-
Field Details
-
DISABLE_NODE_DESCRIPTORS_PROVIDER_FETCH_TIMER
public static final long DISABLE_NODE_DESCRIPTORS_PROVIDER_FETCH_TIMER- See Also:
-
readLock
-
writeLock
-
timerTask
-
-
Constructor Details
-
AbstractNodeDescriptorsProvider
-
-
Method Details
-
getIntervalTime
public long getIntervalTime() -
setIntervalTime
public void setIntervalTime(long intervalMS) -
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStart
- Overrides:
serviceStartin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStop
terminate the timer- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
cleanUp
method for subclasses to cleanup.- Throws:
Exception
-
getDescriptors
Description copied from interface:NodeDescriptorsProviderProvides the descriptors. The provider is expected to give same descriptors continuously until there is a change. If null is returned then an empty set is assumed by the caller.- Specified by:
getDescriptorsin interfaceNodeDescriptorsProvider<T>- Returns:
- Returns output from provider.
-
setDescriptors
Description copied from interface:NodeDescriptorsProviderSets a set of descriptors to the provider.- Specified by:
setDescriptorsin interfaceNodeDescriptorsProvider<T>- Parameters:
descriptorsSet- node descriptors.
-
verifyConfiguredScript
Method used to determine if or not node descriptors fetching script is configured and whether it is fit to run. Returns true if following conditions are met:- Path to the script is not empty
- The script file exists
- Throws:
IOException
-
getScheduler
-
createTimerTask
Creates a timer task which be scheduled periodically by the provider, and the task is responsible to update node descriptors to the provider.- Returns:
- a timer task.
-