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

[1/3] git commit: ACCUMULO-2270 Make initialization of static threadpool thread-safe

Repository: accumulo
Updated Branches:
  refs/heads/1.5.2-SNAPSHOT f76b8e07a -> 18006d245
  refs/heads/1.6.0-SNAPSHOT d2da4315c -> 9231648ae
  refs/heads/master 7028f1e51 -> 7b0e4635b


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/1.5.2-SNAPSHOT
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>();


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

Posted by bh...@apache.org.
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/7b0e4635
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/7b0e4635
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/7b0e4635

Branch: refs/heads/master
Commit: 7b0e4635b82bc2efd6893de28a04bd574381c6fd
Parents: 7028f1e
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:47:40 2014 -0500

----------------------------------------------------------------------
 .../org/apache/accumulo/master/tableOps/BulkImport.java  | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/7b0e4635/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java
index 430f14d..bdc89dd 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java
@@ -484,19 +484,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();
     VolumeManager fs = master.getFileSystem();
     List<FileStatus> files = new ArrayList<FileStatus>();
@@ -533,7 +534,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>();


[2/3] git commit: ACCUMULO-2270 Make initialization of static threadpool thread-safe

Posted by bh...@apache.org.
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/9231648a
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/9231648a
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/9231648a

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 9231648ae1d7795456970f858b37f6bfc110e6ca
Parents: d2da431
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:45:49 2014 -0500

----------------------------------------------------------------------
 .../org/apache/accumulo/master/tableOps/BulkImport.java  | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/9231648a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java
index 430f14d..bdc89dd 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java
@@ -484,19 +484,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();
     VolumeManager fs = master.getFileSystem();
     List<FileStatus> files = new ArrayList<FileStatus>();
@@ -533,7 +534,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>();