asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mhub...@apache.org
Subject asterixdb git commit: ASTERIXDB-1498: Validate DatasetLifeCycleManager State
Date Wed, 29 Jun 2016 01:45:09 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 6b16171d0 -> 6dc71486b


ASTERIXDB-1498: Validate DatasetLifeCycleManager State

This change adds appropriate error message when trying
to access a dataset/index after the DatasetLifeCycleManager
has been stopped.

Change-Id: Ie2c4a506103e0c04ec6b203253144603704e7e5c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/964
Reviewed-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <michael.blow@couchbase.com>


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

Branch: refs/heads/master
Commit: 6dc71486bb597c45151d9723f7bee0d69df27ea1
Parents: 6b16171
Author: Murtadha Hubail <mhubail@uci.edu>
Authored: Tue Jun 28 23:18:14 2016 +0300
Committer: Murtadha Hubail <hubailmor@gmail.com>
Committed: Tue Jun 28 18:44:30 2016 -0700

----------------------------------------------------------------------
 .../common/context/DatasetLifecycleManager.java    | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6dc71486/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
index 84317ea..f4eec05 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
@@ -63,6 +63,7 @@ public class DatasetLifecycleManager implements IDatasetLifecycleManager,
ILifeC
     private final ILogManager logManager;
     private final LogRecord logRecord;
     private final int numPartitions;
+    private boolean stopped = false;
 
     public DatasetLifecycleManager(AsterixStorageProperties storageProperties,
             ILocalResourceRepository resourceRepository, int firstAvilableUserDatasetID,
ILogManager logManager,
@@ -82,6 +83,7 @@ public class DatasetLifecycleManager implements IDatasetLifecycleManager,
ILifeC
 
     @Override
     public synchronized IIndex getIndex(String resourcePath) throws HyracksDataException
{
+        validateDatasetLifecycleManagerState();
         int datasetID = getDIDfromResourcePath(resourcePath);
         long resourceID = getResourceIDfromResourcePath(resourcePath);
         return getIndex(datasetID, resourceID);
@@ -89,6 +91,7 @@ public class DatasetLifecycleManager implements IDatasetLifecycleManager,
ILifeC
 
     @Override
     public synchronized IIndex getIndex(int datasetID, long resourceID) throws HyracksDataException
{
+        validateDatasetLifecycleManagerState();
         DatasetInfo dsInfo = datasetInfos.get(datasetID);
         if (dsInfo == null) {
             return null;
@@ -102,6 +105,7 @@ public class DatasetLifecycleManager implements IDatasetLifecycleManager,
ILifeC
 
     @Override
     public synchronized void register(String resourcePath, IIndex index) throws HyracksDataException
{
+        validateDatasetLifecycleManagerState();
         int did = getDIDfromResourcePath(resourcePath);
         long resourceID = getResourceIDfromResourcePath(resourcePath);
         DatasetInfo dsInfo = datasetInfos.get(did);
@@ -138,6 +142,7 @@ public class DatasetLifecycleManager implements IDatasetLifecycleManager,
ILifeC
 
     @Override
     public synchronized void unregister(String resourcePath) throws HyracksDataException
{
+        validateDatasetLifecycleManagerState();
         int did = getDIDfromResourcePath(resourcePath);
         long resourceID = getResourceIDfromResourcePath(resourcePath);
 
@@ -183,6 +188,7 @@ public class DatasetLifecycleManager implements IDatasetLifecycleManager,
ILifeC
 
     @Override
     public synchronized void open(String resourcePath) throws HyracksDataException {
+        validateDatasetLifecycleManagerState();
         int did = getDIDfromResourcePath(resourcePath);
         long resourceID = getResourceIDfromResourcePath(resourcePath);
 
@@ -267,6 +273,7 @@ public class DatasetLifecycleManager implements IDatasetLifecycleManager,
ILifeC
 
     @Override
     public synchronized void close(String resourcePath) throws HyracksDataException {
+        validateDatasetLifecycleManagerState();
         int did = getDIDfromResourcePath(resourcePath);
         long resourceID = getResourceIDfromResourcePath(resourcePath);
 
@@ -348,6 +355,12 @@ public class DatasetLifecycleManager implements IDatasetLifecycleManager,
ILifeC
         }
     }
 
+    private void validateDatasetLifecycleManagerState() throws HyracksDataException {
+        if (stopped) {
+            throw new HyracksDataException(DatasetLifecycleManager.class.getSimpleName()
+ " was stopped.");
+        }
+    }
+
     private static abstract class Info {
         protected int referenceCount;
         protected boolean isOpen;
@@ -630,6 +643,9 @@ public class DatasetLifecycleManager implements IDatasetLifecycleManager,
ILifeC
 
     @Override
     public synchronized void stop(boolean dumpState, OutputStream outputStream) throws IOException
{
+        if (stopped) {
+            return;
+        }
         if (dumpState) {
             dumpState(outputStream);
         }
@@ -639,6 +655,7 @@ public class DatasetLifecycleManager implements IDatasetLifecycleManager,
ILifeC
         datasetVirtualBufferCachesMap.clear();
         datasetOpTrackers.clear();
         datasetInfos.clear();
+        stopped = true;
     }
 
     @Override


Mime
View raw message