List of usage examples for io.netty.util.internal.logging Log4JLoggerFactory Log4JLoggerFactory
@Deprecated
public Log4JLoggerFactory()
From source file:com.tesora.dve.db.mysql.portal.MySqlPortal.java
License:Open Source License
public MySqlPortal(Properties props) throws PEException { // This is the port the Portal is going to listen on - // default to Mysql's port int port = Singletons.require(HostService.class).getPortalPort(props); Singletons.replace(MySqlPortalService.class, this); InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory()); int max_concurrent = KnownVariables.MAX_CONCURRENT.getValue(null).intValue(); //TODO: parse/plan is on this pool, which is probably ok, especially with blocking calls to catalog. Check for responses that can be done by backend netty threads and avoid two context shifts. clientExecutorService = new PEThreadPoolExecutor(max_concurrent, max_concurrent, 30L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), //The thread count limits concurrency here. Using a bounded queue here would block netty threads (very bad), so this pool could be overrun by 'bad' clients that pipeline. -sgossard new PEDefaultThreadFactory("msp-client")); clientExecutorService.allowCoreThreadTimeOut(true); bossGroup = new NioEventLoopGroup(1, new PEDefaultThreadFactory("msp-boss")); //fixes the number of Netty NIO threads to the number of available CPUs. workerGroup = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors(), new PEDefaultThreadFactory("netty-worker")); ServerBootstrap b = new ServerBootstrap(); try {/* w w w . j a va2 s . co m*/ b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { if (PACKET_LOGGER) ch.pipeline().addFirst(new LoggingHandler(LogLevel.INFO)); ch.pipeline() .addLast(MSPProtocolDecoder.class.getSimpleName(), new MSPProtocolDecoder( MSPProtocolDecoder.MyDecoderState.READ_CLIENT_AUTH)) .addLast(new MSPAuthenticateHandlerV10()) .addLast(MSPCommandHandler.class.getSimpleName(), new MSPCommandHandler(clientExecutorService)) .addLast(ConnectionHandlerAdapter.getInstance()); } }) .childOption(ChannelOption.ALLOCATOR, USE_POOLED_BUFFERS ? PooledByteBufAllocator.DEFAULT : UnpooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.TCP_NODELAY, true).childOption(ChannelOption.SO_KEEPALIVE, true) .bind(port).sync(); logger.info("DVE Server bound to port " + port); } catch (Exception e) { throw new PEException("Failed to bind DVE server to port " + port + " - " + e.getMessage(), e); } }
From source file:com.tesora.dve.standalone.LoadBalancer.java
License:Open Source License
public static void main(String[] args) throws Exception { Properties props = PEFileUtils.loadPropertiesFile(LoadBalancer.class, PEConstants.CONFIG_FILE_NAME); if (args.length == 2 && "-port".equalsIgnoreCase(args[0])) props.setProperty(PORT_PROPERTY, args[1]); else if (args.length > 0) throw new Exception("Usage: LoadBalancer [-port <port>]"); InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory()); LoadBalancer loadBalancer = new LoadBalancer(props); loadBalancer.run();/* w ww . j a v a2 s . c o m*/ }
From source file:org.helios.octo.ReadSuspendTest.java
License:Open Source License
/** * @param args//www . ja va 2s . c om */ public static void main(String[] args) { BasicConfigurator.configure(); InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory()); EmbeddedChannel channel = new EmbeddedChannel(new Throttler(), new Decoder()); channel.config().setAutoRead(false); for (int i = 0; i < 20; i++) { LOG.info("Writing [" + i + "]"); channel.write(Unpooled.wrappedBuffer("any payload".getBytes())).syncUninterruptibly(); LOG.info("Wrote [" + i + "]"); } }
From source file:org.helios.octo.server.OctoServer.java
License:Open Source License
/** * <p>Starts the OctoServer</p> * @throws Exception Thrown on any error */// w ww.j a v a2 s .c o m protected void startService() throws Exception { log.info( "\n\t===========================================\n\tStarting OctoServer\n\t==========================================="); InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory()); initClassLoader(); log.info("Starting listener on [" + address + ":" + port + "]"); bossGroup = new NioEventLoopGroup(); workerGroup = new NioEventLoopGroup(); channelGroup = new DefaultChannelGroup(workerGroup.next()); ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .localAddress(new InetSocketAddress(address, port)).childHandler(new ChannelHandler() { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { channelGroup.add(ctx.channel()); } @Override public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { /* No Op */ } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { log.error("Exception caught in client pipeline", cause); } }).childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { //ch.pipeline().addLast("logging", logging); ch.pipeline().addLast("objectDecoder", new ObjectDecoder(classResolver)); //ch.pipeline().addLast("objectEncoder", objectEncoder); ch.pipeline().addLast("logging", logging); ch.pipeline().addLast("out", outAdapter); ch.pipeline().addLast("stringEncoder", new StringEncoder()); //ch.pipeline().addLast("err", errAdapter); ch.pipeline().addLast("invHandler", invocationHandler); } }); b.bind().addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture f) throws Exception { if (f.isSuccess()) { serverChannel = (NioServerSocketChannel) f.channel(); closeFuture = serverChannel.closeFuture(); log.info("Started and listening on " + serverChannel.localAddress()); if (!SystemStreamRedirector.isInstalledOnCurrentThread()) { SystemStreamRedirector.install(); } log.info( "\n\t===========================================\n\tStarted OctoServer\n\t==========================================="); } } }); }