private AdminResponse handleReplicationControlRequest(DataInputStream requestStream, AdminRequest adminRequest)
      throws IOException {
    Collection<PartitionId> partitionIds;
    ServerErrorCode error = ServerErrorCode.NoError;
    ReplicationControlAdminRequest replControlRequest =
        ReplicationControlAdminRequest.readFrom(requestStream, adminRequest);
    if (replControlRequest.getPartitionId() != null) {
      error = validateRequest(replControlRequest.getPartitionId(), RequestOrResponseType.AdminRequest, false);
      partitionIds = Collections.singletonList(replControlRequest.getPartitionId());
    } else {
      partitionIds = storeManager.getLocalPartitions();
    }
    if (!error.equals(ServerErrorCode.PartitionUnknown)) {
      if (replicationEngine.controlReplicationForPartitions(partitionIds, replControlRequest.getOrigins(),
          replControlRequest.shouldEnable())) {
        error = ServerErrorCode.NoError;
      } else {
        logger.error("Could not set enable status for replication of {} from {} to {}. Check partition validity and"
            + " origins list", partitionIds, replControlRequest.getOrigins(), replControlRequest.shouldEnable());
        error = ServerErrorCode.BadRequest;
      }
    }
    return new AdminResponse(adminRequest.getCorrelationId(), adminRequest.getClientId(), error);
  }
Handles {@link com.github.ambry.protocol.AdminRequestOrResponseType#ReplicationControl}.
@param requestStream the serialized bytes of the request.
@param adminRequest the {@link AdminRequest} received.
@return the {@link AdminResponse} to the request.
@throws IOException if there is any I/O error reading from the {@code requestStream}.
ambry-server/src/main/java/com/github/ambry/server/AmbryServerRequests.java