use of joptsimple.OptionSet in project voldemort by voldemort.
the class PartitionAnalysisCLI method main.
public static void main(String[] args) throws Exception {
setupParser();
OptionSet options = getValidOptions(args);
String clusterXML = (String) options.valueOf("cluster");
String storesXML = (String) options.valueOf("stores");
Cluster currentCluster = new ClusterMapper().readCluster(new File(clusterXML));
List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new File(storesXML));
PartitionBalance partitionBalance = new PartitionBalance(currentCluster, storeDefs);
System.out.println(partitionBalance);
}
use of joptsimple.OptionSet in project voldemort by voldemort.
the class RepartitionerCLI method main.
public static void main(String[] args) throws Exception {
setupParser();
OptionSet options = getValidOptions(args);
// Required args
String currentClusterXML = (String) options.valueOf("current-cluster");
String currentStoresXML = (String) options.valueOf("current-stores");
String interimClusterXML = new String(currentClusterXML);
if (options.has("interim-cluster")) {
interimClusterXML = (String) options.valueOf("interim-cluster");
}
String finalStoresXML = new String(currentStoresXML);
if (options.has("final-stores")) {
finalStoresXML = (String) options.valueOf("final-stores");
}
Cluster currentCluster = new ClusterMapper().readCluster(new File(currentClusterXML));
List<StoreDefinition> currentStoreDefs = new StoreDefinitionsMapper().readStoreList(new File(currentStoresXML));
RebalanceUtils.validateClusterStores(currentCluster, currentStoreDefs);
Cluster interimCluster = new ClusterMapper().readCluster(new File(interimClusterXML));
List<StoreDefinition> finalStoreDefs = new StoreDefinitionsMapper().readStoreList(new File(finalStoresXML));
RebalanceUtils.validateClusterStores(interimCluster, finalStoreDefs);
RebalanceUtils.validateCurrentInterimCluster(currentCluster, interimCluster);
// Optional administrivia args
int attempts = CmdUtils.valueOf(options, "attempts", Repartitioner.DEFAULT_REPARTITION_ATTEMPTS);
String outputDir = null;
if (options.has("output-dir")) {
outputDir = (String) options.valueOf("output-dir");
}
// Optional repartitioning args
boolean disableNodeBalancing = options.has("disable-node-balancing");
boolean disableZoneBalancing = options.has("disable-zone-balancing");
boolean enableRandomSwaps = options.has("enable-random-swaps");
int randomSwapAttempts = CmdUtils.valueOf(options, "random-swap-attempts", Repartitioner.DEFAULT_RANDOM_SWAP_ATTEMPTS);
int randomSwapSuccesses = CmdUtils.valueOf(options, "random-swap-successes", Repartitioner.DEFAULT_RANDOM_SWAP_SUCCESSES);
List<Integer> randomSwapZoneIds = CmdUtils.valuesOf(options, "random-swap-zoneids", Repartitioner.DEFAULT_RANDOM_SWAP_ZONE_IDS);
boolean enableGreedySwaps = options.has("enable-greedy-swaps");
int greedySwapAttempts = CmdUtils.valueOf(options, "greedy-swap-attempts", Repartitioner.DEFAULT_GREEDY_SWAP_ATTEMPTS);
int greedyMaxPartitionsPerNode = CmdUtils.valueOf(options, "greedy-max-partitions-per-node", Repartitioner.DEFAULT_GREEDY_MAX_PARTITIONS_PER_NODE);
int greedyMaxPartitionsPerZone = CmdUtils.valueOf(options, "greedy-max-partitions-per-zone", Repartitioner.DEFAULT_GREEDY_MAX_PARTITIONS_PER_ZONE);
List<Integer> greedySwapZoneIds = CmdUtils.valuesOf(options, "greedy-swap-zoneids", Repartitioner.DEFAULT_GREEDY_SWAP_ZONE_IDS);
int maxContiguousPartitionsPerZone = CmdUtils.valueOf(options, "max-contiguous-partitions", Repartitioner.DEFAULT_MAX_CONTIGUOUS_PARTITIONS);
// Sanity check optional repartitioning args
if (disableNodeBalancing && !enableRandomSwaps && !enableGreedySwaps && maxContiguousPartitionsPerZone == 0) {
printUsageAndDie("Did not enable any forms for repartitioning.");
}
if ((options.has("random-swap-attempts") || options.has("random-swap-successes")) && !enableRandomSwaps) {
printUsageAndDie("Provided arguments for generate random swaps but did not enable the feature");
}
if ((options.has("greedy-swap-attempts") || options.has("greedy-max-partitions-per-node") || options.has("greedy-max-partitions-per-zone")) && !enableGreedySwaps) {
printUsageAndDie("Provided arguments for generate greedy swaps but did not enable the feature");
}
Repartitioner.repartition(currentCluster, currentStoreDefs, interimCluster, finalStoreDefs, outputDir, attempts, disableNodeBalancing, disableZoneBalancing, enableRandomSwaps, randomSwapAttempts, randomSwapSuccesses, randomSwapZoneIds, enableGreedySwaps, greedySwapAttempts, greedyMaxPartitionsPerNode, greedyMaxPartitionsPerZone, greedySwapZoneIds, maxContiguousPartitionsPerZone);
}
use of joptsimple.OptionSet in project voldemort by voldemort.
the class RepartitionerCLI 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");
if (missing.size() > 0) {
printUsageAndDie("Missing required arguments: " + Joiner.on(", ").join(missing));
}
if (options.has("final-stores") && !options.has("interim-cluster")) {
printUsageAndDie("final-stores specified, but interim-cluster not specified.");
}
return options;
}
use of joptsimple.OptionSet in project voldemort by voldemort.
the class ReadOnlyReplicationHelperCLI method main.
public static void main(String[] args) throws Exception {
setupParser();
OptionSet options = getValidOptions(args);
// Required args
String url = (String) options.valueOf(OPT_URL);
Integer nodeId = (Integer) options.valueOf(OPT_NODE);
PrintStream outputStream;
if (options.has(OPT_OUTPUT)) {
String output = (String) options.valueOf(OPT_OUTPUT);
outputStream = new PrintStream(output);
} else {
outputStream = System.out;
}
Boolean local = options.has(OPT_LOCAL);
AdminClient adminClient = new AdminClient(url);
outputStream.println("src_host_name,src_node_id,src_rel_path,dest_rel_path");
List<String> infoList = getReadOnlyReplicationInfo(adminClient, nodeId, local);
for (String info : infoList) {
outputStream.println(info);
}
if (outputStream != System.out) {
outputStream.close();
}
}
use of joptsimple.OptionSet 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;
}
Aggregations