public final class SyncCallback extends org.voltdb.client.AbstractProcedureArgumentCacher implements ProcedureCallback
A utility class that allows a client to queue a stored procedure invocation asynchronously and then poll
or join on the response. Useful when invoking multiple stored procedures synchronously
from a single thread. Queue each of the invocations asynchronously with a different SyncCallback
and
then call waitForResponse()
on each of the SyncCallback
s to join on the responses.
Constructor and Description |
---|
SyncCallback()
Create a SyncCallback instance.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object[] |
args()
Return the arguments provided with the procedure invocation.
|
boolean |
checkForResponse()
Non-blocking poll method that checks for the response to the invocation associated with this callback.
|
boolean |
checkForResponse(long timeout)
poll method that checks for the response to the invocation associated with this callback.
|
void |
clientCallback(ClientResponse clientResponse)
Implementation of callback to be provided by client applications.
|
ClientResponse |
getResponse()
Retrieve the ClientResponse returned for this procedure invocation.
|
void |
waitForResponse()
Block until a response has been received for the invocation associated with this callback.
|
public void clientCallback(ClientResponse clientResponse)
ProcedureCallback
clientCallback
in interface ProcedureCallback
clientResponse
- Response to the stored procedure invocation this callback is associated withpublic boolean checkForResponse()
Non-blocking poll method that checks for the response to the invocation associated with this callback. Call getResponse to retrieve the response or result() to retrieve the just the results.
public boolean checkForResponse(long timeout)
poll method that checks for the response to the invocation associated with this callback. The timeout in millisecond indicates how long you wish to wait for a response. if no response is received after this you can waitForResponse or ignore depending on how caller wishes to handle. Call getResponse to retrieve the response or result() to retrieve the just the results.
timeout
- timeout in millisecondspublic ClientResponse getResponse()
Retrieve the ClientResponse returned for this procedure invocation.
public void waitForResponse() throws java.lang.InterruptedException
Block until a response has been received for the invocation associated with this callback. Call getResponse to retrieve the response or result() to retrieve the just the results.
java.lang.InterruptedException
- on interruption.public java.lang.Object[] args()
Return the arguments provided with the procedure invocation.
args
in class org.voltdb.client.AbstractProcedureArgumentCacher