asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [1/2] asterixdb git commit: ASTERIXDB-1494: refactor ExternalLibraryManager and make it non-static.
Date Fri, 08 Jul 2016 12:50:21 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 20e085b38 -> f09607dd9


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f09607dd/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/feeds/FeedMetadataUtil.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/feeds/FeedMetadataUtil.java
b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/feeds/FeedMetadataUtil.java
index 1a51b74..6b55d81 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/feeds/FeedMetadataUtil.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/feeds/FeedMetadataUtil.java
@@ -36,6 +36,7 @@ import org.apache.asterix.common.dataflow.AsterixLSMTreeInsertDeleteOperatorDesc
 import org.apache.asterix.common.exceptions.ACIDException;
 import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.common.functions.FunctionSignature;
+import org.apache.asterix.common.library.ILibraryManager;
 import org.apache.asterix.external.api.IAdapterFactory;
 import org.apache.asterix.external.api.IDataSourceAdapter;
 import org.apache.asterix.external.api.IDataSourceAdapter.AdapterType;
@@ -44,7 +45,6 @@ import org.apache.asterix.external.feed.api.IFeedRuntime.FeedRuntimeType;
 import org.apache.asterix.external.feed.management.FeedConnectionId;
 import org.apache.asterix.external.feed.policy.FeedPolicyAccessor;
 import org.apache.asterix.external.feed.runtime.FeedRuntimeId;
-import org.apache.asterix.external.library.ExternalLibraryManager;
 import org.apache.asterix.external.operators.FeedCollectOperatorDescriptor;
 import org.apache.asterix.external.operators.FeedMetaOperatorDescriptor;
 import org.apache.asterix.external.provider.AdapterFactoryProvider;
