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

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

Introduction

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

Prototype

boolean isSuccess();

Source Link

Document

Returns true if and only if the I/O operation was completed successfully.

Usage

From source file:reactor.io.net.netty.udp.NettyDatagramServer.java

License:Apache License

@Override
public Promise<Boolean> shutdown() {
    final Promise<Boolean> d = Promises.ready(getEnvironment(), getReactor().getDispatcher());

    getReactor().schedule(new Consumer<Void>() {
        @SuppressWarnings("unchecked")
        @Override/*from w w  w .j a  v  a 2  s  .  c o m*/
        public void accept(Void v) {
            GenericFutureListener listener = new GenericFutureListener() {
                @Override
                public void operationComplete(Future future) throws Exception {
                    if (future.isSuccess()) {
                        d.onNext(true);
                    } else {
                        d.onError(future.cause());
                    }
                }
            };
            if (null == nettyOptions || null == nettyOptions.eventLoopGroup()) {
                ioGroup.shutdownGracefully().addListener(listener);
            }
        }
    }, null);
    notifyShutdown();

    return d;
}

From source file:reactor.ipc.netty.channel.PooledClientContextHandler.java

License:Open Source License

@Override
public void operationComplete(Future<CHANNEL> future) throws Exception {
    sink.setCancellation(this);
    if (future.isCancelled() || cancelled) {
        if (log.isDebugEnabled()) {
            log.debug("Cancelled {}", future.toString());
        }/*from w w w.jav a2 s .com*/
        return;
    }
    if (!future.isSuccess()) {
        if (future.cause() != null) {
            sink.error(future.cause());
        } else {
            sink.error(new IOException("error while connecting to " + future.toString()));
        }
        return;
    }
    CHANNEL c = future.get();

    if (c.eventLoop().inEventLoop()) {
        connectOrAcquire(c);
    } else {
        c.eventLoop().execute(() -> connectOrAcquire(c));
    }
}