org.apache.hadoop.yarn.server.nodemanager.nodelabels

## 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 and Description
    --- | ---
    `static long` | `DISABLE_NODE_DESCRIPTORS_PROVIDER_FETCH_TIMER`
    `protected Lock` | `readLock`
    `protected TimerTask` | `timerTask`
    `protected Lock` | `writeLock`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractNodeDescriptorsProvider(String name)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `cleanUp()` method for subclasses to cleanup.
    `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.
    `Set<T>` | `getDescriptors()` Provides the descriptors.
    `long` | `getIntervalTime()`
    `Timer` | `getScheduler()`
    `protected void` | `serviceInit(org.apache.hadoop.conf.Configuration conf)`
    `protected void` | `serviceStart()`
    `protected void` | `serviceStop()` terminate the timer
    `void` | `setDescriptors(Set<T> descriptorsSet)` Sets a set of descriptors to the provider.
    `void` | `setIntervalTime(long intervalMS)`
    `protected void` | `verifyConfiguredScript(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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DISABLE_NODE_DESCRIPTORS_PROVIDER_FETCH_TIMER

          public static final long DISABLE_NODE_DESCRIPTORS_PROVIDER_FETCH_TIMER

      See Also:
        Constant Field Values

    - #### readLock

          protected Lock readLock

    - #### writeLock

          protected Lock writeLock

    - #### timerTask

          protected TimerTask timerTask

  - ### Constructor Detail

    - #### AbstractNodeDescriptorsProvider

          public AbstractNodeDescriptorsProvider(String name)

  - ### Method Detail

    - #### 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

          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.

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.