[TEST] Register data.path for all nodes on close in InternalTestCluster

We need to register those data paths otherwise we might miss path that
need to get cleaned when using local gatway etc. which can otherwise
cause imports of dangeling indices.
This commit is contained in:
Simon Willnauer 2014-11-17 22:08:09 +01:00
parent 2f40b464ad
commit c6c709eda2
1 changed files with 17 additions and 5 deletions

View File

@ -784,11 +784,16 @@ public final class InternalTestCluster extends TestCluster {
transportClient = null; transportClient = null;
} }
void closeNode() {
registerDataPath();
node.close();
}
void restart(RestartCallback callback) throws Exception { void restart(RestartCallback callback) throws Exception {
assert callback != null; assert callback != null;
resetClient(); resetClient();
if (!node.isClosed()) { if (!node.isClosed()) {
node.close(); closeNode();
} }
Settings newSettings = callback.onNodeStopped(name); Settings newSettings = callback.onNodeStopped(name);
if (newSettings == null) { if (newSettings == null) {
@ -797,18 +802,25 @@ public final class InternalTestCluster extends TestCluster {
if (callback.clearData(name)) { if (callback.clearData(name)) {
NodeEnvironment nodeEnv = getInstanceFromNode(NodeEnvironment.class, node); NodeEnvironment nodeEnv = getInstanceFromNode(NodeEnvironment.class, node);
if (nodeEnv.hasNodeFile()) { if (nodeEnv.hasNodeFile()) {
IOUtils.rm(FileSystemUtils.toPaths(nodeEnv.nodeDataLocations())); IOUtils.rm(nodeEnv.nodeDataPaths());
} }
} }
node = (InternalNode) nodeBuilder().settings(node.settings()).settings(newSettings).node(); node = (InternalNode) nodeBuilder().settings(node.settings()).settings(newSettings).node();
} }
void registerDataPath() {
NodeEnvironment nodeEnv = getInstanceFromNode(NodeEnvironment.class, node);
if (nodeEnv.hasNodeFile()) {
dataDirToClean.addAll(Arrays.asList(nodeEnv.nodeDataPaths()));
}
}
@Override @Override
public void close() throws IOException { public void close() throws IOException {
resetClient(); resetClient();
closed.set(true); closed.set(true);
node.close(); closeNode();
} }
} }
@ -1205,7 +1217,7 @@ public final class InternalTestCluster extends TestCluster {
if (activeDisruptionScheme != null) { if (activeDisruptionScheme != null) {
activeDisruptionScheme.removeFromNode(nodeAndClient.name, this); activeDisruptionScheme.removeFromNode(nodeAndClient.name, this);
} }
nodeAndClient.node.close(); nodeAndClient.closeNode();
} }
for (NodeAndClient nodeAndClient : nodes.values()) { for (NodeAndClient nodeAndClient : nodes.values()) {
logger.info("Starting node [{}] ", nodeAndClient.name); logger.info("Starting node [{}] ", nodeAndClient.name);
@ -1413,7 +1425,7 @@ public final class InternalTestCluster extends TestCluster {
assert !nodeAndClient.node().isClosed(); assert !nodeAndClient.node().isClosed();
NodeEnvironment nodeEnv = getInstanceFromNode(NodeEnvironment.class, nodeAndClient.node); NodeEnvironment nodeEnv = getInstanceFromNode(NodeEnvironment.class, nodeAndClient.node);
if (nodeEnv.hasNodeFile()) { if (nodeEnv.hasNodeFile()) {
dataDirToClean.addAll(Arrays.asList(FileSystemUtils.toPaths(nodeEnv.nodeDataLocations()))); dataDirToClean.addAll(Arrays.asList(nodeEnv.nodeDataPaths()));
} }
nodes.put(nodeAndClient.name, nodeAndClient); nodes.put(nodeAndClient.name, nodeAndClient);
applyDisruptionSchemeToNode(nodeAndClient); applyDisruptionSchemeToNode(nodeAndClient);