You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by sj...@apache.org on 2016/12/16 21:59:33 UTC

asterixdb-bad git commit: Updated to Asterix changes

Repository: asterixdb-bad
Updated Branches:
  refs/heads/master 3afba4275 -> 7cc6a84c3


Updated to Asterix changes

Removed the word Asterix from class names
Made BAD ruleset more robust to Asterix rule changes

Change-Id: I371cf7f0dc2e4d904d8c6c1e5cca644283ef3626


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

Branch: refs/heads/master
Commit: 7cc6a84c354de338adb41df843bad55439ca4e2f
Parents: 3afba42
Author: Steven Glenn Jacobs <sj...@ucr.edu>
Authored: Fri Dec 16 12:23:11 2016 -0800
Committer: Steven Glenn Jacobs <sj...@ucr.edu>
Committed: Fri Dec 16 12:23:11 2016 -0800

----------------------------------------------------------------------
 .../asterix/bad/lang/BADRuleSetFactory.java     | 36 +++++++++++++++-----
 .../lang/statement/ChannelDropStatement.java    |  6 ++--
 .../statement/ChannelSubscribeStatement.java    |  4 +--
 .../statement/ChannelUnsubscribeStatement.java  |  4 +--
 .../lang/statement/CreateChannelStatement.java  |  4 +--
 .../bad/metadata/ChannelEventsListener.java     |  6 ++--
 .../InsertBrokerNotifierForChannelRule.java     |  8 ++---
 .../bad/runtime/NotifyBrokerRuntime.java        |  4 +--
 .../asterix/bad/test/BADExecutionTest.java      |  4 +--
 9 files changed, 47 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/7cc6a84c/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADRuleSetFactory.java
----------------------------------------------------------------------
diff --git a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADRuleSetFactory.java b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADRuleSetFactory.java
index 31d8cd0..7e45fd6 100644
--- a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADRuleSetFactory.java
+++ b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/BADRuleSetFactory.java
@@ -18,6 +18,7 @@
  */
 package org.apache.asterix.bad.lang;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.asterix.bad.rules.InsertBrokerNotifierForChannelRule;
