Module org.elasticsearch.server
Package org.elasticsearch.common.logging
Class NodeAndClusterIdStateListener
java.lang.Object
org.elasticsearch.common.logging.NodeAndClusterIdStateListener
- All Implemented Interfaces:
ClusterStateObserver.Listener
The
NodeAndClusterIdStateListener listens to cluster state changes and ONLY when receives the first update
it sets the clusterUUID and nodeID in log4j pattern converter NodeIdConverter.
Once the first update is received, it will automatically be de-registered from subsequent updates.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidgetAndSetNodeIdAndClusterId(ClusterService clusterService, ThreadContext threadContext) Subscribes for the first cluster state update where nodeId and clusterId is present and sets these values inNodeIdConverter.voidcalled when the cluster service is closedvoidonNewClusterState(ClusterState state) Called when a new state is observed.voidCalled when theClusterStateObservertimes out while waiting for a new matching cluster state if a timeout is used when creating the observer.
-
Method Details
-
getAndSetNodeIdAndClusterId
public static void getAndSetNodeIdAndClusterId(ClusterService clusterService, ThreadContext threadContext) Subscribes for the first cluster state update where nodeId and clusterId is present and sets these values inNodeIdConverter. -
onNewClusterState
Description copied from interface:ClusterStateObserver.ListenerCalled when a new state is observed. Implementations should avoid doing heavy operations on the calling thread and fork to a threadpool if necessary to avoid blocking theClusterApplierService. Note that operations such as sending a new request (e.g. viaClientorTransportService) is cheap enough to be performed without forking.- Specified by:
onNewClusterStatein interfaceClusterStateObserver.Listener
-
onClusterServiceClose
public void onClusterServiceClose()Description copied from interface:ClusterStateObserver.Listenercalled when the cluster service is closed- Specified by:
onClusterServiceClosein interfaceClusterStateObserver.Listener
-
onTimeout
Description copied from interface:ClusterStateObserver.ListenerCalled when theClusterStateObservertimes out while waiting for a new matching cluster state if a timeout is used when creating the observer. Upon timeout,onTimeoutis called on the GENERIC threadpool.- Specified by:
onTimeoutin interfaceClusterStateObserver.Listener
-