public class BulkLightblueRequester extends Object implements LightblueRequester
Future is
resolved, at which point all queued requests are performed in a single batch.
This class may be used across multiple threads safely, however the returned Futures
are not threadsafe. That is, a given future instance should not be shared among multiple threads,
which should not be a relevant limitation (if it is, however, it would not be hard to make them
thread safe). Requests are queued up atomically, and performed and cleared atomically as well.
That is, when one future is resolved, the current batch of requests is frozen, copied, cleared,
and performed. A thread queueing a request while another thread resolves a future will
not result in a loss of requests. It will either make it in for the batch, or be queued
for the next.
While this class is thread safe, the logical "scope" of returned Futures is
significant to consider. If you know you are going to batch up a bunch of requests, you don't
want some other thread interrupting your batch performing your requests before you've finished
queueing all of them up. So, you should create a new BulkLightblueRequester instance per
logical "batch," and generally should avoid sharing an instance among multiple threads.
| Constructor and Description |
|---|
BulkLightblueRequester(com.redhat.lightblue.client.LightblueClient lightblue) |
BulkLightblueRequester(com.redhat.lightblue.client.LightblueClient lightblue,
boolean ordered) |
| Modifier and Type | Method and Description |
|---|---|
TransformableFuture<LightblueDataResponses> |
request(Collection<? extends com.redhat.lightblue.client.request.CRUDRequest> requests) |
TransformableFuture<LightblueDataResponses> |
request(com.redhat.lightblue.client.request.CRUDRequest... requests) |
TransformableFuture<LightblueResponses> |
tryRequest(com.redhat.lightblue.client.request.CRUDRequest... req)
Like
Requester.request(Object[]), except with relaxed failure conditions so that listeners to
this future result may examine and transform errors from lightblue in addition to successful
responses. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waittryRequestpublic BulkLightblueRequester(com.redhat.lightblue.client.LightblueClient lightblue)
public BulkLightblueRequester(com.redhat.lightblue.client.LightblueClient lightblue,
boolean ordered)
public TransformableFuture<LightblueDataResponses> request(com.redhat.lightblue.client.request.CRUDRequest... requests)
public TransformableFuture<LightblueDataResponses> request(Collection<? extends com.redhat.lightblue.client.request.CRUDRequest> requests)
public TransformableFuture<LightblueResponses> tryRequest(com.redhat.lightblue.client.request.CRUDRequest... req)
LightblueRequesterRequester.request(Object[]), except with relaxed failure conditions so that listeners to
this future result may examine and transform errors from lightblue in addition to successful
responses. A listener can examine whether or not these responses are failed with
LightblueResponse.isSuccess().
The returned future will only fail if the lightblue request did not complete and there are no responses with which to populate the future value.
This contrasts with Requester.request(Object[]) which always returns successful
LightblueDataResponses, and if any responses have returned with errors, the future
will fail.
tryRequest in interface LightblueRequesterLightblueResponseCopyright © 2017. All rights reserved.