private void processRequest(AsyncRequestInfo asyncRequestInfo) throws RestServiceException {
    long processingStartTime = System.currentTimeMillis();
    // needed to avoid double counting.
    long restRequestProcessingTime = 0;
    RestRequest restRequest = asyncRequestInfo.restRequest;
    try {
      onRequestDequeue(asyncRequestInfo);
      RestResponseChannel restResponseChannel = asyncRequestInfo.restResponseChannel;
      RestMethod restMethod = restRequest.getRestMethod();
      restRequest.prepare();
      logger.trace("Processing request {} with RestMethod {}", restRequest.getUri(), restMethod);
      long restRequestProcessingStartTime = System.currentTimeMillis();
      switch (restMethod) {
        case GET:
          restRequestService.handleGet(restRequest, restResponseChannel);
          break;
        case POST:
          restRequestService.handlePost(restRequest, restResponseChannel);
          break;
        case PUT:
          restRequestService.handlePut(restRequest, restResponseChannel);
          break;
        case DELETE:
          restRequestService.handleDelete(restRequest, restResponseChannel);
          break;
        case HEAD:
          restRequestService.handleHead(restRequest, restResponseChannel);
          break;
        case OPTIONS:
          restRequestService.handleOptions(restRequest, restResponseChannel);
          break;
        default:
          metrics.unknownRestMethodError.inc();
          RestServiceException e = new RestServiceException("Unsupported REST method: " + restMethod,
              RestServiceErrorCode.UnsupportedRestMethod);
          onProcessingFailure(restRequest, restResponseChannel, e);
      }
      restRequestProcessingTime = System.currentTimeMillis() - restRequestProcessingStartTime;
    } finally {
      restRequest.getMetricsTracker().scalingMetricsTracker.addToRequestProcessingTime(
          System.currentTimeMillis() - processingStartTime - restRequestProcessingTime);
    }
  }
Processes the {@code asyncRequestInfo}. Discerns the type of {@link RestMethod} in the request and calls the right
function of the {@link RestRequestService}.
@param asyncRequestInfo the currently dequeued {@link AsyncRequestInfo}.
@throws RestServiceException if the request cannot be prepared for hand-off to the {@link RestRequestService}.
ambry-rest/src/main/java/com/github/ambry/rest/AsyncRequestResponseHandler.java