Package org.elasticsearch.cluster
Class InternalClusterInfoService
- java.lang.Object
-
- org.elasticsearch.common.component.AbstractComponent
-
- org.elasticsearch.cluster.InternalClusterInfoService
-
- All Implemented Interfaces:
ClusterInfoService,ClusterStateListener,LocalNodeMasterListener
public class InternalClusterInfoService extends AbstractComponent implements ClusterInfoService, LocalNodeMasterListener, ClusterStateListener
InternalClusterInfoService provides the ClusterInfoService interface, routinely updated on a timer. The timer can be dynamically changed by setting thecluster.info.update.intervalsetting (defaulting to 30 seconds). The InternalClusterInfoService only runs on the master node. Listens for changes in the number of data nodes and immediately submits a ClusterInfoUpdateJob if a node has been added. Every time the timer runs, gathers information about the disk usage and shard sizes across the cluster.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classInternalClusterInfoService.SubmitReschedulingClusterInfoUpdatedJobClass used to submitmaybeRefresh()on theInternalClusterInfoServicethreadpool, these jobs will reschedule themselves by placing a new instance of this class onto the scheduled threadpool.
-
Field Summary
Fields Modifier and Type Field Description static Setting<TimeValue>INTERNAL_CLUSTER_INFO_TIMEOUT_SETTINGstatic Setting<TimeValue>INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING-
Fields inherited from class org.elasticsearch.common.component.AbstractComponent
deprecationLogger, logger, settings
-
-
Constructor Summary
Constructors Constructor Description InternalClusterInfoService(Settings settings, ClusterService clusterService, ThreadPool threadPool, NodeClient client, java.util.function.Consumer<ClusterInfo> listener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclusterChanged(ClusterChangedEvent event)Called when cluster state changes.java.lang.StringexecutorName()The name of the executor that the implementation of the callbacks of this lister should be executed on.ClusterInfogetClusterInfo()The latest cluster informationvoidoffMaster()Called when the local node used to be the master, a new master was elected and it's no longer the local node.voidonMaster()Called when local node is elected to be the masterClusterInforefresh()Refreshes the ClusterInfo in a blocking fashionprotected java.util.concurrent.CountDownLatchupdateIndicesStats(ActionListener<IndicesStatsResponse> listener)Retrieve the latest indices stats, calling the listener when completeprotected java.util.concurrent.CountDownLatchupdateNodeStats(ActionListener<NodesStatsResponse> listener)Retrieve the latest nodes stats, calling the listener when complete-
Methods inherited from class org.elasticsearch.common.component.AbstractComponent
nodeName
-
-
-
-
Constructor Detail
-
InternalClusterInfoService
public InternalClusterInfoService(Settings settings, ClusterService clusterService, ThreadPool threadPool, NodeClient client, java.util.function.Consumer<ClusterInfo> listener)
-
-
Method Detail
-
onMaster
public void onMaster()
Description copied from interface:LocalNodeMasterListenerCalled when local node is elected to be the master- Specified by:
onMasterin interfaceLocalNodeMasterListener
-
offMaster
public void offMaster()
Description copied from interface:LocalNodeMasterListenerCalled when the local node used to be the master, a new master was elected and it's no longer the local node.- Specified by:
offMasterin interfaceLocalNodeMasterListener
-
executorName
public java.lang.String executorName()
Description copied from interface:LocalNodeMasterListenerThe name of the executor that the implementation of the callbacks of this lister should be executed on. The thread that is responsible for managing instances of this lister is the same thread handling the cluster state events. If the work done is the callbacks above is inexpensive, this value may beSAME(indicating that the callbacks will run on the same thread as the cluster state events are fired with). On the other hand, if the logic in the callbacks are heavier and take longer to process (or perhaps involve blocking due to IO operations), prefer to execute them on a separate more appropriate executor (eg.GENERICorMANAGEMENT).- Specified by:
executorNamein interfaceLocalNodeMasterListener- Returns:
- The name of the executor that will run the callbacks of this listener.
-
clusterChanged
public void clusterChanged(ClusterChangedEvent event)
Description copied from interface:ClusterStateListenerCalled when cluster state changes.- Specified by:
clusterChangedin interfaceClusterStateListener
-
getClusterInfo
public ClusterInfo getClusterInfo()
Description copied from interface:ClusterInfoServiceThe latest cluster information- Specified by:
getClusterInfoin interfaceClusterInfoService
-
updateNodeStats
protected java.util.concurrent.CountDownLatch updateNodeStats(ActionListener<NodesStatsResponse> listener)
Retrieve the latest nodes stats, calling the listener when complete- Returns:
- a latch that can be used to wait for the nodes stats to complete if desired
-
updateIndicesStats
protected java.util.concurrent.CountDownLatch updateIndicesStats(ActionListener<IndicesStatsResponse> listener)
Retrieve the latest indices stats, calling the listener when complete- Returns:
- a latch that can be used to wait for the indices stats to complete if desired
-
refresh
public final ClusterInfo refresh()
Refreshes the ClusterInfo in a blocking fashion
-
-