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..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 @@ -68,10 +68,10 @@ 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()); + builder.field("name", nodeInfo.getNode().getName(), XContentBuilder.FieldCaseConversion.NONE); + 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 214b6f245cd..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 @@ -299,8 +299,8 @@ 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("transport_address", getNode().address().toString(), XContentBuilder.FieldCaseConversion.NONE); + builder.field("name", getNode().getName(), 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/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/node/tasks/list/ListTasksResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java index c1f877c7f4a..7b308affcc9 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 @@ -164,8 +164,8 @@ 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("transport_address", node.address().toString()); + builder.field("name", node.getName()); + 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/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java index ba62002c1c6..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 @@ -86,8 +86,8 @@ 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.field(Fields.NAME, node.name(), XContentBuilder.FieldCaseConversion.NONE); + builder.startObject(node.getId(), 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/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/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/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 TransportNodesAction @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/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() { @@ -330,7 +330,7 @@ public abstract class TransportBroadcastByNodeAction(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 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..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]); @@ -161,7 +161,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 < this.nodesIds.length; i++) { this.nodes[i] = nodes.get(this.nodesIds[i]); @@ -237,7 +237,7 @@ public abstract class TransportTasksAction< onFailure(idx, nodeId, new NoSuchNodeException(nodeId)); } else { NodeTaskRequest nodeRequest = new NodeTaskRequest(request); - nodeRequest.setParentTask(clusterService.localNode().id(), task.getId()); + nodeRequest.setParentTask(clusterService.localNode().getId(), task.getId()); taskManager.registerChildTask(task, node.getId()); transportService.sendRequest(node, transportNodeAction, nodeRequest, builder.build(), new BaseTransportResponseHandler() { @@ -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..e407a2e7ada 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); @@ -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.getName(), nodeWithInfo.getId(), nodeWithInfo.getHostName(), nodeWithInfo.getHostAddress(), listedNode.getAddress(), nodeWithInfo.getAttributes(), nodeWithInfo.getRoles(), nodeWithInfo.getVersion())); } else { @@ -491,11 +491,11 @@ public class TransportClientNodesService extends AbstractComponent { for (Map.Entry 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; } - 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/ClusterChangedEvent.java b/core/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java index 98853e8447f..13955dad6d2 100644 --- a/core/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java +++ b/core/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java @@ -186,7 +186,7 @@ public class ClusterChangedEvent { * Returns true 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/ClusterState.java b/core/src/main/java/org/elasticsearch/cluster/ClusterState.java index 1ac379555ab..3f9ef6a82b8 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)) { @@ -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/InternalClusterInfoService.java b/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java index 6d885db1747..20837d9238e 100644 --- a/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java +++ b/core/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java @@ -167,7 +167,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; } @@ -182,7 +182,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()); } @@ -396,7 +396,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; @@ -410,7 +410,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/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/action/index/NodeIndexDeletedAction.java b/core/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexDeletedAction.java index 93fce95fc23..377addd48f3 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 @@ -78,9 +78,9 @@ public class NodeIndexDeletedAction extends AbstractComponent { public void nodeIndexDeleted(final ClusterState clusterState, final Index index, final IndexSettings indexSettings, final String nodeId) { final DiscoveryNodes nodes = clusterState.nodes(); - transportService.sendRequest(clusterState.nodes().masterNode(), + transportService.sendRequest(clusterState.nodes().getMasterNode(), 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; } @@ -104,7 +104,7 @@ public class NodeIndexDeletedAction extends AbstractComponent { // due to a "currently canceled recovery" or so. The shard will delete itself BEFORE the lock is released so it's guaranteed to be // deleted by the time we get the lock indicesService.processPendingDeletes(indexSettings.getIndex(), indexSettings, new TimeValue(30, TimeUnit.MINUTES)); - transportService.sendRequest(clusterState.nodes().masterNode(), + transportService.sendRequest(clusterState.nodes().getMasterNode(), INDEX_STORE_DELETED_ACTION_NAME, new NodeIndexStoreDeletedMessage(index, nodeId), EmptyTransportResponseHandler.INSTANCE_SAME); } catch (LockObtainFailedException exc) { logger.warn("[{}] failed to lock all shards for index - timed out after 30 seconds", index); diff --git a/core/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingRefreshAction.java b/core/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingRefreshAction.java index c7dddce36f7..0645accb42a 100644 --- a/core/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingRefreshAction.java +++ b/core/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingRefreshAction.java @@ -60,11 +60,11 @@ public class NodeMappingRefreshAction extends AbstractComponent { public void nodeMappingRefresh(final ClusterState state, final NodeMappingRefreshRequest request) { final DiscoveryNodes nodes = state.nodes(); - if (nodes.masterNode() == null) { + if (nodes.getMasterNode() == null) { logger.warn("can't send mapping refresh for [{}], no master known.", request.index()); return; } - transportService.sendRequest(nodes.masterNode(), ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME); + transportService.sendRequest(nodes.getMasterNode(), ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME); } private class NodeMappingRefreshTransportHandler implements TransportRequestHandler { 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/health/ClusterStateHealth.java b/core/src/main/java/org/elasticsearch/cluster/health/ClusterStateHealth.java index 42ab496fe33..03e4c6ee443 100644 --- a/core/src/main/java/org/elasticsearch/cluster/health/ClusterStateHealth.java +++ b/core/src/main/java/org/elasticsearch/cluster/health/ClusterStateHealth.java @@ -91,8 +91,8 @@ public final class ClusterStateHealth implements Iterable, S public ClusterStateHealth(ClusterState clusterState, String[] concreteIndices) { RoutingTableValidation validation = clusterState.routingTable().validate(clusterState.metaData()); validationFailures = validation.failures(); - numberOfNodes = clusterState.nodes().size(); - numberOfDataNodes = clusterState.nodes().dataNodes().size(); + numberOfNodes = clusterState.nodes().getSize(); + 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/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/metadata/MetaDataDeleteIndexService.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java index 5e6d35aacfe..4cd9f5d4727 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java @@ -101,9 +101,9 @@ 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(); + 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..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,11 +79,11 @@ 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 - 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/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 2671fb372ff..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; @@ -47,7 +46,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); } @@ -68,20 +67,18 @@ 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); } - public static boolean dataNode(Settings settings) { + public static boolean isDataNode(Settings settings) { 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); } - public static final List EMPTY_LIST = Collections.emptyList(); - private final String nodeName; private final String nodeId; private final String hostName; @@ -207,46 +204,25 @@ 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(); - } - - /** - * The unique id of the node. - */ - public String id() { - return nodeId; + return address; } /** * The unique id of the node. */ public String getId() { - return id(); - } - - /** - * The name of the node. - */ - public String name() { - return this.nodeName; + return nodeId; } /** * The name of the node. */ public String getName() { - return name(); + return this.nodeName; } /** @@ -256,32 +232,18 @@ 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(); - } - - /** - * Can this node become master or not. - */ - public boolean masterNode() { - return roles.contains(Role.MASTER); + return roles.contains(Role.DATA); } /** * Can this node become master or not. */ public boolean isMasterNode() { - return masterNode(); + return roles.contains(Role.MASTER); } /** @@ -299,7 +261,7 @@ public class DiscoveryNode implements Writeable, ToXContent { return roles; } - public Version version() { + public Version getVersion() { return this.version; } @@ -311,10 +273,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); @@ -377,9 +335,9 @@ public class DiscoveryNode implements Writeable, ToXContent { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(id(), XContentBuilder.FieldCaseConversion.NONE); - builder.field("name", name()); - builder.field("transport_address", address().toString()); + builder.startObject(getId(), XContentBuilder.FieldCaseConversion.NONE); + builder.field("name", getName()); + 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 891b75f002e..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); @@ -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; } @@ -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 d48668b3abd..ed4cfbd9134 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -78,17 +78,9 @@ public class DiscoveryNodes extends AbstractDiffable implements } /** - * Is this a valid nodes that has the minimal information set. The minimal set is defined - * by the localNodeId being set. + * Returns true if the local node is the elected master node. */ - public boolean valid() { - return localNodeId != null; - } - - /** - * Returns true if the local node is the master node. - */ - public boolean localNodeMaster() { + public boolean isLocalNodeElectedMaster() { if (localNodeId == null) { // we don't know yet the local node id, return false return false; @@ -96,31 +88,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(); - } - - /** - * 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; + return nodes.size(); } /** @@ -129,16 +103,7 @@ public class DiscoveryNodes extends AbstractDiffable implements * @return {@link Map} of the discovered nodes arranged by their ids */ public ImmutableOpenMap getNodes() { - return 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; + return this.nodes; } /** @@ -147,16 +112,7 @@ public class DiscoveryNodes extends AbstractDiffable implements * @return {@link Map} of the discovered data nodes arranged by their ids */ public ImmutableOpenMap getDataNodes() { - return 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; + return this.dataNodes; } /** @@ -165,7 +121,7 @@ public class DiscoveryNodes extends AbstractDiffable implements * @return {@link Map} of the discovered master nodes arranged by their ids */ public ImmutableOpenMap getMasterNodes() { - return masterNodes(); + return this.masterNodes; } /** @@ -180,7 +136,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(); @@ -206,31 +162,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(); - } - - /** - * Get the id of the local node - * - * @return id of the local node - */ - public String localNodeId() { - return this.localNodeId; + return this.masterNodeId; } /** @@ -239,16 +177,7 @@ public class DiscoveryNodes extends AbstractDiffable implements * @return id of the local node */ public String getLocalNodeId() { - return localNodeId(); - } - - /** - * Get the local node - * - * @return local node - */ - public DiscoveryNode localNode() { - return nodes.get(localNodeId); + return this.localNodeId; } /** @@ -257,16 +186,7 @@ public class DiscoveryNodes extends AbstractDiffable implements * @return local node */ public DiscoveryNode getLocalNode() { - return localNode(); - } - - /** - * Get the master node - * - * @return master node - */ - public DiscoveryNode masterNode() { - return nodes.get(masterNodeId); + return nodes.get(localNodeId); } /** @@ -275,7 +195,7 @@ public class DiscoveryNodes extends AbstractDiffable implements * @return master node */ public DiscoveryNode getMasterNode() { - return masterNode(); + return nodes.get(masterNodeId); } /** @@ -287,7 +207,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; } } @@ -304,7 +224,7 @@ public class DiscoveryNodes extends AbstractDiffable implements * * @return the oldest version in the cluster */ - public Version smallestVersion() { + public Version getSmallestVersion() { return minNodeVersion; } @@ -313,7 +233,7 @@ public class DiscoveryNodes extends AbstractDiffable implements * * @return the oldest version in the cluster */ - public Version smallestNonClientNodeVersion() { + public Version getSmallestNonClientNodeVersion() { return minNonClientNodeVersion; } @@ -340,19 +260,19 @@ 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 { 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); } } else if (nodeId.equals("_master")) { - String masterNodeId = masterNodeId(); + String masterNodeId = getMasterNodeId(); if (masterNodeId != null) { resolvedNodesIds.add(masterNodeId); } @@ -361,15 +281,15 @@ 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())) { - resolvedNodesIds.add(node.id()); + if (Regex.simpleMatch(nodeId, node.getName())) { + 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 +320,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 +335,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 +353,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); } } @@ -446,8 +366,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)); @@ -469,10 +389,10 @@ 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()) { + if (node == getMasterNode()) { sb.append(", master"); } sb.append("\n"); @@ -480,10 +400,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; @@ -539,7 +455,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 +483,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 +521,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; } @@ -621,7 +537,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() { @@ -643,13 +559,13 @@ 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.masterNodeId = nodes.getMasterNodeId(); + this.localNodeId = nodes.getLocalNodeId(); + this.nodes = ImmutableOpenMap.builder(nodes.getNodes()); } public Builder put(DiscoveryNode node) { - nodes.put(node.id(), node); + nodes.put(node.getId(), node); return this; } @@ -675,18 +591,18 @@ 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()); + minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.getVersion()); } - if (nodeEntry.value.masterNode()) { + 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/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/routing/OperationRouting.java b/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java index 2b67b9f1820..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); } @@ -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 bd41176d086..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,8 +86,8 @@ 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<>()); + for (ObjectCursor cursor : clusterState.nodes().getDataNodes().values()) { + 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/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/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/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/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/routing/allocation/decider/DiskThresholdDecider.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java index 890bbd3c31d..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 @@ -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()); } /** @@ -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/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/cluster/service/ClusterService.java b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java index 8a38453eb4c..f74e3b6f85f 100644 --- a/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java +++ b/core/src/main/java/org/elasticsearch/cluster/service/ClusterService.java @@ -158,8 +158,8 @@ 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()); + 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(); } @@ -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() { @@ -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,11 +661,11 @@ 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().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()); } } @@ -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/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/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java index cf697871d35..03f27d093e8 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; } @@ -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(); } @@ -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; } @@ -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()); @@ -339,8 +339,8 @@ 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) { - assert nodeSpecificClusterState.nodes().masterNode() != null : "received a cluster state without a master"; + if (nodeSpecificClusterState.nodes().getLocalNode() != null) { + 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() { @@ -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/NodeJoinController.java b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java index 0edbf8841ad..39a3f51ac32 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/NodeJoinController.java @@ -240,13 +240,13 @@ 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"); } - DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder(currentState.nodes()).masterNodeId(currentState.nodes().localNode().id()); + 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(); @@ -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(); @@ -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()); + 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 0169ac1994e..ac595e640bc 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 + "]"); } @@ -242,25 +242,25 @@ 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()) { + } else if (!nodes.isLocalNodeElectedMaster()) { try { - membership.sendLeaveRequestBlocking(nodes.masterNode(), nodes.localNode(), 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 - 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)) { + 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); + logger.debug("failed to send leave request from master [{}] to possible master [{}]", e, nodes.getMasterNode(), possibleMaster); } } } @@ -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 */ @@ -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()); @@ -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"); } @@ -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())) { @@ -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"); } } @@ -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().getMasterNodeId())) { // 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 @@ -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"); + if (currentState.nodes().isLocalNodeElectedMaster()) { + return handleAnotherMaster(currentState, newClusterState.nodes().getMasterNode(), newClusterState.version(), "via a new cluster state"); } if (shouldIgnoreOrRejectNewClusterState(logger, currentState, newClusterState)) { @@ -692,13 +692,13 @@ 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())) { // 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,17 +783,17 @@ 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())) { - 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() + ")"); + 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().getMasterNode(), currentNodes.getMasterNode()); + throw new IllegalStateException("cluster state from a different master than the current one, rejecting (received " + newClusterState.nodes().getMasterNode() + ", current " + currentNodes.getMasterNode() + ")"); } } 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) { @@ -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) { @@ -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()) { @@ -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/elect/ElectMasterService.java b/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java index a3da8be5a94..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,13 +148,13 @@ 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.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..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 @@ -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() { @@ -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(); } @@ -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/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/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 4806871be3b..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 @@ -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 { @@ -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.getLocalNodeId())) { // that's us, ignore continue; } @@ -565,7 +565,8 @@ 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.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 2f444f50288..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()) { @@ -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/discovery/zen/publish/PublishClusterStateAction.java b/core/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java index acb5f640db0..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 @@ -125,9 +125,9 @@ public class PublishClusterStateAction extends AbstractComponent { final boolean sendFullVersion; try { nodes = clusterChangedEvent.state().nodes(); - nodesToPublishTo = new HashSet<>(nodes.size()); - DiscoveryNode localNode = nodes.localNode(); - final int totalMasterNodes = nodes.masterNodes().size(); + nodesToPublishTo = new HashSet<>(nodes.getSize()); + DiscoveryNode localNode = nodes.getLocalNode(); + final int totalMasterNodes = nodes.getMasterNodes().size(); for (final DiscoveryNode node : nodes) { if (node.equals(localNode) == false) { nodesToPublishTo.add(node); @@ -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,18 +210,18 @@ 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())); + 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) { @@ -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); @@ -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.localNode().equals(incomingState.nodes().localNode()) == false) { - logger.warn("received a cluster state from [{}] and not part of the cluster, should not happen", incomingState.nodes().masterNode()); + 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().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/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/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/GatewayAllocator.java b/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java index 0059a0ef61b..7553a4b47a3 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java @@ -68,9 +68,9 @@ 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.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 867b7420107..534a73355af 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.masterNode(settings) || DiscoveryNode.dataNode(settings)) { + if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings)) { nodeEnv.ensureAtomicMoveSupported(); } - if (DiscoveryNode.masterNode(settings) || DiscoveryNode.dataNode(settings)) { + if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings)) { try { ensureNoPre019State(); IndexFolderUpgrader.upgradeIndicesIfNeeded(settings, nodeEnv); @@ -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().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().masterNode() == 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().masterNode() == false) && state.nodes().localNode().dataNode()); + return ((state.nodes().getLocalNode().isMasterNode() == false) && state.nodes().getLocalNode().isDataNode()); } /** @@ -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/gateway/GatewayService.java b/core/src/main/java/org/elasticsearch/gateway/GatewayService.java index 7dcc45f1c0a..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; } @@ -163,17 +163,17 @@ 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.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); - } else if (recoverAfterDataNodes != -1 && nodes.dataNodes().size() < recoverAfterDataNodes) { + 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.dataNodes().size(), recoverAfterDataNodes); - } else if (recoverAfterMasterNodes != -1 && nodes.masterNodes().size() < recoverAfterMasterNodes) { + nodes.getDataNodes().size(), recoverAfterDataNodes); + } 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; @@ -185,15 +185,15 @@ 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() + "]"; - } else if (expectedDataNodes != -1 && (nodes.dataNodes().size() < expectedDataNodes)) { // does not meet the expected... + 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.dataNodes().size() + "]"; - } else if (expectedMasterNodes != -1 && (nodes.masterNodes().size() < expectedMasterNodes)) { // does not meet the expected... + reason = "expecting [" + expectedDataNodes + "] data nodes, but only have [" + nodes.getDataNodes().size() + "]"; + } 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/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/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..d2e3d7f42cf 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) { @@ -216,8 +216,8 @@ 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()) { - RoutingNode node = allocation.routingNodes().node(cursor.value.id()); + for (ObjectCursor cursor : allocation.nodes().getDataNodes().values()) { + 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; } @@ -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/IndicesService.java b/core/src/main/java/org/elasticsearch/indices/IndicesService.java index 1e268c88c97..ef1cd6196a8 100644 --- a/core/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/core/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -536,7 +536,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().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()); @@ -609,7 +609,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 82f1466bf13..7b1c03218b1 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 { 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/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..6eccf8f02db 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java @@ -316,20 +316,20 @@ 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.TRANSPORT_ADDRESS, sourceNode.getAddress().toString()); builder.field(Fields.IP, sourceNode.getHostAddress()); - builder.field(Fields.NAME, sourceNode.name()); + builder.field(Fields.NAME, sourceNode.getName()); builder.endObject(); } 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.TRANSPORT_ADDRESS, targetNode.getAddress().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/indices/store/IndicesStore.java b/core/src/main/java/org/elasticsearch/indices/store/IndicesStore.java index fcca5769ddd..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().id(); + 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/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java index f88c4b7e7f2..8bf330851ba 100644 --- a/core/src/main/java/org/elasticsearch/node/Node.java +++ b/core/src/main/java/org/elasticsearch/node/Node.java @@ -216,7 +216,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()); @@ -333,7 +333,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/repositories/RepositoriesService.java b/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java index da2d9688095..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.masterNode(settings)) { + if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isMasterNode(settings)) { clusterService.add(this); } this.verifyAction = new VerifyNodeRepositoryAction(settings, transportService, clusterService, this); @@ -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/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java b/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java index 48ffbd5c1cb..93bcca1c375 100644 --- a/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java +++ b/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java @@ -69,9 +69,9 @@ 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.masterAndDataNodes().values(); + final ObjectContainer masterAndDataNodes = discoNodes.getMasterAndDataNodes().values(); final List nodes = new ArrayList<>(); for (ObjectCursor cursor : masterAndDataNodes) { DiscoveryNode node = cursor.value; @@ -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..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 @@ -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(); @@ -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/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/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/RestNodeAttrsAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java index 24c7562c71b..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 @@ -102,16 +102,16 @@ 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(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()); 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 42604f10b17..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,12 +223,12 @@ 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) { - 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,11 +239,11 @@ 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) { - table.addCell(((InetSocketTransportAddress) node.address()).address().getPort()); + if (node.getAddress() instanceof InetSocketTransportAddress) { + table.addCell(((InetSocketTransportAddress) node.getAddress()).address().getPort()); } else { table.addCell("-"); } @@ -287,8 +287,8 @@ 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(node.name()); + table.addCell(masterId == null ? "x" : masterId.equals(node.getId()) ? "*" : "-"); + 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 1a37ab6da38..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 @@ -94,12 +94,12 @@ 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.name()); + table.addCell(node.getId()); + 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/rest/action/cat/RestThreadPoolAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java index b4ba4bbeffa..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 @@ -226,16 +226,16 @@ 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()); - 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/search/SearchService.java b/core/src/main/java/org/elasticsearch/search/SearchService.java index e2c59206436..4aaa96378a4 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchService.java +++ b/core/src/main/java/org/elasticsearch/search/SearchService.java @@ -544,7 +544,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/RestoreService.java b/core/src/main/java/org/elasticsearch/snapshots/RestoreService.java index be2d6ccfea1..0f03fa6ad9e 100644 --- a/core/src/main/java/org/elasticsearch/snapshots/RestoreService.java +++ b/core/src/main/java/org/elasticsearch/snapshots/RestoreService.java @@ -301,9 +301,9 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis for (int shard = 0; shard < snapshotIndexMetaData.getNumberOfShards(); shard++) { if (!ignoreShards.contains(shard)) { - shardsBuilder.put(new ShardId(renamedIndex, shard), new RestoreInProgress.ShardRestoreStatus(clusterService.state().nodes().localNodeId())); + shardsBuilder.put(new ShardId(renamedIndex, shard), new RestoreInProgress.ShardRestoreStatus(clusterService.state().nodes().getLocalNodeId())); } else { - shardsBuilder.put(new ShardId(renamedIndex, shard), new RestoreInProgress.ShardRestoreStatus(clusterService.state().nodes().localNodeId(), RestoreInProgress.State.FAILURE)); + shardsBuilder.put(new ShardId(renamedIndex, shard), new RestoreInProgress.ShardRestoreStatus(clusterService.state().nodes().getLocalNodeId(), RestoreInProgress.State.FAILURE)); } } } @@ -486,8 +486,8 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis public void indexShardRestoreCompleted(SnapshotId snapshotId, ShardId shardId) { logger.trace("[{}] successfully restored shard [{}]", snapshotId, shardId); UpdateIndexShardRestoreStatusRequest request = new UpdateIndexShardRestoreStatusRequest(snapshotId, shardId, - new ShardRestoreStatus(clusterService.state().nodes().localNodeId(), RestoreInProgress.State.SUCCESS)); - transportService.sendRequest(clusterService.state().nodes().masterNode(), + new ShardRestoreStatus(clusterService.state().nodes().getLocalNodeId(), RestoreInProgress.State.SUCCESS)); + transportService.sendRequest(clusterService.state().nodes().getMasterNode(), UPDATE_RESTORE_ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME); } @@ -760,8 +760,8 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis public void failRestore(SnapshotId snapshotId, ShardId shardId) { logger.debug("[{}] failed to restore shard [{}]", snapshotId, shardId); UpdateIndexShardRestoreStatusRequest request = new UpdateIndexShardRestoreStatusRequest(snapshotId, shardId, - new ShardRestoreStatus(clusterService.state().nodes().localNodeId(), RestoreInProgress.State.FAILURE)); - transportService.sendRequest(clusterService.state().nodes().masterNode(), + new ShardRestoreStatus(clusterService.state().nodes().getLocalNodeId(), RestoreInProgress.State.FAILURE)); + transportService.sendRequest(clusterService.state().nodes().getMasterNode(), UPDATE_RESTORE_ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME); } diff --git a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java index 4a15dbdac2e..c2a33680efa 100644 --- a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java +++ b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java @@ -108,13 +108,13 @@ 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) { @@ -255,12 +255,12 @@ public class SnapshotShardsService 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"); } @@ -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 da629a0d47f..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(); @@ -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"); } @@ -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); } @@ -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..a6cfec81126 100644 --- a/core/src/main/java/org/elasticsearch/tribe/TribeService.java +++ b/core/src/main/java/org/elasticsearch/tribe/TribeService.java @@ -353,21 +353,21 @@ 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(), - tribe.address(), unmodifiableMap(tribeAttr), tribe.getRoles(), tribe.version()); + DiscoveryNode discoNode = new DiscoveryNode(tribe.getName(), tribe.getId(), tribe.getHostName(), tribe.getHostAddress(), + 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/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/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..f76fdf4fd20 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) @@ -318,9 +318,9 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase { Request request = new Request(new String[]{TEST_INDEX}); PlainActionFuture 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.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()); } } @@ -403,9 +403,9 @@ 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.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..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 @@ -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()); } @@ -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); @@ -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..b928e08d860 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 @@ -376,7 +376,7 @@ public class TransportReplicationActionTests extends ESTestCase { final List 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))); @@ -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/bwcompat/BasicBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java index c26da0e6f1c..8db5b1536e8 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)); } } @@ -450,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/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/client/transport/TransportClientIT.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java index bd1bd83ef8f..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)); } @@ -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/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/ClusterStateDiffIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java index 017537443a2..84cb47f4b7a 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); @@ -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); @@ -133,14 +133,14 @@ public class ClusterStateDiffIT extends ESIntegTestCase { assertThat(clusterStateFromDiffs.stateUUID(), equalTo(clusterState.stateUUID())); // Check nodes - assertThat(clusterStateFromDiffs.nodes().nodes(), equalTo(clusterState.nodes().nodes())); - 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())); + 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); DiscoveryNode node2 = clusterStateFromDiffs.nodes().get(node.value); - assertThat(node1.version(), equalTo(node2.version())); - assertThat(node1.address(), equalTo(node2.address())); + assertThat(node1.getVersion(), equalTo(node2.getVersion())); + assertThat(node1.getAddress(), equalTo(node2.getAddress())); assertThat(node1.getAttributes(), equalTo(node2.getAttributes())); } @@ -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/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/MinimumMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java index 9c004a95f3b..991ed9ee883 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,9 +252,9 @@ 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))); + assertThat(state.nodes().getMasterNodeId(), not(isOneOf(newNodes))); logger.info("--> verify we the data back"); for (int i = 0; i < 10; i++) { @@ -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/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/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/SpecificMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java index 207232883c7..792c28680e3 100644 --- a/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java @@ -46,21 +46,21 @@ 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 } 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().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(); 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 @@ -68,34 +68,34 @@ 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().getMasterNode().getName(), equalTo(nextMasterEligibleNodeName)); + assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligibleNodeName)); } public void testElectOnlyBetweenMasterNodes() throws IOException { 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 } 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().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().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().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().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().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/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..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); @@ -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); @@ -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().getMasterNodes().iterator().next().value.getId()); setState(clusterService, ClusterState.builder(clusterService.state()).nodes(masterBuilder)); }); 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 37f8572f98c..d074ad15166 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/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/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 77ffb371cba..b0942ab401c 100644 --- a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java @@ -39,10 +39,10 @@ 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.id() : node.name()); - assertThat(resolvedNode.id(), equalTo(node.id())); + DiscoveryNode resolvedNode = discoveryNodes.resolveNode(randomBoolean() ? node.getId() : node.getName()); + 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")); @@ -77,18 +77,18 @@ 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.name()); - expectedNodeIdsSet.add(discoveryNode.id()); + nodeSelectors.add(discoveryNode.getName()); + 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(); } @@ -124,12 +124,12 @@ 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 Set matchingNodeIds(DiscoveryNodes nodes) { - return Collections.singleton(nodes.masterNodeId()); + return Collections.singleton(nodes.getMasterNodeId()); } }, MASTER_ELIGIBLE(DiscoveryNode.Role.MASTER.getRoleName() + ":true") { @Override @@ -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/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/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..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 @@ -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(); @@ -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/cluster/routing/allocation/RandomAllocationDeciderTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java index 582fcfd52c7..c9b59e1403c 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/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..a2a25ceafd2 100644 --- a/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java @@ -518,8 +518,8 @@ 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().localNodeMaster(), is(true)); + assertThat(clusterService.state().nodes().getMasterNode(), notNullValue()); + assertThat(clusterService.state().nodes().isLocalNodeElectedMaster(), is(true)); assertThat(testService.master(), is(true)); String node_1 = internalCluster().startNode(settings); @@ -530,7 +530,7 @@ public class ClusterServiceIT extends ESIntegTestCase { assertThat(clusterHealth.isTimedOut(), equalTo(false)); // the second node should not be the master as node1 is already the master. - assertThat(clusterService1.state().nodes().localNodeMaster(), is(false)); + assertThat(clusterService1.state().nodes().isLocalNodeElectedMaster(), is(false)); assertThat(testService1.master(), is(false)); internalCluster().stopCurrentMasterNode(); @@ -538,7 +538,7 @@ public class ClusterServiceIT extends ESIntegTestCase { assertThat(clusterHealth.isTimedOut(), equalTo(false)); // now that node0 is closed, node1 should be elected as master - assertThat(clusterService1.state().nodes().localNodeMaster(), is(true)); + assertThat(clusterService1.state().nodes().isLocalNodeElectedMaster(), is(true)); assertThat(testService1.master(), is(true)); // start another node and set min_master_node @@ -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().name())) { + 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/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/discovery/DiscoveryWithServiceDisruptionsIT.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java index 2f131672880..03a3cb19754 100644 --- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java @@ -401,8 +401,8 @@ 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("different masters ", state.nodes().masterNodeId(), nodeState.nodes().masterNodeId()); + assertEquals("unequal node count", state.nodes().getSize(), nodeState.nodes().getSize()); + 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"); @@ -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)); } } @@ -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(); } } @@ -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); @@ -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 { @@ -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().name(); + 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))); } @@ -1205,8 +1205,8 @@ 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())); - String otherMasterNodeName = state.nodes().masterNode() != null ? state.nodes().masterNode().name() : null; + assertThat("wrong node count on [" + node + "]. " + failMsgSuffix, state.nodes().getSize(), equalTo(nodes.size())); + 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/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/ZenUnicastDiscoveryIT.java b/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java index efbfa800437..e3c11a6e322 100644 --- a/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/ZenUnicastDiscoveryIT.java @@ -92,11 +92,11 @@ 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(); + 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/ElectMasterServiceTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/ElectMasterServiceTests.java index c279cad910e..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,10 +65,10 @@ 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()) { - assertTrue(prevNode.id().compareTo(node.id()) < 0); + 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,8 +99,8 @@ public class ElectMasterServiceTests extends ESTestCase { } else { assertNotNull(master); for (DiscoveryNode node : nodes) { - if (node.masterNode()) { - assertTrue(master.id().compareTo(node.id()) <= 0); + if (node.isMasterNode()) { + 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..3a81b905eb5 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java @@ -94,10 +94,10 @@ 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.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); @@ -208,7 +208,7 @@ public class NodeJoinControllerTests extends ESTestCase { nodeJoinController.waitToBeElectedAsMaster(requiredJoins, TimeValue.timeValueHours(30), new NodeJoinController.ElectionCallback() { @Override public void onElectedAsMaster(ClusterState state) { - assertThat("callback called with elected as master, but state disagrees", state.nodes().localNodeMaster(), equalTo(true)); + assertThat("callback called with elected as master, but state disagrees", state.nodes().isLocalNodeElectedMaster(), equalTo(true)); electionFuture.markAsDone(); } @@ -256,7 +256,7 @@ public class NodeJoinControllerTests extends ESTestCase { nodeJoinController.waitToBeElectedAsMaster(requiredJoins, TimeValue.timeValueHours(30), new NodeJoinController.ElectionCallback() { @Override public void onElectedAsMaster(ClusterState state) { - assertThat("callback called with elected as master, but state disagrees", state.nodes().localNodeMaster(), equalTo(true)); + assertThat("callback called with elected as master, but state disagrees", state.nodes().isLocalNodeElectedMaster(), equalTo(true)); electionFuture.markAsDone(); } @@ -374,7 +374,7 @@ public class NodeJoinControllerTests extends ESTestCase { nodeJoinController.waitToBeElectedAsMaster(requiredJoins, TimeValue.timeValueMillis(1), new NodeJoinController.ElectionCallback() { @Override public void onElectedAsMaster(ClusterState state) { - assertThat("callback called with elected as master, but state disagrees", state.nodes().localNodeMaster(), equalTo(true)); + assertThat("callback called with elected as master, but state disagrees", state.nodes().isLocalNodeElectedMaster(), equalTo(true)); latch.countDown(); } @@ -492,7 +492,7 @@ public class NodeJoinControllerTests extends ESTestCase { nodeJoinController.waitToBeElectedAsMaster(requiredJoins, TimeValue.timeValueHours(30), new NodeJoinController.ElectionCallback() { @Override public void onElectedAsMaster(ClusterState state) { - assertThat("callback called with elected as master, but state disagrees", state.nodes().localNodeMaster(), equalTo(true)); + assertThat("callback called with elected as master, but state disagrees", state.nodes().isLocalNodeElectedMaster(), equalTo(true)); latch.countDown(); } @@ -555,9 +555,9 @@ 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())); + assertThat(discoveryNodes.getSize(), equalTo(expectedNodes.size())); } static class SimpleFuture extends BaseFuture { 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..6ea3967c46f 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; } } @@ -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<>(); @@ -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/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/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/discovery/zen/publish/PublishClusterStateActionTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java index 0fa844b0e56..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 @@ -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; } @@ -118,12 +118,12 @@ 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); } - if (clusterState.nodes().masterNode() == null || newClusterState.supersedes(clusterState)) { + if (clusterState.nodes().getMasterNode() == null || newClusterState.supersedes(clusterState)) { clusterState = newClusterState; } action.pendingStatesQueue().markAsProcessed(newClusterState); @@ -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 @@ -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)); } } @@ -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/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/ReplicaShardAllocatorTests.java b/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java index 7ab136b4772..bb1bc01780c 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/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 b91cf428ee6..6bff253e670 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/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/indices/recovery/IndexRecoveryIT.java b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java index e2138938796..4549283e656 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)); } } @@ -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/state/RareClusterStateIT.java b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java index efdae8106a4..0b1723bd5aa 100644 --- a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java +++ b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java @@ -234,13 +234,13 @@ 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().getMasterNode().getName()); List shards = state.routingTable().allShards("index"); assertThat(shards, hasSize(1)); 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 } @@ -352,13 +352,13 @@ 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().getMasterNode().getName()); List shards = state.routingTable().allShards("index"); assertThat(shards, hasSize(2)); 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/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java index 4251241c62e..59b0f4c8dd4 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/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(); 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/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 { diff --git a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java index 86d5ca09fde..014366d492c 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())); } }); } @@ -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"))) { 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/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/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 e9096275d5d..252fc143cf6 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; @@ -1048,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); @@ -1058,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 @@ -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/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/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/ExternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java index c997a41ad6d..45c0a8aabc3 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java @@ -42,7 +42,6 @@ import java.net.InetSocketAddress; import java.nio.file.Path; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.concurrent.atomic.AtomicInteger; import static org.hamcrest.Matchers.equalTo; @@ -95,10 +94,10 @@ public final class ExternalTestCluster extends TestCluster { for (int i = 0; i < nodeInfos.getNodes().length; i++) { NodeInfo nodeInfo = nodeInfos.getNodes()[i]; httpAddresses[i] = ((InetSocketTransportAddress) nodeInfo.getHttp().address().publishAddress()).address(); - if (DiscoveryNode.dataNode(nodeInfo.getSettings())) { + if (DiscoveryNode.isDataNode(nodeInfo.getSettings())) { dataNodes++; masterAndDataNodes++; - } else if (DiscoveryNode.masterNode(nodeInfo.getSettings())) { + } else if (DiscoveryNode.isMasterNode(nodeInfo.getSettings())) { masterAndDataNodes++; } } 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..0db133ba0cf 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"; @@ -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().getMasterNode().getName(); } catch (Throwable e) { logger.warn("Can't fetch cluster state", e); throw new RuntimeException("Can't get master node " + e.getMessage(), e); @@ -1643,15 +1643,15 @@ public final class InternalTestCluster extends TestCluster { private static final class DataNodePredicate implements Predicate { @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()) || - DiscoveryNode.masterNode(nodeAndClient.node.settings()); + return DiscoveryNode.isDataNode(nodeAndClient.node.settings()) || + DiscoveryNode.isMasterNode(nodeAndClient.node.settings()); } } @@ -1671,8 +1671,8 @@ public final class InternalTestCluster extends TestCluster { private static final class NoDataNoMasterNodePredicate implements Predicate { @Override public boolean test(NodeAndClient nodeAndClient) { - return DiscoveryNode.masterNode(nodeAndClient.node.settings()) == false && - DiscoveryNode.dataNode(nodeAndClient.node.settings()) == false; + return DiscoveryNode.isMasterNode(nodeAndClient.node.settings()) == false && + DiscoveryNode.isDataNode(nodeAndClient.node.settings()) == false; } } 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); }