FS Gateway: Change indices location (Requires manual upgrade), closes #188.
This commit is contained in:
parent
32829aeba5
commit
116cfce6f2
|
@ -41,29 +41,23 @@ import static org.elasticsearch.util.io.FileSystemUtils.*;
|
||||||
*/
|
*/
|
||||||
public class FsIndexGateway extends AbstractIndexComponent implements IndexGateway {
|
public class FsIndexGateway extends AbstractIndexComponent implements IndexGateway {
|
||||||
|
|
||||||
private final Environment environment;
|
|
||||||
|
|
||||||
private final Gateway gateway;
|
|
||||||
|
|
||||||
private final String location;
|
private final String location;
|
||||||
|
|
||||||
private File indexGatewayHome;
|
private File indexGatewayHome;
|
||||||
|
|
||||||
@Inject public FsIndexGateway(Index index, @IndexSettings Settings indexSettings, Environment environment, Gateway gateway) {
|
@Inject public FsIndexGateway(Index index, @IndexSettings Settings indexSettings, Environment environment, Gateway gateway) {
|
||||||
super(index, indexSettings);
|
super(index, indexSettings);
|
||||||
this.environment = environment;
|
|
||||||
this.gateway = gateway;
|
|
||||||
|
|
||||||
String location = componentSettings.get("location");
|
String location = componentSettings.get("location");
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
if (gateway instanceof FsGateway) {
|
if (gateway instanceof FsGateway) {
|
||||||
indexGatewayHome = new File(((FsGateway) gateway).gatewayHome(), index().name());
|
indexGatewayHome = new File(new File(((FsGateway) gateway).gatewayHome(), "indices"), index.name());
|
||||||
} else {
|
} 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());
|
location = Strings.cleanPath(indexGatewayHome.getAbsolutePath());
|
||||||
} else {
|
} else {
|
||||||
indexGatewayHome = new File(location);
|
indexGatewayHome = new File(new File(location), index.name());
|
||||||
}
|
}
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ import org.elasticsearch.node.internal.InternalNode;
|
||||||
import org.elasticsearch.util.logging.ESLogger;
|
import org.elasticsearch.util.logging.ESLogger;
|
||||||
import org.elasticsearch.util.logging.Loggers;
|
import org.elasticsearch.util.logging.Loggers;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterMethod;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.client.Requests.*;
|
import static org.elasticsearch.client.Requests.*;
|
||||||
|
@ -51,7 +51,7 @@ public class HdfsGatewayTests {
|
||||||
|
|
||||||
private Node node;
|
private Node node;
|
||||||
|
|
||||||
@BeforeTest void setUpNodes() throws Exception {
|
@BeforeMethod void setUpNodes() throws Exception {
|
||||||
node = buildNode();
|
node = buildNode();
|
||||||
((InternalNode) node).injector().getInstance(Gateway.class).reset();
|
((InternalNode) node).injector().getInstance(Gateway.class).reset();
|
||||||
node.start();
|
node.start();
|
||||||
|
@ -66,7 +66,7 @@ public class HdfsGatewayTests {
|
||||||
return nodeBuilder().settings(settingsBuilder().put(settings).put("node.name", "node1")).build();
|
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();
|
((InternalNode) node).injector().getInstance(Gateway.class).reset();
|
||||||
node.close();
|
node.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue