Remove DiscoveryNode#dataNode in favour of existing DiscoveryNode#isDataNode
This commit is contained in:
parent
a8bbdff3bc
commit
dfeb9379ab
|
@ -166,7 +166,7 @@ public class InternalClusterInfoService extends AbstractComponent implements Clu
|
||||||
// Check whether it was a data node that was added
|
// Check whether it was a data node that was added
|
||||||
boolean dataNodeAdded = false;
|
boolean dataNodeAdded = false;
|
||||||
for (DiscoveryNode addedNode : event.nodesDelta().addedNodes()) {
|
for (DiscoveryNode addedNode : event.nodesDelta().addedNodes()) {
|
||||||
if (addedNode.dataNode()) {
|
if (addedNode.isDataNode()) {
|
||||||
dataNodeAdded = true;
|
dataNodeAdded = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ public class InternalClusterInfoService extends AbstractComponent implements Clu
|
||||||
|
|
||||||
if (this.isMaster && event.nodesRemoved()) {
|
if (this.isMaster && event.nodesRemoved()) {
|
||||||
for (DiscoveryNode removedNode : event.nodesDelta().removedNodes()) {
|
for (DiscoveryNode removedNode : event.nodesDelta().removedNodes()) {
|
||||||
if (removedNode.dataNode()) {
|
if (removedNode.isDataNode()) {
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.trace("Removing node from cluster info: {}", removedNode.getId());
|
logger.trace("Removing node from cluster info: {}", removedNode.getId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,18 +242,11 @@ public class DiscoveryNode implements Writeable<DiscoveryNode>, ToXContent {
|
||||||
return this.attributes;
|
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.
|
* Should this node hold data (shards) or not.
|
||||||
*/
|
*/
|
||||||
public boolean isDataNode() {
|
public boolean isDataNode() {
|
||||||
return dataNode();
|
return roles.contains(Role.DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -675,7 +675,7 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
||||||
Version minNodeVersion = Version.CURRENT;
|
Version minNodeVersion = Version.CURRENT;
|
||||||
Version minNonClientNodeVersion = Version.CURRENT;
|
Version minNonClientNodeVersion = Version.CURRENT;
|
||||||
for (ObjectObjectCursor<String, DiscoveryNode> nodeEntry : nodes) {
|
for (ObjectObjectCursor<String, DiscoveryNode> nodeEntry : nodes) {
|
||||||
if (nodeEntry.value.dataNode()) {
|
if (nodeEntry.value.isDataNode()) {
|
||||||
dataNodesBuilder.put(nodeEntry.key, nodeEntry.value);
|
dataNodesBuilder.put(nodeEntry.key, nodeEntry.value);
|
||||||
minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.version());
|
minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.version());
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
* 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) {
|
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 + "]");
|
return explainOrThrowRejectedCommand(explain, allocation, "allocation can only be done on data nodes, not [" + node + "]");
|
||||||
} else {
|
} else {
|
||||||
return explainOrThrowRejectedCommand(explain, allocation, "could not find [" + node + "] among the routing nodes");
|
return explainOrThrowRejectedCommand(explain, allocation, "could not find [" + node + "] among the routing nodes");
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL
|
||||||
Set<Index> relevantIndices = Collections.emptySet();
|
Set<Index> relevantIndices = Collections.emptySet();
|
||||||
boolean success = true;
|
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
|
// 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) {
|
if (previousMetaData == null) {
|
||||||
try {
|
try {
|
||||||
// we determine if or if not we write meta data on data only nodes by looking at the shard routing
|
// 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) {
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class TransportClientIT extends ESIntegTestCase {
|
||||||
String nodeName = internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false));
|
String nodeName = internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false));
|
||||||
|
|
||||||
TransportClient client = (TransportClient) internalCluster().client(nodeName);
|
TransportClient client = (TransportClient) internalCluster().client(nodeName);
|
||||||
assertThat(client.connectedNodes().get(0).dataNode(), equalTo(false));
|
assertThat(client.connectedNodes().get(0).isDataNode(), equalTo(false));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -436,7 +436,7 @@ public class TribeIT extends ESIntegTestCase {
|
||||||
private int countDataNodesForTribe(String tribeName, DiscoveryNodes nodes) {
|
private int countDataNodesForTribe(String tribeName, DiscoveryNodes nodes) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (DiscoveryNode node : nodes) {
|
for (DiscoveryNode node : nodes) {
|
||||||
if (!node.dataNode()) {
|
if (!node.isDataNode()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (tribeName.equals(node.getAttributes().get("tribe.name"))) {
|
if (tribeName.equals(node.getAttributes().get("tribe.name"))) {
|
||||||
|
|
Loading…
Reference in New Issue