Skip to content

Commit

Permalink
Use a more specific constant instead of Integer.MAX_VALUE
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveCTurner committed Jan 29, 2019
1 parent 7c8a540 commit 9137ad2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING;
import static org.elasticsearch.cluster.routing.allocation.decider.FilterAllocationDecider.CLUSTER_ROUTING_EXCLUDE_GROUP_SETTING;
import static org.elasticsearch.node.Node.NODE_NAME_SETTING;
import static org.elasticsearch.test.InternalTestCluster.REMOVED_MINIMUM_MASTER_NODES;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

Expand Down Expand Up @@ -196,7 +197,7 @@ public Settings onNodeStopped(String nodeName) {
ClusterHealthResponse clusterHealthResponse = clusterHealthRequestBuilder.get();
assertFalse(nodeName, clusterHealthResponse.isTimedOut());
return Coordinator.addZen1Attribute(false, Settings.builder().put(ZEN2_SETTINGS)
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), Integer.MAX_VALUE)).build();
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), REMOVED_MINIMUM_MASTER_NODES)).build();
}
});

Expand Down Expand Up @@ -291,7 +292,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
return Coordinator.addZen1Attribute(false, Settings.builder())
.put(ZEN2_SETTINGS)
.putList(INITIAL_MASTER_NODES_SETTING.getKey(), nodeNames)
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), Integer.MAX_VALUE)
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), REMOVED_MINIMUM_MASTER_NODES)
.build();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,8 @@ public synchronized void close() {
}
}

public static final int REMOVED_MINIMUM_MASTER_NODES = Integer.MAX_VALUE;

private final class NodeAndClient implements Closeable {
private MockNode node;
private final Settings originalNodeSettings;
Expand Down Expand Up @@ -989,10 +991,10 @@ private void recreateNode(final Settings newSettings, final Runnable onTransport
} else {
if (DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.exists(finalSettings)) {
// simulating an upgrade from Zen1 to Zen2, but there's no way to remove a setting when restarting a node, so
// you have to set it to Integer.MAX_VALUE to indicate its removal:
// you have to set it to REMOVED_MINIMUM_MASTER_NODES (== Integer.MAX_VALUE) to indicate its removal:
assertTrue(USE_ZEN2.exists(finalSettings));
assertTrue(USE_ZEN2.get(finalSettings));
assertThat(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.get(finalSettings), equalTo(Integer.MAX_VALUE));
assertThat(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.get(finalSettings), equalTo(REMOVED_MINIMUM_MASTER_NODES));

final Builder builder = Settings.builder().put(finalSettings);
builder.remove(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey());
Expand Down

0 comments on commit 9137ad2

Please sign in to comment.