Package org.jboss.netty.handler.execution

Examples of org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor


        this.protocol = protocol;
        this.secure = secure;
    }
   
    protected ExecutionHandler createExecutionHandler(int size) {
        return new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(size, 0, 0));
    }
View Full Code Here


        // replies in the expected order. eg this is required by TCP.
        // and use a Camel thread factory so we have consistent thread namings
        // we should use a shared thread pool as recommended by Netty
        String pattern = getCamelContext().getExecutorServiceManager().getThreadNamePattern();
        ThreadFactory factory = new CamelThreadFactory(pattern, "NettyOrderedWorker", true);
        return new OrderedMemoryAwareThreadPoolExecutor(configuration.getMaximumPoolSize(),
                0L, 0L, 30, TimeUnit.SECONDS, factory);
    }
View Full Code Here

  public void setup() {
    serverBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
        Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));

    serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
      Executor executor = new OrderedMemoryAwareThreadPoolExecutor(
          Runtime.getRuntime().availableProcessors(),
          1024 * 1024,
          128 * 1024 * 1024
      );

View Full Code Here

  public void setup() {
    serverBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
        Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));

    serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
      Executor executor = new OrderedMemoryAwareThreadPoolExecutor(
          Runtime.getRuntime().availableProcessors(),
          1024 * 1024,
          128 * 1024 * 1024
      );

View Full Code Here

        // replies in the expected order. eg this is required by TCP.
        // and use a Camel thread factory so we have consistent thread namings
        // we should use a shared thread pool as recommended by Netty
        String pattern = getCamelContext().getExecutorServiceManager().getThreadNamePattern();
        ThreadFactory factory = new CamelThreadFactory(pattern, "NettyOrderedWorker", true);
        return new OrderedMemoryAwareThreadPoolExecutor(configuration.getMaximumPoolSize(),
                0L, 0L, 30, TimeUnit.SECONDS, factory);
    }
View Full Code Here

      if (AppContext.scWorkerThreadPool == null) {
        AppContext.scWorkerThreadPool = Executors.newCachedThreadPool(new NamedPriorityThreadFactory("SC_WORKER"));
      }

      if (AppContext.orderedSCWorkerThreadPool == null) {
        AppContext.orderedSCWorkerThreadPool = new OrderedMemoryAwareThreadPoolExecutor(
            Constants.DEFAULT_MAX_ORDERED_IO_THREADS, 0, 0, 10, TimeUnit.SECONDS, new NamedPriorityThreadFactory(
                "ORDERED_SC_WORKER"));
      }
    }
  }
View Full Code Here

    }

    public void run() {
        LocalAddress socketAddress = new LocalAddress(port);

        OrderedMemoryAwareThreadPoolExecutor eventExecutor =
            new OrderedMemoryAwareThreadPoolExecutor(
                    5, 1000000, 10000000, 100,
                    TimeUnit.MILLISECONDS);

        ServerBootstrap sb = new ServerBootstrap(
                new DefaultLocalServerChannelFactory());

        sb.setPipelineFactory(new LocalServerPipelineFactory(eventExecutor));
        sb.bind(socketAddress);

        ClientBootstrap cb = new ClientBootstrap(
                new DefaultLocalClientChannelFactory());

        cb.setPipelineFactory(new ChannelPipelineFactory() {
            public ChannelPipeline getPipeline() throws Exception {
                return Channels.pipeline(
                        new StringDecoder(),
                        new StringEncoder(),
                        new LoggingHandler(InternalLogLevel.INFO));
            }
        });

        // Read commands from array
        String[] commands = { "First", "Second", "Third", "quit" };
        for (int j = 0; j < 5 ; j++) {
            System.err.println("Start " + j);
            ChannelFuture channelFuture = cb.connect(socketAddress);
            channelFuture.awaitUninterruptibly();
            if (! channelFuture.isSuccess()) {
                System.err.println("CANNOT CONNECT");
                channelFuture.getCause().printStackTrace();
                break;
            }
            ChannelFuture lastWriteFuture = null;
            for (String line: commands) {
                // Sends the received line to the server.
                lastWriteFuture = channelFuture.getChannel().write(line);
            }

            // Wait until all messages are flushed before closing the channel.
            if (lastWriteFuture != null) {
                lastWriteFuture.awaitUninterruptibly();
            }
            channelFuture.getChannel().close();
            // Wait until the connection is closed or the connection attempt fails.
            channelFuture.getChannel().getCloseFuture().awaitUninterruptibly();
            System.err.println("End " + j);
        }

        // Release all resources
        cb.releaseExternalResources();
        sb.releaseExternalResources();
        eventExecutor.shutdownNow();
    }
View Full Code Here

        sb.getPipeline().addLast("handler", sh);
        cb.getPipeline().addFirst("ssl", new SslHandler(cse));
        cb.getPipeline().addLast("handler", ch);
        ExecutorService eventExecutor = null;
        if (isExecutorRequired()) {
            eventExecutor = new OrderedMemoryAwareThreadPoolExecutor(16, 0, 0);
            sb.getPipeline().addFirst("executor", new ExecutionHandler(eventExecutor));
            cb.getPipeline().addFirst("executor", new ExecutionHandler(eventExecutor));
        }

        Channel sc = sb.bind(new InetSocketAddress(0));
View Full Code Here

        this.protocol = protocol;
        this.secure = secure;
    }
   
    protected ExecutionHandler createExecutionHandler(int size) {
        return new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(size, 0, 0));
    }
View Full Code Here

        bootstrap = new ServerBootstrap(factory);
        // Create the global ChannelGroup
        channelGroup = new DefaultChannelGroup(MessagingServer.class.getName());
        // 200 threads max, Memory limitation: 1MB by channel, 1GB global, 100 ms of timeout
        OrderedMemoryAwareThreadPoolExecutor pipelineExecutor = new OrderedMemoryAwareThreadPoolExecutor(
                200, 1048576, 1073741824, 100, TimeUnit.MILLISECONDS, Executors
                        .defaultThreadFactory());
        // We need to use a pipeline factory because we are using stateful handlers
        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
View Full Code Here

TOP

Related Classes of org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor

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.