Package org.apache.iotdb.itbase.runtime
Class RequestDelegate<T>
java.lang.Object
org.apache.iotdb.itbase.runtime.RequestDelegate<T>
- Direct Known Subclasses:
ParallelRequestDelegate,SerialRequestDelegate
This class is used to handle multi requests and gather their returned values.
-
Constructor Summary
ConstructorsConstructorDescriptionRequestDelegate(List<String> endpoints) Initialize a RequestDelegate instance with a list of endpoints. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddRequest(Callable<T> request) Add a request to this RequestDelegate.protected voidhandleExceptions(Exception[] exceptions) Do the requests which have been added, and return a list of their return values.final TDo the requests which have been added, and then comparing their return values.
-
Constructor Details
-
RequestDelegate
Initialize a RequestDelegate instance with a list of endpoints.- Parameters:
endpoints- the list of endpoints.
-
-
Method Details
-
addRequest
Add a request to this RequestDelegate. The request sequence should correspond to endpoints.- Parameters:
request- the request to add.
-
requestAll
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
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 anSQLExceptionwill 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
- Throws:
SQLException
-
getEndpoints
-
getRequests
-