asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amo...@apache.org
Subject asterixdb git commit: Enable Extensions Through EntryPoints
Date Sat, 20 Aug 2016 16:59:56 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master ab81748ab -> 80fbd9983


Enable Extensions Through EntryPoints

This change enable an instance with its implementations of entry points
to add extensions programmatically.

Change-Id: I363df794c48644ca806958f583a05aea10a93166
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1096
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>


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

Branch: refs/heads/master
Commit: 80fbd9983d1eddb3028a1defc2963f9e14138edc
Parents: ab81748
Author: Abdullah Alamoudi <bamousaa@gmail.com>
Authored: Sat Aug 20 16:24:25 2016 +0300
Committer: abdullah alamoudi <bamousaa@gmail.com>
Committed: Sat Aug 20 09:58:38 2016 -0700

----------------------------------------------------------------------
 .../app/nc/AsterixNCAppRuntimeContext.java      | 21 ++++++++++-----
 .../bootstrap/CCApplicationEntryPoint.java      |  8 ++++--
 .../bootstrap/NCApplicationEntryPoint.java      | 28 +++++++++++++-------
 .../asterix/common/config/AsterixExtension.java | 15 +++++++++++
 4 files changed, 54 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/80fbd998/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/AsterixNCAppRuntimeContext.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/AsterixNCAppRuntimeContext.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/AsterixNCAppRuntimeContext.java
index 3ebe873..c73ab0f 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/AsterixNCAppRuntimeContext.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/AsterixNCAppRuntimeContext.java
@@ -21,6 +21,8 @@ package org.apache.asterix.app.nc;
 import java.io.IOException;
 import java.rmi.RemoteException;
 import java.rmi.server.UnicastRemoteObject;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -33,6 +35,7 @@ import org.apache.asterix.common.api.IDatasetLifecycleManager;
 import org.apache.asterix.common.cluster.ClusterPartition;
 import org.apache.asterix.common.config.AsterixBuildProperties;
 import org.apache.asterix.common.config.AsterixCompilerProperties;
+import org.apache.asterix.common.config.AsterixExtension;
 import org.apache.asterix.common.config.AsterixExtensionProperties;
 import org.apache.asterix.common.config.AsterixExternalProperties;
 import org.apache.asterix.common.config.AsterixFeedProperties;
@@ -134,9 +137,10 @@ public class AsterixNCAppRuntimeContext implements IAsterixAppRuntimeContext,
IA
     private final ILibraryManager libraryManager;
     private final NCExtensionManager ncExtensionManager;
 
-    public AsterixNCAppRuntimeContext(INCApplicationContext ncApplicationContext, int metadataRmiPort)
-            throws AsterixException, InstantiationException, IllegalAccessException, ClassNotFoundException,
-            IOException {
+    public AsterixNCAppRuntimeContext(INCApplicationContext ncApplicationContext, int metadataRmiPort,
+            List<AsterixExtension> extensions) throws AsterixException, InstantiationException,
IllegalAccessException,
+            ClassNotFoundException, IOException {
+        List<AsterixExtension> allExtensions = new ArrayList<>();
         this.ncApplicationContext = ncApplicationContext;
         // Determine whether to use old-style asterix-configuration.xml or new-style configuration.
         // QQQ strip this out eventually
@@ -159,8 +163,11 @@ public class AsterixNCAppRuntimeContext implements IAsterixAppRuntimeContext,
IA
                 AsterixClusterProperties.INSTANCE.getCluster());
         this.metadataRmiPort = metadataRmiPort;
         libraryManager = new ExternalLibraryManager();
-        ncExtensionManager = new NCExtensionManager(
-                new AsterixExtensionProperties(propertiesAccessor).getExtensions());
+        if (extensions != null) {
+            allExtensions.addAll(extensions);
+        }
+        allExtensions.addAll(new AsterixExtensionProperties(propertiesAccessor).getExtensions());
+        ncExtensionManager = new NCExtensionManager(allExtensions);
     }
 
     @Override
@@ -181,8 +188,8 @@ public class AsterixNCAppRuntimeContext implements IAsterixAppRuntimeContext,
IA
         metadataMergePolicyFactory = new PrefixMergePolicyFactory();
 
         ILocalResourceRepositoryFactory persistentLocalResourceRepositoryFactory =
-                new PersistentLocalResourceRepositoryFactory(ioManager, ncApplicationContext.getNodeId(),
-                        metadataProperties);
+                new PersistentLocalResourceRepositoryFactory(
+                ioManager, ncApplicationContext.getNodeId(), metadataProperties);
 
         localResourceRepository = (PersistentLocalResourceRepository) persistentLocalResourceRepositoryFactory
                 .createRepository();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/80fbd998/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
index cf57174..1e40d837 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
@@ -47,6 +47,7 @@ import org.apache.asterix.app.external.ActiveLifecycleListener;
 import org.apache.asterix.app.external.ExternalLibraryUtils;
 import org.apache.asterix.common.api.AsterixThreadFactory;
 import org.apache.asterix.common.api.IClusterManagementWork.ClusterState;
+import org.apache.asterix.common.config.AsterixExtension;
 import org.apache.asterix.common.config.AsterixExternalProperties;
 import org.apache.asterix.common.config.AsterixMetadataProperties;
 import org.apache.asterix.common.library.ILibraryManager;
