[Internal] introduce ClusterState.UNKNOWN_VERSION constant

Used as null value for cluster state versions.
This commit is contained in:
Boaz Leskes 2014-08-29 22:57:23 +02:00
parent ed5b2e0e35
commit d8a5ff0047
3 changed files with 6 additions and 3 deletions

View File

@ -115,6 +115,8 @@ public class ClusterState implements ToXContent {
} }
public static final long UNKNOWN_VERSION = -1;
private final long version; private final long version;
private final RoutingTable routingTable; private final RoutingTable routingTable;

View File

@ -216,7 +216,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
final String nodeId = DiscoveryService.generateNodeId(settings); final String nodeId = DiscoveryService.generateNodeId(settings);
localNode = new DiscoveryNode(settings.get("name"), nodeId, transportService.boundAddress().publishAddress(), nodeAttributes, version); localNode = new DiscoveryNode(settings.get("name"), nodeId, transportService.boundAddress().publishAddress(), nodeAttributes, version);
latestDiscoNodes = new DiscoveryNodes.Builder().put(localNode).localNodeId(localNode.id()).build(); latestDiscoNodes = new DiscoveryNodes.Builder().put(localNode).localNodeId(localNode.id()).build();
nodesFD.updateNodes(latestDiscoNodes, -1); nodesFD.updateNodes(latestDiscoNodes, ClusterState.UNKNOWN_VERSION);
pingService.start(); pingService.start();
// do the join on a different thread, the DiscoveryService waits for 30s anyhow till it is discovered // do the join on a different thread, the DiscoveryService waits for 30s anyhow till it is discovered

View File

@ -22,6 +22,7 @@ package org.elasticsearch.discovery.zen.fd;
import org.elasticsearch.ElasticsearchIllegalStateException; import org.elasticsearch.ElasticsearchIllegalStateException;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.component.AbstractComponent;
@ -82,7 +83,7 @@ public class NodesFaultDetection extends AbstractComponent {
private volatile DiscoveryNodes latestNodes = EMPTY_NODES; private volatile DiscoveryNodes latestNodes = EMPTY_NODES;
private volatile long clusterStateVersion = -1; private volatile long clusterStateVersion = ClusterState.UNKNOWN_VERSION;
private volatile boolean running = false; private volatile boolean running = false;
@ -349,7 +350,7 @@ public class NodesFaultDetection extends AbstractComponent {
private DiscoveryNode masterNode; private DiscoveryNode masterNode;
private long clusterStateVersion = -1; private long clusterStateVersion = ClusterState.UNKNOWN_VERSION;
PingRequest() { PingRequest() {
} }