Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.ChannelFutureListener


        // Now make the TopicSubscriber channel not-readable. This will buffer
        // up messages if any are sent from the server. Note that this is an
        // asynchronous call. If this fails (not likely), the futureListener
        // will just log an error message for now.
        ChannelFuture future = topicSubscriberChannel.setReadable(false);
        future.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                if (!future.isSuccess()) {
                    logger.error("Unable to make subscriber Channel not readable in stopDelivery call for topic: "
                                 + topic.toStringUtf8() + ", subscriberId: " + subscriberId.toStringUtf8());
View Full Code Here


            Channel channel = topicSubscriber2Channel.get(topicSubscriber);
            topicSubscriber2Channel.remove(topicSubscriber);
            // Close the subscribe channel asynchronously.
            HedwigClientImpl.getResponseHandlerFromChannel(channel).channelClosedExplicitly = true;
            ChannelFuture future = channel.close();
            future.addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    if (!future.isSuccess()) {
                        logger.error("Failed to close the subscription channel for topic: " + topic.toStringUtf8()
                                     + ", subscriberId: " + subscriberId.toStringUtf8());
View Full Code Here

        bootstrap.setOption("tcpNoDelay", conf.getClientTcpNoDelay());
        bootstrap.setOption("keepAlive", true);

        ChannelFuture future = bootstrap.connect(addr);

        future.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                int rc;
                Queue<GenericCallback<Void>> oldPendingOps;
View Full Code Here

        header.writeBytes(masterKey);

        ChannelBuffer wrappedBuffer = ChannelBuffers.wrappedBuffer(header, toSend);

        ChannelFuture future = channel.write(wrappedBuffer);
        future.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                if (future.isSuccess()) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Successfully wrote request for adding entry: " + entryId + " ledger-id: " + ledgerId
View Full Code Here

                                           BookieProtocol.READENTRY, (short)options).toInt());
        tmpEntry.writeLong(ledgerId);
        tmpEntry.writeLong(entryId);

        ChannelFuture future = channel.write(tmpEntry);
        future.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                if (future.isSuccess()) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Successfully wrote request for reading entry: " + entryId + " ledger-id: "
View Full Code Here

                                                  ProtocolVersion.VERSION_ONE).setStatusCode(StatusCode.SUCCESS).setTxnId(0).setMessage(msg)
                                              .setTopic(topic).setSubscriberId(subscriberId).build();

                    ChannelFuture future = subscribedChannel.write(response);

                    future.addListener(new ChannelFutureListener() {
                        @Override
                        public void operationComplete(ChannelFuture future) throws Exception {
                            if (!future.isSuccess()) {
                                // ignoring this failure, because this will
                                // only happen due to channel disconnect.
View Full Code Here

    }

    @Override
    public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
        if (isSSLEnabled) {
            ctx.getPipeline().get(SslHandler.class).handshake(e.getChannel()).addListener(new ChannelFutureListener() {
                public void operationComplete(ChannelFuture future) throws Exception {
                    if (future.isSuccess()) {
                        if (logger.isDebugEnabled()) {
                            logger.debug("SSL handshake has completed successfully!");
                        }
View Full Code Here

        if (!engine.isInboundDone()) {
            if (sentCloseNotify.compareAndSet(false, true)) {
                engine.closeOutbound();
                synchronized (closeFutures) {
                    ChannelFuture closeNotifyFuture = wrapNonAppData(context, e.getChannel());
                    closeNotifyFuture.addListener(new ChannelFutureListener() {
                        public void operationComplete(ChannelFuture closeNotifyFuture) throws Exception {
                            boolean offered = closeFutures.offer(e.getFuture());
                            assert offered;
                        }
                    });
View Full Code Here

        context.sendDownstream(e);
    }

    private static ChannelFuture newHandshakeFuture(Channel channel) {
        ChannelFuture future = future(channel);
        future.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future)
                    throws Exception {
                if (!future.isSuccess()) {
                    fireExceptionCaught(future.getChannel(), future.getCause());
                }
View Full Code Here

            if (consumer.getConfiguration().isTextline()) {
                body = NettyHelper.getTextlineBody(body, exchange, consumer.getConfiguration().getDelimiter(), consumer.getConfiguration().isAutoAppendDelimiter());
            }

            // we got a body to write
            ChannelFutureListener listener = new ResponseFutureListener(exchange, messageEvent.getRemoteAddress());
            if (consumer.getConfiguration().isTcp()) {
                NettyHelper.writeBodyAsync(messageEvent.getChannel(), null, body, exchange, listener);
            } else {
                NettyHelper.writeBodyAsync(messageEvent.getChannel(), messageEvent.getRemoteAddress(), body, exchange, listener);
            }
View Full Code Here

TOP

Related Classes of org.jboss.netty.channel.ChannelFutureListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.