use of com.github.ambry.rest.RequestPath in project ambry by linkedin.
the class FrontendRestRequestService method handleGet.
@Override
public void handleGet(final RestRequest restRequest, final RestResponseChannel restResponseChannel) {
ThrowingConsumer<RequestPath> routingAction = requestPath -> {
if (requestPath.matchesOperation(Operations.GET_PEERS)) {
getPeersHandler.handle(restRequest, restResponseChannel, (result, exception) -> submitResponse(restRequest, restResponseChannel, result, exception));
} else if (requestPath.matchesOperation(Operations.GET_CLUSTER_MAP_SNAPSHOT)) {
getClusterMapSnapshotHandler.handle(restRequest, restResponseChannel, (result, exception) -> submitResponse(restRequest, restResponseChannel, result, exception));
} else if (requestPath.matchesOperation(Operations.GET_SIGNED_URL)) {
getSignedUrlHandler.handle(restRequest, restResponseChannel, (result, exception) -> submitResponse(restRequest, restResponseChannel, result, exception));
} else if (requestPath.matchesOperation(Operations.ACCOUNTS)) {
getAccountsHandler.handle(restRequest, restResponseChannel, (result, exception) -> submitResponse(restRequest, restResponseChannel, result, exception));
} else if (requestPath.matchesOperation(Operations.STATS_REPORT)) {
getStatsReportHandler.handle(restRequest, restResponseChannel, (result, exception) -> submitResponse(restRequest, restResponseChannel, result, exception));
} else if (requestPath.matchesOperation(Operations.NAMED_BLOB) && NamedBlobPath.parse(requestPath, restRequest.getArgs()).getBlobName() == null) {
listNamedBlobsHandler.handle(restRequest, restResponseChannel, ((result, exception) -> submitResponse(restRequest, restResponseChannel, result, exception)));
} else {
SubResource subResource = requestPath.getSubResource();
GetBlobOptions options = buildGetBlobOptions(restRequest.getArgs(), subResource, getGetOption(restRequest, frontendConfig.defaultRouterGetOption), restRequest, requestPath.getBlobSegmentIdx());
GetCallback routerCallback = new GetCallback(restRequest, restResponseChannel, subResource, options);
SecurityProcessRequestCallback securityCallback = new SecurityProcessRequestCallback(restRequest, restResponseChannel, routerCallback);
if (subResource == SubResource.Replicas) {
securityCallback = new SecurityProcessRequestCallback(restRequest, restResponseChannel);
}
RestRequestMetricsGroup metricsGroup = getMetricsGroupForGet(frontendMetrics, subResource);
RestRequestMetrics restRequestMetrics = metricsGroup.getRestRequestMetrics(restRequest.isSslUsed(), false);
restRequest.getMetricsTracker().injectMetrics(restRequestMetrics);
// named blob requests have their account/container in the URI, so checks can be done prior to ID conversion.
if (requestPath.matchesOperation(Operations.NAMED_BLOB)) {
accountAndContainerInjector.injectAccountAndContainerForNamedBlob(restRequest, metricsGroup);
}
securityService.processRequest(restRequest, securityCallback);
}
};
preProcessAndRouteRequest(restRequest, restResponseChannel, frontendMetrics.getPreProcessingMetrics, routingAction);
}
Aggregations