Class BaseService

java.lang.Object
org.apache.hadoop.lib.server.BaseService
All Implemented Interfaces:
Service
Direct Known Subclasses:
FileSystemAccessService, GroupsService, InstrumentationService, SchedulerService

@Private public abstract class BaseService extends Object implements Service
Convenience class implementing the Service interface.
  • Constructor Details

    • BaseService

      public BaseService(String prefix)
      Service constructor.
      Parameters:
      prefix - service prefix.
  • Method Details

    • init

      public final void init(Server server) throws ServiceException
      Initializes the service.

      It collects all service properties (properties having the #SERVER#.#SERVICE#. prefix). The property names are then trimmed from the #SERVER#.#SERVICE#. prefix.

      After collecting the service properties it delegates to the init() method.

      Specified by:
      init in interface Service
      Parameters:
      server - the server initializing the service, give access to the server context.
      Throws:
      ServiceException - thrown if the service could not be initialized.
    • postInit

      public void postInit() throws ServiceException
      Post initializes the service. This method is called by the Server after all services of the server have been initialized.

      This method does a NOP.

      Specified by:
      postInit in interface Service
      Throws:
      ServiceException - thrown if the service could not be post-initialized.
    • destroy

      public void destroy()
      Destroy the services. This method is called once, when the Server owning the service is being destroyed.

      This method does a NOP.

      Specified by:
      destroy in interface Service
    • getServiceDependencies

      public Class[] getServiceDependencies()
      Returns the service dependencies of this service. The service will be instantiated only if all the service dependencies are already initialized.

      This method returns an empty array (size 0)

      Specified by:
      getServiceDependencies in interface Service
      Returns:
      an empty array (size 0).
    • serverStatusChange

      public void serverStatusChange(Server.Status oldStatus, Server.Status newStatus) throws ServiceException
      Notification callback when the server changes its status.

      This method returns an empty array (size 0)

      Specified by:
      serverStatusChange in interface Service
      Parameters:
      oldStatus - old server status.
      newStatus - new server status.
      Throws:
      ServiceException - thrown if the service could not process the status change.
    • getPrefix

      protected String getPrefix()
      Returns the service prefix.
      Returns:
      the service prefix.
    • getServer

      protected Server getServer()
      Returns the server owning the service.
      Returns:
      the server owning the service.
    • getPrefixedName

      protected String getPrefixedName(String name)
      Returns the full prefixed name of a service property.
      Parameters:
      name - of the property.
      Returns:
      prefixed name of the property.
    • getServiceConfig

      protected org.apache.hadoop.conf.Configuration getServiceConfig()
      Returns the service configuration properties. Property names are trimmed off from its prefix.

      The sevice configuration properties are all properties with names starting with #SERVER#.#SERVICE#. in the server configuration.

      Returns:
      the service configuration properties with names trimmed off from their #SERVER#.#SERVICE#. prefix.
    • init

      protected abstract void init() throws ServiceException
      Initializes the server.

      This method is called by init(Server) after all service properties (properties prefixed with

      Throws:
      ServiceException - thrown if the service could not be initialized.