@Override
  public synchronized void setStatus(ResponseStatus status) throws RestServiceException {
    if (isOpen() && !responseMetadataFinalized.get()) {
      try {
        responseMetadata.put(RESPONSE_STATUS_KEY, status.name());
        onEventComplete(Event.SetStatus);
      } catch (JSONException e) {
        throw new RestServiceException("Unable to set Status", RestServiceErrorCode.InternalServerError);
      }
    } else {
      throw new IllegalStateException("Cannot change response metadata after it has been finalized");
    }
  }
Called when an event (function call) finishes successfully in MockRestResponseChannel. Does *not* trigger if the
event (function) fails.
@param mockRestResponseChannel the {@link MockRestResponseChannel} where the event occurred.
@param event the {@link Event} that occurred.
ambry-test-utils/src/main/java/com/github/ambry/rest/MockRestResponseChannel.java