Example usage for io.netty.util.concurrent Future await

List of usage examples for io.netty.util.concurrent Future await

Introduction

In this page you can find the example usage for io.netty.util.concurrent Future await.

Prototype

Future<V> await() throws InterruptedException;

Source Link

Document

Waits for this future to be completed.

Usage

From source file:org.redisson.RedissonBlockingDeque.java

License:Apache License

@Override
public V pollFirst(long timeout, TimeUnit unit) throws InterruptedException {
    Future<V> res = pollFirstAsync(timeout, unit);
    return res.await().getNow();
}

From source file:org.redisson.RedissonBlockingDeque.java

License:Apache License

@Override
public V pollLast(long timeout, TimeUnit unit) throws InterruptedException {
    Future<V> res = pollLastAsync(timeout, unit);
    return res.await().getNow();
}

From source file:org.redisson.RedissonBlockingQueue.java

License:Apache License

@Override
public V take() throws InterruptedException {
    Future<V> res = takeAsync();
    return res.await().getNow();
}

From source file:org.redisson.RedissonBlockingQueue.java

License:Apache License

@Override
public V poll(long timeout, TimeUnit unit) throws InterruptedException {
    Future<V> res = pollAsync(timeout, unit);
    return res.await().getNow();
}

From source file:org.redisson.RedissonBlockingQueue.java

License:Apache License

@Override
public V pollFromAny(long timeout, TimeUnit unit, String... queueNames) throws InterruptedException {
    Future<V> res = pollFromAnyAsync(timeout, unit, queueNames);
    return res.await().getNow();
}

From source file:org.redisson.RedissonBlockingQueue.java

License:Apache License

@Override
public V pollLastAndOfferFirstTo(String queueName, long timeout, TimeUnit unit) throws InterruptedException {
    Future<V> res = pollLastAndOfferFirstToAsync(queueName, timeout, unit);
    return res.await().getNow();
}

From source file:org.redisson.RedissonCountDownLatch.java

License:Apache License

public void await() throws InterruptedException {
    Future<Boolean> promise = subscribe();
    try {/*from  w  w  w .j a v  a  2  s  .  c  om*/
        promise.await();

        while (getCountInner() > 0) {
            // waiting for open state
            RedissonCountDownLatchEntry entry = ENTRIES.get(getEntryName());
            if (entry != null) {
                entry.getLatch().await();
            }
        }
    } finally {
        unsubscribe();
    }
}

From source file:org.robotninjas.barge.rpc.netty.NettyRaftService.java

License:Apache License

public static Closeable makeCloseable(EventExecutorGroup eventLoopGroup) {
    return new Closeable() {
        @Override/* ww w  .  jav  a2s  . co  m*/
        public void close() throws IOException {
            try {
                Future<?> future = eventLoopGroup.shutdownGracefully(1, 1, TimeUnit.SECONDS);
                future.await();
            } catch (Exception e) {
                throw new IOException("Error shutting down netty event loop", e);
            }
        }
    };
}

From source file:org.tinygroup.nettyremote.impl.ClientImpl.java

License:GNU General Public License

public void stop() {
    LOGGER.logMessage(LogLevel.INFO, "");
    if (reConnect == true) {
        reConnect = false;/*from w w w  .j  av  a 2s .c o  m*/
        try {
            executor.shutdownNow();
        } catch (Exception e) {
            LOGGER.errorMessage("?", e);
        }

    }
    start = false;
    Future wg = null;
    try {
        wg = group.shutdownGracefully();
    } catch (Exception e) {
        LOGGER.errorMessage("Client", e);
    }

    try {
        if (wg != null) {
            wg.await();
        }
    } catch (InterruptedException e) {
        LOGGER.logMessage(LogLevel.INFO, "EventLoopGroup shutdownGracefully");
    }

    setReady(false);
    LOGGER.logMessage(LogLevel.INFO, "?");
}

From source file:org.tinygroup.nettyremote.impl.ServerImpl.java

License:GNU General Public License

public void stop() {
    LOGGER.logMessage(LogLevel.INFO, "?");
    if (f != null) {
        try {/* w  w w.ja va 2s  .  c om*/
            f.channel().closeFuture();
        } catch (Exception e) {
            LOGGER.errorMessage("?Channnel?", e);
        }

    }
    setStart(false);
    Future bg = null;
    try {
        bg = bossGroup.shutdownGracefully();
    } catch (Exception e) {
        LOGGER.errorMessage("??", e);
    }
    Future wg = null;
    try {
        wg = workerGroup.shutdownGracefully();
    } catch (Exception e) {
        LOGGER.errorMessage("??", e);
    }
    if (bg != null) {
        try {
            bg.await();
        } catch (InterruptedException ignore) {
            LOGGER.logMessage(LogLevel.INFO, "EventLoopGroup shutdownGracefully");
        }
    }

    if (wg != null) {
        try {
            wg.await();
        } catch (InterruptedException ignore) {
            LOGGER.logMessage(LogLevel.INFO, "EventLoopGroup shutdownGracefully");
        }
    }

    LOGGER.logMessage(LogLevel.INFO, "??");
}