Remove DiscoveryNode#dataNode in favour of existing DiscoveryNode#isDataNode

This commit is contained in:
javanna 2016-03-30 14:51:36 +02:00 committed by Luca Cavanna
parent a8bbdff3bc
commit dfeb9379ab
7 changed files with 9 additions and 16 deletions

View File

@ -166,7 +166,7 @@ public class InternalClusterInfoService extends AbstractComponent implements Clu
// Check whether it was a data node that was added
boolean dataNodeAdded = false;
for (DiscoveryNode addedNode : event.nodesDelta().addedNodes()) {
if (addedNode.dataNode()) {
if (addedNode.isDataNode()) {
dataNodeAdded = true;
break;
}
@ -181,7 +181,7 @@ public class InternalClusterInfoService extends AbstractComponent implements Clu
if (this.isMaster && event.nodesRemoved()) {
for (DiscoveryNode removedNode : event.nodesDelta().removedNodes()) {
if (removedNode.dataNode()) {
if (removedNode.isDataNode()) {
if (logger.isTraceEnabled()) {
logger.trace("Removing node from cluster info: {}", removedNode.getId());
}

View File

@ -242,18 +242,11 @@ public class DiscoveryNode implements Writeable<DiscoveryNode>, ToXContent {
return this.attributes;
}
/**
* Should this node hold data (shards) or not.
*/
public boolean dataNode() {
return roles.contains(Role.DATA);
}
/**
* Should this node hold data (shards) or not.
*/
public boolean isDataNode() {
return dataNode();
return roles.contains(Role.DATA);
}
/**

View File

@ -675,7 +675,7 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
Version minNodeVersion = Version.CURRENT;
Version minNonClientNodeVersion = Version.CURRENT;
for (ObjectObjectCursor<String, DiscoveryNode> nodeEntry : nodes) {
if (nodeEntry.value.dataNode()) {
if (nodeEntry.value.isDataNode()) {
dataNodesBuilder.put(nodeEntry.key, nodeEntry.value);
minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.version());
}

View File

@ -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");

View File

@ -118,7 +118,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL
Set<Index> relevantIndices = Collections.emptySet();
boolean success = true;
// write the state if this node is a master eligible node or if it is a data node and has shards allocated on it
if (state.nodes().localNode().masterNode() || state.nodes().localNode().dataNode()) {
if (state.nodes().localNode().masterNode() || state.nodes().localNode().isDataNode()) {
if (previousMetaData == null) {
try {
// we determine if or if not we write meta data on data only nodes by looking at the shard routing
@ -188,7 +188,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL
protected static boolean isDataOnlyNode(ClusterState state) {
return ((state.nodes().localNode().masterNode() == false) && state.nodes().localNode().dataNode());
return ((state.nodes().localNode().masterNode() == false) && state.nodes().localNode().isDataNode());
}
/**

View File

@ -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));
}

View File

@ -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"))) {