Examples of ThreadFactory


Examples of java.util.concurrent.ThreadFactory

     */
    //TODO Implement an integration test to test for jvm exit as part of the standalone example
    // (so we don't have to change the unit test execution model for the core module)
    public void enableSessionValidation() {
        if (this.interval > 0l) {
            this.service = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
                public Thread newThread(Runnable r) {
                    Thread thread = new Thread(r);
                    thread.setDaemon(true);
                    return thread;
                }
View Full Code Here

Examples of java.util.concurrent.ThreadFactory

      // If OIO each connection will have it's own thread
      // If NIO these are capped at nio-remoting-threads which defaults to num cores * 3
      // This needs to be a different thread pool to the main thread pool especially for OIO where we may need
      // to support many hundreds of connections, but the main thread pool must be kept small for better performance

      ThreadFactory tFactory = new HornetQThreadFactory("HornetQ-remoting-threads-" + server.toString() +
                                                           "-" +
                                                           System.identityHashCode(this), false, tccl);

      threadPool = Executors.newCachedThreadPool(tFactory);

View Full Code Here

Examples of java.util.concurrent.ThreadFactory

        cachedNotifications = new ConcurrentLinkedQueue<ApnsNotification>();
        notificationsBuffer = new ConcurrentLinkedQueue<ApnsNotification>();
    }

    private ThreadFactory defaultThreadFactory() {
        return new ThreadFactory() {
            ThreadFactory wrapped = Executors.defaultThreadFactory();
            @Override
            public Thread newThread( Runnable r )
            {
                Thread result = wrapped.newThread(r);
View Full Code Here

Examples of java.util.concurrent.ThreadFactory

       
        // Configure the server.
        int buffer_size = Utils.getInt(storm_conf.get(Config.STORM_MESSAGING_NETTY_BUFFER_SIZE));
        int maxWorkers = Utils.getInt(storm_conf.get(Config.STORM_MESSAGING_NETTY_SERVER_WORKER_THREADS));

        ThreadFactory bossFactory = new NettyRenameThreadFactory(name() + "-boss");
        ThreadFactory workerFactory = new NettyRenameThreadFactory(name() + "-worker");
       
        if (maxWorkers > 0) {
            factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(bossFactory),
                Executors.newCachedThreadPool(workerFactory), maxWorkers);
        } else {
View Full Code Here

Examples of java.util.concurrent.ThreadFactory

        this.storm_conf = storm_conf;
        connections = new Vector<IConnection>();

        //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),
View Full Code Here

Examples of java.util.concurrent.ThreadFactory

   *
   * @param volumes The roots of the file system volumes.
   */
  public AsyncDiskService(String[] volumes) throws IOException {
   
    threadFactory = new ThreadFactory() {
      public Thread newThread(Runnable r) {
        return new Thread(threadGroup, r);
      }
    };
   
View Full Code Here

Examples of java.util.concurrent.ThreadFactory

 
  // background executor
  private ExecutorService backgroundExecutor;
 
  public CassandraService() {
    backgroundExecutor = Executors.newCachedThreadPool(new ThreadFactory() {
      private AtomicInteger idCounter = new AtomicInteger();
      @Override
      public Thread newThread(Runnable r) {
        Thread thread = new Thread(r);
        thread.setName("CassandraWebConsoleExecutor-" + idCounter.incrementAndGet());
View Full Code Here

Examples of java.util.concurrent.ThreadFactory

            throw new IllegalArgumentException("defaultResurce must be > 0"); //$NON-NLS-1$
        }
        if (threadConfig == null) {
            throw new IllegalArgumentException("threadConfig must not be null"); //$NON-NLS-1$
        }
        this.defaultExecutor = Executors.newFixedThreadPool(defaultResuorce, new ThreadFactory() {
            private final AtomicInteger count = new AtomicInteger();
            @Override
            public Thread newThread(Runnable r) {
                Thread thread = new Thread(r);
                thread.setName(MessageFormat.format(
                        "ParallelJobScheduler-{0}",
                        String.valueOf(count.incrementAndGet())));
                return thread;
            }
        });
        HashMap<String, ExecutorService> map = new HashMap<String, ExecutorService>();
        for (Map.Entry<String, Integer> entry : threadConfig.entrySet()) {
            final String name = entry.getKey();
            Integer value = entry.getValue();
            if (value == null || value < 0) {
                throw new IllegalArgumentException(MessageFormat.format(
                        "thread config must be > 0: key={0}, value={1}",
                        name,
                        value));
            }
            map.put(name, Executors.newFixedThreadPool(value, new ThreadFactory() {
                private final AtomicInteger count = new AtomicInteger();
                @Override
                public Thread newThread(Runnable r) {
                    Thread thread = new Thread(r);
                    thread.setName(MessageFormat.format(
View Full Code Here

Examples of java.util.concurrent.ThreadFactory

        }
    }

    private ExecutorService createJobflowExecutor(final String batchId) {
        assert batchId != null;
        ThreadFactory threadFactory = new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                Thread thread = new Thread(r);
                thread.setName(MessageFormat.format(
                        "JobflowExecutor-{0}",
View Full Code Here

Examples of java.util.concurrent.ThreadFactory

      this.sharedState = state;
   }

   public void start() {
      this.flushThread = new FlushThread();
      this.scheduledExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
         @Override
         public Thread newThread(Runnable r) {
            Thread t = new Thread(Thread.currentThread().getThreadGroup(), r);
            t.setDaemon(true);
            t.setName("Flush Thread");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.