@Override
  public ReplicateWALEntryResponse replicateToReplica(RpcController controller,
    ReplicateWALEntryRequest request) throws ServiceException {
    CellScanner cells = getAndReset(controller);
    try {
      checkOpen();
      List<WALEntry> entries = request.getEntryList();
      if (entries == null || entries.isEmpty()) {
        // empty input
        return ReplicateWALEntryResponse.newBuilder().build();
      }
      ByteString regionName = entries.get(0).getKey().getEncodedRegionName();
      HRegion region = server.getRegionByEncodedName(regionName.toStringUtf8());
      if (RegionReplicaUtil.isDefaultReplica(region.getRegionInfo())) {
        throw new DoNotRetryIOException(
          "Should not replicate to primary replica " + region.getRegionInfo() + ", CODE BUG?");
      }
      for (WALEntry entry : entries) {
        if (!regionName.equals(entry.getKey().getEncodedRegionName())) {
          throw new NotServingRegionException(
            "ReplicateToReplica request contains entries from multiple " + "regions. First region:"
              + regionName.toStringUtf8() + " , other region:"
              + entry.getKey().getEncodedRegionName());
        }
        region.replayWALEntry(entry, cells);
      }
      return ReplicateWALEntryResponse.newBuilder().build();
    } catch (IOException ie) {
      throw new ServiceException(ie);
    }
  }
Replay the given changes on a secondary replica
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java