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 void
getAndSetNodeIdAndClusterId
(ClusterService clusterService, ThreadContext threadContext) Subscribes for the first cluster state update where nodeId and clusterId is present and sets these values inNodeIdConverter
.void
called when the cluster service is closedvoid
onNewClusterState
(ClusterState state) Called when a new state is observed.void
Called when theClusterStateObserver
times 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.Listener
Called 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. viaClient
orTransportService
) is cheap enough to be performed without forking.- Specified by:
onNewClusterState
in interfaceClusterStateObserver.Listener
-
onClusterServiceClose
public void onClusterServiceClose()Description copied from interface:ClusterStateObserver.Listener
called when the cluster service is closed- Specified by:
onClusterServiceClose
in interfaceClusterStateObserver.Listener
-
onTimeout
Description copied from interface:ClusterStateObserver.Listener
Called when theClusterStateObserver
times out while waiting for a new matching cluster state if a timeout is used when creating the observer. Upon timeout,onTimeout
is called on the GENERIC threadpool.- Specified by:
onTimeout
in interfaceClusterStateObserver.Listener
-