Skip to content

Commit fda3927

Browse files
committed
avoid hotspot in a mixed cluster
1 parent f43fdd1 commit fda3927

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
import java.util.function.Consumer;
7979
import java.util.function.LongConsumer;
8080
import java.util.function.LongSupplier;
81-
import java.util.function.Predicate;
8281
import java.util.function.Supplier;
8382

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

123122
@Override
124123
public Assignment getAssignment(final ShardFollowTask params, final ClusterState clusterState) {
125-
DiscoveryNode node = selectLeastLoadedNode(
124+
final DiscoveryNode selectedNode = selectLeastLoadedNode(
126125
clusterState,
127-
((Predicate<DiscoveryNode>) DiscoveryNode::isDataNode).and(DiscoveryNode::isRemoteClusterClient)
126+
node -> node.isDataNode() && (node.isRemoteClusterClient() || node.getVersion().before(DiscoveryNode.PLUGGABLE_ROLES_VERSION))
128127
);
129-
if (node == null) {
130-
node = selectLeastLoadedNode(clusterState, n -> n.isDataNode() && n.getVersion().before(DiscoveryNode.PLUGGABLE_ROLES_VERSION));
131-
}
132-
if (node == null) {
128+
if (selectedNode == null) {
133129
return NO_ASSIGNMENT;
134130
} else {
135-
return new Assignment(node.getId(), "node is the least loaded data node and remote cluster client");
131+
return new Assignment(selectedNode.getId(), "node is the least loaded data node and remote cluster client");
136132
}
137133
}
138134

0 commit comments

Comments
 (0)