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:proxyService.Proxy.java
License:Apache License
public void run() { System.err.println("Proxying *:" + LOCAL_PORT + " to " + node.getIp() + ':' + node.getPort() + " ..."); // Configure the bootstrap. EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try {/* w w w . j a va 2s . c o m*/ ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ProxyInitializer(node)) .childOption(ChannelOption.AUTO_READ, false).bind(LOCAL_PORT).syncUninterruptibly().channel() .closeFuture().syncUninterruptibly(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:proxyService.ProxyInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new ProxyFrontendHandler(node)); }
From source file:ru.calypso.ogar.server.net.NetworkManager.java
License:Open Source License
public void start() throws IOException, InterruptedException { bossGroup = new NioEventLoopGroup(); workerGroup = new NioEventLoopGroup(); ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ClientInitializer(server)); channel = b.bind(Config.Server.PORT).sync().channel(); _log.info("Server started on port " + Config.Server.PORT + "."); }
From source file:sas.systems.imflux.session.rtsp.SimpleRtspSession.java
License:Apache License
/** * {@inheritDoc}/*w w w . j a va 2s .c om*/ */ @Override public synchronized boolean init() { if (this.running.get()) { return true; } // create bootstrap Class<? extends ServerChannel> channelType; if (useNio) { this.workerGroup = new NioEventLoopGroup(); this.bossGroup = new NioEventLoopGroup(); channelType = NioServerSocketChannel.class; } else { this.workerGroup = new OioEventLoopGroup(); this.bossGroup = new OioEventLoopGroup(); channelType = OioServerSocketChannel.class; } bootstrap = new ServerBootstrap(); bootstrap.group(this.bossGroup, this.workerGroup).option(ChannelOption.SO_SNDBUF, this.sendBufferSize) .option(ChannelOption.SO_RCVBUF, this.receiveBufferSize).channel(channelType) .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ChannelInitializer<Channel>() { // is used to initialize the ChannelPipeline @Override protected void initChannel(Channel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast("encoder", new RtspEncoder()); pipeline.addLast("decoder", new RtspDecoder()); pipeline.addLast("aggregator", new HttpObjectAggregator(64 * 1024)); pipeline.addLast("handler", new RtspHandler(SimpleRtspSession.this)); } }); // create channel try { ChannelFuture future = bootstrap.bind(this.localAddress); this.channel = future.sync().channel(); // wait for future to complete and retrieve channel } catch (Exception e) { LOG.error("Failed to bind RTSP channel for session with id " + this.id, e); this.workerGroup.shutdownGracefully(); this.bossGroup.shutdownGracefully(); this.workerGroup.terminationFuture().syncUninterruptibly(); this.bossGroup.terminationFuture().syncUninterruptibly(); return false; } LOG.debug("RTSP channel bound for RtspSession with id {}.", this.id); this.running.set(true); return true; }
From source file:server.telnet.TelnetServer.java
License:Apache License
public Channel start() throws Exception { // Configure SSL. final SslContext sslCtx; if (SSL) {// w w w. j av a 2 s .com SelfSignedCertificate ssc = new SelfSignedCertificate(); sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build(); } 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 TelnetServerInitializer(sslCtx)); // b.bind(PORT).sync();// .channel().closeFuture().sync(); Channel ch = b.bind(PORT).sync().channel(); return ch; } finally { // bossGroup.shutdownGracefully(); // workerGroup.shutdownGracefully(); } }
From source file:sk.spsjm.ptacademy.newchat.server.NettyServer.java
License:Open Source License
/** * @param args/*from w w w . ja va2s . c om*/ */ public static void main(String[] args) { 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 NettyInitializer()); try { b.bind(PORT).sync().channel().closeFuture().sync(); } catch (InterruptedException e) { e.printStackTrace(); } } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:storm.falcon.echo.EchoServer.java
License:Apache License
public static void main(String[] args) throws Exception { // ??//w ww .j a va 2s. com EventLoopGroup bossGroup = new NioEventLoopGroup(1); // EventLoopGroup workerGroup = new NioEventLoopGroup(); try { // ??? ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup) // .channel(NioServerSocketChannel.class) // NIO? .option(ChannelOption.SO_BACKLOG, 100) // TCP .handler(new LoggingHandler(LogLevel.INFO)) // .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline(); //p.addLast(new LoggingHandler(LogLevel.INFO)); p.addLast(new EchoServerHandler()); } }); // ?? ChannelFuture f = b.bind(PORT).sync(); // socket f.channel().closeFuture().sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:subterranean.crimson.server.network.ClientListener.java
License:Open Source License
@Override public void run() { if (UPNP) {/*www . ja va2 s . c o m*/ Logger.add("Attempting to automatically forward the port"); try { PortMapper.forward(PORT); Logger.add("Port mapping Success!"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); Logger.add("Port mapping failed!"); } } 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 ChannelInitializer<SocketChannel>() { @Override public void initChannel(final SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); if (sslCtx != null) { p.addLast("SSL Handler", sslCtx.newHandler(ch.alloc())); } final ServerHandler sh = new ServerHandler(); final ChannelTrafficShapingHandler ctsh = new ChannelTrafficShapingHandler(300); p.addLast(ctsh, new ObjectEncoder(), new ObjectDecoder(Integer.MAX_VALUE, ClassResolvers.cacheDisabled(null)), sh); // spawn a new connection object new Thread(new Runnable() { public void run() { Connection c = new Connection(key, encryption, sh, ctsh, ch.remoteAddress()); c.handshake(); } }).start(); } }); // Bind and start to accept incoming connections. b.bind(PORT).sync().channel().closeFuture().sync(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); if (UPNP) { Logger.add("Attempting to remove port mapping"); try { PortMapper.unforward(PORT); Logger.add("Port mapping removed"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); Logger.add("Failed to remove port mapping"); } } } }
From source file:system.core.netty.nio.chapter4.frame.delimiter.EchoServer.java
License:Apache License
public void bind(int port) throws Exception { // ??NIO//from w w w. j a va 2 s . c o m EventLoopGroup bossGroup = new NioEventLoopGroup(); 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 { ByteBuf delimiter = Unpooled.copiedBuffer("$_".getBytes()); ch.pipeline().addLast(new DelimiterBasedFrameDecoder(300, delimiter)); ch.pipeline().addLast(new StringDecoder()); ch.pipeline().addLast(new EchoServerHandler()); } }); // ??? ChannelFuture f = b.bind(port).sync(); // ??? f.channel().closeFuture().sync(); } finally { // ? bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:taichu.kafka.test.netty4.example.EchoServer.EchoServer.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure SSL. final SslContext sslCtx; if (SSL) {// ww w . j a va 2 s .c o m SelfSignedCertificate ssc = new SelfSignedCertificate(); sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build(); } 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) // .option(ChannelOption., 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(new LoggingHandler(LogLevel.INFO)); p.addLast(new 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(); } }