@BeforeClass
  public static void setUpBeforeClass() throws IOException {
    CONF.setInt(AsyncConnectionConfiguration.START_LOG_ERRORS_AFTER_COUNT_KEY, 0);
    AsyncRegionLocator locator = mock(AsyncRegionLocator.class);
    when(locator.getRegionLocation(any(), any(), anyInt(), any(), anyLong()))
      .thenReturn(CompletableFuture.completedFuture(new HRegionLocation(REPLICA,
        ServerName.valueOf("localhost", 12345, EnvironmentEdgeManager.currentTime()))));
    AdminService.Interface stub = mock(AdminService.Interface.class);
    // fail the call to replicateToReplica
    doAnswer(i -> {
      HBaseRpcController controller = i.getArgument(0, HBaseRpcController.class);
      controller.setFailed(new DoNotRetryIOException(new UnsupportedOperationException()));
      RpcCallback<?> done = i.getArgument(2, RpcCallback.class);
      done.run(null);
      return null;
    }).when(stub).replicateToReplica(any(), any(), any());
    doAnswer(i -> {
      REPLAY_CALLED.set(true);
      RpcCallback<?> done = i.getArgument(2, RpcCallback.class);
      done.run(null);
      return null;
    }).when(stub).replay(any(), any(), any());
    CONN = new AsyncClusterConnectionImpl(CONF, mock(ConnectionRegistry.class), "test", null,
      User.getCurrent()) {

      @Override
      AsyncRegionLocator getLocator() {
        return locator;
      }

      @Override
      Interface getAdminStub(ServerName serverName) throws IOException {
        return stub;
      }
    };
    CALLER = new AsyncRegionReplicationRetryingCaller(AsyncClusterConnectionImpl.RETRY_TIMER, CONN,
      10, TimeUnit.SECONDS.toNanos(1), TimeUnit.SECONDS.toNanos(10), REPLICA,
      Collections.emptyList());
  }
Make sure we could fallback to use replay method if replicateToReplica method is not present,
i.e, we are connecting an old region server.
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFallbackToUseReplay.java