Package org.jboss.netty.bootstrap

Examples of org.jboss.netty.bootstrap.ConnectionlessBootstrap


    public void connect(Configuration conf) throws IOException {
      // Can't be NiO with Netty today => not implemented in Netty.
      DatagramChannelFactory f = new OioDatagramChannelFactory(service);

      ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
      b.setPipeline(Channels.pipeline(
          new ProtobufDecoder(ClusterStatusProtos.ClusterStatus.getDefaultInstance()),
          new ClusterStatusHandler()));

      String mcAddress = conf.get(HConstants.STATUS_MULTICAST_ADDRESS,
          HConstants.DEFAULT_STATUS_MULTICAST_ADDRESS);
      int port = conf.getInt(HConstants.STATUS_MULTICAST_PORT,
          HConstants.DEFAULT_STATUS_MULTICAST_PORT);
      channel = (DatagramChannel) b.bind(new InetSocketAddress(mcAddress, port));

      channel.getConfig().setReuseAddress(true);

      InetAddress ina;
      try {
View Full Code Here


          HConstants.DEFAULT_STATUS_MULTICAST_PORT);

      // Can't be NiO with Netty today => not implemented in Netty.
      DatagramChannelFactory f = new OioDatagramChannelFactory(service);

      ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
      b.setPipeline(Channels.pipeline(new ProtobufEncoder(),
          new ChannelUpstreamHandler() {
            @Override
            public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)
                throws Exception {
              // We're just writing here. Discard any incoming data. See HBASE-8466.
            }
          }));


      channel = (DatagramChannel) b.bind(new InetSocketAddress(0));
      channel.getConfig().setReuseAddress(true);

      InetAddress ina;
      try {
        ina = InetAddress.getByName(mcAddress);
View Full Code Here

        if (configuration.getWorkerCount() <= 0) {
            datagramChannelFactory = new NioDatagramChannelFactory(workerExecutor);
        } else {
            datagramChannelFactory = new NioDatagramChannelFactory(workerExecutor, configuration.getWorkerCount());
        }
        connectionlessServerBootstrap = new ConnectionlessBootstrap(datagramChannelFactory);
        connectionlessServerBootstrap.setOption("child.keepAlive", configuration.isKeepAlive());
        connectionlessServerBootstrap.setOption("child.tcpNoDelay", configuration.isTcpNoDelay());
        connectionlessServerBootstrap.setOption("reuseAddress", configuration.isReuseAddress());
        connectionlessServerBootstrap.setOption("child.reuseAddress", configuration.isReuseAddress());
        connectionlessServerBootstrap.setOption("child.connectTimeoutMillis", configuration.getConnectTimeout());
View Full Code Here

            // set the pipeline on the bootstrap
            clientBootstrap.setPipeline(clientPipeline);
            answer = clientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));
            return answer;
        } else {
            ConnectionlessBootstrap connectionlessClientBootstrap = new ConnectionlessBootstrap(datagramChannelFactory);
            connectionlessClientBootstrap.setOption("child.keepAlive", configuration.isKeepAlive());
            connectionlessClientBootstrap.setOption("child.tcpNoDelay", configuration.isTcpNoDelay());
            connectionlessClientBootstrap.setOption("child.reuseAddress", configuration.isReuseAddress());
            connectionlessClientBootstrap.setOption("child.connectTimeoutMillis", configuration.getConnectTimeout());
            connectionlessClientBootstrap.setOption("child.broadcast", configuration.isBroadcast());
            connectionlessClientBootstrap.setOption("sendBufferSize", configuration.getSendBufferSize());
            connectionlessClientBootstrap.setOption("receiveBufferSize", configuration.getReceiveBufferSize());

            // set the pipeline on the bootstrap
            connectionlessClientBootstrap.setPipeline(clientPipeline);
            connectionlessClientBootstrap.bind(new InetSocketAddress(0));
            answer = connectionlessClientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));
            return answer;
        }
    }
