Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.ChannelFuture


          HessianProxyFactory factory = new HessianProxyFactory(executor, host.getName()+":"+host.getPort());
          bootstrap.setPipelineFactory(
                  new RPCClientPipelineFactory(executor, factory));
         
           // Start the connection attempt.
          ChannelFuture future = bootstrap.connect(new InetSocketAddress(host.getName(), host.getPort()));
          try
        {
          future.await(10000);
          connected = future.isSuccess();


          if (connected)
          {
              Map options = new HashMap();
              options.put("sync", true);
              options.put("timeout", new Long(10000));
            proxy = (AsyncServiceManagerServer) factory.create(AsyncServiceManagerServer.class, HubMain.class.getClassLoader(), options);
            connected = ((Boolean)proxy.isServiceManager()).booleanValue();
            if (connected)
            {
              synchronized(proxies)
              {
            proxies.put(host.getName(), proxy);
              }
            Host newHost = new Host(host.getName(), host.getPort());
            newHost.setIncluded(true);
            newHost.setState("CONNECTED");
            hostsList.remove(host.getName());
            hostsList.put(newHost.getName(), newHost);
            //if (host.isIncluded())
            // TODO  servicesList.addService(host.getName(), proxy);
            }
            else
              future.getChannel().close();
          }
        }
        catch (Exception e)
        {
          System.out.println("error accessing "+host.getName());
          e.printStackTrace();
         
          connected = false;
          if (future != null)
            future.getChannel().close();
        }
       
      }
       
      if (!connected)
View Full Code Here


            // get the port - hostName should be the local host
            String[] x = host.split(":");
            int port = Integer.parseInt(x[1]);
            String hostName = x[0];
            // try to connect
            ChannelFuture future = bootstrap.connect(new InetSocketAddress(hostName, port));
            // future.await(10000);

            // stop discovery
            discovery.stop();
            // doConnected();
View Full Code Here

          public void run()
          {
            if (_session != null && _session.isConnected() && !_stopping && !_appearHanging)
            {
              ChannelFuture future = _session.write(new Message(Constants.WRAPPER_MSG_PING, null));
              try
              {
                future.await(10000);
              }
              catch (InterruptedException e)
              {
                e.printStackTrace();
              }
View Full Code Here

    // try connecting, if we could not sleep then retry
    while (!_started)
    {
      if (_debug)
        log.fine("connecting to port " + _port);
      final ChannelFuture future1 = connector.connect();
      try
      {
        future1.await();
        _started = future1.isSuccess();
      }
      catch (InterruptedException e1)
      {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      /*
       * executor.execute(new Runnable() {
       *
       * public void run() { future1.addListener(new
       * ChannelFutureListener() { public void
       * operationComplete(ChannelFuture future) throws Exception {
       * _lock.lock(); System.out.println("future" + future.isSuccess());
       * _started = future.isSuccess(); _connectEnd.signal();
       * _lock.unlock();
       *
       * } }); }
       *
       * });
       *
       * _lock.lock(); try { _connectEnd.await(); } catch
       * (InterruptedException e1) { // TODO Auto-generated catch block
       * e1.printStackTrace(); } _lock.unlock();
       * System.out.println("started "+_started);
       */

      if (_started)
        future1.getChannel().write(new Message(Constants.WRAPPER_MSG_KEY, _key));
      else
        try
        {
          if (_debug)
            log.fine("connection failed -> sleep then retry");
View Full Code Here

    try
    {
    super.flush();
    if (future == null)
    {
      ChannelFuture f = sendDownstream(null);
      f.await(20000);
      //if (!f.await(10000))
      //  throw new IOException("write longer than 10 secs");
    }
    else
    {
View Full Code Here

   protected ChannelFuture handleRefusedChannel(ChannelHandlerContext ctx, ChannelEvent e,
         InetSocketAddress inetSocketAddress) throws Exception
   {
      if (listener == null)
         return null;
      ChannelFuture result = listener.refused(ctx, e, inetSocketAddress);
      return result;
   }
View Full Code Here

   protected ChannelFuture handleAllowedChannel(ChannelHandlerContext ctx, ChannelEvent e,
         InetSocketAddress inetSocketAddress) throws Exception
   {
      if (listener == null)
         return null;
      ChannelFuture result = listener.allowed(ctx, e, inetSocketAddress);
      return result;
   }
View Full Code Here

                  // CONNECTED
                  InetSocketAddress inetSocketAddress = (InetSocketAddress) e.getChannel().getRemoteAddress();
                  if (!accept(ctx, e, inetSocketAddress))
                  {
                     ctx.setAttachment(Boolean.TRUE);
                     ChannelFuture future = handleRefusedChannel(ctx, e, inetSocketAddress);
                     if (future != null)
                     {
                        future.addListener(ChannelFutureListener.CLOSE);
                     }
                     else
                     {
                        Channels.close(e.getChannel());
                     }
View Full Code Here

    public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
      // remeber the event. it will be sent upstream when session has been created
    _connectedEvent = e;
    String id = _session == null ? "?" : _session.getId();
    // send the session id to client
    ChannelFuture future = Channels.future(ctx.getChannel());
    Channels.write(ctx, future, ChannelBuffers.wrappedBuffer(id.getBytes()));
    }
View Full Code Here

    ChannelPipeline currentPipeline = ctx.getPipeline();
    pipeline.mixin(currentPipeline);
    ctx.setAttachment(session);
    _channel = ctx.getChannel();
    // first send session and wait until it has been transmitted
    ChannelFuture future = Channels.future(ctx.getChannel());
    Channels.write(ctx, future, ChannelBuffers.wrappedBuffer(session.getId().getBytes()));
    try
    {
      future.await();
    }
    catch (InterruptedException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

TOP

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

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.