Examples of ChannelFuture


Examples of org.jboss.netty.channel.ChannelFuture

   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

Examples of org.jboss.netty.channel.ChannelFuture

   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

Examples of org.jboss.netty.channel.ChannelFuture

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

Examples of org.jboss.netty.channel.ChannelFuture

    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

Examples of org.jboss.netty.channel.ChannelFuture

    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

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();
            proxy = (AsyncServiceManagerServer) factory.create(AsyncServiceManagerServer.class, ClientMain.class.getClassLoader(), options);
            connected = ((Boolean)((Future)proxy.isServiceManager()).get(10, TimeUnit.SECONDS)).booleanValue();
            if (connected)
            {
            proxies.put(host.getName(), proxy);
            Host newHost = new Host(host.getName(), host.getPort());
            newHost.setIncluded(host.isIncluded());
            newHost.setState("CONNECTED");
            hosts.updateObject(newHost);
            if (host.isIncluded())
              servicesTable.addService(host.getName(), proxy);
            }
            else
              future.getChannel().close();
          }
        }
        catch (Exception e)
        {
          System.out.println("error accessing "+host.getName());
          connected = false;
          if (future != null)
            future.getChannel().close();
        }
       
      }
       
      if (!connected)
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

  @Override
  void timedOut(ChannelHandlerContext ctx)
  {
      Constants.ahessianLogger.info("write timed out -> send empty buffer heartbeat");
    ChannelFuture future = Channels.future(_ctx.getChannel());
    ChannelBuffer b = ChannelBuffers.buffer(1);
    b.writeByte(0);
        _ctx.sendDownstream(new DownstreamMessageEvent(_ctx.getChannel(), future, b, _ctx.getChannel().getRemoteAddress()));
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

                 
                });
            }
        });
       
        ChannelFuture f = bootstrap.connect();
        channel = f.getChannel();
       
        mcast.init(new ChannelPipelineFactory() {
            public ChannelPipeline getPipeline() {
                return Channels.pipeline(new SimpleChannelUpstreamHandler()
                {
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

        }

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

        // Wait until the future is available.
        ChannelFuture future = null;
        do {
            try {
                future = futureQueue.poll(Integer.MAX_VALUE, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                // Ignore
            }
        } while (future == null);

        // Wait for the future.
        future.awaitUninterruptibly();
        if (!future.isSuccess()) {
            future.getChannel().close().awaitUninterruptibly();
            throw new ChannelException("Failed to bind to: " + localAddress, future.getCause());
        }

        return channel;
    }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

          @Override
          public void run()
          {
            //System.err.println("Client running on thread: " + Thread.currentThread());
            ChannelFuture connectFuture = _clientBootstrap.connect(new LocalAddress(serverAddr));
            connectFuture.awaitUninterruptibly();
            _channel = connectFuture.getChannel();
            _lock.lock();
            try
            {
              _connected = connectFuture.isSuccess();
              _connectedCondition.signalAll();
              while (!_shutdownRequested)
              {
                try
                {
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.