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:org.greencheek.elasticacheconfig.server.StringServer.java
License:Apache License
/** * Override to set up your specific external resource. * * @throws if setup fails (which will disable {@code after} */// www .j av a2 s . c o m public void before(final String[] message, final TimeUnit delayUnit, final long delay, boolean sendAllMessages) throws Throwable { final ServerSocket socket = findFreePort(); final ChannelHandler sharedHandler = new StringBasedServerHandler(message, delayUnit, delay, sendAllMessages); // do nothing try { final ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 100).option(ChannelOption.SO_SNDBUF, 100) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); p.addLast(new ConfigGetClusterDecoder()); p.addLast(new LoggingHandler(LogLevel.INFO)); p.addLast(sharedHandler); } }); // Start the server. if (startDelay > 0) { port = getPortNoClose(socket); workerGroup.schedule(new Runnable() { @Override public void run() { try { port = getPort(socket); b.bind(port).sync(); outputStartedMessage(); } catch (InterruptedException e) { } } }, startDelay, startDelayUnit); } else { port = getPort(socket); b.bind(port).sync(); outputStartedMessage(); } } finally { } }
From source file:org.iotivity.cloud.base.CoapServer.java
License:Open Source License
public void startServer(InetSocketAddress inetSocketAddress) throws CertificateException, SSLException, InterruptedException { try {// w ww .ja v a2s.co m ServerBootstrap b = new ServerBootstrap(); b.group(acceptorGroup, workerGroup); b.channel(NioServerSocketChannel.class); b.option(ChannelOption.TCP_NODELAY, true); b.option(ChannelOption.SO_KEEPALIVE, true); b.handler(new LoggingHandler(LogLevel.INFO)); b.childHandler(initializer); ChannelFuture channelFuture = b.bind(inetSocketAddress).sync(); channelFuture.addListener(new GenericFutureListener<ChannelFuture>() { @Override public void operationComplete(ChannelFuture future) throws Exception { // TODO Auto-generated method stub Logger.d("Connection status of TCP CoAP SERVER : " + future.isSuccess()); } }); } finally { } }
From source file:org.iotivity.cloud.base.HttpServer.java
License:Open Source License
public void startServer(InetSocketAddress inetSocketAddress) throws CertificateException, SSLException, InterruptedException { try {/*from ww w . j ava 2 s . c om*/ ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup); b.channel(NioServerSocketChannel.class); b.handler(new LoggingHandler(LogLevel.INFO)); b.childHandler(initializer); ChannelFuture ch = b.bind(inetSocketAddress).sync(); ch.addListener(new GenericFutureListener<ChannelFuture>() { @Override public void operationComplete(ChannelFuture future) throws Exception { // TODO Auto-generated method stub System.out.println("Connection status of TCP Http SERVER : " + future.isSuccess()); } }); } finally { } }
From source file:org.iotivity.cloud.base.server.Server.java
License:Open Source License
public void startServer(boolean tlsMode) throws CertificateException, SSLException, InterruptedException { try {/*w ww .ja v a 2s.c o m*/ if (tlsMode) Log.i("Server starts with TLS!"); if (tlsMode == true) { File serverCert = new File(OICConstants.CLOUD_CERT_FILE); File serverKey = new File(OICConstants.CLOUD_KEY_FILE); mSslContext = SslContextBuilder.forServer(serverCert, serverKey).build(); } ServerBootstrap b = new ServerBootstrap(); b.group(acceptorGroup, workerGroup); b.channel(NioServerSocketChannel.class); b.handler(new LoggingHandler(LogLevel.INFO)); b.childHandler(mServerInitializer); b.bind(mInetSocketAddress).sync(); } finally { } }
From source file:org.jboss.aerogear.webpush.netty.WebPushNettyServer.java
License:Apache License
public static void main(final String[] args) throws Exception { final WebPushServerConfig config = readConfig(args); final DataStore inMemoryDataStore = new InMemoryDataStore(); final SslContext sslCtx = createSslContext(config); final EventLoopGroup bossGroup = new NioEventLoopGroup(1); final EventLoopGroup workerGroup = new NioEventLoopGroup(); try {//from w w w.ja v a 2 s .c o m final ServerBootstrap b = new ServerBootstrap(); b.option(ChannelOption.SO_BACKLOG, 1024).group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class).handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new WebPushChannelInitializer(sslCtx, inMemoryDataStore, config)); final Channel ch = b.bind(config.host(), config.port()).sync().channel(); LOGGER.info("WebPush server bound to {}:{}", config.host(), config.port()); ch.closeFuture().sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:org.jocean.http.server.HttpTestServer.java
License:Apache License
public HttpTestServer(final boolean enableSSL, final SocketAddress localAddress, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup, final Class<? extends ServerChannel> serverChannelType, final Callable<ChannelInboundHandler> newHandler) throws Exception { // Configure SSL. final SslContext sslCtx; if (enableSSL) { SelfSignedCertificate ssc = new SelfSignedCertificate(); sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey()); } else {//from ww w .j av a2 s .com sslCtx = null; } // Configure the server. _bossGroup = bossGroup; _workerGroup = workerGroup; ServerBootstrap b = new ServerBootstrap(); b.option(ChannelOption.SO_BACKLOG, 1024); b.group(_bossGroup, _workerGroup).channel(serverChannelType).handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new HttpTestServerInitializer(sslCtx, newHandler)); b.bind(localAddress).sync(); }
From source file:org.knoxcraft.netty.server.HttpUploadServer.java
License:Apache License
public boolean enable(final Logman logger) { thread = new Thread() { public void run() { bossGroup = new NioEventLoopGroup(1); 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 ChannelInitializer<SocketChannel>() { @Override//from w w w. j av a 2 s .c om public void initChannel(SocketChannel ch) { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(new HttpRequestDecoder()); // Prevents HTTP messages from being "chunked" pipeline.addLast("aggregator", new HttpObjectAggregator(1048576)); pipeline.addLast(new HttpResponseEncoder()); // Remove the following line if you don't want automatic content compression. pipeline.addLast(new HttpContentCompressor()); pipeline.addLast(new HttpUploadServerHandler(logger)); } }); Channel ch = b.bind(PORT).sync().channel(); ch.closeFuture().sync(); } catch (InterruptedException e) { // TODO: log this server-side using logman? logger.error("Interrupted server thread!"); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } } }; thread.start(); return true; }
From source file:org.l2junity.loginserver.network.gameserver.GameServerInitializer.java
License:Open Source License
@Override protected void initChannel(SocketChannel ch) { final SecretKey blowfishKey = KeyManager.getInstance().generateBlowfishKey(); ch.pipeline().addLast("length-decoder", new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 0x8000 - 2, 0, 2, -2, 2, false)); ch.pipeline().addLast("length-encoder", LENGTH_ENCODER); ch.pipeline().addLast("crypt-codec", new CryptCodec(new Crypt(blowfishKey))); ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO)); final GameServerHandler gameServerHandler = new GameServerHandler(); ch.pipeline().addLast("packet-decoder", new PacketDecoder<>(ByteOrder.LITTLE_ENDIAN, IncomingPackets.PACKET_ARRAY, gameServerHandler)); ch.pipeline().addLast("packet-encoder", PACKET_ENCODER); ch.pipeline().addLast(gameServerHandler); }
From source file:org.loggo.server.Server.java
License:Apache License
void initialize(HierarchicalINIConfiguration config) throws ConfigurationException, AccumuloException, AccumuloSecurityException { Configuration kafkaConsumerSection = config.getSection("KafkaConsumer"); Configuration serverSection = config.getSection("server"); Configuration accumuloSection = config.getSection("accumulo"); Configuration batchSection = config.getSection("batchwriter"); Configuration kafkaSection = config.getSection("kafka"); ClientConfiguration clientConfig = new ClientConfiguration(accumuloSection); // connect to accumulo, check on the table String username = batchSection.getString("user", Defaults.USER); String password = batchSection.getString("password", Defaults.PASSWORD); String table = batchSection.getString("table", Defaults.TABLE); Instance instance = new ZooKeeperInstance(clientConfig); Connector connector = instance.getConnector(username, new PasswordToken(password.getBytes())); if (!connector.tableOperations().exists(table)) { createTable(connector, table);// ww w . j ava 2 s . c o m } createTopic(kafkaConsumerSection.getString("zookeeper.connect"), kafkaSection); LinkedBlockingDeque<LogEntry> queue = new LinkedBlockingDeque<LogEntry>( config.getInt("queue.size", Defaults.QUEUE_SIZE)); this.writer = new Writer(queue, clientConfig, batchSection); ServerBootstrap b = new ServerBootstrap(); // @formatter:off // tcp b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new LoggerReaderInitializer(queue)); // udp Bootstrap bb = new Bootstrap(); bb.group(dgramGroup).channel(NioDatagramChannel.class).handler(new DgramHandler(queue)); // @formatter:on String host = serverSection.getString("host", Defaults.HOST); serverSection.setProperty("host", host); if (host.equals(Defaults.HOST)) { try { serverSection.setProperty("host", InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException ex) { throw new RuntimeException("Unable to determine local hostname: " + ex.toString()); } } try { int tcpPort = serverSection.getInteger("tcp.port", Defaults.PORT); channel = b.bind(host, tcpPort).sync().channel(); tcpPort = ((InetSocketAddress) channel.localAddress()).getPort(); serverSection.setProperty("tcp.port", tcpPort); int udpPort = serverSection.getInteger("udp.port", Defaults.PORT); Channel channel2 = bb.bind(host, udpPort).sync().channel(); udpPort = ((InetSocketAddress) channel2.localAddress()).getPort(); serverSection.setProperty("udp.port", udpPort); registerInZookeeper(serverSection); } catch (IOException | KeeperException | InterruptedException ex) { throw new RuntimeException(ex); } String zookeeperConnect = kafkaConsumerSection.getString("zookeeper.connect"); if (zookeeperConnect != null) { kafkaConsumer = new KafkaConsumer(); kafkaConsumer.initialize(config, queue); kafkaConsumer.start(); } }
From source file:org.mobicents.protocols.sctp.netty.NettyServerImpl.java
License:Open Source License
private void initSocket() throws Exception { ServerBootstrap b = new ServerBootstrap(); b.group(this.management.getBossGroup(), this.management.getWorkerGroup()); if (this.ipChannelType == IpChannelType.SCTP) { b.channel(NioSctpServerChannel.class); b.option(ChannelOption.SO_BACKLOG, 100); b.childHandler(new NettySctpServerChannelInitializer(this, this.management)); this.applySctpOptions(b); } else {/* w w w.j a va 2 s . com*/ b.channel(NioServerSocketChannel.class); b.option(ChannelOption.SO_BACKLOG, 100); b.childHandler(new NettyTcpServerChannelInitializer(this, this.management)); } b.handler(new LoggingHandler(LogLevel.INFO)); InetSocketAddress localAddress = new InetSocketAddress(this.hostAddress, this.hostport); // Bind the server to primary address. ChannelFuture channelFuture = b.bind(localAddress).sync(); // Get the underlying sctp channel if (this.ipChannelType == IpChannelType.SCTP) { this.serverChannelSctp = (SctpServerChannel) channelFuture.channel(); // Bind the secondary address. // Please note that, bindAddress in the client channel should be done before connecting if you have not // enable Dynamic Address Configuration. See net.sctp.addip_enable kernel param if (this.extraHostAddresses != null) { for (int count = 0; count < this.extraHostAddresses.length; count++) { String localSecondaryAddress = this.extraHostAddresses[count]; InetAddress localSecondaryInetAddress = InetAddress.getByName(localSecondaryAddress); channelFuture = this.serverChannelSctp.bindAddress(localSecondaryInetAddress).sync(); } } if (logger.isInfoEnabled()) { logger.info(String.format("SctpServerChannel bound to=%s ", this.serverChannelSctp.allLocalAddresses())); } } else { this.serverChannelTcp = (NioServerSocketChannel) channelFuture.channel(); if (logger.isInfoEnabled()) { logger.info( String.format("ServerSocketChannel bound to=%s ", this.serverChannelTcp.localAddress())); } } }