Examples of ChannelHandlerContext


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

            }
        }
    }

    public ChannelFuture close() {
        ChannelHandlerContext ctx = this.ctx;
        if (ctx == null) {
            throw new IllegalStateException("not added to a pipeline");
        }
        return finishEncode(ctx, null);
    }
View Full Code Here

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

        deflater = new Deflater(compressionLevel);
        deflater.setDictionary(dictionary);
    }

    public ChannelFuture close() {
        ChannelHandlerContext ctx = this.ctx;
        if (ctx == null) {
            throw new IllegalStateException("not added to a pipeline");
        }
        return finishEncode(ctx, null);
    }
View Full Code Here

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

     * @param consolidateOnFlush
     *        {@code true} if and only if the buffered write requests are merged
     *        into a single write request
     */
    public void flush(boolean consolidateOnFlush) {
        final ChannelHandlerContext ctx = this.ctx;
        if (ctx == null) {
            // No write request was made.
            return;
        }
        Channel channel = ctx.getChannel();
        boolean acquired;

        // use CAS to see if the have flush already running, if so we don't need to take further actions
        if (acquired = flush.compareAndSet(false, true)) {
            final Queue<MessageEvent> queue = getQueue();
            if (consolidateOnFlush) {
                if (queue.isEmpty()) {
                    flush.set(false);
                    return;
                }

                List<MessageEvent> pendingWrites = new ArrayList<MessageEvent>();
                for (;;) {
                    MessageEvent e = queue.poll();
                    if (e == null) {
                        break;
                    }
                    if (!(e.getMessage() instanceof ChannelBuffer)) {
                        if ((pendingWrites = consolidatedWrite(pendingWrites)) == null) {
                            pendingWrites = new ArrayList<MessageEvent>();
                        }
                        ctx.sendDownstream(e);
                    } else {
                        pendingWrites.add(e);
                    }
                }
                consolidatedWrite(pendingWrites);
            } else {
                for (;;) {
                    MessageEvent e = queue.poll();
                    if (e == null) {
                        break;
                    }
                    ctx.sendDownstream(e);
                }
            }
           flush.set(false);
       }

View Full Code Here

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

    /**
     * Continues to fetch the chunks from the input.
     */
    public void resumeTransfer() {
        ChannelHandlerContext ctx = this.ctx;
        if (ctx == null) {
            return;
        }

        try {
View Full Code Here

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

                        ChannelFuture writeFuture = Channels.future(e.getChannel());

                        // The transfer window size is pre-decremented when sending a data frame downstream.
                        // Close the stream on write failures that leaves the transfer window in a corrupt state.
                        final SocketAddress remoteAddress = e.getRemoteAddress();
                        final ChannelHandlerContext context = ctx;
                        e.getFuture().addListener(new ChannelFutureListener() {
                            public void operationComplete(ChannelFuture future) throws Exception {
                                if (!future.isSuccess()) {
                                    issueStreamError(
                                            context, remoteAddress, streamId, SpdyStreamStatus.INTERNAL_ERROR);
                                }
                            }
                        });

                        Channels.write(ctx, writeFuture, partialDataFrame, remoteAddress);
                        return;
                    } else {
                        // Window size is large enough to send entire data frame
                        spdySession.updateSendWindowSize(streamId, -1 * dataLength);

                        // The transfer window size is pre-decremented when sending a data frame downstream.
                        // Close the stream on write failures that leaves the transfer window in a corrupt state.
                        final SocketAddress remoteAddress = e.getRemoteAddress();
                        final ChannelHandlerContext context = ctx;
                        e.getFuture().addListener(new ChannelFutureListener() {
                            public void operationComplete(ChannelFuture future) throws Exception {
                                if (!future.isSuccess()) {
                                    issueStreamError(
                                            context, remoteAddress, streamId, SpdyStreamStatus.INTERNAL_ERROR);
View Full Code Here

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

                    newWindowSize = spdySession.updateSendWindowSize(streamId, -1 * dataFrameSize);

                    // The transfer window size is pre-decremented when sending a data frame downstream.
                    // Close the stream on write failures that leaves the transfer window in a corrupt state.
                    final SocketAddress remoteAddress = e.getRemoteAddress();
                    final ChannelHandlerContext context = ctx;
                    e.getFuture().addListener(new ChannelFutureListener() {
                        public void operationComplete(ChannelFuture future) throws Exception {
                            if (!future.isSuccess()) {
                                issueStreamError(context, remoteAddress, streamId, SpdyStreamStatus.INTERNAL_ERROR);
                            }
                        }
                    });

                    // Close the local side of the stream if this is the last frame
                    if (spdyDataFrame.isLast()) {
                        halfCloseStream(streamId, false, e.getFuture());
                    }

                    Channels.write(ctx, e.getFuture(), spdyDataFrame, e.getRemoteAddress());
                } else {
                    // We can send a partial frame
                    spdySession.updateSendWindowSize(streamId, -1 * newWindowSize);

                    // Create a partial data frame whose length is the current window size
                    SpdyDataFrame partialDataFrame = new DefaultSpdyDataFrame(streamId);
                    partialDataFrame.setData(spdyDataFrame.getData().readSlice(newWindowSize));

                    ChannelFuture writeFuture = Channels.future(e.getChannel());

                    // The transfer window size is pre-decremented when sending a data frame downstream.
                    // Close the stream on write failures that leaves the transfer window in a corrupt state.
                    final SocketAddress remoteAddress = e.getRemoteAddress();
                    final ChannelHandlerContext context = ctx;
                    e.getFuture().addListener(new ChannelFutureListener() {
                        public void operationComplete(ChannelFuture future) throws Exception {
                            if (!future.isSuccess()) {
                                issueStreamError(context, remoteAddress, streamId, SpdyStreamStatus.INTERNAL_ERROR);
                            }
View Full Code Here

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

            long channelCounter = getChannelCounter(channel).addAndGet(increment);
            //System.out.println("IC: " + channelCounter + ", " + increment);
            if (maxChannelMemorySize != 0 && channelCounter >= maxChannelMemorySize && channel.isOpen()) {
                if (channel.isReadable()) {
                    //System.out.println("UNREADABLE");
                    ChannelHandlerContext ctx = eventTask.getContext();
                    if (ctx.getHandler() instanceof ExecutionHandler) {
                        // readSuspended = true;
                        ctx.setAttachment(Boolean.TRUE);
                    }
                    channel.setReadable(false);
                }
            }
        } else {
View Full Code Here

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

            long channelCounter = getChannelCounter(channel).addAndGet(-increment);
            //System.out.println("DC: " + channelCounter + ", " + increment);
            if (maxChannelMemorySize != 0 && channelCounter < maxChannelMemorySize && channel.isOpen()) {
                if (!channel.isReadable()) {
                    //System.out.println("READABLE");
                    ChannelHandlerContext ctx = eventTask.getContext();
                    if (ctx.getHandler() instanceof ExecutionHandler) {
                        // check if the attachment was set as this means that we suspend the channel
                        // from reads. This only works when this pool is used with ExecutionHandler
                        // but I guess thats good enough for us.
                        //
                        // See #215
                        if (ctx.getAttachment() != null) {
                            // readSuspended = false;
                            ctx.setAttachment(null);
                            channel.setReadable(true);
                        }
                    } else {
                        channel.setReadable(true);
                    }
View Full Code Here

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

        synchronized (handshakeLock) {
            if (handshaken && !isEnableRenegotiation()) {
                throw new IllegalStateException("renegotiation disabled");
            }

            final ChannelHandlerContext ctx = this.ctx;
            final Channel channel = ctx.getChannel();
            ChannelFuture handshakeFuture;
            Exception exception = null;

            if (handshaking) {
                return this.handshakeFuture;
View Full Code Here

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

    /**
     * Sends an SSL {@code close_notify} message to the specified channel and
     * destroys the underlying {@link SSLEngine}.
     */
    public ChannelFuture close() {
        ChannelHandlerContext ctx = this.ctx;
        Channel channel = ctx.getChannel();
        try {
            engine.closeOutbound();
            return wrapNonAppData(ctx, channel);
        } catch (SSLException e) {
            fireExceptionCaught(ctx, e);
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.