FS Gateway: Change indices location (Requires manual upgrade), closes #188.

This commit is contained in:
kimchy 2010-05-23 08:37:41 +03:00
parent 32829aeba5
commit 116cfce6f2
2 changed files with 7 additions and 13 deletions

View File

@ -41,29 +41,23 @@ import static org.elasticsearch.util.io.FileSystemUtils.*;
*/
public class FsIndexGateway extends AbstractIndexComponent implements IndexGateway {
private final Environment environment;
private final Gateway gateway;
private final String location;
private File indexGatewayHome;
@Inject public FsIndexGateway(Index index, @IndexSettings Settings indexSettings, Environment environment, Gateway gateway) {
super(index, indexSettings);
this.environment = environment;
this.gateway = gateway;
String location = componentSettings.get("location");
if (location == null) {
if (gateway instanceof FsGateway) {
indexGatewayHome = new File(((FsGateway) gateway).gatewayHome(), index().name());
indexGatewayHome = new File(new File(((FsGateway) gateway).gatewayHome(), "indices"), index.name());
} else {
indexGatewayHome = new File(new File(environment.workWithClusterFile(), "gateway"), index().name());
indexGatewayHome = new File(new File(new File(environment.workWithClusterFile(), "gateway"), "indices"), index.name());
}
location = Strings.cleanPath(indexGatewayHome.getAbsolutePath());
} else {
indexGatewayHome = new File(location);
indexGatewayHome = new File(new File(location), index.name());
}
this.location = location;

View File

@ -32,8 +32,8 @@ import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.util.logging.ESLogger;
import org.elasticsearch.util.logging.Loggers;
import org.elasticsearch.util.settings.Settings;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.elasticsearch.client.Requests.*;
@ -51,7 +51,7 @@ public class HdfsGatewayTests {
private Node node;
@BeforeTest void setUpNodes() throws Exception {
@BeforeMethod void setUpNodes() throws Exception {
node = buildNode();
((InternalNode) node).injector().getInstance(Gateway.class).reset();
node.start();
@ -66,7 +66,7 @@ public class HdfsGatewayTests {
return nodeBuilder().settings(settingsBuilder().put(settings).put("node.name", "node1")).build();
}
@AfterTest void closeNodes() throws Exception {
@AfterMethod void closeNodes() throws Exception {
((InternalNode) node).injector().getInstance(Gateway.class).reset();
node.close();
}