示例#1
0
  @Override
  public void read(
      final PentoQuery query,
      final Distribution distribution,
      final PentoCallback handler,
      final OperationContext operationContext) {
    List<PentoStoreWorker> workers = readWorkerFactory.getWorkers(operationContext, distribution);
    for (PentoStoreWorker worker : workers) {
      Callable callable = worker.execute(query);
      ListenableFuture future = ioExecutor.submit(callable);

      Futures.addCallback(
          future,
          new FutureCallback() {
            public void onSuccess(Object response) {
              handler.callback(response);
            }

            public void onFailure(Throwable thrown) {
              logger.error(thrown.getMessage());
              handler.error(thrown);
            }
          });
    }
  }
示例#2
0
 /**
  * Submits the task and adds a listener that adds the future to {@code queue} when it completes.
  */
 @GwtIncompatible // TODO
 private static <T> ListenableFuture<T> submitAndAddQueueListener(
     ListeningExecutorService executorService,
     Callable<T> task,
     final BlockingQueue<Future<T>> queue) {
   final ListenableFuture<T> future = executorService.submit(task);
   future.addListener(
       new Runnable() {
         @Override
         public void run() {
           queue.add(future);
         }
       },
       directExecutor());
   return future;
 }
示例#3
0
 public void close() throws Exception {
   ioExecutor.shutdown();
 }