Example usage for io.netty.channel ChannelHandlerContext fireChannelActive

List of usage examples for io.netty.channel ChannelHandlerContext fireChannelActive

Introduction

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

Prototype

@Override
    ChannelHandlerContext fireChannelActive();

Source Link

Usage

From source file:org.iotivity.cloud.base.protocols.http.HttpLogHandler.java

License:Open Source License

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    Log.v(ctx.channel().id().asLongText().substring(26) + " HTTP Connected, Address: "
            + ctx.channel().remoteAddress().toString());

    ctx.fireChannelActive();
}

From source file:org.jupiter.transport.netty.handler.connector.ConnectionWatchdog.java

License:Apache License

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    Channel ch = ctx.channel();/*from ww  w .  j a v  a  2 s . co  m*/

    if (group != null) {
        group.add(NettyChannel.attachChannel(ch));
    }

    attempts = 0;

    logger.info("Connects with {}.", ch);

    ctx.fireChannelActive();
}

From source file:org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.AsyncSshHandler.java

License:Open Source License

private synchronized void handleSshChanelOpened(final ChannelHandlerContext ctx) {
    LOG.trace("SSH subsystem channel opened successfully on channel: {}", ctx.channel());

    connectPromise.setSuccess();/*from   w w  w  .j  a  v  a2  s.  c o m*/

    // TODO we should also read from error stream and at least log from that

    sshReadAsyncListener = new AsyncSshHandlerReader(new AutoCloseable() {
        @Override
        public void close() throws Exception {
            AsyncSshHandler.this.disconnect(ctx, ctx.newPromise());
        }
    }, new AsyncSshHandlerReader.ReadMsgHandler() {
        @Override
        public void onMessageRead(final ByteBuf msg) {
            ctx.fireChannelRead(msg);
        }
    }, channel.toString(), channel.getAsyncOut());

    // if readAsyncListener receives immediate close, it will close this handler and closing this handler sets channel variable to null
    if (channel != null) {
        sshWriteAsyncHandler = new AsyncSshHandlerWriter(channel.getAsyncIn());
        ctx.fireChannelActive();
    }
}

From source file:org.opendaylight.controller.netconf.nettyutil.handler.ssh.virtualsocket.ChannelInputStream.java

License:Open Source License

public void channelActive(ChannelHandlerContext ctx) {
    ctx.fireChannelActive();
}

From source file:org.opendaylight.controller.netconf.util.handler.ssh.virtualsocket.ChannelInputStream.java

License:Open Source License

public void channelActive(ChannelHandlerContext ctx) throws Exception {
    ctx.fireChannelActive();
}

From source file:org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler.java

License:Open Source License

private synchronized void handleSshChanelOpened(final ChannelHandlerContext ctx) {
    LOG.trace("SSH subsystem channel opened successfully on channel: {}", ctx.channel());

    if (negotiationFuture == null) {
        connectPromise.setSuccess();// w w w  .  jav  a  2s . c o m
    }

    // TODO we should also read from error stream and at least log from that

    sshReadAsyncListener = new AsyncSshHandlerReader(new AutoCloseable() {
        @Override
        public void close() throws Exception {
            AsyncSshHandler.this.disconnect(ctx, ctx.newPromise());
        }
    }, new AsyncSshHandlerReader.ReadMsgHandler() {
        @Override
        public void onMessageRead(final ByteBuf msg) {
            ctx.fireChannelRead(msg);
        }
    }, channel.toString(), channel.getAsyncOut());

    // if readAsyncListener receives immediate close, it will close this handler and closing this handler sets channel variable to null
    if (channel != null) {
        sshWriteAsyncHandler = new AsyncSshHandlerWriter(channel.getAsyncIn());
        ctx.fireChannelActive();
    }
}

From source file:org.opendaylight.sxp.core.handler.ConnectionDecoder.java

License:Open Source License

@Override
public void channelActive(ChannelHandlerContext ctx) throws SocketAddressNotRecognizedException {
    InetSocketAddress address = getAddress(ctx);
    final SxpConnection connection = owner.getConnection(address);
    final SxpDomain domain = getTemplateDomain(address);
    if (connection != null || domain == null) {
        ctx.fireChannelActive();
    }/*www.  j a  v  a2s .c  o m*/
}

From source file:org.ow2.petals.bc.gateway.commons.handlers.AuthenticatorSSLHandler.java

License:Open Source License

@Override
public void channelActive(final @Nullable ChannelHandlerContext ctx) throws Exception {
    assert ctx != null;

    authenticate(ctx);/*from w ww  .  j  a va 2s. c  o m*/

    // maybe another handler needs to know about this
    ctx.fireChannelActive();
}

From source file:org.redisson.client.handler.BaseConnectionHandler.java

License:Apache License

@Override
public void channelActive(final ChannelHandlerContext ctx) {
    List<RFuture<Object>> futures = new ArrayList<RFuture<Object>>();

    RedisClientConfig config = redisClient.getConfig();
    if (config.getPassword() != null) {
        RFuture<Object> future = connection.async(RedisCommands.AUTH, config.getPassword());
        futures.add(future);/*w  ww  .j  av  a  2 s.c  om*/
    }
    if (config.getDatabase() != 0) {
        RFuture<Object> future = connection.async(RedisCommands.SELECT, config.getDatabase());
        futures.add(future);
    }
    if (config.getClientName() != null) {
        RFuture<Object> future = connection.async(RedisCommands.CLIENT_SETNAME, config.getClientName());
        futures.add(future);
    }
    if (config.isReadOnly()) {
        RFuture<Object> future = connection.async(RedisCommands.READONLY);
        futures.add(future);
    }
    if (config.getPingConnectionInterval() > 0) {
        RFuture<Object> future = connection.async(RedisCommands.PING);
        futures.add(future);
    }

    if (futures.isEmpty()) {
        ctx.fireChannelActive();
        connectionPromise.trySuccess(connection);
        return;
    }

    final AtomicBoolean retry = new AtomicBoolean();
    final AtomicInteger commandsCounter = new AtomicInteger(futures.size());
    for (RFuture<Object> future : futures) {
        future.onComplete((res, e) -> {
            if (e != null) {
                if (e instanceof RedisLoadingException) {
                    if (retry.compareAndSet(false, true)) {
                        ctx.executor().schedule(() -> {
                            channelActive(ctx);
                        }, 1, TimeUnit.SECONDS);
                    }
                    return;
                }
                connection.closeAsync();
                connectionPromise.tryFailure(e);
                return;
            }
            if (commandsCounter.decrementAndGet() == 0) {
                ctx.fireChannelActive();
                connectionPromise.trySuccess(connection);
            }
        });
    }
}

From source file:org.redisson.client.handler.ConnectionWatchdog.java

License:Apache License

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    channels.add(ctx.channel());/*from   w w w  .  j a v  a2 s.  c o m*/
    ctx.fireChannelActive();
}