new local gateway should only load state if its data (for shards state) or master (for metadata) and not try and load if its not (so we don't load if its a client node)
This commit is contained in:
parent
f282081361
commit
e0508809cb
|
@ -37,8 +37,6 @@ import static org.elasticsearch.common.transport.TransportAddressSerializers.add
|
|||
|
||||
/**
|
||||
* A discovery node represents a node that is part of the cluster.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DiscoveryNode implements Streamable, Serializable {
|
||||
|
||||
|
@ -46,6 +44,27 @@ public class DiscoveryNode implements Streamable, Serializable {
|
|||
return !(settings.getAsBoolean("node.client", false) || (!settings.getAsBoolean("node.data", true) && !settings.getAsBoolean("node.master", true)));
|
||||
}
|
||||
|
||||
public static boolean clientNode(Settings settings) {
|
||||
String client = settings.get("node.client");
|
||||
return client != null && client.equals("true");
|
||||
}
|
||||
|
||||
public static boolean masterNode(Settings settings) {
|
||||
String master = settings.get("node.master");
|
||||
if (master == null) {
|
||||
return !clientNode(settings);
|
||||
}
|
||||
return master.equals("true");
|
||||
}
|
||||
|
||||
public static boolean dataNode(Settings settings) {
|
||||
String data = settings.get("data");
|
||||
if (data == null) {
|
||||
return !clientNode(settings);
|
||||
}
|
||||
return data.equals("true");
|
||||
}
|
||||
|
||||
public static final ImmutableList<DiscoveryNode> EMPTY_LIST = ImmutableList.of();
|
||||
|
||||
private String nodeName = "".intern();
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterChangedEvent;
|
|||
import org.elasticsearch.cluster.ClusterStateListener;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -73,14 +74,16 @@ public class LocalGatewayMetaState extends AbstractComponent implements ClusterS
|
|||
formatParams = ToXContent.EMPTY_PARAMS;
|
||||
}
|
||||
|
||||
try {
|
||||
pre019Upgrade();
|
||||
long start = System.currentTimeMillis();
|
||||
loadState();
|
||||
logger.debug("took {} to load state", TimeValue.timeValueMillis(System.currentTimeMillis() - start));
|
||||
} catch (Exception e) {
|
||||
logger.error("failed to read local state, exiting...", e);
|
||||
throw e;
|
||||
if (DiscoveryNode.masterNode(settings)) {
|
||||
try {
|
||||
pre019Upgrade();
|
||||
long start = System.currentTimeMillis();
|
||||
loadState();
|
||||
logger.debug("took {} to load state", TimeValue.timeValueMillis(System.currentTimeMillis() - start));
|
||||
} catch (Exception e) {
|
||||
logger.error("failed to read local state, exiting...", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.google.common.collect.Maps;
|
|||
import com.google.common.io.Closeables;
|
||||
import org.elasticsearch.cluster.ClusterChangedEvent;
|
||||
import org.elasticsearch.cluster.ClusterStateListener;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.routing.*;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
|
@ -62,14 +63,16 @@ public class LocalGatewayShardsState extends AbstractComponent implements Cluste
|
|||
this.nodeEnv = nodeEnv;
|
||||
listGatewayStartedShards.initGateway(this);
|
||||
|
||||
try {
|
||||
pre019Upgrade();
|
||||
long start = System.currentTimeMillis();
|
||||
loadStartedShards();
|
||||
logger.debug("took {} to load started shards state", TimeValue.timeValueMillis(System.currentTimeMillis() - start));
|
||||
} catch (Exception e) {
|
||||
logger.error("failed to read local state (started shards), exiting...", e);
|
||||
throw e;
|
||||
if (DiscoveryNode.dataNode(settings)) {
|
||||
try {
|
||||
pre019Upgrade();
|
||||
long start = System.currentTimeMillis();
|
||||
loadStartedShards();
|
||||
logger.debug("took {} to load started shards state", TimeValue.timeValueMillis(System.currentTimeMillis() - start));
|
||||
} catch (Exception e) {
|
||||
logger.error("failed to read local state (started shards), exiting...", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue