private static final String ALL_METADATA = "all";
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
OptionParser parser = new OptionParser();
// This is a generic argument that should be eventually supported by all
// RW operations.
// If you omit this argument the operation will be executed in a "batch"
// mode which is useful for scripting
// Otherwise you will be presented with a summary of changes and with a
// Y/N prompt
parser.accepts("auto", "[OPTIONAL] enable auto/batch mode");
parser.accepts("help", "print help information");
parser.accepts("url", "[REQUIRED] bootstrap URL")
.withRequiredArg()
.describedAs("bootstrap-url")
.ofType(String.class);
parser.accepts("node", "node id")
.withRequiredArg()
.describedAs("node-id")
.ofType(Integer.class);
parser.accepts("delete-partitions", "Delete partitions")
.withRequiredArg()
.describedAs("partition-ids")
.withValuesSeparatedBy(',')
.ofType(Integer.class);
parser.accepts("restore",
"Restore from replication [ Optional parallelism param - Default - 5 ]")
.withOptionalArg()
.describedAs("parallelism")
.ofType(Integer.class);
parser.accepts("ascii", "Fetch keys as ASCII");
parser.accepts("fetch-keys", "Fetch keys")
.withOptionalArg()
.describedAs("partition-ids")
.withValuesSeparatedBy(',')
.ofType(Integer.class);
parser.accepts("fetch-entries", "Fetch full entries")
.withOptionalArg()
.describedAs("partition-ids")
.withValuesSeparatedBy(',')
.ofType(Integer.class);
parser.accepts("outdir", "Output directory")
.withRequiredArg()
.describedAs("output-directory")
.ofType(String.class);
parser.accepts("nodes", "list of nodes")
.withRequiredArg()
.describedAs("nodes")
.withValuesSeparatedBy(',')
.ofType(Integer.class);
parser.accepts("stores", "Store names")
.withRequiredArg()
.describedAs("store-names")
.withValuesSeparatedBy(',')
.ofType(String.class);
parser.accepts("store", "Store name for querying keys")
.withRequiredArg()
.describedAs("store-name")
.ofType(String.class);
parser.accepts("add-stores", "Add stores in this stores.xml")
.withRequiredArg()
.describedAs("stores.xml containing just the new stores")
.ofType(String.class);
parser.accepts("delete-store", "Delete store")
.withRequiredArg()
.describedAs("store-name")
.ofType(String.class);
parser.accepts("update-entries", "Insert or update entries")
.withRequiredArg()
.describedAs("input-directory")
.ofType(String.class);
parser.accepts("get-metadata",
"retreive metadata information " + MetadataStore.METADATA_KEYS)
.withOptionalArg()
.describedAs("metadata-key")
.ofType(String.class);
parser.accepts("check-metadata",
"retreive metadata information from all nodes and checks if they are consistent across [ "
+ MetadataStore.CLUSTER_KEY + " | " + MetadataStore.STORES_KEY
+ " | " + MetadataStore.REBALANCING_SOURCE_CLUSTER_XML + " | "
+ MetadataStore.SERVER_STATE_KEY + " ]")
.withRequiredArg()
.describedAs("metadata-key")
.ofType(String.class);
parser.accepts("ro-metadata",
"retrieve version information [current | max | storage-format]")
.withRequiredArg()
.describedAs("type")
.ofType(String.class);
parser.accepts("truncate", "truncate a store")
.withRequiredArg()
.describedAs("store-name")
.ofType(String.class);
parser.accepts("set-metadata",
"Forceful setting of metadata [ " + MetadataStore.CLUSTER_KEY + " | "
+ MetadataStore.STORES_KEY + " | " + MetadataStore.SERVER_STATE_KEY
+ " | " + MetadataStore.REBALANCING_SOURCE_CLUSTER_XML + " | "
+ MetadataStore.REBALANCING_STEAL_INFO + " ]")
.withRequiredArg()
.describedAs("metadata-key")
.ofType(String.class);
parser.accepts("set-metadata-value",
"The value for the set-metadata [ " + MetadataStore.CLUSTER_KEY + " | "
+ MetadataStore.STORES_KEY + ", "
+ MetadataStore.REBALANCING_SOURCE_CLUSTER_XML + ", "
+ MetadataStore.REBALANCING_STEAL_INFO
+ " ] - xml file location, [ " + MetadataStore.SERVER_STATE_KEY
+ " ] - " + MetadataStore.VoldemortState.NORMAL_SERVER + ","
+ MetadataStore.VoldemortState.REBALANCING_MASTER_SERVER + ","
+ MetadataStore.VoldemortState.OFFLINE_SERVER)
.withRequiredArg()
.describedAs("metadata-value")
.ofType(String.class);
parser.accepts("update-store-defs",
"Update the ["
+ MetadataStore.STORES_KEY
+ "] with the new value for only the specified stores in update-value.");
parser.accepts("update-store-value",
"The value for update-store-defs ] - xml file location")
.withRequiredArg()
.describedAs("stores-xml-value")
.ofType(String.class);
parser.accepts("set-metadata-pair",
"Atomic setting of metadata pair [ " + MetadataStore.CLUSTER_KEY + " & "
+ MetadataStore.STORES_KEY + " ]")
.withRequiredArg()
.describedAs("metadata-keys-pair")
.withValuesSeparatedBy(',')
.ofType(String.class);
parser.accepts("set-metadata-value-pair",
"The value for the set-metadata pair [ " + MetadataStore.CLUSTER_KEY + " & "
+ MetadataStore.STORES_KEY + " ]")
.withRequiredArg()
.describedAs("metadata-value-pair")
.withValuesSeparatedBy(',')
.ofType(String.class);
parser.accepts("clear-rebalancing-metadata", "Remove the metadata related to rebalancing");
parser.accepts("async",
"a) Get a list of async job ids [get] b) Stop async job ids [stop] ")
.withRequiredArg()
.describedAs("op-type")
.ofType(String.class);
parser.accepts("async-id", "Comma separated list of async ids to stop")
.withOptionalArg()
.describedAs("job-ids")
.withValuesSeparatedBy(',')
.ofType(Integer.class);
parser.accepts("repair-job", "Clean after rebalancing is done");
parser.accepts("prune-job", "Prune versioned put data, after rebalancing");
parser.accepts("purge-slops",
"Purge the slop stores selectively, based on nodeId or zoneId");
parser.accepts("native-backup", "Perform a native backup")
.withRequiredArg()
.describedAs("store-name")
.ofType(String.class);
parser.accepts("backup-dir")
.withRequiredArg()
.describedAs("backup-directory")
.ofType(String.class);
parser.accepts("backup-timeout")
.withRequiredArg()
.describedAs("minutes to wait for backup completion, default 30 mins")
.ofType(Integer.class);
parser.accepts("backup-verify",
"If provided, backup will also verify checksum (with extra overhead)");
parser.accepts("backup-incremental",
"Perform an incremental backup for point-in-time recovery."
+ " By default backup has latest consistent snapshot.");
parser.accepts("zone", "zone id")
.withRequiredArg()
.describedAs("zone-id")
.ofType(Integer.class);
parser.accepts("rollback", "rollback a store")
.withRequiredArg()
.describedAs("store-name")
.ofType(String.class);
parser.accepts("version", "Push version of store to rollback to")
.withRequiredArg()
.describedAs("version")
.ofType(Long.class);
parser.accepts("verify-metadata-version",
"Verify the version of Metadata on all the cluster nodes");
parser.accepts("synchronize-metadata-version",
"Synchronize the metadata versions across all the nodes.");
parser.accepts("reserve-memory", "Memory in MB to reserve for the store")
.withRequiredArg()
.describedAs("size-in-mb")
.ofType(Long.class);
parser.accepts("query-key", "Get values of a key on specific node")
.withRequiredArg()
.describedAs("query-key")
.ofType(String.class);
parser.accepts("query-key-format", "Format of the query key. Can be one of [hex|readable]")
.withRequiredArg()
.describedAs("key-format")
.ofType(String.class);
parser.accepts("show-routing-plan", "Routing plan of the specified keys")
.withRequiredArg()
.describedAs("keys-to-be-routed")
.withValuesSeparatedBy(',')
.ofType(String.class);
parser.accepts("mirror-from-url", "Cluster url to mirror data from")
.withRequiredArg()
.describedAs("mirror-cluster-bootstrap-url")
.ofType(String.class);
parser.accepts("mirror-node", "Node id in the mirror cluster to mirror from")
.withRequiredArg()
.describedAs("id-of-mirror-node")
.ofType(Integer.class);
parser.accepts("fetch-orphaned", "Fetch any orphaned keys/entries in the node");
parser.accepts("set-quota", "Enforce some quota on the servers")
.withRequiredArg()
.describedAs("quota-type")
.ofType(String.class);
parser.accepts("quota-value", "Value of the quota enforced on the servers")
.withRequiredArg()
.describedAs("quota-value")
.ofType(String.class);
parser.accepts("unset-quota", "Remove some quota already enforced on the servers")
.withRequiredArg()
.describedAs("quota-type")
.ofType(String.class);
// TODO add a way to retrieve all quotas for a given store.
parser.accepts("get-quota", "Retrieve some quota already enforced on the servers")
.withRequiredArg()
.describedAs("quota-type")
.ofType(String.class);
OptionSet options = parser.parse(args);
if(options.has("help")) {
printHelp(System.out, parser);
System.exit(0);
}