asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "abdullah alamoudi (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: Remove Installed Libraries before Unit Tests
Date Tue, 12 Apr 2016 19:24:23 GMT
abdullah alamoudi has submitted this change and it was merged.

Change subject: Remove Installed Libraries before Unit Tests
......................................................................


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>
---
M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedWorkCollection.java
M asterixdb/asterix-app/src/test/java/org/apache/asterix/app/external/TestLibrarian.java
M asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTest.java
M asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
4 files changed, 38 insertions(+), 6 deletions(-)

Approvals:
  Murtadha Hubail: Looks good to me, approved
  Jenkins: Verified



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 @@
                     if (LOGGER.isLoggable(Level.SEVERE)) {
                         LOGGER.severe("Exception in executing " + request);
                     }
-                    throw new RuntimeException(e);
                 }
             }
         }
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.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 @@
     @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 @@
         }
         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);
+        }
+    }
 }
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 @@
 
     @Test
     public void test() throws Exception {
+        TestLibrarian.cleanup();
         testExecutor.executeTest(PATH_ACTUAL, tcCtx, null, false, ExecutionTestUtil.FailedGroup);
     }
 }
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 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 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);
+    }
+
 }

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/797
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9dea8c8fc46a717acd0b86ac7b07e0276bb5e95c
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: abdullah alamoudi <bamousaa@gmail.com>
Gerrit-Reviewer: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <michael.blow@couchbase.com>
Gerrit-Reviewer: Murtadha Hubail <hubailmor@gmail.com>
Gerrit-Reviewer: abdullah alamoudi <bamousaa@gmail.com>

Mime
View raw message