diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java index 70f71a63cf0..c49a5f2fc40 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -123,22 +123,13 @@ public class DiscoveryNodes extends AbstractDiffable 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 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 getMasterNodes() { - return masterNodes(); + return this.masterNodes; } /** diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java index a4c06536fa9..ce18f3473a1 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -176,7 +176,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent 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 + "]"); } diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java b/core/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java index 00cebac1435..87ed92d7a41 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java @@ -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); diff --git a/core/src/main/java/org/elasticsearch/gateway/Gateway.java b/core/src/main/java/org/elasticsearch/gateway/Gateway.java index b2cb2d11079..4da789b43fc 100644 --- a/core/src/main/java/org/elasticsearch/gateway/Gateway.java +++ b/core/src/main/java/org/elasticsearch/gateway/Gateway.java @@ -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(); diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayService.java b/core/src/main/java/org/elasticsearch/gateway/GatewayService.java index 288deac432e..d30dec998bb 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayService.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayService.java @@ -171,9 +171,9 @@ public class GatewayService extends AbstractLifecycleComponent 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 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); diff --git a/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java b/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java index a4afd30f788..0915ede3eea 100644 --- a/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java @@ -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)); });