Java Code Examples for org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine#getOptionValue()
The following examples show how to use
org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine#getOptionValue() .
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: 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 2
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 3
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 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: MasterProcedureSchedulerPerformanceEvaluation.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { numTables = getOptionAsInt(cmd, NUM_TABLES_OPTION.getOpt(), DEFAULT_NUM_TABLES); regionsPerTable = getOptionAsInt(cmd, REGIONS_PER_TABLE_OPTION.getOpt(), DEFAULT_REGIONS_PER_TABLE); numOps = getOptionAsInt(cmd, NUM_OPERATIONS_OPTION.getOpt(), DEFAULT_NUM_OPERATIONS); numThreads = getOptionAsInt(cmd, NUM_THREADS_OPTION.getOpt(), DEFAULT_NUM_THREADS); opsType = cmd.getOptionValue(OPS_TYPE_OPTION.getOpt(), DEFAULT_OPS_TYPE); }
Example 6
Source File: ThriftServer.java From hbase with Apache License 2.0 | 5 votes |
protected static void optionToConf(CommandLine cmd, String option, Configuration conf, String destConfKey) { if (cmd.hasOption(option)) { String value = cmd.getOptionValue(option); LOG.info("Set configuration key:" + destConfKey + " value:" + value); conf.set(destConfKey, value); } }
Example 7
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 8
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 9
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); }
Example 10
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 11
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 12
Source File: IntegrationTestBigLinkedListWithVisibility.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { super.processOptions(cmd); if (cmd.hasOption(USER_OPT)) { userName = cmd.getOptionValue(USER_OPT); } }
Example 13
Source File: End2EndTestDriver.java From phoenix with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { String testFilterString = cmd.getOptionValue(SHORT_REGEX_ARG, null); if (testFilterString != null) { end2endTestFilter.setPattern(testFilterString); } skipTests = cmd.hasOption(SKIP_TESTS); }
Example 14
Source File: RSGroupMajorCompactionTTL.java From hbase with Apache License 2.0 | 5 votes |
@Override public int run(String[] args) throws Exception { Options options = getOptions(); final CommandLineParser cmdLineParser = new DefaultParser(); CommandLine commandLine; try { commandLine = cmdLineParser.parse(options, args); } catch (ParseException parseException) { System.out.println("ERROR: Unable to parse command-line arguments " + Arrays.toString(args) + " due to: " + parseException); printUsage(options); return -1; } if (commandLine == null) { System.out.println("ERROR: Failed parse, empty commandLine; " + Arrays.toString(args)); printUsage(options); return -1; } String rsgroup = commandLine.getOptionValue("rsgroup"); int numServers = Integer.parseInt(commandLine.getOptionValue("numservers", "-1")); int numRegions = Integer.parseInt(commandLine.getOptionValue("numregions", "-1")); int concurrency = Integer.parseInt(commandLine.getOptionValue("servers", "1")); long sleep = Long.parseLong(commandLine.getOptionValue("sleep", Long.toString(30000))); boolean dryRun = commandLine.hasOption("dryRun"); boolean skipWait = commandLine.hasOption("skipWait"); Configuration conf = getConf(); return compactTTLRegionsOnGroup(conf, rsgroup, concurrency, sleep, numServers, numRegions, dryRun, skipWait); }
Example 15
Source File: BackupCommands.java From hbase with Apache License 2.0 | 5 votes |
private void executeDeleteListOfBackups(CommandLine cmdline) throws IOException { String value = cmdline.getOptionValue(OPTION_LIST); String[] backupIds = value.split(","); try (BackupAdminImpl admin = new BackupAdminImpl(conn)) { int deleted = admin.deleteBackups(backupIds); System.out.println("Deleted " + deleted + " backups. Total requested: " + backupIds.length); } catch (IOException e) { System.err.println("Delete command FAILED. Please run backup repair tool to restore backup " + "system integrity"); throw e; } }
Example 16
Source File: AbstractHBaseToolTest.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { requiredValue = cmd.getOptionValue(Options.REQUIRED.getLongOpt()); if (cmd.hasOption(Options.OPTIONAL.getLongOpt())) { optionalValue = cmd.getOptionValue(Options.OPTIONAL.getLongOpt()); } booleanValue = booleanValue || cmd.hasOption(Options.BOOLEAN.getLongOpt()); }
Example 17
Source File: IntegrationTestZKAndFSPermissions.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { isForce = cmd.hasOption(FORCE_CHECK_ARG); masterPrincipal = getShortUserName(conf.get(SecurityConstants.MASTER_KRB_PRINCIPAL)); superUser = cmd.getOptionValue(SUPERUSER_ARG, conf.get("hbase.superuser")); masterPrincipal = cmd.getOptionValue(PRINCIPAL_ARG, masterPrincipal); fsPerms = cmd.getOptionValue(FS_PERMS, "700"); skipFSCheck = cmd.hasOption(SKIP_CHECK_FS); skipZKCheck = cmd.hasOption(SKIP_CHECK_ZK); }
Example 18
Source File: SnapshotInfo.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { snapshotName = cmd.getOptionValue(Options.SNAPSHOT.getLongOpt()); showFiles = cmd.hasOption(Options.FILES.getLongOpt()); showStats = cmd.hasOption(Options.FILES.getLongOpt()) || cmd.hasOption(Options.STATS.getLongOpt()); showSchema = cmd.hasOption(Options.SCHEMA.getLongOpt()); listSnapshots = cmd.hasOption(Options.LIST_SNAPSHOTS.getLongOpt()); printSizeInBytes = cmd.hasOption(Options.SIZE_IN_BYTES.getLongOpt()); if (cmd.hasOption(Options.REMOTE_DIR.getLongOpt())) { remoteDir = new Path(cmd.getOptionValue(Options.REMOTE_DIR.getLongOpt())); } }
Example 19
Source File: CreateSnapshot.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void processOptions(CommandLine cmd) { this.tableName = TableName.valueOf(cmd.getOptionValue('t')); this.snapshotName = cmd.getOptionValue('n'); String snapshotTypeName = cmd.getOptionValue('s'); if (snapshotTypeName != null) { snapshotTypeName = snapshotTypeName.toUpperCase(Locale.ROOT); this.snapshotType = SnapshotType.valueOf(snapshotTypeName); } }
Example 20
Source File: MajorCompactor.java From hbase with Apache License 2.0 | 4 votes |
@Override public int run(String[] args) throws Exception { Options options = getCommonOptions(); options.addOption( Option.builder("table") .required() .desc("table name") .hasArg() .build() ); options.addOption( Option.builder("cf") .optionalArg(true) .desc("column families: comma separated eg: a,b,c") .hasArg() .build() ); final CommandLineParser cmdLineParser = new DefaultParser(); CommandLine commandLine = null; try { commandLine = cmdLineParser.parse(options, args); } catch (ParseException parseException) { System.out.println( "ERROR: Unable to parse command-line arguments " + Arrays.toString(args) + " due to: " + parseException); printUsage(options); return -1; } if (commandLine == null) { System.out.println("ERROR: Failed parse, empty commandLine; " + Arrays.toString(args)); printUsage(options); return -1; } String tableName = commandLine.getOptionValue("table"); String cf = commandLine.getOptionValue("cf", null); Set<String> families = Sets.newHashSet(); if (cf != null) { Iterables.addAll(families, Splitter.on(",").split(cf)); } Configuration configuration = getConf(); int concurrency = Integer.parseInt(commandLine.getOptionValue("servers")); long minModTime = Long.parseLong( commandLine.getOptionValue("minModTime", String.valueOf(System.currentTimeMillis()))); String quorum = commandLine.getOptionValue("zk", configuration.get(HConstants.ZOOKEEPER_QUORUM)); String rootDir = commandLine.getOptionValue("rootDir", configuration.get(HConstants.HBASE_DIR)); long sleep = Long.parseLong(commandLine.getOptionValue("sleep", Long.toString(30000))); int numServers = Integer.parseInt(commandLine.getOptionValue("numservers", "-1")); int numRegions = Integer.parseInt(commandLine.getOptionValue("numregions", "-1")); configuration.set(HConstants.HBASE_DIR, rootDir); configuration.set(HConstants.ZOOKEEPER_QUORUM, quorum); MajorCompactor compactor = new MajorCompactor(configuration, TableName.valueOf(tableName), families, concurrency, minModTime, sleep); compactor.setNumServers(numServers); compactor.setNumRegions(numRegions); compactor.setSkipWait(commandLine.hasOption("skipWait")); compactor.initializeWorkQueues(); if (!commandLine.hasOption("dryRun")) { compactor.compactAllRegions(); } compactor.shutdown(); return ERRORS.size(); }