Skip shard management code when updating cluster state on client/tribe nodes (#20731)
IndicesClusterStateService and IndicesStore are responsible for synchronizing local shard state based on incoming cluster state updates. On client/tribe nodes, which don't store any such shard/index data/metadata, all of the logic that computes which data is to be deleted, which shards to be initialized etc. can be completely skipped, saving precious CPU cycles.
This commit is contained in:
parent
ff245a72c5
commit
3dcf1d5445
|
@ -148,12 +148,17 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent imple
|
|||
|
||||
@Override
|
||||
protected void doStart() {
|
||||
clusterService.addFirst(this);
|
||||
// Doesn't make sense to manage shards on non-master and non-data nodes
|
||||
if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isMasterNode(settings)) {
|
||||
clusterService.addFirst(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() {
|
||||
clusterService.remove(this);
|
||||
if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isMasterNode(settings)) {
|
||||
clusterService.remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -94,12 +94,17 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe
|
|||
this.threadPool = threadPool;
|
||||
transportService.registerRequestHandler(ACTION_SHARD_EXISTS, ShardActiveRequest::new, ThreadPool.Names.SAME, new ShardActiveRequestHandler());
|
||||
this.deleteShardTimeout = INDICES_STORE_DELETE_SHARD_TIMEOUT.get(settings);
|
||||
clusterService.addLast(this);
|
||||
// Doesn't make sense to delete shards on non-data nodes
|
||||
if (DiscoveryNode.isDataNode(settings)) {
|
||||
clusterService.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
clusterService.remove(this);
|
||||
if (DiscoveryNode.isDataNode(settings)) {
|
||||
clusterService.remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue