Examples of ChannelFuture


Examples of org.jboss.netty.channel.ChannelFuture

    finally
    {
      _lock.unlock();
    }

    ChannelFuture closeFuture = _channel.close();
    closeFuture.awaitUninterruptibly();
    _clientBootstrap.releaseExternalResources();
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

    finally
    {
      _lock.unlock();
    }

    ChannelFuture closeFuture = _channel.close();
    closeFuture.awaitUninterruptibly();
    _srvBootstrap.releaseExternalResources();
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

  public void sendServerResponse(SocketAddress clientAddr, Object response, long timeoutMillis)
  {
    Channel childChannel = getChildChannel(clientAddr);
    Assert.assertNotEquals(childChannel, null);
    ChannelFuture writeFuture = childChannel.write(response);
    if (timeoutMillis > 0)
    {
      try
      {
        writeFuture.await(timeoutMillis);
      }
      catch (InterruptedException e)
      {
        //NOOP
      }
      Assert.assertTrue(writeFuture.isDone());
      Assert.assertTrue(writeFuture.isSuccess());
    }
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

  public void sendServerClose(SocketAddress clientAddr, long timeoutMillis)
  {
    Channel childChannel = getChildChannel(clientAddr);
    Assert.assertNotEquals(childChannel, null);
    ChannelFuture closeFuture = childChannel.close();
    if (timeoutMillis > 0)
    {
      try
      {
        closeFuture.await(timeoutMillis);
      }
      catch (InterruptedException e)
      {
        //NOOP
      }
      Assert.assertTrue(closeFuture.isDone());
      Assert.assertTrue(closeFuture.isSuccess());
    }
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

  public abstract ChannelBuffer serializeToBinary();

  @Override
  public void writeToChannelAsBinary(ChannelHandlerContext ctx, ChannelFuture future)
  {
    ChannelFuture realFuture = (null != future) ? future : Channels.future(ctx.getChannel());

    ChannelBuffer serializedResponse = serializeToBinary();
    DownstreamMessageEvent e = new DownstreamMessageEvent(ctx.getChannel(), realFuture,
                                                          serializedResponse,
                                                          ctx.getChannel().getRemoteAddress());
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

    responseHandler.setConnectionListener(connectListener);
    Channel channel = createClientBootstrap(responseHandler);
    try
    {
        setListeners(responseHandler,respProcessor,requestListener,closeListener);
        ChannelFuture writeFuture = channel.write(new DefaultHttpRequest(HttpVersion.HTTP_1_1,
                                                                         HttpMethod.GET, "/test"));
        Assert.assertTrue(writeFuture.await(1000));

        //It seems that there is a race condition between the writeFuture succeeding
        //and the writeComplete message getting to the handler. Make sure that the
        //writeComplete has got to the handler before we do anything else with
        //the channel.
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

    responseHandler.setRequestListener(requestListener);
    responseHandler.setConnectionListener(connectListener);
    responseHandler.setCloseListener(closeListener);

    //use port 0 to generate connect fail
    ChannelFuture channelFuture = createChannelFuture(responseHandler,0);
    Channel channel = channelFuture.getChannel();

    try
    {
      channel.write(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/test"));
      final List<String> respCallbacks = respProcessor.getCallbacks();
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

  void sendServerResponse(SocketAddress clientAddr, Object response, long timeoutMillis)
  {
    Channel childChannel = _dummyServer.getChildChannel(clientAddr);
    Assert.assertNotEquals(childChannel, null);
    ChannelFuture writeFuture = childChannel.write(response);
    if (timeoutMillis > 0)
    {
      try
      {
        writeFuture.await(timeoutMillis);
      }
      catch (InterruptedException e)
      {
        //NOOP
      }
      Assert.assertTrue(writeFuture.isDone());
      Assert.assertTrue(writeFuture.isSuccess());
    }
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

            res.setContent(ChannelBuffers.copiedBuffer(res.getStatus().toString(), CharsetUtil.UTF_8));
            setContentLength(res, res.getContent().readableBytes());
        }

        // 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);
        }
    }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

        // Write the initial line and the header.
        ch.write(response);

        // Write the content.
        ChannelFuture writeFuture;
        if (ch.getPipeline().get(SslHandler.class) != null) {
            // Cannot use zero-copy with HTTPS.
            writeFuture = ch.write(new ChunkedFile(raf, 0, fileLength, 8192));
        } else {
            // No encryption - use zero-copy.
            final FileRegion region =
                    new DefaultFileRegion(raf.getChannel(), 0, fileLength);
            writeFuture = ch.write(region);
            writeFuture.addListener(new ChannelFutureProgressListener() {
                public void operationComplete(ChannelFuture future) {
                    region.releaseExternalResources();
                }

                public void operationProgressed(
                        ChannelFuture future, long amount, long current, long total) {
                }
            });
        }

        // 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);
        }
    }
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.