@@ -96,8 +97,7 @@ public class CCApplicationEntryPoint implements ICCApplicationEntryPoint
{
         ExternalLibraryUtils.setUpExternaLibraries(libraryManager, false);
         AsterixAppContextInfo.initialize(appCtx, getNewHyracksClientConnection(), GlobalRecoveryManager.instance(),
                 libraryManager);
-        ccExtensionManager = new CompilerExtensionManager(
-                AsterixAppContextInfo.getInstance().getExtensionProperties().getExtensions());
+        ccExtensionManager = new CompilerExtensionManager(getExtensions());
         AsterixAppContextInfo.getInstance().setExtensionManager(ccExtensionManager);
 
         if (System.getProperty("java.rmi.server.hostname") == null) {
@@ -126,6 +126,10 @@ public class CCApplicationEntryPoint implements ICCApplicationEntryPoint
{
         ccAppCtx.setMessageBroker(messageBroker);
     }
 
+    protected List<AsterixExtension> getExtensions() {
+        return AsterixAppContextInfo.getInstance().getExtensionProperties().getExtensions();
+    }
+
     protected List<Server> configureServers() throws Exception {
         AsterixExternalProperties externalProperties = AsterixAppContextInfo.getInstance().getExternalProperties();
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/80fbd998/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
index 5abe6bc..582ff62 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
@@ -19,6 +19,7 @@
 package org.apache.asterix.hyracks.bootstrap;
 
 import java.io.File;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -29,6 +30,7 @@ import org.apache.asterix.app.external.ExternalLibraryUtils;
 import org.apache.asterix.app.nc.AsterixNCAppRuntimeContext;
 import org.apache.asterix.common.api.AsterixThreadFactory;
 import org.apache.asterix.common.api.IAsterixAppRuntimeContext;
+import org.apache.asterix.common.config.AsterixExtension;
 import org.apache.asterix.common.config.AsterixMetadataProperties;
 import org.apache.asterix.common.config.AsterixTransactionProperties;
 import org.apache.asterix.common.config.IAsterixPropertiesProvider;
@@ -58,13 +60,17 @@ import org.kohsuke.args4j.Option;
 public class NCApplicationEntryPoint implements INCApplicationEntryPoint {
     private static final Logger LOGGER = Logger.getLogger(NCApplicationEntryPoint.class.getName());
 
-    @Option(name = "-metadata-port", usage = "IP port to bind metadata listener (default:
random port)", required = false)
+    @Option(name = "-metadata-port", usage = "IP port to bind metadata listener (default:
random port)",
+            required = false)
     public int metadataRmiPort = 0;
 
-    @Option(name = "-initial-run", usage = "A flag indicating if it's the first time the
NC is started (default: false)", required = false)
+    @Option(name = "-initial-run",
+            usage = "A flag indicating if it's the first time the NC is started (default:
false)", required = false)
     public boolean initialRun = false;
 
-    @Option(name = "-virtual-NC", usage = "A flag indicating if this NC is running on virtual
cluster (default: false)", required = false)
+    @Option(name = "-virtual-NC",
+            usage = "A flag indicating if this NC is running on virtual cluster " + "(default:
false)",
+            required = false)
     public boolean virtualNC = false;
 
     private INCApplicationContext ncApplicationContext = null;
@@ -96,11 +102,10 @@ public class NCApplicationEntryPoint implements INCApplicationEntryPoint
{
         }
 
         if (System.getProperty("java.rmi.server.hostname") == null) {
-            System.setProperty("java.rmi.server.hostname",
-                    ((NodeControllerService) ncAppCtx.getControllerService())
-                            .getConfiguration().clusterNetPublicIPAddress);
+            System.setProperty("java.rmi.server.hostname", ((NodeControllerService) ncAppCtx.getControllerService())
+                    .getConfiguration().clusterNetPublicIPAddress);
         }
-        runtimeContext = new AsterixNCAppRuntimeContext(ncApplicationContext, metadataRmiPort);
+        runtimeContext = new AsterixNCAppRuntimeContext(ncApplicationContext, metadataRmiPort,
getExtensions());
         AsterixMetadataProperties metadataProperties = ((IAsterixPropertiesProvider) runtimeContext)
                 .getMetadataProperties();
         if (!metadataProperties.getNodeNames().contains(ncApplicationContext.getNodeId()))
{
@@ -154,6 +159,10 @@ public class NCApplicationEntryPoint implements INCApplicationEntryPoint
{
         }
     }
 
+    protected List<AsterixExtension> getExtensions() {
+        return Collections.emptyList();
+    }
+
     private void startReplicationService() throws InterruptedException {
         //Open replication channel
         runtimeContext.getReplicationChannel().start();
@@ -206,8 +215,9 @@ public class NCApplicationEntryPoint implements INCApplicationEntryPoint
{
                 LOGGER.info("Root Metadata Store: " + metadataProperties.getStores().get(nodeId)[0]);
             }
 
-            PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository)
runtimeContext
-                    .getLocalResourceRepository();
+            PersistentLocalResourceRepository localResourceRepository =
+                    (PersistentLocalResourceRepository) runtimeContext
+                            .getLocalResourceRepository();
             localResourceRepository.initializeNewUniverse(AsterixClusterProperties.INSTANCE.getStorageDirectoryName());
         }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/80fbd998/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixExtension.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixExtension.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixExtension.java
index 7417bc6..d1d6e0c 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixExtension.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixExtension.java
@@ -20,6 +20,7 @@ package org.apache.asterix.common.config;
 
 import java.util.List;
 
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.hyracks.algebricks.common.utils.Pair;
 
 public class AsterixExtension {
@@ -38,4 +39,18 @@ public class AsterixExtension {
     public String getClassName() {
         return className;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o instanceof AsterixExtension) {
+            AsterixExtension other = (AsterixExtension) o;
+            return ObjectUtils.equals(className, other.className) && ObjectUtils.equals(args,
other.args);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return ObjectUtils.hashCodeMulti(className);
+    }
 }
\ No newline at end of file


Mime
View raw message