Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.ChannelFactory


        }

        // *** 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


  public void setName(String name) {
    this.serviceName = name;
  }

  public void init(ChannelPipelineFactory pipeline, int workerNum) {
    ChannelFactory factory = RpcChannelFactory.createServerChannelFactory(serviceName, workerNum);

    DefaultChannelFuture.setUseDeadLockChecker(false);

    pipelineFactory = pipeline;
    bootstrap = new ServerBootstrap(factory);
View Full Code Here

    Executor workerThreads = Executors.newCachedThreadPool(new ThreadFactoryBuilder()
                                                             .setDaemon(true)
                                                             .setNameFormat("worker-thread#%d")
                                                             .build());

    ChannelFactory factory = new NioServerSocketChannelFactory(bossThreads, workerThreads);

    bootstrap = new ServerBootstrap(factory);

    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
      public ChannelPipeline getPipeline() {
View Full Code Here

        int clusterSize = this.topology.getPhysicalCluster().getNodes().size();
        partitionChannelMap = Maps.synchronizedBiMap(HashBiMap.<Integer, Channel> create(clusterSize));
        partitionNodeMap = HashBiMap.create(clusterSize);

        // Initialize netty related structures
        ChannelFactory factory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(),
                Executors.newCachedThreadPool());
        bootstrap = new ClientBootstrap(factory);
        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
            @Override
            public ChannelPipeline getPipeline() {
View Full Code Here

    public TCPListener(Assignment assignment, @Named("s4.comm.timeout") int timeout) {
        // wait for an assignment
        node = assignment.assignClusterNode();
        nettyTimeout = timeout;

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

        bootstrap = new ServerBootstrap(factory);

        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
View Full Code Here

public class TestNettyServerWithCompression extends TestNettyServer{


  protected static Server initializeServer(Responder responder) {
    ChannelFactory channelFactory = new NioServerSocketChannelFactory(
        Executors.newCachedThreadPool(),
        Executors.newCachedThreadPool()
    );
    return  new NettyServer(responder, new InetSocketAddress(0),
        channelFactory, new CompressionChannelPipelineFactory(),
View Full Code Here

public class TestNettyServerWithSSL extends TestNettyServer{
  public static final String TEST_CERTIFICATE = "servercert.p12";
  public static final String TEST_CERTIFICATE_PASSWORD = "s3cret";
 
  protected static Server initializeServer(Responder responder) {
    ChannelFactory channelFactory = new NioServerSocketChannelFactory(
        Executors.newCachedThreadPool(),
        Executors.newCachedThreadPool()
    );
    return new NettyServer(responder, new InetSocketAddress(0),
        channelFactory, new SSLChannelPipelineFactory(),
View Full Code Here

  public static void initializeConnections() throws Exception {
    // start server
    System.out.println("starting server...");
    mailService = new MailImpl();
    Responder responder = new SpecificResponder(Mail.class, mailService);
    ChannelFactory channelFactory = new NioServerSocketChannelFactory(
        Executors.newCachedThreadPool(),
        Executors.newCachedThreadPool()
    );
    server = new NettyServer(responder, new InetSocketAddress(0),
                             channelFactory, new SSLChannelPipelineFactory(),
View Full Code Here

    }

    @SuppressWarnings("unused")
    private static void runSyncClients(InetSocketAddress server, int nClients, int nSelectors)
            throws InterruptedException {
        ChannelFactory channelFactory = new NioClientSocketChannelFactory(
                Executors.newCachedThreadPool(),
                Executors.newCachedThreadPool(),
                nSelectors);
        allConnected = new CountDownLatch(nClients);
        startLatch = new CountDownLatch(1);
View Full Code Here

        }
    }

    private static void runAsyncClients(SocketAddress server, int nClients, int nSelectors)
            throws Exception {
        ChannelFactory channelFactory = new NioClientSocketChannelFactory(
                Executors.newCachedThreadPool(),
                Executors.newCachedThreadPool(),
                nSelectors);
        allConnected = new CountDownLatch(nClients);
        allFinished = new CountDownLatch(nClients);
View Full Code Here

TOP

Related Classes of org.jboss.netty.channel.ChannelFactory

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.