merged -r1282:1373 from asterix_stabilization to asterix_lsm_stabilization
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_lsm_stabilization@1384 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java
index 4af1424..c5b7c41 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java
@@ -22,6 +22,7 @@
import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator;
import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DieOperator;
import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DistinctOperator;
+import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DistributeResultOperator;
import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.EmptyTupleSourceOperator;
import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.ExchangeOperator;
import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.ExtensionOperator;
@@ -396,6 +397,11 @@
}
@Override
+ public ILogicalOperator visitDistributeResultOperator(DistributeResultOperator op, ILogicalOperator arg) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public ILogicalOperator visitWriteResultOperator(WriteResultOperator op, ILogicalOperator arg) {
throw new UnsupportedOperationException();
}
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
index 512b107..053028a 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
@@ -26,7 +26,6 @@
import edu.uci.ics.asterix.optimizer.rules.ExtractOrderExpressionsRule;
import edu.uci.ics.asterix.optimizer.rules.FeedScanCollectionToUnnest;
import edu.uci.ics.asterix.optimizer.rules.FuzzyEqRule;
-import edu.uci.ics.asterix.optimizer.rules.FuzzyJoinRule;
import edu.uci.ics.asterix.optimizer.rules.IfElseToSwitchCaseFunctionRule;
import edu.uci.ics.asterix.optimizer.rules.InlineUnnestFunctionRule;
import edu.uci.ics.asterix.optimizer.rules.IntroduceDynamicTypeCastRule;
@@ -176,7 +175,7 @@
public final static List<IAlgebraicRewriteRule> buildFuzzyJoinRuleCollection() {
List<IAlgebraicRewriteRule> fuzzy = new LinkedList<IAlgebraicRewriteRule>();
- fuzzy.add(new FuzzyJoinRule());
+ // fuzzy.add(new FuzzyJoinRule()); -- The non-indexed fuzzy join will be temporarily disabled. It should be enabled some time in the near future.
fuzzy.add(new InferTypesRule());
return fuzzy;
}
diff --git a/asterix-app/data/temporal/temporalData.json b/asterix-app/data/temporal/temporalData.json
index 520fd4b..5b3a0f5 100644
--- a/asterix-app/data/temporal/temporalData.json
+++ b/asterix-app/data/temporal/temporalData.json
@@ -1,3 +1,3 @@
-{"id": "001", "dateField": date("-2012-12-12"), "dateFieldPlus": date("0990-01-01"), "timeField": time("23:49:12.39Z"), "timeFieldPlus": time("03:23:12.2"), "datetimeField": datetime("2012-12-12T00:00:00.001"), "datetimeFieldPlus": datetime("-00130810T221015398"), "durationField": duration("P20Y19DT3H74M23.34S"), "durationFieldPlus": duration("-P2MT4M300.68S"), "intervalField": dtinterval("2012-12-12T00:00:00.001,20130810T221015398") }
-{"id": "002", "datetimeField": datetime("19201220T232918478") }
-{"id": "003", "intervalPlus": tinterval("19:23:32.328Z,23:20:20") }
\ No newline at end of file
+{"id": "001", "dateField": date("-2012-12-12"), "dateFieldPlus": date("0990-01-01"), "timeField": time("23:49:12.39Z"), "timeFieldPlus": time("03:23:12.2"), "datetimeField": datetime("2012-12-12T00:00:00.001"), "datetimeFieldPlus": datetime("-00130810T221015398"), "durationField": duration("P20Y19DT3H74M23.34S"), "durationFieldPlus": duration("-P2MT4M300.68S"), "intervalField": interval-datetime("2012-12-12T00:00:00.001,20130810T221015398") }
+{"id": "002", "timeField": time("12:12:12.219+08:00"), "timeField2": time("13:13:13.321-08:00"), "datetimeField": datetime("19201220T232918478-1200"), "intervalField": interval-time("12:29:30+08:00, 235959999-0800") }
+{"id": "003", "durationField": duration("-P27Y48DT2400H"), "datetimeField": datetime("-0290-03-23T00:59:48.999+07:00"), "intervalField": interval-date("-2012-03-17, 2013-04-01"), "intervalPlus": interval-time("19:23:32.328Z,23:20:20") }
\ No newline at end of file
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
index 73353dd..98731ba 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
@@ -378,7 +378,7 @@
DisplayFormat pdf) throws Exception {
for (int i = 0; i < specs.length; i++) {
specs[i].setMaxReattempts(0);
- JobId jobId = hcc.startJob(GlobalConfig.HYRACKS_APP_NAME, specs[i]);
+ JobId jobId = hcc.startJob(specs[i]);
long startTime = System.currentTimeMillis();
hcc.waitForCompletion(jobId);
long endTime = System.currentTimeMillis();
@@ -394,7 +394,7 @@
jobs[i].getJobSpec().setMaxReattempts(0);
long startTime = System.currentTimeMillis();
try {
- JobId jobId = hcc.startJob(GlobalConfig.HYRACKS_APP_NAME, jobs[i].getJobSpec());
+ JobId jobId = hcc.startJob(jobs[i].getJobSpec());
if (jobs[i].getSubmissionMode() == SubmissionMode.ASYNCHRONOUS) {
continue;
}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/AsterixHyracksIntegrationUtil.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/AsterixHyracksIntegrationUtil.java
index 3c43736..d207acb 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/AsterixHyracksIntegrationUtil.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/AsterixHyracksIntegrationUtil.java
@@ -3,6 +3,8 @@
import java.util.EnumSet;
import edu.uci.ics.asterix.common.config.GlobalConfig;
+import edu.uci.ics.asterix.hyracks.bootstrap.CCApplicationEntryPoint;
+import edu.uci.ics.asterix.hyracks.bootstrap.NCApplicationEntryPoint;
import edu.uci.ics.hyracks.api.client.HyracksConnection;
import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
import edu.uci.ics.hyracks.api.job.JobFlag;
@@ -35,6 +37,7 @@
ccConfig.clientNetPort = DEFAULT_HYRACKS_CC_CLIENT_PORT;
ccConfig.clusterNetPort = DEFAULT_HYRACKS_CC_CLUSTER_PORT;
ccConfig.defaultMaxJobAttempts = 0;
+ ccConfig.appCCMainClass = CCApplicationEntryPoint.class.getName();
// ccConfig.useJOL = true;
cc = new ClusterControllerService(ccConfig);
cc.start();
@@ -44,7 +47,9 @@
ncConfig1.ccPort = DEFAULT_HYRACKS_CC_CLUSTER_PORT;
ncConfig1.clusterNetIPAddress = "127.0.0.1";
ncConfig1.dataIPAddress = "127.0.0.1";
+ ncConfig1.datasetIPAddress = "127.0.0.1";
ncConfig1.nodeId = NC1_ID;
+ ncConfig1.appNCMainClass = NCApplicationEntryPoint.class.getName();
nc1 = new NodeControllerService(ncConfig1);
nc1.start();
@@ -53,27 +58,19 @@
ncConfig2.ccPort = DEFAULT_HYRACKS_CC_CLUSTER_PORT;
ncConfig2.clusterNetIPAddress = "127.0.0.1";
ncConfig2.dataIPAddress = "127.0.0.1";
+ ncConfig2.datasetIPAddress = "127.0.0.1";
ncConfig2.nodeId = NC2_ID;
+ ncConfig2.appNCMainClass = NCApplicationEntryPoint.class.getName();
nc2 = new NodeControllerService(ncConfig2);
nc2.start();
hcc = new HyracksConnection(cc.getConfig().clientNetIpAddress, cc.getConfig().clientNetPort);
- hcc.createApplication(GlobalConfig.HYRACKS_APP_NAME, null);
-
}
public static IHyracksClientConnection getHyracksClientConnection() {
return hcc;
}
- public static void destroyApp() throws Exception {
- hcc.destroyApplication(GlobalConfig.HYRACKS_APP_NAME);
- }
-
- public static void createApp() throws Exception {
- hcc.createApplication(GlobalConfig.HYRACKS_APP_NAME, null);
- }
-
public static void deinit() throws Exception {
nc2.stop();
nc1.stop();
@@ -82,7 +79,7 @@
public static void runJob(JobSpecification spec) throws Exception {
GlobalConfig.ASTERIX_LOGGER.info(spec.toJSON().toString());
- JobId jobId = hcc.startJob(GlobalConfig.HYRACKS_APP_NAME, spec, EnumSet.of(JobFlag.PROFILE_RUNTIME));
+ JobId jobId = hcc.startJob(spec, EnumSet.of(JobFlag.PROFILE_RUNTIME));
GlobalConfig.ASTERIX_LOGGER.info(jobId.toString());
hcc.waitForCompletion(jobId);
}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
index e7364c7..db537be 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
@@ -1399,7 +1399,7 @@
for (int i = 0; i < jobs.length; i++) {
JobSpecification spec = jobs[i].getJobSpec();
spec.setMaxReattempts(0);
- JobId jobId = hcc.startJob(GlobalConfig.HYRACKS_APP_NAME, spec);
+ JobId jobId = hcc.startJob(spec);
hcc.waitForCompletion(jobId);
}
}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCBootstrapImpl.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
similarity index 66%
rename from asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCBootstrapImpl.java
rename to asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
index 9b29427..e755bc8 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCBootstrapImpl.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
@@ -1,17 +1,3 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * you may obtain a copy of the License from
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
package edu.uci.ics.asterix.hyracks.bootstrap;
import java.util.logging.Level;
@@ -29,14 +15,10 @@
import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
import edu.uci.ics.asterix.metadata.bootstrap.AsterixStateProxy;
import edu.uci.ics.hyracks.api.application.ICCApplicationContext;
-import edu.uci.ics.hyracks.api.application.ICCBootstrap;
+import edu.uci.ics.hyracks.api.application.ICCApplicationEntryPoint;
-/**
- * The bootstrap class of the application that will manage its life cycle at the
- * Cluster Controller.
- */
-public class CCBootstrapImpl implements ICCBootstrap {
- private static final Logger LOGGER = Logger.getLogger(CCBootstrapImpl.class.getName());
+public class CCApplicationEntryPoint implements ICCApplicationEntryPoint {
+ private static final Logger LOGGER = Logger.getLogger(CCApplicationEntryPoint.class.getName());
private static final int DEFAULT_WEB_SERVER_PORT = 19001;
@@ -45,7 +27,8 @@
private ICCApplicationContext appCtx;
@Override
- public void start() throws Exception {
+ public void start(ICCApplicationContext ccAppCtx, String[] args) throws Exception {
+ this.appCtx = ccAppCtx;
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Starting Asterix cluster controller");
}
@@ -72,11 +55,6 @@
webServer.stop();
}
- @Override
- public void setApplicationContext(ICCApplicationContext appCtx) {
- this.appCtx = appCtx;
- }
-
private void setupWebServer() throws Exception {
String portStr = System.getProperty(GlobalConfig.WEB_SERVER_PORT_PROPERTY);
int port = DEFAULT_WEB_SERVER_PORT;
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
new file mode 100644
index 0000000..59ae6f9
--- /dev/null
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
@@ -0,0 +1,131 @@
+package edu.uci.ics.asterix.hyracks.bootstrap;
+
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import edu.uci.ics.asterix.common.context.AsterixAppRuntimeContext;
+import edu.uci.ics.asterix.metadata.MetadataManager;
+import edu.uci.ics.asterix.metadata.MetadataNode;
+import edu.uci.ics.asterix.metadata.api.IAsterixStateProxy;
+import edu.uci.ics.asterix.metadata.api.IMetadataNode;
+import edu.uci.ics.asterix.metadata.bootstrap.MetadataBootstrap;
+import edu.uci.ics.asterix.transaction.management.service.recovery.IRecoveryManager;
+import edu.uci.ics.asterix.transaction.management.service.recovery.IRecoveryManager.SystemState;
+import edu.uci.ics.hyracks.api.application.INCApplicationContext;
+import edu.uci.ics.hyracks.api.application.INCApplicationEntryPoint;
+
+public class NCApplicationEntryPoint implements INCApplicationEntryPoint {
+ private static final Logger LOGGER = Logger.getLogger(NCApplicationEntryPoint.class.getName());
+
+ private INCApplicationContext ncApplicationContext = null;
+ private AsterixAppRuntimeContext runtimeContext;
+ private String nodeId;
+ private boolean isMetadataNode = false;
+ private boolean stopInitiated = false;
+
+ @Override
+ public void start(INCApplicationContext ncAppCtx, String[] args) throws Exception {
+ ncApplicationContext = ncAppCtx;
+ nodeId = ncApplicationContext.getNodeId();
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Starting Asterix node controller: " + nodeId);
+ }
+
+ runtimeContext = new AsterixAppRuntimeContext(ncApplicationContext);
+ runtimeContext.initialize();
+ ncApplicationContext.setApplicationObject(runtimeContext);
+ JVMShutdownHook sHook = new JVMShutdownHook(this);
+ Runtime.getRuntime().addShutdownHook(sHook);
+
+ //#. recover if the system is corrupted by checking system state.
+ IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
+ if (recoveryMgr.getSystemState() == SystemState.CORRUPTED) {
+ recoveryMgr.startRecovery(true);
+ }
+ recoveryMgr.checkpoint(true);
+
+ //TODO
+ //#. synchronize metadata and jobid
+ /*********************************************
+ if (isMetadataNode) {
+ //#. clean-up incomplete DDL operations, which is DDLRecovery
+ MetadataBootstrap.startDDLRecovery();
+ }
+ **********************************************/
+ }
+
+ @Override
+ public void stop() throws Exception {
+ if (!stopInitiated) {
+ stopInitiated = true;
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Stopping Asterix node controller: " + nodeId);
+ }
+
+ if (isMetadataNode) {
+ MetadataBootstrap.stopUniverse();
+ }
+ runtimeContext.deinitialize();
+ } else {
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Duplicate attempt to stop ignored: " + nodeId);
+ }
+ }
+ }
+
+ @Override
+ public void notifyStartupComplete() throws Exception {
+ IAsterixStateProxy proxy = (IAsterixStateProxy) ncApplicationContext.getDistributedState();
+ isMetadataNode = nodeId.equals(proxy.getAsterixProperties().getMetadataNodeName());
+ if (isMetadataNode) {
+ registerRemoteMetadataNode(proxy);
+
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Bootstrapping metadata");
+ }
+ MetadataManager.INSTANCE = new MetadataManager(proxy);
+ MetadataManager.INSTANCE.init();
+ MetadataBootstrap.startUniverse(proxy.getAsterixProperties(), ncApplicationContext);
+ }
+ }
+
+ public void registerRemoteMetadataNode(IAsterixStateProxy proxy) throws RemoteException {
+ IMetadataNode stub = null;
+ MetadataNode.INSTANCE.initialize(runtimeContext);
+ stub = (IMetadataNode) UnicastRemoteObject.exportObject(MetadataNode.INSTANCE, 0);
+ proxy.setMetadataNode(stub);
+
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Metadata node bound");
+ }
+ }
+
+ /**
+ * Shutdown hook that invokes {@link NCApplicationEntryPoint#stop() stop} method.
+ */
+ private static class JVMShutdownHook extends Thread {
+
+ private final NCApplicationEntryPoint ncAppEntryPoint;
+
+ public JVMShutdownHook(NCApplicationEntryPoint ncAppEntryPoint) {
+ this.ncAppEntryPoint = ncAppEntryPoint;
+ }
+
+ public void run() {
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Shutdown hook in progress");
+ }
+ try {
+ ncAppEntryPoint.stop();
+ } catch (Exception e) {
+ if (LOGGER.isLoggable(Level.WARNING)) {
+ LOGGER.warning("Exception in executing shutdown hook" + e);
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/dml/DmlTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/dml/DmlTest.java
index 5b88edb..d6fda24 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/dml/DmlTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/dml/DmlTest.java
@@ -47,9 +47,6 @@
loadReader.close();
}
asterixLoad.execute();
- AsterixHyracksIntegrationUtil.destroyApp();
-
- AsterixHyracksIntegrationUtil.createApp();
File enlistFile = new File(ENLIST_FILE);
String resultFileName = TestsUtils.aqlExtToResExt(enlistFile.getName());
File expectedFile = new File(PATH_EXPECTED + SEPARATOR + resultFileName);
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/time_order.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/time_order.aql
index ba0d211..df9966e 100644
--- a/asterix-app/src/test/resources/runtimets/queries/comparison/time_order.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/time_order.aql
@@ -7,7 +7,7 @@
let $t1 := time("13:00:00.382-10:00")
let $t2 := time("23:59:59.999Z")
let $t3 := time("22:00:00+03:00")
-let $t4 := time("00:00:00.00Z")
+let $t4 := time("00:00:00.00")
let $t5 := time("00:00:00.00-02:00")
let $t6 := time("00:00:00.47+04:00")
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/date_01.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/date_01.aql
index 9bbfb9d..821854c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/constructor/date_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/date_01.aql
@@ -12,6 +12,8 @@
let $c6 := date("-2043-11-19")
let $c7 := date("-19280329")
let $c8 := date("19280329")
+let $c9 := date("19000228")
+let $c10 := date("20000229")
-return {"date1": $c1, "date2": $c2, "date3": $c3, "date4": $c4, "date5": $c5, "date6": $c6, "date7": $c7, "date8": $c8}
+return {"date1": $c1, "date2": $c2, "date3": $c3, "date4": $c4, "date5": $c5, "date6": $c6, "date7": $c7, "date8": $c8, "date9": $c9, "date10": $c10}
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/interval.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/interval.aql
index 71e90fa..e116984 100644
--- a/asterix-app/src/test/resources/runtimets/queries/constructor/interval.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/interval.aql
@@ -5,10 +5,10 @@
write output to nc1:"rttest/constructor_interval.adm";
let $itv1 := interval-from-date("2010-10-30", "2012-10-21")
-let $itv2 := interval-from-time("03:04:05.678", "232425267")
-let $itv3 := interval-from-datetime("-1987-11-19T02:43:57.938", "1999-11-12T12:49:35.948")
+let $itv2 := interval-from-time("03:04:05.678-11:00", "232425267+0200")
+let $itv3 := interval-from-datetime("-1987-11-19T02:43:57.938+08:00", "19991112T124935948-0700")
let $itv4 := interval-start-from-date("0001-12-27", "P3Y394DT48H398.483S")
-let $itv5 := interval-start-from-time("20:03:20.948", "PT48M389.938S")
+let $itv5 := interval-start-from-time("20:03:20.948", "P60DT48M389.938S")
let $itv6 := interval-start-from-datetime("-2043-11-19T15:32:39.293", "P439Y3M20DT20H39M58.949S")
return {"interval1": $itv1, "interval2": $itv2, "interval3": $itv3, "interval4": $itv4, "interval5": $itv5, "interval6": $itv6}
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/time_01.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/time_01.aql
index 4a040a1..995215d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/constructor/time_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/time_01.aql
@@ -14,6 +14,6 @@
let $c8 := time("12:59:00.01-01:00")
let $c9 := time("12:59:00.019-01:00")
let $c10 := time("12590001-0100")
-let $c11 := time("125900019-0100")
+let $c11 := time("125900019+0100")
return {"time1": $c1, "time2": $c2, "time3": $c3, "time4": $c4, "time5": $c5, "time6": $c6, "time7": $c7, "time8": $c8, "time9": $c9, "time10": $c10, "time11": $c11}
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv20.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv20.aql
new file mode 100644
index 0000000..beebca4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/cross-dv20.aql
@@ -0,0 +1,50 @@
+/*
+ * Description : Test various syntax for dataset access
+ * : Using parentheses for dataset access is now optional
+ * : New syntax can use fully qualified names to access datasets.
+ * Expected Res : Success
+ * Date : 6th March 2013
+ */
+
+drop dataverse student if exists;
+drop dataverse teacher if exists;
+
+create dataverse student;
+create dataverse teacher;
+
+write output to nc1:"rttest/cross-dataverse_cross-dv20.adm";
+
+create type student.stdType as open {
+id : int32,
+name : string,
+age : int32,
+sex : string,
+dept : string
+}
+
+create type teacher.tchrType as open {
+id : int32,
+name : string,
+age : int32,
+sex : string,
+dept : string
+}
+
+create dataset student.ugdstd(stdType) primary key id;
+create dataset student.gdstd(stdType) primary key id;
+create dataset teacher.prof(tchrType) primary key id;
+create dataset teacher.pstdoc(tchrType) primary key id;
+
+insert into dataset student.ugdstd({"id":457,"name":"John Doe","age":22,"sex":"M","dept":"Dance"});
+
+insert into dataset student.gdstd({"id":418,"name":"John Smith","age":26,"sex":"M","dept":"Economics"});
+
+insert into dataset teacher.prof({"id":152,"name":"John Meyer","age":42,"sex":"M","dept":"History"});
+
+insert into dataset teacher.pstdoc({"id":259,"name":"Sophia Reece","age":36,"sex":"F","dept":"Anthropology"});
+
+for $s in dataset student.ugdstd
+for $p in dataset('teacher.prof')
+for $a in dataset("student.gdstd")
+for $b in dataset teacher.pstdoc
+return {"ug-student":$s,"prof":$p,"grd-student":$a,"postdoc":$b}
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/delete-syntax-change.aql b/asterix-app/src/test/resources/runtimets/queries/dml/delete-syntax-change.aql
new file mode 100644
index 0000000..fb9682d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/delete-syntax-change.aql
@@ -0,0 +1,43 @@
+/*
+ * Description : Test variant syntax for delete
+ * : Ending semi-colon is optional for delete
+ * Expected Res : Success
+ * Date : 6th March 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type LineItemType as closed {
+ l_orderkey: int32,
+ l_partkey: int32,
+ l_suppkey: int32,
+ l_linenumber: int32,
+ l_quantity: int32,
+ l_extendedprice: double,
+ l_discount: double,
+ l_tax: double,
+ l_returnflag: string,
+ l_linestatus: string,
+ l_shipdate: string,
+ l_commitdate: string,
+ l_receiptdate: string,
+ l_shipinstruct: string,
+ l_shipmode: string,
+ l_comment: string
+}
+
+create dataset LineItem(LineItemType)
+ primary key l_orderkey, l_linenumber;
+
+load dataset LineItem
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
+
+delete $l from dataset LineItem where $l.l_orderkey>=10
+
+write output to nc1:"rttest/dml_delete-syntax-change.adm";
+for $c in dataset('LineItem')
+order by $c.l_orderkey, $c.l_linenumber
+return $c
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-syntax.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-syntax.aql
new file mode 100644
index 0000000..58177d3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-syntax.aql
@@ -0,0 +1,35 @@
+/*
+ * Test case Name : insert-syntax-change.aql
+ * Description : verify various AQL syntax for insert
+ * Expected Result : Success
+ * Date : 6th March 2013
+ */
+
+drop dataverse testdv2 if exists;
+create dataverse testdv2;
+use dataverse testdv2;
+
+create type testtype as open {
+ id: int32,
+ name: string
+}
+
+create dataset testds(testtype) primary key id;
+
+ insert into dataset testds (
+ { "id": 1, "name": "Person One", "hobbies": {{"Rock", "Metal"}}}
+ );
+
+ insert into dataset testds (
+ { "id": 2, "name": "Person Two", "hobbies": {{"Rock", "Jazz"}}}
+ )
+
+ insert into dataset testds { "id": 3, "name": "Person Three", "hobbies": {{"Blues"}}};
+
+ insert into dataset testds { "id": 4, "name": "Person Four", "hobbies": {{"Metal", "Jazz"}}}
+
+write output to nc1:"rttest/dml_insert-syntax.adm";
+
+for $d in dataset("testds")
+order by $d.id
+return $d
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_1.aql
index dd88883..4e6d919 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-aqlplus_1.aql
@@ -24,6 +24,6 @@
for $dblp in dataset('DBLP')
for $dblp2 in dataset('DBLP')
-where $dblp.title ~= $dblp2.title and $dblp.id < $dblp2.id
+where word-tokens($dblp.title) ~= word-tokens($dblp2.title) and $dblp.id < $dblp2.id
order by $dblp.id, $dblp2.id
return {'dblp': $dblp, 'dblp2': $dblp2}
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_1.aql
index 0195185..36c231f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_1.aql
@@ -37,6 +37,6 @@
for $i in dataset('DBLP')
for $j in dataset('CSX')
-where $i.title ~= $j.title
+where word-tokens($i.title) ~= word-tokens($j.title)
order by $i.id, $j.id
return {'dblp': $i, 'csx': $j}
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_2.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_2.aql
index 085d139..1213a68 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_2.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_2.aql
@@ -37,6 +37,6 @@
for $csx in dataset('CSX')
for $dblp in dataset('DBLP')
-where $dblp.title ~= $csx.title
+where word-tokens($dblp.title) ~= word-tokens($csx.title)
order by $dblp.id, $csx.id
return {'dblp': $dblp, 'csx': $csx}
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_3.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_3.aql
index d379cc4..41de9cd 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-aqlplus_3.aql
@@ -37,6 +37,6 @@
for $dblp in dataset('DBLP')
for $csx in dataset('CSX')
-where $csx.title ~= $dblp.title
+where word-tokens($csx.title) ~= word-tokens($dblp.title)
order by $dblp.id, $csx.id
return {'dblp': $dblp, 'csx': $csx}
diff --git a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-dblp-aqlplus_1.aql b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-dblp-aqlplus_1.aql
index cb774be..19c40d9 100644
--- a/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-dblp-aqlplus_1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/fuzzyjoin/dblp-csx-dblp-aqlplus_1.aql
@@ -38,6 +38,6 @@
for $dblp in dataset('DBLP')
for $csx in dataset('CSX')
for $dblp2 in dataset('DBLP')
-where $dblp.title ~= $csx.title and $csx.authors ~= $dblp2.authors
+where word-tokens($dblp.title) ~= word-tokens($csx.title) and word-tokens($csx.authors) ~= word-tokens($dblp2.authors)
order by $dblp.id, $csx.id, $dblp2.id
return {'dblp': $dblp, 'csx': $csx, 'dblp2': $dblp2}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/abs3.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/abs3.aql
index 4364409..8e947de 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/abs3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/abs3.aql
@@ -12,5 +12,6 @@
let $c4 := double("-INF")
let $c5 := double("-0.0")
let $c6 := double("0.0")
+let $c7 := double("-6223372036854775807.89239")
return {"d0": numeric-abs($c0), "d1": numeric-abs($c1),"d2": numeric-abs($c2),
- "d3": numeric-abs($c3),"d4": numeric-abs($c4),"d5": numeric-abs($c5), "d6": numeric-abs($c6)}
+ "d3": numeric-abs($c3),"d4": numeric-abs($c4),"d5": numeric-abs($c5), "d6": numeric-abs($c6), "d7": numeric-abs($c7)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/abs4.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/abs4.aql
index b2db5fd..03d145f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/abs4.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/abs4.aql
@@ -5,4 +5,4 @@
write output to nc1:"rttest/numeric_abs4.adm";
let $c0 := int8("-20")
-return {"f0": numeric-abs($c0), "f1": numeric-abs(-1.11),"f2": numeric-abs(12.9), "f3": numeric-abs(1.11)}
+return {"f0": numeric-abs($c0), "f1": numeric-abs(-1.11),"f2": numeric-abs(12.9), "f3": numeric-abs(1.11), "f4": numeric-abs(null)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/ceiling3.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/ceiling3.aql
index 67ad9db..a47d696 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/ceiling3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/ceiling3.aql
@@ -12,5 +12,6 @@
let $c4 := double("-INF")
let $c5 := double("-0.0")
let $c6 := double("0.0")
+let $c7 := double("-6223372036854775807.89239")
return {"d0": numeric-ceiling($c0), "d1": numeric-ceiling($c1),"d2": numeric-ceiling($c2),
- "d3": numeric-ceiling($c3),"d4": numeric-ceiling($c4),"d5": numeric-ceiling($c5), "d6": numeric-ceiling($c6)}
+ "d3": numeric-ceiling($c3),"d4": numeric-ceiling($c4),"d5": numeric-ceiling($c5), "d6": numeric-ceiling($c6), "d7": numeric-ceiling($c7)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/ceiling4.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/ceiling4.aql
index a90851c..860c586 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/ceiling4.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/ceiling4.aql
@@ -5,4 +5,4 @@
write output to nc1:"rttest/numeric_ceiling4.adm";
let $c0 := int8("-20")
-return {"f0": numeric-ceiling($c0), "f1": numeric-ceiling(-1.11),"f2": numeric-ceiling(12.9), "f3": numeric-ceiling(1.11)}
+return {"f0": numeric-ceiling($c0), "f1": numeric-ceiling(-1.11),"f2": numeric-ceiling(12.9), "f3": numeric-ceiling(1.11), "f4": numeric-ceiling(null)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/floor3.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/floor3.aql
index d975dfc..9478448 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/floor3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/floor3.aql
@@ -12,5 +12,6 @@
let $c4 := double("-INF")
let $c5 := double("-0.0")
let $c6 := double("0.0")
+let $c7 := double("-6223372036854775807.89239")
return {"d0": numeric-floor($c0), "d1": numeric-floor($c1),"d2": numeric-floor($c2),
- "d3": numeric-floor($c3),"d4": numeric-floor($c4),"d5": numeric-floor($c5), "d6": numeric-floor($c6)}
+ "d3": numeric-floor($c3),"d4": numeric-floor($c4),"d5": numeric-floor($c5), "d6": numeric-floor($c6), "d7": numeric-floor($c7)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/floor4.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/floor4.aql
index eae917d..7d51da7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/floor4.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/floor4.aql
@@ -5,4 +5,4 @@
write output to nc1:"rttest/numeric_floor4.adm";
let $c0 := int8("-20")
-return {"f0": numeric-floor($c0), "f1": numeric-floor(-1.11),"f2": numeric-floor(12.9), "f3": numeric-floor(1.11)}
+return {"f0": numeric-floor($c0), "f1": numeric-floor(-1.11),"f2": numeric-floor(12.9), "f3": numeric-floor(1.11), "f4": numeric-floor(null)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even23.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even23.aql
index cbbcd10..5d401bd 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even23.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even23.aql
@@ -12,5 +12,6 @@
let $c4 := double("-INF")
let $c5 := double("-0.0")
let $c6 := double("0.0")
+let $c7 := double("-6223372036854775807.89239")
return {"d0": numeric-round-half-to-even2($c0,2), "d1": numeric-round-half-to-even2($c1,2),"d2": numeric-round-half-to-even2($c2,3),
- "d3": numeric-round-half-to-even2($c3,4),"d4": numeric-round-half-to-even2($c4,5),"d5": numeric-round-half-to-even2($c5,6), "d6": numeric-round-half-to-even2($c6,0)}
+ "d3": numeric-round-half-to-even2($c3,4),"d4": numeric-round-half-to-even2($c4,5),"d5": numeric-round-half-to-even2($c5,6), "d6": numeric-round-half-to-even2($c6,0), "d7": numeric-round-half-to-even2($c7, -2)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even24.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even24.aql
index 8fe21fe..a112281 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even24.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even24.aql
@@ -10,5 +10,5 @@
let $c2 := double("3.567812E+3")
let $c3 := double("4.7564E-3")
let $c4 := double("35612.25")
-return {"d0": numeric-round-half-to-even2($c0,2), "d1": numeric-round-half-to-even2($c1,2),"d2": numeric-round-half-to-even2($c2,2),
- "d3": numeric-round-half-to-even2($c3,2),"d4": numeric-round-half-to-even2($c4,-2)}
+return {"d0": numeric-round-half-to-even2($c0, 2), "d1": numeric-round-half-to-even2($c1, 2),"d2": numeric-round-half-to-even2($c2, 2),
+ "d3": numeric-round-half-to-even2($c3, 2),"d4": numeric-round-half-to-even2($c4, -2), "d5": numeric-round-half-to-even2(null, -2)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even3.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even3.aql
index 6d10ae1..8024e68 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even3.aql
@@ -12,5 +12,6 @@
let $c4 := double("-INF")
let $c5 := double("-0.0")
let $c6 := double("0.0")
+let $c7 := double("-6223372036854775807.89239")
return {"d0": numeric-round-half-to-even($c0), "d1": numeric-round-half-to-even($c1), "d2": numeric-round-half-to-even($c2),
- "d3": numeric-round-half-to-even($c3), "d4": numeric-round-half-to-even($c4), "d5": numeric-round-half-to-even($c5), "d6": numeric-round-half-to-even($c6)}
+ "d3": numeric-round-half-to-even($c3), "d4": numeric-round-half-to-even($c4), "d5": numeric-round-half-to-even($c5), "d6": numeric-round-half-to-even($c6), "d7": numeric-round-half-to-even($c7)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even5.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even5.aql
index b89388f..bfa308f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even5.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/round-half-to-even5.aql
@@ -5,4 +5,4 @@
write output to nc1:"rttest/numeric_round-half-to-even5.adm";
let $c0 := int8("-20")
-return {"f0": numeric-round-half-to-even($c0), "f1": numeric-round-half-to-even(-1.5),"f2": numeric-round-half-to-even(12.5), "f3": numeric-round-half-to-even(1.5)}
+return {"f0": numeric-round-half-to-even($c0), "f1": numeric-round-half-to-even(-1.5),"f2": numeric-round-half-to-even(12.5), "f3": numeric-round-half-to-even(1.5), "f4": numeric-round-half-to-even(null)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/round3.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/round3.aql
index 54e2685..c5b752a 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/round3.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/round3.aql
@@ -12,5 +12,6 @@
let $c4 := double("-INF")
let $c5 := double("-0.0")
let $c6 := double("0.0")
+let $c7 := double("-6223372036854775807.89239")
return {"d0": numeric-round($c0), "d1": numeric-round($c1),"d2": numeric-round($c2),
- "d3": numeric-round($c3),"d4": numeric-round($c4),"d5": numeric-round($c5), "d6": numeric-round($c6)}
+ "d3": numeric-round($c3),"d4": numeric-round($c4),"d5": numeric-round($c5), "d6": numeric-round($c6), "d7": numeric-round($c7)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/round4.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/round4.aql
index 5dccfd7..9c2faf3 100644
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/round4.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/numeric/round4.aql
@@ -5,4 +5,4 @@
write output to nc1:"rttest/numeric_round4.adm";
let $c0 := int8("-20")
-return {"f0": numeric-round($c0), "f1": numeric-round(-1.11),"f2": numeric-round(12.9), "f3": numeric-round(1.11)}
+return {"f0": numeric-round($c0), "f1": numeric-round(-1.11),"f2": numeric-round(12.9), "f3": numeric-round(1.11), "f4": numeric-round(null)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/scan/alltypes_02.aql b/asterix-app/src/test/resources/runtimets/queries/scan/alltypes_02.aql
new file mode 100644
index 0000000..7f01c3e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/scan/alltypes_02.aql
@@ -0,0 +1,48 @@
+/*
+ * Description : Test variant syntax for dataset access (scan)
+ * : using parentheses and quotes is optional
+ * Expected Res : Success
+ * Date : 6th March 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as open {
+ number: int32,
+ street: string,
+ city: string
+}
+
+create type AllType as open {
+ id: int32,
+ name: string,
+ age: float,
+ salary: double,
+ married: boolean,
+ interests: {{string}},
+ children: [string],
+ address: AddressType,
+ dob: date,
+ time: time,
+ datetime: datetime,
+ duration: duration,
+ location2d: point,
+ location3d: point3d,
+ line: line,
+ polygon: polygon,
+ circle: circle
+
+ // binary
+ // union
+}
+
+create external dataset All(AllType)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/nontagged/allData.json"),("format"="adm"));
+
+write output to nc1:"rttest/scan_alltypes_02.adm";
+
+for $a in dataset All
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/scan/invalid-scan-syntax.aql b/asterix-app/src/test/resources/runtimets/queries/scan/invalid-scan-syntax.aql
new file mode 100644
index 0000000..254ecc4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/scan/invalid-scan-syntax.aql
@@ -0,0 +1,22 @@
+/*
+ * Description : Tests syntax error for the changed dataset access syntax
+ * Expected Result: Syntax Error from parser
+ * Date: March 6th 2013
+ */
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Employee as closed {
+id: int32,
+name: string,
+salary: int32
+}
+
+create dataset Office(Employee)
+primary key id;
+
+insert into dataset Office({"id": 1, "name": "clerk#1", "salary":120000});
+
+for $t in dataset 'test.Office'
+return $t
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches11.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches11.aql
index 1e96b5f..8b9d3be 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/matches11.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches11.aql
@@ -11,6 +11,8 @@
matches("hello","helllo"),
matches("hello"," "),
matches(null,"hello"),
+matches(null, ""),
+matches(null, null),
matches("hello","[^a-z]")]
return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/replace1.aql b/asterix-app/src/test/resources/runtimets/queries/string/replace1.aql
index 3a9e932..419fe4b 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/replace1.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/replace1.aql
@@ -7,4 +7,6 @@
let $c1 := replace("abracadabra", "a", "")
let $c2 := replace("abracadabra", "a(.)", "a$1$1")
let $c3 := replace("darted", "^(.*?)d(.*)$", "$1c$2")
-return {"result1": $c1, "result2": $c2, "result3": $c3}
+let $c4 := replace("hello", "", "-")
+let $c5 := replace(null, "*", "-")
+return {"result1": $c1, "result2": $c2, "result3": $c3, "result4": $c4, "result5": $c5}
diff --git a/asterix-app/src/test/resources/runtimets/queries/temp/calendar_duration.aql b/asterix-app/src/test/resources/runtimets/queries/temp/calendar_duration.aql
deleted file mode 100644
index 67360ce..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/temp/calendar_duration.aql
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Description : Check the calendar-duration functions
- * Expected Result : Success
- * Date : 15th Oct, 2012
- */
-
-drop dataverse test if exists;
-create dataverse test;
-use dataverse test;
-
-write output to nc1:"rttest/temp_calendar_duration.adm";
-
-let $t1 := datetime("1987-11-19T23:49:23.938")
-let $t2 := date("-1328-10-23")
-let $dr1 := duration("P7382DT39283M3921.329S")
-let $dr2 := duration("-PT63H398212M3219.328S")
-let $dr3 := duration("P1Y90M")
-let $dr4 := duration("-P3Y89M4089DT47382.983S")
-let $cdr1 := calendar-duration-from-datetime($t1, $dr1)
-let $cdr2 := calendar-duration-from-datetime($t1, $dr2)
-let $cdr3 := calendar-duration-from-datetime($t1, $dr3)
-let $cdr4 := calendar-duration-from-datetime($t1, $dr4)
-let $cdr5 := calendar-duration-from-date($t2, $dr1)
-let $cdr6 := calendar-duration-from-date($t2, $dr2)
-let $cdr7 := calendar-duration-from-date($t2, $dr3)
-let $cdr8 := calendar-duration-from-date($t2, $dr4)
-
-return { "cduration1":$cdr1, "cduration2":$cdr2, "cduration3":$cdr3, "cduration4":$cdr4, "cduration5":$cdr5, "cduration6":$cdr6, "cduration7":$cdr7, "cduration8":$cdr8 }
diff --git a/asterix-app/src/test/resources/runtimets/queries/temp/accessors.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors.aql
similarity index 95%
rename from asterix-app/src/test/resources/runtimets/queries/temp/accessors.aql
rename to asterix-app/src/test/resources/runtimets/queries/temporal/accessors.aql
index 9cc9f8d..7830438 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temp/accessors.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors.aql
@@ -8,7 +8,7 @@
create dataverse test;
use dataverse test;
-write output to nc1:"rttest/temp_accessors.adm";
+write output to nc1:"rttest/temporal_accessors.adm";
let $c1 := date("2010-10-30")
let $c2 := datetime("1987-11-19T23:49:23.938")
diff --git a/asterix-app/src/test/resources/runtimets/queries/temp/adjust_timezone.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/adjust_timezone.aql
similarity index 88%
rename from asterix-app/src/test/resources/runtimets/queries/temp/adjust_timezone.aql
rename to asterix-app/src/test/resources/runtimets/queries/temporal/adjust_timezone.aql
index 9f6c60e..13c2487 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temp/adjust_timezone.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/adjust_timezone.aql
@@ -8,7 +8,7 @@
create dataverse test;
use dataverse test;
-write output to nc1:"rttest/temp_adjust_timezone.adm";
+write output to nc1:"rttest/temporal_adjust_timezone.adm";
let $t1 := time("20:15:10.327")
let $dt1 := datetime("2010-10-23T01:12:13.329Z")
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/calendar_duration.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/calendar_duration.aql
new file mode 100644
index 0000000..2d0c91b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/calendar_duration.aql
@@ -0,0 +1,52 @@
+/*
+ * Description : Check the calendar-duration functions
+ * Expected Result : Success
+ * Date : 15th Oct, 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/temporal_calendar_duration.adm";
+
+let $t1 := datetime("1987-11-19T23:49:23.938")
+let $t2 := date("-1328-10-23")
+let $dr1 := duration("P7382DT39283M3921.329S")
+let $dr2 := duration("-PT63H398212M3219.328S")
+let $dr3 := duration("P1Y90M")
+let $dr4 := duration("-P3Y89M4089DT47382.983S")
+let $cdr1 := calendar-duration-from-datetime($t1, $dr1)
+let $dt1 := add-datetime-duration($t1, $dr1)
+let $dtt1 := add-datetime-duration($t1, $cdr1)
+let $c1 := $dt1 = $dtt1
+let $cdr2 := calendar-duration-from-datetime($t1, $dr2)
+let $dt2 := add-datetime-duration($t1, $dr2)
+let $dtt2 := add-datetime-duration($t1, $cdr2)
+let $c2 := $dt2 = $dtt2
+let $cdr3 := calendar-duration-from-datetime($t1, $dr3)
+let $dt3 := add-datetime-duration($t1, $dr3)
+let $dtt3 := add-datetime-duration($t1, $cdr3)
+let $c3 := $dt3 = $dtt3
+let $cdr4 := calendar-duration-from-datetime($t1, $dr4)
+let $dt4 := add-datetime-duration($t1, $dr4)
+let $dtt4 := add-datetime-duration($t1, $cdr4)
+let $c4 := $dt4 = $dtt4
+let $cdr5 := calendar-duration-from-date($t2, $dr1)
+let $dt5 := add-date-duration($t2, $dr1)
+let $dtt5 := add-date-duration($t2, $cdr5)
+let $c5 := $dt5 = $dtt5
+let $cdr6 := calendar-duration-from-date($t2, $dr2)
+let $dt6 := add-date-duration($t2, $dr2)
+let $dtt6 := add-date-duration($t2, $cdr6)
+let $c6 := $dt6 = $dtt6
+let $cdr7 := calendar-duration-from-date($t2, $dr3)
+let $dt7 := add-date-duration($t2, $dr3)
+let $dtt7 := add-date-duration($t2, $cdr7)
+let $c7 := $dt7 = $dtt7
+let $cdr8 := calendar-duration-from-date($t2, $dr4)
+let $dt8 := add-date-duration($t2, $dr4)
+let $dtt8 := add-date-duration($t2, $cdr8)
+let $c8 := $dt8 = $dtt8
+
+return { "cduration1":$cdr1, "c1":$c1, "cduration2":$cdr2, "c2":$c2, "cduration3":$cdr3, "c3":$c3, "cduration4":$cdr4, "c4":$c4, "cduration5":$cdr5, "c5":$c5, "cduration6":$cdr6, "c6":$c6, "cduration7":$cdr7, "c7":$c7, "cduration8":$cdr8, "c8":$c8 }
diff --git a/asterix-app/src/test/resources/runtimets/queries/temp/date_functions.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions.aql
similarity index 72%
rename from asterix-app/src/test/resources/runtimets/queries/temp/date_functions.aql
rename to asterix-app/src/test/resources/runtimets/queries/temporal/date_functions.aql
index 310fa43..4f9ef5c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temp/date_functions.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions.aql
@@ -7,7 +7,7 @@
create dataverse test;
use dataverse test;
-write output to nc1:"rttest/temp_date_functions.adm";
+write output to nc1:"rttest/temporal_date_functions.adm";
let $d1 := date-from-unix-time-in-days(15600)
let $dt1 := datetime("1327-12-02T23:35:49.938Z")
@@ -16,9 +16,11 @@
let $d3 := date-from-datetime($dt2)
let $dr1 := duration("-P2Y1M90DT30H")
let $d4 := add-date-duration($d1, $dr1)
+let $c1 := $d1 = add-date-duration($d4, subtract-date($d1, $d4))
let $dr2 := duration("P300Y900MT360000M")
let $d5 := add-date-duration($d2, $dr2)
+let $c2 := $d2 = add-date-duration($d5, subtract-date($d2, $d5))
let $dr3 := subtract-date($d5, $d2)
let $dr4 := subtract-date($d4, $d1)
-return { "date1" : $d1, "date2" : $d2, "date3" : $d3, "date4" : $d4, "date5" : $d5, "duration1" : $dr3, "duration2" : $dr4 }
\ No newline at end of file
+return { "date1" : $d1, "date2" : $d2, "date3" : $d3, "date4" : $d4, "date5" : $d5, "duration1" : $dr3, "duration2" : $dr4, "c1" : $c1, "c2" : $c2 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temp/datetime_functions.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions.aql
similarity index 70%
rename from asterix-app/src/test/resources/runtimets/queries/temp/datetime_functions.aql
rename to asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions.aql
index a70c9f2..cc68789 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temp/datetime_functions.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions.aql
@@ -8,13 +8,14 @@
create dataverse test;
use dataverse test;
-write output to nc1:"rttest/temp_datetime_functions.adm";
+write output to nc1:"rttest/temporal_datetime_functions.adm";
let $dt1 := datetime-from-unix-time-in-ms(956007429)
let $d1 := date("1327-12-02")
-let $t1 := time("23:35:49.938Z")
+let $t1 := time("15:35:49.938-0800")
let $dt2 := datetime-from-date-time($d1, $t1)
let $dr1 := subtract-datetime($dt2, $dt1)
let $dt3 := add-datetime-duration($dt1, $dr1)
+let $c1 := $dt1 = add-datetime-duration($dt3, subtract-datetime($dt1, $dt3))
-return { "datetime1" : $dt1, "datetime2" : $dt2, "datetime3" : $dt3, "duration1" : $dr1 }
\ No newline at end of file
+return { "datetime1" : $dt1, "datetime2" : $dt2, "datetime3" : $dt3, "duration1" : $dr1, "c1" : $c1 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temp/insert_from_delimited_ds.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_delimited_ds.aql
similarity index 91%
rename from asterix-app/src/test/resources/runtimets/queries/temp/insert_from_delimited_ds.aql
rename to asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_delimited_ds.aql
index 4520f46..344db02 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temp/insert_from_delimited_ds.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_delimited_ds.aql
@@ -16,7 +16,7 @@
durationField: duration
}
-write output to nc1:"rttest/temp_insert_from_delimited_ds.adm";
+write output to nc1:"rttest/temporal_insert_from_delimited_ds.adm";
create external dataset testds(testtype)
using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/temp/insert_from_ext_ds.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_ext_ds.aql
similarity index 92%
rename from asterix-app/src/test/resources/runtimets/queries/temp/insert_from_ext_ds.aql
rename to asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_ext_ds.aql
index 5813696..0a3903f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temp/insert_from_ext_ds.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/insert_from_ext_ds.aql
@@ -17,7 +17,7 @@
intervalField: interval?
}
-write output to nc1:"rttest/temp_insert_from_ext_ds.adm";
+write output to nc1:"rttest/temporal_insert_from_ext_ds.adm";
create external dataset testds(testtype)
using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
diff --git a/asterix-app/src/test/resources/runtimets/queries/temp/interval_functions.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_functions.aql
similarity index 76%
rename from asterix-app/src/test/resources/runtimets/queries/temp/interval_functions.aql
rename to asterix-app/src/test/resources/runtimets/queries/temporal/interval_functions.aql
index a29f7f5..5831468 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temp/interval_functions.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_functions.aql
@@ -8,11 +8,11 @@
create dataverse test;
use dataverse test;
-write output to nc1:"rttest/temp_interval_functions.adm";
+write output to nc1:"rttest/temporal_interval_functions.adm";
let $itv1 := interval-from-date("2010-10-30", "2010-12-21")
let $itv2 := interval-from-date("2011-10-30", "2012-10-21")
-let $itv3 := interval-from-date("2010-06-30", "2013-01-01")
+let $itv3 := interval-from-date("2010-12-21", "2013-01-01")
let $blnBefore1 := interval-before($itv1, $itv2)
let $blnAfter1 := interval-after($itv2, $itv1)
let $blnBefore2 := interval-before($itv1, $itv3)
@@ -28,11 +28,11 @@
let $itv7 := interval-from-time("12:32:38", "20:29:20")
let $itv8 := interval-from-time("17:48:19", "22:19:49")
-let $itv9 := interval-from-time("01:32:49", "12:33:00")
+let $itv9 := interval-from-time("01:32:49", "17:48:19")
let $blnOverlaps1 := interval-overlaps($itv7, $itv8)
let $blnOverlapped1 := interval-overlapped-by($itv8, $itv7)
-let $blnOverlaps2 := interval-overlaps($itv8, $itv7)
-let $blnOverlapped2 := interval-overlapped-by($itv7, $itv8)
+let $blnOverlaps2 := interval-overlaps($itv9, $itv8)
+let $blnOverlapped2 := interval-overlapped-by($itv8, $itv9)
let $blnOverlap1 := overlap($itv9, $itv7)
let $blnOverlap2 := overlap($itv9, $itv8)
@@ -42,10 +42,13 @@
let $blnStartedBy1 := interval-started-by($itv1, $itv10)
let $blnStartedBy2 := interval-started-by($itv10, $itv2)
-let $blnCovers1 := interval-covers($itv6, $itv4)
-let $blnCovers2 := interval-covers($itv6, $itv5)
-let $blnCoveredBy1 := interval-covered-by($itv4, $itv6)
-let $blnCoveredBy2 := interval-covered-by($itv5, $itv6)
+let $itv10 := interval-from-datetime("19000707T020202222", "2013-08-07T03:03:03.333")
+let $itv11 := interval-from-datetime("19990707T020202222", "2013-08-07T03:03:03.333")
+let $itv12 := interval-from-datetime("-19990707T020202222", "2013-08-07T03:03:03.333")
+let $blnCovers1 := interval-covers($itv10, $itv11)
+let $blnCovers2 := interval-covers($itv10, $itv12)
+let $blnCoveredBy1 := interval-covered-by($itv11, $itv10)
+let $blnCoveredBy2 := interval-covered-by($itv12, $itv10)
let $itv11 := interval-from-time("19:00:00.009", "20:29:20.000")
let $blnEnds1 := interval-ends($itv11, $itv7)
diff --git a/asterix-app/src/test/resources/runtimets/queries/temp/time_functions.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions.aql
similarity index 74%
rename from asterix-app/src/test/resources/runtimets/queries/temp/time_functions.aql
rename to asterix-app/src/test/resources/runtimets/queries/temporal/time_functions.aql
index 29adcc0..c1d39fc 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temp/time_functions.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions.aql
@@ -8,7 +8,7 @@
create dataverse test;
use dataverse test;
-write output to nc1:"rttest/temp_time_functions.adm";
+write output to nc1:"rttest/temporal_time_functions.adm";
let $t1 := time-from-unix-time-in-ms(1560074)
let $dt1 := datetime("1327-12-02T23:35:49.938Z")
@@ -17,12 +17,14 @@
let $t3 := time-from-datetime($dt2)
let $dr1 := duration("-PT30H")
let $t4 := add-time-duration($t1, $dr1)
+let $c1 := $t1 = add-time-duration($t4, subtract-time($t1, $t4))
let $dr2 := duration("PT36M")
let $t5 := add-time-duration($t2, $dr2)
+let $c2 := $t2 = add-time-duration($t5, subtract-time($t2, $t5))
let $dr3 := subtract-time($t5, $t2)
let $dr4 := subtract-time($t4, $t1)
let $ct := current-time()
let $cd := current-date()
let $cdt := current-datetime()
-return { "time1" : $t1, "time2" : $t2, "time3" : $t3, "time4" : $t4, "time5" : $t5, "duration1" : $dr3, "duration2" : $dr4 }
\ No newline at end of file
+return { "time1" : $t1, "time2" : $t2, "time3" : $t3, "time4" : $t4, "time5" : $t5, "duration1" : $dr3, "duration2" : $dr4, "c1" : $c1, "c2" : $c2 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/constructor/date_01.adm b/asterix-app/src/test/resources/runtimets/results/constructor/date_01.adm
index 2a90c4d..8a08a03 100644
--- a/asterix-app/src/test/resources/runtimets/results/constructor/date_01.adm
+++ b/asterix-app/src/test/resources/runtimets/results/constructor/date_01.adm
@@ -1 +1 @@
-{ "date1": date("2010-10-30"), "date2": date("1987-11-19"), "date3": date("-1987-11-19"), "date4": date("0001-12-27"), "date5": date("-1951-12-27"), "date6": date("-2043-11-19"), "date7": date("-1928-03-29"), "date8": date("1928-03-29") }
\ No newline at end of file
+{ "date1": date("2010-10-30"), "date2": date("1987-11-19"), "date3": date("-1987-11-19"), "date4": date("0001-12-27"), "date5": date("-1951-12-27"), "date6": date("-2043-11-19"), "date7": date("-1928-03-29"), "date8": date("1928-03-29"), "date9": date("1900-02-28"), "date10": date("2000-02-29") }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/constructor/interval.adm b/asterix-app/src/test/resources/runtimets/results/constructor/interval.adm
index 8fb7e25..893c3ff 100644
--- a/asterix-app/src/test/resources/runtimets/results/constructor/interval.adm
+++ b/asterix-app/src/test/resources/runtimets/results/constructor/interval.adm
@@ -1 +1 @@
-{ "interval1": interval("date("2010-10-30"), date("2012-10-21")"), "interval2": interval("time("03:04:05.678Z"), time("23:24:25.267Z")"), "interval3": interval("datetime("-1987-11-19T02:43:57.938Z"), datetime("1999-11-12T12:49:35.948Z")"), "interval4": interval("date("0001-12-27"), date("0006-01-27")"), "interval5": interval("time("20:03:20.948Z"), time("20:57:50.886Z")"), "interval6": interval("datetime("-2043-11-19T15:32:39.293Z"), datetime("-1603-03-12T12:12:38.242Z")") }
\ No newline at end of file
+{ "interval1": interval-date("2010-10-30, 2012-10-21"), "interval2": interval-time("14:04:05.678Z, 21:24:25.267Z"), "interval3": interval-datetime("-1987-11-18T18:43:57.938Z, 1999-11-12T19:49:35.948Z"), "interval4": interval-date("0001-12-27, 0006-01-27"), "interval5": interval-time("20:03:20.948Z, 20:57:50.886Z"), "interval6": interval-datetime("-2043-11-19T15:32:39.293Z, -1603-03-12T12:12:38.242Z") }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/constructor/time_01.adm b/asterix-app/src/test/resources/runtimets/results/constructor/time_01.adm
index ef6adc9..34a119f 100644
--- a/asterix-app/src/test/resources/runtimets/results/constructor/time_01.adm
+++ b/asterix-app/src/test/resources/runtimets/results/constructor/time_01.adm
@@ -1 +1 @@
-{ "time1": time("05:50:56.200Z"), "time2": time("21:05:56.200Z"), "time3": time("10:50:56.000Z"), "time4": time("10:50:56.200Z"), "time5": time("13:29:59.999Z"), "time6": time("09:15:00.000Z"), "time7": time("13:59:00.019Z"), "time8": time("13:59:00.010Z"), "time9": time("13:59:00.019Z"), "time10": time("13:59:00.010Z"), "time11": time("13:59:00.019Z") }
+{ "time1": time("05:50:56.200Z"), "time2": time("21:05:56.200Z"), "time3": time("10:50:56.000Z"), "time4": time("10:50:56.200Z"), "time5": time("13:29:59.999Z"), "time6": time("09:15:00.000Z"), "time7": time("13:59:00.019Z"), "time8": time("13:59:00.010Z"), "time9": time("13:59:00.019Z"), "time10": time("13:59:00.010Z"), "time11": time("11:59:00.019Z") }
diff --git a/asterix-app/src/test/resources/runtimets/results/cross-dataverse/cross-dv20.adm b/asterix-app/src/test/resources/runtimets/results/cross-dataverse/cross-dv20.adm
new file mode 100644
index 0000000..83de609
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/cross-dataverse/cross-dv20.adm
@@ -0,0 +1 @@
+{ "ug-student": { "id": 457, "name": "John Doe", "age": 22, "sex": "M", "dept": "Dance" }, "prof": { "id": 152, "name": "John Meyer", "age": 42, "sex": "M", "dept": "History" }, "grd-student": { "id": 418, "name": "John Smith", "age": 26, "sex": "M", "dept": "Economics" }, "postdoc": { "id": 259, "name": "Sophia Reece", "age": 36, "sex": "F", "dept": "Anthropology" } }
diff --git a/asterix-app/src/test/resources/runtimets/results/dml/delete-syntax-change.adm b/asterix-app/src/test/resources/runtimets/results/dml/delete-syntax-change.adm
new file mode 100644
index 0000000..7039cfe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/dml/delete-syntax-change.adm
@@ -0,0 +1,25 @@
+{ "l_orderkey": 1, "l_partkey": 156, "l_suppkey": 4, "l_linenumber": 1, "l_quantity": 17, "l_extendedprice": 17954.55d, "l_discount": 0.04d, "l_tax": 0.02d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-03-13", "l_commitdate": "1996-02-12", "l_receiptdate": "1996-03-22", "l_shipinstruct": "DELIVER IN PERSON", "l_shipmode": "TRUCK", "l_comment": "egular courts above the" }
+{ "l_orderkey": 1, "l_partkey": 68, "l_suppkey": 9, "l_linenumber": 2, "l_quantity": 36, "l_extendedprice": 34850.16d, "l_discount": 0.09d, "l_tax": 0.06d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-04-12", "l_commitdate": "1996-02-28", "l_receiptdate": "1996-04-20", "l_shipinstruct": "TAKE BACK RETURN", "l_shipmode": "MAIL", "l_comment": "ly final dependencies: slyly bold " }
+{ "l_orderkey": 1, "l_partkey": 64, "l_suppkey": 5, "l_linenumber": 3, "l_quantity": 8, "l_extendedprice": 7712.48d, "l_discount": 0.1d, "l_tax": 0.02d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-01-29", "l_commitdate": "1996-03-05", "l_receiptdate": "1996-01-31", "l_shipinstruct": "TAKE BACK RETURN", "l_shipmode": "REG AIR", "l_comment": "riously. regular, express dep" }
+{ "l_orderkey": 1, "l_partkey": 3, "l_suppkey": 6, "l_linenumber": 4, "l_quantity": 28, "l_extendedprice": 25284.0d, "l_discount": 0.09d, "l_tax": 0.06d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-04-21", "l_commitdate": "1996-03-30", "l_receiptdate": "1996-05-16", "l_shipinstruct": "NONE", "l_shipmode": "AIR", "l_comment": "lites. fluffily even de" }
+{ "l_orderkey": 1, "l_partkey": 25, "l_suppkey": 8, "l_linenumber": 5, "l_quantity": 24, "l_extendedprice": 22200.48d, "l_discount": 0.1d, "l_tax": 0.04d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-03-30", "l_commitdate": "1996-03-14", "l_receiptdate": "1996-04-01", "l_shipinstruct": "NONE", "l_shipmode": "FOB", "l_comment": " pending foxes. slyly re" }
+{ "l_orderkey": 1, "l_partkey": 16, "l_suppkey": 3, "l_linenumber": 6, "l_quantity": 32, "l_extendedprice": 29312.32d, "l_discount": 0.07d, "l_tax": 0.02d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-01-30", "l_commitdate": "1996-02-07", "l_receiptdate": "1996-02-03", "l_shipinstruct": "DELIVER IN PERSON", "l_shipmode": "MAIL", "l_comment": "arefully slyly ex" }
+{ "l_orderkey": 2, "l_partkey": 107, "l_suppkey": 2, "l_linenumber": 1, "l_quantity": 38, "l_extendedprice": 38269.8d, "l_discount": 0.0d, "l_tax": 0.05d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1997-01-28", "l_commitdate": "1997-01-14", "l_receiptdate": "1997-02-02", "l_shipinstruct": "TAKE BACK RETURN", "l_shipmode": "RAIL", "l_comment": "ven requests. deposits breach a" }
+{ "l_orderkey": 3, "l_partkey": 5, "l_suppkey": 2, "l_linenumber": 1, "l_quantity": 45, "l_extendedprice": 40725.0d, "l_discount": 0.06d, "l_tax": 0.0d, "l_returnflag": "R", "l_linestatus": "F", "l_shipdate": "1994-02-02", "l_commitdate": "1994-01-04", "l_receiptdate": "1994-02-23", "l_shipinstruct": "NONE", "l_shipmode": "AIR", "l_comment": "ongside of the furiously brave acco" }
+{ "l_orderkey": 3, "l_partkey": 20, "l_suppkey": 10, "l_linenumber": 2, "l_quantity": 49, "l_extendedprice": 45080.98d, "l_discount": 0.1d, "l_tax": 0.0d, "l_returnflag": "R", "l_linestatus": "F", "l_shipdate": "1993-11-09", "l_commitdate": "1993-12-20", "l_receiptdate": "1993-11-24", "l_shipinstruct": "TAKE BACK RETURN", "l_shipmode": "RAIL", "l_comment": " unusual accounts. eve" }
+{ "l_orderkey": 3, "l_partkey": 129, "l_suppkey": 8, "l_linenumber": 3, "l_quantity": 27, "l_extendedprice": 27786.24d, "l_discount": 0.06d, "l_tax": 0.07d, "l_returnflag": "A", "l_linestatus": "F", "l_shipdate": "1994-01-16", "l_commitdate": "1993-11-22", "l_receiptdate": "1994-01-23", "l_shipinstruct": "DELIVER IN PERSON", "l_shipmode": "SHIP", "l_comment": "nal foxes wake. " }
+{ "l_orderkey": 3, "l_partkey": 30, "l_suppkey": 5, "l_linenumber": 4, "l_quantity": 2, "l_extendedprice": 1860.06d, "l_discount": 0.01d, "l_tax": 0.06d, "l_returnflag": "A", "l_linestatus": "F", "l_shipdate": "1993-12-04", "l_commitdate": "1994-01-07", "l_receiptdate": "1994-01-01", "l_shipinstruct": "NONE", "l_shipmode": "TRUCK", "l_comment": "y. fluffily pending d" }
+{ "l_orderkey": 3, "l_partkey": 184, "l_suppkey": 5, "l_linenumber": 5, "l_quantity": 28, "l_extendedprice": 30357.04d, "l_discount": 0.04d, "l_tax": 0.0d, "l_returnflag": "R", "l_linestatus": "F", "l_shipdate": "1993-12-14", "l_commitdate": "1994-01-10", "l_receiptdate": "1994-01-01", "l_shipinstruct": "TAKE BACK RETURN", "l_shipmode": "FOB", "l_comment": "ages nag slyly pending" }
+{ "l_orderkey": 3, "l_partkey": 63, "l_suppkey": 8, "l_linenumber": 6, "l_quantity": 26, "l_extendedprice": 25039.56d, "l_discount": 0.1d, "l_tax": 0.02d, "l_returnflag": "A", "l_linestatus": "F", "l_shipdate": "1993-10-29", "l_commitdate": "1993-12-18", "l_receiptdate": "1993-11-04", "l_shipinstruct": "TAKE BACK RETURN", "l_shipmode": "RAIL", "l_comment": "ges sleep after the caref" }
+{ "l_orderkey": 4, "l_partkey": 89, "l_suppkey": 10, "l_linenumber": 1, "l_quantity": 30, "l_extendedprice": 29672.4d, "l_discount": 0.03d, "l_tax": 0.08d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-01-10", "l_commitdate": "1995-12-14", "l_receiptdate": "1996-01-18", "l_shipinstruct": "DELIVER IN PERSON", "l_shipmode": "REG AIR", "l_comment": "- quickly regular packages sleep. idly" }
+{ "l_orderkey": 5, "l_partkey": 109, "l_suppkey": 10, "l_linenumber": 1, "l_quantity": 15, "l_extendedprice": 15136.5d, "l_discount": 0.02d, "l_tax": 0.04d, "l_returnflag": "R", "l_linestatus": "F", "l_shipdate": "1994-10-31", "l_commitdate": "1994-08-31", "l_receiptdate": "1994-11-20", "l_shipinstruct": "NONE", "l_shipmode": "AIR", "l_comment": "ts wake furiously " }
+{ "l_orderkey": 5, "l_partkey": 124, "l_suppkey": 5, "l_linenumber": 2, "l_quantity": 26, "l_extendedprice": 26627.12d, "l_discount": 0.07d, "l_tax": 0.08d, "l_returnflag": "R", "l_linestatus": "F", "l_shipdate": "1994-10-16", "l_commitdate": "1994-09-25", "l_receiptdate": "1994-10-19", "l_shipinstruct": "NONE", "l_shipmode": "FOB", "l_comment": "sts use slyly quickly special instruc" }
+{ "l_orderkey": 5, "l_partkey": 38, "l_suppkey": 4, "l_linenumber": 3, "l_quantity": 50, "l_extendedprice": 46901.5d, "l_discount": 0.08d, "l_tax": 0.03d, "l_returnflag": "A", "l_linestatus": "F", "l_shipdate": "1994-08-08", "l_commitdate": "1994-10-13", "l_receiptdate": "1994-08-26", "l_shipinstruct": "DELIVER IN PERSON", "l_shipmode": "AIR", "l_comment": "eodolites. fluffily unusual" }
+{ "l_orderkey": 6, "l_partkey": 140, "l_suppkey": 6, "l_linenumber": 1, "l_quantity": 37, "l_extendedprice": 38485.18d, "l_discount": 0.08d, "l_tax": 0.03d, "l_returnflag": "A", "l_linestatus": "F", "l_shipdate": "1992-04-27", "l_commitdate": "1992-05-15", "l_receiptdate": "1992-05-02", "l_shipinstruct": "TAKE BACK RETURN", "l_shipmode": "TRUCK", "l_comment": "p furiously special foxes" }
+{ "l_orderkey": 7, "l_partkey": 183, "l_suppkey": 4, "l_linenumber": 1, "l_quantity": 12, "l_extendedprice": 12998.16d, "l_discount": 0.07d, "l_tax": 0.03d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-05-07", "l_commitdate": "1996-03-13", "l_receiptdate": "1996-06-03", "l_shipinstruct": "TAKE BACK RETURN", "l_shipmode": "FOB", "l_comment": "ss pinto beans wake against th" }
+{ "l_orderkey": 7, "l_partkey": 146, "l_suppkey": 3, "l_linenumber": 2, "l_quantity": 9, "l_extendedprice": 9415.26d, "l_discount": 0.08d, "l_tax": 0.08d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-02-01", "l_commitdate": "1996-03-02", "l_receiptdate": "1996-02-19", "l_shipinstruct": "TAKE BACK RETURN", "l_shipmode": "SHIP", "l_comment": "es. instructions" }
+{ "l_orderkey": 7, "l_partkey": 95, "l_suppkey": 8, "l_linenumber": 3, "l_quantity": 46, "l_extendedprice": 45774.14d, "l_discount": 0.1d, "l_tax": 0.07d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-01-15", "l_commitdate": "1996-03-27", "l_receiptdate": "1996-02-03", "l_shipinstruct": "COLLECT COD", "l_shipmode": "MAIL", "l_comment": " unusual reques" }
+{ "l_orderkey": 7, "l_partkey": 164, "l_suppkey": 5, "l_linenumber": 4, "l_quantity": 28, "l_extendedprice": 29796.48d, "l_discount": 0.03d, "l_tax": 0.04d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-03-21", "l_commitdate": "1996-04-08", "l_receiptdate": "1996-04-20", "l_shipinstruct": "NONE", "l_shipmode": "FOB", "l_comment": ". slyly special requests haggl" }
+{ "l_orderkey": 7, "l_partkey": 152, "l_suppkey": 4, "l_linenumber": 5, "l_quantity": 38, "l_extendedprice": 39981.7d, "l_discount": 0.08d, "l_tax": 0.01d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-02-11", "l_commitdate": "1996-02-24", "l_receiptdate": "1996-02-18", "l_shipinstruct": "DELIVER IN PERSON", "l_shipmode": "TRUCK", "l_comment": "ns haggle carefully ironic deposits. bl" }
+{ "l_orderkey": 7, "l_partkey": 80, "l_suppkey": 10, "l_linenumber": 6, "l_quantity": 35, "l_extendedprice": 34302.8d, "l_discount": 0.06d, "l_tax": 0.03d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-01-16", "l_commitdate": "1996-02-23", "l_receiptdate": "1996-01-22", "l_shipinstruct": "TAKE BACK RETURN", "l_shipmode": "FOB", "l_comment": "jole. excuses wake carefully alongside of " }
+{ "l_orderkey": 7, "l_partkey": 158, "l_suppkey": 3, "l_linenumber": 7, "l_quantity": 5, "l_extendedprice": 5290.75d, "l_discount": 0.04d, "l_tax": 0.02d, "l_returnflag": "N", "l_linestatus": "O", "l_shipdate": "1996-02-10", "l_commitdate": "1996-03-26", "l_receiptdate": "1996-02-13", "l_shipinstruct": "NONE", "l_shipmode": "FOB", "l_comment": "ithely regula" }
diff --git a/asterix-app/src/test/resources/runtimets/results/dml/insert-syntax.adm b/asterix-app/src/test/resources/runtimets/results/dml/insert-syntax.adm
new file mode 100644
index 0000000..9407868
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/dml/insert-syntax.adm
@@ -0,0 +1,4 @@
+{ "id": 1, "name": "Person One", "hobbies": {{ "Rock", "Metal" }} }
+{ "id": 2, "name": "Person Two", "hobbies": {{ "Rock", "Jazz" }} }
+{ "id": 3, "name": "Person Three", "hobbies": {{ "Blues" }} }
+{ "id": 4, "name": "Person Four", "hobbies": {{ "Metal", "Jazz" }} }
diff --git a/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-aqlplus_1.adm b/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-aqlplus_1.adm
index b79bfe0..10357e5 100644
--- a/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-aqlplus_1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-aqlplus_1.adm
@@ -1,4 +1,3 @@
-{ "dblp": { "id": 21, "dblpid": "books/acm/kim95/MengY95", "title": "Query Processing in Multidatabase Systems.", "authors": "Weiyi Meng Clement T. Yu", "misc": "2002-01-03 551-572 1995 Modern Database Systems db/books/collections/kim95.html#MengY95" }, "dblp2": { "id": 24, "dblpid": "books/acm/kim95/OzsuB95", "title": "Query Processing in Object-Oriented Database Systems.", "authors": "M. Tamer Özsu José A. Blakeley", "misc": "2002-01-03 146-174 1995 Modern Database Systems db/books/collections/kim95.html#OzsuB95" } }
{ "dblp": { "id": 81, "dblpid": "journals/siamcomp/AspnesW96", "title": "Randomized Consensus in Expected O(n log² n) Operations Per Processor.", "authors": "James Aspnes Orli Waarts", "misc": "2002-01-03 1024-1044 1996 25 SIAM J. Comput. 5 db/journals/siamcomp/siamcomp25.html#AspnesW96" }, "dblp2": { "id": 82, "dblpid": "conf/focs/AspnesW92", "title": "Randomized Consensus in Expected O(n log ^2 n) Operations Per Processor", "authors": "James Aspnes Orli Waarts", "misc": "2006-04-25 137-146 conf/focs/FOCS33 1992 FOCS db/conf/focs/focs92.html#AspnesW92" } }
{ "dblp": { "id": 83, "dblpid": "journals/siamcomp/Bloniarz83", "title": "A Shortest-Path Algorithm with Expected Time O(n² log n log* n).", "authors": "Peter A. Bloniarz", "misc": "2002-01-03 588-600 1983 12 SIAM J. Comput. 3 db/journals/siamcomp/siamcomp12.html#Bloniarz83" }, "dblp2": { "id": 84, "dblpid": "conf/stoc/Bloniarz80", "title": "A Shortest-Path Algorithm with Expected Time O(n^2 log n log ^* n)", "authors": "Peter A. Bloniarz", "misc": "2006-04-25 378-384 conf/stoc/STOC12 1980 STOC db/conf/stoc/stoc80.html#Bloniarz80" } }
{ "dblp": { "id": 83, "dblpid": "journals/siamcomp/Bloniarz83", "title": "A Shortest-Path Algorithm with Expected Time O(n² log n log* n).", "authors": "Peter A. Bloniarz", "misc": "2002-01-03 588-600 1983 12 SIAM J. Comput. 3 db/journals/siamcomp/siamcomp12.html#Bloniarz83" }, "dblp2": { "id": 87, "dblpid": "journals/siamcomp/MoffatT87", "title": "An All Pairs Shortest Path Algorithm with Expected Time O(n² log n).", "authors": "Alistair Moffat Tadao Takaoka", "misc": "2002-01-03 1023-1031 1987 16 SIAM J. Comput. 6 db/journals/siamcomp/siamcomp16.html#MoffatT87" } }
diff --git a/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_1.adm b/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_1.adm
index 9e9c6d4..57135b0 100644
--- a/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_1.adm
@@ -1,6 +1,5 @@
{ "dblp": { "id": 1, "dblpid": "books/acm/kim95/AnnevelinkACFHK95", "title": "Object SQL - A Language for the Design and Implementation of Object Databases.", "authors": "Jurgen Annevelink Rafiul Ahad Amelia Carlson Daniel H. Fishman Michael L. Heytens William Kent", "misc": "2002-01-03 42-68 1995 Modern Database Systems db/books/collections/kim95.html#AnnevelinkACFHK95" }, "csx": { "id": 1, "csxid": "oai CiteSeerXPSU 10.1.1.39.1830", "title": "Object SQL - A Language for the Design and Implementation of Object Databases", "authors": "Jurgen Annevelink Rafiul Ahad Amelia Carlson Dan Fishman Mike Heytens William Kent", "misc": "2009-04-13 ly, a function application expression consists of two expressions a function reference (labelled func_ref in Figure 3 line 2), and an argument (labelled arg). The func_ref expression evaluates to a (generic or specific) function identifier, which may be the same as the function that the expression is a part of, thus allowing recursive function invocations. The expression labelled arg evaluates to an arbitrary object or aggregate object. The semantics of evaluating function applications was discussed in detail in section 2. For example, to set the name of a person, we evaluate the following expression FunAssign(function name.person) (p1,'John') In this example, the first expression is itself a function call, applying the function FunAssign to the function name.person (an example of a specific function reference). This returns the oid of the function that sets a person's name, which is subsequently applied to a tuple of two elements, the oid of the person and the new name (a string o... CiteSeerX ACM Press 2009-04-13 2007-11-22 1994 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.39.1830 http //www.tu-chemnitz.de/~igrdb/docs/OpenODB/osql.ps.gz en 10.1.1.31.2534 10.1.1.28.4658 10.1.1.44.5947 10.1.1.39.199 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 5, "dblpid": "books/acm/kim95/DayalHW95", "title": "Active Database Systems.", "authors": "Umeshwar Dayal Eric N. Hanson Jennifer Widom", "misc": "2002-01-03 434-456 1995 Modern Database Systems db/books/collections/kim95.html#DayalHW95" }, "csx": { "id": 98, "csxid": "oai CiteSeerXPSU 10.1.1.49.2910", "title": "Active Database Systems", "authors": "Umeshwar Dayal Eric N. Hanson Jennifer Widom", "misc": "2009-04-12 In Won Kim editor Modern Database Systems The Object Model Integrating a production rules facility into a database system provides a uniform mechanism for a number of advanced database features including integrity constraint enforcement, derived data maintenance, triggers, alerters, protection, version control, and others. In addition, a database system with rule processing capabilities provides a useful platform for large and efficient knowledge-base and expert systems. Database systems with production rules are referred to as active database systems, and the field of active database systems has indeed been active. This chapter summarizes current work in active database systems topics covered include active database rule models and languages, rule execution semantics, and implementation issues. 1 Introduction Conventional database systems are passive they only execute queries or transactions explicitly submitted by a user or an application program. For many applications, however, it is important to monitor situations of interest, and to ... CiteSeerX ACM Press 2009-04-12 2007-11-22 1994 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.49.2910 http //www-db.stanford.edu/pub/papers/book-chapter.ps en 10.1.1.17.1323 10.1.1.143.7196 10.1.1.50.3821 10.1.1.51.9946 10.1.1.41.2030 10.1.1.46.2504 10.1.1.52.4421 10.1.1.38.2083 10.1.1.34.661 10.1.1.103.7630 10.1.1.100.9015 10.1.1.97.1699 10.1.1.107.4220 10.1.1.47.9217 10.1.1.133.7157 10.1.1.101.5051 10.1.1.30.9989 10.1.1.53.6941 10.1.1.50.8529 10.1.1.133.4287 10.1.1.50.7278 10.1.1.10.1688 10.1.1.19.8669 10.1.1.44.7600 10.1.1.144.376 10.1.1.44.1348 10.1.1.47.9998 10.1.1.90.4428 10.1.1.108.344 10.1.1.48.9470 10.1.1.53.5472 10.1.1.52.4872 10.1.1.144.4965 10.1.1.31.7578 10.1.1.32.6426 10.1.1.58.6335 10.1.1.85.8052 10.1.1.93.1931 10.1.1.55.4610 10.1.1.21.3821 10.1.1.26.9208 10.1.1.31.4869 10.1.1.48.1833 10.1.1.83.8628 10.1.1.87.9318 10.1.1.90.2195 10.1.1.36.5184 10.1.1.21.1704 10.1.1.53.1733 10.1.1.90.3181 10.1.1.53.6783 10.1.1.52.6151 10.1.1.104.6911 10.1.1.105.1691 10.1.1.21.1984 10.1.1.23.2775 10.1.1.62.5556 10.1.1.68.9063 10.1.1.74.4746 10.1.1.78.5097 10.1.1.84.743 10.1.1.84.904 10.1.1.87.6019 10.1.1.88.3907 10.1.1.89.9631 10.1.1.90.4147 10.1.1.92.365 10.1.1.100.2747 10.1.1.98.5083 10.1.1.98.6663 10.1.1.99.1894 10.1.1.99.8174 10.1.1.133.8073 10.1.1.52.7823 10.1.1.39.5341 10.1.1.35.3458 10.1.1.26.4620 10.1.1.18.8936 10.1.1.19.3694 10.1.1.12.631 10.1.1.48.6394 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
-{ "dblp": { "id": 21, "dblpid": "books/acm/kim95/MengY95", "title": "Query Processing in Multidatabase Systems.", "authors": "Weiyi Meng Clement T. Yu", "misc": "2002-01-03 551-572 1995 Modern Database Systems db/books/collections/kim95.html#MengY95" }, "csx": { "id": 89, "csxid": "oai CiteSeerXPSU 10.1.1.33.8596", "title": "Dynamic Query Optimization and Query Processing in Multidatabase Systems 1.", "authors": "Henryk Josinski", "misc": "2009-04-15 Introduction The multidatabase system (MDBS) approach, as a solution for integrated access to information distributed among diverse data sources, has gained a lot of attention in recent years. The multidatabase system is a database system which integrates pre--existing databases allowing the users to access simultaneously database systems (DBMSs) formulating a global query based on a global schema. The component DBMSs are assumed to be heterogeneous and autonomous. Heterogeneity refers to different user interfaces, data models, query languages, and query optimization strategies [5]. Local autonomy means that each DBMS retains complete control over local data and processing. As result of this, its cost model may not be available to the global query optimizer. When a global query is submitted, it is decomposed into two types of queries [1] -- subqueries, operating on sharable data items from local databases, -- assembling queries, consisting of, CiteSeerX 2009-04-15 2007-11-22 2000 application/pdf text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.33.8596 http //www.edbt2000.uni-konstanz.de/phd-workshop/papers/Josinski.pdf en 10.1.1.27.4704 10.1.1.51.8352 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 25, "dblpid": "books/acm/kim95/RusinkiewiczS95", "title": "Specification and Execution of Transactional Workflows.", "authors": "Marek Rusinkiewicz Amit P. Sheth", "misc": "2004-03-08 592-620 Modern Database Systems books/acm/Kim95 db/books/collections/kim95.html#RusinkiewiczS95 1995" }, "csx": { "id": 88, "csxid": "oai CiteSeerXPSU 10.1.1.43.3839", "title": "Specification and Execution of Transactional Workflows", "authors": "Marek Rusinkiewicz Amit Sheth", "misc": "2009-04-13 The basic transaction model has evolved over time to incorporate more complex transaction structures and to selectively modify the atomicity and isolation properties. In this chapter we discuss the application of transaction concepts to activities that involve coordinated execution of multiple tasks (possibly of different types) over different processing entities. Such applications are referred to as transactional workflows. In this chapter we discuss the specification of such workflows and the issues involved in their execution. 1 What is a Workflow? Workflows are activities involving the coordinated execution of multiple tasks performed by different processing entities. A task defines some work to be done and can be specified in a number of ways, including a textual description in a file or an email, a form, a message, or a computer program. A processing entity that performs the tasks may be a person or a software system (e.g., a mailer, an application program, a database mana... CiteSeerX ACM Press 2009-04-13 2007-11-22 1995 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.43.3839 http //lsdis.cs.uga.edu/lib/././download/RS93.ps en 10.1.1.17.1323 10.1.1.59.5051 10.1.1.38.6210 10.1.1.68.7445 10.1.1.109.5175 10.1.1.17.7962 10.1.1.44.7778 10.1.1.112.244 10.1.1.13.7602 10.1.1.102.7874 10.1.1.41.4043 10.1.1.49.5143 10.1.1.41.7252 10.1.1.17.3225 10.1.1.54.7761 10.1.1.55.5255 10.1.1.108.958 10.1.1.35.7733 10.1.1.52.3682 10.1.1.36.1618 10.1.1.45.6317 10.1.1.43.3180 10.1.1.35.8718 10.1.1.44.6365 10.1.1.51.2883 10.1.1.50.9206 10.1.1.6.9085 10.1.1.30.1707 10.1.1.80.6634 10.1.1.49.355 10.1.1.127.3550 10.1.1.35.3562 10.1.1.137.8832 10.1.1.49.4085 10.1.1.41.5506 10.1.1.40.4657 10.1.1.43.2369 10.1.1.40.832 10.1.1.74.5411 10.1.1.90.4428 10.1.1.110.6967 10.1.1.27.2122 10.1.1.15.5605 10.1.1.54.727 10.1.1.49.7512 10.1.1.45.8796 10.1.1.50.5984 10.1.1.53.137 10.1.1.30.3262 10.1.1.28.1680 10.1.1.21.7110 10.1.1.29.3148 10.1.1.57.687 10.1.1.59.5924 10.1.1.46.2812 10.1.1.51.5552 10.1.1.17.7375 10.1.1.40.1598 10.1.1.52.9787 10.1.1.1.3496 10.1.1.50.6791 10.1.1.55.3358 10.1.1.137.7582 10.1.1.118.4127 10.1.1.49.3580 10.1.1.35.5825 10.1.1.46.9382 10.1.1.31.7411 10.1.1.48.5504 10.1.1.55.5163 10.1.1.18.1603 10.1.1.52.8129 10.1.1.1.9723 10.1.1.21.9113 10.1.1.49.7644 10.1.1.52.6646 10.1.1.75.3106 10.1.1.80.2072 10.1.1.55.8770 10.1.1.54.8188 10.1.1.101.7919 10.1.1.104.8176 10.1.1.24.5741 10.1.1.29.4667 10.1.1.4.1055 10.1.1.48.9175 10.1.1.56.792 10.1.1.65.3172 10.1.1.66.5947 10.1.1.73.8532 10.1.1.83.8299 10.1.1.86.8521 10.1.1.87.2402 10.1.1.87.4648 10.1.1.90.5638 10.1.1.91.1709 10.1.1.94.4248 10.1.1.114.511 10.1.1.119.5037 10.1.1.124.7957 10.1.1.49.215 10.1.1.53.7777 10.1.1.53.9711 10.1.1.45.9409 10.1.1.40.8789 10.1.1.43.4845 10.1.1.34.8273 10.1.1.35.4783 10.1.1.28.3176 10.1.1.16.8151 10.1.1.8.9117 10.1.1.58.3449 10.1.1.142.7041 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 51, "dblpid": "books/aw/kimL89/NierstraszT89", "title": "Integrated Office Systems.", "authors": "Oscar Nierstrasz Dennis Tsichritzis", "misc": "2002-01-03 199-215 1989 Object-Oriented Concepts, Databases, and Applications db/books/collections/kim89.html#NierstraszT89" }, "csx": { "id": 92, "csxid": "oai CiteSeerXPSU 10.1.1.13.2374", "title": "Integrated Office Systems", "authors": "O. M. Nierstrasz D. C. Tsichritzis", "misc": "2009-04-17 Introduction New techniques are sorely needed to aid in the development and maintenance of large application systems. The problem with traditional approaches to software engineering is well in evidence in the field of o#ce information systems it is costly and di#cult to extend existing applications, and to get unrelated applications to \"talk\" to each other. The objectoriented approach is already being tentatively applied in the modeling of \"o#ce objects\" and in the presentation of these entities to users as such in \"desktop\" interfaces to o#ce software. In order to fully exploit the approach to achieve integrated o#ce systems, we need to use object-oriented programming languages, object-oriented run-time support, and object-oriented software engineering environments. We can view the fundamental idea behind the object-oriented approach as that of encapsulation object-oriented languages and systems exploit encapsulation in various ways in an attempt to enhance productivity through, f CiteSeerX 2009-04-17 2007-11-21 1988 application/pdf text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.13.2374 http //www.iam.unibe.ch/~scg/Archive/OSG/Nier89bIntegOfficeSystems.pdf en 10.1.1.26.9545 10.1.1.65.5865 10.1.1.34.624 10.1.1.12.8544 10.1.1.144.6983 10.1.1.26.6746 10.1.1.49.3064 10.1.1.30.4607 10.1.1.38.4894 10.1.1.20.8197 10.1.1.26.4381 10.1.1.29.1890 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 51, "dblpid": "books/aw/kimL89/NierstraszT89", "title": "Integrated Office Systems.", "authors": "Oscar Nierstrasz Dennis Tsichritzis", "misc": "2002-01-03 199-215 1989 Object-Oriented Concepts, Databases, and Applications db/books/collections/kim89.html#NierstraszT89" }, "csx": { "id": 93, "csxid": "oai CiteSeerXPSU 10.1.1.42.9253", "title": "Integrated Office Systems", "authors": "O. M. Nierstrasz D. C. Tsichritzis", "misc": "2009-04-11 Introduction New techniques are sorely needed to aid in the development and maintenance of large application systems. The problem with traditional approaches to software engineering is well in evidence in the field of office information systems it is costly and difficult to extend existing applications, and to get unrelated applications to \"talk\" to each other. The objectoriented approach is already being tentatively applied in the modeling of \"office objects\" and in the presentation of these entities to users as such in \"desktop\" interfaces to office software. In order to fully exploit the approach to achieve integrated office systems, we need to use object-oriented programming languages, object-oriented run-time support, and object-oriented software engineering environments. We can view the fundamental idea behind the object-oriented approach as that of encapsulation object-oriented languages and systems exploit encapsulation in various ways in an attempt t CiteSeerX ACM Press and Addison-Wesley 2009-04-11 2007-11-22 1988 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.42.9253 ftp //ftp.iam.unibe.ch/pub/scg/Papers/integratedOfficeSystems.ps.gz en 10.1.1.26.9545 10.1.1.65.5865 10.1.1.34.624 10.1.1.12.8544 10.1.1.144.6983 10.1.1.26.6746 10.1.1.49.3064 10.1.1.30.4607 10.1.1.38.4894 10.1.1.20.8197 10.1.1.26.4381 10.1.1.29.1890 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
diff --git a/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_2.adm b/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_2.adm
index 9e9c6d4..57135b0 100644
--- a/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_2.adm
+++ b/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_2.adm
@@ -1,6 +1,5 @@
{ "dblp": { "id": 1, "dblpid": "books/acm/kim95/AnnevelinkACFHK95", "title": "Object SQL - A Language for the Design and Implementation of Object Databases.", "authors": "Jurgen Annevelink Rafiul Ahad Amelia Carlson Daniel H. Fishman Michael L. Heytens William Kent", "misc": "2002-01-03 42-68 1995 Modern Database Systems db/books/collections/kim95.html#AnnevelinkACFHK95" }, "csx": { "id": 1, "csxid": "oai CiteSeerXPSU 10.1.1.39.1830", "title": "Object SQL - A Language for the Design and Implementation of Object Databases", "authors": "Jurgen Annevelink Rafiul Ahad Amelia Carlson Dan Fishman Mike Heytens William Kent", "misc": "2009-04-13 ly, a function application expression consists of two expressions a function reference (labelled func_ref in Figure 3 line 2), and an argument (labelled arg). The func_ref expression evaluates to a (generic or specific) function identifier, which may be the same as the function that the expression is a part of, thus allowing recursive function invocations. The expression labelled arg evaluates to an arbitrary object or aggregate object. The semantics of evaluating function applications was discussed in detail in section 2. For example, to set the name of a person, we evaluate the following expression FunAssign(function name.person) (p1,'John') In this example, the first expression is itself a function call, applying the function FunAssign to the function name.person (an example of a specific function reference). This returns the oid of the function that sets a person's name, which is subsequently applied to a tuple of two elements, the oid of the person and the new name (a string o... CiteSeerX ACM Press 2009-04-13 2007-11-22 1994 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.39.1830 http //www.tu-chemnitz.de/~igrdb/docs/OpenODB/osql.ps.gz en 10.1.1.31.2534 10.1.1.28.4658 10.1.1.44.5947 10.1.1.39.199 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 5, "dblpid": "books/acm/kim95/DayalHW95", "title": "Active Database Systems.", "authors": "Umeshwar Dayal Eric N. Hanson Jennifer Widom", "misc": "2002-01-03 434-456 1995 Modern Database Systems db/books/collections/kim95.html#DayalHW95" }, "csx": { "id": 98, "csxid": "oai CiteSeerXPSU 10.1.1.49.2910", "title": "Active Database Systems", "authors": "Umeshwar Dayal Eric N. Hanson Jennifer Widom", "misc": "2009-04-12 In Won Kim editor Modern Database Systems The Object Model Integrating a production rules facility into a database system provides a uniform mechanism for a number of advanced database features including integrity constraint enforcement, derived data maintenance, triggers, alerters, protection, version control, and others. In addition, a database system with rule processing capabilities provides a useful platform for large and efficient knowledge-base and expert systems. Database systems with production rules are referred to as active database systems, and the field of active database systems has indeed been active. This chapter summarizes current work in active database systems topics covered include active database rule models and languages, rule execution semantics, and implementation issues. 1 Introduction Conventional database systems are passive they only execute queries or transactions explicitly submitted by a user or an application program. For many applications, however, it is important to monitor situations of interest, and to ... CiteSeerX ACM Press 2009-04-12 2007-11-22 1994 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.49.2910 http //www-db.stanford.edu/pub/papers/book-chapter.ps en 10.1.1.17.1323 10.1.1.143.7196 10.1.1.50.3821 10.1.1.51.9946 10.1.1.41.2030 10.1.1.46.2504 10.1.1.52.4421 10.1.1.38.2083 10.1.1.34.661 10.1.1.103.7630 10.1.1.100.9015 10.1.1.97.1699 10.1.1.107.4220 10.1.1.47.9217 10.1.1.133.7157 10.1.1.101.5051 10.1.1.30.9989 10.1.1.53.6941 10.1.1.50.8529 10.1.1.133.4287 10.1.1.50.7278 10.1.1.10.1688 10.1.1.19.8669 10.1.1.44.7600 10.1.1.144.376 10.1.1.44.1348 10.1.1.47.9998 10.1.1.90.4428 10.1.1.108.344 10.1.1.48.9470 10.1.1.53.5472 10.1.1.52.4872 10.1.1.144.4965 10.1.1.31.7578 10.1.1.32.6426 10.1.1.58.6335 10.1.1.85.8052 10.1.1.93.1931 10.1.1.55.4610 10.1.1.21.3821 10.1.1.26.9208 10.1.1.31.4869 10.1.1.48.1833 10.1.1.83.8628 10.1.1.87.9318 10.1.1.90.2195 10.1.1.36.5184 10.1.1.21.1704 10.1.1.53.1733 10.1.1.90.3181 10.1.1.53.6783 10.1.1.52.6151 10.1.1.104.6911 10.1.1.105.1691 10.1.1.21.1984 10.1.1.23.2775 10.1.1.62.5556 10.1.1.68.9063 10.1.1.74.4746 10.1.1.78.5097 10.1.1.84.743 10.1.1.84.904 10.1.1.87.6019 10.1.1.88.3907 10.1.1.89.9631 10.1.1.90.4147 10.1.1.92.365 10.1.1.100.2747 10.1.1.98.5083 10.1.1.98.6663 10.1.1.99.1894 10.1.1.99.8174 10.1.1.133.8073 10.1.1.52.7823 10.1.1.39.5341 10.1.1.35.3458 10.1.1.26.4620 10.1.1.18.8936 10.1.1.19.3694 10.1.1.12.631 10.1.1.48.6394 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
-{ "dblp": { "id": 21, "dblpid": "books/acm/kim95/MengY95", "title": "Query Processing in Multidatabase Systems.", "authors": "Weiyi Meng Clement T. Yu", "misc": "2002-01-03 551-572 1995 Modern Database Systems db/books/collections/kim95.html#MengY95" }, "csx": { "id": 89, "csxid": "oai CiteSeerXPSU 10.1.1.33.8596", "title": "Dynamic Query Optimization and Query Processing in Multidatabase Systems 1.", "authors": "Henryk Josinski", "misc": "2009-04-15 Introduction The multidatabase system (MDBS) approach, as a solution for integrated access to information distributed among diverse data sources, has gained a lot of attention in recent years. The multidatabase system is a database system which integrates pre--existing databases allowing the users to access simultaneously database systems (DBMSs) formulating a global query based on a global schema. The component DBMSs are assumed to be heterogeneous and autonomous. Heterogeneity refers to different user interfaces, data models, query languages, and query optimization strategies [5]. Local autonomy means that each DBMS retains complete control over local data and processing. As result of this, its cost model may not be available to the global query optimizer. When a global query is submitted, it is decomposed into two types of queries [1] -- subqueries, operating on sharable data items from local databases, -- assembling queries, consisting of, CiteSeerX 2009-04-15 2007-11-22 2000 application/pdf text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.33.8596 http //www.edbt2000.uni-konstanz.de/phd-workshop/papers/Josinski.pdf en 10.1.1.27.4704 10.1.1.51.8352 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 25, "dblpid": "books/acm/kim95/RusinkiewiczS95", "title": "Specification and Execution of Transactional Workflows.", "authors": "Marek Rusinkiewicz Amit P. Sheth", "misc": "2004-03-08 592-620 Modern Database Systems books/acm/Kim95 db/books/collections/kim95.html#RusinkiewiczS95 1995" }, "csx": { "id": 88, "csxid": "oai CiteSeerXPSU 10.1.1.43.3839", "title": "Specification and Execution of Transactional Workflows", "authors": "Marek Rusinkiewicz Amit Sheth", "misc": "2009-04-13 The basic transaction model has evolved over time to incorporate more complex transaction structures and to selectively modify the atomicity and isolation properties. In this chapter we discuss the application of transaction concepts to activities that involve coordinated execution of multiple tasks (possibly of different types) over different processing entities. Such applications are referred to as transactional workflows. In this chapter we discuss the specification of such workflows and the issues involved in their execution. 1 What is a Workflow? Workflows are activities involving the coordinated execution of multiple tasks performed by different processing entities. A task defines some work to be done and can be specified in a number of ways, including a textual description in a file or an email, a form, a message, or a computer program. A processing entity that performs the tasks may be a person or a software system (e.g., a mailer, an application program, a database mana... CiteSeerX ACM Press 2009-04-13 2007-11-22 1995 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.43.3839 http //lsdis.cs.uga.edu/lib/././download/RS93.ps en 10.1.1.17.1323 10.1.1.59.5051 10.1.1.38.6210 10.1.1.68.7445 10.1.1.109.5175 10.1.1.17.7962 10.1.1.44.7778 10.1.1.112.244 10.1.1.13.7602 10.1.1.102.7874 10.1.1.41.4043 10.1.1.49.5143 10.1.1.41.7252 10.1.1.17.3225 10.1.1.54.7761 10.1.1.55.5255 10.1.1.108.958 10.1.1.35.7733 10.1.1.52.3682 10.1.1.36.1618 10.1.1.45.6317 10.1.1.43.3180 10.1.1.35.8718 10.1.1.44.6365 10.1.1.51.2883 10.1.1.50.9206 10.1.1.6.9085 10.1.1.30.1707 10.1.1.80.6634 10.1.1.49.355 10.1.1.127.3550 10.1.1.35.3562 10.1.1.137.8832 10.1.1.49.4085 10.1.1.41.5506 10.1.1.40.4657 10.1.1.43.2369 10.1.1.40.832 10.1.1.74.5411 10.1.1.90.4428 10.1.1.110.6967 10.1.1.27.2122 10.1.1.15.5605 10.1.1.54.727 10.1.1.49.7512 10.1.1.45.8796 10.1.1.50.5984 10.1.1.53.137 10.1.1.30.3262 10.1.1.28.1680 10.1.1.21.7110 10.1.1.29.3148 10.1.1.57.687 10.1.1.59.5924 10.1.1.46.2812 10.1.1.51.5552 10.1.1.17.7375 10.1.1.40.1598 10.1.1.52.9787 10.1.1.1.3496 10.1.1.50.6791 10.1.1.55.3358 10.1.1.137.7582 10.1.1.118.4127 10.1.1.49.3580 10.1.1.35.5825 10.1.1.46.9382 10.1.1.31.7411 10.1.1.48.5504 10.1.1.55.5163 10.1.1.18.1603 10.1.1.52.8129 10.1.1.1.9723 10.1.1.21.9113 10.1.1.49.7644 10.1.1.52.6646 10.1.1.75.3106 10.1.1.80.2072 10.1.1.55.8770 10.1.1.54.8188 10.1.1.101.7919 10.1.1.104.8176 10.1.1.24.5741 10.1.1.29.4667 10.1.1.4.1055 10.1.1.48.9175 10.1.1.56.792 10.1.1.65.3172 10.1.1.66.5947 10.1.1.73.8532 10.1.1.83.8299 10.1.1.86.8521 10.1.1.87.2402 10.1.1.87.4648 10.1.1.90.5638 10.1.1.91.1709 10.1.1.94.4248 10.1.1.114.511 10.1.1.119.5037 10.1.1.124.7957 10.1.1.49.215 10.1.1.53.7777 10.1.1.53.9711 10.1.1.45.9409 10.1.1.40.8789 10.1.1.43.4845 10.1.1.34.8273 10.1.1.35.4783 10.1.1.28.3176 10.1.1.16.8151 10.1.1.8.9117 10.1.1.58.3449 10.1.1.142.7041 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 51, "dblpid": "books/aw/kimL89/NierstraszT89", "title": "Integrated Office Systems.", "authors": "Oscar Nierstrasz Dennis Tsichritzis", "misc": "2002-01-03 199-215 1989 Object-Oriented Concepts, Databases, and Applications db/books/collections/kim89.html#NierstraszT89" }, "csx": { "id": 92, "csxid": "oai CiteSeerXPSU 10.1.1.13.2374", "title": "Integrated Office Systems", "authors": "O. M. Nierstrasz D. C. Tsichritzis", "misc": "2009-04-17 Introduction New techniques are sorely needed to aid in the development and maintenance of large application systems. The problem with traditional approaches to software engineering is well in evidence in the field of o#ce information systems it is costly and di#cult to extend existing applications, and to get unrelated applications to \"talk\" to each other. The objectoriented approach is already being tentatively applied in the modeling of \"o#ce objects\" and in the presentation of these entities to users as such in \"desktop\" interfaces to o#ce software. In order to fully exploit the approach to achieve integrated o#ce systems, we need to use object-oriented programming languages, object-oriented run-time support, and object-oriented software engineering environments. We can view the fundamental idea behind the object-oriented approach as that of encapsulation object-oriented languages and systems exploit encapsulation in various ways in an attempt to enhance productivity through, f CiteSeerX 2009-04-17 2007-11-21 1988 application/pdf text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.13.2374 http //www.iam.unibe.ch/~scg/Archive/OSG/Nier89bIntegOfficeSystems.pdf en 10.1.1.26.9545 10.1.1.65.5865 10.1.1.34.624 10.1.1.12.8544 10.1.1.144.6983 10.1.1.26.6746 10.1.1.49.3064 10.1.1.30.4607 10.1.1.38.4894 10.1.1.20.8197 10.1.1.26.4381 10.1.1.29.1890 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 51, "dblpid": "books/aw/kimL89/NierstraszT89", "title": "Integrated Office Systems.", "authors": "Oscar Nierstrasz Dennis Tsichritzis", "misc": "2002-01-03 199-215 1989 Object-Oriented Concepts, Databases, and Applications db/books/collections/kim89.html#NierstraszT89" }, "csx": { "id": 93, "csxid": "oai CiteSeerXPSU 10.1.1.42.9253", "title": "Integrated Office Systems", "authors": "O. M. Nierstrasz D. C. Tsichritzis", "misc": "2009-04-11 Introduction New techniques are sorely needed to aid in the development and maintenance of large application systems. The problem with traditional approaches to software engineering is well in evidence in the field of office information systems it is costly and difficult to extend existing applications, and to get unrelated applications to \"talk\" to each other. The objectoriented approach is already being tentatively applied in the modeling of \"office objects\" and in the presentation of these entities to users as such in \"desktop\" interfaces to office software. In order to fully exploit the approach to achieve integrated office systems, we need to use object-oriented programming languages, object-oriented run-time support, and object-oriented software engineering environments. We can view the fundamental idea behind the object-oriented approach as that of encapsulation object-oriented languages and systems exploit encapsulation in various ways in an attempt t CiteSeerX ACM Press and Addison-Wesley 2009-04-11 2007-11-22 1988 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.42.9253 ftp //ftp.iam.unibe.ch/pub/scg/Papers/integratedOfficeSystems.ps.gz en 10.1.1.26.9545 10.1.1.65.5865 10.1.1.34.624 10.1.1.12.8544 10.1.1.144.6983 10.1.1.26.6746 10.1.1.49.3064 10.1.1.30.4607 10.1.1.38.4894 10.1.1.20.8197 10.1.1.26.4381 10.1.1.29.1890 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
diff --git a/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_3.adm b/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_3.adm
index 9e9c6d4..57135b0 100644
--- a/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_3.adm
+++ b/asterix-app/src/test/resources/runtimets/results/fuzzyjoin/dblp-csx-aqlplus_3.adm
@@ -1,6 +1,5 @@
{ "dblp": { "id": 1, "dblpid": "books/acm/kim95/AnnevelinkACFHK95", "title": "Object SQL - A Language for the Design and Implementation of Object Databases.", "authors": "Jurgen Annevelink Rafiul Ahad Amelia Carlson Daniel H. Fishman Michael L. Heytens William Kent", "misc": "2002-01-03 42-68 1995 Modern Database Systems db/books/collections/kim95.html#AnnevelinkACFHK95" }, "csx": { "id": 1, "csxid": "oai CiteSeerXPSU 10.1.1.39.1830", "title": "Object SQL - A Language for the Design and Implementation of Object Databases", "authors": "Jurgen Annevelink Rafiul Ahad Amelia Carlson Dan Fishman Mike Heytens William Kent", "misc": "2009-04-13 ly, a function application expression consists of two expressions a function reference (labelled func_ref in Figure 3 line 2), and an argument (labelled arg). The func_ref expression evaluates to a (generic or specific) function identifier, which may be the same as the function that the expression is a part of, thus allowing recursive function invocations. The expression labelled arg evaluates to an arbitrary object or aggregate object. The semantics of evaluating function applications was discussed in detail in section 2. For example, to set the name of a person, we evaluate the following expression FunAssign(function name.person) (p1,'John') In this example, the first expression is itself a function call, applying the function FunAssign to the function name.person (an example of a specific function reference). This returns the oid of the function that sets a person's name, which is subsequently applied to a tuple of two elements, the oid of the person and the new name (a string o... CiteSeerX ACM Press 2009-04-13 2007-11-22 1994 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.39.1830 http //www.tu-chemnitz.de/~igrdb/docs/OpenODB/osql.ps.gz en 10.1.1.31.2534 10.1.1.28.4658 10.1.1.44.5947 10.1.1.39.199 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 5, "dblpid": "books/acm/kim95/DayalHW95", "title": "Active Database Systems.", "authors": "Umeshwar Dayal Eric N. Hanson Jennifer Widom", "misc": "2002-01-03 434-456 1995 Modern Database Systems db/books/collections/kim95.html#DayalHW95" }, "csx": { "id": 98, "csxid": "oai CiteSeerXPSU 10.1.1.49.2910", "title": "Active Database Systems", "authors": "Umeshwar Dayal Eric N. Hanson Jennifer Widom", "misc": "2009-04-12 In Won Kim editor Modern Database Systems The Object Model Integrating a production rules facility into a database system provides a uniform mechanism for a number of advanced database features including integrity constraint enforcement, derived data maintenance, triggers, alerters, protection, version control, and others. In addition, a database system with rule processing capabilities provides a useful platform for large and efficient knowledge-base and expert systems. Database systems with production rules are referred to as active database systems, and the field of active database systems has indeed been active. This chapter summarizes current work in active database systems topics covered include active database rule models and languages, rule execution semantics, and implementation issues. 1 Introduction Conventional database systems are passive they only execute queries or transactions explicitly submitted by a user or an application program. For many applications, however, it is important to monitor situations of interest, and to ... CiteSeerX ACM Press 2009-04-12 2007-11-22 1994 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.49.2910 http //www-db.stanford.edu/pub/papers/book-chapter.ps en 10.1.1.17.1323 10.1.1.143.7196 10.1.1.50.3821 10.1.1.51.9946 10.1.1.41.2030 10.1.1.46.2504 10.1.1.52.4421 10.1.1.38.2083 10.1.1.34.661 10.1.1.103.7630 10.1.1.100.9015 10.1.1.97.1699 10.1.1.107.4220 10.1.1.47.9217 10.1.1.133.7157 10.1.1.101.5051 10.1.1.30.9989 10.1.1.53.6941 10.1.1.50.8529 10.1.1.133.4287 10.1.1.50.7278 10.1.1.10.1688 10.1.1.19.8669 10.1.1.44.7600 10.1.1.144.376 10.1.1.44.1348 10.1.1.47.9998 10.1.1.90.4428 10.1.1.108.344 10.1.1.48.9470 10.1.1.53.5472 10.1.1.52.4872 10.1.1.144.4965 10.1.1.31.7578 10.1.1.32.6426 10.1.1.58.6335 10.1.1.85.8052 10.1.1.93.1931 10.1.1.55.4610 10.1.1.21.3821 10.1.1.26.9208 10.1.1.31.4869 10.1.1.48.1833 10.1.1.83.8628 10.1.1.87.9318 10.1.1.90.2195 10.1.1.36.5184 10.1.1.21.1704 10.1.1.53.1733 10.1.1.90.3181 10.1.1.53.6783 10.1.1.52.6151 10.1.1.104.6911 10.1.1.105.1691 10.1.1.21.1984 10.1.1.23.2775 10.1.1.62.5556 10.1.1.68.9063 10.1.1.74.4746 10.1.1.78.5097 10.1.1.84.743 10.1.1.84.904 10.1.1.87.6019 10.1.1.88.3907 10.1.1.89.9631 10.1.1.90.4147 10.1.1.92.365 10.1.1.100.2747 10.1.1.98.5083 10.1.1.98.6663 10.1.1.99.1894 10.1.1.99.8174 10.1.1.133.8073 10.1.1.52.7823 10.1.1.39.5341 10.1.1.35.3458 10.1.1.26.4620 10.1.1.18.8936 10.1.1.19.3694 10.1.1.12.631 10.1.1.48.6394 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
-{ "dblp": { "id": 21, "dblpid": "books/acm/kim95/MengY95", "title": "Query Processing in Multidatabase Systems.", "authors": "Weiyi Meng Clement T. Yu", "misc": "2002-01-03 551-572 1995 Modern Database Systems db/books/collections/kim95.html#MengY95" }, "csx": { "id": 89, "csxid": "oai CiteSeerXPSU 10.1.1.33.8596", "title": "Dynamic Query Optimization and Query Processing in Multidatabase Systems 1.", "authors": "Henryk Josinski", "misc": "2009-04-15 Introduction The multidatabase system (MDBS) approach, as a solution for integrated access to information distributed among diverse data sources, has gained a lot of attention in recent years. The multidatabase system is a database system which integrates pre--existing databases allowing the users to access simultaneously database systems (DBMSs) formulating a global query based on a global schema. The component DBMSs are assumed to be heterogeneous and autonomous. Heterogeneity refers to different user interfaces, data models, query languages, and query optimization strategies [5]. Local autonomy means that each DBMS retains complete control over local data and processing. As result of this, its cost model may not be available to the global query optimizer. When a global query is submitted, it is decomposed into two types of queries [1] -- subqueries, operating on sharable data items from local databases, -- assembling queries, consisting of, CiteSeerX 2009-04-15 2007-11-22 2000 application/pdf text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.33.8596 http //www.edbt2000.uni-konstanz.de/phd-workshop/papers/Josinski.pdf en 10.1.1.27.4704 10.1.1.51.8352 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 25, "dblpid": "books/acm/kim95/RusinkiewiczS95", "title": "Specification and Execution of Transactional Workflows.", "authors": "Marek Rusinkiewicz Amit P. Sheth", "misc": "2004-03-08 592-620 Modern Database Systems books/acm/Kim95 db/books/collections/kim95.html#RusinkiewiczS95 1995" }, "csx": { "id": 88, "csxid": "oai CiteSeerXPSU 10.1.1.43.3839", "title": "Specification and Execution of Transactional Workflows", "authors": "Marek Rusinkiewicz Amit Sheth", "misc": "2009-04-13 The basic transaction model has evolved over time to incorporate more complex transaction structures and to selectively modify the atomicity and isolation properties. In this chapter we discuss the application of transaction concepts to activities that involve coordinated execution of multiple tasks (possibly of different types) over different processing entities. Such applications are referred to as transactional workflows. In this chapter we discuss the specification of such workflows and the issues involved in their execution. 1 What is a Workflow? Workflows are activities involving the coordinated execution of multiple tasks performed by different processing entities. A task defines some work to be done and can be specified in a number of ways, including a textual description in a file or an email, a form, a message, or a computer program. A processing entity that performs the tasks may be a person or a software system (e.g., a mailer, an application program, a database mana... CiteSeerX ACM Press 2009-04-13 2007-11-22 1995 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.43.3839 http //lsdis.cs.uga.edu/lib/././download/RS93.ps en 10.1.1.17.1323 10.1.1.59.5051 10.1.1.38.6210 10.1.1.68.7445 10.1.1.109.5175 10.1.1.17.7962 10.1.1.44.7778 10.1.1.112.244 10.1.1.13.7602 10.1.1.102.7874 10.1.1.41.4043 10.1.1.49.5143 10.1.1.41.7252 10.1.1.17.3225 10.1.1.54.7761 10.1.1.55.5255 10.1.1.108.958 10.1.1.35.7733 10.1.1.52.3682 10.1.1.36.1618 10.1.1.45.6317 10.1.1.43.3180 10.1.1.35.8718 10.1.1.44.6365 10.1.1.51.2883 10.1.1.50.9206 10.1.1.6.9085 10.1.1.30.1707 10.1.1.80.6634 10.1.1.49.355 10.1.1.127.3550 10.1.1.35.3562 10.1.1.137.8832 10.1.1.49.4085 10.1.1.41.5506 10.1.1.40.4657 10.1.1.43.2369 10.1.1.40.832 10.1.1.74.5411 10.1.1.90.4428 10.1.1.110.6967 10.1.1.27.2122 10.1.1.15.5605 10.1.1.54.727 10.1.1.49.7512 10.1.1.45.8796 10.1.1.50.5984 10.1.1.53.137 10.1.1.30.3262 10.1.1.28.1680 10.1.1.21.7110 10.1.1.29.3148 10.1.1.57.687 10.1.1.59.5924 10.1.1.46.2812 10.1.1.51.5552 10.1.1.17.7375 10.1.1.40.1598 10.1.1.52.9787 10.1.1.1.3496 10.1.1.50.6791 10.1.1.55.3358 10.1.1.137.7582 10.1.1.118.4127 10.1.1.49.3580 10.1.1.35.5825 10.1.1.46.9382 10.1.1.31.7411 10.1.1.48.5504 10.1.1.55.5163 10.1.1.18.1603 10.1.1.52.8129 10.1.1.1.9723 10.1.1.21.9113 10.1.1.49.7644 10.1.1.52.6646 10.1.1.75.3106 10.1.1.80.2072 10.1.1.55.8770 10.1.1.54.8188 10.1.1.101.7919 10.1.1.104.8176 10.1.1.24.5741 10.1.1.29.4667 10.1.1.4.1055 10.1.1.48.9175 10.1.1.56.792 10.1.1.65.3172 10.1.1.66.5947 10.1.1.73.8532 10.1.1.83.8299 10.1.1.86.8521 10.1.1.87.2402 10.1.1.87.4648 10.1.1.90.5638 10.1.1.91.1709 10.1.1.94.4248 10.1.1.114.511 10.1.1.119.5037 10.1.1.124.7957 10.1.1.49.215 10.1.1.53.7777 10.1.1.53.9711 10.1.1.45.9409 10.1.1.40.8789 10.1.1.43.4845 10.1.1.34.8273 10.1.1.35.4783 10.1.1.28.3176 10.1.1.16.8151 10.1.1.8.9117 10.1.1.58.3449 10.1.1.142.7041 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 51, "dblpid": "books/aw/kimL89/NierstraszT89", "title": "Integrated Office Systems.", "authors": "Oscar Nierstrasz Dennis Tsichritzis", "misc": "2002-01-03 199-215 1989 Object-Oriented Concepts, Databases, and Applications db/books/collections/kim89.html#NierstraszT89" }, "csx": { "id": 92, "csxid": "oai CiteSeerXPSU 10.1.1.13.2374", "title": "Integrated Office Systems", "authors": "O. M. Nierstrasz D. C. Tsichritzis", "misc": "2009-04-17 Introduction New techniques are sorely needed to aid in the development and maintenance of large application systems. The problem with traditional approaches to software engineering is well in evidence in the field of o#ce information systems it is costly and di#cult to extend existing applications, and to get unrelated applications to \"talk\" to each other. The objectoriented approach is already being tentatively applied in the modeling of \"o#ce objects\" and in the presentation of these entities to users as such in \"desktop\" interfaces to o#ce software. In order to fully exploit the approach to achieve integrated o#ce systems, we need to use object-oriented programming languages, object-oriented run-time support, and object-oriented software engineering environments. We can view the fundamental idea behind the object-oriented approach as that of encapsulation object-oriented languages and systems exploit encapsulation in various ways in an attempt to enhance productivity through, f CiteSeerX 2009-04-17 2007-11-21 1988 application/pdf text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.13.2374 http //www.iam.unibe.ch/~scg/Archive/OSG/Nier89bIntegOfficeSystems.pdf en 10.1.1.26.9545 10.1.1.65.5865 10.1.1.34.624 10.1.1.12.8544 10.1.1.144.6983 10.1.1.26.6746 10.1.1.49.3064 10.1.1.30.4607 10.1.1.38.4894 10.1.1.20.8197 10.1.1.26.4381 10.1.1.29.1890 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
{ "dblp": { "id": 51, "dblpid": "books/aw/kimL89/NierstraszT89", "title": "Integrated Office Systems.", "authors": "Oscar Nierstrasz Dennis Tsichritzis", "misc": "2002-01-03 199-215 1989 Object-Oriented Concepts, Databases, and Applications db/books/collections/kim89.html#NierstraszT89" }, "csx": { "id": 93, "csxid": "oai CiteSeerXPSU 10.1.1.42.9253", "title": "Integrated Office Systems", "authors": "O. M. Nierstrasz D. C. Tsichritzis", "misc": "2009-04-11 Introduction New techniques are sorely needed to aid in the development and maintenance of large application systems. The problem with traditional approaches to software engineering is well in evidence in the field of office information systems it is costly and difficult to extend existing applications, and to get unrelated applications to \"talk\" to each other. The objectoriented approach is already being tentatively applied in the modeling of \"office objects\" and in the presentation of these entities to users as such in \"desktop\" interfaces to office software. In order to fully exploit the approach to achieve integrated office systems, we need to use object-oriented programming languages, object-oriented run-time support, and object-oriented software engineering environments. We can view the fundamental idea behind the object-oriented approach as that of encapsulation object-oriented languages and systems exploit encapsulation in various ways in an attempt t CiteSeerX ACM Press and Addison-Wesley 2009-04-11 2007-11-22 1988 application/postscript text http //citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.42.9253 ftp //ftp.iam.unibe.ch/pub/scg/Papers/integratedOfficeSystems.ps.gz en 10.1.1.26.9545 10.1.1.65.5865 10.1.1.34.624 10.1.1.12.8544 10.1.1.144.6983 10.1.1.26.6746 10.1.1.49.3064 10.1.1.30.4607 10.1.1.38.4894 10.1.1.20.8197 10.1.1.26.4381 10.1.1.29.1890 Metadata may be used without restrictions as long as the oai identifier remains attached to it." } }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/abs3.adm b/asterix-app/src/test/resources/runtimets/results/numeric/abs3.adm
index 4da3272..9cf05af 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/abs3.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/abs3.adm
@@ -1 +1 @@
-{ "d0": 20.1d, "d1": 2.056E-29d, "d2": NaNd, "d3": Infinityd, "d4": Infinityd, "d5": 0.0d, "d6": 0.0d }
+{ "d0": 20.1d, "d1": 2.056E-29d, "d2": NaNd, "d3": Infinityd, "d4": Infinityd, "d5": 0.0d, "d6": 0.0d, "d7": 6.223372036854775808E18d }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/abs4.adm b/asterix-app/src/test/resources/runtimets/results/numeric/abs4.adm
index f365181..01eec81 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/abs4.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/abs4.adm
@@ -1 +1 @@
-{ "f0": 20i8, "f1": 1.11d, "f2": 12.9d, "f3": 1.11d }
+{ "f0": 20i8, "f1": 1.11d, "f2": 12.9d, "f3": 1.11d, "f4": null }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/ceiling3.adm b/asterix-app/src/test/resources/runtimets/results/numeric/ceiling3.adm
index bf497d4..a188100 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/ceiling3.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/ceiling3.adm
@@ -1 +1 @@
-{ "d0": 21.0d, "d1": -0.0d, "d2": NaNd, "d3": Infinityd, "d4": -Infinityd, "d5": -0.0d, "d6": 0.0d }
+{ "d0": 21.0d, "d1": -0.0d, "d2": NaNd, "d3": Infinityd, "d4": -Infinityd, "d5": -0.0d, "d6": 0.0d, "d7": -6.223372036854775808E18d }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/ceiling4.adm b/asterix-app/src/test/resources/runtimets/results/numeric/ceiling4.adm
index dcc17c0..35c0079 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/ceiling4.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/ceiling4.adm
@@ -1 +1 @@
-{ "f0": -20i8, "f1": -1.0d, "f2": 13.0d, "f3": 2.0d }
+{ "f0": -20i8, "f1": -1.0d, "f2": 13.0d, "f3": 2.0d, "f4": null }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/floor3.adm b/asterix-app/src/test/resources/runtimets/results/numeric/floor3.adm
index 58bdd79..34fb2f4 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/floor3.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/floor3.adm
@@ -1 +1 @@
-{ "d0": 20.0d, "d1": -1.0d, "d2": NaNd, "d3": Infinityd, "d4": -Infinityd, "d5": -0.0d, "d6": 0.0d }
+{ "d0": 20.0d, "d1": -1.0d, "d2": NaNd, "d3": Infinityd, "d4": -Infinityd, "d5": -0.0d, "d6": 0.0d, "d7": -6.223372036854775808E18d }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/floor4.adm b/asterix-app/src/test/resources/runtimets/results/numeric/floor4.adm
index 3e972b3..43cd8ae 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/floor4.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/floor4.adm
@@ -1 +1 @@
-{ "f0": -20i8, "f1": -2.0d, "f2": 12.0d, "f3": 1.0d }
+{ "f0": -20i8, "f1": -2.0d, "f2": 12.0d, "f3": 1.0d, "f4": null }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even23.adm b/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even23.adm
index 914a79e..00ca33d 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even23.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even23.adm
@@ -1 +1 @@
-{ "d0": 0.56d, "d1": 0.32d, "d2": NaNd, "d3": Infinityd, "d4": -Infinityd, "d5": -0.0d, "d6": 0.0d }
+{ "d0": 0.56d, "d1": 0.32d, "d2": NaNd, "d3": Infinityd, "d4": -Infinityd, "d5": -0.0d, "d6": 0.0d, "d7": -6223372036854775807.89d }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even24.adm b/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even24.adm
index 956f0ac..01c28f3 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even24.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even24.adm
@@ -1 +1 @@
-{ "d0": 0.02d, "d1": 0.02d, "d2": 3567.81d, "d3": 0.0d, "d4": 35600.0d }
+{ "d0": 0.02d, "d1": 0.02d, "d2": 3567.81d, "d3": 0.0d, "d4": 35600.0d, "d5": null }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even3.adm b/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even3.adm
index 60b7c52..2502aef 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even3.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even3.adm
@@ -1 +1 @@
-{ "d0": 0.0d, "d1": -20.0d, "d2": NaNd, "d3": Infinityd, "d4": -Infinityd, "d5": -0.0d, "d6": 0.0d }
+{ "d0": 0.0d, "d1": -20.0d, "d2": NaNd, "d3": Infinityd, "d4": -Infinityd, "d5": -0.0d, "d6": 0.0d, "d7": -6.223372036854775808E18d }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even5.adm b/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even5.adm
index a53f62f..5507314 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even5.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/round-half-to-even5.adm
@@ -1 +1 @@
-{ "f0": -20i8, "f1": -2.0d, "f2": 12.0d, "f3": 2.0d }
+{ "f0": -20i8, "f1": -2.0d, "f2": 12.0d, "f3": 2.0d, "f4": null }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/round3.adm b/asterix-app/src/test/resources/runtimets/results/numeric/round3.adm
index 1b1936d..9281799 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/round3.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/round3.adm
@@ -1 +1 @@
-{ "d0": 20.0d, "d1": 0.0d, "d2": 0.0d, "d3": 9.223372036854776E18d, "d4": -9.223372036854776E18d, "d5": 0.0d, "d6": 0.0d }
+{ "d0": 20.0d, "d1": 0.0d, "d2": 0.0d, "d3": 9.223372036854776E18d, "d4": -9.223372036854776E18d, "d5": 0.0d, "d6": 0.0d, "d7": -6.223372036854775808E18d }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/round4.adm b/asterix-app/src/test/resources/runtimets/results/numeric/round4.adm
index ce70363..64fc940 100644
--- a/asterix-app/src/test/resources/runtimets/results/numeric/round4.adm
+++ b/asterix-app/src/test/resources/runtimets/results/numeric/round4.adm
@@ -1 +1 @@
-{ "f0": -20i8, "f1": -1.0d, "f2": 13.0d, "f3": 1.0d }
+{ "f0": -20i8, "f1": -1.0d, "f2": 13.0d, "f3": 1.0d, "f4": null }
diff --git a/asterix-app/src/test/resources/runtimets/results/scan/alltypes_02.adm b/asterix-app/src/test/resources/runtimets/results/scan/alltypes_02.adm
new file mode 100644
index 0000000..64aee7c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/scan/alltypes_02.adm
@@ -0,0 +1 @@
+{ "id": 10, "name": "Nancy", "age": 32.5f, "salary": 12.0d, "married": true, "interests": {{ "reading", "writing" }}, "children": [ "Brad", "Scott" ], "address": { "number": 8389, "street": "Hill St.", "city": "Mountain View" }, "dob": date("-2011-01-27"), "time": time("12:20:30.000Z"), "datetime": datetime("-1951-12-27T12:20:30.000Z"), "duration": duration("P10Y11M12DT10H50M30S"), "location2d": point("41.0,44.0"), "location3d": point3d("44.0,13.0,41.0"), "line": line("10.1,11.1 10.2,11.2"), "polygon": polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), "circle": circle("10.1,11.1 10.2") }
diff --git a/asterix-app/src/test/resources/runtimets/results/string/matches11.adm b/asterix-app/src/test/resources/runtimets/results/string/matches11.adm
index 440a996..65ffc69 100644
--- a/asterix-app/src/test/resources/runtimets/results/string/matches11.adm
+++ b/asterix-app/src/test/resources/runtimets/results/string/matches11.adm
@@ -3,3 +3,5 @@
false
false
false
+true
+false
diff --git a/asterix-app/src/test/resources/runtimets/results/string/replace1.adm b/asterix-app/src/test/resources/runtimets/results/string/replace1.adm
index 5f992ce..24d401c 100644
--- a/asterix-app/src/test/resources/runtimets/results/string/replace1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/string/replace1.adm
@@ -1 +1 @@
-{ "result1": "brcdbr", "result2": "abbraccaddabbra", "result3": "carted" }
+{ "result1": "brcdbr", "result2": "abbraccaddabbra", "result3": "carted", "result4": "-h-e-l-l-o-", "result5": null }
diff --git a/asterix-app/src/test/resources/runtimets/results/string/string-equal-true1.adm b/asterix-app/src/test/resources/runtimets/results/string/string-equal-true1.adm
deleted file mode 100644
index ea9ca72..0000000
--- a/asterix-app/src/test/resources/runtimets/results/string/string-equal-true1.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "result1": false }
diff --git a/asterix-app/src/test/resources/runtimets/results/temp/calendar_duration.adm b/asterix-app/src/test/resources/runtimets/results/temp/calendar_duration.adm
deleted file mode 100644
index eb7d565..0000000
--- a/asterix-app/src/test/resources/runtimets/results/temp/calendar_duration.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "cduration1": duration("P20Y3M13DT7H48M21.329S"), "cduration2": duration("-P9M6DT4H45M39.328S"), "cduration3": duration("P8Y6M"), "cduration4": duration("-P21Y7M10DT13H9M42.983S"), "cduration5": duration("P20Y3M12DT7H48M21.329S"), "cduration6": duration("-P9M5DT4H45M39.328S"), "cduration7": duration("P8Y6M"), "cduration8": duration("-P21Y7M10DT13H9M42.983S") }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temp/insert_from_ext_ds.adm b/asterix-app/src/test/resources/runtimets/results/temp/insert_from_ext_ds.adm
deleted file mode 100644
index afe2ccc..0000000
--- a/asterix-app/src/test/resources/runtimets/results/temp/insert_from_ext_ds.adm
+++ /dev/null
@@ -1,3 +0,0 @@
-{ "date": date("-2012-12-12"), "time": time("23:49:12.390Z"), "datetime": datetime("2012-12-12T00:00:00.001Z"), "duration": duration("P20Y19DT4H14M23.34S"), "interval": interval("datetime("2012-12-12T00:00:00.001Z"), datetime("2013-08-10T22:10:15.398Z")") }
-{ "date": null, "time": null, "datetime": datetime("1920-12-20T23:29:18.478Z"), "duration": null, "interval": null }
-{ "date": null, "time": null, "datetime": null, "duration": null, "interval": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temp/accessors.adm b/asterix-app/src/test/resources/runtimets/results/temporal/accessors.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/temp/accessors.adm
rename to asterix-app/src/test/resources/runtimets/results/temporal/accessors.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/temp/adjust_timezone.adm b/asterix-app/src/test/resources/runtimets/results/temporal/adjust_timezone.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/temp/adjust_timezone.adm
rename to asterix-app/src/test/resources/runtimets/results/temporal/adjust_timezone.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/calendar_duration.adm b/asterix-app/src/test/resources/runtimets/results/temporal/calendar_duration.adm
new file mode 100644
index 0000000..957388f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/calendar_duration.adm
@@ -0,0 +1 @@
+{ "cduration1": duration("P20Y3M12DT7H48M21.329S"), "c1": true, "cduration2": duration("-P9M6DT4H45M39.328S"), "c2": true, "cduration3": duration("P8Y6M"), "c3": true, "cduration4": duration("-P21Y7M10DT13H9M42.983S"), "c4": true, "cduration5": duration("P20Y3M12DT7H48M21.329S"), "c5": true, "cduration6": duration("-P9M5DT4H45M39.328S"), "c6": true, "cduration7": duration("P8Y6M"), "c7": true, "cduration8": duration("-P21Y7M10DT13H9M42.983S"), "c8": true }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temp/date_functions.adm b/asterix-app/src/test/resources/runtimets/results/temporal/date_functions.adm
similarity index 80%
rename from asterix-app/src/test/resources/runtimets/results/temp/date_functions.adm
rename to asterix-app/src/test/resources/runtimets/results/temporal/date_functions.adm
index 2276f85..a5285d8 100644
--- a/asterix-app/src/test/resources/runtimets/results/temp/date_functions.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/date_functions.adm
@@ -1 +1 @@
-{ "date1": date("2012-09-17"), "date2": date("1327-12-02"), "date3": date("2012-10-10"), "date4": date("2010-05-17"), "date5": date("1703-08-09"), "duration1": duration("P137216D"), "duration2": duration("-P854D") }
\ No newline at end of file
+{ "date1": date("2012-09-17"), "date2": date("1327-12-02"), "date3": date("2012-10-10"), "date4": date("2010-05-17"), "date5": date("1703-08-09"), "duration1": duration("P137216D"), "duration2": duration("-P854D"), "c1": true, "c2": true }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temp/datetime_functions.adm b/asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions.adm
similarity index 88%
rename from asterix-app/src/test/resources/runtimets/results/temp/datetime_functions.adm
rename to asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions.adm
index 6ebc562..01f3758 100644
--- a/asterix-app/src/test/resources/runtimets/results/temp/datetime_functions.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions.adm
@@ -1 +1 @@
-{ "datetime1": datetime("1970-01-12T01:33:27.429Z"), "datetime2": datetime("1327-12-02T23:35:49.938Z"), "datetime3": datetime("1327-12-02T23:35:49.938Z"), "duration1": duration("-P234526DT1H57M37.491S") }
\ No newline at end of file
+{ "datetime1": datetime("1970-01-12T01:33:27.429Z"), "datetime2": datetime("1327-12-02T23:35:49.938Z"), "datetime3": datetime("1327-12-02T23:35:49.938Z"), "duration1": duration("-P234526DT1H57M37.491S"), "c1": true }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temp/insert_from_delimited_ds.adm b/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_delimited_ds.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/temp/insert_from_delimited_ds.adm
rename to asterix-app/src/test/resources/runtimets/results/temporal/insert_from_delimited_ds.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_ext_ds.adm b/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_ext_ds.adm
new file mode 100644
index 0000000..b087496
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_ext_ds.adm
@@ -0,0 +1,3 @@
+{ "date": date("-2012-12-12"), "time": time("23:49:12.390Z"), "datetime": datetime("2012-12-12T00:00:00.001Z"), "duration": duration("P20Y19DT4H14M23.34S"), "interval": interval-datetime("2012-12-12T00:00:00.001Z, 2013-08-10T22:10:15.398Z") }
+{ "date": null, "time": time("04:12:12.219Z"), "datetime": datetime("1920-12-21T11:29:18.478Z"), "duration": null, "interval": interval-time("04:29:30.000Z, 07:59:59.999Z") }
+{ "date": null, "time": null, "datetime": datetime("-0290-03-22T17:59:48.999Z"), "duration": duration("-P27Y148D"), "interval": interval-date("-2012-03-17, 2013-04-01") }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temp/interval_functions.adm b/asterix-app/src/test/resources/runtimets/results/temporal/interval_functions.adm
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/results/temp/interval_functions.adm
rename to asterix-app/src/test/resources/runtimets/results/temporal/interval_functions.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/temp/time_functions.adm b/asterix-app/src/test/resources/runtimets/results/temporal/time_functions.adm
similarity index 75%
rename from asterix-app/src/test/resources/runtimets/results/temp/time_functions.adm
rename to asterix-app/src/test/resources/runtimets/results/temporal/time_functions.adm
index 56531bd..791d652 100644
--- a/asterix-app/src/test/resources/runtimets/results/temp/time_functions.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/time_functions.adm
@@ -1 +1 @@
-{ "time1": time("00:26:00.074Z"), "time2": time("23:35:49.938Z"), "time3": time("23:30:23.000Z"), "time4": time("18:26:00.074Z"), "time5": time("00:11:49.938Z"), "duration1": duration("-PT23H24M"), "duration2": duration("PT18H") }
\ No newline at end of file
+{ "time1": time("00:26:00.074Z"), "time2": time("23:35:49.938Z"), "time3": time("23:30:23.000Z"), "time4": time("18:26:00.074Z"), "time5": time("00:11:49.938Z"), "duration1": duration("-PT23H24M"), "duration2": duration("PT18H"), "c1": true, "c2": true }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 5f52f9a..809c40b 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -754,6 +754,11 @@
</compilation-unit>
</test-case>
<test-case FilePath="dml">
+ <compilation-unit name="delete-syntax-change">
+ <output-file compare="Text">delete-syntax-change.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="dml">
<compilation-unit name="drop-empty-secondary-indexes">
<output-file compare="Text">drop-empty-secondary-indexes.adm</output-file>
</compilation-unit>
@@ -784,8 +789,13 @@
</compilation-unit>
</test-case>
<test-case FilePath="dml">
- <compilation-unit name="insert-into-empty-dataset">
- <output-file compare="Text">insert-into-empty-dataset.adm</output-file>
+ <compilation-unit name="insert-into-empty-dataset-with-index">
+ <output-file compare="Text">insert-into-empty-dataset-with-index.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="dml">
+ <compilation-unit name="insert-syntax">
+ <output-file compare="Text">insert-syntax.adm</output-file>
</compilation-unit>
</test-case>
<test-case FilePath="dml">
@@ -2728,6 +2738,12 @@
</compilation-unit>
</test-case>
<test-case FilePath="scan">
+ <compilation-unit name="invalid-scan-syntax">
+ <output-file compare="Text">invalid-scan-syntax.adm</output-file>
+ <expected-error>SyntaxError</expected-error>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="scan">
<compilation-unit name="30">
<output-file compare="Text">30.adm</output-file>
</compilation-unit>
@@ -2738,6 +2754,11 @@
</compilation-unit>
</test-case>
<test-case FilePath="scan">
+ <compilation-unit name="alltypes_02">
+ <output-file compare="Text">alltypes_02.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="scan">
<compilation-unit name="numeric_types_01">
<output-file compare="Text">numeric_types_01.adm</output-file>
</compilation-unit>
@@ -3759,6 +3780,11 @@
</compilation-unit>
</test-case>
<test-case FilePath="cross-dataverse">
+ <compilation-unit name="cross-dv20">
+ <output-file compare="Text">cross-dv20.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="cross-dataverse">
<compilation-unit name="insert_across_dataverses">
<output-file compare="Text">insert_across_dataverses.adm</output-file>
</compilation-unit>
@@ -3995,4 +4021,76 @@
</compilation-unit>
</test-case>
</test-group>
-</test-suite>
+ <test-group name="temporal">
+ <test-case FilePath="temporal">
+ <compilation-unit name="accessors">
+ <output-file compare="Text">accessors.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="adjust_timezone">
+ <output-file compare="Text">adjust_timezone.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="calendar_duration">
+ <output-file compare="Text">calendar_duration.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="date_functions">
+ <output-file compare="Text">date_functions.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="datetime_functions">
+ <output-file compare="Text">datetime_functions.adm</output-file>
+ </compilation-unit>
+ </test-case>
+<!-- <test-case FilePath="temporal">
+ <compilation-unit name="insert_from_delimited_ds">
+ <output-file compare="Text">insert_from_delimited_ds.adm</output-file>
+ </compilation-unit>
+ </test-case> -->
+ <test-case FilePath="temporal">
+ <compilation-unit name="insert_from_ext_ds">
+ <output-file compare="Text">insert_from_ext_ds.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="interval_functions">
+ <output-file compare="Text">interval_functions.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="time_functions">
+ <output-file compare="Text">time_functions.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="constructor">
+ <compilation-unit name="date_01">
+ <output-file compare="Text">date_01.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="constructor">
+ <compilation-unit name="time_01">
+ <output-file compare="Text">time_01.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="constructor">
+ <compilation-unit name="datetime_01">
+ <output-file compare="Text">datetime_01.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="constructor">
+ <compilation-unit name="duration_01">
+ <output-file compare="Text">duration_01.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="constructor">
+ <compilation-unit name="interval">
+ <output-file compare="Text">interval.adm</output-file>
+ </compilation-unit>
+ </test-case>
+ </test-group>
+</test-suite>
\ No newline at end of file
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index 5256322..5ede3ac 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -260,7 +260,7 @@
datasetName = nameComponents.second;
}
- <LEFTPAREN> query = Query() <RIGHTPAREN> ";"
+ (<LEFTPAREN>)? query = Query() (<RIGHTPAREN>)? (";")?
{return new InsertStatement(dataverseName, datasetName, query, getVarCounter());}
}
@@ -280,7 +280,7 @@
{
nameComponents = getDotSeparatedPair();
}
- ("where" condition = Expression())? (dieClause = DieClause())? ";"
+ ("where" condition = Expression())? (dieClause = DieClause())? (";")?
{return new DeleteStatement(var, nameComponents.first, nameComponents.second, condition, dieClause, getVarCounter()); }
}
@@ -1828,10 +1828,11 @@
Expression expr = null;
}
{
- //Literal | VariableRef | ListConstructor | RecordConstructor | FunctionCallExpr | ParenthesizedExpression
+ //Literal | VariableRef | ListConstructor | RecordConstructor | FunctionCallExpr | DatasetAccessExpression | ParenthesizedExpression
(
expr =Literal()
| expr = FunctionCallExpr()
+ | expr = DatasetAccessExpression()
| expr =VariableRef()
{
@@ -2056,7 +2057,8 @@
String id2=null;
}
{
- ( <IDENTIFIER> { dataverse = defaultDataverse; funcName = token.image;} ("." <IDENTIFIER> { dataverse = funcName; funcName = token.image;})? | <DATASET> {dataverse = MetadataConstants.METADATA_DATAVERSE_NAME; funcName = getToken(0).toString();})
+
+ <IDENTIFIER> { dataverse = defaultDataverse; funcName = token.image;} ("." <IDENTIFIER> { dataverse = funcName; funcName = token.image;})?
{
hint = getHint(token);
}
@@ -2080,7 +2082,34 @@
}
}
-
+Expression DatasetAccessExpression() throws ParseException:
+{
+ CallExpr callExpr;
+ List<Expression> argList = new ArrayList<Expression>();
+ String funcName;
+ String dataverse;
+ LiteralExpr ds;
+ LiteralExpr dvds;
+ Expression nameArg;
+ int arity = 0;
+}
+{
+ <DATASET> {dataverse = MetadataConstants.METADATA_DATAVERSE_NAME; funcName = getToken(0).toString();}
+ (
+ (<IDENTIFIER> {ds = new LiteralExpr(); ds.setValue( new StringLiteral(token.image) ); argList.add(ds); arity ++;} ("." <IDENTIFIER> { dvds = new LiteralExpr(); dvds.setValue(new StringLiteral(ds.getValue()+"."+token.image)); argList.remove(0); argList.add(dvds);})? ) |
+ (<LEFTPAREN> nameArg = Expression() {argList.add(nameArg); arity ++;} ("," nameArg = Expression() { argList.add(nameArg); arity++; })* <RIGHTPAREN>)
+ )
+
+ {
+ FunctionSignature signature = lookupFunctionSignature(dataverse, funcName.toString(), arity);
+ if(signature == null)
+ {
+ signature = new FunctionSignature(dataverse, funcName.toString(), arity);
+ }
+ callExpr = new CallExpr(signature,argList);
+ return callExpr;
+ }
+}
Expression ParenthesizedExpression() throws ParseException:
{
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java
index 1139e98..c3c4b87 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java
@@ -25,8 +25,6 @@
public static final int DEFAULT_BUFFER_CACHE_NUM_PAGES = 4096;
- public static final String HYRACKS_APP_NAME = "asterix";
-
public static final int DEFAULT_FRAME_SIZE = 32768;
public static final String FRAME_SIZE_PROPERTY = "FrameSize";
diff --git a/asterix-dist/pom.xml b/asterix-dist/pom.xml
deleted file mode 100644
index 654a11e..0000000
--- a/asterix-dist/pom.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>asterix-dist</artifactId>
- <parent>
- <groupId>edu.uci.ics.asterix</groupId>
- <artifactId>asterix</artifactId>
- <version>0.0.4-SNAPSHOT</version>
- </parent>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-5</version>
- <executions>
- <execution>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/binary-assembly.xml</descriptor>
- </descriptors>
- </configuration>
- <phase>package</phase>
- <goals>
- <goal>attached</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>edu.uci.ics.hyracks</groupId>
- <artifactId>hyracks-server</artifactId>
- <version>0.2.3-SNAPSHOT</version>
- <type>zip</type>
- <classifier>binary-assembly</classifier>
- </dependency>
- <dependency>
- <groupId>edu.uci.ics.hyracks</groupId>
- <artifactId>hyracks-cli</artifactId>
- <version>0.2.3-SNAPSHOT</version>
- <type>zip</type>
- <classifier>binary-assembly</classifier>
- </dependency>
- <dependency>
- <groupId>edu.uci.ics.asterix</groupId>
- <artifactId>asterix-app</artifactId>
- <version>0.0.4-SNAPSHOT</version>
- <type>zip</type>
- <classifier>binary-assembly</classifier>
- </dependency>
- </dependencies>
-</project>
diff --git a/asterix-dist/src/main/assembly/binary-assembly.xml b/asterix-dist/src/main/assembly/binary-assembly.xml
deleted file mode 100644
index ecf6d32..0000000
--- a/asterix-dist/src/main/assembly/binary-assembly.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<assembly>
- <id>binary-assembly</id>
- <formats>
- <format>zip</format>
- <format>dir</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
- <fileSets>
- <fileSet>
- <directory>src/main/scripts</directory>
- <outputDirectory>.</outputDirectory>
- </fileSet>
- </fileSets>
- <dependencySets>
- <dependencySet>
- <outputDirectory>hyracks-server</outputDirectory>
- <includes>
- <include>hyracks-server*</include>
- </includes>
- <unpack>true</unpack>
- <useTransitiveDependencies>false</useTransitiveDependencies>
- </dependencySet>
- <dependencySet>
- <outputDirectory>hyracks-cli</outputDirectory>
- <includes>
- <include>hyracks-cli*</include>
- </includes>
- <unpack>true</unpack>
- <useTransitiveDependencies>false</useTransitiveDependencies>
- </dependencySet>
- <dependencySet>
- <outputDirectory>asterix</outputDirectory>
- <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>asterix-app*</include>
- </includes>
- <useTransitiveDependencies>false</useTransitiveDependencies>
- </dependencySet>
- <!--dependencySet>
- <outputDirectory>archives</outputDirectory>
- <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
- <excludes>
- <exclude>asterix-dist*</exclude>
- </excludes>
- <useTransitiveDependencies>false</useTransitiveDependencies>
- </dependencySet-->
- </dependencySets>
-</assembly>
diff --git a/asterix-dist/src/main/scripts/startasterix.sh b/asterix-dist/src/main/scripts/startasterix.sh
deleted file mode 100644
index b84834f..0000000
--- a/asterix-dist/src/main/scripts/startasterix.sh
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/bash
-
-# Logging output for the CC and NCs is directed to their appropriately named
-# files in LOG_HOME
-#
-# Example usage: ./runasterix.sh 4
-# Loads 1 CC, 4 NCs (nc0, nc1, nc2, and nc3)
-#
-
-BASEDIR=`pwd`/$(dirname $0)
-echo "Base dir: " ${BASEDIR}
-
-ASTERIX_BIN=${BASEDIR}/asterix/asterix-app.zip
-HYRACKS_SERVER_BIN=${BASEDIR}/hyracks-server/bin
-HYRACKS_CLI_BIN=${BASEDIR}/hyracks-cli/bin
-
-CONFIG_DIR=${BASEDIR}/config
-LOG_DIR=${BASEDIR}/log
-
-mkdir ${LOG_DIR} ${CONFIG_DIR}
-
-CONFIG_NAME=local-autogen.properties # name of config file to generate
-
-# check existence of directories
-dirs=($HYRACKS_SERVER_BIN $HYRACKS_CLI_BIN $LOG_DIR $CONFIG_DIR)
-for i in "${dirs[@]}"
-do
- if [ ! -d "$i" ]
- then
- printf "Error: invalid directory layout -- can't access $i\n" >&2
- exit 2
- fi
-done
-
-# set number of node controllers to load
-if [ "$1" == "" ]
-then
- numnc=1
-else
- if echo $1 | egrep -q '^[0-9]+$'; then
- numnc=$1
- else
- printf "Error: $1 is not a number.\n" >&2
- printf "usage: %s [number_of_ncs]\n" $(basename $0) >&2
- exit 2
- fi
-fi
-
-# generate a suitable config file
-echo "generating config file..."
-printf "MetadataNode=nc1\nNewUniverse=true\n" > $CONFIG_DIR/$CONFIG_NAME
-for ((i=1;i<=$numnc;i++)); do
- echo "nc$i.stores=/tmp/nc$i/" >> $CONFIG_DIR/$CONFIG_NAME
-done
-echo "OutputDir=/tmp/asterix_output/" >> $CONFIG_DIR/$CONFIG_NAME
-
-# point to the config file and give java some extra memory
-export CLASSPATH_PREFIX=$CONFIG_DIR
-export JAVA_OPTS="-DAsterixConfigFileName=$CONFIG_NAME -Xms256m -Xmx512m"
-
-echo "cluster controller starting..."
-sh $HYRACKS_SERVER_BIN/hyrackscc -cc-root localhost -client-net-ip-address 127.0.0.1 -cluster-net-ip-address 127.0.0.1 &> $LOG_DIR/cc.log &
-
-# for some reason this helps against getting a socket error
-sleep 3
-
-# start the node controllers
-for ((i=1;i<=$numnc;i++)); do
- echo "node controller (nc$i) starting..."
- sh $HYRACKS_SERVER_BIN/hyracksnc -cc-host localhost -cluster-net-ip-address 127.0.0.1 -data-ip-address 127.0.0.1 -node-id "nc$i" \
- &> $LOG_DIR/nc$i.log &
-
- # avoid socket error
- sleep .5
-done
-
-# deploy the asterix application to hyracks
-echo "connect to \"localhost\";create application asterix \"$ASTERIX_BIN\";" > $CONFIG_DIR/deploy.hcli
-cat $CONFIG_DIR/deploy.hcli | sh $HYRACKS_CLI_BIN/hyrackscli
diff --git a/asterix-dist/src/main/scripts/stopasterix.sh b/asterix-dist/src/main/scripts/stopasterix.sh
deleted file mode 100644
index 7b32b85..0000000
--- a/asterix-dist/src/main/scripts/stopasterix.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-# get the PIDs of java processes we started
-if [ "$JAVA_HOME" != "" ]
-then
- PIDS=`$JAVA_HOME/bin/jps`
-else
- PIDS=`jps`
-fi
-
-while IFS='\n' read -ra MYPIDS; do
- for i in "${MYPIDS[@]}"; do
- pid=`echo $i | grep 'CCDriver\|NCDriver\|VirtualClusterDriver' | awk '{print $1}'`
- name=`echo $i | grep 'CCDriver\|NCDriver\|VirtualClusterDriver' | awk '{print $2}'`
- if [ "$pid" != "" ]
- then
- echo "Stopping $name: $pid"
- kill -9 $pid
- fi
- done
-done <<< "$PIDS"
diff --git a/asterix-events/pom.xml b/asterix-events/pom.xml
new file mode 100644
index 0000000..46bb96a
--- /dev/null
+++ b/asterix-events/pom.xml
@@ -0,0 +1,171 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>asterix</artifactId>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <version>0.0.4-SNAPSHOT</version>
+ </parent>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-events</artifactId>
+ <version>0.0.4-SNAPSHOT</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>event</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <args>
+ <arg>-Xsetters</arg>
+ <arg>-Xvalue-constructor</arg>
+ </args>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-basics</artifactId>
+ <version>0.6.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-value-constructor</artifactId>
+ <version>3.0</version>
+ </plugin>
+ </plugins>
+ <schemaDirectory>src/main/resources/schema</schemaDirectory>
+ <schemaIncludes>
+ <include>event.xsd</include>
+ </schemaIncludes>
+ <generatePackage>edu.uci.ics.asterix.event.schema.event</generatePackage>
+ <generateDirectory>${project.build.directory}/generated-sources/event</generateDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <id>pattern</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <args>
+ <arg>-Xsetters</arg>
+ <arg>-Xvalue-constructor</arg>
+ </args>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-basics</artifactId>
+ <version>0.6.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-value-constructor</artifactId>
+ <version>3.0</version>
+ </plugin>
+ </plugins>
+ <schemaDirectory>src/main/resources/schema</schemaDirectory>
+ <schemaIncludes>
+ <include>pattern.xsd</include>
+ </schemaIncludes>
+ <generatePackage>edu.uci.ics.asterix.event.schema.pattern</generatePackage>
+ <generateDirectory>${project.build.directory}/generated-sources/pattern</generateDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <id>cluster</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <args>
+ <arg>-Xsetters</arg>
+ <arg>-Xvalue-constructor</arg>
+ </args>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-basics</artifactId>
+ <version>0.6.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-value-constructor</artifactId>
+ <version>3.0</version>
+ </plugin>
+ </plugins>
+ <schemaDirectory>src/main/resources/schema</schemaDirectory>
+ <schemaIncludes>
+ <include>cluster.xsd</include>
+ </schemaIncludes>
+ <generatePackage>edu.uci.ics.asterix.event.schema.cluster</generatePackage>
+ <generateDirectory>${project.build.directory}/generated-sources/cluster</generateDirectory>
+ <bindingDirectory>src/main/resources/schema</bindingDirectory>
+ <bindingIncludes>
+ <bindingInclude>jaxb-bindings.xjb</bindingInclude>
+ </bindingIncludes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-2</version>
+ <executions>
+ <execution>
+ <configuration>
+ <descriptor>src/main/assembly/binary-assembly.xml</descriptor>
+ </configuration>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>args4j</groupId>
+ <artifactId>args4j</artifactId>
+ <version>2.0.12</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-value-constructor</artifactId>
+ <version>3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/asterix-events/src/main/assembly/binary-assembly.xml b/asterix-events/src/main/assembly/binary-assembly.xml
new file mode 100644
index 0000000..29ebbdd
--- /dev/null
+++ b/asterix-events/src/main/assembly/binary-assembly.xml
@@ -0,0 +1,27 @@
+<assembly>
+ <id>bin</id>
+ <formats>
+ <format>tar.gz</format>
+ <format>tar.bz2</format>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/resources/events</directory>
+ <outputDirectory>events</outputDirectory>
+ <includes></includes>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/resources/scripts</directory>
+ <outputDirectory>scripts</outputDirectory>
+ <includes></includes>
+ </fileSet>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory>target</outputDirectory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/api/ClusterInfo.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/api/ClusterInfo.java
new file mode 100644
index 0000000..630f9b3
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/api/ClusterInfo.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.api;
+
+import java.util.List;
+
+public class ClusterInfo {
+
+ List<NodeInfo> nodes;
+
+ public ClusterInfo(List<NodeInfo> nodes) {
+ this.nodes = nodes;
+ }
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/api/NodeInfo.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/api/NodeInfo.java
new file mode 100644
index 0000000..835e0dc
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/api/NodeInfo.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.api;
+
+public class NodeInfo {
+
+ private final String id;
+ private final String ip;
+
+ public NodeInfo(String id, String ip) {
+ this.id = id;
+ this.ip = ip;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getIp() {
+ return ip;
+ }
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventConfig.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventConfig.java
new file mode 100644
index 0000000..9d0138b
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventConfig.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.driver;
+
+import org.kohsuke.args4j.Option;
+
+public class EventConfig {
+
+ @Option(name = "-h", required = false, usage = "Help")
+ public boolean help = false;
+
+ @Option(name = "-d", required = false, usage = "Show the execution on a timeline")
+ public boolean dryRun = false;
+
+ @Option(name = "-s", required = false, usage = "Seed for randomization")
+ public int seed = -1;
+
+ @Option(name = "-c", required = true, usage = "Path to cluster configuration (REQUIRED)")
+ public String clusterPath;
+
+ @Option(name = "-p", required = true, usage = "Path to pattern configuration (REQUIRED)")
+ public String patternPath;
+
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java
new file mode 100644
index 0000000..d3c338d
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.driver;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.kohsuke.args4j.CmdLineParser;
+
+import edu.uci.ics.asterix.event.management.DefaultOutputHandler;
+import edu.uci.ics.asterix.event.management.EventUtil;
+import edu.uci.ics.asterix.event.management.EventrixClient;
+import edu.uci.ics.asterix.event.management.IOutputHandler;
+import edu.uci.ics.asterix.event.management.Randomizer;
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.cluster.Property;
+import edu.uci.ics.asterix.event.schema.event.Events;
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+
+public class EventDriver {
+
+ public static final String CLIENT_NODE_ID = "client_node";
+ public static final Node CLIENT_NODE = new Node(CLIENT_NODE_ID, "127.0.0.1", null, null, null, null, null);
+
+ private static String eventsDir;
+ private static Events events;
+ private static Map<String, String> env = new HashMap<String, String>();
+ private static String scriptDirSuffix;
+
+ public static String getEventsDir() {
+ return eventsDir;
+ }
+
+ public static Events getEvents() {
+ return events;
+ }
+
+ public static Map<String, String> getEnvironment() {
+ return env;
+ }
+
+ public static String getStringifiedEnv(Cluster cluster) {
+ StringBuffer buffer = new StringBuffer();
+ for (Property p : cluster.getEnv().getProperty()) {
+ buffer.append(p.getKey() + "=" + p.getValue() + " ");
+ }
+ return buffer.toString();
+ }
+
+ public static Cluster initializeCluster(String path) throws JAXBException, IOException {
+ File file = new File(path);
+ JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ Cluster cluster = (Cluster) unmarshaller.unmarshal(file);
+ for (Property p : cluster.getEnv().getProperty()) {
+ env.put(p.getKey(), p.getValue());
+ }
+ return cluster;
+ }
+
+ public static Patterns initializePatterns(String path) throws JAXBException, IOException {
+ File file = new File(path);
+ JAXBContext ctx = JAXBContext.newInstance(Patterns.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ return (Patterns) unmarshaller.unmarshal(file);
+ }
+
+ private static void initialize(EventConfig eventConfig) throws IOException, JAXBException {
+
+ }
+
+ public static EventrixClient getClient(String eventsDir, Cluster cluster, boolean dryRun) throws Exception {
+ return new EventrixClient(eventsDir, cluster, dryRun, new DefaultOutputHandler());
+ }
+
+ public static EventrixClient getClient(String eventsDir, Cluster cluster, boolean dryRun,
+ IOutputHandler outputHandler) throws Exception {
+ return new EventrixClient(eventsDir, cluster, dryRun, outputHandler);
+ }
+
+ public static void main(String[] args) throws Exception {
+ String eventsHome = System.getenv("EVENT_HOME");
+ if (eventsHome == null) {
+ throw new IllegalStateException("EVENT_HOME is not set");
+ }
+ eventsDir = eventsHome + File.separator + EventUtil.EVENTS_DIR;
+ EventConfig eventConfig = new EventConfig();
+ CmdLineParser parser = new CmdLineParser(eventConfig);
+ try {
+ parser.parseArgument(args);
+ if (eventConfig.help) {
+ parser.printUsage(System.out);
+ }
+ if (eventConfig.seed > 0) {
+ Randomizer.getInstance(eventConfig.seed);
+ }
+ Cluster cluster = initializeCluster(eventConfig.clusterPath);
+ Patterns patterns = initializePatterns(eventConfig.patternPath);
+ initialize(eventConfig);
+
+ if (!eventConfig.dryRun) {
+ prepare(cluster);
+ }
+ EventrixClient client = new EventrixClient(eventsDir, cluster, eventConfig.dryRun,
+ new DefaultOutputHandler());
+ client.submit(patterns);
+ if (!eventConfig.dryRun) {
+ cleanup(cluster);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ parser.printUsage(System.err);
+ }
+ }
+
+ private static void prepare(Cluster cluster) throws IOException, InterruptedException {
+
+ scriptDirSuffix = "" + System.nanoTime();
+ List<String> args = new ArrayList<String>();
+ args.add(scriptDirSuffix);
+ Node clientNode = new Node();
+ clientNode.setId("client");
+ clientNode.setIp("127.0.0.1");
+ for (Node node : cluster.getNode()) {
+ args.add(node.getIp());
+ }
+ EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events" + "/" + "prepare.sh", args);
+ }
+
+ private static void cleanup(Cluster cluster) throws IOException, InterruptedException {
+ List<String> args = new ArrayList<String>();
+ args.add(scriptDirSuffix);
+ Node clientNode = new Node();
+ clientNode.setId("client");
+ clientNode.setIp("127.0.0.1");
+ for (Node node : cluster.getNode()) {
+ args.add(node.getIp());
+ }
+ EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events" + "/" + "cleanup.sh", args);
+ }
+
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/DefaultOutputHandler.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/DefaultOutputHandler.java
new file mode 100644
index 0000000..e8f06a0
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/DefaultOutputHandler.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+import edu.uci.ics.asterix.event.schema.pattern.Event;
+
+public class DefaultOutputHandler implements IOutputHandler {
+
+ @Override
+ public OutputAnalysis reportEventOutput(Event event, String output) {
+ return new OutputAnalysis(true, null);
+ }
+
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/ErrorHandler.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/ErrorHandler.java
new file mode 100644
index 0000000..a6c038b
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/ErrorHandler.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+public class ErrorHandler {
+
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java
new file mode 100644
index 0000000..0157f65
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.IOUtils;
+
+import edu.uci.ics.asterix.event.driver.EventDriver;
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.cluster.Property;
+import edu.uci.ics.asterix.event.schema.pattern.Pattern;
+
+public class EventExecutor {
+
+ public static final String EVENTS_DIR = "events";
+ private static final String EXECUTE_SCRIPT = "execute.sh";
+ private static final String IP_LOCATION = "IP_LOCATION";
+ private static final String CLUSTER_ENV = "ENV";
+ private static final String SCRIPT = "SCRIPT";
+ private static final String ARGS = "ARGS";
+ private static final String DAEMON = "DAEMON";
+
+ public void executeEvent(Node node, String script, List<String> args, boolean isDaemon, Cluster cluster,
+ Pattern pattern, IOutputHandler outputHandler, EventrixClient client) throws IOException {
+ List<String> pargs = new ArrayList<String>();
+ pargs.add("/bin/bash");
+ pargs.add(client.getEventsDir() + File.separator + "scripts" + File.separator + EXECUTE_SCRIPT);
+ StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "=" + node.getIp() + " ");
+ if (!node.getId().equals(EventDriver.CLIENT_NODE_ID) && cluster.getEnv() != null) {
+ for (Property p : cluster.getEnv().getProperty()) {
+ if (p.getKey().equals("JAVA_HOME")) {
+ String val = node.getJavaHome() == null ? p.getValue() : node.getJavaHome();
+ envBuffer.append(p.getKey() + "=" + val + " ");
+ } else if (p.getKey().equals("JAVA_OPTS")) {
+ String val = "\"" + "-Xmx"
+ + (node.getJavaHeap() == null ? cluster.getJavaHeap() : node.getJavaHeap());
+ if (node.getDebug() != null) {
+ val = val + " " + "-Xdebug -Xrunjdwp:transport=dt_socket,address=" + node.getDebug().intValue()
+ + "," + "server=y,suspend=n";
+ }
+ val = val + "\"";
+ envBuffer.append(p.getKey() + "=" + val + " ");
+ } else {
+ envBuffer.append(p.getKey() + "=" + p.getValue() + " ");
+ }
+
+ }
+ pargs.add(cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername());
+ }
+ StringBuffer argBuffer = new StringBuffer();
+ if (args != null && args.size() > 0) {
+ for (String arg : args) {
+ argBuffer.append(arg + " ");
+ }
+ }
+
+ ProcessBuilder pb = new ProcessBuilder(pargs);
+ pb.environment().put(IP_LOCATION, node.getIp());
+ pb.environment().put(CLUSTER_ENV, envBuffer.toString());
+ pb.environment().put(SCRIPT, script);
+ pb.environment().put(ARGS, argBuffer.toString());
+ pb.environment().put(DAEMON, isDaemon ? "true" : "false");
+
+ Process p = pb.start();
+ if (!isDaemon) {
+ BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
+ StringWriter writer = new StringWriter();
+ IOUtils.copy(bis, writer, "UTF-8");
+ String result = writer.getBuffer().toString();
+ OutputAnalysis analysis = outputHandler.reportEventOutput(pattern.getEvent(), result);
+ if (!analysis.isExpected()) {
+ throw new IOException(analysis.getErrorMessage() + result);
+ }
+ }
+ }
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventTask.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventTask.java
new file mode 100644
index 0000000..2586adf
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventTask.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+import org.apache.log4j.Logger;
+
+import edu.uci.ics.asterix.event.driver.EventDriver;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.event.Event;
+import edu.uci.ics.asterix.event.schema.pattern.Pattern;
+import edu.uci.ics.asterix.event.schema.pattern.Period;
+
+public class EventTask extends TimerTask {
+
+ public static enum State {
+ INITIALIZED, IN_PROGRESS, COMPLETED, FAILED
+ }
+
+ private static final Logger logger = Logger.getLogger(EventTask.class
+ .getName());
+
+ private Pattern pattern;
+ private Event event;
+ private long interval = 0;
+ private long initialDelay = 0;
+ private int maxOccurs = Integer.MAX_VALUE;
+ private int occurrenceCount = 0;
+ private Timer timer;
+ private String taskScript;
+ private Node location;
+ private List<String> taskArgs;
+ private EventrixClient client;
+ private List<Node> candidateLocations;
+ private boolean dynamicLocation = false;
+ private boolean reuseLocation = false;
+ private State state;
+
+
+
+ public EventTask(Pattern pattern, EventrixClient client) {
+ this.pattern = pattern;
+ this.client = client;
+ Period period = pattern.getPeriod();
+ if (period != null && period.getAbsvalue() != null) {
+ this.interval = EventUtil.parseTimeInterval(period.getAbsvalue(),
+ period.getUnit());
+ }
+ if (pattern.getDelay() != null) {
+ this.initialDelay = EventUtil.parseTimeInterval(new ValueType(
+ pattern.getDelay().getValue()), pattern.getDelay()
+ .getUnit());
+ }
+ if (pattern.getMaxOccurs() != null) {
+ this.maxOccurs = pattern.getMaxOccurs();
+ }
+ this.timer = new Timer();
+ taskArgs = EventUtil.getEventArgs(pattern);
+ candidateLocations = EventUtil.getCandidateLocations(pattern,
+ client.getCluster());
+ if (pattern.getEvent().getNodeid().getValue().getRandom() != null
+ && period != null && maxOccurs > 1) {
+ dynamicLocation = true;
+ reuseLocation = pattern.getEvent().getNodeid().getValue()
+ .getRandom().getRange().isReuse();
+ } else {
+ location = EventUtil.getEventLocation(pattern, candidateLocations,
+ client.getCluster());
+ }
+ String scriptsDir;
+ if (location.getId().equals(EventDriver.CLIENT_NODE_ID)) {
+ scriptsDir = client.getEventsDir() + File.separator + "events";
+ } else {
+ scriptsDir = client.getCluster().getWorkingDir().getDir()
+ + File.separator + "eventrix" + File.separator + "events";
+ }
+ event = EventUtil.getEvent(pattern, client.getEvents());
+ taskScript = scriptsDir + File.separator + event.getScript();
+ state = State.INITIALIZED;
+ }
+
+ public void start() {
+ if (interval > 0) {
+ timer.schedule(this, initialDelay, interval);
+ } else {
+ timer.schedule(this, initialDelay);
+ }
+ }
+
+ @Override
+ public void run() {
+ if (candidateLocations.size() == 0) {
+ timer.cancel();
+ client.notifyCompletion(new EventTaskReport(this));
+ } else {
+ if (dynamicLocation) {
+ location = EventUtil.getEventLocation(pattern,
+ candidateLocations, client.getCluster());
+ if (!reuseLocation) {
+ candidateLocations.remove(location);
+ }
+ }
+
+ logger.debug(EventUtil.dateFormat.format(new Date()) + " "
+ + "EVENT " + pattern.getEvent().getType().toUpperCase()
+ + " at " + location.getId().toUpperCase());
+ try {
+ if (!client.isDryRun()) {
+ new EventExecutor().executeEvent(location, taskScript,
+ taskArgs, event.isDaemon(), client.getCluster(),
+ pattern, client.getErrorHandler(), client);
+ }
+ occurrenceCount++;
+ if (occurrenceCount >= maxOccurs) {
+ timer.cancel();
+ client.notifyCompletion(new EventTaskReport(this));
+ }
+ } catch (IOException ioe) {
+ timer.cancel();
+ client.notifyCompletion(new EventTaskReport(this, false, ioe));
+ }
+ }
+
+ }
+
+ public Node getLocation() {
+ return location;
+ }
+
+ public long getInterval() {
+ return interval;
+ }
+
+ public long getInitialDelay() {
+ return initialDelay;
+ }
+
+ public Pattern getPattern() {
+ return pattern;
+ }
+
+ public State getState() {
+ return state;
+ }
+
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventTaskReport.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventTaskReport.java
new file mode 100644
index 0000000..7ad3682
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventTaskReport.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+import java.io.Serializable;
+
+public class EventTaskReport implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private final EventTask task;
+ private final boolean success;
+ private final Exception e;
+
+ public EventTaskReport(EventTask task, boolean success, Exception e) {
+ this.task = task;
+ this.success = success;
+ this.e = e;
+ }
+
+ public EventTaskReport(EventTask task) {
+ this.task = task;
+ this.success = true;
+ this.e = null;
+ }
+
+ public Exception getException() {
+ return e;
+ }
+
+ public EventTask getTask() {
+ return task;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java
new file mode 100644
index 0000000..bf31e9f
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java
@@ -0,0 +1,262 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import edu.uci.ics.asterix.event.driver.EventDriver;
+import edu.uci.ics.asterix.event.management.ValueType.Type;
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.event.Event;
+import edu.uci.ics.asterix.event.schema.event.Events;
+import edu.uci.ics.asterix.event.schema.pattern.Pattern;
+
+public class EventUtil {
+
+ public static final String EVENTS_DIR = "events";
+ public static final String CLUSTER_CONF = "config/cluster.xml";
+ public static final String PATTERN_CONF = "config/pattern.xml";
+ public static final DateFormat dateFormat = new SimpleDateFormat(
+ "yyyy/MM/dd HH:mm:ss");
+
+ private static final String IP_LOCATION = "IP_LOCATION";
+ private static final String CLUSTER_ENV = "ENV";
+ private static final String SCRIPT = "SCRIPT";
+ private static final String ARGS = "ARGS";
+ private static final String EXECUTE_SCRIPT = "events/execute.sh";
+
+ public static long parseTimeInterval(ValueType v, String unit)
+ throws IllegalArgumentException {
+ int val = 0;
+ switch (v.getType()) {
+ case ABS:
+ val = Integer.parseInt(v.getAbsoluteValue());
+ break;
+ case RANDOM_MIN_MAX:
+ val = Randomizer.getInstance().getRandomInt(v.getMin(), v.getMax());
+ break;
+ case RANDOM_RANGE:
+ String[] values = v.getRangeSet();
+ val = Integer.parseInt(values[Randomizer.getInstance()
+ .getRandomInt(0, values.length - 1)]);
+ break;
+ }
+ return computeInterval(val, unit);
+ }
+
+ public static long parseTimeInterval(String v, String unit)
+ throws IllegalArgumentException {
+ int value = Integer.parseInt(v);
+ return computeInterval(value, unit);
+ }
+
+ private static long computeInterval(int val, String unit) {
+ int vmult = 1;
+ if ("hr".equalsIgnoreCase(unit)) {
+ vmult = 3600 * 1000;
+ } else if ("min".equalsIgnoreCase(unit)) {
+ vmult = 60 * 1000;
+ } else if ("sec".equalsIgnoreCase(unit)) {
+ vmult = 1000;
+ } else
+ throw new IllegalArgumentException(
+ " invalid unit value specified for frequency (hr,min,sec)");
+ return val * vmult;
+
+ }
+
+ public static Event getEvent(Pattern pattern, Events events) {
+ for (Event event : events.getEvent()) {
+ if (event.getType().equals(pattern.getEvent().getType())) {
+ return event;
+ }
+ }
+ throw new IllegalArgumentException(" Unknown event type"
+ + pattern.getEvent().getType());
+ }
+
+ public static Node getEventLocation(Pattern pattern,
+ List<Node> candidateLocations, Cluster cluster) {
+ ValueType value = new ValueType(pattern.getEvent().getNodeid()
+ .getValue());
+ Node location = null;
+ Type vtype = value.getType();
+
+ switch (vtype) {
+ case ABS:
+ location = getNodeFromId(value.getAbsoluteValue(), cluster);
+ break;
+ case RANDOM_RANGE:
+ int nodeIndex = Randomizer.getInstance().getRandomInt(0,
+ candidateLocations.size() - 1);
+ location = candidateLocations.get(nodeIndex);
+ break;
+ case RANDOM_MIN_MAX:
+ throw new IllegalStateException(
+ " Canont configure a min max value range for location");
+ }
+ return location;
+
+ }
+
+ public static List<Node> getCandidateLocations(Pattern pattern,
+ Cluster cluster) {
+ ValueType value = new ValueType(pattern.getEvent().getNodeid()
+ .getValue());
+ List<Node> candidateList = new ArrayList<Node>();
+ switch (value.getType()) {
+ case ABS:
+ candidateList.add(getNodeFromId(value.getAbsoluteValue(), cluster));
+ break;
+ case RANDOM_RANGE:
+ boolean anyOption = false;
+ String[] values = value.getRangeSet();
+ for (String v : values) {
+ if (v.equalsIgnoreCase("ANY")) {
+ anyOption = true;
+ }
+ }
+ if (anyOption) {
+ for (Node node : cluster.getNode()) {
+ candidateList.add(node);
+ }
+ } else {
+ boolean found = false;
+ for (String v : values) {
+ for (Node node : cluster.getNode()) {
+ if (node.getId().equals(v)) {
+ candidateList.add(node);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ throw new IllegalStateException("Unknonw nodeId : " + v);
+ }
+ found = false;
+ }
+
+ }
+ String[] excluded = value.getRangeExcluded();
+ if (excluded != null && excluded.length > 0) {
+ List<Node> markedForRemoval = new ArrayList<Node>();
+ for (String exclusion : excluded) {
+ for (Node node : candidateList) {
+ if (node.getId().equals(exclusion)) {
+ markedForRemoval.add(node);
+ }
+ }
+ }
+ candidateList.removeAll(markedForRemoval);
+ }
+ break;
+ case RANDOM_MIN_MAX:
+ throw new IllegalStateException(
+ " Invalid value configured for location");
+ }
+ return candidateList;
+ }
+
+ private static Node getNodeFromId(String nodeid, Cluster cluster) {
+ if (nodeid.equals(EventDriver.CLIENT_NODE.getId())) {
+ return EventDriver.CLIENT_NODE;
+ }
+
+ if (nodeid.equals(cluster.getMasterNode().getId())) {
+ String ram = cluster.getMasterNode().getJavaHeap() == null ? cluster
+ .getJavaHeap() : cluster.getMasterNode().getJavaHeap();
+ String logDir = cluster.getMasterNode().getLogdir() == null ? cluster
+ .getLogdir() : cluster.getMasterNode().getLogdir();
+ String javaHome = cluster.getMasterNode().getJavaHome() == null ? cluster
+ .getJavaHome() : cluster.getMasterNode().getJavaHome();
+ BigInteger debug = cluster.getMasterNode().getDebug();
+ return new Node(cluster.getMasterNode().getId(), cluster
+ .getMasterNode().getIp(), ram, javaHome, logDir, null,
+ debug);
+ }
+
+ List<Node> nodeList = cluster.getNode();
+ for (Node node : nodeList) {
+ if (node.getId().equals(nodeid)) {
+ return node;
+ }
+ }
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(EventDriver.CLIENT_NODE.getId() + ",");
+ buffer.append(cluster.getMasterNode().getId() + ",");
+ for (Node v : cluster.getNode()) {
+ buffer.append(v.getId() + ",");
+ }
+ buffer.deleteCharAt(buffer.length() - 1);
+ throw new IllegalArgumentException("Unknown node id :" + nodeid
+ + " valid ids:" + buffer);
+ }
+
+ public static void executeEventScript(Node node, String script,
+ List<String> args, Cluster cluster) throws IOException,
+ InterruptedException {
+ List<String> pargs = new ArrayList<String>();
+ pargs.add("/bin/bash");
+ pargs.add(EventDriver.getEventsDir() + "/" + EXECUTE_SCRIPT);
+ StringBuffer argBuffer = new StringBuffer();
+ String env = EventDriver.getStringifiedEnv(cluster) + " " + IP_LOCATION
+ + "=" + node.getIp();
+ if (args != null) {
+ for (String arg : args) {
+ argBuffer.append(arg + " ");
+ }
+ }
+ ProcessBuilder pb = new ProcessBuilder(pargs);
+ pb.environment().putAll(EventDriver.getEnvironment());
+ pb.environment().put(IP_LOCATION, node.getIp());
+ pb.environment().put(CLUSTER_ENV, env);
+ pb.environment().put(SCRIPT, script);
+ pb.environment().put(ARGS, argBuffer.toString());
+ pb.start();
+ }
+
+ public static void executeLocalScript(Node node, String script,
+ List<String> args) throws IOException, InterruptedException {
+ List<String> pargs = new ArrayList<String>();
+ pargs.add("/bin/bash");
+ pargs.add(script);
+ if (args != null) {
+ pargs.addAll(args);
+ }
+ ProcessBuilder pb = new ProcessBuilder(pargs);
+ pb.environment().putAll(EventDriver.getEnvironment());
+ pb.environment().put(IP_LOCATION, node.getIp());
+ pb.start();
+ }
+
+ public static List<String> getEventArgs(Pattern pattern) {
+ List<String> pargs = new ArrayList<String>();
+ if (pattern.getEvent().getPargs() == null) {
+ return pargs;
+ }
+ String[] args = pattern.getEvent().getPargs().split(" ");
+ for (String arg : args) {
+ pargs.add(arg.trim());
+ }
+ return pargs;
+ }
+
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventrixClient.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventrixClient.java
new file mode 100644
index 0000000..4cd4b82
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventrixClient.java
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import edu.uci.ics.asterix.event.driver.EventDriver;
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.event.Events;
+import edu.uci.ics.asterix.event.schema.pattern.Event;
+import edu.uci.ics.asterix.event.schema.pattern.Nodeid;
+import edu.uci.ics.asterix.event.schema.pattern.Pattern;
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.event.schema.pattern.Value;
+
+public class EventrixClient {
+
+ private static final Logger LOGGER = Logger.getLogger(EventrixClient.class
+ .getName());
+
+ private EventTask[] tasks;
+ private boolean dryRun = false;
+ private LinkedBlockingQueue<EventTaskReport> msgInbox = new LinkedBlockingQueue<EventTaskReport>();
+ private AtomicInteger pendingTasks = new AtomicInteger(0);
+ private final Cluster cluster;
+ private IPatternListener listener;
+ private IOutputHandler outputHandler;
+ private Events events;
+ private String eventsDir;
+
+ public EventrixClient(String eventsDir, Cluster cluster, boolean dryRun,
+ IOutputHandler outputHandler) throws Exception {
+ this.eventsDir = eventsDir;
+ this.events = initializeEvents();
+ this.cluster = cluster;
+ this.dryRun = dryRun;
+ this.outputHandler = outputHandler;
+ if (!dryRun) {
+ initializeCluster(eventsDir);
+ }
+ }
+
+ public void submit(Patterns patterns) throws Exception {
+ initTasks(patterns);
+ try {
+ waitForCompletion();
+ } catch (InterruptedException ie) {
+ LOGGER.info("Interrupted exception :" + ie);
+ } catch (Exception e) {
+ throw e;
+ }
+
+ }
+
+ public void submit(Patterns patterns, IPatternListener listener)
+ throws Exception {
+ this.listener = listener;
+ initTasks(patterns);
+ }
+
+ private void initTasks(Patterns patterns) {
+ tasks = new EventTask[patterns.getPattern().size()];
+ pendingTasks.set(tasks.length);
+ int index = 0;
+ for (Pattern pattern : patterns.getPattern()) {
+ tasks[index] = new EventTask(pattern, this);
+ tasks[index].start();
+ index++;
+ }
+ }
+
+ public Cluster getCluster() {
+ return cluster;
+ }
+
+ public boolean isDryRun() {
+ return dryRun;
+ }
+
+ public Events getEvents() {
+ return events;
+ }
+
+ public String getEventsDir() {
+ return eventsDir;
+ }
+
+ public synchronized void notifyCompletion(EventTaskReport report) {
+
+ if (report.isSuccess()) {
+ if (listener != null) {
+ pendingTasks.decrementAndGet();
+ listener.eventCompleted(report);
+ if (pendingTasks.get() == 0) {
+ listener.jobCompleted();
+ }
+ } else {
+ try {
+ msgInbox.put(report);
+ } catch (InterruptedException e) {
+ }
+ }
+ } else {
+ for (EventTask t : tasks) {
+ if (t.getState() == EventTask.State.INITIALIZED
+ || t.getState() == EventTask.State.IN_PROGRESS) {
+ t.cancel();
+ }
+ }
+ if (listener != null) {
+ listener.jobFailed(report);
+ } else {
+ try {
+ msgInbox.put(report);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ }
+
+ private void waitForCompletion() throws Exception {
+ while (true) {
+ EventTaskReport report = msgInbox.take();
+ if (report.isSuccess()) {
+ if (pendingTasks.decrementAndGet() == 0) {
+ break;
+ }
+ } else {
+ throw new RuntimeException(report.getException().getMessage());
+ }
+ }
+ }
+
+ private void initializeCluster(String eventsDir) throws Exception {
+ Patterns patterns = initPattern(eventsDir);
+ submit(patterns);
+ }
+
+ private Patterns initPattern(String eventsDir) {
+ Nodeid nodeid = new Nodeid(new Value(null,
+ EventDriver.CLIENT_NODE.getId()));
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ String workingDir = cluster.getWorkingDir().getDir();
+ String username = cluster.getUsername() == null ? System
+ .getProperty("user.name") : cluster.getUsername();
+ patternList.add(getDirectoryTransferPattern(username, eventsDir,
+ nodeid, cluster.getMasterNode().getIp(), workingDir));
+
+ if (!cluster.getWorkingDir().isNFS()) {
+ for (Node node : cluster.getNode()) {
+ patternList.add(getDirectoryTransferPattern(username,
+ eventsDir, nodeid, node.getIp(), workingDir));
+ }
+ }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
+
+ private Pattern getDirectoryTransferPattern(String username, String src,
+ Nodeid srcNode, String destNodeIp, String destDir) {
+ String pargs = username + " " + src + " " + destNodeIp + " " + destDir;
+ Event event = new Event("directory_transfer", srcNode, pargs);
+ return new Pattern(null, 1, null, event);
+ }
+
+ public IOutputHandler getErrorHandler() {
+ return outputHandler;
+ }
+
+ private Events initializeEvents() throws JAXBException,
+ FileNotFoundException {
+ File file = new File(eventsDir + File.separator + "events"
+ + File.separator + "events.xml");
+ JAXBContext eventCtx = JAXBContext.newInstance(Events.class);
+ Unmarshaller unmarshaller = eventCtx.createUnmarshaller();
+ events = (Events) unmarshaller.unmarshal(file);
+ return events;
+ }
+
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/IOutputHandler.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/IOutputHandler.java
new file mode 100644
index 0000000..c7929cb
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/IOutputHandler.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+import edu.uci.ics.asterix.event.schema.pattern.Event;
+
+public interface IOutputHandler {
+
+ public OutputAnalysis reportEventOutput(Event event, String output);
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/IPatternListener.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/IPatternListener.java
new file mode 100644
index 0000000..06a56cf
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/IPatternListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+public interface IPatternListener {
+
+ public void eventCompleted(EventTaskReport report);
+
+ public void jobCompleted();
+
+ public void jobFailed(EventTaskReport report);
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/OutputAnalysis.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/OutputAnalysis.java
new file mode 100644
index 0000000..2845ede
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/OutputAnalysis.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+public class OutputAnalysis {
+
+ private final boolean expected;
+ private final String errorMessage;
+
+ public OutputAnalysis(boolean expected, String errorMessage) {
+ this.expected = expected;
+ this.errorMessage = errorMessage;
+ }
+
+ public boolean isExpected() {
+ return expected;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/Randomizer.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/Randomizer.java
new file mode 100644
index 0000000..e59e154
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/Randomizer.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+import java.util.Random;
+import java.util.logging.Logger;
+
+public class Randomizer {
+
+ private static final Logger LOGGER = Logger.getLogger(Randomizer.class
+ .getName());
+ private static Randomizer INSTANCE;
+ private final Random random;
+ private final int seed;
+
+ public static Randomizer getInstance(int seed) {
+ if (INSTANCE == null) {
+ INSTANCE = new Randomizer(seed);
+ }
+ return INSTANCE;
+ }
+
+ public static Randomizer getInstance() {
+ if (INSTANCE == null) {
+ INSTANCE = new Randomizer();
+ }
+ return INSTANCE;
+ }
+
+ private Randomizer() {
+ Random rm = new Random();
+ seed = rm.nextInt(10000);
+ random = new Random(seed);
+ LOGGER.info("SEED:" + seed);
+ }
+
+ private Randomizer(int seed) {
+ this.seed = seed;
+ random = new Random(seed);
+ LOGGER.info("SEED:" + seed);
+ }
+
+ public Random getRandom() {
+ return random;
+ }
+
+ public int getSeed() {
+ return seed;
+ }
+
+ public int getRandomInt(int min, int max) {
+ return min + random.nextInt(max - min + 1);
+ }
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/ValueType.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/ValueType.java
new file mode 100644
index 0000000..8aa5cc5
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/ValueType.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.management;
+
+import edu.uci.ics.asterix.event.schema.pattern.Value;
+
+public class ValueType {
+
+ public static enum Type {
+ ABS, RANDOM_RANGE, RANDOM_MIN_MAX
+ }
+
+ private Value value;
+ private Type type;
+
+ public ValueType(Value value) {
+ this.value = value;
+ if (value.getAbsvalue() != null) {
+ type = Type.ABS;
+ } else if (value.getRandom() != null) {
+ if (value.getRandom().getMinmax() != null) {
+ type = Type.RANDOM_MIN_MAX;
+ } else if (value.getRandom().getRange() != null) {
+ type = Type.RANDOM_RANGE;
+ } else {
+ throw new IllegalStateException("Incorrect value type");
+ }
+ }
+ }
+
+ public int getMin() {
+ switch (type) {
+ case RANDOM_MIN_MAX:
+ return Integer.parseInt(value.getRandom().getMinmax().getMin());
+ default:
+ throw new IllegalStateException("");
+ }
+ }
+
+ public int getMax() {
+ switch (type) {
+ case RANDOM_MIN_MAX:
+ return Integer.parseInt(value.getRandom().getMinmax().getMax());
+ default:
+ throw new IllegalStateException("");
+ }
+ }
+
+ public String[] getRangeSet() {
+ switch (type) {
+ case RANDOM_RANGE:
+ return value.getRandom().getRange().getSet().split(" ");
+ default:
+ throw new IllegalStateException("");
+ }
+ }
+
+ public String[] getRangeExcluded() {
+ switch (type) {
+ case RANDOM_RANGE:
+ String exl = value.getRandom().getRange().getExclude();
+ return exl != null ? exl.split(" ") : null;
+ default:
+ throw new IllegalStateException("");
+ }
+ }
+
+ public String getAbsoluteValue() {
+ switch (type) {
+ case ABS:
+ return value.getAbsvalue();
+ default:
+ throw new IllegalStateException("");
+ }
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/xml/PatternParser.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/xml/PatternParser.java
new file mode 100644
index 0000000..426279c
--- /dev/null
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/xml/PatternParser.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.event.xml;
+
+public class PatternParser {
+
+ public static void parsePattern(String path){
+
+ }
+}
+
diff --git a/asterix-events/src/main/resources/events/backup/backup.sh b/asterix-events/src/main/resources/events/backup/backup.sh
new file mode 100755
index 0000000..e10a4c9
--- /dev/null
+++ b/asterix-events/src/main/resources/events/backup/backup.sh
@@ -0,0 +1,35 @@
+WORKING_DIR=$1
+ASTERIX_INSTANCE_NAME=$2
+ASTERIX_DATA_DIR=$3
+BACKUP_ID=$4
+BACKUP_DIR=$5
+BACKUP_TYPE=$6
+NODE_ID=$7
+
+nodeStores=$(echo $ASTERIX_DATA_DIR | tr "," "\n")
+
+if [ $BACKUP_TYPE == "hdfs" ];
+then
+ HDFS_URL=$8
+ HADOOP_VERSION=$9
+ export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION
+ for nodeStore in $nodeStores
+ do
+ MANGLED_DIR_NAME=`echo $nodeStores | tr / _`
+ NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/$MANGLED_DIR_NAME
+ echo "$HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/ $HDFS_URL/$NODE_BACKUP_DIR/" >> ~/backup.log
+ $HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/ $HDFS_URL/$NODE_BACKUP_DIR/
+ done
+else
+ for nodeStore in $nodeStores
+ do
+ MANGLED_DIR_NAME=`echo $nodeStores | tr / _`
+ NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/$MANGLED_DIR_NAME
+ if [ ! -d $NODE_BACKUP_DIR ];
+ then
+ mkdir -p $NODE_BACKUP_DIR
+ fi
+ echo "cp -r $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/* $NODE_BACKUP_DIR/" >> ~/backup.log
+ cp -r $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/* $NODE_BACKUP_DIR/
+ done
+fi
diff --git a/asterix-events/src/main/resources/events/cc_failure/cc_failure.sh b/asterix-events/src/main/resources/events/cc_failure/cc_failure.sh
new file mode 100755
index 0000000..aa722e5
--- /dev/null
+++ b/asterix-events/src/main/resources/events/cc_failure/cc_failure.sh
@@ -0,0 +1,6 @@
+#kill -9 `ps -ef | grep hyracks | grep -v grep | cut -d "/" -f1 | tr -s " " | cut -d " " -f2`
+CC_PARENT_ID_INFO=`ps -ef | grep asterix | grep cc_start | grep -v ssh`
+CC_PARENT_ID=`echo $CC_PARENT_ID_INFO | tr -s " " | cut -d " " -f2`
+CC_ID_INFO=`ps -ef | grep asterix | grep $CC_PARENT_ID | grep -v bash`
+CC_ID=`echo $CC_ID_INFO | tr -s " " | cut -d " " -f2`
+kill -9 $CC_ID
diff --git a/asterix-events/src/main/resources/events/cc_start/cc_start.sh b/asterix-events/src/main/resources/events/cc_start/cc_start.sh
new file mode 100755
index 0000000..37645bc
--- /dev/null
+++ b/asterix-events/src/main/resources/events/cc_start/cc_start.sh
@@ -0,0 +1,5 @@
+if [ ! -d $LOG_DIR ];
+then
+ mkdir -p $LOG_DIR
+fi
+$ASTERIX_HOME/bin/asterixcc -client-net-ip-address $CLIENT_NET_IP -client-net-port 1098 -cluster-net-ip-address $CLUSTER_NET_IP -cluster-net-port 1099 -http-port 8888 &> $LOG_DIR/cc.log
diff --git a/asterix-events/src/main/resources/events/events.xml b/asterix-events/src/main/resources/events/events.xml
new file mode 100644
index 0000000..f85e3ea1
--- /dev/null
+++ b/asterix-events/src/main/resources/events/events.xml
@@ -0,0 +1,106 @@
+<events xmlns="events">
+ <event>
+ <type>node_join</type>
+ <script>node_join/nc_join.sh</script>
+ <description>Creates a NodeController process at a specified location.</description>
+ <args>location_of_cc location(hostname/ip_address) node_controller_id</args>
+ <daemon>true</daemon>
+ </event>
+ <event>
+ <type>node_failure</type>
+ <script>node_failure/nc_failure.sh</script>
+ <description>Kills a NodeController process at a specified location.</description>
+ <args>node_controller_id</args>
+ <daemon>false</daemon>
+ </event>
+ <event>
+ <type>cc_start</type>
+ <script>cc_start/cc_start.sh</script>
+ <description>Starts a ClusterController process at a specified location.</description>
+ <args></args>
+ <daemon>true</daemon>
+ </event>
+ <event>
+ <type>cc_failure</type>
+ <script>cc_failure/cc_failure.sh</script>
+ <description>Kills the Cluster Controller process running at a specified location.</description>
+ <args></args>
+ <daemon>false</daemon>
+ </event>
+ <event>
+ <type>node_restart</type>
+ <script>node_restart/nc_restart.sh</script>
+ <description>Shuts and restarts a NodeControllerProcess after a specified time interval, at a specified location</description>
+ <args>address of cc, node controller id and sleep interval(seconds)</args>
+ <daemon>true</daemon>
+ </event>
+ <event>
+ <type>asterix_deploy</type>
+ <script>asterix_deploy/asterix_deploy.sh</script>
+ <description>Deploys Asterix application on a cluster running hyracks</description>
+ <args>IP address of the node running the hyracks cluster controller</args>
+ <daemon>false</daemon>
+ </event>
+ <event>
+ <type>zookeeper_start</type>
+ <script>zookeeper/start.sh</script>
+ <description>Launches ZooKeeper server process</description>
+ <args>IP address of the ZooKeeper server</args>
+ <daemon>true</daemon>
+ </event>
+ <event>
+ <type>zookeeper_stop</type>
+ <script>zookeeper/stop.sh</script>
+ <description>Terminates ZooKeeper server process</description>
+ <args>IP address of the ZooKeeper server</args>
+ <daemon>false</daemon>
+ </event>
+ <event>
+ <type>file_transfer</type>
+ <script>file/transfer.sh</script>
+ <description>Copies a file on the local file system to a remote node</description>
+ <args>local_source_path destination_node destination_path</args>
+ <daemon>false</daemon>
+ </event>
+ <event>
+ <type>directory_transfer</type>
+ <script>file/dir_transfer.sh</script>
+ <description>Copies a directory (and its contents) on the local file system to a remote node</description>
+ <args>local_source_path destination_node destination_path</args>
+ <daemon>false</daemon>
+ </event>
+ <event>
+ <type>file_delete</type>
+ <script>file/delete.sh</script>
+ <description>Deletes a file on the local file system to a remote node</description>
+ <args>local_source_path destination_node destination_path</args>
+ <daemon>false</daemon>
+ </event>
+ <event>
+ <type>backup</type>
+ <script>backup/backup.sh</script>
+ <description>Takes a backup of an Asterix instance</description>
+ <args>Asterix_data_dir HDFSurl</args>
+ <daemon>false</daemon>
+ </event>
+ <event>
+ <type>restore</type>
+ <script>restore/restore.sh</script>
+ <description>Restores an Asterix instance from a back up</description>
+ <args>Asterix_data_dir HDFSurl</args>
+ <daemon>false</daemon>
+ </event>
+ <event>
+ <type>hdfs_delete</type>
+ <script>hdfs/delete.sh</script>
+ <description>Deletes an HDFS path</description>
+ <args>WorkingDir HadoopVersion HDFSUrl Path_to_Delete</args>
+ <daemon>false</daemon>
+ </event>
+ <event>
+ <type>node_info</type>
+ <script>node_info/node_info.sh</script>
+ <description>Retrieved environment information for a node</description>
+ <daemon>false</daemon>
+ </event>
+</events>
diff --git a/asterix-events/src/main/resources/events/file/delete.sh b/asterix-events/src/main/resources/events/file/delete.sh
new file mode 100755
index 0000000..d5ac3ff
--- /dev/null
+++ b/asterix-events/src/main/resources/events/file/delete.sh
@@ -0,0 +1,3 @@
+PATH_TO_DELETE=$1
+echo "rm -rf $PATH_TO_DELETE" >> ~/backup.log
+rm -rf $PATH_TO_DELETE
diff --git a/asterix-events/src/main/resources/events/file/dir_transfer.sh b/asterix-events/src/main/resources/events/file/dir_transfer.sh
new file mode 100755
index 0000000..af7da70
--- /dev/null
+++ b/asterix-events/src/main/resources/events/file/dir_transfer.sh
@@ -0,0 +1,7 @@
+USERNAME=$1
+DIR_TO_TRANSFER=$2
+DEST_HOST=$3
+DEST_DIR=$4
+ssh -l $USERNAME $DEST_HOST "mkdir -p $DEST_DIR"
+echo "scp -r $DIR_TO_TRANSFER $USERNAME@$DEST_HOST:$DEST_DIR/"
+scp -r $DIR_TO_TRANSFER $USERNAME@$DEST_HOST:$DEST_DIR/
diff --git a/asterix-events/src/main/resources/events/file/transfer.sh b/asterix-events/src/main/resources/events/file/transfer.sh
new file mode 100755
index 0000000..fbd4554
--- /dev/null
+++ b/asterix-events/src/main/resources/events/file/transfer.sh
@@ -0,0 +1,24 @@
+USERNAME=$1
+FILE_TO_TRANSFER=$2
+DEST_HOST=$3
+DEST_DIR=$4
+POST_ACTION=$5
+ssh -l $USERNAME $DEST_HOST "mkdir -p $DEST_DIR"
+echo "scp $FILE_TO_TRANSFER $USERNAME@$DEST_HOST:$DEST_DIR/"
+scp $FILE_TO_TRANSFER $USERNAME@$DEST_HOST:$DEST_DIR/
+if [ $POST_ACTION == "unpack" ]
+ then
+ filename=`echo ${FILE_TO_TRANSFER##*/}`
+ fileType=`echo ${FILE_TO_TRANSFER##*.}`
+ if [ $fileType == "tar" ]
+ then
+ echo "ssh -l $USERNAME $DEST_HOST cd $DEST_DIR && tar xf $filename"
+ ssh -l $USERNAME $DEST_HOST "cd $DEST_DIR && tar xf $filename"
+ else if [ $fileType == "zip" ]
+ then
+ echo "ssh -l $USERNAME $DEST_HOST unzip -o -q -d $DEST_DIR $DEST_DIR/$filename"
+ ssh -l $USERNAME $DEST_HOST "unzip -o -q -d $DEST_DIR $DEST_DIR/$filename"
+ ssh -l $USERNAME $DEST_HOST "chmod -R 755 $DEST_DIR"
+ fi
+ fi
+fi
diff --git a/asterix-events/src/main/resources/events/hdfs/delete.sh b/asterix-events/src/main/resources/events/hdfs/delete.sh
new file mode 100755
index 0000000..6ff54ee
--- /dev/null
+++ b/asterix-events/src/main/resources/events/hdfs/delete.sh
@@ -0,0 +1,7 @@
+WORKING_DIR=$1
+HADOOP_VERSION=$2
+HDFS_URL=$3
+HDFS_PATH=$4
+export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION
+echo "$HADOOP_HOME/bin/hadoop fs -rmr $HDFS_URL/$HDFS_PATH"
+$HADOOP_HOME/bin/hadoop fs -rmr $HDFS_URL/$HDFS_PATH
diff --git a/asterix-events/src/main/resources/events/node_failure/nc_failure.sh b/asterix-events/src/main/resources/events/node_failure/nc_failure.sh
new file mode 100755
index 0000000..3ca083c
--- /dev/null
+++ b/asterix-events/src/main/resources/events/node_failure/nc_failure.sh
@@ -0,0 +1,7 @@
+NC_ID=$1
+
+INFO=`ps -ef | grep nc_join | grep -v grep | grep -v ssh| grep $NC_ID | head -n 1`
+PARENT_ID=`echo $INFO | cut -d " " -f2`
+PID_INFO=`ps -ef | grep asterix | grep -v grep | grep -v nc_join | grep $PARENT_ID`
+PID=`echo $PID_INFO | cut -d " " -f2`
+kill -15 $PID
diff --git a/asterix-events/src/main/resources/events/node_info/node_info.sh b/asterix-events/src/main/resources/events/node_info/node_info.sh
new file mode 100755
index 0000000..2179d5a
--- /dev/null
+++ b/asterix-events/src/main/resources/events/node_info/node_info.sh
@@ -0,0 +1,2 @@
+JAVA_VERSION=`java -version 2>&1 |awk 'NR==1{ gsub(/"/,""); print $3 }'`
+echo "java_version=$JAVA_VERSION" 1>&2
diff --git a/asterix-events/src/main/resources/events/node_join/nc_join.sh b/asterix-events/src/main/resources/events/node_join/nc_join.sh
new file mode 100755
index 0000000..e0f5e55
--- /dev/null
+++ b/asterix-events/src/main/resources/events/node_join/nc_join.sh
@@ -0,0 +1,7 @@
+CC_HOST=$1
+NC_ID=$2
+if [ ! -d $LOG_DIR ];
+then
+ mkdir -p $LOG_DIR
+fi
+$ASTERIX_HOME/bin/asterixnc -node-id $NC_ID -cc-host $CC_HOST -cc-port 1099 -cluster-net-ip-address $IP_LOCATION -data-ip-address $IP_LOCATION &> $LOG_DIR/${NC_ID}.log
diff --git a/asterix-events/src/main/resources/events/node_restart/nc_restart.sh b/asterix-events/src/main/resources/events/node_restart/nc_restart.sh
new file mode 100755
index 0000000..961ce8d
--- /dev/null
+++ b/asterix-events/src/main/resources/events/node_restart/nc_restart.sh
@@ -0,0 +1,21 @@
+CC_HOST=$1
+NC_ID=$2
+SLEEP_TIME=$3
+
+if [ $NC_ID == 'ANY' ]
+then
+ NC_ID="."
+ PARENT_ID=`ps -ej | tr -s " " | grep nc_join | grep -v grep | grep -v ssh | cut -d " " -f2 | head -n 1`
+ PARENT_PROCESS_ENTRY=`ps -ef | grep $PARENT_ID | grep -v grep | head -n 1`
+ NC_ID=`echo ${PARENT_PROCESS_ENTRY##* }`
+ echo "NCid is $NC_ID" >> ~/try.txt
+else
+ PARENT_ID=`ps -ej | tr -s " " | grep nc_join | grep -v grep | grep -v ssh | grep $NC_ID | cut -d " " -f2 | head -n 1`
+fi
+
+PID=`ps -ej | tr -s " " | grep hyracks | grep -v grep | grep -v nc_join | grep $PARENT_ID | cut -d " " -f2 | head -n 1`
+kill -9 $PID
+
+sleep $3
+
+$HYRACKS_HOME/hyracks-server/target/hyracks-server-0.2.2-SNAPSHOT-binary-assembly/bin/hyracksnc -node-id $NC_ID -cc-host $CC_HOST -cc-port 1099 -cluster-net-ip-address $IP_LOCATION -data-ip-address $IP_LOCATION
diff --git a/asterix-events/src/main/resources/events/restore/restore.sh b/asterix-events/src/main/resources/events/restore/restore.sh
new file mode 100755
index 0000000..515efc1
--- /dev/null
+++ b/asterix-events/src/main/resources/events/restore/restore.sh
@@ -0,0 +1,32 @@
+WORKING_DIR=$1
+ASTERIX_INSTANCE_NAME=$2
+ASTERIX_DATA_DIR=$3
+BACKUP_ID=$4
+BACKUP_DIR=$5
+BACKUP_TYPE=$6
+NODE_ID=$7
+HDFS_URL=$8
+HADOOP_VERSION=$9
+
+export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION
+nodeStores=$(echo $ASTERIX_DATA_DIR | tr "," "\n")
+
+for nodeStore in $nodeStores
+do
+ MANGLED_BACKUP_DIR=`echo $nodeStore | tr / _`
+ NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/$MANGLED_BACKUP_DIR
+ DEST_DIR=$nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME
+ if [ ! -d $DEST_DIR ]
+ then
+ mkdir -p $DEST_DIR
+ else
+ rm -rf $DEST_DIR/*
+ fi
+
+ if [ $BACKUP_TYPE == "hdfs" ];
+ then
+ $HADOOP_HOME/bin/hadoop fs -copyToLocal $HDFS_URL/$NODE_BACKUP_DIR/* $DEST_DIR/
+ else
+ cp -r $NODE_BACKUP_DIR/* $DEST_DIR/
+ fi
+done
diff --git a/asterix-events/src/main/resources/schema/cluster.xsd b/asterix-events/src/main/resources/schema/cluster.xsd
new file mode 100644
index 0000000..38afda3
--- /dev/null
+++ b/asterix-events/src/main/resources/schema/cluster.xsd
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cl="cluster" targetNamespace="cluster" elementFormDefault="qualified">
+
+<!-- definition of simple types -->
+<xs:element name="name" type="xs:string"/>
+<xs:element name="java_heap" type="xs:string"/>
+<xs:element name="logdir" type="xs:string"/>
+<xs:element name="id" type="xs:string"/>
+<xs:element name="ip" type="xs:string"/>
+<xs:element name="cluster-ip" type="xs:string"/>
+<xs:element name="key" type="xs:string"/>
+<xs:element name="value" type="xs:string"/>
+<xs:element name="dir" type="xs:string"/>
+<xs:element name="NFS" type="xs:boolean"/>
+<xs:element name="store" type="xs:string"/>
+<xs:element name="java_home" type="xs:string"/>
+<xs:element name="username" type="xs:string"/>
+<xs:element name="debug" type="xs:integer"/>
+
+<!-- definition of complex elements -->
+<xs:element name="workingDir">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="cl:dir"/>
+ <xs:element ref="cl:NFS"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="master-node">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="cl:id"/>
+ <xs:element ref="cl:ip"/>
+ <xs:element ref="cl:cluster-ip"/>
+ <xs:element ref="cl:java_home" minOccurs="0"/>
+ <xs:element ref="cl:java_heap" minOccurs="0"/>
+ <xs:element ref="cl:logdir" minOccurs="0"/>
+ <xs:element ref="cl:debug" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="property">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="cl:key"/>
+ <xs:element ref="cl:value"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="env">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="cl:property" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="node">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="cl:id"/>
+ <xs:element ref="cl:ip"/>
+ <xs:element ref="cl:java_heap" minOccurs="0"/>
+ <xs:element ref="cl:java_home" minOccurs="0"/>
+ <xs:element ref="cl:logdir" minOccurs="0"/>
+ <xs:element ref="cl:store" minOccurs="0"/>
+ <xs:element ref="cl:debug" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="cluster">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="cl:name"/>
+ <xs:element ref="cl:username"/>
+ <xs:element ref="cl:env" minOccurs="0"/>
+ <xs:element ref="cl:java_heap" minOccurs="0"/>
+ <xs:element ref="cl:java_home" minOccurs="0"/>
+ <xs:element ref="cl:logdir" minOccurs="0"/>
+ <xs:element ref="cl:store" minOccurs="0"/>
+ <xs:element ref="cl:workingDir"/>
+ <xs:element ref="cl:master-node"/>
+ <xs:element ref="cl:node" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+</xs:schema>
diff --git a/asterix-events/src/main/resources/schema/event.xsd b/asterix-events/src/main/resources/schema/event.xsd
new file mode 100644
index 0000000..a233c18
--- /dev/null
+++ b/asterix-events/src/main/resources/schema/event.xsd
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:es="events" targetNamespace="events" elementFormDefault="qualified">
+
+<!-- definition of simple types -->
+<xs:element name="script" type="xs:string"/>
+<xs:element name="type" type="xs:string"/>
+<xs:element name="description" type="xs:string"/>
+<xs:element name="args" type="xs:string"/>
+<xs:element name="daemon" type="xs:boolean"/>
+
+<!-- definition of complex elements -->
+
+<xs:element name="event">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="es:type"/>
+ <xs:element ref="es:script"/>
+ <xs:element ref="es:description"/>
+ <xs:element ref="es:args"/>
+ <xs:element ref="es:daemon"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="events">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="es:event" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+</xs:schema>
diff --git a/asterix-events/src/main/resources/schema/jaxb-bindings.xjb b/asterix-events/src/main/resources/schema/jaxb-bindings.xjb
new file mode 100644
index 0000000..b5982e0
--- /dev/null
+++ b/asterix-events/src/main/resources/schema/jaxb-bindings.xjb
@@ -0,0 +1,9 @@
+<jxb:bindings version="1.0"
+xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
+xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+<jxb:globalBindings>
+ <jxb:serializable uid="1"/>
+</jxb:globalBindings>
+
+</jxb:bindings>
diff --git a/asterix-events/src/main/resources/schema/pattern.xsd b/asterix-events/src/main/resources/schema/pattern.xsd
new file mode 100644
index 0000000..4eee880
--- /dev/null
+++ b/asterix-events/src/main/resources/schema/pattern.xsd
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:eg="patterns" targetNamespace="patterns">
+
+
+<!-- definition of simple types -->
+<xs:element name="maxOccurs" type = "xs:int"/>
+<xs:element name="pargs" type="xs:string"/>
+<xs:element name="absvalue" type="xs:string"/>
+<xs:element name="unit" type="xs:string"/>
+<xs:element name="type" type="xs:string"/>
+<xs:element name="min" type="xs:string"/>
+<xs:element name="max" type="xs:string"/>
+<xs:element name="abs" type="xs:string"/>
+<xs:element name="set" type="xs:string"/>
+<xs:element name="exclude" type="xs:string"/>
+<xs:element name="reuse" type="xs:boolean"/>
+<!-- definition of attributes -->
+
+<!-- definition of complex elements -->
+
+<xs:element name="range">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="eg:set"/>
+ <xs:element ref="eg:exclude" minOccurs="0"/>
+ <xs:element ref="eg:reuse" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="minmax">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="eg:min"/>
+ <xs:element ref="eg:max"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+
+<xs:element name="random">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="eg:minmax" minOccurs="0"/>
+ <xs:element ref="eg:range" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="value">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="eg:random" minOccurs="0"/>
+ <xs:element ref="eg:absvalue" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="nodeid">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="eg:value"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="period">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="eg:absvalue"/>
+ <xs:element ref="eg:unit"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="delay">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="eg:value"/>
+ <xs:element ref="eg:unit"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="event">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="eg:type"/>
+ <xs:element ref="eg:nodeid"/>
+ <xs:element ref="eg:pargs"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="pattern">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="eg:delay"/>
+ <xs:element ref="eg:maxOccurs" maxOccurs="1" minOccurs="0"/>
+ <xs:element ref="eg:period"/>
+ <xs:element ref="eg:event"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="patterns">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="eg:pattern" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+</xs:schema>
diff --git a/asterix-events/src/main/resources/scripts/execute.sh b/asterix-events/src/main/resources/scripts/execute.sh
new file mode 100755
index 0000000..30f6c2f
--- /dev/null
+++ b/asterix-events/src/main/resources/scripts/execute.sh
@@ -0,0 +1,27 @@
+USERNAME=$1
+if [ ! -d $MANAGIX_HOME/logs ];
+then
+ mkdir -p $MANAGIX_HOME/logs
+fi
+LOGDIR=$MANAGIX_HOME/logs
+if [ $DAEMON == "false" ]; then
+ if [ -z $USERNAME ]
+ then
+ cmd_output=$(ssh $IP_LOCATION "$ENV $SCRIPT $ARGS" 2>&1 >/dev/null)
+ echo "ssh $IP_LOCATION $ENV $SCRIPT $ARGS" >> $LOGDIR/execute.log
+ echo "$cmd_output"
+ else
+ echo "ssh -l $USERNAME $IP_LOCATION $ENV $SCRIPT $ARGS" >> $LOGDIR/execute.log
+ cmd_output=$(ssh -l $USERNAME $IP_LOCATION "$ENV $SCRIPT $ARGS" 2>&1 >/dev/null)
+ echo "$cmd_output"
+ fi
+else
+ if [ -z $USERNAME ];
+ then
+ echo "ssh $IP_LOCATION $ENV $SCRIPT $ARGS &" >> $LOGDIR/execute.log
+ ssh $IP_LOCATION "$ENV $SCRIPT $ARGS" &
+ else
+ echo "ssh -l $USERNAME $IP_LOCATION $ENV $SCRIPT $ARGS &" >> $LOGDIR/execute.log
+ ssh -l $USERNAME $IP_LOCATION "$ENV $SCRIPT $ARGS" &
+ fi
+fi
diff --git a/asterix-events/src/main/resources/scripts/prepare.sh b/asterix-events/src/main/resources/scripts/prepare.sh
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/asterix-events/src/main/resources/scripts/prepare.sh
diff --git a/asterix-installer/pom.xml b/asterix-installer/pom.xml
new file mode 100644
index 0000000..fa5666a
--- /dev/null
+++ b/asterix-installer/pom.xml
@@ -0,0 +1,152 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>asterix</artifactId>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <version>0.0.4-SNAPSHOT</version>
+ </parent>
+ <artifactId>asterix-installer</artifactId>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>configuration</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <args>
+ <arg>-Xsetters</arg>
+ <arg>-Xvalue-constructor</arg>
+ </args>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-basics</artifactId>
+ <version>0.6.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-value-constructor</artifactId>
+ <version>3.0</version>
+ </plugin>
+ </plugins>
+ <schemaDirectory>src/main/resources/schema</schemaDirectory>
+ <schemaIncludes>
+ <include>installer-conf.xsd</include>
+ </schemaIncludes>
+ <generatePackage>edu.uci.ics.asterix.installer.schema.conf</generatePackage>
+ <generateDirectory>${project.build.directory}/generated-sources/configuration</generateDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <id>cluster</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <schemaDirectory>src/main/resources/schema</schemaDirectory>
+ <schemaIncludes>
+ <include>cluster.xsd</include>
+ </schemaIncludes>
+ <generatePackage>edu.uci.ics.asterix.installer.schema.cluster</generatePackage>
+ <bindingDirectory>src/main/resources/schema</bindingDirectory>
+ <bindingIncludes>
+ <bindingInclude>jaxb-bindings.xjb</bindingInclude>
+ </bindingIncludes>
+ <generateDirectory>${project.build.directory}/generated-sources/cluster</generateDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-2</version>
+ <executions>
+ <execution>
+ <configuration>
+ <descriptor>src/main/assembly/binary-assembly.xml</descriptor>
+ </configuration>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>args4j</groupId>
+ <artifactId>args4j</artifactId>
+ <version>2.0.12</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ <version>3.4.5</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.sun.jmx</groupId>
+ <artifactId>jmxri</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jdmk</groupId>
+ <artifactId>jmxtools</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-events</artifactId>
+ <version>0.0.4-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-server</artifactId>
+ <version>0.0.4-SNAPSHOT</version>
+ <type>zip</type>
+ <classifier>binary-assembly</classifier>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/asterix-installer/src/main/assembly/binary-assembly.xml b/asterix-installer/src/main/assembly/binary-assembly.xml
new file mode 100644
index 0000000..6a0c130
--- /dev/null
+++ b/asterix-installer/src/main/assembly/binary-assembly.xml
@@ -0,0 +1,108 @@
+<assembly>
+ <id>binary-assembly</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/resources/conf</directory>
+ <outputDirectory>conf</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/resources/clusters</directory>
+ <outputDirectory>clusters</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/resources/zookeeper</directory>
+ <fileMode>0755</fileMode>
+ <outputDirectory>.installer/zookeeper/bin</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/resources/scripts</directory>
+ <fileMode>0755</fileMode>
+ <includes>
+ <include>managix</include>
+ </includes>
+ <outputDirectory>bin</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/resources/scripts</directory>
+ <fileMode>0755</fileMode>
+ <excludes>
+ <exclude>managix</exclude>
+ </excludes>
+ <outputDirectory>.installer/scripts</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/resources/hadoop-0.20.2</directory>
+ <outputDirectory>.installer/hadoop-0.20.2</outputDirectory>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory>lib</outputDirectory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>../asterix-events/src/main/resources/events</directory>
+ <outputDirectory>.installer/eventrix/events</outputDirectory>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>../asterix-events/src/main/resources/scripts</directory>
+ <outputDirectory>.installer/eventrix/scripts</outputDirectory>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+ <dependencySet>
+ <includes>
+ <include>log4j:log4j</include>
+ <include>edu.uci.ics.asterix:asterix-events</include>
+ <include>org.apache.zookeeper:zookeeper</include>
+ <include>args4j:args4j</include>
+ <include>log4j:log4j</include>
+ <include>commons-io:commons-io</include>
+ <include>org.slf4j:slf4j-api</include>
+ <include>org.slf4j:slf4j-log4j12</include>
+ </includes>
+ <unpack>false</unpack>
+ <outputDirectory>lib</outputDirectory>
+ </dependencySet>
+ <dependencySet>
+ <includes>
+ <include>org.apache.hadoop:hadoop-core</include>
+ <include>commons-cli:commons-cli</include>
+ <include>commons-logging:commons-logging</include>
+ </includes>
+ <unpack>false</unpack>
+ <outputDirectory>.installer/hadoop-0.20.2/lib</outputDirectory>
+ </dependencySet>
+ <dependencySet>
+ <includes>
+ <include>org.apache.zookeeper:zookeeper</include>
+ <include>log4j:log4j</include>
+ <include>org.slf4j:slf4j-api</include>
+ </includes>
+ <unpack>false</unpack>
+ <outputDirectory>.installer/zookeeper/lib</outputDirectory>
+ </dependencySet>
+ <dependencySet>
+ <outputDirectory>asterix</outputDirectory>
+ <includes>
+ <include>asterix-server*</include>
+ </includes>
+ <useTransitiveDependencies>false</useTransitiveDependencies>
+ </dependencySet>
+ <dependencySet>
+ <outputDirectory>.installer/eventrix</outputDirectory>
+ <includes>
+ <include>asterix-events*</include>
+ </includes>
+ <unpack>false</unpack>
+ <useTransitiveDependencies>false</useTransitiveDependencies>
+ </dependencySet>
+ </dependencySets>
+</assembly>
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommand.java
new file mode 100644
index 0000000..af7dbb7
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommand.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import org.apache.log4j.Logger;
+import org.kohsuke.args4j.CmdLineParser;
+
+public abstract class AbstractCommand implements ICommand {
+
+ protected static final Logger LOGGER = Logger.getLogger(AbstractCommand.class.getName());
+
+ protected CommandConfig config;
+
+ protected String usageDescription;
+
+ public void execute(String[] args) throws Exception {
+ String[] cmdArgs = new String[args.length - 1];
+ System.arraycopy(args, 1, cmdArgs, 0, cmdArgs.length);
+ if (cmdArgs.length >= 1 && cmdArgs[0].equals("-help")) {
+ System.out.println(getUsageDescription());
+ } else {
+ config = getCommandConfig();
+ CmdLineParser parser = new CmdLineParser(config);
+ parser.parseArgument(cmdArgs);
+ execCommand();
+ }
+ }
+
+ abstract protected void execCommand() throws Exception;
+
+ abstract protected String getUsageDescription();
+
+ abstract protected CommandConfig getCommandConfig();
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommandConfig.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommandConfig.java
new file mode 100644
index 0000000..f28dfd9
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommandConfig.java
@@ -0,0 +1,15 @@
+package edu.uci.ics.asterix.installer.command;
+
+import org.kohsuke.args4j.Option;
+
+public class AbstractCommandConfig implements CommandConfig {
+
+ @Option(name = "-help", required = false, usage = "Help")
+ public boolean help = false;
+
+ @Override
+ public boolean helpMode() {
+ return help;
+ }
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AlterCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AlterCommand.java
new file mode 100644
index 0000000..e52308e
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AlterCommand.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import java.util.Date;
+import java.util.Properties;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.service.ILookupService;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class AlterCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ String instanceName = ((AlterConfig) config).name;
+ InstallerUtil.validateAsterixInstanceExists(instanceName, State.INACTIVE);
+ ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
+ AsterixInstance instance = lookupService.getAsterixInstance(instanceName);
+
+ Properties asterixConfProp = InstallerUtil.getAsterixConfiguration(((AlterConfig) config).confPath);
+ instance.setConfiguration(asterixConfProp);
+ instance.setModifiedTimestamp(new Date());
+ lookupService.updateAsterixInstance(instance);
+ LOGGER.info("Configuration for Asterix instance: " + instanceName + " has been altered");
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new AlterConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nAlter the instance's configuration settings."
+ + "\nPrior to running this command, the instance is required to be INACTIVE state."
+ + "\n\nAvailable arguments/options"
+ + "\n-n name of the ASTERIX instance"
+ + "\n-conf path to the ASTERIX configuration file.";
+ }
+
+}
+
+class AlterConfig extends AbstractCommandConfig {
+
+ @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
+ public String name;
+
+ @Option(name = "-conf", required = true, usage = "Path to instance configuration")
+ public String confPath;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java
new file mode 100644
index 0000000..cd4cc5c
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import java.util.Date;
+import java.util.List;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.events.PatternCreator;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.model.BackupInfo;
+import edu.uci.ics.asterix.installer.schema.conf.Backup;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class BackupCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ String asterixInstanceName = ((BackupConfig) config).name;
+ AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
+ List<BackupInfo> backupInfo = instance.getBackupInfo();
+ PatternCreator pc = new PatternCreator();
+ Backup backupConf = InstallerDriver.getConfiguration().getBackup();
+ Patterns patterns = pc.getBackUpAsterixPattern(instance, backupConf);
+ InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
+ int backupId = backupInfo.size();
+ BackupInfo binfo = new BackupInfo(backupId, new Date(), backupConf);
+ backupInfo.add(binfo);
+ LOGGER.info(asterixInstanceName + " backed up " + binfo);
+ ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new BackupConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nIn an undesirable event of data loss either due to a disk/system"
+ + "\nfailure or accidental execution of a DDL statement (drop dataverse/dataset),"
+ + "\nyou may need to recover the lost data. The backup command allows you to take a"
+ + "\nbackup of the data stored with an ASTERIX instance. "
+ + "\nThe backed up snapshot is stored in HDFS."
+ + "\n\nAvailable arguments/options:"
+ + "\n-n name of the Asterix instance";
+
+ }
+
+}
+
+class BackupConfig extends AbstractCommandConfig {
+
+ @Option(name = "-n", required = true, usage = "Name of the Asterix instance")
+ public String name;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java
new file mode 100644
index 0000000..94aa935
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+public interface CommandConfig {
+
+ public boolean helpMode();
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java
new file mode 100644
index 0000000..8a9347a
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import edu.uci.ics.asterix.installer.command.ICommand.CommandType;
+
+public class CommandHandler {
+
+ public void processCommand(String args[]) throws Exception {
+ CommandType cmdType = CommandType.valueOf(args[0].toUpperCase());
+ ICommand cmd = null;
+ switch (cmdType) {
+ case CREATE:
+ cmd = new CreateCommand();
+ break;
+ case ALTER:
+ cmd = new AlterCommand();
+ break;
+ case DELETE:
+ cmd = new DeleteCommand();
+ break;
+ case DESCRIBE:
+ cmd = new DescribeCommand();
+ break;
+ case BACKUP:
+ cmd = new BackupCommand();
+ break;
+ case RESTORE:
+ cmd = new RestoreCommand();
+ break;
+ case START:
+ cmd = new StartCommand();
+ break;
+ case STOP:
+ cmd = new StopCommand();
+ break;
+ case VALIDATE:
+ cmd = new ValidateCommand();
+ break;
+ case CONFIGURE:
+ cmd = new ConfigureCommand();
+ break;
+ case SHUTDOWN:
+ cmd = new ShutdownCommand();
+ break;
+ }
+ cmd.execute(args);
+ }
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java
new file mode 100644
index 0000000..6b0b53d
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java
@@ -0,0 +1,65 @@
+package edu.uci.ics.asterix.installer.command;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.WorkingDir;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.schema.conf.Configuration;
+
+public class ConfigureCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ String localClusterPath = InstallerDriver.getManagixHome() + File.separator + "clusters" + File.separator
+ + "local" + File.separator + "local.xml";
+
+ JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ Cluster cluster = (Cluster) unmarshaller.unmarshal(new File(localClusterPath));
+
+ String workingDir = InstallerDriver.getManagixHome() + File.separator + "clusters" + File.separator + "local"
+ + File.separator + "working_dir";
+ cluster.setWorkingDir(new WorkingDir(workingDir, true));
+ cluster.setStore(workingDir + File.separator + "storage");
+ cluster.setLogdir(workingDir + File.separator + "logs");
+ cluster.setJavaHome(System.getenv("JAVA_HOME"));
+
+ Marshaller marshaller = ctx.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ marshaller.marshal(cluster, new FileOutputStream(localClusterPath));
+
+ String installerConfPath = InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_CONF_XML;
+ ctx = JAXBContext.newInstance(Configuration.class);
+ unmarshaller = ctx.createUnmarshaller();
+ Configuration configuration = (Configuration) unmarshaller.unmarshal(new File(installerConfPath));
+
+ configuration.getBackup().setBackupDir(workingDir + File.separator + "backup");
+ configuration.getZookeeper().setHomeDir(workingDir + File.separator + "zookeeper");
+ marshaller = ctx.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ marshaller.marshal(configuration, new FileOutputStream(installerConfPath));
+
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nAuto-generates the ASTERIX installer configruation settings and ASTERIX cluster "
+ + "\n configuration settings for a single node setup.";
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new ConfigureConfig();
+ }
+
+}
+
+class ConfigureConfig extends AbstractCommandConfig {
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java
new file mode 100644
index 0000000..5ddc9e9
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.Env;
+import edu.uci.ics.asterix.event.schema.cluster.Property;
+import edu.uci.ics.asterix.event.schema.cluster.WorkingDir;
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.error.VerificationUtil;
+import edu.uci.ics.asterix.installer.events.PatternCreator;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixRuntimeState;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class CreateCommand extends AbstractCommand {
+
+ private String asterixInstanceName;
+ private Cluster cluster;
+
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ ValidateCommand validateCommand = new ValidateCommand();
+ boolean valid = validateCommand
+ .validateCluster(((CreateConfig) config).clusterPath);
+ if (!valid) {
+ throw new Exception("Cannot create an Asterix instance.");
+ }
+ asterixInstanceName = ((CreateConfig) config).name;
+ InstallerUtil.validateAsterixInstanceNotExists(asterixInstanceName);
+ CreateConfig createConfig = (CreateConfig) config;
+ JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ cluster = (Cluster) unmarshaller.unmarshal(new File(
+ createConfig.clusterPath));
+ cluster.setWorkingDir(new WorkingDir(cluster.getWorkingDir().getDir()
+ + File.separator + asterixInstanceName, cluster.getWorkingDir()
+ .isNFS()));
+ cluster.setLogdir(cluster.getLogdir() + File.separator
+ + asterixInstanceName);
+ AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(
+ asterixInstanceName, cluster);
+ InstallerUtil.evaluateConflictWithOtherInstances(asterixInstance);
+ InstallerUtil.createAsterixZip(asterixInstance, true);
+ List<Property> clusterProperties = new ArrayList<Property>();
+ clusterProperties.add(new Property("ASTERIX_HOME", cluster
+ .getWorkingDir().getDir() + File.separator + "asterix"));
+ clusterProperties.add(new Property("JAVA_OPTS", "-Xmx"
+ + cluster.getJavaHeap()));
+ clusterProperties.add(new Property("CLUSTER_NET_IP", cluster
+ .getMasterNode().getClusterIp()));
+ clusterProperties.add(new Property("CLIENT_NET_IP", cluster
+ .getMasterNode().getIp()));
+ clusterProperties.add(new Property("LOG_DIR", cluster.getLogdir()));
+ clusterProperties.add(new Property("JAVA_HOME", cluster.getJavaHome()));
+ clusterProperties.add(new Property("WORKING_DIR", cluster
+ .getWorkingDir().getDir()));
+ cluster.setEnv(new Env(clusterProperties));
+
+ PatternCreator pc = new PatternCreator();
+ Patterns patterns = pc.getStartAsterixPattern(asterixInstanceName,
+ cluster);
+ InstallerUtil.getEventrixClient(cluster).submit(patterns);
+
+ AsterixRuntimeState runtimeState = VerificationUtil
+ .getAsterixRuntimeState(asterixInstance);
+ VerificationUtil.updateInstanceWithRuntimeDescription(asterixInstance,
+ runtimeState, true);
+ ServiceProvider.INSTANCE.getLookupService().writeAsterixInstance(
+ asterixInstance);
+ InstallerUtil.deleteDirectory(InstallerDriver.getManagixHome()
+ + File.separator + InstallerDriver.ASTERIX_DIR + File.separator
+ + asterixInstanceName);
+ LOGGER.info(asterixInstance.getDescription(false));
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new CreateConfig();
+ }
+
+ public Cluster getCluster() {
+ return cluster;
+ }
+
+ public String getAsterixInstanceName() {
+ return asterixInstanceName;
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nCreates an ASTERIX instance with a specified name."
+ + "\n\nPost creation, the instance is in ACTIVE state, indicating its "
+ + "\navailability for executing statements/queries."
+ + "\n\nUsage arguments/options:"
+ + "\n-n Name of the ASTERIX instance."
+ + "\n-c Path to the cluster configuration file";
+ }
+
+}
+
+class CreateConfig extends AbstractCommandConfig {
+
+ @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
+ public String name;
+
+ @Option(name = "-c", required = true, usage = "Path to cluster configuration")
+ public String clusterPath;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DeleteCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DeleteCommand.java
new file mode 100644
index 0000000..a2788b4
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DeleteCommand.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.events.PatternCreator;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class DeleteCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ String asterixInstanceName = ((DeleteConfig) config).name;
+ AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(
+ asterixInstanceName, State.INACTIVE);
+ PatternCreator pc = new PatternCreator();
+ Patterns patterns = pc.createDeleteInstancePattern(instance);
+ InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
+
+ patterns = pc.createRemoveAsterixWorkingDirPattern(instance);
+ InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
+ ServiceProvider.INSTANCE.getLookupService().removeAsterixInstance(
+ asterixInstanceName);
+ LOGGER.info("Deleted Asterix instance: " + asterixInstanceName);
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new DeleteConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nPermanently deletes an ASTERIX instance." + "\n"
+ + "The instance must be in the INACTIVE state."
+ + "\n\nAvailable arguments/options"
+ + "\n-n name of the ASTERIX instance.";
+ }
+
+}
+
+class DeleteConfig extends AbstractCommandConfig {
+
+ @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
+ public String name;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DescribeCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DescribeCommand.java
new file mode 100644
index 0000000..bec82d5
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DescribeCommand.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import java.util.List;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.error.InstallerException;
+import edu.uci.ics.asterix.installer.error.VerificationUtil;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.model.AsterixRuntimeState;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class DescribeCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ String asterixInstanceName = ((DescribeConfig) config).name;
+ boolean adminView = ((DescribeConfig) config).admin;
+ if (asterixInstanceName != null) {
+ InstallerUtil.validateAsterixInstanceExists(asterixInstanceName,
+ State.INACTIVE, State.ACTIVE, State.UNUSABLE);
+ AsterixInstance instance = ServiceProvider.INSTANCE
+ .getLookupService().getAsterixInstance(asterixInstanceName);
+ if (instance != null) {
+ AsterixRuntimeState state = VerificationUtil
+ .getAsterixRuntimeState(instance);
+ boolean expectedRunning = instance.getState().equals(
+ State.UNUSABLE) ? instance.getPreviousState().equals(
+ State.ACTIVE) : !instance.getState().equals(
+ State.INACTIVE);
+ VerificationUtil.updateInstanceWithRuntimeDescription(instance,
+ state, expectedRunning);
+ ServiceProvider.INSTANCE.getLookupService()
+ .updateAsterixInstance(instance);
+ LOGGER.info(instance.getDescription(adminView));
+ } else {
+ throw new InstallerException("Asterix instance by the name "
+ + asterixInstanceName + " does not exist.");
+ }
+ } else {
+ List<AsterixInstance> asterixInstances = ServiceProvider.INSTANCE
+ .getLookupService().getAsterixInstances();
+ if (asterixInstances.size() > 0) {
+ for (AsterixInstance instance : asterixInstances) {
+ AsterixRuntimeState state = VerificationUtil
+ .getAsterixRuntimeState(instance);
+ boolean expectedRunning = instance.getState().equals(
+ State.UNUSABLE) ? instance.getPreviousState()
+ .equals(State.ACTIVE) : !instance.getState()
+ .equals(State.INACTIVE);
+ VerificationUtil.updateInstanceWithRuntimeDescription(
+ instance, state, expectedRunning);
+ ServiceProvider.INSTANCE.getLookupService()
+ .updateAsterixInstance(instance);
+ LOGGER.info(instance.getDescription(adminView));
+ }
+ } else {
+ LOGGER.info("No Asterix instances found!");
+ }
+
+ }
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new DescribeConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nProvides information about an ASTERIX instance."
+ + "\n\nUsage arguments/options:-"
+ + "\n[-n] Name of the ASTERIX instance."
+ + "\n[-admin] Provides a detailed description";
+ }
+
+}
+
+class DescribeConfig extends AbstractCommandConfig {
+
+ @Option(name = "-n", required = false, usage = "Name of Asterix Instance")
+ public String name;
+
+ @Option(name = "-admin", required = false, usage = "Detailed description")
+ public boolean admin;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java
new file mode 100644
index 0000000..d27fee9
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+public interface ICommand {
+
+ public enum CommandType {
+ CREATE,
+ DELETE,
+ START,
+ STOP,
+ BACKUP,
+ RESTORE,
+ DESCRIBE,
+ ALTER,
+ VALIDATE,
+ CONFIGURE,
+ SHUTDOWN
+ }
+
+ public void execute(String args[]) throws Exception;
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/RestoreCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/RestoreCommand.java
new file mode 100644
index 0000000..49629a4
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/RestoreCommand.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import java.util.List;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.events.PatternCreator;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.model.BackupInfo;
+
+public class RestoreCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ String asterixInstanceName = ((RestoreConfig) config).name;
+ AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
+ int backupId = ((RestoreConfig) config).backupId;
+ List<BackupInfo> backupInfoList = instance.getBackupInfo();
+ if (backupInfoList.size() <= backupId || backupId < 0) {
+ throw new IllegalStateException("Invalid backup id");
+ }
+
+ BackupInfo backupInfo = backupInfoList.get(backupId);
+ PatternCreator pc = new PatternCreator();
+ Patterns patterns = pc.getRestoreAsterixPattern(instance, backupInfo);
+ InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
+ LOGGER.info("Asterix instance: " + asterixInstanceName + " has been restored from backup");
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new RestoreConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nRestores an ASTERIX instance's data from a previously taken backup snapshot."
+ + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance"
+ + "\n-b id of the backup snapshot ";
+ }
+
+}
+
+class RestoreConfig extends AbstractCommandConfig {
+
+ @Option(name = "-n", required = true, usage = "Name of the Asterix instance")
+ public String name;
+
+ @Option(name = "-b", required = true, usage = "Id corresponding to the backed up version")
+ public int backupId;
+
+}
\ No newline at end of file
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ShutdownCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ShutdownCommand.java
new file mode 100644
index 0000000..cbfd5c5
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ShutdownCommand.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.service.ILookupService;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class ShutdownCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
+ lookupService.stopService(InstallerDriver.getConfiguration());
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new ShutdownConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nShuts down the installer's backgrouund processes";
+ }
+
+}
+
+class ShutdownConfig extends AbstractCommandConfig {
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartCommand.java
new file mode 100644
index 0000000..8004e9a
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartCommand.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import java.io.File;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.error.VerificationUtil;
+import edu.uci.ics.asterix.installer.events.PatternCreator;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.model.AsterixRuntimeState;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class StartCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ String asterixInstanceName = ((StartConfig) config).name;
+ AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
+ InstallerUtil.createAsterixZip(instance, false);
+ PatternCreator pc = new PatternCreator();
+ Patterns patterns = pc.getStartAsterixPattern(asterixInstanceName, instance.getCluster());
+ InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
+ InstallerUtil.deleteDirectory(InstallerDriver.getManagixHome() + File.separator + InstallerDriver.ASTERIX_DIR
+ + File.separator + asterixInstanceName);
+ AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(instance);
+ VerificationUtil.updateInstanceWithRuntimeDescription(instance, runtimeState, true);
+ LOGGER.info(instance.getDescription(false));
+ ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new StartConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nStarts an ASTERIX instance that is in INACTIVE state."
+ + "\nAfter executing the start command, the ASTERIX instance transits to the ACTIVE state,"
+ + "\nindicating that it is now available for executing statements/queries."
+ + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance. ";
+ }
+}
+
+class StartConfig extends AbstractCommandConfig {
+
+ @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
+ public String name;
+
+
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java
new file mode 100644
index 0000000..85fcb68
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.event.management.EventrixClient;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.pattern.Pattern;
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.events.PatternCreator;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class StopCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ String asterixInstanceName = ((StopConfig) config).name;
+ AsterixInstance asterixInstance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName,
+ State.ACTIVE, State.UNUSABLE);
+ PatternCreator pc = new PatternCreator();
+ List<Pattern> patternsToExecute = new ArrayList<Pattern>();
+ patternsToExecute.add(pc.createCCStopPattern(asterixInstance.getCluster().getMasterNode().getId()));
+
+ for (Node node : asterixInstance.getCluster().getNode()) {
+ patternsToExecute.add(pc.createNCStopPattern(node.getId(), asterixInstanceName + "_" + node.getId()));
+ }
+ EventrixClient client = InstallerUtil.getEventrixClient(asterixInstance.getCluster());
+ try {
+ client.submit(new Patterns(patternsToExecute));
+ } catch (Exception e) {
+ // processes are already dead
+ LOGGER.debug("Attempt to kill non-existing processess");
+ }
+ asterixInstance.setState(State.INACTIVE);
+ asterixInstance.setStateChangeTimestamp(new Date());
+ ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(asterixInstance);
+ LOGGER.info("Stopped Asterix instance: " + asterixInstanceName);
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new StopConfig();
+ }
+
+ public String getAsterixInstanceName() {
+ return ((StopConfig) config).name;
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nShuts an ASTERIX instance that is in ACTIVE/UNUSABLE state."
+ + "\nAfter executing the stop command, the ASTERIX instance transits"
+ + "\nto the INACTIVE state, indicating that it is no longer available"
+ + "\nfor executing statements/queries." + "\n\nAvailable arguments/options"
+ + "\n-n name of the ASTERIX instance.";
+
+ }
+
+}
+
+class StopConfig extends AbstractCommandConfig {
+
+ @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
+ public String name;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java
new file mode 100644
index 0000000..8d9804c
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java
@@ -0,0 +1,276 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import java.io.File;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.MasterNode;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.events.PatternCreator;
+import edu.uci.ics.asterix.installer.schema.conf.Configuration;
+import edu.uci.ics.asterix.installer.schema.conf.Zookeeper;
+
+public class ValidateCommand extends AbstractCommand {
+
+ private static final String OK = " [" + "\u2713" + "]";
+ private static final String ERROR = " [" + "x" + "]";
+ private static final String WARNING = " [" + "!" + "]";
+
+ @Override
+ protected void execCommand() throws Exception {
+ ValidateConfig vConfig = (ValidateConfig) config;
+ logValidationResult("Environment", validateEnvironment());
+ if (((ValidateConfig) config).cluster != null) {
+ logValidationResult("Cluster configuration",
+ validateCluster(vConfig.cluster));
+ } else {
+ logValidationResult("Installer Configuration",
+ validateConfiguration());
+ }
+ }
+
+ private void logValidationResult(String prefix, boolean isValid) {
+ if (!isValid) {
+ LOGGER.fatal(prefix + ERROR);
+ } else {
+ LOGGER.info(prefix + OK);
+ }
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new ValidateConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nValidate the installer's configuration or a cluster configuration"
+ + "\nUsage"
+ + "\nFor validating the installer configuration"
+ + "\nuse managix validate"
+ + "\n\nFor validating a cluster configuration"
+ + "\nuse managix validate -c <path to the cluster configuration file>";
+ }
+
+ public boolean validateEnvironment() throws Exception {
+ boolean valid = true;
+ String managixHome = System.getenv(InstallerDriver.ENV_MANAGIX_HOME);
+ if (managixHome == null) {
+ valid = false;
+ LOGGER.fatal(InstallerDriver.ENV_MANAGIX_HOME + " not set " + ERROR);
+ } else {
+ File home = new File(managixHome);
+ if (!home.exists()) {
+ valid = false;
+ LOGGER.fatal(InstallerDriver.ENV_MANAGIX_HOME + ": "
+ + home.getAbsolutePath() + " does not exist!" + ERROR);
+ }
+ }
+ return valid;
+
+ }
+
+ public boolean validateCluster(String clusterPath) throws Exception {
+ boolean valid = true;
+ Cluster cluster = null;
+ File f = new File(clusterPath);
+ if (!f.exists() || !f.isFile()) {
+ LOGGER.error(" Invalid path " + f.getAbsolutePath() + ERROR);
+ valid = false;
+ } else {
+ JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ cluster = (Cluster) unmarshaller.unmarshal(new File(clusterPath));
+ validateClusterProperties(cluster);
+
+ Set<String> servers = new HashSet<String>();
+ Set<String> serverIds = new HashSet<String>();
+ servers.add(cluster.getMasterNode().getIp());
+ serverIds.add(cluster.getMasterNode().getId());
+
+ MasterNode masterNode = cluster.getMasterNode();
+ Node master = new Node(masterNode.getId(), masterNode.getIp(),
+ masterNode.getJavaHeap(), masterNode.getJavaHome(),
+ masterNode.getLogdir(), null, masterNode.getDebug());
+
+ valid = valid & validateNodeConfiguration(master, cluster);
+
+ for (Node node : cluster.getNode()) {
+ servers.add(node.getIp());
+ if (serverIds.contains(node.getId())) {
+ valid = false;
+ LOGGER.error("Duplicate node id :" + node.getId() + ERROR);
+ } else {
+ valid = valid & validateNodeConfiguration(node, cluster);
+ }
+ }
+ }
+
+ if (valid) {
+ checkJavaVersion(cluster);
+ }
+ return valid;
+ }
+
+ private void checkJavaVersion(Cluster cluster) throws Exception {
+ PatternCreator pc = new PatternCreator();
+ Patterns patterns = pc.getClusterInfoPattern(cluster);
+ InstallerUtil.getEventrixClient(cluster).submit(patterns);
+ }
+
+ private void validateClusterProperties(Cluster cluster) {
+ List<String> tempDirs = new ArrayList<String>();
+ if (cluster.getLogdir() != null
+ && checkTemporaryPath(cluster.getLogdir())) {
+ tempDirs.add("Log directory: " + cluster.getLogdir());
+ }
+ if (cluster.getStore() != null
+ && checkTemporaryPath(cluster.getStore())) {
+ tempDirs.add("Store directory: " + cluster.getStore());
+ }
+
+ if (tempDirs.size() > 0) {
+ StringBuffer msg = new StringBuffer();
+ msg.append("The following paths are subject to be cleaned up by OS");
+ for (String tempDir : tempDirs) {
+ msg.append("\n" + tempDir + WARNING);
+ }
+ LOGGER.warn(msg);
+ }
+
+ }
+
+ private boolean validateNodeConfiguration(Node node, Cluster cluster) {
+ boolean valid = true;
+ valid = checkNodeReachability(node.getIp());
+ if (node.getJavaHome() == null || node.getJavaHome().length() == 0) {
+ if (cluster.getJavaHome() == null
+ || cluster.getJavaHome().length() == 0) {
+ valid = false;
+ LOGGER.fatal("java_home not defined at cluster/node level for node: "
+ + node.getId() + ERROR);
+ }
+ }
+
+ if (node.getLogdir() == null || node.getLogdir().length() == 0) {
+ if (cluster.getLogdir() == null
+ || cluster.getLogdir().length() == 0) {
+ valid = false;
+ LOGGER.fatal("log_dir not defined at cluster/node level for node: "
+ + node.getId() + ERROR);
+ }
+ }
+
+ if (node.getStore() == null || cluster.getStore().length() == 0) {
+ if (cluster.getMasterNode().getId().equals(node.getId())
+ && (cluster.getStore() == null || cluster.getStore()
+ .length() == 0)) {
+ valid = false;
+ LOGGER.fatal("store not defined at cluster/node level for node: "
+ + node.getId() + ERROR);
+ }
+ }
+
+ if (node.getJavaHeap() == null || node.getJavaHeap().length() == 0) {
+ if (cluster.getJavaHeap() == null
+ || cluster.getJavaHeap().length() == 0) {
+ valid = false;
+ LOGGER.fatal("java heap size not defined at cluster/node level for node: "
+ + node.getId() + ERROR);
+ }
+ }
+ return valid;
+ }
+
+ private boolean checkTemporaryPath(String logdir) {
+ return logdir.startsWith("/tmp/");
+
+ }
+
+ public boolean validateConfiguration() throws Exception {
+ String managixHome = System.getenv(InstallerDriver.ENV_MANAGIX_HOME);
+ File configFile = new File(managixHome + File.separator
+ + InstallerDriver.MANAGIX_CONF_XML);
+ JAXBContext configCtx = JAXBContext.newInstance(Configuration.class);
+ Unmarshaller unmarshaller = configCtx.createUnmarshaller();
+ Configuration conf = (Configuration) unmarshaller.unmarshal(configFile);
+ return validateZookeeperConfiguration(conf);
+ }
+
+ private boolean validateZookeeperConfiguration(Configuration conf)
+ throws Exception {
+ boolean valid = true;
+ Zookeeper zk = conf.getZookeeper();
+
+ if (zk.getHomeDir() == null || zk.getHomeDir().length() == 0) {
+ valid = false;
+ LOGGER.fatal("Zookeeper home dir not configured" + ERROR);
+ } else if (checkTemporaryPath(zk.getHomeDir())) {
+ LOGGER.warn("Zookeeper home dir is subject to be cleaned up by OS"
+ + WARNING);
+ }
+
+ if (zk.getServers().getServer().isEmpty()) {
+ valid = false;
+ LOGGER.fatal("Zookeeper servers not configured" + ERROR);
+ }
+
+ boolean validEnsemble = true;
+ for (String server : zk.getServers().getServer()) {
+ validEnsemble = validEnsemble && checkNodeReachability(server);
+ }
+
+ return valid;
+ }
+
+ private boolean checkNodeReachability(String server) {
+ boolean reachable = true;
+ try {
+ InetAddress address = InetAddress.getByName(server);
+ if (!address.isReachable(1000)) {
+ LOGGER.fatal("\n" + "Server: " + server + " unreachable"
+ + ERROR);
+ reachable = false;
+ }
+ } catch (Exception e) {
+ reachable = false;
+ LOGGER.fatal("\n" + "Server: " + server + " Invalid address"
+ + ERROR);
+ }
+ return reachable;
+ }
+
+}
+
+class ValidateConfig extends AbstractCommandConfig {
+
+ @Option(name = "-c", required = false, usage = "Path to the cluster configuration xml")
+ public String cluster;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java
new file mode 100644
index 0000000..321fd1a
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.driver;
+
+import java.io.File;
+import java.io.FileFilter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+import edu.uci.ics.asterix.installer.command.CommandHandler;
+import edu.uci.ics.asterix.installer.schema.conf.Configuration;
+import edu.uci.ics.asterix.installer.service.ILookupService;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class InstallerDriver {
+
+ public static final String MANAGIX_INTERNAL_DIR = ".installer";
+ public static final String MANAGIX_EVENT_DIR = MANAGIX_INTERNAL_DIR + File.separator + "eventrix";
+ public static final String MANAGIX_EVENT_SCRIPTS_DIR = MANAGIX_INTERNAL_DIR + File.separator + "eventrix"
+ + File.separator + "scripts";
+ public static final String ASTERIX_DIR = "asterix";
+ public static final String EVENTS_DIR = "events";
+
+ private static final Logger LOGGER = Logger.getLogger(InstallerDriver.class.getName());
+ public static final String ENV_MANAGIX_HOME = "MANAGIX_HOME";
+ public static final String MANAGIX_CONF_XML = "conf" + File.separator + "managix-conf.xml";
+
+ private static Configuration conf;
+ private static String managixHome;
+ private static String asterixZip;
+
+ public static String getAsterixZip() {
+ return asterixZip;
+ }
+
+ public static Configuration getConfiguration() {
+ return conf;
+ }
+
+ public static void initConfig() throws Exception {
+ File configFile = new File(managixHome + File.separator + MANAGIX_CONF_XML);
+ JAXBContext configCtx = JAXBContext.newInstance(Configuration.class);
+ Unmarshaller unmarshaller = configCtx.createUnmarshaller();
+ conf = (Configuration) unmarshaller.unmarshal(configFile);
+ asterixZip = initBinary("asterix-server");
+
+ ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
+ if (!lookupService.isRunning(conf)) {
+ lookupService.startService(conf);
+ }
+ }
+
+ private static String initBinary(final String fileNamePattern) {
+ String asterixDir = InstallerDriver.getAsterixDir();
+ File file = new File(asterixDir);
+ File[] zipFiles = file.listFiles(new FileFilter() {
+ public boolean accept(File arg0) {
+ return arg0.getAbsolutePath().contains(fileNamePattern) && arg0.isFile();
+ }
+ });
+ if (zipFiles.length == 0) {
+ String msg = " Binary not found at " + asterixDir;
+ LOGGER.log(Level.FATAL, msg);
+ throw new IllegalStateException(msg);
+ }
+ if (zipFiles.length > 1) {
+ String msg = " Multiple binaries found at " + asterixDir;
+ LOGGER.log(Level.FATAL, msg);
+ throw new IllegalStateException(msg);
+ }
+
+ return zipFiles[0].getAbsolutePath();
+ }
+
+ public static String getManagixHome() {
+ return managixHome;
+ }
+
+ public static String getAsterixDir() {
+ return managixHome + File.separator + ASTERIX_DIR;
+ }
+
+ public static void main(String args[]) {
+ try {
+ if (args.length != 0) {
+ managixHome = System.getenv(ENV_MANAGIX_HOME);
+ CommandHandler cmdHandler = new CommandHandler();
+ cmdHandler.processCommand(args);
+ } else {
+ printUsage();
+ }
+ } catch (IllegalArgumentException iae) {
+ LOGGER.error("Unknown command");
+ printUsage();
+ } catch (Exception e) {
+ LOGGER.error(e.getMessage());
+ }
+ }
+
+ private static void printUsage() {
+ StringBuffer buffer = new StringBuffer("managix <command> <options>" + "\n");
+ buffer.append("Commands" + "\n");
+ buffer.append("create " + ":" + " Creates a new asterix instance" + "\n");
+ buffer.append("delete " + ":" + " Deletes an asterix instance" + "\n");
+ buffer.append("start " + ":" + " Starts an asterix instance" + "\n");
+ buffer.append("stop " + ":" + " Stops an asterix instance that is in ACTIVE state" + "\n");
+ buffer.append("backup " + ":" + " Creates a back up for an existing asterix instance" + "\n");
+ buffer.append("restore " + ":" + " Restores an asterix instance" + "\n");
+ buffer.append("describe " + ":" + " Describes an existing asterix instance" + "\n");
+ buffer.append("validate " + ":" + " Validates the installer/cluster configuration" + "\n");
+ buffer.append("configure" + ":" + " Auto-generate configuration for local psedu-distributed Asterix instance"
+ + "\n");
+ buffer.append("shutdown " + ":" + " Shutdown the installer service" + "\n");
+ buffer.append("validate " + ":" + " Validates the installer/cluster configuration" + "\n");
+ buffer.append("configure" + ":" + " Auto-generate configuration for local psedu-distributed Asterix instance"
+ + "\n");
+ buffer.append("shutdown " + ":" + " Shutdown the installer service" + "\n");
+ LOGGER.info(buffer.toString());
+ }
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
new file mode 100644
index 0000000..24b531a
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
@@ -0,0 +1,358 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.driver;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+import java.util.Random;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.commons.io.IOUtils;
+
+import edu.uci.ics.asterix.event.driver.EventDriver;
+import edu.uci.ics.asterix.event.management.EventrixClient;
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.installer.error.InstallerException;
+import edu.uci.ics.asterix.installer.error.OutputHandler;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class InstallerUtil {
+
+ public static AsterixInstance createAsterixInstance(String asterixInstanceName, Cluster cluster)
+ throws FileNotFoundException, IOException {
+ Properties asterixConfProp = new Properties();
+ asterixConfProp.put("output_dir", cluster.getWorkingDir().getDir() + File.separator + "asterix_output");
+ Node metadataNode = getMetadataNode(cluster);
+ String asterixZipName = InstallerDriver.getAsterixZip().substring(
+ InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
+ String asterixVersion = asterixZipName.substring("asterix-server-".length(),
+ asterixZipName.indexOf("-binary-assembly"));
+ AsterixInstance instance = new AsterixInstance(asterixInstanceName, cluster, asterixConfProp,
+ metadataNode.getId(), asterixVersion);
+ return instance;
+ }
+
+ public static void createAsterixZip(AsterixInstance asterixInstance, boolean newDeployment) throws IOException {
+ writeAsterixConfigurationFile(asterixInstance, newDeployment);
+ String asterixInstanceDir = InstallerDriver.getAsterixDir() + File.separator + asterixInstance.getName();
+ unzip(InstallerDriver.getAsterixZip(), asterixInstanceDir);
+ File sourceJar = new File(asterixInstanceDir + File.separator + "lib" + File.separator + "asterix-app-"
+ + asterixInstance.getAsterixVersion() + ".jar");
+ String origFile = "test.properties";
+ File replacementFile = new File(asterixInstanceDir + File.separator + "test.properties");
+ replaceInJar(sourceJar, origFile, replacementFile);
+ new File(asterixInstanceDir + File.separator + "test.properties").delete();
+ String asterixZipName = InstallerDriver.getAsterixZip().substring(
+ InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
+ zipDir(new File(asterixInstanceDir), new File(asterixInstanceDir + File.separator + asterixZipName));
+
+ }
+
+ public static void addLibraryToAsterixZip(AsterixInstance asterixInstance, String dataverseName,
+ String libraryName, String libraryPath) throws IOException {
+ File instanceDir = new File(InstallerDriver.getAsterixDir() + File.separator + asterixInstance.getName());
+ if (!instanceDir.exists()) {
+ instanceDir.mkdirs();
+ }
+ String asterixZipName = InstallerDriver.getAsterixZip().substring(
+ InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
+
+ String sourceZip = instanceDir.getAbsolutePath() + File.separator + asterixZipName;
+ unzip(sourceZip, instanceDir.getAbsolutePath());
+ File libraryPathInZip = new File(instanceDir.getAbsolutePath() + File.separator + "external" + File.separator
+ + "library" + dataverseName + File.separator + "to-add" + File.separator + libraryName);
+ libraryPathInZip.mkdirs();
+ Runtime.getRuntime().exec("cp" + " " + libraryPath + " " + libraryPathInZip.getAbsolutePath());
+ Runtime.getRuntime().exec("rm " + sourceZip);
+ String destZip = InstallerDriver.getAsterixDir() + File.separator + asterixInstance.getName() + File.separator
+ + asterixZipName;
+ zipDir(instanceDir, new File(destZip));
+ Runtime.getRuntime().exec("mv" + " " + destZip + " " + sourceZip);
+ }
+
+ private static Node getMetadataNode(Cluster cluster) {
+ Random random = new Random();
+ int nNodes = cluster.getNode().size();
+ return cluster.getNode().get(random.nextInt(nNodes));
+ }
+
+ public static String getNodeDirectories(String asterixInstanceName, Node node, Cluster cluster) {
+ String storeDataSubDir = asterixInstanceName + File.separator + "data" + File.separator;
+ String storeLibrarySubDir = asterixInstanceName + File.separator + "library" + File.separator;
+ String[] storeDirs = null;
+ StringBuffer nodeDataStore = new StringBuffer();
+ String storeDirValue = node.getStore();
+ if (storeDirValue == null) {
+ storeDirValue = cluster.getStore();
+ if (storeDirValue == null) {
+ throw new IllegalStateException(" Store not defined for node " + node.getId());
+ }
+ storeDataSubDir = node.getId() + File.separator + storeDataSubDir;
+ storeLibrarySubDir = node.getId() + File.separator + storeLibrarySubDir;
+ }
+
+ storeDirs = storeDirValue.split(",");
+ for (String ns : storeDirs) {
+ nodeDataStore.append(ns + File.separator + storeDataSubDir.trim());
+ nodeDataStore.append(",");
+ }
+ nodeDataStore.deleteCharAt(nodeDataStore.length() - 1);
+ return nodeDataStore.toString();
+ }
+
+ private static void writeAsterixConfigurationFile(AsterixInstance asterixInstance, boolean newData)
+ throws IOException {
+ String asterixInstanceName = asterixInstance.getName();
+ Cluster cluster = asterixInstance.getCluster();
+ String metadataNodeId = asterixInstance.getMetadataNodeId();
+
+ StringBuffer conf = new StringBuffer();
+ conf.append("MetadataNode=" + asterixInstanceName + "_" + metadataNodeId + "\n");
+ conf.append("NewUniverse=" + newData + "\n");
+
+ for (Node node : cluster.getNode()) {
+ String nodeDir = getNodeDirectories(asterixInstance.getName(), node, cluster);
+ conf.append(asterixInstanceName + "_" + node.getId() + ".stores" + "=" + nodeDir + "\n");
+ }
+ Properties asterixConfProp = asterixInstance.getConfiguration();
+ String outputDir = asterixConfProp.getProperty("output_dir");
+ conf.append("OutputDir=" + outputDir);
+ File asterixConfDir = new File(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName);
+ asterixConfDir.mkdirs();
+ dumpToFile(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName + File.separator
+ + "test.properties", conf.toString());
+ }
+
+ public static Properties getAsterixConfiguration(String asterixConf) throws FileNotFoundException, IOException {
+ Properties prop = new Properties();
+ prop.load(new FileInputStream(asterixConf));
+ return prop;
+ }
+
+ public static void unzip(String sourceFile, String destDir) throws IOException {
+ BufferedOutputStream dest = null;
+ FileInputStream fis = new FileInputStream(sourceFile);
+ ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
+ ZipEntry entry = null;
+
+ int BUFFER_SIZE = 4096;
+ while ((entry = zis.getNextEntry()) != null) {
+ String dst = destDir + File.separator + entry.getName();
+ if (entry.isDirectory()) {
+ createDir(destDir, entry);
+ continue;
+ }
+ int count;
+ byte data[] = new byte[BUFFER_SIZE];
+
+ //write the file to the disk
+ FileOutputStream fos = new FileOutputStream(dst);
+ dest = new BufferedOutputStream(fos, BUFFER_SIZE);
+ while ((count = zis.read(data, 0, BUFFER_SIZE)) != -1) {
+ dest.write(data, 0, count);
+ }
+ //close the output streams
+ dest.flush();
+ dest.close();
+ }
+
+ zis.close();
+ }
+
+ public static void zipDir(File sourceDir, File destFile) throws IOException {
+ FileOutputStream fos = new FileOutputStream(destFile);
+ ZipOutputStream zos = new ZipOutputStream(fos);
+ zipDir(sourceDir, destFile, zos);
+ zos.close();
+ }
+
+ private static void zipDir(File sourceDir, final File destFile, ZipOutputStream zos) throws IOException {
+ File[] dirList = sourceDir.listFiles(new FileFilter() {
+ public boolean accept(File f) {
+ return !f.getName().endsWith(destFile.getName());
+ }
+ });
+ for (int i = 0; i < dirList.length; i++) {
+ File f = dirList[i];
+ if (f.isDirectory()) {
+ zipDir(f, destFile, zos);
+ } else {
+ int bytesIn = 0;
+ byte[] readBuffer = new byte[2156];
+ FileInputStream fis = new FileInputStream(f);
+ ZipEntry entry = new ZipEntry(sourceDir.getName() + File.separator + f.getName());
+ zos.putNextEntry(entry);
+ while ((bytesIn = fis.read(readBuffer)) != -1) {
+ zos.write(readBuffer, 0, bytesIn);
+ }
+ fis.close();
+ }
+ }
+ }
+
+ private static void replaceInJar(File sourceJar, String origFile, File replacementFile) throws IOException {
+ File destJar = new File(sourceJar.getAbsolutePath() + ".modified");
+ InputStream jarIs = null;
+ FileInputStream fis = new FileInputStream(replacementFile);
+ JarFile sourceJarFile = new JarFile(sourceJar);
+ Enumeration<JarEntry> entries = sourceJarFile.entries();
+ JarOutputStream jos = new JarOutputStream(new FileOutputStream(destJar));
+ byte[] buffer = new byte[2048];
+ int read;
+ while (entries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) entries.nextElement();
+ String name = entry.getName();
+ if (name.equals(origFile)) {
+ continue;
+ }
+ jarIs = sourceJarFile.getInputStream(entry);
+ jos.putNextEntry(entry);
+ while ((read = jarIs.read(buffer)) != -1) {
+ jos.write(buffer, 0, read);
+ }
+ }
+ JarEntry entry = new JarEntry(origFile);
+ jos.putNextEntry(entry);
+ while ((read = fis.read(buffer)) != -1) {
+ jos.write(buffer, 0, read);
+ }
+ fis.close();
+ jos.close();
+ jarIs.close();
+ sourceJar.delete();
+ destJar.renameTo(sourceJar);
+ sourceJar.setExecutable(true);
+ }
+
+ public static void dumpToFile(String dest, String content) throws IOException {
+ FileWriter writer = new FileWriter(dest);
+ writer.write(content);
+ writer.close();
+ }
+
+ private static void createDir(String destDirectory, ZipEntry entry) {
+ String name = entry.getName();
+ int index = name.lastIndexOf(File.separator);
+ String dirSequence = name.substring(0, index);
+ File newDirs = new File(destDirectory + File.separator + dirSequence);
+ newDirs.mkdirs();
+ }
+
+ public static AsterixInstance validateAsterixInstanceExists(String name, State... permissibleStates)
+ throws Exception {
+ AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(name);
+ if (instance == null) {
+ throw new InstallerException("Asterix instance by name " + name + " does not exist.");
+ }
+ boolean valid = false;
+ for (State state : permissibleStates) {
+ if (state.equals(instance.getState())) {
+ valid = true;
+ break;
+ }
+ }
+ if (!valid) {
+ throw new InstallerException("Asterix instance by the name " + name + " is in " + instance.getState()
+ + " state ");
+ }
+ return instance;
+ }
+
+ public static void validateAsterixInstanceNotExists(String name) throws Exception {
+ AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(name);
+ if (instance != null) {
+ throw new InstallerException("Asterix instance by name " + name + " already exists.");
+ }
+ }
+
+ public static void evaluateConflictWithOtherInstances(AsterixInstance instance) throws Exception {
+ List<AsterixInstance> existingInstances = ServiceProvider.INSTANCE.getLookupService().getAsterixInstances();
+ List<String> usedIps = new ArrayList<String>();
+ String masterIp = instance.getCluster().getMasterNode().getIp();
+ for (Node node : instance.getCluster().getNode()) {
+ usedIps.add(node.getIp());
+ }
+ usedIps.add(instance.getCluster().getMasterNode().getIp());
+ boolean conflictFound = false;
+ AsterixInstance conflictingInstance = null;
+ for (AsterixInstance existing : existingInstances) {
+ conflictFound = existing.getCluster().getMasterNode().getIp().equals(masterIp);
+ if (conflictFound) {
+ conflictingInstance = existing;
+ break;
+ }
+ for (Node n : existing.getCluster().getNode()) {
+ if (usedIps.contains(n.getIp())) {
+ conflictFound = true;
+ conflictingInstance = existing;
+ break;
+ }
+ }
+ }
+ if (conflictFound) {
+ throw new Exception("Cluster definition conflicts with an existing instance of Asterix: "
+ + conflictingInstance.getName());
+ }
+ }
+
+ public static void deleteDirectory(String path) throws IOException {
+ Runtime.getRuntime().exec("rm -rf " + path);
+ }
+
+ public static String executeLocalScript(String path, List<String> args) throws Exception {
+ List<String> pargs = new ArrayList<String>();
+ pargs.add("/bin/bash");
+ pargs.add(path);
+ if (args != null) {
+ pargs.addAll(args);
+ }
+ ProcessBuilder pb = new ProcessBuilder(pargs);
+ pb.environment().putAll(EventDriver.getEnvironment());
+ pb.environment().put("IP_LOCATION", EventDriver.CLIENT_NODE.getIp());
+ Process p = pb.start();
+ BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
+ StringWriter writer = new StringWriter();
+ IOUtils.copy(bis, writer, "UTF-8");
+ return writer.toString();
+ }
+
+ public static EventrixClient getEventrixClient(Cluster cluster) throws Exception {
+ return new EventrixClient(
+ InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_EVENT_DIR, cluster, false,
+ OutputHandler.INSTANCE);
+ }
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/InstallerException.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/InstallerException.java
new file mode 100644
index 0000000..89dedb6
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/InstallerException.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.error;
+
+public class InstallerException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public InstallerException(String message) {
+ super(message);
+ }
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/OutputHandler.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/OutputHandler.java
new file mode 100644
index 0000000..4699402
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/OutputHandler.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.error;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import edu.uci.ics.asterix.event.management.IOutputHandler;
+import edu.uci.ics.asterix.event.management.OutputAnalysis;
+import edu.uci.ics.asterix.event.schema.pattern.Event;
+import edu.uci.ics.asterix.installer.model.EventList.EventType;
+
+public class OutputHandler implements IOutputHandler {
+
+ public static IOutputHandler INSTANCE = new OutputHandler();
+
+ private OutputHandler() {
+
+ }
+
+ public OutputAnalysis reportEventOutput(Event event, String output) {
+
+ EventType eventType = EventType.valueOf(event.getType().toUpperCase());
+ boolean ignore = true;
+ String trimmedOutput = output.trim();
+ StringBuffer errorMessage = new StringBuffer();
+ switch (eventType) {
+ case FILE_TRANSFER:
+ if (trimmedOutput.length() > 0) {
+ if (output.contains("Permission denied") || output.contains("cannot find or open")) {
+ ignore = false;
+ break;
+ }
+ }
+ break;
+
+ case BACKUP:
+ case RESTORE:
+ if (trimmedOutput.length() > 0) {
+ if (trimmedOutput.contains("AccessControlException")) {
+ errorMessage.append("Insufficient permissions on back up directory");
+ ignore = false;
+ }
+ if (output.contains("does not exist") || output.contains("File exist")
+ || (output.contains("No such file or directory"))) {
+ ignore = true;
+ } else {
+ ignore = false;
+ }
+ }
+ break;
+
+ case NODE_INFO:
+ Properties p = new Properties();
+ try {
+ p.load(new ByteArrayInputStream(trimmedOutput.getBytes()));
+ } catch (IOException e) {
+ }
+ String javaVersion = (String) p.get("java_version");
+ if (p.get("java_version") == null) {
+ errorMessage.append("Java not installed on " + event.getNodeid().getValue().getAbsvalue());
+ ignore = false;
+ } else if (!javaVersion.contains("1.7")) {
+ errorMessage.append("Asterix requires Java 1.7.x. Incompatible version found on "
+ + event.getNodeid().getValue().getAbsvalue() + "\n");
+ ignore = false;
+ }
+ break;
+ }
+ if (ignore) {
+ return new OutputAnalysis(true, null);
+ } else {
+ return new OutputAnalysis(false, errorMessage.toString());
+ }
+ }
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/VerificationUtil.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/VerificationUtil.java
new file mode 100644
index 0000000..7c7a792
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/VerificationUtil.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.error;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.model.AsterixRuntimeState;
+import edu.uci.ics.asterix.installer.model.ProcessInfo;
+
+public class VerificationUtil {
+
+ private static final String VERIFY_SCRIPT_PATH = InstallerDriver.getManagixHome() + File.separator
+ + InstallerDriver.MANAGIX_INTERNAL_DIR + File.separator + "scripts" + File.separator + "verify.sh";
+
+ public static AsterixRuntimeState getAsterixRuntimeState(AsterixInstance instance) throws Exception {
+
+ Cluster cluster = instance.getCluster();
+ List<String> args = new ArrayList<String>();
+ args.add(instance.getName());
+ args.add(instance.getCluster().getMasterNode().getIp());
+ for (Node node : cluster.getNode()) {
+ args.add(node.getIp());
+ args.add(instance.getName() + "_" + node.getId());
+ }
+
+ String output = InstallerUtil.executeLocalScript(VERIFY_SCRIPT_PATH, args);
+ boolean ccRunning = true;
+ List<String> failedNCs = new ArrayList<String>();
+ String[] infoFields;
+ ProcessInfo pInfo;
+ List<ProcessInfo> processes = new ArrayList<ProcessInfo>();
+
+ for (String line : output.split("\n")) {
+ infoFields = line.split(":");
+ try {
+ int pid = Integer.parseInt(infoFields[3]);
+ pInfo = new ProcessInfo(infoFields[0], infoFields[1], pid);
+ processes.add(pInfo);
+ } catch (Exception e) {
+ if (infoFields[0].equalsIgnoreCase("CC")) {
+ ccRunning = false;
+ } else {
+ failedNCs.add(infoFields[1]);
+ }
+ }
+ }
+ return new AsterixRuntimeState(processes, failedNCs, ccRunning);
+ }
+
+ public static void updateInstanceWithRuntimeDescription(AsterixInstance instance, AsterixRuntimeState state,
+ boolean expectedRunning) {
+ StringBuffer summary = new StringBuffer();
+ if (expectedRunning) {
+ if (!state.isCcRunning()) {
+ summary.append("Cluster Controller not running at " + instance.getCluster().getMasterNode().getIp()
+ + "\n");
+ instance.setState(State.UNUSABLE);
+ }
+ if (state.getFailedNCs() != null && !state.getFailedNCs().isEmpty()) {
+ summary.append("Node Controller not running at the following nodes" + "\n");
+ for (String failedNC : state.getFailedNCs()) {
+ summary.append(failedNC + "\n");
+ }
+ instance.setState(State.UNUSABLE);
+ }
+ if (!(instance.getState().equals(State.UNUSABLE))) {
+ instance.setState(State.ACTIVE);
+ }
+ } else {
+ if (state.getProcesses() != null && state.getProcesses().size() > 0) {
+ summary.append("Following process still running " + "\n");
+ for (ProcessInfo pInfo : state.getProcesses()) {
+ summary.append(pInfo + "\n");
+ }
+ instance.setState(State.UNUSABLE);
+ } else {
+ instance.setState(State.INACTIVE);
+ }
+ }
+ state.setSummary(summary.toString());
+ instance.setAsterixRuntimeStates(state);
+ }
+
+ public static void verifyBackupRestoreConfiguration(String hdfsUrl, String hadoopVersion, String hdfsBackupDir)
+ throws Exception {
+ StringBuffer errorCheck = new StringBuffer();
+ if (hdfsUrl == null || hdfsUrl.length() == 0) {
+ errorCheck.append("\n HDFS Url not configured");
+ }
+ if (hadoopVersion == null || hadoopVersion.length() == 0) {
+ errorCheck.append("\n HDFS version not configured");
+ }
+ if (hdfsBackupDir == null || hdfsBackupDir.length() == 0) {
+ errorCheck.append("\n HDFS backup directory not configured");
+ }
+ if (errorCheck.length() > 0) {
+ throw new Exception("Incomplete hdfs configuration in " + InstallerDriver.getManagixHome() + File.separator
+ + InstallerDriver.MANAGIX_CONF_XML + errorCheck);
+ }
+ }
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
new file mode 100644
index 0000000..46b909c
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
@@ -0,0 +1,441 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.events;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import edu.uci.ics.asterix.event.driver.EventDriver;
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.pattern.Delay;
+import edu.uci.ics.asterix.event.schema.pattern.Event;
+import edu.uci.ics.asterix.event.schema.pattern.Nodeid;
+import edu.uci.ics.asterix.event.schema.pattern.Pattern;
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.event.schema.pattern.Value;
+import edu.uci.ics.asterix.installer.command.StopCommand;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.error.VerificationUtil;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.BackupInfo;
+import edu.uci.ics.asterix.installer.model.BackupInfo.BackupType;
+import edu.uci.ics.asterix.installer.schema.conf.Backup;
+import edu.uci.ics.asterix.installer.service.ILookupService;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class PatternCreator {
+
+ private ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
+
+ private void addInitialDelay(Pattern p, int delay, String unit) {
+ Delay d = new Delay(new Value(null, "" + delay), unit);
+ p.setDelay(d);
+ }
+
+ public Patterns getStartAsterixPattern(String asterixInstanceName, Cluster cluster) throws Exception {
+ String ccLocationId = cluster.getMasterNode().getId();
+ String ccLocationIp = cluster.getMasterNode().getIp();
+
+ String destDir = cluster.getWorkingDir().getDir() + File.separator + "asterix";
+ List<Pattern> ps = new ArrayList<Pattern>();
+
+ Pattern copyHyracks = createCopyHyracksPattern(asterixInstanceName, cluster, ccLocationIp, destDir);
+ ps.add(copyHyracks);
+
+ Pattern createCC = createCCStartPattern(ccLocationId);
+ addInitialDelay(createCC, 2, "sec");
+ ps.add(createCC);
+
+ boolean copyHyracksToNC = !cluster.getWorkingDir().isNFS();
+ for (Node node : cluster.getNode()) {
+ if (copyHyracksToNC) {
+ Pattern copyHyracksForNC = createCopyHyracksPattern(asterixInstanceName, cluster, node.getIp(), destDir);
+ ps.add(copyHyracksForNC);
+ }
+ Pattern createNC = createNCStartPattern(cluster.getMasterNode().getIp(), node.getId(), asterixInstanceName
+ + "_" + node.getId());
+ addInitialDelay(createNC, 4, "sec");
+ ps.add(createNC);
+ }
+
+ Patterns patterns = new Patterns(ps);
+ patterns.getPattern().addAll(createHadoopLibraryTransferPattern(cluster).getPattern());
+ return patterns;
+ }
+
+ public Patterns getClusterInfoPattern(Cluster cluster) throws Exception {
+ List<Pattern> ps = new ArrayList<Pattern>();
+ String pargs = "";
+ List<Node> nodeList = cluster.getNode();
+ nodeList.add(new Node(cluster.getMasterNode().getId(), cluster.getMasterNode().getIp(), null, null, null, null,
+ null));
+ for (Node node : nodeList) {
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ Event event = new Event("node_info", nodeid, pargs);
+ ps.add(new Pattern(null, 1, null, event));
+ }
+ return new Patterns(ps);
+ }
+
+ public Patterns getStopCommandPattern(StopCommand stopCommand) throws Exception {
+ List<Pattern> ps = new ArrayList<Pattern>();
+ AsterixInstance asterixInstance = lookupService.getAsterixInstance(stopCommand.getAsterixInstanceName());
+ Cluster cluster = asterixInstance.getCluster();
+
+ String ccLocation = cluster.getMasterNode().getId();
+ Pattern createCC = createCCStopPattern(ccLocation);
+ addInitialDelay(createCC, 5, "sec");
+ ps.add(createCC);
+
+ String asterixInstanceName = stopCommand.getAsterixInstanceName();
+ int nodeControllerIndex = 1;
+ for (Node node : cluster.getNode()) {
+ Pattern createNC = createNCStopPattern(node.getId(), asterixInstanceName + "_" + nodeControllerIndex);
+ ps.add(createNC);
+ nodeControllerIndex++;
+ }
+
+ Patterns patterns = new Patterns(ps);
+ return patterns;
+ }
+
+ public Patterns getBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
+ BackupType backupType = BackupInfo.getBackupType(backupConf);
+ Patterns patterns = null;
+ switch (backupType) {
+ case HDFS:
+ patterns = getHDFSBackUpAsterixPattern(instance, backupConf);
+ break;
+ case LOCAL:
+ patterns = getLocalBackUpAsterixPattern(instance, backupConf);
+ break;
+ }
+ return patterns;
+ }
+
+ public Patterns getRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
+ BackupType backupType = backupInfo.getBackupType();
+ Patterns patterns = null;
+ switch (backupType) {
+ case HDFS:
+ patterns = getHDFSRestoreAsterixPattern(instance, backupInfo);
+ break;
+ case LOCAL:
+ patterns = getLocalRestoreAsterixPattern(instance, backupInfo);
+ break;
+ }
+ return patterns;
+ }
+
+ private Patterns getHDFSBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
+ Cluster cluster = instance.getCluster();
+ String clusterStore = instance.getCluster().getStore();
+ String hdfsUrl = backupConf.getHdfs().getUrl();
+ String hadoopVersion = backupConf.getHdfs().getVersion();
+ String hdfsBackupDir = backupConf.getBackupDir();
+ VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
+ String workingDir = cluster.getWorkingDir().getDir();
+ String backupId = "" + instance.getBackupInfo().size();
+ String nodeStore;
+ String pargs;
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ for (Node node : cluster.getNode()) {
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ nodeStore = node.getStore() == null ? clusterStore : node.getStore();
+ pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + hdfsBackupDir
+ + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
+ Event event = new Event("backup", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ return new Patterns(patternList);
+ }
+
+ private Patterns getLocalBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
+ Cluster cluster = instance.getCluster();
+ String clusterStore = instance.getCluster().getStore();
+ String backupDir = backupConf.getBackupDir();
+ String workingDir = cluster.getWorkingDir().getDir();
+ String backupId = "" + instance.getBackupInfo().size();
+ String nodeStore;
+ String pargs;
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ for (Node node : cluster.getNode()) {
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ nodeStore = node.getStore() == null ? clusterStore : node.getStore();
+ pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + backupDir + " "
+ + "local" + " " + node.getId();
+ Event event = new Event("backup", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ return new Patterns(patternList);
+ }
+
+ public Patterns getHDFSRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
+ Cluster cluster = instance.getCluster();
+ String clusterStore = instance.getCluster().getStore();
+ String hdfsUrl = backupInfo.getBackupConf().getHdfs().getUrl();
+ String hadoopVersion = backupInfo.getBackupConf().getHdfs().getVersion();
+ String hdfsBackupDir = backupInfo.getBackupConf().getBackupDir();
+ VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
+ String workingDir = cluster.getWorkingDir().getDir();
+ int backupId = backupInfo.getId();
+ String nodeStore;
+ String pargs;
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ for (Node node : cluster.getNode()) {
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ nodeStore = node.getStore() == null ? clusterStore : node.getStore();
+ pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + hdfsBackupDir
+ + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
+ Event event = new Event("restore", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ return new Patterns(patternList);
+ }
+
+ public Patterns getLocalRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
+ Cluster cluster = instance.getCluster();
+ String clusterStore = instance.getCluster().getStore();
+ String backupDir = backupInfo.getBackupConf().getBackupDir();
+ String workingDir = cluster.getWorkingDir().getDir();
+ int backupId = backupInfo.getId();
+ String nodeStore;
+ String pargs;
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ for (Node node : cluster.getNode()) {
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ nodeStore = node.getStore() == null ? clusterStore : node.getStore();
+ pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + backupDir + " "
+ + "local" + " " + node.getId();
+ Event event = new Event("restore", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ return new Patterns(patternList);
+ }
+
+ public Patterns createHadoopLibraryTransferPattern(Cluster cluster) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ String workingDir = cluster.getWorkingDir().getDir();
+ String hadoopVersion = InstallerDriver.getConfiguration().getBackup().getHdfs().getVersion();
+ File hadoopDir = new File(InstallerDriver.getManagixHome() + File.separator
+ + InstallerDriver.MANAGIX_INTERNAL_DIR + File.separator + "hadoop-" + hadoopVersion);
+ if (!hadoopDir.exists()) {
+ throw new IllegalStateException("Hadoop version :" + hadoopVersion + " not supported");
+ }
+
+ Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
+ String username = cluster.getUsername() != null ? cluster.getUsername() : System.getProperty("user.name");
+ String pargs = username + " " + hadoopDir.getAbsolutePath() + " " + cluster.getMasterNode().getIp() + " "
+ + workingDir;
+ Event event = new Event("directory_transfer", nodeid, pargs);
+ Pattern p = new Pattern(null, 1, null, event);
+ addInitialDelay(p, 2, "sec");
+ patternList.add(p);
+
+ boolean copyToNC = !cluster.getWorkingDir().isNFS();
+ if (copyToNC) {
+ for (Node node : cluster.getNode()) {
+ nodeid = new Nodeid(new Value(null, node.getId()));
+ pargs = cluster.getUsername() + " " + hadoopDir.getAbsolutePath() + " " + node.getIp() + " "
+ + workingDir;
+ event = new Event("directory_transfer", nodeid, pargs);
+ p = new Pattern(null, 1, null, event);
+ addInitialDelay(p, 2, "sec");
+ patternList.add(p);
+ }
+ }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
+
+ public Patterns createDeleteInstancePattern(AsterixInstance instance) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ patternList.addAll(createRemoveAsterixStoragePattern(instance).getPattern());
+ if (instance.getBackupInfo() != null && instance.getBackupInfo().size() > 0) {
+ List<BackupInfo> backups = instance.getBackupInfo();
+ Set<String> removedBackupDirsHDFS = new HashSet<String>();
+ Set<String> removedBackupDirsLocal = new HashSet<String>();
+
+ String backupDir;
+ for (BackupInfo binfo : backups) {
+ backupDir = binfo.getBackupConf().getBackupDir();
+ switch (binfo.getBackupType()) {
+ case HDFS:
+ if (removedBackupDirsHDFS.contains(backups)) {
+ continue;
+ }
+ patternList.addAll(createRemoveHDFSBackupPattern(instance, backupDir).getPattern());
+ removedBackupDirsHDFS.add(backupDir);
+ break;
+
+ case LOCAL:
+ if (removedBackupDirsLocal.contains(backups)) {
+ continue;
+ }
+ patternList.addAll(createRemoveLocalBackupPattern(instance, backupDir).getPattern());
+ removedBackupDirsLocal.add(backupDir);
+ break;
+ }
+
+ }
+ }
+ patternList.addAll(createRemoveAsterixLogDirPattern(instance).getPattern());
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
+
+ private Patterns createRemoveHDFSBackupPattern(AsterixInstance instance, String hdfsBackupDir) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ Cluster cluster = instance.getCluster();
+ String hdfsUrl = InstallerDriver.getConfiguration().getBackup().getHdfs().getUrl();
+ String hadoopVersion = InstallerDriver.getConfiguration().getBackup().getHdfs().getVersion();
+ String workingDir = cluster.getWorkingDir().getDir();
+ Node launchingNode = cluster.getNode().get(0);
+ Nodeid nodeid = new Nodeid(new Value(null, launchingNode.getId()));
+ String pathToDelete = hdfsBackupDir + File.separator + instance.getName();
+ String pargs = workingDir + " " + hadoopVersion + " " + hdfsUrl + " " + pathToDelete;
+ Event event = new Event("hdfs_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
+
+ private Patterns createRemoveLocalBackupPattern(AsterixInstance instance, String localBackupDir) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ Cluster cluster = instance.getCluster();
+
+ String pathToDelete = localBackupDir + File.separator + instance.getName();
+ String pargs = pathToDelete;
+ List<String> removedBackupDirs = new ArrayList<String>();
+ for (Node node : cluster.getNode()) {
+ if (removedBackupDirs.contains(node.getIp())) {
+ continue;
+ }
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ Event event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ removedBackupDirs.add(node.getIp());
+ }
+
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
+
+ public Patterns createRemoveAsterixWorkingDirPattern(AsterixInstance instance) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ Cluster cluster = instance.getCluster();
+ String workingDir = cluster.getWorkingDir().getDir();
+ String pargs = workingDir;
+ Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode().getId()));
+ Event event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+
+ if (!cluster.getWorkingDir().isNFS()) {
+ for (Node node : cluster.getNode()) {
+ nodeid = new Nodeid(new Value(null, node.getId()));
+ event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
+
+ private Patterns createRemoveAsterixLogDirPattern(AsterixInstance instance) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ Cluster cluster = instance.getCluster();
+ String pargs = instance.getCluster().getLogdir();
+ Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode().getId()));
+ Event event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+
+ if (!cluster.getWorkingDir().isNFS()) {
+ for (Node node : cluster.getNode()) {
+ nodeid = new Nodeid(new Value(null, node.getId()));
+ event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
+
+ private Patterns createRemoveAsterixStoragePattern(AsterixInstance instance) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ Cluster cluster = instance.getCluster();
+ String pargs = null;
+
+ for (Node node : cluster.getNode()) {
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ String[] nodeStores;
+ if (node.getStore() != null) {
+ nodeStores = node.getStore().trim().split(",");
+ for (String ns : nodeStores) {
+ pargs = ns + File.separator + instance.getName();
+ }
+ } else {
+ nodeStores = cluster.getStore().trim().split(",");
+ for (String ns : nodeStores) {
+ pargs = ns + File.separator + node.getId() + File.separator + instance.getName();
+ }
+ }
+ Event event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
+
+ private Pattern createCopyHyracksPattern(String instanceName, Cluster cluster, String destinationIp, String destDir) {
+ Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
+ String username = cluster.getUsername() != null ? cluster.getUsername() : System.getProperty("user.name");
+ String asterixZipName = InstallerDriver.getAsterixZip().substring(
+ InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
+ String fileToTransfer = new File(InstallerDriver.getAsterixDir() + File.separator + instanceName
+ + File.separator + asterixZipName).getAbsolutePath();
+ String pargs = username + " " + fileToTransfer + " " + destinationIp + " " + destDir + " " + "unpack";
+ Event event = new Event("file_transfer", nodeid, pargs);
+ return new Pattern(null, 1, null, event);
+ }
+
+ private Pattern createCCStartPattern(String hostId) {
+ Nodeid nodeid = new Nodeid(new Value(null, hostId));
+ Event event = new Event("cc_start", nodeid, "");
+ return new Pattern(null, 1, null, event);
+ }
+
+ public Pattern createCCStopPattern(String hostId) {
+ Nodeid nodeid = new Nodeid(new Value(null, hostId));
+ Event event = new Event("cc_failure", nodeid, null);
+ return new Pattern(null, 1, null, event);
+ }
+
+ public Pattern createNCStartPattern(String ccHost, String hostId, String nodeControllerId) {
+ Nodeid nodeid = new Nodeid(new Value(null, hostId));
+ Event event = new Event("node_join", nodeid, ccHost + " " + nodeControllerId);
+ return new Pattern(null, 1, null, event);
+ }
+
+ public Pattern createNCStopPattern(String hostId, String nodeControllerId) {
+ Nodeid nodeid = new Nodeid(new Value(null, hostId));
+ Event event = new Event("node_failure", nodeid, nodeControllerId);
+ return new Pattern(null, 1, null, event);
+ }
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
new file mode 100644
index 0000000..d3ba758
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+
+public class AsterixInstance implements Serializable {
+
+ private static final long serialVersionUID = 2874439550187520449L;
+
+ public enum State {
+ ACTIVE,
+ INACTIVE,
+ UNUSABLE
+ }
+
+ private final Cluster cluster;
+ private final String name;
+ private final Date createdTimestamp;
+ private Date stateChangeTimestamp;
+ private Date modifiedTimestamp;
+ private Properties configuration;
+ private State state;
+ private final String metadataNodeId;
+ private final String asterixVersion;
+ private final List<BackupInfo> backupInfo;
+ private final String webInterfaceUrl;
+ private AsterixRuntimeState runtimeState;
+ private State previousState;
+
+ public AsterixInstance(String name, Cluster cluster, Properties configuration, String metadataNodeId,
+ String asterixVersion) {
+ this.name = name;
+ this.cluster = cluster;
+ this.configuration = configuration;
+ this.metadataNodeId = metadataNodeId;
+ this.state = State.ACTIVE;
+ this.previousState = State.UNUSABLE;
+ this.asterixVersion = asterixVersion;
+ this.createdTimestamp = new Date();
+ this.backupInfo = new ArrayList<BackupInfo>();
+ this.webInterfaceUrl = "http://" + cluster.getMasterNode().getIp() + ":" + 19001;
+ }
+
+ public Date getModifiedTimestamp() {
+ return stateChangeTimestamp;
+ }
+
+ public Properties getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(Properties properties) {
+ this.configuration = properties;
+ }
+
+ public State getState() {
+ return state;
+ }
+
+ public void setState(State state) {
+ this.previousState = this.state;
+ this.state = state;
+ }
+
+ public Cluster getCluster() {
+ return cluster;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Date getCreatedTimestamp() {
+ return createdTimestamp;
+ }
+
+ public Date getStateChangeTimestamp() {
+ return stateChangeTimestamp;
+ }
+
+ public void setStateChangeTimestamp(Date stateChangeTimestamp) {
+ this.stateChangeTimestamp = stateChangeTimestamp;
+ }
+
+ public void setModifiedTimestamp(Date modifiedTimestamp) {
+ this.modifiedTimestamp = modifiedTimestamp;
+ }
+
+ public String getMetadataNodeId() {
+ return metadataNodeId;
+ }
+
+ public String getAsterixVersion() {
+ return asterixVersion;
+ }
+
+ public String getDescription(boolean detailed) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Name:" + name + "\n");
+ buffer.append("Created:" + createdTimestamp + "\n");
+ buffer.append("Web-Url:" + webInterfaceUrl + "\n");
+ buffer.append("State:" + state);
+ if (!state.equals(State.UNUSABLE) && stateChangeTimestamp != null) {
+ buffer.append(" (" + stateChangeTimestamp + ")" + "\n");
+ } else {
+ buffer.append("\n");
+ }
+ if (modifiedTimestamp != null) {
+ buffer.append("Last modified timestamp:" + modifiedTimestamp + "\n");
+ }
+
+ if (runtimeState.getSummary() != null && runtimeState.getSummary().length() > 0) {
+ buffer.append("\nWARNING!:" + runtimeState.getSummary() + "\n");
+ }
+ if (detailed) {
+ addDetailedInformation(buffer);
+ }
+ return buffer.toString();
+ }
+
+ public List<BackupInfo> getBackupInfo() {
+ return backupInfo;
+ }
+
+ public String getWebInterfaceUrl() {
+ return webInterfaceUrl;
+ }
+
+ public AsterixRuntimeState getAsterixRuntimeState() {
+ return runtimeState;
+ }
+
+ public void setAsterixRuntimeStates(AsterixRuntimeState runtimeState) {
+ this.runtimeState = runtimeState;
+ }
+
+ private void addDetailedInformation(StringBuffer buffer) {
+ buffer.append("Master node:" + cluster.getMasterNode().getId() + ":" + cluster.getMasterNode().getIp() + "\n");
+ for (Node node : cluster.getNode()) {
+ buffer.append(node.getId() + ":" + node.getIp() + "\n");
+ }
+
+ if (backupInfo != null && backupInfo.size() > 0) {
+ for (BackupInfo info : backupInfo) {
+ buffer.append(info + "\n");
+ }
+ }
+ buffer.append("\n");
+ buffer.append("Asterix version:" + asterixVersion + "\n");
+ buffer.append("Metadata Node:" + metadataNodeId + "\n");
+ buffer.append("Processes" + "\n");
+ for (ProcessInfo pInfo : runtimeState.getProcesses()) {
+ buffer.append(pInfo + "\n");
+ }
+
+ }
+
+ public State getPreviousState() {
+ return previousState;
+ }
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixRuntimeState.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixRuntimeState.java
new file mode 100644
index 0000000..207c570
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixRuntimeState.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.model;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class AsterixRuntimeState implements Serializable {
+
+ private final List<ProcessInfo> processes;
+ private final List<String> failedNCs;
+ private final boolean ccRunning;
+ private String summary;
+
+ public AsterixRuntimeState(List<ProcessInfo> processes, List<String> failedNCs, boolean ccRunning) {
+ this.processes = processes;
+ this.failedNCs = failedNCs;
+ this.ccRunning = ccRunning;
+ }
+
+ public List<ProcessInfo> getProcesses() {
+ return processes;
+ }
+
+ public List<String> getFailedNCs() {
+ return failedNCs;
+ }
+
+ public boolean isCcRunning() {
+ return ccRunning;
+ }
+
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
+
+ public String getSummary() {
+ return summary;
+ }
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/BackupInfo.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/BackupInfo.java
new file mode 100644
index 0000000..cea8087
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/BackupInfo.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import edu.uci.ics.asterix.installer.schema.conf.Backup;
+import edu.uci.ics.asterix.installer.schema.conf.Hdfs;
+
+public class BackupInfo implements Serializable {
+
+ public static enum BackupType {
+ LOCAL,
+ HDFS
+ };
+
+ private final int id;
+ private final Date date;
+ private final Backup backupConf;
+
+ public BackupInfo(int id, Date date, Backup backupConf) {
+ this.id = id;
+ this.date = date;
+ this.backupConf = backupConf;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public Backup getBackupConf() {
+ return backupConf;
+ }
+
+ @Override
+ public String toString() {
+ return id + " " + date + " " + "(" + getBackupType() + ")" + " " + "[ " + this.getBackupConf().getBackupDir()
+ + " ]";
+
+ }
+
+ public BackupType getBackupType() {
+ return getBackupType(this.getBackupConf());
+ }
+
+ public static BackupType getBackupType(Backup backupConf) {
+ Hdfs hdfs = backupConf.getHdfs();
+ return (hdfs != null && hdfs.getUrl() != null && hdfs.getUrl().length() > 0) ? BackupType.HDFS
+ : BackupType.LOCAL;
+ }
+}
\ No newline at end of file
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java
new file mode 100644
index 0000000..b605889
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.model;
+
+public class EventList {
+
+ public enum EventType {
+ NODE_JOIN,
+ NODE_FAILURE,
+ CC_START,
+ CC_FAILURE,
+ BACKUP,
+ RESTORE,
+ FILE_DELETE,
+ HDFS_DELETE,
+ FILE_TRANSFER,
+ FILE_CREATE,
+ DIRECTORY_TRANSFER,
+ NODE_INFO
+ }
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/ProcessInfo.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/ProcessInfo.java
new file mode 100644
index 0000000..2880671
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/ProcessInfo.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.model;
+
+import java.io.Serializable;
+
+public class ProcessInfo implements Serializable {
+
+ private static final long serialVersionUID = 304186774065853730L;
+ private final String processName;
+ private final String host;
+ private final int processId;
+
+ public ProcessInfo(String processName, String host, int processId) {
+ this.processName = processName;
+ this.host = host;
+ this.processId = processId;
+ }
+
+ public String getProcessName() {
+ return processName;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getProcessId() {
+ return processId;
+ }
+
+ public String toString() {
+ return processName + " at " + host + " [ " + processId + " ] ";
+ }
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ILookupService.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ILookupService.java
new file mode 100644
index 0000000..aad963f
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ILookupService.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.service;
+
+import java.util.List;
+
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.schema.conf.Configuration;
+
+public interface ILookupService {
+
+ public void writeAsterixInstance(AsterixInstance asterixInstance) throws Exception;
+
+ public AsterixInstance getAsterixInstance(String name) throws Exception;
+
+ public boolean isRunning(Configuration conf) throws Exception;
+
+ public void startService(Configuration conf) throws Exception;
+
+ public void stopService(Configuration conf) throws Exception;
+
+ public boolean exists(String name) throws Exception;
+
+ public void removeAsterixInstance(String name) throws Exception;
+
+ public List<AsterixInstance> getAsterixInstances() throws Exception;
+
+ public void updateAsterixInstance(AsterixInstance updatedInstance) throws Exception;
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ServiceProvider.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ServiceProvider.java
new file mode 100644
index 0000000..1a9e9e6
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ServiceProvider.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.service;
+
+public class ServiceProvider {
+
+ public static ServiceProvider INSTANCE = new ServiceProvider();
+ private static ILookupService lookupService = new ZooKeeperService();
+
+ private ServiceProvider() {
+
+ }
+
+ public ILookupService getLookupService() {
+ return lookupService;
+ }
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ZooKeeperService.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ZooKeeperService.java
new file mode 100644
index 0000000..1bd8772
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ZooKeeperService.java
@@ -0,0 +1,245 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.service;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.log4j.Logger;
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.data.Stat;
+
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.error.InstallerException;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.schema.conf.Configuration;
+
+public class ZooKeeperService implements ILookupService {
+
+ private static final Logger LOGGER = Logger.getLogger(ZooKeeperService.class.getName());
+
+ private static final int ZOOKEEPER_LEADER_CONN_PORT = 2222;
+ private static final int ZOOKEEPER_LEADER_ELEC_PORT = 2223;
+ private static final int ZOOKEEPER_SESSION_TIME_OUT = 40 * 1000; //milliseconds
+ private static final String ZOOKEEPER_HOME = InstallerDriver.getManagixHome() + File.separator
+ + InstallerDriver.MANAGIX_INTERNAL_DIR + File.separator + "zookeeper";
+ private static final String ZOO_KEEPER_CONFIG = ZOOKEEPER_HOME + File.separator + "zk.cfg";
+
+ private boolean isRunning = false;
+ private ZooKeeper zk;
+ private String zkConnectionString;
+ private static final String ASTERIX_INSTANCE_BASE_PATH = "/Asterix";
+ private static final int DEFAULT_NODE_VERSION = -1;
+ private LinkedBlockingQueue<String> msgQ = new LinkedBlockingQueue<String>();
+ private ZooKeeperWatcher watcher = new ZooKeeperWatcher(msgQ);
+
+ public boolean isRunning(Configuration conf) throws Exception {
+ List<String> servers = conf.getZookeeper().getServers().getServer();
+ int clientPort = conf.getZookeeper().getClientPort().intValue();
+ StringBuffer connectionString = new StringBuffer();
+ for (String serverAddress : servers) {
+ connectionString.append(serverAddress);
+ connectionString.append(":");
+ connectionString.append(clientPort);
+ connectionString.append(",");
+ }
+ if (connectionString.length() > 0) {
+ connectionString.deleteCharAt(connectionString.length() - 1);
+ }
+ zkConnectionString = connectionString.toString();
+
+ zk = new ZooKeeper(zkConnectionString, ZOOKEEPER_SESSION_TIME_OUT, watcher);
+ try {
+ zk.exists("/dummy", watcher);
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("ZooKeeper running at " + connectionString);
+ }
+ createRootIfNotExist();
+ isRunning = true;
+ } catch (KeeperException ke) {
+ isRunning = false;
+ }
+ return isRunning;
+ }
+
+ public void startService(Configuration conf) throws Exception {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Starting ZooKeeper at " + zkConnectionString);
+ }
+ ZookeeperUtil.writeConfiguration(ZOO_KEEPER_CONFIG, conf, ZOOKEEPER_LEADER_CONN_PORT,
+ ZOOKEEPER_LEADER_ELEC_PORT);
+ String initScript = ZOOKEEPER_HOME + File.separator + "bin" + File.separator + "zk.init";
+ StringBuffer cmdBuffer = new StringBuffer();
+ cmdBuffer.append(initScript + " ");
+ cmdBuffer.append(conf.getZookeeper().getHomeDir() + " ");
+ List<String> zkServers = conf.getZookeeper().getServers().getServer();
+ for (String zkServer : zkServers) {
+ cmdBuffer.append(zkServer + " ");
+ }
+ Runtime.getRuntime().exec(cmdBuffer.toString());
+ zk = new ZooKeeper(zkConnectionString, ZOOKEEPER_SESSION_TIME_OUT, watcher);
+ String head = msgQ.poll(10, TimeUnit.SECONDS);
+ if (head == null) {
+ String msg = "Unable to start Zookeeper Service. Please verify the configuration at "
+ + InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_CONF_XML;
+ throw new Exception(msg);
+ }
+ msgQ.take();
+ createRootIfNotExist();
+ }
+
+ public void stopService(Configuration conf) throws Exception {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Stopping ZooKeeper running at " + zkConnectionString);
+ }
+ String stopScript = ZOOKEEPER_HOME + File.separator + "bin" + File.separator + "stop_zk";
+ StringBuffer cmdBuffer = new StringBuffer();
+ cmdBuffer.append(stopScript + " ");
+ cmdBuffer.append(conf.getZookeeper().getHomeDir() + " ");
+ List<String> zkServers = conf.getZookeeper().getServers().getServer();
+ for (String zkServer : zkServers) {
+ cmdBuffer.append(zkServer + " ");
+ }
+ Runtime.getRuntime().exec(cmdBuffer.toString());
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Stopped ZooKeeper service at " + zkConnectionString);
+ }
+ }
+
+ public void writeAsterixInstance(AsterixInstance asterixInstance) throws Exception {
+ String instanceBasePath = ASTERIX_INSTANCE_BASE_PATH + File.separator + asterixInstance.getName();
+ ByteArrayOutputStream b = new ByteArrayOutputStream();
+ ObjectOutputStream o = new ObjectOutputStream(b);
+ o.writeObject(asterixInstance);
+ zk.create(instanceBasePath, b.toByteArray(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+ }
+
+ private void createRootIfNotExist() throws Exception {
+ try {
+ Stat stat = zk.exists(ASTERIX_INSTANCE_BASE_PATH, false);
+ if (stat == null) {
+ zk.create(ASTERIX_INSTANCE_BASE_PATH, "root".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+ }
+ } catch (Exception e) {
+ createRootIfNotExist();
+ }
+ }
+
+ public AsterixInstance getAsterixInstance(String name) throws Exception {
+ String path = ASTERIX_INSTANCE_BASE_PATH + File.separator + name;
+ Stat stat = zk.exists(ASTERIX_INSTANCE_BASE_PATH + File.separator + name, false);
+ if (stat == null) {
+ return null;
+ }
+ byte[] asterixInstanceBytes = zk.getData(path, false, new Stat());
+ return readAsterixInstanceObject(asterixInstanceBytes);
+ }
+
+ public boolean exists(String asterixInstanceName) throws Exception {
+ return zk.exists(ASTERIX_INSTANCE_BASE_PATH + File.separator + asterixInstanceName, false) != null;
+ }
+
+ public void removeAsterixInstance(String name) throws Exception {
+ if (!exists(name)) {
+ throw new InstallerException("Asterix instance by name " + name + " does not exists.");
+ }
+ zk.delete(ASTERIX_INSTANCE_BASE_PATH + File.separator + name, DEFAULT_NODE_VERSION);
+ }
+
+ public List<AsterixInstance> getAsterixInstances() throws Exception {
+ List<String> instanceNames = zk.getChildren(ASTERIX_INSTANCE_BASE_PATH, false);
+ List<AsterixInstance> asterixInstances = new ArrayList<AsterixInstance>();
+ String path;
+ for (String instanceName : instanceNames) {
+ path = ASTERIX_INSTANCE_BASE_PATH + File.separator + instanceName;
+ byte[] asterixInstanceBytes = zk.getData(path, false, new Stat());
+ asterixInstances.add(readAsterixInstanceObject(asterixInstanceBytes));
+ }
+ return asterixInstances;
+ }
+
+ private AsterixInstance readAsterixInstanceObject(byte[] asterixInstanceBytes) throws IOException,
+ ClassNotFoundException {
+ ByteArrayInputStream b = new ByteArrayInputStream(asterixInstanceBytes);
+ ObjectInputStream ois = new ObjectInputStream(b);
+ return (AsterixInstance) ois.readObject();
+ }
+
+ public void updateAsterixInstance(AsterixInstance updatedInstance) throws Exception {
+ removeAsterixInstance(updatedInstance.getName());
+ writeAsterixInstance(updatedInstance);
+ }
+
+}
+
+class ZooKeeperWatcher implements Watcher {
+
+ private boolean isRunning = true;
+ private LinkedBlockingQueue<String> msgQ;
+
+ public ZooKeeperWatcher(LinkedBlockingQueue<String> msgQ) {
+ this.msgQ = msgQ;
+ }
+
+ public void process(WatchedEvent wEvent) {
+ switch (wEvent.getState()) {
+ case SyncConnected:
+ msgQ.add("connected");
+ break;
+ }
+ }
+
+ public boolean isRunning() {
+ return isRunning;
+ }
+
+}
+
+class ZookeeperUtil {
+
+ public static void writeConfiguration(String zooKeeperConfigPath, Configuration conf, int leaderConnPort,
+ int leaderElecPort) throws IOException {
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("tickTime=1000" + "\n");
+ buffer.append("dataDir=" + conf.getZookeeper().getHomeDir() + File.separator + "data" + "\n");
+ buffer.append("clientPort=" + conf.getZookeeper().getClientPort().intValue() + "\n");
+ buffer.append("initLimit=" + 2 + "\n");
+ buffer.append("syncLimit=" + 2 + "\n");
+
+ List<String> servers = conf.getZookeeper().getServers().getServer();
+ int serverId = 1;
+ for (String server : servers) {
+ buffer.append("server" + "." + serverId + "=" + server + ":" + leaderConnPort + ":" + leaderElecPort + "\n");
+ serverId++;
+ }
+ InstallerUtil.dumpToFile(zooKeeperConfigPath, buffer.toString());
+ }
+
+}
diff --git a/asterix-installer/src/main/resources/clusters/local/conf/asterix.conf b/asterix-installer/src/main/resources/clusters/local/conf/asterix.conf
new file mode 100644
index 0000000..659b48e
--- /dev/null
+++ b/asterix-installer/src/main/resources/clusters/local/conf/asterix.conf
@@ -0,0 +1 @@
+output_dir=/tmp/asterix_output/
diff --git a/asterix-installer/src/main/resources/clusters/local/local.xml b/asterix-installer/src/main/resources/clusters/local/local.xml
new file mode 100644
index 0000000..7a8e78f
--- /dev/null
+++ b/asterix-installer/src/main/resources/clusters/local/local.xml
@@ -0,0 +1,20 @@
+<cluster xmlns="cluster">
+ <name>local</name>
+ <workingDir>
+ <dir>/tmp/asterix-installer</dir>
+ <NFS>true</NFS>
+ </workingDir>
+ <logdir>/tmp/asterix/logs</logdir>
+ <store>/tmp/asterix/storage</store>
+ <java_home></java_home>
+ <java_heap>1024m</java_heap>
+ <master-node>
+ <id>master</id>
+ <ip>127.0.0.1</ip>
+ <cluster-ip>127.0.0.1</cluster-ip>
+ </master-node>
+ <node>
+ <id>node1</id>
+ <ip>127.0.0.1</ip>
+ </node>
+</cluster>
diff --git a/asterix-installer/src/main/resources/conf/log4j.properties b/asterix-installer/src/main/resources/conf/log4j.properties
new file mode 100644
index 0000000..fedf941
--- /dev/null
+++ b/asterix-installer/src/main/resources/conf/log4j.properties
@@ -0,0 +1,9 @@
+log4j.rootLogger=info, A1
+
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+# Print the date in ISO 8601 format
+log4j.appender.A1.layout.ConversionPattern=%-p: %m%n
+
+log4j.logger.edu.uci.ics.asterix.event.management=error
+log4j.logger.org.apache.zookeeper=error
diff --git a/asterix-installer/src/main/resources/conf/managix-conf.xml b/asterix-installer/src/main/resources/conf/managix-conf.xml
new file mode 100644
index 0000000..ed3f8a2
--- /dev/null
+++ b/asterix-installer/src/main/resources/conf/managix-conf.xml
@@ -0,0 +1,16 @@
+<configuration xmlns="installer">
+ <backup>
+ <hdfs>
+ <version>0.20.2</version>
+ <url></url>
+ <backupDir></backupDir>
+ </hdfs>
+ </backup>
+ <zookeeper>
+ <homeDir>/tmp/zookeeper</homeDir>
+ <clientPort>2900</clientPort>
+ <servers>
+ <server>localhost</server>
+ </servers>
+ </zookeeper>
+</configuration>
diff --git a/asterix-installer/src/main/resources/hadoop-0.20.2/bin/hadoop b/asterix-installer/src/main/resources/hadoop-0.20.2/bin/hadoop
new file mode 100755
index 0000000..683e95d
--- /dev/null
+++ b/asterix-installer/src/main/resources/hadoop-0.20.2/bin/hadoop
@@ -0,0 +1,290 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# The Hadoop command script
+#
+# Environment Variables
+#
+# JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
+#
+# HADOOP_CLASSPATH Extra Java CLASSPATH entries.
+#
+# HADOOP_HEAPSIZE The maximum amount of heap to use, in MB.
+# Default is 1000.
+#
+# HADOOP_OPTS Extra Java runtime options.
+#
+# HADOOP_NAMENODE_OPTS These options are added to HADOOP_OPTS
+# HADOOP_CLIENT_OPTS when the respective command is run.
+# HADOOP_{COMMAND}_OPTS etc HADOOP_JT_OPTS applies to JobTracker
+# for e.g. HADOOP_CLIENT_OPTS applies to
+# more than one command (fs, dfs, fsck,
+# dfsadmin etc)
+#
+# HADOOP_CONF_DIR Alternate conf dir. Default is ${HADOOP_HOME}/conf.
+#
+# HADOOP_ROOT_LOGGER The root appender. Default is INFO,console
+#
+
+bin=`dirname "$0"`
+bin=`cd "$bin"; pwd`
+
+. "$bin"/hadoop-config.sh
+
+cygwin=false
+case "`uname`" in
+CYGWIN*) cygwin=true;;
+esac
+
+# if no args specified, show usage
+if [ $# = 0 ]; then
+ echo "Usage: hadoop [--config confdir] COMMAND"
+ echo "where COMMAND is one of:"
+ echo " namenode -format format the DFS filesystem"
+ echo " secondarynamenode run the DFS secondary namenode"
+ echo " namenode run the DFS namenode"
+ echo " datanode run a DFS datanode"
+ echo " dfsadmin run a DFS admin client"
+ echo " mradmin run a Map-Reduce admin client"
+ echo " fsck run a DFS filesystem checking utility"
+ echo " fs run a generic filesystem user client"
+ echo " balancer run a cluster balancing utility"
+ echo " jobtracker run the MapReduce job Tracker node"
+ echo " pipes run a Pipes job"
+ echo " tasktracker run a MapReduce task Tracker node"
+ echo " job manipulate MapReduce jobs"
+ echo " queue get information regarding JobQueues"
+ echo " version print the version"
+ echo " jar <jar> run a jar file"
+ echo " distcp <srcurl> <desturl> copy file or directories recursively"
+ echo " archive -archiveName NAME <src>* <dest> create a hadoop archive"
+ echo " daemonlog get/set the log level for each daemon"
+ echo " or"
+ echo " CLASSNAME run the class named CLASSNAME"
+ echo "Most commands print help when invoked w/o parameters."
+ exit 1
+fi
+
+# get arguments
+COMMAND=$1
+shift
+
+if [ -f "${HADOOP_CONF_DIR}/hadoop-env.sh" ]; then
+ . "${HADOOP_CONF_DIR}/hadoop-env.sh"
+fi
+
+# some Java parameters
+if [ "$JAVA_HOME" != "" ]; then
+ #echo "run java in $JAVA_HOME"
+ JAVA_HOME=$JAVA_HOME
+fi
+
+if [ "$JAVA_HOME" = "" ]; then
+ echo "Error: JAVA_HOME is not set."
+ exit 1
+fi
+
+JAVA=$JAVA_HOME/bin/java
+JAVA_HEAP_MAX=-Xmx1000m
+
+# check envvars which might override default args
+if [ "$HADOOP_HEAPSIZE" != "" ]; then
+ #echo "run with heapsize $HADOOP_HEAPSIZE"
+ JAVA_HEAP_MAX="-Xmx""$HADOOP_HEAPSIZE""m"
+ #echo $JAVA_HEAP_MAX
+fi
+
+# CLASSPATH initially contains $HADOOP_CONF_DIR
+CLASSPATH=${HADOOP_CONF_DIR}
+CLASSPATH=${CLASSPATH}:$JAVA_HOME/lib/tools.jar
+
+# for developers, add Hadoop classes to CLASSPATH
+if [ -d "$HADOOP_HOME/build/classes" ]; then
+ CLASSPATH=${CLASSPATH}:$HADOOP_HOME/build/classes
+fi
+if [ -d "$HADOOP_HOME/build/webapps" ]; then
+ CLASSPATH=${CLASSPATH}:$HADOOP_HOME/build
+fi
+if [ -d "$HADOOP_HOME/build/test/classes" ]; then
+ CLASSPATH=${CLASSPATH}:$HADOOP_HOME/build/test/classes
+fi
+if [ -d "$HADOOP_HOME/build/tools" ]; then
+ CLASSPATH=${CLASSPATH}:$HADOOP_HOME/build/tools
+fi
+
+# so that filenames w/ spaces are handled correctly in loops below
+IFS=
+
+# for releases, add core hadoop jar & webapps to CLASSPATH
+if [ -d "$HADOOP_HOME/webapps" ]; then
+ CLASSPATH=${CLASSPATH}:$HADOOP_HOME
+fi
+for f in $HADOOP_HOME/hadoop-*-core.jar; do
+ CLASSPATH=${CLASSPATH}:$f;
+done
+
+# add libs to CLASSPATH
+for f in $HADOOP_HOME/lib/*.jar; do
+ CLASSPATH=${CLASSPATH}:$f;
+done
+
+if [ -d "$HADOOP_HOME/build/ivy/lib/Hadoop/common" ]; then
+for f in $HADOOP_HOME/build/ivy/lib/Hadoop/common/*.jar; do
+ CLASSPATH=${CLASSPATH}:$f;
+done
+fi
+
+for f in $HADOOP_HOME/lib/jsp-2.1/*.jar; do
+ CLASSPATH=${CLASSPATH}:$f;
+done
+
+for f in $HADOOP_HOME/hadoop-*-tools.jar; do
+ TOOL_PATH=${TOOL_PATH}:$f;
+done
+for f in $HADOOP_HOME/build/hadoop-*-tools.jar; do
+ TOOL_PATH=${TOOL_PATH}:$f;
+done
+
+# add user-specified CLASSPATH last
+if [ "$HADOOP_CLASSPATH" != "" ]; then
+ CLASSPATH=${HADOOP_CLASSPATH}:${CLASSPATH}
+fi
+
+# default log directory & file
+if [ "$HADOOP_LOG_DIR" = "" ]; then
+ HADOOP_LOG_DIR="$HADOOP_HOME/logs"
+fi
+if [ "$HADOOP_LOGFILE" = "" ]; then
+ HADOOP_LOGFILE='hadoop.log'
+fi
+
+# default policy file for service-level authorization
+if [ "$HADOOP_POLICYFILE" = "" ]; then
+ HADOOP_POLICYFILE="hadoop-policy.xml"
+fi
+
+# restore ordinary behaviour
+unset IFS
+
+# figure out which class to run
+if [ "$COMMAND" = "namenode" ] ; then
+ CLASS='org.apache.hadoop.hdfs.server.namenode.NameNode'
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_NAMENODE_OPTS"
+elif [ "$COMMAND" = "secondarynamenode" ] ; then
+ CLASS='org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode'
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_SECONDARYNAMENODE_OPTS"
+elif [ "$COMMAND" = "datanode" ] ; then
+ CLASS='org.apache.hadoop.hdfs.server.datanode.DataNode'
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_DATANODE_OPTS"
+elif [ "$COMMAND" = "fs" ] ; then
+ CLASS=org.apache.hadoop.fs.FsShell
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
+elif [ "$COMMAND" = "dfs" ] ; then
+ CLASS=org.apache.hadoop.fs.FsShell
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
+elif [ "$COMMAND" = "dfsadmin" ] ; then
+ CLASS=org.apache.hadoop.hdfs.tools.DFSAdmin
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
+elif [ "$COMMAND" = "mradmin" ] ; then
+ CLASS=org.apache.hadoop.mapred.tools.MRAdmin
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
+elif [ "$COMMAND" = "fsck" ] ; then
+ CLASS=org.apache.hadoop.hdfs.tools.DFSck
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
+elif [ "$COMMAND" = "balancer" ] ; then
+ CLASS=org.apache.hadoop.hdfs.server.balancer.Balancer
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_BALANCER_OPTS"
+elif [ "$COMMAND" = "jobtracker" ] ; then
+ CLASS=org.apache.hadoop.mapred.JobTracker
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_JOBTRACKER_OPTS"
+elif [ "$COMMAND" = "tasktracker" ] ; then
+ CLASS=org.apache.hadoop.mapred.TaskTracker
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_TASKTRACKER_OPTS"
+elif [ "$COMMAND" = "job" ] ; then
+ CLASS=org.apache.hadoop.mapred.JobClient
+elif [ "$COMMAND" = "queue" ] ; then
+ CLASS=org.apache.hadoop.mapred.JobQueueClient
+elif [ "$COMMAND" = "pipes" ] ; then
+ CLASS=org.apache.hadoop.mapred.pipes.Submitter
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
+elif [ "$COMMAND" = "version" ] ; then
+ CLASS=org.apache.hadoop.util.VersionInfo
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
+elif [ "$COMMAND" = "jar" ] ; then
+ CLASS=org.apache.hadoop.util.RunJar
+elif [ "$COMMAND" = "distcp" ] ; then
+ CLASS=org.apache.hadoop.tools.DistCp
+ CLASSPATH=${CLASSPATH}:${TOOL_PATH}
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
+elif [ "$COMMAND" = "daemonlog" ] ; then
+ CLASS=org.apache.hadoop.log.LogLevel
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
+elif [ "$COMMAND" = "archive" ] ; then
+ CLASS=org.apache.hadoop.tools.HadoopArchives
+ CLASSPATH=${CLASSPATH}:${TOOL_PATH}
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
+elif [ "$COMMAND" = "sampler" ] ; then
+ CLASS=org.apache.hadoop.mapred.lib.InputSampler
+ HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
+else
+ CLASS=$COMMAND
+fi
+
+# cygwin path translation
+if $cygwin; then
+ CLASSPATH=`cygpath -p -w "$CLASSPATH"`
+ HADOOP_HOME=`cygpath -w "$HADOOP_HOME"`
+ HADOOP_LOG_DIR=`cygpath -w "$HADOOP_LOG_DIR"`
+ TOOL_PATH=`cygpath -p -w "$TOOL_PATH"`
+fi
+# setup 'java.library.path' for native-hadoop code if necessary
+JAVA_LIBRARY_PATH=''
+if [ -d "${HADOOP_HOME}/build/native" -o -d "${HADOOP_HOME}/lib/native" ]; then
+ JAVA_PLATFORM=`CLASSPATH=${CLASSPATH} ${JAVA} -Xmx32m org.apache.hadoop.util.PlatformName | sed -e "s/ /_/g"`
+
+ if [ -d "$HADOOP_HOME/build/native" ]; then
+ JAVA_LIBRARY_PATH=${HADOOP_HOME}/build/native/${JAVA_PLATFORM}/lib
+ fi
+
+ if [ -d "${HADOOP_HOME}/lib/native" ]; then
+ if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
+ JAVA_LIBRARY_PATH=${JAVA_LIBRARY_PATH}:${HADOOP_HOME}/lib/native/${JAVA_PLATFORM}
+ else
+ JAVA_LIBRARY_PATH=${HADOOP_HOME}/lib/native/${JAVA_PLATFORM}
+ fi
+ fi
+fi
+
+# cygwin path translation
+if $cygwin; then
+ JAVA_LIBRARY_PATH=`cygpath -p "$JAVA_LIBRARY_PATH"`
+fi
+
+HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.log.dir=$HADOOP_LOG_DIR"
+HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.log.file=$HADOOP_LOGFILE"
+HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.home.dir=$HADOOP_HOME"
+HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.id.str=$HADOOP_IDENT_STRING"
+HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.root.logger=${HADOOP_ROOT_LOGGER:-INFO,console}"
+if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
+ HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=$JAVA_LIBRARY_PATH"
+fi
+HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.policy.file=$HADOOP_POLICYFILE"
+
+# run it
+#echo "exec "$JAVA" $JAVA_HEAP_MAX $HADOOP_OPTS -classpath "$CLASSPATH" $CLASS "$@""
+exec "$JAVA" $JAVA_HEAP_MAX $HADOOP_OPTS -classpath "$CLASSPATH" $CLASS "$@"
diff --git a/asterix-installer/src/main/resources/hadoop-0.20.2/bin/hadoop-config.sh b/asterix-installer/src/main/resources/hadoop-0.20.2/bin/hadoop-config.sh
new file mode 100755
index 0000000..1f9d52d
--- /dev/null
+++ b/asterix-installer/src/main/resources/hadoop-0.20.2/bin/hadoop-config.sh
@@ -0,0 +1,68 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# included in all the hadoop scripts with source command
+# should not be executable directly
+# also should not be passed any arguments, since we need original $*
+
+# resolve links - $0 may be a softlink
+
+this="$0"
+while [ -h "$this" ]; do
+ ls=`ls -ld "$this"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '.*/.*' > /dev/null; then
+ this="$link"
+ else
+ this=`dirname "$this"`/"$link"
+ fi
+done
+
+# convert relative path to absolute path
+bin=`dirname "$this"`
+script=`basename "$this"`
+bin=`cd "$bin"; pwd`
+this="$bin/$script"
+
+# the root of the Hadoop installation
+export HADOOP_HOME=`dirname "$this"`/..
+
+#check to see if the conf dir is given as an optional argument
+if [ $# -gt 1 ]
+then
+ if [ "--config" = "$1" ]
+ then
+ shift
+ confdir=$1
+ shift
+ HADOOP_CONF_DIR=$confdir
+ fi
+fi
+
+# Allow alternate conf dir location.
+HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_HOME/conf}"
+
+#check to see it is specified whether to use the slaves or the
+# masters file
+if [ $# -gt 1 ]
+then
+ if [ "--hosts" = "$1" ]
+ then
+ shift
+ slavesfile=$1
+ shift
+ export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$slavesfile"
+ fi
+fi
diff --git a/asterix-installer/src/main/resources/hadoop-0.20.2/conf/hadoop-env.sh b/asterix-installer/src/main/resources/hadoop-0.20.2/conf/hadoop-env.sh
new file mode 100644
index 0000000..e9396a4
--- /dev/null
+++ b/asterix-installer/src/main/resources/hadoop-0.20.2/conf/hadoop-env.sh
@@ -0,0 +1,54 @@
+# Set Hadoop-specific environment variables here.
+
+# The only required environment variable is JAVA_HOME. All others are
+# optional. When running a distributed configuration it is best to
+# set JAVA_HOME in this file, so that it is correctly defined on
+# remote nodes.
+
+# The java implementation to use. Required.
+# export JAVA_HOME=$JAVA_HOME
+
+# Extra Java CLASSPATH elements. Optional.
+# export HADOOP_CLASSPATH=
+
+# The maximum amount of heap to use, in MB. Default is 1000.
+# export HADOOP_HEAPSIZE=2000
+
+# Extra Java runtime options. Empty by default.
+# export HADOOP_OPTS=-server
+
+# Command specific options appended to HADOOP_OPTS when specified
+export HADOOP_NAMENODE_OPTS="-Dcom.sun.management.jmxremote $HADOOP_NAMENODE_OPTS"
+export HADOOP_SECONDARYNAMENODE_OPTS="-Dcom.sun.management.jmxremote $HADOOP_SECONDARYNAMENODE_OPTS"
+export HADOOP_DATANODE_OPTS="-Dcom.sun.management.jmxremote $HADOOP_DATANODE_OPTS"
+export HADOOP_BALANCER_OPTS="-Dcom.sun.management.jmxremote $HADOOP_BALANCER_OPTS"
+export HADOOP_JOBTRACKER_OPTS="-Dcom.sun.management.jmxremote $HADOOP_JOBTRACKER_OPTS"
+# export HADOOP_TASKTRACKER_OPTS=
+# The following applies to multiple commands (fs, dfs, fsck, distcp etc)
+# export HADOOP_CLIENT_OPTS
+
+# Extra ssh options. Empty by default.
+# export HADOOP_SSH_OPTS="-o ConnectTimeout=1 -o SendEnv=HADOOP_CONF_DIR"
+
+# Where log files are stored. $HADOOP_HOME/logs by default.
+# export HADOOP_LOG_DIR=${HADOOP_HOME}/logs
+
+# File naming remote slave hosts. $HADOOP_HOME/conf/slaves by default.
+# export HADOOP_SLAVES=${HADOOP_HOME}/conf/slaves
+
+# host:path where hadoop code should be rsync'd from. Unset by default.
+# export HADOOP_MASTER=master:/home/$USER/src/hadoop
+
+# Seconds to sleep between slave commands. Unset by default. This
+# can be useful in large clusters, where, e.g., slave rsyncs can
+# otherwise arrive faster than the master can service them.
+# export HADOOP_SLAVE_SLEEP=0.1
+
+# The directory where pid files are stored. /tmp by default.
+# export HADOOP_PID_DIR=/var/hadoop/pids
+
+# A string representing this instance of hadoop. $USER by default.
+# export HADOOP_IDENT_STRING=$USER
+
+# The scheduling priority for daemon processes. See 'man nice'.
+# export HADOOP_NICENESS=10
diff --git a/asterix-installer/src/main/resources/schema/installer-conf.xsd b/asterix-installer/src/main/resources/schema/installer-conf.xsd
new file mode 100644
index 0000000..318e7ce
--- /dev/null
+++ b/asterix-installer/src/main/resources/schema/installer-conf.xsd
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mg="installer" targetNamespace="installer" elementFormDefault="qualified">
+
+<!-- definition of simple types -->
+<xs:element name="asterix_home" type="xs:string"/>
+<xs:element name="hyracks_home" type="xs:string"/>
+<xs:element name="hdfsurl" type="xs:string"/>
+<xs:element name="server" type="xs:string"/>
+<xs:element name="clientPort" type="xs:integer"/>
+<xs:element name="homeDir" type="xs:string"/>
+<xs:element name="version" type="xs:string"/>
+<xs:element name="url" type="xs:string"/>
+<xs:element name="backupDir" type="xs:string"/>
+
+<!-- definition of complex elements -->
+<xs:element name="hdfs">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="mg:version"/>
+ <xs:element ref="mg:url"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="backup">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="mg:hdfs" minOccurs="0"/>
+ <xs:element ref="mg:backupDir"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="zookeeper">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="mg:homeDir"/>
+ <xs:element ref="mg:clientPort"/>
+ <xs:element ref="mg:servers"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="servers">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="mg:server" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="configuration">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="mg:backup" minOccurs="0"/>
+ <xs:element ref="mg:asterix_home" minOccurs="0"/>
+ <xs:element ref="mg:hyracks_home" minOccurs="0"/>
+ <xs:element ref="mg:hdfsurl" minOccurs="0"/>
+ <xs:element ref="mg:zookeeper"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+</xs:schema>
diff --git a/asterix-installer/src/main/resources/schema/jaxb-bindings.xjb b/asterix-installer/src/main/resources/schema/jaxb-bindings.xjb
new file mode 100644
index 0000000..b5982e0
--- /dev/null
+++ b/asterix-installer/src/main/resources/schema/jaxb-bindings.xjb
@@ -0,0 +1,9 @@
+<jxb:bindings version="1.0"
+xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
+xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+<jxb:globalBindings>
+ <jxb:serializable uid="1"/>
+</jxb:globalBindings>
+
+</jxb:bindings>
diff --git a/asterix-installer/src/main/resources/scripts/managix b/asterix-installer/src/main/resources/scripts/managix
new file mode 100755
index 0000000..cd0794e
--- /dev/null
+++ b/asterix-installer/src/main/resources/scripts/managix
@@ -0,0 +1,20 @@
+if [ -z $MANAGIX_HOME ]
+ then
+ echo "MANAGIX_HOME is not defined"
+ exit 1
+fi
+
+VERSION=0.0.4-SNAPSHOT
+
+for jar in `ls $MANAGIX_HOME/lib/*.jar`
+ do
+ if [ -z $MANAGIX_CLASSPATH ]
+ then
+ MANAGIX_CLASSPATH=$jar
+ else
+ MANAGIX_CLASSPATH=$MANAGIX_CLASSPATH:$jar
+ fi
+done
+
+MANAGIX_CLASSPATH=$MANAGIX_CLASSPATH:$MANAGIX_HOME/conf/log4j.properties
+java $JAVA_OPTS -Dlog4j.configuration=file:$MANAGIX_HOME/conf/log4j.properties -cp $MANAGIX_CLASSPATH edu.uci.ics.asterix.installer.driver.InstallerDriver $@
diff --git a/asterix-installer/src/main/resources/scripts/verify.sh b/asterix-installer/src/main/resources/scripts/verify.sh
new file mode 100755
index 0000000..cac8189
--- /dev/null
+++ b/asterix-installer/src/main/resources/scripts/verify.sh
@@ -0,0 +1,21 @@
+INSTANCE_NAME=$1
+MASTER_NODE=$2
+shift 2
+numargs=$#
+for ((i=1 ; i <= numargs ; i=i+2))
+do
+ host=$1
+ nc_id=$2
+ INFO=$(ssh $host "ps -ef | grep nc_join | grep -v grep | grep -v ssh| grep $nc_id" | head -n 1 )
+ PARENT_ID=`echo $INFO | cut -d " " -f2`
+ PID_INFO=$(ssh $host "ps -ef | grep asterix | grep -v grep | grep -v nc_join | grep $PARENT_ID")
+ PID=`echo $PID_INFO | cut -d " " -f2`
+ echo "NC:$host:$nc_id:$PID"
+ shift 2
+done
+
+CC_PARENT_ID_INFO=$(ssh $MASTER_NODE "ps -ef | grep asterix | grep cc_start | grep -v ssh")
+CC_PARENT_ID=`echo $CC_PARENT_ID_INFO | tr -s " " | cut -d " " -f2`
+CC_ID_INFO=$(ssh $MASTER_NODE "ps -ef | grep asterix | grep $CC_PARENT_ID | grep -v bash")
+CC_ID=`echo $CC_ID_INFO | tr -s " " | cut -d " " -f2`
+echo "CC:$MASTER_NODE:N/A:$CC_ID"
diff --git a/asterix-installer/src/main/resources/zookeeper/start_zk.sh b/asterix-installer/src/main/resources/zookeeper/start_zk.sh
new file mode 100755
index 0000000..033e5f8
--- /dev/null
+++ b/asterix-installer/src/main/resources/zookeeper/start_zk.sh
@@ -0,0 +1,8 @@
+ZK_HOME=$1
+ZK_ID=$2
+mkdir $ZK_HOME/data
+echo $2 > $ZK_HOME/data/myid
+CLASSPATH=$ZK_HOME/lib/zookeeper-3.4.5.jar:$ZK_HOME/lib/log4j-1.2.15.jar:$ZK_HOME/lib/slf4j-api-1.6.1.jar:$ZK_HOME/conf:$ZK_HOME/conf/log4j.properties
+ZK_CONF=$ZK_HOME/zk.cfg
+export JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8400,server=y,suspend=n"
+java $JAVA_OPTS -Dlog4j.configuration="file:$ZK_HOME/conf/log4j.properties" -cp $CLASSPATH org.apache.zookeeper.server.quorum.QuorumPeerMain $ZK_CONF
diff --git a/asterix-installer/src/main/resources/zookeeper/stop_zk b/asterix-installer/src/main/resources/zookeeper/stop_zk
new file mode 100755
index 0000000..d8615d9
--- /dev/null
+++ b/asterix-installer/src/main/resources/zookeeper/stop_zk
@@ -0,0 +1,6 @@
+ZK_HOME=$1
+shift 1
+for zk_host in $@
+do
+ ssh $zk_host "kill -9 `jps | grep QuorumPeerMain | cut -d " " -f1`" &
+done
diff --git a/asterix-installer/src/main/resources/zookeeper/zk.init b/asterix-installer/src/main/resources/zookeeper/zk.init
new file mode 100755
index 0000000..937d8b3
--- /dev/null
+++ b/asterix-installer/src/main/resources/zookeeper/zk.init
@@ -0,0 +1,13 @@
+ZK_HOME=$1
+shift 1
+cd $MANAGIX_HOME/.installer/zookeeper
+tar cf zk.pkg.tar *
+zk_server_id=1
+for zk_host in $@
+do
+ ssh $zk_host "mkdir -p $ZK_HOME"
+ scp ./zk.pkg.tar $zk_host:$ZK_HOME/
+ ssh $zk_host "cd $ZK_HOME && tar xf $ZK_HOME/zk.pkg.tar && chmod +x $ZK_HOME/bin/start_zk.sh"
+ ssh $zk_host "$ZK_HOME/bin/start_zk.sh $ZK_HOME $zk_server_id" &
+ zk_server_id=`expr $zk_server_id + 1`
+done
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
index f1650ca..69fdbbb 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
@@ -332,14 +332,16 @@
ITreeIndexMetaDataFrameFactory metaDataFrameFactory = new LIFOMetaDataFrameFactory();
IInMemoryFreePageManager memFreePageManager = new InMemoryFreePageManager(DEFAULT_MEM_NUM_PAGES,
metaDataFrameFactory);
- LSMBTree lsmBtree = LSMBTreeUtils.createLSMTree(memBufferCache, memFreePageManager, ioManager, file,
- bufferCache, fileMapProvider, typeTraits, comparatorFactories, bloomFilterKeyFields,
- runtimeContext.getLSMMergePolicy(), runtimeContext.getLSMBTreeOperationTrackerFactory(),
- runtimeContext.getLSMIOScheduler(), AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER);
+ LSMBTree lsmBtree = null;
long resourceID = -1;
if (create) {
+ lsmBtree = LSMBTreeUtils.createLSMTree(memBufferCache, memFreePageManager, ioManager, file,
+ bufferCache, fileMapProvider, typeTraits, comparatorFactories, bloomFilterKeyFields,
+ runtimeContext.getLSMMergePolicy(), runtimeContext.getLSMBTreeOperationTrackerFactory(),
+ runtimeContext.getLSMIOScheduler(), AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER);
lsmBtree.create();
resourceID = runtimeContext.getResourceIdFactory().createId();
+ indexLifecycleManager.register(resourceID, lsmBtree);
ILocalResourceMetadata localResourceMetadata = new LSMBTreeLocalResourceMetadata(typeTraits,
comparatorFactories, bloomFilterKeyFields, index.isPrimaryIndex(),
@@ -351,12 +353,22 @@
.getPath(), 0));
} else {
resourceID = localResourceRepository.getResourceByName(file.getFile().getPath()).getResourceId();
+ lsmBtree = (LSMBTree) indexLifecycleManager.getIndex(resourceID);
+ if (lsmBtree == null) {
+ lsmBtree = LSMBTreeUtils.createLSMTree(memBufferCache, memFreePageManager, ioManager, file,
+ bufferCache, fileMapProvider, typeTraits, comparatorFactories, bloomFilterKeyFields,
+ runtimeContext.getLSMMergePolicy(), runtimeContext.getLSMBTreeOperationTrackerFactory(),
+ runtimeContext.getLSMIOScheduler(), AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER);
+ indexLifecycleManager.register(resourceID, lsmBtree);
+ }
}
+
index.setResourceID(resourceID);
index.setFile(file);
- indexLifecycleManager.register(resourceID, lsmBtree);
indexLifecycleManager.open(resourceID);
}
+
+
public static String getOutputDir() {
return outputDir;
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
index f1ac141..c6bb21a 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
@@ -601,6 +601,14 @@
}
@Override
+ public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getResultHandleRuntime(IDataSink sink,
+ int[] printColumns, IPrinterFactory[] printerFactories, RecordDescriptor inputDesc, boolean ordered,
+ JobSpecification spec) throws AlgebricksException {
+ // TODO(madhusudancs): Stub implementation of the method
+ return null;
+ }
+
+ @Override
public IDataSourceIndex<String, AqlSourceId> findDataSourceIndex(String indexId, AqlSourceId dataSourceId)
throws AlgebricksException {
AqlDataSource ads = findDataSource(dataSourceId);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADatePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADatePrinter.java
index 918e286..327faf1 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADatePrinter.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADatePrinter.java
@@ -30,4 +30,14 @@
.append("-").append(String.format("%02d", gCalInstance.getDayOfMonthYear(chrononTime, year, month)));
ps.print("\")");
}
+
+ public void printString(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+ long chrononTime = AInt32SerializerDeserializer.getInt(b, s + 1) * CHRONON_OF_DAY;
+
+ int year = gCalInstance.getYear(chrononTime);
+ int month = gCalInstance.getMonthOfYear(chrononTime, year);
+
+ ps.append(String.format(year < 0 ? "%05d" : "%04d", year)).append("-").append(String.format("%02d", month))
+ .append("-").append(String.format("%02d", gCalInstance.getDayOfMonthYear(chrononTime, year, month)));
+ }
}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADateTimePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADateTimePrinter.java
index 96df767..7cf1478 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADateTimePrinter.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADateTimePrinter.java
@@ -33,4 +33,18 @@
.append(String.format("%03d", gCalInstance.getMillisOfSec(chrononTime))).append("Z");
ps.print("\")");
}
+
+ public void printString(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+ long chrononTime = AInt64SerializerDeserializer.getLong(b, s + 1);
+
+ int year = gCalInstance.getYear(chrononTime);
+ int month = gCalInstance.getMonthOfYear(chrononTime, year);
+
+ ps.append(String.format(year < 0 ? "%05d" : "%04d", year)).append("-").append(String.format("%02d", month))
+ .append("-").append(String.format("%02d", gCalInstance.getDayOfMonthYear(chrononTime, year, month)))
+ .append("T").append(String.format("%02d", gCalInstance.getHourOfDay(chrononTime))).append(":")
+ .append(String.format("%02d", gCalInstance.getMinOfHour(chrononTime))).append(":")
+ .append(String.format("%02d", gCalInstance.getSecOfMin(chrononTime))).append(".")
+ .append(String.format("%03d", gCalInstance.getMillisOfSec(chrononTime))).append("Z");
+ }
}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AIntervalPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AIntervalPrinter.java
index 99c40b2..b96feff 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AIntervalPrinter.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/AIntervalPrinter.java
@@ -23,8 +23,6 @@
public class AIntervalPrinter implements IPrinter {
- private static final long serialVersionUID = 1L;
-
public static final AIntervalPrinter INSTANCE = new AIntervalPrinter();
/* (non-Javadoc)
@@ -39,32 +37,34 @@
*/
@Override
public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
- ps.print("interval(\"");
+ ps.print("interval");
short typetag = AInt8SerializerDeserializer.getByte(b, s + 1 + 8 * 2);
IPrinter timeInstancePrinter;
if (typetag == ATypeTag.DATE.serialize()) {
+ ps.print("-date(\"");
timeInstancePrinter = ADatePrinter.INSTANCE;
+ ((ADatePrinter)timeInstancePrinter).printString(b, s + 4, 4, ps);
+ ps.print(", ");
+ ((ADatePrinter)timeInstancePrinter).printString(b, s + 12, 4, ps);
} else if (typetag == ATypeTag.TIME.serialize()) {
+ ps.print("-time(\"");
timeInstancePrinter = ATimePrinter.INSTANCE;
+ ((ATimePrinter)timeInstancePrinter).printString(b, s + 4, 4, ps);
+ ps.print(", ");
+ ((ATimePrinter)timeInstancePrinter).printString(b, s + 12, 4, ps);
} else if (typetag == ATypeTag.DATETIME.serialize()) {
+ ps.print("-datetime(\"");
timeInstancePrinter = ADateTimePrinter.INSTANCE;
+ ((ADateTimePrinter)timeInstancePrinter).printString(b, s, 8, ps);
+ ps.print(", ");
+ ((ADateTimePrinter)timeInstancePrinter).printString(b, s + 8, 8, ps);
} else {
throw new AlgebricksException("Unsupport internal time types in interval: " + typetag);
}
- if (typetag == ATypeTag.TIME.serialize() || typetag == ATypeTag.DATE.serialize()) {
- timeInstancePrinter.print(b, s + 1 + 4 - 1, 8, ps);
- ps.print(", ");
- timeInstancePrinter.print(b, s + 1 + 8 + 4 - 1, 8, ps);
- } else {
- timeInstancePrinter.print(b, s, 8, ps);
- ps.print(", ");
- timeInstancePrinter.print(b, s + 1 + 8 - 1, 8, ps);
- }
-
ps.print("\")");
}
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ATimePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ATimePrinter.java
index b77ee64..aba6a4b 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ATimePrinter.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ATimePrinter.java
@@ -29,5 +29,14 @@
ps.print("\")");
}
+
+ public void printString(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+ int time = AInt32SerializerDeserializer.getInt(b, s + 1);
+
+ ps.append(String.format("%02d", gCalInstance.getHourOfDay(time))).append(":")
+ .append(String.format("%02d", gCalInstance.getMinOfHour(time))).append(":")
+ .append(String.format("%02d", gCalInstance.getSecOfMin(time))).append(".")
+ .append(String.format("%03d", gCalInstance.getMillisOfSec(time))).append("Z");
+ }
}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java
index 86a9a8d..5f68522 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java
@@ -23,7 +23,6 @@
import edu.uci.ics.asterix.om.base.AMutableDate;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -63,9 +62,7 @@
long chrononTimeInMs = 0;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
- charAccessor.reset(date, 0, date.length());
- chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor, true);
+ chrononTimeInMs = ADateParserFactory.parseDatePart(date, 0, date.length());
} catch (Exception e) {
throw new HyracksDataException(e);
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java
index cedfc8d..34c3a5b 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java
@@ -23,7 +23,6 @@
import edu.uci.ics.asterix.om.base.AMutableDateTime;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
@@ -37,7 +36,7 @@
@SuppressWarnings("unchecked")
private static final ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATETIME);
-
+ private static final AMutableDateTime aDateTime = new AMutableDateTime(0L);
private static final String errorMessage = "This can not be an instance of datetime";
private ADateTimeSerializerDeserializer() {
@@ -62,28 +61,25 @@
}
public static void parse(String datetime, DataOutput out) throws HyracksDataException {
- AMutableDateTime aDateTime = new AMutableDateTime(0L);
long chrononTimeInMs = 0;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
- charAccessor.reset(datetime, 0, datetime.length());
// +1 if it is negative (-)
- short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+ short timeOffset = (short) ((datetime.charAt(0) == '-') ? 1 : 0);
- if (charAccessor.getCharAt(timeOffset + 10) != 'T' && charAccessor.getCharAt(timeOffset + 8) != 'T') {
- throw new AlgebricksException(errorMessage + ": missing T");
+ timeOffset += 8;
+
+ if(datetime.charAt(timeOffset) != 'T'){
+ timeOffset += 2;
+ if(datetime.charAt(timeOffset) != 'T'){
+ throw new AlgebricksException(errorMessage + ": missing T");
+ }
}
- // if extended form 11, else 9
- timeOffset += (charAccessor.getCharAt(timeOffset + 13) == ':') ? (short) (11) : (short) (9);
+ chrononTimeInMs = ADateParserFactory.parseDatePart(datetime, 0, timeOffset);
- chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor, false);
-
- charAccessor.reset(datetime, timeOffset, datetime.length() - timeOffset);
-
- chrononTimeInMs += ATimeParserFactory.parseTimePart(charAccessor);
+ chrononTimeInMs += ATimeParserFactory.parseTimePart(datetime, timeOffset + 1, datetime.length() - timeOffset - 1);
} catch (Exception e) {
throw new HyracksDataException(e);
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
index 88e2ea5..6930f60 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
@@ -8,7 +8,6 @@
import edu.uci.ics.asterix.om.base.ADuration;
import edu.uci.ics.asterix.om.base.AMutableDuration;
import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -21,6 +20,7 @@
@SuppressWarnings("unchecked")
private static final ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADURATION);
+ private static final AMutableDuration aDuration = new AMutableDuration(0, 0);
private ADurationSerializerDeserializer() {
}
@@ -46,11 +46,7 @@
public static void parse(String duration, DataOutput out) throws HyracksDataException {
try {
- AMutableDuration aDuration = new AMutableDuration(0, 0);
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
- charAccessor.reset(duration, 0, duration.length());
- ADurationParserFactory.parseDuration(charAccessor, aDuration);
-
+ ADurationParserFactory.parseDuration(duration, 0, duration.length(), aDuration);
durationSerde.serialize(aDuration, out);
} catch (Exception e) {
throw new HyracksDataException(e);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
index 7c87dfa..8c4def0 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
@@ -24,7 +24,6 @@
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
import edu.uci.ics.asterix.om.types.ATypeTag;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -39,7 +38,7 @@
@SuppressWarnings("unchecked")
private static final ISerializerDeserializer<AInterval> intervalSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINTERVAL);
-
+ private static final AMutableInterval aInterval = new AMutableInterval(0L, 0L, (byte) 0);
private static final String errorMessage = "This can not be an instance of interval";
private AIntervalSerializerDeserializer() {
@@ -64,7 +63,6 @@
} catch (IOException e) {
throw new HyracksDataException(e);
}
-
}
public static long getIntervalStart(byte[] data, int offset) {
@@ -87,68 +85,46 @@
* @throws HyracksDataException
*/
public static void parseDatetime(String interval, DataOutput out) throws HyracksDataException {
- AMutableInterval aInterval = new AMutableInterval(0l, 0l, (byte) 0);
long chrononTimeInMsStart = 0;
long chrononTimeInMsEnd = 0;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
+ // the starting point for parsing (so for the accessor)
+ int startOffset = 0;
+ int endOffset, timeSeperatorOffsetInDatetimeString;
// Get the index for the comma
int commaIndex = interval.indexOf(',');
- if (commaIndex < 0) {
+ if (commaIndex < 1) {
throw new AlgebricksException("comma is missing for a string of interval");
}
- int nonSpaceIndex = commaIndex - 1;
- while (interval.charAt(nonSpaceIndex) == ' ') {
- nonSpaceIndex--;
+ endOffset = commaIndex - 1;
+
+ timeSeperatorOffsetInDatetimeString = interval.indexOf('T');
+
+ if (timeSeperatorOffsetInDatetimeString < 0) {
+ throw new AlgebricksException(errorMessage + ": missing T for a datetime value.");
}
- // Interval Start
- charAccessor.reset(interval, 0, nonSpaceIndex + 1);
+ chrononTimeInMsStart = parseDatePart(interval, startOffset, timeSeperatorOffsetInDatetimeString - 1);
- // +1 if it is negative (-)
- short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
-
- if (charAccessor.getCharAt(timeOffset + 10) != 'T' && charAccessor.getCharAt(timeOffset + 8) != 'T') {
- throw new AlgebricksException(errorMessage + ": missing T");
- }
-
- // if extended form 11, else 9
- timeOffset += (charAccessor.getCharAt(timeOffset + 13) == ':') ? (short) (11) : (short) (9);
-
- chrononTimeInMsStart = ADateParserFactory.parseDatePart(charAccessor, false);
-
- charAccessor.reset(interval, timeOffset, nonSpaceIndex - timeOffset + 1);
-
- chrononTimeInMsStart += ATimeParserFactory.parseTimePart(charAccessor);
+ chrononTimeInMsStart += parseTimePart(interval, timeSeperatorOffsetInDatetimeString + 1, endOffset);
// Interval End
- nonSpaceIndex = commaIndex + 1;
- while (interval.charAt(nonSpaceIndex) == ' ') {
- nonSpaceIndex++;
+ startOffset = commaIndex + 1;
+ endOffset = interval.length() - 1;
+
+ timeSeperatorOffsetInDatetimeString = interval.indexOf('T', startOffset);
+
+ if (timeSeperatorOffsetInDatetimeString < 0) {
+ throw new AlgebricksException(errorMessage + ": missing T for a datetime value.");
}
- charAccessor.reset(interval, nonSpaceIndex, interval.length() - nonSpaceIndex);
+ chrononTimeInMsEnd = parseDatePart(interval, startOffset, timeSeperatorOffsetInDatetimeString - 1);
- // +1 if it is negative (-)
- timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
-
- if (charAccessor.getCharAt(timeOffset + 10) != 'T' && charAccessor.getCharAt(timeOffset + 8) != 'T') {
- throw new AlgebricksException(errorMessage + ": missing T");
- }
-
- // if extended form 11, else 9
- timeOffset += (charAccessor.getCharAt(timeOffset + 13) == ':') ? (short) (11) : (short) (9);
-
- chrononTimeInMsEnd = ADateParserFactory.parseDatePart(charAccessor, false);
-
- charAccessor.reset(interval, nonSpaceIndex + timeOffset, interval.length() - nonSpaceIndex - timeOffset);
-
- chrononTimeInMsEnd += ATimeParserFactory.parseTimePart(charAccessor);
-
+ chrononTimeInMsEnd += parseTimePart(interval, timeSeperatorOffsetInDatetimeString + 1, endOffset);
} catch (Exception e) {
throw new HyracksDataException(e);
}
@@ -159,13 +135,13 @@
}
public static void parseTime(String interval, DataOutput out) throws HyracksDataException {
- AMutableInterval aInterval = new AMutableInterval(0l, 0l, (byte) 0);
long chrononTimeInMsStart = 0;
long chrononTimeInMsEnd = 0;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
+ int startOffset = 0;
+ int endOffset;
// Get the index for the comma
int commaIndex = interval.indexOf(',');
@@ -173,27 +149,20 @@
throw new AlgebricksException("comma is missing for a string of interval");
}
- int nonSpaceIndex = commaIndex - 1;
- while (interval.charAt(nonSpaceIndex) == ' ') {
- nonSpaceIndex--;
- }
+ endOffset = commaIndex - 1;
// Interval Start
- charAccessor.reset(interval, 0, nonSpaceIndex + 1);
- chrononTimeInMsStart = ATimeParserFactory.parseTimePart(charAccessor);
+ chrononTimeInMsStart = parseTimePart(interval, startOffset, endOffset);
if (chrononTimeInMsStart < 0) {
chrononTimeInMsStart += GregorianCalendarSystem.CHRONON_OF_DAY;
}
// Interval End
- nonSpaceIndex = commaIndex + 1;
- while (interval.charAt(nonSpaceIndex) == ' ') {
- nonSpaceIndex++;
- }
+ startOffset = commaIndex + 1;
+ endOffset = interval.length() - 1;
- charAccessor.reset(interval, nonSpaceIndex, interval.length() - nonSpaceIndex);
- chrononTimeInMsEnd = ATimeParserFactory.parseTimePart(charAccessor);
+ chrononTimeInMsEnd = parseTimePart(interval, startOffset, endOffset);
if (chrononTimeInMsEnd < 0) {
chrononTimeInMsEnd += GregorianCalendarSystem.CHRONON_OF_DAY;
@@ -208,57 +177,67 @@
}
public static void parseDate(String interval, DataOutput out) throws HyracksDataException {
- AMutableInterval aInterval = new AMutableInterval(0l, 0l, (byte) 0);
long chrononTimeInMsStart = 0;
long chrononTimeInMsEnd = 0;
- short tempStart = 0;
- short tempEnd = 0;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
+
+ // the starting point for parsing (so for the accessor)
+ int startOffset = 0;
+ int endOffset;
// Get the index for the comma
int commaIndex = interval.indexOf(',');
- if (commaIndex < 0) {
+ if (commaIndex < 1) {
throw new AlgebricksException("comma is missing for a string of interval");
}
- int nonSpaceIndex = commaIndex - 1;
- while (interval.charAt(nonSpaceIndex) == ' ') {
- nonSpaceIndex--;
- }
+ endOffset = commaIndex - 1;
- // Interval Start
- charAccessor.reset(interval, 0, nonSpaceIndex + 1);
-
- chrononTimeInMsStart = ADateParserFactory.parseDatePart(charAccessor, true);
-
- if (chrononTimeInMsStart < 0 && chrononTimeInMsStart % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
- tempStart = 1;
- }
+ chrononTimeInMsStart = parseDatePart(interval, startOffset, endOffset);
// Interval End
- nonSpaceIndex = commaIndex + 1;
- while (interval.charAt(nonSpaceIndex) == ' ') {
- nonSpaceIndex++;
- }
+ startOffset = commaIndex + 1;
+ endOffset = interval.length() - 1;
- charAccessor.reset(interval, nonSpaceIndex, interval.length() - nonSpaceIndex);
-
- chrononTimeInMsEnd = ADateParserFactory.parseDatePart(charAccessor, true);
-
- if (chrononTimeInMsEnd < 0 && chrononTimeInMsEnd % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
- tempEnd = 1;
- }
+ chrononTimeInMsEnd = parseDatePart(interval, startOffset, endOffset);
} catch (Exception e) {
throw new HyracksDataException(e);
}
- aInterval.setValue((chrononTimeInMsStart / GregorianCalendarSystem.CHRONON_OF_DAY) - tempStart,
- (chrononTimeInMsEnd / GregorianCalendarSystem.CHRONON_OF_DAY) - tempEnd, ATypeTag.DATE.serialize());
+ aInterval.setValue((chrononTimeInMsStart / GregorianCalendarSystem.CHRONON_OF_DAY),
+ (chrononTimeInMsEnd / GregorianCalendarSystem.CHRONON_OF_DAY), ATypeTag.DATE.serialize());
intervalSerde.serialize(aInterval, out);
}
+ private static long parseDatePart(String interval, int startOffset, int endOffset) throws AlgebricksException,
+ HyracksDataException {
+
+ while (interval.charAt(endOffset) == '"' || interval.charAt(endOffset) == ' ') {
+ endOffset--;
+ }
+
+ while (interval.charAt(startOffset) == '"' || interval.charAt(startOffset) == ' ') {
+ startOffset++;
+ }
+
+ return ADateParserFactory.parseDatePart(interval, startOffset, endOffset - startOffset + 1);
+ }
+
+ private static int parseTimePart(String interval, int startOffset, int endOffset) throws AlgebricksException,
+ HyracksDataException {
+
+ while (interval.charAt(endOffset) == '"' || interval.charAt(endOffset) == ' ') {
+ endOffset--;
+ }
+
+ while (interval.charAt(startOffset) == '"' || interval.charAt(startOffset) == ' ') {
+ startOffset++;
+ }
+
+ return ATimeParserFactory.parseTimePart(interval, startOffset, endOffset - startOffset + 1);
+ }
+
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java
index 26e8d7a..8c3134a 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java
@@ -8,7 +8,6 @@
import edu.uci.ics.asterix.om.base.AMutableTime;
import edu.uci.ics.asterix.om.base.ATime;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -22,7 +21,8 @@
@SuppressWarnings("unchecked")
private static final ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ATIME);
-
+ private static final AMutableTime aTime = new AMutableTime(0);
+
private ATimeSerializerDeserializer() {
}
@@ -47,13 +47,10 @@
}
public static void parse(String time, DataOutput out) throws HyracksDataException {
- AMutableTime aTime = new AMutableTime(0);
int chrononTimeInMs;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
- charAccessor.reset(time, 0, time.length());
- chrononTimeInMs = ATimeParserFactory.parseTimePart(charAccessor);
+ chrononTimeInMs = ATimeParserFactory.parseTimePart(time, 0, time.length());
} catch (Exception e) {
throw new HyracksDataException(e);
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java
index 8192919..c1fbcb2 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java
@@ -36,15 +36,12 @@
@Override
public IValueParser createValueParser() {
- final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
-
return new IValueParser() {
@Override
public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
- charArrayAccessor.reset(buffer, start, length);
try {
- out.writeInt((int) (parseDatePart(charArrayAccessor, true) / GregorianCalendarSystem.CHRONON_OF_DAY));
+ out.writeInt((int) (parseDatePart(buffer, start, length) / GregorianCalendarSystem.CHRONON_OF_DAY));
} catch (IOException ex) {
throw new HyracksDataException(ex);
}
@@ -63,10 +60,9 @@
* @return
* @throws Exception
*/
- public static <T> long parseDatePart(ICharSequenceAccessor<T> charAccessor, boolean isDateOnly)
+ public static long parseDatePart(String dateString, int start, int length)
throws HyracksDataException {
- int length = charAccessor.getLength();
int offset = 0;
int year = 0, month = 0, day = 0;
@@ -74,26 +70,25 @@
boolean isExtendedForm = false;
- if (charAccessor.getCharAt(offset) == '-') {
+ if (dateString.charAt(start + offset) == '-') {
offset++;
positive = false;
}
- if ((isDateOnly) && charAccessor.getCharAt(offset + 4) == '-' || (!isDateOnly)
- && charAccessor.getCharAt(offset + 13) == ':') {
+ if (dateString.charAt(start + offset + 4) == '-') {
isExtendedForm = true;
}
if (isExtendedForm) {
- if (charAccessor.getCharAt(offset + 4) != '-' || charAccessor.getCharAt(offset + 7) != '-') {
+ if (dateString.charAt(start + offset + 4) != '-' || dateString.charAt(start + offset + 7) != '-') {
throw new HyracksDataException("Missing dash in the date string as an extended form");
}
}
// year
for (int i = 0; i < 4; i++) {
- if (charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9') {
- year = year * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if (dateString.charAt(start + offset + i) >= '0' && dateString.charAt(start + offset + i) <= '9') {
+ year = year * 10 + dateString.charAt(start + offset + i) - '0';
} else {
throw new HyracksDataException("Non-numeric value in year field");
}
@@ -108,8 +103,8 @@
// month
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
- month = month * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if ((dateString.charAt(start + offset + i) >= '0' && dateString.charAt(start + offset + i) <= '9')) {
+ month = month * 10 + dateString.charAt(start + offset + i) - '0';
} else {
throw new HyracksDataException("Non-numeric value in month field");
}
@@ -123,8 +118,8 @@
// day
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
- day = day * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if ((dateString.charAt(start + offset + i) >= '0' && dateString.charAt(start + offset + i) <= '9')) {
+ day = day * 10 + dateString.charAt(start + offset + i) - '0';
} else {
throw new HyracksDataException("Non-numeric value in day field");
}
@@ -141,10 +136,208 @@
year *= -1;
}
- if (isDateOnly && length > offset) {
+ if (length > offset) {
throw new HyracksDataException("Too many chars for a date only value");
}
+
+ if (!GregorianCalendarSystem.getInstance().validate(year, month, day, 0, 0, 0, 0)){
+ throw new HyracksDataException(dateErrorMessage);
+ }
+
+ return GregorianCalendarSystem.getInstance().getChronon(year, month, day, 0, 0, 0, 0, 0);
+ }
+
+ /**
+ * A copy-and-paste of {@link #parseDatePart(String, int, int)} but for a char array, in order
+ * to avoid object creation.
+ *
+ * @param dateString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static long parseDatePart(char[] dateString, int start, int length)
+ throws HyracksDataException {
+
+ int offset = 0;
+
+ int year = 0, month = 0, day = 0;
+ boolean positive = true;
+
+ boolean isExtendedForm = false;
+
+ if (dateString[start + offset] == '-') {
+ offset++;
+ positive = false;
+ }
+
+ if (dateString[start + offset + 4] == '-') {
+ isExtendedForm = true;
+ }
+
+ if (isExtendedForm) {
+ if (dateString[start + offset + 4] != '-' || dateString[start + offset + 7] != '-') {
+ throw new HyracksDataException("Missing dash in the date string as an extended form");
+ }
+ }
+
+ // year
+ for (int i = 0; i < 4; i++) {
+ if (dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9') {
+ year = year * 10 + dateString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in year field");
+ }
+ }
+
+ if (year < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.YEAR.ordinal()]
+ || year > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.YEAR.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": year " + year);
+ }
+
+ offset += (isExtendedForm) ? 5 : 4;
+
+ // month
+ for (int i = 0; i < 2; i++) {
+ if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+ month = month * 10 + dateString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in month field");
+ }
+ }
+
+ if (month < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MONTH.ordinal()]
+ || month > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MONTH.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": month " + month);
+ }
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // day
+ for (int i = 0; i < 2; i++) {
+ if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+ day = day * 10 + dateString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in day field");
+ }
+ }
+
+ if (day < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.DAY.ordinal()]
+ || day > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.DAY.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": day " + day);
+ }
+
+ offset += 2;
+
+ if (!positive) {
+ year *= -1;
+ }
+
+ if (length > offset) {
+ throw new HyracksDataException("Too many chars for a date only value");
+ }
+
+ if (!GregorianCalendarSystem.getInstance().validate(year, month, day, 0, 0, 0, 0)){
+ throw new HyracksDataException(dateErrorMessage);
+ }
+
return GregorianCalendarSystem.getInstance().getChronon(year, month, day, 0, 0, 0, 0, 0);
}
+ /**
+ * A copy-and-paste of {@link #parseDatePart(String, int, int)} but for a byte array, in order
+ * to avoid object creation.
+ *
+ * @param dateString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static long parseDatePart(byte[] dateString, int start, int length)
+ throws HyracksDataException {
+
+ int offset = 0;
+
+ int year = 0, month = 0, day = 0;
+ boolean positive = true;
+
+ boolean isExtendedForm = false;
+
+ if (dateString[start + offset] == '-') {
+ offset++;
+ positive = false;
+ }
+
+ if (dateString[start + offset + 4] == '-') {
+ isExtendedForm = true;
+ }
+
+ if (isExtendedForm) {
+ if (dateString[start + offset + 4] != '-' || dateString[start + offset + 7] != '-') {
+ throw new HyracksDataException("Missing dash in the date string as an extended form");
+ }
+ }
+
+ // year
+ for (int i = 0; i < 4; i++) {
+ if (dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9') {
+ year = year * 10 + dateString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in year field");
+ }
+ }
+
+ if (year < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.YEAR.ordinal()]
+ || year > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.YEAR.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": year " + year);
+ }
+
+ offset += (isExtendedForm) ? 5 : 4;
+
+ // month
+ for (int i = 0; i < 2; i++) {
+ if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+ month = month * 10 + dateString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in month field");
+ }
+ }
+
+ if (month < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MONTH.ordinal()]
+ || month > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MONTH.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": month " + month);
+ }
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // day
+ for (int i = 0; i < 2; i++) {
+ if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+ day = day * 10 + dateString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in day field");
+ }
+ }
+
+ if (day < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.DAY.ordinal()]
+ || day > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.DAY.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": day " + day);
+ }
+
+ offset += 2;
+
+ if (!positive) {
+ year *= -1;
+ }
+
+ if (length > offset) {
+ throw new HyracksDataException("Too many chars for a date only value");
+ }
+
+ if (!GregorianCalendarSystem.getInstance().validate(year, month, day, 0, 0, 0, 0)){
+ throw new HyracksDataException(dateErrorMessage);
+ }
+
+ return GregorianCalendarSystem.getInstance().getChronon(year, month, day, 0, 0, 0, 0, 0);
+ }
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java
index 2df3c3b..c95ac3a 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java
@@ -36,31 +36,27 @@
@Override
public IValueParser createValueParser() {
- final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
-
return new IValueParser() {
@Override
public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
long chrononTimeInMs = 0;
- charArrayAccessor.reset(buffer, start, length);
+ short timeOffset = (short) ((buffer[start] == '-') ? 1 : 0);
- short timeOffset = (short) ((charArrayAccessor.getCharAt(0) == '-') ? 1 : 0);
+ timeOffset += 8;
- if (charArrayAccessor.getCharAt(timeOffset + 10) != 'T'
- && charArrayAccessor.getCharAt(timeOffset + 8) != 'T') {
- throw new HyracksDataException(dateTimeErrorMessage + ": missing T");
+ if (buffer[start + timeOffset] != 'T') {
+ timeOffset += 2;
+ if (buffer[start + timeOffset] != 'T') {
+ throw new HyracksDataException(dateTimeErrorMessage + ": missing T");
+ }
}
- // if extended form 11, else 9
- timeOffset += (charArrayAccessor.getCharAt(timeOffset + 13) == ':') ? (short) (11) : (short) (9);
+ chrononTimeInMs = ADateParserFactory.parseDatePart(buffer, start, timeOffset);
- chrononTimeInMs = ADateParserFactory.parseDatePart(charArrayAccessor, false);
-
- charArrayAccessor.reset(buffer, start + timeOffset, length - timeOffset);
-
- chrononTimeInMs += ATimeParserFactory.parseTimePart(charArrayAccessor);
+ chrononTimeInMs += ATimeParserFactory.parseTimePart(buffer, start + timeOffset + 1, length - timeOffset
+ - 1);
try {
out.writeLong(chrononTimeInMs);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
index b176061..de5a6a1 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
@@ -36,14 +36,12 @@
@Override
public IValueParser createValueParser() {
- final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
final AMutableDuration aMutableDuration = new AMutableDuration(0, 0);
return new IValueParser() {
@Override
public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
- charArrayAccessor.reset(buffer, start, length);
- parseDuration(charArrayAccessor, aMutableDuration);
+ parseDuration(buffer, start, length, aMutableDuration);
try {
out.writeInt(aMutableDuration.getMonths());
out.writeLong(aMutableDuration.getMilliseconds());
@@ -66,7 +64,7 @@
SEC;
};
- public static <T> void parseDuration(ICharSequenceAccessor<T> charAccessor, AMutableDuration aDuration)
+ public static void parseDuration(String durationString, int start, int length, AMutableDuration aDuration)
throws HyracksDataException {
boolean positive = true;
@@ -74,21 +72,23 @@
int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
State state = State.NOTHING_READ;
- if (charAccessor.getCharAt(offset) == '-') {
+ if (durationString.charAt(start + offset) == '-') {
offset++;
positive = false;
}
- if (charAccessor.getCharAt(offset++) != 'P') {
+ if (durationString.charAt(start + offset) != 'P') {
throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
}
- for (; offset < charAccessor.getLength(); offset++) {
- if (charAccessor.getCharAt(offset) >= '0' && charAccessor.getCharAt(offset) <= '9') {
+ offset++;
+
+ for (; offset < length; offset++) {
+ if (durationString.charAt(start + offset) >= '0' && durationString.charAt(start + offset) <= '9') {
// accumulate the digit fields
- value = value * 10 + charAccessor.getCharAt(offset) - '0';
+ value = value * 10 + durationString.charAt(start + offset) - '0';
} else {
- switch (charAccessor.getCharAt(offset)) {
+ switch (durationString.charAt(start + offset)) {
case 'Y':
if (state.compareTo(State.YEAR) < 0) {
year = value;
@@ -139,11 +139,276 @@
case '.':
if (state.compareTo(State.MILLISEC) < 0) {
int i = 1;
- for (; offset + i < charAccessor.getLength(); i++) {
- if (charAccessor.getCharAt(offset + i) >= '0'
- && charAccessor.getCharAt(offset + i) <= '9') {
+ for (; offset + i < length; i++) {
+ if (durationString.charAt(start + offset + i) >= '0'
+ && durationString.charAt(start + offset + i) <= '9') {
if (i < 4) {
- millisecond = millisecond * 10 + (charAccessor.getCharAt(offset + i) - '0');
+ millisecond = millisecond * 10
+ + (durationString.charAt(start + offset + i) - '0');
+ } else {
+ throw new HyracksDataException(durationErrorMessage
+ + ": wrong MILLISECOND field.");
+ }
+ } else {
+ break;
+ }
+ }
+ offset += i;
+ state = State.MILLISEC;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MILLISECOND field.");
+ }
+ case 'S':
+ if (state.compareTo(State.SEC) < 0) {
+ second = value;
+ state = State.SEC;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong SECOND field.");
+ }
+ break;
+ default:
+ throw new HyracksDataException(durationErrorMessage + ": wrong format for duration.");
+
+ }
+ value = 0;
+ }
+ }
+
+ if (state.compareTo(State.TIME) == 0) {
+ throw new HyracksDataException(durationErrorMessage + ": no time fields after time separator.");
+ }
+
+ short temp = 1;
+ if (!positive) {
+ temp = -1;
+ }
+
+ aDuration.setValue(temp * (year * 12 + month), temp
+ * (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second * 1000L + millisecond));
+
+ }
+
+ /**
+ * Copy-and-paste the code in {@link #parseDuration(String, int, int, AMutableDuration)} in order to eliminate
+ * object creation.
+ *
+ * @param charAccessor
+ * @param start
+ * @param length
+ * @param aDuration
+ * @throws HyracksDataException
+ */
+ public static void parseDuration(char[] charAccessor, int start, int length, AMutableDuration aDuration)
+ throws HyracksDataException {
+
+ boolean positive = true;
+ int offset = 0;
+ int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
+ State state = State.NOTHING_READ;
+
+ if (charAccessor[start + offset] == '-') {
+ offset++;
+ positive = false;
+ }
+
+ if (charAccessor[start + offset] != 'P') {
+ throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
+ }
+
+ offset++;
+
+ for (; offset < length; offset++) {
+ if (charAccessor[start + offset] >= '0' && charAccessor[start + offset] <= '9') {
+ // accumulate the digit fields
+ value = value * 10 + charAccessor[start + offset] - '0';
+ } else {
+ switch (charAccessor[start + offset]) {
+ case 'Y':
+ if (state.compareTo(State.YEAR) < 0) {
+ year = value;
+ state = State.YEAR;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong YEAR feild.");
+ }
+ break;
+ case 'M':
+ if (state.compareTo(State.TIME) < 0) {
+ if (state.compareTo(State.MONTH) < 0) {
+ month = value;
+ state = State.MONTH;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MONTH field.");
+ }
+ } else if (state.compareTo(State.MIN) < 0) {
+ minute = value;
+ state = State.MIN;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MIN field.");
+ }
+ break;
+ case 'D':
+ if (state.compareTo(State.DAY) < 0) {
+ day = value;
+ state = State.DAY;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong DAY field");
+ }
+ break;
+ case 'T':
+ if (state.compareTo(State.TIME) < 0) {
+ state = State.TIME;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong TIME field.");
+ }
+ break;
+
+ case 'H':
+ if (state.compareTo(State.HOUR) < 0) {
+ hour = value;
+ state = State.HOUR;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong HOUR field.");
+ }
+ break;
+ case '.':
+ if (state.compareTo(State.MILLISEC) < 0) {
+ int i = 1;
+ for (; offset + i < length; i++) {
+ if (charAccessor[start + offset + i] >= '0' && charAccessor[start + offset + i] <= '9') {
+ if (i < 4) {
+ millisecond = millisecond * 10 + (charAccessor[start + offset + i] - '0');
+ } else {
+ throw new HyracksDataException(durationErrorMessage
+ + ": wrong MILLISECOND field.");
+ }
+ } else {
+ break;
+ }
+ }
+ offset += i;
+ state = State.MILLISEC;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MILLISECOND field.");
+ }
+ case 'S':
+ if (state.compareTo(State.SEC) < 0) {
+ second = value;
+ state = State.SEC;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong SECOND field.");
+ }
+ break;
+ default:
+ throw new HyracksDataException(durationErrorMessage + ": wrong format for duration.");
+
+ }
+ value = 0;
+ }
+ }
+
+ if (state.compareTo(State.TIME) == 0) {
+ throw new HyracksDataException(durationErrorMessage + ": no time fields after time separator.");
+ }
+
+ short temp = 1;
+ if (!positive) {
+ temp = -1;
+ }
+
+ aDuration.setValue(temp * (year * 12 + month), temp
+ * (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second * 1000L + millisecond));
+
+ }
+
+ /**
+ * Copy-and-paste the code in {@link #parseDuration(String, int, int, AMutableDuration)} in order to eliminate
+ * object creation.
+ *
+ * @param charAccessor
+ * @param start
+ * @param length
+ * @param aDuration
+ * @throws HyracksDataException
+ */
+ public static void parseDuration(byte[] charAccessor, int start, int length, AMutableDuration aDuration)
+ throws HyracksDataException {
+
+ boolean positive = true;
+ int offset = 0;
+ int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
+ State state = State.NOTHING_READ;
+
+ if (charAccessor[start + offset] == '-') {
+ offset++;
+ positive = false;
+ }
+
+ if (charAccessor[start + offset] != 'P') {
+ throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
+ }
+
+ offset++;
+
+ for (; offset < length; offset++) {
+ if (charAccessor[start + offset] >= '0' && charAccessor[start + offset] <= '9') {
+ // accumulate the digit fields
+ value = value * 10 + charAccessor[start + offset] - '0';
+ } else {
+ switch (charAccessor[start + offset]) {
+ case 'Y':
+ if (state.compareTo(State.YEAR) < 0) {
+ year = value;
+ state = State.YEAR;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong YEAR feild.");
+ }
+ break;
+ case 'M':
+ if (state.compareTo(State.TIME) < 0) {
+ if (state.compareTo(State.MONTH) < 0) {
+ month = value;
+ state = State.MONTH;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MONTH field.");
+ }
+ } else if (state.compareTo(State.MIN) < 0) {
+ minute = value;
+ state = State.MIN;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MIN field.");
+ }
+ break;
+ case 'D':
+ if (state.compareTo(State.DAY) < 0) {
+ day = value;
+ state = State.DAY;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong DAY field");
+ }
+ break;
+ case 'T':
+ if (state.compareTo(State.TIME) < 0) {
+ state = State.TIME;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong TIME field.");
+ }
+ break;
+
+ case 'H':
+ if (state.compareTo(State.HOUR) < 0) {
+ hour = value;
+ state = State.HOUR;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong HOUR field.");
+ }
+ break;
+ case '.':
+ if (state.compareTo(State.MILLISEC) < 0) {
+ int i = 1;
+ for (; offset + i < length; i++) {
+ if (charAccessor[start + offset + i] >= '0' && charAccessor[start + offset + i] <= '9') {
+ if (i < 4) {
+ millisecond = millisecond * 10 + (charAccessor[start + offset + i] - '0');
} else {
throw new HyracksDataException(durationErrorMessage
+ ": wrong MILLISECOND field.");
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java
index d76f41d..c0f0957 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java
@@ -36,15 +36,12 @@
@Override
public IValueParser createValueParser() {
- final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
-
return new IValueParser() {
@Override
public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
- charArrayAccessor.reset(buffer, start, length);
try {
- out.writeInt(parseTimePart(charArrayAccessor));
+ out.writeInt(parseTimePart(buffer, start, length));
} catch (IOException ex) {
throw new HyracksDataException(ex);
}
@@ -53,32 +50,34 @@
}
/**
- * Parse the given char sequence as a time string, and return the milliseconds represented by the time.
+ * Parse the given string as a time string, and return the milliseconds represented by the time.
*
- * @param charAccessor
+ * @param timeString
+ * @param start
+ * @param length
* @return
- * @throws Exception
+ * @throws HyracksDataException
*/
- public static <T> int parseTimePart(ICharSequenceAccessor<T> charAccessor) throws HyracksDataException {
+ public static int parseTimePart(String timeString, int start, int length) throws HyracksDataException {
- int length = charAccessor.getLength();
int offset = 0;
int hour = 0, min = 0, sec = 0, millis = 0;
int timezone = 0;
boolean isExtendedForm = false;
- if (charAccessor.getCharAt(offset + 2) == ':') {
+ if (timeString.charAt(start + offset + 2) == ':') {
isExtendedForm = true;
}
- if (isExtendedForm && (charAccessor.getCharAt(offset + 2) != ':' || charAccessor.getCharAt(offset + 5) != ':')) {
+ if (isExtendedForm
+ && (timeString.charAt(start + offset + 2) != ':' || timeString.charAt(start + offset + 5) != ':')) {
throw new HyracksDataException(timeErrorMessage + ": Missing colon in an extended time format.");
}
// hour
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
- hour = hour * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if ((timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9')) {
+ hour = hour * 10 + timeString.charAt(start + offset + i) - '0';
} else {
throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in hour field");
}
@@ -93,8 +92,8 @@
// minute
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
- min = min * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if ((timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9')) {
+ min = min * 10 + timeString.charAt(start + offset + i) - '0';
} else {
throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in minute field");
}
@@ -109,8 +108,8 @@
// second
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
- sec = sec * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if ((timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9')) {
+ sec = sec * 10 + timeString.charAt(start + offset + i) - '0';
} else {
throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in second field");
}
@@ -123,14 +122,14 @@
offset += 2;
- if ((isExtendedForm && length > offset && charAccessor.getCharAt(offset) == '.')
+ if ((isExtendedForm && length > offset && timeString.charAt(start + offset) == '.')
|| (!isExtendedForm && length > offset)) {
offset += (isExtendedForm) ? 1 : 0;
int i = 0;
for (; i < 3 && offset + i < length; i++) {
- if (charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9') {
- millis = millis * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if (timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9') {
+ millis = millis * 10 + timeString.charAt(start + offset + i) - '0';
} else {
break;
}
@@ -143,32 +142,31 @@
}
// error is thrown if more than three digits are seen for the millisecond part
- if (charAccessor.getLength() > offset && charAccessor.getCharAt(offset) >= '0'
- && charAccessor.getCharAt(offset) <= '9') {
+ if (length > offset && timeString.charAt(start + offset) >= '0' && timeString.charAt(start + offset) <= '9') {
throw new HyracksDataException(timeErrorMessage + ": too many fields for millisecond.");
}
}
if (length > offset) {
- timezone = parseTimezonePart(charAccessor, offset);
+ timezone = parseTimezonePart(timeString, start + offset);
}
return GregorianCalendarSystem.getInstance().getChronon(hour, min, sec, millis, timezone);
}
/**
- * Parse the given char sequence as a time string, and return the milliseconds represented by the time.
+ * Parse the given string as a time string, and parse the timezone field.
*
- * @param charAccessor
+ * @param timeString
+ * @param start
* @return
- * @throws Exception
+ * @throws HyracksDataException
*/
- public static <T> int parseTimezonePart(ICharSequenceAccessor<T> charAccessor, int offset)
- throws HyracksDataException {
+ public static int parseTimezonePart(String timeString, int start) throws HyracksDataException {
int timezone = 0;
- if (charAccessor.getCharAt(offset) != 'Z') {
- if ((charAccessor.getCharAt(offset) != '+' && charAccessor.getCharAt(offset) != '-')) {
+ if (timeString.charAt(start) != 'Z') {
+ if ((timeString.charAt(start) != '+' && timeString.charAt(start) != '-')) {
throw new HyracksDataException("Wrong timezone format: missing sign or missing colon for a time zone");
}
@@ -176,8 +174,8 @@
short timezoneMinute = 0;
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + 1 + i) >= '0' && charAccessor.getCharAt(offset + 1 + i) <= '9')) {
- timezoneHour = (short) (timezoneHour * 10 + charAccessor.getCharAt(offset + 1 + i) - '0');
+ if ((timeString.charAt(start + 1 + i) >= '0' && timeString.charAt(start + 1 + i) <= '9')) {
+ timezoneHour = (short) (timezoneHour * 10 + timeString.charAt(start + 1 + i) - '0');
} else {
throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone hour field");
}
@@ -188,13 +186,12 @@
throw new HyracksDataException(timeErrorMessage + ": time zone hour " + timezoneHour);
}
- int temp_offset = (charAccessor.getCharAt(offset + 3) == ':') ? 1 : 0;
+ int temp_offset = (timeString.charAt(start + 3) == ':') ? 1 : 0;
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + temp_offset + 3 + i) >= '0' && charAccessor.getCharAt(offset
- + temp_offset + 3 + i) <= '9')) {
- timezoneMinute = (short) (timezoneMinute * 10
- + charAccessor.getCharAt(offset + temp_offset + 3 + i) - '0');
+ if ((timeString.charAt(start + temp_offset + 3 + i) >= '0' && timeString.charAt(start + temp_offset + 3
+ + i) <= '9')) {
+ timezoneMinute = (short) (timezoneMinute * 10 + timeString.charAt(start + temp_offset + 3 + i) - '0');
} else {
throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone minute field");
}
@@ -205,7 +202,333 @@
throw new HyracksDataException(timeErrorMessage + ": time zone minute " + timezoneMinute);
}
- if (charAccessor.getCharAt(offset) == '-') {
+ if (timeString.charAt(start) == '-') {
+ timezone = (byte) -((timezoneHour * 4) + timezoneMinute / 15);
+ } else {
+ timezone = (byte) ((timezoneHour * 4) + timezoneMinute / 15);
+ }
+ }
+ return timezone;
+ }
+
+ /**
+ * Similar to {@link #parseTimePart(String, int, int)} but use a char array as input; although this is almost
+ * a copy-and-past code but it avoids object creation.
+ *
+ * @param timeString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static int parseTimePart(char[] timeString, int start, int length) throws HyracksDataException {
+
+ int offset = 0;
+
+ int hour = 0, min = 0, sec = 0, millis = 0;
+ int timezone = 0;
+
+ boolean isExtendedForm = false;
+ if (timeString[start + offset + 2] == ':') {
+ isExtendedForm = true;
+ }
+
+ if (isExtendedForm && (timeString[start + offset + 2] != ':' || timeString[start + offset + 5] != ':')) {
+ throw new HyracksDataException(timeErrorMessage + ": Missing colon in an extended time format.");
+ }
+ // hour
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ hour = hour * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in hour field");
+ }
+ }
+
+ if (hour < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.HOUR.ordinal()]
+ || hour > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.HOUR.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": hour " + hour);
+ }
+
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // minute
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ min = min * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in minute field");
+ }
+ }
+
+ if (min < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]
+ || min > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": min " + min);
+ }
+
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // second
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ sec = sec * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in second field");
+ }
+ }
+
+ if (sec < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.SECOND.ordinal()]
+ || sec > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.SECOND.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": sec " + sec);
+ }
+
+ offset += 2;
+
+ if ((isExtendedForm && length > offset && timeString[start + offset] == '.')
+ || (!isExtendedForm && length > offset)) {
+
+ offset += (isExtendedForm) ? 1 : 0;
+ int i = 0;
+ for (; i < 3 && offset + i < length; i++) {
+ if (timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9') {
+ millis = millis * 10 + timeString[start + offset + i] - '0';
+ } else {
+ break;
+ }
+ }
+
+ offset += i;
+
+ for (; i < 3; i++) {
+ millis = millis * 10;
+ }
+
+ // error is thrown if more than three digits are seen for the millisecond part
+ if (length > offset && timeString[start + offset] >= '0' && timeString[start + offset] <= '9') {
+ throw new HyracksDataException(timeErrorMessage + ": too many fields for millisecond.");
+ }
+ }
+
+ if (length > offset) {
+ timezone = parseTimezonePart(timeString, start + offset);
+ }
+
+ return GregorianCalendarSystem.getInstance().getChronon(hour, min, sec, millis, timezone);
+ }
+
+ /**
+ * Similar to {@link #parseTimezonePart(String, int)} but use a char array as input; although this is almost
+ * a copy-and-past code but it avoids object creation.
+ *
+ * @param timeString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static int parseTimezonePart(char[] timeString, int start) throws HyracksDataException {
+ int timezone = 0;
+
+ if (timeString[start] != 'Z') {
+ if ((timeString[start] != '+' && timeString[start] != '-')) {
+ throw new HyracksDataException("Wrong timezone format: missing sign or missing colon for a time zone");
+ }
+
+ short timezoneHour = 0;
+ short timezoneMinute = 0;
+
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + 1 + i] >= '0' && timeString[start + 1 + i] <= '9')) {
+ timezoneHour = (short) (timezoneHour * 10 + timeString[start + 1 + i] - '0');
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone hour field");
+ }
+ }
+
+ if (timezoneHour < GregorianCalendarSystem.TIMEZONE_HOUR_MIN
+ || timezoneHour > GregorianCalendarSystem.TIMEZONE_HOUR_MAX) {
+ throw new HyracksDataException(timeErrorMessage + ": time zone hour " + timezoneHour);
+ }
+
+ int temp_offset = (timeString[start + 3] == ':') ? 1 : 0;
+
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + temp_offset + 3 + i] >= '0' && timeString[start + temp_offset + 3 + i] <= '9')) {
+ timezoneMinute = (short) (timezoneMinute * 10 + timeString[start + temp_offset + 3 + i] - '0');
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone minute field");
+ }
+ }
+
+ if (timezoneMinute < GregorianCalendarSystem.TIMEZONE_MIN_MIN
+ || timezoneMinute > GregorianCalendarSystem.TIMEZONE_MIN_MAX) {
+ throw new HyracksDataException(timeErrorMessage + ": time zone minute " + timezoneMinute);
+ }
+
+ if (timeString[start] == '-') {
+ timezone = (byte) -((timezoneHour * 4) + timezoneMinute / 15);
+ } else {
+ timezone = (byte) ((timezoneHour * 4) + timezoneMinute / 15);
+ }
+ }
+ return timezone;
+ }
+
+ /**
+ * Similar to {@link #parseTimePart(String, int, int)} but use a byte array as input; although this is almost
+ * a copy-and-past code but it avoids object creation.
+ *
+ * @param timeString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static int parseTimePart(byte[] timeString, int start, int length) throws HyracksDataException {
+
+ int offset = 0;
+
+ int hour = 0, min = 0, sec = 0, millis = 0;
+ int timezone = 0;
+
+ boolean isExtendedForm = false;
+ if (timeString[start + offset + 2] == ':') {
+ isExtendedForm = true;
+ }
+
+ if (isExtendedForm && (timeString[start + offset + 2] != ':' || timeString[start + offset + 5] != ':')) {
+ throw new HyracksDataException(timeErrorMessage + ": Missing colon in an extended time format.");
+ }
+ // hour
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ hour = hour * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in hour field");
+ }
+ }
+
+ if (hour < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.HOUR.ordinal()]
+ || hour > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.HOUR.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": hour " + hour);
+ }
+
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // minute
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ min = min * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in minute field");
+ }
+ }
+
+ if (min < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]
+ || min > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": min " + min);
+ }
+
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // second
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ sec = sec * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in second field");
+ }
+ }
+
+ if (sec < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.SECOND.ordinal()]
+ || sec > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.SECOND.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": sec " + sec);
+ }
+
+ offset += 2;
+
+ if ((isExtendedForm && length > offset && timeString[start + offset] == '.')
+ || (!isExtendedForm && length > offset)) {
+
+ offset += (isExtendedForm) ? 1 : 0;
+ int i = 0;
+ for (; i < 3 && offset + i < length; i++) {
+ if (timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9') {
+ millis = millis * 10 + timeString[start + offset + i] - '0';
+ } else {
+ break;
+ }
+ }
+
+ offset += i;
+
+ for (; i < 3; i++) {
+ millis = millis * 10;
+ }
+
+ // error is thrown if more than three digits are seen for the millisecond part
+ if (length > offset && timeString[start + offset] >= '0' && timeString[start + offset] <= '9') {
+ throw new HyracksDataException(timeErrorMessage + ": too many fields for millisecond.");
+ }
+ }
+
+ if (length > offset) {
+ timezone = parseTimezonePart(timeString, start + offset);
+ }
+
+ return GregorianCalendarSystem.getInstance().getChronon(hour, min, sec, millis, timezone);
+ }
+
+ /**
+ * Similar to {@link #parseTimezonePart(String, int)} but use a byte array as input; although this is almost
+ * a copy-and-past code but it avoids object creation.
+ *
+ * @param timeString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static int parseTimezonePart(byte[] timeString, int start) throws HyracksDataException {
+ int timezone = 0;
+
+ if (timeString[start] != 'Z') {
+ if ((timeString[start] != '+' && timeString[start] != '-')) {
+ throw new HyracksDataException("Wrong timezone format: missing sign or missing colon for a time zone");
+ }
+
+ short timezoneHour = 0;
+ short timezoneMinute = 0;
+
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + 1 + i] >= '0' && timeString[start + 1 + i] <= '9')) {
+ timezoneHour = (short) (timezoneHour * 10 + timeString[start + 1 + i] - '0');
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone hour field");
+ }
+ }
+
+ if (timezoneHour < GregorianCalendarSystem.TIMEZONE_HOUR_MIN
+ || timezoneHour > GregorianCalendarSystem.TIMEZONE_HOUR_MAX) {
+ throw new HyracksDataException(timeErrorMessage + ": time zone hour " + timezoneHour);
+ }
+
+ int temp_offset = (timeString[start + 3] == ':') ? 1 : 0;
+
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + temp_offset + 3 + i] >= '0' && timeString[start + temp_offset + 3 + i] <= '9')) {
+ timezoneMinute = (short) (timezoneMinute * 10 + timeString[start + temp_offset + 3 + i] - '0');
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone minute field");
+ }
+ }
+
+ if (timezoneMinute < GregorianCalendarSystem.TIMEZONE_MIN_MIN
+ || timezoneMinute > GregorianCalendarSystem.TIMEZONE_MIN_MAX) {
+ throw new HyracksDataException(timeErrorMessage + ": time zone minute " + timezoneMinute);
+ }
+
+ if (timeString[start] == '-') {
timezone = (byte) -((timezoneHour * 4) + timezoneMinute / 15);
} else {
timezone = (byte) ((timezoneHour * 4) + timezoneMinute / 15);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ByteArrayCharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ByteArrayCharSequenceAccessor.java
deleted file mode 100644
index 453c86f..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ByteArrayCharSequenceAccessor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * you may obtain a copy of the License from
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public class ByteArrayCharSequenceAccessor implements ICharSequenceAccessor<Byte[]> {
-
- private byte[] buf;
- private int offset;
- private int length;
-
- @Override
- public char getCharAt(int index) throws AsterixRuntimeException {
- if (index < 0 || index >= length) {
- throw new AsterixRuntimeException("Byte array char accessor is out of bound: " + index + ":" + length);
- }
- return (char) (buf[index + offset]);
- }
-
- /**
- * Reset the wrapped byte array.
- *
- * @param obj
- * The byte array to be wrapped
- * @param beginOffset
- * The offset of the string stored in the byte array.
- * @param offset
- * The offset of the substring of the string stored (offset from the beginOffset).
- */
- public void reset(byte[] obj, int offset, int length) {
- this.buf = obj;
- this.offset = offset;
- this.length = length;
- }
-
- @Override
- public int getLength() {
- return length;
- }
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/CharArrayCharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/CharArrayCharSequenceAccessor.java
deleted file mode 100644
index 404f0ee..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/CharArrayCharSequenceAccessor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * you may obtain a copy of the License from
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public class CharArrayCharSequenceAccessor implements ICharSequenceAccessor<char[]> {
-
- private char[] buf;
- private int offset;
- private int length;
-
- @Override
- public char getCharAt(int index) throws AsterixRuntimeException {
- if (index < 0 || index >= length) {
- throw new AsterixRuntimeException("Byte array char accessor is out of bound: " + index + ":" + length);
- }
- return (char) (buf[index + offset]);
- }
-
- /**
- * Reset the wrapped byte array.
- *
- * @param obj
- * The byte array to be wrapped
- * @param beginOffset
- * The offset of the string stored in the byte array.
- * @param offset
- * The offset of the substring of the string stored (offset from the beginOffset).
- */
- public void reset(char[] obj, int offset, int length) {
- this.buf = obj;
- this.offset = offset;
- this.length = length;
- }
-
- @Override
- public int getLength() {
- return length;
- }
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java
index d43f235..f74af9b 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java
@@ -135,11 +135,11 @@
// Check whether leap month.
if (month == 2) {
if (isLeapYear(year)) {
- if (month > DAYS_OF_MONTH_LEAP[1]) {
+ if (day > DAYS_OF_MONTH_LEAP[1]) {
return false;
}
} else {
- if (month > DAYS_OF_MONTH_ORDI[1]) {
+ if (day > DAYS_OF_MONTH_ORDI[1]) {
return false;
}
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ICharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ICharSequenceAccessor.java
deleted file mode 100644
index d5a99a0..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ICharSequenceAccessor.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * you may obtain a copy of the License from
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public interface ICharSequenceAccessor<T> {
-
- /**
- * Return the character in the wrapped char sequence at the given index.
- *
- * @param index
- * @return
- */
- public char getCharAt(int index) throws AsterixRuntimeException;
-
- /**
- * Get the length of the wrapped char sequence.
- *
- * @return
- */
- public int getLength();
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/StringCharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/StringCharSequenceAccessor.java
deleted file mode 100644
index 17e483a..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/StringCharSequenceAccessor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * you may obtain a copy of the License from
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public class StringCharSequenceAccessor implements ICharSequenceAccessor<String> {
-
- private String string;
- private int offset;
- private int length;
-
- @Override
- public char getCharAt(int index) throws AsterixRuntimeException {
- if (index >= length) {
- throw new AsterixRuntimeException("String accessor is out of bound.");
- }
- return string.charAt(index + offset);
- }
-
- public void reset(String obj, int offset, int len) {
- this.string = obj;
- this.offset = offset;
- this.length = len;
- }
-
- @Override
- public int getLength() {
- return length;
- }
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
index a547737..e8a9719 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
@@ -448,7 +448,7 @@
public static final FunctionIdentifier ACCESSOR_TEMPORAL_YEAR = new FunctionIdentifier(
FunctionConstants.ASTERIX_NS, "year", 1);
public static final FunctionIdentifier ACCESSOR_TEMPORAL_MONTH = new FunctionIdentifier(
- FunctionConstants.ASTERIX_NS, "month", 2);
+ FunctionConstants.ASTERIX_NS, "month", 1);
public static final FunctionIdentifier ACCESSOR_TEMPORAL_DAY = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
"day", 1);
public static final FunctionIdentifier ACCESSOR_TEMPORAL_HOUR = new FunctionIdentifier(
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/APrintVisitor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/APrintVisitor.java
index 3664804..b78308d 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/APrintVisitor.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/APrintVisitor.java
@@ -31,6 +31,7 @@
import edu.uci.ics.asterix.dataflow.data.nontagged.printers.AInt32Printer;
import edu.uci.ics.asterix.dataflow.data.nontagged.printers.AInt64Printer;
import edu.uci.ics.asterix.dataflow.data.nontagged.printers.AInt8Printer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.printers.AIntervalPrinter;
import edu.uci.ics.asterix.dataflow.data.nontagged.printers.ALinePrinter;
import edu.uci.ics.asterix.dataflow.data.nontagged.printers.ANullPrinter;
import edu.uci.ics.asterix.dataflow.data.nontagged.printers.APoint3DPrinter;
@@ -173,6 +174,10 @@
AStringPrinter.INSTANCE.print(b, s, l, ps);
break;
}
+ case INTERVAL: {
+ AIntervalPrinter.INSTANCE.print(b, s, l, ps);
+ break;
+ }
default: {
throw new NotImplementedException("No printer for type " + typeTag);
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
index e69fbcd..a0ad3e1 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
@@ -42,9 +42,9 @@
LINE(30),
POLYGON(31),
CIRCLE(32),
- INTERVAL(34),
RECTANGLE(33),
- SYSTEM_NULL(34);
+ INTERVAL(34),
+ SYSTEM_NULL(35);
private byte value;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
index 2b4ea3a..1565cb9 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
@@ -136,7 +136,7 @@
private ComparisonResult compareDateOrTimeWithArg(ATypeTag typeTag2) throws AlgebricksException {
if (typeTag2 == ATypeTag.NULL) {
return ComparisonResult.GREATER_THAN;
- } else if (typeTag2 == ATypeTag.DATETIME) {
+ } else if (typeTag2 == ATypeTag.DATE || typeTag2 == ATypeTag.TIME) {
int result = dateOrTimeBinaryComp.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
outRight.getByteArray(), 1, outRight.getLength() - 1);
if (result == 0)
@@ -146,7 +146,7 @@
else
return ComparisonResult.GREATER_THAN;
}
- throw new AlgebricksException("Comparison is undefined between types ADateTime and " + typeTag2 + " .");
+ throw new AlgebricksException("Comparison is undefined between types Date/Time and " + typeTag2 + " .");
}
private ComparisonResult compareDateTimeWithArg(ATypeTag typeTag2) throws AlgebricksException {
@@ -162,7 +162,7 @@
else
return ComparisonResult.GREATER_THAN;
}
- throw new AlgebricksException("Comparison is undefined between types ADateTime and " + typeTag2 + " .");
+ throw new AlgebricksException("Comparison is undefined between types Datetime and " + typeTag2 + " .");
}
private ComparisonResult compareBooleanWithArg(ATypeTag typeTag2) throws AlgebricksException {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
index 44fcf7c..a1f9911 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
@@ -22,7 +22,6 @@
import edu.uci.ics.asterix.om.base.AMutableDate;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -73,8 +72,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -86,8 +83,17 @@
int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
- charAccessor.reset(serString, 3, stringLength);
- long chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor, true);
+ int startOffset = 3;
+ while (serString[startOffset] == ' ') {
+ startOffset++;
+ }
+ int endOffset = stringLength - 1 + 3;
+ while (serString[endOffset] == ' ') {
+ endOffset--;
+ }
+
+ long chrononTimeInMs = ADateParserFactory.parseDatePart(serString, startOffset,
+ endOffset - startOffset + 1);
short temp = 0;
if (chrononTimeInMs < 0
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
index 6a5783b..83f4c8b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
@@ -23,7 +23,6 @@
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -72,7 +71,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -85,25 +83,22 @@
int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
- charAccessor.reset(serString, 3, stringLength);
-
// +1 if it is negative (-)
- short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+ short timeOffset = (short) ((serString[3] == '-') ? 1 : 0);
- if (charAccessor.getCharAt(timeOffset + 10) != 'T'
- && charAccessor.getCharAt(timeOffset + 8) != 'T') {
- throw new AlgebricksException(errorMessage + ": missing T");
+ timeOffset += 8;
+
+ if (serString[3 + timeOffset] != 'T') {
+ timeOffset += 2;
+ if (serString[3 + timeOffset] != 'T') {
+ throw new AlgebricksException(errorMessage + ": missing T");
+ }
}
- // if extended form 11, else 9
- timeOffset += (charAccessor.getCharAt(timeOffset + 13) == ':') ? (short) (11)
- : (short) (9);
+ long chrononTimeInMs = ADateParserFactory.parseDatePart(serString, 3, timeOffset);
- long chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor, false);
-
- charAccessor.reset(serString, 3 + timeOffset, stringLength - timeOffset);
-
- chrononTimeInMs += ATimeParserFactory.parseTimePart(charAccessor);
+ chrononTimeInMs += ATimeParserFactory.parseTimePart(serString, 3 + timeOffset + 1,
+ stringLength - timeOffset - 1);
aDateTime.setValue(chrononTimeInMs);
datetimeSerde.serialize(aDateTime, out);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
index b2b3f4e..a84ae1d 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
@@ -21,7 +21,6 @@
import edu.uci.ics.asterix.om.base.AMutableDuration;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -43,8 +42,6 @@
private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
- private final static ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
public IFunctionDescriptor createFunctionDescriptor() {
return new ADurationConstructorDescriptor();
@@ -85,9 +82,7 @@
int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
- charAccessor.reset(serString, 3, stringLength);
-
- ADurationParserFactory.parseDuration(charAccessor, aDuration);
+ ADurationParserFactory.parseDuration(serString, 3, stringLength, aDuration);
durationSerde.serialize(aDuration, out);
} else if (serString[0] == SER_NULL_TYPE_TAG) {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
index e1a12f8..0414874 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
@@ -23,7 +23,6 @@
import edu.uci.ics.asterix.om.base.AMutableInterval;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -78,8 +77,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -100,17 +97,15 @@
+ (argOut0.getByteArray()[2] & 0xff << 0);
// start date
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
- long intervalStart = ADateParserFactory.parseDatePart(charAccessor, true)
- / GregorianCalendarSystem.CHRONON_OF_DAY;
- // end date
+ long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+ stringLength) / GregorianCalendarSystem.CHRONON_OF_DAY;
+ // end date
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
- long intervalEnd = ADateParserFactory.parseDatePart(charAccessor, true)
- / GregorianCalendarSystem.CHRONON_OF_DAY;
+ long intervalEnd = ADateParserFactory.parseDatePart(argOut1.getByteArray(), 3,
+ stringLength) / GregorianCalendarSystem.CHRONON_OF_DAY;
if (intervalEnd < intervalStart) {
throw new AlgebricksException(
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
index 72a8e37..6b3e2b6 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
@@ -24,7 +24,6 @@
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -78,8 +77,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -95,47 +92,43 @@
nullSerde.serialize(ANull.NULL, out);
} else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG
&& argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
- // start date
-
+ // start datetime
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
// get offset for time part: +1 if it is negative (-)
- short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
-
- if (charAccessor.getCharAt(timeOffset + 10) != 'T'
- && charAccessor.getCharAt(timeOffset + 8) != 'T') {
- throw new AlgebricksException(errorMessage + ": missing T");
+ short timeOffset = (short) ((argOut0.getByteArray()[3] == '-') ? 1 : 0);
+ timeOffset += 8;
+ if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
+ timeOffset += 2;
+ if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
+ throw new AlgebricksException(errorMessage + ": missing T");
+ }
}
- // if extended form 11, else 9
- timeOffset += (charAccessor.getCharAt(timeOffset + 13) == ':') ? (short) (11)
- : (short) (9);
- long intervalStart = ADateParserFactory.parseDatePart(charAccessor, false);
- charAccessor.reset(argOut0.getByteArray(), 3 + timeOffset, stringLength - timeOffset);
- intervalStart += ATimeParserFactory.parseTimePart(charAccessor);
+ long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+ timeOffset);
+ intervalStart += ATimeParserFactory.parseTimePart(argOut0.getByteArray(),
+ 3 + timeOffset + 1, stringLength - timeOffset - 1);
- // end date
-
+ // end datetime
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
// get offset for time part: +1 if it is negative (-)
- timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
-
- if (charAccessor.getCharAt(timeOffset + 10) != 'T'
- && charAccessor.getCharAt(timeOffset + 8) != 'T') {
- throw new AlgebricksException(errorMessage + ": missing T");
+ timeOffset = (short) ((argOut1.getByteArray()[3] == '-') ? 1 : 0);
+ timeOffset += 8;
+ if (argOut1.getByteArray()[3 + timeOffset] != 'T') {
+ timeOffset += 2;
+ if (argOut1.getByteArray()[3 + timeOffset] != 'T') {
+ throw new AlgebricksException(errorMessage + ": missing T");
+ }
}
- // if extended form 11, else 9
- timeOffset += (charAccessor.getCharAt(timeOffset + 13) == ':') ? (short) (11)
- : (short) (9);
- long intervalEnd = ADateParserFactory.parseDatePart(charAccessor, false);
- charAccessor.reset(argOut1.getByteArray(), 3 + timeOffset, stringLength - timeOffset);
- intervalEnd += ATimeParserFactory.parseTimePart(charAccessor);
+ long intervalEnd = ADateParserFactory.parseDatePart(argOut1.getByteArray(), 3,
+ timeOffset);
+ intervalEnd += ATimeParserFactory.parseTimePart(argOut1.getByteArray(),
+ 3 + timeOffset + 1, stringLength - timeOffset - 1);
if (intervalEnd < intervalStart) {
throw new AlgebricksException(
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
index 3ce722a..042a33b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
@@ -23,7 +23,6 @@
import edu.uci.ics.asterix.om.base.AMutableInterval;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -78,8 +77,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -96,23 +93,21 @@
} else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG
&& argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// start date
-
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
- long intervalStart = ATimeParserFactory.parseTimePart(charAccessor);
+ long intervalStart = ATimeParserFactory.parseTimePart(argOut0.getByteArray(), 3,
+ stringLength);
if (intervalStart < 0) {
intervalStart += GregorianCalendarSystem.CHRONON_OF_DAY;
}
// end date
-
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
- long intervalEnd = ATimeParserFactory.parseTimePart(charAccessor);
+ long intervalEnd = ATimeParserFactory.parseTimePart(argOut1.getByteArray(), 3,
+ stringLength);
if (intervalEnd < 0) {
intervalEnd += GregorianCalendarSystem.CHRONON_OF_DAY;
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
index 23fdb07..d5a0db9 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
@@ -25,7 +25,6 @@
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -82,8 +81,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -99,20 +96,20 @@
nullSerde.serialize(ANull.NULL, out);
} else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG
&& argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
- // start date
+ // start date
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
- long intervalStart = ADateParserFactory.parseDatePart(charAccessor, true);
- // duration
+ long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+ stringLength);
+ // duration
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
- ADurationParserFactory.parseDuration(charAccessor, aDuration);
+ ADurationParserFactory
+ .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
long intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
aDuration.getMonths(), aDuration.getMilliseconds());
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
index 91c45df..d821fc3 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
@@ -26,7 +26,6 @@
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -82,8 +81,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -104,29 +101,29 @@
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
// get offset for time part: +1 if it is negative (-)
- short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+ short timeOffset = (short) ((argOut0.getByteArray()[3] == '-') ? 1 : 0);
- if (charAccessor.getCharAt(timeOffset + 10) != 'T'
- && charAccessor.getCharAt(timeOffset + 8) != 'T') {
- throw new AlgebricksException(errorMessage + ": missing T");
+ timeOffset += 8;
+
+ if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
+ timeOffset += 2;
+ if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
+ throw new AlgebricksException(errorMessage + ": missing T");
+ }
}
- // if extended form 11, else 9
- timeOffset += (charAccessor.getCharAt(timeOffset + 13) == ':') ? (short) (11)
- : (short) (9);
- long intervalStart = ADateParserFactory.parseDatePart(charAccessor, false);
- charAccessor.reset(argOut0.getByteArray(), 3 + timeOffset, stringLength - timeOffset);
- intervalStart += ATimeParserFactory.parseTimePart(charAccessor);
+ long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+ timeOffset);
+ intervalStart += ATimeParserFactory.parseTimePart(argOut0.getByteArray(),
+ 3 + timeOffset + 1, stringLength - timeOffset - 1);
// duration
-
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
- ADurationParserFactory.parseDuration(charAccessor, aDuration);
+ ADurationParserFactory
+ .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
long intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
aDuration.getMonths(), aDuration.getMilliseconds());
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
index e576fef..8135598 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
@@ -25,7 +25,6 @@
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -82,8 +81,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -104,8 +101,8 @@
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
- int intervalStart = ATimeParserFactory.parseTimePart(charAccessor);
+ int intervalStart = ATimeParserFactory.parseTimePart(argOut0.getByteArray(), 3,
+ stringLength);
if (intervalStart < 0) {
intervalStart += GregorianCalendarSystem.CHRONON_OF_DAY;
@@ -116,8 +113,8 @@
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
- ADurationParserFactory.parseDuration(charAccessor, aDuration);
+ ADurationParserFactory
+ .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
if (aDuration.getMonths() != 0) {
throw new AlgebricksException("Cannot add a year-month duration to a time value.");
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
index caff78b..f2ad400 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
@@ -22,7 +22,6 @@
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.ATime;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -73,8 +72,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -86,8 +83,7 @@
int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
- charAccessor.reset(serString, 3, stringLength);
- int chrononTimeInMs = ATimeParserFactory.parseTimePart(charAccessor);
+ int chrononTimeInMs = ATimeParserFactory.parseTimePart(serString, 3, stringLength);
if (chrononTimeInMs < 0) {
chrononTimeInMs += GregorianCalendarSystem.CHRONON_OF_DAY;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CodePointToStringDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CodePointToStringDescriptor.java
index 5dcb838..55fe563 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CodePointToStringDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CodePointToStringDescriptor.java
@@ -93,9 +93,6 @@
private ICopyEvaluatorFactory listEvalFactory = args[0];
private ArrayBackedValueStorage outInputList = new ArrayBackedValueStorage();
private ICopyEvaluator evalList = listEvalFactory.createEvaluator(outInputList);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -103,10 +100,6 @@
outInputList.reset();
evalList.evaluate(tuple);
byte[] serOrderedList = outInputList.getByteArray();
- if (serOrderedList[0] == SER_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- return;
- }
if (serOrderedList[0] != SER_ORDEREDLIST_TYPE_TAG) {
throw new AlgebricksException("Expects an Integer List."
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serOrderedList[0]));
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericRoundHalfToEven2Descriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericRoundHalfToEven2Descriptor.java
index 06cf69a..e205bf5 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericRoundHalfToEven2Descriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericRoundHalfToEven2Descriptor.java
@@ -98,13 +98,10 @@
return (int) AInt32SerializerDeserializer.getInt(argOut.getByteArray(), 1);
} else if (argOut.getByteArray()[0] == serInt64TypeTag) {
return (int) AInt64SerializerDeserializer.getLong(argOut.getByteArray(), 1);
- } else if (argOut.getByteArray()[0] == serFloatTypeTag) {
- return (int) AFloatSerializerDeserializer.getFloat(argOut.getByteArray(), 1);
- } else if (argOut.getByteArray()[0] == serDoubleTypeTag) {
- return (int) ADoubleSerializerDeserializer.getDouble(argOut.getByteArray(), 1);
+ } else {
+ throw new AlgebricksException(
+ "The precision argument for round-half-to-even should be an integer.");
}
-
- return 0;
}
@SuppressWarnings("unchecked")
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringConcatDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringConcatDescriptor.java
index f975579..f53ebe8 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringConcatDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringConcatDescriptor.java
@@ -4,7 +4,6 @@
import java.io.IOException;
import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
@@ -67,10 +66,6 @@
} catch (AsterixException e) {
throw new AlgebricksException(e);
}
- if (listAccessor.getItemType() == ATypeTag.NULL) {
- nullSerde.serialize(ANull.NULL, out);
- return;
- }
try {
// calculate length first
int utf8Len = 0;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringJoinDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringJoinDescriptor.java
index c379c3e3..67334ce 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringJoinDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringJoinDescriptor.java
@@ -5,20 +5,16 @@
import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AOrderedListSerializerDeserializer;
-import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.asterix.om.types.EnumDeserializer;
import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
-import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -37,7 +33,6 @@
}
};
private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
- private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
private final static byte SER_ORDEREDLIST_TYPE_TAG = ATypeTag.ORDEREDLIST.serialize();
private final byte stringTypeTag = ATypeTag.STRING.serialize();
@@ -58,9 +53,6 @@
private ArrayBackedValueStorage outInputSep = new ArrayBackedValueStorage();
private ICopyEvaluator evalList = listEvalFactory.createEvaluator(outInputList);
private ICopyEvaluator evalSep = sepEvalFactory.createEvaluator(outInputSep);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -72,20 +64,14 @@
outInputSep.reset();
evalSep.evaluate(tuple);
byte[] serSep = outInputSep.getByteArray();
- if (serOrderedList[0] == SER_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- return;
- }
if (serOrderedList[0] != SER_ORDEREDLIST_TYPE_TAG) {
- throw new AlgebricksException("Expects String List."
+ throw new AlgebricksException("Expects String List but got "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serOrderedList[0]));
}
- if (serSep[0] == SER_NULL_TYPE_TAG) {
- }
if (serSep[0] != SER_STRING_TYPE_TAG) {
- throw new AlgebricksException("Expects String as Seperator."
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serOrderedList[0]));
+ throw new AlgebricksException("Expects String as Seperator but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serSep[0]));
}
int size = AOrderedListSerializerDeserializer.getNumberOfItems(serOrderedList);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringToCodePointDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringToCodePointDescriptor.java
index fdd45e2..3d845e1 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringToCodePointDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringToCodePointDescriptor.java
@@ -7,7 +7,6 @@
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.AInt32;
import edu.uci.ics.asterix.om.base.AMutableInt32;
-import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -43,7 +42,6 @@
}
};
private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
- private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
@Override
public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) {
@@ -62,9 +60,6 @@
private ArrayBackedValueStorage inputVal = new ArrayBackedValueStorage();
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
private final ISerializerDeserializer<AInt32> int32Serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT32);
private final AMutableInt32 aInt32 = new AMutableInt32(0);
@@ -123,9 +118,7 @@
}
listBuilder.write(out, true);
- } else if (serString[0] == SER_NULL_TYPE_TAG)
- nullSerde.serialize(ANull.NULL, out);
- else
+ } else
throw new AlgebricksException("Expects String Type.");
} catch (IOException e1) {
throw new AlgebricksException(e1.getMessage());
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
index fb01e97..21d098a 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
@@ -21,7 +21,6 @@
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem.Fields;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -81,8 +80,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance();
@Override
@@ -111,12 +108,7 @@
+ argOut1.getByteArray()[0]);
}
- int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
- + (argOut1.getByteArray()[2] & 0xff << 0);
-
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
-
- int timezone = ATimeParserFactory.parseTimezonePart(charAccessor, 0);
+ int timezone = ATimeParserFactory.parseTimezonePart(argOut1.getByteArray(), 3);
if (!calInstance.validateTimeZone(timezone)) {
throw new AlgebricksException("Wrong format for a time zone string!");
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
index 1323664..1f8842e 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
@@ -21,7 +21,6 @@
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem.Fields;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -81,8 +80,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance();
@Override
@@ -111,12 +108,7 @@
+ argOut1.getByteArray()[0]);
}
- int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
- + (argOut0.getByteArray()[2] & 0xff << 0);
-
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
-
- int timezone = ATimeParserFactory.parseTimezonePart(charAccessor, 0);
+ int timezone = ATimeParserFactory.parseTimezonePart(argOut1.getByteArray(), 3);
if (!calInstance.validateTimeZone(timezone)) {
throw new AlgebricksException("Wrong format for a time zone string!");
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
index c6be030..cbd600f 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
@@ -186,9 +186,9 @@
}
if (day < 0) {
- boolean isLeapYear = calInstanct.isLeapYear(year0);
- day += (isLeapYear) ? (GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[month0 - 1])
- : (GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[month0 - 1]);
+ boolean isLeapYear = calInstanct.isLeapYear(year1);
+ day += (isLeapYear) ? (GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[month1 - 2])
+ : (GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[month1 - 2]);
month -= 1;
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
index 2c7a9a7..8df3c7f 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
@@ -124,13 +124,13 @@
if (argOut0.getByteArray()[0] != SER_DATETIME_TYPE_TAG) {
throw new AlgebricksException(
- "Inapplicable input type for parameter 0: expecting ADateTime, but got: "
+ "Inapplicable input type for parameter 0: expecting Datetime, but got: "
+ argOut0.getByteArray()[0]);
}
if (argOut1.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
throw new AlgebricksException(
- "Inapplicable input type for parameter 1: expecting ADateTime, but got: "
+ "Inapplicable input type for parameter 1: expecting Duration, but got: "
+ argOut1.getByteArray()[0]);
}
@@ -202,9 +202,9 @@
}
if (day < 0) {
- boolean isLeapYear = calInstanct.isLeapYear(year0);
- day += (isLeapYear) ? (GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[month0 - 1])
- : (GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[month0 - 1]);
+ boolean isLeapYear = calInstanct.isLeapYear(year1);
+ day += (isLeapYear) ? (GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[month1 - 2])
+ : (GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[month1 - 2]);
month -= 1;
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
index 2e64ad4..b32110b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
@@ -234,7 +234,7 @@
try {
if (checkType(ATypeTag.INTERVAL, objectType, out)) {
if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
- if (admLexer.next() == AdmLexer.TOKEN_STRING_CONS) {
+ if (admLexer.next() == AdmLexer.TOKEN_STRING_LITERAL) {
AIntervalSerializerDeserializer.parseDate(admLexer.getLastTokenImage(), out);
if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
@@ -252,7 +252,7 @@
try {
if (checkType(ATypeTag.INTERVAL, objectType, out)) {
if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
- if (admLexer.next() == AdmLexer.TOKEN_STRING_CONS) {
+ if (admLexer.next() == AdmLexer.TOKEN_STRING_LITERAL) {
AIntervalSerializerDeserializer.parseTime(admLexer.getLastTokenImage(), out);
if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
@@ -270,7 +270,7 @@
try {
if (checkType(ATypeTag.INTERVAL, objectType, out)) {
if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
- if (admLexer.next() == AdmLexer.TOKEN_STRING_CONS) {
+ if (admLexer.next() == AdmLexer.TOKEN_STRING_LITERAL) {
AIntervalSerializerDeserializer.parseDatetime(admLexer.getLastTokenImage(), out);
if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
diff --git a/asterix-runtime/src/main/resources/adm.grammar b/asterix-runtime/src/main/resources/adm.grammar
index 56c7212..4d4158f 100644
--- a/asterix-runtime/src/main/resources/adm.grammar
+++ b/asterix-runtime/src/main/resources/adm.grammar
@@ -26,9 +26,9 @@
RECTANGLE_CONS = string(rectangle)
CIRCLE_CONS = string(circle)
TIME_CONS = string(time)
-INTERVAL_TIME_CONS = string(interval_time)
-INTERVAL_DATE_CONS = string(interval_date)
-INTERVAL_DATETIME_CONS = string(interval_datetime)
+INTERVAL_TIME_CONS = string(interval-time)
+INTERVAL_DATE_CONS = string(interval-date)
+INTERVAL_DATETIME_CONS = string(interval-datetime)
NULL_LITERAL = string(null)
TRUE_LITERAL = string(true)
diff --git a/asterix-server/pom.xml b/asterix-server/pom.xml
new file mode 100644
index 0000000..e4b8aa6
--- /dev/null
+++ b/asterix-server/pom.xml
@@ -0,0 +1,86 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>asterix-server</artifactId>
+ <name>asterix-server</name>
+ <parent>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix</artifactId>
+ <version>0.0.4-SNAPSHOT</version>
+ </parent>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>appassembler-maven-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <configuration>
+ <programs>
+ <program>
+ <mainClass>edu.uci.ics.hyracks.control.cc.CCDriver</mainClass>
+ <name>asterixcc</name>
+ <commandLineArguments>
+ <commandLineArgument>-app-cc-main-class</commandLineArgument>
+ <commandLineArgument>edu.uci.ics.asterix.hyracks.bootstrap.CCApplicationEntryPoint</commandLineArgument>
+ </commandLineArguments>
+ </program>
+ <program>
+ <mainClass>edu.uci.ics.hyracks.control.nc.NCDriver</mainClass>
+ <name>asterixnc</name>
+ <commandLineArguments>
+ <commandLineArgument>-app-nc-main-class</commandLineArgument>
+ <commandLineArgument>edu.uci.ics.asterix.hyracks.bootstrap.NCApplicationEntryPoint</commandLineArgument>
+ </commandLineArguments>
+ </program>
+ </programs>
+ <repositoryLayout>flat</repositoryLayout>
+ <repositoryName>lib</repositoryName>
+ </configuration>
+ <phase>package</phase>
+ <goals>
+ <goal>assemble</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-5</version>
+ <executions>
+ <execution>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/binary-assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>edu.uci.ics.hyracks</groupId>
+ <artifactId>hyracks-control-cc</artifactId>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.hyracks</groupId>
+ <artifactId>hyracks-control-nc</artifactId>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-app</artifactId>
+ <version>0.0.4-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/asterix-server/src/main/assembly/binary-assembly.xml b/asterix-server/src/main/assembly/binary-assembly.xml
new file mode 100644
index 0000000..cd598d9
--- /dev/null
+++ b/asterix-server/src/main/assembly/binary-assembly.xml
@@ -0,0 +1,23 @@
+<assembly>
+ <id>binary-assembly</id>
+ <formats>
+ <format>zip</format>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>target/appassembler/bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>target/appassembler/lib</directory>
+ <outputDirectory>lib</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>docs</directory>
+ <outputDirectory>docs</outputDirectory>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
index e2f26b2..8aae6b1 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
@@ -116,8 +116,8 @@
} catch (FileNotFoundException e) {
//This is initial bootstrap.
//Otherwise, the checkpoint file is deleted unfortunately. What we can do in this case?
- state = SystemState.CORRUPTED;
- new ACIDException("Checkpoint file doesn't exist", e);
+ state = SystemState.HEALTHY;
+ return state;
}
//#. if minMCTFirstLSN is equal to -1 &&
diff --git a/pom.xml b/pom.xml
index 6c26ae1..6ae70d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,9 +81,11 @@
<module>asterix-aql</module>
<module>asterix-external-data</module>
<module>asterix-metadata</module>
- <module>asterix-dist</module>
<module>asterix-test-framework</module>
- <module>asterix-maven-plugins</module>
+ <module>asterix-maven-plugins</module>
+ <module>asterix-server</module>
+ <module>asterix-installer</module>
+ <module>asterix-events</module>
</modules>
<repositories>