diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGateway.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGateway.java index 471862020bc..623115c1485 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGateway.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGateway.java @@ -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; diff --git a/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java b/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java index b6518073ab5..a16bcc1b785 100644 --- a/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java +++ b/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java @@ -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(); }