hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r730325 - /hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java
Date Wed, 31 Dec 2008 06:26:43 GMT
Author: stack
Date: Tue Dec 30 22:26:42 2008
New Revision: 730325

URL: http://svn.apache.org/viewvc?rev=730325&view=rev
Log:
HBASE-1076 CME in HStore.notifyChangedReadersObservers; Trying copy-on-write Set from concurrent
utils.

Modified:
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java?rev=730325&r1=730324&r2=730325&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java Tue Dec 30
22:26:42 2008
@@ -33,6 +33,7 @@
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
+import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -124,8 +125,8 @@
   private final int compactionThreshold;
   
   // All access must be synchronized.
-  private final Set<ChangedReadersObserver> changedReaderObservers =
-    new HashSet<ChangedReadersObserver>();
+  private final CopyOnWriteArraySet<ChangedReadersObserver> changedReaderObservers
=
+    new CopyOnWriteArraySet<ChangedReadersObserver>();
 
   /**
    * An HStore is a set of zero or more MapFiles, which stretch backwards over 
@@ -725,36 +726,30 @@
       this.lock.writeLock().unlock();
     }
   }
-  
+
   /*
    * Notify all observers that set of Readers has changed.
    * @throws IOException
    */
   private void notifyChangedReadersObservers() throws IOException {
-    synchronized (this.changedReaderObservers) {
-      for (ChangedReadersObserver o: this.changedReaderObservers) {
-        o.updateReaders();
-      }
+    for (ChangedReadersObserver o: this.changedReaderObservers) {
+      o.updateReaders();
     }
   }
-  
+
   /*
    * @param o Observer who wants to know about changes in set of Readers
    */
   void addChangedReaderObserver(ChangedReadersObserver o) {
-    synchronized(this.changedReaderObservers) {
-      this.changedReaderObservers.add(o);
-    }
+    this.changedReaderObservers.add(o);
   }
   
   /*
    * @param o Observer no longer interested in changes in set of Readers.
    */
   void deleteChangedReaderObserver(ChangedReadersObserver o) {
-    synchronized (this.changedReaderObservers) {
-      if (!this.changedReaderObservers.remove(o)) {
-        LOG.warn("Not in set" + o);
-      }
+    if (!this.changedReaderObservers.remove(o)) {
+      LOG.warn("Not in set" + o);
     }
   }
 



Mime
View raw message