@@ -150,8 +150,7 @@ public class FeedMetadataUtil {
         boolean preProcessingRequired = preProcessingRequired(feedConnectionId);
         // copy operators
         String operandId = null;
-        Map<OperatorDescriptorId, OperatorDescriptorId> oldNewOID =
-                new HashMap<OperatorDescriptorId, OperatorDescriptorId>();
+        Map<OperatorDescriptorId, OperatorDescriptorId> oldNewOID = new HashMap<>();
         FeedMetaOperatorDescriptor metaOp = null;
         for (Entry<OperatorDescriptorId, IOperatorDescriptor> entry : operatorMap.entrySet())
{
             operandId = FeedRuntimeId.DEFAULT_TARGET_ID;
@@ -197,8 +196,7 @@ public class FeedMetadataUtil {
         }
 
         // copy connectors
-        Map<ConnectorDescriptorId, ConnectorDescriptorId> connectorMapping =
-                new HashMap<ConnectorDescriptorId, ConnectorDescriptorId>();
+        Map<ConnectorDescriptorId, ConnectorDescriptorId> connectorMapping = new HashMap<>();
         for (Entry<ConnectorDescriptorId, IConnectorDescriptor> entry : spec.getConnectorMap().entrySet())
{
             IConnectorDescriptor connDesc = entry.getValue();
             ConnectorDescriptorId newConnId;
@@ -229,9 +227,8 @@ public class FeedMetadataUtil {
         }
 
         // prepare for setting partition constraints
-        Map<OperatorDescriptorId, List<LocationConstraint>> operatorLocations
=
-                new HashMap<OperatorDescriptorId, List<LocationConstraint>>();
-        Map<OperatorDescriptorId, Integer> operatorCounts = new HashMap<OperatorDescriptorId,
Integer>();
+        Map<OperatorDescriptorId, List<LocationConstraint>> operatorLocations
= new HashMap<>();
+        Map<OperatorDescriptorId, Integer> operatorCounts = new HashMap<>();
 
         for (Constraint constraint : spec.getUserConstraints()) {
             LValueConstraintExpression lexpr = constraint.getLValue();
@@ -454,7 +451,7 @@ public class FeedMetadataUtil {
         return preProcessingRequired;
     }
 
-    public static void validateFeed(Feed feed, MetadataTransactionContext mdTxnCtx)
+    public static void validateFeed(Feed feed, MetadataTransactionContext mdTxnCtx, ILibraryManager
libraryManager)
             throws AsterixException {
         try {
             String adapterName = feed.getAdapterName();
@@ -464,9 +461,8 @@ public class FeedMetadataUtil {
             ExternalDataUtils.prepareFeed(configuration, feed.getDataverseName(), feed.getFeedName());
             ExternalDataUtils.prepareFeed(configuration, feed.getDataverseName(), feed.getFeedName());
             // Get adapter from metadata dataset <Metadata dataverse>
-            DatasourceAdapter adapterEntity =
-                    MetadataManager.INSTANCE.getAdapter(mdTxnCtx, MetadataConstants.METADATA_DATAVERSE_NAME,
-                            adapterName);
+            DatasourceAdapter adapterEntity = MetadataManager.INSTANCE.getAdapter(mdTxnCtx,
+                    MetadataConstants.METADATA_DATAVERSE_NAME, adapterName);
             // Get adapter from metadata dataset <The feed dataverse>
             if (adapterEntity == null) {
                 adapterEntity = MetadataManager.INSTANCE.getAdapter(mdTxnCtx, feed.getDataverseName(),
adapterName);
@@ -483,8 +479,7 @@ public class FeedMetadataUtil {
                     case EXTERNAL:
                         String[] anameComponents = adapterName.split("#");
                         String libraryName = anameComponents[0];
-                        ClassLoader cl =
-                                ExternalLibraryManager.getLibraryClassLoader(feed.getDataverseName(),
libraryName);
+                        ClassLoader cl = libraryManager.getLibraryClassLoader(feed.getDataverseName(),
libraryName);
                         adapterFactory = (IAdapterFactory) cl.loadClass(adapterFactoryClassname).newInstance();
                         break;
                     default:
@@ -492,9 +487,9 @@ public class FeedMetadataUtil {
                 }
                 adapterFactory.setOutputType(adapterOutputType);
                 adapterFactory.setMetaType(metaType);
-                adapterFactory.configure(configuration);
+                adapterFactory.configure(null, configuration);
             } else {
-                AdapterFactoryProvider.getAdapterFactory(adapterName, configuration, adapterOutputType,
+                AdapterFactoryProvider.getAdapterFactory(libraryManager, adapterName, configuration,
adapterOutputType,
                         metaType);
             }
             if (metaType == null && configuration.containsKey(ExternalDataConstants.KEY_META_TYPE_NAME))
{
@@ -520,9 +515,9 @@ public class FeedMetadataUtil {
     }
 
     @SuppressWarnings("rawtypes")
-    public static Triple<IAdapterFactory, RecordDescriptor, IDataSourceAdapter.AdapterType>
-            getPrimaryFeedFactoryAndOutput(Feed feed, FeedPolicyAccessor policyAccessor,
-                    MetadataTransactionContext mdTxnCtx) throws AlgebricksException {
+    public static Triple<IAdapterFactory, RecordDescriptor, AdapterType> getPrimaryFeedFactoryAndOutput(Feed
feed,
+            FeedPolicyAccessor policyAccessor, MetadataTransactionContext mdTxnCtx, ILibraryManager
libraryManager)
+            throws AlgebricksException {
         // This method needs to be re-visited
         String adapterName = null;
         DatasourceAdapter adapterEntity = null;
@@ -556,8 +551,7 @@ public class FeedMetadataUtil {
                     case EXTERNAL:
                         String[] anameComponents = adapterName.split("#");
                         String libraryName = anameComponents[0];
-                        ClassLoader cl =
-                                ExternalLibraryManager.getLibraryClassLoader(feed.getDataverseName(),
libraryName);
+                        ClassLoader cl = libraryManager.getLibraryClassLoader(feed.getDataverseName(),
libraryName);
                         adapterFactory = (IAdapterFactory) cl.loadClass(adapterFactoryClassname).newInstance();
                         break;
                     default:
@@ -565,10 +559,10 @@ public class FeedMetadataUtil {
                 }
                 adapterFactory.setOutputType(adapterOutputType);
                 adapterFactory.setMetaType(metaType);
-                adapterFactory.configure(configuration);
+                adapterFactory.configure(null, configuration);
             } else {
-                adapterFactory = AdapterFactoryProvider.getAdapterFactory(adapterName, configuration,
adapterOutputType,
-                        metaType);
+                adapterFactory = AdapterFactoryProvider.getAdapterFactory(libraryManager,
adapterName, configuration,
+                        adapterOutputType, metaType);
                 adapterType = IDataSourceAdapter.AdapterType.INTERNAL;
             }
             if (metaType == null) {
@@ -681,7 +675,7 @@ public class FeedMetadataUtil {
 
     public static String getSecondaryFeedOutput(Feed feed, FeedPolicyAccessor policyAccessor,
             MetadataTransactionContext mdTxnCtx)
-                    throws AlgebricksException, MetadataException, RemoteException, ACIDException
{
+            throws AlgebricksException, MetadataException, RemoteException, ACIDException
{
         String outputType = null;
         String primaryFeedName = feed.getSourceFeedName();
         Feed primaryFeed = MetadataManager.INSTANCE.getFeed(mdTxnCtx, feed.getDataverseName(),
primaryFeedName);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f09607dd/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/AsterixAppContextInfo.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/AsterixAppContextInfo.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/AsterixAppContextInfo.java
index e26a92b..bb1e554 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/AsterixAppContextInfo.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/AsterixAppContextInfo.java
@@ -33,6 +33,7 @@ import org.apache.asterix.common.config.AsterixTransactionProperties;
 import org.apache.asterix.common.config.IAsterixPropertiesProvider;
 import org.apache.asterix.common.dataflow.IAsterixApplicationContextInfo;
 import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.library.ILibraryManager;
 import org.apache.asterix.transaction.management.service.transaction.AsterixRuntimeComponentsProvider;
 import org.apache.hyracks.api.application.IApplicationConfig;
 import org.apache.hyracks.api.application.ICCApplicationContext;
@@ -60,13 +61,14 @@ public class AsterixAppContextInfo implements IAsterixApplicationContextInfo,
IA
     private AsterixReplicationProperties replicationProperties;
     private final IGlobalRecoveryMaanger globalRecoveryMaanger;
     private IHyracksClientConnection hcc;
+    private final ILibraryManager libraryManager;
 
     public static void initialize(ICCApplicationContext ccAppCtx, IHyracksClientConnection
hcc,
-            IGlobalRecoveryMaanger globalRecoveryMaanger) throws AsterixException {
+            IGlobalRecoveryMaanger globalRecoveryMaanger, ILibraryManager libraryManager)
throws AsterixException {
         if (INSTANCE != null) {
             return;
         }
-        INSTANCE = new AsterixAppContextInfo(ccAppCtx, hcc, globalRecoveryMaanger);
+        INSTANCE = new AsterixAppContextInfo(ccAppCtx, hcc, globalRecoveryMaanger, libraryManager);
 
         // Determine whether to use old-style asterix-configuration.xml or new-style configuration.
         // QQQ strip this out eventually
@@ -92,10 +94,11 @@ public class AsterixAppContextInfo implements IAsterixApplicationContextInfo,
IA
     }
 
     private AsterixAppContextInfo(ICCApplicationContext ccAppCtx, IHyracksClientConnection
hcc,
-            IGlobalRecoveryMaanger globalRecoveryMaanger) {
+            IGlobalRecoveryMaanger globalRecoveryMaanger, ILibraryManager libraryManager)
{
         this.appCtx = ccAppCtx;
         this.hcc = hcc;
         this.globalRecoveryMaanger = globalRecoveryMaanger;
+        this.libraryManager = libraryManager;
     }
 
     public static AsterixAppContextInfo getInstance() {
@@ -165,4 +168,9 @@ public class AsterixAppContextInfo implements IAsterixApplicationContextInfo,
IA
     public IGlobalRecoveryMaanger getGlobalRecoveryManager() {
         return globalRecoveryMaanger;
     }
+
+    @Override
+    public ILibraryManager getLibraryManager() {
+        return libraryManager;
+    }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f09607dd/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
index 7917e4a..ad3ffc1 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
@@ -54,16 +54,17 @@ public class CCApplicationContext extends ApplicationContext implements
ICCAppli
     private final ClusterControllerService ccs;
 
     public CCApplicationContext(ClusterControllerService ccs, ServerContext serverCtx, ICCContext
ccContext,
-                                IApplicationConfig appConfig) throws IOException {
+            IApplicationConfig appConfig) throws IOException {
         super(serverCtx, appConfig);
         this.ccContext = ccContext;
         this.ccs = ccs;
-        initPendingNodeIds = new HashSet<String>();
-        deinitPendingNodeIds = new HashSet<String>();
-        jobLifecycleListeners = new ArrayList<IJobLifecycleListener>();
-        clusterLifecycleListeners = new ArrayList<IClusterLifecycleListener>();
+        initPendingNodeIds = new HashSet<>();
+        deinitPendingNodeIds = new HashSet<>();
+        jobLifecycleListeners = new ArrayList<>();
+        clusterLifecycleListeners = new ArrayList<>();
     }
 
+    @Override
     public ICCContext getCCContext() {
         return ccContext;
     }


Mime
View raw message