List of usage examples for io.netty.channel ChannelHandlerContext fireChannelRead
@Override ChannelHandlerContext fireChannelRead(Object msg);
From source file:gedi.oml.remote.Pipeline.ReceiverGroup.java
License:Apache License
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { RemotePipelineData data = (RemotePipelineData) msg; boolean release = false; try {//from w w w . j av a2 s . c o m synchronized (location) { boolean answerCorrect = data.getData().getReference().equals(location.getReference()) && data.getData().getRegion().equals(location.getRegion()); if (answerCorrect) ctx.fireChannelRead(msg); else release = true; // noone is interested in this answer anymore (i.e. the corresponding thread has been interrupted already) } } finally { if (release) ReferenceCountUtil.release(msg); } }
From source file:gedi.oml.remote.TracksServer.java
License:Apache License
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { boolean release = false; try {/*from w w w . j a v a 2s . c o m*/ if (msg instanceof String) { if (((String) msg).startsWith("E:")) { for (Sender s : idToSender.values()) s.setDisabled(true); for (String disabled : StringUtils.split(((String) msg).substring(2), ',')) idToSender.get(disabled).setDisabled(false); } else { // pipeline oml Pipeline pipeline = new OmlNodeExecutor().execute(new OmlReader().parse((String) msg)); log.log(Level.INFO, pipeline.getPetriNet().getTransitions().size() + " transitions found!"); dataManager = new TracksDataManager(pipeline.getPetriNet()); for (Sender sender : pipeline.getObjects(Sender.class)) { sender.setChannelHandlerContext(ctx); idToSender.put(sender.getInput(), sender); } release = true; } } else if (msg instanceof RemotePipelineData) { RemotePipelineData data = (RemotePipelineData) msg; dataManager.setLocation((PixelBasepairMapper) data.getData().getData(), data.getData().getReference(), data.getData().getRegion(), (x) -> { }); release = true; } else { ctx.fireChannelRead(msg); release = false; } } finally { if (release) { ReferenceCountUtil.release(msg); } } }
From source file:godfinger.http.FaviconHandler.java
License:Apache License
@Override public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception { if (msg instanceof HttpRequest) { HttpRequest request = (HttpRequest) msg; if ("/favicon.ico".equals(request.getUri())) { DefaultFullHttpResponse response = new DefaultFullHttpResponse(request.getProtocolVersion(), NOT_FOUND);/*w w w . j a v a 2 s. c om*/ if (isKeepAlive(request)) { response.headers().set(CONNECTION, KEEP_ALIVE); ctx.writeAndFlush(response); } else { ctx.writeAndFlush(response).addListener(CLOSE); } return; } } ctx.fireChannelRead(msg); }
From source file:herddb.network.netty.DataMessageDecoder.java
License:Apache License
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ByteBuf in = (ByteBuf) msg;//w w w . j a v a2s. c om try { ctx.fireChannelRead(MessageUtils.decodeMessage(in)); } finally { ReferenceCountUtil.release(msg); } }
From source file:herddb.network.netty.ProtocolMessageDecoder.java
License:Apache License
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ByteBuf in = (ByteBuf) msg;/*from w w w .j ava 2 s . c om*/ if (LOGGER.isLoggable(Level.FINEST)) { StringBuilder dumper = new StringBuilder(); ByteBufUtil.appendPrettyHexDump(dumper, in); LOGGER.log(Level.FINEST, "Received from {}: {}", new Object[] { ctx.channel(), dumper }); } try { Pdu pdu = PduCodec.decodePdu(in); ctx.fireChannelRead(pdu); } catch (Throwable err) { LOGGER.log(Level.SEVERE, "Error decoding PDU", err); ReferenceCountUtil.safeRelease(msg); } }
From source file:http2.server.Http2ServerInitializer.java
License:Apache License
/** * Configure the pipeline for a cleartext upgrade from HTTP to HTTP/2.0 *///from w w w .jav a 2 s .co m private void configureClearText(SocketChannel ch) { final ChannelPipeline p = ch.pipeline(); final HttpServerCodec sourceCodec = new HttpServerCodec(); p.addLast(sourceCodec); p.addLast(new HttpServerUpgradeHandler(sourceCodec, upgradeCodecFactory)); // ? p.addLast(new SimpleChannelInboundHandler<HttpMessage>() { @Override protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception { // If this handler is hit then no upgrade has been attempted and the client is just talking HTTP. System.err.println("Directly talking: " + msg.protocolVersion() + " (no upgrade was attempted)"); ChannelPipeline pipeline = ctx.pipeline(); ChannelHandlerContext thisCtx = pipeline.context(this); pipeline.addAfter(thisCtx.name(), null, new HelloWorldHttp1Handler("Direct. No Upgrade Attempted.")); pipeline.replace(this, null, new HttpObjectAggregator(maxHttpContentLength)); ctx.fireChannelRead(ReferenceCountUtil.retain(msg)); } }); p.addLast(new UserEventLogger()); }
From source file:io.airlift.drift.transport.netty.client.ThriftClientHandler.java
License:Apache License
@Override public void channelRead(ChannelHandlerContext context, Object message) { if (message instanceof ThriftFrame) { messageReceived(context, (ThriftFrame) message); return;//from ww w. j a va 2 s.c om } context.fireChannelRead(message); }
From source file:io.airlift.drift.transport.netty.codec.HeaderCodec.java
License:Apache License
@Override public void channelRead(ChannelHandlerContext context, Object message) { if (message instanceof ByteBuf) { ByteBuf request = (ByteBuf) message; if (request.isReadable()) { context.fireChannelRead(HeaderTransport.decodeFrame(request)); return; }// w ww . jav a 2s . co m } context.fireChannelRead(message); }
From source file:io.airlift.drift.transport.netty.codec.SimpleFrameCodec.java
License:Apache License
@Override public void channelRead(ChannelHandlerContext context, Object message) throws Exception { if (message instanceof ByteBuf) { ByteBuf buffer = (ByteBuf) message; if (buffer.isReadable()) { context.fireChannelRead(new ThriftFrame(extractResponseSequenceId(buffer.retain()), buffer, ImmutableMap.of(), transport, protocol, assumeClientsSupportOutOfOrderResponses)); return; }/*from ww w .ja va 2 s .c o m*/ } context.fireChannelRead(message); }
From source file:io.airlift.drift.transport.netty.server.ResponseOrderingHandler.java
License:Apache License
@Override public void channelRead(ChannelHandlerContext context, Object message) { if (message instanceof ThriftFrame) { ThriftFrame thriftFrame = (ThriftFrame) message; if (!thriftFrame.isSupportOutOfOrderResponse()) { context.channel().config().setAutoRead(false); }/*w w w . j av a 2 s . co m*/ } context.fireChannelRead(message); }