private String getDatasetVersion(RestRequest restRequest) throws RestServiceException {
      long startGetDatasetVersionTime = System.currentTimeMillis();
      String accountName = null;
      String containerName = null;
      String datasetName = null;
      String version = null;
      try {
        Dataset dataset = (Dataset) restRequest.getArgs().get(InternalKeys.TARGET_DATASET);
        accountName = dataset.getAccountName();
        containerName = dataset.getContainerName();
        datasetName = dataset.getDatasetName();
        version = (String) restRequest.getArgs().get(TARGET_DATASET_VERSION);
        DatasetVersionRecord datasetVersionRecord =
            accountService.getDatasetVersion(accountName, containerName, datasetName, version);
        FrontendUtils.replaceRequestPathWithNewOperationOrBlobIdIfNeeded(restRequest, datasetVersionRecord, version);
        restResponseChannel.setHeader(RestUtils.Headers.TARGET_ACCOUNT_NAME, accountName);
        restResponseChannel.setHeader(RestUtils.Headers.TARGET_CONTAINER_NAME, containerName);
        restResponseChannel.setHeader(RestUtils.Headers.TARGET_DATASET_NAME, datasetName);
        restResponseChannel.setHeader(RestUtils.Headers.TARGET_DATASET_VERSION, datasetVersionRecord.getVersion());
        if (datasetVersionRecord.getRenameFrom() != null) {
          restResponseChannel.setHeader(RestUtils.Headers.TARGET_DATASET_ORIGINAL_VERSION,
              datasetVersionRecord.getRenameFrom());
        }
        if (datasetVersionRecord.getExpirationTimeMs() != Utils.Infinite_Time) {
          restResponseChannel.setHeader(RestUtils.Headers.DATASET_EXPIRATION_TIME,
              new Date(datasetVersionRecord.getExpirationTimeMs()));
        }
        metrics.getDatasetVersionProcessingTimeInMs.update(System.currentTimeMillis() - startGetDatasetVersionTime);
        // If version is null, use the latest version + 1 from DatasetVersionRecord to construct named blob path.
        return datasetVersionRecord.getNamedBlobNamePath(accountName, containerName);
      } catch (AccountServiceException ex) {
        LOGGER.error(
            "Failed to get dataset version for accountName: " + accountName + " containerName: " + containerName
                + " datasetName: " + datasetName + " version: " + version);
        throw new RestServiceException(ex.getMessage(),
            RestServiceErrorCode.getRestServiceErrorCode(ex.getErrorCode()));
      }
    }
Support get dataset version queries before get the named blob.
@param restRequest {@link RestRequest} representing the request.
@return the named blob path uri corresponding to the dataset version.
@throws RestServiceException
ambry-frontend/src/main/java/com/github/ambry/frontend/GetBlobHandler.java