Class RequestDelegate<T>

java.lang.Object
org.apache.iotdb.itbase.runtime.RequestDelegate<T>
Direct Known Subclasses:
ParallelRequestDelegate, SerialRequestDelegate

public abstract class RequestDelegate<T> extends Object
This class is used to handle multi requests and gather their returned values.
  • Constructor Details

    • RequestDelegate

      public RequestDelegate(List<String> endpoints)
      Initialize a RequestDelegate instance with a list of endpoints.
      Parameters:
      endpoints - the list of endpoints.
  • Method Details

    • addRequest

      public final void addRequest(Callable<T> request)
      Add a request to this RequestDelegate. The request sequence should correspond to endpoints.
      Parameters:
      request - the request to add.
    • requestAll

      public abstract List<T> requestAll() throws SQLException
      Do the requests which have been added, and return a list of their return values. If some exception throws from the request, the exception thrown by each request will be compared and be thrown if they are even, or an InconsistentDataException.
      Returns:
      the return values of all the request added in order.
      Throws:
      SQLException - if any error happens during requesting.
    • requestAllAndCompare

      public final T requestAllAndCompare() throws SQLException
      Do the requests which have been added, and then comparing their return values. If all the values are equal, one value will be returned. Otherwise an SQLException will be thrown.
      Returns:
      the return value of one request, as all requests return the same one.
      Throws:
      SQLException - if any error happens during requesting.
      InconsistentDataException - if the return values of requests are not equal.
    • handleExceptions

      protected void handleExceptions(Exception[] exceptions) throws SQLException
      Throws:
      SQLException
    • getEndpoints

      protected List<String> getEndpoints()
    • getRequests

      protected List<Callable<T>> getRequests()