private String getAndVerifyReservedMetadataBlobId(Map<String, String> metadata, String reservedMetadataBlobId,
        String chunkId) throws RestServiceException {
      String chunkReservedMetadataBlobId = RestUtils.getHeader(metadata, RestUtils.Headers.RESERVED_METADATA_ID, false);
      if (chunkReservedMetadataBlobId == null) {
        ReservedMetadataIdMetrics.getReservedMetadataIdMetrics(
            frontendMetrics.getMetricRegistry()).noReservedMetadataForChunkedUploadCount.inc();
        throwRestServiceExceptionIfEnabled(
            new RestServiceException(String.format("No reserved metadata id present in chunk %s signed url", chunkId),
                RestServiceErrorCode.BadRequest), router.getRouterConfig().routerReservedMetadataEnabled);
      }
      if (reservedMetadataBlobId != null && !reservedMetadataBlobId.equals(chunkReservedMetadataBlobId)) {
        ReservedMetadataIdMetrics.getReservedMetadataIdMetrics(
            frontendMetrics.getMetricRegistry()).mismatchedReservedMetadataForChunkedUploadCount.inc();
        throwRestServiceExceptionIfEnabled(new RestServiceException(String.format(
                "Reserved metadata id for the chunks are not same. For chunk: %s the reserved metadata id is %s. But reserved metadata id %s was found earlier.",
                chunkId, chunkReservedMetadataBlobId, reservedMetadataBlobId), RestServiceErrorCode.BadRequest),
            router.getRouterConfig().routerReservedMetadataEnabled);
      }
      return chunkReservedMetadataBlobId;
    }
Verify that the reserved metadata id for the specified chunkId is same as seen for previous chunks.
Also return the chunk's reserved metadata id.
@param metadata {@link Map} of metadata set in the signed ids.
@param reservedMetadataBlobId Reserved metadata id for the chunks. Can be {@code null}.
@param chunkId The chunk id.
@return The reserved metadata id.
@throws RestServiceException in case of any exception.
ambry-frontend/src/main/java/com/github/ambry/frontend/NamedBlobPutHandler.java