Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.Channel


    Timeout timeOut = session.removeTimeout();
    if (timeOut != null)
      timeOut.cancel();
   
    // check if the session is already connected to a channel
    Channel c = pipeline.getChannel();
    if (c != null && c.isOpen())
    {
      Constants.ahessianLogger.warn(ctx.getChannel()+" session already attached -> close connection");
      c.close();
    }
   
    // now that we have a session extend the pipeline
    ChannelPipeline currentPipeline = ctx.getPipeline();
    pipeline.mixin(currentPipeline);
View Full Code Here


    bootstrap
        .setPipelineFactory(new AHessianServerPipelineFactory(executor, new IpFilterRuleHandler(new IpFilterRuleList(ipFilter)), mbeanServer, log));

    int serverPort = port;
    // Bind and start to accept incoming connections.
    Channel channel = bootstrap.bind(new InetSocketAddress(serverPort));
    if (serverPort == 0)
      serverPort = ((InetSocketAddress) channel.getLocalAddress()).getPort();

    log.info("ahessian jmx service bound to port " + serverPort);

    DiscoveryServer discovery = new DiscoveryServer();
    discovery.setName(serviceDiscoveryName);
View Full Code Here

       
        bootstrap.setPipelineFactory(
               new RPCServerPipelineFactory(executor, factory, acl));

        // Bind and start to accept incoming connections.
        Channel channel =  bootstrap.bind(new InetSocketAddress(port));
  }
View Full Code Here

                passMessage.release();
              }
            }
      });

      final Channel serverChannel = getServerChannelForClientConn(conn);
      Thread asyncChannelClose = new Thread(new Runnable()
      {
        @Override
        public void run()
        {
          log.info("closing server channel");
          serverChannel.close();
          log.info("server channel: closed");
          closeSent.countDown();
        }
      }, "asyncChannelCloseThread");
      asyncChannelClose.setDaemon(true);
View Full Code Here

    }
  }

  private Channel getServerChannelForClientConn(final AbstractNettyHttpConnection conn)
  {
    Channel channel = conn._channel;
    SocketAddress clientAddr = channel.getLocalAddress();

    return _dummyServer.getChildChannel(clientAddr);

  }
View Full Code Here

        return null != conn._channel && conn._channel.isConnected();
      }
    }, "wait for client to connect", 1000, log);

    //introspect connection to server
    Channel channel = conn._channel;
    SocketAddress clientAddr = channel.getLocalAddress();

    Channel serverChannel = _dummyServer.getChildChannel(clientAddr);
    ChannelPipeline serverPipeline = serverChannel.getPipeline();
    SimpleObjectCaptureHandler objCapture = (SimpleObjectCaptureHandler)serverPipeline.get("3");

    Assert.assertTrue(objCapture.waitForMessage(1000, 0));
    Object msgObj = objCapture.getMessages().get(0);
    Assert.assertTrue(msgObj instanceof HttpRequest);
View Full Code Here

        ChannelHandler parentHandler = getParentHandler();
        if (parentHandler != null) {
            bossPipeline.addLast("userHandler", parentHandler);
        }

        Channel channel = getFactory().newChannel(bossPipeline);

        // Wait until the future is available.
        ChannelFuture future = null;
        do {
            try {
View Full Code Here

    return _childrenChannels.get(clientAddr);
  }

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

    }
  }

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

    TestConnectListener connectListener = new TestConnectListener(log);
    TestSendRequestListener requestListener = new TestSendRequestListener(log);
    TestCloseListener closeListener = new TestCloseListener(log);

    responseHandler.setConnectionListener(connectListener);
    Channel channel = createClientBootstrap(responseHandler);

    SocketAddress clientAddr = channel.getLocalAddress();
    try
    {
      setListeners(responseHandler,respProcessor,requestListener,closeListener);
      channel.write(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/test"));
        //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.
        final GenericHttpResponseHandler handler = getResponseHandler(channel);
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return handler._messageState.hasSentRequest();
          }
        }, "request sent", 1000, log);

      HttpResponse resp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
      resp.setContent(null);
      resp.setHeader(HttpHeaders.Names.CONTENT_LENGTH, 0);
      sendServerResponse(clientAddr, resp, 1000);
      final List<String> callbacks = respProcessor.getCallbacks();
      TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return 2 == callbacks.size();
          }
        }, "waiting for response processed", 1000, null);
      final List<String> connectCallbacks = connectListener.getCallbacks();
      final List<String> requestCallbacks = requestListener.getCallbacks();
      final List<String> closeCallbacks = closeListener.getCallbacks();

      stateSanityCheck(connectCallbacks,requestCallbacks,callbacks,closeCallbacks);
      Assert.assertEquals(callbacks.get(0), "startResponse");
      Assert.assertEquals(callbacks.get(1), "finishResponse");
    }
    finally
    {
      channel.close();
    }
  }
View Full Code Here

TOP

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

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.