|
@@ -396,49 +396,6 @@ public class NodeEnvironmentTests extends ESTestCase {
|
|
|
env.close();
|
|
|
}
|
|
|
|
|
|
- public void testWhetherClusterFolderShouldBeUsed() throws Exception {
|
|
|
- Path tempNoCluster = createTempDir();
|
|
|
- Path tempDataPath = tempNoCluster.toAbsolutePath();
|
|
|
-
|
|
|
- Path tempPath = tempNoCluster.resolve("foo"); // "foo" is the cluster name
|
|
|
- Path tempClusterPath = tempPath.toAbsolutePath();
|
|
|
-
|
|
|
- assertFalse("non-existent directory should not be used", NodeEnvironment.readFromDataPathWithClusterName(tempPath));
|
|
|
- Settings settings = Settings.builder()
|
|
|
- .put("cluster.name", "foo")
|
|
|
- .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toAbsolutePath().toString())
|
|
|
- .put(Environment.PATH_DATA_SETTING.getKey(), tempDataPath.toString()).build();
|
|
|
- try (NodeEnvironment env = new NodeEnvironment(settings, new Environment(settings))) {
|
|
|
- Path nodeDataPath = env.nodeDataPaths()[0];
|
|
|
- assertEquals(nodeDataPath, tempDataPath.resolve("nodes").resolve("0"));
|
|
|
- }
|
|
|
- IOUtils.rm(tempNoCluster);
|
|
|
-
|
|
|
- Files.createDirectories(tempPath);
|
|
|
- assertFalse("empty directory should not be read from", NodeEnvironment.readFromDataPathWithClusterName(tempPath));
|
|
|
- settings = Settings.builder()
|
|
|
- .put("cluster.name", "foo")
|
|
|
- .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toAbsolutePath().toString())
|
|
|
- .put(Environment.PATH_DATA_SETTING.getKey(), tempDataPath.toString()).build();
|
|
|
- try (NodeEnvironment env = new NodeEnvironment(settings, new Environment(settings))) {
|
|
|
- Path nodeDataPath = env.nodeDataPaths()[0];
|
|
|
- assertEquals(nodeDataPath, tempDataPath.resolve("nodes").resolve("0"));
|
|
|
- }
|
|
|
- IOUtils.rm(tempNoCluster);
|
|
|
-
|
|
|
- // Create a directory for the cluster name
|
|
|
- Files.createDirectories(tempPath.resolve(NodeEnvironment.NODES_FOLDER));
|
|
|
- assertTrue("there is data in the directory", NodeEnvironment.readFromDataPathWithClusterName(tempPath));
|
|
|
- settings = Settings.builder()
|
|
|
- .put("cluster.name", "foo")
|
|
|
- .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toAbsolutePath().toString())
|
|
|
- .put(Environment.PATH_DATA_SETTING.getKey(), tempClusterPath.toString()).build();
|
|
|
- try (NodeEnvironment env = new NodeEnvironment(settings, new Environment(settings))) {
|
|
|
- Path nodeDataPath = env.nodeDataPaths()[0];
|
|
|
- assertEquals(nodeDataPath, tempClusterPath.resolve("nodes").resolve("0"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public void testPersistentNodeId() throws IOException {
|
|
|
String[] paths = tmpPaths();
|
|
|
NodeEnvironment env = newNodeEnvironment(paths, Settings.builder()
|