Java Code Examples for org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine

The following examples show how to use org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine. These examples are extracted from open source projects. 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 Project: hbase-operator-tools   Source File: HBCK2.java    License: Apache License 2.0 6 votes vote down vote up
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 2
Source Project: hbase   Source File: ThriftServer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 Project: hbase   Source File: CoprocessorValidator.java    License: Apache License 2.0 6 votes vote down vote up
@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 Project: hbase   Source File: HFileProcedurePrettyPrinter.java    License: Apache License 2.0 6 votes vote down vote up
@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 Project: hbase   Source File: RegionMover.java    License: Apache License 2.0 6 votes vote down vote up
@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 Project: hbase   Source File: LoadBalancerPerformanceEvaluation.java    License: Apache License 2.0 6 votes vote down vote up
@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 Project: hbase   Source File: TestHFileSeek.java    License: Apache License 2.0 6 votes vote down vote up
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 Project: hbase   Source File: RowCounter.java    License: Apache License 2.0 6 votes vote down vote up
@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 Project: hbase   Source File: ExportSnapshot.java    License: Apache License 2.0 6 votes vote down vote up
@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 10
Source Project: hbase   Source File: IntegrationTestBase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 11
Source Project: hbase   Source File: IntegrationTestIngestWithACL.java    License: Apache License 2.0 6 votes vote down vote up
@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 12
Source Project: hbase   Source File: IntegrationTestMobCompaction.java    License: Apache License 2.0 6 votes vote down vote up
@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 13
Source Project: hbase   Source File: ChaosMonkeyRunner.java    License: Apache License 2.0 6 votes vote down vote up
@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 14
Source Project: hbase   Source File: IntegrationTestLoadAndVerify.java    License: Apache License 2.0 6 votes vote down vote up
@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 15
Source Project: hbase   Source File: IntegrationTestRegionReplicaPerf.java    License: Apache License 2.0 6 votes vote down vote up
@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 16
Source Project: hbase   Source File: IntegrationTestIngestWithMOB.java    License: Apache License 2.0 6 votes vote down vote up
@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 17
Source Project: hbase-operator-tools   Source File: HBCK2.java    License: Apache License 2.0 5 votes vote down vote up
List<Long> assigns(Hbck hbck, String[] args) throws IOException {
  Options options = new Options();
  Option override = Option.builder("o").longOpt("override").build();
  Option inputFile = Option.builder("i").longOpt("inputFiles").build();
  options.addOption(override);
  options.addOption(inputFile);
  // 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());

  List<String> argList = commandLine.getArgList();
  if (!commandLine.hasOption(inputFile.getOpt())) {
    return hbck.assigns(argList, overrideFlag);
  }
  List<String> assignmentList = new ArrayList<>();
  for (String filePath : argList) {
    try (InputStream fileStream = new FileInputStream(filePath)){
      LineIterator it = IOUtils.lineIterator(fileStream, "UTF-8");
      while (it.hasNext()) {
        assignmentList.add(it.nextLine().trim());
      }
    }
  }
  return hbck.assigns(assignmentList, overrideFlag);
}
 
Example 18
Source Project: hbase-operator-tools   Source File: HBCK2.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return List of results OR null if failed to run.
 */
private List<Boolean> bypass(String[] args) throws IOException {
  // Bypass has two options....
  Options options = new Options();
  // See usage for 'help' on these options.
  Option override = Option.builder("o").longOpt("override").build();
  options.addOption(override);
  Option recursive = Option.builder("r").longOpt("recursive").build();
  options.addOption(recursive);
  Option wait = Option.builder("w").longOpt("lockWait").hasArg().type(Integer.class).build();
  options.addOption(wait);
  // Parse command-line.
  CommandLineParser parser = new DefaultParser();
  CommandLine commandLine;
  try {
    commandLine = parser.parse(options, args, false);
  } catch (ParseException e) {
    showErrorMessage(e.getMessage());
    return null;
  }
  long lockWait = DEFAULT_LOCK_WAIT;
  if (commandLine.hasOption(wait.getOpt())) {
    lockWait = Integer.parseInt(commandLine.getOptionValue(wait.getOpt()));
  }
  String[] pidStrs = commandLine.getArgs();
  if (pidStrs == null || pidStrs.length <= 0) {
    showErrorMessage("No pids supplied.");
    return null;
  }
  boolean overrideFlag = commandLine.hasOption(override.getOpt());
  boolean recursiveFlag = commandLine.hasOption(recursive.getOpt());
  List<Long> pids = Arrays.stream(pidStrs).map(Long::valueOf).collect(Collectors.toList());
  try (ClusterConnection connection = connect(); Hbck hbck = connection.getHbck()) {
    checkFunctionSupported(connection, BYPASS);
    return hbck.bypassProcedure(pids, lockWait, overrideFlag, recursiveFlag);
  }
}
 
