}
@SuppressWarnings("static-access")
private static Options constructCommandLineOptions()
{
Option helpOption =
OptionBuilder.withLongOpt(help)
.withDescription("Prints command-line options info")
.create();
Option zkServerOption =
OptionBuilder.withLongOpt(zkServerAddress)
.withDescription("Provide zookeeper address")
.create();
zkServerOption.setArgs(1);
zkServerOption.setRequired(true);
zkServerOption.setArgName("ZookeeperServerAddress(Required)");
Option listClustersOption =
OptionBuilder.withLongOpt(listClusters)
.withDescription("List existing clusters")
.create();
listClustersOption.setArgs(0);
listClustersOption.setRequired(false);
Option listResourceOption =
OptionBuilder.withLongOpt(listResources)
.withDescription("List resources hosted in a cluster")
.create();
listResourceOption.setArgs(1);
listResourceOption.setRequired(false);
listResourceOption.setArgName("clusterName");
Option listInstancesOption =
OptionBuilder.withLongOpt(listInstances)
.withDescription("List Instances in a cluster")
.create();
listInstancesOption.setArgs(1);
listInstancesOption.setRequired(false);
listInstancesOption.setArgName("clusterName");
Option addClusterOption =
OptionBuilder.withLongOpt(addCluster)
.withDescription("Add a new cluster")
.create();
addClusterOption.setArgs(1);
addClusterOption.setRequired(false);
addClusterOption.setArgName("clusterName");
Option activateClusterOption =
OptionBuilder.withLongOpt(activateCluster)
.withDescription("Enable/disable a cluster in distributed controller mode")
.create();
activateClusterOption.setArgs(3);
activateClusterOption.setRequired(false);
activateClusterOption.setArgName("clusterName grandCluster true/false");
Option deleteClusterOption =
OptionBuilder.withLongOpt(dropCluster)
.withDescription("Delete a cluster")
.create();
deleteClusterOption.setArgs(1);
deleteClusterOption.setRequired(false);
deleteClusterOption.setArgName("clusterName");
Option addInstanceOption =
OptionBuilder.withLongOpt(addInstance)
.withDescription("Add a new Instance to a cluster")
.create();
addInstanceOption.setArgs(2);
addInstanceOption.setRequired(false);
addInstanceOption.setArgName("clusterName InstanceAddress(host:port)");
Option addResourceOption =
OptionBuilder.withLongOpt(addResource)
.withDescription("Add a resource to a cluster")
.create();
addResourceOption.setArgs(4);
addResourceOption.setRequired(false);
addResourceOption.setArgName("clusterName resourceName partitionNum stateModelRef <-mode modeValue>");
Option expandResourceOption =
OptionBuilder.withLongOpt(expandResource)
.withDescription("Expand resource to additional nodes")
.create();
expandResourceOption.setArgs(2);
expandResourceOption.setRequired(false);
expandResourceOption.setArgName("clusterName resourceName");
Option expandClusterOption =
OptionBuilder.withLongOpt(expandCluster)
.withDescription("Expand a cluster and all the resources")
.create();
expandClusterOption.setArgs(1);
expandClusterOption.setRequired(false);
expandClusterOption.setArgName("clusterName");
Option resourceModeOption =
OptionBuilder.withLongOpt(mode)
.withDescription("Specify resource mode, used with addResourceGroup command")
.create();
resourceModeOption.setArgs(1);
resourceModeOption.setRequired(false);
resourceModeOption.setArgName("IdealState mode");
Option resourceBucketSizeOption =
OptionBuilder.withLongOpt(bucketSize)
.withDescription("Specify size of a bucket, used with addResourceGroup command")
.create();
resourceBucketSizeOption.setArgs(1);
resourceBucketSizeOption.setRequired(false);
resourceBucketSizeOption.setArgName("Size of a bucket for a resource");
Option resourceKeyOption =
OptionBuilder.withLongOpt(resourceKeyPrefix)
.withDescription("Specify resource key prefix, used with rebalance command")
.create();
resourceKeyOption.setArgs(1);
resourceKeyOption.setRequired(false);
resourceKeyOption.setArgName("Resource key prefix");
Option addStateModelDefOption =
OptionBuilder.withLongOpt(addStateModelDef)
.withDescription("Add a State model to a cluster")
.create();
addStateModelDefOption.setArgs(2);
addStateModelDefOption.setRequired(false);
addStateModelDefOption.setArgName("clusterName <filename>");
Option addIdealStateOption =
OptionBuilder.withLongOpt(addIdealState)
.withDescription("Add a State model to a cluster")
.create();
addIdealStateOption.setArgs(3);
addIdealStateOption.setRequired(false);
addIdealStateOption.setArgName("clusterName resourceName <filename>");
Option dropInstanceOption =
OptionBuilder.withLongOpt(dropInstance)
.withDescription("Drop an existing Instance from a cluster")
.create();
dropInstanceOption.setArgs(2);
dropInstanceOption.setRequired(false);
dropInstanceOption.setArgName("clusterName InstanceAddress(host:port)");
Option swapInstanceOption =
OptionBuilder.withLongOpt(swapInstance)
.withDescription("Swap an old instance from a cluster with a new instance")
.create();
swapInstanceOption.setArgs(3);
swapInstanceOption.setRequired(false);
swapInstanceOption.setArgName("clusterName oldInstance newInstance");
Option dropResourceOption =
OptionBuilder.withLongOpt(dropResource)
.withDescription("Drop an existing resource from a cluster")
.create();
dropResourceOption.setArgs(2);
dropResourceOption.setRequired(false);
dropResourceOption.setArgName("clusterName resourceName");
Option rebalanceOption =
OptionBuilder.withLongOpt(rebalance)
.withDescription("Rebalance a resource in a cluster")
.create();
rebalanceOption.setArgs(3);
rebalanceOption.setRequired(false);
rebalanceOption.setArgName("clusterName resourceName replicas");
Option instanceInfoOption =
OptionBuilder.withLongOpt(listInstanceInfo)
.withDescription("Query info of a Instance in a cluster")
.create();
instanceInfoOption.setArgs(2);
instanceInfoOption.setRequired(false);
instanceInfoOption.setArgName("clusterName InstanceName");
Option clusterInfoOption =
OptionBuilder.withLongOpt(listClusterInfo)
.withDescription("Query info of a cluster")
.create();
clusterInfoOption.setArgs(1);
clusterInfoOption.setRequired(false);
clusterInfoOption.setArgName("clusterName");
Option resourceInfoOption =
OptionBuilder.withLongOpt(listResourceInfo)
.withDescription("Query info of a resource")
.create();
resourceInfoOption.setArgs(2);
resourceInfoOption.setRequired(false);
resourceInfoOption.setArgName("clusterName resourceName");
Option addResourcePropertyOption =
OptionBuilder.withLongOpt(addResourceProperty)
.withDescription("Add a resource property")
.create();
addResourcePropertyOption.setArgs(4);
addResourcePropertyOption.setRequired(false);
addResourcePropertyOption.setArgName("clusterName resourceName propertyName propertyValue");
Option removeResourcePropertyOption =
OptionBuilder.withLongOpt(removeResourceProperty)
.withDescription("Remove a resource property")
.create();
removeResourcePropertyOption.setArgs(3);
removeResourcePropertyOption.setRequired(false);
removeResourcePropertyOption.setArgName("clusterName resourceName propertyName");
Option partitionInfoOption =
OptionBuilder.withLongOpt(listPartitionInfo)
.withDescription("Query info of a partition")
.create();
partitionInfoOption.setArgs(3);
partitionInfoOption.setRequired(false);
partitionInfoOption.setArgName("clusterName resourceName partitionName");
Option enableInstanceOption =
OptionBuilder.withLongOpt(enableInstance)
.withDescription("Enable/disable a Instance")
.create();
enableInstanceOption.setArgs(3);
enableInstanceOption.setRequired(false);
enableInstanceOption.setArgName("clusterName InstanceName true/false");
Option enablePartitionOption =
OptionBuilder.hasArgs()
.withLongOpt(enablePartition)
.withDescription("Enable/disable partitions")
.create();
enablePartitionOption.setRequired(false);
enablePartitionOption.setArgName("true/false clusterName instanceName resourceName partitionName1...");
Option enableClusterOption =
OptionBuilder.withLongOpt(enableCluster)
.withDescription("pause/resume the controller of a cluster")
.create();
enableClusterOption.setArgs(2);
enableClusterOption.setRequired(false);
enableClusterOption.setArgName("clusterName true/false");
Option resetPartitionOption =
OptionBuilder.withLongOpt(resetPartition)
.withDescription("Reset a partition in error state")
.create();
resetPartitionOption.setArgs(4);
resetPartitionOption.setRequired(false);
resetPartitionOption.setArgName("clusterName instanceName resourceName partitionName");
Option resetInstanceOption =
OptionBuilder.withLongOpt(resetInstance)
.withDescription("Reset all partitions in error state for an instance")
.create();
resetInstanceOption.setArgs(2);
resetInstanceOption.setRequired(false);
resetInstanceOption.setArgName("clusterName instanceName");
Option resetResourceOption =
OptionBuilder.withLongOpt(resetResource)
.withDescription("Reset all partitions in error state for a resource")
.create();
resetResourceOption.setArgs(2);
resetResourceOption.setRequired(false);
resetResourceOption.setArgName("clusterName resourceName");
Option listStateModelsOption =
OptionBuilder.withLongOpt(listStateModels)
.withDescription("Query info of state models in a cluster")
.create();
listStateModelsOption.setArgs(1);
listStateModelsOption.setRequired(false);
listStateModelsOption.setArgName("clusterName");
Option listStateModelOption =
OptionBuilder.withLongOpt(listStateModel)
.withDescription("Query info of a state model in a cluster")
.create();
listStateModelOption.setArgs(2);
listStateModelOption.setRequired(false);
listStateModelOption.setArgName("clusterName stateModelName");
Option addStatOption =
OptionBuilder.withLongOpt(addStat)
.withDescription("Add a persistent stat")
.create();
addStatOption.setArgs(2);
addStatOption.setRequired(false);
addStatOption.setArgName("clusterName statName");
Option addAlertOption =
OptionBuilder.withLongOpt(addAlert).withDescription("Add an alert").create();
addAlertOption.setArgs(2);
addAlertOption.setRequired(false);
addAlertOption.setArgName("clusterName alertName");
Option dropStatOption =
OptionBuilder.withLongOpt(dropStat)
.withDescription("Drop a persistent stat")
.create();
dropStatOption.setArgs(2);
dropStatOption.setRequired(false);
dropStatOption.setArgName("clusterName statName");
Option dropAlertOption =
OptionBuilder.withLongOpt(dropAlert).withDescription("Drop an alert").create();
dropAlertOption.setArgs(2);
dropAlertOption.setRequired(false);
dropAlertOption.setArgName("clusterName alertName");
// set/get configs option
Option setConfOption =
OptionBuilder.withLongOpt(setConfig).withDescription("Set a config").create();
setConfOption.setArgs(2);
setConfOption.setRequired(false);
setConfOption.setArgName("ConfigScope(e.g. CLUSTER=cluster,RESOURCE=rc,...) KeyValueMap(e.g. k1=v1,k2=v2,...)");
Option getConfOption =
OptionBuilder.withLongOpt(getConfig).withDescription("Get a config").create();
getConfOption.setArgs(2);
getConfOption.setRequired(false);
getConfOption.setArgName("ConfigScope(e.g. CLUSTER=cluster,RESOURCE=rc,...) KeySet(e.g. k1,k2,...)");
OptionGroup group = new OptionGroup();
group.setRequired(true);
group.addOption(rebalanceOption);
group.addOption(addResourceOption);