View Full Code Here

    private void initializeUDPServerSocketCommunicationLayer() throws Exception {
        ExecutorService workerExecutor = context.getExecutorServiceManager().newThreadPool(this, "NettyUDPWorker",
                configuration.getCorePoolSize(), configuration.getMaxPoolSize());

        datagramChannelFactory = new NioDatagramChannelFactory(workerExecutor);
        connectionlessServerBootstrap = new ConnectionlessBootstrap(datagramChannelFactory);
        if (configuration.getServerPipelineFactory() != null) {
            configuration.getServerPipelineFactory().setConsumer(this);
            connectionlessServerBootstrap.setPipelineFactory(configuration.getServerPipelineFactory());
        } else {
            connectionlessServerBootstrap.setPipelineFactory(new DefaultServerPipelineFactory(this));
View Full Code Here

  }

  @Override
  public void start() {
    // setup Netty server
    ConnectionlessBootstrap serverBootstrap = new ConnectionlessBootstrap
        (new OioDatagramChannelFactory(Executors.newCachedThreadPool()));
    serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
      public ChannelPipeline getPipeline() {
       return Channels.pipeline(new syslogHandler());
      }
     });

    if (host == null) {
      nettyChannel = serverBootstrap.bind(new InetSocketAddress(port));
    } else {
      nettyChannel = serverBootstrap.bind(new InetSocketAddress(host, port));
    }

    super.start();
  }
View Full Code Here

  public void run() {
    // Configure the client.
    DatagramChannelFactory f = new NioDatagramChannelFactory(
        Executors.newCachedThreadPool(), workerCount);

    ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
    ChannelPipeline p = b.getPipeline();
    p.addLast("handler", new SimpleUdpServerHandler(rpcProgram));

    b.setOption("broadcast", "false");
    b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
    b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);
   
    // Listen to the UDP port
    b.bind(new InetSocketAddress(port));

    LOG.info("Started listening to UDP requests at port " + port + " for "
        + rpcProgram + " with workerCount " + workerCount);
  }
View Full Code Here

          HConstants.DEFAULT_STATUS_MULTICAST_PORT);

      // Can't be NiO with Netty today => not implemented in Netty.
      DatagramChannelFactory f = new OioDatagramChannelFactory(service);

      ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
      b.setPipeline(Channels.pipeline(new ProtobufEncoder()));


      channel = (DatagramChannel) b.bind(new InetSocketAddress(0));
      channel.getConfig().setReuseAddress(true);

      InetAddress ina;
      try {
        ina = InetAddress.getByName(mcAddress);
View Full Code Here

    public void connect(Configuration conf) throws IOException {
      // Can't be NiO with Netty today => not implemented in Netty.
      DatagramChannelFactory f = new OioDatagramChannelFactory(service);

      ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
      b.setPipeline(Channels.pipeline(
          new ProtobufDecoder(ClusterStatusProtos.ClusterStatus.getDefaultInstance()),
          new ClusterStatusHandler()));

      String mcAddress = conf.get(HConstants.STATUS_MULTICAST_ADDRESS,
          HConstants.DEFAULT_STATUS_MULTICAST_ADDRESS);
      int port = conf.getInt(HConstants.STATUS_MULTICAST_PORT,
          HConstants.DEFAULT_STATUS_MULTICAST_PORT);
      channel = (DatagramChannel) b.bind(new InetSocketAddress(mcAddress, port));

      channel.getConfig().setReuseAddress(true);

      InetAddress ina;
      try {
View Full Code Here

    runner = executor;

    final DatagramChannelFactory channelFactory = new NioDatagramChannelFactory(
        runner);

    boot = new ConnectionlessBootstrap(channelFactory);

    final ChannelPipelineFactory pipelineFactory = new PipelineFactoryDDF(
        this);

    boot.setPipelineFactory(pipelineFactory);
View Full Code Here

TOP

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

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.