@InterfaceAudience.Public @InterfaceStability.Stable public interface LifecycleAware
An interface implemented by any class that has a defined, stateful, lifecycle.
Implementations of LifecycleAware
conform to a standard method of
starting, stopping, and reporting their current state. Additionally, this
interface creates a standard method of communicating failure to perform a
lifecycle operation to the caller (i.e. via LifecycleException
). It
is never considered valid to call start()
or
stop()
more than once or to call them in the wrong order.
While this is not strictly enforced, it may be in the future.
Example services may include Flume nodes and the master, but also lower level components that can be controlled in a similar manner.
Example usage
public class MyService implements LifecycleAware { private LifecycleState lifecycleState; public MyService() { lifecycleState = LifecycleState.IDLE; }
Modifier and Type | Method and Description |
---|---|
LifecycleState |
getLifecycleState()
Return the current state of the service or component.
|
void |
start()
Starts a service or component.
|
void |
stop()
Stops a service or component.
|
void start()
Starts a service or component.
Implementations should determine the result of any start logic and effect
the return value of getLifecycleState()
accordingly.
void stop()
Stops a service or component.
Implementations should determine the result of any stop logic and effect
the return value of getLifecycleState()
accordingly.
LifecycleState getLifecycleState()
Return the current state of the service or component.
Copyright © 2009–2019 Apache Software Foundation. All rights reserved.