You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/03/07 21:53:55 UTC

[41/50] [abbrv] git commit: ACCUMULO-2270 Make initialization of static threadpool thread-safe

ACCUMULO-2270 Make initialization of static threadpool thread-safe

Signed-off-by: Bill Havanki <bh...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/18006d24
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/18006d24
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/18006d24

Branch: refs/heads/ACCUMULO-2061
Commit: 18006d245372640472ecc9f987a32cb989cb3be6
Parents: f76b8e0
Author: Vikram Srivastava <vi...@cloudera.com>
Authored: Tue Jan 28 23:29:10 2014 -0800
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Fri Mar 7 10:43:40 2014 -0500

----------------------------------------------------------------------
 .../apache/accumulo/server/master/tableOps/BulkImport.java  | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/18006d24/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java b/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java
index 5e85277..2281eea 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java
@@ -476,19 +476,20 @@ class LoadFiles extends MasterRepo {
       return 500;
     return 0;
   }
-  
-  synchronized void initializeThreadPool(Master master) {
+
+  private static synchronized ExecutorService getThreadPool(Master master) {
     if (threadPool == null) {
       int threadPoolSize = master.getSystemConfiguration().getCount(Property.MASTER_BULK_THREADPOOL_SIZE);
       ThreadPoolExecutor pool = new SimpleThreadPool(threadPoolSize, "bulk import");
       pool.allowCoreThreadTimeOut(true);
       threadPool = new TraceExecutorService(pool);
     }
+    return threadPool;
   }
 
   @Override
   public Repo<Master> call(final long tid, final Master master) throws Exception {
-    initializeThreadPool(master);
+    ExecutorService executor = getThreadPool(master);
     final SiteConfiguration conf = ServerConfiguration.getSiteConfiguration();
     FileSystem fs = master.getFileSystem();
     List<FileStatus> files = new ArrayList<FileStatus>();
@@ -525,7 +526,7 @@ class LoadFiles extends MasterRepo {
       // Use the threadpool to assign files one-at-a-time to the server
       final List<String> loaded = Collections.synchronizedList(new ArrayList<String>());
       for (final String file : filesToLoad) {
-        results.add(threadPool.submit(new Callable<List<String>>() {
+        results.add(executor.submit(new Callable<List<String>>() {
           @Override
           public List<String> call() {
             List<String> failures = new ArrayList<String>();