Package org.elasticsearch.cluster
Class InternalClusterInfoService
- java.lang.Object
-
- org.elasticsearch.cluster.InternalClusterInfoService
-
- All Implemented Interfaces:
ClusterInfoService
,ClusterStateListener
,LocalNodeMasterListener
public class InternalClusterInfoService extends java.lang.Object 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.interval
setting (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 class
InternalClusterInfoService.SubmitReschedulingClusterInfoUpdatedJob
Class used to submitmaybeRefresh()
on theInternalClusterInfoService
threadpool, 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_SETTING
static Setting<TimeValue>
INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING
-
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 void
clusterChanged(ClusterChangedEvent event)
Called when cluster state changes.java.lang.String
executorName()
The name of the executor that the implementation of the callbacks of this lister should be executed on.ClusterInfo
getClusterInfo()
The latest cluster informationvoid
offMaster()
Called when the local node used to be the master, a new master was elected and it's no longer the local node.void
onMaster()
Called when local node is elected to be the masterClusterInfo
refresh()
Refreshes the ClusterInfo in a blocking fashionprotected java.util.concurrent.CountDownLatch
updateIndicesStats(ActionListener<IndicesStatsResponse> listener)
Retrieve the latest indices stats, calling the listener when completeprotected java.util.concurrent.CountDownLatch
updateNodeStats(ActionListener<NodesStatsResponse> listener)
Retrieve the latest nodes stats, calling the listener when complete
-
-
-
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:LocalNodeMasterListener
Called when local node is elected to be the master- Specified by:
onMaster
in interfaceLocalNodeMasterListener
-
offMaster
public void offMaster()
Description copied from interface:LocalNodeMasterListener
Called when the local node used to be the master, a new master was elected and it's no longer the local node.- Specified by:
offMaster
in interfaceLocalNodeMasterListener
-
executorName
public java.lang.String executorName()
Description copied from interface:LocalNodeMasterListener
The 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.GENERIC
orMANAGEMENT
).- Specified by:
executorName
in 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:ClusterStateListener
Called when cluster state changes.- Specified by:
clusterChanged
in interfaceClusterStateListener
-
getClusterInfo
public ClusterInfo getClusterInfo()
Description copied from interface:ClusterInfoService
The latest cluster information- Specified by:
getClusterInfo
in 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
-
-