protected ServerErrorCode validateRequest(PartitionId partition, RequestOrResponseType requestType,
      boolean skipPartitionAndDiskAvailableCheck) {
    // Check partition is not null
    if (partition == null) {
      metrics.badRequestError.inc();
      return ServerErrorCode.BadRequest;
    }
    // Ensure if the partition can be written to
    if (requestType.equals(RequestOrResponseType.PutRequest)
        && partition.getPartitionState() == PartitionState.READ_ONLY) {
      metrics.partitionReadOnlyError.inc();
      return ServerErrorCode.PartitionReadOnly;
    }
    return ServerErrorCode.NoError;
  }
Check that the provided partition is valid and writable, and the disk (if any) is available.
@param partition the partition to validate.
@param requestType the {@link RequestOrResponseType} being validated.
@param skipPartitionAndDiskAvailableCheck whether to skip ({@code true}) conditions check for the availability of
                                          partition and disk.
@return {@link ServerErrorCode#NoError} error if the partition can be written to, or the corresponding error code
        if it cannot.
ambry-server/src/main/java/com/github/ambry/server/AmbryRequests.java