@Test
  public void testBulkLoadByFamily() throws Exception {
    Path dir = util.getDataTestDirOnTestFS("testBulkLoadByFamily");
    FileSystem fs = util.getTestFileSystem();
    dir = dir.makeQualified(fs.getUri(), fs.getWorkingDirectory());
    String tableName = tn.getMethodName();
    String[] families = { "cf1", "cf2", "cf3" };
    for (int i = 0; i < families.length; i++) {
      byte[] from = Bytes.toBytes(i + "begin");
      byte[] to = Bytes.toBytes(i + "end");
      Path familyDir = new Path(dir, families[i]);
      HFileTestUtil.createHFile(util.getConfiguration(), fs, new Path(familyDir, "hfile"),
        Bytes.toBytes(families[i]), QUALIFIER, from, to, 1000);
    }
    Table table = util.createTable(TableName.valueOf(tableName), families);
    final AtomicInteger attmptedCalls = new AtomicInteger();
    util.getConfiguration().setBoolean(BulkLoadHFilesTool.BULK_LOAD_HFILES_BY_FAMILY, true);
    BulkLoadHFiles loader = new BulkLoadHFilesTool(util.getConfiguration()) {
      @Override
      protected CompletableFuture<Collection<LoadQueueItem>> tryAtomicRegionLoad(
        final AsyncClusterConnection conn, final TableName tableName, boolean copyFiles,
        final byte[] first, Collection<LoadQueueItem> lqis) {
        attmptedCalls.incrementAndGet();
        return super.tryAtomicRegionLoad(conn, tableName, copyFiles, first, lqis);
      }
    };
    try {
      loader.bulkLoad(table.getName(), dir);
      assertEquals(families.length, attmptedCalls.get());
      assertEquals(1000 * families.length, HBaseTestingUtil.countRows(table));
    } finally {
      if (null != table) {
        table.close();
      }
      util.getConfiguration().setBoolean(BulkLoadHFilesTool.BULK_LOAD_HFILES_BY_FAMILY, false);
    }
  }
test split storefile with favorite node information
hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java