Java 类io.netty.util.internal.logging.Log4JLoggerFactory 实例源码

项目:tesora-dve-pub    文件:LoadBalancer.java   
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();
    }
项目:mqttserver    文件:Server.java   
public ChannelFuture run() throws Exception {
  InternalLoggerFactory.setDefaultFactory(Log4JLoggerFactory.INSTANCE);

  Channel channle = getDefaultServerBootstrap().childHandler(new TcpChannelInitializer()).bind(port).sync().channel();
  channels.add(channle);

  logger.info("MQTT server is started at port " + port + '.');

  ChannelFuture future = getDefaultServerBootstrap().childHandler(new HttpChannelInitializer()).bind(httpPort);

  Channel httpChannel = future.sync().channel();
  channels.add(httpChannel);

  logger.info("MQTT websocket server is started at port " + httpPort + '.');

  return future;
}
项目:tesora-dve-pub    文件:MySqlPortal.java   
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 {
        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);
    }               
}