Repository: hbase
Updated Branches:
  refs/heads/0.98 19fa2e346 -> ed1a7896e


HBASE-11302 ReplicationSourceManager#sources is not thread safe (Qianxi Zhang)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3a52381a
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3a52381a
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3a52381a

Branch: refs/heads/0.98
Commit: 3a52381a2a98bbb7b66e1734d542b611fb603f92
Parents: 19fa2e3
Author: Ted Yu <te...@apache.org>
Authored: Fri Jun 6 16:57:57 2014 +0000
Committer: Enis Soztutar <e...@apache.org>
Committed: Mon Jul 14 16:54:35 2014 -0700

----------------------------------------------------------------------
 .../replication/regionserver/ReplicationSourceManager.java    | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/3a52381a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
index b9ac55b..30640ba 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -114,13 +115,15 @@ public class ReplicationSourceManager implements 
ReplicationListener {
       final ReplicationPeers replicationPeers, final ReplicationTracker 
replicationTracker,
       final Configuration conf, final Stoppable stopper, final FileSystem fs, 
final Path logDir,
       final Path oldLogDir, final UUID clusterId) {
-    this.sources = new ArrayList<ReplicationSourceInterface>();
+    //CopyOnWriteArrayList is thread-safe.
+    //Generally, reading is more than modifying. 
+    this.sources = new CopyOnWriteArrayList<ReplicationSourceInterface>();
     this.replicationQueues = replicationQueues;
     this.replicationPeers = replicationPeers;
     this.replicationTracker = replicationTracker;
     this.stopper = stopper;
     this.hlogsById = new HashMap<String, SortedSet<String>>();
-    this.oldsources = new ArrayList<ReplicationSourceInterface>();
+    this.oldsources = new CopyOnWriteArrayList<ReplicationSourceInterface>();
     this.conf = conf;
     this.fs = fs;
     this.logDir = logDir;

Reply via email to