Package org.jboss.netty.bootstrap

Examples of org.jboss.netty.bootstrap.ServerBootstrap


                     final ChannelPipelineFactory pipelineFactory,
                     final ExecutionHandler executionHandler) {
    this.responder = responder;
    this.channelFactory = channelFactory;
    this.executionHandler = executionHandler;
    ServerBootstrap bootstrap = new ServerBootstrap(channelFactory);
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
      @Override
      public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline p = pipelineFactory.getPipeline();
        p.addLast("frameDecoder", new NettyFrameDecoder());
        p.addLast("frameEncoder", new NettyFrameEncoder());
        if (executionHandler != null) {
          p.addLast("executionHandler", executionHandler);
        }
        p.addLast("handler", new NettyServerAvroHandler());
        return p;
      }
    });
    serverChannel = bootstrap.bind(addr);
    allChannels.add(serverChannel);
  }
View Full Code Here


  public NettyServer(Responder responder, InetSocketAddress addr,
                     ChannelFactory channelFactory, final ExecutionHandler executionHandler) {
      this.responder = responder;
      this.channelFactory = channelFactory;
      this.executionHandler = executionHandler;
      ServerBootstrap bootstrap = new ServerBootstrap(channelFactory);
      bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
          @Override
          public ChannelPipeline getPipeline() throws Exception {
              ChannelPipeline p = Channels.pipeline();
              p.addLast("frameDecoder", new NettyFrameDecoder());
              p.addLast("frameEncoder", new NettyFrameEncoder());
              if (executionHandler != null) {
                  p.addLast("executionHandler", executionHandler);
              }
              p.addLast("handler", new NettyServerAvroHandler());
              return p;
          }
      });
      serverChannel = bootstrap.bind(addr);
      allChannels.add(serverChannel);
  }
View Full Code Here

    private int startServer(ChannelHandler... handlers) {
        return startServer(new PipelineFactory(handlers));
    }

    private int startServer(ChannelPipelineFactory factory) {
        ServerBootstrap bootstrap = new ServerBootstrap(
                new NioServerSocketChannelFactory(
                        Executors.newCachedThreadPool(),
                        Executors.newCachedThreadPool()));

        bootstrap.setPipelineFactory(factory);

        port = bindBootstrap(bootstrap, 0);
        return port;
    }
View Full Code Here

    @Override
    protected void startInner() {
        initialize();
        // Configure the service
        this.workerPool = (ThreadPoolExecutor) Executors.newCachedThreadPool();
        this.bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), workerPool));
        this.bootstrap.setOption("backlog", this.coordinatorConfig.getNettyServerBacklog());
        this.bootstrap.setOption("child.tcpNoDelay", true);
        this.bootstrap.setOption("child.keepAlive", true);
        this.bootstrap.setOption("child.reuseAddress", true);
View Full Code Here

        nettyTimeout = timeout;

        ChannelFactory factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
                Executors.newCachedThreadPool());

        bootstrap = new ServerBootstrap(factory);

        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
            public ChannelPipeline getPipeline() {
                ChannelPipeline p = Channels.pipeline();
                p.addLast("1", new LengthFieldBasedFrameDecoder(999999, 0, 4, 0, 4));
View Full Code Here

    @PostConstruct
    public void start() {
        logger.info("Starting server.");
        // Configure the server.
        bootstrap = new ServerBootstrap(
                new NioServerSocketChannelFactory(
                        Executors.newCachedThreadPool(),
                        Executors.newCachedThreadPool()));

        // Set up the pipeline factory.
View Full Code Here

//
//        bootstrap = new ServerBootstrap(
//                new NioServerSocketChannelFactory(bossExec, ioExec, Runtime.getRuntime().availableProcessors() + 1));

        // Configure the server.
        bootstrap = new ServerBootstrap(
                new NioServerSocketChannelFactory(
                        Executors.newCachedThreadPool(),
                        Executors.newCachedThreadPool()));

        bootstrap.setOption("child.tcpNoDelay", true);
View Full Code Here

   */
  public NettyServer(InetSocketAddress addr, ChannelFactory channelFactory,
      final ExecutionHandler executionHandler, Configuration conf) {
    this.channelFactory = channelFactory;
    this.executionHandler = executionHandler;
    ServerBootstrap bootstrap = new ServerBootstrap(channelFactory);
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
      @Override
      public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline p = Channels.pipeline();
        p.addLast("frameDecoder", new NettyFrameDecoder());
        p.addLast("frameEncoder", new NettyFrameEncoder());
        if (executionHandler != null) {
          p.addLast("executionHandler", executionHandler);
        }
        p.addLast("handler", new NettyServerWaspHandler());
        return p;
      }
    });
    this.addr = addr;
    serverChannel = bootstrap.bind(addr);
    allChannels.add(serverChannel);
  }
View Full Code Here

      else
      {
         channelFactory = new OioServerSocketChannelFactory(bossExecutor, workerExecutor);
      }

      bootstrap = new ServerBootstrap(channelFactory);

      final SSLContext context;
      if (sslEnabled)
      {
         try
View Full Code Here

      Executor workerExecutor = Executors.newCachedThreadPool();

      NioServerSocketChannelFactory factory = new NioServerSocketChannelFactory(masterExecutor, workerExecutor, workerThreads());

      // Configure the server.
      ServerBootstrap bootstrap = new ServerBootstrap(factory);

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

      // Bind and start to accept incoming connections.
      bootstrap.setOption("child.tcpNoDelay", tcpNoDelay);
      if (sendBufSize > 0) bootstrap.setOption("child.sendBufferSize", sendBufSize);
      if (recvBufSize > 0) bootstrap.setOption("child.receiveBufferSize", recvBufSize);

      bootstrap.bind(address);
   }
View Full Code Here

TOP

Related Classes of org.jboss.netty.bootstrap.ServerBootstrap

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.