Skip to content
Snippets Groups Projects
Commit 3255b726 authored by Rob Adams's avatar Rob Adams
Browse files

Add delete node option and make it so you can set domain ID and seeds at the same time

parent ab43676d
No related branches found
No related tags found
No related merge requests found
package org.sdnplatform.sync.client;
import java.util.ArrayList;
import org.kohsuke.args4j.Option;
import org.sdnplatform.sync.IStoreClient;
import org.sdnplatform.sync.Versioned;
......@@ -56,6 +55,13 @@ public class BootstrapTool extends SyncClientBase {
"bootstrap process while retaining existing node IDs. " +
"The node will be put into its own local domain.")
protected boolean reseed;
@Option(name="--delete",
usage="Remove the specified node from the cluster. Note " +
"that if the node is still active it will rejoin " +
"automatically, so only run this once the node has " +
"been disabled.")
protected short deleteNode;
}
public BootstrapTool(BootstrapToolSettings bootstrapSettings) {
......@@ -72,21 +78,6 @@ public class BootstrapTool extends SyncClientBase {
syncManager.getStoreClient(SyncStoreCCProvider.
SYSTEM_NODE_STORE,
Short.class, Node.class);
Short localNodeId = null;
if (bSettings.reseed || bSettings.domainId != 0) {
String localNodeIdStr =
waitForValue(uStoreClient,
SyncStoreCCProvider.LOCAL_NODE_ID,
5000000);
if (localNodeIdStr == null) {
err.println("Error: Local node ID is not set; you must " +
"first seed the cluster by using the --seeds " +
"option");
System.exit(3);
}
localNodeId = Short.valueOf(localNodeIdStr);
}
if (bSettings.localNodeIface != null) {
while (true) {
......@@ -115,14 +106,6 @@ public class BootstrapTool extends SyncClientBase {
} catch (ObsoleteVersionException e) {}
}
}
if (bSettings.reseed) {
while (true) {
try {
nodeStoreClient.delete(localNodeId);
break;
} catch (ObsoleteVersionException e) { };
}
}
if (bSettings.seeds != null) {
String[] seedsStr = bSettings.seeds.split(",");
boolean seedsvalid = true;
......@@ -153,6 +136,28 @@ public class BootstrapTool extends SyncClientBase {
} catch (ObsoleteVersionException e) {}
}
}
Short localNodeId = null;
if (bSettings.reseed || bSettings.domainId != 0) {
String localNodeIdStr =
waitForValue(uStoreClient,
SyncStoreCCProvider.LOCAL_NODE_ID,
10000000000L);
if (localNodeIdStr == null) {
err.println("Error: Local node ID is not set; you must " +
"first seed the cluster by using the --seeds " +
"option");
System.exit(3);
}
localNodeId = Short.valueOf(localNodeIdStr);
}
if (bSettings.reseed) {
while (true) {
try {
nodeStoreClient.delete(localNodeId);
break;
} catch (ObsoleteVersionException e) { };
}
}
if (bSettings.domainId != 0) {
while (true) {
try {
......@@ -176,6 +181,14 @@ public class BootstrapTool extends SyncClientBase {
}
}
if (bSettings.deleteNode != 0) {
while (true) {
try {
nodeStoreClient.delete(bSettings.deleteNode);
break;
} catch (ObsoleteVersionException e) {}
}
}
}
private String waitForValue(IStoreClient<String, String> uStoreClient,
......
......@@ -138,7 +138,7 @@ public class BootstrapTest {
syncManagers.toArray(new SyncManager[syncManagers.size()]);
waitForFullMesh(syncManagerArr, 5000);
logger.info("Cluster successfully build. Attempting reseed");
logger.info("Cluster successfully built. Attempting reseed");
// Test reseeding
nodeStores.get(0).delete(nodeIds.get(0));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment