Package java.util.concurrent

Examples of java.util.concurrent.ThreadPoolExecutor.submit()


    NamingThreadFactory f  = new NamingThreadFactory(
            "SplitWriter-%1$d", Executors.defaultThreadFactory());
    ThreadPoolExecutor threadPool = (ThreadPoolExecutor)Executors.newFixedThreadPool(logWriterThreads, f);
    for (final byte[] region : splitLogsMap.keySet()) {
      Callable splitter = createNewSplitter(rootDir, logWriters, splitLogsMap, region, fs, conf);
      writeFutureResult.put(region, threadPool.submit(splitter));
    }

    threadPool.shutdown();
    // Wait for all threads to terminate
    try {
View Full Code Here


          } catch (InterruptedException ie) { }
        }
      });
    }
    // First, add two threads and make sure the pool size follows
    pool.submit(threads.get(0));
    assertEquals(1, pool.getPoolSize());
    pool.submit(threads.get(1));
    assertEquals(2, pool.getPoolSize());

    // Next, terminate those threads and then make sure the pool is still the
View Full Code Here

      });
    }
    // First, add two threads and make sure the pool size follows
    pool.submit(threads.get(0));
    assertEquals(1, pool.getPoolSize());
    pool.submit(threads.get(1));
    assertEquals(2, pool.getPoolSize());

    // Next, terminate those threads and then make sure the pool is still the
    // same size
    queue.put(new Object());
View Full Code Here

    threads.get(1).join();
    assertEquals(2, pool.getPoolSize());

    // Now let's simulate adding a RS meaning that we'll go up to three
    // concurrent threads. The pool should not grow larger than three.
    pool.submit(threads.get(2));
    pool.submit(threads.get(3));
    pool.submit(threads.get(4));
    assertEquals(3, pool.getPoolSize());
    queue.put(new Object());
    queue.put(new Object());
View Full Code Here

    assertEquals(2, pool.getPoolSize());

    // Now let's simulate adding a RS meaning that we'll go up to three
    // concurrent threads. The pool should not grow larger than three.
    pool.submit(threads.get(2));
    pool.submit(threads.get(3));
    pool.submit(threads.get(4));
    assertEquals(3, pool.getPoolSize());
    queue.put(new Object());
    queue.put(new Object());
    queue.put(new Object());
View Full Code Here

    // Now let's simulate adding a RS meaning that we'll go up to three
    // concurrent threads. The pool should not grow larger than three.
    pool.submit(threads.get(2));
    pool.submit(threads.get(3));
    pool.submit(threads.get(4));
    assertEquals(3, pool.getPoolSize());
    queue.put(new Object());
    queue.put(new Object());
    queue.put(new Object());
  }
View Full Code Here

            }
        };
       
        // send two tasks through the stage: one to follow existing tasks and a second to follow tasks created by
        // those existing tasks: tasks won't recursively create more tasks
        stage.submit(noop).get(5000, TimeUnit.MILLISECONDS);
        stage.submit(noop).get(5000, TimeUnit.MILLISECONDS);
    }
}
View Full Code Here

        };
       
        // send two tasks through the stage: one to follow existing tasks and a second to follow tasks created by
        // those existing tasks: tasks won't recursively create more tasks
        stage.submit(noop).get(5000, TimeUnit.MILLISECONDS);
        stage.submit(noop).get(5000, TimeUnit.MILLISECONDS);
    }
}
View Full Code Here

     // Split each store file.
    for (StoreFile sf: hstoreFilesToSplit) {
      //splitStoreFile(sf, splitdir);
      StoreFileSplitter sfs = new StoreFileSplitter(sf, splitdir);
      futures.add(threadPool.submit(sfs));
    }
    // Shutdown the pool
    threadPool.shutdown();

    // Wait for all the tasks to finish
View Full Code Here

                ThreadPoolExecutor timerThreadPool = m_sender.getTimerThreadPool();
                if (timerThreadPool == null) {
                    throw new InterruptedException();
                }

                Future<CommandResponse> futureTask = timerThreadPool.submit((Callable<CommandResponse>) this);
                try {
                    response = futureTask.get(m_timeout, TimeUnit.MILLISECONDS);
                } catch (ExecutionException ee) {
                    throw ee.getCause();
                } catch (TimeoutException te) {
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.