Package org.jboss.netty.channel.socket

Examples of org.jboss.netty.channel.socket.ServerSocketChannelFactory


    this.outgoingCallback = outgoingCallback;
    this.channelHandlers = channelHandlers;
  }
 
  public void startListening(){
    final ServerSocketChannelFactory cf = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
    final ServerBootstrap server = new ServerBootstrap(cf);
    server.setPipelineFactory(new FIXAcceptorPipelineFactory(
        headerFields,
        trailerFields,
        isDebugOn,
View Full Code Here


                cp.addLast("handler", new TestHandler());
                return cp;
            }
        });

        ServerSocketChannelFactory serverFactory;
        if (nio) {
            serverFactory = new NioServerSocketChannelFactory();
        } else {
            serverFactory = new OioServerSocketChannelFactory();
        }
View Full Code Here

          MUST_BE_WRITEABLE, CREATE_IF_NEEDED);
    } catch (IllegalArgumentException e) {
      usage(argp, e.getMessage(), 3);
    }

    final ServerSocketChannelFactory factory;
    if (config.getBoolean("tsd.network.async_io")) {
      int workers = Runtime.getRuntime().availableProcessors() * 2;
      if (config.hasProperty("tsd.network.worker_threads")) {
        try {
        workers = config.getInt("tsd.network.worker_threads");
        } catch (NumberFormatException nfe) {
          usage(argp, "Invalid worker thread count", 1);
        }
      }
      factory = new NioServerSocketChannelFactory(
          Executors.newCachedThreadPool(), Executors.newCachedThreadPool(),
          workers);
    } else {
      factory = new OioServerSocketChannelFactory(
          Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
    }
   
    TSDB tsdb = null;
    try {
      tsdb = new TSDB(config);
      tsdb.initializePlugins(true);
     
      // Make sure we don't even start if we can't find our tables.
      tsdb.checkNecessaryTablesExist().joinUninterruptibly();

      registerShutdownHook(tsdb);
      final ServerBootstrap server = new ServerBootstrap(factory);

      server.setPipelineFactory(new PipelineFactory(tsdb));
      if (config.hasProperty("tsd.network.backlog")) {
        server.setOption("backlog", config.getInt("tsd.network.backlog"));
      }
      server.setOption("child.tcpNoDelay",
          config.getBoolean("tsd.network.tcp_no_delay"));
      server.setOption("child.keepAlive",
          config.getBoolean("tsd.network.keep_alive"));
      server.setOption("reuseAddress",
          config.getBoolean("tsd.network.reuse_address"));

      // null is interpreted as the wildcard address.
      InetAddress bindAddress = null;
      if (config.hasProperty("tsd.network.bind")) {
        bindAddress = InetAddress.getByName(config.getString("tsd.network.bind"));
      }

      // we validated the network port config earlier
      final InetSocketAddress addr = new InetSocketAddress(bindAddress,
          config.getInt("tsd.network.port"));
      server.bind(addr);
      log.info("Ready to serve on " + addr);
    } catch (Throwable e) {
      factory.releaseExternalResources();
      try {
        if (tsdb != null)
          tsdb.shutdown().joinUninterruptibly();
      } catch (Exception e2) {
        log.error("Failed to shutdown HBase client", e2);
View Full Code Here

TOP

Related Classes of org.jboss.netty.channel.socket.ServerSocketChannelFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.