@Override public List<String> names() { return delegate.names(); }
protected String format(ChannelHandlerContext ctx, String message) { String chStr = ctx.channel().toString() + ' ' + message; if (logger.isTraceEnabled()) { chStr += NEW_LINE + "channel: " + ctx.channel().id() + NEW_LINE + "pipeline: " + ctx.pipeline().names() + NEW_LINE; } return chStr; }
private void initHttpPipeline(ChannelHandlerContext ctx) { ctx.pipeline() .addLast(resetPasswordLogic) .addLast(httpAPILogic) .addLast(noMatchHandler) .remove(this); if (log.isTraceEnabled()) { log.trace("Initialized https pipeline. {}", ctx.pipeline().names()); } }
private void setIdleTime(ChannelPipeline pipeline, int idleTime) { if (pipeline.names().contains("idleStateHandler")) { pipeline.remove("idleStateHandler"); } pipeline.addFirst("idleStateHandler", new IdleStateHandler(idleTime, 0, 0)); }
@Override public List<String> names() { return pipeline.names(); }
@Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); /** * We will use a length prepended payload to defragment TCP fragments. */ pipeline.addLast("decoder", new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4)); pipeline.addLast("encoder", new LengthFieldPrepender(4)); //pipeline.addLast("logger", new LoggingHandler()); pipeline.addLast("handler", _handler); LOGGER.info("Server Channel pipeline setup. Pipeline:" + ch.pipeline().names()); } }
ctx.channel().remoteAddress(), cause.getMessage()); } else { log.error("DecoderException. Pipeline : {}.", ctx.pipeline().names(), cause);
private void initWebSocketPipeline(ChannelHandlerContext ctx, String websocketPath) { var pipeline = ctx.pipeline(); //websockets specific handlers pipeline.addFirst("WSIdleStateHandler", new IdleStateHandler(hardwareIdleTimeout, 0, 0)) .addLast("WSChannelState", hardwareChannelStateHandler) .addLast("WSWebSocketServerProtocolHandler", new WebSocketServerProtocolHandler(websocketPath, true)) .addLast("WSWebSocket", webSocketHandler) .addLast("WSMessageDecoder", new MessageDecoder(stats, holder.limits)) .addLast("WSSocketWrapper", webSocketWrapperEncoder) .addLast("WSMessageEncoder", new MessageEncoder(stats)) .addLast("WSLogin", hardwareLoginHandler) .addLast("WSNotLogged", alreadyLoggedHandler); pipeline.remove(ChunkedWriteHandler.class); pipeline.remove(UrlReWriterHandler.class); pipeline.remove(StaticFileHandler.class); pipeline.remove(this); if (log.isTraceEnabled()) { log.trace("Initialized secured hardware websocket pipeline. {}", ctx.pipeline().names()); } } };
private void initWebDashboardSocket(ChannelHandlerContext ctx) { var pipeline = ctx.pipeline(); //websockets specific handlers pipeline.addFirst("AChannelState", appChannelStateHandler) .addFirst("AReadTimeout", new IdleStateHandler(appIdleTimeout, 0, 0)) .addLast("WSWebSocketServerProtocolHandler", new WebSocketServerProtocolHandler(WEBSOCKET_WEB_PATH)) .addLast("WSMessageDecoder", new WSMessageDecoder(stats, holder.limits)) .addLast("WSMessageEncoder", webAppMessageEncoder) .addLast("AGetServer", getServerHandler) .addLast("ALogin", appLoginHandler) .addLast("ANotLogged", userNotLoggedHandler); pipeline.remove(ChunkedWriteHandler.class); pipeline.remove(UrlReWriterHandler.class); pipeline.remove(StaticFileHandler.class); pipeline.remove(this); if (log.isTraceEnabled()) { log.trace("Initialized web dashboard pipeline. {}", ctx.pipeline().names()); } }
private void initWebSocketPipeline(ChannelHandlerContext ctx, String websocketPath) { var pipeline = ctx.pipeline(); //websockets specific handlers pipeline.addFirst("WSIdleStateHandler", new IdleStateHandler(hardTimeoutSecs, 0, 0)) .addLast("WSChannelState", hardwareChannelStateHandler) .addLast("WSWebSocketServerProtocolHandler", new WebSocketServerProtocolHandler(websocketPath, true)) .addLast("WSWebSocket", new WSHandler(stats)) .addLast("WSMessageDecoder", new MessageDecoder(stats, holder.limits)) .addLast("WSSocketWrapper", new WSWrapperEncoder()) .addLast("WSMessageEncoder", new MessageEncoder(stats)) .addLast("WSLogin", hardwareLoginHandler) .addLast("WSNotLogged", alreadyLoggedHandler) .remove(this); if (log.isTraceEnabled()) { log.trace("Initialized hardware websocket pipeline. {}", ctx.pipeline().names()); } } };
private void initAdminPipeline(ChannelHandlerContext ctx) { if (!ipFilterHandler.accept(ctx)) { ctx.close(); return; } var pipeline = ctx.pipeline(); pipeline.addLast(new UploadHandler(holder.props.jarPath, "/upload", "/static/ota")) .addLast(new OTAHandler(holder, rootPath + "/ota/start", "/static/ota")) .addLast(adminAuthHandler) .addLast(authCookieHandler) .addLast(cookieBasedUrlReWriterHandler); pipeline.remove(StaticFileHandler.class); pipeline.addLast(new StaticFileHandler(holder.props, new NoCacheStaticFile("/static"))) .addLast(otaLogic) .addLast(usersLogic) .addLast(statsLogic) .addLast(configsLogic) .addLast(hardwareStatsLogic) .addLast(httpAPILogic) .addLast(noMatchHandler) .remove(this); if (log.isTraceEnabled()) { log.trace("Initialized admin pipeline. {}", ctx.pipeline().names()); } }
private void initHttpPipeline(ChannelHandlerContext ctx) { ctx.pipeline() .addLast(letsEncryptHandler) .addLast("HttpChunkedWrite", new ChunkedWriteHandler()) .addLast("HttpUrlMapper", new UrlReWriterHandler("/favicon.ico", "/static/favicon.ico")) .addLast("HttpStaticFile", new StaticFileHandler(holder.props, new StaticFile("/static"), new StaticFileEdsWith(FileUtils.CSV_DIR, ".gz"), new StaticFileEdsWith(FileUtils.CSV_DIR, ".zip"))) .addLast(resetPasswordLogic) .addLast(httpAPILogic) .addLast(noMatchHandler) .remove(this); if (log.isTraceEnabled()) { log.trace("Initialized http pipeline. {}", ctx.pipeline().names()); } }
public EmbeddedChannelPipelineDelegate(EmbeddedChannel newChannel) { pipeline = newChannel.pipeline(); final ChannelHandler lastHandler = pipeline.last(); if (null != lastHandler) { List<String> names = pipeline.names(); for (String name : names) { if (pipeline.get(name) == lastHandler) { lastHandlerName = name; return; } } lastHandlerName = null; } else { lastHandlerName = null; } }
if (channelPipeline.names().contains(RpcConstants.SSL_HANDLER)) { channelPipeline.addAfter(RpcConstants.SSL_HANDLER, RpcConstants.SASL_DECRYPTION_HANDLER, new SaslDecryptionHandler(saslCodec, getMaxWrappedSize(), OutOfMemoryHandler.DEFAULT_INSTANCE));
public void add(@NotNull ChannelHandlerContext ctx) { // Direction only matters for the init path when the init handler hasn't been removed if (!ctx.pipeline().names().contains("InitRequestHandler")) { findOrNewPeer(ctx.channel().remoteAddress()).handleActiveOutConnection(ctx); } }
@Test public void addNonByteEncoderWhenEmptyPipeline() { ChannelHandler encoder = new ChannelHandlerAdapter() { }; testContext.addHandlerFirst("encoder", encoder); assertEquals(channel.pipeline() .names(), Arrays.asList("encoder", "DefaultChannelPipeline$TailContext#0")); }
@Test public void addNonByteDecoderWhenEmptyPipeline() { ChannelHandler decoder = new ChannelHandlerAdapter() { }; testContext.addHandlerLast("decoder", decoder); assertEquals(channel.pipeline() .names(), Arrays.asList("decoder", "DefaultChannelPipeline$TailContext#0")); }
@Test public void addDecoderSkipsIfExist() { channel.pipeline() .addFirst("foo", new Utf8FrameValidator()); testContext.addHandlerFirst("foo", new LineBasedFrameDecoder(10)); assertEquals(channel.pipeline() .names(), Arrays.asList("foo", "DefaultChannelPipeline$TailContext#0")); assertThat(channel.pipeline() .get("foo"), is(instanceOf(Utf8FrameValidator.class))); }
@Test public void addEncoderSkipsIfExist() { channel.pipeline() .addFirst("foo", new Utf8FrameValidator()); testContext.addHandlerFirst("foo", new LineBasedFrameDecoder(10)); assertEquals(channel.pipeline() .names(), Arrays.asList("foo", "DefaultChannelPipeline$TailContext#0")); assertThat(channel.pipeline() .get("foo"), is(instanceOf(Utf8FrameValidator.class))); }
@Test public void addByteDecoderWhenEmptyPipeline() { ChannelHandler decoder = new LineBasedFrameDecoder(12); testContext.addHandlerLast("decoder", decoder) .addHandlerFirst("decoder$extract", NettyPipeline.inboundHandler(ADD_EXTRACTOR)); assertEquals(channel.pipeline() .names(), Arrays.asList("decoder$extract", "decoder", "DefaultChannelPipeline$TailContext#0")); }