change nodeFile to nodeLocation

This commit is contained in:
kimchy 2010-08-29 23:25:23 +03:00
parent 5b5d42445d
commit 8ed54c24bd
4 changed files with 6 additions and 9 deletions

View File

@ -89,7 +89,7 @@ public class NodeEnvironment extends AbstractComponent {
return nodeFile != null && lock != null; return nodeFile != null && lock != null;
} }
public File nodeFile() { public File nodeLocation() {
if (nodeFile == null || lock == null) { if (nodeFile == null || lock == null) {
throw new ElasticSearchIllegalStateException("node is not configured to store local location"); throw new ElasticSearchIllegalStateException("node is not configured to store local location");
} }

View File

@ -48,7 +48,6 @@ import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.gateway.Gateway; import org.elasticsearch.gateway.Gateway;
import org.elasticsearch.gateway.GatewayException; import org.elasticsearch.gateway.GatewayException;
import org.elasticsearch.index.gateway.local.LocalIndexGatewayModule; import org.elasticsearch.index.gateway.local.LocalIndexGatewayModule;
import org.elasticsearch.threadpool.ThreadPool;
import java.io.*; import java.io.*;
import java.util.Map; import java.util.Map;
@ -68,8 +67,6 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> implements
private File location; private File location;
private final ClusterName clusterName;
private final ClusterService clusterService; private final ClusterService clusterService;
private final NodeEnvironment nodeEnv; private final NodeEnvironment nodeEnv;
@ -81,9 +78,8 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> implements
private volatile LocalGatewayState currentState; private volatile LocalGatewayState currentState;
@Inject public LocalGateway(Settings settings, ClusterService clusterService, MetaDataCreateIndexService createIndexService, @Inject public LocalGateway(Settings settings, ClusterService clusterService, MetaDataCreateIndexService createIndexService,
NodeEnvironment nodeEnv, ClusterName clusterName, ThreadPool threadPool, TransportNodesListGatewayState listGatewayState) { NodeEnvironment nodeEnv, TransportNodesListGatewayState listGatewayState) {
super(settings); super(settings);
this.clusterName = clusterName;
this.clusterService = clusterService; this.clusterService = clusterService;
this.createIndexService = createIndexService; this.createIndexService = createIndexService;
this.nodeEnv = nodeEnv; this.nodeEnv = nodeEnv;
@ -105,7 +101,7 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> implements
return; return;
} }
// create the location where the state will be stored // create the location where the state will be stored
this.location = new File(nodeEnv.nodeFile(), "_state"); this.location = new File(nodeEnv.nodeLocation(), "_state");
this.location.mkdirs(); this.location.mkdirs();
try { try {
@ -199,6 +195,7 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> implements
} }
@Override public void reset() throws Exception { @Override public void reset() throws Exception {
FileSystemUtils.deleteRecursively(nodeEnv.nodeLocation());
} }
@Override public void clusterChanged(final ClusterChangedEvent event) { @Override public void clusterChanged(final ClusterChangedEvent event) {

View File

@ -47,7 +47,7 @@ public abstract class FsIndexStore extends AbstractIndexStore {
public FsIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService, NodeEnvironment nodeEnv) { public FsIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService, NodeEnvironment nodeEnv) {
super(index, indexSettings, indexService); super(index, indexSettings, indexService);
if (nodeEnv.hasNodeFile()) { if (nodeEnv.hasNodeFile()) {
this.location = new File(new File(nodeEnv.nodeFile(), "indices"), index.name()); this.location = new File(new File(nodeEnv.nodeLocation(), "indices"), index.name());
} else { } else {
this.location = null; this.location = null;
} }

View File

@ -59,7 +59,7 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog
@Inject public FsTranslog(ShardId shardId, @IndexSettings Settings indexSettings, NodeEnvironment nodeEnv) { @Inject public FsTranslog(ShardId shardId, @IndexSettings Settings indexSettings, NodeEnvironment nodeEnv) {
super(shardId, indexSettings); super(shardId, indexSettings);
this.location = new File(new File(new File(new File(nodeEnv.nodeFile(), "indices"), shardId.index().name()), Integer.toString(shardId.id())), "translog"); this.location = new File(new File(new File(new File(nodeEnv.nodeLocation(), "indices"), shardId.index().name()), Integer.toString(shardId.id())), "translog");
this.location.mkdirs(); this.location.mkdirs();
this.useStream = componentSettings.getAsBoolean("use_stream", false); this.useStream = componentSettings.getAsBoolean("use_stream", false);
} }