Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.ChannelFuture.addListener()


        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 {
                            closeFutures.offer(e.getFuture());
                        }
                    });
                }
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

        } else {
            // No encryption - use zero-copy.
            final FileRegion region =
                    new DefaultFileRegion(raf.getChannel(), 0, fileLength);
            writeFuture = ch.write(region);
            writeFuture.addListener(new ChannelFutureProgressListener() {
                @Override
                public void operationComplete(ChannelFuture future) {
                    region.releaseExternalResources();
                }
View Full Code Here

        }

        // Decide whether to close the connection or not.
        if (!isKeepAlive(request)) {
            // Close the connection when the whole content is written out.
            writeFuture.addListener(ChannelFutureListener.CLOSE);
        }
    }

    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
            throws Exception {
View Full Code Here

            response.setHeader(HttpHeaders.Names.CONNECTION, "Keep-Alive");
        }

        final ChannelFuture future = ctx.getChannel().write(response);
        if (!isKeepAlive(request)) {
            future.addListener(ChannelFutureListener.CLOSE);
        }
    }

    public void write(String data, Charset charset) {
        write(data.getBytes(charset));
View Full Code Here

        }
        setContentLength(response, response.getContent().readableBytes());

        ChannelFuture future = ctx.getChannel().write(response);
        if (!isKeepAlive(request)) {
            future.addListener(ChannelFutureListener.CLOSE);
        }
    }

    public void writeJSON(Object object) throws IOException {
        ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer();
View Full Code Here

      }

      // Send the response and close the connection if necessary.
      ChannelFuture f = ctx.getChannel().write(res);
      if (!isKeepAlive(req) || res.getStatus().getCode() != 200) {
         f.addListener(ChannelFutureListener.CLOSE);
      }
   }

   private void loadScriptToResponse(HttpRequest req, DefaultHttpResponse res) {
      String wsAddress = getWebSocketLocation(req);
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 {
                            closeFutures.offer(e.getFuture());
                        }
                    });
                }
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

        shuffleMetrics.failedOutput();
        sendError(ctx, e.getMessage(), INTERNAL_SERVER_ERROR);
        return;
      }
    }
    lastMap.addListener(ChannelFutureListener.CLOSE);
  }

  protected ChannelFuture sendMapOutput(ChannelHandlerContext ctx, Channel ch,
      String jobId, String mapId, int reduce) throws IOException {
    LocalDirAllocator lDirAlloc = attributes.getLocalDirAllocator();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.