public class RequestBundler extends Object
Constructor and Description |
---|
RequestBundler(BroadWorksServer broadWorksServer)
Creates a new RequestBundler for the given BroadWorksServer
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
Future<ResponseBundle> |
fire()
Fires the RequestBundler.
|
org.apache.commons.lang3.mutable.MutableInt |
getOutstandingBundleCount() |
int |
getQueueSize() |
ExecutorService |
getResponseService() |
<R extends Response> |
postResponse(Request<R> request,
ResponseBundle responseBundle)
Posts the response from the response bundle to the mapped request.
|
<R extends Response> |
put(Request<R> request,
Consumer<R> consumer)
Adds a Request to the RequestBundler to be completed in the next outgoing bundle.
|
<R extends Response> |
put(Request<R> request,
Consumer<R> consumer,
boolean forceFire)
Adds a Request to the RequestBundler to be completed in the next outgoing bundle.
|
<R extends Response> |
putAndWait(List<? extends Request<R>> requests,
Consumer<R> consumer)
Adds a list of Requests to the RequestBundler and waits until the Requests have been completed to return.
|
<R extends Response> |
putAndWait(Request<R> request,
Consumer<R> consumer)
Adds a Request to the RequestBundler and waits until the Request has been completed to return.
|
Future<ResponseBundle> |
resendAlone(Request<? extends Response> request)
Resends a Request that already has a response handler in the RequestMap.
|
void |
waitForCondition(BooleanSupplier condition)
This sleeps the thread until the provided condition is met or the async load timeout occurs as specified in
the configuration file.
|
void |
waitForEmptyQueue()
Method to Block for up to the AsyncLoadTimeout for the current request queue to clear
|
public RequestBundler(BroadWorksServer broadWorksServer)
broadWorksServer
- The BroadWorksServer for this Bundlerpublic ExecutorService getResponseService()
public org.apache.commons.lang3.mutable.MutableInt getOutstandingBundleCount()
public int getQueueSize()
public void close()
public Future<ResponseBundle> fire()
public <R extends Response> void postResponse(Request<R> request, ResponseBundle responseBundle)
If the ResponseBundle is null -- due to a socket timeout for exampe - the request is removed from the map but the consumer is not fired.
R
- The response type.request
- The request to retrieve a response from the bundle.responseBundle
- The response bundle for the request bundle.public Future<ResponseBundle> resendAlone(Request<? extends Response> request)
request
- The request to sendpublic <R extends Response> Future<ResponseBundle> put(Request<R> request, Consumer<R> consumer, boolean forceFire)
If the request is null or invalid it will not be added to the backing bundle. A null consumer is allowed but the response will be ignored.
R
- The Response typerequest
- The request to sendconsumer
- The consumer of the responseforceFire
- Force the firing of the request bundle.public <R extends Response> Future<ResponseBundle> put(Request<R> request, Consumer<R> consumer)
If the request is null or invalid it will not be added to the backing bundle. A null consumer is allowed but the response will be ignored.
R
- The Response typerequest
- The request to sendconsumer
- The consumer of the responsepublic <R extends Response> boolean putAndWait(Request<R> request, Consumer<R> consumer)
R
- The Response typerequest
- The request to sendconsumer
- The consumer of the responsepublic <R extends Response> boolean putAndWait(List<? extends Request<R>> requests, Consumer<R> consumer)
R
- The Response typerequests
- The requests to sendconsumer
- The consumer of the responsepublic void waitForEmptyQueue()
public void waitForCondition(BooleanSupplier condition)
condition
- The condition that must be true before continuing.Copyright © 2017 ECG. All rights reserved.