java类org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory的实例源码

PullServerAuxService.java 文件源码 项目:incubator-tajo 阅读 21 收藏 0 点赞 0 评论 0
@Override
public synchronized void init(Configuration conf) {
  try {
    manageOsCache = conf.getBoolean(SHUFFLE_MANAGE_OS_CACHE,
        DEFAULT_SHUFFLE_MANAGE_OS_CACHE);

    readaheadLength = conf.getInt(SHUFFLE_READAHEAD_BYTES,
        DEFAULT_SHUFFLE_READAHEAD_BYTES);

    ThreadFactory bossFactory = new ThreadFactoryBuilder()
        .setNameFormat("PullServerAuxService Netty Boss #%d")
        .build();
    ThreadFactory workerFactory = new ThreadFactoryBuilder()
        .setNameFormat("PullServerAuxService Netty Worker #%d")
        .build();

    selector = new NioServerSocketChannelFactory(
        Executors.newCachedThreadPool(bossFactory),
        Executors.newCachedThreadPool(workerFactory));

    localFS = new LocalFileSystem();
    super.init(new Configuration(conf));
  } catch (Throwable t) {
    LOG.error(t);
  }
}
PullServerAuxService.java 文件源码 项目:tajo-cdh 阅读 26 收藏 0 点赞 0 评论 0
@Override
public synchronized void init(Configuration conf) {
  try {
    manageOsCache = conf.getBoolean(SHUFFLE_MANAGE_OS_CACHE,
        DEFAULT_SHUFFLE_MANAGE_OS_CACHE);

    readaheadLength = conf.getInt(SHUFFLE_READAHEAD_BYTES,
        DEFAULT_SHUFFLE_READAHEAD_BYTES);

    ThreadFactory bossFactory = new ThreadFactoryBuilder()
        .setNameFormat("PullServerAuxService Netty Boss #%d")
        .build();
    ThreadFactory workerFactory = new ThreadFactoryBuilder()
        .setNameFormat("PullServerAuxService Netty Worker #%d")
        .build();

    selector = new NioServerSocketChannelFactory(
        Executors.newCachedThreadPool(bossFactory),
        Executors.newCachedThreadPool(workerFactory));

    localFS = new LocalFileSystem();
    super.init(new Configuration(conf));
  } catch (Throwable t) {
    LOG.error(t);
  }
}
ShuffleHandler.java 文件源码 项目:hadoop-TCP 阅读 26 收藏 0 点赞 0 评论 0
@Override
protected void serviceInit(Configuration conf) throws Exception {
  manageOsCache = conf.getBoolean(SHUFFLE_MANAGE_OS_CACHE,
      DEFAULT_SHUFFLE_MANAGE_OS_CACHE);

  readaheadLength = conf.getInt(SHUFFLE_READAHEAD_BYTES,
      DEFAULT_SHUFFLE_READAHEAD_BYTES);

  maxShuffleConnections = conf.getInt(MAX_SHUFFLE_CONNECTIONS, 
                                      DEFAULT_MAX_SHUFFLE_CONNECTIONS);

  ThreadFactory bossFactory = new ThreadFactoryBuilder()
    .setNameFormat("ShuffleHandler Netty Boss #%d")
    .build();
  ThreadFactory workerFactory = new ThreadFactoryBuilder()
    .setNameFormat("ShuffleHandler Netty Worker #%d")
    .build();

  selector = new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool(bossFactory),
      Executors.newCachedThreadPool(workerFactory));
  super.serviceInit(new Configuration(conf));
}
RemoteRunMaster.java 文件源码 项目:remoterun 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Creates a new RemoteRunMaster.
 *
 * @param bossExecutor the {@link Executor} which will execute the boss threads, see
 * {@link org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory(Executor, Executor)}
 * @param workerExecutor the {@link Executor} which will execute the I/O worker threads, see
 * {@link org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory(Executor, Executor)}
 * @param callback optional callback when agents connect/send messages
 */
