Example usage for com.google.common.util.concurrent Uninterruptibles getUninterruptibly

List of usage examples for com.google.common.util.concurrent Uninterruptibles getUninterruptibly

Introduction

In this page you can find the example usage for com.google.common.util.concurrent Uninterruptibles getUninterruptibly.

Prototype

public static <V> V getUninterruptibly(Future<V> future) throws ExecutionException 

Source Link

Usage

From source file:com.intuit.wasabi.repository.cassandra.UninterruptibleUtil.java

public static <T> Result<T> getUninterruptibly(ListenableFuture<Result<T>> aFuture) {
    try {/*from  w  ww .  j a  v a  2s.  c o  m*/
        return Uninterruptibles.getUninterruptibly(aFuture);
    } catch (ExecutionException e) {
        throw propagateCause(e);
    }
}

From source file:info.archinnov.achilles.internals.dsl.action.MutationAction.java

/**
 * Execute the INSERT/UPDATE/DELETE action
 *///ww  w . j a  v a  2s .co  m
default void execute() {
    try {
        Uninterruptibles.getUninterruptibly(executeAsync());
    } catch (ExecutionException e) {
        throw extractCauseFromExecutionException(e);
    }
}

From source file:com.google.devtools.build.lib.util.LoggingUtil.java

/** Returns the installed logger, or null if none is installed. */
public static synchronized Logger getRemoteLogger() {
    try {//from   w w w.  jav  a  2  s .co m
        return (remoteLogger == null) ? null : Uninterruptibles.getUninterruptibly(remoteLogger);
    } catch (ExecutionException e) {
        throw new RuntimeException("Unexpected error initializing remote logging", e);
    }
}

From source file:org.stem.client.ReplicaResponseHandler.java

public void start() {
    try {//from   ww  w .  j a v a2s. c  o m
        response = Uninterruptibles.getUninterruptibly(future);
    } catch (ExecutionException e) {
        cause = e.getCause();
        logger.error("Error sending request {} to {}, {}", future.request(), endpoint, cause.getMessage());
    } finally {
        context.onRequestFinished(this);
    }
}

From source file:com.facebook.buck.util.concurrent.MoreFutures.java

/**
 * Invoke multiple callables on the provided executor and wait for all to return successfully.
 * An exception is thrown (immediately) if any callable fails.
 * @param executorService Executor service.
 * @param callables Callables to call./* w  w w  .  j  a  v a 2s . c o  m*/
 * @return List of values from each invoked callable in order if all callables execute without
 *     throwing.
 * @throws ExecutionException If any callable throws an exception, the first of such is wrapped
 *     in an ExecutionException and thrown.  Access via
 *     {@link java.util.concurrent.ExecutionException#getCause()}}.
 */
public static <V> List<V> getAllUninterruptibly(ListeningExecutorService executorService,
        Iterable<Callable<V>> callables) throws ExecutionException {
    // Invoke.
    ImmutableList.Builder<ListenableFuture<V>> futures = ImmutableList.builder();
    for (Callable<V> callable : callables) {
        ListenableFuture<V> future = executorService.submit(callable);
        futures.add(future);
    }

    // Wait for completion.
    ListenableFuture<List<V>> allAsOne = Futures.allAsList(futures.build());
    return Uninterruptibles.getUninterruptibly(allAsOne);
}

From source file:info.archinnov.achilles.internals.dsl.action.MutationAction.java

/**
 * Execute the INSERT/UPDATE/DELETE action
 * and return an {@link com.datastax.driver.core.ExecutionInfo} object
 *///  w w  w .  j a  va2  s.  c o m
default ExecutionInfo executeWithStats() {
    try {
        return Uninterruptibles.getUninterruptibly(executeAsyncWithStats());
    } catch (ExecutionException e) {
        throw extractCauseFromExecutionException(e);
    }
}

From source file:info.archinnov.achilles.internals.types.TypedMapIteratorWrapper.java

public TypedMapIteratorWrapper(CompletableFuture<ResultSet> futureRS, StatementWrapper statementWrapper,
        Options options) {/*from www . j  av a 2  s . co  m*/
    this.statementWrapper = statementWrapper;
    this.options = options;
    try {
        this.delegate = Uninterruptibles.getUninterruptibly(futureRS.thenApply(options::resultSetAsyncListener)
                .thenApply(statementWrapper::logTrace).thenApply(rs -> rs.iterator()));
    } catch (ExecutionException e) {
        throw extractCauseFromExecutionException(e);
    }
}

From source file:info.archinnov.achilles.internals.types.JSONIteratorWrapper.java

public JSONIteratorWrapper(CompletableFuture<ResultSet> futureRS, StatementWrapper statementWrapper,
        Options options) {/*from   w ww. j  a  va 2  s  .  c  o  m*/
    this.statementWrapper = statementWrapper;
    this.options = options;
    try {
        this.delegate = Uninterruptibles.getUninterruptibly(futureRS.thenApply(options::resultSetAsyncListener)
                .thenApply(statementWrapper::logTrace).thenApply(rs -> {
                    JSONIteratorWrapper.this.executionInfo = rs.getExecutionInfo();
                    return rs;
                }).thenApply(rs -> rs.iterator()));
    } catch (ExecutionException e) {
        throw extractCauseFromExecutionException(e);
    }
}

From source file:org.dcache.cells.FutureReply.java

@Override
public void run() {
    try {/*from  w ww  .  jav  a 2 s  .  c  om*/
        T msg = Uninterruptibles.getUninterruptibly(future);
        if (msg != null) {
            reply(msg);
        }
    } catch (ExecutionException e) {
        reply(e.getCause());
    }
}

From source file:info.archinnov.achilles.async.AchillesFuture.java

public V getImmediately() {
    try {/*from  w ww .jav  a 2s .c om*/
        return Uninterruptibles.getUninterruptibly(delegate);
    } catch (ExecutionException e) {
        throw extractCauseFromExecutionException(e);
    }
}