Class SyncCallback

java.lang.Object
org.voltdb.client.AbstractProcedureArgumentCacher
org.voltdb.client.SyncCallback
All Implemented Interfaces:
org.voltdb.client.ProcedureArgumentCacher, ProcedureCallback

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 SyncCallbacks to join on the responses.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a SyncCallback instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the arguments provided with the procedure invocation.
    boolean
    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
    Implementation of callback to be provided by client applications.
    Retrieve the ClientResponse returned for this procedure invocation.
    void
    Block until a response has been received for the invocation associated with this callback.

    Methods inherited from class org.voltdb.client.AbstractProcedureArgumentCacher

    setArgs

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SyncCallback

      public SyncCallback()
      Create a SyncCallback instance.
  • Method Details

    • clientCallback

      public void clientCallback(ClientResponse clientResponse)
      Description copied from interface: ProcedureCallback
      Implementation of callback to be provided by client applications.
      Specified by:
      clientCallback in interface ProcedureCallback
      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

      public ClientResponse getResponse()

      Retrieve the ClientResponse returned for this procedure invocation.

      Returns:
      ClientResponse for this invocation
    • waitForResponse

      public void waitForResponse() throws 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.

      Throws:
      InterruptedException - on interruption.
    • args

      public Object[] args()

      Return the arguments provided with the procedure invocation.

      Overrides:
      args in class org.voltdb.client.AbstractProcedureArgumentCacher
      Returns:
      Object array containing procedure arguments