From 9889f10e5ee01572d7593ace9676403a4cebe97b Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 14:42:15 +0200 Subject: [PATCH 01/25] Remove DiscoveryNode#id in favour of existing DiscoveryNode#getId --- .../cluster/node/info/NodesInfoResponse.java | 2 +- .../node/stats/NodesStatsResponse.java | 2 +- .../verify/VerifyRepositoryResponse.java | 2 +- .../status/TransportNodesSnapshotsStatus.java | 2 +- .../TransportIndicesShardStoresAction.java | 2 +- .../search/AbstractSearchAsyncAction.java | 2 +- .../node/TransportBroadcastByNodeAction.java | 6 ++-- .../support/nodes/BaseNodesResponse.java | 2 +- .../support/nodes/TransportNodesAction.java | 4 +-- .../TransportReplicationAction.java | 2 +- .../support/tasks/TransportTasksAction.java | 8 +++--- .../TransportClientNodesService.java | 2 +- .../cluster/InternalClusterInfoService.java | 2 +- .../cluster/node/DiscoveryNode.java | 11 ++------ .../cluster/node/DiscoveryNodeFilters.java | 2 +- .../cluster/node/DiscoveryNodes.java | 28 +++++++++---------- .../cluster/routing/RoutingNodes.java | 4 +-- ...AllocateEmptyPrimaryAllocationCommand.java | 2 +- .../AllocateReplicaAllocationCommand.java | 3 +- ...AllocateStalePrimaryAllocationCommand.java | 3 +- .../command/CancelAllocationCommand.java | 2 +- .../command/MoveAllocationCommand.java | 4 +-- .../cluster/service/ClusterService.java | 2 +- .../discovery/local/LocalDiscovery.java | 12 ++++---- .../discovery/zen/NodeJoinController.java | 6 ++-- .../discovery/zen/ZenDiscovery.java | 12 ++++---- .../zen/elect/ElectMasterService.java | 2 +- .../zen/fd/MasterFaultDetection.java | 2 +- .../discovery/zen/fd/NodesFaultDetection.java | 8 +++--- .../zen/ping/unicast/UnicastZenPing.java | 6 ++-- .../publish/PublishClusterStateAction.java | 4 +-- .../gateway/PrimaryShardAllocator.java | 10 +++---- .../gateway/ReplicaShardAllocator.java | 6 ++-- .../indices/flush/SyncedFlushService.java | 2 +- .../indices/recovery/RecoverySource.java | 2 +- .../indices/recovery/RecoveryState.java | 4 +-- .../indices/store/IndicesStore.java | 2 +- .../VerifyNodeRepositoryAction.java | 4 +-- .../rest/action/cat/RestAllocationAction.java | 2 +- .../rest/action/cat/RestFielddataAction.java | 2 +- .../rest/action/cat/RestNodeAttrsAction.java | 4 +-- .../rest/action/cat/RestNodesAction.java | 8 +++--- .../rest/action/cat/RestPluginsAction.java | 4 +-- .../rest/action/cat/RestThreadPoolAction.java | 6 ++-- .../elasticsearch/search/SearchService.java | 2 +- .../snapshots/SnapshotShardsService.java | 2 +- .../transport/netty/NettyTransport.java | 6 ++-- .../org/elasticsearch/tribe/TribeService.java | 8 +++--- .../IndicesShardStoreResponseTests.java | 2 +- .../TransportBroadcastByNodeActionTests.java | 14 +++++----- .../nodes/TransportNodesActionTests.java | 4 +-- .../ClusterStateCreationUtils.java | 26 ++++++++--------- .../TransportReplicationActionTests.java | 2 +- .../client/transport/TransportClientIT.java | 2 +- .../cluster/ClusterStateDiffIT.java | 2 +- .../cluster/ClusterStateTests.java | 6 ++-- .../ack/AckClusterUpdateSettingsIT.java | 6 ++-- .../action/shard/ShardStateActionTests.java | 2 +- .../cluster/allocation/ClusterRerouteIT.java | 22 +++++++-------- .../cluster/node/DiscoveryNodesTests.java | 14 +++++----- .../allocation/AddIncrementallyTests.java | 2 +- .../NodeVersionAllocationDeciderTests.java | 8 +++--- .../discovery/ZenFaultDetectionTests.java | 8 +++--- .../zen/ElectMasterServiceTests.java | 4 +-- .../zen/NodeJoinControllerTests.java | 4 +-- .../discovery/zen/ZenPingTests.java | 2 +- .../zen/ping/unicast/UnicastZenPingIT.java | 4 +-- .../PublishClusterStateActionTests.java | 18 ++++++------ .../gateway/PrimaryShardAllocatorTests.java | 16 +++++------ .../gateway/ReplicaShardAllocatorTests.java | 14 +++++----- .../indices/recovery/IndexRecoveryIT.java | 2 +- .../store/IndicesStoreIntegrationIT.java | 4 +-- .../indices/store/IndicesStoreTests.java | 8 +++--- .../test/transport/CapturingTransport.java | 4 +-- 74 files changed, 207 insertions(+), 218 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java index 000ab3c8385..c22dc616421 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java @@ -68,7 +68,7 @@ public class NodesInfoResponse extends BaseNodesResponse implements To builder.startObject("nodes"); for (NodeInfo nodeInfo : this) { - builder.startObject(nodeInfo.getNode().id(), XContentBuilder.FieldCaseConversion.NONE); + builder.startObject(nodeInfo.getNode().getId(), XContentBuilder.FieldCaseConversion.NONE); builder.field("name", nodeInfo.getNode().name(), XContentBuilder.FieldCaseConversion.NONE); builder.field("transport_address", nodeInfo.getNode().address().toString()); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java index e57fd552d7c..ffd28f90251 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java @@ -65,7 +65,7 @@ public class NodesStatsResponse extends BaseNodesResponse implements builder.startObject("nodes"); for (NodeStats nodeStats : this) { - builder.startObject(nodeStats.getNode().id(), XContentBuilder.FieldCaseConversion.NONE); + builder.startObject(nodeStats.getNode().getId(), XContentBuilder.FieldCaseConversion.NONE); builder.field("timestamp", nodeStats.getTimestamp()); nodeStats.toXContent(builder, params); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java index ba62002c1c6..2b8c6b348b8 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java @@ -86,7 +86,7 @@ public class VerifyRepositoryResponse extends ActionResponse implements ToXConte public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.NODES); for (DiscoveryNode node : nodes) { - builder.startObject(node.id(), XContentBuilder.FieldCaseConversion.NONE); + builder.startObject(node.getId(), XContentBuilder.FieldCaseConversion.NONE); builder.field(Fields.NAME, node.name(), XContentBuilder.FieldCaseConversion.NONE); builder.endObject(); } diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java index 0bc13db9644..fb6310a45bf 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java @@ -107,7 +107,7 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction> snapshotMapBuilder = new HashMap<>(); try { - String nodeId = clusterService.localNode().id(); + String nodeId = clusterService.localNode().getId(); for (SnapshotId snapshotId : request.snapshotIds) { Map shardsStatus = snapshotShardsService.currentSnapshotShards(snapshotId); if (shardsStatus == null) { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java index bf4dbd3359e..d6ea00c0ee1 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java @@ -194,7 +194,7 @@ public class TransportIndicesShardStoresAction extends TransportMasterNodeReadAc } private IndicesShardStoresResponse.StoreStatus.AllocationStatus getAllocationStatus(String index, int shardID, DiscoveryNode node) { - for (ShardRouting shardRouting : routingNodes.node(node.id())) { + for (ShardRouting shardRouting : routingNodes.node(node.getId())) { ShardId shardId = shardRouting.shardId(); if (shardId.id() == shardID && shardId.getIndexName().equals(index)) { if (shardRouting.primary()) { diff --git a/core/src/main/java/org/elasticsearch/action/search/AbstractSearchAsyncAction.java b/core/src/main/java/org/elasticsearch/action/search/AbstractSearchAsyncAction.java index 732e9098ee7..78d397f8de9 100644 --- a/core/src/main/java/org/elasticsearch/action/search/AbstractSearchAsyncAction.java +++ b/core/src/main/java/org/elasticsearch/action/search/AbstractSearchAsyncAction.java @@ -155,7 +155,7 @@ abstract class AbstractSearchAsyncAction @Override public void onFailure(Throwable t) { - onFirstPhaseResult(shardIndex, shard, node.id(), shardIt, t); + onFirstPhaseResult(shardIndex, shard, node.getId(), shardIt, t); } }); } diff --git a/core/src/main/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java b/core/src/main/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java index 3ed3e8ffb7a..d4f17e8ee58 100644 --- a/core/src/main/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java +++ b/core/src/main/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java @@ -299,7 +299,7 @@ public abstract class TransportBroadcastByNodeAction() { @@ -330,7 +330,7 @@ public abstract class TransportBroadcastByNodeAction if (nodesMap == null) { nodesMap = new HashMap<>(); for (TNodeResponse nodeResponse : nodes) { - nodesMap.put(nodeResponse.getNode().id(), nodeResponse); + nodesMap.put(nodeResponse.getNode().getId(), nodeResponse); } } return nodesMap; diff --git a/core/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java b/core/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java index 9c021efbe40..a6a646ec251 100644 --- a/core/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java +++ b/core/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java @@ -161,7 +161,7 @@ public abstract class TransportNodesAction() { @@ -253,7 +253,7 @@ public abstract class TransportTasksAction< @Override public void handleException(TransportException exp) { - onFailure(idx, node.id(), exp); + onFailure(idx, node.getId(), exp); } @Override diff --git a/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java b/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java index 69b4cd03e3b..12936321fc0 100644 --- a/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java +++ b/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java @@ -383,7 +383,7 @@ public class TransportClientNodesService extends AbstractComponent { // use discovered information but do keep the original transport address, // so people can control which address is exactly used. DiscoveryNode nodeWithInfo = livenessResponse.getDiscoveryNode(); - newNodes.add(new DiscoveryNode(nodeWithInfo.name(), nodeWithInfo.id(), nodeWithInfo.getHostName(), + newNodes.add(new DiscoveryNode(nodeWithInfo.name(), nodeWithInfo.getId(), nodeWithInfo.getHostName(), nodeWithInfo.getHostAddress(), listedNode.getAddress(), nodeWithInfo.getAttributes(), nodeWithInfo.getRoles(), nodeWithInfo.getVersion())); } else { diff --git a/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java b/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java index 9a9ee06ce19..7384c6c7c61 100644 --- a/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java +++ b/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java @@ -409,7 +409,7 @@ public class InternalClusterInfoService extends AbstractComponent implements Clu mostAvailablePath = info; } } - String nodeId = nodeStats.getNode().id(); + String nodeId = nodeStats.getNode().getId(); String nodeName = nodeStats.getNode().getName(); if (logger.isTraceEnabled()) { logger.trace("node: [{}], most available: total disk: {}, available disk: {} / least available: total disk: {}, available disk: {}", diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 2671fb372ff..8a4739bbf7a 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -221,18 +221,11 @@ public class DiscoveryNode implements Writeable, ToXContent { return address(); } - /** - * The unique id of the node. - */ - public String id() { - return nodeId; - } - /** * The unique id of the node. */ public String getId() { - return id(); + return nodeId; } /** @@ -377,7 +370,7 @@ public class DiscoveryNode implements Writeable, ToXContent { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(id(), XContentBuilder.FieldCaseConversion.NONE); + builder.startObject(getId(), XContentBuilder.FieldCaseConversion.NONE); builder.field("name", name()); builder.field("transport_address", address().toString()); diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java index 891b75f002e..86729530a2a 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java @@ -155,7 +155,7 @@ public class DiscoveryNodeFilters { } } else if ("_id".equals(attr)) { for (String value : values) { - if (node.id().equals(value)) { + if (node.getId().equals(value)) { if (opType == OpType.OR) { return true; } 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 d48668b3abd..46ede31bfde 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -340,7 +340,7 @@ public class DiscoveryNodes extends AbstractDiffable implements int index = 0; nodesIds = new String[nodes.size()]; for (DiscoveryNode node : this) { - nodesIds[index++] = node.id(); + nodesIds[index++] = node.getId(); } return nodesIds; } else { @@ -362,14 +362,14 @@ public class DiscoveryNodes extends AbstractDiffable implements // not a node id, try and search by name for (DiscoveryNode node : this) { if (Regex.simpleMatch(nodeId, node.name())) { - resolvedNodesIds.add(node.id()); + resolvedNodesIds.add(node.getId()); } } for (DiscoveryNode node : this) { if (Regex.simpleMatch(nodeId, node.getHostAddress())) { - resolvedNodesIds.add(node.id()); + resolvedNodesIds.add(node.getId()); } else if (Regex.simpleMatch(nodeId, node.getHostName())) { - resolvedNodesIds.add(node.id()); + resolvedNodesIds.add(node.getId()); } } int index = nodeId.indexOf(':'); @@ -400,7 +400,7 @@ public class DiscoveryNodes extends AbstractDiffable implements String attrName = entry.getKey(); String attrValue = entry.getValue(); if (Regex.simpleMatch(matchAttrName, attrName) && Regex.simpleMatch(matchAttrValue, attrValue)) { - resolvedNodesIds.add(node.id()); + resolvedNodesIds.add(node.getId()); } } } @@ -415,7 +415,7 @@ public class DiscoveryNodes extends AbstractDiffable implements public DiscoveryNodes removeDeadMembers(Set newNodes, String masterNodeId) { Builder builder = new Builder().masterNodeId(masterNodeId).localNodeId(localNodeId); for (DiscoveryNode node : this) { - if (newNodes.contains(node.id())) { + if (newNodes.contains(node.getId())) { builder.put(node); } } @@ -433,12 +433,12 @@ public class DiscoveryNodes extends AbstractDiffable implements List removed = new ArrayList<>(); List added = new ArrayList<>(); for (DiscoveryNode node : other) { - if (!this.nodeExists(node.id())) { + if (!this.nodeExists(node.getId())) { removed.add(node); } } for (DiscoveryNode node : this) { - if (!other.nodeExists(node.id())) { + if (!other.nodeExists(node.getId())) { added.add(node); } } @@ -539,7 +539,7 @@ public class DiscoveryNodes extends AbstractDiffable implements public String shortSummary() { StringBuilder sb = new StringBuilder(); if (!removed() && masterNodeChanged()) { - if (newMasterNode.id().equals(localNodeId)) { + if (newMasterNode.getId().equals(localNodeId)) { // we are the master, no nodes we removed, we are actually the first master sb.append("new_master ").append(newMasterNode()); } else { @@ -567,13 +567,13 @@ public class DiscoveryNodes extends AbstractDiffable implements } if (added()) { // don't print if there is one added, and it is us - if (!(addedNodes().size() == 1 && addedNodes().get(0).id().equals(localNodeId))) { + if (!(addedNodes().size() == 1 && addedNodes().get(0).getId().equals(localNodeId))) { if (removed() || masterNodeChanged()) { sb.append(", "); } sb.append("added {"); for (DiscoveryNode node : addedNodes()) { - if (!node.id().equals(localNodeId)) { + if (!node.getId().equals(localNodeId)) { // don't print ourself sb.append(node).append(','); } @@ -605,12 +605,12 @@ public class DiscoveryNodes extends AbstractDiffable implements builder.masterNodeId(in.readString()); } if (localNode != null) { - builder.localNodeId(localNode.id()); + builder.localNodeId(localNode.getId()); } int size = in.readVInt(); for (int i = 0; i < size; i++) { DiscoveryNode node = new DiscoveryNode(in); - if (localNode != null && node.id().equals(localNode.id())) { + if (localNode != null && node.getId().equals(localNode.getId())) { // reuse the same instance of our address and local node id for faster equality node = localNode; } @@ -649,7 +649,7 @@ public class DiscoveryNodes extends AbstractDiffable implements } public Builder put(DiscoveryNode node) { - nodes.put(node.id(), node); + nodes.put(node.getId(), node); return this; } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java index bd41176d086..1af8b83d909 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java @@ -87,7 +87,7 @@ public class RoutingNodes implements Iterable { Map> nodesToShards = new HashMap<>(); // fill in the nodeToShards with the "live" nodes for (ObjectCursor cursor : clusterState.nodes().dataNodes().values()) { - nodesToShards.put(cursor.value.id(), new ArrayList<>()); + nodesToShards.put(cursor.value.getId(), new ArrayList<>()); } // fill in the inverse of node -> shards allocated @@ -570,7 +570,7 @@ public class RoutingNodes implements Iterable { public void addNode(DiscoveryNode node) { ensureMutable(); - RoutingNode routingNode = new RoutingNode(node.id(), node); + RoutingNode routingNode = new RoutingNode(node.getId(), node); nodesToShards.put(routingNode.nodeId(), routingNode); } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateEmptyPrimaryAllocationCommand.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateEmptyPrimaryAllocationCommand.java index c7ddefedc24..87ae4984f5e 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateEmptyPrimaryAllocationCommand.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateEmptyPrimaryAllocationCommand.java @@ -91,7 +91,7 @@ public class AllocateEmptyPrimaryAllocationCommand extends BasePrimaryAllocation return explainOrThrowRejectedCommand(explain, allocation, e); } final RoutingNodes routingNodes = allocation.routingNodes(); - RoutingNode routingNode = routingNodes.node(discoNode.id()); + RoutingNode routingNode = routingNodes.node(discoNode.getId()); if (routingNode == null) { return explainOrThrowMissingRoutingNode(allocation, explain, discoNode); } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateReplicaAllocationCommand.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateReplicaAllocationCommand.java index 616e08b8f3f..6e40ac2c3d3 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateReplicaAllocationCommand.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateReplicaAllocationCommand.java @@ -30,7 +30,6 @@ import org.elasticsearch.cluster.routing.allocation.decider.Decision; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardNotFoundException; import java.io.IOException; @@ -90,7 +89,7 @@ public class AllocateReplicaAllocationCommand extends AbstractAllocateAllocation return explainOrThrowRejectedCommand(explain, allocation, e); } final RoutingNodes routingNodes = allocation.routingNodes(); - RoutingNode routingNode = routingNodes.node(discoNode.id()); + RoutingNode routingNode = routingNodes.node(discoNode.getId()); if (routingNode == null) { return explainOrThrowMissingRoutingNode(allocation, explain, discoNode); } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateStalePrimaryAllocationCommand.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateStalePrimaryAllocationCommand.java index f4b1be19af4..39f2d2463f6 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateStalePrimaryAllocationCommand.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocateStalePrimaryAllocationCommand.java @@ -30,7 +30,6 @@ import org.elasticsearch.cluster.routing.allocation.decider.Decision; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardNotFoundException; import java.io.IOException; @@ -92,7 +91,7 @@ public class AllocateStalePrimaryAllocationCommand extends BasePrimaryAllocation return explainOrThrowRejectedCommand(explain, allocation, e); } final RoutingNodes routingNodes = allocation.routingNodes(); - RoutingNode routingNode = routingNodes.node(discoNode.id()); + RoutingNode routingNode = routingNodes.node(discoNode.getId()); if (routingNode == null) { return explainOrThrowMissingRoutingNode(allocation, explain, discoNode); } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/CancelAllocationCommand.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/CancelAllocationCommand.java index 32eae8c19d7..7272d57dcf0 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/CancelAllocationCommand.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/CancelAllocationCommand.java @@ -175,7 +175,7 @@ public class CancelAllocationCommand implements AllocationCommand { public RerouteExplanation execute(RoutingAllocation allocation, boolean explain) { DiscoveryNode discoNode = allocation.nodes().resolveNode(node); boolean found = false; - for (RoutingNodes.RoutingNodeIterator it = allocation.routingNodes().routingNodeIter(discoNode.id()); it.hasNext(); ) { + for (RoutingNodes.RoutingNodeIterator it = allocation.routingNodes().routingNodeIter(discoNode.getId()); it.hasNext(); ) { ShardRouting shardRouting = it.next(); if (!shardRouting.shardId().getIndex().getName().equals(index)) { continue; diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/MoveAllocationCommand.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/MoveAllocationCommand.java index 75a9400807c..837ae06c6f0 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/MoveAllocationCommand.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/MoveAllocationCommand.java @@ -155,7 +155,7 @@ public class MoveAllocationCommand implements AllocationCommand { Decision decision = null; boolean found = false; - for (ShardRouting shardRouting : allocation.routingNodes().node(fromDiscoNode.id())) { + for (ShardRouting shardRouting : allocation.routingNodes().node(fromDiscoNode.getId())) { if (!shardRouting.shardId().getIndexName().equals(index)) { continue; } @@ -174,7 +174,7 @@ public class MoveAllocationCommand implements AllocationCommand { ", shard is not started (state = " + shardRouting.state() + "]"); } - RoutingNode toRoutingNode = allocation.routingNodes().node(toDiscoNode.id()); + RoutingNode toRoutingNode = allocation.routingNodes().node(toDiscoNode.getId()); decision = allocation.deciders().canAllocate(shardRouting, toRoutingNode, allocation); if (decision.type() == Decision.Type.NO) { if (explain) { diff --git a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java index 8a38453eb4c..559c5d6300e 100644 --- a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java +++ b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java @@ -159,7 +159,7 @@ public class ClusterService extends AbstractLifecycleComponent { synchronized public void setLocalNode(DiscoveryNode localNode) { assert clusterState.nodes().localNodeId() == null : "local node is already set"; - DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.nodes()).put(localNode).localNodeId(localNode.id()); + DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.nodes()).put(localNode).localNodeId(localNode.getId()); this.clusterState = ClusterState.builder(clusterState).nodes(nodeBuilder).build(); } diff --git a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java index cf697871d35..89395c86bd9 100644 --- a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java @@ -129,7 +129,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem for (LocalDiscovery discovery : clusterGroups.get(clusterName).members()) { nodesBuilder.put(discovery.localNode()); } - nodesBuilder.localNodeId(master.localNode().id()).masterNodeId(master.localNode().id()); + nodesBuilder.localNodeId(master.localNode().getId()).masterNodeId(master.localNode().getId()); // remove the NO_MASTER block in this case ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(discoverySettings.getNoMasterBlock()); return ClusterState.builder(currentState).nodes(nodesBuilder).blocks(blocks).build(); @@ -155,7 +155,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem for (LocalDiscovery discovery : clusterGroups.get(clusterName).members()) { nodesBuilder.put(discovery.localNode()); } - nodesBuilder.localNodeId(master.localNode().id()).masterNodeId(master.localNode().id()); + nodesBuilder.localNodeId(master.localNode().getId()).masterNodeId(master.localNode().getId()); return ClusterState.builder(currentState).nodes(nodesBuilder).build(); } @@ -207,7 +207,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem final Set newMembers = new HashSet<>(); for (LocalDiscovery discovery : clusterGroup.members()) { - newMembers.add(discovery.localNode().id()); + newMembers.add(discovery.localNode().getId()); } final LocalDiscovery master = firstMaster; @@ -219,7 +219,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem @Override public ClusterState execute(ClusterState currentState) { - DiscoveryNodes newNodes = currentState.nodes().removeDeadMembers(newMembers, master.localNode().id()); + DiscoveryNodes newNodes = currentState.nodes().removeDeadMembers(newMembers, master.localNode().getId()); DiscoveryNodes.Delta delta = newNodes.delta(currentState.nodes()); if (delta.added()) { logger.warn("No new nodes should be created when a new discovery view is accepted"); @@ -251,7 +251,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem @Override public String nodeDescription() { - return clusterName.value() + "/" + localNode().id(); + return clusterName.value() + "/" + localNode().getId(); } @Override @@ -312,7 +312,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem synchronized (this) { // we do the marshaling intentionally, to check it works well... // check if we published cluster state at least once and node was in the cluster when we published cluster state the last time - if (discovery.lastProcessedClusterState != null && clusterChangedEvent.previousState().nodes().nodeExists(discovery.localNode().id())) { + if (discovery.lastProcessedClusterState != null && clusterChangedEvent.previousState().nodes().nodeExists(discovery.localNode().getId())) { // both conditions are true - which means we can try sending cluster state as diffs if (clusterStateDiffBytes == null) { Diff diff = clusterState.diff(clusterChangedEvent.previousState()); diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java index 0edbf8841ad..bc5acba6286 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java @@ -246,7 +246,7 @@ public class NodeJoinController extends AbstractComponent { throw new NotMasterException("Node [" + clusterService.localNode() + "] not master for join request"); } - DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder(currentState.nodes()).masterNodeId(currentState.nodes().localNode().id()); + DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder(currentState.nodes()).masterNodeId(currentState.nodes().localNode().getId()); // update the fact that we are the master... ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(discoverySettings.getNoMasterBlock()).build(); currentState = ClusterState.builder(currentState).nodes(builder).blocks(clusterBlocks).build(); @@ -378,14 +378,14 @@ public class NodeJoinController extends AbstractComponent { final DiscoveryNode node = entry.getKey(); joinCallbacksToRespondTo.addAll(entry.getValue()); iterator.remove(); - if (currentState.nodes().nodeExists(node.id())) { + if (currentState.nodes().nodeExists(node.getId())) { logger.debug("received a join request for an existing node [{}]", node); } else { nodeAdded = true; nodesBuilder.put(node); for (DiscoveryNode existingNode : currentState.nodes()) { if (node.address().equals(existingNode.address())) { - nodesBuilder.remove(existingNode.id()); + nodesBuilder.remove(existingNode.getId()); logger.warn("received join request from node [{}], but found existing node {} with same address, removing existing node", node, existingNode); } } 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 0169ac1994e..3b61d7e6cf8 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -283,7 +283,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen @Override public String nodeDescription() { - return clusterName.value() + "/" + clusterService.localNode().id(); + return clusterName.value() + "/" + clusterService.localNode().getId(); } /** start of {@link org.elasticsearch.discovery.zen.ping.PingContextProvider } implementation */ @@ -501,7 +501,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen clusterService.submitStateUpdateTask("zen-disco-node_left(" + node + ")", new ClusterStateUpdateTask(Priority.IMMEDIATE) { @Override public ClusterState execute(ClusterState currentState) { - DiscoveryNodes.Builder builder = DiscoveryNodes.builder(currentState.nodes()).remove(node.id()); + DiscoveryNodes.Builder builder = DiscoveryNodes.builder(currentState.nodes()).remove(node.getId()); currentState = ClusterState.builder(currentState).nodes(builder).build(); // check if we have enough master nodes, if not, we need to move into joining the cluster again if (!electMaster.hasEnoughMasterNodes(currentState.nodes())) { @@ -541,12 +541,12 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen clusterService.submitStateUpdateTask("zen-disco-node_failed(" + node + "), reason " + reason, new ClusterStateUpdateTask(Priority.IMMEDIATE) { @Override public ClusterState execute(ClusterState currentState) { - if (currentState.nodes().get(node.id()) == null) { + if (currentState.nodes().get(node.getId()) == null) { logger.debug("node [{}] already removed from cluster state. ignoring.", node); return currentState; } DiscoveryNodes.Builder builder = DiscoveryNodes.builder(currentState.nodes()) - .remove(node.id()); + .remove(node.getId()); currentState = ClusterState.builder(currentState).nodes(builder).build(); // check if we have enough master nodes, if not, we need to move into joining the cluster again if (!electMaster.hasEnoughMasterNodes(currentState.nodes())) { @@ -634,14 +634,14 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen @Override public ClusterState execute(ClusterState currentState) { - if (!masterNode.id().equals(currentState.nodes().masterNodeId())) { + if (!masterNode.getId().equals(currentState.nodes().masterNodeId())) { // master got switched on us, no need to send anything return currentState; } DiscoveryNodes discoveryNodes = DiscoveryNodes.builder(currentState.nodes()) // make sure the old master node, which has failed, is not part of the nodes we publish - .remove(masterNode.id()) + .remove(masterNode.getId()) .masterNodeId(null).build(); // flush any pending cluster states from old master, so it will not be set as master again diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java b/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java index a3da8be5a94..fd60993cbf8 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java @@ -154,7 +154,7 @@ public class ElectMasterService extends AbstractComponent { if (!o1.masterNode() && o2.masterNode()) { return 1; } - return o1.id().compareTo(o2.id()); + return o1.getId().compareTo(o2.getId()); } } } diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java b/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java index 96ed7f76419..a3974fd48e1 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java @@ -227,7 +227,7 @@ public class MasterFaultDetection extends FaultDetection { threadPool.schedule(pingInterval, ThreadPool.Names.SAME, MasterPinger.this); return; } - final MasterPingRequest request = new MasterPingRequest(clusterService.localNode().id(), masterToPing.id(), clusterName); + final MasterPingRequest request = new MasterPingRequest(clusterService.localNode().getId(), masterToPing.getId(), clusterName); final TransportRequestOptions options = TransportRequestOptions.builder().withType(TransportRequestOptions.Type.PING).withTimeout(pingRetryTimeout).build(); transportService.sendRequest(masterToPing, MASTER_PING_ACTION_NAME, request, options, new BaseTransportResponseHandler() { diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/fd/NodesFaultDetection.java b/core/src/main/java/org/elasticsearch/discovery/zen/fd/NodesFaultDetection.java index 4b1077cc1b2..7dbe50577ce 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/fd/NodesFaultDetection.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/fd/NodesFaultDetection.java @@ -94,7 +94,7 @@ public class NodesFaultDetection extends FaultDetection { public void updateNodesAndPing(ClusterState clusterState) { // remove any nodes we don't need, this will cause their FD to stop for (DiscoveryNode monitoredNode : nodesFD.keySet()) { - if (!clusterState.nodes().nodeExists(monitoredNode.id())) { + if (!clusterState.nodes().nodeExists(monitoredNode.getId())) { nodesFD.remove(monitoredNode); } } @@ -200,7 +200,7 @@ public class NodesFaultDetection extends FaultDetection { if (!running()) { return; } - final PingRequest pingRequest = new PingRequest(node.id(), clusterName, localNode, clusterStateVersion); + final PingRequest pingRequest = new PingRequest(node.getId(), clusterName, localNode, clusterStateVersion); final TransportRequestOptions options = TransportRequestOptions.builder().withType(TransportRequestOptions.Type.PING).withTimeout(pingRetryTimeout).build(); transportService.sendRequest(node, PING_ACTION_NAME, pingRequest, options, new BaseTransportResponseHandler() { @Override @@ -255,8 +255,8 @@ public class NodesFaultDetection extends FaultDetection { public void messageReceived(PingRequest request, TransportChannel channel) throws Exception { // if we are not the node we are supposed to be pinged, send an exception // this can happen when a kill -9 is sent, and another node is started using the same port - if (!localNode.id().equals(request.nodeId)) { - throw new IllegalStateException("Got pinged as node [" + request.nodeId + "], but I am node [" + localNode.id() + "]"); + if (!localNode.getId().equals(request.nodeId)) { + throw new IllegalStateException("Got pinged as node [" + request.nodeId + "], but I am node [" + localNode.getId() + "]"); } // PingRequest will have clusterName set to null if it came from a node of version <1.4.0 diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java index 4806871be3b..93021a9d3a6 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java @@ -378,9 +378,9 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen // to make sure we don't disconnect a true node which was temporarily removed from the DiscoveryNodes // but will be added again during the pinging. We therefore create a new temporary node if (!nodeFoundByAddress) { - if (!nodeToSend.id().startsWith(UNICAST_NODE_PREFIX)) { + if (!nodeToSend.getId().startsWith(UNICAST_NODE_PREFIX)) { DiscoveryNode tempNode = new DiscoveryNode("", - UNICAST_NODE_PREFIX + unicastNodeIdGenerator.incrementAndGet() + "_" + nodeToSend.id() + "#", + UNICAST_NODE_PREFIX + unicastNodeIdGenerator.incrementAndGet() + "_" + nodeToSend.getId() + "#", nodeToSend.getHostName(), nodeToSend.getHostAddress(), nodeToSend.getAddress(), nodeToSend.getAttributes(), nodeToSend.getRoles(), nodeToSend.getVersion()); @@ -469,7 +469,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen try { DiscoveryNodes discoveryNodes = contextProvider.nodes(); for (PingResponse pingResponse : response.pingResponses) { - if (pingResponse.node().id().equals(discoveryNodes.localNodeId())) { + if (pingResponse.node().getId().equals(discoveryNodes.localNodeId())) { // that's us, ignore continue; } 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 acb5f640db0..64b77588726 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 @@ -179,7 +179,7 @@ public class PublishClusterStateAction extends AbstractComponent { // try and serialize the cluster state once (or per version), so we don't serialize it // per node when we send it over the wire, compress it while we are at it... // we don't send full version if node didn't exist in the previous version of cluster state - if (sendFullVersion || !previousState.nodes().nodeExists(node.id())) { + if (sendFullVersion || !previousState.nodes().nodeExists(node.getId())) { sendFullClusterState(clusterState, serializedStates, node, publishTimeout, sendingController); } else { sendClusterStateDiff(clusterState, serializedDiffs, serializedStates, node, publishTimeout, sendingController); @@ -210,7 +210,7 @@ public class PublishClusterStateAction extends AbstractComponent { Diff diff = null; for (final DiscoveryNode node : nodesToPublishTo) { try { - if (sendFullVersion || !previousState.nodes().nodeExists(node.id())) { + if (sendFullVersion || !previousState.nodes().nodeExists(node.getId())) { // will send a full reference if (serializedStates.containsKey(node.version()) == false) { serializedStates.put(node.version(), serializeFullClusterState(clusterState, node.version())); diff --git a/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java b/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java index e7447e301c4..8cfe446a29b 100644 --- a/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java +++ b/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java @@ -158,12 +158,12 @@ public abstract class PrimaryShardAllocator extends AbstractComponent { NodeGatewayStartedShards nodeShardState = nodesToAllocate.yesNodeShards.get(0); logger.debug("[{}][{}]: allocating [{}] to [{}] on primary allocation", shard.index(), shard.id(), shard, nodeShardState.getNode()); changed = true; - unassignedIterator.initialize(nodeShardState.getNode().id(), nodeShardState.allocationId(), ShardRouting.UNAVAILABLE_EXPECTED_SHARD_SIZE); + unassignedIterator.initialize(nodeShardState.getNode().getId(), nodeShardState.allocationId(), ShardRouting.UNAVAILABLE_EXPECTED_SHARD_SIZE); } else if (nodesToAllocate.throttleNodeShards.isEmpty() == true && nodesToAllocate.noNodeShards.isEmpty() == false) { NodeGatewayStartedShards nodeShardState = nodesToAllocate.noNodeShards.get(0); logger.debug("[{}][{}]: forcing allocating [{}] to [{}] on primary allocation", shard.index(), shard.id(), shard, nodeShardState.getNode()); changed = true; - unassignedIterator.initialize(nodeShardState.getNode().id(), nodeShardState.allocationId(), ShardRouting.UNAVAILABLE_EXPECTED_SHARD_SIZE); + unassignedIterator.initialize(nodeShardState.getNode().getId(), nodeShardState.allocationId(), ShardRouting.UNAVAILABLE_EXPECTED_SHARD_SIZE); } else { // we are throttling this, but we have enough to allocate to this node, ignore it for now logger.debug("[{}][{}]: throttling allocation [{}] to [{}] on primary allocation", shard.index(), shard.id(), shard, nodesToAllocate.throttleNodeShards); @@ -187,7 +187,7 @@ public abstract class PrimaryShardAllocator extends AbstractComponent { DiscoveryNode node = nodeShardState.getNode(); String allocationId = nodeShardState.allocationId(); - if (ignoreNodes.contains(node.id())) { + if (ignoreNodes.contains(node.getId())) { continue; } @@ -272,7 +272,7 @@ public abstract class PrimaryShardAllocator extends AbstractComponent { List throttledNodeShards = new ArrayList<>(); List noNodeShards = new ArrayList<>(); for (NodeGatewayStartedShards nodeShardState : nodeShardStates) { - RoutingNode node = allocation.routingNodes().node(nodeShardState.getNode().id()); + RoutingNode node = allocation.routingNodes().node(nodeShardState.getNode().getId()); if (node == null) { continue; } @@ -302,7 +302,7 @@ public abstract class PrimaryShardAllocator extends AbstractComponent { long version = nodeShardState.legacyVersion(); DiscoveryNode node = nodeShardState.getNode(); - if (ignoreNodes.contains(node.id())) { + if (ignoreNodes.contains(node.getId())) { continue; } diff --git a/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java b/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java index 74511639d47..533bbffee40 100644 --- a/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java +++ b/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java @@ -164,7 +164,7 @@ public abstract class ReplicaShardAllocator extends AbstractComponent { MatchingNodes matchingNodes = findMatchingNodes(shard, allocation, primaryStore, shardStores); if (matchingNodes.getNodeWithHighestMatch() != null) { - RoutingNode nodeWithHighestMatch = allocation.routingNodes().node(matchingNodes.getNodeWithHighestMatch().id()); + RoutingNode nodeWithHighestMatch = allocation.routingNodes().node(matchingNodes.getNodeWithHighestMatch().getId()); // we only check on THROTTLE since we checked before before on NO Decision decision = allocation.deciders().canAllocate(shard, nodeWithHighestMatch, allocation); if (decision.type() == Decision.Type.THROTTLE) { @@ -217,7 +217,7 @@ public abstract class ReplicaShardAllocator extends AbstractComponent { */ private boolean canBeAllocatedToAtLeastOneNode(ShardRouting shard, RoutingAllocation allocation) { for (ObjectCursor cursor : allocation.nodes().dataNodes().values()) { - RoutingNode node = allocation.routingNodes().node(cursor.value.id()); + RoutingNode node = allocation.routingNodes().node(cursor.value.getId()); if (node == null) { continue; } @@ -259,7 +259,7 @@ public abstract class ReplicaShardAllocator extends AbstractComponent { continue; } - RoutingNode node = allocation.routingNodes().node(discoNode.id()); + RoutingNode node = allocation.routingNodes().node(discoNode.getId()); if (node == null) { continue; } diff --git a/core/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java b/core/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java index b1d7af7ff9c..f572b3b5002 100644 --- a/core/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java +++ b/core/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java @@ -380,7 +380,7 @@ public class SyncedFlushService extends AbstractComponent implements IndexEventL @Override public void handleResponse(PreSyncedFlushResponse response) { - Engine.CommitId existing = commitIds.putIfAbsent(node.id(), response.commitId()); + Engine.CommitId existing = commitIds.putIfAbsent(node.getId(), response.commitId()); assert existing == null : "got two answers for node [" + node + "]"; // count after the assert so we won't decrement twice in handleException if (countDown.countDown()) { diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java index aaf351f6056..77fedd8184f 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java @@ -88,7 +88,7 @@ public class RecoverySource extends AbstractComponent implements IndexEventListe // starting recovery from that our (the source) shard state is marking the shard to be in recovery mode as well, otherwise // the index operations will not be routed to it properly - RoutingNode node = clusterService.state().getRoutingNodes().node(request.targetNode().id()); + RoutingNode node = clusterService.state().getRoutingNodes().node(request.targetNode().getId()); if (node == null) { logger.debug("delaying recovery of {} as source node {} is unknown", request.shardId(), request.targetNode()); throw new DelayRecoveryException("source node does not have the node [" + request.targetNode() + "] in its state yet.."); diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java index 604879452ba..7d0c246400d 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java @@ -316,7 +316,7 @@ public class RecoveryState implements ToXContent, Streamable { restoreSource.toXContent(builder, params); } else { builder.startObject(Fields.SOURCE); - builder.field(Fields.ID, sourceNode.id()); + builder.field(Fields.ID, sourceNode.getId()); builder.field(Fields.HOST, sourceNode.getHostName()); builder.field(Fields.TRANSPORT_ADDRESS, sourceNode.address().toString()); builder.field(Fields.IP, sourceNode.getHostAddress()); @@ -325,7 +325,7 @@ public class RecoveryState implements ToXContent, Streamable { } builder.startObject(Fields.TARGET); - builder.field(Fields.ID, targetNode.id()); + builder.field(Fields.ID, targetNode.getId()); builder.field(Fields.HOST, targetNode.getHostName()); builder.field(Fields.TRANSPORT_ADDRESS, targetNode.address().toString()); builder.field(Fields.IP, targetNode.getHostAddress()); diff --git a/core/src/main/java/org/elasticsearch/indices/store/IndicesStore.java b/core/src/main/java/org/elasticsearch/indices/store/IndicesStore.java index fcca5769ddd..c86d6504e28 100644 --- a/core/src/main/java/org/elasticsearch/indices/store/IndicesStore.java +++ b/core/src/main/java/org/elasticsearch/indices/store/IndicesStore.java @@ -160,7 +160,7 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe } // check if shard is active on the current node or is getting relocated to the our node - String localNodeId = state.getNodes().localNode().id(); + String localNodeId = state.getNodes().localNode().getId(); if (localNodeId.equals(shardRouting.currentNodeId()) || localNodeId.equals(shardRouting.relocatingNodeId())) { return false; } diff --git a/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java b/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java index 48ffbd5c1cb..4276fc43ef3 100644 --- a/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java +++ b/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java @@ -85,7 +85,7 @@ public class VerifyNodeRepositoryAction extends AbstractComponent { doVerify(repository, verificationToken); } catch (Throwable t) { logger.warn("[{}] failed to verify repository", t, repository); - errors.add(new VerificationFailure(node.id(), t)); + errors.add(new VerificationFailure(node.getId(), t)); } if (counter.decrementAndGet() == 0) { finishVerification(listener, nodes, errors); @@ -101,7 +101,7 @@ public class VerifyNodeRepositoryAction extends AbstractComponent { @Override public void handleException(TransportException exp) { - errors.add(new VerificationFailure(node.id(), exp)); + errors.add(new VerificationFailure(node.getId(), exp)); if (counter.decrementAndGet() == 0) { finishVerification(listener, nodes, errors); } diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java index 7acc0763e85..a0abff40625 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java @@ -120,7 +120,7 @@ public class RestAllocationAction extends AbstractCatAction { for (NodeStats nodeStats : stats.getNodes()) { DiscoveryNode node = nodeStats.getNode(); - int shardCount = allocs.getOrDefault(node.id(), 0); + int shardCount = allocs.getOrDefault(node.getId(), 0); ByteSizeValue total = nodeStats.getFs().getTotal().getTotal(); ByteSizeValue avail = nodeStats.getFs().getTotal().getAvailable(); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java index 486e04cc343..46e75ae7de5 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java @@ -124,7 +124,7 @@ public class RestFielddataAction extends AbstractCatAction { table.startRow(); // add the node info and field data total before each individual field NodeStats ns = statsEntry.getKey(); - table.addCell(ns.getNode().id()); + table.addCell(ns.getNode().getId()); table.addCell(ns.getNode().getHostName()); table.addCell(ns.getNode().getHostAddress()); table.addCell(ns.getNode().getName()); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java index 24c7562c71b..f86d70e7f12 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java @@ -102,11 +102,11 @@ public class RestNodeAttrsAction extends AbstractCatAction { Table table = getTableWithHeader(req); for (DiscoveryNode node : nodes) { - NodeInfo info = nodesInfo.getNodesMap().get(node.id()); + NodeInfo info = nodesInfo.getNodesMap().get(node.getId()); for (Map.Entry attrEntry : node.getAttributes().entrySet()) { table.startRow(); table.addCell(node.name()); - table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4)); + table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4)); table.addCell(info == null ? null : info.getProcess().getId()); table.addCell(node.getHostName()); table.addCell(node.getHostAddress()); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java index 42604f10b17..5681a4808f3 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java @@ -227,8 +227,8 @@ public class RestNodesAction extends AbstractCatAction { Table table = getTableWithHeader(req); for (DiscoveryNode node : nodes) { - NodeInfo info = nodesInfo.getNodesMap().get(node.id()); - NodeStats stats = nodesStats.getNodesMap().get(node.id()); + NodeInfo info = nodesInfo.getNodesMap().get(node.getId()); + NodeStats stats = nodesStats.getNodesMap().get(node.getId()); JvmInfo jvmInfo = info == null ? null : info.getJvm(); JvmStats jvmStats = stats == null ? null : stats.getJvm(); @@ -239,7 +239,7 @@ public class RestNodesAction extends AbstractCatAction { table.startRow(); - table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4)); + table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4)); table.addCell(info == null ? null : info.getProcess().getId()); table.addCell(node.getHostAddress()); if (node.address() instanceof InetSocketTransportAddress) { @@ -287,7 +287,7 @@ public class RestNodesAction extends AbstractCatAction { roles = node.getRoles().stream().map(DiscoveryNode.Role::getAbbreviation).collect(Collectors.joining()); } table.addCell(roles); - table.addCell(masterId == null ? "x" : masterId.equals(node.id()) ? "*" : "-"); + table.addCell(masterId == null ? "x" : masterId.equals(node.getId()) ? "*" : "-"); table.addCell(node.name()); CompletionStats completionStats = indicesStats == null ? null : stats.getIndices().getCompletion(); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java index 1a37ab6da38..3da0bfd5764 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java @@ -94,11 +94,11 @@ public class RestPluginsAction extends AbstractCatAction { Table table = getTableWithHeader(req); for (DiscoveryNode node : nodes) { - NodeInfo info = nodesInfo.getNodesMap().get(node.id()); + NodeInfo info = nodesInfo.getNodesMap().get(node.getId()); for (PluginInfo pluginInfo : info.getPlugins().getPluginInfos()) { table.startRow(); - table.addCell(node.id()); + table.addCell(node.getId()); table.addCell(node.name()); table.addCell(pluginInfo.getName()); table.addCell(pluginInfo.getVersion()); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java index b4ba4bbeffa..9116ac15a98 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java @@ -226,11 +226,11 @@ public class RestThreadPoolAction extends AbstractCatAction { Table table = getTableWithHeader(req); for (DiscoveryNode node : nodes) { - NodeInfo info = nodesInfo.getNodesMap().get(node.id()); - NodeStats stats = nodesStats.getNodesMap().get(node.id()); + NodeInfo info = nodesInfo.getNodesMap().get(node.getId()); + NodeStats stats = nodesStats.getNodesMap().get(node.getId()); table.startRow(); - table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4)); + table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4)); table.addCell(info == null ? null : info.getProcess().getId()); table.addCell(node.getHostName()); table.addCell(node.getHostAddress()); diff --git a/core/src/main/java/org/elasticsearch/search/SearchService.java b/core/src/main/java/org/elasticsearch/search/SearchService.java index 98085bfed35..4defe7b76e5 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchService.java +++ b/core/src/main/java/org/elasticsearch/search/SearchService.java @@ -542,7 +542,7 @@ public class SearchService extends AbstractLifecycleComponent imp final SearchContext createContext(ShardSearchRequest request, @Nullable Engine.Searcher searcher) throws IOException { IndexService indexService = indicesService.indexServiceSafe(request.shardId().getIndex()); IndexShard indexShard = indexService.getShard(request.shardId().getId()); - SearchShardTarget shardTarget = new SearchShardTarget(clusterService.localNode().id(), indexShard.shardId()); + SearchShardTarget shardTarget = new SearchShardTarget(clusterService.localNode().getId(), indexShard.shardId()); Engine.Searcher engineSearcher = searcher == null ? indexShard.acquireSearcher("search") : searcher; diff --git a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java index 4a15dbdac2e..9a0cc0f8cb0 100644 --- a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java +++ b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java @@ -207,7 +207,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent> newSnapshots = new HashMap<>(); // Now go through all snapshots and update existing or create missing - final String localNodeId = clusterService.localNode().id(); + final String localNodeId = clusterService.localNode().getId(); if (snapshotsInProgress != null) { for (SnapshotsInProgress.Entry entry : snapshotsInProgress.entries()) { if (entry.state() == SnapshotsInProgress.State.STARTED) { diff --git a/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java b/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java index da629a0d47f..f76f7b0d158 100644 --- a/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java +++ b/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java @@ -951,7 +951,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem globalLock.readLock().lock(); try { - try (Releasable ignored = connectionLock.acquire(node.id())) { + try (Releasable ignored = connectionLock.acquire(node.getId())) { if (!lifecycle.started()) { throw new IllegalStateException("can't add nodes to a stopped transport"); } @@ -1109,7 +1109,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem @Override public void disconnectFromNode(DiscoveryNode node) { - try (Releasable ignored = connectionLock.acquire(node.id())) { + try (Releasable ignored = connectionLock.acquire(node.getId())) { NodeChannels nodeChannels = connectedNodes.remove(node); if (nodeChannels != null) { try { @@ -1131,7 +1131,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem // check outside of the lock NodeChannels nodeChannels = connectedNodes.get(node); if (nodeChannels != null && nodeChannels.hasChannel(channel)) { - try (Releasable ignored = connectionLock.acquire(node.id())) { + try (Releasable ignored = connectionLock.acquire(node.getId())) { nodeChannels = connectedNodes.get(node); // check again within the connection lock, if its still applicable to remove it if (nodeChannels != null && nodeChannels.hasChannel(channel)) { diff --git a/core/src/main/java/org/elasticsearch/tribe/TribeService.java b/core/src/main/java/org/elasticsearch/tribe/TribeService.java index a31624c5175..7588728396d 100644 --- a/core/src/main/java/org/elasticsearch/tribe/TribeService.java +++ b/core/src/main/java/org/elasticsearch/tribe/TribeService.java @@ -353,20 +353,20 @@ public class TribeService extends AbstractLifecycleComponent { for (DiscoveryNode discoNode : currentState.nodes()) { String markedTribeName = discoNode.getAttributes().get(TRIBE_NAME_SETTING.getKey()); if (markedTribeName != null && markedTribeName.equals(tribeName)) { - if (tribeState.nodes().get(discoNode.id()) == null) { + if (tribeState.nodes().get(discoNode.getId()) == null) { clusterStateChanged = true; logger.info("[{}] removing node [{}]", tribeName, discoNode); - nodes.remove(discoNode.id()); + nodes.remove(discoNode.getId()); } } } // go over tribe nodes, and see if they need to be added for (DiscoveryNode tribe : tribeState.nodes()) { - if (currentState.nodes().get(tribe.id()) == null) { + if (currentState.nodes().get(tribe.getId()) == null) { // a new node, add it, but also add the tribe name to the attributes Map tribeAttr = new HashMap<>(tribe.getAttributes()); tribeAttr.put(TRIBE_NAME_SETTING.getKey(), tribeName); - DiscoveryNode discoNode = new DiscoveryNode(tribe.name(), tribe.id(), tribe.getHostName(), tribe.getHostAddress(), + DiscoveryNode discoNode = new DiscoveryNode(tribe.name(), tribe.getId(), tribe.getHostName(), tribe.getHostAddress(), tribe.address(), unmodifiableMap(tribeAttr), tribe.getRoles(), tribe.version()); clusterStateChanged = true; logger.info("[{}] adding node [{}]", tribeName, discoNode); diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreResponseTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreResponseTests.java index e10e08286e0..e100bcae4ac 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreResponseTests.java @@ -111,7 +111,7 @@ public class IndicesShardStoreResponseTests extends ESTestCase { assertThat(eitherLegacyVersionOrAllocationIdSet, equalTo(true)); assertThat(storeInfo.containsKey("allocation"), equalTo(true)); assertThat(((String) storeInfo.get("allocation")), equalTo(storeStatus.getAllocationStatus().value())); - assertThat(storeInfo.containsKey(storeStatus.getNode().id()), equalTo(true)); + assertThat(storeInfo.containsKey(storeStatus.getNode().getId()), equalTo(true)); if (storeStatus.getStoreException() != null) { assertThat(storeInfo.containsKey("store_exception"), equalTo(true)); } diff --git a/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java b/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java index b81cd2a4d8b..973129fb856 100644 --- a/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java @@ -224,14 +224,14 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase { totalIndexShards += numberOfShards; for (int j = 0; j < numberOfShards; j++) { final ShardId shardId = new ShardId(index, "_na_", ++shardIndex); - ShardRouting shard = TestShardRouting.newShardRouting(index, shardId.getId(), node.id(), true, ShardRoutingState.STARTED); + ShardRouting shard = TestShardRouting.newShardRouting(index, shardId.getId(), node.getId(), true, ShardRoutingState.STARTED); IndexShardRoutingTable.Builder indexShard = new IndexShardRoutingTable.Builder(shardId); indexShard.addShard(shard); indexRoutingTable.addIndexShard(indexShard.build()); } } - discoBuilder.localNodeId(newNode(0).id()); - discoBuilder.masterNodeId(newNode(numberOfNodes - 1).id()); + discoBuilder.localNodeId(newNode(0).getId()); + discoBuilder.masterNodeId(newNode(numberOfNodes - 1).getId()); ClusterState.Builder stateBuilder = ClusterState.builder(new ClusterName(TEST_CLUSTER)); stateBuilder.nodes(discoBuilder); final IndexMetaData.Builder indexMetaData = IndexMetaData.builder(index) @@ -320,7 +320,7 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase { DiscoveryNode masterNode = clusterService.state().nodes().masterNode(); DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes()); - builder.remove(masterNode.id()); + builder.remove(masterNode.getId()); setState(clusterService, ClusterState.builder(clusterService.state()).nodes(builder)); @@ -332,7 +332,7 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase { ShardsIterator shardIt = clusterService.state().routingTable().allShards(new String[]{TEST_INDEX}); Set set = new HashSet<>(); for (ShardRouting shard : shardIt.asUnordered()) { - if (!shard.currentNodeId().equals(masterNode.id())) { + if (!shard.currentNodeId().equals(masterNode.getId())) { set.add(shard.currentNodeId()); } } @@ -405,7 +405,7 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase { if (simulateFailedMasterNode) { failedMasterNode = clusterService.state().nodes().masterNode(); DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes()); - builder.remove(failedMasterNode.id()); + builder.remove(failedMasterNode.getId()); builder.masterNodeId(null); setState(clusterService, ClusterState.builder(clusterService.state()).nodes(builder)); @@ -453,7 +453,7 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase { } } if (simulateFailedMasterNode) { - totalShards += map.get(failedMasterNode.id()).size(); + totalShards += map.get(failedMasterNode.getId()).size(); } Response response = listener.get(); diff --git a/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java b/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java index 9a80cf75e59..0ceb433db20 100644 --- a/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java @@ -135,8 +135,8 @@ public class TransportNodesActionTests extends ESTestCase { discoBuilder = discoBuilder.put(node); discoveryNodes.add(node); } - discoBuilder.localNodeId(randomFrom(discoveryNodes).id()); - discoBuilder.masterNodeId(randomFrom(discoveryNodes).id()); + discoBuilder.localNodeId(randomFrom(discoveryNodes).getId()); + discoBuilder.masterNodeId(randomFrom(discoveryNodes).getId()); ClusterState.Builder stateBuilder = ClusterState.builder(CLUSTER_NAME); stateBuilder.nodes(discoBuilder); ClusterState clusterState = stateBuilder.build(); diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/ClusterStateCreationUtils.java b/core/src/test/java/org/elasticsearch/action/support/replication/ClusterStateCreationUtils.java index a5c711ec383..f40ffcbc9e7 100644 --- a/core/src/test/java/org/elasticsearch/action/support/replication/ClusterStateCreationUtils.java +++ b/core/src/test/java/org/elasticsearch/action/support/replication/ClusterStateCreationUtils.java @@ -82,10 +82,10 @@ public class ClusterStateCreationUtils { for (int i = 0; i < numberOfNodes + 1; i++) { final DiscoveryNode node = newNode(i); discoBuilder = discoBuilder.put(node); - unassignedNodes.add(node.id()); + unassignedNodes.add(node.getId()); } - discoBuilder.localNodeId(newNode(0).id()); - discoBuilder.masterNodeId(newNode(1).id()); // we need a non-local master to test shard failures + discoBuilder.localNodeId(newNode(0).getId()); + discoBuilder.masterNodeId(newNode(1).getId()); // we need a non-local master to test shard failures final int primaryTerm = randomInt(200); IndexMetaData indexMetaData = IndexMetaData.builder(index).settings(Settings.builder() .put(SETTING_VERSION_CREATED, Version.CURRENT) @@ -101,11 +101,11 @@ public class ClusterStateCreationUtils { UnassignedInfo unassignedInfo = null; if (primaryState != ShardRoutingState.UNASSIGNED) { if (activePrimaryLocal) { - primaryNode = newNode(0).id(); + primaryNode = newNode(0).getId(); unassignedNodes.remove(primaryNode); } else { Set unassignedNodesExecludingPrimary = new HashSet<>(unassignedNodes); - unassignedNodesExecludingPrimary.remove(newNode(0).id()); + unassignedNodesExecludingPrimary.remove(newNode(0).getId()); primaryNode = selectAndRemove(unassignedNodesExecludingPrimary); } if (primaryState == ShardRoutingState.RELOCATING) { @@ -154,8 +154,8 @@ public class ClusterStateCreationUtils { final DiscoveryNode node = newNode(i); discoBuilder = discoBuilder.put(node); } - discoBuilder.localNodeId(newNode(0).id()); - discoBuilder.masterNodeId(newNode(1).id()); // we need a non-local master to test shard failures + discoBuilder.localNodeId(newNode(0).getId()); + discoBuilder.masterNodeId(newNode(1).getId()); // we need a non-local master to test shard failures IndexMetaData indexMetaData = IndexMetaData.builder(index).settings(Settings.builder() .put(SETTING_VERSION_CREATED, Version.CURRENT) .put(SETTING_NUMBER_OF_SHARDS, numberOfShards).put(SETTING_NUMBER_OF_REPLICAS, 1) @@ -169,9 +169,9 @@ public class ClusterStateCreationUtils { routing.addAsNew(indexMetaData); final ShardId shardId = new ShardId(index, "_na_", i); IndexShardRoutingTable.Builder indexShardRoutingBuilder = new IndexShardRoutingTable.Builder(shardId); - indexShardRoutingBuilder.addShard(TestShardRouting.newShardRouting(index, i, newNode(0).id(), null, null, true, + indexShardRoutingBuilder.addShard(TestShardRouting.newShardRouting(index, i, newNode(0).getId(), null, null, true, ShardRoutingState.STARTED, null)); - indexShardRoutingBuilder.addShard(TestShardRouting.newShardRouting(index, i, newNode(1).id(), null, null, false, + indexShardRoutingBuilder.addShard(TestShardRouting.newShardRouting(index, i, newNode(1).getId(), null, null, false, ShardRoutingState.STARTED, null)); indexRoutingTableBuilder.addIndexShard(indexShardRoutingBuilder.build()); } @@ -221,8 +221,8 @@ public class ClusterStateCreationUtils { public static ClusterState stateWithNoShard() { int numberOfNodes = 2; DiscoveryNodes.Builder discoBuilder = DiscoveryNodes.builder(); - discoBuilder.localNodeId(newNode(0).id()); - discoBuilder.masterNodeId(newNode(1).id()); + discoBuilder.localNodeId(newNode(0).getId()); + discoBuilder.masterNodeId(newNode(1).getId()); ClusterState.Builder state = ClusterState.builder(new ClusterName("test")); state.nodes(discoBuilder); state.metaData(MetaData.builder().generateClusterUuidIfNeeded()); @@ -244,9 +244,9 @@ public class ClusterStateCreationUtils { discoBuilder.put(node); } if (masterNode != null) { - discoBuilder.masterNodeId(masterNode.id()); + discoBuilder.masterNodeId(masterNode.getId()); } - discoBuilder.localNodeId(localNode.id()); + discoBuilder.localNodeId(localNode.getId()); ClusterState.Builder state = ClusterState.builder(new ClusterName("test")); state.nodes(discoBuilder); diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java index 4c148d7923e..306ba2b787f 100644 --- a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java @@ -768,7 +768,7 @@ public class TransportReplicationActionTests extends ESTestCase { assertEquals(1, shardFailedRequests.length); CapturingTransport.CapturedRequest shardFailedRequest = shardFailedRequests[0]; // get the shard the request was sent to - ShardRouting routing = clusterService.state().getRoutingNodes().node(capturedRequest.node.id()).get(request.shardId.id()); + ShardRouting routing = clusterService.state().getRoutingNodes().node(capturedRequest.node.getId()).get(request.shardId.id()); // and the shard that was requested to be failed ShardStateAction.ShardRoutingEntry shardRoutingEntry = (ShardStateAction.ShardRoutingEntry) shardFailedRequest.request; // the shard the request was sent to and the shard to be failed should be the same diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java index bd1bd83ef8f..2d1d7fe71af 100644 --- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java +++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java @@ -72,7 +72,7 @@ public class TransportClientIT extends ESIntegTestCase { } for (DiscoveryNode discoveryNode : nodeService.listedNodes()) { - assertThat(discoveryNode.id(), startsWith("#transport#-")); + assertThat(discoveryNode.getId(), startsWith("#transport#-")); assertThat(discoveryNode.getVersion(), equalTo(Version.CURRENT.minimumCompatibilityVersion())); } diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java index 0745bd38804..7a3ee125465 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java @@ -74,7 +74,7 @@ public class ClusterStateDiffIT extends ESIntegTestCase { emptyMap(), emptySet(), Version.CURRENT); DiscoveryNode otherNode = new DiscoveryNode("other", new LocalTransportAddress("other"), emptyMap(), emptySet(), Version.CURRENT); - DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().put(masterNode).put(otherNode).localNodeId(masterNode.id()).build(); + DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().put(masterNode).put(otherNode).localNodeId(masterNode.getId()).build(); ClusterState clusterState = ClusterState.builder(new ClusterName("test")).nodes(discoveryNodes).build(); ClusterState clusterStateFromDiffs = ClusterState.Builder.fromBytes(ClusterState.Builder.toBytes(clusterState), otherNode); diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java index 0ffbf617f27..92be2331a8c 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java @@ -36,9 +36,9 @@ public class ClusterStateTests extends ESTestCase { final DiscoveryNodes nodes = DiscoveryNodes.builder().put(node1).put(node2).build(); ClusterState noMaster1 = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(nodes).build(); ClusterState noMaster2 = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(nodes).build(); - ClusterState withMaster1a = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.id())).build(); - ClusterState withMaster1b = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.id())).build(); - ClusterState withMaster2 = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node2.id())).build(); + ClusterState withMaster1a = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.getId())).build(); + ClusterState withMaster1b = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.getId())).build(); + ClusterState withMaster2 = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node2.getId())).build(); // states with no master should never supersede anything assertFalse(noMaster1.supersedes(noMaster2)); diff --git a/core/src/test/java/org/elasticsearch/cluster/ack/AckClusterUpdateSettingsIT.java b/core/src/test/java/org/elasticsearch/cluster/ack/AckClusterUpdateSettingsIT.java index 03cfbf2b307..279e40bbc59 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ack/AckClusterUpdateSettingsIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/ack/AckClusterUpdateSettingsIT.java @@ -84,7 +84,7 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase { String excludedNodeId = null; for (NodeInfo nodeInfo : nodesInfo) { if (nodeInfo.getNode().isDataNode()) { - excludedNodeId = nodeInfo.getNode().id(); + excludedNodeId = nodeInfo.getNode().getId(); break; } } @@ -102,7 +102,7 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { assert clusterState.nodes() != null; - if (shardRouting.unassigned() == false && clusterState.nodes().get(shardRouting.currentNodeId()).id().equals(excludedNodeId)) { + if (shardRouting.unassigned() == false && clusterState.nodes().get(shardRouting.currentNodeId()).getId().equals(excludedNodeId)) { //if the shard is still there it must be relocating and all nodes need to know, since the request was acknowledged //reroute happens as part of the update settings and we made sure no throttling comes into the picture via settings assertThat(shardRouting.relocating(), equalTo(true)); @@ -127,7 +127,7 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase { String excludedNodeId = null; for (NodeInfo nodeInfo : nodesInfo) { if (nodeInfo.getNode().isDataNode()) { - excludedNodeId = nodeInfo.getNode().id(); + excludedNodeId = nodeInfo.getNode().getId(); break; } } 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 be8984830e4..561b51de1e9 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.id()); + masterBuilder.masterNodeId(clusterService.state().nodes().masterNodes().iterator().next().value.getId()); setState(clusterService, ClusterState.builder(clusterService.state()).nodes(masterBuilder)); }); diff --git a/core/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java b/core/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java index 2016175a49c..1021cdbf848 100644 --- a/core/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java @@ -22,10 +22,8 @@ package org.elasticsearch.cluster.allocation; import org.apache.lucene.util.IOUtils; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse; -import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.health.ClusterHealthStatus; -import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRoutingState; @@ -107,7 +105,7 @@ public class ClusterRerouteIT extends ESIntegTestCase { .setDryRun(true) .execute().actionGet().getState(); assertThat(state.getRoutingNodes().unassigned().size(), equalTo(1)); - assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).id()).get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); + assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).getId()).get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); logger.info("--> get the state, verify nothing changed because of the dry run"); state = client().admin().cluster().prepareState().execute().actionGet().getState(); @@ -119,7 +117,7 @@ public class ClusterRerouteIT extends ESIntegTestCase { .add(new AllocateEmptyPrimaryAllocationCommand("test", 0, node_1, true)) .execute().actionGet().getState(); assertThat(state.getRoutingNodes().unassigned().size(), equalTo(1)); - assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).id()).get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); + assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).getId()).get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); @@ -127,7 +125,7 @@ public class ClusterRerouteIT extends ESIntegTestCase { logger.info("--> get the state, verify shard 1 primary allocated"); state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.getRoutingNodes().unassigned().size(), equalTo(1)); - assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).id()).get(0).state(), equalTo(ShardRoutingState.STARTED)); + assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).getId()).get(0).state(), equalTo(ShardRoutingState.STARTED)); logger.info("--> move shard 1 primary from node1 to node2"); state = client().admin().cluster().prepareReroute() @@ -135,8 +133,8 @@ public class ClusterRerouteIT extends ESIntegTestCase { .add(new MoveAllocationCommand("test", 0, node_1, node_2)) .execute().actionGet().getState(); - assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).id()).get(0).state(), equalTo(ShardRoutingState.RELOCATING)); - assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_2).id()).get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); + assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).getId()).get(0).state(), equalTo(ShardRoutingState.RELOCATING)); + assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_2).getId()).get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); healthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().setWaitForRelocatingShards(0).execute().actionGet(); @@ -145,7 +143,7 @@ public class ClusterRerouteIT extends ESIntegTestCase { logger.info("--> get the state, verify shard 1 primary moved from node1 to node2"); state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.getRoutingNodes().unassigned().size(), equalTo(1)); - assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_2).id()).get(0).state(), equalTo(ShardRoutingState.STARTED)); + assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_2).getId()).get(0).state(), equalTo(ShardRoutingState.STARTED)); } public void testRerouteWithAllocateLocalGateway_disableAllocationSettings() throws Exception { @@ -218,7 +216,7 @@ public class ClusterRerouteIT extends ESIntegTestCase { .add(new AllocateEmptyPrimaryAllocationCommand("test", 0, node_1, true)) .execute().actionGet().getState(); assertThat(state.getRoutingNodes().unassigned().size(), equalTo(1)); - assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).id()).get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); + assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).getId()).get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); healthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); @@ -226,7 +224,7 @@ public class ClusterRerouteIT extends ESIntegTestCase { logger.info("--> get the state, verify shard 1 primary allocated"); state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.getRoutingNodes().unassigned().size(), equalTo(1)); - assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).id()).get(0).state(), equalTo(ShardRoutingState.STARTED)); + assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).getId()).get(0).state(), equalTo(ShardRoutingState.STARTED)); client().prepareIndex("test", "type", "1").setSource("field", "value").setRefresh(true).execute().actionGet(); final Index index = resolveIndex("test"); @@ -253,7 +251,7 @@ public class ClusterRerouteIT extends ESIntegTestCase { .add(new AllocateEmptyPrimaryAllocationCommand("test", 0, node_1, true)) .execute().actionGet().getState(); assertThat(state.getRoutingNodes().unassigned().size(), equalTo(1)); - assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).id()).get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); + assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).getId()).get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); healthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); @@ -261,7 +259,7 @@ public class ClusterRerouteIT extends ESIntegTestCase { logger.info("--> get the state, verify shard 1 primary allocated"); state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.getRoutingNodes().unassigned().size(), equalTo(1)); - assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).id()).get(0).state(), equalTo(ShardRoutingState.STARTED)); + assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_1).getId()).get(0).state(), equalTo(ShardRoutingState.STARTED)); } diff --git a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java index 77ffb371cba..7836fb759e4 100644 --- a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java @@ -41,8 +41,8 @@ public class DiscoveryNodesTests extends ESTestCase { DiscoveryNodes discoveryNodes = buildDiscoveryNodes(); DiscoveryNode[] nodes = discoveryNodes.nodes().values().toArray(DiscoveryNode.class); DiscoveryNode node = randomFrom(nodes); - DiscoveryNode resolvedNode = discoveryNodes.resolveNode(randomBoolean() ? node.id() : node.name()); - assertThat(resolvedNode.id(), equalTo(node.id())); + DiscoveryNode resolvedNode = discoveryNodes.resolveNode(randomBoolean() ? node.getId() : node.name()); + assertThat(resolvedNode.getId(), equalTo(node.getId())); } public void testResolveNodeByAttribute() { @@ -52,7 +52,7 @@ public class DiscoveryNodesTests extends ESTestCase { try { DiscoveryNode resolvedNode = discoveryNodes.resolveNode(nodeSelector.selector); assertThat(matchingNodeIds.size(), equalTo(1)); - assertThat(resolvedNode.id(), equalTo(matchingNodeIds.iterator().next())); + assertThat(resolvedNode.getId(), equalTo(matchingNodeIds.iterator().next())); } catch(IllegalArgumentException e) { if (matchingNodeIds.size() == 0) { assertThat(e.getMessage(), equalTo("failed to resolve [" + nodeSelector.selector + "], no matching nodes")); @@ -88,7 +88,7 @@ public class DiscoveryNodesTests extends ESTestCase { for (int i = 0; i < numNodeNames; i++) { DiscoveryNode discoveryNode = randomFrom(nodes); nodeSelectors.add(discoveryNode.name()); - expectedNodeIdsSet.add(discoveryNode.id()); + expectedNodeIdsSet.add(discoveryNode.getId()); } String[] resolvedNodesIds = discoveryNodes.resolveNodesIds(nodeSelectors.toArray(new String[nodeSelectors.size()])); @@ -111,8 +111,8 @@ public class DiscoveryNodesTests extends ESTestCase { discoBuilder = discoBuilder.put(node); nodesList.add(node); } - discoBuilder.localNodeId(randomFrom(nodesList).id()); - discoBuilder.masterNodeId(randomFrom(nodesList).id()); + discoBuilder.localNodeId(randomFrom(nodesList).getId()); + discoBuilder.masterNodeId(randomFrom(nodesList).getId()); return discoBuilder.build(); } @@ -158,7 +158,7 @@ public class DiscoveryNodesTests extends ESTestCase { Set ids = new HashSet<>(); nodes.getNodes().valuesIt().forEachRemaining(node -> { if ("value".equals(node.getAttributes().get("attr"))) { - ids.add(node.id()); + ids.add(node.getId()); } }); return ids; diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java index 1c5f77ce408..c579752d681 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java @@ -389,7 +389,7 @@ public class AddIncrementallyTests extends ESAllocationTestCase { ArrayList discoveryNodes = CollectionUtils.iterableAsArrayList(clusterState.nodes()); Collections.shuffle(discoveryNodes, random()); for (DiscoveryNode node : discoveryNodes) { - nodes.remove(node.id()); + nodes.remove(node.getId()); numNodes--; if (numNodes <= 0) { break; diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java index 1296dfdad18..ab3eb45ef7e 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java @@ -319,14 +319,14 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase { RoutingTable routingTable = RoutingTable.builder() .add(IndexRoutingTable.builder(shard1.getIndex()) .addIndexShard(new IndexShardRoutingTable.Builder(shard1) - .addShard(TestShardRouting.newShardRouting(shard1.getIndexName(), shard1.getId(), newNode.id(), true, ShardRoutingState.STARTED)) - .addShard(TestShardRouting.newShardRouting(shard1.getIndexName(), shard1.getId(), oldNode1.id(), false, ShardRoutingState.STARTED)) + .addShard(TestShardRouting.newShardRouting(shard1.getIndexName(), shard1.getId(), newNode.getId(), true, ShardRoutingState.STARTED)) + .addShard(TestShardRouting.newShardRouting(shard1.getIndexName(), shard1.getId(), oldNode1.getId(), false, ShardRoutingState.STARTED)) .build()) ) .add(IndexRoutingTable.builder(shard2.getIndex()) .addIndexShard(new IndexShardRoutingTable.Builder(shard2) - .addShard(TestShardRouting.newShardRouting(shard2.getIndexName(), shard2.getId(), newNode.id(), true, ShardRoutingState.STARTED)) - .addShard(TestShardRouting.newShardRouting(shard2.getIndexName(), shard2.getId(), oldNode1.id(), false, ShardRoutingState.STARTED)) + .addShard(TestShardRouting.newShardRouting(shard2.getIndexName(), shard2.getId(), newNode.getId(), true, ShardRoutingState.STARTED)) + .addShard(TestShardRouting.newShardRouting(shard2.getIndexName(), shard2.getId(), oldNode1.getId(), false, ShardRoutingState.STARTED)) .build()) ) .build(); diff --git a/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java b/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java index bfa7f31fdaf..bedbbbd5391 100644 --- a/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java @@ -122,8 +122,8 @@ public class ZenFaultDetectionTests extends ESTestCase { DiscoveryNodes.Builder builder = DiscoveryNodes.builder(); builder.put(nodeA); builder.put(nodeB); - builder.localNodeId(nodeA.id()); - builder.masterNodeId(master ? nodeA.id() : nodeB.id()); + builder.localNodeId(nodeA.getId()); + builder.masterNodeId(master ? nodeA.getId() : nodeB.getId()); return builder.build(); } @@ -131,8 +131,8 @@ public class ZenFaultDetectionTests extends ESTestCase { DiscoveryNodes.Builder builder = DiscoveryNodes.builder(); builder.put(nodeA); builder.put(nodeB); - builder.localNodeId(nodeB.id()); - builder.masterNodeId(master ? nodeB.id() : nodeA.id()); + builder.localNodeId(nodeB.getId()); + builder.masterNodeId(master ? nodeB.getId() : nodeA.getId()); return builder.build(); } diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java index c279cad910e..3025866e061 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java @@ -68,7 +68,7 @@ public class ElectMasterServiceTests extends ESTestCase { if (!prevNode.masterNode()) { assertFalse(node.masterNode()); } else if (node.masterNode()) { - assertTrue(prevNode.id().compareTo(node.id()) < 0); + assertTrue(prevNode.getId().compareTo(node.getId()) < 0); } prevNode = node; } @@ -100,7 +100,7 @@ public class ElectMasterServiceTests extends ESTestCase { assertNotNull(master); for (DiscoveryNode node : nodes) { if (node.masterNode()) { - assertTrue(master.id().compareTo(node.id()) <= 0); + assertTrue(master.getId().compareTo(node.getId()) <= 0); } } } diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java index ec760661658..b924f52a68f 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java @@ -97,7 +97,7 @@ public class NodeJoinControllerTests extends ESTestCase { final DiscoveryNode localNode = initialNodes.localNode(); // make sure we have a master setState(clusterService, ClusterState.builder(clusterService.state()).nodes( - DiscoveryNodes.builder(initialNodes).masterNodeId(localNode.id()))); + DiscoveryNodes.builder(initialNodes).masterNodeId(localNode.getId()))); nodeJoinController = new NodeJoinController(clusterService, new NoopRoutingService(Settings.EMPTY), new DiscoverySettings(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), Settings.EMPTY); @@ -555,7 +555,7 @@ public class NodeJoinControllerTests extends ESTestCase { logger.info("assert for [{}] in:\n{}", expectedNodes, state.prettyPrint()); DiscoveryNodes discoveryNodes = state.nodes(); for (DiscoveryNode node : expectedNodes) { - assertThat("missing " + node + "\n" + discoveryNodes.prettyPrint(), discoveryNodes.get(node.id()), equalTo(node)); + assertThat("missing " + node + "\n" + discoveryNodes.prettyPrint(), discoveryNodes.get(node.getId()), equalTo(node)); } assertThat(discoveryNodes.size(), equalTo(expectedNodes.size())); } diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ZenPingTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/ZenPingTests.java index d7ed66f94d6..90b31ff3342 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/ZenPingTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/ZenPingTests.java @@ -72,7 +72,7 @@ public class ZenPingTests extends ESTestCase { ZenPing.PingResponse[] aggregate = collection.toArray(); for (ZenPing.PingResponse ping : aggregate) { - int nodeId = Integer.parseInt(ping.node().id()); + int nodeId = Integer.parseInt(ping.node().getId()); assertThat(maxIdPerNode[nodeId], equalTo(ping.id())); assertThat(masterPerNode[nodeId], equalTo(ping.master())); assertThat(hasJoinedOncePerNode[nodeId], equalTo(ping.hasJoinedOnce())); diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingIT.java b/core/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingIT.java index 751a575b445..26bd0409836 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingIT.java @@ -110,14 +110,14 @@ public class UnicastZenPingIT extends ESTestCase { logger.info("ping from UZP_A"); ZenPing.PingResponse[] pingResponses = zenPingA.pingAndWait(TimeValue.timeValueSeconds(10)); assertThat(pingResponses.length, equalTo(1)); - assertThat(pingResponses[0].node().id(), equalTo("UZP_B")); + assertThat(pingResponses[0].node().getId(), equalTo("UZP_B")); assertTrue(pingResponses[0].hasJoinedOnce()); // ping again, this time from B, logger.info("ping from UZP_B"); pingResponses = zenPingB.pingAndWait(TimeValue.timeValueSeconds(10)); assertThat(pingResponses.length, equalTo(1)); - assertThat(pingResponses[0].node().id(), equalTo("UZP_A")); + assertThat(pingResponses[0].node().getId(), equalTo("UZP_A")); assertFalse(pingResponses[0].hasJoinedOnce()); } finally { diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java index 0fa844b0e56..f5904cc79bd 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java @@ -97,11 +97,11 @@ public class PublishClusterStateActionTests extends ESTestCase { this.service = service; this.listener = listener; this.logger = logger; - this.clusterState = ClusterState.builder(ClusterName.DEFAULT).nodes(DiscoveryNodes.builder().put(discoveryNode).localNodeId(discoveryNode.id()).build()).build(); + this.clusterState = ClusterState.builder(ClusterName.DEFAULT).nodes(DiscoveryNodes.builder().put(discoveryNode).localNodeId(discoveryNode.getId()).build()).build(); } public MockNode setAsMaster() { - this.clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).masterNodeId(discoveryNode.id())).build(); + this.clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).masterNodeId(discoveryNode.getId())).build(); return this; } @@ -306,8 +306,8 @@ public class PublishClusterStateActionTests extends ESTestCase { .put(nodeA.discoveryNode) .put(nodeB.discoveryNode) .put(nodeC.discoveryNode) - .masterNodeId(nodeB.discoveryNode.id()) - .localNodeId(nodeB.discoveryNode.id()) + .masterNodeId(nodeB.discoveryNode.getId()) + .localNodeId(nodeB.discoveryNode.getId()) .build(); previousClusterState = ClusterState.builder(new ClusterName("test")).nodes(discoveryNodes).build(); clusterState = ClusterState.builder(clusterState).nodes(discoveryNodes).incrementVersion().build(); @@ -358,7 +358,7 @@ public class PublishClusterStateActionTests extends ESTestCase { }); // Initial cluster state - DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().put(nodeA.discoveryNode).localNodeId(nodeA.discoveryNode.id()).masterNodeId(nodeA.discoveryNode.id()).build(); + DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().put(nodeA.discoveryNode).localNodeId(nodeA.discoveryNode.getId()).masterNodeId(nodeA.discoveryNode.getId()).build(); ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).nodes(discoveryNodes).build(); // cluster state update - add nodeB @@ -485,7 +485,7 @@ public class PublishClusterStateActionTests extends ESTestCase { for (int i = 0; i < dataNodes; i++) { discoveryNodesBuilder.put(createMockNode("data_" + i, dataSettings).discoveryNode); } - discoveryNodesBuilder.localNodeId(master.discoveryNode.id()).masterNodeId(master.discoveryNode.id()); + discoveryNodesBuilder.localNodeId(master.discoveryNode.getId()).masterNodeId(master.discoveryNode.getId()); DiscoveryNodes discoveryNodes = discoveryNodesBuilder.build(); MetaData metaData = MetaData.EMPTY_META_DATA; ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).nodes(discoveryNodes).build(); @@ -562,7 +562,7 @@ public class PublishClusterStateActionTests extends ESTestCase { logger.info("--> expecting commit to {}. good nodes [{}], errors [{}], timeouts [{}]. min_master_nodes [{}]", expectedBehavior, goodNodes + 1, errorNodes, timeOutNodes, minMasterNodes); - discoveryNodesBuilder.localNodeId(master.discoveryNode.id()).masterNodeId(master.discoveryNode.id()); + discoveryNodesBuilder.localNodeId(master.discoveryNode.getId()).masterNodeId(master.discoveryNode.getId()); DiscoveryNodes discoveryNodes = discoveryNodesBuilder.build(); MetaData metaData = MetaData.EMPTY_META_DATA; ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).nodes(discoveryNodes).build(); @@ -623,7 +623,7 @@ public class PublishClusterStateActionTests extends ESTestCase { try { MockNode otherNode = createMockNode("otherNode"); state = ClusterState.builder(node.clusterState).nodes( - DiscoveryNodes.builder(node.nodes()).put(otherNode.discoveryNode).localNodeId(otherNode.discoveryNode.id()).build() + DiscoveryNodes.builder(node.nodes()).put(otherNode.discoveryNode).localNodeId(otherNode.discoveryNode.getId()).build() ).incrementVersion().build(); node.action.validateIncomingState(state, node.clusterState); fail("node accepted state with existent but wrong local node"); @@ -696,7 +696,7 @@ public class PublishClusterStateActionTests extends ESTestCase { MockNode master = createMockNode("master", settings); MockNode node = createMockNode("node", settings); ClusterState state = ClusterState.builder(master.clusterState) - .nodes(DiscoveryNodes.builder(master.clusterState.nodes()).put(node.discoveryNode).masterNodeId(master.discoveryNode.id())).build(); + .nodes(DiscoveryNodes.builder(master.clusterState.nodes()).put(node.discoveryNode).masterNodeId(master.discoveryNode.getId())).build(); for (int i = 0; i < 10; i++) { state = ClusterState.builder(state).incrementVersion().build(); diff --git a/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java b/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java index 572b87dfa6b..1c63cda4174 100644 --- a/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java +++ b/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java @@ -135,7 +135,7 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase { assertThat(changed, equalTo(true)); assertThat(allocation.routingNodes().unassigned().ignored().isEmpty(), equalTo(true)); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node1.id())); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node1.getId())); } /** @@ -173,7 +173,7 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase { assertThat(changed, equalTo(true)); assertThat(allocation.routingNodes().unassigned().ignored().isEmpty(), equalTo(true)); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node1.id())); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node1.getId())); if (useAllocationIds) { // check that allocation id is reused assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).allocationId().getId(), equalTo("allocId1")); @@ -195,7 +195,7 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase { assertThat(allocation.routingNodes().unassigned().ignored().isEmpty(), equalTo(true)); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); DiscoveryNode allocatedNode = node1HasPrimaryShard ? node1 : node2; - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(allocatedNode.id())); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(allocatedNode.getId())); } /** @@ -234,7 +234,7 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase { assertThat(changed, equalTo(true)); assertThat(allocation.routingNodes().unassigned().ignored().isEmpty(), equalTo(true)); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node1.id())); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node1.getId())); } /** @@ -247,7 +247,7 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase { assertThat(changed, equalTo(true)); assertThat(allocation.routingNodes().unassigned().ignored().isEmpty(), equalTo(true)); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node2.id())); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node2.getId())); } /** @@ -265,7 +265,7 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase { assertThat(changed, equalTo(true)); assertThat(allocation.routingNodes().unassigned().ignored().isEmpty(), equalTo(true)); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node2.id())); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node2.getId())); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).allocationId().getId(), equalTo("some allocId")); } @@ -466,7 +466,7 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase { assertThat(allocation.routingNodes().unassigned().ignored().size(), equalTo(0)); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.UNASSIGNED).size(), equalTo(2)); // replicas assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), anyOf(equalTo(node2.id()), equalTo(node1.id()))); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), anyOf(equalTo(node2.getId()), equalTo(node1.getId()))); } /** @@ -507,7 +507,7 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase { assertThat(allocation.routingNodes().unassigned().ignored().size(), equalTo(0)); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.UNASSIGNED).size(), equalTo(2)); // replicas assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node2.id())); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node2.getId())); } private RoutingAllocation routingAllocationWithOnePrimaryNoReplicas(AllocationDeciders deciders, boolean asNew, Version version, String... activeAllocationIds) { diff --git a/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java b/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java index a4a62a8f5e0..113dcdaaf3a 100644 --- a/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java +++ b/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java @@ -122,7 +122,7 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase { .addData(nodeToMatch, false, "MATCH", new StoreFileMetaData("file1", 10, "MATCH_CHECKSUM")); testAllocator.allocateUnassigned(allocation); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(nodeToMatch.id())); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(nodeToMatch.getId())); } /** @@ -135,7 +135,7 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase { .addData(nodeToMatch, false, "MATCH", new StoreFileMetaData("file1", 10, "NO_MATCH_CHECKSUM")); testAllocator.allocateUnassigned(allocation); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(nodeToMatch.id())); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(nodeToMatch.getId())); } /** @@ -148,7 +148,7 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase { .addData(nodeToMatch, false, "NO_MATCH", new StoreFileMetaData("file1", 10, "MATCH_CHECKSUM")); testAllocator.allocateUnassigned(allocation); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(nodeToMatch.id())); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(nodeToMatch.getId())); } /** @@ -246,7 +246,7 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase { changed = testAllocator.allocateUnassigned(allocation); assertThat(changed, equalTo(true)); assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(1)); - assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node2.id())); + assertThat(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo(node2.getId())); } public void testCancelRecoveryBetterSyncId() { @@ -284,7 +284,7 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase { } private RoutingAllocation onePrimaryOnNode1And1Replica(AllocationDeciders deciders, Settings settings, UnassignedInfo.Reason reason) { - ShardRouting primaryShard = TestShardRouting.newShardRouting(shardId.getIndex(), shardId.getId(), node1.id(), true, ShardRoutingState.STARTED); + ShardRouting primaryShard = TestShardRouting.newShardRouting(shardId.getIndex(), shardId.getId(), node1.getId(), true, ShardRoutingState.STARTED); MetaData metaData = MetaData.builder() .put(IndexMetaData.builder(shardId.getIndexName()).settings(settings(Version.CURRENT).put(settings)) .numberOfShards(1).numberOfReplicas(1) @@ -306,7 +306,7 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase { } private RoutingAllocation onePrimaryOnNode1And1ReplicaRecovering(AllocationDeciders deciders) { - ShardRouting primaryShard = TestShardRouting.newShardRouting(shardId.getIndex(), shardId.getId(), node1.id(), true, ShardRoutingState.STARTED); + ShardRouting primaryShard = TestShardRouting.newShardRouting(shardId.getIndex(), shardId.getId(), node1.getId(), true, ShardRoutingState.STARTED); MetaData metaData = MetaData.builder() .put(IndexMetaData.builder(shardId.getIndexName()).settings(settings(Version.CURRENT)) .numberOfShards(1).numberOfReplicas(1) @@ -316,7 +316,7 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase { .add(IndexRoutingTable.builder(shardId.getIndex()) .addIndexShard(new IndexShardRoutingTable.Builder(shardId) .addShard(primaryShard) - .addShard(TestShardRouting.newShardRouting(shardId.getIndex(), shardId.getId(), node2.id(), null, null, false, ShardRoutingState.INITIALIZING, new UnassignedInfo(UnassignedInfo.Reason.CLUSTER_RECOVERED, null))) + .addShard(TestShardRouting.newShardRouting(shardId.getIndex(), shardId.getId(), node2.getId(), null, null, false, ShardRoutingState.INITIALIZING, new UnassignedInfo(UnassignedInfo.Reason.CLUSTER_RECOVERED, null))) .build()) ) .build(); diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java index 140ff153b9f..286781b5bca 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java @@ -561,7 +561,7 @@ public class IndexRecoveryIT extends ESIntegTestCase { ensureSearchable(indexName); ClusterStateResponse stateResponse = client().admin().cluster().prepareState().get(); - final String blueNodeId = internalCluster().getInstance(ClusterService.class, blueNodeName).localNode().id(); + final String blueNodeId = internalCluster().getInstance(ClusterService.class, blueNodeName).localNode().getId(); assertFalse(stateResponse.getState().getRoutingNodes().node(blueNodeId).isEmpty()); diff --git a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java index 84d86324fee..15232ded102 100644 --- a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java @@ -381,8 +381,8 @@ public class IndicesStoreIntegrationIT extends ESIntegTestCase { final String masterNode = internalCluster().getMasterName(); final String nonMasterNode = nodes.get(0).equals(masterNode) ? nodes.get(1) : nodes.get(0); - final String masterId = internalCluster().clusterService(masterNode).localNode().id(); - final String nonMasterId = internalCluster().clusterService(nonMasterNode).localNode().id(); + final String masterId = internalCluster().clusterService(masterNode).localNode().getId(); + final String nonMasterId = internalCluster().clusterService(nonMasterNode).localNode().getId(); final int numShards = scaledRandomIntBetween(2, 10); assertAcked(prepareCreate("test") diff --git a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java index bab0cd9b6c5..721c66c04e1 100644 --- a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java +++ b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java @@ -140,7 +140,7 @@ public class IndicesStoreTests extends ESTestCase { ClusterState.Builder clusterState = ClusterState.builder(new ClusterName("test")); clusterState.metaData(MetaData.builder().put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(numShards).numberOfReplicas(numReplicas))); - clusterState.nodes(DiscoveryNodes.builder().localNodeId(localNode.id()).put(localNode).put(new DiscoveryNode("xyz", + clusterState.nodes(DiscoveryNodes.builder().localNodeId(localNode.getId()).put(localNode).put(new DiscoveryNode("xyz", new LocalTransportAddress("xyz"), emptyMap(), emptySet(), Version.CURRENT))); IndexShardRoutingTable.Builder routingTable = new IndexShardRoutingTable.Builder(new ShardId("test", "_na_", 1)); int localShardId = randomInt(numShards - 1); @@ -163,7 +163,7 @@ public class IndicesStoreTests extends ESTestCase { ClusterState.Builder clusterState = ClusterState.builder(new ClusterName("test")); clusterState.metaData(MetaData.builder().put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(numShards).numberOfReplicas(numReplicas))); - clusterState.nodes(DiscoveryNodes.builder().localNodeId(localNode.id()).put(localNode)); + clusterState.nodes(DiscoveryNodes.builder().localNodeId(localNode.getId()).put(localNode)); IndexShardRoutingTable.Builder routingTable = new IndexShardRoutingTable.Builder(new ShardId("test", "_na_", 1)); for (int i = 0; i < numShards; i++) { String relocatingNodeId = randomBoolean() ? null : "def"; @@ -185,7 +185,7 @@ public class IndicesStoreTests extends ESTestCase { final Version nodeVersion = randomBoolean() ? CURRENT : randomVersion(random()); ClusterState.Builder clusterState = ClusterState.builder(new ClusterName("test")); clusterState.metaData(MetaData.builder().put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(numShards).numberOfReplicas(numReplicas))); - clusterState.nodes(DiscoveryNodes.builder().localNodeId(localNode.id()).put(localNode).put(new DiscoveryNode("xyz", + clusterState.nodes(DiscoveryNodes.builder().localNodeId(localNode.getId()).put(localNode).put(new DiscoveryNode("xyz", new LocalTransportAddress("xyz"), emptyMap(), emptySet(), nodeVersion))); IndexShardRoutingTable.Builder routingTable = new IndexShardRoutingTable.Builder(new ShardId("test", "_na_", 1)); for (int i = 0; i < numShards; i++) { @@ -207,7 +207,7 @@ public class IndicesStoreTests extends ESTestCase { clusterState.metaData(MetaData.builder().put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(numShards).numberOfReplicas(numReplicas))); final Version nodeVersion = randomBoolean() ? CURRENT : randomVersion(random()); - clusterState.nodes(DiscoveryNodes.builder().localNodeId(localNode.id()) + clusterState.nodes(DiscoveryNodes.builder().localNodeId(localNode.getId()) .put(localNode) .put(new DiscoveryNode("xyz", new LocalTransportAddress("xyz"), emptyMap(), emptySet(), Version.CURRENT)) .put(new DiscoveryNode("def", new LocalTransportAddress("def"), emptyMap(), emptySet(), nodeVersion) // <-- only set relocating, since we're testing that in this test diff --git a/test/framework/src/main/java/org/elasticsearch/test/transport/CapturingTransport.java b/test/framework/src/main/java/org/elasticsearch/test/transport/CapturingTransport.java index 48d79ef064b..ebdd1da3987 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/transport/CapturingTransport.java +++ b/test/framework/src/main/java/org/elasticsearch/test/transport/CapturingTransport.java @@ -93,10 +93,10 @@ public class CapturingTransport implements Transport { public Map> capturedRequestsByTargetNode() { Map> map = new HashMap<>(); for (CapturedRequest request : capturedRequests) { - List nodeList = map.get(request.node.id()); + List nodeList = map.get(request.node.getId()); if (nodeList == null) { nodeList = new ArrayList<>(); - map.put(request.node.id(), nodeList); + map.put(request.node.getId(), nodeList); } nodeList.add(request); } From a8bbdff3bc896d0e873b53afaabc8da74fe00bc1 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 14:47:36 +0200 Subject: [PATCH 02/25] Remove DiscoveryNode#name in favour of existing DiscoveryNode#getName --- .../cluster/node/info/NodesInfoResponse.java | 2 +- .../admin/cluster/node/stats/NodeStats.java | 2 +- .../node/tasks/list/ListTasksResponse.java | 2 +- .../verify/VerifyRepositoryResponse.java | 2 +- .../TransportClientNodesService.java | 2 +- .../cluster/InternalClusterInfoService.java | 2 +- .../cluster/node/DiscoveryNode.java | 11 ++-------- .../cluster/node/DiscoveryNodeFilters.java | 2 +- .../cluster/node/DiscoveryNodes.java | 2 +- .../decider/DiskThresholdDecider.java | 6 ++--- .../gateway/ReplicaShardAllocator.java | 4 ++-- .../indices/recovery/RecoveryState.java | 4 ++-- .../rest/action/cat/RestAllocationAction.java | 2 +- .../rest/action/cat/RestNodeAttrsAction.java | 2 +- .../rest/action/cat/RestNodesAction.java | 2 +- .../rest/action/cat/RestPluginsAction.java | 2 +- .../rest/action/cat/RestShardsAction.java | 4 ++-- .../transport/ConnectTransportException.java | 2 +- .../ReceiveTimeoutTransportException.java | 2 +- .../SendRequestTransportException.java | 2 +- .../transport/TransportService.java | 2 +- .../org/elasticsearch/tribe/TribeService.java | 2 +- .../admin/cluster/node/tasks/TasksIT.java | 4 ++-- .../shards/IndicesShardStoreRequestIT.java | 2 +- .../BasicBackwardsCompatibilityIT.java | 3 +-- .../cluster/SpecificMasterNodesIT.java | 22 +++++++++---------- .../allocation/AwarenessAllocationIT.java | 12 +++++----- .../allocation/FilteringAllocationIT.java | 6 ++--- .../cluster/node/DiscoveryNodesTests.java | 4 ++-- .../cluster/routing/PrimaryAllocationIT.java | 9 ++++---- .../routing/allocation/ShardStateIT.java | 2 +- .../cluster/service/ClusterServiceIT.java | 2 +- .../DiscoveryWithServiceDisruptionsIT.java | 8 +++---- .../discovery/zen/ZenDiscoveryIT.java | 2 +- .../PublishClusterStateActionTests.java | 2 +- .../gateway/RecoveryFromGatewayIT.java | 4 ++-- .../gateway/ReusePeerRecoverySharedTest.java | 4 ++-- .../index/store/CorruptedFileIT.java | 14 ++++++------ .../index/store/ExceptionRetryIT.java | 4 ++-- .../elasticsearch/indices/flush/FlushIT.java | 2 +- .../indices/recovery/IndexRecoveryIT.java | 16 +++++++------- .../indices/state/RareClusterStateIT.java | 4 ++-- .../recovery/TruncatedRecoveryIT.java | 8 +++---- .../messy/tests/GeoShapeIntegrationTests.java | 2 +- .../test/ESBackcompatTestCase.java | 2 +- .../elasticsearch/test/ESIntegTestCase.java | 4 +--- .../org/elasticsearch/test/ExternalNode.java | 2 +- .../test/InternalTestCluster.java | 2 +- 48 files changed, 99 insertions(+), 110 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java index c22dc616421..9c3c77ee85e 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java @@ -70,7 +70,7 @@ public class NodesInfoResponse extends BaseNodesResponse implements To for (NodeInfo nodeInfo : this) { builder.startObject(nodeInfo.getNode().getId(), XContentBuilder.FieldCaseConversion.NONE); - builder.field("name", nodeInfo.getNode().name(), XContentBuilder.FieldCaseConversion.NONE); + builder.field("name", nodeInfo.getNode().getName(), XContentBuilder.FieldCaseConversion.NONE); builder.field("transport_address", nodeInfo.getNode().address().toString()); builder.field("host", nodeInfo.getNode().getHostName(), XContentBuilder.FieldCaseConversion.NONE); builder.field("ip", nodeInfo.getNode().getHostAddress(), XContentBuilder.FieldCaseConversion.NONE); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java index 214b6f245cd..99fae604a6f 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java @@ -299,7 +299,7 @@ public class NodeStats extends BaseNodeResponse implements ToXContent { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (!params.param("node_info_format", "default").equals("none")) { - builder.field("name", getNode().name(), XContentBuilder.FieldCaseConversion.NONE); + builder.field("name", getNode().getName(), XContentBuilder.FieldCaseConversion.NONE); builder.field("transport_address", getNode().address().toString(), XContentBuilder.FieldCaseConversion.NONE); builder.field("host", getNode().getHostName(), XContentBuilder.FieldCaseConversion.NONE); builder.field("ip", getNode().getAddress(), XContentBuilder.FieldCaseConversion.NONE); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java index 9713a1455a4..a8e833eb46f 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java @@ -124,7 +124,7 @@ public class ListTasksResponse extends BaseTasksResponse implements ToXContent { for (Map.Entry> entry : getPerNodeTasks().entrySet()) { DiscoveryNode node = entry.getKey(); builder.startObject(node.getId(), XContentBuilder.FieldCaseConversion.NONE); - builder.field("name", node.name()); + builder.field("name", node.getName()); builder.field("transport_address", node.address().toString()); builder.field("host", node.getHostName()); builder.field("ip", node.getAddress()); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java index 2b8c6b348b8..ddc2f7035d7 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java @@ -87,7 +87,7 @@ public class VerifyRepositoryResponse extends ActionResponse implements ToXConte builder.startObject(Fields.NODES); for (DiscoveryNode node : nodes) { builder.startObject(node.getId(), XContentBuilder.FieldCaseConversion.NONE); - builder.field(Fields.NAME, node.name(), XContentBuilder.FieldCaseConversion.NONE); + builder.field(Fields.NAME, node.getName(), XContentBuilder.FieldCaseConversion.NONE); builder.endObject(); } builder.endObject(); diff --git a/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java b/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java index 12936321fc0..d94f3bacfc3 100644 --- a/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java +++ b/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java @@ -383,7 +383,7 @@ public class TransportClientNodesService extends AbstractComponent { // use discovered information but do keep the original transport address, // so people can control which address is exactly used. DiscoveryNode nodeWithInfo = livenessResponse.getDiscoveryNode(); - newNodes.add(new DiscoveryNode(nodeWithInfo.name(), nodeWithInfo.getId(), nodeWithInfo.getHostName(), + newNodes.add(new DiscoveryNode(nodeWithInfo.getName(), nodeWithInfo.getId(), nodeWithInfo.getHostName(), nodeWithInfo.getHostAddress(), listedNode.getAddress(), nodeWithInfo.getAttributes(), nodeWithInfo.getRoles(), nodeWithInfo.getVersion())); } else { diff --git a/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java b/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java index 7384c6c7c61..7a0bbb20f21 100644 --- a/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java +++ b/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java @@ -395,7 +395,7 @@ public class InternalClusterInfoService extends AbstractComponent implements Clu ImmutableOpenMap.Builder newMostAvaiableUsages) { for (NodeStats nodeStats : nodeStatsArray) { if (nodeStats.getFs() == null) { - logger.warn("Unable to retrieve node FS stats for {}", nodeStats.getNode().name()); + logger.warn("Unable to retrieve node FS stats for {}", nodeStats.getNode().getName()); } else { FsInfo.Path leastAvailablePath = null; FsInfo.Path mostAvailablePath = null; diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 8a4739bbf7a..6bd1a6ad721 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -228,18 +228,11 @@ public class DiscoveryNode implements Writeable, ToXContent { return nodeId; } - /** - * The name of the node. - */ - public String name() { - return this.nodeName; - } - /** * The name of the node. */ public String getName() { - return name(); + return this.nodeName; } /** @@ -371,7 +364,7 @@ public class DiscoveryNode implements Writeable, ToXContent { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(getId(), XContentBuilder.FieldCaseConversion.NONE); - builder.field("name", name()); + builder.field("name", getName()); builder.field("transport_address", address().toString()); builder.startObject("attributes"); diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java index 86729530a2a..9d45de84445 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java @@ -167,7 +167,7 @@ public class DiscoveryNodeFilters { } } else if ("_name".equals(attr) || "name".equals(attr)) { for (String value : values) { - if (Regex.simpleMatch(value, node.name())) { + if (Regex.simpleMatch(value, node.getName())) { if (opType == OpType.OR) { return true; } 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 46ede31bfde..160026534a1 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -361,7 +361,7 @@ public class DiscoveryNodes extends AbstractDiffable implements } else { // not a node id, try and search by name for (DiscoveryNode node : this) { - if (Regex.simpleMatch(nodeId, node.name())) { + if (Regex.simpleMatch(nodeId, node.getName())) { resolvedNodesIds.add(node.getId()); } } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java index 890bbd3c31d..71968b0743b 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java @@ -519,7 +519,7 @@ public class DiskThresholdDecider extends AllocationDecider { if (includeRelocations) { long relocatingShardsSize = sizeOfRelocatingShards(node, clusterInfo, true, usage.getPath()); - DiskUsage usageIncludingRelocations = new DiskUsage(node.nodeId(), node.node().name(), usage.getPath(), + DiskUsage usageIncludingRelocations = new DiskUsage(node.nodeId(), node.node().getName(), usage.getPath(), usage.getTotalBytes(), usage.getFreeBytes() - relocatingShardsSize); if (logger.isTraceEnabled()) { logger.trace("usage without relocations: {}", usage); @@ -539,7 +539,7 @@ public class DiskThresholdDecider extends AllocationDecider { */ public DiskUsage averageUsage(RoutingNode node, ImmutableOpenMap usages) { if (usages.size() == 0) { - return new DiskUsage(node.nodeId(), node.node().name(), "_na_", 0, 0); + return new DiskUsage(node.nodeId(), node.node().getName(), "_na_", 0, 0); } long totalBytes = 0; long freeBytes = 0; @@ -547,7 +547,7 @@ public class DiskThresholdDecider extends AllocationDecider { totalBytes += du.value.getTotalBytes(); freeBytes += du.value.getFreeBytes(); } - return new DiskUsage(node.nodeId(), node.node().name(), "_na_", totalBytes / usages.size(), freeBytes / usages.size()); + return new DiskUsage(node.nodeId(), node.node().getName(), "_na_", totalBytes / usages.size(), freeBytes / usages.size()); } /** diff --git a/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java b/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java index 533bbffee40..e20988d051e 100644 --- a/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java +++ b/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java @@ -286,7 +286,7 @@ public abstract class ReplicaShardAllocator extends AbstractComponent { String replicaSyncId = storeFilesMetaData.syncId(); // see if we have a sync id we can make use of if (replicaSyncId != null && replicaSyncId.equals(primarySyncId)) { - logger.trace("{}: node [{}] has same sync id {} as primary", shard, discoNode.name(), replicaSyncId); + logger.trace("{}: node [{}] has same sync id {} as primary", shard, discoNode.getName(), replicaSyncId); nodesToSize.put(discoNode, Long.MAX_VALUE); } else { long sizeMatched = 0; @@ -297,7 +297,7 @@ public abstract class ReplicaShardAllocator extends AbstractComponent { } } logger.trace("{}: node [{}] has [{}/{}] bytes of re-usable data", - shard, discoNode.name(), new ByteSizeValue(sizeMatched), sizeMatched); + shard, discoNode.getName(), new ByteSizeValue(sizeMatched), sizeMatched); nodesToSize.put(discoNode, sizeMatched); } } diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java index 7d0c246400d..0a2b970c15a 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java @@ -320,7 +320,7 @@ public class RecoveryState implements ToXContent, Streamable { builder.field(Fields.HOST, sourceNode.getHostName()); builder.field(Fields.TRANSPORT_ADDRESS, sourceNode.address().toString()); builder.field(Fields.IP, sourceNode.getHostAddress()); - builder.field(Fields.NAME, sourceNode.name()); + builder.field(Fields.NAME, sourceNode.getName()); builder.endObject(); } @@ -329,7 +329,7 @@ public class RecoveryState implements ToXContent, Streamable { builder.field(Fields.HOST, targetNode.getHostName()); builder.field(Fields.TRANSPORT_ADDRESS, targetNode.address().toString()); builder.field(Fields.IP, targetNode.getHostAddress()); - builder.field(Fields.NAME, targetNode.name()); + builder.field(Fields.NAME, targetNode.getName()); builder.endObject(); builder.startObject(Fields.INDEX); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java index a0abff40625..4a64ef409db 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java @@ -143,7 +143,7 @@ public class RestAllocationAction extends AbstractCatAction { table.addCell(diskPercent < 0 ? null : diskPercent); table.addCell(node.getHostName()); table.addCell(node.getHostAddress()); - table.addCell(node.name()); + table.addCell(node.getName()); table.endRow(); } diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java index f86d70e7f12..99e8d630a40 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java @@ -105,7 +105,7 @@ public class RestNodeAttrsAction extends AbstractCatAction { NodeInfo info = nodesInfo.getNodesMap().get(node.getId()); for (Map.Entry attrEntry : node.getAttributes().entrySet()) { table.startRow(); - table.addCell(node.name()); + table.addCell(node.getName()); table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4)); table.addCell(info == null ? null : info.getProcess().getId()); table.addCell(node.getHostName()); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java index 5681a4808f3..85e3bd36354 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java @@ -288,7 +288,7 @@ public class RestNodesAction extends AbstractCatAction { } table.addCell(roles); table.addCell(masterId == null ? "x" : masterId.equals(node.getId()) ? "*" : "-"); - table.addCell(node.name()); + table.addCell(node.getName()); CompletionStats completionStats = indicesStats == null ? null : stats.getIndices().getCompletion(); table.addCell(completionStats == null ? null : completionStats.getSize()); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java index 3da0bfd5764..189273a7722 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java @@ -99,7 +99,7 @@ public class RestPluginsAction extends AbstractCatAction { for (PluginInfo pluginInfo : info.getPlugins().getPluginInfos()) { table.startRow(); table.addCell(node.getId()); - table.addCell(node.name()); + table.addCell(node.getName()); table.addCell(pluginInfo.getName()); table.addCell(pluginInfo.getVersion()); table.addCell(pluginInfo.getDescription()); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java index 8bf67653f6f..9954bd3098b 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java @@ -208,10 +208,10 @@ public class RestShardsAction extends AbstractCatAction { String ip = state.getState().nodes().get(shard.currentNodeId()).getHostAddress(); String nodeId = shard.currentNodeId(); StringBuilder name = new StringBuilder(); - name.append(state.getState().nodes().get(shard.currentNodeId()).name()); + name.append(state.getState().nodes().get(shard.currentNodeId()).getName()); if (shard.relocating()) { String reloIp = state.getState().nodes().get(shard.relocatingNodeId()).getHostAddress(); - String reloNme = state.getState().nodes().get(shard.relocatingNodeId()).name(); + String reloNme = state.getState().nodes().get(shard.relocatingNodeId()).getName(); String reloNodeId = shard.relocatingNodeId(); name.append(" -> "); name.append(reloIp); diff --git a/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java b/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java index e867acedef0..f24f5f80c06 100644 --- a/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java +++ b/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java @@ -45,7 +45,7 @@ public class ConnectTransportException extends ActionTransportException { } public ConnectTransportException(DiscoveryNode node, String msg, String action, Throwable cause) { - super(node == null ? null : node.name(), node == null ? null : node.address(), action, msg, cause); + super(node == null ? null : node.getName(), node == null ? null : node.address(), action, msg, cause); this.node = node; } diff --git a/core/src/main/java/org/elasticsearch/transport/ReceiveTimeoutTransportException.java b/core/src/main/java/org/elasticsearch/transport/ReceiveTimeoutTransportException.java index e16357f9621..75504a90eec 100644 --- a/core/src/main/java/org/elasticsearch/transport/ReceiveTimeoutTransportException.java +++ b/core/src/main/java/org/elasticsearch/transport/ReceiveTimeoutTransportException.java @@ -30,7 +30,7 @@ import java.io.IOException; public class ReceiveTimeoutTransportException extends ActionTransportException { public ReceiveTimeoutTransportException(DiscoveryNode node, String action, String msg) { - super(node.name(), node.address(), action, msg, null); + super(node.getName(), node.address(), action, msg, null); } public ReceiveTimeoutTransportException(StreamInput in) throws IOException { diff --git a/core/src/main/java/org/elasticsearch/transport/SendRequestTransportException.java b/core/src/main/java/org/elasticsearch/transport/SendRequestTransportException.java index 7c4faa5e87b..3870bf59553 100644 --- a/core/src/main/java/org/elasticsearch/transport/SendRequestTransportException.java +++ b/core/src/main/java/org/elasticsearch/transport/SendRequestTransportException.java @@ -31,7 +31,7 @@ import java.io.IOException; public class SendRequestTransportException extends ActionTransportException implements ElasticsearchWrapperException { public SendRequestTransportException(DiscoveryNode node, String action, Throwable cause) { - super(node == null ? null : node.name(), node == null ? null : node.address(), action, cause); + super(node == null ? null : node.getName(), node == null ? null : node.address(), action, cause); } public SendRequestTransportException(StreamInput in) throws IOException { diff --git a/core/src/main/java/org/elasticsearch/transport/TransportService.java b/core/src/main/java/org/elasticsearch/transport/TransportService.java index cb0443587a4..12c058dbc91 100644 --- a/core/src/main/java/org/elasticsearch/transport/TransportService.java +++ b/core/src/main/java/org/elasticsearch/transport/TransportService.java @@ -873,7 +873,7 @@ public class TransportService extends AbstractLifecycleComponent { // a new node, add it, but also add the tribe name to the attributes Map tribeAttr = new HashMap<>(tribe.getAttributes()); tribeAttr.put(TRIBE_NAME_SETTING.getKey(), tribeName); - DiscoveryNode discoNode = new DiscoveryNode(tribe.name(), tribe.getId(), tribe.getHostName(), tribe.getHostAddress(), + DiscoveryNode discoNode = new DiscoveryNode(tribe.getName(), tribe.getId(), tribe.getHostName(), tribe.getHostAddress(), tribe.address(), unmodifiableMap(tribeAttr), tribe.getRoles(), tribe.version()); clusterStateChanged = true; logger.info("[{}] adding node [{}]", tribeName, discoNode); diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java index e9ade3ef5af..3c2d90b77ab 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java @@ -188,7 +188,7 @@ public class TasksIT extends ESIntegTestCase { logger.debug("number of shards, total: [{}], primaries: [{}] ", numberOfShards.totalNumShards, numberOfShards.numPrimaries); logger.debug("main events {}", numberOfEvents(RefreshAction.NAME, Tuple::v1)); - logger.debug("main event node {}", findEvents(RefreshAction.NAME, Tuple::v1).get(0).getNode().name()); + logger.debug("main event node {}", findEvents(RefreshAction.NAME, Tuple::v1).get(0).getNode().getName()); logger.debug("[s] events {}", numberOfEvents(RefreshAction.NAME + "[s]", Tuple::v1)); logger.debug("[s][*] events {}", numberOfEvents(RefreshAction.NAME + "[s][*]", Tuple::v1)); logger.debug("nodes with the index {}", internalCluster().nodesInclude("test")); @@ -436,7 +436,7 @@ public class TasksIT extends ESIntegTestCase { DiscoveryNode node = internalCluster().getInstance(ClusterService.class, nodeName).localNode(); RecordingTaskManagerListener listener = new RecordingTaskManagerListener(node, Strings.splitStringToArray(actionMasks, ',')); ((MockTaskManager) internalCluster().getInstance(TransportService.class, nodeName).getTaskManager()).addListener(listener); - RecordingTaskManagerListener oldListener = listeners.put(new Tuple<>(node.name(), actionMasks), listener); + RecordingTaskManagerListener oldListener = listeners.put(new Tuple<>(node.getName(), actionMasks), listener); assertNull(oldListener); } } diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java index c31993ebb81..6e3e5d76224 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java @@ -192,7 +192,7 @@ public class IndicesShardStoreRequestIT extends ESIntegTestCase { for (IntObjectCursor> shardStatus : shardStatuses) { for (IndicesShardStoresResponse.StoreStatus status : shardStatus.value) { if (corruptedShardIDMap.containsKey(shardStatus.key) - && corruptedShardIDMap.get(shardStatus.key).contains(status.getNode().name())) { + && corruptedShardIDMap.get(shardStatus.key).contains(status.getNode().getName())) { assertThat(status.getLegacyVersion(), greaterThanOrEqualTo(0L)); assertThat(status.getStoreException(), notNullValue()); } else { diff --git a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java index ae739701593..9d74ef66319 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java @@ -38,7 +38,6 @@ import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.termvectors.TermVectorsResponse; import org.elasticsearch.action.update.UpdateRequestBuilder; import org.elasticsearch.action.update.UpdateResponse; @@ -259,7 +258,7 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { if (shardRouting.currentNodeId() != null && index.equals(shardRouting.getIndexName())) { - String name = clusterState.nodes().get(shardRouting.currentNodeId()).name(); + String name = clusterState.nodes().get(shardRouting.currentNodeId()).getName(); assertThat("Allocated on new node: " + name, Regex.simpleMatch(pattern, name), is(true)); } } diff --git a/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java index 207232883c7..5b473879011 100644 --- a/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java @@ -53,8 +53,8 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { } logger.info("--> start master node"); final String masterNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true)); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(masterNodeName)); - assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(masterNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); + assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); logger.info("--> stop master node"); internalCluster().stopCurrentMasterNode(); @@ -68,8 +68,8 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { logger.info("--> start master node"); final String nextMasterEligibleNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true)); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(nextMasterEligibleNodeName)); - assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(nextMasterEligibleNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligibleNodeName)); + assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligibleNodeName)); } public void testElectOnlyBetweenMasterNodes() throws IOException { @@ -83,19 +83,19 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { } logger.info("--> start master node (1)"); final String masterNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true)); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(masterNodeName)); - assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(masterNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); + assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); logger.info("--> start master node (2)"); final String nextMasterEligableNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true)); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(masterNodeName)); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(masterNodeName)); - assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(masterNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); + assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); logger.info("--> closing master node (1)"); internalCluster().stopCurrentMasterNode(); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(nextMasterEligableNodeName)); - assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(nextMasterEligableNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligableNodeName)); + assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligableNodeName)); } /** diff --git a/core/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java b/core/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java index cf948366f6a..c43187d2e40 100644 --- a/core/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java @@ -92,7 +92,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase { for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { - counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).name(), 1); + counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).getName(), 1); } } } @@ -141,7 +141,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase { for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { - counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).name(), 1); + counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).getName(), 1); } } } @@ -175,7 +175,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase { for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { - counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).name(), 1); + counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).getName(), 1); } } } @@ -197,7 +197,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase { for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { - counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).name(), 1); + counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).getName(), 1); } } } @@ -219,7 +219,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase { for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { - counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).name(), 1); + counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).getName(), 1); } } } @@ -240,7 +240,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase { for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { - counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).name(), 1); + counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).getName(), 1); } } } diff --git a/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java b/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java index f775918b8f7..6413cf7277c 100644 --- a/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java @@ -71,7 +71,7 @@ public class FilteringAllocationIT extends ESIntegTestCase { for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { - assertThat(clusterState.nodes().get(shardRouting.currentNodeId()).name(), equalTo(node_0)); + assertThat(clusterState.nodes().get(shardRouting.currentNodeId()).getName(), equalTo(node_0)); } } } @@ -105,7 +105,7 @@ public class FilteringAllocationIT extends ESIntegTestCase { int numShardsOnNode1 = 0; for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { - if ("node1".equals(clusterState.nodes().get(shardRouting.currentNodeId()).name())) { + if ("node1".equals(clusterState.nodes().get(shardRouting.currentNodeId()).getName())) { numShardsOnNode1++; } } @@ -129,7 +129,7 @@ public class FilteringAllocationIT extends ESIntegTestCase { indexRoutingTable = clusterState.routingTable().index("test"); for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { - assertThat(clusterState.nodes().get(shardRouting.currentNodeId()).name(), equalTo(node_1)); + assertThat(clusterState.nodes().get(shardRouting.currentNodeId()).getName(), equalTo(node_1)); } } diff --git a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java index 7836fb759e4..fe80baebd52 100644 --- a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java @@ -41,7 +41,7 @@ public class DiscoveryNodesTests extends ESTestCase { DiscoveryNodes discoveryNodes = buildDiscoveryNodes(); DiscoveryNode[] nodes = discoveryNodes.nodes().values().toArray(DiscoveryNode.class); DiscoveryNode node = randomFrom(nodes); - DiscoveryNode resolvedNode = discoveryNodes.resolveNode(randomBoolean() ? node.getId() : node.name()); + DiscoveryNode resolvedNode = discoveryNodes.resolveNode(randomBoolean() ? node.getId() : node.getName()); assertThat(resolvedNode.getId(), equalTo(node.getId())); } @@ -87,7 +87,7 @@ public class DiscoveryNodesTests extends ESTestCase { DiscoveryNode[] nodes = discoveryNodes.nodes().values().toArray(DiscoveryNode.class); for (int i = 0; i < numNodeNames; i++) { DiscoveryNode discoveryNode = randomFrom(nodes); - nodeSelectors.add(discoveryNode.name()); + nodeSelectors.add(discoveryNode.getName()); expectedNodeIdsSet.add(discoveryNode.getId()); } diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java b/core/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java index da6f270a79d..f990f382c8c 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java @@ -29,7 +29,6 @@ import org.elasticsearch.common.collect.ImmutableOpenIntMap; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.gateway.GatewayAllocator; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.disruption.NetworkDisconnectPartition; @@ -78,11 +77,11 @@ public class PrimaryAllocationIT extends ESIntegTestCase { final String primaryNode; final String replicaNode; if (shards.get(0).primary()) { - primaryNode = state.getRoutingNodes().node(shards.get(0).currentNodeId()).node().name(); - replicaNode = state.getRoutingNodes().node(shards.get(1).currentNodeId()).node().name(); + primaryNode = state.getRoutingNodes().node(shards.get(0).currentNodeId()).node().getName(); + replicaNode = state.getRoutingNodes().node(shards.get(1).currentNodeId()).node().getName(); } else { - primaryNode = state.getRoutingNodes().node(shards.get(1).currentNodeId()).node().name(); - replicaNode = state.getRoutingNodes().node(shards.get(0).currentNodeId()).node().name(); + primaryNode = state.getRoutingNodes().node(shards.get(1).currentNodeId()).node().getName(); + replicaNode = state.getRoutingNodes().node(shards.get(0).currentNodeId()).node().getName(); } NetworkDisconnectPartition partition = new NetworkDisconnectPartition( diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java index 38c15750423..5f2e0241a82 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java @@ -42,7 +42,7 @@ public class ShardStateIT extends ESIntegTestCase { ClusterState state = client().admin().cluster().prepareState().get().getState(); final int shard = randomBoolean() ? 0 : 1; final String nodeId = state.routingTable().index("test").shard(shard).primaryShard().currentNodeId(); - final String node = state.nodes().get(nodeId).name(); + final String node = state.nodes().get(nodeId).getName(); logger.info("--> failing primary of [{}] on node [{}]", shard, node); IndicesService indicesService = internalCluster().getInstance(IndicesService.class, node); indicesService.indexService(resolveIndex("test")).getShard(shard).failShard("simulated test failure", null); diff --git a/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java b/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java index f2a0dcc0d79..bf55968df9f 100644 --- a/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java @@ -572,7 +572,7 @@ public class ClusterServiceIT extends ESIntegTestCase { // now that we started node1 again, a new master should be elected assertThat(clusterService2.state().nodes().masterNode(), is(notNullValue())); - if (node_2.equals(clusterService2.state().nodes().masterNode().name())) { + if (node_2.equals(clusterService2.state().nodes().masterNode().getName())) { assertThat(testService1.master(), is(false)); assertThat(testService2.master(), is(true)); } else { diff --git a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java index f588652ac8c..f4a96260bff 100644 --- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java @@ -626,8 +626,8 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { DiscoveryNode currentMaster = event.state().nodes().getMasterNode(); if (!Objects.equals(previousMaster, currentMaster)) { logger.info("node {} received new cluster state: {} \n and had previous cluster state: {}", node, event.state(), event.previousState()); - String previousMasterNodeName = previousMaster != null ? previousMaster.name() : null; - String currentMasterNodeName = currentMaster != null ? currentMaster.name() : null; + String previousMasterNodeName = previousMaster != null ? previousMaster.getName() : null; + String currentMasterNodeName = currentMaster != null ? currentMaster.getName() : null; masters.get(node).add(new Tuple<>(previousMasterNodeName, currentMasterNodeName)); } } @@ -1192,7 +1192,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { ClusterState state = getNodeClusterState(node); String masterNode = null; if (state.nodes().masterNode() != null) { - masterNode = state.nodes().masterNode().name(); + masterNode = state.nodes().masterNode().getName(); } logger.trace("[{}] master is [{}]", node, state.nodes().masterNode()); assertThat("node [" + node + "] still has [" + masterNode + "] as master", @@ -1206,7 +1206,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { ClusterState state = getNodeClusterState(node); String failMsgSuffix = "cluster_state:\n" + state.prettyPrint(); assertThat("wrong node count on [" + node + "]. " + failMsgSuffix, state.nodes().size(), equalTo(nodes.size())); - String otherMasterNodeName = state.nodes().masterNode() != null ? state.nodes().masterNode().name() : null; + String otherMasterNodeName = state.nodes().masterNode() != null ? state.nodes().masterNode().getName() : null; assertThat("wrong master on node [" + node + "]. " + failMsgSuffix, otherMasterNodeName, equalTo(masterNode)); } } diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java index 2ba0e3a834f..9cd7cc9c99d 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java @@ -186,7 +186,7 @@ public class ZenDiscoveryIT extends ESIntegTestCase { ClusterState state = internalCluster().getInstance(ClusterService.class).state(); DiscoveryNode node = null; for (DiscoveryNode discoveryNode : state.nodes()) { - if (discoveryNode.name().equals(noneMasterNode)) { + if (discoveryNode.getName().equals(noneMasterNode)) { node = discoveryNode; } } diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java index f5904cc79bd..bb7ef29e3d5 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java @@ -118,7 +118,7 @@ public class PublishClusterStateActionTests extends ESTestCase { @Override public void onNewClusterState(String reason) { ClusterState newClusterState = action.pendingStatesQueue().getNextClusterStateToProcess(); - logger.debug("[{}] received version [{}], uuid [{}]", discoveryNode.name(), newClusterState.version(), newClusterState.stateUUID()); + logger.debug("[{}] received version [{}], uuid [{}]", discoveryNode.getName(), newClusterState.version(), newClusterState.stateUUID()); if (listener != null) { ClusterChangedEvent event = new ClusterChangedEvent("", newClusterState, clusterState); listener.clusterChanged(event); diff --git a/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java b/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java index dac284ee594..9a85f404bf7 100644 --- a/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java +++ b/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java @@ -457,7 +457,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase { } if (!recoveryState.getPrimary() && (useSyncIds == false)) { logger.info("--> replica shard {} recovered from {} to {}, recovered {}, reuse {}", - recoveryState.getShardId().getId(), recoveryState.getSourceNode().name(), recoveryState.getTargetNode().name(), + recoveryState.getShardId().getId(), recoveryState.getSourceNode().getName(), recoveryState.getTargetNode().getName(), recoveryState.getIndex().recoveredBytes(), recoveryState.getIndex().reusedBytes()); assertThat("no bytes should be recovered", recoveryState.getIndex().recoveredBytes(), equalTo(recovered)); assertThat("data should have been reused", recoveryState.getIndex().reusedBytes(), greaterThan(0L)); @@ -469,7 +469,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase { } else { if (useSyncIds && !recoveryState.getPrimary()) { logger.info("--> replica shard {} recovered from {} to {} using sync id, recovered {}, reuse {}", - recoveryState.getShardId().getId(), recoveryState.getSourceNode().name(), recoveryState.getTargetNode().name(), + recoveryState.getShardId().getId(), recoveryState.getSourceNode().getName(), recoveryState.getTargetNode().getName(), recoveryState.getIndex().recoveredBytes(), recoveryState.getIndex().reusedBytes()); } assertThat(recoveryState.getIndex().recoveredBytes(), equalTo(0L)); diff --git a/core/src/test/java/org/elasticsearch/gateway/ReusePeerRecoverySharedTest.java b/core/src/test/java/org/elasticsearch/gateway/ReusePeerRecoverySharedTest.java index d28e5333225..c82e60bf933 100644 --- a/core/src/test/java/org/elasticsearch/gateway/ReusePeerRecoverySharedTest.java +++ b/core/src/test/java/org/elasticsearch/gateway/ReusePeerRecoverySharedTest.java @@ -124,7 +124,7 @@ public class ReusePeerRecoverySharedTest { } if (!recoveryState.getPrimary() && (useSyncIds == false)) { logger.info("--> replica shard {} recovered from {} to {}, recovered {}, reuse {}", recoveryState.getShardId().getId(), - recoveryState.getSourceNode().name(), recoveryState.getTargetNode().name(), + recoveryState.getSourceNode().getName(), recoveryState.getTargetNode().getName(), recoveryState.getIndex().recoveredBytes(), recoveryState.getIndex().reusedBytes()); assertThat("no bytes should be recovered", recoveryState.getIndex().recoveredBytes(), equalTo(recovered)); assertThat("data should have been reused", recoveryState.getIndex().reusedBytes(), greaterThan(0L)); @@ -139,7 +139,7 @@ public class ReusePeerRecoverySharedTest { } else { if (useSyncIds && !recoveryState.getPrimary()) { logger.info("--> replica shard {} recovered from {} to {} using sync id, recovered {}, reuse {}", - recoveryState.getShardId().getId(), recoveryState.getSourceNode().name(), recoveryState.getTargetNode().name(), + recoveryState.getShardId().getId(), recoveryState.getSourceNode().getName(), recoveryState.getTargetNode().getName(), recoveryState.getIndex().recoveredBytes(), recoveryState.getIndex().reusedBytes()); } assertThat(recoveryState.getIndex().recoveredBytes(), equalTo(0L)); diff --git a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java index aaa1671f84b..56da125fc61 100644 --- a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java +++ b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java @@ -331,7 +331,7 @@ public class CorruptedFileIT extends ESIntegTestCase { assertAcked(prepareCreate("test").setSettings(Settings.builder() .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, "0") .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) - .put("index.routing.allocation.include._name", primariesNode.getNode().name()) + .put("index.routing.allocation.include._name", primariesNode.getNode().getName()) .put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE) )); @@ -339,8 +339,8 @@ public class CorruptedFileIT extends ESIntegTestCase { final AtomicBoolean corrupt = new AtomicBoolean(true); final CountDownLatch hasCorrupted = new CountDownLatch(1); for (NodeStats dataNode : dataNodeStats) { - MockTransportService mockTransportService = ((MockTransportService) internalCluster().getInstance(TransportService.class, dataNode.getNode().name())); - mockTransportService.addDelegate(internalCluster().getInstance(TransportService.class, unluckyNode.getNode().name()), new MockTransportService.DelegateTransport(mockTransportService.original()) { + MockTransportService mockTransportService = ((MockTransportService) internalCluster().getInstance(TransportService.class, dataNode.getNode().getName())); + mockTransportService.addDelegate(internalCluster().getInstance(TransportService.class, unluckyNode.getNode().getName()), new MockTransportService.DelegateTransport(mockTransportService.original()) { @Override public void sendRequest(DiscoveryNode node, long requestId, String action, TransportRequest request, TransportRequestOptions options) throws IOException, TransportException { @@ -358,7 +358,7 @@ public class CorruptedFileIT extends ESIntegTestCase { Settings build = Settings.builder() .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, "1") - .put("index.routing.allocation.include._name", primariesNode.getNode().name() + "," + unluckyNode.getNode().name()).build(); + .put("index.routing.allocation.include._name", primariesNode.getNode().getName() + "," + unluckyNode.getNode().getName()).build(); client().admin().indices().prepareUpdateSettings("test").setSettings(build).get(); client().admin().cluster().prepareReroute().get(); hasCorrupted.await(); @@ -395,7 +395,7 @@ public class CorruptedFileIT extends ESIntegTestCase { .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, between(1, 4)) // don't go crazy here it must recovery fast // This does corrupt files on the replica, so we can't check: .put(MockFSIndexStore.INDEX_CHECK_INDEX_ON_CLOSE_SETTING.getKey(), false) - .put("index.routing.allocation.include._name", primariesNode.getNode().name()) + .put("index.routing.allocation.include._name", primariesNode.getNode().getName()) .put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE) )); ensureGreen(); @@ -411,8 +411,8 @@ public class CorruptedFileIT extends ESIntegTestCase { assertHitCount(countResponse, numDocs); final boolean truncate = randomBoolean(); for (NodeStats dataNode : dataNodeStats) { - MockTransportService mockTransportService = ((MockTransportService) internalCluster().getInstance(TransportService.class, dataNode.getNode().name())); - mockTransportService.addDelegate(internalCluster().getInstance(TransportService.class, unluckyNode.getNode().name()), new MockTransportService.DelegateTransport(mockTransportService.original()) { + MockTransportService mockTransportService = ((MockTransportService) internalCluster().getInstance(TransportService.class, dataNode.getNode().getName())); + mockTransportService.addDelegate(internalCluster().getInstance(TransportService.class, unluckyNode.getNode().getName()), new MockTransportService.DelegateTransport(mockTransportService.original()) { @Override public void sendRequest(DiscoveryNode node, long requestId, String action, TransportRequest request, TransportRequestOptions options) throws IOException, TransportException { diff --git a/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java b/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java index 42554913fd0..163d72f4553 100644 --- a/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java +++ b/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java @@ -81,8 +81,8 @@ public class ExceptionRetryIT extends ESIntegTestCase { //create a transport service that throws a ConnectTransportException for one bulk request and therefore triggers a retry. for (NodeStats dataNode : nodeStats.getNodes()) { - MockTransportService mockTransportService = ((MockTransportService) internalCluster().getInstance(TransportService.class, dataNode.getNode().name())); - mockTransportService.addDelegate(internalCluster().getInstance(TransportService.class, unluckyNode.getNode().name()), new MockTransportService.DelegateTransport(mockTransportService.original()) { + MockTransportService mockTransportService = ((MockTransportService) internalCluster().getInstance(TransportService.class, dataNode.getNode().getName())); + mockTransportService.addDelegate(internalCluster().getInstance(TransportService.class, unluckyNode.getNode().getName()), new MockTransportService.DelegateTransport(mockTransportService.original()) { @Override public void sendRequest(DiscoveryNode node, long requestId, String action, TransportRequest request, TransportRequestOptions options) throws IOException, TransportException { diff --git a/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java b/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java index 1a858c3e603..8c724efdfc7 100644 --- a/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java +++ b/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java @@ -122,7 +122,7 @@ public class FlushIT extends ESIntegTestCase { String newNodeName = internalCluster().startNode(); ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); ShardRouting shardRouting = clusterState.getRoutingTable().index("test").shard(0).iterator().next(); - String currentNodeName = clusterState.nodes().resolveNode(shardRouting.currentNodeId()).name(); + String currentNodeName = clusterState.nodes().resolveNode(shardRouting.currentNodeId()).getName(); assertFalse(currentNodeName.equals(newNodeName)); internalCluster().client().admin().cluster().prepareReroute().add(new MoveAllocationCommand("test", 0, currentNodeName, newNodeName)).get(); diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java index 286781b5bca..1c448dd70a0 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java @@ -297,12 +297,12 @@ public class IndexRecoveryIT extends ESIntegTestCase { long nodeBThrottling = Long.MAX_VALUE; for (NodeStats nodeStats : statsResponse.getNodes()) { final RecoveryStats recoveryStats = nodeStats.getIndices().getRecoveryStats(); - if (nodeStats.getNode().name().equals(nodeA)) { + if (nodeStats.getNode().getName().equals(nodeA)) { assertThat("node A should have ongoing recovery as source", recoveryStats.currentAsSource(), equalTo(1)); assertThat("node A should not have ongoing recovery as target", recoveryStats.currentAsTarget(), equalTo(0)); nodeAThrottling = recoveryStats.throttleTime().millis(); } - if (nodeStats.getNode().name().equals(nodeB)) { + if (nodeStats.getNode().getName().equals(nodeB)) { assertThat("node B should not have ongoing recovery as source", recoveryStats.currentAsSource(), equalTo(0)); assertThat("node B should have ongoing recovery as target", recoveryStats.currentAsTarget(), equalTo(1)); nodeBThrottling = recoveryStats.throttleTime().millis(); @@ -319,10 +319,10 @@ public class IndexRecoveryIT extends ESIntegTestCase { assertThat(statsResponse.getNodes(), arrayWithSize(2)); for (NodeStats nodeStats : statsResponse.getNodes()) { final RecoveryStats recoveryStats = nodeStats.getIndices().getRecoveryStats(); - if (nodeStats.getNode().name().equals(nodeA)) { + if (nodeStats.getNode().getName().equals(nodeA)) { assertThat("node A throttling should increase", recoveryStats.throttleTime().millis(), greaterThan(finalNodeAThrottling)); } - if (nodeStats.getNode().name().equals(nodeB)) { + if (nodeStats.getNode().getName().equals(nodeB)) { assertThat("node B throttling should increase", recoveryStats.throttleTime().millis(), greaterThan(finalNodeBThrottling)); } } @@ -350,10 +350,10 @@ public class IndexRecoveryIT extends ESIntegTestCase { final RecoveryStats recoveryStats = nodeStats.getIndices().getRecoveryStats(); assertThat(recoveryStats.currentAsSource(), equalTo(0)); assertThat(recoveryStats.currentAsTarget(), equalTo(0)); - if (nodeStats.getNode().name().equals(nodeA)) { + if (nodeStats.getNode().getName().equals(nodeA)) { assertThat("node A throttling should be >0", recoveryStats.throttleTime().millis(), greaterThan(0L)); } - if (nodeStats.getNode().name().equals(nodeB)) { + if (nodeStats.getNode().getName().equals(nodeB)) { assertThat("node B throttling should be >0 ", recoveryStats.throttleTime().millis(), greaterThan(0L)); } } @@ -369,10 +369,10 @@ public class IndexRecoveryIT extends ESIntegTestCase { final RecoveryStats recoveryStats = nodeStats.getIndices().getRecoveryStats(); assertThat(recoveryStats.currentAsSource(), equalTo(0)); assertThat(recoveryStats.currentAsTarget(), equalTo(0)); - if (nodeStats.getNode().name().equals(nodeA)) { + if (nodeStats.getNode().getName().equals(nodeA)) { assertThat("node A throttling should be >0", recoveryStats.throttleTime().millis(), greaterThan(0L)); } - if (nodeStats.getNode().name().equals(nodeB)) { + if (nodeStats.getNode().getName().equals(nodeB)) { assertThat("node B throttling should be >0 ", recoveryStats.throttleTime().millis(), greaterThan(0L)); } } diff --git a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java index 8ce4229172f..90d049601a8 100644 --- a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java +++ b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java @@ -234,7 +234,7 @@ public class RareClusterStateIT extends ESIntegTestCase { // Check routing tables ClusterState state = client().admin().cluster().prepareState().get().getState(); - assertEquals(master, state.nodes().masterNode().name()); + assertEquals(master, state.nodes().masterNode().getName()); List shards = state.routingTable().allShards("index"); assertThat(shards, hasSize(1)); for (ShardRouting shard : shards) { @@ -352,7 +352,7 @@ public class RareClusterStateIT extends ESIntegTestCase { // Check routing tables ClusterState state = client().admin().cluster().prepareState().get().getState(); - assertEquals(master, state.nodes().masterNode().name()); + assertEquals(master, state.nodes().masterNode().getName()); List shards = state.routingTable().allShards("index"); assertThat(shards, hasSize(2)); for (ShardRouting shard : shards) { diff --git a/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java b/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java index b441dd32c78..552ed3da495 100644 --- a/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java +++ b/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java @@ -94,7 +94,7 @@ public class TruncatedRecoveryIT extends ESIntegTestCase { assertAcked(prepareCreate("test") .addMapping("type1", "field1", "type=text", "the_id", "type=text") .setSettings(settingsBuilder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numberOfShards()) - .put("index.routing.allocation.include._name", primariesNode.getNode().name()))); // only allocate on the lucky node + .put("index.routing.allocation.include._name", primariesNode.getNode().getName()))); // only allocate on the lucky node // index some docs and check if they are coming back int numDocs = randomIntBetween(100, 200); @@ -116,8 +116,8 @@ public class TruncatedRecoveryIT extends ESIntegTestCase { final CountDownLatch latch = new CountDownLatch(1); final AtomicBoolean truncate = new AtomicBoolean(true); for (NodeStats dataNode : dataNodeStats) { - MockTransportService mockTransportService = ((MockTransportService) internalCluster().getInstance(TransportService.class, dataNode.getNode().name())); - mockTransportService.addDelegate(internalCluster().getInstance(TransportService.class, unluckyNode.getNode().name()), new MockTransportService.DelegateTransport(mockTransportService.original()) { + MockTransportService mockTransportService = ((MockTransportService) internalCluster().getInstance(TransportService.class, dataNode.getNode().getName())); + mockTransportService.addDelegate(internalCluster().getInstance(TransportService.class, unluckyNode.getNode().getName()), new MockTransportService.DelegateTransport(mockTransportService.original()) { @Override public void sendRequest(DiscoveryNode node, long requestId, String action, TransportRequest request, TransportRequestOptions options) throws IOException, TransportException { @@ -138,7 +138,7 @@ public class TruncatedRecoveryIT extends ESIntegTestCase { client().admin().indices().prepareUpdateSettings("test").setSettings(settingsBuilder() .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1) .put("index.routing.allocation.include._name", // now allow allocation on all nodes - primariesNode.getNode().name() + "," + unluckyNode.getNode().name())).get(); + primariesNode.getNode().getName() + "," + unluckyNode.getNode().getName())).get(); latch.await(); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoShapeIntegrationTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoShapeIntegrationTests.java index 8a86a0a1fb4..73943dfaaba 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoShapeIntegrationTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoShapeIntegrationTests.java @@ -103,6 +103,6 @@ public class GeoShapeIntegrationTests extends ESIntegTestCase { ClusterState state = client().admin().cluster().prepareState().get().getState(); IndexShardRoutingTable shard = state.getRoutingTable().index(index).shard(0); String nodeId = shard.assignedShards().get(0).currentNodeId(); - return state.getNodes().get(nodeId).name(); + return state.getNodes().get(nodeId).getName(); } } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESBackcompatTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESBackcompatTestCase.java index d8dd665efe6..d37f118d373 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESBackcompatTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESBackcompatTestCase.java @@ -231,7 +231,7 @@ public abstract class ESBackcompatTestCase extends ESIntegTestCase { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { if (shardRouting.currentNodeId() != null && index.equals(shardRouting.getIndexName())) { - String name = clusterState.nodes().get(shardRouting.currentNodeId()).name(); + String name = clusterState.nodes().get(shardRouting.currentNodeId()).getName(); assertThat("Allocated on new node: " + name, Regex.simpleMatch(pattern, name), is(true)); } } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index 6920ba4a8e0..b98cb3d75fb 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -101,7 +101,6 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexModule; import org.elasticsearch.index.IndexService; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.IndexWarmer; import org.elasticsearch.index.MergePolicyConfig; import org.elasticsearch.index.MergeSchedulerConfig; import org.elasticsearch.index.MockEngineFactoryPlugin; @@ -111,7 +110,6 @@ import org.elasticsearch.index.mapper.internal.TimestampFieldMapper; import org.elasticsearch.index.translog.Translog; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.IndicesRequestCache; -import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.store.IndicesStore; import org.elasticsearch.node.NodeMocksPlugin; import org.elasticsearch.plugins.Plugin; @@ -1889,7 +1887,7 @@ public abstract class ESIntegTestCase extends ESTestCase { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { if (shardRouting.currentNodeId() != null && index.equals(shardRouting.getIndexName())) { - String name = clusterState.nodes().get(shardRouting.currentNodeId()).name(); + String name = clusterState.nodes().get(shardRouting.currentNodeId()).getName(); nodes.add(name); assertThat("Allocated on new node: " + name, Regex.simpleMatch(pattern, name), is(true)); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ExternalNode.java b/test/framework/src/main/java/org/elasticsearch/test/ExternalNode.java index ea106bf9b98..41bd1a301aa 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ExternalNode.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ExternalNode.java @@ -194,7 +194,7 @@ final class ExternalNode implements Closeable { Settings clientSettings = settingsBuilder().put(externalNodeSettings) .put("client.transport.nodes_sampler_interval", "1s") - .put("node.name", "transport_client_" + nodeInfo.getNode().name()) + .put("node.name", "transport_client_" + nodeInfo.getNode().getName()) .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), clusterName).put("client.transport.sniff", false).build(); TransportClient client = TransportClient.builder().settings(clientSettings).build(); client.addTransportAddress(addr); diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index dbf9227bc19..f367ff3f75a 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -1363,7 +1363,7 @@ public final class InternalTestCluster extends TestCluster { try { Client client = viaNode != null ? client(viaNode) : client(); ClusterState state = client.admin().cluster().prepareState().execute().actionGet().getState(); - return state.nodes().masterNode().name(); + return state.nodes().masterNode().getName(); } catch (Throwable e) { logger.warn("Can't fetch cluster state", e); throw new RuntimeException("Can't get master node " + e.getMessage(), e); From dfeb9379ab81d6de63a42dfdc82a5feb1252f4e0 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 14:51:36 +0200 Subject: [PATCH 03/25] Remove DiscoveryNode#dataNode in favour of existing DiscoveryNode#isDataNode --- .../cluster/InternalClusterInfoService.java | 4 ++-- .../org/elasticsearch/cluster/node/DiscoveryNode.java | 9 +-------- .../org/elasticsearch/cluster/node/DiscoveryNodes.java | 2 +- .../command/AbstractAllocateAllocationCommand.java | 2 +- .../java/org/elasticsearch/gateway/GatewayMetaState.java | 4 ++-- .../client/transport/TransportClientIT.java | 2 +- core/src/test/java/org/elasticsearch/tribe/TribeIT.java | 2 +- 7 files changed, 9 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java b/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java index 7a0bbb20f21..735d34c8d02 100644 --- a/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java +++ b/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java @@ -166,7 +166,7 @@ public class InternalClusterInfoService extends AbstractComponent implements Clu // Check whether it was a data node that was added boolean dataNodeAdded = false; for (DiscoveryNode addedNode : event.nodesDelta().addedNodes()) { - if (addedNode.dataNode()) { + if (addedNode.isDataNode()) { dataNodeAdded = true; break; } @@ -181,7 +181,7 @@ public class InternalClusterInfoService extends AbstractComponent implements Clu if (this.isMaster && event.nodesRemoved()) { for (DiscoveryNode removedNode : event.nodesDelta().removedNodes()) { - if (removedNode.dataNode()) { + if (removedNode.isDataNode()) { if (logger.isTraceEnabled()) { logger.trace("Removing node from cluster info: {}", removedNode.getId()); } diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 6bd1a6ad721..c5e91413f02 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -242,18 +242,11 @@ public class DiscoveryNode implements Writeable, ToXContent { return this.attributes; } - /** - * Should this node hold data (shards) or not. - */ - public boolean dataNode() { - return roles.contains(Role.DATA); - } - /** * Should this node hold data (shards) or not. */ public boolean isDataNode() { - return dataNode(); + return roles.contains(Role.DATA); } /** 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 160026534a1..f388d440724 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -675,7 +675,7 @@ public class DiscoveryNodes extends AbstractDiffable implements Version minNodeVersion = Version.CURRENT; Version minNonClientNodeVersion = Version.CURRENT; for (ObjectObjectCursor nodeEntry : nodes) { - if (nodeEntry.value.dataNode()) { + if (nodeEntry.value.isDataNode()) { dataNodesBuilder.put(nodeEntry.key, nodeEntry.value); minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.version()); } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AbstractAllocateAllocationCommand.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AbstractAllocateAllocationCommand.java index 3a89507871e..d16a9aca9fe 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AbstractAllocateAllocationCommand.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AbstractAllocateAllocationCommand.java @@ -184,7 +184,7 @@ public abstract class AbstractAllocateAllocationCommand implements AllocationCom * Handle case where a disco node cannot be found in the routing table. Usually means that it's not a data node. */ protected RerouteExplanation explainOrThrowMissingRoutingNode(RoutingAllocation allocation, boolean explain, DiscoveryNode discoNode) { - if (!discoNode.dataNode()) { + if (!discoNode.isDataNode()) { return explainOrThrowRejectedCommand(explain, allocation, "allocation can only be done on data nodes, not [" + node + "]"); } else { return explainOrThrowRejectedCommand(explain, allocation, "could not find [" + node + "] among the routing nodes"); diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java index 867b7420107..348d620cef7 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java @@ -118,7 +118,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL Set relevantIndices = Collections.emptySet(); boolean success = true; // write the state if this node is a master eligible node or if it is a data node and has shards allocated on it - if (state.nodes().localNode().masterNode() || state.nodes().localNode().dataNode()) { + if (state.nodes().localNode().masterNode() || state.nodes().localNode().isDataNode()) { if (previousMetaData == null) { try { // we determine if or if not we write meta data on data only nodes by looking at the shard routing @@ -188,7 +188,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL protected static boolean isDataOnlyNode(ClusterState state) { - return ((state.nodes().localNode().masterNode() == false) && state.nodes().localNode().dataNode()); + return ((state.nodes().localNode().masterNode() == false) && state.nodes().localNode().isDataNode()); } /** diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java index 2d1d7fe71af..079c4a65ec0 100644 --- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java +++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java @@ -46,7 +46,7 @@ public class TransportClientIT extends ESIntegTestCase { String nodeName = internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false)); TransportClient client = (TransportClient) internalCluster().client(nodeName); - assertThat(client.connectedNodes().get(0).dataNode(), equalTo(false)); + assertThat(client.connectedNodes().get(0).isDataNode(), equalTo(false)); } diff --git a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java index 7313d880a63..2d7d8843eea 100644 --- a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java +++ b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java @@ -436,7 +436,7 @@ public class TribeIT extends ESIntegTestCase { private int countDataNodesForTribe(String tribeName, DiscoveryNodes nodes) { int count = 0; for (DiscoveryNode node : nodes) { - if (!node.dataNode()) { + if (!node.isDataNode()) { continue; } if (tribeName.equals(node.getAttributes().get("tribe.name"))) { From 41039a64310bd42ef81aedf1c93177308fa4d839 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 14:52:39 +0200 Subject: [PATCH 04/25] Remove DiscoveryNode#masterNode in favour of existing DiscoveryNode#isMasterNode --- .../org/elasticsearch/cluster/node/DiscoveryNode.java | 9 +-------- .../org/elasticsearch/cluster/node/DiscoveryNodes.java | 2 +- .../elasticsearch/discovery/local/LocalDiscovery.java | 4 ++-- .../org/elasticsearch/discovery/zen/ZenDiscovery.java | 2 +- .../discovery/zen/elect/ElectMasterService.java | 8 ++++---- .../org/elasticsearch/gateway/GatewayAllocator.java | 2 +- .../org/elasticsearch/gateway/GatewayMetaState.java | 6 +++--- .../java/org/elasticsearch/indices/IndicesService.java | 2 +- .../repositories/RepositoriesService.java | 4 ++-- .../discovery/zen/ElectMasterServiceTests.java | 10 +++++----- 10 files changed, 21 insertions(+), 28 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index c5e91413f02..3533f849a7e 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -249,18 +249,11 @@ public class DiscoveryNode implements Writeable, ToXContent { return roles.contains(Role.DATA); } - /** - * Can this node become master or not. - */ - public boolean masterNode() { - return roles.contains(Role.MASTER); - } - /** * Can this node become master or not. */ public boolean isMasterNode() { - return masterNode(); + return roles.contains(Role.MASTER); } /** 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 f388d440724..3fa192cb9c1 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -679,7 +679,7 @@ public class DiscoveryNodes extends AbstractDiffable implements dataNodesBuilder.put(nodeEntry.key, nodeEntry.value); minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.version()); } - if (nodeEntry.value.masterNode()) { + if (nodeEntry.value.isMasterNode()) { masterNodesBuilder.put(nodeEntry.key, nodeEntry.value); minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.version()); } diff --git a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java index 89395c86bd9..256c18e1972 100644 --- a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java @@ -106,7 +106,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem LocalDiscovery firstMaster = null; for (LocalDiscovery localDiscovery : clusterGroup.members()) { - if (localDiscovery.localNode().masterNode()) { + if (localDiscovery.localNode().isMasterNode()) { firstMaster = localDiscovery; break; } @@ -193,7 +193,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem LocalDiscovery firstMaster = null; for (LocalDiscovery localDiscovery : clusterGroup.members()) { - if (localDiscovery.localNode().masterNode()) { + if (localDiscovery.localNode().isMasterNode()) { firstMaster = localDiscovery; break; } 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 3b61d7e6cf8..9046eb76474 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -863,7 +863,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen Set activeNodes = new HashSet<>(); // nodes discovered who has previously been part of the cluster and do not ping for the very first time Set joinedOnceActiveNodes = new HashSet<>(); - if (localNode.masterNode()) { + if (localNode.isMasterNode()) { activeNodes.add(localNode); long joinsCounter = clusterJoinsCounter.get(); if (joinsCounter > 0) { diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java b/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java index fd60993cbf8..2870037eeb7 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java @@ -73,7 +73,7 @@ public class ElectMasterService extends AbstractComponent { } int count = 0; for (DiscoveryNode node : nodes) { - if (node.masterNode()) { + if (node.isMasterNode()) { count++; } } @@ -136,7 +136,7 @@ public class ElectMasterService extends AbstractComponent { // clean non master nodes for (Iterator it = possibleNodes.iterator(); it.hasNext(); ) { DiscoveryNode node = it.next(); - if (!node.masterNode()) { + if (!node.isMasterNode()) { it.remove(); } } @@ -148,10 +148,10 @@ public class ElectMasterService extends AbstractComponent { @Override public int compare(DiscoveryNode o1, DiscoveryNode o2) { - if (o1.masterNode() && !o2.masterNode()) { + if (o1.isMasterNode() && !o2.isMasterNode()) { return -1; } - if (!o1.masterNode() && o2.masterNode()) { + if (!o1.isMasterNode() && o2.isMasterNode()) { return 1; } return o1.getId().compareTo(o2.getId()); diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java b/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java index 0059a0ef61b..f8fcaa43286 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java @@ -70,7 +70,7 @@ public class GatewayAllocator extends AbstractComponent { boolean cleanCache = false; DiscoveryNode localNode = event.state().nodes().localNode(); if (localNode != null) { - if (localNode.masterNode() == true && event.localNodeMaster() == false) { + if (localNode.isMasterNode() == true && event.localNodeMaster() == false) { cleanCache = true; } } else { diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java index 348d620cef7..22c3287f31c 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java @@ -118,7 +118,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL Set relevantIndices = Collections.emptySet(); boolean success = true; // write the state if this node is a master eligible node or if it is a data node and has shards allocated on it - if (state.nodes().localNode().masterNode() || state.nodes().localNode().isDataNode()) { + if (state.nodes().localNode().isMasterNode() || state.nodes().localNode().isDataNode()) { if (previousMetaData == null) { try { // we determine if or if not we write meta data on data only nodes by looking at the shard routing @@ -178,7 +178,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL Set relevantIndices; if (isDataOnlyNode(state)) { relevantIndices = getRelevantIndicesOnDataOnlyNode(state, previousState, previouslyWrittenIndices); - } else if (state.nodes().localNode().masterNode() == true) { + } else if (state.nodes().localNode().isMasterNode() == true) { relevantIndices = getRelevantIndicesForMasterEligibleNode(state); } else { relevantIndices = Collections.emptySet(); @@ -188,7 +188,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL protected static boolean isDataOnlyNode(ClusterState state) { - return ((state.nodes().localNode().masterNode() == false) && state.nodes().localNode().isDataNode()); + return ((state.nodes().localNode().isMasterNode() == false) && state.nodes().localNode().isDataNode()); } /** diff --git a/core/src/main/java/org/elasticsearch/indices/IndicesService.java b/core/src/main/java/org/elasticsearch/indices/IndicesService.java index 2719075a5c7..1f3482cd60a 100644 --- a/core/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/core/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -535,7 +535,7 @@ public class IndicesService extends AbstractLifecycleComponent i throw new IllegalStateException("Can't delete index store for [" + index.getName() + "] - it's still part of the indices service [" + localUUid + "] [" + metaData.getIndexUUID() + "]"); } - if (clusterState.metaData().hasIndex(index.getName()) && (clusterState.nodes().localNode().masterNode() == true)) { + if (clusterState.metaData().hasIndex(index.getName()) && (clusterState.nodes().localNode().isMasterNode() == true)) { // we do not delete the store if it is a master eligible node and the index is still in the cluster state // because we want to keep the meta data for indices around even if no shards are left here final IndexMetaData idxMeta = clusterState.metaData().index(index.getName()); diff --git a/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java b/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java index da2d9688095..8c6ab070fc6 100644 --- a/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java +++ b/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java @@ -154,7 +154,7 @@ public class RepositoriesService extends AbstractComponent implements ClusterSta @Override public boolean mustAck(DiscoveryNode discoveryNode) { - return discoveryNode.masterNode(); + return discoveryNode.isMasterNode(); } }); } @@ -205,7 +205,7 @@ public class RepositoriesService extends AbstractComponent implements ClusterSta @Override public boolean mustAck(DiscoveryNode discoveryNode) { // Since operation occurs only on masters, it's enough that only master-eligible nodes acked - return discoveryNode.masterNode(); + return discoveryNode.isMasterNode(); } }); } diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java index 3025866e061..498aff28ee6 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java @@ -65,9 +65,9 @@ public class ElectMasterServiceTests extends ESTestCase { DiscoveryNode prevNode = sortedNodes.get(0); for (int i = 1; i < sortedNodes.size(); i++) { DiscoveryNode node = sortedNodes.get(i); - if (!prevNode.masterNode()) { - assertFalse(node.masterNode()); - } else if (node.masterNode()) { + if (!prevNode.isMasterNode()) { + assertFalse(node.isMasterNode()); + } else if (node.isMasterNode()) { assertTrue(prevNode.getId().compareTo(node.getId()) < 0); } prevNode = node; @@ -83,7 +83,7 @@ public class ElectMasterServiceTests extends ESTestCase { int master_nodes = 0; for (DiscoveryNode node : nodes) { - if (node.masterNode()) { + if (node.isMasterNode()) { master_nodes++; } } @@ -99,7 +99,7 @@ public class ElectMasterServiceTests extends ESTestCase { } else { assertNotNull(master); for (DiscoveryNode node : nodes) { - if (node.masterNode()) { + if (node.isMasterNode()) { assertTrue(master.getId().compareTo(node.getId()) <= 0); } } From 00f5ca57facdd6089959d5ba56296663313c0064 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 14:54:42 +0200 Subject: [PATCH 05/25] Remove DiscoveryNode#address in favour of existing DiscoveryNode#getAddress --- .../admin/cluster/node/info/NodesInfoResponse.java | 2 +- .../action/admin/cluster/node/stats/NodeStats.java | 2 +- .../cluster/node/tasks/list/ListTasksResponse.java | 2 +- .../client/transport/TransportClientNodesService.java | 6 +++--- .../org/elasticsearch/cluster/node/DiscoveryNode.java | 11 ++--------- .../cluster/node/DiscoveryNodeFilters.java | 8 ++++---- .../elasticsearch/cluster/node/DiscoveryNodes.java | 2 +- .../discovery/zen/NodeJoinController.java | 2 +- .../org/elasticsearch/discovery/zen/ZenDiscovery.java | 2 +- .../discovery/zen/ping/unicast/UnicastZenPing.java | 2 +- .../elasticsearch/indices/recovery/RecoveryState.java | 4 ++-- .../rest/action/cat/RestNodeAttrsAction.java | 4 ++-- .../rest/action/cat/RestNodesAction.java | 4 ++-- .../rest/action/cat/RestThreadPoolAction.java | 4 ++-- .../transport/ConnectTransportException.java | 2 +- .../transport/ReceiveTimeoutTransportException.java | 2 +- .../transport/SendRequestTransportException.java | 2 +- .../elasticsearch/transport/local/LocalTransport.java | 2 +- .../elasticsearch/transport/netty/NettyTransport.java | 4 ++-- .../java/org/elasticsearch/tribe/TribeService.java | 2 +- .../bwcompat/ClusterStateBackwardsCompatIT.java | 4 ++-- .../bwcompat/NodesStatsBasicBackwardsCompatIT.java | 4 ++-- .../org/elasticsearch/cluster/ClusterStateDiffIT.java | 2 +- .../transport/AbstractSimpleTransportTestCase.java | 4 ++-- 24 files changed, 38 insertions(+), 45 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java index 9c3c77ee85e..79eab0f61a0 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java @@ -71,7 +71,7 @@ public class NodesInfoResponse extends BaseNodesResponse implements To builder.startObject(nodeInfo.getNode().getId(), XContentBuilder.FieldCaseConversion.NONE); builder.field("name", nodeInfo.getNode().getName(), XContentBuilder.FieldCaseConversion.NONE); - builder.field("transport_address", nodeInfo.getNode().address().toString()); + builder.field("transport_address", nodeInfo.getNode().getAddress().toString()); builder.field("host", nodeInfo.getNode().getHostName(), XContentBuilder.FieldCaseConversion.NONE); builder.field("ip", nodeInfo.getNode().getHostAddress(), XContentBuilder.FieldCaseConversion.NONE); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java index 99fae604a6f..ce16a848fc6 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java @@ -300,7 +300,7 @@ public class NodeStats extends BaseNodeResponse implements ToXContent { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (!params.param("node_info_format", "default").equals("none")) { builder.field("name", getNode().getName(), XContentBuilder.FieldCaseConversion.NONE); - builder.field("transport_address", getNode().address().toString(), XContentBuilder.FieldCaseConversion.NONE); + builder.field("transport_address", getNode().getAddress().toString(), XContentBuilder.FieldCaseConversion.NONE); builder.field("host", getNode().getHostName(), XContentBuilder.FieldCaseConversion.NONE); builder.field("ip", getNode().getAddress(), XContentBuilder.FieldCaseConversion.NONE); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java index a8e833eb46f..4119e08a757 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java @@ -125,7 +125,7 @@ public class ListTasksResponse extends BaseTasksResponse implements ToXContent { DiscoveryNode node = entry.getKey(); builder.startObject(node.getId(), XContentBuilder.FieldCaseConversion.NONE); builder.field("name", node.getName()); - builder.field("transport_address", node.address().toString()); + builder.field("transport_address", node.getAddress().toString()); builder.field("host", node.getHostName()); builder.field("ip", node.getAddress()); diff --git a/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java b/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java index d94f3bacfc3..a91fb09144e 100644 --- a/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java +++ b/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java @@ -138,7 +138,7 @@ public class TransportClientNodesService extends AbstractComponent { public List transportAddresses() { List lstBuilder = new ArrayList<>(); for (DiscoveryNode listedNode : listedNodes) { - lstBuilder.add(listedNode.address()); + lstBuilder.add(listedNode.getAddress()); } return Collections.unmodifiableList(lstBuilder); } @@ -164,7 +164,7 @@ public class TransportClientNodesService extends AbstractComponent { for (TransportAddress transportAddress : transportAddresses) { boolean found = false; for (DiscoveryNode otherNode : listedNodes) { - if (otherNode.address().equals(transportAddress)) { + if (otherNode.getAddress().equals(transportAddress)) { found = true; logger.debug("address [{}] already exists with [{}], ignoring...", transportAddress, otherNode); break; @@ -198,7 +198,7 @@ public class TransportClientNodesService extends AbstractComponent { } List builder = new ArrayList<>(); for (DiscoveryNode otherNode : listedNodes) { - if (!otherNode.address().equals(transportAddress)) { + if (!otherNode.getAddress().equals(transportAddress)) { builder.add(otherNode); } else { logger.debug("removing address [{}]", otherNode); diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 3533f849a7e..c3a7d2a44dc 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -207,18 +207,11 @@ public class DiscoveryNode implements Writeable, ToXContent { this.roles = Collections.unmodifiableSet(rolesSet); } - /** - * The address that the node can be communicated with. - */ - public TransportAddress address() { - return address; - } - /** * The address that the node can be communicated with. */ public TransportAddress getAddress() { - return address(); + return address; } /** @@ -351,7 +344,7 @@ public class DiscoveryNode implements Writeable, ToXContent { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(getId(), XContentBuilder.FieldCaseConversion.NONE); builder.field("name", getName()); - builder.field("transport_address", address().toString()); + builder.field("transport_address", getAddress().toString()); builder.startObject("attributes"); for (Map.Entry entry : attributes.entrySet()) { diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java index 9d45de84445..e8ede54f4a2 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java @@ -82,8 +82,8 @@ public class DiscoveryNodeFilters { if ("_ip".equals(attr)) { // We check both the host_ip or the publish_ip String publishAddress = null; - if (node.address() instanceof InetSocketTransportAddress) { - publishAddress = NetworkAddress.format(((InetSocketTransportAddress) node.address()).address().getAddress()); + if (node.getAddress() instanceof InetSocketTransportAddress) { + publishAddress = NetworkAddress.format(((InetSocketTransportAddress) node.getAddress()).address().getAddress()); } boolean match = matchByIP(values, node.getHostAddress(), publishAddress); @@ -116,8 +116,8 @@ public class DiscoveryNodeFilters { } else if ("_publish_ip".equals(attr)) { // We check explicitly only the publish_ip String address = null; - if (node.address() instanceof InetSocketTransportAddress) { - address = NetworkAddress.format(((InetSocketTransportAddress) node.address()).address().getAddress()); + if (node.getAddress() instanceof InetSocketTransportAddress) { + address = NetworkAddress.format(((InetSocketTransportAddress) node.getAddress()).address().getAddress()); } boolean match = matchByIP(values, address, null); 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 3fa192cb9c1..37cbbc95af1 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -287,7 +287,7 @@ public class DiscoveryNodes extends AbstractDiffable implements public DiscoveryNode findByAddress(TransportAddress address) { for (ObjectCursor cursor : nodes.values()) { DiscoveryNode node = cursor.value; - if (node.address().equals(address)) { + if (node.getAddress().equals(address)) { return node; } } diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java index bc5acba6286..7b0cf8361b3 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java @@ -384,7 +384,7 @@ public class NodeJoinController extends AbstractComponent { nodeAdded = true; nodesBuilder.put(node); for (DiscoveryNode existingNode : currentState.nodes()) { - if (node.address().equals(existingNode.address())) { + if (node.getAddress().equals(existingNode.getAddress())) { nodesBuilder.remove(existingNode.getId()); logger.warn("received join request from node [{}], but found existing node {} with same address, removing existing node", node, existingNode); } 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 9046eb76474..b83e8e4aa72 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -793,7 +793,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } void handleJoinRequest(final DiscoveryNode node, final ClusterState state, final MembershipAction.JoinCallback callback) { - if (!transportService.addressSupported(node.address().getClass())) { + if (!transportService.addressSupported(node.getAddress().getClass())) { // TODO, what should we do now? Maybe inform that node that its crap? logger.warn("received a wrong address type from [{}], ignoring...", node); } else if (nodeJoinController == null) { diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java index 93021a9d3a6..0135b53a844 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java @@ -360,7 +360,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen for (final DiscoveryNode node : nodesToPing) { // make sure we are connected final boolean nodeFoundByAddress; - DiscoveryNode nodeToSend = discoNodes.findByAddress(node.address()); + DiscoveryNode nodeToSend = discoNodes.findByAddress(node.getAddress()); if (nodeToSend != null) { nodeFoundByAddress = true; } else { diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java index 0a2b970c15a..6eccf8f02db 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java @@ -318,7 +318,7 @@ public class RecoveryState implements ToXContent, Streamable { builder.startObject(Fields.SOURCE); builder.field(Fields.ID, sourceNode.getId()); builder.field(Fields.HOST, sourceNode.getHostName()); - builder.field(Fields.TRANSPORT_ADDRESS, sourceNode.address().toString()); + builder.field(Fields.TRANSPORT_ADDRESS, sourceNode.getAddress().toString()); builder.field(Fields.IP, sourceNode.getHostAddress()); builder.field(Fields.NAME, sourceNode.getName()); builder.endObject(); @@ -327,7 +327,7 @@ public class RecoveryState implements ToXContent, Streamable { builder.startObject(Fields.TARGET); builder.field(Fields.ID, targetNode.getId()); builder.field(Fields.HOST, targetNode.getHostName()); - builder.field(Fields.TRANSPORT_ADDRESS, targetNode.address().toString()); + builder.field(Fields.TRANSPORT_ADDRESS, targetNode.getAddress().toString()); builder.field(Fields.IP, targetNode.getHostAddress()); builder.field(Fields.NAME, targetNode.getName()); builder.endObject(); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java index 99e8d630a40..2190e1e2993 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java @@ -110,8 +110,8 @@ public class RestNodeAttrsAction extends AbstractCatAction { table.addCell(info == null ? null : info.getProcess().getId()); table.addCell(node.getHostName()); table.addCell(node.getHostAddress()); - if (node.address() instanceof InetSocketTransportAddress) { - table.addCell(((InetSocketTransportAddress) node.address()).address().getPort()); + if (node.getAddress() instanceof InetSocketTransportAddress) { + table.addCell(((InetSocketTransportAddress) node.getAddress()).address().getPort()); } else { table.addCell("-"); } diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java index 85e3bd36354..b3dc1952913 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java @@ -242,8 +242,8 @@ public class RestNodesAction extends AbstractCatAction { table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4)); table.addCell(info == null ? null : info.getProcess().getId()); table.addCell(node.getHostAddress()); - if (node.address() instanceof InetSocketTransportAddress) { - table.addCell(((InetSocketTransportAddress) node.address()).address().getPort()); + if (node.getAddress() instanceof InetSocketTransportAddress) { + table.addCell(((InetSocketTransportAddress) node.getAddress()).address().getPort()); } else { table.addCell("-"); } diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java index 9116ac15a98..2ade4a1db39 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java @@ -234,8 +234,8 @@ public class RestThreadPoolAction extends AbstractCatAction { table.addCell(info == null ? null : info.getProcess().getId()); table.addCell(node.getHostName()); table.addCell(node.getHostAddress()); - if (node.address() instanceof InetSocketTransportAddress) { - table.addCell(((InetSocketTransportAddress) node.address()).address().getPort()); + if (node.getAddress() instanceof InetSocketTransportAddress) { + table.addCell(((InetSocketTransportAddress) node.getAddress()).address().getPort()); } else { table.addCell("-"); } diff --git a/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java b/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java index f24f5f80c06..0d36733cbbc 100644 --- a/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java +++ b/core/src/main/java/org/elasticsearch/transport/ConnectTransportException.java @@ -45,7 +45,7 @@ public class ConnectTransportException extends ActionTransportException { } public ConnectTransportException(DiscoveryNode node, String msg, String action, Throwable cause) { - super(node == null ? null : node.getName(), node == null ? null : node.address(), action, msg, cause); + super(node == null ? null : node.getName(), node == null ? null : node.getAddress(), action, msg, cause); this.node = node; } diff --git a/core/src/main/java/org/elasticsearch/transport/ReceiveTimeoutTransportException.java b/core/src/main/java/org/elasticsearch/transport/ReceiveTimeoutTransportException.java index 75504a90eec..6245a1afd22 100644 --- a/core/src/main/java/org/elasticsearch/transport/ReceiveTimeoutTransportException.java +++ b/core/src/main/java/org/elasticsearch/transport/ReceiveTimeoutTransportException.java @@ -30,7 +30,7 @@ import java.io.IOException; public class ReceiveTimeoutTransportException extends ActionTransportException { public ReceiveTimeoutTransportException(DiscoveryNode node, String action, String msg) { - super(node.getName(), node.address(), action, msg, null); + super(node.getName(), node.getAddress(), action, msg, null); } public ReceiveTimeoutTransportException(StreamInput in) throws IOException { diff --git a/core/src/main/java/org/elasticsearch/transport/SendRequestTransportException.java b/core/src/main/java/org/elasticsearch/transport/SendRequestTransportException.java index 3870bf59553..41c743c775e 100644 --- a/core/src/main/java/org/elasticsearch/transport/SendRequestTransportException.java +++ b/core/src/main/java/org/elasticsearch/transport/SendRequestTransportException.java @@ -31,7 +31,7 @@ import java.io.IOException; public class SendRequestTransportException extends ActionTransportException implements ElasticsearchWrapperException { public SendRequestTransportException(DiscoveryNode node, String action, Throwable cause) { - super(node == null ? null : node.getName(), node == null ? null : node.address(), action, cause); + super(node == null ? null : node.getName(), node == null ? null : node.getAddress(), action, cause); } public SendRequestTransportException(StreamInput in) throws IOException { diff --git a/core/src/main/java/org/elasticsearch/transport/local/LocalTransport.java b/core/src/main/java/org/elasticsearch/transport/local/LocalTransport.java index a7783148ef3..aed46a56f96 100644 --- a/core/src/main/java/org/elasticsearch/transport/local/LocalTransport.java +++ b/core/src/main/java/org/elasticsearch/transport/local/LocalTransport.java @@ -175,7 +175,7 @@ public class LocalTransport extends AbstractLifecycleComponent implem if (connectedNodes.containsKey(node)) { return; } - final LocalTransport targetTransport = transports.get(node.address()); + final LocalTransport targetTransport = transports.get(node.getAddress()); if (targetTransport == null) { throw new ConnectTransportException(node, "Failed to connect"); } diff --git a/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java b/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java index f76f7b0d158..84da18b2a09 100644 --- a/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java +++ b/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java @@ -993,7 +993,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem } protected NodeChannels connectToChannelsLight(DiscoveryNode node) { - InetSocketAddress address = ((InetSocketTransportAddress) node.address()).address(); + InetSocketAddress address = ((InetSocketTransportAddress) node.getAddress()).address(); ChannelFuture connect = clientBootstrap.connect(address); connect.awaitUninterruptibly((long) (connectTimeout.millis() * 1.5)); if (!connect.isSuccess()) { @@ -1011,7 +1011,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem ChannelFuture[] connectReg = new ChannelFuture[nodeChannels.reg.length]; ChannelFuture[] connectState = new ChannelFuture[nodeChannels.state.length]; ChannelFuture[] connectPing = new ChannelFuture[nodeChannels.ping.length]; - InetSocketAddress address = ((InetSocketTransportAddress) node.address()).address(); + InetSocketAddress address = ((InetSocketTransportAddress) node.getAddress()).address(); for (int i = 0; i < connectRecovery.length; i++) { connectRecovery[i] = clientBootstrap.connect(address); } diff --git a/core/src/main/java/org/elasticsearch/tribe/TribeService.java b/core/src/main/java/org/elasticsearch/tribe/TribeService.java index 675f8332705..0802ed64099 100644 --- a/core/src/main/java/org/elasticsearch/tribe/TribeService.java +++ b/core/src/main/java/org/elasticsearch/tribe/TribeService.java @@ -367,7 +367,7 @@ public class TribeService extends AbstractLifecycleComponent { Map tribeAttr = new HashMap<>(tribe.getAttributes()); tribeAttr.put(TRIBE_NAME_SETTING.getKey(), tribeName); DiscoveryNode discoNode = new DiscoveryNode(tribe.getName(), tribe.getId(), tribe.getHostName(), tribe.getHostAddress(), - tribe.address(), unmodifiableMap(tribeAttr), tribe.getRoles(), tribe.version()); + tribe.getAddress(), unmodifiableMap(tribeAttr), tribe.getRoles(), tribe.version()); clusterStateChanged = true; logger.info("[{}] adding node [{}]", tribeName, discoNode); nodes.put(discoNode); diff --git a/core/src/test/java/org/elasticsearch/bwcompat/ClusterStateBackwardsCompatIT.java b/core/src/test/java/org/elasticsearch/bwcompat/ClusterStateBackwardsCompatIT.java index 665aa5217ac..108fcefecd4 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/ClusterStateBackwardsCompatIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/ClusterStateBackwardsCompatIT.java @@ -46,7 +46,7 @@ public class ClusterStateBackwardsCompatIT extends ESBackcompatTestCase { // connect to each node with a custom TransportClient, issue a ClusterStateRequest to test serialization for (NodeInfo n : clusterNodes()) { try (TransportClient tc = newTransportClient()) { - tc.addTransportAddress(n.getNode().address()); + tc.addTransportAddress(n.getNode().getAddress()); ClusterStateResponse response = tc.admin().cluster().prepareState().execute().actionGet(); assertThat(response.getState().status(), equalTo(ClusterState.ClusterStateStatus.UNKNOWN)); @@ -70,7 +70,7 @@ public class ClusterStateBackwardsCompatIT extends ESBackcompatTestCase { for (NodeInfo n : clusterNodes()) { try (TransportClient tc = newTransportClient()) { - tc.addTransportAddress(n.getNode().address()); + tc.addTransportAddress(n.getNode().getAddress()); ClusterStateResponse response = tc.admin().cluster().prepareState().setIndices("test-blocks") .setBlocks(true).setNodes(false).execute().actionGet(); diff --git a/core/src/test/java/org/elasticsearch/bwcompat/NodesStatsBasicBackwardsCompatIT.java b/core/src/test/java/org/elasticsearch/bwcompat/NodesStatsBasicBackwardsCompatIT.java index 39ed23b9779..29d4fdeb3b5 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/NodesStatsBasicBackwardsCompatIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/NodesStatsBasicBackwardsCompatIT.java @@ -44,7 +44,7 @@ public class NodesStatsBasicBackwardsCompatIT extends ESBackcompatTestCase { // We explicitly connect to each node with a custom TransportClient for (NodeInfo n : nodesInfo.getNodes()) { - TransportClient tc = TransportClient.builder().settings(settings).build().addTransportAddress(n.getNode().address()); + TransportClient tc = TransportClient.builder().settings(settings).build().addTransportAddress(n.getNode().getAddress()); // Just verify that the NS can be sent and serialized/deserialized between nodes with basic indices NodesStatsResponse ns = tc.admin().cluster().prepareNodesStats().setIndices(true).execute().actionGet(); tc.close(); @@ -62,7 +62,7 @@ public class NodesStatsBasicBackwardsCompatIT extends ESBackcompatTestCase { // We explicitly connect to each node with a custom TransportClient for (NodeInfo n : nodesInfo.getNodes()) { - TransportClient tc = TransportClient.builder().settings(settings).build().addTransportAddress(n.getNode().address()); + TransportClient tc = TransportClient.builder().settings(settings).build().addTransportAddress(n.getNode().getAddress()); // randomize the combination of flags set // Uses reflection to find methods in an attempt to future-proof this test against newly added flags diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java index 7a3ee125465..059bda8082d 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java @@ -140,7 +140,7 @@ public class ClusterStateDiffIT extends ESIntegTestCase { DiscoveryNode node1 = clusterState.nodes().get(node.value); DiscoveryNode node2 = clusterStateFromDiffs.nodes().get(node.value); assertThat(node1.version(), equalTo(node2.version())); - assertThat(node1.address(), equalTo(node2.address())); + assertThat(node1.getAddress(), equalTo(node2.getAddress())); assertThat(node1.getAttributes(), equalTo(node2.getAttributes())); } diff --git a/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java b/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java index c5744a736a4..38b1ef05335 100644 --- a/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java +++ b/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java @@ -1258,8 +1258,8 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase { fail("message round trip did not complete within a sensible time frame"); } - assertTrue(nodeA.address().sameHost(addressA.get())); - assertTrue(nodeB.address().sameHost(addressB.get())); + assertTrue(nodeA.getAddress().sameHost(addressA.get())); + assertTrue(nodeB.getAddress().sameHost(addressB.get())); } public void testBlockingIncomingRequests() throws Exception { From 3942c9e4df6b55dbd5e28535bd89de35f1e9fb9b Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 14:56:15 +0200 Subject: [PATCH 06/25] Remove DiscoveryNode#version in favour of existing DiscoveryNode#getVersion --- .../cluster/node/DiscoveryNode.java | 6 +----- .../cluster/node/DiscoveryNodes.java | 6 +++--- .../decider/NodeVersionAllocationDecider.java | 12 +++++------ .../publish/PublishClusterStateAction.java | 20 +++++++++---------- .../transport/local/LocalTransport.java | 2 +- .../transport/netty/NettyTransport.java | 4 ++-- .../org/elasticsearch/tribe/TribeService.java | 2 +- .../cluster/ClusterStateDiffIT.java | 2 +- .../NodeVersionAllocationDeciderTests.java | 18 ++++++++--------- .../discovery/zen/ZenDiscoveryIT.java | 2 +- 10 files changed, 35 insertions(+), 39 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index c3a7d2a44dc..340e00a71f3 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -264,7 +264,7 @@ public class DiscoveryNode implements Writeable, ToXContent { return roles; } - public Version version() { + public Version getVersion() { return this.version; } @@ -276,10 +276,6 @@ public class DiscoveryNode implements Writeable, ToXContent { return this.hostAddress; } - public Version getVersion() { - return this.version; - } - @Override public DiscoveryNode readFrom(StreamInput in) throws IOException { return new DiscoveryNode(in); 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 37cbbc95af1..f41e3c50682 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -677,16 +677,16 @@ public class DiscoveryNodes extends AbstractDiffable implements for (ObjectObjectCursor nodeEntry : nodes) { if (nodeEntry.value.isDataNode()) { dataNodesBuilder.put(nodeEntry.key, nodeEntry.value); - minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.version()); + minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.getVersion()); } if (nodeEntry.value.isMasterNode()) { masterNodesBuilder.put(nodeEntry.key, nodeEntry.value); - minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.version()); + minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.getVersion()); } if (nodeEntry.value.isIngestNode()) { ingestNodesBuilder.put(nodeEntry.key, nodeEntry.value); } - minNodeVersion = Version.smallest(minNodeVersion, nodeEntry.value.version()); + minNodeVersion = Version.smallest(minNodeVersion, nodeEntry.value.getVersion()); } return new DiscoveryNodes( diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/NodeVersionAllocationDecider.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/NodeVersionAllocationDecider.java index 95540d89a6f..17ac486a8ce 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/NodeVersionAllocationDecider.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/NodeVersionAllocationDecider.java @@ -73,26 +73,26 @@ public class NodeVersionAllocationDecider extends AllocationDecider { private Decision isVersionCompatible(final RoutingNodes routingNodes, final String sourceNodeId, final RoutingNode target, RoutingAllocation allocation) { final RoutingNode source = routingNodes.node(sourceNodeId); - if (target.node().version().onOrAfter(source.node().version())) { + if (target.node().getVersion().onOrAfter(source.node().getVersion())) { /* we can allocate if we can recover from a node that is younger or on the same version * if the primary is already running on a newer version that won't work due to possible * differences in the lucene index format etc.*/ return allocation.decision(Decision.YES, NAME, "target node version [%s] is the same or newer than source node version [%s]", - target.node().version(), source.node().version()); + target.node().getVersion(), source.node().getVersion()); } else { return allocation.decision(Decision.NO, NAME, "target node version [%s] is older than the source node version [%s]", - target.node().version(), source.node().version()); + target.node().getVersion(), source.node().getVersion()); } } private Decision isVersionCompatible(RestoreSource restoreSource, final RoutingNode target, RoutingAllocation allocation) { - if (target.node().version().onOrAfter(restoreSource.version())) { + if (target.node().getVersion().onOrAfter(restoreSource.version())) { /* we can allocate if we can restore from a snapshot that is older or on the same version */ return allocation.decision(Decision.YES, NAME, "target node version [%s] is the same or newer than snapshot version [%s]", - target.node().version(), restoreSource.version()); + target.node().getVersion(), restoreSource.version()); } else { return allocation.decision(Decision.NO, NAME, "target node version [%s] is older than the snapshot version [%s]", - target.node().version(), restoreSource.version()); + target.node().getVersion(), restoreSource.version()); } } } 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 64b77588726..0c8d16c2cb8 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 @@ -212,16 +212,16 @@ public class PublishClusterStateAction extends AbstractComponent { try { if (sendFullVersion || !previousState.nodes().nodeExists(node.getId())) { // will send a full reference - if (serializedStates.containsKey(node.version()) == false) { - serializedStates.put(node.version(), serializeFullClusterState(clusterState, node.version())); + if (serializedStates.containsKey(node.getVersion()) == false) { + serializedStates.put(node.getVersion(), serializeFullClusterState(clusterState, node.getVersion())); } } else { // will send a diff if (diff == null) { diff = clusterState.diff(previousState); } - if (serializedDiffs.containsKey(node.version()) == false) { - serializedDiffs.put(node.version(), serializeDiffClusterState(diff, node.version())); + if (serializedDiffs.containsKey(node.getVersion()) == false) { + serializedDiffs.put(node.getVersion(), serializeDiffClusterState(diff, node.getVersion())); } } } catch (IOException e) { @@ -232,11 +232,11 @@ public class PublishClusterStateAction extends AbstractComponent { private void sendFullClusterState(ClusterState clusterState, Map serializedStates, DiscoveryNode node, TimeValue publishTimeout, SendingController sendingController) { - BytesReference bytes = serializedStates.get(node.version()); + BytesReference bytes = serializedStates.get(node.getVersion()); if (bytes == null) { try { - bytes = serializeFullClusterState(clusterState, node.version()); - serializedStates.put(node.version(), bytes); + bytes = serializeFullClusterState(clusterState, node.getVersion()); + serializedStates.put(node.getVersion(), bytes); } catch (Throwable e) { logger.warn("failed to serialize cluster_state before publishing it to node {}", e, node); sendingController.onNodeSendFailed(node, e); @@ -249,8 +249,8 @@ public class PublishClusterStateAction extends AbstractComponent { private void sendClusterStateDiff(ClusterState clusterState, Map serializedDiffs, Map serializedStates, DiscoveryNode node, TimeValue publishTimeout, SendingController sendingController) { - BytesReference bytes = serializedDiffs.get(node.version()); - assert bytes != null : "failed to find serialized diff for node " + node + " of version [" + node.version() + "]"; + BytesReference bytes = serializedDiffs.get(node.getVersion()); + assert bytes != null : "failed to find serialized diff for node " + node + " of version [" + node.getVersion() + "]"; sendClusterStateToNode(clusterState, bytes, node, publishTimeout, sendingController, true, serializedStates); } @@ -266,7 +266,7 @@ public class PublishClusterStateAction extends AbstractComponent { // -> no need to compress, we already compressed the bytes TransportRequestOptions options = TransportRequestOptions.builder().withType(TransportRequestOptions.Type.STATE).withCompress(false).build(); transportService.sendRequest(node, SEND_ACTION_NAME, - new BytesTransportRequest(bytes, node.version()), + new BytesTransportRequest(bytes, node.getVersion()), options, new EmptyTransportResponseHandler(ThreadPool.Names.SAME) { diff --git a/core/src/main/java/org/elasticsearch/transport/local/LocalTransport.java b/core/src/main/java/org/elasticsearch/transport/local/LocalTransport.java index aed46a56f96..8585e54f50d 100644 --- a/core/src/main/java/org/elasticsearch/transport/local/LocalTransport.java +++ b/core/src/main/java/org/elasticsearch/transport/local/LocalTransport.java @@ -202,7 +202,7 @@ public class LocalTransport extends AbstractLifecycleComponent implem @Override public void sendRequest(final DiscoveryNode node, final long requestId, final String action, final TransportRequest request, TransportRequestOptions options) throws IOException, TransportException { - final Version version = Version.smallest(node.version(), this.version); + final Version version = Version.smallest(node.getVersion(), this.version); try (BytesStreamOutput stream = new BytesStreamOutput()) { stream.setVersion(version); diff --git a/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java b/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java index 84da18b2a09..5b9029fa03e 100644 --- a/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java +++ b/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java @@ -887,7 +887,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem // we pick the smallest of the 2, to support both backward and forward compatibility // note, this is the only place we need to do this, since from here on, we use the serialized version // as the version to use also when the node receiving this request will send the response with - Version version = Version.smallest(this.version, node.version()); + Version version = Version.smallest(this.version, node.getVersion()); stream.setVersion(version); threadPool.getThreadContext().writeTo(stream); @@ -900,7 +900,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem // more explicit). if (request instanceof BytesTransportRequest) { BytesTransportRequest bRequest = (BytesTransportRequest) request; - assert node.version().equals(bRequest.version()); + assert node.getVersion().equals(bRequest.version()); bRequest.writeThin(stream); stream.close(); bytes = bStream.bytes(); diff --git a/core/src/main/java/org/elasticsearch/tribe/TribeService.java b/core/src/main/java/org/elasticsearch/tribe/TribeService.java index 0802ed64099..a6cfec81126 100644 --- a/core/src/main/java/org/elasticsearch/tribe/TribeService.java +++ b/core/src/main/java/org/elasticsearch/tribe/TribeService.java @@ -367,7 +367,7 @@ public class TribeService extends AbstractLifecycleComponent { Map tribeAttr = new HashMap<>(tribe.getAttributes()); tribeAttr.put(TRIBE_NAME_SETTING.getKey(), tribeName); DiscoveryNode discoNode = new DiscoveryNode(tribe.getName(), tribe.getId(), tribe.getHostName(), tribe.getHostAddress(), - tribe.getAddress(), unmodifiableMap(tribeAttr), tribe.getRoles(), tribe.version()); + tribe.getAddress(), unmodifiableMap(tribeAttr), tribe.getRoles(), tribe.getVersion()); clusterStateChanged = true; logger.info("[{}] adding node [{}]", tribeName, discoNode); nodes.put(discoNode); diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java index 059bda8082d..00b8291957c 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java @@ -139,7 +139,7 @@ public class ClusterStateDiffIT extends ESIntegTestCase { for (ObjectCursor node : clusterStateFromDiffs.nodes().nodes().keys()) { DiscoveryNode node1 = clusterState.nodes().get(node.value); DiscoveryNode node2 = clusterStateFromDiffs.nodes().get(node.value); - assertThat(node1.version(), equalTo(node2.version())); + assertThat(node1.getVersion(), equalTo(node2.getVersion())); assertThat(node1.getAddress(), equalTo(node2.getAddress())); assertThat(node1.getAttributes(), equalTo(node2.getAttributes())); } diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java index ab3eb45ef7e..49e38d7adba 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java @@ -415,17 +415,17 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase { String fromId = r.currentNodeId(); assertThat(fromId, notNullValue()); assertThat(toId, notNullValue()); - logger.trace("From: {} with Version: {} to: {} with Version: {}", fromId, routingNodes.node(fromId).node().version(), - toId, routingNodes.node(toId).node().version()); - assertTrue(routingNodes.node(toId).node().version().onOrAfter(routingNodes.node(fromId).node().version())); + logger.trace("From: {} with Version: {} to: {} with Version: {}", fromId, routingNodes.node(fromId).node().getVersion(), + toId, routingNodes.node(toId).node().getVersion()); + assertTrue(routingNodes.node(toId).node().getVersion().onOrAfter(routingNodes.node(fromId).node().getVersion())); } else { ShardRouting primary = routingNodes.activePrimary(r); assertThat(primary, notNullValue()); String fromId = primary.currentNodeId(); String toId = r.relocatingNodeId(); - logger.trace("From: {} with Version: {} to: {} with Version: {}", fromId, routingNodes.node(fromId).node().version(), - toId, routingNodes.node(toId).node().version()); - assertTrue(routingNodes.node(toId).node().version().onOrAfter(routingNodes.node(fromId).node().version())); + logger.trace("From: {} with Version: {} to: {} with Version: {}", fromId, routingNodes.node(fromId).node().getVersion(), + toId, routingNodes.node(toId).node().getVersion()); + assertTrue(routingNodes.node(toId).node().getVersion().onOrAfter(routingNodes.node(fromId).node().getVersion())); } } @@ -436,9 +436,9 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase { assertThat(primary, notNullValue()); String fromId = primary.currentNodeId(); String toId = r.currentNodeId(); - logger.trace("From: {} with Version: {} to: {} with Version: {}", fromId, routingNodes.node(fromId).node().version(), - toId, routingNodes.node(toId).node().version()); - assertTrue(routingNodes.node(toId).node().version().onOrAfter(routingNodes.node(fromId).node().version())); + logger.trace("From: {} with Version: {} to: {} with Version: {}", fromId, routingNodes.node(fromId).node().getVersion(), + toId, routingNodes.node(toId).node().getVersion()); + assertTrue(routingNodes.node(toId).node().getVersion().onOrAfter(routingNodes.node(fromId).node().getVersion())); } } diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java index 9cd7cc9c99d..2dc53127684 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java @@ -197,7 +197,7 @@ public class ZenDiscoveryIT extends ESIntegTestCase { emptySet(), Version.CURRENT)).masterNodeId("abc"); ClusterState.Builder builder = ClusterState.builder(state); builder.nodes(nodes); - BytesReference bytes = PublishClusterStateAction.serializeFullClusterState(builder.build(), node.version()); + BytesReference bytes = PublishClusterStateAction.serializeFullClusterState(builder.build(), node.getVersion()); final CountDownLatch latch = new CountDownLatch(1); final AtomicReference reference = new AtomicReference<>(); From 2230fec9ea75c0725bf57995bd28312ec19bc259 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 14:57:36 +0200 Subject: [PATCH 07/25] Rename static DiscoveryNode#masterNode(Settings) to isMasterNode --- .../java/org/elasticsearch/cluster/node/DiscoveryNode.java | 2 +- .../main/java/org/elasticsearch/gateway/GatewayMetaState.java | 4 ++-- .../org/elasticsearch/repositories/RepositoriesService.java | 2 +- .../org/elasticsearch/snapshots/SnapshotShardsService.java | 2 +- .../java/org/elasticsearch/snapshots/SnapshotsService.java | 2 +- .../main/java/org/elasticsearch/test/ExternalTestCluster.java | 3 +-- .../main/java/org/elasticsearch/test/InternalTestCluster.java | 4 ++-- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 340e00a71f3..31a0f91ea38 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -68,7 +68,7 @@ public class DiscoveryNode implements Writeable, ToXContent { return Node.NODE_DATA_SETTING.get(settings) || Node.NODE_MASTER_SETTING.get(settings); } - public static boolean masterNode(Settings settings) { + public static boolean isMasterNode(Settings settings) { return Node.NODE_MASTER_SETTING.get(settings); } diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java index 22c3287f31c..52aa8cefdbf 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java @@ -80,10 +80,10 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL ensureNoPre019ShardState(nodeEnv); } - if (DiscoveryNode.masterNode(settings) || DiscoveryNode.dataNode(settings)) { + if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.dataNode(settings)) { nodeEnv.ensureAtomicMoveSupported(); } - if (DiscoveryNode.masterNode(settings) || DiscoveryNode.dataNode(settings)) { + if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.dataNode(settings)) { try { ensureNoPre019State(); IndexFolderUpgrader.upgradeIndicesIfNeeded(settings, nodeEnv); diff --git a/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java b/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java index 8c6ab070fc6..384a375903a 100644 --- a/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java +++ b/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java @@ -77,7 +77,7 @@ public class RepositoriesService extends AbstractComponent implements ClusterSta this.clusterService = clusterService; // Doesn't make sense to maintain repositories on non-master and non-data nodes // Nothing happens there anyway - if (DiscoveryNode.dataNode(settings) || DiscoveryNode.masterNode(settings)) { + if (DiscoveryNode.dataNode(settings) || DiscoveryNode.isMasterNode(settings)) { clusterService.add(this); } this.verifyAction = new VerifyNodeRepositoryAction(settings, transportService, clusterService, this); diff --git a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java index 9a0cc0f8cb0..000c387cc82 100644 --- a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java +++ b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java @@ -114,7 +114,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent { @Override public boolean test(NodeAndClient nodeAndClient) { - return DiscoveryNode.masterNode(nodeAndClient.node.settings()) == false && + return DiscoveryNode.isMasterNode(nodeAndClient.node.settings()) == false && DiscoveryNode.dataNode(nodeAndClient.node.settings()) == false; } } From 49e952e27229e592ad3608ef5731700f17acf9a3 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 14:58:28 +0200 Subject: [PATCH 08/25] Rename static DiscoveryNode#dataNode(Settings) to isDataNode --- .../java/org/elasticsearch/cluster/node/DiscoveryNode.java | 2 +- .../java/org/elasticsearch/gateway/GatewayMetaState.java | 6 +++--- .../org/elasticsearch/repositories/RepositoriesService.java | 2 +- .../org/elasticsearch/snapshots/SnapshotShardsService.java | 2 +- .../java/org/elasticsearch/test/ExternalTestCluster.java | 2 +- .../java/org/elasticsearch/test/InternalTestCluster.java | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 31a0f91ea38..1c2ad220ccd 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -72,7 +72,7 @@ public class DiscoveryNode implements Writeable, ToXContent { return Node.NODE_MASTER_SETTING.get(settings); } - public static boolean dataNode(Settings settings) { + public static boolean isDataNode(Settings settings) { return Node.NODE_DATA_SETTING.get(settings); } diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java index 52aa8cefdbf..a229b8ed5a1 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java @@ -76,14 +76,14 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL this.metaDataIndexUpgradeService = metaDataIndexUpgradeService; nodesListGatewayMetaState.init(this); - if (DiscoveryNode.dataNode(settings)) { + if (DiscoveryNode.isDataNode(settings)) { ensureNoPre019ShardState(nodeEnv); } - if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.dataNode(settings)) { + if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings)) { nodeEnv.ensureAtomicMoveSupported(); } - if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.dataNode(settings)) { + if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings)) { try { ensureNoPre019State(); IndexFolderUpgrader.upgradeIndicesIfNeeded(settings, nodeEnv); diff --git a/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java b/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java index 384a375903a..951e7760239 100644 --- a/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java +++ b/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java @@ -77,7 +77,7 @@ public class RepositoriesService extends AbstractComponent implements ClusterSta this.clusterService = clusterService; // Doesn't make sense to maintain repositories on non-master and non-data nodes // Nothing happens there anyway - if (DiscoveryNode.dataNode(settings) || DiscoveryNode.isMasterNode(settings)) { + if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isMasterNode(settings)) { clusterService.add(this); } this.verifyAction = new VerifyNodeRepositoryAction(settings, transportService, clusterService, this); diff --git a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java index 000c387cc82..ee17672d6d5 100644 --- a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java +++ b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java @@ -108,7 +108,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent { @Override public boolean test(NodeAndClient nodeAndClient) { - return DiscoveryNode.dataNode(nodeAndClient.node.settings()); + return DiscoveryNode.isDataNode(nodeAndClient.node.settings()); } } private static final class DataOrMasterNodePredicate implements Predicate { @Override public boolean test(NodeAndClient nodeAndClient) { - return DiscoveryNode.dataNode(nodeAndClient.node.settings()) || + return DiscoveryNode.isDataNode(nodeAndClient.node.settings()) || DiscoveryNode.isMasterNode(nodeAndClient.node.settings()); } } @@ -1672,7 +1672,7 @@ public final class InternalTestCluster extends TestCluster { @Override public boolean test(NodeAndClient nodeAndClient) { return DiscoveryNode.isMasterNode(nodeAndClient.node.settings()) == false && - DiscoveryNode.dataNode(nodeAndClient.node.settings()) == false; + DiscoveryNode.isDataNode(nodeAndClient.node.settings()) == false; } } From 7751b45f0f1add963ecfddb31bbdb6a6201b1c80 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 14:58:57 +0200 Subject: [PATCH 09/25] Rename static DiscoveryNode#ingestNode(Settings) to isIngestNode --- .../main/java/org/elasticsearch/cluster/node/DiscoveryNode.java | 2 +- core/src/main/java/org/elasticsearch/node/Node.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 1c2ad220ccd..428eeee9fc8 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -76,7 +76,7 @@ public class DiscoveryNode implements Writeable, ToXContent { return Node.NODE_DATA_SETTING.get(settings); } - public static boolean ingestNode(Settings settings) { + public static boolean isIngestNode(Settings settings) { return Node.NODE_INGEST_SETTING.get(settings); } diff --git a/core/src/main/java/org/elasticsearch/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java index 363250e07cd..5b4f32635f9 100644 --- a/core/src/main/java/org/elasticsearch/node/Node.java +++ b/core/src/main/java/org/elasticsearch/node/Node.java @@ -220,7 +220,7 @@ public class Node implements Closeable { modules.add(new ClusterModule(this.settings)); modules.add(new IndicesModule()); modules.add(new SearchModule(settings, namedWriteableRegistry)); - modules.add(new ActionModule(DiscoveryNode.ingestNode(settings), false)); + modules.add(new ActionModule(DiscoveryNode.isIngestNode(settings), false)); modules.add(new GatewayModule(settings)); modules.add(new NodeClientModule()); modules.add(new ResourceWatcherModule()); From 2dbba45f2c43399f51b638452356f9305a4aaf74 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:00:03 +0200 Subject: [PATCH 10/25] Rename static DiscoveryNode#localNode(Settings) to DiscoveryNode#isLocalNode(Settings) --- .../java/org/elasticsearch/cluster/node/DiscoveryNode.java | 2 +- .../java/org/elasticsearch/common/network/NetworkModule.java | 2 +- .../main/java/org/elasticsearch/discovery/DiscoveryModule.java | 2 +- .../main/java/org/elasticsearch/test/ESSingleNodeTestCase.java | 3 +-- .../main/java/org/elasticsearch/test/InternalTestCluster.java | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 428eeee9fc8..8668a1c68f5 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -47,7 +47,7 @@ import static org.elasticsearch.common.transport.TransportAddressSerializers.add */ public class DiscoveryNode implements Writeable, ToXContent { - public static boolean localNode(Settings settings) { + public static boolean isLocalNode(Settings settings) { if (Node.NODE_LOCAL_SETTING.exists(settings)) { return Node.NODE_LOCAL_SETTING.get(settings); } diff --git a/core/src/main/java/org/elasticsearch/common/network/NetworkModule.java b/core/src/main/java/org/elasticsearch/common/network/NetworkModule.java index 4c32abe8156..7c7c16025b9 100644 --- a/core/src/main/java/org/elasticsearch/common/network/NetworkModule.java +++ b/core/src/main/java/org/elasticsearch/common/network/NetworkModule.java @@ -387,7 +387,7 @@ public class NetworkModule extends AbstractModule { bind(NamedWriteableRegistry.class).toInstance(namedWriteableRegistry); transportServiceTypes.bindType(binder(), settings, TRANSPORT_SERVICE_TYPE_KEY, NETTY_TRANSPORT); - String defaultTransport = DiscoveryNode.localNode(settings) ? LOCAL_TRANSPORT : NETTY_TRANSPORT; + String defaultTransport = DiscoveryNode.isLocalNode(settings) ? LOCAL_TRANSPORT : NETTY_TRANSPORT; transportTypes.bindType(binder(), settings, TRANSPORT_TYPE_KEY, defaultTransport); if (transportClient) { diff --git a/core/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java b/core/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java index 4076b880d6f..f70eb46e666 100644 --- a/core/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java +++ b/core/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java @@ -47,7 +47,7 @@ import java.util.function.Function; public class DiscoveryModule extends AbstractModule { public static final Setting DISCOVERY_TYPE_SETTING = - new Setting<>("discovery.type", settings -> DiscoveryNode.localNode(settings) ? "local" : "zen", Function.identity(), + new Setting<>("discovery.type", settings -> DiscoveryNode.isLocalNode(settings) ? "local" : "zen", Function.identity(), Property.NodeScope); public static final Setting ZEN_MASTER_SERVICE_TYPE_SETTING = new Setting<>("discovery.zen.masterservice.type", "zen", Function.identity(), Property.NodeScope); diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java index 73576c9a840..de7a5219445 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java @@ -23,7 +23,6 @@ import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.admin.indices.get.GetIndexResponse; -import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequestBuilder; import org.elasticsearch.cache.recycler.PageCacheRecycler; import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; @@ -191,7 +190,7 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { .build(); Node build = new MockNode(settings, getVersion(), getPlugins()); build.start(); - assertThat(DiscoveryNode.localNode(build.settings()), is(true)); + assertThat(DiscoveryNode.isLocalNode(build.settings()), is(true)); return build; } diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index f49d51237cf..dca508852a0 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -329,7 +329,7 @@ public final class InternalTestCluster extends TestCluster { if (Strings.hasLength(System.getProperty("es.node.local"))) { builder.put(Node.NODE_LOCAL_SETTING.getKey(), System.getProperty("es.node.local")); } - if (DiscoveryNode.localNode(builder.build())) { + if (DiscoveryNode.isLocalNode(builder.build())) { return "local"; } else { return "network"; From 131f5b0596bf13b099c44b208b1b5397a0c4e474 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:06:34 +0200 Subject: [PATCH 11/25] Remove unused emptyDelta method from DiscoveryNodes and related EMPTY_LIST from DiscoveryNode --- .../java/org/elasticsearch/cluster/node/DiscoveryNode.java | 3 --- .../java/org/elasticsearch/cluster/node/DiscoveryNodes.java | 4 ---- 2 files changed, 7 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 8668a1c68f5..ea1973c4057 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -35,7 +35,6 @@ import java.io.IOException; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Predicate; @@ -80,8 +79,6 @@ public class DiscoveryNode implements Writeable, ToXContent { return Node.NODE_INGEST_SETTING.get(settings); } - public static final List EMPTY_LIST = Collections.emptyList(); - private final String nodeName; private final String nodeId; private final String hostName; 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 f41e3c50682..a4be17ea9e4 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -480,10 +480,6 @@ public class DiscoveryNodes extends AbstractDiffable implements return sb.toString(); } - public Delta emptyDelta() { - return new Delta(null, null, localNodeId, DiscoveryNode.EMPTY_LIST, DiscoveryNode.EMPTY_LIST); - } - public static class Delta { private final String localNodeId; From fc2e6d7ce073ba5906bd94835beae2b38fcc1f90 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:08:34 +0200 Subject: [PATCH 12/25] Remove DiscoveryNodes#size in favour of existing DiscoveryNodes#getSize --- .../action/search/TransportClearScrollAction.java | 2 +- .../cluster/health/ClusterStateHealth.java | 2 +- .../metadata/MetaDataDeleteIndexService.java | 2 +- .../elasticsearch/cluster/node/DiscoveryNodes.java | 11 +---------- .../zen/publish/PublishClusterStateAction.java | 2 +- .../support/nodes/TransportNodesActionTests.java | 2 +- .../client/transport/TransportClientRetryIT.java | 2 +- .../cluster/ClusterChangedEventTests.java | 2 +- .../cluster/MinimumMasterNodesIT.java | 14 +++++++------- .../cluster/NodeConnectionsServiceTests.java | 2 +- .../allocation/RandomAllocationDeciderTests.java | 8 ++++---- .../DiscoveryWithServiceDisruptionsIT.java | 4 ++-- .../discovery/ZenUnicastDiscoveryIT.java | 2 +- .../discovery/zen/NodeJoinControllerTests.java | 2 +- 14 files changed, 24 insertions(+), 33 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/search/TransportClearScrollAction.java b/core/src/main/java/org/elasticsearch/action/search/TransportClearScrollAction.java index fb021fdd9f9..c2922bf6deb 100644 --- a/core/src/main/java/org/elasticsearch/action/search/TransportClearScrollAction.java +++ b/core/src/main/java/org/elasticsearch/action/search/TransportClearScrollAction.java @@ -75,7 +75,7 @@ public class TransportClearScrollAction extends HandledTransportAction, S public ClusterStateHealth(ClusterState clusterState, String[] concreteIndices) { RoutingTableValidation validation = clusterState.routingTable().validate(clusterState.metaData()); validationFailures = validation.failures(); - numberOfNodes = clusterState.nodes().size(); + numberOfNodes = clusterState.nodes().getSize(); numberOfDataNodes = clusterState.nodes().dataNodes().size(); for (String index : concreteIndices) { diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java index 5e6d35aacfe..763b1038dc8 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java @@ -101,7 +101,7 @@ public class MetaDataDeleteIndexService extends AbstractComponent { metaDataBuilder.remove(indexName); } // wait for events from all nodes that it has been removed from their respective metadata... - int count = currentState.nodes().size(); + int count = currentState.nodes().getSize(); // add the notifications that the store was deleted from *data* nodes count += currentState.nodes().dataNodes().size(); final AtomicInteger counter = new AtomicInteger(count * indices.size()); 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 a4be17ea9e4..bbd5f5b724d 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -96,22 +96,13 @@ public class DiscoveryNodes extends AbstractDiffable implements return localNodeId.equals(masterNodeId); } - /** - * Get the number of known nodes - * - * @return number of nodes - */ - public int size() { - return nodes.size(); - } - /** * Get the number of known nodes * * @return number of nodes */ public int getSize() { - return size(); + return nodes.size(); } /** 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 0c8d16c2cb8..00cebac1435 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 @@ -125,7 +125,7 @@ public class PublishClusterStateAction extends AbstractComponent { final boolean sendFullVersion; try { nodes = clusterChangedEvent.state().nodes(); - nodesToPublishTo = new HashSet<>(nodes.size()); + nodesToPublishTo = new HashSet<>(nodes.getSize()); DiscoveryNode localNode = nodes.localNode(); final int totalMasterNodes = nodes.masterNodes().size(); for (final DiscoveryNode node : nodes) { diff --git a/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java b/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java index 0ceb433db20..d5c8283b8b1 100644 --- a/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java @@ -68,7 +68,7 @@ public class TransportNodesActionTests extends ESTestCase { PlainActionFuture listener = new PlainActionFuture<>(); action.new AsyncAction(null, request, listener).start(); Map> capturedRequests = transport.getCapturedRequestsByTargetNodeAndClear(); - int numNodes = clusterService.state().getNodes().size(); + int numNodes = clusterService.state().getNodes().getSize(); // check a request was sent to the right number of nodes assertEquals(numNodes, capturedRequests.size()); } diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java index 9d7598325e3..e45b1685c5a 100644 --- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java +++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java @@ -78,7 +78,7 @@ public class TransportClientRetryIT extends ESIntegTestCase { transportClient.admin().cluster().state(clusterStateRequest, future); clusterState = future.get().getState(); } - assertThat(clusterState.nodes().size(), greaterThanOrEqualTo(size - j)); + assertThat(clusterState.nodes().getSize(), greaterThanOrEqualTo(size - j)); assertThat(transportClient.connectedNodes().size(), greaterThanOrEqualTo(size - j)); } } diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java b/core/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java index c89ea900962..e7e73334d26 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java @@ -265,7 +265,7 @@ public class ClusterChangedEventTests extends ESTestCase { builder.metaData(metaBuilder); } if (numNodesToRemove > 0) { - final int discoveryNodesSize = previousState.getNodes().size(); + final int discoveryNodesSize = previousState.getNodes().getSize(); final DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(previousState.getNodes()); for (int i = 0; i < numNodesToRemove && i < discoveryNodesSize; i++) { nodesBuilder.remove(NODE_ID_PREFIX + i); diff --git a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java index 9c004a95f3b..be013c22101 100644 --- a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java @@ -88,7 +88,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { logger.info("--> should be blocked, no master..."); ClusterState state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState(); assertThat(state.blocks().hasGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID), equalTo(true)); - assertThat(state.nodes().size(), equalTo(1)); // verify that we still see the local node in the cluster state + assertThat(state.nodes().getSize(), equalTo(1)); // verify that we still see the local node in the cluster state logger.info("--> start second node, cluster should be formed"); internalCluster().startNode(settings); @@ -102,7 +102,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { assertThat(state.blocks().hasGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID), equalTo(false)); state = client().admin().cluster().prepareState().execute().actionGet().getState(); - assertThat(state.nodes().size(), equalTo(2)); + assertThat(state.nodes().getSize(), equalTo(2)); assertThat(state.metaData().indices().containsKey("test"), equalTo(false)); createIndex("test"); @@ -128,7 +128,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { }); state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState(); assertThat(state.blocks().hasGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID), equalTo(true)); - assertThat(state.nodes().size(), equalTo(1)); // verify that we still see the local node in the cluster state + assertThat(state.nodes().getSize(), equalTo(1)); // verify that we still see the local node in the cluster state logger.info("--> starting the previous master node again..."); internalCluster().startNode(settings); @@ -142,7 +142,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { assertThat(state.blocks().hasGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID), equalTo(false)); state = client().admin().cluster().prepareState().execute().actionGet().getState(); - assertThat(state.nodes().size(), equalTo(2)); + assertThat(state.nodes().getSize(), equalTo(2)); assertThat(state.metaData().indices().containsKey("test"), equalTo(true)); ensureGreen(); @@ -174,7 +174,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { assertThat(state.blocks().hasGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID), equalTo(false)); state = client().admin().cluster().prepareState().execute().actionGet().getState(); - assertThat(state.nodes().size(), equalTo(2)); + assertThat(state.nodes().getSize(), equalTo(2)); assertThat(state.metaData().indices().containsKey("test"), equalTo(true)); logger.info("Running Cluster Health"); @@ -217,7 +217,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { assertThat(clusterHealthResponse.isTimedOut(), equalTo(false)); state = client().admin().cluster().prepareState().execute().actionGet().getState(); - assertThat(state.nodes().size(), equalTo(4)); + assertThat(state.nodes().getSize(), equalTo(4)); createIndex("test"); NumShards numShards = getNumShards("test"); @@ -252,7 +252,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { assertThat(clusterHealthResponse.isTimedOut(), equalTo(false)); state = client().admin().cluster().prepareState().execute().actionGet().getState(); - assertThat(state.nodes().size(), equalTo(4)); + assertThat(state.nodes().getSize(), equalTo(4)); // we prefer to elect up and running nodes assertThat(state.nodes().masterNodeId(), not(isOneOf(newNodes))); diff --git a/core/src/test/java/org/elasticsearch/cluster/NodeConnectionsServiceTests.java b/core/src/test/java/org/elasticsearch/cluster/NodeConnectionsServiceTests.java index 76eb51f525f..e54dc4b5874 100644 --- a/core/src/test/java/org/elasticsearch/cluster/NodeConnectionsServiceTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/NodeConnectionsServiceTests.java @@ -129,7 +129,7 @@ public class NodeConnectionsServiceTests extends ESTestCase { private void assertConnectedExactlyToNodes(ClusterState state) { assertConnected(state.nodes()); - assertThat(transport.connectedNodes.size(), equalTo(state.nodes().size())); + assertThat(transport.connectedNodes.size(), equalTo(state.nodes().getSize())); } private void assertConnected(Iterable nodes) { diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java index 0bdab7a1158..86b8e522fc2 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java @@ -89,7 +89,7 @@ public class RandomAllocationDeciderTests extends ESAllocationTestCase { ClusterState.Builder stateBuilder = ClusterState.builder(clusterState); DiscoveryNodes.Builder newNodesBuilder = DiscoveryNodes.builder(clusterState.nodes()); - if (clusterState.nodes().size() <= atMostNodes && + if (clusterState.nodes().getSize() <= atMostNodes && (nodeIdCounter == 0 || (frequentNodes ? frequently() : rarely()))) { int numNodes = scaledRandomIntBetween(1, 3); for (int j = 0; j < numNodes; j++) { @@ -115,10 +115,10 @@ public class RandomAllocationDeciderTests extends ESAllocationTestCase { } } logger.info("Fill up nodes such that every shard can be allocated"); - if (clusterState.nodes().size() < maxNumReplicas) { + if (clusterState.nodes().getSize() < maxNumReplicas) { ClusterState.Builder stateBuilder = ClusterState.builder(clusterState); DiscoveryNodes.Builder newNodesBuilder = DiscoveryNodes.builder(clusterState.nodes()); - for (int j = 0; j < (maxNumReplicas - clusterState.nodes().size()); j++) { + for (int j = 0; j < (maxNumReplicas - clusterState.nodes().getSize()); j++) { logger.info("adding node [{}]", nodeIdCounter); newNodesBuilder.put(newNode("NODE_" + (nodeIdCounter++))); } @@ -149,7 +149,7 @@ public class RandomAllocationDeciderTests extends ESAllocationTestCase { assertThat(clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.UNASSIGNED).size(), equalTo(0)); int shards = clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.STARTED).size(); assertThat(shards, equalTo(totalNumShards)); - final int numNodes = clusterState.nodes().size(); + final int numNodes = clusterState.nodes().getSize(); final int upperBound = (int) Math.round(((shards / numNodes) * 1.10)); final int lowerBound = (int) Math.round(((shards / numNodes) * 0.90)); for (int i = 0; i < nodeIdCounter; i++) { diff --git a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java index f4a96260bff..7a30621223b 100644 --- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java @@ -401,7 +401,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { // assert nodes are identical try { assertEquals("unequal versions", state.version(), nodeState.version()); - assertEquals("unequal node count", state.nodes().size(), nodeState.nodes().size()); + assertEquals("unequal node count", state.nodes().getSize(), nodeState.nodes().getSize()); assertEquals("different masters ", state.nodes().masterNodeId(), nodeState.nodes().masterNodeId()); assertEquals("different meta data version", state.metaData().version(), nodeState.metaData().version()); if (!state.routingTable().prettyPrint().equals(nodeState.routingTable().prettyPrint())) { @@ -1205,7 +1205,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { for (String node : nodes) { ClusterState state = getNodeClusterState(node); String failMsgSuffix = "cluster_state:\n" + state.prettyPrint(); - assertThat("wrong node count on [" + node + "]. " + failMsgSuffix, state.nodes().size(), equalTo(nodes.size())); + assertThat("wrong node count on [" + node + "]. " + failMsgSuffix, state.nodes().getSize(), equalTo(nodes.size())); String otherMasterNodeName = state.nodes().masterNode() != null ? state.nodes().masterNode().getName() : null; assertThat("wrong master on node [" + node + "]. " + failMsgSuffix, otherMasterNodeName, equalTo(masterNode)); } diff --git a/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java b/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java index efbfa800437..6bc0301cd08 100644 --- a/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java @@ -92,7 +92,7 @@ public class ZenUnicastDiscoveryIT extends ESIntegTestCase { DiscoveryNode masterDiscoNode = null; for (String node : nodes) { ClusterState state = internalCluster().client(node).admin().cluster().prepareState().setLocal(true).execute().actionGet().getState(); - assertThat(state.nodes().size(), equalTo(currentNumNodes)); + assertThat(state.nodes().getSize(), equalTo(currentNumNodes)); if (masterDiscoNode == null) { masterDiscoNode = state.nodes().masterNode(); } else { diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java index b924f52a68f..74b96a1241e 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java @@ -557,7 +557,7 @@ public class NodeJoinControllerTests extends ESTestCase { for (DiscoveryNode node : expectedNodes) { assertThat("missing " + node + "\n" + discoveryNodes.prettyPrint(), discoveryNodes.get(node.getId()), equalTo(node)); } - assertThat(discoveryNodes.size(), equalTo(expectedNodes.size())); + assertThat(discoveryNodes.getSize(), equalTo(expectedNodes.size())); } static class SimpleFuture extends BaseFuture { From c175e07c8a0b5101a47ba9bef6a4dcb60d4564c5 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:09:41 +0200 Subject: [PATCH 13/25] Remove DiscoveryNodes#nodes in favour of existing DiscoveryNodes#getNodes --- .../action/support/nodes/TransportNodesAction.java | 2 +- .../action/support/tasks/TransportTasksAction.java | 2 +- .../elasticsearch/cluster/node/DiscoveryNodes.java | 13 ++----------- .../elasticsearch/discovery/zen/ZenDiscovery.java | 2 +- .../support/nodes/TransportNodesActionTests.java | 2 +- .../elasticsearch/cluster/ClusterStateDiffIT.java | 12 ++++++------ .../elasticsearch/cluster/SimpleClusterStateIT.java | 4 ++-- .../cluster/action/shard/ShardStateActionTests.java | 2 +- .../cluster/node/DiscoveryNodesTests.java | 6 +++--- 9 files changed, 18 insertions(+), 27 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java b/core/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java index a6a646ec251..6f236db1d7d 100644 --- a/core/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java +++ b/core/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java @@ -127,7 +127,7 @@ public abstract class TransportNodesAction nodes = clusterState.nodes().nodes(); + ImmutableOpenMap nodes = clusterState.nodes().getNodes(); this.nodes = new DiscoveryNode[nodesIds.length]; for (int i = 0; i < nodesIds.length; i++) { this.nodes[i] = nodes.get(nodesIds[i]); diff --git a/core/src/main/java/org/elasticsearch/action/support/tasks/TransportTasksAction.java b/core/src/main/java/org/elasticsearch/action/support/tasks/TransportTasksAction.java index 68c286a943d..b1bdb5b2b84 100644 --- a/core/src/main/java/org/elasticsearch/action/support/tasks/TransportTasksAction.java +++ b/core/src/main/java/org/elasticsearch/action/support/tasks/TransportTasksAction.java @@ -205,7 +205,7 @@ public abstract class TransportTasksAction< ClusterState clusterState = clusterService.state(); String[] nodesIds = resolveNodes(request, clusterState); this.nodesIds = filterNodeIds(clusterState.nodes(), nodesIds); - ImmutableOpenMap nodes = clusterState.nodes().nodes(); + ImmutableOpenMap nodes = clusterState.nodes().getNodes(); this.nodes = new DiscoveryNode[nodesIds.length]; for (int i = 0; i < this.nodesIds.length; i++) { this.nodes[i] = nodes.get(this.nodesIds[i]); 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 bbd5f5b724d..9f7bc4c2a06 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -105,22 +105,13 @@ public class DiscoveryNodes extends AbstractDiffable implements return nodes.size(); } - /** - * Get a {@link Map} of the discovered nodes arranged by their ids - * - * @return {@link Map} of the discovered nodes arranged by their ids - */ - public ImmutableOpenMap nodes() { - return this.nodes; - } - /** * Get a {@link Map} of the discovered nodes arranged by their ids * * @return {@link Map} of the discovered nodes arranged by their ids */ public ImmutableOpenMap getNodes() { - return nodes(); + return this.nodes; } /** @@ -632,7 +623,7 @@ public class DiscoveryNodes extends AbstractDiffable implements public Builder(DiscoveryNodes nodes) { this.masterNodeId = nodes.masterNodeId(); this.localNodeId = nodes.localNodeId(); - this.nodes = ImmutableOpenMap.builder(nodes.nodes()); + this.nodes = ImmutableOpenMap.builder(nodes.getNodes()); } public Builder put(DiscoveryNode node) { 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 b83e8e4aa72..a4c06536fa9 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -252,7 +252,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } } else { // we're master -> let other potential master we left and start a master election now rather then wait for masterFD - DiscoveryNode[] possibleMasters = electMaster.nextPossibleMasters(nodes.nodes().values(), 5); + DiscoveryNode[] possibleMasters = electMaster.nextPossibleMasters(nodes.getNodes().values(), 5); for (DiscoveryNode possibleMaster : possibleMasters) { if (nodes.localNode().equals(possibleMaster)) { continue; diff --git a/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java b/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java index d5c8283b8b1..ad2326c3148 100644 --- a/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java @@ -80,7 +80,7 @@ public class TransportNodesActionTests extends ESTestCase { nodeSelectors.add(randomFrom(NodeSelector.values()).selector); } int numNodeIds = randomIntBetween(0, 3); - String[] nodeIds = clusterService.state().nodes().nodes().keys().toArray(String.class); + String[] nodeIds = clusterService.state().nodes().getNodes().keys().toArray(String.class); for (int i = 0; i < numNodeIds; i++) { String nodeId = randomFrom(nodeIds); nodeSelectors.add(nodeId); diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java index 00b8291957c..0490864dbc2 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java @@ -133,10 +133,10 @@ public class ClusterStateDiffIT extends ESIntegTestCase { assertThat(clusterStateFromDiffs.stateUUID(), equalTo(clusterState.stateUUID())); // Check nodes - assertThat(clusterStateFromDiffs.nodes().nodes(), equalTo(clusterState.nodes().nodes())); + assertThat(clusterStateFromDiffs.nodes().getNodes(), equalTo(clusterState.nodes().getNodes())); assertThat(clusterStateFromDiffs.nodes().localNodeId(), equalTo(previousClusterStateFromDiffs.nodes().localNodeId())); - assertThat(clusterStateFromDiffs.nodes().nodes(), equalTo(clusterState.nodes().nodes())); - for (ObjectCursor node : clusterStateFromDiffs.nodes().nodes().keys()) { + assertThat(clusterStateFromDiffs.nodes().getNodes(), equalTo(clusterState.nodes().getNodes())); + for (ObjectCursor node : clusterStateFromDiffs.nodes().getNodes().keys()) { DiscoveryNode node1 = clusterState.nodes().get(node.value); DiscoveryNode node2 = clusterStateFromDiffs.nodes().get(node.value); assertThat(node1.getVersion(), equalTo(node2.getVersion())); @@ -184,7 +184,7 @@ public class ClusterStateDiffIT extends ESIntegTestCase { */ private ClusterState.Builder randomNodes(ClusterState clusterState) { DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(clusterState.nodes()); - List nodeIds = randomSubsetOf(randomInt(clusterState.nodes().nodes().size() - 1), clusterState.nodes().nodes().keys().toArray(String.class)); + List nodeIds = randomSubsetOf(randomInt(clusterState.nodes().getNodes().size() - 1), clusterState.nodes().getNodes().keys().toArray(String.class)); for (String nodeId : nodeIds) { if (nodeId.startsWith("node-")) { if (randomBoolean()) { @@ -215,13 +215,13 @@ public class ClusterStateDiffIT extends ESIntegTestCase { if (randomBoolean()) { builder.remove(index); } else { - builder.add(randomChangeToIndexRoutingTable(clusterState.routingTable().indicesRouting().get(index), clusterState.nodes().nodes().keys().toArray(String.class))); + builder.add(randomChangeToIndexRoutingTable(clusterState.routingTable().indicesRouting().get(index), clusterState.nodes().getNodes().keys().toArray(String.class))); } } } int additionalIndexCount = randomIntBetween(1, 20); for (int i = 0; i < additionalIndexCount; i++) { - builder.add(randomIndexRoutingTable("index-" + randomInt(), clusterState.nodes().nodes().keys().toArray(String.class))); + builder.add(randomIndexRoutingTable("index-" + randomInt(), clusterState.nodes().getNodes().keys().toArray(String.class))); } return ClusterState.builder(clusterState).routingTable(builder.build()); } diff --git a/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java b/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java index da5f3149d6c..2de99d6296c 100644 --- a/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java @@ -72,10 +72,10 @@ public class SimpleClusterStateIT extends ESIntegTestCase { public void testNodes() throws Exception { ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().clear().setNodes(true).get(); - assertThat(clusterStateResponse.getState().nodes().nodes().size(), is(cluster().size())); + assertThat(clusterStateResponse.getState().nodes().getNodes().size(), is(cluster().size())); ClusterStateResponse clusterStateResponseFiltered = client().admin().cluster().prepareState().clear().get(); - assertThat(clusterStateResponseFiltered.getState().nodes().nodes().size(), is(0)); + assertThat(clusterStateResponseFiltered.getState().nodes().getNodes().size(), is(0)); } public void testMetadata() throws Exception { 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 561b51de1e9..a4afd30f788 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 @@ -333,7 +333,7 @@ public class ShardStateActionTests extends ESTestCase { ShardRouting failedShard = getRandomShardRouting(index); - String nodeId = randomFrom(clusterService.state().nodes().nodes().keys().toArray(String.class)); + String nodeId = randomFrom(clusterService.state().nodes().getNodes().keys().toArray(String.class)); AtomicReference failure = new AtomicReference<>(); CountDownLatch latch = new CountDownLatch(1); diff --git a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java index fe80baebd52..a282fcaa3a6 100644 --- a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java @@ -39,7 +39,7 @@ public class DiscoveryNodesTests extends ESTestCase { public void testResolveNodeByIdOrName() { DiscoveryNodes discoveryNodes = buildDiscoveryNodes(); - DiscoveryNode[] nodes = discoveryNodes.nodes().values().toArray(DiscoveryNode.class); + DiscoveryNode[] nodes = discoveryNodes.getNodes().values().toArray(DiscoveryNode.class); DiscoveryNode node = randomFrom(nodes); DiscoveryNode resolvedNode = discoveryNodes.resolveNode(randomBoolean() ? node.getId() : node.getName()); assertThat(resolvedNode.getId(), equalTo(node.getId())); @@ -77,14 +77,14 @@ public class DiscoveryNodesTests extends ESTestCase { } } int numNodeIds = randomIntBetween(0, 3); - String[] nodeIds = discoveryNodes.nodes().keys().toArray(String.class); + String[] nodeIds = discoveryNodes.getNodes().keys().toArray(String.class); for (int i = 0; i < numNodeIds; i++) { String nodeId = randomFrom(nodeIds); nodeSelectors.add(nodeId); expectedNodeIdsSet.add(nodeId); } int numNodeNames = randomIntBetween(0, 3); - DiscoveryNode[] nodes = discoveryNodes.nodes().values().toArray(DiscoveryNode.class); + DiscoveryNode[] nodes = discoveryNodes.getNodes().values().toArray(DiscoveryNode.class); for (int i = 0; i < numNodeNames; i++) { DiscoveryNode discoveryNode = randomFrom(nodes); nodeSelectors.add(discoveryNode.getName()); From 463fbe45c6c25b17e7738056b58d796d9bb965ad Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:12:34 +0200 Subject: [PATCH 14/25] Remove DiscoveryNodes#dataNodes in favour of existing DiscoveryNodes#getDataNodes --- .../client/transport/TransportClientNodesService.java | 2 +- .../cluster/health/ClusterStateHealth.java | 2 +- .../cluster/metadata/MetaDataDeleteIndexService.java | 2 +- .../metadata/MetaDataUpdateSettingsService.java | 2 +- .../elasticsearch/cluster/node/DiscoveryNodes.java | 11 +---------- .../cluster/routing/OperationRouting.java | 2 +- .../elasticsearch/cluster/routing/RoutingNodes.java | 2 +- .../cluster/routing/allocation/AllocationService.java | 4 ++-- .../allocation/decider/DiskThresholdDecider.java | 2 +- .../org/elasticsearch/gateway/AsyncShardFetch.java | 2 +- .../org/elasticsearch/gateway/GatewayService.java | 8 ++++---- .../elasticsearch/gateway/ReplicaShardAllocator.java | 2 +- .../indices/recovery/IndexPrimaryRelocationIT.java | 4 ++-- .../test/java/org/elasticsearch/tribe/TribeIT.java | 4 ++-- 14 files changed, 20 insertions(+), 29 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java b/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java index a91fb09144e..6f62d4e888c 100644 --- a/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java +++ b/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java @@ -495,7 +495,7 @@ public class TransportClientNodesService extends AbstractComponent { newFilteredNodes.add(entry.getKey()); continue; } - for (ObjectCursor cursor : entry.getValue().getState().nodes().dataNodes().values()) { + for (ObjectCursor cursor : entry.getValue().getState().nodes().getDataNodes().values()) { newNodes.add(cursor.value); } } diff --git a/core/src/main/java/org/elasticsearch/cluster/health/ClusterStateHealth.java b/core/src/main/java/org/elasticsearch/cluster/health/ClusterStateHealth.java index 032425eda3d..03e4c6ee443 100644 --- a/core/src/main/java/org/elasticsearch/cluster/health/ClusterStateHealth.java +++ b/core/src/main/java/org/elasticsearch/cluster/health/ClusterStateHealth.java @@ -92,7 +92,7 @@ public final class ClusterStateHealth implements Iterable, S RoutingTableValidation validation = clusterState.routingTable().validate(clusterState.metaData()); validationFailures = validation.failures(); numberOfNodes = clusterState.nodes().getSize(); - numberOfDataNodes = clusterState.nodes().dataNodes().size(); + numberOfDataNodes = clusterState.nodes().getDataNodes().size(); for (String index : concreteIndices) { IndexRoutingTable indexRoutingTable = clusterState.routingTable().index(index); diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java index 763b1038dc8..4cd9f5d4727 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java @@ -103,7 +103,7 @@ public class MetaDataDeleteIndexService extends AbstractComponent { // wait for events from all nodes that it has been removed from their respective metadata... int count = currentState.nodes().getSize(); // add the notifications that the store was deleted from *data* nodes - count += currentState.nodes().dataNodes().size(); + count += currentState.nodes().getDataNodes().size(); final AtomicInteger counter = new AtomicInteger(count * indices.size()); // this listener will be notified once we get back a notification based on the cluster state change below. diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java index c925b43056b..4d503e9a92c 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java @@ -83,7 +83,7 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements return; } // we will want to know this for translating "all" to a number - final int dataNodeCount = event.state().nodes().dataNodes().size(); + final int dataNodeCount = event.state().nodes().getDataNodes().size(); Map> nrReplicasChanged = new HashMap<>(); // we need to do this each time in case it was changed by update settings 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 9f7bc4c2a06..70f71a63cf0 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -114,22 +114,13 @@ public class DiscoveryNodes extends AbstractDiffable implements return this.nodes; } - /** - * Get a {@link Map} of the discovered data nodes arranged by their ids - * - * @return {@link Map} of the discovered data nodes arranged by their ids - */ - public ImmutableOpenMap dataNodes() { - return this.dataNodes; - } - /** * Get a {@link Map} of the discovered data nodes arranged by their ids * * @return {@link Map} of the discovered data nodes arranged by their ids */ public ImmutableOpenMap getDataNodes() { - return dataNodes(); + return this.dataNodes; } /** diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java b/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java index 2b67b9f1820..3db26b45254 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java @@ -230,7 +230,7 @@ public class OperationRouting extends AbstractComponent { } private void ensureNodeIdExists(DiscoveryNodes nodes, String nodeId) { - if (!nodes.dataNodes().keys().contains(nodeId)) { + if (!nodes.getDataNodes().keys().contains(nodeId)) { throw new IllegalArgumentException("No data node with id[" + nodeId + "] found"); } } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java index 1af8b83d909..e5ea414ba87 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java @@ -86,7 +86,7 @@ public class RoutingNodes implements Iterable { Map> nodesToShards = new HashMap<>(); // fill in the nodeToShards with the "live" nodes - for (ObjectCursor cursor : clusterState.nodes().dataNodes().values()) { + for (ObjectCursor cursor : clusterState.nodes().getDataNodes().values()) { nodesToShards.put(cursor.value.getId(), new ArrayList<>()); } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java index da0fea69c68..cdfdace8136 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java @@ -406,7 +406,7 @@ public class AllocationService extends AbstractComponent { */ private void applyNewNodes(RoutingAllocation allocation) { final RoutingNodes routingNodes = allocation.routingNodes(); - for (ObjectCursor cursor : allocation.nodes().dataNodes().values()) { + for (ObjectCursor cursor : allocation.nodes().getDataNodes().values()) { DiscoveryNode node = cursor.value; if (!routingNodes.isKnown(node)) { routingNodes.addNode(node); @@ -418,7 +418,7 @@ public class AllocationService extends AbstractComponent { boolean changed = false; for (RoutingNodes.RoutingNodesIterator it = allocation.routingNodes().nodes(); it.hasNext(); ) { RoutingNode node = it.next(); - if (allocation.nodes().dataNodes().containsKey(node.nodeId())) { + if (allocation.nodes().getDataNodes().containsKey(node.nodeId())) { // its a live node, continue continue; } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java index 71968b0743b..4d56711c097 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java @@ -618,7 +618,7 @@ public class DiskThresholdDecider extends AllocationDecider { } // Allow allocation regardless if only a single data node is available - if (allocation.nodes().dataNodes().size() <= 1) { + if (allocation.nodes().getDataNodes().size() <= 1) { if (logger.isTraceEnabled()) { logger.trace("only a single data node is present, allowing allocation"); } diff --git a/core/src/main/java/org/elasticsearch/gateway/AsyncShardFetch.java b/core/src/main/java/org/elasticsearch/gateway/AsyncShardFetch.java index 1ccdb43cc45..51718350253 100644 --- a/core/src/main/java/org/elasticsearch/gateway/AsyncShardFetch.java +++ b/core/src/main/java/org/elasticsearch/gateway/AsyncShardFetch.java @@ -223,7 +223,7 @@ public abstract class AsyncShardFetch implements Rel */ private void fillShardCacheWithDataNodes(Map> shardCache, DiscoveryNodes nodes) { // verify that all current data nodes are there - for (ObjectObjectCursor cursor : nodes.dataNodes()) { + for (ObjectObjectCursor cursor : nodes.getDataNodes()) { DiscoveryNode node = cursor.value; if (shardCache.containsKey(node.getId()) == false) { shardCache.put(node.getId(), new NodeEntry(node.getId())); diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayService.java b/core/src/main/java/org/elasticsearch/gateway/GatewayService.java index 7dcc45f1c0a..288deac432e 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayService.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayService.java @@ -168,9 +168,9 @@ public class GatewayService extends AbstractLifecycleComponent i } else if (recoverAfterNodes != -1 && (nodes.masterAndDataNodes().size()) < recoverAfterNodes) { logger.debug("not recovering from gateway, nodes_size (data+master) [{}] < recover_after_nodes [{}]", nodes.masterAndDataNodes().size(), recoverAfterNodes); - } else if (recoverAfterDataNodes != -1 && nodes.dataNodes().size() < recoverAfterDataNodes) { + } else if (recoverAfterDataNodes != -1 && nodes.getDataNodes().size() < recoverAfterDataNodes) { logger.debug("not recovering from gateway, nodes_size (data) [{}] < recover_after_data_nodes [{}]", - nodes.dataNodes().size(), recoverAfterDataNodes); + nodes.getDataNodes().size(), recoverAfterDataNodes); } else if (recoverAfterMasterNodes != -1 && nodes.masterNodes().size() < recoverAfterMasterNodes) { logger.debug("not recovering from gateway, nodes_size (master) [{}] < recover_after_master_nodes [{}]", nodes.masterNodes().size(), recoverAfterMasterNodes); @@ -188,9 +188,9 @@ public class GatewayService extends AbstractLifecycleComponent i if (expectedNodes != -1 && (nodes.masterAndDataNodes().size() < expectedNodes)) { // does not meet the expected... enforceRecoverAfterTime = true; reason = "expecting [" + expectedNodes + "] nodes, but only have [" + nodes.masterAndDataNodes().size() + "]"; - } else if (expectedDataNodes != -1 && (nodes.dataNodes().size() < expectedDataNodes)) { // does not meet the expected... + } else if (expectedDataNodes != -1 && (nodes.getDataNodes().size() < expectedDataNodes)) { // does not meet the expected... enforceRecoverAfterTime = true; - reason = "expecting [" + expectedDataNodes + "] data nodes, but only have [" + nodes.dataNodes().size() + "]"; + reason = "expecting [" + expectedDataNodes + "] data nodes, but only have [" + nodes.getDataNodes().size() + "]"; } else if (expectedMasterNodes != -1 && (nodes.masterNodes().size() < expectedMasterNodes)) { // does not meet the expected... enforceRecoverAfterTime = true; reason = "expecting [" + expectedMasterNodes + "] master nodes, but only have [" + nodes.masterNodes().size() + "]"; diff --git a/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java b/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java index e20988d051e..d2e3d7f42cf 100644 --- a/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java +++ b/core/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java @@ -216,7 +216,7 @@ public abstract class ReplicaShardAllocator extends AbstractComponent { * Can the shard be allocated on at least one node based on the allocation deciders. */ private boolean canBeAllocatedToAtLeastOneNode(ShardRouting shard, RoutingAllocation allocation) { - for (ObjectCursor cursor : allocation.nodes().dataNodes().values()) { + for (ObjectCursor cursor : allocation.nodes().getDataNodes().values()) { RoutingNode node = allocation.routingNodes().node(cursor.value.getId()); if (node == null) { continue; diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java b/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java index 322ed269bcf..9bc2ce76cc4 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java @@ -64,8 +64,8 @@ public class IndexPrimaryRelocationIT extends ESIntegTestCase { indexingThread.start(); ClusterState initialState = client().admin().cluster().prepareState().get().getState(); - DiscoveryNode[] dataNodes = initialState.getNodes().dataNodes().values().toArray(DiscoveryNode.class); - DiscoveryNode relocationSource = initialState.getNodes().dataNodes().get(initialState.getRoutingTable().shardRoutingTable("test", 0).primaryShard().currentNodeId()); + DiscoveryNode[] dataNodes = initialState.getNodes().getDataNodes().values().toArray(DiscoveryNode.class); + DiscoveryNode relocationSource = initialState.getNodes().getDataNodes().get(initialState.getRoutingTable().shardRoutingTable("test", 0).primaryShard().currentNodeId()); for (int i = 0; i < RELOCATION_COUNT; i++) { DiscoveryNode relocationTarget = randomFrom(dataNodes); while (relocationTarget.equals(relocationSource)) { diff --git a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java index 2d7d8843eea..5b922b40fe3 100644 --- a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java +++ b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java @@ -427,8 +427,8 @@ public class TribeIT extends ESIntegTestCase { @Override public void run() { DiscoveryNodes tribeNodes = tribeNode.client().admin().cluster().prepareState().get().getState().getNodes(); - assertThat(countDataNodesForTribe("t1", tribeNodes), equalTo(internalCluster().client().admin().cluster().prepareState().get().getState().getNodes().dataNodes().size())); - assertThat(countDataNodesForTribe("t2", tribeNodes), equalTo(cluster2.client().admin().cluster().prepareState().get().getState().getNodes().dataNodes().size())); + assertThat(countDataNodesForTribe("t1", tribeNodes), equalTo(internalCluster().client().admin().cluster().prepareState().get().getState().getNodes().getDataNodes().size())); + assertThat(countDataNodesForTribe("t2", tribeNodes), equalTo(cluster2.client().admin().cluster().prepareState().get().getState().getNodes().getDataNodes().size())); } }); } From 4032859e90d84b8d0400fefa20c29f5bd58b2072 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:13:14 +0200 Subject: [PATCH 15/25] Remove DiscoveryNodes#masterNodes in favour of existing DiscoveryNodes#getMasterNodes --- .../elasticsearch/cluster/node/DiscoveryNodes.java | 11 +---------- .../org/elasticsearch/discovery/zen/ZenDiscovery.java | 2 +- .../zen/publish/PublishClusterStateAction.java | 2 +- .../main/java/org/elasticsearch/gateway/Gateway.java | 2 +- .../org/elasticsearch/gateway/GatewayService.java | 8 ++++---- .../cluster/action/shard/ShardStateActionTests.java | 2 +- 6 files changed, 9 insertions(+), 18 deletions(-) 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)); }); From 97f7aef7763d4cd4ff1bcba7feacfcfb006e3dc6 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:14:10 +0200 Subject: [PATCH 16/25] Rename DiscoveryNodes#masterAndDataNodes to getMasterAndDataNodes --- .../org/elasticsearch/cluster/node/DiscoveryNodes.java | 2 +- .../java/org/elasticsearch/gateway/GatewayService.java | 8 ++++---- .../repositories/VerifyNodeRepositoryAction.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) 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 c49a5f2fc40..ff8e355c5a8 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -144,7 +144,7 @@ public class DiscoveryNodes extends AbstractDiffable implements * * @return {@link Map} of the discovered master and data nodes arranged by their ids */ - public ImmutableOpenMap masterAndDataNodes() { + public ImmutableOpenMap getMasterAndDataNodes() { ImmutableOpenMap.Builder nodes = ImmutableOpenMap.builder(dataNodes); nodes.putAll(masterNodes); return nodes.build(); diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayService.java b/core/src/main/java/org/elasticsearch/gateway/GatewayService.java index d30dec998bb..89cc6015ddc 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayService.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayService.java @@ -165,9 +165,9 @@ public class GatewayService extends AbstractLifecycleComponent i DiscoveryNodes nodes = state.nodes(); if (state.nodes().masterNodeId() == null) { logger.debug("not recovering from gateway, no master elected yet"); - } else if (recoverAfterNodes != -1 && (nodes.masterAndDataNodes().size()) < recoverAfterNodes) { + } else if (recoverAfterNodes != -1 && (nodes.getMasterAndDataNodes().size()) < recoverAfterNodes) { logger.debug("not recovering from gateway, nodes_size (data+master) [{}] < recover_after_nodes [{}]", - nodes.masterAndDataNodes().size(), recoverAfterNodes); + nodes.getMasterAndDataNodes().size(), recoverAfterNodes); } 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); @@ -185,9 +185,9 @@ public class GatewayService extends AbstractLifecycleComponent i // one of the expected is set, see if all of them meet the need, and ignore the timeout in this case enforceRecoverAfterTime = false; reason = ""; - if (expectedNodes != -1 && (nodes.masterAndDataNodes().size() < expectedNodes)) { // does not meet the expected... + if (expectedNodes != -1 && (nodes.getMasterAndDataNodes().size() < expectedNodes)) { // does not meet the expected... enforceRecoverAfterTime = true; - reason = "expecting [" + expectedNodes + "] nodes, but only have [" + nodes.masterAndDataNodes().size() + "]"; + reason = "expecting [" + expectedNodes + "] nodes, but only have [" + nodes.getMasterAndDataNodes().size() + "]"; } 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() + "]"; diff --git a/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java b/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java index 4276fc43ef3..c474b5c7cd8 100644 --- a/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java +++ b/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java @@ -71,7 +71,7 @@ public class VerifyNodeRepositoryAction extends AbstractComponent { final DiscoveryNodes discoNodes = clusterService.state().nodes(); final DiscoveryNode localNode = discoNodes.localNode(); - final ObjectContainer masterAndDataNodes = discoNodes.masterAndDataNodes().values(); + final ObjectContainer masterAndDataNodes = discoNodes.getMasterAndDataNodes().values(); final List nodes = new ArrayList<>(); for (ObjectCursor cursor : masterAndDataNodes) { DiscoveryNode node = cursor.value; From f8b5d1f5b07fe015e755ed3ffdf450b11a51ef63 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:15:49 +0200 Subject: [PATCH 17/25] Remove DiscoveryNodes#masterNodeId in favour of existing DiscoveryNodes#getMasterNodeId --- .../org/elasticsearch/cluster/ClusterState.java | 4 ++-- .../cluster/MasterNodeChangePredicate.java | 2 +- .../cluster/node/DiscoveryNodes.java | 15 +++------------ .../discovery/local/LocalDiscovery.java | 2 +- .../elasticsearch/discovery/zen/ZenDiscovery.java | 8 ++++---- .../zen/publish/PendingClusterStatesQueue.java | 2 +- .../org/elasticsearch/gateway/GatewayService.java | 2 +- .../main/java/org/elasticsearch/node/Node.java | 2 +- .../rest/action/cat/RestMasterAction.java | 2 +- .../rest/action/cat/RestNodesAction.java | 2 +- .../snapshots/SnapshotShardsService.java | 4 ++-- .../cluster/MinimumMasterNodesIT.java | 2 +- .../cluster/SpecificMasterNodesIT.java | 6 +++--- .../cluster/node/DiscoveryNodesTests.java | 2 +- .../DiscoveryWithServiceDisruptionsIT.java | 4 ++-- .../publish/PendingClusterStatesQueueTests.java | 6 +++--- .../indices/state/RareClusterStateIT.java | 4 ++-- .../azure/AzureMinimumMasterNodesTests.java | 8 ++++---- .../discovery/azure/AzureSimpleTests.java | 4 ++-- .../azure/AzureTwoStartedNodesTests.java | 8 ++++---- .../org/elasticsearch/test/ESIntegTestCase.java | 4 ++-- 21 files changed, 42 insertions(+), 51 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/ClusterState.java b/core/src/main/java/org/elasticsearch/cluster/ClusterState.java index 1ac379555ab..6dd8f3bc747 100644 --- a/core/src/main/java/org/elasticsearch/cluster/ClusterState.java +++ b/core/src/main/java/org/elasticsearch/cluster/ClusterState.java @@ -317,7 +317,7 @@ public class ClusterState implements ToXContent, Diffable { * In essence that means that all the changes from the other cluster state are also reflected by the current one */ public boolean supersedes(ClusterState other) { - return this.nodes().masterNodeId() != null && this.nodes().masterNodeId().equals(other.nodes().masterNodeId()) && this.version() > other.version(); + return this.nodes().getMasterNodeId() != null && this.nodes().getMasterNodeId().equals(other.nodes().getMasterNodeId()) && this.version() > other.version(); } @@ -382,7 +382,7 @@ public class ClusterState implements ToXContent, Diffable { } if (metrics.contains(Metric.MASTER_NODE)) { - builder.field("master_node", nodes().masterNodeId()); + builder.field("master_node", nodes().getMasterNodeId()); } if (metrics.contains(Metric.BLOCKS)) { diff --git a/core/src/main/java/org/elasticsearch/cluster/MasterNodeChangePredicate.java b/core/src/main/java/org/elasticsearch/cluster/MasterNodeChangePredicate.java index 6d91ec7fd27..afb557e5bbc 100644 --- a/core/src/main/java/org/elasticsearch/cluster/MasterNodeChangePredicate.java +++ b/core/src/main/java/org/elasticsearch/cluster/MasterNodeChangePredicate.java @@ -30,7 +30,7 @@ public enum MasterNodeChangePredicate implements ClusterStateObserver.ChangePred ClusterState.ClusterStateStatus newStatus) { // checking if the masterNodeId changed is insufficient as the // same master node might get re-elected after a disruption - return newState.nodes().masterNodeId() != null && newState != previousState; + return newState.nodes().getMasterNodeId() != null && newState != previousState; } @Override 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 ff8e355c5a8..4987cb2cf43 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -170,22 +170,13 @@ public class DiscoveryNodes extends AbstractDiffable implements return nodes.containsKey(nodeId); } - /** - * Get the id of the master node - * - * @return id of the master - */ - public String masterNodeId() { - return this.masterNodeId; - } - /** * Get the id of the master node * * @return id of the master */ public String getMasterNodeId() { - return masterNodeId(); + return this.masterNodeId; } /** @@ -316,7 +307,7 @@ public class DiscoveryNodes extends AbstractDiffable implements resolvedNodesIds.add(localNodeId); } } else if (nodeId.equals("_master")) { - String masterNodeId = masterNodeId(); + String masterNodeId = getMasterNodeId(); if (masterNodeId != null) { resolvedNodesIds.add(masterNodeId); } @@ -603,7 +594,7 @@ public class DiscoveryNodes extends AbstractDiffable implements } public Builder(DiscoveryNodes nodes) { - this.masterNodeId = nodes.masterNodeId(); + this.masterNodeId = nodes.getMasterNodeId(); this.localNodeId = nodes.localNodeId(); this.nodes = ImmutableOpenMap.builder(nodes.getNodes()); } diff --git a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java index 256c18e1972..2b22da61290 100644 --- a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java @@ -357,7 +357,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem if (currentState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock())) { // its a fresh update from the master as we transition from a start of not having a master to having one - logger.debug("got first state from fresh master [{}]", nodeSpecificClusterState.nodes().masterNodeId()); + logger.debug("got first state from fresh master [{}]", nodeSpecificClusterState.nodes().getMasterNodeId()); return nodeSpecificClusterState; } 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 ce18f3473a1..d7aaac5612b 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -634,7 +634,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen @Override public ClusterState execute(ClusterState currentState) { - if (!masterNode.getId().equals(currentState.nodes().masterNodeId())) { + if (!masterNode.getId().equals(currentState.nodes().getMasterNodeId())) { // master got switched on us, no need to send anything return currentState; } @@ -698,7 +698,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen if (currentState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock())) { // its a fresh update from the master as we transition from a start of not having a master to having one - logger.debug("got first state from fresh master [{}]", newClusterState.nodes().masterNodeId()); + logger.debug("got first state from fresh master [{}]", newClusterState.nodes().getMasterNodeId()); long count = clusterJoinsCounter.incrementAndGet(); logger.trace("updated cluster join cluster to [{}]", count); @@ -783,10 +783,10 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen */ public static void validateStateIsFromCurrentMaster(ESLogger logger, DiscoveryNodes currentNodes, ClusterState newClusterState) { - if (currentNodes.masterNodeId() == null) { + if (currentNodes.getMasterNodeId() == null) { return; } - if (!currentNodes.masterNodeId().equals(newClusterState.nodes().masterNodeId())) { + if (!currentNodes.getMasterNodeId().equals(newClusterState.nodes().getMasterNodeId())) { logger.warn("received a cluster state from a different master than the current one, rejecting (received {}, current {})", newClusterState.nodes().masterNode(), currentNodes.masterNode()); throw new IllegalStateException("cluster state from a different master than the current one, rejecting (received " + newClusterState.nodes().masterNode() + ", current " + currentNodes.masterNode() + ")"); } diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueue.java b/core/src/main/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueue.java index 2f444f50288..5638f877967 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueue.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueue.java @@ -278,7 +278,7 @@ public class PendingClusterStatesQueue { "[uuid[%s], v[%d], m[%s]]", stateUUID(), state.version(), - state.nodes().masterNodeId() + state.nodes().getMasterNodeId() ); } } diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayService.java b/core/src/main/java/org/elasticsearch/gateway/GatewayService.java index 89cc6015ddc..b584080fdac 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayService.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayService.java @@ -163,7 +163,7 @@ public class GatewayService extends AbstractLifecycleComponent i } DiscoveryNodes nodes = state.nodes(); - if (state.nodes().masterNodeId() == null) { + if (state.nodes().getMasterNodeId() == null) { logger.debug("not recovering from gateway, no master elected yet"); } else if (recoverAfterNodes != -1 && (nodes.getMasterAndDataNodes().size()) < recoverAfterNodes) { logger.debug("not recovering from gateway, nodes_size (data+master) [{}] < recover_after_nodes [{}]", diff --git a/core/src/main/java/org/elasticsearch/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java index 5b4f32635f9..45337e1d405 100644 --- a/core/src/main/java/org/elasticsearch/node/Node.java +++ b/core/src/main/java/org/elasticsearch/node/Node.java @@ -337,7 +337,7 @@ public class Node implements Closeable { if (DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.get(settings).millis() > 0) { final ThreadPool thread = injector.getInstance(ThreadPool.class); ClusterStateObserver observer = new ClusterStateObserver(clusterService, null, logger, thread.getThreadContext()); - if (observer.observedState().nodes().masterNodeId() == null) { + if (observer.observedState().nodes().getMasterNodeId() == null) { final CountDownLatch latch = new CountDownLatch(1); observer.waitForNextChange(new ClusterStateObserver.Listener() { @Override diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java index f43c8c019d2..e7a7d7afc96 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java @@ -81,7 +81,7 @@ public class RestMasterAction extends AbstractCatAction { DiscoveryNodes nodes = state.getState().nodes(); table.startRow(); - DiscoveryNode master = nodes.get(nodes.masterNodeId()); + DiscoveryNode master = nodes.get(nodes.getMasterNodeId()); if (master == null) { table.addCell("-"); table.addCell("-"); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java index b3dc1952913..aa19b138d34 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java @@ -223,7 +223,7 @@ public class RestNodesAction extends AbstractCatAction { boolean fullId = req.paramAsBoolean("full_id", false); DiscoveryNodes nodes = state.getState().nodes(); - String masterId = nodes.masterNodeId(); + String masterId = nodes.getMasterNodeId(); Table table = getTableWithHeader(req); for (DiscoveryNode node : nodes) { diff --git a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java index ee17672d6d5..85ccef8305c 100644 --- a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java +++ b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java @@ -159,8 +159,8 @@ public class SnapshotShardsService extends AbstractLifecycleComponent verify we the data back"); for (int i = 0; i < 10; i++) { diff --git a/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java index 5b473879011..625428d09e9 100644 --- a/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java @@ -46,7 +46,7 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { logger.info("--> start data node / non master node"); internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), true).put(Node.NODE_MASTER_SETTING.getKey(), false).put("discovery.initial_state_timeout", "1s")); try { - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().masterNodeId(), nullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().getMasterNodeId(), nullValue()); fail("should not be able to find master"); } catch (MasterNotDiscoveredException e) { // all is well, no master elected @@ -60,7 +60,7 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { internalCluster().stopCurrentMasterNode(); try { - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().masterNodeId(), nullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().getMasterNodeId(), nullValue()); fail("should not be able to find master"); } catch (MasterNotDiscoveredException e) { // all is well, no master elected @@ -76,7 +76,7 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { logger.info("--> start data node / non master node"); internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), true).put(Node.NODE_MASTER_SETTING.getKey(), false).put("discovery.initial_state_timeout", "1s")); try { - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().masterNodeId(), nullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().getMasterNodeId(), nullValue()); fail("should not be able to find master"); } catch (MasterNotDiscoveredException e) { // all is well, no master elected diff --git a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java index a282fcaa3a6..74b81736971 100644 --- a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java @@ -129,7 +129,7 @@ public class DiscoveryNodesTests extends ESTestCase { }, ELECTED_MASTER("_master") { @Override Set matchingNodeIds(DiscoveryNodes nodes) { - return Collections.singleton(nodes.masterNodeId()); + return Collections.singleton(nodes.getMasterNodeId()); } }, MASTER_ELIGIBLE(DiscoveryNode.Role.MASTER.getRoleName() + ":true") { @Override diff --git a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java index 7a30621223b..f6daef45a25 100644 --- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java @@ -402,7 +402,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { try { assertEquals("unequal versions", state.version(), nodeState.version()); assertEquals("unequal node count", state.nodes().getSize(), nodeState.nodes().getSize()); - assertEquals("different masters ", state.nodes().masterNodeId(), nodeState.nodes().masterNodeId()); + assertEquals("different masters ", state.nodes().getMasterNodeId(), nodeState.nodes().getMasterNodeId()); assertEquals("different meta data version", state.metaData().version(), nodeState.metaData().version()); if (!state.routingTable().prettyPrint().equals(nodeState.routingTable().prettyPrint())) { fail("different routing"); @@ -638,7 +638,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { internalCluster().getInstance(ClusterService.class, oldMasterNode).add(new ClusterStateListener() { @Override public void clusterChanged(ClusterChangedEvent event) { - if (event.state().nodes().masterNodeId() == null) { + if (event.state().nodes().getMasterNodeId() == null) { oldMasterNodeSteppedDown.countDown(); } } diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueueTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueueTests.java index 1b989da9dcf..3d4c464f128 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueueTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueueTests.java @@ -108,18 +108,18 @@ public class PendingClusterStatesQueueTests extends ESTestCase { List committedContexts = randomCommitStates(queue); ClusterState randomCommitted = randomFrom(committedContexts).state; queue.markAsProcessed(randomCommitted); - final String processedMaster = randomCommitted.nodes().masterNodeId(); + final String processedMaster = randomCommitted.nodes().getMasterNodeId(); // now check that queue doesn't contain anything pending from another master for (ClusterStateContext context : queue.pendingStates) { - final String pendingMaster = context.state.nodes().masterNodeId(); + final String pendingMaster = context.state.nodes().getMasterNodeId(); assertThat("found a cluster state from [" + pendingMaster + "], after a state from [" + processedMaster + "] was processed", pendingMaster, equalTo(processedMaster)); } // and check all committed contexts from another master were failed for (ClusterStateContext context : committedContexts) { - if (context.state.nodes().masterNodeId().equals(processedMaster) == false) { + if (context.state.nodes().getMasterNodeId().equals(processedMaster) == false) { assertThat(((MockListener) context.listener).failure, notNullValue()); } } diff --git a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java index 90d049601a8..920fb2ba442 100644 --- a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java +++ b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java @@ -240,7 +240,7 @@ public class RareClusterStateIT extends ESIntegTestCase { for (ShardRouting shard : shards) { if (shard.primary()) { // primary must not be on the master node - assertFalse(state.nodes().masterNodeId().equals(shard.currentNodeId())); + assertFalse(state.nodes().getMasterNodeId().equals(shard.currentNodeId())); } else { fail(); // only primaries } @@ -358,7 +358,7 @@ public class RareClusterStateIT extends ESIntegTestCase { for (ShardRouting shard : shards) { if (shard.primary()) { // primary must be on the master - assertEquals(state.nodes().masterNodeId(), shard.currentNodeId()); + assertEquals(state.nodes().getMasterNodeId(), shard.currentNodeId()); } else { assertTrue(shard.active()); } diff --git a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTests.java b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTests.java index 57a6482f676..0da34ad45ca 100644 --- a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTests.java +++ b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTests.java @@ -63,20 +63,20 @@ public class AzureMinimumMasterNodesTests extends AbstractAzureComputeServiceTes logger.info("--> start data node / non master node"); internalCluster().startNode(); try { - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().masterNodeId(), nullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().getMasterNodeId(), nullValue()); fail("should not be able to find master"); } catch (MasterNotDiscoveredException e) { // all is well, no master elected } logger.info("--> start another node"); internalCluster().startNode(); - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().getMasterNodeId(), notNullValue()); logger.info("--> stop master node"); internalCluster().stopCurrentMasterNode(); try { - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), nullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().getMasterNodeId(), nullValue()); fail("should not be able to find master"); } catch (MasterNotDiscoveredException e) { // all is well, no master elected @@ -84,6 +84,6 @@ public class AzureMinimumMasterNodesTests extends AbstractAzureComputeServiceTes logger.info("--> start another node"); internalCluster().startNode(); - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().getMasterNodeId(), notNullValue()); } } diff --git a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTests.java b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTests.java index 0232956016b..7e445c75104 100644 --- a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTests.java +++ b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTests.java @@ -45,7 +45,7 @@ public class AzureSimpleTests extends AbstractAzureComputeServiceTestCase { logger.info("--> start one node"); internalCluster().startNode(settings); - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().getMasterNodeId(), notNullValue()); // We expect having 1 node as part of the cluster, let's test that checkNumberOfNodes(1); @@ -58,7 +58,7 @@ public class AzureSimpleTests extends AbstractAzureComputeServiceTestCase { logger.info("--> start one node"); internalCluster().startNode(settings); - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().getMasterNodeId(), notNullValue()); // We expect having 1 node as part of the cluster, let's test that checkNumberOfNodes(1); diff --git a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTests.java b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTests.java index bb15ad050f0..b61dcf8de2e 100644 --- a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTests.java +++ b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTests.java @@ -46,11 +46,11 @@ public class AzureTwoStartedNodesTests extends AbstractAzureComputeServiceTestCa logger.info("--> start first node"); internalCluster().startNode(settings); - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().getMasterNodeId(), notNullValue()); logger.info("--> start another node"); internalCluster().startNode(settings); - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().getMasterNodeId(), notNullValue()); // We expect having 2 nodes as part of the cluster, let's test that checkNumberOfNodes(2); @@ -64,11 +64,11 @@ public class AzureTwoStartedNodesTests extends AbstractAzureComputeServiceTestCa logger.info("--> start first node"); internalCluster().startNode(settings); - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().getMasterNodeId(), notNullValue()); logger.info("--> start another node"); internalCluster().startNode(settings); - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue()); + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().getMasterNodeId(), notNullValue()); // We expect having 2 nodes as part of the cluster, let's test that checkNumberOfNodes(2); diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index b98cb3d75fb..f7e5028383c 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -1046,7 +1046,7 @@ public abstract class ESIntegTestCase extends ESTestCase { masterClusterState = ClusterState.Builder.fromBytes(masterClusterStateBytes, null); Map masterStateMap = convertToMap(masterClusterState); int masterClusterStateSize = ClusterState.Builder.toBytes(masterClusterState).length; - String masterId = masterClusterState.nodes().masterNodeId(); + String masterId = masterClusterState.nodes().getMasterNodeId(); for (Client client : cluster().getClients()) { ClusterState localClusterState = client.admin().cluster().prepareState().all().setLocal(true).get().getState(); byte[] localClusterStateBytes = ClusterState.Builder.toBytes(localClusterState); @@ -1056,7 +1056,7 @@ public abstract class ESIntegTestCase extends ESTestCase { final int localClusterStateSize = ClusterState.Builder.toBytes(localClusterState).length; // Check that the non-master node has the same version of the cluster state as the master and // that the master node matches the master (otherwise there is no requirement for the cluster state to match) - if (masterClusterState.version() == localClusterState.version() && masterId.equals(localClusterState.nodes().masterNodeId())) { + if (masterClusterState.version() == localClusterState.version() && masterId.equals(localClusterState.nodes().getMasterNodeId())) { try { assertEquals("clusterstate UUID does not match", masterClusterState.stateUUID(), localClusterState.stateUUID()); // We cannot compare serialization bytes since serialization order of maps is not guaranteed From f26d05eac894bc00559aad1a59897f8c451dc7f7 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:17:09 +0200 Subject: [PATCH 18/25] Remove DiscoveryNodes#localNodeId in favour of existing DiscoveryNodes#getLocalNodeId --- .../replication/TransportReplicationAction.java | 6 +++--- .../cluster/node/DiscoveryNodes.java | 15 +++------------ .../cluster/routing/OperationRouting.java | 6 +++--- .../cluster/service/ClusterService.java | 2 +- .../elasticsearch/discovery/zen/ZenDiscovery.java | 2 +- .../discovery/zen/fd/MasterFaultDetection.java | 2 +- .../zen/ping/unicast/UnicastZenPing.java | 2 +- .../elasticsearch/gateway/GatewayMetaState.java | 2 +- .../cluster/IndicesClusterStateService.java | 14 +++++++------- .../elasticsearch/snapshots/RestoreService.java | 8 ++++---- .../snapshots/SnapshotShardsService.java | 8 ++++---- .../TransportReplicationActionTests.java | 4 ++-- .../elasticsearch/cluster/ClusterStateDiffIT.java | 2 +- .../cluster/node/DiscoveryNodesTests.java | 2 +- .../cluster/service/ClusterServiceTests.java | 2 +- .../nodesinfo/SimpleNodesInfoIT.java | 8 ++++---- 16 files changed, 38 insertions(+), 47 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java b/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java index d27a8547fa6..d3a4698c53a 100644 --- a/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java +++ b/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java @@ -449,7 +449,7 @@ public abstract class TransportReplicationAction implements return this.masterNodeId; } - /** - * Get the id of the local node - * - * @return id of the local node - */ - public String localNodeId() { - return this.localNodeId; - } - /** * Get the id of the local node * * @return id of the local node */ public String getLocalNodeId() { - return localNodeId(); + return this.localNodeId; } /** @@ -302,7 +293,7 @@ public class DiscoveryNodes extends AbstractDiffable implements ObjectHashSet resolvedNodesIds = new ObjectHashSet<>(nodesIds.length); for (String nodeId : nodesIds) { if (nodeId.equals("_local")) { - String localNodeId = localNodeId(); + String localNodeId = getLocalNodeId(); if (localNodeId != null) { resolvedNodesIds.add(localNodeId); } @@ -595,7 +586,7 @@ public class DiscoveryNodes extends AbstractDiffable implements public Builder(DiscoveryNodes nodes) { this.masterNodeId = nodes.getMasterNodeId(); - this.localNodeId = nodes.localNodeId(); + this.localNodeId = nodes.getLocalNodeId(); this.nodes = ImmutableOpenMap.builder(nodes.getNodes()); } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java b/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java index 3db26b45254..aabb1a8de6e 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java @@ -58,12 +58,12 @@ public class OperationRouting extends AbstractComponent { } public ShardIterator getShards(ClusterState clusterState, String index, String type, String id, @Nullable String routing, @Nullable String preference) { - return preferenceActiveShardIterator(shards(clusterState, index, id, routing), clusterState.nodes().localNodeId(), clusterState.nodes(), preference); + return preferenceActiveShardIterator(shards(clusterState, index, id, routing), clusterState.nodes().getLocalNodeId(), clusterState.nodes(), preference); } public ShardIterator getShards(ClusterState clusterState, String index, int shardId, @Nullable String preference) { final IndexShardRoutingTable indexShard = clusterState.getRoutingTable().shardRoutingTable(index, shardId); - return preferenceActiveShardIterator(indexShard, clusterState.nodes().localNodeId(), clusterState.nodes(), preference); + return preferenceActiveShardIterator(indexShard, clusterState.nodes().getLocalNodeId(), clusterState.nodes(), preference); } public int searchShardsCount(ClusterState clusterState, String[] concreteIndices, @Nullable Map> routing) { @@ -75,7 +75,7 @@ public class OperationRouting extends AbstractComponent { final Set shards = computeTargetedShards(clusterState, concreteIndices, routing); final Set set = new HashSet<>(shards.size()); for (IndexShardRoutingTable shard : shards) { - ShardIterator iterator = preferenceActiveShardIterator(shard, clusterState.nodes().localNodeId(), clusterState.nodes(), preference); + ShardIterator iterator = preferenceActiveShardIterator(shard, clusterState.nodes().getLocalNodeId(), clusterState.nodes(), preference); if (iterator != null) { set.add(iterator); } diff --git a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java index 559c5d6300e..924a20c2c3a 100644 --- a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java +++ b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java @@ -158,7 +158,7 @@ public class ClusterService extends AbstractLifecycleComponent { } synchronized public void setLocalNode(DiscoveryNode localNode) { - assert clusterState.nodes().localNodeId() == null : "local node is already set"; + assert clusterState.nodes().getLocalNodeId() == null : "local node is already set"; DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.nodes()).put(localNode).localNodeId(localNode.getId()); this.clusterState = ClusterState.builder(clusterState).nodes(nodeBuilder).build(); } 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 d7aaac5612b..22c5221c0e8 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -967,7 +967,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen // since the network connections are asymmetric, it may be that we received a state but have disconnected from the node // in the past (after a master failure, for example) transportService.connectToNode(otherMaster); - transportService.sendRequest(otherMaster, DISCOVERY_REJOIN_ACTION_NAME, new RejoinClusterRequest(localClusterState.nodes().localNodeId()), new EmptyTransportResponseHandler(ThreadPool.Names.SAME) { + transportService.sendRequest(otherMaster, DISCOVERY_REJOIN_ACTION_NAME, new RejoinClusterRequest(localClusterState.nodes().getLocalNodeId()), new EmptyTransportResponseHandler(ThreadPool.Names.SAME) { @Override public void handleException(TransportException exp) { diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java b/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java index a3974fd48e1..116e622088e 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java @@ -328,7 +328,7 @@ public class MasterFaultDetection extends FaultDetection { final DiscoveryNodes nodes = clusterService.state().nodes(); // check if we are really the same master as the one we seemed to be think we are // this can happen if the master got "kill -9" and then another node started using the same port - if (!request.masterNodeId.equals(nodes.localNodeId())) { + if (!request.masterNodeId.equals(nodes.getLocalNodeId())) { throw new ThisIsNotTheMasterYouAreLookingForException(); } diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java index 0135b53a844..69f107d0ab1 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java @@ -469,7 +469,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen try { DiscoveryNodes discoveryNodes = contextProvider.nodes(); for (PingResponse pingResponse : response.pingResponses) { - if (pingResponse.node().getId().equals(discoveryNodes.localNodeId())) { + if (pingResponse.node().getId().equals(discoveryNodes.getLocalNodeId())) { // that's us, ignore continue; } diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java index a229b8ed5a1..905e572160c 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java @@ -285,7 +285,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL } public static Set getRelevantIndicesOnDataOnlyNode(ClusterState state, ClusterState previousState, Set previouslyWrittenIndices) { - RoutingNode newRoutingNode = state.getRoutingNodes().node(state.nodes().localNodeId()); + RoutingNode newRoutingNode = state.getRoutingNodes().node(state.nodes().getLocalNodeId()); if (newRoutingNode == null) { throw new IllegalStateException("cluster state does not contain this node - cannot write index meta state"); } diff --git a/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index 82f1466bf13..0a9a73cf0f1 100644 --- a/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -193,7 +193,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent hasAllocations = new HashSet<>(); - final RoutingNode node = event.state().getRoutingNodes().node(event.state().nodes().localNodeId()); + final RoutingNode node = event.state().getRoutingNodes().node(event.state().nodes().getLocalNodeId()); // if no shards are allocated ie. if this node is a master-only node it can return nul if (node != null) { for (ShardRouting routing : node) { @@ -362,7 +362,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent capturedRequests = transport.getCapturedRequestsByTargetNodeAndClear().get(primaryNodeId); assertThat(capturedRequests, notNullValue()); assertThat(capturedRequests.size(), equalTo(1)); - if (clusterService.state().nodes().localNodeId().equals(primaryNodeId)) { + if (clusterService.state().nodes().getLocalNodeId().equals(primaryNodeId)) { assertThat(capturedRequests.get(0).action, equalTo("testAction[p]")); assertPhase(task, "waiting_on_primary"); } else { @@ -722,7 +722,7 @@ public class TransportReplicationActionTests extends ESTestCase { assertEquals(request.shardId, replicationRequest.shardId); } - String localNodeId = clusterService.state().getNodes().localNodeId(); + String localNodeId = clusterService.state().getNodes().getLocalNodeId(); // no request was sent to the local node assertThat(nodesSentTo.keySet(), not(hasItem(localNodeId))); diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java index 0490864dbc2..88eb7c37097 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java @@ -134,7 +134,7 @@ public class ClusterStateDiffIT extends ESIntegTestCase { // Check nodes assertThat(clusterStateFromDiffs.nodes().getNodes(), equalTo(clusterState.nodes().getNodes())); - assertThat(clusterStateFromDiffs.nodes().localNodeId(), equalTo(previousClusterStateFromDiffs.nodes().localNodeId())); + assertThat(clusterStateFromDiffs.nodes().getLocalNodeId(), equalTo(previousClusterStateFromDiffs.nodes().getLocalNodeId())); assertThat(clusterStateFromDiffs.nodes().getNodes(), equalTo(clusterState.nodes().getNodes())); for (ObjectCursor node : clusterStateFromDiffs.nodes().getNodes().keys()) { DiscoveryNode node1 = clusterState.nodes().get(node.value); diff --git a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java index 74b81736971..b0942ab401c 100644 --- a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java @@ -124,7 +124,7 @@ public class DiscoveryNodesTests extends ESTestCase { LOCAL("_local") { @Override Set matchingNodeIds(DiscoveryNodes nodes) { - return Collections.singleton(nodes.localNodeId()); + return Collections.singleton(nodes.getLocalNodeId()); } }, ELECTED_MASTER("_master") { @Override diff --git a/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceTests.java b/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceTests.java index 66b5fd0671b..94b54b771e6 100644 --- a/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceTests.java @@ -123,7 +123,7 @@ public class ClusterServiceTests extends ESTestCase { ClusterState state = timedClusterService.state(); final DiscoveryNodes nodes = state.nodes(); final DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(nodes) - .masterNodeId(makeMaster ? nodes.localNodeId() : null); + .masterNodeId(makeMaster ? nodes.getLocalNodeId() : null); state = ClusterState.builder(state).blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK) .nodes(nodesBuilder).build(); setState(timedClusterService, state); diff --git a/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java b/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java index 03b7a258f4f..c38aeb967ef 100644 --- a/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java +++ b/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java @@ -49,8 +49,8 @@ public class SimpleNodesInfoIT extends ESIntegTestCase { ClusterHealthResponse clusterHealth = client().admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get(); logger.info("--> done cluster_health, status {}", clusterHealth.getStatus()); - String server1NodeId = internalCluster().getInstance(ClusterService.class, node_1).state().nodes().localNodeId(); - String server2NodeId = internalCluster().getInstance(ClusterService.class, node_2).state().nodes().localNodeId(); + String server1NodeId = internalCluster().getInstance(ClusterService.class, node_1).state().nodes().getLocalNodeId(); + String server2NodeId = internalCluster().getInstance(ClusterService.class, node_2).state().nodes().getLocalNodeId(); logger.info("--> started nodes: {} and {}", server1NodeId, server2NodeId); NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet(); @@ -93,8 +93,8 @@ public class SimpleNodesInfoIT extends ESIntegTestCase { ClusterHealthResponse clusterHealth = client().admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get(); logger.info("--> done cluster_health, status {}", clusterHealth.getStatus()); - String server1NodeId = internalCluster().getInstance(ClusterService.class, node_1).state().nodes().localNodeId(); - String server2NodeId = internalCluster().getInstance(ClusterService.class, node_2).state().nodes().localNodeId(); + String server1NodeId = internalCluster().getInstance(ClusterService.class, node_1).state().nodes().getLocalNodeId(); + String server2NodeId = internalCluster().getInstance(ClusterService.class, node_2).state().nodes().getLocalNodeId(); logger.info("--> started nodes: {} and {}", server1NodeId, server2NodeId); NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet(); From 7ebc094353cf489621dee01d6e5d6fc505870cad Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:18:10 +0200 Subject: [PATCH 19/25] Remove DiscoveryNodes#localNode in favour of existing DiscoveryNodes#getLocalNode --- .../TransportInstanceSingleOperationAction.java | 2 +- .../transport/TransportClientNodesService.java | 2 +- .../org/elasticsearch/cluster/ClusterState.java | 2 +- .../action/index/NodeIndexDeletedAction.java | 2 +- .../cluster/node/DiscoveryNodes.java | 15 +++------------ .../cluster/routing/IndexShardRoutingTable.java | 2 +- .../cluster/service/ClusterService.java | 8 ++++---- .../discovery/local/LocalDiscovery.java | 2 +- .../discovery/zen/NodeJoinController.java | 2 +- .../elasticsearch/discovery/zen/ZenDiscovery.java | 6 +++--- .../zen/membership/MembershipAction.java | 2 +- .../zen/ping/unicast/UnicastZenPing.java | 2 +- .../zen/publish/PublishClusterStateAction.java | 6 +++--- .../elasticsearch/gateway/GatewayAllocator.java | 2 +- .../elasticsearch/gateway/GatewayMetaState.java | 6 +++--- .../org/elasticsearch/indices/IndicesService.java | 4 ++-- .../cluster/IndicesClusterStateService.java | 10 +++++----- .../elasticsearch/indices/store/IndicesStore.java | 2 +- .../repositories/VerifyNodeRepositoryAction.java | 2 +- .../java/org/elasticsearch/tasks/TaskManager.java | 2 +- .../elasticsearch/cluster/ClusterStateDiffIT.java | 2 +- .../DiscoveryWithServiceDisruptionsIT.java | 2 +- .../discovery/zen/NodeJoinControllerTests.java | 2 +- .../discovery/zen/ZenDiscoveryIT.java | 2 +- .../publish/PublishClusterStateActionTests.java | 2 +- 25 files changed, 41 insertions(+), 50 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/support/single/instance/TransportInstanceSingleOperationAction.java b/core/src/main/java/org/elasticsearch/action/support/single/instance/TransportInstanceSingleOperationAction.java index fba7d80299b..847eee195e8 100644 --- a/core/src/main/java/org/elasticsearch/action/support/single/instance/TransportInstanceSingleOperationAction.java +++ b/core/src/main/java/org/elasticsearch/action/support/single/instance/TransportInstanceSingleOperationAction.java @@ -228,7 +228,7 @@ public abstract class TransportInstanceSingleOperationAction entry : clusterStateResponses.entrySet()) { if (!ignoreClusterName && !clusterName.equals(entry.getValue().getClusterName())) { logger.warn("node {} not part of the cluster {}, ignoring...", - entry.getValue().getState().nodes().localNode(), clusterName); + entry.getValue().getState().nodes().getLocalNode(), clusterName); newFilteredNodes.add(entry.getKey()); continue; } diff --git a/core/src/main/java/org/elasticsearch/cluster/ClusterState.java b/core/src/main/java/org/elasticsearch/cluster/ClusterState.java index 6dd8f3bc747..3f9ef6a82b8 100644 --- a/core/src/main/java/org/elasticsearch/cluster/ClusterState.java +++ b/core/src/main/java/org/elasticsearch/cluster/ClusterState.java @@ -747,7 +747,7 @@ public class ClusterState implements ToXContent, Diffable { @Override public ClusterState readFrom(StreamInput in) throws IOException { - return readFrom(in, nodes.localNode()); + return readFrom(in, nodes.getLocalNode()); } @Override diff --git a/core/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexDeletedAction.java b/core/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexDeletedAction.java index 93fce95fc23..c9a27f2c929 100644 --- a/core/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexDeletedAction.java +++ b/core/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexDeletedAction.java @@ -80,7 +80,7 @@ public class NodeIndexDeletedAction extends AbstractComponent { final DiscoveryNodes nodes = clusterState.nodes(); transportService.sendRequest(clusterState.nodes().masterNode(), INDEX_DELETED_ACTION_NAME, new NodeIndexDeletedMessage(index, nodeId), EmptyTransportResponseHandler.INSTANCE_SAME); - if (nodes.localNode().isDataNode() == false) { + if (nodes.getLocalNode().isDataNode() == false) { logger.trace("[{}] not acking store deletion (not a data node)", index); return; } 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 0dc1517ef11..45ac4a6b971 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -188,22 +188,13 @@ public class DiscoveryNodes extends AbstractDiffable implements return this.localNodeId; } - /** - * Get the local node - * - * @return local node - */ - public DiscoveryNode localNode() { - return nodes.get(localNodeId); - } - /** * Get the local node * * @return local node */ public DiscoveryNode getLocalNode() { - return localNode(); + return nodes.get(localNodeId); } /** @@ -415,7 +406,7 @@ public class DiscoveryNodes extends AbstractDiffable implements sb.append("nodes: \n"); for (DiscoveryNode node : this) { sb.append(" ").append(node); - if (node == localNode()) { + if (node == getLocalNode()) { sb.append(", local"); } if (node == masterNode()) { @@ -563,7 +554,7 @@ public class DiscoveryNodes extends AbstractDiffable implements @Override public DiscoveryNodes readFrom(StreamInput in) throws IOException { - return readFrom(in, localNode()); + return readFrom(in, getLocalNode()); } public static Builder builder() { diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java b/core/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java index 5096b578fb7..d504a74dc3c 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java @@ -477,7 +477,7 @@ public class IndexShardRoutingTable implements Iterable { private static List collectAttributeShards(AttributesKey key, DiscoveryNodes nodes, ArrayList from) { final ArrayList to = new ArrayList<>(); for (final String attribute : key.attributes) { - final String localAttributeValue = nodes.localNode().getAttributes().get(attribute); + final String localAttributeValue = nodes.getLocalNode().getAttributes().get(attribute); if (localAttributeValue != null) { for (Iterator iterator = from.iterator(); iterator.hasNext(); ) { ShardRouting fromShard = iterator.next(); diff --git a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java index 924a20c2c3a..d280ec591e3 100644 --- a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java +++ b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java @@ -198,7 +198,7 @@ public class ClusterService extends AbstractLifecycleComponent { @Override synchronized protected void doStart() { Objects.requireNonNull(clusterStatePublisher, "please set a cluster state publisher before starting"); - Objects.requireNonNull(clusterState.nodes().localNode(), "please set the local node before starting"); + Objects.requireNonNull(clusterState.nodes().getLocalNode(), "please set the local node before starting"); Objects.requireNonNull(nodeConnectionsService, "please set the node connection service before starting"); add(localNodeMasterListeners); this.clusterState = ClusterState.builder(clusterState).blocks(initialBlocks).build(); @@ -229,7 +229,7 @@ public class ClusterService extends AbstractLifecycleComponent { * The local node. */ public DiscoveryNode localNode() { - return clusterState.getNodes().localNode(); + return clusterState.getNodes().getLocalNode(); } public OperationRouting operationRouting() { @@ -663,9 +663,9 @@ public class ClusterService extends AbstractLifecycleComponent { //manual ack only from the master at the end of the publish if (newClusterState.nodes().localNodeMaster()) { try { - ackListener.onNodeAck(newClusterState.nodes().localNode(), null); + ackListener.onNodeAck(newClusterState.nodes().getLocalNode(), null); } catch (Throwable t) { - logger.debug("error while processing ack for master node [{}]", t, newClusterState.nodes().localNode()); + logger.debug("error while processing ack for master node [{}]", t, newClusterState.nodes().getLocalNode()); } } diff --git a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java index 2b22da61290..97ecf00b1fc 100644 --- a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java @@ -339,7 +339,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem nodeSpecificClusterState.status(ClusterState.ClusterStateStatus.RECEIVED); // ignore cluster state messages that do not include "me", not in the game yet... - if (nodeSpecificClusterState.nodes().localNode() != null) { + if (nodeSpecificClusterState.nodes().getLocalNode() != null) { assert nodeSpecificClusterState.nodes().masterNode() != null : "received a cluster state without a master"; assert !nodeSpecificClusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock()) : "received a cluster state with a master block"; diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java index 7b0cf8361b3..5afc81c484a 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java @@ -246,7 +246,7 @@ public class NodeJoinController extends AbstractComponent { throw new NotMasterException("Node [" + clusterService.localNode() + "] not master for join request"); } - DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder(currentState.nodes()).masterNodeId(currentState.nodes().localNode().getId()); + DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder(currentState.nodes()).masterNodeId(currentState.nodes().getLocalNode().getId()); // update the fact that we are the master... ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(discoverySettings.getNoMasterBlock()).build(); currentState = ClusterState.builder(currentState).nodes(builder).blocks(clusterBlocks).build(); 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 22c5221c0e8..353880a39cb 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -246,7 +246,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen // if we don't know who the master is, nothing to do here } else if (!nodes.localNodeMaster()) { try { - membership.sendLeaveRequestBlocking(nodes.masterNode(), nodes.localNode(), TimeValue.timeValueSeconds(1)); + membership.sendLeaveRequestBlocking(nodes.masterNode(), nodes.getLocalNode(), TimeValue.timeValueSeconds(1)); } catch (Exception e) { logger.debug("failed to send leave request to master [{}]", e, nodes.masterNode()); } @@ -254,11 +254,11 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen // we're master -> let other potential master we left and start a master election now rather then wait for masterFD DiscoveryNode[] possibleMasters = electMaster.nextPossibleMasters(nodes.getNodes().values(), 5); for (DiscoveryNode possibleMaster : possibleMasters) { - if (nodes.localNode().equals(possibleMaster)) { + if (nodes.getLocalNode().equals(possibleMaster)) { continue; } try { - membership.sendLeaveRequest(nodes.localNode(), possibleMaster); + membership.sendLeaveRequest(nodes.getLocalNode(), possibleMaster); } catch (Exception e) { logger.debug("failed to send leave request from master [{}] to possible master [{}]", e, nodes.masterNode(), possibleMaster); } diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java b/core/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java index bec5abccd24..46686965741 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java @@ -171,7 +171,7 @@ public class MembershipAction extends AbstractComponent { @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - this.state = ClusterState.Builder.readFrom(in, nodesProvider.nodes().localNode()); + this.state = ClusterState.Builder.readFrom(in, nodesProvider.nodes().getLocalNode()); } @Override diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java index 69f107d0ab1..0d4d4a9b004 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java @@ -565,7 +565,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen } private PingResponse createPingResponse(DiscoveryNodes discoNodes) { - return new PingResponse(discoNodes.localNode(), discoNodes.masterNode(), clusterName, contextProvider.nodeHasJoinedClusterOnce()); + return new PingResponse(discoNodes.getLocalNode(), discoNodes.masterNode(), clusterName, contextProvider.nodeHasJoinedClusterOnce()); } static class UnicastPingResponse extends TransportResponse { 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 87ed92d7a41..1f5eb882f77 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 @@ -126,7 +126,7 @@ public class PublishClusterStateAction extends AbstractComponent { try { nodes = clusterChangedEvent.state().nodes(); nodesToPublishTo = new HashSet<>(nodes.getSize()); - DiscoveryNode localNode = nodes.localNode(); + DiscoveryNode localNode = nodes.getLocalNode(); final int totalMasterNodes = nodes.getMasterNodes().size(); for (final DiscoveryNode node : nodes) { if (node.equals(localNode) == false) { @@ -363,7 +363,7 @@ public class PublishClusterStateAction extends AbstractComponent { final ClusterState incomingState; // If true we received full cluster state - otherwise diffs if (in.readBoolean()) { - incomingState = ClusterState.Builder.readFrom(in, nodesProvider.nodes().localNode()); + incomingState = ClusterState.Builder.readFrom(in, nodesProvider.nodes().getLocalNode()); logger.debug("received full cluster state version [{}] with size [{}]", incomingState.version(), request.bytes().length()); } else if (lastSeenClusterState != null) { Diff diff = lastSeenClusterState.readDiffFrom(in); @@ -396,7 +396,7 @@ public class PublishClusterStateAction extends AbstractComponent { } final DiscoveryNodes currentNodes = nodesProvider.nodes(); - if (currentNodes.localNode().equals(incomingState.nodes().localNode()) == false) { + if (currentNodes.getLocalNode().equals(incomingState.nodes().getLocalNode()) == false) { logger.warn("received a cluster state from [{}] and not part of the cluster, should not happen", incomingState.nodes().masterNode()); throw new IllegalStateException("received state from a node that is not part of the cluster"); } diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java b/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java index f8fcaa43286..7553a4b47a3 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java @@ -68,7 +68,7 @@ public class GatewayAllocator extends AbstractComponent { @Override public void clusterChanged(ClusterChangedEvent event) { boolean cleanCache = false; - DiscoveryNode localNode = event.state().nodes().localNode(); + DiscoveryNode localNode = event.state().nodes().getLocalNode(); if (localNode != null) { if (localNode.isMasterNode() == true && event.localNodeMaster() == false) { cleanCache = true; diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java index 905e572160c..534a73355af 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java @@ -118,7 +118,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL Set relevantIndices = Collections.emptySet(); boolean success = true; // write the state if this node is a master eligible node or if it is a data node and has shards allocated on it - if (state.nodes().localNode().isMasterNode() || state.nodes().localNode().isDataNode()) { + if (state.nodes().getLocalNode().isMasterNode() || state.nodes().getLocalNode().isDataNode()) { if (previousMetaData == null) { try { // we determine if or if not we write meta data on data only nodes by looking at the shard routing @@ -178,7 +178,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL Set relevantIndices; if (isDataOnlyNode(state)) { relevantIndices = getRelevantIndicesOnDataOnlyNode(state, previousState, previouslyWrittenIndices); - } else if (state.nodes().localNode().isMasterNode() == true) { + } else if (state.nodes().getLocalNode().isMasterNode() == true) { relevantIndices = getRelevantIndicesForMasterEligibleNode(state); } else { relevantIndices = Collections.emptySet(); @@ -188,7 +188,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL protected static boolean isDataOnlyNode(ClusterState state) { - return ((state.nodes().localNode().isMasterNode() == false) && state.nodes().localNode().isDataNode()); + return ((state.nodes().getLocalNode().isMasterNode() == false) && state.nodes().getLocalNode().isDataNode()); } /** diff --git a/core/src/main/java/org/elasticsearch/indices/IndicesService.java b/core/src/main/java/org/elasticsearch/indices/IndicesService.java index 1f3482cd60a..55cf7d43eab 100644 --- a/core/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/core/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -535,7 +535,7 @@ public class IndicesService extends AbstractLifecycleComponent i throw new IllegalStateException("Can't delete index store for [" + index.getName() + "] - it's still part of the indices service [" + localUUid + "] [" + metaData.getIndexUUID() + "]"); } - if (clusterState.metaData().hasIndex(index.getName()) && (clusterState.nodes().localNode().isMasterNode() == true)) { + if (clusterState.metaData().hasIndex(index.getName()) && (clusterState.nodes().getLocalNode().isMasterNode() == true)) { // we do not delete the store if it is a master eligible node and the index is still in the cluster state // because we want to keep the meta data for indices around even if no shards are left here final IndexMetaData idxMeta = clusterState.metaData().index(index.getName()); @@ -608,7 +608,7 @@ public class IndicesService extends AbstractLifecycleComponent i nodeEnv.deleteShardDirectorySafe(shardId, indexSettings); logger.debug("{} deleted shard reason [{}]", shardId, reason); - if (clusterState.nodes().localNode().isMasterNode() == false && // master nodes keep the index meta data, even if having no shards.. + if (clusterState.nodes().getLocalNode().isMasterNode() == false && // master nodes keep the index meta data, even if having no shards.. canDeleteIndexContents(shardId.getIndex(), indexSettings, false)) { if (nodeEnv.findAllShardIds(shardId.getIndex()).isEmpty()) { try { diff --git a/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index 0a9a73cf0f1..255d6fb2e6a 100644 --- a/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -617,7 +617,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent { try { - if (indexShard.recoverFromStore(nodes.localNode())) { + if (indexShard.recoverFromStore(nodes.getLocalNode())) { shardStateAction.shardStarted(shardRouting, "after recovery from store", SHARD_STATE_ACTION_LISTENER); } } catch (Throwable t) { @@ -644,13 +644,13 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent { final ShardId sId = indexShard.shardId(); try { final IndexShardRepository indexShardRepository = repositoriesService.indexShardRepository(restoreSource.snapshotId().getRepository()); - if (indexShard.restoreFromRepository(indexShardRepository, nodes.localNode())) { + if (indexShard.restoreFromRepository(indexShardRepository, nodes.getLocalNode())) { restoreService.indexShardRestoreCompleted(restoreSource.snapshotId(), sId); shardStateAction.shardStarted(shardRouting, "after recovery from repository", SHARD_STATE_ACTION_LISTENER); } diff --git a/core/src/main/java/org/elasticsearch/indices/store/IndicesStore.java b/core/src/main/java/org/elasticsearch/indices/store/IndicesStore.java index c86d6504e28..3402349743f 100644 --- a/core/src/main/java/org/elasticsearch/indices/store/IndicesStore.java +++ b/core/src/main/java/org/elasticsearch/indices/store/IndicesStore.java @@ -160,7 +160,7 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe } // check if shard is active on the current node or is getting relocated to the our node - String localNodeId = state.getNodes().localNode().getId(); + String localNodeId = state.getNodes().getLocalNode().getId(); if (localNodeId.equals(shardRouting.currentNodeId()) || localNodeId.equals(shardRouting.relocatingNodeId())) { return false; } diff --git a/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java b/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java index c474b5c7cd8..93bcca1c375 100644 --- a/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java +++ b/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java @@ -69,7 +69,7 @@ public class VerifyNodeRepositoryAction extends AbstractComponent { public void verify(String repository, String verificationToken, final ActionListener listener) { final DiscoveryNodes discoNodes = clusterService.state().nodes(); - final DiscoveryNode localNode = discoNodes.localNode(); + final DiscoveryNode localNode = discoNodes.getLocalNode(); final ObjectContainer masterAndDataNodes = discoNodes.getMasterAndDataNodes().values(); final List nodes = new ArrayList<>(); diff --git a/core/src/main/java/org/elasticsearch/tasks/TaskManager.java b/core/src/main/java/org/elasticsearch/tasks/TaskManager.java index c881e1756e8..c1f130e0d9a 100644 --- a/core/src/main/java/org/elasticsearch/tasks/TaskManager.java +++ b/core/src/main/java/org/elasticsearch/tasks/TaskManager.java @@ -231,7 +231,7 @@ public class TaskManager extends AbstractComponent implements ClusterStateListen TaskId taskId = banIterator.next(); if (lastDiscoveryNodes.nodeExists(taskId.getNodeId()) == false) { logger.debug("Removing ban for the parent [{}] on the node [{}], reason: the parent node is gone", taskId, - event.state().getNodes().localNode()); + event.state().getNodes().getLocalNode()); banIterator.remove(); } } diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java index 88eb7c37097..410bbd735c7 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java @@ -112,7 +112,7 @@ public class ClusterStateDiffIT extends ESIntegTestCase { if (randomIntBetween(0, 10) < 1) { // Update cluster state via full serialization from time to time - clusterStateFromDiffs = ClusterState.Builder.fromBytes(ClusterState.Builder.toBytes(clusterState), previousClusterStateFromDiffs.nodes().localNode()); + clusterStateFromDiffs = ClusterState.Builder.fromBytes(ClusterState.Builder.toBytes(clusterState), previousClusterStateFromDiffs.nodes().getLocalNode()); } else { // Update cluster states using diffs Diff diffBeforeSerialization = clusterState.diff(previousClusterState); diff --git a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java index f6daef45a25..ab76924e685 100644 --- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java @@ -856,7 +856,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { logger.info("blocking cluster state publishing from master [{}] to non master [{}]", masterNode, nonMasterNode); MockTransportService masterTransportService = (MockTransportService) internalCluster().getInstance(TransportService.class, masterNode); - TransportService localTransportService = internalCluster().getInstance(TransportService.class, discoveryNodes.localNode().getName()); + TransportService localTransportService = internalCluster().getInstance(TransportService.class, discoveryNodes.getLocalNode().getName()); if (randomBoolean()) { masterTransportService.addFailToSendNoConnectRule(localTransportService, PublishClusterStateAction.SEND_ACTION_NAME); } else { diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java index 74b96a1241e..1cba170e8ad 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java @@ -94,7 +94,7 @@ public class NodeJoinControllerTests extends ESTestCase { super.setUp(); clusterService = createClusterService(threadPool); final DiscoveryNodes initialNodes = clusterService.state().nodes(); - final DiscoveryNode localNode = initialNodes.localNode(); + final DiscoveryNode localNode = initialNodes.getLocalNode(); // make sure we have a master setState(clusterService, ClusterState.builder(clusterService.state()).nodes( DiscoveryNodes.builder(initialNodes).masterNodeId(localNode.getId()))); diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java index 2dc53127684..6ea3967c46f 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java @@ -235,7 +235,7 @@ public class ZenDiscoveryIT extends ESIntegTestCase { ClusterState stateWithCustomMetaData = ClusterState.builder(state).metaData(mdBuilder).build(); final AtomicReference holder = new AtomicReference<>(); - DiscoveryNode node = state.nodes().localNode(); + DiscoveryNode node = state.nodes().getLocalNode(); zenDiscovery.handleJoinRequest(node, stateWithCustomMetaData, new MembershipAction.JoinCallback() { @Override public void onSuccess() { diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java index bb7ef29e3d5..a94a03fb671 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java @@ -420,7 +420,7 @@ public class PublishClusterStateActionTests extends ESTestCase { for (MockNode node : nodes.values()) { assertSameState(node.clusterState, clusterState); - assertThat(node.clusterState.nodes().localNode(), equalTo(node.discoveryNode)); + assertThat(node.clusterState.nodes().getLocalNode(), equalTo(node.discoveryNode)); } } From 62ac7d219f821d8ba295e023e272cceeac4cecbf Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:19:28 +0200 Subject: [PATCH 20/25] Remove DiscoveryNodes#masterNode in favour of existing DiscoveryNodes#getMasterNode --- .../master/TransportMasterNodeAction.java | 8 +++--- .../action/index/NodeIndexDeletedAction.java | 4 +-- .../index/NodeMappingRefreshAction.java | 4 +-- .../action/shard/ShardStateAction.java | 2 +- .../cluster/node/DiscoveryNodes.java | 17 +++--------- .../cluster/service/ClusterService.java | 2 +- .../discovery/local/LocalDiscovery.java | 2 +- .../discovery/zen/NodeJoinController.java | 4 +-- .../discovery/zen/ZenDiscovery.java | 26 +++++++++---------- .../zen/ping/unicast/UnicastZenPing.java | 2 +- .../publish/PendingClusterStatesQueue.java | 4 +-- .../publish/PublishClusterStateAction.java | 6 ++--- .../gateway/LocalAllocateDangledIndices.java | 2 +- .../cluster/IndicesClusterStateService.java | 16 ++++++------ .../snapshots/RestoreService.java | 4 +-- .../snapshots/SnapshotShardsService.java | 2 +- .../TransportBroadcastByNodeActionTests.java | 4 +-- .../BasicBackwardsCompatibilityIT.java | 2 +- .../cluster/MinimumMasterNodesIT.java | 2 +- .../cluster/SpecificMasterNodesIT.java | 22 ++++++++-------- .../action/shard/ShardStateActionTests.java | 2 +- .../cluster/service/ClusterServiceIT.java | 8 +++--- .../DiscoveryWithServiceDisruptionsIT.java | 12 ++++----- .../discovery/ZenUnicastDiscoveryIT.java | 4 +-- .../PublishClusterStateActionTests.java | 2 +- .../indices/state/RareClusterStateIT.java | 4 +-- .../test/InternalTestCluster.java | 2 +- 27 files changed, 80 insertions(+), 89 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeAction.java b/core/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeAction.java index 1a7092c3a97..cd07b87cdc9 100644 --- a/core/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeAction.java +++ b/core/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeAction.java @@ -168,12 +168,12 @@ public abstract class TransportMasterNodeAction(listener) { + taskManager.registerChildTask(task, nodes.getMasterNode().getId()); + transportService.sendRequest(nodes.getMasterNode(), actionName, request, new ActionListenerResponseHandler(listener) { @Override public Response newInstance() { return newResponse(); @@ -185,7 +185,7 @@ public abstract class TransportMasterNodeAction { diff --git a/core/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java b/core/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java index 68926368ddb..6b9079cb363 100644 --- a/core/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java +++ b/core/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java @@ -92,7 +92,7 @@ public class ShardStateAction extends AbstractComponent { } private void sendShardAction(final String actionName, final ClusterStateObserver observer, final ShardRoutingEntry shardRoutingEntry, final Listener listener) { - DiscoveryNode masterNode = observer.observedState().nodes().masterNode(); + DiscoveryNode masterNode = observer.observedState().nodes().getMasterNode(); if (masterNode == null) { logger.warn("{} no master known for action [{}] for shard [{}]", shardRoutingEntry.getShardRouting().shardId(), actionName, shardRoutingEntry.getShardRouting()); waitForNewMasterAndRetry(actionName, observer, shardRoutingEntry, listener); 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 45ac4a6b971..e24098ea8ab 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -197,22 +197,13 @@ public class DiscoveryNodes extends AbstractDiffable implements return nodes.get(localNodeId); } - /** - * Get the master node - * - * @return master node - */ - public DiscoveryNode masterNode() { - return nodes.get(masterNodeId); - } - /** * Get the master node * * @return master node */ public DiscoveryNode getMasterNode() { - return masterNode(); + return nodes.get(masterNodeId); } /** @@ -383,8 +374,8 @@ public class DiscoveryNodes extends AbstractDiffable implements DiscoveryNode newMasterNode = null; if (masterNodeId != null) { if (other.masterNodeId == null || !other.masterNodeId.equals(masterNodeId)) { - previousMasterNode = other.masterNode(); - newMasterNode = masterNode(); + previousMasterNode = other.getMasterNode(); + newMasterNode = getMasterNode(); } } return new Delta(previousMasterNode, newMasterNode, localNodeId, Collections.unmodifiableList(removed), Collections.unmodifiableList(added)); @@ -409,7 +400,7 @@ public class DiscoveryNodes extends AbstractDiffable implements if (node == getLocalNode()) { sb.append(", local"); } - if (node == masterNode()) { + if (node == getMasterNode()) { sb.append(", master"); } sb.append("\n"); diff --git a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java index d280ec591e3..ca350ea0a05 100644 --- a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java +++ b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java @@ -973,7 +973,7 @@ public class ClusterService extends AbstractLifecycleComponent { public void onNodeAck(DiscoveryNode node, @Nullable Throwable t) { if (!ackedTaskListener.mustAck(node)) { //we always wait for the master ack anyway - if (!node.equals(nodes.masterNode())) { + if (!node.equals(nodes.getMasterNode())) { return; } } diff --git a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java index 97ecf00b1fc..03f27d093e8 100644 --- a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java @@ -340,7 +340,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem nodeSpecificClusterState.status(ClusterState.ClusterStateStatus.RECEIVED); // ignore cluster state messages that do not include "me", not in the game yet... if (nodeSpecificClusterState.nodes().getLocalNode() != null) { - assert nodeSpecificClusterState.nodes().masterNode() != null : "received a cluster state without a master"; + assert nodeSpecificClusterState.nodes().getMasterNode() != null : "received a cluster state without a master"; assert !nodeSpecificClusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock()) : "received a cluster state with a master block"; discovery.clusterService.submitStateUpdateTask("local-disco-receive(from master)", new ClusterStateUpdateTask() { diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java index 5afc81c484a..ddfb49340a4 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java @@ -240,9 +240,9 @@ public class NodeJoinController extends AbstractComponent { // Take into account the previous known nodes, if they happen not to be available // then fault detection will remove these nodes. - if (currentState.nodes().masterNode() != null) { + if (currentState.nodes().getMasterNode() != null) { // TODO can we tie break here? we don't have a remote master cluster state version to decide on - logger.trace("join thread elected local node as master, but there is already a master in place: {}", currentState.nodes().masterNode()); + logger.trace("join thread elected local node as master, but there is already a master in place: {}", currentState.nodes().getMasterNode()); throw new NotMasterException("Node [" + clusterService.localNode() + "] not master for join request"); } 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 353880a39cb..40487170837 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -242,13 +242,13 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen nodesFD.stop(); DiscoveryNodes nodes = nodes(); if (sendLeaveRequest) { - if (nodes.masterNode() == null) { + if (nodes.getMasterNode() == null) { // if we don't know who the master is, nothing to do here } else if (!nodes.localNodeMaster()) { try { - membership.sendLeaveRequestBlocking(nodes.masterNode(), nodes.getLocalNode(), TimeValue.timeValueSeconds(1)); + membership.sendLeaveRequestBlocking(nodes.getMasterNode(), nodes.getLocalNode(), TimeValue.timeValueSeconds(1)); } catch (Exception e) { - logger.debug("failed to send leave request to master [{}]", e, nodes.masterNode()); + logger.debug("failed to send leave request to master [{}]", e, nodes.getMasterNode()); } } else { // we're master -> let other potential master we left and start a master election now rather then wait for masterFD @@ -260,7 +260,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen try { membership.sendLeaveRequest(nodes.getLocalNode(), possibleMaster); } catch (Exception e) { - logger.debug("failed to send leave request from master [{}] to possible master [{}]", e, nodes.masterNode(), possibleMaster); + logger.debug("failed to send leave request from master [{}] to possible master [{}]", e, nodes.getMasterNode(), possibleMaster); } } } @@ -419,7 +419,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen return currentState; } - if (currentState.getNodes().masterNode() == null) { + if (currentState.getNodes().getMasterNode() == null) { // Post 1.3.0, the master should publish a new cluster state before acking our join request. we now should have // a valid master. logger.debug("no master node is set, despite of join request completing. retrying pings."); @@ -427,7 +427,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen return currentState; } - if (!currentState.getNodes().masterNode().equals(finalMasterNode)) { + if (!currentState.getNodes().getMasterNode().equals(finalMasterNode)) { return joinThreadControl.stopRunningThreadAndRejoin(currentState, "master_switched_while_finalizing_join"); } @@ -524,7 +524,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen logger.error("unexpected failure during [{}]", t, source); } }); - } else if (node.equals(nodes().masterNode())) { + } else if (node.equals(nodes().getMasterNode())) { handleMasterGone(node, null, "shut_down"); } } @@ -680,11 +680,11 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen return currentState; } - assert newClusterState.nodes().masterNode() != null : "received a cluster state without a master"; + assert newClusterState.nodes().getMasterNode() != null : "received a cluster state without a master"; assert !newClusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock()) : "received a cluster state with a master block"; if (currentState.nodes().localNodeMaster()) { - return handleAnotherMaster(currentState, newClusterState.nodes().masterNode(), newClusterState.version(), "via a new cluster state"); + return handleAnotherMaster(currentState, newClusterState.nodes().getMasterNode(), newClusterState.version(), "via a new cluster state"); } if (shouldIgnoreOrRejectNewClusterState(logger, currentState, newClusterState)) { @@ -692,8 +692,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } // check to see that we monitor the correct master of the cluster - if (masterFD.masterNode() == null || !masterFD.masterNode().equals(newClusterState.nodes().masterNode())) { - masterFD.restart(newClusterState.nodes().masterNode(), "new cluster state received and we are monitoring the wrong master [" + masterFD.masterNode() + "]"); + if (masterFD.masterNode() == null || !masterFD.masterNode().equals(newClusterState.nodes().getMasterNode())) { + masterFD.restart(newClusterState.nodes().getMasterNode(), "new cluster state received and we are monitoring the wrong master [" + masterFD.masterNode() + "]"); } if (currentState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock())) { @@ -787,8 +787,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen return; } if (!currentNodes.getMasterNodeId().equals(newClusterState.nodes().getMasterNodeId())) { - logger.warn("received a cluster state from a different master than the current one, rejecting (received {}, current {})", newClusterState.nodes().masterNode(), currentNodes.masterNode()); - throw new IllegalStateException("cluster state from a different master than the current one, rejecting (received " + newClusterState.nodes().masterNode() + ", current " + currentNodes.masterNode() + ")"); + logger.warn("received a cluster state from a different master than the current one, rejecting (received {}, current {})", newClusterState.nodes().getMasterNode(), currentNodes.getMasterNode()); + throw new IllegalStateException("cluster state from a different master than the current one, rejecting (received " + newClusterState.nodes().getMasterNode() + ", current " + currentNodes.getMasterNode() + ")"); } } diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java index 0d4d4a9b004..d04a216fd31 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java @@ -565,7 +565,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen } private PingResponse createPingResponse(DiscoveryNodes discoNodes) { - return new PingResponse(discoNodes.getLocalNode(), discoNodes.masterNode(), clusterName, contextProvider.nodeHasJoinedClusterOnce()); + return new PingResponse(discoNodes.getLocalNode(), discoNodes.getMasterNode(), clusterName, contextProvider.nodeHasJoinedClusterOnce()); } static class UnicastPingResponse extends TransportResponse { diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueue.java b/core/src/main/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueue.java index 5638f877967..b3ad7329d99 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueue.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueue.java @@ -138,7 +138,7 @@ public class PendingClusterStatesQueue { if (findState(state.stateUUID()) == null) { throw new IllegalStateException("can't resolve processed cluster state with uuid [" + state.stateUUID() + "], version [" + state.version() + "]"); } - final DiscoveryNode currentMaster = state.nodes().masterNode(); + final DiscoveryNode currentMaster = state.nodes().getMasterNode(); assert currentMaster != null : "processed cluster state mast have a master. " + state; // fail or remove any incoming state from a different master @@ -147,7 +147,7 @@ public class PendingClusterStatesQueue { for (int index = 0; index < pendingStates.size(); index++) { final ClusterStateContext pendingContext = pendingStates.get(index); final ClusterState pendingState = pendingContext.state; - final DiscoveryNode pendingMasterNode = pendingState.nodes().masterNode(); + final DiscoveryNode pendingMasterNode = pendingState.nodes().getMasterNode(); if (Objects.equals(currentMaster, pendingMasterNode) == false) { contextsToRemove.add(pendingContext); if (pendingContext.committed()) { 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 1f5eb882f77..d7c4ac1568d 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 @@ -391,13 +391,13 @@ public class PublishClusterStateAction extends AbstractComponent { void validateIncomingState(ClusterState incomingState, ClusterState lastSeenClusterState) { final ClusterName incomingClusterName = incomingState.getClusterName(); if (!incomingClusterName.equals(this.clusterName)) { - logger.warn("received cluster state from [{}] which is also master but with a different cluster name [{}]", incomingState.nodes().masterNode(), incomingClusterName); + logger.warn("received cluster state from [{}] which is also master but with a different cluster name [{}]", incomingState.nodes().getMasterNode(), incomingClusterName); throw new IllegalStateException("received state from a node that is not part of the cluster"); } final DiscoveryNodes currentNodes = nodesProvider.nodes(); if (currentNodes.getLocalNode().equals(incomingState.nodes().getLocalNode()) == false) { - logger.warn("received a cluster state from [{}] and not part of the cluster, should not happen", incomingState.nodes().masterNode()); + logger.warn("received a cluster state from [{}] and not part of the cluster, should not happen", incomingState.nodes().getMasterNode()); throw new IllegalStateException("received state from a node that is not part of the cluster"); } @@ -427,7 +427,7 @@ public class PublishClusterStateAction extends AbstractComponent { } }); if (state != null) { - newPendingClusterStatelistener.onNewClusterState("master " + state.nodes().masterNode() + " committed version [" + state.version() + "]"); + newPendingClusterStatelistener.onNewClusterState("master " + state.nodes().getMasterNode() + " committed version [" + state.version() + "]"); } } diff --git a/core/src/main/java/org/elasticsearch/gateway/LocalAllocateDangledIndices.java b/core/src/main/java/org/elasticsearch/gateway/LocalAllocateDangledIndices.java index face4c62ca7..3ee6851f8a5 100644 --- a/core/src/main/java/org/elasticsearch/gateway/LocalAllocateDangledIndices.java +++ b/core/src/main/java/org/elasticsearch/gateway/LocalAllocateDangledIndices.java @@ -76,7 +76,7 @@ public class LocalAllocateDangledIndices extends AbstractComponent { public void allocateDangled(Collection indices, final Listener listener) { ClusterState clusterState = clusterService.state(); - DiscoveryNode masterNode = clusterState.nodes().masterNode(); + DiscoveryNode masterNode = clusterState.nodes().getMasterNode(); if (masterNode == null) { listener.onFailure(new MasterNotDiscoveredException("no master to send allocate dangled request")); return; diff --git a/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index 255d6fb2e6a..7b1c03218b1 100644 --- a/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -483,14 +483,14 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent listener = new PlainActionFuture<>(); - DiscoveryNode masterNode = clusterService.state().nodes().masterNode(); + DiscoveryNode masterNode = clusterService.state().nodes().getMasterNode(); DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes()); builder.remove(masterNode.getId()); @@ -403,7 +403,7 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase { final boolean simulateFailedMasterNode = rarely(); DiscoveryNode failedMasterNode = null; if (simulateFailedMasterNode) { - failedMasterNode = clusterService.state().nodes().masterNode(); + failedMasterNode = clusterService.state().nodes().getMasterNode(); DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes()); builder.remove(failedMasterNode.getId()); builder.masterNodeId(null); diff --git a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java index 9d74ef66319..6ea530d1de5 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java @@ -449,7 +449,7 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase { public Version getMasterVersion() { - return client().admin().cluster().prepareState().get().getState().nodes().masterNode().getVersion(); + return client().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getVersion(); } public void testDeleteRoutingRequired() throws ExecutionException, InterruptedException, IOException { diff --git a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java index b97b973a728..991ed9ee883 100644 --- a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java @@ -409,7 +409,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { assertBusy(new Runnable() { @Override public void run() { - assertThat(masterClusterService.state().nodes().masterNode(), nullValue()); + assertThat(masterClusterService.state().nodes().getMasterNode(), nullValue()); } }); diff --git a/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java index 625428d09e9..792c28680e3 100644 --- a/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java @@ -53,8 +53,8 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { } logger.info("--> start master node"); final String masterNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true)); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); - assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName)); + assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName)); logger.info("--> stop master node"); internalCluster().stopCurrentMasterNode(); @@ -68,8 +68,8 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { logger.info("--> start master node"); final String nextMasterEligibleNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true)); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligibleNodeName)); - assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligibleNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligibleNodeName)); + assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligibleNodeName)); } public void testElectOnlyBetweenMasterNodes() throws IOException { @@ -83,19 +83,19 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { } logger.info("--> start master node (1)"); final String masterNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true)); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); - assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName)); + assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName)); logger.info("--> start master node (2)"); final String nextMasterEligableNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true)); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); - assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName)); + assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName)); logger.info("--> closing master node (1)"); internalCluster().stopCurrentMasterNode(); - assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligableNodeName)); - assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligableNodeName)); + assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligableNodeName)); + assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligableNodeName)); } /** 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 0915ede3eea..c79d198d350 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 @@ -162,7 +162,7 @@ public class ShardStateActionTests extends ESTestCase { // for the right shard assertEquals(shardRouting, shardRoutingEntry.getShardRouting()); // sent to the master - assertEquals(clusterService.state().nodes().masterNode().getId(), capturedRequests[0].node.getId()); + assertEquals(clusterService.state().nodes().getMasterNode().getId(), capturedRequests[0].node.getId()); transport.handleResponse(capturedRequests[0].requestId, TransportResponse.Empty.INSTANCE); diff --git a/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java b/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java index bf55968df9f..b21f019e3b7 100644 --- a/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java @@ -518,7 +518,7 @@ public class ClusterServiceIT extends ESIntegTestCase { assertThat(clusterHealth.isTimedOut(), equalTo(false)); // the first node should be a master as the minimum required is 1 - assertThat(clusterService.state().nodes().masterNode(), notNullValue()); + assertThat(clusterService.state().nodes().getMasterNode(), notNullValue()); assertThat(clusterService.state().nodes().localNodeMaster(), is(true)); assertThat(testService.master(), is(true)); @@ -554,7 +554,7 @@ public class ClusterServiceIT extends ESIntegTestCase { internalCluster().stopRandomNonMasterNode(); // there should not be any master as the minimum number of required eligible masters is not met - awaitBusy(() -> clusterService1.state().nodes().masterNode() == null && + awaitBusy(() -> clusterService1.state().nodes().getMasterNode() == null && clusterService1.state().status() == ClusterState.ClusterStateStatus.APPLIED); assertThat(testService1.master(), is(false)); @@ -571,8 +571,8 @@ public class ClusterServiceIT extends ESIntegTestCase { .setWaitForNodes("2").get().isTimedOut(), is(false)); // now that we started node1 again, a new master should be elected - assertThat(clusterService2.state().nodes().masterNode(), is(notNullValue())); - if (node_2.equals(clusterService2.state().nodes().masterNode().getName())) { + assertThat(clusterService2.state().nodes().getMasterNode(), is(notNullValue())); + if (node_2.equals(clusterService2.state().nodes().getMasterNode().getName())) { assertThat(testService1.master(), is(false)); assertThat(testService2.master(), is(true)); } else { diff --git a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java index ab76924e685..0c0bc05a2ad 100644 --- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java @@ -846,7 +846,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { DiscoveryNodes discoveryNodes = internalCluster().getInstance(ClusterService.class, nonMasterNode).state().nodes(); - TransportService masterTranspotService = internalCluster().getInstance(TransportService.class, discoveryNodes.masterNode().getName()); + TransportService masterTranspotService = internalCluster().getInstance(TransportService.class, discoveryNodes.getMasterNode().getName()); logger.info("blocking requests from non master [{}] to master [{}]", nonMasterNode, masterNode); MockTransportService nonMasterTransportService = (MockTransportService) internalCluster().getInstance(TransportService.class, nonMasterNode); @@ -1175,7 +1175,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { @Override public void run() { ClusterState state = getNodeClusterState(node); - assertNull("node [" + node + "] still has [" + state.nodes().masterNode() + "] as master", state.nodes().masterNode()); + assertNull("node [" + node + "] still has [" + state.nodes().getMasterNode() + "] as master", state.nodes().getMasterNode()); if (expectedBlocks != null) { for (ClusterBlockLevel level : expectedBlocks.levels()) { assertTrue("node [" + node + "] does have level [" + level + "] in it's blocks", state.getBlocks().hasGlobalBlock(level)); @@ -1191,10 +1191,10 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { public void run() { ClusterState state = getNodeClusterState(node); String masterNode = null; - if (state.nodes().masterNode() != null) { - masterNode = state.nodes().masterNode().getName(); + if (state.nodes().getMasterNode() != null) { + masterNode = state.nodes().getMasterNode().getName(); } - logger.trace("[{}] master is [{}]", node, state.nodes().masterNode()); + logger.trace("[{}] master is [{}]", node, state.nodes().getMasterNode()); assertThat("node [" + node + "] still has [" + masterNode + "] as master", oldMasterNode, not(equalTo(masterNode))); } @@ -1206,7 +1206,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { ClusterState state = getNodeClusterState(node); String failMsgSuffix = "cluster_state:\n" + state.prettyPrint(); assertThat("wrong node count on [" + node + "]. " + failMsgSuffix, state.nodes().getSize(), equalTo(nodes.size())); - String otherMasterNodeName = state.nodes().masterNode() != null ? state.nodes().masterNode().getName() : null; + String otherMasterNodeName = state.nodes().getMasterNode() != null ? state.nodes().getMasterNode().getName() : null; assertThat("wrong master on node [" + node + "]. " + failMsgSuffix, otherMasterNodeName, equalTo(masterNode)); } } diff --git a/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java b/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java index 6bc0301cd08..e3c11a6e322 100644 --- a/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java @@ -94,9 +94,9 @@ public class ZenUnicastDiscoveryIT extends ESIntegTestCase { ClusterState state = internalCluster().client(node).admin().cluster().prepareState().setLocal(true).execute().actionGet().getState(); assertThat(state.nodes().getSize(), equalTo(currentNumNodes)); if (masterDiscoNode == null) { - masterDiscoNode = state.nodes().masterNode(); + masterDiscoNode = state.nodes().getMasterNode(); } else { - assertThat(masterDiscoNode.equals(state.nodes().masterNode()), equalTo(true)); + assertThat(masterDiscoNode.equals(state.nodes().getMasterNode()), equalTo(true)); } } } diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java index a94a03fb671..b32581e0e2b 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java @@ -123,7 +123,7 @@ public class PublishClusterStateActionTests extends ESTestCase { ClusterChangedEvent event = new ClusterChangedEvent("", newClusterState, clusterState); listener.clusterChanged(event); } - if (clusterState.nodes().masterNode() == null || newClusterState.supersedes(clusterState)) { + if (clusterState.nodes().getMasterNode() == null || newClusterState.supersedes(clusterState)) { clusterState = newClusterState; } action.pendingStatesQueue().markAsProcessed(newClusterState); diff --git a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java index 920fb2ba442..87e317be734 100644 --- a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java +++ b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java @@ -234,7 +234,7 @@ public class RareClusterStateIT extends ESIntegTestCase { // Check routing tables ClusterState state = client().admin().cluster().prepareState().get().getState(); - assertEquals(master, state.nodes().masterNode().getName()); + assertEquals(master, state.nodes().getMasterNode().getName()); List shards = state.routingTable().allShards("index"); assertThat(shards, hasSize(1)); for (ShardRouting shard : shards) { @@ -352,7 +352,7 @@ public class RareClusterStateIT extends ESIntegTestCase { // Check routing tables ClusterState state = client().admin().cluster().prepareState().get().getState(); - assertEquals(master, state.nodes().masterNode().getName()); + assertEquals(master, state.nodes().getMasterNode().getName()); List shards = state.routingTable().allShards("index"); assertThat(shards, hasSize(2)); for (ShardRouting shard : shards) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index dca508852a0..0db133ba0cf 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -1363,7 +1363,7 @@ public final class InternalTestCluster extends TestCluster { try { Client client = viaNode != null ? client(viaNode) : client(); ClusterState state = client.admin().cluster().prepareState().execute().actionGet().getState(); - return state.nodes().masterNode().getName(); + return state.nodes().getMasterNode().getName(); } catch (Throwable e) { logger.warn("Can't fetch cluster state", e); throw new RuntimeException("Can't get master node " + e.getMessage(), e); From 030420768c1a5326bb2aaf5c029d0ffb3f1c4ce6 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:20:43 +0200 Subject: [PATCH 21/25] Rename DiscoveryNodes#smallestNodeVersion to getSmallestNodeVersion --- .../java/org/elasticsearch/cluster/node/DiscoveryNodes.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e24098ea8ab..f6b4217f12c 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -232,7 +232,7 @@ public class DiscoveryNodes extends AbstractDiffable implements * * @return the oldest version in the cluster */ - public Version smallestVersion() { + public Version getSmallestVersion() { return minNodeVersion; } From 2075c7f0a76ede4218571f48c22afdd0b2228f35 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:21:06 +0200 Subject: [PATCH 22/25] Rename DiscoveryNodes#smallestNonClientNodeVersion to getSmallestNonClientNodeVersion --- .../cluster/metadata/MetaDataCreateIndexService.java | 2 +- .../java/org/elasticsearch/cluster/node/DiscoveryNodes.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java index e0db19cb516..e85ef9e4bc9 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java @@ -294,7 +294,7 @@ public class MetaDataCreateIndexService extends AbstractComponent { if (indexSettingsBuilder.get(SETTING_VERSION_CREATED) == null) { DiscoveryNodes nodes = currentState.nodes(); - final Version createdVersion = Version.smallest(version, nodes.smallestNonClientNodeVersion()); + final Version createdVersion = Version.smallest(version, nodes.getSmallestNonClientNodeVersion()); indexSettingsBuilder.put(SETTING_VERSION_CREATED, createdVersion); } 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 f6b4217f12c..603a36a1d61 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -241,7 +241,7 @@ public class DiscoveryNodes extends AbstractDiffable implements * * @return the oldest version in the cluster */ - public Version smallestNonClientNodeVersion() { + public Version getSmallestNonClientNodeVersion() { return minNonClientNodeVersion; } From 30b57be8f4ca45d57254038c8723aa54c4fcb871 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:22:39 +0200 Subject: [PATCH 23/25] Rename DiscoveryNodes#localNodeMaster to isLocalNodeElectedMaster --- .../settings/TransportClusterUpdateSettingsAction.java | 2 +- .../cluster/stats/TransportClusterStatsAction.java | 2 +- .../support/master/TransportMasterNodeAction.java | 2 +- .../org/elasticsearch/cluster/ClusterChangedEvent.java | 2 +- .../metadata/MetaDataUpdateSettingsService.java | 2 +- .../org/elasticsearch/cluster/node/DiscoveryNodes.java | 4 ++-- .../elasticsearch/cluster/routing/RoutingService.java | 2 +- .../elasticsearch/cluster/service/ClusterService.java | 8 ++++---- .../discovery/zen/NodeJoinController.java | 2 +- .../org/elasticsearch/discovery/zen/ZenDiscovery.java | 10 +++++----- .../discovery/zen/fd/MasterFaultDetection.java | 2 +- .../java/org/elasticsearch/gateway/GatewayService.java | 2 +- .../elasticsearch/snapshots/SnapshotShardsService.java | 2 +- .../org/elasticsearch/snapshots/SnapshotsService.java | 4 ++-- .../cluster/service/ClusterServiceIT.java | 6 +++--- .../discovery/zen/NodeJoinControllerTests.java | 8 ++++---- 16 files changed, 30 insertions(+), 30 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java index 60a0e7a8046..1abca63794b 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java @@ -114,7 +114,7 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeAct // We're about to send a second update task, so we need to check if we're still the elected master // For example the minimum_master_node could have been breached and we're no longer elected master, // so we should *not* execute the reroute. - if (!clusterService.state().nodes().localNodeMaster()) { + if (!clusterService.state().nodes().isLocalNodeElectedMaster()) { logger.debug("Skipping reroute after cluster update settings, because node is no longer master"); listener.onResponse(new ClusterUpdateSettingsResponse(updateSettingsAcked, updater.getTransientUpdates(), updater.getPersistentUpdate())); return; diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java index 6d1614eb485..4a0eb33c0b5 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java @@ -111,7 +111,7 @@ public class TransportClusterStatsAction extends TransportNodesActiontrue iff the local node is the mater node of the cluster. */ public boolean localNodeMaster() { - return state.nodes().localNodeMaster(); + return state.nodes().isLocalNodeElectedMaster(); } /** diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java index 4d503e9a92c..e1b0415fbd0 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java @@ -79,7 +79,7 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements @Override public void clusterChanged(ClusterChangedEvent event) { // update an index with number of replicas based on data nodes if possible - if (!event.state().nodes().localNodeMaster()) { + if (!event.state().nodes().isLocalNodeElectedMaster()) { return; } // we will want to know this for translating "all" to a number 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 603a36a1d61..f073b577a2a 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -86,9 +86,9 @@ public class DiscoveryNodes extends AbstractDiffable implements } /** - * Returns true if the local node is the master node. + * Returns true if the local node is the elected master node. */ - public boolean localNodeMaster() { + public boolean isLocalNodeElectedMaster() { if (localNodeId == null) { // we don't know yet the local node id, return false return false; diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingService.java b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingService.java index 90565a6569d..1ebd4699d1a 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingService.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingService.java @@ -100,7 +100,7 @@ public class RoutingService extends AbstractLifecycleComponent i @Override public void clusterChanged(ClusterChangedEvent event) { - if (event.state().nodes().localNodeMaster()) { + if (event.state().nodes().isLocalNodeElectedMaster()) { // Figure out if an existing scheduled reroute is good enough or whether we need to cancel and reschedule. // If the minimum of the currently relevant delay settings is larger than something we scheduled in the past, // we are guaranteed that the planned schedule will happen before any of the current shard delays are expired. diff --git a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java index ca350ea0a05..f74e3b6f85f 100644 --- a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java +++ b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java @@ -494,7 +494,7 @@ public class ClusterService extends AbstractLifecycleComponent { } logger.debug("processing [{}]: execute", source); ClusterState previousClusterState = clusterState; - if (!previousClusterState.nodes().localNodeMaster() && executor.runOnlyOnMaster()) { + if (!previousClusterState.nodes().isLocalNodeElectedMaster() && executor.runOnlyOnMaster()) { logger.debug("failing [{}]: local node is no longer master", source); toExecute.stream().forEach(task -> task.listener.onNoLongerMaster(task.source)); return; @@ -561,7 +561,7 @@ public class ClusterService extends AbstractLifecycleComponent { try { ArrayList ackListeners = new ArrayList<>(); - if (newClusterState.nodes().localNodeMaster()) { + if (newClusterState.nodes().isLocalNodeElectedMaster()) { // only the master controls the version numbers Builder builder = ClusterState.builder(newClusterState).incrementVersion(); if (previousClusterState.routingTable() != newClusterState.routingTable()) { @@ -617,7 +617,7 @@ public class ClusterService extends AbstractLifecycleComponent { // if we are the master, publish the new state to all nodes // we publish here before we send a notification to all the listeners, since if it fails // we don't want to notify - if (newClusterState.nodes().localNodeMaster()) { + if (newClusterState.nodes().isLocalNodeElectedMaster()) { logger.debug("publishing cluster state version [{}]", newClusterState.version()); try { clusterStatePublisher.accept(clusterChangedEvent, ackListener); @@ -661,7 +661,7 @@ public class ClusterService extends AbstractLifecycleComponent { } //manual ack only from the master at the end of the publish - if (newClusterState.nodes().localNodeMaster()) { + if (newClusterState.nodes().isLocalNodeElectedMaster()) { try { ackListener.onNodeAck(newClusterState.nodes().getLocalNode(), null); } catch (Throwable t) { diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java index ddfb49340a4..39a3f51ac32 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java @@ -322,7 +322,7 @@ public class NodeJoinController extends AbstractComponent { public void onElectedAsMaster(ClusterState state) { assert pendingSetAsMasterTask.get() : "onElectedAsMaster called but pendingSetAsMasterTask is not set"; assertClusterStateThread(); - assert state.nodes().localNodeMaster() : "onElectedAsMaster called but local node is not master"; + assert state.nodes().isLocalNodeElectedMaster() : "onElectedAsMaster called but local node is not master"; if (closed.compareAndSet(false, true)) { try { onClose(); 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 40487170837..ac595e640bc 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -244,7 +244,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen if (sendLeaveRequest) { if (nodes.getMasterNode() == null) { // if we don't know who the master is, nothing to do here - } else if (!nodes.localNodeMaster()) { + } else if (!nodes.isLocalNodeElectedMaster()) { try { membership.sendLeaveRequestBlocking(nodes.getMasterNode(), nodes.getLocalNode(), TimeValue.timeValueSeconds(1)); } catch (Exception e) { @@ -302,7 +302,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen @Override public void publish(ClusterChangedEvent clusterChangedEvent, AckListener ackListener) { - if (!clusterChangedEvent.state().getNodes().localNodeMaster()) { + if (!clusterChangedEvent.state().getNodes().isLocalNodeElectedMaster()) { throw new IllegalStateException("Shouldn't publish state when not master"); } nodesFD.updateNodesAndPing(clusterChangedEvent.state()); @@ -683,7 +683,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen assert newClusterState.nodes().getMasterNode() != null : "received a cluster state without a master"; assert !newClusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock()) : "received a cluster state with a master block"; - if (currentState.nodes().localNodeMaster()) { + if (currentState.nodes().isLocalNodeElectedMaster()) { return handleAnotherMaster(currentState, newClusterState.nodes().getMasterNode(), newClusterState.version(), "via a new cluster state"); } @@ -951,11 +951,11 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } private boolean localNodeMaster() { - return nodes().localNodeMaster(); + return nodes().isLocalNodeElectedMaster(); } private ClusterState handleAnotherMaster(ClusterState localClusterState, final DiscoveryNode otherMaster, long otherClusterStateVersion, String reason) { - assert localClusterState.nodes().localNodeMaster() : "handleAnotherMaster called but current node is not a master"; + assert localClusterState.nodes().isLocalNodeElectedMaster() : "handleAnotherMaster called but current node is not a master"; assert Thread.currentThread().getName().contains(ClusterService.UPDATE_THREAD_NAME) : "not called from the cluster state update thread"; if (otherClusterStateVersion > localClusterState.version()) { diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java b/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java index 116e622088e..4e7ea5be3af 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java @@ -346,7 +346,7 @@ public class MasterFaultDetection extends FaultDetection { // all processing is finished. // - if (!nodes.localNodeMaster() || !nodes.nodeExists(request.nodeId)) { + if (!nodes.isLocalNodeElectedMaster() || !nodes.nodeExists(request.nodeId)) { logger.trace("checking ping from [{}] under a cluster state thread", request.nodeId); clusterService.submitStateUpdateTask("master ping (from: [" + request.nodeId + "])", new ClusterStateUpdateTask() { diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayService.java b/core/src/main/java/org/elasticsearch/gateway/GatewayService.java index b584080fdac..7261f812696 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayService.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayService.java @@ -153,7 +153,7 @@ public class GatewayService extends AbstractLifecycleComponent i final ClusterState state = event.state(); - if (state.nodes().localNodeMaster() == false) { + if (state.nodes().isLocalNodeElectedMaster() == false) { // not our job to recover return; } diff --git a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java index 48f7375381b..c2a33680efa 100644 --- a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java +++ b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java @@ -477,7 +477,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent Date: Wed, 30 Mar 2016 15:23:45 +0200 Subject: [PATCH 24/25] remove unused DiscoveryNodes#valid method --- .../org/elasticsearch/cluster/node/DiscoveryNodes.java | 8 -------- 1 file changed, 8 deletions(-) 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 f073b577a2a..ed4cfbd9134 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -77,14 +77,6 @@ public class DiscoveryNodes extends AbstractDiffable implements return nodes.valuesIt(); } - /** - * Is this a valid nodes that has the minimal information set. The minimal set is defined - * by the localNodeId being set. - */ - public boolean valid() { - return localNodeId != null; - } - /** * Returns true if the local node is the elected master node. */ From 52dcc9899e1a7677feeaaafc521a6b1ef739672b Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 30 Mar 2016 15:45:41 +0200 Subject: [PATCH 25/25] fix checkstyle line lenght issue --- .../discovery/zen/ping/unicast/UnicastZenPing.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java index d04a216fd31..640582af226 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java @@ -565,7 +565,8 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen } private PingResponse createPingResponse(DiscoveryNodes discoNodes) { - return new PingResponse(discoNodes.getLocalNode(), discoNodes.getMasterNode(), clusterName, contextProvider.nodeHasJoinedClusterOnce()); + return new PingResponse(discoNodes.getLocalNode(), discoNodes.getMasterNode(), clusterName, + contextProvider.nodeHasJoinedClusterOnce()); } static class UnicastPingResponse extends TransportResponse {