Class SyncCallback
- All Implemented Interfaces:
org.voltdb.client.ProcedureArgumentCacher,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 SyncCallbacks to join on the responses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionObject[]args()Return the arguments provided with the procedure invocation.booleanNon-blocking poll method that checks for the response to the invocation associated with this callback.booleancheckForResponse(long timeout) poll method that checks for the response to the invocation associated with this callback.voidclientCallback(ClientResponse clientResponse) Implementation of callback to be provided by client applications.Retrieve the ClientResponse returned for this procedure invocation.voidBlock until a response has been received for the invocation associated with this callback.Methods inherited from class org.voltdb.client.AbstractProcedureArgumentCacher
setArgs
-
Constructor Details
-
SyncCallback
public SyncCallback()Create a SyncCallback instance.
-
-
Method Details
-
clientCallback
Description copied from interface:ProcedureCallbackImplementation of callback to be provided by client applications.- Specified by:
clientCallbackin interfaceProcedureCallback- Parameters:
clientResponse- Response to the stored procedure invocation this callback is associated with
-
checkForResponse
public 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.
- Returns:
- True if the response is available, false otherwise
-
checkForResponse
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.
- Parameters:
timeout- timeout in milliseconds- Returns:
- True if the response is available, false otherwise
-
getResponse
Retrieve the ClientResponse returned for this procedure invocation.
- Returns:
- ClientResponse for this invocation
-
waitForResponse
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.
- Throws:
InterruptedException- on interruption.
-
args
Return the arguments provided with the procedure invocation.
- Overrides:
argsin classorg.voltdb.client.AbstractProcedureArgumentCacher- Returns:
- Object array containing procedure arguments
-