public static void createTable()

in src/main/java/org/apache/accumulo/testing/continuous/CreateTable.java [55:105]


  public static void createTable(AccumuloClient client, String tableName, int numTablets,
      long rowMin, long rowMax, Map<String,String> serverProps, Map<String,String> tableProps)
      throws Exception {
    if (client.tableOperations().exists(tableName)) {
      log.error("Accumulo table {} already exists", tableName);
      System.exit(-1);
    }

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

    // set tserver props
    if (!serverProps.isEmpty()) {
      try {
        client.instanceOperations().modifyProperties(properties -> properties.putAll(serverProps));
      } catch (AccumuloException | AccumuloSecurityException e) {
        log.error("Failed to set tserver props");
        throw new Exception(e);
      }
    }

    NewTableConfiguration ntc = new NewTableConfiguration();

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

    ntc.setProperties(tableProps);

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

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