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
    Modifier and Type
    Field
    Description
    static final long
     
    protected Lock
     
    protected TimerTask
     
    protected Lock
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    method for subclasses to cleanup.
    abstract TimerTask
    Creates 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.
    long
     
     
    protected void
    serviceInit(org.apache.hadoop.conf.Configuration conf)
     
    protected void
     
    protected void
    terminate the timer
    void
    setDescriptors(Set<T> descriptorsSet)
    Sets a set of descriptors to the provider.
    void
    setIntervalTime(long intervalMS)
     
    protected void
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • DISABLE_NODE_DESCRIPTORS_PROVIDER_FETCH_TIMER

      public static final long DISABLE_NODE_DESCRIPTORS_PROVIDER_FETCH_TIMER
      See Also:
    • readLock

      protected Lock readLock
    • writeLock

      protected Lock writeLock
    • timerTask

      protected TimerTask timerTask
  • Constructor Details

    • AbstractNodeDescriptorsProvider

      public AbstractNodeDescriptorsProvider(String name)
  • Method Details

    • getIntervalTime

      public long getIntervalTime()
    • setIntervalTime

      public void setIntervalTime(long intervalMS)
    • serviceInit

      protected void serviceInit(org.apache.hadoop.conf.Configuration conf) throws Exception
      Overrides:
      serviceInit in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • serviceStart

      protected void serviceStart() throws Exception
      Overrides:
      serviceStart in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • serviceStop

      protected void serviceStop() throws Exception
      terminate the timer
      Overrides:
      serviceStop in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • cleanUp

      protected abstract void cleanUp() throws Exception
      method for subclasses to cleanup.
      Throws:
      Exception
    • getDescriptors

      public Set<T> getDescriptors()
      Description copied from interface: NodeDescriptorsProvider
      Provides 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:
      getDescriptors in interface NodeDescriptorsProvider<T>
      Returns:
      Returns output from provider.
    • setDescriptors

      public void setDescriptors(Set<T> descriptorsSet)
      Description copied from interface: NodeDescriptorsProvider
      Sets a set of descriptors to the provider.
      Specified by:
      setDescriptors in interface NodeDescriptorsProvider<T>
      Parameters:
      descriptorsSet - node descriptors.
    • verifyConfiguredScript

      protected void verifyConfiguredScript(String scriptPath) throws IOException
      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:
      1. Path to the script is not empty
      2. The script file exists
      Throws:
      IOException
    • getScheduler

      @VisibleForTesting public Timer getScheduler()
    • createTimerTask

      public abstract TimerTask 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.