don't write the local gateway state if there is no master, since we don't want to override the fact that they do exists on that node under the respective version
This commit is contained in:
parent
e2d6f82cd3
commit
770ccf421b
|
@ -91,6 +91,10 @@ public class ClusterBlocks {
|
|||
return levelHolders[level.id()].indices();
|
||||
}
|
||||
|
||||
public boolean hasGlobalBlock(ClusterBlock block) {
|
||||
return global.contains(block);
|
||||
}
|
||||
|
||||
public boolean hasIndexBlock(String index, ClusterBlock block) {
|
||||
return indicesBlocks.containsKey(index) && indicesBlocks.get(index).contains(block);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
package org.elasticsearch.discovery;
|
||||
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlock;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
|
||||
|
@ -32,6 +34,8 @@ import org.elasticsearch.common.component.LifecycleComponent;
|
|||
*/
|
||||
public interface Discovery extends LifecycleComponent<Discovery> {
|
||||
|
||||
final ClusterBlock NO_MASTER_BLOCK = new ClusterBlock(2, "no master", ClusterBlockLevel.ALL);
|
||||
|
||||
DiscoveryNode localNode();
|
||||
|
||||
void addListener(InitialStateDiscoveryListener listener);
|
||||
|
|
|
@ -22,8 +22,6 @@ package org.elasticsearch.discovery.zen;
|
|||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.ElasticSearchIllegalStateException;
|
||||
import org.elasticsearch.cluster.*;
|
||||
import org.elasticsearch.cluster.block.ClusterBlock;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.block.ClusterBlocks;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
|
@ -63,8 +61,6 @@ import static org.elasticsearch.common.unit.TimeValue.*;
|
|||
*/
|
||||
public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implements Discovery, DiscoveryNodesProvider {
|
||||
|
||||
public final ClusterBlock NO_MASTER_BLOCK = new ClusterBlock(2, "no master", ClusterBlockLevel.ALL);
|
||||
|
||||
private final ThreadPool threadPool;
|
||||
|
||||
private final TransportService transportService;
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.common.io.FileSystemUtils;
|
|||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.*;
|
||||
import org.elasticsearch.discovery.Discovery;
|
||||
import org.elasticsearch.env.NodeEnvironment;
|
||||
import org.elasticsearch.gateway.Gateway;
|
||||
import org.elasticsearch.gateway.GatewayException;
|
||||
|
@ -222,7 +223,10 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> implements
|
|||
return;
|
||||
}
|
||||
|
||||
if (event.state().nodes().localNode().masterNode() && event.metaDataChanged()) {
|
||||
// we only write the local metadata if this is a possible master node, the metadata has changed, and
|
||||
// we don't have a NO_MASTER block (in which case, the routing is cleaned, and we don't want to override what
|
||||
// we have now, since it might be needed when later on performing full state recovery)
|
||||
if (event.state().nodes().localNode().masterNode() && event.metaDataChanged() && !event.state().blocks().hasGlobalBlock(Discovery.NO_MASTER_BLOCK)) {
|
||||
executor.execute(new Runnable() {
|
||||
@Override public void run() {
|
||||
LocalGatewayMetaState.Builder builder = LocalGatewayMetaState.builder();
|
||||
|
|
Loading…
Reference in New Issue