|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.elasticsearch.common.component.Lifecycle
@ThreadSafe public class Lifecycle
Lifecycle state. Allows the following transitions:
Also allows to stay in the same state. For example, when calling stop on a component, the following logic can be applied:
public void stop() { if (!lifeccycleState.moveToStopped()) { return; } // continue with stop logic }
Note, closed is only allowed to be called when stopped, so make sure to stop the component first. Here is how the logic can be applied:
public void close() { if (lifecycleState.started()) { stop(); } if (!lifecycleState.moveToClosed()) { return; } // perofrm close logic here }
Nested Class Summary | |
---|---|
static class |
Lifecycle.State
|
Constructor Summary | |
---|---|
Lifecycle()
|
Method Summary | |
---|---|
boolean |
canMoveToClosed()
|
boolean |
canMoveToStarted()
|
boolean |
canMoveToStopped()
|
boolean |
closed()
Returns true if the state is closed. |
boolean |
initialized()
Returns true if the state is initialized. |
boolean |
moveToClosed()
|
boolean |
moveToStarted()
|
boolean |
moveToStopped()
|
boolean |
started()
Returns true if the state is started. |
Lifecycle.State |
state()
|
boolean |
stopped()
Returns true if the state is stopped. |
boolean |
stoppedOrClosed()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Lifecycle()
Method Detail |
---|
public Lifecycle.State state()
public boolean initialized()
public boolean started()
public boolean stopped()
public boolean closed()
public boolean stoppedOrClosed()
public boolean canMoveToStarted() throws ElasticSearchIllegalStateException
ElasticSearchIllegalStateException
public boolean moveToStarted() throws ElasticSearchIllegalStateException
ElasticSearchIllegalStateException
public boolean canMoveToStopped() throws ElasticSearchIllegalStateException
ElasticSearchIllegalStateException
public boolean moveToStopped() throws ElasticSearchIllegalStateException
ElasticSearchIllegalStateException
public boolean canMoveToClosed() throws ElasticSearchIllegalStateException
ElasticSearchIllegalStateException
public boolean moveToClosed() throws ElasticSearchIllegalStateException
ElasticSearchIllegalStateException
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |