asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject [2/2] asterixdb git commit: Merge commit '19a2b58c32d56060a8167a2ad69bb942083ba4c1' from release-0.9.3-pre-rc
Date Wed, 22 Nov 2017 07:16:10 GMT
Merge commit '19a2b58c32d56060a8167a2ad69bb942083ba4c1' from release-0.9.3-pre-rc

Change-Id: I9e0ca4288a38d6311ce3e6d4a71a41086f59a2bb


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/63b2b5a2
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/63b2b5a2
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/63b2b5a2

Branch: refs/heads/master
Commit: 63b2b5a266432af64c06c61984415c0805d8f7fe
Parents: 2c04ae0 19a2b58
Author: Michael Blow <mblow@apache.org>
Authored: Wed Nov 22 01:15:04 2017 -0500
Committer: Michael Blow <mblow@apache.org>
Committed: Wed Nov 22 01:15:04 2017 -0500

----------------------------------------------------------------------
 .../apache/asterix/app/active/RecoveryTask.java |   5 +-
 .../asterix/metadata/lock/DatasetLock.java      | 111 ++++---
 .../metadata/lock/MetadataLockManagerTest.java  | 307 +++++++++++++++++++
 3 files changed, 384 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/63b2b5a2/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/lock/DatasetLock.java
----------------------------------------------------------------------
diff --cc asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/lock/DatasetLock.java
index 31f2089,bc302c2..1988f0a
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/lock/DatasetLock.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/lock/DatasetLock.java
@@@ -24,6 -24,7 +24,7 @@@ import java.util.concurrent.locks.Reent
  import org.apache.asterix.common.exceptions.ErrorCode;
  import org.apache.asterix.common.exceptions.MetadataException;
  import org.apache.asterix.common.metadata.IMetadataLock;
 -import org.apache.asterix.common.utils.InterruptUtil;
++import org.apache.asterix.common.utils.InvokeUtil;
  import org.apache.commons.lang3.mutable.MutableInt;
  import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
  
@@@ -77,7 -85,31 +85,31 @@@ public class DatasetLock implements IMe
  
      private void modifyReadLock() {
          // insert
-         dsModifyLock.readLock().lock();
+         modifyLock.readLock().lock();
+         incrementModifyCounter();
+     }
+ 
+     private void incrementModifyCounter() {
 -        InterruptUtil.doUninterruptibly(() -> {
++        InvokeUtil.doUninterruptibly(() -> {
+             synchronized (indexBuildCounter) {
+                 while (indexBuildCounter.getValue() > 0) {
+                     indexBuildCounter.wait();
+                 }
+                 synchronized (dsModifyCounter) {
+                     dsModifyCounter.increment();
+                 }
+             }
+         });
+     }
+ 
+     private void decrementModifyCounter() {
+         synchronized (indexBuildCounter) {
+             synchronized (dsModifyCounter) {
+                 if (dsModifyCounter.decrementAndGet() == 0) {
+                     indexBuildCounter.notifyAll();
+                 }
+             }
+         }
      }
  
      private void modifyReadUnlock() {
@@@ -97,10 -130,19 +130,19 @@@
          // Build index statement
          synchronized (indexBuildCounter) {
              if (indexBuildCounter.getValue() > 0) {
-                 indexBuildCounter.setValue(indexBuildCounter.getValue() + 1);
+                 indexBuildCounter.increment();
              } else {
-                 dsModifyLock.writeLock().lock();
-                 indexBuildCounter.setValue(1);
 -                InterruptUtil.doUninterruptibly(() -> {
++                InvokeUtil.doUninterruptibly(() -> {
+                     while (true) {
+                         synchronized (dsModifyCounter) {
+                             if (dsModifyCounter.getValue() == 0) {
+                                 indexBuildCounter.increment();
+                                 return;
+                             }
+                         }
+                         indexBuildCounter.wait();
+                     }
+                 });
              }
          }
      }


Mime
View raw message