Example usage for io.netty.channel ChannelPromiseNotifier ChannelPromiseNotifier

List of usage examples for io.netty.channel ChannelPromiseNotifier ChannelPromiseNotifier

Introduction

In this page you can find the example usage for io.netty.channel ChannelPromiseNotifier ChannelPromiseNotifier.

Prototype

ChannelPromiseNotifier

Source Link

Usage

From source file:org.opendaylight.sxp.core.SxpNode.java

License:Open Source License

/**
 * @param sxpNode Node where MD5 keys will be updated
 * @return ChannelFutureListener callback
 *///from   w  w  w . j a v a  2  s  .  c o  m
private ChannelFutureListener createMD5updateListener(final SxpNode sxpNode) {
    channelInitializationWait("Error while Updating MD5");
    if (serverChannel == null) {
        updateMD5counter.set(0);
        return new ChannelPromiseNotifier();
    }
    LOG.info("{} Updating MD5 keys", this);
    return future -> ConnectFacade.createServer(sxpNode, handlerFactoryServer)
            .addListener(new ChannelFutureListener() {

                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    serverChannel = future.channel();
                    serverChannelInit.set(false);
                    if (updateMD5counter.decrementAndGet() > 0) {
                        updateMD5counter.set(1);
                        serverChannel.close().addListener(createMD5updateListener(sxpNode))
                                .syncUninterruptibly();
                    }
                }
            });
}