Skip to content

Commit

Permalink
Rename BlobStorageService to RestRequestService (#1342)
Browse files Browse the repository at this point in the history
Rename BlobStorageService to RestRequestService, for

1. RestRequestService makes more sense since the interface arguments are RestRequest.
2. Create have clearer names for FrontendRestRequestService and StorageServerRestRequestService.
  • Loading branch information
zzmao authored and justinlin-linkedin committed Dec 18, 2019
1 parent 1d12e5c commit 37c6246
Show file tree
Hide file tree
Showing 42 changed files with 428 additions and 431 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,28 @@ public class FrontendConfig {
public final String optionsAllowMethods;

/**
* The IdConverterFactory that needs to be used by AmbryBlobStorageService to convert IDs.
* The IdConverterFactory that needs to be used by FrontendRestRequestService to convert IDs.
*/
@Config("frontend.id.converter.factory")
@Default("com.github.ambry.frontend.AmbryIdConverterFactory")
public final String idConverterFactory;

/**
* The SecurityServiceFactory that needs to be used by AmbryBlobStorageService to validate requests.
* The SecurityServiceFactory that needs to be used by FrontendRestRequestService to validate requests.
*/
@Config("frontend.security.service.factory")
@Default("com.github.ambry.frontend.AmbrySecurityServiceFactory")
public final String securityServiceFactory;

/**
* The UrlSigningServiceFactory that needs to be used by AmbryBlobStorageService to sign and verify URLs.
* The UrlSigningServiceFactory that needs to be used by FrontendRestRequestService to sign and verify URLs.
*/
@Config("frontend.url.signing.service.factory")
@Default("com.github.ambry.frontend.AmbryUrlSigningServiceFactory")
public final String urlSigningServiceFactory;

/**
* The IdSigningService that needs to be used by AmbryBlobStorageService to sign and verify IDs.
* The IdSigningService that needs to be used by FrontendRestRequestService to sign and verify IDs.
*/
private static final String ID_SIGNING_SERVICE_FACTORY_KEY = PREFIX + "id.signing.service.factory";
@Config(ID_SIGNING_SERVICE_FACTORY_KEY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package com.github.ambry.config;

import com.github.ambry.rest.RestRequestService;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
Expand Down Expand Up @@ -121,7 +122,7 @@ public class NettyConfig {

/**
* A comma separated list of query parameters that should not be honored when forwarded to the
* {@link com.github.ambry.rest.BlobStorageService} layer.
* {@link RestRequestService} layer.
*/
@Config(NETTY_SERVER_BLACKLISTED_QUERY_PARAMS)
@Default("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/
public class RestServerConfig {
/**
* The BlobStorageServiceFactory that needs to be used by the RestServer
* for bootstrapping the BlobStorageService.
* The RestRequestServiceFactory that needs to be used by the RestServer
* for bootstrapping the RestRequestService.
*/
@Config("rest.server.blob.storage.service.factory")
public final String restServerBlobStorageServiceFactory;
@Config("rest.server.rest.request.service.factory")
public final String restServerRestRequestServiceFactory;

/**
* The NioServerFactory that needs to be used by the RestServer or AmbryServer for
Expand Down Expand Up @@ -63,7 +63,7 @@ public class RestServerConfig {
public final String restServerResponseHandlerFactory;

/**
* The AccountServiceFactory that needs to be used by AmbryBlobStorageService to get account-related information.
* The AccountServiceFactory that needs to be used by FrontendRestRequestService to get account-related information.
*/
@Config("rest.server.account.service.factory")
@Default("com.github.ambry.account.InMemoryUnknownAccountServiceFactory")
Expand Down Expand Up @@ -99,7 +99,7 @@ public class RestServerConfig {
public final String restServerHealthCheckUri;

public RestServerConfig(VerifiableProperties verifiableProperties) {
restServerBlobStorageServiceFactory = verifiableProperties.getString("rest.server.blob.storage.service.factory");
restServerRestRequestServiceFactory = verifiableProperties.getString("rest.server.rest.request.service.factory");
restServerNioServerFactory = verifiableProperties.getString("rest.server.nio.server.factory",
"com.github.ambry.rest.FrontendNettyFactory");
restServerRequestHandlerScalingUnitCount =
Expand Down
4 changes: 2 additions & 2 deletions ambry-api/src/main/java/com.github.ambry/rest/NioServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
* and sending responses and supports doing these operations in a non-blocking manner.
* <p/>
* A typical implementation of a NioServer will handle incoming connections from clients, decode the REST protocol
* (usually HTTP), convert them to generic objects that the {@link BlobStorageService} can understand, instantiate a
* (usually HTTP), convert them to generic objects that the {@link RestRequestService} can understand, instantiate a
* NioServer specific implementation of {@link RestResponseChannel} to return responses to clients and push them down
* the pipeline. The NioServer should be non-blocking while receiving requests and sending responses. It should also
* provide methods that the downstream can use to control the flow of data towards the {@link BlobStorageService}.
* provide methods that the downstream can use to control the flow of data towards the {@link RestRequestService}.
*/
public interface NioServer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* Meant to be the component that handles and routes all incoming requests.
* <p/>
* The requests are usually submitted by a {@link NioServer} and handled by a {@link BlobStorageService} with the
* The requests are usually submitted by a {@link NioServer} and handled by a {@link RestRequestService} with the
* RestRequestHandler forming a bridge between them to provide scaling capabilities and non-blocking behaviour.
* <p/>
* Implementations are expected to be thread-safe.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* {@link RestRequestMetrics} (metrics) object associated with the tracker tracks "unknown" requests.
* 3. As the request passes through the NIO framework and the scaling framework, metrics associated with these layers
* are tracked and stored but not updated in the metrics object.
* 4. When the request reaches the {@link BlobStorageService}, it is usually identified as a specific type and a custom
* 4. When the request reaches the {@link RestRequestService}, it is usually identified as a specific type and a custom
* metrics object that tracks that specific type of request is "injected" into the tracker associated with the
* request.
* 5. When the response for the request is complete and the request is "closed", the metrics that are stored are
Expand Down Expand Up @@ -124,7 +124,7 @@ public void markRequestCompleted() {

/**
* Helper for updating scaling related metrics. These metrics are updated in the classes that provide scaling
* capabilities when transferring control from {@link NioServer} to {@link BlobStorageService}.
* capabilities when transferring control from {@link NioServer} to {@link RestRequestService}.
*/
public static class ScalingMetricsTracker {
private final AtomicLong requestProcessingTimeInMs = new AtomicLong(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,24 @@
package com.github.ambry.rest;

/**
* BlobStorageService defines a service that forms the bridge b/w a RESTful frontend and a storage backend (or something
* that communicates with a storage backend).
* <p/>
* Typically, a BlobStorageService is expected to receive requests from the RESTful frontend, handle them as required
* and either send a response (if immediately available) or pass control to another component that does further handling
* and generates a response. The information received from the scaling layer should be enough to perform these
* functions.
* <p/>
* RestRequestService defines a service that handles {@link RestRequest}.
* Typically, a RestRequestService is expected to receive requests and handle them as required and either send a
* response (if immediately available) or pass control to another component that does further handling and generates a
* response.
* Most operations are performed async and responses are therefore queued asynchronously instead of being available at
* the end of the function call.
* <p/>
* Implementations are expected to be thread-safe.
*/
public interface BlobStorageService {
public interface RestRequestService {

/**
* Does startup tasks for the BlobStorageService. When the function returns, startup is FULLY complete.
* @throws InstantiationException if BlobStorageService is unable to start.
* Does startup tasks for the RestRequestService. When the function returns, startup is FULLY complete.
* @throws InstantiationException if RestRequestService is unable to start.
*/
public void start() throws InstantiationException;

/**
* Does shutdown tasks for the BlobStorageService. When the function returns, shutdown is FULLY complete.
* Does shutdown tasks for the RestRequestService. When the function returns, shutdown is FULLY complete.
*/
public void shutdown();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
package com.github.ambry.rest;

/**
* BlobStorageServiceFactory is a factory to generate all the supporting cast required to instantiate a
* {@link BlobStorageService}.
* RestRequestServiceFactory is a factory to generate all the supporting cast required to instantiate a
* {@link RestRequestService}.
* <p/>
* Usually called with the canonical class name and as such might have to support appropriate (multiple) constructors.
*/
public interface BlobStorageServiceFactory {
public interface RestRequestServiceFactory {

/**
* Returns an instance of the {@link BlobStorageService} that the factory generates.
* @return an instance of {@link BlobStorageService} generated by this factory.
* @throws InstantiationException if the {@link BlobStorageService} instance cannot be created.
* Returns an instance of the {@link RestRequestService} that the factory generates.
* @return an instance of {@link RestRequestService} generated by this factory.
* @throws InstantiationException if the {@link RestRequestService} instance cannot be created.
*/
public BlobStorageService getBlobStorageService() throws InstantiationException;
public RestRequestService getRestRequestService() throws InstantiationException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
/**
* The RestResponseChannel is meant to provide a {@link NioServer} implementation independent way to return responses
* to the client. It deals with data in terms of bytes only and is not concerned with different types of data that might
* need to be returned from the {@link BlobStorageService}.
* need to be returned from the {@link RestRequestService}.
* <p/>
* This functionality is mostly required by implementations of {@link BlobStorageService} since they are agnostic to
* This functionality is mostly required by implementations of {@link RestRequestService} since they are agnostic to
* both the REST protocol being used and the framework used for the implementation of {@link NioServer}.
* <p/>
* Typically, the RestResponseChannel wraps the underlying network channel and the APIs of the NIO framework to return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Meant to be the component that handles and routes all outgoing responses.
* <p/>
* The responses are usually submitted by the {@link BlobStorageService} and sent out via the
* The responses are usually submitted by the {@link RestRequestService} and sent out via the
* {@link RestResponseChannel} with the RestResponseHandler forming a bridge between them to provide scaling
* capabilities and non-blocking behaviour.
* <p/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static final class Headers {
public final static String ENCRYPTED_IN_STORAGE = "x-ambry-encrypted-in-storage";
/**
* optional in request; defines an option while getting the blob and is optional support in a
* {@link BlobStorageService}. Valid values are available in {@link GetOption}. Defaults to {@link GetOption#None}
* {@link RestRequestService}. Valid values are available in {@link GetOption}. Defaults to {@link GetOption#None}
*/
public final static String GET_OPTION = "x-ambry-get-option";
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* Implementation of {@link RestRequestHandler} and {@link RestResponseHandler} that can be used in tests.
* <p/>
* This implementation simply calls the appropriate method (based on the {@link RestMethod} in the request) in the
* underlying {@link BlobStorageService} on being asked to handle a request. If the implementation of
* {@link BlobStorageService} is blocking, then this will be blocking too.
* underlying {@link RestRequestService} on being asked to handle a request. If the implementation of
* {@link RestRequestService} is blocking, then this will be blocking too.
* <p/>
* Submitted responses also will be sent out immediately so response handling will block until the response has been
* sent out completely.
Expand All @@ -40,12 +40,12 @@ public class MockRestRequestResponseHandler implements RestRequestHandler, RestR
private boolean isRunning = false;
private VerifiableProperties failureProperties = null;

private BlobStorageService blobStorageService = null;
private RestRequestService restRequestService = null;

@Override
public void start() throws InstantiationException {
if (blobStorageService == null) {
throw new InstantiationException("BlobStorageService not set");
if (restRequestService == null) {
throw new InstantiationException("RestRequestService not set");
}
isRunning = true;
}
Expand All @@ -56,8 +56,8 @@ public void shutdown() {
}

/**
* Calls the appropriate method in the {@link BlobStorageService}. Non-blocking nature depends on the implementation
* of the underlying {@link BlobStorageService}.
* Calls the appropriate method in the {@link RestRequestService}. Non-blocking nature depends on the implementation
* of the underlying {@link RestRequestService}.
* @param restRequest the {@link RestRequest} that needs to be handled.
* @param restResponseChannel the {@link RestResponseChannel} on which a response to the request may be sent.
* @throws IllegalArgumentException if either of {@code restRequest} or {@code restResponseChannel} is null.
Expand All @@ -71,19 +71,19 @@ public void handleRequest(RestRequest restRequest, RestResponseChannel restRespo
restRequest.prepare();
switch (restMethod) {
case GET:
blobStorageService.handleGet(restRequest, restResponseChannel);
restRequestService.handleGet(restRequest, restResponseChannel);
break;
case POST:
blobStorageService.handlePost(restRequest, restResponseChannel);
restRequestService.handlePost(restRequest, restResponseChannel);
break;
case PUT:
blobStorageService.handlePut(restRequest, restResponseChannel);
restRequestService.handlePut(restRequest, restResponseChannel);
break;
case DELETE:
blobStorageService.handleDelete(restRequest, restResponseChannel);
restRequestService.handleDelete(restRequest, restResponseChannel);
break;
case HEAD:
blobStorageService.handleHead(restRequest, restResponseChannel);
restRequestService.handleHead(restRequest, restResponseChannel);
break;
default:
throw new RestServiceException("Unknown rest method - " + restMethod,
Expand Down Expand Up @@ -143,11 +143,11 @@ public void fix() {
}

/**
* Sets the {@link BlobStorageService} that will be used.
* @param blobStorageService the {@link BlobStorageService} instance to be used to process requests.
* Sets the {@link RestRequestService} that will be used.
* @param restRequestService the {@link RestRequestService} instance to be used to process requests.
*/
protected void setBlobStorageService(BlobStorageService blobStorageService) {
this.blobStorageService = blobStorageService;
protected void setRestRequestService(RestRequestService restRequestService) {
this.restRequestService = restRequestService;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public MockRestRequestResponseHandlerFactory(Object handlerCount, Object metricR
}

public MockRestRequestResponseHandlerFactory(Object handlerCount, Object metricRegistry,
BlobStorageService blobStorageService) {
RestRequestService restRequestService) {
MockRestRequestResponseHandler requestHandler = getInstance();
requestHandler.setBlobStorageService(blobStorageService);
requestHandler.setRestRequestService(restRequestService);
}

/**
Expand Down
Loading

0 comments on commit 37c6246

Please sign in to comment.