java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.server.nodemanager.containermanager.AuxServices
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.service.Service, org.apache.hadoop.service.ServiceStateChangeListener, org.apache.hadoop.yarn.event.EventHandler<AuxServicesEvent>

public class AuxServices extends org.apache.hadoop.service.AbstractService implements org.apache.hadoop.service.ServiceStateChangeListener, org.apache.hadoop.yarn.event.EventHandler<AuxServicesEvent>
  • Field Details

  • Method Details

    • isManifestEnabled

      public boolean isManifestEnabled()
      Returns whether aux services manifest / dynamic loading is enabled.
    • addService

      protected final void addService(String name, org.apache.hadoop.yarn.server.api.AuxiliaryService service, AuxServiceRecord serviceRecord)
      Adds a service to the service map.
      Parameters:
      name - aux service name
      service - aux service
      serviceRecord - aux service record
    • getServiceRecords

      public Collection<AuxServiceRecord> getServiceRecords()
      Gets current aux service records.
      Returns:
      a collection of service records
    • getMetaData

      public Map<String,ByteBuffer> getMetaData()
      Returns:
      the meta data for all registered services, that have been started. If a service has not been started no metadata will be available. The key is the name of the service as defined in the configuration.
    • maybeDownloadJars

      @VisibleForTesting protected org.apache.hadoop.fs.Path maybeDownloadJars(String sName, String className, String remoteFile, AuxServiceFile.TypeEnum type, org.apache.hadoop.conf.Configuration conf) throws IOException
      Copies the specified remote file to local NM aux service directory. If the same file already exists (as determined by modification time), the file will not be copied again.
      Parameters:
      sName - service name
      className - service class name
      remoteFile - location of the file to download
      type - type of file (STATIC for a jar or ARCHIVE for a tarball)
      conf - configuration
      Returns:
      path of the downloaded file
      Throws:
      IOException
    • reloadManifest

      @VisibleForTesting protected void reloadManifest() throws IOException
      Reloads auxiliary services manifest. Must be called after service init.
      Throws:
      IOException - if manifest can't be loaded
    • reload

      public void reload(AuxServiceRecords services) throws IOException
      Reloads auxiliary services. Must be called after service init.
      Parameters:
      services - a list of auxiliary services
      Throws:
      IOException - if aux services have not been started yet or dynamic reloading is not enabled
    • loadManifest

      @VisibleForTesting protected void loadManifest(org.apache.hadoop.conf.Configuration conf, boolean startServices) throws IOException
      Updates current aux services based on changes found in the manifest.
      Parameters:
      conf - configuration
      startServices - if true starts services, otherwise only inits services
      Throws:
      IOException
    • serviceInit

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

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

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

      public void stateChanged(org.apache.hadoop.service.Service service)
      Specified by:
      stateChanged in interface org.apache.hadoop.service.ServiceStateChangeListener
    • handle

      public void handle(AuxServicesEvent event)
      Specified by:
      handle in interface org.apache.hadoop.yarn.event.EventHandler<AuxServicesEvent>
    • newAuxService

      protected static AuxServiceRecord newAuxService(String name, String className)
    • setClasspath

      protected static void setClasspath(AuxServiceRecord service, String classpath)
    • setSystemClasses

      protected static void setSystemClasses(AuxServiceRecord service, String systemClasses)
    • getManifestFS

      protected org.apache.hadoop.fs.FileSystem getManifestFS()