Remove DiscoveryNodes#masterNodes in favour of existing DiscoveryNodes#getMasterNodes
This commit is contained in:
parent
463fbe45c6
commit
4032859e90
|
@ -123,22 +123,13 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
|||
return this.dataNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link Map} of the discovered master nodes arranged by their ids
|
||||
*
|
||||
* @return {@link Map} of the discovered master nodes arranged by their ids
|
||||
*/
|
||||
public ImmutableOpenMap<String, DiscoveryNode> masterNodes() {
|
||||
return this.masterNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link Map} of the discovered master nodes arranged by their ids
|
||||
*
|
||||
* @return {@link Map} of the discovered master nodes arranged by their ids
|
||||
*/
|
||||
public ImmutableOpenMap<String, DiscoveryNode> getMasterNodes() {
|
||||
return masterNodes();
|
||||
return this.masterNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -176,7 +176,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
|
||||
clusterSettings.addSettingsUpdateConsumer(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING, this::handleMinimumMasterNodesChanged, (value) -> {
|
||||
final ClusterState clusterState = clusterService.state();
|
||||
int masterNodes = clusterState.nodes().masterNodes().size();
|
||||
int masterNodes = clusterState.nodes().getMasterNodes().size();
|
||||
if (value > masterNodes) {
|
||||
throw new IllegalArgumentException("cannot set " + ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey() + " to more than the current master nodes count [" + masterNodes + "]");
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ public class PublishClusterStateAction extends AbstractComponent {
|
|||
nodes = clusterChangedEvent.state().nodes();
|
||||
nodesToPublishTo = new HashSet<>(nodes.getSize());
|
||||
DiscoveryNode localNode = nodes.localNode();
|
||||
final int totalMasterNodes = nodes.masterNodes().size();
|
||||
final int totalMasterNodes = nodes.getMasterNodes().size();
|
||||
for (final DiscoveryNode node : nodes) {
|
||||
if (node.equals(localNode) == false) {
|
||||
nodesToPublishTo.add(node);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class Gateway extends AbstractComponent implements ClusterStateListener {
|
|||
}
|
||||
|
||||
public void performStateRecovery(final GatewayStateRecoveredListener listener) throws GatewayException {
|
||||
String[] nodesIds = clusterService.state().nodes().masterNodes().keys().toArray(String.class);
|
||||
String[] nodesIds = clusterService.state().nodes().getMasterNodes().keys().toArray(String.class);
|
||||
logger.trace("performing state recovery from {}", Arrays.toString(nodesIds));
|
||||
TransportNodesListGatewayMetaState.NodesGatewayMetaState nodesState = listGatewayMetaState.list(nodesIds, null).actionGet();
|
||||
|
||||
|
|
|
@ -171,9 +171,9 @@ public class GatewayService extends AbstractLifecycleComponent<GatewayService> i
|
|||
} else if (recoverAfterDataNodes != -1 && nodes.getDataNodes().size() < recoverAfterDataNodes) {
|
||||
logger.debug("not recovering from gateway, nodes_size (data) [{}] < recover_after_data_nodes [{}]",
|
||||
nodes.getDataNodes().size(), recoverAfterDataNodes);
|
||||
} else if (recoverAfterMasterNodes != -1 && nodes.masterNodes().size() < recoverAfterMasterNodes) {
|
||||
} else if (recoverAfterMasterNodes != -1 && nodes.getMasterNodes().size() < recoverAfterMasterNodes) {
|
||||
logger.debug("not recovering from gateway, nodes_size (master) [{}] < recover_after_master_nodes [{}]",
|
||||
nodes.masterNodes().size(), recoverAfterMasterNodes);
|
||||
nodes.getMasterNodes().size(), recoverAfterMasterNodes);
|
||||
} else {
|
||||
boolean enforceRecoverAfterTime;
|
||||
String reason;
|
||||
|
@ -191,9 +191,9 @@ public class GatewayService extends AbstractLifecycleComponent<GatewayService> i
|
|||
} else if (expectedDataNodes != -1 && (nodes.getDataNodes().size() < expectedDataNodes)) { // does not meet the expected...
|
||||
enforceRecoverAfterTime = true;
|
||||
reason = "expecting [" + expectedDataNodes + "] data nodes, but only have [" + nodes.getDataNodes().size() + "]";
|
||||
} else if (expectedMasterNodes != -1 && (nodes.masterNodes().size() < expectedMasterNodes)) { // does not meet the expected...
|
||||
} else if (expectedMasterNodes != -1 && (nodes.getMasterNodes().size() < expectedMasterNodes)) { // does not meet the expected...
|
||||
enforceRecoverAfterTime = true;
|
||||
reason = "expecting [" + expectedMasterNodes + "] master nodes, but only have [" + nodes.masterNodes().size() + "]";
|
||||
reason = "expecting [" + expectedMasterNodes + "] master nodes, but only have [" + nodes.getMasterNodes().size() + "]";
|
||||
}
|
||||
}
|
||||
performStateRecovery(enforceRecoverAfterTime, reason);
|
||||
|
|
|
@ -375,7 +375,7 @@ public class ShardStateActionTests extends ESTestCase {
|
|||
private void setUpMasterRetryVerification(int numberOfRetries, AtomicInteger retries, CountDownLatch latch, LongConsumer retryLoop) {
|
||||
shardStateAction.setOnBeforeWaitForNewMasterAndRetry(() -> {
|
||||
DiscoveryNodes.Builder masterBuilder = DiscoveryNodes.builder(clusterService.state().nodes());
|
||||
masterBuilder.masterNodeId(clusterService.state().nodes().masterNodes().iterator().next().value.getId());
|
||||
masterBuilder.masterNodeId(clusterService.state().nodes().getMasterNodes().iterator().next().value.getId());
|
||||
setState(clusterService, ClusterState.builder(clusterService.state()).nodes(masterBuilder));
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue