public static BulkLoadHFileRequest buildBulkLoadHFileRequest(
    final List<Pair<byte[], String>> familyPaths, final byte[] regionName, boolean assignSeqNum,
    final Token<?> userToken, final String bulkToken, boolean copyFiles, List<String> clusterIds,
    boolean replicate) {
    RegionSpecifier region =
      RequestConverter.buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);

    ClientProtos.DelegationToken protoDT = null;
    if (userToken != null) {
      protoDT = ClientProtos.DelegationToken.newBuilder()
        .setIdentifier(UnsafeByteOperations.unsafeWrap(userToken.getIdentifier()))
        .setPassword(UnsafeByteOperations.unsafeWrap(userToken.getPassword()))
        .setKind(userToken.getKind().toString()).setService(userToken.getService().toString())
        .build();
    }

    List<ClientProtos.BulkLoadHFileRequest.FamilyPath> protoFamilyPaths =
      new ArrayList<>(familyPaths.size());
    if (!familyPaths.isEmpty()) {
      ClientProtos.BulkLoadHFileRequest.FamilyPath.Builder pathBuilder =
        ClientProtos.BulkLoadHFileRequest.FamilyPath.newBuilder();
      for (Pair<byte[], String> el : familyPaths) {
        protoFamilyPaths.add(pathBuilder.setFamily(UnsafeByteOperations.unsafeWrap(el.getFirst()))
          .setPath(el.getSecond()).build());
      }
      pathBuilder.clear();
    }

    BulkLoadHFileRequest.Builder request = ClientProtos.BulkLoadHFileRequest.newBuilder()
      .setRegion(region).setAssignSeqNum(assignSeqNum).addAllFamilyPath(protoFamilyPaths);
    if (userToken != null) {
      request.setFsToken(protoDT);
    }
    if (bulkToken != null) {
      request.setBulkToken(bulkToken);
    }
    request.setCopyFile(copyFiles);
    if (clusterIds != null) {
      request.addAllClusterIds(clusterIds);
    }
    request.setReplicate(replicate);
    return request.build();
  }
Create a protocol buffer bulk load request
@return a bulk load request
hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java