Package com.google.apphosting.runtime
Class RequestManager
java.lang.Object
com.google.apphosting.runtime.RequestManager
- All Implemented Interfaces:
RequestThreadManager
RequestManager is responsible for setting up and tearing down any state associated with
each request.
At the moment, this includes:
- Injecting an
Environmentimplementation for the request's thread intoApiProxy. - Scheduling any future actions that must occur while the request is executing (e.g. deadline exceptions), and cleaning up any scheduled actions that do not occur.
RequestManager.RequestToken token =
requestManager.startRequest(...);
try {
...
} finally {
requestManager.finishRequest(token);
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for of a RequestManager instance.classDeadlineRunnablecauses the specifiedThrowableto be thrown within the specified thread.static classRequestTokenacts as a Memento object that passes state between a call tostartRequestandfinishRequest. -
Method Summary
Modifier and TypeMethodDescriptionstatic RequestManager.Builderbuilder()Make a partly-initialized builder for a RequestManager.voidfinishRequest(RequestManager.RequestToken requestToken) Tear down any state associated with the specified request, and restore the current thread's state as it was beforestartRequestwas called.getRequestThreads(AppVersionKey appVersionKey) voidsendDeadline(RequestManager.RequestToken token, boolean isUncatchable) voidsendDeadline(String securityTicket, boolean isUncatchable) voidsetMaxOutstandingApiRpcs(int maxOutstandingApiRpcs) voidNotify requests that the server is shutting down.startRequest(AppVersion appVersion, AnyRpcServerContext rpc, com.google.apphosting.base.protos.RuntimePb.UPRequest upRequest, MutableUpResponse upResponse, ThreadGroup requestThreadGroup) startRequest(AppVersion appVersion, AnyRpcServerContext rpc, RequestAPIData genericRequest, ResponseAPIData genericResponse, ThreadGroup requestThreadGroup) Set up any state necessary to execute a new request using the specified parameters.
-
Method Details
-
builder
Make a partly-initialized builder for a RequestManager. -
setMaxOutstandingApiRpcs
public void setMaxOutstandingApiRpcs(int maxOutstandingApiRpcs) -
startRequest
public RequestManager.RequestToken startRequest(AppVersion appVersion, AnyRpcServerContext rpc, com.google.apphosting.base.protos.RuntimePb.UPRequest upRequest, MutableUpResponse upResponse, ThreadGroup requestThreadGroup) -
startRequest
public RequestManager.RequestToken startRequest(AppVersion appVersion, AnyRpcServerContext rpc, RequestAPIData genericRequest, ResponseAPIData genericResponse, ThreadGroup requestThreadGroup) Set up any state necessary to execute a new request using the specified parameters. The current thread should be the one that will execute the new request.- Returns:
- a
RequestTokenthat should be passed intofinishRequestafter the request completes.
-
finishRequest
Tear down any state associated with the specified request, and restore the current thread's state as it was beforestartRequestwas called.- Throws:
IllegalStateException- if called from the wrong thread.
-
sendDeadline
-
sendDeadline
-
shutdownRequests
Notify requests that the server is shutting down. -
getRequestThreads
- Specified by:
getRequestThreadsin interfaceRequestThreadManager
-