List of usage examples for io.netty.handler.logging LogLevel INFO
LogLevel INFO
To view the source code for io.netty.handler.logging LogLevel INFO.
Click Source Link
From source file:king.flow.test.net.EchoServer.java
License:Apache License
public void run() throws Exception { // Configure the server. EventLoopGroup bossGroup = new NioEventLoopGroup(); EventLoopGroup workerGroup = new NioEventLoopGroup(); try {//w ww .j a va 2 s. c om ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { //new LoggingHandler(LogLevel.INFO), ch.pipeline().addLast(echoServerHandler); } }); // Start the server. ChannelFuture f = b.bind(port).sync(); // Wait until the server socket is closed. f.channel().closeFuture().sync(); } finally { // Shut down all event loops to terminate all threads. bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:lee.study.server.BoomOnlineServer.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure SSL. final SslContext sslCtx; if (SSL) {/*w ww . j ava 2s. c om*/ SelfSignedCertificate ssc = new SelfSignedCertificate(); sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build(); } else { sslCtx = null; } EventLoopGroup bossGroup = new NioEventLoopGroup(); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new WebSocketServerInitializer(sslCtx)); Channel ch = b.bind(PORT).sync().channel(); ch.closeFuture().sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:main.java.ch.epfl.lpd.ServerThread.java
License:Apache License
public void run() { // Configure SSL. final SslContext sslCtx; if (SSL) {/*from www . jav a 2s. co m*/ SelfSignedCertificate ssc; try { ssc = new SelfSignedCertificate(); sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build(); } catch (Exception e) { // TODO Auto-generated catch block logger.error("Got exception", e); } } else { sslCtx = null; } // Configure the server. EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); /* if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc())); } */ p.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter())); p.addLast("decoder", new StringDecoder()); p.addLast("encoder", new StringEncoder()); //p.addLast(new LoggingHandler(LogLevel.INFO)); p.addLast(new ServerHandler()); } }); // Start the server. ChannelFuture f; try { f = b.bind(PORT).sync(); // Wait until the server socket is closed. f.channel().closeFuture().sync(); } catch (Exception e) { // TODO Auto-generated catch block logger.error("Got exception", e); } } finally { // Shut down all event loops to terminate all threads. bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:me.ferrybig.javacoding.teamspeakconnector.internal.TeamspeakConnectionInitizer.java
License:Open Source License
@Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(new DelimiterBasedFrameDecoder(Short.MAX_VALUE, LINES)); pipeline.addLast(DECODER);/*w ww . j a v a 2s.c o m*/ pipeline.addLast(ENCODER); pipeline.addLast(new ReadTimeoutHandler(timeout)); pipeline.addLast(new HandshakeListener(prom)); pipeline.addLast(PACKET_DECODER); pipeline.addLast(new ComplexPacketDecoder()); pipeline.addLast(PACKET_ENCODER); pipeline.addLast(new LoggingHandler(LogLevel.INFO)); pipeline.addLast(new PacketRateLimitingHandler()); }
From source file:me.ferrybig.p2pnetwork.Main.java
private void startIncomingConnectionThread(int port) { ServerBootstrap server = new ServerBootstrap(); server.group(group);//w ww.j a v a2s .c om server.channel(NioServerSocketChannel.class); server.option(ChannelOption.SO_BACKLOG, 128); server.childOption(ChannelOption.SO_KEEPALIVE, true); server.childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { if (blocked.containsKey(((InetSocketAddress) ch.remoteAddress()).getAddress())) { LOG.info(ch + "Rejected at socket level"); ch.close(); return; } ch.pipeline().addLast(new LengthFieldPrepender(4)); ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4)); ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO)); ch.pipeline().addLast(new PacketEncoder()); ch.pipeline().addLast(new PacketDecoder()); ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO)); ch.pipeline().addLast(new ServerBootstrapConnector(addr, incomingListener)); clientsIn.add(ch); ch.closeFuture().addListener(e1 -> { clientsIn.remove(ch); }); } }); ChannelFuture f = server.bind(port); f.addListener(e -> { this.servers.add((ServerChannel) f.channel()); f.channel().closeFuture().addListener(e1 -> { this.servers.remove((ServerChannel) f.channel()); }); }); }
From source file:me.ferrybig.p2pnetwork.Main.java
private void startOutgomingConnectionThread(InetAddress address, int port) { Bootstrap client = new Bootstrap(); client.group(group);//from ww w . j a v a 2 s. c om client.channel(NioSocketChannel.class); client.option(ChannelOption.SO_KEEPALIVE, true); client.handler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(new LengthFieldPrepender(4)); ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4)); ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO)); ch.pipeline().addLast(new PacketEncoder()); ch.pipeline().addLast(new PacketDecoder()); ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO)); ch.pipeline().addLast(new ServerBootstrapConnector(addr, outgoingListener)); } }); ChannelFuture f = client.connect(address, port); f.addListener(e -> { this.clientsOut.add(f.channel()); f.channel().closeFuture().addListener(e1 -> { this.clientsOut.remove(f.channel()); }); }); }
From source file:me.hrps.rp.preview.chat.ChatServer.java
License:Apache License
/** * ???//from ww w. j av a 2 s.c om */ public void init() { new Thread(new Runnable() { @Override public void run() { log.info("???..."); EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)).childHandler(socketServerInit); Channel ch = b.bind(PORT).sync().channel(); ch.closeFuture().sync(); } catch (Exception e) { log.error(e.getMessage()); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } } }).start(); }
From source file:me.hrps.rp.preview.chat.service.WebSocketServer.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure SSL. final SslContext sslCtx; if (SSL) {/*from ww w.j a v a 2 s . c o m*/ SelfSignedCertificate ssc = new SelfSignedCertificate(); sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey()); } else { sslCtx = null; } EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new WebSocketServerInitializer()); Channel ch = b.bind(PORT).sync().channel(); System.out.println("Open your web browser and navigate to " + (SSL ? "https" : "http") + "://127.0.0.1:" + PORT + '/'); ch.closeFuture().sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:me.jesonlee.jjfsserver.httpserver.HttpStaticFileServer.java
License:Apache License
public static void main(String[] args) throws Exception { port = Integer.parseInt(System.getProperty("httpPort")); if (port < 1000 || port > 65535) { logger.error("port can not less than 1000 or beyond 65535"); System.exit(1);//from w ww . j av a 2s .c om } // Configure SSL. final SslContext sslCtx; if (SSL) { SelfSignedCertificate ssc = new SelfSignedCertificate(); sslCtx = SslContext.newServerContext(SslProvider.JDK, ssc.certificate(), ssc.privateKey()); } else { sslCtx = null; } EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new HttpStaticFileServerInitializer(sslCtx)); Channel ch = b.bind(port).sync().channel(); System.out.println("http??" + port); logger.info("http??" + port); System.out.println("Open your web browser and navigate to " + (SSL ? "https" : "http") + "://127.0.0.1:" + port + '/'); ch.closeFuture().sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:me.zhuoran.amoeba.netty.server.HttpServer.java
License:Apache License
public void run(int eventLoopThreads, int maxContentLength) throws Exception { // Configure the server. EventLoopGroup bossGroup = new NioEventLoopGroup();// bossGroup?? EventLoopGroup workerGroup = new NioEventLoopGroup(eventLoopThreads);// //workerGroup??boss?? try {/* ww w . j a va 2s. c o m*/ //ServerBootstrap?NIO????Channel????? ServerBootstrap b = new ServerBootstrap(); b.option(ChannelOption.SO_BACKLOG, 1024);// ? b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new HttpServerInitializer(maxContentLength)); Channel ch = b.bind(port).sync().channel(); ch.closeFuture().sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }