hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject git commit: HBASE-11302 ReplicationSourceManager#sources is not thread safe (Qianxi Zhang)
Date Fri, 06 Jun 2014 16:58:12 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 623cfa33d -> b5e660fff


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/b5e660ff
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b5e660ff
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b5e660ff

Branch: refs/heads/master
Commit: b5e660fff4afcefcde0ec635d7830b4f00d65627
Parents: 623cfa3
Author: Ted Yu <tedyu@apache.org>
Authored: Fri Jun 6 16:57:57 2014 +0000
Committer: Ted Yu <tedyu@apache.org>
Committed: Fri Jun 6 16:57:57 2014 +0000

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


http://git-wip-us.apache.org/repos/asf/hbase/blob/b5e660ff/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 9826489..7b4cd83 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;
@@ -113,13 +114,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;


Mime
View raw message