Skip to content

Commit 9137ad2

Browse files
committed
Use a more specific constant instead of Integer.MAX_VALUE
1 parent 7c8a540 commit 9137ad2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

server/src/test/java/org/elasticsearch/cluster/coordination/Zen1IT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING;
5252
import static org.elasticsearch.cluster.routing.allocation.decider.FilterAllocationDecider.CLUSTER_ROUTING_EXCLUDE_GROUP_SETTING;
5353
import static org.elasticsearch.node.Node.NODE_NAME_SETTING;
54+
import static org.elasticsearch.test.InternalTestCluster.REMOVED_MINIMUM_MASTER_NODES;
5455
import static org.hamcrest.Matchers.equalTo;
5556
import static org.hamcrest.Matchers.is;
5657

@@ -196,7 +197,7 @@ public Settings onNodeStopped(String nodeName) {
196197
ClusterHealthResponse clusterHealthResponse = clusterHealthRequestBuilder.get();
197198
assertFalse(nodeName, clusterHealthResponse.isTimedOut());
198199
return Coordinator.addZen1Attribute(false, Settings.builder().put(ZEN2_SETTINGS)
199-
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), Integer.MAX_VALUE)).build();
200+
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), REMOVED_MINIMUM_MASTER_NODES)).build();
200201
}
201202
});
202203

@@ -291,7 +292,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
291292
return Coordinator.addZen1Attribute(false, Settings.builder())
292293
.put(ZEN2_SETTINGS)
293294
.putList(INITIAL_MASTER_NODES_SETTING.getKey(), nodeNames)
294-
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), Integer.MAX_VALUE)
295+
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), REMOVED_MINIMUM_MASTER_NODES)
295296
.build();
296297
}
297298
});

test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,8 @@ public synchronized void close() {
835835
}
836836
}
837837

838+
public static final int REMOVED_MINIMUM_MASTER_NODES = Integer.MAX_VALUE;
839+
838840
private final class NodeAndClient implements Closeable {
839841
private MockNode node;
840842
private final Settings originalNodeSettings;
@@ -989,10 +991,10 @@ private void recreateNode(final Settings newSettings, final Runnable onTransport
989991
} else {
990992
if (DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.exists(finalSettings)) {
991993
// simulating an upgrade from Zen1 to Zen2, but there's no way to remove a setting when restarting a node, so
992-
// you have to set it to Integer.MAX_VALUE to indicate its removal:
994+
// you have to set it to REMOVED_MINIMUM_MASTER_NODES (== Integer.MAX_VALUE) to indicate its removal:
993995
assertTrue(USE_ZEN2.exists(finalSettings));
994996
assertTrue(USE_ZEN2.get(finalSettings));
995-
assertThat(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.get(finalSettings), equalTo(Integer.MAX_VALUE));
997+
assertThat(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.get(finalSettings), equalTo(REMOVED_MINIMUM_MASTER_NODES));
996998

997999
final Builder builder = Settings.builder().put(finalSettings);
9981000
builder.remove(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey());

0 commit comments

Comments
 (0)