RemoteReplicaInfo removeReplicaInfoIfPresent(ReplicaId remoteReplica) {
    rwLock.writeLock().lock();
    RemoteReplicaInfo replicaInfoToRemove = null;
    try {
      for (RemoteReplicaInfo remoteReplicaInfo : remoteReplicas) {
        if (remoteReplicaInfo.getReplicaId().getDataNodeId() == remoteReplica.getDataNodeId()) {
          replicaInfoToRemove = remoteReplicaInfo;
          break;
        }
      }
      if (replicaInfoToRemove != null) {
        remoteReplicas.remove(replicaInfoToRemove);
      }
    } finally {
      rwLock.writeLock().unlock();
    }
    return replicaInfoToRemove;
  }
Remove {@link RemoteReplicaInfo} of given replica from this {@link PartitionInfo} if it is present.
@param remoteReplica the {@link ReplicaId} whose info should be removed.
@return {@link RemoteReplicaInfo} that is removed, can be null if it is not present.
ambry-replication/src/main/java/com/github/ambry/replication/PartitionInfo.java