Skip to content

Commit

Permalink
avoid hotspot in a mixed cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhatn committed Jul 28, 2020
1 parent f43fdd1 commit fda3927
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
import java.util.function.Consumer;
import java.util.function.LongConsumer;
import java.util.function.LongSupplier;
import java.util.function.Predicate;
import java.util.function.Supplier;

import static org.elasticsearch.xpack.ccr.CcrLicenseChecker.wrapClient;
Expand Down Expand Up @@ -122,17 +121,14 @@ public void validate(ShardFollowTask params, ClusterState clusterState) {

@Override
public Assignment getAssignment(final ShardFollowTask params, final ClusterState clusterState) {
DiscoveryNode node = selectLeastLoadedNode(
final DiscoveryNode selectedNode = selectLeastLoadedNode(
clusterState,
((Predicate<DiscoveryNode>) DiscoveryNode::isDataNode).and(DiscoveryNode::isRemoteClusterClient)
node -> node.isDataNode() && (node.isRemoteClusterClient() || node.getVersion().before(DiscoveryNode.PLUGGABLE_ROLES_VERSION))
);
if (node == null) {
node = selectLeastLoadedNode(clusterState, n -> n.isDataNode() && n.getVersion().before(DiscoveryNode.PLUGGABLE_ROLES_VERSION));
}
if (node == null) {
if (selectedNode == null) {
return NO_ASSIGNMENT;
} else {
return new Assignment(node.getId(), "node is the least loaded data node and remote cluster client");
return new Assignment(selectedNode.getId(), "node is the least loaded data node and remote cluster client");
}
}

Expand Down

0 comments on commit fda3927

Please sign in to comment.