public static void main()

in src/main/java/org/apache/accumulo/testing/continuous/CreateTable.java [40:92]


  public static void main(String[] args) throws Exception {

    try (ContinuousEnv env = new ContinuousEnv(args)) {
      AccumuloClient client = env.getAccumuloClient();

      String tableName = env.getAccumuloTableName();
      if (client.tableOperations().exists(tableName)) {
        log.error("Accumulo table {} already exists", tableName);
        System.exit(-1);
      }

      int numTablets = Integer.parseInt(env.getTestProperty(CI_COMMON_ACCUMULO_NUM_TABLETS));

      if (numTablets < 1) {
        log.error("numTablets < 1");
        System.exit(-1);
      }
      if (env.getRowMin() >= env.getRowMax()) {
        log.error("min >= max");
        System.exit(-1);
      }

      // retrieve and set tserver props
      Map<String,String> props = getProps(env, TestProps.CI_COMMON_ACCUMULO_SERVER_PROPS);
      try {
        client.instanceOperations().modifyProperties(properties -> properties.putAll(props));
      } catch (AccumuloException | AccumuloSecurityException e) {
        log.error("Failed to set tserver props");
        throw new Exception(e);
      }

      SortedSet<Text> splits = new TreeSet<>();
      final int numSplits = numTablets - 1;
      final long distance = ((env.getRowMax() - env.getRowMin()) / numTablets) + 1;
      long split = distance;
      for (int i = 0; i < numSplits; i++) {
        String s = String.format("%016x", split + env.getRowMin());
        while (s.charAt(s.length() - 1) == '0') {
          s = s.substring(0, s.length() - 1);
        }
        splits.add(new Text(s));
        split += distance;
      }

      NewTableConfiguration ntc = new NewTableConfiguration();
      ntc.withSplits(splits);
      ntc.setProperties(getProps(env, TestProps.CI_COMMON_ACCUMULO_TABLE_PROPS));

      client.tableOperations().create(tableName, ntc);

      log.info("Created Accumulo table {} with {} tablets", tableName, numTablets);
    }
  }