@Override
  public CompletableFuture<Boolean> replicationPeerModificationSwitch(boolean on,
    boolean drainProcedures) {
    ReplicationPeerModificationSwitchRequest request =
      ReplicationPeerModificationSwitchRequest.newBuilder().setOn(on).build();
    CompletableFuture<Boolean> callFuture = this.<Boolean> newMasterCaller()
      .action((controller, stub) -> this.<ReplicationPeerModificationSwitchRequest,
        ReplicationPeerModificationSwitchResponse, Boolean> call(controller, stub, request,
          (s, c, req, done) -> s.replicationPeerModificationSwitch(c, req, done),
          resp -> resp.getPreviousValue()))
      .call();
    // if we do not need to wait all previous peer modification procedure done, or we are enabling
    // peer modification, just return here.
    if (!drainProcedures || on) {
      return callFuture;
    }
    // otherwise we need to wait until all previous peer modification procedure done
    CompletableFuture<Boolean> future = new CompletableFuture<>();
    addListener(callFuture, (prevOn, err) -> {
      if (err != null) {
        future.completeExceptionally(err);
        return;
      }
      // even if the previous state is disabled, we still need to wait here, as there could be
      // another client thread which called this method just before us and have already changed the
      // state to off, but there are still peer modification procedures not finished, so we should
      // also wait here.
      waitUntilAllReplicationPeerModificationProceduresDone(future, prevOn, 0);
    });
    return future;
  }
Set the table's replication switch if the table's replication switch is already not set.
@param tableName name of the table
@param enableRep is replication switch enable or disable
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java