asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amo...@apache.org
Subject incubator-asterixdb git commit: Remove Installed Libraries before Unit Tests
Date Tue, 12 Apr 2016 19:30:55 GMT
Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master 18ba0337d -> d7d7affcc


Remove Installed Libraries before Unit Tests

Change-Id: I9dea8c8fc46a717acd0b86ac7b07e0276bb5e95c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/797
Reviewed-by: Murtadha Hubail <hubailmor@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>


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

Branch: refs/heads/master
Commit: d7d7affcc1a4eafe6fabd612e8c04ffc24fe884f
Parents: 18ba033
Author: Abdullah Alamoudi <bamousaa@gmail.com>
Authored: Tue Apr 12 21:53:50 2016 +0300
Committer: abdullah alamoudi <bamousaa@gmail.com>
Committed: Tue Apr 12 12:24:22 2016 -0700

----------------------------------------------------------------------
 .../app/external/FeedWorkCollection.java        |  1 -
 .../asterix/app/external/TestLibrarian.java     | 12 ++++++++
 .../asterix/test/runtime/ExecutionTest.java     |  1 +
 .../library/ExternalLibraryManager.java         | 30 ++++++++++++++++----
 4 files changed, 38 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d7d7affc/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedWorkCollection.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedWorkCollection.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedWorkCollection.java
index 53b9792..2f338d0 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedWorkCollection.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedWorkCollection.java
@@ -99,7 +99,6 @@ public class FeedWorkCollection {
                     if (LOGGER.isLoggable(Level.SEVERE)) {
                         LOGGER.severe("Exception in executing " + request);
                     }
-                    throw new RuntimeException(e);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d7d7affc/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/external/TestLibrarian.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/external/TestLibrarian.java
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/external/TestLibrarian.java
index 4f8fa6f..3416a77 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/external/TestLibrarian.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/external/TestLibrarian.java
@@ -22,12 +22,15 @@ import java.io.File;
 import java.io.IOException;
 import java.rmi.RemoteException;
 import java.util.HashMap;
+import java.util.List;
 
 import org.apache.asterix.common.exceptions.ACIDException;
 import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.event.service.AsterixEventServiceUtil;
+import org.apache.asterix.external.library.ExternalLibraryManager;
 import org.apache.asterix.test.aql.ITestLibrarian;
 import org.apache.commons.io.FileUtils;
+import org.apache.hyracks.algebricks.common.utils.Pair;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 public class TestLibrarian implements ITestLibrarian {
@@ -64,6 +67,7 @@ public class TestLibrarian implements ITestLibrarian {
     @Override
     public void uninstall(String dvName, String libName) throws RemoteException, AsterixException,
ACIDException {
         ExternalLibraryUtils.uninstallLibrary(dvName, libName);
+        ExternalLibraryManager.deregisterLibraryClassLoader(dvName, libName);
     }
 
     public static void removeLibraryDir() throws IOException {
@@ -73,4 +77,12 @@ public class TestLibrarian implements ITestLibrarian {
         }
         FileUtils.deleteQuietly(installLibDir);
     }
+
+    public static void cleanup() throws AsterixException, RemoteException, ACIDException
{
+        List<Pair<String, String>> libs = ExternalLibraryManager.getAllLibraries();
+        for (Pair<String, String> dvAndLib : libs) {
+            ExternalLibraryUtils.uninstallLibrary(dvAndLib.first, dvAndLib.second);
+            ExternalLibraryManager.deregisterLibraryClassLoader(dvAndLib.first, dvAndLib.second);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d7d7affc/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTest.java
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTest.java
index e372d31..dfb61c2 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTest.java
@@ -102,6 +102,7 @@ public class ExecutionTest {
 
     @Test
     public void test() throws Exception {
+        TestLibrarian.cleanup();
         testExecutor.executeTest(PATH_ACTUAL, tcCtx, null, false, ExecutionTestUtil.FailedGroup);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d7d7affc/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
index db85e2f..0283bf2 100755
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
@@ -18,8 +18,13 @@
  */
 package org.apache.asterix.external.library;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.hyracks.algebricks.common.utils.Pair;
 
 public class ExternalLibraryManager {
 
@@ -34,17 +39,27 @@ public class ExternalLibraryManager {
     public static void registerLibraryClassLoader(String dataverseName, String libraryName,
ClassLoader classLoader) {
         String key = getKey(dataverseName, libraryName);
         synchronized (libraryClassLoaders) {
-            if (libraryClassLoaders.get(dataverseName) != null) {
+            if (libraryClassLoaders.get(key) != null) {
                 throw new IllegalStateException("Library class loader already registered!");
             }
             libraryClassLoaders.put(key, classLoader);
         }
     }
 
+    public static List<Pair<String, String>> getAllLibraries() {
+        ArrayList<Pair<String, String>> libs = new ArrayList<>();
+        synchronized (libraryClassLoaders) {
+            for (Entry<String, ClassLoader> entry : libraryClassLoaders.entrySet())
{
+                libs.add(getDataverseAndLibararyName(entry.getKey()));;
+            }
+        }
+        return libs;
+    }
+
     public static void deregisterLibraryClassLoader(String dataverseName, String libraryName)
{
         String key = getKey(dataverseName, libraryName);
         synchronized (libraryClassLoaders) {
-            if (libraryClassLoaders.get(dataverseName) != null) {
+            if (libraryClassLoaders.get(key) != null) {
                 libraryClassLoaders.remove(key);
             }
         }
@@ -52,13 +67,18 @@ public class ExternalLibraryManager {
 
     public static ClassLoader getLibraryClassLoader(String dataverseName, String libraryName)
{
         String key = getKey(dataverseName, libraryName);
-        synchronized (libraryClassLoaders) {
-            return libraryClassLoaders.get(key);
-        }
+        return libraryClassLoaders.get(key);
     }
 
     private static String getKey(String dataverseName, String libraryName) {
         return dataverseName + "." + libraryName;
     }
 
+    private static Pair<String, String> getDataverseAndLibararyName(String key) {
+        int index = key.indexOf(".");
+        String dataverse = key.substring(0, index);
+        String library = key.substring(index + 1);
+        return new Pair<String, String>(dataverse, library);
+    }
+
 }


Mime
View raw message