@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, State state) throws Exception { if (done) { int readable = actualReadableBytes(); if (readable == 0) { return null; } return buffer.readBytes(readable); } else { Object msg = super.decode(ctx, channel, buffer, state); if (failOnMissingResponse) { decrement(msg); } return msg; } }
@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { super.channelClosed(ctx, e); if (failOnMissingResponse) { long missingResponses = requestResponseCounter.get(); if (missingResponses > 0) { throw new PrematureChannelClosureException( "Channel closed but still missing " + missingResponses + " response(s)"); } } } }
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { decoder.handleUpstream(ctx, e); }
HttpTunnelingClientSocketChannel( ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink, ClientSocketChannelFactory clientSocketChannelFactory) { super(null, factory, pipeline, sink); config = new HttpTunnelingSocketChannelConfig(this); DefaultChannelPipeline channelPipeline = new DefaultChannelPipeline(); channelPipeline.addLast("decoder", new HttpResponseDecoder()); channelPipeline.addLast("encoder", new HttpRequestEncoder()); channelPipeline.addLast("handler", handler); realChannel = clientSocketChannelFactory.newChannel(channelPipeline); fireChannelOpen(this); }
@Override protected Object decode(ChannelHandlerContext ctx, Channel ch, ChannelBuffer buf, State state) throws Exception { // Decode the first message Object firstMessage = super.decode(ctx, ch, buf, state); if (firstMessage == null) { return null; } if (switchTo != null) { // Need to add it before the client handler ctx.getPipeline().addBefore("handler", name, switchTo); ctx.getPipeline().remove(this); switchTo = null; if (buf.readable()) { // Hand off the remaining data to the second decoder if (firstMessage != null) { return new Object[]{firstMessage, buf.readBytes(super.actualReadableBytes())}; } else { return new Object[]{buf.readBytes(super.actualReadableBytes())}; } } else { // Nothing to hand off return firstMessage; } } else { return firstMessage; } }
public ChannelPipeline getPipeline() throws Exception { List<ChannelHandler> handlers = new ArrayList<ChannelHandler>(); if (sslEnabled && !useServlet) { SSLEngine engine = context.createSSLEngine(); engine.setUseClientMode(true); engine.setWantClientAuth(true); SslHandler handler = new SslHandler(engine); handlers.add(handler); } if (httpEnabled) { handlers.add(new HttpRequestEncoder()); handlers.add(new HttpResponseDecoder()); handlers.add(new HttpChunkAggregator(Integer.MAX_VALUE)); handlers.add(new HttpHandler()); } handlers.add(new HornetQFrameDecoder2()); handlers.add(new HornetQClientChannelHandler(channelGroup, handler, new Listener())); ChannelPipeline pipeline = new StaticChannelPipeline(handlers.toArray(new ChannelHandler[handlers.size()])); return pipeline; } });
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("decoder", new HttpResponseDecoder()); pipeline.addLast("encoder", new HttpRequestEncoder()); pipeline.addLast("ws-handler", clientHandler); return pipeline; } });
public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("decoder", new HttpResponseDecoder()); pipeline.addLast("encoder", new HttpRequestEncoder()); pipeline.addLast("ws-handler", clientHandler); return pipeline; } });
public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("decoder", new HttpResponseDecoder()); pipeline.addLast("encoder", new HttpRequestEncoder()); pipeline.addLast("ws-handler", clientHandler); return pipeline; } });
public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("decoder", new HttpResponseDecoder()); pipeline.addLast("encoder", new HttpRequestEncoder()); pipeline.addLast("ws-handler", clientHandler); return pipeline; } });
public ChannelPipeline getPipeline() { ChannelPipeline pipeline = pipeline(); pipeline.addLast("decoder", new HttpResponseDecoder()); pipeline.addLast("encoder", new HttpRequestEncoder()); pipeline.addLast("handler", new BucketUpdateResponseHandler()); return pipeline; } }
public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = pipeline(); if (sslHandler != null) { pipeline.addLast("ssl", sslHandler); } pipeline.addLast("decoder", new HttpResponseDecoder()); // Uncomment the following line if you don't want to handle HttpChunks. pipeline.addLast("aggregator", new HttpChunkAggregator(MAX_CONTENT_SIZE)); pipeline.addLast("encoder", new HttpRequestEncoder()); return pipeline; }
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); pipeline.addLast("requestEncoder", new HttpRequestEncoder()); pipeline.addLast("channelEncoder", new HttpEncoder(host, uri)); pipeline.addLast("responseDecoder", new HttpResponseDecoder()); pipeline.addLast("aggregator", new HttpChunkAggregator(1048576)); pipeline.addLast("thriftHandler", (ChannelHandler)handler); return pipeline; } }
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); pipeline.addLast("idle-detection", IDLE_STATE_HANDLER); pipeline.addLast("logging", new LoggingHandler(InternalLogLevel.DEBUG)); pipeline.addLast("http-deflater", new HttpContentCompressor()); pipeline.addLast("decoder", new HttpResponseDecoder(RESPONSE_MAX_INITIAL_LINE_LENGTH, RESPONSE_MAX_HEADER_SIZE, RESPONSE_MAX_CHUNK_SIZE)); pipeline.addLast("encoder", new HttpRequestEncoder()); pipeline.addLast("http-inflater", new HttpContentDecompressor()); pipeline.addLast("remote-hop-timer", new ClientTimingHandler("outbound")); pipeline.addLast("exception-surfacer", EXCEPTION_SURFACER); pipeline.addLast("idle-watchdog", new IdleChannelWatchdog("outbound")); return pipeline; }