accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [1/4] accumulo git commit: ACCUMULO-3745 Always obtain locks in same order in SourceSwitching iter
Date Wed, 22 Apr 2015 22:34:24 GMT
Repository: accumulo
Updated Branches:
  refs/heads/master 9abf6a318 -> 58cfee84d


ACCUMULO-3745 Always obtain locks in same order in SourceSwitching iter

[~ecn] and I sat together and fixed this.  We are not sure how to test.  We
both visually analyzed all locking to ensure it was done in the same order.


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

Branch: refs/heads/master
Commit: 95e234c7e468d61211d6f1d65ee1955d2bf53a9b
Parents: fca7cb4
Author: Keith Turner <kturner@apache.org>
Authored: Wed Apr 22 15:05:06 2015 -0400
Committer: Keith Turner <kturner@apache.org>
Committed: Wed Apr 22 15:05:06 2015 -0400

----------------------------------------------------------------------
 .../system/SourceSwitchingIterator.java         | 29 +++++++++++++-------
 1 file changed, 19 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/95e234c7/core/src/main/java/org/apache/accumulo/core/iterators/system/SourceSwitchingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/SourceSwitchingIterator.java
b/core/src/main/java/org/apache/accumulo/core/iterators/system/SourceSwitchingIterator.java
index 6c40176..7684352 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/SourceSwitchingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/SourceSwitchingIterator.java
@@ -69,11 +69,11 @@ public class SourceSwitchingIterator implements SortedKeyValueIterator<Key,Value
     this.source = source;
     this.onlySwitchAfterRow = onlySwitchAfterRow;
     this.copies = copies;
-    copies.add(this);
   }
 
   public SourceSwitchingIterator(DataSource source, boolean onlySwitchAfterRow) {
     this(source, onlySwitchAfterRow, Collections.synchronizedList(new ArrayList<SourceSwitchingIterator>()));
+    copies.add(this);
   }
 
   public SourceSwitchingIterator(DataSource source) {
@@ -81,8 +81,14 @@ public class SourceSwitchingIterator implements SortedKeyValueIterator<Key,Value
   }
 
   @Override
-  public synchronized SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment
env) {
-    return new SourceSwitchingIterator(source.getDeepCopyDataSource(env), onlySwitchAfterRow,
copies);
+  public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
+    synchronized (copies) {
+      synchronized(this){
+        SourceSwitchingIterator ssi = new SourceSwitchingIterator(source.getDeepCopyDataSource(env),
onlySwitchAfterRow, copies);
+        copies.add(ssi);
+        return ssi;
+      }
+    }
   }
 
   @Override
@@ -186,14 +192,17 @@ public class SourceSwitchingIterator implements SortedKeyValueIterator<Key,Value
   }
 
   @Override
-  public synchronized void setInterruptFlag(AtomicBoolean flag) {
-    if (copies.size() != 1)
-      throw new IllegalStateException("setInterruptFlag() called after deep copies made "
+ copies.size());
+  public void setInterruptFlag(AtomicBoolean flag) {
+    synchronized (copies) {
+      synchronized (this) {
+        if (copies.size() != 1)
+          throw new IllegalStateException("setInterruptFlag() called after deep copies made
" + copies.size());
 
-    if (iter != null)
-      ((InterruptibleIterator) iter).setInterruptFlag(flag);
+        if (iter != null)
+          ((InterruptibleIterator) iter).setInterruptFlag(flag);
 
-    source.setInterruptFlag(flag);
+        source.setInterruptFlag(flag);
+      }
+    }
   }
-
 }


Mime
View raw message