use of joptsimple.OptionException in project voldemort by voldemort.
the class RebalanceControllerCLI method getValidOptions.
private static OptionSet getValidOptions(String[] args) {
OptionSet options = null;
try {
options = parser.parse(args);
} catch (OptionException oe) {
printUsageAndDie("Exception when parsing arguments : " + oe.getMessage());
}
if (options.has("help")) {
printUsage();
System.exit(0);
}
Set<String> missing = CmdUtils.missing(options, "url", "final-cluster");
if (missing.size() > 0) {
printUsageAndDie("Missing required arguments: " + Joiner.on(", ").join(missing));
}
return options;
}
use of joptsimple.OptionException in project voldemort by voldemort.
the class RebalancePlanCLI method getValidOptions.
private static OptionSet getValidOptions(String[] args) {
OptionSet options = null;
try {
options = parser.parse(args);
} catch (OptionException oe) {
printUsageAndDie("Exception when parsing arguments : " + oe.getMessage());
}
if (options.has("help")) {
printUsage();
System.exit(0);
}
Set<String> missing = CmdUtils.missing(options, "current-cluster", "current-stores", "final-cluster");
if (missing.size() > 0) {
printUsageAndDie("Missing required arguments: " + Joiner.on(", ").join(missing));
}
if (options.has("final-stores") && !options.has("final-cluster")) {
printUsageAndDie("final-stores specified, but final-cluster not specified.");
}
return options;
}
use of joptsimple.OptionException in project voldemort by voldemort.
the class DeleteKeysCLI method main.
public static void main(String[] args) throws Exception {
OptionParser parser = null;
OptionSet options = null;
try {
parser = setupParser();
options = parser.parse(args);
} catch (OptionException oe) {
parser.printHelpOn(System.out);
printUsageAndDie("Exception when parsing arguments : " + oe.getMessage());
return;
}
/* validate options */
if (options.has("help")) {
printUsage();
return;
}
if (!options.hasArgument("url") || !options.hasArgument("stores") || !options.hasArgument("keyfile")) {
printUsageAndDie("Missing a required argument.");
return;
}
boolean deleteAllVersions = options.has("delete-all-versions");
System.out.println("New Delete All versions value " + deleteAllVersions);
String url = (String) options.valueOf("url");
String keyFile = (String) options.valueOf("keyfile");
keyFile.replace("~", System.getProperty("user.home"));
int zoneId = Zone.DEFAULT_ZONE_ID;
if (options.hasArgument("zone")) {
zoneId = ((Integer) options.valueOf("zone")).intValue();
}
int qps = ((Integer) options.valueOf("qps")).intValue();
int nodeid = ((Integer) options.valueOf("nodeid")).intValue();
String adminUrl = "";
if (nodeid != -1) {
adminUrl = (String) options.valueOf("admin-url");
}
List<String> stores = null;
if (options.hasArgument("stores")) {
@SuppressWarnings("unchecked") List<String> list = (List<String>) options.valuesOf("stores");
stores = list;
}
int checkKeysCount = 0;
if (options.hasArgument("check-keys-exist")) {
checkKeysCount = ((Integer) options.valueOf("check-keys-exist")).intValue();
if (checkKeysCount <= 0) {
throw new Exception("Expect a positive value for check-keys-exist");
}
}
DeleteKeysCLI deleteKeysCLI = new DeleteKeysCLI(url, adminUrl, stores, keyFile, zoneId, qps, nodeid, deleteAllVersions, checkKeysCount);
deleteKeysCLI.deleteKeys();
}
use of joptsimple.OptionException in project voldemort by voldemort.
the class ValidateNodeIdCLI method main.
public static void main(String[] args) throws IOException {
OptionParser parser = null;
OptionSet options = null;
try {
parser = setupParser();
options = parser.parse(args);
} catch (OptionException oe) {
parser.printHelpOn(System.out);
printUsageAndDie("Exception when parsing arguments : " + oe.getMessage());
return;
}
/* validate options */
if (options.has("help")) {
printUsage();
return;
}
if (!options.hasArgument("id") || !options.hasArgument("path")) {
printUsageAndDie("Missing a required argument.");
return;
}
String id = (String) options.valueOf("id");
int expectedNodeId = Integer.parseInt(id);
String clusterPaths = getFilePath(options, "path");
String[] allPaths = clusterPaths.split(",");
boolean isMatch = false;
for (String path : allPaths) {
path = path.replace("~", System.getProperty("user.home"));
File filePath = new File(path);
if (filePath.exists()) {
isMatch = true;
Cluster cluster = getCluster(filePath);
Properties properties = new Properties();
properties.setProperty(VoldemortConfig.ENABLE_NODE_ID_DETECTION, Boolean.toString(true));
properties.setProperty(VoldemortConfig.VOLDEMORT_HOME, getTempDirPath());
VoldemortConfig config = new VoldemortConfig(properties);
int actualNodeId = VoldemortServer.getNodeId(config, cluster);
if (actualNodeId != expectedNodeId) {
throw new VoldemortApplicationException("Mismatch detected. Computed Node Id " + actualNodeId + " Expected " + expectedNodeId);
} else {
System.out.println("Expected and Computed node Id matched " + expectedNodeId);
}
config.setNodeId(actualNodeId);
VoldemortServer.validateNodeId(config, cluster);
System.out.println("Validation of node Id passed");
}
}
if (!isMatch) {
throw new VoldemortApplicationException("None of the paths matched the cluster.xml");
}
}
use of joptsimple.OptionException in project voldemort by voldemort.
the class ZoneClipperCLI method getValidOptions.
private static OptionSet getValidOptions(String[] args) {
OptionSet options = null;
try {
options = parser.parse(args);
} catch (OptionException oe) {
printUsageAndDie("Exception when parsing arguments : " + oe.getMessage());
}
if (options.has("help")) {
printUsage();
System.exit(0);
}
Set<String> missing = CmdUtils.missing(options, "current-cluster", "current-stores", "drop-zoneid");
if (missing.size() > 0) {
printUsageAndDie("Missing required arguments: " + Joiner.on(", ").join(missing));
}
return options;
}
Aggregations