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:com.netty.fileTest.http.upload.HttpUploadServer.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure SSL. final SslContext sslCtx; if (SSL) {/*w ww .j a va2 s . c om*/ 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); b.channel(NioServerSocketChannel.class); b.handler(new LoggingHandler(LogLevel.INFO)); b.childHandler(new HttpUploadServerInitializer(sslCtx)); Channel ch = b.bind(PORT).sync().channel(); System.err.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:com.netty.grpc.proxy.demo.handler.GrpcProxyInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { System.out.println("---------------------------------MockGrpcServerInitializer-----------------"); ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(new LoggingHandler(LogLevel.INFO)); pipeline.addLast(new GrpcProxyFrontendHandler(remoteHosts, remotePorts, counter)); }
From source file:com.netty.grpc.proxy.demo.start.ProxyStarter.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure the bootstrap. EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); AtomicInteger counter = new AtomicInteger(0); try {// w w w .j a va2s. c o m ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new GrpcProxyInitializer(remote_hosts, remote_ports, counter)) .childOption(ChannelOption.AUTO_READ, false).bind(LOCAL_PORT).sync().channel().closeFuture() .sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:com.newlandframework.avatarmq.broker.server.AvatarMQBrokerServer.java
License:Apache License
public void init() { try {/*from w ww . j ava 2 s . c o m*/ handler = new MessageBrokerHandler().buildConsumerHook(new ConsumerMessageHook()) .buildProducerHook(new ProducerMessageHook()); boss = new NioEventLoopGroup(1, threadBossFactory); workers = new NioEventLoopGroup(parallel, threadWorkerFactory, NettyUtil.getNioSelectorProvider()); KryoCodecUtil util = new KryoCodecUtil(KryoPoolFactory.getKryoPoolInstance()); bootstrap = new ServerBootstrap(); bootstrap.group(boss, workers).channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 1024).option(ChannelOption.SO_REUSEADDR, true) .option(ChannelOption.SO_KEEPALIVE, false).childOption(ChannelOption.TCP_NODELAY, true) .option(ChannelOption.SO_SNDBUF, nettyClustersConfig.getClientSocketSndBufSize()) .option(ChannelOption.SO_RCVBUF, nettyClustersConfig.getClientSocketRcvBufSize()) .handler(new LoggingHandler(LogLevel.INFO)).localAddress(serverIpAddr) .childHandler(new ChannelInitializer<SocketChannel>() { public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(defaultEventExecutorGroup, new MessageObjectEncoder(util), new MessageObjectDecoder(util), handler); } }); super.init(); } catch (IOException ex) { Logger.getLogger(AvatarMQBrokerServer.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.nextcont.ecm.fileengine.http.nettyServer.HttpUploadServer.java
License:Apache License
@Override protected void doStart() throws Exception { final SslContext sslCtx; if (SSL) {//from ww w .ja va 2 s. c om SelfSignedCertificate ssc = new SelfSignedCertificate(); sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build(); } else { sslCtx = null; } boss = new NioEventLoopGroup(); worker = new NioEventLoopGroup(); try { ServerBootstrap server = new ServerBootstrap(); server.group(boss, worker); server.channel(NioServerSocketChannel.class); server.handler(new LoggingHandler(LogLevel.INFO)); server.childHandler(new HttpUploadServerInitializer(sslCtx, fileService, fileRecordManager)); Channel ch = server.bind(PORT).sync().channel(); System.err.println("Open your web browser and navigate to " + (SSL ? "https" : "http") + "://127.0.0.1:" + PORT + '/'); ch.closeFuture().sync(); } finally { boss.shutdownGracefully(); worker.shutdownGracefully(); } }
From source file:com.nus.mazegame.server.GameServer.java
public static void init(int port, int x, int y, int treasure, boolean isSlave) throws Exception { GameService.gameService = new GameService(x, y, treasure, isSlave); // Configure the server. EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try {//from w w w .j a v a 2s . c o m 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(); // Decoders p.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4)); p.addLast("bytesDecoder", new ByteArrayDecoder()); // Encoder p.addLast("frameEncoder", new LengthFieldPrepender(4)); p.addLast("bytesEncoder", new ByteArrayEncoder()); // p.addLast(new LoggingHandler(LogLevel.INFO)); p.addLast(new GameServerHandler()); } }); // Start the server. ChannelFuture f = b.bind(port).sync(); Logger.getLogger(GameServerHandler.class.getName()).log(Level.INFO, "Server started..."); // 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:com.ogarproject.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(server.getConfig().server.port).sync().channel(); OgarServer.log.info("Server started on port " + server.getConfig().server.port + "."); }
From source file:com.ottogroup.bi.asap.server.emitter.websocket.WebSocketServer.java
License:Apache License
public static void main(String[] args) throws Exception { EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try {// w w w. ja v a 2 s. c om ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new WebSocketServerInitializer()); Channel ch = b.bind(9898).sync().channel(); ch.closeFuture().sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:com.ottogroup.bi.spqr.websocket.server.SPQRWebSocketServer.java
License:Apache License
/** * Initializes and executes the server components. Although the other {@link SPQRWebSocketServer#run(String)} * could do the same work this one allows better testing as the {@link InputStream} parameter allows * to inject a variable which may be controlled much better. In the case it would be necessary to * provide a reference to a temporary file which is controlled by the use case ... somehow too much work ;-) * This one is easier. /* www .java 2 s. c o m*/ * @param configurationFileStream stream holding configuration file content * @throws IOException * @throws InterruptedException */ protected void run(final InputStream configurationFileStream) throws IOException, InterruptedException { /////////////////////////////////////////////////////////////////// // parse out configuration from provided input stream ObjectMapper jsonMapper = new ObjectMapper(); SPQRWebSocketServerConfiguration cfg = jsonMapper.readValue(configurationFileStream, SPQRWebSocketServerConfiguration.class); // /////////////////////////////////////////////////////////////////// PropertyConfigurator.configure(cfg.getLog4jConfigurationFile()); EventLoopGroup bossGroup = new NioEventLoopGroup(cfg.getBossEventGroupThreads()); EventLoopGroup workerGroup = new NioEventLoopGroup(cfg.getWorkerEventGroupThreads()); logger.info( "websocket server [port=" + cfg.getPort() + ", bossGroupThreads=" + cfg.getBossEventGroupThreads() + ", workerGroupThreads=" + cfg.getWorkerEventGroupThreads() + "]"); try { ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new SPQRWebSocketServerInitializer()); Channel channel = bootstrap.bind(cfg.getPort()).sync().channel(); channel.closeFuture().sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:com.phei.netty.codec.msgpack.EchoServer.java
License:Apache License
public void run() throws Exception { // Configure the server. EventLoopGroup acceptorGroup = new NioEventLoopGroup(); EventLoopGroup IOGroup = new NioEventLoopGroup(); try {/*from w w w . j a v a2 s.c om*/ ServerBootstrap b = new ServerBootstrap(); b.group(acceptorGroup, IOGroup).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 { ch.pipeline().addLast("msgpack decoder", new MsgpackDecoder()); ch.pipeline().addLast("msgpack encoder", new MsgpackEncoder()); ch.pipeline().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. acceptorGroup.shutdownGracefully(); IOGroup.shutdownGracefully(); } }