Examples of ChannelFuture


Examples of org.jboss.netty.channel.ChannelFuture

        inboundChannel.setReadable(false);

        // Start the connection attempt.
        ClientBootstrap cb = new ClientBootstrap(cf);
        cb.getPipeline().addLast("handler", new OutboundHandler(e.getChannel()));
        ChannelFuture f = cb.connect(new InetSocketAddress(remoteHost, remotePort));

        outboundChannel = f.getChannel();
        f.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future) throws Exception {
                if (future.isSuccess()) {
                    // Connection attempt succeeded:
                    // Begin to accept incoming traffic.
                    inboundChannel.setReadable(true);
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

    });
  }
});
   
     // Start the connection attempt.
    ChannelFuture future = bootstrap.connect(new InetSocketAddress("localhost", 8080));
    // Wait until the connection attempt succeeds or fails.
    Channel channel = future.awaitUninterruptibly().getChannel();
    if (future.isSuccess())
      System.out.println("connected");
   
    // get a proxy

    }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

              ctx.sendUpstream(e);
              System.out.println("channel closed wait to reconnect ...");
                  timer.schedule(new TimerTask() {
                      public void run() {
                        System.out.println("reconnecting...");
                         ChannelFuture f = _bootstrap.connect();
                         try
              {
                           System.out.println("future wait");
                f.awaitUninterruptibly();
                         System.out.println("future wait terminated");
              }
              catch (Exception e)
              {
                // TODO Auto-generated catch block
                e.printStackTrace();
                 }
                       if (f.isSuccess())
                       System.out.println("connected");
                       else
                       {
                         System.out.println("not connected");
                        // f.getChannel().close();
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

      ctx.sendUpstream(e);
      Constants.ahessianLogger.warn("channel closed wait to reconnect ...");
          timer.schedule(new TimerTask() {
              public void run() {
                Constants.ahessianLogger.warn("reconnecting...");
                  ChannelFuture f = _bootstrap.getBootstrap().connect();
                  try
        {
          f.awaitUninterruptibly();
        }
        catch (Exception e)
        {
          // TODO Auto-generated catch block
          Constants.ahessianLogger.warn("", e);
            }
                if (f.isSuccess())
                  Constants.ahessianLogger.warn("connected");
                else
                {
                  Constants.ahessianLogger.warn("not connected");
                }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

        }
      }
      if (_channel != null && _channel.isOpen())
        try
        {
          ChannelFuture cf = _channel.close();
          getLog().info("controller close session");
          cf.await(1000);
        }
        catch (InterruptedException e)
        {
          e.printStackTrace();
          getLog().info("session close wait interrupted in JVMController");
View Full Code Here

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

Examples of org.jboss.netty.channel.ChannelFuture

            // 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

Examples of org.jboss.netty.channel.ChannelFuture

          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

Examples of org.jboss.netty.channel.ChannelFuture

    // 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

Examples of org.jboss.netty.channel.ChannelFuture

    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
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.