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:
Yannick Welsch 2016-10-04 13:22:25 +02:00 committed by GitHub
parent ff245a72c5
commit 3dcf1d5445
2 changed files with 14 additions and 4 deletions

View File

@ -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

View File

@ -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