Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move GatewayShardsState logic into IndexShard #10093

Merged
merged 1 commit into from
Mar 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -301,19 +301,21 @@ public boolean equals(Object o) {
if (shardId != that.shardId) {
return false;
}
if (currentNodeId != null ? !currentNodeId.equals(that.currentNodeId) : that.currentNodeId != null)
if (currentNodeId != null ? !currentNodeId.equals(that.currentNodeId) : that.currentNodeId != null) {
return false;
}
if (index != null ? !index.equals(that.index) : that.index != null) {
return false;
}
if (relocatingNodeId != null ? !relocatingNodeId.equals(that.relocatingNodeId) : that.relocatingNodeId != null)
if (relocatingNodeId != null ? !relocatingNodeId.equals(that.relocatingNodeId) : that.relocatingNodeId != null) {
return false;
}
if (state != that.state) {
return false;
}
if (restoreSource != null ? !restoreSource.equals(that.restoreSource) : that.restoreSource != null)
if (restoreSource != null ? !restoreSource.equals(that.restoreSource) : that.restoreSource != null) {
return false;

}
return true;
}

Expand Down
8 changes: 2 additions & 6 deletions src/main/java/org/elasticsearch/gateway/Gateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.indices.IndicesService;

import java.nio.file.Path;

Expand All @@ -43,7 +44,6 @@ public class Gateway extends AbstractComponent implements ClusterStateListener {

private final NodeEnvironment nodeEnv;

private final GatewayShardsState shardsState;
private final GatewayMetaState metaState;

private final TransportNodesListGatewayMetaState listGatewayMetaState;
Expand All @@ -52,8 +52,7 @@ public class Gateway extends AbstractComponent implements ClusterStateListener {
private final ClusterName clusterName;

@Inject
public Gateway(Settings settings, ClusterService clusterService, NodeEnvironment nodeEnv,
GatewayShardsState shardsState, GatewayMetaState metaState,
public Gateway(Settings settings, ClusterService clusterService, NodeEnvironment nodeEnv, GatewayMetaState metaState,
TransportNodesListGatewayMetaState listGatewayMetaState, ClusterName clusterName) {
super(settings);
this.clusterService = clusterService;
Expand All @@ -62,8 +61,6 @@ public Gateway(Settings settings, ClusterService clusterService, NodeEnvironment
this.listGatewayMetaState = listGatewayMetaState;
this.clusterName = clusterName;

this.shardsState = shardsState;

clusterService.addLast(this);

// we define what is our minimum "master" nodes, use that to allow for recovery
Expand Down Expand Up @@ -180,7 +177,6 @@ public void clusterChanged(final ClusterChangedEvent event) {
// order is important, first metaState, and then shardsState
// so dangling indices will be recorded
metaState.clusterChanged(event);
shardsState.clusterChanged(event);
}

public interface GatewayStateRecoveredListener {
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/org/elasticsearch/gateway/GatewayMetaState.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.discovery.Discovery;
import org.elasticsearch.env.NodeEnvironment;

import java.io.IOException;
Expand Down Expand Up @@ -68,6 +69,9 @@ public GatewayMetaState(Settings settings, NodeEnvironment nodeEnv, MetaStateSer
this.danglingIndicesState = danglingIndicesState;
nodesListGatewayMetaState.init(this);

if (DiscoveryNode.dataNode(settings)) {
ensureNoPre019ShardState(nodeEnv);
}

if (DiscoveryNode.masterNode(settings) || DiscoveryNode.dataNode(settings)) {
nodeEnv.ensureAtomicMoveSupported();
Expand Down Expand Up @@ -230,4 +234,21 @@ private void pre20Upgrade() throws Exception {
+ "used some custom routing logic, you can now remove these settings from your `elasticsearch.yml` file", DEPRECATED_SETTING_ROUTING_HASH_FUNCTION, DEPRECATED_SETTING_ROUTING_USE_TYPE);
}
}


// shard state BWC
private void ensureNoPre019ShardState(NodeEnvironment nodeEnv) throws Exception {
for (Path dataLocation : nodeEnv.nodeDataPaths()) {
final Path stateLocation = dataLocation.resolve(MetaDataStateFormat.STATE_DIR_NAME);
if (Files.exists(stateLocation)) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(stateLocation, "shards-*")) {
for (Path stateFile : stream) {
throw new ElasticsearchIllegalStateException("Detected pre 0.19 shard state file please upgrade to a version before "
+ Version.CURRENT.minimumCompatibilityVersion()
+ " first to upgrade state structures - shard state found: [" + stateFile.getParent().toAbsolutePath());
}
}
}
}
}
}
1 change: 0 additions & 1 deletion src/main/java/org/elasticsearch/gateway/GatewayModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ protected void configure() {
bind(DanglingIndicesState.class).asEagerSingleton();
bind(GatewayService.class).asEagerSingleton();
bind(Gateway.class).asEagerSingleton();
bind(GatewayShardsState.class).asEagerSingleton();
bind(TransportNodesListGatewayMetaState.class).asEagerSingleton();
bind(GatewayMetaState.class).asEagerSingleton();
bind(TransportNodesListGatewayStartedShards.class).asEagerSingleton();
Expand Down
275 changes: 0 additions & 275 deletions src/main/java/org/elasticsearch/gateway/GatewayShardsState.java

This file was deleted.