Package org.jboss.netty.channel.socket.nio

Examples of org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory


    }

    public void initcassandradb() {
  ClientBootstrap client = new ClientBootstrap(
                 new NioClientSocketChannelFactory(
                           Executors.newCachedThreadPool(),
                           Executors.newCachedThreadPool()));

  client.setPipelineFactory(new ClientPipelineFactory());
View Full Code Here


   }

   private void init() {
      // Configure the client.
      ClientBootstrap bootstrap = new ClientBootstrap(
            new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));

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

      // Start the connection attempt.
View Full Code Here

        //each context will have a single client channel factory
        int maxWorkers = Utils.getInt(storm_conf.get(Config.STORM_MESSAGING_NETTY_CLIENT_WORKER_THREADS));
    ThreadFactory bossFactory = new NettyRenameThreadFactory("client" + "-boss");
        ThreadFactory workerFactory = new NettyRenameThreadFactory("client" + "-worker");
        if (maxWorkers > 0) {
            clientChannelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(bossFactory),
                    Executors.newCachedThreadPool(workerFactory), maxWorkers);
        } else {
            clientChannelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(bossFactory),
                    Executors.newCachedThreadPool(workerFactory));
        }
       
        int otherWorkers = Utils.getInt(storm_conf.get(Config.TOPOLOGY_WORKERS), 1) - 1;
        int poolSize = Math.min(Math.max(1, otherWorkers), MAX_CLIENT_SCHEDULER_THREAD_POOL_SIZE);
View Full Code Here

    logger.info("Callback pool created");
    if(!isTimeoutTest) {
      client = new HBaseClient(zkQuorum, zkBaseDir, sinkCallbackPool);
    } else {
      client = new HBaseClient(zkQuorum, zkBaseDir,
        new NioClientSocketChannelFactory(Executors
          .newSingleThreadExecutor(),
          Executors.newSingleThreadExecutor()));
    }
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicBoolean fail = new AtomicBoolean(false);
View Full Code Here

   @Override
   public void start(CoprocessorEnvironment e) throws IOException {
      System.out.println("Starting compacter");
      Configuration conf = e.getConfiguration();
      factory = new NioClientSocketChannelFactory(bossExecutor, workerExecutor, 3);
      bootstrap = new ClientBootstrap(factory);

      bootstrap.getPipeline().addLast("decoder", new ObjectDecoder());
      bootstrap.getPipeline().addLast("handler", new Handler());
      bootstrap.setOption("tcpNoDelay", false);
View Full Code Here

      channel = null;
     
      System.out.println("Starting TSOClient");

      // Start client with Nb of active threads = 3 as maximum.
      factory = new NioClientSocketChannelFactory(Executors
                                                  .newCachedThreadPool(), Executors.newCachedThreadPool(), 3);
      // Create the bootstrap
      bootstrap = new ClientBootstrap(factory);
     
      int executorThreads = conf.getInt("tso.executor.threads", 3);
View Full Code Here

        }

        // *** Start the Netty configuration ***

        // Start client with Nb of active threads = 3 as maximum.
        ChannelFactory factory = new NioClientSocketChannelFactory(Executors
                .newCachedThreadPool(), Executors.newCachedThreadPool(), 30);

        // Create the global ChannelGroup
        ChannelGroup channelGroup = new DefaultChannelGroup(
                TransactionClient.class.getName());
       
        List<ClientHandler> handlers = new ArrayList<ClientHandler>();

        Configuration conf = HBaseConfiguration.create();
        conf.set("tso.host", host);
        conf.setInt("tso.port", port);
        conf.setInt("tso.executor.threads", 10);

        for(int i = 0; i < runs; ++i) {
         // Create the associated Handler
           ClientHandler handler = new ClientHandler(conf, nbMessage, inflight, pauseClient, percentRead);
  
           // *** Start the Netty running ***
  
           System.out.println("PARAM MAX_ROW: " + ClientHandler.MAX_ROW);
           System.out.println("PARAM DB_SIZE: " + ClientHandler.DB_SIZE);
           System.out.println("pause " + pauseClient);
           System.out.println("readPercent " + percentRead);
  
           handlers.add(handler);
          
           if ((i - 1) % 20 == 0) Thread.sleep(1000);
        }
       
        // Wait for the Traffic to finish
        for (ClientHandler handler : handlers) {
           boolean result = handler.waitForAll();
           System.out.println("Result: " + result);
        }

        // *** Start the Netty shutdown ***

        // Now close all channels
        System.out.println("close channelGroup");
        channelGroup.close().awaitUninterruptibly();
        // Now release resources
        System.out.println("close external resources");
        factory.releaseExternalResources();
    }
View Full Code Here

    protected void establishConnection() throws IOException
    {
        // Configure the client.
        bootstrap = new ClientBootstrap(
                        new NioClientSocketChannelFactory(
                            Executors.newCachedThreadPool(),
                            Executors.newCachedThreadPool()));

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

   * @throws FlumeException
   */
  private void connect(long timeout, TimeUnit tu) throws FlumeException {
    callTimeoutPool = Executors.newCachedThreadPool(
        new TransceiverThreadFactory("Flume Avro RPC Client Call Invoker"));
    NioClientSocketChannelFactory socketChannelFactory = null;

    try {

      ExecutorService bossExecutor =
        Executors.newCachedThreadPool(new TransceiverThreadFactory(
          "Avro " + NettyTransceiver.class.getSimpleName() + " Boss"));
      ExecutorService workerExecutor =
        Executors.newCachedThreadPool(new TransceiverThreadFactory(
          "Avro " + NettyTransceiver.class.getSimpleName() + " I/O Worker"));

      if (enableDeflateCompression || enableSsl) {
        if (maxIoWorkers >= 1) {
          socketChannelFactory = new SSLCompressionChannelFactory(
            bossExecutor, workerExecutor,
            enableDeflateCompression, enableSsl, trustAllCerts,
            compressionLevel, truststore, truststorePassword, truststoreType,
            maxIoWorkers);
        } else {
          socketChannelFactory = new SSLCompressionChannelFactory(
            bossExecutor, workerExecutor,
            enableDeflateCompression, enableSsl, trustAllCerts,
            compressionLevel, truststore, truststorePassword, truststoreType);
        }
      } else {
        if (maxIoWorkers >= 1) {
          socketChannelFactory = new NioClientSocketChannelFactory(
              bossExecutor, workerExecutor, maxIoWorkers);
        } else {
          socketChannelFactory = new NioClientSocketChannelFactory(
              bossExecutor, workerExecutor);
        }
      }

      transceiver = new NettyTransceiver(this.address,
          socketChannelFactory,
          tu.toMillis(timeout));
      avroClient =
          SpecificRequestor.getClient(AvroSourceProtocol.Callback.class,
          transceiver);
    } catch (Throwable t) {
      if (callTimeoutPool != null) {
        callTimeoutPool.shutdownNow();
      }
      if (socketChannelFactory != null) {
        socketChannelFactory.releaseExternalResources();
      }
      if (t instanceof IOException) {
        throw new FlumeException(this + ": RPC connection error", t);
      } else if (t instanceof FlumeException) {
        throw (FlumeException) t;
View Full Code Here

                        .withWorkerCount(configuration.getWorkerCount())
                        .withName("NettyClientTCPWorker")
                        .build();
                wp = workerPool;
            }
            channelFactory = new NioClientSocketChannelFactory(bp, wp);
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory

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.