org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine Java Examples
The following examples show how to use
org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntegrationTestIngestWithMOB.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) { super.processOptions(cmd); if (cmd.hasOption(THRESHOLD)) { threshold = Integer.parseInt(cmd.getOptionValue(THRESHOLD)); } if (cmd.hasOption(MIN_MOB_DATA_SIZE)) { minMobDataSize = Integer.parseInt(cmd.getOptionValue(MIN_MOB_DATA_SIZE)); } if (cmd.hasOption(MAX_MOB_DATA_SIZE)) { maxMobDataSize = Integer.parseInt(cmd.getOptionValue(MAX_MOB_DATA_SIZE)); } if (minMobDataSize > maxMobDataSize) { throw new IllegalArgumentException( "The minMobDataSize should not be larger than minMobDataSize"); } }
Example #2
Source File: ThriftServer.java From hbase with Apache License 2.0 | 6 votes |
/** * Parse the command line options to set parameters the conf. */ protected void processOptions(final String[] args) throws Exception { if (args == null || args.length == 0) { return; } Options options = new Options(); addOptions(options); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help")) { printUsageAndExit(options, 1); } parseCommandLine(cmd, options); }
Example #3
Source File: CoprocessorValidator.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) { String[] jars = cmd.getOptionValues("jar"); if (jars != null) { Collections.addAll(this.jars, jars); } String[] tables = cmd.getOptionValues("table"); if (tables != null) { Arrays.stream(tables).map(Pattern::compile).forEach(tablePatterns::add); } String[] classes = cmd.getOptionValues("class"); if (classes != null) { Collections.addAll(this.classes, classes); } config = cmd.hasOption("config"); dieOnWarnings = cmd.hasOption("e"); }
Example #4
Source File: HFileProcedurePrettyPrinter.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) { if (cmd.hasOption("w")) { String key = cmd.getOptionValue("w"); if (key != null && key.length() != 0) { procId = Long.parseLong(key); } else { throw new IllegalArgumentException("Invalid row is specified."); } } if (cmd.hasOption("f")) { files.add(new Path(cmd.getOptionValue("f"))); } if (cmd.hasOption("a")) { try { addAllHFiles(); } catch (IOException e) { throw new UncheckedIOException(e); } } }
Example #5
Source File: RegionMover.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) { String hostname = cmd.getOptionValue("r"); rmbuilder = new RegionMoverBuilder(hostname); if (cmd.hasOption('m')) { rmbuilder.maxthreads(Integer.parseInt(cmd.getOptionValue('m'))); } if (cmd.hasOption('n')) { rmbuilder.ack(false); } if (cmd.hasOption('f')) { rmbuilder.filename(cmd.getOptionValue('f')); } if (cmd.hasOption('x')) { rmbuilder.excludeFile(cmd.getOptionValue('x')); } if (cmd.hasOption('t')) { rmbuilder.timeout(Integer.parseInt(cmd.getOptionValue('t'))); } this.loadUnload = cmd.getOptionValue("o").toLowerCase(Locale.ROOT); }
Example #6
Source File: LoadBalancerPerformanceEvaluation.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) { numRegions = getOptionAsInt(cmd, NUM_REGIONS_OPT.getOpt(), DEFAULT_NUM_REGIONS); Preconditions.checkArgument(numRegions > 0, "Invalid number of regions!"); numServers = getOptionAsInt(cmd, NUM_SERVERS_OPT.getOpt(), DEFAULT_NUM_SERVERS); Preconditions.checkArgument(numServers > 0, "Invalid number of servers!"); loadBalancerType = cmd.getOptionValue(LOAD_BALANCER_OPT.getOpt(), DEFAULT_LOAD_BALANCER); Preconditions.checkArgument(!loadBalancerType.isEmpty(), "Invalid load balancer type!"); try { loadBalancerClazz = Class.forName(loadBalancerType); } catch (ClassNotFoundException e) { System.err.println("Class '" + loadBalancerType + "' not found!"); System.exit(1); } setupConf(); }
Example #7
Source File: TestHFileSeek.java From hbase with Apache License 2.0 | 6 votes |
public MyOptions(String[] args) { seed = System.nanoTime(); try { Options opts = buildOptions(); CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(opts, args, true); processOptions(line, opts); validateOptions(); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Try \"--help\" option for details."); setStopProceed(); } }
Example #8
Source File: RowCounter.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) throws IllegalArgumentException{ this.tableName = cmd.getArgList().get(0); if(cmd.getOptionValue(OPT_RANGE)!=null) { this.rowRangeList = parseRowRangeParameter(cmd.getOptionValue(OPT_RANGE)); } this.endTime = cmd.getOptionValue(OPT_END_TIME) == null ? HConstants.LATEST_TIMESTAMP : Long.parseLong(cmd.getOptionValue(OPT_END_TIME)); this.expectedCount = cmd.getOptionValue(OPT_EXPECTED_COUNT) == null ? Long.MIN_VALUE : Long.parseLong(cmd.getOptionValue(OPT_EXPECTED_COUNT)); this.startTime = cmd.getOptionValue(OPT_START_TIME) == null ? 0 : Long.parseLong(cmd.getOptionValue(OPT_START_TIME)); for(int i=1; i<cmd.getArgList().size(); i++){ String argument = cmd.getArgList().get(i); if(!argument.startsWith("-")){ this.columns.add(argument); } } if (endTime < startTime) { throw new IllegalArgumentException("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime); } }
Example #9
Source File: IntegrationTestBase.java From hbase with Apache License 2.0 | 6 votes |
/** * This allows tests that subclass children of this base class such as * {@link org.apache.hadoop.hbase.test.IntegrationTestReplication} to * include the base options without having to also include the options from the test. * * @param cmd the command line */ protected void processBaseOptions(CommandLine cmd) { if (cmd.hasOption(MONKEY_LONG_OPT)) { monkeyToUse = cmd.getOptionValue(MONKEY_LONG_OPT); } if (cmd.hasOption(NO_CLUSTER_CLEANUP_LONG_OPT)) { noClusterCleanUp = true; } monkeyProps = new Properties(); // Add entries for the CM from hbase-site.xml as a convenience. // Do this prior to loading from the properties file to make sure those in the properties // file are given precedence to those in hbase-site.xml (backwards compatibility). loadMonkeyProperties(monkeyProps, conf); if (cmd.hasOption(CHAOS_MONKEY_PROPS)) { String chaosMonkeyPropsFile = cmd.getOptionValue(CHAOS_MONKEY_PROPS); if (StringUtils.isNotEmpty(chaosMonkeyPropsFile)) { try { monkeyProps.load(this.getClass().getClassLoader() .getResourceAsStream(chaosMonkeyPropsFile)); } catch (IOException e) { LOG.warn("Failed load of monkey properties {} from CLASSPATH", chaosMonkeyPropsFile, e); System.exit(EXIT_FAILURE); } } } }
Example #10
Source File: IntegrationTestIngestWithACL.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) { super.processOptions(cmd); if (cmd.hasOption(OPT_SUPERUSER)) { superUser = cmd.getOptionValue(OPT_SUPERUSER); } if (cmd.hasOption(OPT_USERS)) { userNames = cmd.getOptionValue(OPT_USERS); } if (User.isHBaseSecurityEnabled(getConf())) { boolean authFileNotFound = false; if (cmd.hasOption(OPT_AUTHN)) { authnFileName = cmd.getOptionValue(OPT_AUTHN); if (StringUtils.isEmpty(authnFileName)) { authFileNotFound = true; } } else { authFileNotFound = true; } if (authFileNotFound) { super.printUsage(); System.exit(EXIT_FAILURE); } } }
Example #11
Source File: IntegrationTestMobCompaction.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) { super.processOptions(cmd); regionServerCount = Integer.parseInt(cmd.getOptionValue(REGIONSERVER_COUNT_KEY, Integer.toString(DEFAULT_REGIONSERVER_COUNT))); rowsToLoad = Long.parseLong(cmd.getOptionValue(ROWS_COUNT_KEY, Long.toString(DEFAULT_ROWS_COUNT))); failureProb = Double.parseDouble(cmd.getOptionValue(FAILURE_PROB_KEY, Double.toString(DEFAULT_FAILURE_PROB))); LOG.info(MoreObjects.toStringHelper("Parsed Options") .add(REGIONSERVER_COUNT_KEY, regionServerCount) .add(ROWS_COUNT_KEY, rowsToLoad) .add(FAILURE_PROB_KEY, failureProb) .toString()); }
Example #12
Source File: ChaosMonkeyRunner.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) { if (cmd.hasOption(MONKEY_LONG_OPT)) { monkeyToUse = cmd.getOptionValue(MONKEY_LONG_OPT); } monkeyProps = new Properties(); if (cmd.hasOption(CHAOS_MONKEY_PROPS)) { String chaosMonkeyPropsFile = cmd.getOptionValue(CHAOS_MONKEY_PROPS); if (StringUtils.isNotEmpty(chaosMonkeyPropsFile)) { try { monkeyProps.load(this.getClass().getClassLoader() .getResourceAsStream(chaosMonkeyPropsFile)); } catch (IOException e) { LOG.warn(e.toString(), e); System.exit(EXIT_FAILURE); } } } if (cmd.hasOption(TABLE_NAME_OPT)) { this.tableName = cmd.getOptionValue(TABLE_NAME_OPT); } if (cmd.hasOption(FAMILY_NAME_OPT)) { this.familyName = cmd.getOptionValue(FAMILY_NAME_OPT); } }
Example #13
Source File: IntegrationTestLoadAndVerify.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) { super.processOptions(cmd); String[] args = cmd.getArgs(); if (args == null || args.length < 1) { printUsage(); throw new RuntimeException("Incorrect Number of args."); } toRun = args[0]; if (toRun.equalsIgnoreCase("search")) { if (args.length > 1) { keysDir = args[1]; } } }
Example #14
Source File: IntegrationTestRegionReplicaPerf.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) { tableName = TableName.valueOf(cmd.getOptionValue(TABLE_NAME_KEY, TABLE_NAME_DEFAULT)); sleepTime = Long.parseLong(cmd.getOptionValue(SLEEP_TIME_KEY, SLEEP_TIME_DEFAULT)); replicaCount = Integer.parseInt(cmd.getOptionValue(REPLICA_COUNT_KEY, REPLICA_COUNT_DEFAULT)); primaryTimeout = Integer.parseInt(cmd.getOptionValue(PRIMARY_TIMEOUT_KEY, PRIMARY_TIMEOUT_DEFAULT)); clusterSize = Integer.parseInt(cmd.getOptionValue(NUM_RS_KEY, NUM_RS_DEFAULT)); LOG.debug(MoreObjects.toStringHelper("Parsed Options") .add(TABLE_NAME_KEY, tableName) .add(SLEEP_TIME_KEY, sleepTime) .add(REPLICA_COUNT_KEY, replicaCount) .add(PRIMARY_TIMEOUT_KEY, primaryTimeout) .add(NUM_RS_KEY, clusterSize) .toString()); }
Example #15
Source File: HBCK2.java From hbase-operator-tools with Apache License 2.0 | 6 votes |
List<Long> unassigns(Hbck hbck, String [] args) throws IOException { Options options = new Options(); Option override = Option.builder("o").longOpt("override").build(); options.addOption(override); // Parse command-line. CommandLineParser parser = new DefaultParser(); CommandLine commandLine; try { commandLine = parser.parse(options, args, false); } catch (ParseException e) { showErrorMessage(e.getMessage()); return null; } boolean overrideFlag = commandLine.hasOption(override.getOpt()); return hbck.unassigns(commandLine.getArgList(), overrideFlag); }
Example #16
Source File: ExportSnapshot.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void processOptions(CommandLine cmd) { snapshotName = cmd.getOptionValue(Options.SNAPSHOT.getLongOpt(), snapshotName); targetName = cmd.getOptionValue(Options.TARGET_NAME.getLongOpt(), targetName); if (cmd.hasOption(Options.COPY_TO.getLongOpt())) { outputRoot = new Path(cmd.getOptionValue(Options.COPY_TO.getLongOpt())); } if (cmd.hasOption(Options.COPY_FROM.getLongOpt())) { inputRoot = new Path(cmd.getOptionValue(Options.COPY_FROM.getLongOpt())); } mappers = getOptionAsInt(cmd, Options.MAPPERS.getLongOpt(), mappers); filesUser = cmd.getOptionValue(Options.CHUSER.getLongOpt(), filesUser); filesGroup = cmd.getOptionValue(Options.CHGROUP.getLongOpt(), filesGroup); filesMode = getOptionAsInt(cmd, Options.CHMOD.getLongOpt(), filesMode); bandwidthMB = getOptionAsInt(cmd, Options.BANDWIDTH.getLongOpt(), bandwidthMB); overwrite = cmd.hasOption(Options.OVERWRITE.getLongOpt()); // And verifyChecksum and verifyTarget with values read from old args in processOldArgs(...). verifyChecksum = !cmd.hasOption(Options.NO_CHECKSUM_VERIFY.getLongOpt()); verifyTarget = !cmd.hasOption(Options.NO_TARGET_VERIFY.getLongOpt()); }
Example #17
Source File: AbstractHBaseTool.java From hbase with Apache License 2.0 | 5 votes |
public int getOptionAsInt(CommandLine cmd, String opt, int defaultValue) { if (cmd.hasOption(opt)) { return Integer.parseInt(cmd.getOptionValue(opt)); } else { return defaultValue; } }
Example #18
Source File: AbstractHBaseTool.java From hbase with Apache License 2.0 | 5 votes |
public double getOptionAsDouble(CommandLine cmd, String opt, double defaultValue) { if (cmd.hasOption(opt)) { return Double.parseDouble(cmd.getOptionValue(opt)); } else { return defaultValue; } }
Example #19
Source File: IntegrationTestReplication.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { processBaseOptions(cmd); sourceClusterIdString = cmd.getOptionValue(SOURCE_CLUSTER_OPT); sinkClusterIdString = cmd.getOptionValue(DEST_CLUSTER_OPT); outputDir = cmd.getOptionValue(OUTPUT_DIR_OPT); /** This uses parseInt from {@link org.apache.hadoop.hbase.util.AbstractHBaseTool} */ numMappers = parseInt(cmd.getOptionValue(NUM_MAPPERS_OPT, Integer.toString(DEFAULT_NUM_MAPPERS)), 1, Integer.MAX_VALUE); numReducers = parseInt(cmd.getOptionValue(NUM_REDUCERS_OPT, Integer.toString(DEFAULT_NUM_REDUCERS)), 1, Integer.MAX_VALUE); numNodes = parseInt(cmd.getOptionValue(NUM_NODES_OPT, Integer.toString(DEFAULT_NUM_NODES)), 1, Integer.MAX_VALUE); generateVerifyGap = parseInt(cmd.getOptionValue(GENERATE_VERIFY_GAP_OPT, Integer.toString(DEFAULT_GENERATE_VERIFY_GAP)), 1, Integer.MAX_VALUE); numIterations = parseInt(cmd.getOptionValue(ITERATIONS_OPT, Integer.toString(DEFAULT_NUM_ITERATIONS)), 1, Integer.MAX_VALUE); width = parseInt(cmd.getOptionValue(WIDTH_OPT, Integer.toString(DEFAULT_WIDTH)), 1, Integer.MAX_VALUE); wrapMultiplier = parseInt(cmd.getOptionValue(WRAP_MULTIPLIER_OPT, Integer.toString(DEFAULT_WRAP_MULTIPLIER)), 1, Integer.MAX_VALUE); if (cmd.hasOption(NO_REPLICATION_SETUP_OPT)) { noReplicationSetup = true; } if (numNodes % (width * wrapMultiplier) != 0) { throw new RuntimeException("numNodes must be a multiple of width and wrap multiplier"); } }
Example #20
Source File: BackupCommands.java From hbase with Apache License 2.0 | 5 votes |
public static Command createCommand(Configuration conf, BackupCommand type, CommandLine cmdline) { Command cmd; switch (type) { case CREATE: cmd = new CreateCommand(conf, cmdline); break; case DESCRIBE: cmd = new DescribeCommand(conf, cmdline); break; case PROGRESS: cmd = new ProgressCommand(conf, cmdline); break; case DELETE: cmd = new DeleteCommand(conf, cmdline); break; case HISTORY: cmd = new HistoryCommand(conf, cmdline); break; case SET: cmd = new BackupSetCommand(conf, cmdline); break; case REPAIR: cmd = new RepairCommand(conf, cmdline); break; case MERGE: cmd = new MergeCommand(conf, cmdline); break; case HELP: default: cmd = new HelpCommand(conf, cmdline); break; } return cmd; }
Example #21
Source File: IntegrationTestSendTraceRequests.java From hbase with Apache License 2.0 | 5 votes |
@Override public void processOptions(CommandLine cmd) { String tableNameString = cmd.getOptionValue(TABLE_ARG, TABLE_NAME_DEFAULT); String familyString = cmd.getOptionValue(CF_ARG, COLUMN_FAMILY_DEFAULT); this.tableName = TableName.valueOf(tableNameString); this.familyName = Bytes.toBytes(familyString); }
Example #22
Source File: IntegrationTestBackupRestore.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { super.processOptions(cmd); regionsCountPerServer = Integer.parseInt(cmd.getOptionValue(REGION_COUNT_KEY, Integer.toString(DEFAULT_REGION_COUNT))); regionServerCount = Integer.parseInt(cmd.getOptionValue(REGIONSERVER_COUNT_KEY, Integer.toString(DEFAULT_REGIONSERVER_COUNT))); rowsInIteration = Integer.parseInt(cmd.getOptionValue(ROWS_PER_ITERATION_KEY, Integer.toString(DEFAULT_ROWS_IN_ITERATION))); numIterations = Integer.parseInt(cmd.getOptionValue(NUM_ITERATIONS_KEY, Integer.toString(DEFAULT_NUM_ITERATIONS))); numTables = Integer.parseInt(cmd.getOptionValue(NUMBER_OF_TABLES_KEY, Integer.toString(DEFAULT_NUMBER_OF_TABLES))); sleepTime = Long.parseLong(cmd.getOptionValue(SLEEP_TIME_KEY, Long.toString(SLEEP_TIME_DEFAULT))); LOG.info(MoreObjects.toStringHelper("Parsed Options") .add(REGION_COUNT_KEY, regionsCountPerServer) .add(REGIONSERVER_COUNT_KEY, regionServerCount) .add(ROWS_PER_ITERATION_KEY, rowsInIteration) .add(NUM_ITERATIONS_KEY, numIterations) .add(NUMBER_OF_TABLES_KEY, numTables) .add(SLEEP_TIME_KEY, sleepTime) .toString()); }
Example #23
Source File: IntegrationTestsDriver.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { String testFilterString = cmd.getOptionValue(SHORT_REGEX_ARG, null); if (testFilterString != null) { intTestFilter.setPattern(testFilterString); } }
Example #24
Source File: StripeCompactionsPerformanceEvaluation.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { int minValueSize = 0, maxValueSize = 0; String valueSize = cmd.getOptionValue(VALUE_SIZE_KEY, VALUE_SIZE_DEFAULT); if (valueSize.contains(":")) { String[] valueSizes = valueSize.split(":"); if (valueSize.length() != 2) throw new RuntimeException("Invalid value size: " + valueSize); minValueSize = Integer.parseInt(valueSizes[0]); maxValueSize = Integer.parseInt(valueSizes[1]); } else { minValueSize = maxValueSize = Integer.parseInt(valueSize); } String datagen = cmd.getOptionValue(DATAGEN_KEY, "default").toLowerCase(Locale.ROOT); if ("default".equals(datagen)) { dataGen = new MultiThreadedAction.DefaultDataGenerator( minValueSize, maxValueSize, 1, 1, new byte[][] { COLUMN_FAMILY }); } else if ("sequential".equals(datagen)) { int shards = Integer.parseInt(cmd.getOptionValue(SEQ_SHARDS_PER_SERVER_KEY, "1")); dataGen = new SeqShardedDataGenerator(minValueSize, maxValueSize, shards); } else { throw new RuntimeException("Unknown " + DATAGEN_KEY + ": " + datagen); } iterationCount = Integer.parseInt(cmd.getOptionValue(ITERATIONS_KEY, "1")); preloadKeys = Long.parseLong(cmd.getOptionValue(PRELOAD_COUNT_KEY, "1000000")); writeKeys = Long.parseLong(cmd.getOptionValue(WRITE_COUNT_KEY, "1000000")); writeThreads = Integer.parseInt(cmd.getOptionValue(WRITE_THREADS_KEY, "10")); readThreads = Integer.parseInt(cmd.getOptionValue(READ_THREADS_KEY, "20")); initialStripeCount = getLongOrNull(cmd, INITIAL_STRIPE_COUNT_KEY); splitSize = getLongOrNull(cmd, SPLIT_SIZE_KEY); splitParts = getLongOrNull(cmd, SPLIT_PARTS_KEY); }
Example #25
Source File: ThriftServer.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void parseCommandLine(CommandLine cmd, Options options) throws Shell.ExitCodeException { super.parseCommandLine(cmd, options); boolean readOnly = THRIFT_READONLY_ENABLED_DEFAULT; if (cmd.hasOption(READONLY_OPTION)) { readOnly = true; } conf.setBoolean(THRIFT_READONLY_ENABLED, readOnly); }
Example #26
Source File: LoadTestTool.java From hbase with Apache License 2.0 | 5 votes |
private void parseColumnFamilyOptions(CommandLine cmd) { String dataBlockEncodingStr = cmd.getOptionValue(HFileTestUtil.OPT_DATA_BLOCK_ENCODING); dataBlockEncodingAlgo = dataBlockEncodingStr == null ? null : DataBlockEncoding.valueOf(dataBlockEncodingStr); String compressStr = cmd.getOptionValue(OPT_COMPRESSION); compressAlgo = compressStr == null ? Compression.Algorithm.NONE : Compression.Algorithm.valueOf(compressStr); String bloomStr = cmd.getOptionValue(OPT_BLOOM); bloomType = bloomStr == null ? BloomType.ROW : BloomType.valueOf(bloomStr); if (bloomType == BloomType.ROWPREFIX_FIXED_LENGTH) { if (!cmd.hasOption(OPT_BLOOM_PARAM)) { LOG.error("the parameter of bloom filter {} is not specified", bloomType.name()); } else { conf.set(BloomFilterUtil.PREFIX_LENGTH_KEY, cmd.getOptionValue(OPT_BLOOM_PARAM)); } } inMemoryCF = cmd.hasOption(OPT_INMEMORY); if (cmd.hasOption(OPT_ENCRYPTION)) { cipher = Encryption.getCipher(conf, cmd.getOptionValue(OPT_ENCRYPTION)); } }
Example #27
Source File: LoadTestTool.java From hbase with Apache License 2.0 | 5 votes |
@Override protected CommandLineParser newParser() { // Commons-CLI lacks the capability to handle combinations of options, so we do it ourselves // Validate in parse() to get helpful error messages instead of exploding in processOptions() return new DefaultParser() { @Override public CommandLine parse(Options opts, String[] args, Properties props, boolean stop) throws ParseException { CommandLine cl = super.parse(opts, args, props, stop); boolean isReadWriteUpdate = cmd.hasOption(OPT_READ) || cmd.hasOption(OPT_WRITE) || cmd.hasOption(OPT_UPDATE); boolean isInitOnly = cmd.hasOption(OPT_INIT_ONLY); if (!isInitOnly && !isReadWriteUpdate) { throw new MissingOptionException("Must specify either -" + OPT_INIT_ONLY + " or at least one of -" + OPT_READ + ", -" + OPT_WRITE + ", -" + OPT_UPDATE); } if (isInitOnly && isReadWriteUpdate) { throw new AlreadySelectedException(OPT_INIT_ONLY + " cannot be specified with any of -" + OPT_READ + ", -" + OPT_WRITE + ", -" + OPT_UPDATE); } if (isReadWriteUpdate && !cmd.hasOption(OPT_NUM_KEYS)) { throw new MissingOptionException(OPT_NUM_KEYS + " must be specified in read/write mode."); } return cl; } }; }
Example #28
Source File: ProcedureStorePerformanceEvaluation.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { outputPath = cmd.getOptionValue(OUTPUT_PATH_OPTION.getOpt(), DEFAULT_OUTPUT_PATH); numThreads = getOptionAsInt(cmd, NUM_THREADS_OPTION.getOpt(), DEFAULT_NUM_THREADS); numProcs = getOptionAsInt(cmd, NUM_PROCS_OPTION.getOpt(), DEFAULT_NUM_PROCS); syncType = cmd.getOptionValue(SYNC_OPTION.getOpt(), DEFAULT_SYNC_OPTION); assert "hsync".equals(syncType) || "hflush".equals(syncType) || "nosync".equals( syncType) : "sync argument can only accept one of these three values: hsync, hflush, nosync"; stateSize = getOptionAsInt(cmd, STATE_SIZE_OPTION.getOpt(), DEFAULT_STATE_SIZE); SERIALIZED_STATE = new byte[stateSize]; new Random(12345).nextBytes(SERIALIZED_STATE); }
Example #29
Source File: ProcedureWALPerformanceEvaluation.java From hbase with Apache License 2.0 | 5 votes |
/** * Processes and validates command line options. */ @Override public void processOptions(CommandLine cmd) { super.processOptions(cmd); numWals = getOptionAsInt(cmd, NUM_WALS_OPTION.getOpt(), DEFAULT_NUM_WALS); setupConf(); }
Example #30
Source File: IntegrationTestWithCellVisibilityLoadAndVerify.java From hbase with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override protected void processOptions(CommandLine cmd) { List args = cmd.getArgList(); if (args.size() > 0) { printUsage(); throw new RuntimeException("No args expected."); } // We always want loadAndVerify action args.add("loadAndVerify"); if (cmd.hasOption(USER_OPT)) { userNames = cmd.getOptionValue(USER_OPT); } super.processOptions(cmd); }