public List<T> requestAll() throws SQLException {
    List<Future<T>> resultFutures = new ArrayList<>(getRequests().size());
    for (Callable<T> request : getRequests()) {
      Future<T> f = RequestThreadPool.submit(request);
      resultFutures.add(f);
    }
    List<T> results = new ArrayList<>(getRequests().size());
    Exception[] exceptions = new Exception[getEndpoints().size()];
    for (int i = 0; i < getEndpoints().size(); i++) {
      try {
        results.add(resultFutures.get(i).get(taskTimeoutSeconds, TimeUnit.SECONDS));
      } catch (ExecutionException e) {
        exceptions[i] = e;
      } catch (InterruptedException | TimeoutException e) {
        EnvFactory.getEnv().dumpTestJVMSnapshot();
        for (int j = i; j < getEndpoints().size(); j++) {
          resultFutures.get(j).cancel(true);
        }
        throw new ParallelRequestTimeoutException(
            String.format("Waiting for query results of %s timeout", getEndpoints().get(i)), e);
      }
    }
    handleExceptions(exceptions);
    return results;
  }
ParallelRequestDelegate will handle requests in parallel. It's more efficient when requests
contain network communication.
integration-test/src/main/java/org/apache/iotdb/itbase/runtime/ParallelRequestDelegate.java