@@ -37,21 +38,39 @@ public class BADRuleSetFactory implements IRuleSetFactory {
     public List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> getLogicalRewrites()
             throws AlgebricksException {
         List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> logicalRuleSet = DefaultRuleSetFactory.buildLogical();
-        if (logicalRuleSet.size() != 14) {
-            throw new AlgebricksException("Incorrect RuleSet");
-        }
+
         List<IAlgebraicRewriteRule> normalizationCollection = RuleCollections.buildNormalizationRuleCollection();
+        List<IAlgebraicRewriteRule> alteredNormalizationCollection = new ArrayList<>();
+        alteredNormalizationCollection.addAll(normalizationCollection);
 
-        for (int i = 0; i < normalizationCollection.size(); i++) {
-            IAlgebraicRewriteRule rule = normalizationCollection.get(i);
+        //Create a normalization collection that includes the broker rule
+        for (int i = 0; i < alteredNormalizationCollection.size(); i++) {
+            IAlgebraicRewriteRule rule = alteredNormalizationCollection.get(i);
             if (rule instanceof UnnestToDataScanRule) {
-                normalizationCollection.add(i + 1, new InsertBrokerNotifierForChannelRule());
+                alteredNormalizationCollection.add(i + 1, new InsertBrokerNotifierForChannelRule());
                 break;
             }
         }
+
+        //Find instances of the normalization collection and replace them with the new one
         SequentialOnceRuleController seqOnceCtrl = new SequentialOnceRuleController(true);
-        logicalRuleSet.set(3, new Pair<>(seqOnceCtrl, normalizationCollection));
-        logicalRuleSet.set(7, new Pair<>(seqOnceCtrl, normalizationCollection));
+        for (int i =0; i < logicalRuleSet.size(); i++){
+            List<IAlgebraicRewriteRule> collection = logicalRuleSet.get(i).second;
+            if (collection.size() == normalizationCollection.size()) {
+                boolean isNormalizationCollection = true;
+                for (int j = 0; j < collection.size(); j++) {
+                    //Make sure the set of rules is the same
+                    if (!collection.get(j).getClass().equals(normalizationCollection.get(j).getClass())) {
+                        isNormalizationCollection = false;
+                        break;
+                    }
+                }
+                if (isNormalizationCollection) {
+                    //replace with the new collection
+                    logicalRuleSet.set(i, new Pair<>(seqOnceCtrl, alteredNormalizationCollection));
+                }
+            }
+        }
         return logicalRuleSet;
     }
 
@@ -59,5 +78,4 @@ public class BADRuleSetFactory implements IRuleSetFactory {
     public List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> getPhysicalRewrites() {
         return DefaultRuleSetFactory.buildPhysical();
     }
-
 }

http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/7cc6a84c/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelDropStatement.java
----------------------------------------------------------------------
diff --git a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelDropStatement.java b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelDropStatement.java
index 6811ef2..4c5cb93 100644
--- a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelDropStatement.java
+++ b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelDropStatement.java
@@ -44,7 +44,7 @@ import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
 import org.apache.asterix.metadata.MetadataManager;
 import org.apache.asterix.metadata.MetadataTransactionContext;
 import org.apache.asterix.metadata.declared.MetadataProvider;
-import org.apache.asterix.runtime.util.AsterixAppContextInfo;
+import org.apache.asterix.runtime.util.AppContextInfo;
 import org.apache.asterix.translator.IStatementExecutor;
 import org.apache.asterix.translator.IStatementExecutor.ResultDelivery;
 import org.apache.asterix.translator.IStatementExecutor.Stats;
@@ -128,8 +128,8 @@ public class ChannelDropStatement implements IExtensionStatement {
                 throw new AsterixException("Channel " + channelName + " is not running");
             }
 
-            ICCMessageBroker messageBroker = (ICCMessageBroker) AsterixAppContextInfo.INSTANCE.getCCApplicationContext()
-                    .getMessageBroker();
+            ICCMessageBroker messageBroker =
+                    (ICCMessageBroker) AppContextInfo.INSTANCE.getCCApplicationContext().getMessageBroker();
 
             ChannelJobInfo cInfo = listener.getJobInfo(channel.getChannelId());;
             Set<String> ncs = new HashSet<>(cInfo.getLocations());

http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/7cc6a84c/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelSubscribeStatement.java
----------------------------------------------------------------------
diff --git a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelSubscribeStatement.java b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelSubscribeStatement.java
index e038f37..85ee0fc 100644
--- a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelSubscribeStatement.java
+++ b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelSubscribeStatement.java
@@ -49,7 +49,7 @@ import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
 import org.apache.asterix.metadata.MetadataManager;
 import org.apache.asterix.metadata.MetadataTransactionContext;
 import org.apache.asterix.metadata.declared.MetadataProvider;
-import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.asterix.translator.IStatementExecutor;
 import org.apache.asterix.translator.IStatementExecutor.ResultDelivery;
 import org.apache.asterix.translator.IStatementExecutor.Stats;
@@ -169,7 +169,7 @@ public class ChannelSubscribeStatement implements IExtensionStatement {
 
                 List<Expression> UUIDList = new ArrayList<Expression>();
                 UUIDList.add(new LiteralExpr(new StringLiteral(subscriptionId)));
-                FunctionIdentifier function = AsterixBuiltinFunctions.UUID_CONSTRUCTOR;
+                FunctionIdentifier function = BuiltinFunctions.UUID_CONSTRUCTOR;
                 FunctionSignature UUIDfunc = new FunctionSignature(function.getNamespace(), function.getName(),
                         function.getArity());
                 CallExpr UUIDCall = new CallExpr(UUIDfunc, UUIDList);

http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/7cc6a84c/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelUnsubscribeStatement.java
----------------------------------------------------------------------
diff --git a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelUnsubscribeStatement.java b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelUnsubscribeStatement.java
index 17a54ec..65e6716 100644
--- a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelUnsubscribeStatement.java
+++ b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/ChannelUnsubscribeStatement.java
@@ -42,7 +42,7 @@ import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
 import org.apache.asterix.metadata.MetadataManager;
 import org.apache.asterix.metadata.MetadataTransactionContext;
 import org.apache.asterix.metadata.declared.MetadataProvider;
-import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.asterix.translator.IStatementExecutor;
 import org.apache.asterix.translator.IStatementExecutor.ResultDelivery;
 import org.apache.asterix.translator.IStatementExecutor.Stats;
@@ -143,7 +143,7 @@ public class ChannelUnsubscribeStatement implements IExtensionStatement {
             List<Expression> UUIDList = new ArrayList<Expression>();
             UUIDList.add(new LiteralExpr(new StringLiteral(subscriptionId)));
 
-            FunctionIdentifier function = AsterixBuiltinFunctions.UUID_CONSTRUCTOR;
+            FunctionIdentifier function = BuiltinFunctions.UUID_CONSTRUCTOR;
             FunctionSignature UUIDfunc = new FunctionSignature(function.getNamespace(), function.getName(),
                     function.getArity());
             CallExpr UUIDCall = new CallExpr(UUIDfunc, UUIDList);

http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/7cc6a84c/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/CreateChannelStatement.java
----------------------------------------------------------------------
diff --git a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/CreateChannelStatement.java b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/CreateChannelStatement.java
index 77de93e..0f39c31 100644
--- a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/CreateChannelStatement.java
+++ b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/CreateChannelStatement.java
@@ -68,7 +68,7 @@ import org.apache.asterix.metadata.MetadataTransactionContext;
 import org.apache.asterix.metadata.declared.MetadataProvider;
 import org.apache.asterix.metadata.entities.Function;
 import org.apache.asterix.om.base.temporal.ADurationParserFactory;
-import org.apache.asterix.runtime.util.AsterixAppContextInfo;
+import org.apache.asterix.runtime.util.AppContextInfo;
 import org.apache.asterix.runtime.util.ClusterStateManager;
 import org.apache.asterix.translator.IStatementExecutor;
 import org.apache.asterix.translator.IStatementExecutor.ResultDelivery;
@@ -282,7 +282,7 @@ public class CreateChannelStatement implements IExtensionStatement {
 
     private void setupCompiledJob(MetadataProvider metadataProvider, String dataverse, EntityId entityId,
             JobSpecification channeljobSpec, IHyracksClientConnection hcc) throws Exception {
-        ICCApplicationContext iCCApp = AsterixAppContextInfo.INSTANCE.getCCApplicationContext();
+        ICCApplicationContext iCCApp = AppContextInfo.INSTANCE.getCCApplicationContext();
         ClusterControllerInfo ccInfo = iCCApp.getCCContext().getClusterControllerInfo();
         String strIP = ccInfo.getClientNetAddress();
         int port = ccInfo.getClientNetPort();

http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/7cc6a84c/asterix-bad/src/main/java/org/apache/asterix/bad/metadata/ChannelEventsListener.java
----------------------------------------------------------------------
diff --git a/asterix-bad/src/main/java/org/apache/asterix/bad/metadata/ChannelEventsListener.java b/asterix-bad/src/main/java/org/apache/asterix/bad/metadata/ChannelEventsListener.java
index a3c757b..631acf7 100644
--- a/asterix-bad/src/main/java/org/apache/asterix/bad/metadata/ChannelEventsListener.java
+++ b/asterix-bad/src/main/java/org/apache/asterix/bad/metadata/ChannelEventsListener.java
@@ -35,7 +35,7 @@ import org.apache.asterix.bad.runtime.RepetitiveChannelOperatorDescriptor;
 import org.apache.asterix.external.feed.api.IActiveLifecycleEventSubscriber;
 import org.apache.asterix.external.feed.api.IActiveLifecycleEventSubscriber.ActiveLifecycleEvent;
 import org.apache.asterix.external.feed.management.FeedConnectionId;
-import org.apache.asterix.runtime.util.AsterixAppContextInfo;
+import org.apache.asterix.runtime.util.AppContextInfo;
 import org.apache.hyracks.api.client.IHyracksClientConnection;
 import org.apache.hyracks.api.dataflow.IOperatorDescriptor;
 import org.apache.hyracks.api.dataflow.OperatorDescriptorId;
@@ -97,7 +97,7 @@ public class ChannelEventsListener implements IActiveEntityEventsListener {
     private synchronized void handleJobFinishMessage(ChannelJobInfo cInfo) throws Exception {
         EntityId channelJobId = cInfo.getEntityId();
 
-        IHyracksClientConnection hcc = AsterixAppContextInfo.INSTANCE.getHcc();
+        IHyracksClientConnection hcc = AppContextInfo.INSTANCE.getHcc();
         JobInfo info = hcc.getJobInfo(cInfo.getJobId());
         JobStatus status = info.getStatus();
         boolean failure = status != null && status.equals(JobStatus.FAILURE);
@@ -128,7 +128,7 @@ public class ChannelEventsListener implements IActiveEntityEventsListener {
             }
         }
 
-        IHyracksClientConnection hcc = AsterixAppContextInfo.INSTANCE.getHcc();
+        IHyracksClientConnection hcc = AppContextInfo.INSTANCE.getHcc();
         JobInfo info = hcc.getJobInfo(cInfo.getJobId());
         List<String> locations = new ArrayList<>();
         for (OperatorDescriptorId channelOperatorId : channelOperatorIds) {

http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/7cc6a84c/asterix-bad/src/main/java/org/apache/asterix/bad/rules/InsertBrokerNotifierForChannelRule.java
----------------------------------------------------------------------
diff --git a/asterix-bad/src/main/java/org/apache/asterix/bad/rules/InsertBrokerNotifierForChannelRule.java b/asterix-bad/src/main/java/org/apache/asterix/bad/rules/InsertBrokerNotifierForChannelRule.java
index 89f0d20..d83b606 100644
--- a/asterix-bad/src/main/java/org/apache/asterix/bad/rules/InsertBrokerNotifierForChannelRule.java
+++ b/asterix-bad/src/main/java/org/apache/asterix/bad/rules/InsertBrokerNotifierForChannelRule.java
@@ -30,7 +30,7 @@ import org.apache.asterix.lang.common.util.FunctionUtil;
 import org.apache.asterix.metadata.declared.DatasetDataSource;
 import org.apache.asterix.om.base.AString;
 import org.apache.asterix.om.constants.AsterixConstantValue;
-import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.commons.lang3.mutable.Mutable;
 import org.apache.commons.lang3.mutable.MutableObject;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -174,8 +174,8 @@ public class InsertBrokerNotifierForChannelRule implements IAlgebraicRewriteRule
         LogicalVariable subscriptionListVar = context.newVar();
         List<LogicalVariable> aggVars = new ArrayList<LogicalVariable>();
         aggVars.add(subscriptionListVar);
-        AggregateFunctionCallExpression funAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
-                AsterixBuiltinFunctions.LISTIFY, new ArrayList<Mutable<ILogicalExpression>>());
+        AggregateFunctionCallExpression funAgg = BuiltinFunctions.makeAggregateFunctionExpression(
+                BuiltinFunctions.LISTIFY, new ArrayList<Mutable<ILogicalExpression>>());
         funAgg.getArguments()
                 .add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(subscriptionIdVar)));
         List<Mutable<ILogicalExpression>> aggExpressions = new ArrayList<Mutable<ILogicalExpression>>();
@@ -229,7 +229,7 @@ public class InsertBrokerNotifierForChannelRule implements IAlgebraicRewriteRule
                 new VariableReferenceExpression(brokerScan.getVariables().get(2)));
 
         ScalarFunctionCallExpression fieldAccessByName = new ScalarFunctionCallExpression(
-                FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME), varRef, fieldRef);
+                FunctionUtil.getFunctionInfo(BuiltinFunctions.FIELD_ACCESS_BY_NAME), varRef, fieldRef);
         ArrayList<LogicalVariable> varArray = new ArrayList<LogicalVariable>(1);
         varArray.add(brokerEndpointVar);
         ArrayList<Mutable<ILogicalExpression>> exprArray = new ArrayList<Mutable<ILogicalExpression>>(1);

http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/7cc6a84c/asterix-bad/src/main/java/org/apache/asterix/bad/runtime/NotifyBrokerRuntime.java
----------------------------------------------------------------------
diff --git a/asterix-bad/src/main/java/org/apache/asterix/bad/runtime/NotifyBrokerRuntime.java b/asterix-bad/src/main/java/org/apache/asterix/bad/runtime/NotifyBrokerRuntime.java
index 8634e4c..96b81d1 100644
--- a/asterix-bad/src/main/java/org/apache/asterix/bad/runtime/NotifyBrokerRuntime.java
+++ b/asterix-bad/src/main/java/org/apache/asterix/bad/runtime/NotifyBrokerRuntime.java
@@ -26,7 +26,7 @@ import java.nio.ByteBuffer;
 import org.apache.asterix.active.ActiveManager;
 import org.apache.asterix.active.EntityId;
 import org.apache.asterix.bad.ChannelJobService;
-import org.apache.asterix.common.api.IAsterixAppRuntimeContext;
+import org.apache.asterix.common.api.IAppRuntimeContext;
 import org.apache.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
 import org.apache.asterix.dataflow.data.nontagged.serde.AOrderedListSerializerDeserializer;
 import org.apache.asterix.dataflow.data.nontagged.serde.AStringSerializerDeserializer;
@@ -70,7 +70,7 @@ public class NotifyBrokerRuntime extends AbstractOneInputOneOutputOneFramePushRu
         eval0 = brokerEvalFactory.createScalarEvaluator(ctx);
         eval1 = subEvalFactory.createScalarEvaluator(ctx);
         eval2 = channelExecutionEvalFactory.createScalarEvaluator(ctx);
-        this.activeManager = (ActiveManager) ((IAsterixAppRuntimeContext) ctx.getJobletContext().getApplicationContext()
+        this.activeManager = (ActiveManager) ((IAppRuntimeContext) ctx.getJobletContext().getApplicationContext()
                 .getApplicationObject()).getActiveManager();
         this.entityId = activeJobId;
     }

http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/7cc6a84c/asterix-bad/src/test/java/org/apache/asterix/bad/test/BADExecutionTest.java
----------------------------------------------------------------------
diff --git a/asterix-bad/src/test/java/org/apache/asterix/bad/test/BADExecutionTest.java b/asterix-bad/src/test/java/org/apache/asterix/bad/test/BADExecutionTest.java
index 77e8afe..5d05bb4 100644
--- a/asterix-bad/src/test/java/org/apache/asterix/bad/test/BADExecutionTest.java
+++ b/asterix-bad/src/test/java/org/apache/asterix/bad/test/BADExecutionTest.java
@@ -23,7 +23,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.logging.Logger;
 
-import org.apache.asterix.common.config.AsterixTransactionProperties;
+import org.apache.asterix.common.config.TransactionProperties;
 import org.apache.asterix.test.aql.TestExecutor;
 import org.apache.asterix.test.runtime.ExecutionTestUtil;
 import org.apache.asterix.testframework.context.TestCaseContext;
@@ -50,7 +50,7 @@ public class BADExecutionTest {
 
     protected static final String TEST_CONFIG_FILE_NAME = "src/test/resources/conf/asterix-build-configuration.xml";
 
-    protected static AsterixTransactionProperties txnProperties;
+    protected static TransactionProperties txnProperties;
     private static final TestExecutor testExecutor = new TestExecutor();
     private static final boolean cleanupOnStart = true;
     private static final boolean cleanupOnStop = true;