protected void stopPartitionReplication(PartitionId partitionId) {
    PartitionInfo partitionInfo = partitionToPartitionInfo.remove(partitionId);
    if (partitionInfo == null) {
      logger.warn("Partition {} doesn't exist when removing it from {}. ", partitionId, dataNodeId);
      return;
    }
    removeRemoteReplicaInfoFromReplicaThread(partitionInfo.getRemoteReplicaInfos());
    if (replicationConfig.replicationPersistTokenOnShutdownOrReplicaRemove && persistor != null) {
      try {
        persistor.write(partitionInfo.getLocalReplicaId().getMountPath(), false);
      } catch (IOException | ReplicationException e) {
        logger.error("Exception {} on token write when removing Partition {} from: {}", e, partitionId, dataNodeId);
      }
    }
  }
Stop replication for the specified {@link PartitionId}.
@param partitionId {@link PartitionId} for which replication should be removed.
ambry-replication/src/main/java/com/github/ambry/replication/ReplicationEngine.java