Package org.apache.hadoop.lib.server
Class BaseService
java.lang.Object
org.apache.hadoop.lib.server.BaseService
- All Implemented Interfaces:
Service
- Direct Known Subclasses:
FileSystemAccessService,GroupsService,InstrumentationService,SchedulerService
Convenience class implementing the
Service interface.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroy the services.protected StringReturns the service prefix.protected StringgetPrefixedName(String name) Returns the full prefixed name of a service property.protected ServerReturns the server owning the service.protected org.apache.hadoop.conf.ConfigurationReturns the service configuration properties.Class[]Returns the service dependencies of this service.protected abstract voidinit()Initializes the server.final voidInitializes the service.voidpostInit()Post initializes the service.voidserverStatusChange(Server.Status oldStatus, Server.Status newStatus) Notification callback when the server changes its status.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.lib.server.Service
getInterface
-
Constructor Details
-
BaseService
Service constructor.- Parameters:
prefix- service prefix.
-
-
Method Details
-
init
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:
initin interfaceService- Parameters:
server- the server initializing the service, give access to the server context.- Throws:
ServiceException- thrown if the service could not be initialized.
-
postInit
Post initializes the service. This method is called by theServerafter all services of the server have been initialized.This method does a NOP.
- Specified by:
postInitin interfaceService- Throws:
ServiceException- thrown if the service could not be post-initialized.
-
destroy
public void destroy()Destroy the services. This method is called once, when theServerowning the service is being destroyed.This method does a NOP.
-
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:
getServiceDependenciesin interfaceService- 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:
serverStatusChangein interfaceService- Parameters:
oldStatus- old server status.newStatus- new server status.- Throws:
ServiceException- thrown if the service could not process the status change.
-
getPrefix
Returns the service prefix.- Returns:
- the service prefix.
-
getServer
Returns the server owning the service.- Returns:
- the server owning the service.
-
getPrefixedName
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
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.
-