public static VisibilityLabelsResponse addLabels(Connection connection, final String[] labels)
    throws Throwable {
    try (Table table = connection.getTable(LABELS_TABLE_NAME)) {
      Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse> callable =
        new Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse>() {
          ServerRpcController controller = new ServerRpcController();
          CoprocessorRpcUtils.BlockingRpcCallback<VisibilityLabelsResponse> rpcCallback =
            new CoprocessorRpcUtils.BlockingRpcCallback<>();

          @Override
          public VisibilityLabelsResponse call(VisibilityLabelsService service) throws IOException {
            VisibilityLabelsRequest.Builder builder = VisibilityLabelsRequest.newBuilder();
            for (String label : labels) {
              if (label.length() > 0) {
                VisibilityLabel.Builder newBuilder = VisibilityLabel.newBuilder();
                newBuilder.setLabel(UnsafeByteOperations.unsafeWrap(Bytes.toBytes(label)));
                builder.addVisLabel(newBuilder.build());
              }
            }
            service.addLabels(controller, builder.build(), rpcCallback);
            VisibilityLabelsResponse response = rpcCallback.get();
            if (controller.failedOnException()) {
              throw controller.getFailedOn();
            }
            return response;
          }
        };
      Map<byte[], VisibilityLabelsResponse> result =
        table.coprocessorService(VisibilityLabelsService.class, HConstants.EMPTY_BYTE_ARRAY,
          HConstants.EMPTY_BYTE_ARRAY, callable);
      return result.values().iterator().next(); // There will be exactly one region for labels
      // table and so one entry in result Map.
    }
  }
Utility method for adding labels to the system.
hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityClient.java