Example 19
Source Project: hbase   Source File: BackupCommands.java    License: Apache License 2.0 5 votes vote down vote up
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 20
Source Project: hbase   Source File: BackupCommands.java    License: Apache License 2.0 5 votes vote down vote up
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 21
Source Project: hbase   Source File: ThriftServer.java    License: Apache License 2.0 5 votes vote down vote up
@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 22
Source Project: hbase   Source File: ThriftServer.java    License: Apache License 2.0 5 votes vote down vote up
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 23
Source Project: hbase   Source File: WALProcedurePrettyPrinter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void processOptions(CommandLine cmd) {
  if (cmd.getArgList().size() != 1) {
    throw new IllegalArgumentException("Please specify the file to dump");
  }
  file = cmd.getArgList().get(0);
}
 
Example 24
Source Project: hbase   Source File: RSGroupMajorCompactionTTL.java    License: Apache License 2.0 5 votes vote down vote up
@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 25
Source Project: hbase   Source File: CreateSnapshot.java    License: Apache License 2.0 5 votes vote down vote up
@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 26
Source Project: hbase   Source File: SnapshotInfo.java    License: Apache License 2.0 5 votes vote down vote up
@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 27
Source Project: hbase   Source File: MajorCompactorTTL.java    License: Apache License 2.0 5 votes vote down vote up
@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 table = commandLine.getOptionValue("table");
  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");

  return compactRegionsTTLOnTable(HBaseConfiguration.create(), table, concurrency, sleep,
      numServers, numRegions, dryRun, skipWait);
}
 
Example 28
Source Project: hbase   Source File: AcidGuaranteesTestTool.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void processOptions(CommandLine cmd) {
  millisToRun = getOptionAsLong(cmd, "millis", 5000);
  numWriters = getOptionAsInt(cmd, "numWriters", 50);
  numGetters = getOptionAsInt(cmd, "numGetters", 2);
  numScanners = getOptionAsInt(cmd, "numScanners", 2);
  numUniqueRows = getOptionAsInt(cmd, "numUniqueRows", 3);
  crazyFlush = cmd.hasOption("crazyFlush");
  useMob = cmd.hasOption("useMob");
}
 
Example 29
@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 30
Source Project: hbase   Source File: TestJoinedScanners.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Command line interface:
 * @param args
 * @throws IOException if there is a bug while reading from disk
 */
public static void main(final String[] args) throws Exception {
  Option encodingOption = new Option("e", "blockEncoding", true,
    "Data block encoding; Default: FAST_DIFF");
  encodingOption.setRequired(false);
  options.addOption(encodingOption);

  Option ratioOption = new Option("r", "selectionRatio", true,
    "Ratio of selected rows using essential column family");
  ratioOption.setRequired(false);
  options.addOption(ratioOption);

  Option widthOption = new Option("w", "valueWidth", true,
    "Width of value for non-essential column family");
  widthOption.setRequired(false);
  options.addOption(widthOption);

  CommandLineParser parser = new GnuParser();
  CommandLine cmd = parser.parse(options, args);
  if (args.length < 1) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp("TestJoinedScanners", options, true);
  }

  if (cmd.hasOption("e")) {
    blockEncoding = DataBlockEncoding.valueOf(cmd.getOptionValue("e"));
  }
  if (cmd.hasOption("r")) {
    selectionRatio = Integer.parseInt(cmd.getOptionValue("r"));
  }
  if (cmd.hasOption("w")) {
    valueWidth = Integer.parseInt(cmd.getOptionValue("w"));
  }
  // run the test
  TestJoinedScanners test = new TestJoinedScanners();
  test.testJoinedScanners();
}