Examples of ChannelFuture


Examples of com.facebook.presto.jdbc.internal.netty.channel.ChannelFuture

            }
            return Channels.succeededFuture(ctx.getChannel());
        }

        ChannelBuffer footer;
        ChannelFuture future;
        synchronized (z) {
            try {
                // Configure input.
                z.next_in = EMPTY_ARRAY;
                z.next_in_index = 0;
                z.avail_in = 0;

                // Configure output.
                byte[] out = new byte[32]; // room for ADLER32 + ZLIB / CRC32 + GZIP header
                z.next_out = out;
                z.next_out_index = 0;
                z.avail_out = out.length;

                // Write the ADLER32 checksum (stream footer).
                int resultCode = z.deflate(JZlib.Z_FINISH);
                if (resultCode != JZlib.Z_OK && resultCode != JZlib.Z_STREAM_END) {
                    future = Channels.failedFuture(
                            ctx.getChannel(),
                            ZlibUtil.exception(z, "compression failure", resultCode));
                    footer = null;
                } else if (z.next_out_index != 0) {
                    future = Channels.future(ctx.getChannel());
                    footer =
                        ctx.getChannel().getConfig().getBufferFactory().getBuffer(
                                out, 0, z.next_out_index);
                } else {
                    // Note that we should never use a SucceededChannelFuture
                    // here just in case any downstream handler or a sink wants
                    // to notify a write error.
                    future = Channels.future(ctx.getChannel());
                    footer = ChannelBuffers.EMPTY_BUFFER;
                }
            } finally {
                z.deflateEnd();

                // Deference the external references explicitly to tell the VM that
                // the allocated byte arrays are temporary so that the call stack
                // can be utilized.
                // I'm not sure if the modern VMs do this optimization though.
                z.next_in = null;
                z.next_out = null;
            }
        }

        if (footer != null) {
            Channels.write(ctx, future, footer);
        }

        if (evt != null) {
            future.addListener(new ChannelFutureListener() {
                public void operationComplete(ChannelFuture future) throws Exception {
                    ctx.sendDownstream(evt);
                }
            });
        }
View Full Code Here

Examples of io.netty.channel.ChannelFuture

        public void operationComplete(final Future<Channel> future) {
          if (future.isSuccess()) {
            final List<ExpiredToken> expiredTokens = feedbackServer.getAndClearAllExpiredTokens();

            ChannelFuture lastWriteFuture = null;

            for (final ExpiredToken expiredToken : expiredTokens) {
              lastWriteFuture = context.write(expiredToken);
            }

            if (feedbackServer.closeWhenDone) {
              if (lastWriteFuture != null) {
                lastWriteFuture.addListener(ChannelFutureListener.CLOSE);
              } else {
                context.close();
              }
            }
View Full Code Here

Examples of net.gleamynode.netty.channel.ChannelFuture

        pipeline.addFirst("connector", new Connector(remoteAddress, localAddress, futureQueue));

        getFactory().newChannel(pipeline);

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

Examples of net.minecraft.util.io.netty.channel.ChannelFuture

    public void b() {
        this.a = false;
        Iterator iterator = this.e.iterator();

        while (iterator.hasNext()) {
            ChannelFuture channelfuture = (ChannelFuture) iterator.next();

            channelfuture.channel().close().syncUninterruptibly();
        }
    }
View Full Code Here

Examples of org.elasticsearch.common.netty.channel.ChannelFuture

                        } else {
                            writeBuffer.writeBytes(response.content(), 0, response.contentLength());
                        }
                    }
                }
                ChannelFuture future = channel.write(writeBuffer);
                if (releaseContentListener != null) {
                    future.addListener(releaseContentListener);
                }
            } catch (Exception e) {
                throw new MemcachedTransportException("Failed to write response", e);
            }
        } else {
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

        ClassNotFoundException {
      throw new UnsupportedOperationException();
    }

    public Future<?> write(Object msg) {
      final ChannelFuture future = channel.write(msg);
      future.addListener(completionListener);
      return new Future<Void>() {

        @Override
        public boolean cancel(boolean arg0) {
          return future.cancel();
        }

        @Override
        public Void get() throws InterruptedException,
            ExecutionException {
          future.await();
          if (!future.isSuccess()) {
            throw new ExecutionException(future.getCause());
          }
          return null;
        }

        @Override
        public Void get(long arg0, TimeUnit arg1)
            throws InterruptedException, ExecutionException,
            TimeoutException {
          if (future.await(arg0, arg1)) {
            if (!future.isSuccess()) {
              throw new ExecutionException(future.getCause());
            }
            return null;
          }
          throw new TimeoutException();
        }

        @Override
        public boolean isCancelled() {
          return future.isCancelled();
        }

        @Override
        public boolean isDone() {
          return future.isDone();
        }
      };
    }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

    }

    private void flushResponse() {
        // Send the response and close the connection.
        try {
            ChannelFuture future = write(responseBuffer);
            future.addListener(ChannelFutureListener.CLOSE);
        } catch (Exception e) {
            ioExceptionHandler.uncaughtException(Thread.currentThread(), e);
        }
    }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

                response.addHeader(SET_COOKIE, cookieEncoder.encode());
            }
        }

        // Write the response.
        ChannelFuture future = e.getChannel().write(response);

        // Close the non-keep-alive connection after the write operation is done.
        if (!keepAlive) {
            future.addListener(ChannelFutureListener.CLOSE);
        }
    }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

        // Set up the event pipeline factory.
        bootstrap.setPipelineFactory(new FactorialClientPipelineFactory(count));

        // Make a new connection.
        ChannelFuture connectFuture =
            bootstrap.connect(new InetSocketAddress(host, port));

        // Wait until the connection is made successfully.
        Channel channel = connectFuture.awaitUninterruptibly().getChannel();

        // Get the handler instance to retrieve the answer.
        FactorialClientHandler handler =
            (FactorialClientHandler) channel.getPipeline().getLast();
View Full Code Here

Examples of org.jboss.netty.channel.ChannelFuture

        // Set up the event pipeline factory.
        bootstrap.setPipelineFactory(new HttpClientPipelineFactory(ssl));

        // Start the connection attempt.
        ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));

        // Wait until the connection attempt succeeds or fails.
        Channel channel = future.awaitUninterruptibly().getChannel();
        if (!future.isSuccess()) {
            future.getCause().printStackTrace();
            bootstrap.releaseExternalResources();
            return;
        }

        // Prepare the HTTP request.
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.