Michael Blow has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/3210
Change subject: [NO ISSUE] enable configuration of external library dir ...................................................................... [NO ISSUE] enable configuration of external library dir Change-Id: I31963a79dbae572cad1db930b5d97ebbbd76ee1b --- M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/ExternalLibraryUtils.java M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/ExternalUDFLibrarian.java M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/IExternalUDFLibrarian.java M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java M asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java M asterixdb/asterix-app/src/test/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java M asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java M asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/LangExecutionUtil.java M asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.regexadm M asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.regexadm M asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.regexadm M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ExternalProperties.java M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/library/ILibraryManager.java M asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java M asterixdb/asterix-server/src/main/opt/ansible/conf/cc.conf M asterixdb/asterix-server/src/main/opt/ansible/conf/instance_settings.yml M asterixdb/asterix-server/src/main/opt/ansible/yaml/deploy_udf.yml M asterixdb/asterix-server/src/main/opt/ansible/yaml/start_cc.yml 18 files changed, 114 insertions(+), 77 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/10/3210/1 diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/ExternalLibraryUtils.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/ExternalLibraryUtils.java index 0eac212..03a8b38 100755 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/ExternalLibraryUtils.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/ExternalLibraryUtils.java @@ -65,11 +65,11 @@ // start by un-installing removed libraries (Metadata Node only) Map<String, List<String>> uninstalledLibs = null; if (isMetadataNode) { - uninstalledLibs = uninstallLibraries(); + uninstalledLibs = uninstallLibraries(externalLibraryManager); } // get the directory of the to be installed libraries - File installLibDir = getLibraryInstallDir(); + File installLibDir = externalLibraryManager.getExternalLibDir(); // directory exists? if (installLibDir.exists()) { // get the list of files in the directory @@ -90,11 +90,13 @@ * * @return a map from dataverse -> list of uninstalled libraries. * @throws Exception + * @param externalLibraryManager */ - private static Map<String, List<String>> uninstallLibraries() throws Exception { + private static Map<String, List<String>> uninstallLibraries(ILibraryManager externalLibraryManager) + throws Exception { Map<String, List<String>> uninstalledLibs = new HashMap<>(); // get the directory of the un-install libraries - File uninstallLibDir = getLibraryUninstallDir(); + File uninstallLibDir = getLibraryUninstallDir(externalLibraryManager); String[] uninstallLibNames; // directory exists? if (uninstallLibDir.exists()) { @@ -309,7 +311,7 @@ protected static void registerClassLoader(ILibraryManager externalLibraryManager, String dataverse, String libraryName) throws Exception { // get the class loader - ClassLoader classLoader = getLibraryClassLoader(dataverse, libraryName); + ClassLoader classLoader = getLibraryClassLoader(externalLibraryManager, dataverse, libraryName); // register it with the external library manager externalLibraryManager.registerLibraryClassLoader(dataverse, libraryName, classLoader); } @@ -331,14 +333,17 @@ /** * Get the class loader for the library * + * + * @param externalLibraryManager * @param dataverse * @param libraryName * @return * @throws Exception */ - private static ClassLoader getLibraryClassLoader(String dataverse, String libraryName) throws Exception { + private static ClassLoader getLibraryClassLoader(ILibraryManager externalLibraryManager, String dataverse, + String libraryName) throws Exception { // Get a reference to the library directory - File installDir = getLibraryInstallDir(); + File installDir = externalLibraryManager.getExternalLibDir(); if (LOGGER.isInfoEnabled()) { LOGGER.info("Installing lirbary " + libraryName + " in dataverse " + dataverse + "." + " Install Directory: " + installDir.getAbsolutePath()); @@ -399,20 +404,8 @@ return new ExternalLibraryClassLoader(urls, parentClassLoader); } - /** - * @return the directory "System.getProperty("app.home", System.getProperty("user.home")/lib/udfs" - */ - protected static File getLibraryInstallDir() { - return new File(System.getProperty("app.home", System.getProperty("user.home")) + File.separator + "lib" - + File.separator + "udfs"); - } - - /** - * @return the directory "System.getProperty("app.home", System.getProperty("user.home")/lib/udfs/uninstall" - */ - protected static File getLibraryUninstallDir() { - return new File(System.getProperty("app.home", System.getProperty("user.home")) + File.separator + "lib" - + File.separator + "udfs" + File.separator + "uninstall"); + protected static File getLibraryUninstallDir(ILibraryManager externalLibraryManager) { + return new File(externalLibraryManager.getExternalLibDir(), "uninstall"); } public static String getExternalFunctionFullName(String libraryName, String functionName) { diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/ExternalUDFLibrarian.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/ExternalUDFLibrarian.java index 7246925..abdf0e9 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/ExternalUDFLibrarian.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/ExternalUDFLibrarian.java @@ -26,6 +26,7 @@ import java.rmi.RemoteException; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -36,6 +37,7 @@ import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.io.FileUtils; import org.apache.hyracks.algebricks.common.utils.Pair; +import org.apache.hyracks.util.file.FileUtil; @SuppressWarnings("squid:S134") public class ExternalUDFLibrarian implements IExternalUDFLibrarian { @@ -48,8 +50,8 @@ this.libraryManagers = libraryManagers; } - public static void removeLibraryDir() throws IOException { - File installLibDir = ExternalLibraryUtils.getLibraryInstallDir(); + public static void removeLibraryDir(ILibraryManager manager) { + File installLibDir = manager.getExternalLibDir(); FileUtils.deleteQuietly(installLibDir); } @@ -82,25 +84,26 @@ @Override public void install(String dvName, String libName, String libPath) throws Exception { - // get the directory of the to be installed libraries - File installLibDir = ExternalLibraryUtils.getLibraryInstallDir(); - // directory exists? - if (!installLibDir.exists()) { - installLibDir.mkdir(); - } - // copy the library file into the directory - File destinationDir = - new File(installLibDir.getAbsolutePath() + File.separator + dvName + File.separator + libName); - FileUtils.deleteQuietly(destinationDir); - destinationDir.mkdirs(); - try { - unzip(libPath, destinationDir.getAbsolutePath()); - } catch (Exception e) { - - throw new Exception("Couldn't unzip the file: " + libPath, e); - } - + HashSet<File> visited = new HashSet<>(); for (ILibraryManager libraryManager : libraryManagers) { + // get the directory of the to be installed libraries + File installLibDir = libraryManager.getExternalLibDir(); + // copy the library file into the directory + File destinationDir = new File(installLibDir, FileUtil.joinPath(dvName, libName)); + if (visited.add(installLibDir)) { + // directory exists? + if (!installLibDir.exists()) { + installLibDir.mkdir(); + } + FileUtils.deleteQuietly(destinationDir); + destinationDir.mkdirs(); + try { + unzip(libPath, destinationDir.getAbsolutePath()); + } catch (Exception e) { + + throw new Exception("Couldn't unzip the file: " + libPath, e); + } + } ExternalLibraryUtils.registerClassLoader(libraryManager, dvName, libName); ExternalLibraryUtils.configureLibrary(libraryManager, dvName, destinationDir, new HashMap<>(), libraryManagers.indexOf(libraryManager) != 0); @@ -116,15 +119,17 @@ } public void cleanup() throws AsterixException, RemoteException, ACIDException { + HashSet<File> visited = new HashSet<>(); for (ILibraryManager libraryManager : libraryManagers) { + if (!visited.add(libraryManager.getExternalLibDir())) { + continue; + } List<Pair<String, String>> libs = libraryManager.getAllLibraries(); for (Pair<String, String> dvAndLib : libs) { ExternalLibraryUtils.uninstallLibrary(dvAndLib.first, dvAndLib.second); libraryManager.deregisterLibraryClassLoader(dvAndLib.first, dvAndLib.second); } + FileUtils.deleteQuietly(libraryManager.getExternalLibDir()); } - // get the directory of the to be installed libraries - File installLibDir = ExternalLibraryUtils.getLibraryInstallDir(); - FileUtils.deleteQuietly(installLibDir); } } diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/IExternalUDFLibrarian.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/IExternalUDFLibrarian.java index 9a17444..e6605c7 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/IExternalUDFLibrarian.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/IExternalUDFLibrarian.java @@ -25,7 +25,7 @@ import org.apache.asterix.common.exceptions.AsterixException; public interface IExternalUDFLibrarian { - public void install(String dvName, String libName, String libPath) throws IOException, Exception; + void install(String dvName, String libName, String libPath) throws IOException, Exception; - public void uninstall(String dvName, String libName) throws RemoteException, AsterixException, ACIDException; + void uninstall(String dvName, String libName) throws RemoteException, AsterixException, ACIDException; } diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java index 724691c..123e4dc 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java @@ -165,7 +165,7 @@ replicationProperties = propertiesFactory.newReplicationProperties(); messagingProperties = propertiesFactory.newMessagingProperties(); nodeProperties = propertiesFactory.newNodeProperties(); - libraryManager = new ExternalLibraryManager(); + libraryManager = new ExternalLibraryManager(externalProperties.getExternalLibDir()); if (extensions != null) { allExtensions.addAll(extensions); } diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java index ce98a03..b54850f 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java @@ -142,15 +142,15 @@ hcc = new HyracksConnection(strIP, port, ccServiceCtx.getControllerService().getNetworkSecurityManager().getSocketChannelFactory()); MetadataBuiltinFunctions.init(); - ILibraryManager libraryManager = new ExternalLibraryManager(); - ReplicationProperties repProp = - new ReplicationProperties(PropertiesAccessor.getInstance(ccServiceCtx.getAppConfig())); + PropertiesAccessor propertiesAccessor = PropertiesAccessor.getInstance(ccServiceCtx.getAppConfig()); + ReplicationProperties repProp = new ReplicationProperties(propertiesAccessor); INcLifecycleCoordinator lifecycleCoordinator = createNcLifeCycleCoordinator(repProp.isReplicationEnabled()); + ExternalProperties extProp = new ExternalProperties(propertiesAccessor); + ILibraryManager libraryManager = new ExternalLibraryManager(extProp.getExternalLibDir()); ExternalLibraryUtils.setUpExternaLibraries(libraryManager, false); componentProvider = new StorageComponentProvider(); - List<AsterixExtension> extensions = new ArrayList<>(); - extensions.addAll(getExtensions()); + List<AsterixExtension> extensions = new ArrayList<>(getExtensions()); ccExtensionManager = new CCExtensionManager(extensions); IGlobalRecoveryManager globalRecoveryManager = createGlobalRecoveryManager(); appCtx = createApplicationContext(libraryManager, globalRecoveryManager, lifecycleCoordinator, diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java index 9c24821..247b4c3 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/common/AsterixHyracksIntegrationUtil.java @@ -38,6 +38,7 @@ import org.apache.asterix.app.io.PersistedResourceRegistry; import org.apache.asterix.common.api.IClusterManagementWork.ClusterState; import org.apache.asterix.common.api.INcApplicationContext; +import org.apache.asterix.common.config.ExternalProperties; import org.apache.asterix.common.config.PropertiesAccessor; import org.apache.asterix.common.dataflow.ICcApplicationContext; import org.apache.asterix.common.exceptions.AsterixException; @@ -214,6 +215,7 @@ ccConfig.setResultSweepThreshold(1000L); ccConfig.setEnforceFrameWriterProtocol(true); configManager.set(ControllerConfig.Option.DEFAULT_DIR, joinPath(getDefaultStoragePath(), "asterixdb")); + configManager.set(ExternalProperties.Option.EXTERNAL_LIB_DIR, joinPath(getDefaultStoragePath(), "udfs")); return ccConfig; } @@ -233,6 +235,7 @@ ncConfig.setResultSweepThreshold(1000L); ncConfig.setVirtualNC(); configManager.set(ControllerConfig.Option.DEFAULT_DIR, joinPath(getDefaultStoragePath(), "asterixdb", ncName)); + configManager.set(ExternalProperties.Option.EXTERNAL_LIB_DIR, joinPath(getDefaultStoragePath(), "udfs")); return ncConfig; } diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java index b07a30e..545b734 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java @@ -37,6 +37,7 @@ import org.apache.asterix.common.dataflow.ICcApplicationContext; import org.apache.asterix.common.dataflow.LSMInsertDeleteOperatorNodePushable; import org.apache.asterix.common.exceptions.ACIDException; +import org.apache.asterix.common.library.ILibraryManager; import org.apache.asterix.common.transactions.ITransactionManager; import org.apache.asterix.common.transactions.TxnId; import org.apache.asterix.dataflow.data.nontagged.MissingWriterFactory; @@ -136,6 +137,7 @@ private final String testConfigFileName; private final boolean runHDFS; private final List<Pair<IOption, Object>> options = new ArrayList<>(); + private List<ILibraryManager> libraryManagers; public TestNodeController(String testConfigFileName, boolean runHDFS) { this.testConfigFileName = testConfigFileName; @@ -150,11 +152,11 @@ try { File outdir = new File(PATH_ACTUAL); outdir.mkdirs(); - // remove library directory - ExternalUDFLibrarian.removeLibraryDir(); - ExecutionTestUtil.setUp(cleanupOnStart, + libraryManagers = ExecutionTestUtil.setUp(cleanupOnStart, testConfigFileName == null ? TEST_CONFIG_FILE_NAME : testConfigFileName, ExecutionTestUtil.integrationUtil, runHDFS, options); + // remove library directory + libraryManagers.forEach(ExternalUDFLibrarian::removeLibraryDir); } catch (Throwable th) { th.printStackTrace(); throw th; @@ -166,7 +168,7 @@ } public void deInit(boolean cleanupOnStop) throws Exception { - ExternalUDFLibrarian.removeLibraryDir(); + libraryManagers.forEach(ExternalUDFLibrarian::removeLibraryDir); ExecutionTestUtil.tearDown(cleanupOnStop, runHDFS); } diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/LangExecutionUtil.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/LangExecutionUtil.java index 75eccfd..8f63c35 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/LangExecutionUtil.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/LangExecutionUtil.java @@ -57,6 +57,7 @@ private static final List<String> badTestCases = new ArrayList<>(); private static TestExecutor testExecutor; + private static List<ILibraryManager> libraryManagers; private static ExternalUDFLibrarian librarian; private static final int repeat = Integer.getInteger("test.repeat", 1); private static boolean checkStorageDistribution = true; @@ -69,9 +70,8 @@ testExecutor = executor; File outdir = new File(PATH_ACTUAL); outdir.mkdirs(); - List<ILibraryManager> libraryManagers = - ExecutionTestUtil.setUp(cleanupOnStart, configFile, integrationUtil, startHdfs, null); - ExternalUDFLibrarian.removeLibraryDir(); + libraryManagers = ExecutionTestUtil.setUp(cleanupOnStart, configFile, integrationUtil, startHdfs, null); + libraryManagers.forEach(ExternalUDFLibrarian::removeLibraryDir); librarian = new ExternalUDFLibrarian(libraryManagers); testExecutor.setLibrarian(librarian); if (repeat != 1) { @@ -86,7 +86,7 @@ // Check whether there are leaked threads. checkThreadLeaks(); } finally { - ExternalUDFLibrarian.removeLibraryDir(); + libraryManagers.forEach(ExternalUDFLibrarian::removeLibraryDir); ExecutionTestUtil.tearDown(cleanupOnStop); integrationUtil.removeTestStorageFiles(); if (!badTestCases.isEmpty()) { diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.regexadm b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.regexadm index da464c7..1693bb5 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.regexadm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.regexadm @@ -17,6 +17,7 @@ "compiler\.sortmemory" : 327680, "compiler\.textsearchmemory" : 163840, "default\.dir" : "target/io/dir/asterixdb", + "external\.lib\.dir" : "target/io/dir/udfs", "log\.dir" : "logs/", "log\.level" : "INFO", "max\.wait\.active\.cluster" : 60, diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.regexadm b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.regexadm index fa8f48e..f2b91c4 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.regexadm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.regexadm @@ -17,6 +17,7 @@ "compiler\.sortmemory" : 327680, "compiler\.textsearchmemory" : 163840, "default\.dir" : "target/io/dir/asterixdb", + "external\.lib\.dir" : "target/io/dir/udfs", "log\.dir" : "logs/", "log\.level" : "WARN", "max\.wait\.active\.cluster" : 60, diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.regexadm b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.regexadm index 801900c..a674a4e 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.regexadm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.regexadm @@ -17,6 +17,7 @@ "compiler\.sortmemory" : 327680, "compiler\.textsearchmemory" : 163840, "default\.dir" : "target/io/dir/asterixdb", + "external\.lib\.dir" : "target/io/dir/udfs", "log\.dir" : "logs/", "log\.level" : "WARN", "max\.wait\.active\.cluster" : 60, diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ExternalProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ExternalProperties.java index 620e47c..ce45d25 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ExternalProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ExternalProperties.java @@ -23,10 +23,15 @@ import static org.apache.hyracks.control.common.config.OptionTypes.STRING; import static org.apache.hyracks.control.common.config.OptionTypes.UNSIGNED_INTEGER; +import java.io.File; +import java.util.function.Function; + +import org.apache.hyracks.api.config.IApplicationConfig; import org.apache.hyracks.api.config.IOption; import org.apache.hyracks.api.config.IOptionType; import org.apache.hyracks.api.config.Section; import org.apache.hyracks.util.StorageUtil; +import org.apache.hyracks.util.file.FileUtil; import org.apache.logging.log4j.Level; public class ExternalProperties extends AbstractProperties { @@ -43,12 +48,14 @@ 60, "The max pending time (in seconds) for cluster startup. After the " + "threshold, if the cluster still is not up and running, it is considered unavailable"), - CC_JAVA_OPTS(STRING, "-Xmx1024m", "The JVM options passed to the cluster controller process by managix"), - NC_JAVA_OPTS(STRING, "-Xmx1024m", "The JVM options passed to the node controller process(es) by managix"), MAX_WEB_REQUEST_SIZE( UNSIGNED_INTEGER, StorageUtil.getIntSizeInBytes(50, StorageUtil.StorageUnit.MEGABYTE), - "The maximum accepted web request size in bytes"); + "The maximum accepted web request size in bytes"), + EXTERNAL_LIB_DIR( + STRING, + FileUtil.joinPath(System.getProperty("app.home", System.getProperty("user.home")), "lib", "udfs"), + "The location where external libraries are deployed"); private final IOptionType type; private final Object defaultValue; @@ -73,10 +80,8 @@ case LOG_LEVEL: case MAX_WAIT_ACTIVE_CLUSTER: case MAX_WEB_REQUEST_SIZE: + case EXTERNAL_LIB_DIR: return Section.COMMON; - case CC_JAVA_OPTS: - case NC_JAVA_OPTS: - return Section.VIRTUAL; default: throw new IllegalStateException("NYI: " + this); } @@ -95,6 +100,15 @@ @Override public Object defaultValue() { return defaultValue; + } + + @Override + public String usageDefaultOverride(IApplicationConfig accessor, Function<IOption, String> optionPrinter) { + if (this == Option.EXTERNAL_LIB_DIR) { + return FileUtil.joinPath("${app.home}(or ${user.home} if 'app.home' is undefined)", "lib", "udfs"); + } else { + return null; + } } } @@ -126,14 +140,6 @@ return accessor.getInt(Option.MAX_WAIT_ACTIVE_CLUSTER); } - public String getNCJavaParams() { - return accessor.getString(Option.NC_JAVA_OPTS); - } - - public String getCCJavaParams() { - return accessor.getString(Option.CC_JAVA_OPTS); - } - public int getNcApiPort() { return accessor.getInt(Option.NC_API_PORT); } @@ -141,4 +147,8 @@ public int getMaxWebRequestSize() { return accessor.getInt(Option.MAX_WEB_REQUEST_SIZE); } + + public File getExternalLibDir() { + return new File(accessor.getString(Option.EXTERNAL_LIB_DIR)); + } } diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/library/ILibraryManager.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/library/ILibraryManager.java index ec02692..62f2e8b 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/library/ILibraryManager.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/library/ILibraryManager.java @@ -19,6 +19,7 @@ package org.apache.asterix.common.library; +import java.io.File; import java.util.List; import org.apache.hyracks.algebricks.common.utils.Pair; @@ -75,4 +76,9 @@ * @return A list contains all pre-specified function parameters. */ List<String> getFunctionParameters(String dataverseName, String fullFunctionName); + + /** + * Returns external libs deployment location + */ + File getExternalLibDir(); } 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 b9ce2bd..eb4f2d8 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,6 +18,7 @@ */ package org.apache.asterix.external.library; +import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -33,6 +34,11 @@ private final Map<String, ClassLoader> libraryClassLoaders = new HashMap<>(); private final Map<String, List<String>> externalFunctionParameters = new HashMap<>(); + private final File externalLibDir; + + public ExternalLibraryManager(File externalLibDir) { + this.externalLibDir = externalLibDir; + } @Override public void registerLibraryClassLoader(String dataverseName, String libraryName, ClassLoader classLoader) @@ -81,6 +87,11 @@ return externalFunctionParameters.getOrDefault(dataverseName + "." + fullFunctionName, Collections.emptyList()); } + @Override + public File getExternalLibDir() { + return externalLibDir; + } + private static String getKey(String dataverseName, String libraryName) { return dataverseName + "." + libraryName; } diff --git a/asterixdb/asterix-server/src/main/opt/ansible/conf/cc.conf b/asterixdb/asterix-server/src/main/opt/ansible/conf/cc.conf index 2824219..4e7be83 100644 --- a/asterixdb/asterix-server/src/main/opt/ansible/conf/cc.conf +++ b/asterixdb/asterix-server/src/main/opt/ansible/conf/cc.conf @@ -18,6 +18,7 @@ [common] log.level=INFO log.dir=logs +external.lib.dir=%UDFDIR% [nc] txn.log.dir=txnlog diff --git a/asterixdb/asterix-server/src/main/opt/ansible/conf/instance_settings.yml b/asterixdb/asterix-server/src/main/opt/ansible/conf/instance_settings.yml index b5cd1ae..169276d 100644 --- a/asterixdb/asterix-server/src/main/opt/ansible/conf/instance_settings.yml +++ b/asterixdb/asterix-server/src/main/opt/ansible/conf/instance_settings.yml @@ -35,6 +35,9 @@ # The working directory. binarydir: "{{ basedir }}/{{ product }}" +# Where udf libraries are deployed. +udfdir: "{{ binarydir }}/lib/udfs" + # The full binary distribution directory. dist: "../../../../" diff --git a/asterixdb/asterix-server/src/main/opt/ansible/yaml/deploy_udf.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/deploy_udf.yml index e9300ea..74dc71d 100644 --- a/asterixdb/asterix-server/src/main/opt/ansible/yaml/deploy_udf.yml +++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/deploy_udf.yml @@ -22,9 +22,9 @@ tasks: - include_vars: ../conf/instance_settings.yml - file: - path: "{{ binarydir }}/lib/udfs/{{ dataverse }}/{{ libname }}" + path: "{{ udfdir }}/{{ dataverse }}/{{ libname }}" state: directory mode: 0755 - unarchive: src: "{{ package_path }}" - dest: "{{ binarydir }}/lib/udfs/{{ dataverse }}/{{ libname }}" + dest: "{{ udfdir }}/{{ dataverse }}/{{ libname }}" diff --git a/asterixdb/asterix-server/src/main/opt/ansible/yaml/start_cc.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/start_cc.yml index a5b599c..1d081a5 100644 --- a/asterixdb/asterix-server/src/main/opt/ansible/yaml/start_cc.yml +++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/start_cc.yml @@ -27,7 +27,7 @@ when: debug and ansible_distribution != "MacOSX" - name: Update cluster config - shell: find -P "{{ binarydir }}/cc.conf" | xargs perl -pi -e 's|command=asterixnc|command={{ ncbin }}|g' + shell: find -P "{{ binarydir }}/cc.conf" | xargs perl -pi -e 's|command=asterixnc|command={{ ncbin }}|g ; s|%UDFDIR%|{{ udfdir }}|g' - name: Start CC shell: | -- To view, visit https://asterix-gerrit.ics.uci.edu/3210 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I31963a79dbae572cad1db930b5d97ebbbd76ee1b Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow <mb...@apache.org>