public RemoteRunMaster(Executor bossExecutor, Executor workerExecutor, AgentConnectionCallback callback) {
  this.callback = callback;
  NioServerSocketChannelFactory factory = new NioServerSocketChannelFactory(bossExecutor, workerExecutor);
  bootstrap = new ServerBootstrap(factory);
  bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
    @Override
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(
        new SslHandler(createSslEngine()),

        new LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4),
        new LengthFieldPrepender(4),

        new ProtobufDecoder(RemoteRun.AgentToMaster.getDefaultInstance()),
        new ProtobufEncoder(),

        new NettyLoggingHandler(),
        RemoteRunMaster.this
      );
    }
  });
  bootstrap.setOption("child.tcpNoDelay", true);
  bootstrap.setOption("child.keepAlive", true);
}
Server.java 文件源码 项目:Cassandra-Wasef 阅读 31 收藏 0 点赞 0 评论 0
private void run()
{
    // Configure the server.
    executionHandler = new ExecutionHandler(new RequestThreadPoolExecutor());
    factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
    ServerBootstrap bootstrap = new ServerBootstrap(factory);

    bootstrap.setOption("child.tcpNoDelay", true);

    // Set up the event pipeline factory.
    final EncryptionOptions.ClientEncryptionOptions clientEnc = DatabaseDescriptor.getClientEncryptionOptions();
    if (clientEnc.enabled)
    {
        logger.info("Enabling encrypted CQL connections between client and server");
        bootstrap.setPipelineFactory(new SecurePipelineFactory(this, clientEnc));
    }
    else
    {
        bootstrap.setPipelineFactory(new PipelineFactory(this));
    }

    // Bind and start to accept incoming connections.
    logger.info("Starting listening for CQL clients on {}...", socket);
    Channel channel = bootstrap.bind(socket);
    connectionTracker.allChannels.add(channel);
}
Server.java 文件源码 项目:wso2-cassandra 阅读 25 收藏 0 点赞 0 评论 0
private void run()
{
    // Configure the server.
    executionHandler = new ExecutionHandler(new RequestThreadPoolExecutor());
    factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
    ServerBootstrap bootstrap = new ServerBootstrap(factory);

    bootstrap.setOption("child.tcpNoDelay", true);

    // Set up the event pipeline factory.
    final EncryptionOptions.ClientEncryptionOptions clientEnc = DatabaseDescriptor.getClientEncryptionOptions();
    if (clientEnc.enabled)
    {
        logger.info("Enabling encrypted CQL connections between client and server");
        bootstrap.setPipelineFactory(new SecurePipelineFactory(this, clientEnc));
    }
    else
    {
        bootstrap.setPipelineFactory(new PipelineFactory(this));
    }

    // Bind and start to accept incoming connections.
    logger.info("Starting listening for CQL clients on {}...", socket);
    Channel channel = bootstrap.bind(socket);
    connectionTracker.allChannels.add(channel);
}
NettyConnector.java 文件源码 项目:netty-servlet 阅读 33 收藏 0 点赞 0 评论 0
@Override
public NettyConnector start() throws Exception {
    bootstrap = new ServerBootstrap(
            new NioServerSocketChannelFactory(
                    Executors.newCachedThreadPool(),
                    Executors.newCachedThreadPool()));

    // Set up the event pipeline factory.
    bootstrap.setPipelineFactory(new HttpServerPipelineFactory(getDispatcher()));

    bootstrap.setOption("child.tcpNoDelay", true);

    // Bind and start to accept incoming connections.
    bootstrap.bind(new InetSocketAddress(getPort()));
    return this;
}
ChatServer.java 文件源码 项目:nettyProtobufChat 阅读 25 收藏 0 点赞 0 评论 0
public static void start(){
    // Configure the server.
       ServerBootstrap bootstrap = new ServerBootstrap(
               new NioServerSocketChannelFactory(
                       Executors.newCachedThreadPool(),
                       Executors.newCachedThreadPool()));

       // Set up the event pipeline factory.
       bootstrap.setPipelineFactory(new ChatServerPipelineFactory());

       // Bind and start to accept incoming connections.
       SocketAddress address = new InetSocketAddress(PORT);
       bootstrap.bind(address);
       logger.info("ChatServer start on ... "+address);
       ChatContext.start();
}
CarbonTextServer.java 文件源码 项目:kairos-carbon 阅读 24 收藏 0 点赞 0 评论 0
@Override
public void start() throws KairosDBException
{
    // Configure the server.
    m_serverBootstrap = new ServerBootstrap(
            new NioServerSocketChannelFactory(
                    Executors.newCachedThreadPool(),
                    Executors.newCachedThreadPool()));

    // Configure the pipeline factory.
    m_serverBootstrap.setPipelineFactory(this);
    m_serverBootstrap.setOption("child.tcpNoDelay", true);
    m_serverBootstrap.setOption("child.keepAlive", true);
    m_serverBootstrap.setOption("reuseAddress", true);

    // Bind and start to accept incoming connections.
    m_serverBootstrap.bind(new InetSocketAddress(m_address, m_port));
}
CarbonPickleServer.java 文件源码 项目:kairos-carbon 阅读 21 收藏 0 点赞 0 评论 0
@Override
public void start() throws KairosDBException
{
    // Configure the server.
    m_serverBootstrap = new ServerBootstrap(
            new NioServerSocketChannelFactory(
                    Executors.newCachedThreadPool(),
                    Executors.newCachedThreadPool()));

    // Configure the pipeline factory.
    m_serverBootstrap.setPipelineFactory(this);
    m_serverBootstrap.setOption("child.tcpNoDelay", true);
    m_serverBootstrap.setOption("child.keepAlive", true);
    m_serverBootstrap.setOption("reuseAddress", true);

    // Bind and start to accept incoming connections.
    m_serverBootstrap.bind(new InetSocketAddress(m_address, m_port));
}


问题


面经


文章

微信
公众号

扫码关注公众号