Remove DiscoveryNodes#localNode in favour of existing DiscoveryNodes#getLocalNode
This commit is contained in:
parent
f26d05eac8
commit
7ebc094353
|
@ -228,7 +228,7 @@ public abstract class TransportInstanceSingleOperationAction<Request extends Ins
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClusterServiceClose() {
|
public void onClusterServiceClose() {
|
||||||
listener.onFailure(new NodeClosedException(nodes.localNode()));
|
listener.onFailure(new NodeClosedException(nodes.getLocalNode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -491,7 +491,7 @@ public class TransportClientNodesService extends AbstractComponent {
|
||||||
for (Map.Entry<DiscoveryNode, ClusterStateResponse> entry : clusterStateResponses.entrySet()) {
|
for (Map.Entry<DiscoveryNode, ClusterStateResponse> entry : clusterStateResponses.entrySet()) {
|
||||||
if (!ignoreClusterName && !clusterName.equals(entry.getValue().getClusterName())) {
|
if (!ignoreClusterName && !clusterName.equals(entry.getValue().getClusterName())) {
|
||||||
logger.warn("node {} not part of the cluster {}, ignoring...",
|
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());
|
newFilteredNodes.add(entry.getKey());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -747,7 +747,7 @@ public class ClusterState implements ToXContent, Diffable<ClusterState> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClusterState readFrom(StreamInput in) throws IOException {
|
public ClusterState readFrom(StreamInput in) throws IOException {
|
||||||
return readFrom(in, nodes.localNode());
|
return readFrom(in, nodes.getLocalNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class NodeIndexDeletedAction extends AbstractComponent {
|
||||||
final DiscoveryNodes nodes = clusterState.nodes();
|
final DiscoveryNodes nodes = clusterState.nodes();
|
||||||
transportService.sendRequest(clusterState.nodes().masterNode(),
|
transportService.sendRequest(clusterState.nodes().masterNode(),
|
||||||
INDEX_DELETED_ACTION_NAME, new NodeIndexDeletedMessage(index, nodeId), EmptyTransportResponseHandler.INSTANCE_SAME);
|
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);
|
logger.trace("[{}] not acking store deletion (not a data node)", index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,22 +188,13 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
||||||
return this.localNodeId;
|
return this.localNodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the local node
|
|
||||||
*
|
|
||||||
* @return local node
|
|
||||||
*/
|
|
||||||
public DiscoveryNode localNode() {
|
|
||||||
return nodes.get(localNodeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the local node
|
* Get the local node
|
||||||
*
|
*
|
||||||
* @return local node
|
* @return local node
|
||||||
*/
|
*/
|
||||||
public DiscoveryNode getLocalNode() {
|
public DiscoveryNode getLocalNode() {
|
||||||
return localNode();
|
return nodes.get(localNodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -415,7 +406,7 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
||||||
sb.append("nodes: \n");
|
sb.append("nodes: \n");
|
||||||
for (DiscoveryNode node : this) {
|
for (DiscoveryNode node : this) {
|
||||||
sb.append(" ").append(node);
|
sb.append(" ").append(node);
|
||||||
if (node == localNode()) {
|
if (node == getLocalNode()) {
|
||||||
sb.append(", local");
|
sb.append(", local");
|
||||||
}
|
}
|
||||||
if (node == masterNode()) {
|
if (node == masterNode()) {
|
||||||
|
@ -563,7 +554,7 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiscoveryNodes readFrom(StreamInput in) throws IOException {
|
public DiscoveryNodes readFrom(StreamInput in) throws IOException {
|
||||||
return readFrom(in, localNode());
|
return readFrom(in, getLocalNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
|
|
@ -477,7 +477,7 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
||||||
private static List<ShardRouting> collectAttributeShards(AttributesKey key, DiscoveryNodes nodes, ArrayList<ShardRouting> from) {
|
private static List<ShardRouting> collectAttributeShards(AttributesKey key, DiscoveryNodes nodes, ArrayList<ShardRouting> from) {
|
||||||
final ArrayList<ShardRouting> to = new ArrayList<>();
|
final ArrayList<ShardRouting> to = new ArrayList<>();
|
||||||
for (final String attribute : key.attributes) {
|
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) {
|
if (localAttributeValue != null) {
|
||||||
for (Iterator<ShardRouting> iterator = from.iterator(); iterator.hasNext(); ) {
|
for (Iterator<ShardRouting> iterator = from.iterator(); iterator.hasNext(); ) {
|
||||||
ShardRouting fromShard = iterator.next();
|
ShardRouting fromShard = iterator.next();
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class ClusterService extends AbstractLifecycleComponent<ClusterService> {
|
||||||
@Override
|
@Override
|
||||||
synchronized protected void doStart() {
|
synchronized protected void doStart() {
|
||||||
Objects.requireNonNull(clusterStatePublisher, "please set a cluster state publisher before starting");
|
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");
|
Objects.requireNonNull(nodeConnectionsService, "please set the node connection service before starting");
|
||||||
add(localNodeMasterListeners);
|
add(localNodeMasterListeners);
|
||||||
this.clusterState = ClusterState.builder(clusterState).blocks(initialBlocks).build();
|
this.clusterState = ClusterState.builder(clusterState).blocks(initialBlocks).build();
|
||||||
|
@ -229,7 +229,7 @@ public class ClusterService extends AbstractLifecycleComponent<ClusterService> {
|
||||||
* The local node.
|
* The local node.
|
||||||
*/
|
*/
|
||||||
public DiscoveryNode localNode() {
|
public DiscoveryNode localNode() {
|
||||||
return clusterState.getNodes().localNode();
|
return clusterState.getNodes().getLocalNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationRouting operationRouting() {
|
public OperationRouting operationRouting() {
|
||||||
|
@ -663,9 +663,9 @@ public class ClusterService extends AbstractLifecycleComponent<ClusterService> {
|
||||||
//manual ack only from the master at the end of the publish
|
//manual ack only from the master at the end of the publish
|
||||||
if (newClusterState.nodes().localNodeMaster()) {
|
if (newClusterState.nodes().localNodeMaster()) {
|
||||||
try {
|
try {
|
||||||
ackListener.onNodeAck(newClusterState.nodes().localNode(), null);
|
ackListener.onNodeAck(newClusterState.nodes().getLocalNode(), null);
|
||||||
} catch (Throwable t) {
|
} 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent<Discovery> implem
|
||||||
|
|
||||||
nodeSpecificClusterState.status(ClusterState.ClusterStateStatus.RECEIVED);
|
nodeSpecificClusterState.status(ClusterState.ClusterStateStatus.RECEIVED);
|
||||||
// ignore cluster state messages that do not include "me", not in the game yet...
|
// ignore cluster state messages that do not include "me", not in the game yet...
|
||||||
if (nodeSpecificClusterState.nodes().localNode() != null) {
|
if (nodeSpecificClusterState.nodes().getLocalNode() != null) {
|
||||||
assert nodeSpecificClusterState.nodes().masterNode() != null : "received a cluster state without a master";
|
assert nodeSpecificClusterState.nodes().masterNode() != null : "received a cluster state without a master";
|
||||||
assert !nodeSpecificClusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock()) : "received a cluster state with a master block";
|
assert !nodeSpecificClusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock()) : "received a cluster state with a master block";
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,7 @@ public class NodeJoinController extends AbstractComponent {
|
||||||
throw new NotMasterException("Node [" + clusterService.localNode() + "] not master for join request");
|
throw new NotMasterException("Node [" + clusterService.localNode() + "] not master for join request");
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder(currentState.nodes()).masterNodeId(currentState.nodes().localNode().getId());
|
DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder(currentState.nodes()).masterNodeId(currentState.nodes().getLocalNode().getId());
|
||||||
// update the fact that we are the master...
|
// update the fact that we are the master...
|
||||||
ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(discoverySettings.getNoMasterBlock()).build();
|
ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(discoverySettings.getNoMasterBlock()).build();
|
||||||
currentState = ClusterState.builder(currentState).nodes(builder).blocks(clusterBlocks).build();
|
currentState = ClusterState.builder(currentState).nodes(builder).blocks(clusterBlocks).build();
|
||||||
|
|
|
@ -246,7 +246,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
||||||
// if we don't know who the master is, nothing to do here
|
// if we don't know who the master is, nothing to do here
|
||||||
} else if (!nodes.localNodeMaster()) {
|
} else if (!nodes.localNodeMaster()) {
|
||||||
try {
|
try {
|
||||||
membership.sendLeaveRequestBlocking(nodes.masterNode(), nodes.localNode(), TimeValue.timeValueSeconds(1));
|
membership.sendLeaveRequestBlocking(nodes.masterNode(), nodes.getLocalNode(), TimeValue.timeValueSeconds(1));
|
||||||
} catch (Exception e) {
|
} 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.masterNode());
|
||||||
}
|
}
|
||||||
|
@ -254,11 +254,11 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
||||||
// we're master -> let other potential master we left and start a master election now rather then wait for masterFD
|
// we're master -> let other potential master we left and start a master election now rather then wait for masterFD
|
||||||
DiscoveryNode[] possibleMasters = electMaster.nextPossibleMasters(nodes.getNodes().values(), 5);
|
DiscoveryNode[] possibleMasters = electMaster.nextPossibleMasters(nodes.getNodes().values(), 5);
|
||||||
for (DiscoveryNode possibleMaster : possibleMasters) {
|
for (DiscoveryNode possibleMaster : possibleMasters) {
|
||||||
if (nodes.localNode().equals(possibleMaster)) {
|
if (nodes.getLocalNode().equals(possibleMaster)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
membership.sendLeaveRequest(nodes.localNode(), possibleMaster);
|
membership.sendLeaveRequest(nodes.getLocalNode(), possibleMaster);
|
||||||
} catch (Exception e) {
|
} 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.masterNode(), possibleMaster);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ public class MembershipAction extends AbstractComponent {
|
||||||
@Override
|
@Override
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
super.readFrom(in);
|
super.readFrom(in);
|
||||||
this.state = ClusterState.Builder.readFrom(in, nodesProvider.nodes().localNode());
|
this.state = ClusterState.Builder.readFrom(in, nodesProvider.nodes().getLocalNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -565,7 +565,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
private PingResponse createPingResponse(DiscoveryNodes discoNodes) {
|
private PingResponse createPingResponse(DiscoveryNodes discoNodes) {
|
||||||
return new PingResponse(discoNodes.localNode(), discoNodes.masterNode(), clusterName, contextProvider.nodeHasJoinedClusterOnce());
|
return new PingResponse(discoNodes.getLocalNode(), discoNodes.masterNode(), clusterName, contextProvider.nodeHasJoinedClusterOnce());
|
||||||
}
|
}
|
||||||
|
|
||||||
static class UnicastPingResponse extends TransportResponse {
|
static class UnicastPingResponse extends TransportResponse {
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class PublishClusterStateAction extends AbstractComponent {
|
||||||
try {
|
try {
|
||||||
nodes = clusterChangedEvent.state().nodes();
|
nodes = clusterChangedEvent.state().nodes();
|
||||||
nodesToPublishTo = new HashSet<>(nodes.getSize());
|
nodesToPublishTo = new HashSet<>(nodes.getSize());
|
||||||
DiscoveryNode localNode = nodes.localNode();
|
DiscoveryNode localNode = nodes.getLocalNode();
|
||||||
final int totalMasterNodes = nodes.getMasterNodes().size();
|
final int totalMasterNodes = nodes.getMasterNodes().size();
|
||||||
for (final DiscoveryNode node : nodes) {
|
for (final DiscoveryNode node : nodes) {
|
||||||
if (node.equals(localNode) == false) {
|
if (node.equals(localNode) == false) {
|
||||||
|
@ -363,7 +363,7 @@ public class PublishClusterStateAction extends AbstractComponent {
|
||||||
final ClusterState incomingState;
|
final ClusterState incomingState;
|
||||||
// If true we received full cluster state - otherwise diffs
|
// If true we received full cluster state - otherwise diffs
|
||||||
if (in.readBoolean()) {
|
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());
|
logger.debug("received full cluster state version [{}] with size [{}]", incomingState.version(), request.bytes().length());
|
||||||
} else if (lastSeenClusterState != null) {
|
} else if (lastSeenClusterState != null) {
|
||||||
Diff<ClusterState> diff = lastSeenClusterState.readDiffFrom(in);
|
Diff<ClusterState> diff = lastSeenClusterState.readDiffFrom(in);
|
||||||
|
@ -396,7 +396,7 @@ public class PublishClusterStateAction extends AbstractComponent {
|
||||||
}
|
}
|
||||||
final DiscoveryNodes currentNodes = nodesProvider.nodes();
|
final DiscoveryNodes currentNodes = nodesProvider.nodes();
|
||||||
|
|
||||||
if (currentNodes.localNode().equals(incomingState.nodes().localNode()) == false) {
|
if (currentNodes.getLocalNode().equals(incomingState.nodes().getLocalNode()) == false) {
|
||||||
logger.warn("received a cluster state from [{}] and not part of the cluster, should not happen", incomingState.nodes().masterNode());
|
logger.warn("received a cluster state from [{}] and not part of the cluster, should not happen", incomingState.nodes().masterNode());
|
||||||
throw new IllegalStateException("received state from a node that is not part of the cluster");
|
throw new IllegalStateException("received state from a node that is not part of the cluster");
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class GatewayAllocator extends AbstractComponent {
|
||||||
@Override
|
@Override
|
||||||
public void clusterChanged(ClusterChangedEvent event) {
|
public void clusterChanged(ClusterChangedEvent event) {
|
||||||
boolean cleanCache = false;
|
boolean cleanCache = false;
|
||||||
DiscoveryNode localNode = event.state().nodes().localNode();
|
DiscoveryNode localNode = event.state().nodes().getLocalNode();
|
||||||
if (localNode != null) {
|
if (localNode != null) {
|
||||||
if (localNode.isMasterNode() == true && event.localNodeMaster() == false) {
|
if (localNode.isMasterNode() == true && event.localNodeMaster() == false) {
|
||||||
cleanCache = true;
|
cleanCache = true;
|
||||||
|
|
|
@ -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().isMasterNode() || state.nodes().localNode().isDataNode()) {
|
if (state.nodes().getLocalNode().isMasterNode() || state.nodes().getLocalNode().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
|
||||||
|
@ -178,7 +178,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL
|
||||||
Set<Index> relevantIndices;
|
Set<Index> relevantIndices;
|
||||||
if (isDataOnlyNode(state)) {
|
if (isDataOnlyNode(state)) {
|
||||||
relevantIndices = getRelevantIndicesOnDataOnlyNode(state, previousState, previouslyWrittenIndices);
|
relevantIndices = getRelevantIndicesOnDataOnlyNode(state, previousState, previouslyWrittenIndices);
|
||||||
} else if (state.nodes().localNode().isMasterNode() == true) {
|
} else if (state.nodes().getLocalNode().isMasterNode() == true) {
|
||||||
relevantIndices = getRelevantIndicesForMasterEligibleNode(state);
|
relevantIndices = getRelevantIndicesForMasterEligibleNode(state);
|
||||||
} else {
|
} else {
|
||||||
relevantIndices = Collections.emptySet();
|
relevantIndices = Collections.emptySet();
|
||||||
|
@ -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().isMasterNode() == false) && state.nodes().localNode().isDataNode());
|
return ((state.nodes().getLocalNode().isMasterNode() == false) && state.nodes().getLocalNode().isDataNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -535,7 +535,7 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
|
||||||
throw new IllegalStateException("Can't delete index store for [" + index.getName() + "] - it's still part of the indices service [" + localUUid + "] [" + metaData.getIndexUUID() + "]");
|
throw new IllegalStateException("Can't delete index store for [" + index.getName() + "] - it's still part of the indices service [" + localUUid + "] [" + metaData.getIndexUUID() + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clusterState.metaData().hasIndex(index.getName()) && (clusterState.nodes().localNode().isMasterNode() == true)) {
|
if (clusterState.metaData().hasIndex(index.getName()) && (clusterState.nodes().getLocalNode().isMasterNode() == true)) {
|
||||||
// we do not delete the store if it is a master eligible node and the index is still in the cluster state
|
// 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
|
// 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());
|
final IndexMetaData idxMeta = clusterState.metaData().index(index.getName());
|
||||||
|
@ -608,7 +608,7 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
|
||||||
nodeEnv.deleteShardDirectorySafe(shardId, indexSettings);
|
nodeEnv.deleteShardDirectorySafe(shardId, indexSettings);
|
||||||
logger.debug("{} deleted shard reason [{}]", shardId, reason);
|
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)) {
|
canDeleteIndexContents(shardId.getIndex(), indexSettings, false)) {
|
||||||
if (nodeEnv.findAllShardIds(shardId.getIndex()).isEmpty()) {
|
if (nodeEnv.findAllShardIds(shardId.getIndex()).isEmpty()) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -617,7 +617,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
||||||
// the edge case where its mark as relocated, and we might need to roll it back...
|
// the edge case where its mark as relocated, and we might need to roll it back...
|
||||||
// For replicas: we are recovering a backup from a primary
|
// For replicas: we are recovering a backup from a primary
|
||||||
RecoveryState.Type type = shardRouting.primary() ? RecoveryState.Type.PRIMARY_RELOCATION : RecoveryState.Type.REPLICA;
|
RecoveryState.Type type = shardRouting.primary() ? RecoveryState.Type.PRIMARY_RELOCATION : RecoveryState.Type.REPLICA;
|
||||||
RecoveryState recoveryState = new RecoveryState(indexShard.shardId(), shardRouting.primary(), type, sourceNode, nodes.localNode());
|
RecoveryState recoveryState = new RecoveryState(indexShard.shardId(), shardRouting.primary(), type, sourceNode, nodes.getLocalNode());
|
||||||
indexShard.markAsRecovering("from " + sourceNode, recoveryState);
|
indexShard.markAsRecovering("from " + sourceNode, recoveryState);
|
||||||
recoveryTargetService.startRecovery(indexShard, type, sourceNode, new PeerRecoveryListener(shardRouting, indexService, indexMetaData));
|
recoveryTargetService.startRecovery(indexShard, type, sourceNode, new PeerRecoveryListener(shardRouting, indexService, indexMetaData));
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -629,11 +629,11 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
||||||
// recover from filesystem store
|
// recover from filesystem store
|
||||||
final RecoveryState recoveryState = new RecoveryState(indexShard.shardId(), shardRouting.primary(),
|
final RecoveryState recoveryState = new RecoveryState(indexShard.shardId(), shardRouting.primary(),
|
||||||
RecoveryState.Type.STORE,
|
RecoveryState.Type.STORE,
|
||||||
nodes.localNode(), nodes.localNode());
|
nodes.getLocalNode(), nodes.getLocalNode());
|
||||||
indexShard.markAsRecovering("from store", recoveryState); // mark the shard as recovering on the cluster state thread
|
indexShard.markAsRecovering("from store", recoveryState); // mark the shard as recovering on the cluster state thread
|
||||||
threadPool.generic().execute(() -> {
|
threadPool.generic().execute(() -> {
|
||||||
try {
|
try {
|
||||||
if (indexShard.recoverFromStore(nodes.localNode())) {
|
if (indexShard.recoverFromStore(nodes.getLocalNode())) {
|
||||||
shardStateAction.shardStarted(shardRouting, "after recovery from store", SHARD_STATE_ACTION_LISTENER);
|
shardStateAction.shardStarted(shardRouting, "after recovery from store", SHARD_STATE_ACTION_LISTENER);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -644,13 +644,13 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
||||||
} else {
|
} else {
|
||||||
// recover from a restore
|
// recover from a restore
|
||||||
final RecoveryState recoveryState = new RecoveryState(indexShard.shardId(), shardRouting.primary(),
|
final RecoveryState recoveryState = new RecoveryState(indexShard.shardId(), shardRouting.primary(),
|
||||||
RecoveryState.Type.SNAPSHOT, shardRouting.restoreSource(), nodes.localNode());
|
RecoveryState.Type.SNAPSHOT, shardRouting.restoreSource(), nodes.getLocalNode());
|
||||||
indexShard.markAsRecovering("from snapshot", recoveryState); // mark the shard as recovering on the cluster state thread
|
indexShard.markAsRecovering("from snapshot", recoveryState); // mark the shard as recovering on the cluster state thread
|
||||||
threadPool.generic().execute(() -> {
|
threadPool.generic().execute(() -> {
|
||||||
final ShardId sId = indexShard.shardId();
|
final ShardId sId = indexShard.shardId();
|
||||||
try {
|
try {
|
||||||
final IndexShardRepository indexShardRepository = repositoriesService.indexShardRepository(restoreSource.snapshotId().getRepository());
|
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);
|
restoreService.indexShardRestoreCompleted(restoreSource.snapshotId(), sId);
|
||||||
shardStateAction.shardStarted(shardRouting, "after recovery from repository", SHARD_STATE_ACTION_LISTENER);
|
shardStateAction.shardStarted(shardRouting, "after recovery from repository", SHARD_STATE_ACTION_LISTENER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// check if shard is active on the current node or is getting relocated to the our node
|
||||||
String localNodeId = state.getNodes().localNode().getId();
|
String localNodeId = state.getNodes().getLocalNode().getId();
|
||||||
if (localNodeId.equals(shardRouting.currentNodeId()) || localNodeId.equals(shardRouting.relocatingNodeId())) {
|
if (localNodeId.equals(shardRouting.currentNodeId()) || localNodeId.equals(shardRouting.relocatingNodeId())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class VerifyNodeRepositoryAction extends AbstractComponent {
|
||||||
|
|
||||||
public void verify(String repository, String verificationToken, final ActionListener<VerifyResponse> listener) {
|
public void verify(String repository, String verificationToken, final ActionListener<VerifyResponse> listener) {
|
||||||
final DiscoveryNodes discoNodes = clusterService.state().nodes();
|
final DiscoveryNodes discoNodes = clusterService.state().nodes();
|
||||||
final DiscoveryNode localNode = discoNodes.localNode();
|
final DiscoveryNode localNode = discoNodes.getLocalNode();
|
||||||
|
|
||||||
final ObjectContainer<DiscoveryNode> masterAndDataNodes = discoNodes.getMasterAndDataNodes().values();
|
final ObjectContainer<DiscoveryNode> masterAndDataNodes = discoNodes.getMasterAndDataNodes().values();
|
||||||
final List<DiscoveryNode> nodes = new ArrayList<>();
|
final List<DiscoveryNode> nodes = new ArrayList<>();
|
||||||
|
|
|
@ -231,7 +231,7 @@ public class TaskManager extends AbstractComponent implements ClusterStateListen
|
||||||
TaskId taskId = banIterator.next();
|
TaskId taskId = banIterator.next();
|
||||||
if (lastDiscoveryNodes.nodeExists(taskId.getNodeId()) == false) {
|
if (lastDiscoveryNodes.nodeExists(taskId.getNodeId()) == false) {
|
||||||
logger.debug("Removing ban for the parent [{}] on the node [{}], reason: the parent node is gone", taskId,
|
logger.debug("Removing ban for the parent [{}] on the node [{}], reason: the parent node is gone", taskId,
|
||||||
event.state().getNodes().localNode());
|
event.state().getNodes().getLocalNode());
|
||||||
banIterator.remove();
|
banIterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class ClusterStateDiffIT extends ESIntegTestCase {
|
||||||
|
|
||||||
if (randomIntBetween(0, 10) < 1) {
|
if (randomIntBetween(0, 10) < 1) {
|
||||||
// Update cluster state via full serialization from time to time
|
// 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 {
|
} else {
|
||||||
// Update cluster states using diffs
|
// Update cluster states using diffs
|
||||||
Diff<ClusterState> diffBeforeSerialization = clusterState.diff(previousClusterState);
|
Diff<ClusterState> diffBeforeSerialization = clusterState.diff(previousClusterState);
|
||||||
|
|
|
@ -856,7 +856,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("blocking cluster state publishing from master [{}] to non master [{}]", masterNode, nonMasterNode);
|
logger.info("blocking cluster state publishing from master [{}] to non master [{}]", masterNode, nonMasterNode);
|
||||||
MockTransportService masterTransportService = (MockTransportService) internalCluster().getInstance(TransportService.class, masterNode);
|
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()) {
|
if (randomBoolean()) {
|
||||||
masterTransportService.addFailToSendNoConnectRule(localTransportService, PublishClusterStateAction.SEND_ACTION_NAME);
|
masterTransportService.addFailToSendNoConnectRule(localTransportService, PublishClusterStateAction.SEND_ACTION_NAME);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class NodeJoinControllerTests extends ESTestCase {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
clusterService = createClusterService(threadPool);
|
clusterService = createClusterService(threadPool);
|
||||||
final DiscoveryNodes initialNodes = clusterService.state().nodes();
|
final DiscoveryNodes initialNodes = clusterService.state().nodes();
|
||||||
final DiscoveryNode localNode = initialNodes.localNode();
|
final DiscoveryNode localNode = initialNodes.getLocalNode();
|
||||||
// make sure we have a master
|
// make sure we have a master
|
||||||
setState(clusterService, ClusterState.builder(clusterService.state()).nodes(
|
setState(clusterService, ClusterState.builder(clusterService.state()).nodes(
|
||||||
DiscoveryNodes.builder(initialNodes).masterNodeId(localNode.getId())));
|
DiscoveryNodes.builder(initialNodes).masterNodeId(localNode.getId())));
|
||||||
|
|
|
@ -235,7 +235,7 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
|
||||||
ClusterState stateWithCustomMetaData = ClusterState.builder(state).metaData(mdBuilder).build();
|
ClusterState stateWithCustomMetaData = ClusterState.builder(state).metaData(mdBuilder).build();
|
||||||
|
|
||||||
final AtomicReference<IllegalStateException> holder = new AtomicReference<>();
|
final AtomicReference<IllegalStateException> holder = new AtomicReference<>();
|
||||||
DiscoveryNode node = state.nodes().localNode();
|
DiscoveryNode node = state.nodes().getLocalNode();
|
||||||
zenDiscovery.handleJoinRequest(node, stateWithCustomMetaData, new MembershipAction.JoinCallback() {
|
zenDiscovery.handleJoinRequest(node, stateWithCustomMetaData, new MembershipAction.JoinCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
|
|
@ -420,7 +420,7 @@ public class PublishClusterStateActionTests extends ESTestCase {
|
||||||
|
|
||||||
for (MockNode node : nodes.values()) {
|
for (MockNode node : nodes.values()) {
|
||||||
assertSameState(node.clusterState, clusterState);
|
assertSameState(node.clusterState, clusterState);
|
||||||
assertThat(node.clusterState.nodes().localNode(), equalTo(node.discoveryNode));
|
assertThat(node.clusterState.nodes().getLocalNode(), equalTo(node.discoveryNode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue