@InterfaceAudience.Public @InterfaceStability.Evolving public interface Service extends Closeable
| Modifier and Type | Method and Description | 
|---|---|
| void | close()A version of stop() that is designed to be usable in Java7 closure
 clauses. | 
| Map<String,String> | getBlockers()Get the blockers on a service -remote dependencies
 that are stopping the service from being live. | 
| Configuration | getConfig()Get the configuration of this service. | 
| Throwable | getFailureCause()Get the first exception raised during the service failure. | 
| org.apache.hadoop.service.Service.STATE | getFailureState()Get the state in which the failure in  getFailureCause()occurred. | 
| List<LifecycleEvent> | getLifecycleHistory()Get a snapshot of the lifecycle history; it is a static list | 
| String | getName()Get the name of this service. | 
| org.apache.hadoop.service.Service.STATE | getServiceState()Get the current service state | 
| long | getStartTime()Get the service start time | 
| void | init(Configuration config)Initialize the service. | 
| boolean | isInState(org.apache.hadoop.service.Service.STATE state)Query to see if the service is in a specific state. | 
| void | registerServiceListener(ServiceStateChangeListener listener)Register a listener to the service state change events. | 
| void | start()Start the service. | 
| void | stop()Stop the service. | 
| void | unregisterServiceListener(ServiceStateChangeListener listener)Unregister a previously registered listener of the service state
 change events. | 
| boolean | waitForServiceToStop(long timeout)Block waiting for the service to stop; uses the termination notification
 object to do so. | 
void init(Configuration config)
Service.STATE.NOTINITED to Service.STATE.INITED
 unless the operation failed and an exception was raised, in which case
 stop() MUST be invoked and the service enter the state
 Service.STATE.STOPPED.config - the configuration of the serviceRuntimeException - on any failure during the operationvoid start()
Service.STATE.INITED to Service.STATE.STARTED
 unless the operation failed and an exception was raised, in which case
 stop() MUST be invoked and the service enter the state
 Service.STATE.STOPPED.RuntimeException - on any failure during the operationvoid stop()
Service.STATE.STOPPED state. It SHOULD be a best-effort attempt
 to stop all parts of the service.
 The implementation must be designed to complete regardless of the service
 state, including the initialized/uninitialized state of all its internal
 fields.RuntimeException - on any failure during the stop operationvoid close()
    throws IOException
stop()close in interface AutoCloseableclose in interface CloseableIOException - neverRuntimeException - on any failure during the stop operationvoid registerServiceListener(ServiceStateChangeListener listener)
listener - a new listenervoid unregisterServiceListener(ServiceStateChangeListener listener)
listener - the listener to unregister.String getName()
Configuration getConfig()
org.apache.hadoop.service.Service.STATE getServiceState()
long getStartTime()
boolean isInState(org.apache.hadoop.service.Service.STATE state)
state - the expected stateThrowable getFailureCause()
org.apache.hadoop.service.Service.STATE getFailureState()
getFailureCause() occurred.boolean waitForServiceToStop(long timeout)
timeout - timeout in milliseconds. A value of zero means "forever"List<LifecycleEvent> getLifecycleHistory()
Copyright © 2025 Apache Software Foundation. All rights reserved.