merge from asterix_lsm_stabilization
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
index caa16d4..0f01466 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
@@ -72,6 +72,7 @@
import edu.uci.ics.asterix.aql.expression.WriteStatement;
import edu.uci.ics.asterix.aql.expression.visitor.IAqlExpressionVisitor;
import edu.uci.ics.asterix.aql.util.FunctionUtils;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.common.functions.FunctionConstants;
@@ -79,7 +80,6 @@
import edu.uci.ics.asterix.formats.base.IDataFormat;
import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.metadata.MetadataManager;
-import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
import edu.uci.ics.asterix.metadata.declared.AqlDataSource;
import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
import edu.uci.ics.asterix.metadata.declared.AqlSourceId;
@@ -185,7 +185,6 @@
new EmptyTupleSourceOperator()));
ArrayList<Mutable<ILogicalOperator>> globalPlanRoots = new ArrayList<Mutable<ILogicalOperator>>();
- boolean isTransactionalWrite = false;
ILogicalOperator topOp = p.first;
ProjectOperator project = (ProjectOperator) topOp;
LogicalVariable resVar = project.getVariables().get(0);
@@ -244,7 +243,6 @@
insertOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
leafOperator = new SinkOperator();
leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(insertOp));
- isTransactionalWrite = true;
break;
}
case DELETE: {
@@ -253,7 +251,6 @@
deleteOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
leafOperator = new SinkOperator();
leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(deleteOp));
- isTransactionalWrite = true;
break;
}
case BEGIN_FEED: {
@@ -262,7 +259,6 @@
insertOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
leafOperator = new SinkOperator();
leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(insertOp));
- isTransactionalWrite = false;
break;
}
}
@@ -291,12 +287,9 @@
}
private FileSplit getDefaultOutputFileLocation() throws MetadataException {
- if (AsterixProperties.INSTANCE.getOutputDir() == null) {
- throw new MetadataException(
- "Output location for query result not specified at the time of deployment, must specify explicitly using 'write output to ..' statement");
- }
- String filePath = AsterixProperties.INSTANCE.getOutputDir() + System.getProperty("file.separator")
- + OUTPUT_FILE_PREFIX + outputFileID.incrementAndGet();
+ String outputDir = System.getProperty("java.io.tmpDir");
+ String filePath = outputDir + System.getProperty("file.separator") + OUTPUT_FILE_PREFIX
+ + outputFileID.incrementAndGet();
return new FileSplit(AsterixProperties.INSTANCE.getMetadataNodeName(), new FileReference(new File(filePath)));
}
diff --git a/asterix-app/pom.xml b/asterix-app/pom.xml
index 2c4cf17..452562e 100644
--- a/asterix-app/pom.xml
+++ b/asterix-app/pom.xml
@@ -175,6 +175,13 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-common</artifactId>
+ <version>0.0.6-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>com.kenai.nbpwr</groupId>
<artifactId>org-apache-commons-io</artifactId>
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 1b7d410..2fc9525 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
@@ -22,6 +22,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.logging.Logger;
import org.json.JSONArray;
import org.json.JSONException;
@@ -59,6 +60,7 @@
import edu.uci.ics.asterix.aql.expression.TypeDropStatement;
import edu.uci.ics.asterix.aql.expression.WriteFromQueryResultStatement;
import edu.uci.ics.asterix.aql.expression.WriteStatement;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
import edu.uci.ics.asterix.common.config.GlobalConfig;
import edu.uci.ics.asterix.common.exceptions.AsterixException;
@@ -130,6 +132,8 @@
private Dataverse activeDefaultDataverse;
private List<FunctionDecl> declaredFunctions;
+ private static Logger LOGGER = Logger.getLogger(AqlTranslator.class.getName());
+
public AqlTranslator(List<Statement> aqlStatements, PrintWriter out, SessionConfig pc, DisplayFormat pdf)
throws MetadataException, AsterixException {
this.aqlStatements = aqlStatements;
@@ -153,12 +157,16 @@
* Compiles and submits for execution a list of AQL statements.
*
* @param hcc
- * A Hyracks client connection that is used to submit a jobspec to Hyracks.
+ * A Hyracks client connection that is used to submit a jobspec
+ * to Hyracks.
* @param hdc
- * A Hyracks dataset client object that is used to read the results.
+ * A Hyracks dataset client object that is used to read the
+ * results.
* @param asyncResults
- * True if the results should be read asynchronously or false if we should wait for results to be read.
- * @return A List<QueryResult> containing a QueryResult instance corresponding to each submitted query.
+ * True if the results should be read asynchronously or false if
+ * we should wait for results to be read.
+ * @return A List<QueryResult> containing a QueryResult instance
+ * corresponding to each submitted query.
* @throws Exception
*/
public List<QueryResult> compileAndExecute(IHyracksClientConnection hcc, IHyracksDataset hdc, boolean asyncResults)
@@ -440,13 +448,13 @@
break;
}
}
-
- //#. initialize DatasetIdFactory if it is not initialized.
+
+ // #. initialize DatasetIdFactory if it is not initialized.
if (!DatasetIdFactory.isInitialized()) {
DatasetIdFactory.initialize(MetadataManager.INSTANCE.getMostRecentDatasetId());
}
- //#. add a new dataset with PendingAddOp
+ // #. add a new dataset with PendingAddOp
dataset = new Dataset(dataverseName, datasetName, itemTypeName, datasetDetails, dd.getHints(), dsType,
DatasetIdFactory.generateDatasetId(), IMetadataEntity.PENDING_ADD_OP);
MetadataManager.INSTANCE.addDataset(metadataProvider.getMetadataTxnContext(), dataset);
@@ -457,20 +465,21 @@
JobSpecification jobSpec = DatasetOperations.createDatasetJobSpec(dataverse, datasetName,
metadataProvider);
- //#. make metadataTxn commit before calling runJob.
+ // #. make metadataTxn commit before calling runJob.
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
bActiveTxn = false;
- //#. runJob
+ // #. runJob
runJob(hcc, jobSpec, true);
- //#. begin new metadataTxn
+ // #. begin new metadataTxn
mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
bActiveTxn = true;
metadataProvider.setMetadataTxnContext(mdTxnCtx);
}
- //#. add a new dataset with PendingNoOp after deleting the dataset with PendingAddOp
+ // #. add a new dataset with PendingNoOp after deleting the dataset
+ // with PendingAddOp
MetadataManager.INSTANCE.dropDataset(metadataProvider.getMetadataTxnContext(), dataverseName, datasetName);
MetadataManager.INSTANCE.addDataset(metadataProvider.getMetadataTxnContext(), new Dataset(dataverseName,
datasetName, itemTypeName, datasetDetails, dd.getHints(), dsType, dataset.getDatasetId(),
@@ -482,8 +491,8 @@
}
if (dataset != null) {
- //#. execute compensation operations
- // remove the index in NC
+ // #. execute compensation operations
+ // remove the index in NC
mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
bActiveTxn = true;
metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -498,10 +507,11 @@
if (bActiveTxn) {
MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
}
- //do no throw exception since still the metadata needs to be compensated.
+ // do no throw exception since still the metadata needs to
+ // be compensated.
}
- // remove the record from the metadata.
+ // remove the record from the metadata.
mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
metadataProvider.setMetadataTxnContext(mdTxnCtx);
try {
@@ -569,13 +579,13 @@
}
}
- //#. add a new index with PendingAddOp
+ // #. add a new index with PendingAddOp
Index index = new Index(dataverseName, datasetName, indexName, stmtCreateIndex.getIndexType(),
stmtCreateIndex.getFieldExprs(), stmtCreateIndex.getGramLength(), false,
IMetadataEntity.PENDING_ADD_OP);
MetadataManager.INSTANCE.addIndex(metadataProvider.getMetadataTxnContext(), index);
- //#. create the index artifact in NC.
+ // #. create the index artifact in NC.
CompiledCreateIndexStatement cis = new CompiledCreateIndexStatement(index.getIndexName(), dataverseName,
index.getDatasetName(), index.getKeyFieldNames(), index.getGramLength(), index.getIndexType());
spec = IndexOperations.buildSecondaryIndexCreationJobSpec(cis, metadataProvider);
@@ -592,7 +602,7 @@
bActiveTxn = true;
metadataProvider.setMetadataTxnContext(mdTxnCtx);
- //#. load data into the index in NC.
+ // #. load data into the index in NC.
cis = new CompiledCreateIndexStatement(index.getIndexName(), dataverseName, index.getDatasetName(),
index.getKeyFieldNames(), index.getGramLength(), index.getIndexType());
spec = IndexOperations.buildSecondaryIndexLoadingJobSpec(cis, metadataProvider);
@@ -601,12 +611,13 @@
runJob(hcc, spec, true);
- //#. begin new metadataTxn
+ // #. begin new metadataTxn
mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
bActiveTxn = true;
metadataProvider.setMetadataTxnContext(mdTxnCtx);
- //#. add another new index with PendingNoOp after deleting the index with PendingAddOp
+ // #. add another new index with PendingNoOp after deleting the
+ // index with PendingAddOp
MetadataManager.INSTANCE.dropIndex(metadataProvider.getMetadataTxnContext(), dataverseName, datasetName,
indexName);
index = new Index(dataverseName, datasetName, indexName, stmtCreateIndex.getIndexType(),
@@ -621,8 +632,8 @@
}
if (spec != null) {
- //#. execute compensation operations
- // remove the index in NC
+ // #. execute compensation operations
+ // remove the index in NC
mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
bActiveTxn = true;
metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -637,10 +648,11 @@
if (bActiveTxn) {
MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
}
- //do no throw exception since still the metadata needs to be compensated.
+ // do no throw exception since still the metadata needs to
+ // be compensated.
}
- // remove the record from the metadata.
+ // remove the record from the metadata.
mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
metadataProvider.setMetadataTxnContext(mdTxnCtx);
try {
@@ -725,7 +737,8 @@
return;
}
- //#. prepare jobs which will drop corresponding datasets with indexes.
+ // #. prepare jobs which will drop corresponding datasets with
+ // indexes.
List<Dataset> datasets = MetadataManager.INSTANCE.getDataverseDatasets(mdTxnCtx, dvName);
for (int j = 0; j < datasets.size(); j++) {
String datasetName = datasets.get(j).getDatasetName();
@@ -746,9 +759,10 @@
}
}
- //#. mark PendingDropOp on the dataverse record by
- // first, deleting the dataverse record from the DATAVERSE_DATASET
- // second, inserting the dataverse record with the PendingDropOp value into the DATAVERSE_DATASET
+ // #. mark PendingDropOp on the dataverse record by
+ // first, deleting the dataverse record from the DATAVERSE_DATASET
+ // second, inserting the dataverse record with the PendingDropOp
+ // value into the DATAVERSE_DATASET
MetadataManager.INSTANCE.dropDataverse(mdTxnCtx, dvName);
MetadataManager.INSTANCE.addDataverse(mdTxnCtx, new Dataverse(dvName, dv.getDataFormat(),
IMetadataEntity.PENDING_DROP_OP));
@@ -764,7 +778,7 @@
bActiveTxn = true;
metadataProvider.setMetadataTxnContext(mdTxnCtx);
- //#. finally, delete the dataverse.
+ // #. finally, delete the dataverse.
MetadataManager.INSTANCE.dropDataverse(mdTxnCtx, dvName);
if (activeDefaultDataverse != null && activeDefaultDataverse.getDataverseName() == dvName) {
activeDefaultDataverse = null;
@@ -776,13 +790,13 @@
MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
}
- //#. execute compensation operations
- // remove the all indexes in NC
+ // #. execute compensation operations
+ // remove the all indexes in NC
for (JobSpecification jobSpec : jobsToExecute) {
runJob(hcc, jobSpec, true);
}
- // remove the record from the metadata.
+ // remove the record from the metadata.
mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
metadataProvider.setMetadataTxnContext(mdTxnCtx);
try {
@@ -831,7 +845,7 @@
if (ds.getDatasetType() == DatasetType.INTERNAL || ds.getDatasetType() == DatasetType.FEED) {
- //#. prepare jobs to drop the datatset and the indexes in NC
+ // #. prepare jobs to drop the datatset and the indexes in NC
List<Index> indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dataverseName, datasetName);
for (int j = 0; j < indexes.size(); j++) {
if (indexes.get(j).isSecondaryIndex()) {
@@ -843,7 +857,7 @@
CompiledDatasetDropStatement cds = new CompiledDatasetDropStatement(dataverseName, datasetName);
jobsToExecute.add(DatasetOperations.createDropDatasetJobSpec(cds, metadataProvider));
- //#. mark the existing dataset as PendingDropOp
+ // #. mark the existing dataset as PendingDropOp
MetadataManager.INSTANCE.dropDataset(mdTxnCtx, dataverseName, datasetName);
MetadataManager.INSTANCE.addDataset(
mdTxnCtx,
@@ -853,7 +867,7 @@
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
bActiveTxn = false;
- //#. run the jobs
+ // #. run the jobs
for (JobSpecification jobSpec : jobsToExecute) {
runJob(hcc, jobSpec, true);
}
@@ -863,7 +877,7 @@
metadataProvider.setMetadataTxnContext(mdTxnCtx);
}
- //#. finally, delete the dataset.
+ // #. finally, delete the dataset.
MetadataManager.INSTANCE.dropDataset(mdTxnCtx, dataverseName, datasetName);
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
@@ -872,13 +886,13 @@
MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
}
- //#. execute compensation operations
- // remove the all indexes in NC
+ // #. execute compensation operations
+ // remove the all indexes in NC
for (JobSpecification jobSpec : jobsToExecute) {
runJob(hcc, jobSpec, true);
}
- // remove the record from the metadata.
+ // remove the record from the metadata.
mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
metadataProvider.setMetadataTxnContext(mdTxnCtx);
try {
@@ -931,19 +945,19 @@
throw new AlgebricksException("There is no index with this name " + indexName + ".");
}
} else {
- //#. prepare a job to drop the index in NC.
+ // #. prepare a job to drop the index in NC.
CompiledIndexDropStatement cds = new CompiledIndexDropStatement(dataverseName, datasetName,
indexName);
jobsToExecute.add(IndexOperations.buildDropSecondaryIndexJobSpec(cds, metadataProvider));
- //#. mark PendingDropOp on the existing index
+ // #. mark PendingDropOp on the existing index
MetadataManager.INSTANCE.dropIndex(mdTxnCtx, dataverseName, datasetName, indexName);
MetadataManager.INSTANCE.addIndex(
mdTxnCtx,
new Index(dataverseName, datasetName, indexName, index.getIndexType(), index
.getKeyFieldNames(), index.isPrimaryIndex(), IMetadataEntity.PENDING_DROP_OP));
- //#. commit the existing transaction before calling runJob.
+ // #. commit the existing transaction before calling runJob.
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
bActiveTxn = false;
@@ -951,12 +965,12 @@
runJob(hcc, jobSpec, true);
}
- //#. begin a new transaction
+ // #. begin a new transaction
mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
bActiveTxn = true;
metadataProvider.setMetadataTxnContext(mdTxnCtx);
- //#. finally, delete the existing index
+ // #. finally, delete the existing index
MetadataManager.INSTANCE.dropIndex(mdTxnCtx, dataverseName, datasetName, indexName);
}
} else {
@@ -970,13 +984,13 @@
MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
}
- //#. execute compensation operations
- // remove the all indexes in NC
+ // #. execute compensation operations
+ // remove the all indexes in NC
for (JobSpecification jobSpec : jobsToExecute) {
runJob(hcc, jobSpec, true);
}
- // remove the record from the metadata.
+ // remove the record from the metadata.
mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
metadataProvider.setMetadataTxnContext(mdTxnCtx);
try {
@@ -1135,7 +1149,8 @@
if (!index.isSecondaryIndex()) {
continue;
}
- // Create CompiledCreateIndexStatement from metadata entity 'index'.
+ // Create CompiledCreateIndexStatement from metadata entity
+ // 'index'.
CompiledCreateIndexStatement cis = new CompiledCreateIndexStatement(index.getIndexName(),
dataverseName, index.getDatasetName(), index.getKeyFieldNames(), index.getGramLength(),
index.getIndexType());
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
index 5ab94f3..25ef5da 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
@@ -14,10 +14,10 @@
import edu.uci.ics.asterix.api.http.servlet.QueryStatusAPIServlet;
import edu.uci.ics.asterix.api.http.servlet.UpdateAPIServlet;
import edu.uci.ics.asterix.common.api.AsterixAppContextInfoImpl;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
import edu.uci.ics.asterix.common.config.GlobalConfig;
import edu.uci.ics.asterix.metadata.MetadataManager;
import edu.uci.ics.asterix.metadata.api.IAsterixStateProxy;
-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.ICCApplicationEntryPoint;
@@ -79,11 +79,8 @@
}
private void setupWebServer() throws Exception {
- String portStr = System.getProperty(GlobalConfig.WEB_SERVER_PORT_PROPERTY);
- int port = DEFAULT_WEB_SERVER_PORT;
- if (portStr != null) {
- port = Integer.parseInt(portStr);
- }
+ int port = Integer.parseInt((String) AsterixProperties.INSTANCE.getProperty(
+ AsterixProperties.AsterixConfigurationKeys.WEB_INTERFACE_PORT, "" + DEFAULT_WEB_SERVER_PORT));
webServer = new Server(port);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
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
index 72c0c24..8ad8c67 100644
--- 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
@@ -47,6 +47,7 @@
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("System is in a state: " + systemState);
}
+
if (systemState != SystemState.NEW_UNIVERSE) {
PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
.getLocalResourceRepository();
@@ -89,6 +90,7 @@
if (systemState == SystemState.NEW_UNIVERSE) {
PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
.getLocalResourceRepository();
+
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("nodeid" + nodeId);
LOGGER.info("proxy" + proxy);
diff --git a/asterix-app/src/main/resources/asterix-configuration.xml b/asterix-app/src/main/resources/asterix-configuration.xml
new file mode 100644
index 0000000..2a52305
--- /dev/null
+++ b/asterix-app/src/main/resources/asterix-configuration.xml
@@ -0,0 +1,16 @@
+<asterixConfiguration xmlns="asterixconf">
+ <metadataNode>nc1</metadataNode>
+ <store>
+ <ncId>nc1</ncId>
+ <storeDirs>nc1data</storeDirs>
+ </store>
+ <store>
+ <ncId>nc2</ncId>
+ <storeDirs>nc2data</storeDirs>
+ </store>
+ <property>
+ <name>log_level</name>
+ <value>SEVERE</value>
+ <description></description>
+ </property>
+</asterixConfiguration>
diff --git a/asterix-app/src/main/resources/asterix-metadata.properties b/asterix-app/src/main/resources/asterix-metadata.properties
deleted file mode 100644
index e9ccc63..0000000
--- a/asterix-app/src/main/resources/asterix-metadata.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-MetadataNode=nc1
-NewUniverse=true
-nc1.stores=/tmp/nc1data/
-nc2.stores=/tmp/nc2data/, /tmp/nc2data1/
\ No newline at end of file
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
index 56259fa..bf21c7f 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
@@ -14,50 +14,29 @@
*/
package edu.uci.ics.asterix.test.metadata;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
-import java.util.logging.Logger;
-import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.io.FileUtils;
-import org.json.JSONObject;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
import edu.uci.ics.asterix.api.common.AsterixHyracksIntegrationUtil;
import edu.uci.ics.asterix.common.config.GlobalConfig;
import edu.uci.ics.asterix.test.aql.TestsUtils;
import edu.uci.ics.asterix.testframework.context.TestCaseContext;
-import edu.uci.ics.asterix.testframework.context.TestFileContext;
-import edu.uci.ics.asterix.testframework.xml.TestCase.CompilationUnit;
/**
* Executes the Metadata tests.
*/
-@RunWith(Parameterized.class)
public class MetadataTest {
- private TestCaseContext tcCtx;
-
- private static final Logger LOGGER = Logger.getLogger(MetadataTest.class.getName());
private static final String PATH_ACTUAL = "mdtest/";
private static final String PATH_BASE = "src/test/resources/metadata/";
- private static final String TEST_CONFIG_FILE_NAME = "test.properties";
+ private static final String TEST_CONFIG_FILE_NAME = "asterix-configuration.xml";
private static final String WEB_SERVER_PORT = "19002";
+ private static List<TestCaseContext> testCaseCollection;
@BeforeClass
public static void setUp() throws Exception {
@@ -72,7 +51,8 @@
}
AsterixHyracksIntegrationUtil.init();
-
+ TestCaseContext.Builder b = new TestCaseContext.Builder();
+ testCaseCollection = b.build(new File(PATH_BASE));
}
@AfterClass
@@ -95,197 +75,10 @@
}
}
- @Parameters
- public static Collection<Object[]> tests() throws Exception {
- Collection<Object[]> testArgs = new ArrayList<Object[]>();
- TestCaseContext.Builder b = new TestCaseContext.Builder();
- for (TestCaseContext ctx : b.build(new File(PATH_BASE))) {
- testArgs.add(new Object[] { ctx });
- }
- return testArgs;
- }
-
- public MetadataTest(TestCaseContext tcCtx) {
- this.tcCtx = tcCtx;
- }
-
- // Method that reads a DDL/Update/Query File
- // and returns the contents as a string
- // This string is later passed to REST API for execution.
- public String readTestFile(File testFile) throws Exception {
- BufferedReader reader = new BufferedReader(new FileReader(testFile));
- String line = null;
- StringBuilder stringBuilder = new StringBuilder();
- String ls = System.getProperty("line.separator");
-
- while ((line = reader.readLine()) != null) {
- stringBuilder.append(line);
- stringBuilder.append(ls);
- }
-
- return stringBuilder.toString();
- }
-
- // To execute DDL and Update statements
- // create type statement
- // create dataset statement
- // create index statement
- // create dataverse statement
- // create function statement
- public void executeDDL(String str) throws Exception {
- final String url = "http://localhost:19101/ddl";
-
- // Create an instance of HttpClient.
- HttpClient client = new HttpClient();
-
- // Create a method instance.
- GetMethod method = new GetMethod(url);
-
- method.setQueryString(new NameValuePair[] { new NameValuePair("ddl", str) });
-
- // Provide custom retry handler is necessary
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
- // Execute the method.
- int statusCode = client.executeMethod(method);
-
- // Read the response body as String.
- String responseBody = method.getResponseBodyAsString();
-
- // Check if the method was executed successfully.
- if (statusCode != HttpStatus.SC_OK) {
- System.err.println("Method failed: " + method.getStatusLine());
- }
- }
-
- // To execute Update statements
- // Insert and Delete statements are executed here
- public void executeUpdate(String str) throws Exception {
- final String url = "http://localhost:19101/update";
-
- // Create an instance of HttpClient.
- HttpClient client = new HttpClient();
-
- // Create a method instance.
- GetMethod method = new GetMethod(url);
-
- method.setQueryString(new NameValuePair[] { new NameValuePair("statements", str) });
-
- // Provide custom retry handler is necessary
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
- // Execute the method.
- int statusCode = client.executeMethod(method);
-
- // Read the response body as String.
- String responseBody = method.getResponseBodyAsString();
-
- // Check if the method was executed successfully.
- if (statusCode != HttpStatus.SC_OK) {
- System.err.println("Method failed: " + method.getStatusLine());
- }
- }
-
- // Executes Query and returns results as JSONArray
- public JSONObject executeQuery(String str) throws Exception {
-
- final String url = "http://localhost:19101/query";
-
- // Create an instance of HttpClient.
- HttpClient client = new HttpClient();
-
- // Create a method instance.
- GetMethod method = new GetMethod(url);
-
- method.setQueryString(new NameValuePair[] { new NameValuePair("query", str) });
-
- // Provide custom retry handler is necessary
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
- JSONObject result = null;
-
- try {
- // Execute the method.
- int statusCode = client.executeMethod(method);
-
- // Check if the method was executed successfully.
- if (statusCode != HttpStatus.SC_OK) {
- System.err.println("Method failed: " + method.getStatusLine());
- }
-
- // Read the response body as String.
- String responseBody = method.getResponseBodyAsString();
-
- result = new JSONObject(responseBody);
- } catch (Exception e) {
- System.out.println(e.getMessage());
- e.printStackTrace();
- }
- return result;
- }
-
@Test
public void test() throws Exception {
- List<TestFileContext> testFileCtxs;
- List<TestFileContext> expectedResultFileCtxs;
-
- File testFile;
- File expectedResultFile;
- String statement;
-
- int queryCount = 0;
- JSONObject result;
-
- List<CompilationUnit> cUnits = tcCtx.getTestCase().getCompilationUnit();
- for (CompilationUnit cUnit : cUnits) {
- testFileCtxs = tcCtx.getTestFiles(cUnit);
- expectedResultFileCtxs = tcCtx.getExpectedResultFiles(cUnit);
-
- for (TestFileContext ctx : testFileCtxs) {
- testFile = ctx.getFile();
- statement = readTestFile(testFile);
- try {
- switch (ctx.getType()) {
- case "ddl":
- executeDDL(statement);
- break;
- case "update":
- executeUpdate(statement);
- break;
- case "query":
- result = executeQuery(statement);
- if (!cUnit.getExpectedError().isEmpty()) {
- if (!result.has("error")) {
- throw new Exception("Test \"" + testFile + "\" FAILED!");
- }
- } else {
- expectedResultFile = expectedResultFileCtxs.get(queryCount).getFile();
-
- File actualFile = new File(PATH_ACTUAL + File.separator
- + tcCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
- + cUnit.getName() + ".adm");
-
- File actualResultFile = tcCtx.getActualResultFile(cUnit, new File(PATH_ACTUAL));
- actualResultFile.getParentFile().mkdirs();
-
- TestsUtils.writeResultsToFile(actualFile, result);
-
- TestsUtils.runScriptAndCompareWithResult(testFile, new PrintWriter(System.err),
- expectedResultFile, actualFile);
- }
- queryCount++;
- break;
- default:
- throw new IllegalArgumentException("No statements of type " + ctx.getType());
- }
- } catch (Exception e) {
- LOGGER.severe("Test \"" + testFile + "\" FAILED!");
- e.printStackTrace();
- if (cUnit.getExpectedError().isEmpty()) {
- throw new Exception("Test \"" + testFile + "\" FAILED!", e);
- }
- }
- }
+ for (TestCaseContext testCaseCtx : testCaseCollection) {
+ TestsUtils.executeTest(PATH_ACTUAL, testCaseCtx);
}
}
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
index 8530ba1..b559079 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
@@ -47,7 +47,7 @@
private static final ArrayList<String> ignore = AsterixTestHelper.readFile(FILENAME_IGNORE, PATH_BASE);
private static final ArrayList<String> only = AsterixTestHelper.readFile(FILENAME_ONLY, PATH_BASE);
- private static final String TEST_CONFIG_FILE_NAME = "asterix-metadata.properties";
+ private static final String TEST_CONFIG_FILE_NAME = "asterix-configuration.xml";
@BeforeClass
public static void setUp() throws Exception {
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
index 85bf257..0ed5193 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
@@ -1,28 +1,14 @@
package edu.uci.ics.asterix.test.runtime;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
-import java.util.logging.Logger;
-import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.io.FileUtils;
-import org.json.JSONObject;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
import edu.uci.ics.asterix.api.common.AsterixHyracksIntegrationUtil;
import edu.uci.ics.asterix.common.config.GlobalConfig;
@@ -30,259 +16,75 @@
import edu.uci.ics.asterix.external.util.IdentitiyResolverFactory;
import edu.uci.ics.asterix.test.aql.TestsUtils;
import edu.uci.ics.asterix.testframework.context.TestCaseContext;
-import edu.uci.ics.asterix.testframework.context.TestFileContext;
-import edu.uci.ics.asterix.testframework.xml.TestCase.CompilationUnit;
/**
* Runs the runtime test cases under 'asterix-app/src/test/resources/runtimets'.
*/
-@RunWith(Parameterized.class)
+//@RunWith(Parameterized.class)
public class ExecutionTest {
- private static final String PATH_ACTUAL = "rttest/";
- private static final String PATH_BASE = "src/test/resources/runtimets/";
+ private static final String PATH_ACTUAL = "rttest/";
+ private static final String PATH_BASE = "src/test/resources/runtimets/";
- private static final String TEST_CONFIG_FILE_NAME = "test.properties";
- private static final String[] ASTERIX_DATA_DIRS = new String[] { "nc1data", "nc2data" };
+ private static final String TEST_CONFIG_FILE_NAME = "asterix-configuration.xml";
+ private static final String[] ASTERIX_DATA_DIRS = new String[] { "nc1data",
+ "nc2data" };
- private static final Logger LOGGER = Logger.getLogger(ExecutionTest.class.getName());
+ private static List<TestCaseContext> testCaseCollection;
- // private static NCBootstrapImpl _bootstrap = new NCBootstrapImpl();
+ @BeforeClass
+ public static void setUp() throws Exception {
+ System.setProperty(GlobalConfig.CONFIG_FILE_PROPERTY,
+ TEST_CONFIG_FILE_NAME);
+ System.setProperty(GlobalConfig.WEB_SERVER_PORT_PROPERTY, "19002");
+ File outdir = new File(PATH_ACTUAL);
+ outdir.mkdirs();
- @BeforeClass
- public static void setUp() throws Exception {
- System.setProperty(GlobalConfig.CONFIG_FILE_PROPERTY, TEST_CONFIG_FILE_NAME);
- System.setProperty(GlobalConfig.WEB_SERVER_PORT_PROPERTY, "19002");
- File outdir = new File(PATH_ACTUAL);
- outdir.mkdirs();
+ File log = new File("asterix_logs");
+ if (log.exists()) {
+ FileUtils.deleteDirectory(log);
+ }
- File log = new File("asterix_logs");
- if (log.exists()) {
- FileUtils.deleteDirectory(log);
- }
+ AsterixHyracksIntegrationUtil.init();
- AsterixHyracksIntegrationUtil.init();
+ // TODO: Uncomment when hadoop version is upgraded and adapters are
+ // ported.
+ HDFSCluster.getInstance().setup();
- // TODO: Uncomment when hadoop version is upgraded and adapters are
- // ported.
- HDFSCluster.getInstance().setup();
+ // Set the node resolver to be the identity resolver that expects node
+ // names
+ // to be node controller ids; a valid assumption in test environment.
+ System.setProperty(
+ FileSystemBasedAdapter.NODE_RESOLVER_FACTORY_PROPERTY,
+ IdentitiyResolverFactory.class.getName());
+ TestCaseContext.Builder b = new TestCaseContext.Builder();
+ testCaseCollection = b.build(new File(PATH_BASE));
+ }
- // Set the node resolver to be the identity resolver that expects node names
- // to be node controller ids; a valid assumption in test environment.
- System.setProperty(FileSystemBasedAdapter.NODE_RESOLVER_FACTORY_PROPERTY,
- IdentitiyResolverFactory.class.getName());
- }
+ @AfterClass
+ public static void tearDown() throws Exception {
+ AsterixHyracksIntegrationUtil.deinit();
+ File outdir = new File(PATH_ACTUAL);
+ File[] files = outdir.listFiles();
+ if (files == null || files.length == 0) {
+ outdir.delete();
+ }
+ // clean up the files written by the ASTERIX storage manager
+ for (String d : ASTERIX_DATA_DIRS) {
+ TestsUtils.deleteRec(new File(d));
+ }
- @AfterClass
- public static void tearDown() throws Exception {
- AsterixHyracksIntegrationUtil.deinit();
- File outdir = new File(PATH_ACTUAL);
- File[] files = outdir.listFiles();
- if (files == null || files.length == 0) {
- outdir.delete();
- }
- // clean up the files written by the ASTERIX storage manager
- for (String d : ASTERIX_DATA_DIRS) {
- TestsUtils.deleteRec(new File(d));
- }
+ File log = new File("asterix_logs");
+ if (log.exists()) {
+ FileUtils.deleteDirectory(log);
+ }
+ HDFSCluster.getInstance().cleanup();
+ }
- File log = new File("asterix_logs");
- if (log.exists()) {
- FileUtils.deleteDirectory(log);
- }
- HDFSCluster.getInstance().cleanup();
- }
+ @Test
+ public void test() throws Exception {
+ for (TestCaseContext testCaseCtx : testCaseCollection) {
+ TestsUtils.executeTest(PATH_ACTUAL, testCaseCtx);
+ }
- @Parameters
- public static Collection<Object[]> tests() throws Exception {
- Collection<Object[]> testArgs = new ArrayList<Object[]>();
- TestCaseContext.Builder b = new TestCaseContext.Builder();
- for (TestCaseContext ctx : b.build(new File(PATH_BASE))) {
- testArgs.add(new Object[] { ctx });
- }
- return testArgs;
- }
-
- private TestCaseContext tcCtx;
-
- public ExecutionTest(TestCaseContext tcCtx) {
- this.tcCtx = tcCtx;
- }
-
- // Method that reads a DDL/Update/Query File
- // and returns the contents as a string
- // This string is later passed to REST API for execution.
- public String readTestFile(File testFile) throws Exception {
- BufferedReader reader = new BufferedReader(new FileReader(testFile));
- String line = null;
- StringBuilder stringBuilder = new StringBuilder();
- String ls = System.getProperty("line.separator");
-
- while ((line = reader.readLine()) != null) {
- stringBuilder.append(line);
- stringBuilder.append(ls);
- }
-
- return stringBuilder.toString();
- }
-
- // To execute DDL and Update statements
- // create type statement
- // create dataset statement
- // create index statement
- // create dataverse statement
- // create function statement
- public void executeDDL(String str) throws Exception {
- final String url = "http://localhost:19101/ddl";
-
- // Create an instance of HttpClient.
- HttpClient client = new HttpClient();
-
- // Create a method instance.
- GetMethod method = new GetMethod(url);
-
- method.setQueryString(new NameValuePair[] { new NameValuePair("ddl", str) });
-
- // Provide custom retry handler is necessary
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
- // Execute the method.
- int statusCode = client.executeMethod(method);
-
- LOGGER.info("DDL: " + method.getResponseBodyAsString());
-
- // Check if the method was executed successfully.
- if (statusCode != HttpStatus.SC_OK) {
- System.err.println("Method failed: " + method.getStatusLine());
- }
- }
-
- // To execute Update statements
- // Insert and Delete statements are executed here
- public void executeUpdate(String str) throws Exception {
- final String url = "http://localhost:19101/update";
-
- // Create an instance of HttpClient.
- HttpClient client = new HttpClient();
-
- // Create a method instance.
- GetMethod method = new GetMethod(url);
-
- method.setQueryString(new NameValuePair[] { new NameValuePair("statements", str) });
-
- // Provide custom retry handler is necessary
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
- // Execute the method.
- int statusCode = client.executeMethod(method);
-
- LOGGER.info("Update: " + method.getResponseBodyAsString());
-
- // Check if the method was executed successfully.
- if (statusCode != HttpStatus.SC_OK) {
- System.err.println("Method failed: " + method.getStatusLine());
- }
- }
-
- // Executes Query and returns results as JSONArray
- public JSONObject executeQuery(String str) throws Exception {
-
- final String url = "http://localhost:19101/query";
-
- // Create an instance of HttpClient.
- HttpClient client = new HttpClient();
-
- // Create a method instance.
- GetMethod method = new GetMethod(url);
-
- method.setQueryString(new NameValuePair[] { new NameValuePair("query", str) });
-
- // Provide custom retry handler is necessary
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
- JSONObject result = null;
-
- try {
- // Execute the method.
- int statusCode = client.executeMethod(method);
-
- // Check if the method was executed successfully.
- if (statusCode != HttpStatus.SC_OK) {
- System.err.println("Method failed: " + method.getStatusLine());
- }
-
- // Read the response body as String.
- String responseBody = method.getResponseBodyAsString();
-
- result = new JSONObject(responseBody);
- } catch (Exception e) {
- System.out.println(e.getMessage());
- e.printStackTrace();
- }
- return result;
- }
-
- @Test
- public void test() throws Exception {
- List<TestFileContext> testFileCtxs;
- List<TestFileContext> expectedResultFileCtxs;
-
- File testFile;
- File expectedResultFile;
- String statement;
-
- int queryCount = 0;
- JSONObject result;
-
- List<CompilationUnit> cUnits = tcCtx.getTestCase().getCompilationUnit();
- for (CompilationUnit cUnit : cUnits) {
- LOGGER.severe("[TEST]: " + tcCtx.getTestCase().getFilePath() + "/" + cUnit.getName());
-
- testFileCtxs = tcCtx.getTestFiles(cUnit);
- expectedResultFileCtxs = tcCtx.getExpectedResultFiles(cUnit);
-
- for (TestFileContext ctx : testFileCtxs) {
- testFile = ctx.getFile();
- statement = readTestFile(testFile);
- try {
- switch (ctx.getType()) {
- case "ddl":
- executeDDL(statement);
- break;
- case "update":
- executeUpdate(statement);
- break;
- case "query":
- result = executeQuery(statement);
- if (!cUnit.getExpectedError().isEmpty()) {
- if (!result.has("error")) {
- throw new Exception("Test \"" + testFile + "\" FAILED!");
- }
- } else {
- expectedResultFile = expectedResultFileCtxs.get(queryCount).getFile();
-
- File actualFile = new File(PATH_ACTUAL + File.separator
- + tcCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
- + cUnit.getName() + ".adm");
-
- File actualResultFile = tcCtx.getActualResultFile(cUnit, new File(PATH_ACTUAL));
- actualResultFile.getParentFile().mkdirs();
-
- TestsUtils.writeResultsToFile(actualFile, result);
-
- TestsUtils.runScriptAndCompareWithResult(testFile, new PrintWriter(System.err),
- expectedResultFile, actualFile);
- }
- queryCount++;
- break;
- default:
- throw new IllegalArgumentException("No statements of type " + ctx.getType());
- }
- } catch (Exception e) {
- if (cUnit.getExpectedError().isEmpty()) {
- throw new Exception("Test \"" + testFile + "\" FAILED!", e);
- }
- }
- }
- }
- }
+ }
}
diff --git a/asterix-common/pom.xml b/asterix-common/pom.xml
index 0d5c506..1a0e782 100644
--- a/asterix-common/pom.xml
+++ b/asterix-common/pom.xml
@@ -1,4 +1,5 @@
-<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">
+<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>
@@ -18,6 +19,63 @@
<fork>true</fork>
</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>asterix-conf.xsd</include>
+ </schemaIncludes>
+ <generatePackage>edu.uci.ics.asterix.common.configuration</generatePackage>
+ <bindingDirectory>src/main/resources/schema</bindingDirectory>
+ <bindingIncludes>
+ <bindingInclude>jaxb-bindings.xjb</bindingInclude>
+ </bindingIncludes>
+ <generateDirectory>${project.build.directory}/generated-sources/configuration</generateDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <includes>
+ <include>**/*.class</include>
+ </includes>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
@@ -31,6 +89,16 @@
<artifactId>hyracks-dataflow-std</artifactId>
</dependency>
<dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+ <dependency>
<groupId>edu.uci.ics.asterix</groupId>
<artifactId>asterix-transactions</artifactId>
<version>0.0.6-SNAPSHOT</version>
@@ -41,6 +109,18 @@
<groupId>edu.uci.ics.hyracks</groupId>
<artifactId>hyracks-storage-am-lsm-common</artifactId>
</dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-test-framework</artifactId>
+ <version>0.0.6-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixProperties.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixProperties.java
new file mode 100644
index 0000000..b94436a
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixProperties.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright 2009-2010 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.common.config;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
+import edu.uci.ics.asterix.common.configuration.Property;
+import edu.uci.ics.asterix.common.configuration.Store;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+/**
+ * Holder for Asterix properties values typically set as Java Properties.
+ * Intended to live in the AsterixStateProxy so it can be accessed remotely.
+ */
+public class AsterixProperties implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private static String metadataNodeName;
+ private static HashSet<String> nodeNames;
+ private static Map<String, String[]> stores;
+ private static Map<String, String> asterixConfigurationParams;
+
+ public static AsterixProperties INSTANCE = new AsterixProperties();
+
+ public static class AsterixConfigurationKeys {
+
+ // JVM parameters for each Node Contoller (NC)
+ public static final String NC_JAVA_OPTS = "nc_java_opts"; // default
+ // "-Xmx1024m"
+
+ // JVM parameters for the Cluster Contoller (CC)
+ public static final String CC_JAVA_OPTS = "cc_java_opts"; // default
+ // "-Xmx1024m"
+
+ public static final String SIZE_MEMORY_COMPONENT = "size_memory_component"; // default
+ // "512m"
+
+ public static final String TOTAL_SIZE_MEMORY_COMPONENT = "total_size_memory_component"; // default
+ // "512m"
+
+ public static final String LOG_BUFFER_NUM_PAGES = "log_buffer_num_pages"; // default
+ // "8"
+
+ public static final String LOG_BUFFER_PAGE_SIZE = "log_buffer_page_size"; // default
+ // "131072 (128K)"
+
+ public static final String LOG_PARTITION_SIZE = "log_partition_size"; // default
+ // "2147483648 (2GB)"
+
+ public static final String GROUP_COMMIT_INTERVAL = "group_commit_interval"; // default
+ // "200ms (128K)"
+
+ public static final String SORT_OP_MEMORY = "sort_op_memory"; // default
+ // "512m"
+
+ public static final String JOIN_OP_MEMORY = "join_op_memory"; // default
+ // "512m"
+
+ public static final String WEB_INTERFACE_PORT = "web_interface_port"; // default
+ // "19001"
+
+ public static final String NC_PORT = "nc_port"; // default "14601"
+
+ public static final String NUM_PAGES_BUFFER_CACHE = "num_pages_buffer_cache"; // default
+ // "1000"
+
+ public static final String LOG_LEVEL = "log_level"; // default "INFO"
+
+ public static final String LSN_THRESHOLD = "lsn_threshold"; // default
+ // "64m"
+
+ public static final String CHECKPOINT_TERMS_IN_SECS = "checkpoint_terms_in_secs"; // default
+ // "120"
+
+ public static final String ESCALATE_THRSHOLD_ENTITY_TO_DATASET = "escalate_threshold_entity_to_dataset"; // default
+ // "8"
+
+ public static final String SHRINK_TIMER_THRESHOLD = "shrink_timer_threshold"; // default
+ // "120000"
+
+ }
+
+ private AsterixProperties() {
+ try {
+ String fileName = System.getProperty(GlobalConfig.CONFIG_FILE_PROPERTY);
+ if (fileName == null) {
+ fileName = GlobalConfig.DEFAULT_CONFIG_FILE_NAME;
+ }
+ InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName);
+ if (is == null) {
+ try {
+ fileName = GlobalConfig.DEFAULT_CONFIG_FILE_NAME;
+ is = new FileInputStream(fileName);
+ } catch (FileNotFoundException fnf) {
+ throw new AlgebricksException("Could not find the configuration file " + fileName);
+ }
+ }
+
+ JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ AsterixConfiguration asterixConfiguration = (AsterixConfiguration) unmarshaller.unmarshal(is);
+ metadataNodeName = asterixConfiguration.getMetadataNode();
+ stores = new HashMap<String, String[]>();
+ List<Store> configuredStores = asterixConfiguration.getStore();
+ nodeNames = new HashSet<String>();
+ for (Store store : configuredStores) {
+ String trimmedStoreDirs = store.getStoreDirs().trim();
+ stores.put(store.getNcId(), trimmedStoreDirs.split(","));
+ nodeNames.add(store.getNcId());
+ }
+ asterixConfigurationParams = new HashMap<String, String>();
+ for (Property p : asterixConfiguration.getProperty()) {
+ asterixConfigurationParams.put(p.getName(), p.getValue());
+ }
+
+ initializeLogLevel(getProperty(AsterixConfigurationKeys.LOG_LEVEL, "INFO"));
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public String getMetadataNodeName() {
+ return metadataNodeName;
+ }
+
+ public String getMetadataStore() {
+ return stores.get(metadataNodeName)[0];
+ }
+
+ public Map<String, String[]> getStores() {
+ return stores;
+ }
+
+ public HashSet<String> getNodeNames() {
+ return nodeNames;
+ }
+
+ public String getProperty(String property, String defaultValue) {
+ String propValue = asterixConfigurationParams.get(property);
+ return (propValue != null && propValue.length() > 0) ? propValue : defaultValue;
+ }
+
+ private void initializeLogLevel(String configuredLogLevel) {
+ Level level = null;
+ switch (configuredLogLevel.toLowerCase()) {
+ case "info":
+ level = Level.INFO;
+ break;
+ case "fine":
+ level = Level.FINE;
+ break;
+ case "finer":
+ level = Level.FINER;
+ break;
+ case "finest":
+ level = Level.FINEST;
+ break;
+ case "severe":
+ level = Level.SEVERE;
+ break;
+ case "off":
+ level = Level.OFF;
+ break;
+ case "warning":
+ level = Level.WARNING;
+ break;
+ default:
+ level = Level.ALL;
+ }
+ Logger.getLogger("edu.uci.ics").setLevel(level);
+ }
+}
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 1183b65..ebce6fe 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
@@ -3,57 +3,61 @@
import java.util.logging.Logger;
public class GlobalConfig {
- public static final boolean DEBUG = true;
+ public static final boolean DEBUG = true;
- public static final String ASTERIX_LOGGER_NAME = "edu.uci.ics.asterix";
+ public static final String ASTERIX_LOGGER_NAME = "edu.uci.ics.asterix";
- public static final Logger ASTERIX_LOGGER = Logger.getLogger(ASTERIX_LOGGER_NAME);
+ public static final Logger ASTERIX_LOGGER = Logger
+ .getLogger(ASTERIX_LOGGER_NAME);
- public static final String ASTERIX_LOGFILE_PATTERN = "%t/asterix.log";
+ public static final String ASTERIX_LOGFILE_PATTERN = "%t/asterix.log";
- public static final String DEFAULT_CONFIG_FILE_NAME = "test.properties";
+ public static final String DEFAULT_CONFIG_FILE_NAME = "asterix-configuration.xml";
- public static final String TEST_CONFIG_FILE_NAME = "src/main/resources/test.properties";
+ public static final String TEST_CONFIG_FILE_NAME = "src/main/resources/asterix-configuration.xml";
- public static final String CONFIG_FILE_PROPERTY = "AsterixConfigFileName";
+ public static final String CONFIG_FILE_PROPERTY = "AsterixConfigFileName";
- public static final String WEB_SERVER_PORT_PROPERTY = "AsterixWebServerPort";
+ public static final String WEB_SERVER_PORT_PROPERTY = "AsterixWebServerPort";
- public static final String JSON_API_SERVER_PORT_PROPERTY = "AsterixJSONAPIServerPort";
+ public static final String JSON_API_SERVER_PORT_PROPERTY = "AsterixJSONAPIServerPort";
- public static final String BUFFER_CACHE_PAGE_SIZE_PROPERTY = "BufferCachePageSize";
+ public static final String BUFFER_CACHE_PAGE_SIZE_PROPERTY = "BufferCachePageSize";
- public static final String BUFFER_CACHE_NUM_PAGES_PROPERTY = "BufferCacheNumPages";
+ public static final String BUFFER_CACHE_NUM_PAGES_PROPERTY = "BufferCacheNumPages";
- public static final int DEFAULT_BUFFER_CACHE_NUM_PAGES = 4096;
+ public static final int DEFAULT_BUFFER_CACHE_NUM_PAGES = 4096;
- public static final int DEFAULT_FRAME_SIZE = 32768;
+ public static final int DEFAULT_FRAME_SIZE = 32768;
- public static final String FRAME_SIZE_PROPERTY = "FrameSize";
+ public static final String FRAME_SIZE_PROPERTY = "FrameSize";
- public static final float DEFAULT_BTREE_FILL_FACTOR = 1.00f;
+ public static final float DEFAULT_BTREE_FILL_FACTOR = 1.00f;
- public static int DEFAULT_INPUT_DATA_COLUMN = 0;
+ public static int DEFAULT_INPUT_DATA_COLUMN = 0;
- public static int DEFAULT_INDEX_MEM_PAGE_SIZE = 32768;
+ public static int DEFAULT_INDEX_MEM_PAGE_SIZE = 32768;
- public static int DEFAULT_INDEX_MEM_NUM_PAGES = 1000;
+ public static int DEFAULT_INDEX_MEM_NUM_PAGES = 1000;
- public static int getFrameSize() {
- int frameSize = GlobalConfig.DEFAULT_FRAME_SIZE;
- String frameSizeStr = System.getProperty(GlobalConfig.FRAME_SIZE_PROPERTY);
- if (frameSizeStr != null) {
- int fz = -1;
- try {
- fz = Integer.parseInt(frameSizeStr);
- } catch (NumberFormatException nfe) {
- GlobalConfig.ASTERIX_LOGGER.warning("Wrong frame size size argument. Picking default value ("
- + GlobalConfig.DEFAULT_FRAME_SIZE + ") instead.\n");
- }
- if (fz >= 0) {
- frameSize = fz;
- }
- }
- return frameSize;
- }
+ public static int getFrameSize() {
+ int frameSize = GlobalConfig.DEFAULT_FRAME_SIZE;
+ String frameSizeStr = System
+ .getProperty(GlobalConfig.FRAME_SIZE_PROPERTY);
+ if (frameSizeStr != null) {
+ int fz = -1;
+ try {
+ fz = Integer.parseInt(frameSizeStr);
+ } catch (NumberFormatException nfe) {
+ GlobalConfig.ASTERIX_LOGGER
+ .warning("Wrong frame size size argument. Picking default value ("
+ + GlobalConfig.DEFAULT_FRAME_SIZE
+ + ") instead.\n");
+ }
+ if (fz >= 0) {
+ frameSize = fz;
+ }
+ }
+ return frameSize;
+ }
}
diff --git a/asterix-common/src/main/resources/schema/asterix-conf.xsd b/asterix-common/src/main/resources/schema/asterix-conf.xsd
new file mode 100644
index 0000000..f53fb4b
--- /dev/null
+++ b/asterix-common/src/main/resources/schema/asterix-conf.xsd
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:mg="asterixconf" targetNamespace="asterixconf"
+ elementFormDefault="qualified">
+
+ <!-- definition of simple types -->
+
+
+ <xs:element name="metadataNode" type="xs:string" />
+ <xs:element name="storeDirs" type="xs:string" />
+ <xs:element name="ncId" type="xs:string" />
+ <xs:element name="name" type="xs:string" />
+ <xs:element name="value" type="xs:string" />
+ <xs:element name="description" type="xs:string" />
+
+ <!-- definition of complex elements -->
+ <xs:element name="store">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="mg:ncId" />
+ <xs:element ref="mg:storeDirs" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="property">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="mg:name" />
+ <xs:element ref="mg:value" />
+ <xs:element ref="mg:description" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+
+ <xs:element name="asterixConfiguration">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="mg:metadataNode" minOccurs="0"/>
+ <xs:element ref="mg:store" maxOccurs="unbounded" />
+ <xs:element ref="mg:property" minOccurs="0" maxOccurs="unbounded" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+</xs:schema>
diff --git a/asterix-common/src/main/resources/schema/jaxb-bindings.xjb b/asterix-common/src/main/resources/schema/jaxb-bindings.xjb
new file mode 100644
index 0000000..b5982e0
--- /dev/null
+++ b/asterix-common/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/java/edu/uci/ics/asterix/event/driver/EventDriver.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java
index 1721666..b6a32e3 100644
--- 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
@@ -41,7 +41,7 @@
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, null);
+ 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;
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
index 6d89c88..39e1a2f 100644
--- 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
@@ -51,19 +51,21 @@
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")) {
+ } else if (p.getKey().equals("NC_JAVA_OPTS") && !node.getId().equals(cluster.getMasterNode().getId())) {
StringBuilder builder = new StringBuilder();
builder.append("\"");
- String javaOpts = (node.getJavaOpts() == null ? cluster.getJavaOpts() : node.getJavaOpts());
+ String javaOpts = p.getValue();
if (javaOpts != null) {
builder.append(javaOpts);
}
- if (cluster.isDebugEnabled() != null && cluster.isDebugEnabled().booleanValue()) {
- BigInteger debugPort = node.getDebug() == null ? cluster.getDebug() : node.getDebug();
- if (debugPort != null) {
- builder.append("-Xdebug -Xrunjdwp:transport=dt_socket,address=" + debugPort.intValue()
- + "," + "server=y,suspend=n");
- }
+ builder.append("\"");
+ envBuffer.append(p.getKey() + "=" + builder + " ");
+ } else if (p.getKey().equals("CC_JAVA_OPTS") && node.getId().equals(cluster.getMasterNode().getId())) {
+ StringBuilder builder = new StringBuilder();
+ builder.append("\"");
+ String javaOpts = p.getValue();
+ if (javaOpts != null) {
+ builder.append(javaOpts);
}
builder.append("\"");
envBuffer.append(p.getKey() + "=" + builder + " ");
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
index 0761c7f..7cbb515 100644
--- 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
@@ -36,251 +36,230 @@
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");
+ 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";
- private static final String LOCALHOST = "localhost";
- private static final String LOCALHOST_IP = "127.0.0.1";
+ 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";
+ private static final String LOCALHOST = "localhost";
+ private static final String LOCALHOST_IP = "127.0.0.1";
- public static Cluster getCluster(String clusterConfigurationPath)
- throws JAXBException {
- File file = new File(clusterConfigurationPath);
- JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
- Unmarshaller unmarshaller = ctx.createUnmarshaller();
- Cluster cluster = (Cluster) unmarshaller.unmarshal(file);
- if (cluster.getMasterNode().getClusterIp().equals(LOCALHOST)) {
- cluster.getMasterNode().setClusterIp(LOCALHOST_IP);
- }
- for (Node node : cluster.getNode()) {
- if (node.getClusterIp().equals(LOCALHOST)) {
- node.setClusterIp(LOCALHOST_IP);
- }
- }
- return cluster;
- }
+ public static Cluster getCluster(String clusterConfigurationPath) throws JAXBException {
+ File file = new File(clusterConfigurationPath);
+ JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ Cluster cluster = (Cluster) unmarshaller.unmarshal(file);
+ if (cluster.getMasterNode().getClusterIp().equals(LOCALHOST)) {
+ cluster.getMasterNode().setClusterIp(LOCALHOST_IP);
+ }
+ for (Node node : cluster.getNode()) {
+ if (node.getClusterIp().equals(LOCALHOST)) {
+ node.setClusterIp(LOCALHOST_IP);
+ }
+ }
+ return cluster;
+ }
- 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(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);
- }
+ 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;
+ 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 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();
+ 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;
+ 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;
- }
+ 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;
- }
+ }
+ 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;
- }
+ 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 javaOpts = cluster.getMasterNode().getJavaOpts() == null ? cluster
- .getJavaOpts() : cluster.getMasterNode().getJavaOpts();
- 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().getClusterIp(), javaHome, javaOpts,
- logDir, null, null, debug);
- }
+ if (nodeid.equals(cluster.getMasterNode().getId())) {
+ String logDir = cluster.getMasterNode().getLogDir() == null ? cluster.getLogDir() : cluster.getMasterNode()
+ .getLogDir();
+ String javaHome = cluster.getMasterNode().getJavaHome() == null ? cluster.getJavaHome() : cluster
+ .getMasterNode().getJavaHome();
+ return new Node(cluster.getMasterNode().getId(), cluster.getMasterNode().getClusterIp(), javaHome, logDir,
+ null, null, null);
+ }
- 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);
- }
+ 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.getClusterIp();
- 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.getClusterIp());
- pb.environment().put(CLUSTER_ENV, env);
- pb.environment().put(SCRIPT, script);
- pb.environment().put(ARGS, argBuffer.toString());
- pb.start();
- }
+ 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.getClusterIp();
+ 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.getClusterIp());
+ 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.getClusterIp());
- 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.getClusterIp());
+ 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;
- }
+ 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/resources/events/backup/backup.sh b/asterix-events/src/main/resources/events/backup/backup.sh
index 556ca39..fc6e3cc 100755
--- a/asterix-events/src/main/resources/events/backup/backup.sh
+++ b/asterix-events/src/main/resources/events/backup/backup.sh
@@ -3,7 +3,7 @@
ASTERIX_IODEVICES=$3
NODE_STORE=$4
ASTERIX_ROOT_METADATA_DIR=$5
-TXN_LOG_DIR_NAME=$6
+TXN_LOG_DIR=$6
BACKUP_ID=$7
BACKUP_DIR=$8
BACKUP_TYPE=$9
@@ -20,7 +20,6 @@
for nodeIODevice in $nodeIODevices
do
STORE_DIR=$nodeIODevice/$NODE_STORE
- TXN_LOG_DIR=$nodeIODevice/$TXN_LOG_DIR_NAME
NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/
# make the destination directory
@@ -46,7 +45,6 @@
for nodeIODevice in $nodeIODevices
do
STORE_DIR=$nodeIODevice/$NODE_STORE
- TXN_LOG_DIR=$nodeIODevice/$TXN_LOG_DIR_NAME
NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID
# create the backup directory, if it does not exists
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
index 003d9cf..dfc8ad9 100755
--- a/asterix-events/src/main/resources/events/cc_start/cc_start.sh
+++ b/asterix-events/src/main/resources/events/cc_start/cc_start.sh
@@ -3,4 +3,5 @@
mkdir -p $LOG_DIR
fi
cd $WORKING_DIR
+export JAVA_OPTS=$CC_JAVA_OPTS
$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/node_join/nc_join.sh b/asterix-events/src/main/resources/events/node_join/nc_join.sh
index d8bbbd2..2e2cfac 100755
--- a/asterix-events/src/main/resources/events/node_join/nc_join.sh
+++ b/asterix-events/src/main/resources/events/node_join/nc_join.sh
@@ -6,4 +6,5 @@
mkdir -p $LOG_DIR
fi
cd $WORKING_DIR
+export JAVA_OPTS=$NC_JAVA_OPTS
$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 -iodevices $IO_DEVICES -result-ip-address $IP_LOCATION &> $LOG_DIR/${NC_ID}.log
diff --git a/asterix-events/src/main/resources/events/restore/restore.sh b/asterix-events/src/main/resources/events/restore/restore.sh
index 6396eec..88c5a6f 100755
--- a/asterix-events/src/main/resources/events/restore/restore.sh
+++ b/asterix-events/src/main/resources/events/restore/restore.sh
@@ -3,7 +3,7 @@
ASTERIX_IODEVICES=$3
NODE_STORE=$4
ASTERIX_ROOT_METADATA_DIR=$5
-TXN_LOG_DIR_NAME=$6
+TXN_LOG_DIR=$6
BACKUP_ID=$7
BACKUP_DIR=$8
BACKUP_TYPE=$9
@@ -33,8 +33,9 @@
rm -rf $DEST_STORE_DIR/$SOURCE_STORE_DIR
# remove the existing log directory
- DEST_LOG_DIR=$iodevice/$TXN_LOG_DIR_NAME/
- rm -rf $DEST_LOG_DIR
+ DEST_LOG_DIR=$TXN_LOG_DIR
+ rm -rf $DEST_LOG_DIR/*
+ TXN_LOG_DIR_NAME=${TXN_LOG_DIR%/*}
# remove the existing asterix metadata directory
rm -rf $iodevice/$ASTERIX_ROOT_METADATA_DIR
@@ -52,7 +53,7 @@
$HADOOP_HOME/bin/hadoop fs -copyToLocal $HDFS_URL/$NODE_BACKUP_DIR/$ASTERIX_ROOT_METADATA_DIR $iodevice/
# copy transaction logs directory
- $HADOOP_HOME/bin/hadoop fs -copyToLocal $HDFS_URL/$NODE_BACKUP_DIR/$TXN_LOG_DIR_NAME $iodevice/
+ $HADOOP_HOME/bin/hadoop fs -copyToLocal $HDFS_URL/$NODE_BACKUP_DIR/$TXN_LOG_DIR_NAME $$TXN_LOG_DIR/
fi
else
@@ -67,7 +68,7 @@
cp -r $NODE_BACKUP_DIR/$ASTERIX_ROOT_METADATA_DIR $iodevice/
# copy transaction logs directory
- cp -r $NODE_BACKUP_DIR/$TXN_LOG_DIR_NAME $iodevice/
+ cp -r $NODE_BACKUP_DIR/$TXN_LOG_DIR_NAME $TXN_LOG_DIR/
fi
fi
diff --git a/asterix-events/src/main/resources/schema/cluster.xsd b/asterix-events/src/main/resources/schema/cluster.xsd
index 0e1adce..718d7b0 100644
--- a/asterix-events/src/main/resources/schema/cluster.xsd
+++ b/asterix-events/src/main/resources/schema/cluster.xsd
@@ -1,98 +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">
+<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_opts" type="xs:string"/>
-<xs:element name="logdir" type="xs:string"/>
-<xs:element name="id" type="xs:string"/>
-<xs:element name="client-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="iodevices" 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"/>
-<xs:element name="debugEnabled" type="xs:boolean"/>
+ <!-- definition of simple types -->
+ <xs:element name="name" type="xs:string" />
+ <xs:element name="log_dir" type="xs:string" />
+ <xs:element name="txn_log_dir" type="xs:string" />
+ <xs:element name="id" type="xs:string" />
+ <xs:element name="client_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="iodevices" type="xs:string" />
+ <xs:element name="java_home" type="xs:string" />
+ <xs:element name="username" type="xs:string" />
-<!-- 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>
+ <!-- definition of complex elements -->
+ <xs:element name="working_dir">
+ <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:client-ip"/>
- <xs:element ref="cl:cluster-ip"/>
- <xs:element ref="cl:java_home" minOccurs="0"/>
- <xs:element ref="cl:java_opts" 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="master_node">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="cl:id" />
+ <xs:element ref="cl:client_ip" />
+ <xs:element ref="cl:cluster_ip" />
+ <xs:element ref="cl:java_home" minOccurs="0" />
+ <xs:element ref="cl:log_dir" 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="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="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:cluster-ip"/>
- <xs:element ref="cl:java_home" minOccurs="0"/>
- <xs:element ref="cl:java_opts" minOccurs="0"/>
- <xs:element ref="cl:logdir" minOccurs="0"/>
- <xs:element ref="cl:store" minOccurs="0"/>
- <xs:element ref="cl:iodevices" minOccurs="0"/>
- <xs:element ref="cl:debug" minOccurs="0"/>
- </xs:sequence>
- </xs:complexType>
-</xs:element>
+ <xs:element name="node">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="cl:id" />
+ <xs:element ref="cl:cluster_ip" />
+ <xs:element ref="cl:java_home" minOccurs="0" />
+ <xs:element ref="cl:log_dir" minOccurs="0" />
+ <xs:element ref="cl:txn_log_dir" minOccurs="0" />
+ <xs:element ref="cl:store" minOccurs="0" />
+ <xs:element ref="cl:iodevices" 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_home" minOccurs="0"/>
- <xs:element ref="cl:java_opts" minOccurs="0"/>
- <xs:element ref="cl:logdir" minOccurs="0"/>
- <xs:element ref="cl:store" minOccurs="0"/>
- <xs:element ref="cl:iodevices" minOccurs="0"/>
- <xs:element ref="cl:workingDir"/>
- <xs:element ref="cl:debugEnabled" minOccurs="0"/>
- <xs:element ref="cl:debug" minOccurs="0"/>
- <xs:element ref="cl:master-node"/>
- <xs:element ref="cl:node" maxOccurs="unbounded"/>
- </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_home" minOccurs="0" />
+ <xs:element ref="cl:log_dir" minOccurs="0" />
+ <xs:element ref="cl:txn_log_dir" minOccurs="0" />
+ <xs:element ref="cl:store" minOccurs="0" />
+ <xs:element ref="cl:iodevices" minOccurs="0" />
+ <xs:element ref="cl:working_dir" />
+ <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-installer/pom.xml b/asterix-installer/pom.xml
index 60ae2ce..4b1add5 100644
--- a/asterix-installer/pom.xml
+++ b/asterix-installer/pom.xml
@@ -6,146 +6,183 @@
<version>0.0.6-SNAPSHOT</version>
</parent>
<artifactId>asterix-installer</artifactId>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
- <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>
- <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>
+ <args>
+ <arg>-Xsetters</arg>
+ <arg>-Xvalue-constructor</arg>
+ </args>
+ <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-5</version>
+ <executions>
+ <execution>
+ <configuration>
+ <descriptor>src/main/assembly/binary-assembly.xml</descriptor>
+ </configuration>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
- <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>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.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.6-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-common</artifactId>
+ <version>0.0.6-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-common</artifactId>
+ <version>0.0.6-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-server</artifactId>
+ <version>0.0.6-SNAPSHOT</version>
+ <type>zip</type>
+ <classifier>binary-assembly</classifier>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-test-framework</artifactId>
+ <version>0.0.6-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <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.6-SNAPSHOT</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>edu.uci.ics.asterix</groupId>
- <artifactId>asterix-server</artifactId>
- <version>0.0.6-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
index 6a0c130..66d6cfe 100644
--- a/asterix-installer/src/main/assembly/binary-assembly.xml
+++ b/asterix-installer/src/main/assembly/binary-assembly.xml
@@ -2,6 +2,7 @@
<id>binary-assembly</id>
<formats>
<format>zip</format>
+ <format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
@@ -61,6 +62,7 @@
<includes>
<include>log4j:log4j</include>
<include>edu.uci.ics.asterix:asterix-events</include>
+ <include>edu.uci.ics.asterix:asterix-common</include>
<include>org.apache.zookeeper:zookeeper</include>
<include>args4j:args4j</include>
<include>log4j:log4j</include>
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
index 5ef7449..15c28cd 100644
--- 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
@@ -15,10 +15,10 @@
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.common.configuration.AsterixConfiguration;
import edu.uci.ics.asterix.installer.driver.InstallerDriver;
import edu.uci.ics.asterix.installer.driver.InstallerUtil;
import edu.uci.ics.asterix.installer.model.AsterixInstance;
@@ -35,12 +35,14 @@
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);
+ InstallerUtil.createClusterProperties(instance.getCluster(), instance.getAsterixConfiguration());
+ AsterixConfiguration asterixConfiguration = InstallerUtil
+ .getAsterixConfiguration(((AlterConfig) config).confPath);
+ instance.setAsterixConfiguration(asterixConfiguration);
instance.setModifiedTimestamp(new Date());
lookupService.updateAsterixInstance(instance);
- LOGGER.info("Configuration for Asterix instance: " + instanceName + " has been altered");
+ LOGGER.info("Altered configuration settings for Asterix instance: " + instanceName);
+
}
@Override
@@ -52,6 +54,7 @@
protected String getUsageDescription() {
return "\nAlter the instance's configuration settings."
+ "\nPrior to running this command, the instance is required to be INACTIVE state."
+ + "\nChanged configuration settings will be reflected when the instance is started."
+ "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance"
+ "\n-conf path to the ASTERIX configuration file.";
}
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
index e742c4e..43400ea 100644
--- 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
@@ -26,9 +26,9 @@
cluster.setWorkingDir(new WorkingDir(workingDir, true));
cluster.setIodevices(workingDir);
cluster.setStore("storage");
- cluster.setLogdir(workingDir + File.separator + "logs");
- cluster.setJavaHome(System.getenv("JAVA_HOME"));
- cluster.setJavaOpts("-Xmx1024m");
+ cluster.setLogDir(workingDir + File.separator + "logs");
+ cluster.setTxnLogDir(workingDir + File.separator + "txnLogs");
+ cluster.setJavaHome(System.getProperty("java.home"));
JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
Marshaller marshaller = ctx.createMarshaller();
@@ -44,7 +44,7 @@
configuration.getZookeeper().setHomeDir(
InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_INTERNAL_DIR
+ File.separator + "zookeeper_home");
- configuration.getZookeeper().getServers().setJavaHome(System.getenv("JAVA_HOME"));
+ configuration.getZookeeper().getServers().setJavaHome(System.getProperty("java.home"));
marshaller = ctx.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
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
index 2de8e53..3317483 100644
--- 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
@@ -15,16 +15,13 @@
package edu.uci.ics.asterix.installer.command;
import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
import org.kohsuke.args4j.Option;
+import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
import edu.uci.ics.asterix.event.management.EventUtil;
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.Env;
-import edu.uci.ics.asterix.event.schema.cluster.Property;
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;
@@ -38,6 +35,7 @@
private String asterixInstanceName;
private Cluster cluster;
+ private AsterixConfiguration asterixConfiguration;
@Override
protected void execCommand() throws Exception {
@@ -51,24 +49,12 @@
InstallerUtil.validateAsterixInstanceNotExists(asterixInstanceName);
CreateConfig createConfig = (CreateConfig) config;
cluster = EventUtil.getCluster(createConfig.clusterPath);
- AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(asterixInstanceName, cluster);
+ asterixConfiguration = InstallerUtil.getAsterixConfiguration(createConfig.asterixConfPath);
+ AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(asterixInstanceName, cluster,
+ asterixConfiguration);
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"));
- StringBuilder javaOpts = new StringBuilder();
- if (cluster.getJavaOpts() != null) {
- javaOpts.append(cluster.getJavaOpts());
- }
- clusterProperties.add(new Property("JAVA_OPTS", javaOpts.toString()));
- clusterProperties.add(new Property("CLUSTER_NET_IP", cluster.getMasterNode().getClusterIp()));
- clusterProperties.add(new Property("CLIENT_NET_IP", cluster.getMasterNode().getClientIp()));
- 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));
-
+ InstallerUtil.createAsterixZip(asterixInstance);
+ InstallerUtil.createClusterProperties(cluster, asterixConfiguration);
EventrixClient eventrixClient = InstallerUtil.getEventrixClient(cluster);
PatternCreator pc = new PatternCreator();
@@ -117,4 +103,7 @@
@Option(name = "-c", required = true, usage = "Path to cluster configuration")
public String clusterPath;
+ @Option(name = "-a", required = false, usage = "Path to asterix configuration")
+ public String asterixConfPath;
+
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java
index a9864a3..3bc700d 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java
@@ -55,6 +55,9 @@
case VALIDATE:
helpMessage = new ValidateCommand().getUsageDescription();
break;
+ case ALTER:
+ helpMessage = new AlterCommand().getUsageDescription();
+ break;
default:
helpMessage = "Unknown command " + command;
}
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
index 01fdda4..1180a4e 100644
--- 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
@@ -25,8 +25,8 @@
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.model.AsterixInstance.State;
import edu.uci.ics.asterix.installer.service.ServiceProvider;
public class StartCommand extends AbstractCommand {
@@ -36,13 +36,13 @@
InstallerDriver.initConfig();
String asterixInstanceName = ((StartConfig) config).name;
AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
- InstallerUtil.createAsterixZip(instance, false);
+ InstallerUtil.createAsterixZip(instance);
PatternCreator pc = new PatternCreator();
EventrixClient client = InstallerUtil.getEventrixClient(instance.getCluster());
Patterns asterixBinaryTransferPattern = pc.getAsterixBinaryTransferPattern(asterixInstanceName,
instance.getCluster());
client.submit(asterixBinaryTransferPattern);
-
+ InstallerUtil.createClusterProperties(instance.getCluster(), instance.getAsterixConfiguration());
Patterns patterns = pc.getStartAsterixPattern(asterixInstanceName, instance.getCluster());
client.submit(patterns);
InstallerUtil.deleteDirectory(InstallerDriver.getManagixHome() + File.separator + InstallerDriver.ASTERIX_DIR
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
index 4e6460b..f469fe4 100644
--- 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
@@ -32,7 +32,6 @@
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.ProcessInfo;
import edu.uci.ics.asterix.installer.schema.conf.Configuration;
import edu.uci.ics.asterix.installer.schema.conf.Zookeeper;
@@ -110,8 +109,8 @@
serverIds.add(cluster.getMasterNode().getId());
MasterNode masterNode = cluster.getMasterNode();
- Node master = new Node(masterNode.getId(), masterNode.getClusterIp(), masterNode.getJavaOpts(),
- masterNode.getJavaHome(), masterNode.getLogdir(), null, null, null);
+ Node master = new Node(masterNode.getId(), masterNode.getClusterIp(), masterNode.getJavaHome(),
+ masterNode.getLogDir(), null, null, null);
ipAddresses.add(masterNode.getClusterIp());
valid = valid & validateNodeConfiguration(master, cluster);
@@ -163,8 +162,8 @@
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.getLogDir() != null && checkTemporaryPath(cluster.getLogDir())) {
+ tempDirs.add("Log directory: " + cluster.getLogDir());
}
if (cluster.getIodevices() != null && checkTemporaryPath(cluster.getIodevices())) {
tempDirs.add("IO Device: " + cluster.getIodevices());
@@ -191,8 +190,8 @@
}
}
- if (node.getLogdir() == null || node.getLogdir().length() == 0) {
- if (cluster.getLogdir() == null || cluster.getLogdir().length() == 0) {
+ 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);
}
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
index 3596032..08249ee 100644
--- 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
@@ -34,6 +34,8 @@
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 DEFAULT_ASTERIX_CONFIGURATION_PATH = "conf" + File.separator + File.separator
+ + "asterix-configuration.xml";
public static final String ASTERIX_DIR = "asterix";
public static final String EVENTS_DIR = "events";
@@ -92,6 +94,10 @@
return managixHome;
}
+ public static void setManagixHome(String managixHome) {
+ InstallerDriver.managixHome = managixHome;
+ }
+
public static String getAsterixDir() {
return managixHome + File.separator + ASTERIX_DIR;
}
@@ -125,13 +131,13 @@
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("alter " + ":" + " Alter the instance's configuration settings" + "\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("configure" + ":" + " Configure the Asterix installer" + "\n");
buffer.append("shutdown " + ":" + " Shutdown the installer service" + "\n");
buffer.append("help " + ":" + " Provides usage description of a command" + "\n");
-
+ buffer.append("\nTo get more information about a command, use managix help -cmd <command>");
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
index e2be142..c9395ca 100644
--- 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
@@ -40,12 +40,21 @@
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
import org.apache.commons.io.IOUtils;
+import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
+import edu.uci.ics.asterix.common.configuration.Store;
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.Env;
import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.cluster.Property;
import edu.uci.ics.asterix.installer.error.InstallerException;
import edu.uci.ics.asterix.installer.error.OutputHandler;
import edu.uci.ics.asterix.installer.model.AsterixInstance;
@@ -56,40 +65,63 @@
public static final String TXN_LOG_DIR = "txnLogs";
public static final String TXN_LOG_DIR_KEY_SUFFIX = "txnLogDir";
+ public static final String ASTERIX_CONFIGURATION_FILE = "asterix-configuration.xml";
+ public static final String TXN_LOG_CONFIGURATION_FILE = "log.properties";
- 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");
+ public static AsterixInstance createAsterixInstance(String asterixInstanceName, Cluster cluster,
+ AsterixConfiguration asterixConfiguration) throws FileNotFoundException, IOException {
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,
+ AsterixInstance instance = new AsterixInstance(asterixInstanceName, cluster, asterixConfiguration,
metadataNode.getId(), asterixVersion);
return instance;
}
- public static void createAsterixZip(AsterixInstance asterixInstance, boolean newDeployment) throws IOException,
- InterruptedException {
+ public static void createAsterixZip(AsterixInstance asterixInstance) throws IOException, InterruptedException,
+ JAXBException, InstallerException {
- String modifiedZipPath = injectAsterixPropertyFile(InstallerDriver.getAsterixZip(), asterixInstance,
- newDeployment);
+ String modifiedZipPath = injectAsterixPropertyFile(InstallerDriver.getAsterixZip(), asterixInstance);
injectAsterixLogPropertyFile(modifiedZipPath, asterixInstance);
}
- private static String injectAsterixPropertyFile(String origZipFile, AsterixInstance asterixInstance,
- boolean newDeployment) throws IOException {
- writeAsterixConfigurationFile(asterixInstance, newDeployment);
+ public static void createClusterProperties(Cluster cluster, AsterixConfiguration asterixConfiguration) {
+ List<Property> clusterProperties = null;
+ if (cluster.getEnv() != null && cluster.getEnv().getProperty() != null) {
+ clusterProperties = cluster.getEnv().getProperty();
+ clusterProperties.clear();
+ } else {
+ clusterProperties = new ArrayList<Property>();
+ }
+ for (edu.uci.ics.asterix.common.configuration.Property property : asterixConfiguration.getProperty()) {
+ if (property.getName().equalsIgnoreCase(AsterixInstance.CC_JAVA_OPTS)) {
+ clusterProperties.add(new Property("CC_JAVA_OPTS", property.getValue()));
+ } else if (property.getName().equalsIgnoreCase(AsterixInstance.NC_JAVA_OPTS)) {
+ clusterProperties.add(new Property("NC_JAVA_OPTS", property.getValue()));
+ }
+ }
+ clusterProperties.add(new Property("ASTERIX_HOME", cluster.getWorkingDir().getDir() + File.separator
+ + "asterix"));
+ clusterProperties.add(new Property("CLUSTER_NET_IP", cluster.getMasterNode().getClusterIp()));
+ clusterProperties.add(new Property("CLIENT_NET_IP", cluster.getMasterNode().getClientIp()));
+ 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));
+ }
+
+ private static String injectAsterixPropertyFile(String origZipFile, AsterixInstance asterixInstance)
+ throws IOException, JAXBException {
+ writeAsterixConfigurationFile(asterixInstance);
String asterixInstanceDir = InstallerDriver.getAsterixDir() + File.separator + asterixInstance.getName();
unzip(origZipFile, asterixInstanceDir);
File sourceJar = new File(asterixInstanceDir + File.separator + "lib" + File.separator + "asterix-app-"
+ asterixInstance.getAsterixVersion() + ".jar");
- String asterixPropertyFile = "test.properties";
- File replacementFile = new File(asterixInstanceDir + File.separator + "test.properties");
- replaceInJar(sourceJar, asterixPropertyFile, replacementFile);
- new File(asterixInstanceDir + File.separator + "test.properties").delete();
+ File replacementFile = new File(asterixInstanceDir + File.separator + ASTERIX_CONFIGURATION_FILE);
+ replaceInJar(sourceJar, ASTERIX_CONFIGURATION_FILE, replacementFile);
+ new File(asterixInstanceDir + File.separator + ASTERIX_CONFIGURATION_FILE).delete();
String asterixZipName = InstallerDriver.getAsterixZip().substring(
InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
zipDir(new File(asterixInstanceDir), new File(asterixInstanceDir + File.separator + asterixZipName));
@@ -97,25 +129,24 @@
}
private static String injectAsterixLogPropertyFile(String origZipFile, AsterixInstance asterixInstance)
- throws IOException {
+ throws IOException, InstallerException {
String asterixInstanceDir = InstallerDriver.getAsterixDir() + File.separator + asterixInstance.getName();
unzip(origZipFile, asterixInstanceDir);
File sourceJar1 = new File(asterixInstanceDir + File.separator + "lib" + File.separator + "asterix-app-"
+ asterixInstance.getAsterixVersion() + ".jar");
- String txnLogPropertyFile = "log.properties";
Properties txnLogProperties = new Properties();
URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { sourceJar1.toURI().toURL() });
- InputStream in = urlClassLoader.getResourceAsStream(txnLogPropertyFile);
+ InputStream in = urlClassLoader.getResourceAsStream(TXN_LOG_CONFIGURATION_FILE);
if (in != null) {
txnLogProperties.load(in);
}
- writeAsterixLogConfigurationFile(asterixInstance.getName(), asterixInstance.getCluster(), txnLogProperties);
+ writeAsterixLogConfigurationFile(asterixInstance, txnLogProperties);
File sourceJar2 = new File(asterixInstanceDir + File.separator + "lib" + File.separator + "asterix-app-"
+ asterixInstance.getAsterixVersion() + ".jar");
File replacementFile = new File(asterixInstanceDir + File.separator + "log.properties");
- replaceInJar(sourceJar2, txnLogPropertyFile, replacementFile);
+ replaceInJar(sourceJar2, TXN_LOG_CONFIGURATION_FILE, replacementFile);
new File(asterixInstanceDir + File.separator + "log.properties").delete();
String asterixZipName = InstallerDriver.getAsterixZip().substring(
@@ -174,54 +205,74 @@
return nodeDataStore.toString();
}
- private static void writeAsterixConfigurationFile(AsterixInstance asterixInstance, boolean newData)
- throws IOException {
+ private static void writeAsterixConfigurationFile(AsterixInstance asterixInstance) throws IOException,
+ JAXBException {
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");
+ AsterixConfiguration configuration = asterixInstance.getAsterixConfiguration();
+ configuration.setMetadataNode(asterixInstanceName + "_" + metadataNodeId);
String storeDir = null;
+ List<Store> stores = new ArrayList<Store>();
for (Node node : cluster.getNode()) {
storeDir = node.getStore() == null ? cluster.getStore() : node.getStore();
- conf.append(asterixInstanceName + "_" + node.getId() + ".stores" + "=" + storeDir + "\n");
+ stores.add(new Store(asterixInstanceName + "_" + node.getId(), storeDir));
}
-
- Properties asterixConfProp = asterixInstance.getConfiguration();
- String outputDir = asterixConfProp.getProperty("output_dir");
- conf.append("OutputDir=" + outputDir);
+ configuration.setStore(stores);
File asterixConfDir = new File(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName);
asterixConfDir.mkdirs();
- dumpToFile(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName + File.separator
- + "test.properties", conf.toString());
+
+ JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
+ Marshaller marshaller = ctx.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ marshaller.marshal(configuration, new FileOutputStream(asterixConfDir + File.separator
+ + ASTERIX_CONFIGURATION_FILE));
}
- private static void writeAsterixLogConfigurationFile(String asterixInstanceName, Cluster cluster,
- Properties logProperties) throws IOException {
+ private static void writeAsterixLogConfigurationFile(AsterixInstance asterixInstance, Properties logProperties)
+ throws IOException, InstallerException {
+ String asterixInstanceName = asterixInstance.getName();
+ Cluster cluster = asterixInstance.getCluster();
StringBuffer conf = new StringBuffer();
for (Map.Entry<Object, Object> p : logProperties.entrySet()) {
conf.append(p.getKey() + "=" + p.getValue() + "\n");
}
for (Node node : cluster.getNode()) {
- String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
- String txnLogDir = iodevices.split(",")[0].trim() + File.separator + InstallerUtil.TXN_LOG_DIR;
+ String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
+ if (txnLogDir == null) {
+ throw new InstallerException("Transaction log directory (txn_log_dir) not configured for node: "
+ + node.getId());
+ }
conf.append(asterixInstanceName + "_" + node.getId() + "." + TXN_LOG_DIR_KEY_SUFFIX + "=" + txnLogDir
+ "\n");
}
+ List<edu.uci.ics.asterix.common.configuration.Property> properties = asterixInstance.getAsterixConfiguration()
+ .getProperty();
+ for (edu.uci.ics.asterix.common.configuration.Property p : properties) {
+ if (p.getName().trim().toLowerCase().contains("log")) {
+ conf.append(p.getValue() + "=" + p.getValue());
+ }
+ }
dumpToFile(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName + File.separator
+ "log.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 AsterixConfiguration getAsterixConfiguration(String asterixConf) throws FileNotFoundException,
+ IOException, JAXBException {
+ if (asterixConf == null) {
+ asterixConf = InstallerDriver.getManagixHome() + File.separator
+ + InstallerDriver.DEFAULT_ASTERIX_CONFIGURATION_PATH;
+ }
+ File file = new File(asterixConf);
+ JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ AsterixConfiguration asterixConfiguration = (AsterixConfiguration) unmarshaller.unmarshal(file);
+ return asterixConfiguration;
}
public static void unzip(String sourceFile, String destDir) throws IOException {
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
index 0d50bbf..4216978 100644
--- 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
@@ -173,16 +173,18 @@
String workingDir = cluster.getWorkingDir().getDir();
String backupId = "" + instance.getBackupInfo().size();
String iodevices;
+ String txnLogDir;
String store;
String pargs;
List<Pattern> patternList = new ArrayList<Pattern>();
for (Node node : cluster.getNode()) {
Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
iodevices = node.getIodevices() == null ? instance.getCluster().getIodevices() : node.getIodevices();
+ txnLogDir = node.getTxnLogDir() == null ? instance.getCluster().getTxnLogDir() : node.getTxnLogDir();
store = node.getStore() == null ? cluster.getStore() : node.getStore();
pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + store + " "
- + BackupCommand.ASTERIX_ROOT_METADATA_DIR + " " + InstallerUtil.TXN_LOG_DIR + " " + backupId + " "
- + backupDir + " " + "local" + " " + node.getId();
+ + BackupCommand.ASTERIX_ROOT_METADATA_DIR + " " + txnLogDir + " " + backupId + " " + backupDir
+ + " " + "local" + " " + node.getId();
Event event = new Event("backup", nodeid, pargs);
patternList.add(new Pattern(null, 1, null, event));
}
@@ -407,7 +409,7 @@
private Patterns createRemoveAsterixLogDirPattern(AsterixInstance instance) throws Exception {
List<Pattern> patternList = new ArrayList<Pattern>();
Cluster cluster = instance.getCluster();
- String pargs = instance.getCluster().getLogdir();
+ 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));
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
index 9a2d43d..1eba89f 100644
--- 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
@@ -18,8 +18,9 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import java.util.Properties;
+import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
+import edu.uci.ics.asterix.common.configuration.Property;
import edu.uci.ics.asterix.event.schema.cluster.Cluster;
import edu.uci.ics.asterix.event.schema.cluster.Node;
@@ -27,6 +28,9 @@
private static final long serialVersionUID = 2874439550187520449L;
+ public static final String CC_JAVA_OPTS = "cc_java_opts";
+ public static final String NC_JAVA_OPTS = "nc_java_opts";
+
public enum State {
ACTIVE,
INACTIVE,
@@ -38,7 +42,7 @@
private final Date createdTimestamp;
private Date stateChangeTimestamp;
private Date modifiedTimestamp;
- private Properties configuration;
+ private AsterixConfiguration asterixConfiguration;
private State state;
private final String metadataNodeId;
private final String asterixVersion;
@@ -47,11 +51,11 @@
private AsterixRuntimeState runtimeState;
private State previousState;
- public AsterixInstance(String name, Cluster cluster, Properties configuration, String metadataNodeId,
- String asterixVersion) {
+ public AsterixInstance(String name, Cluster cluster, AsterixConfiguration asterixConfiguration,
+ String metadataNodeId, String asterixVersion) {
this.name = name;
this.cluster = cluster;
- this.configuration = configuration;
+ this.asterixConfiguration = asterixConfiguration;
this.metadataNodeId = metadataNodeId;
this.state = State.ACTIVE;
this.previousState = State.UNUSABLE;
@@ -65,14 +69,6 @@
return stateChangeTimestamp;
}
- public Properties getConfiguration() {
- return configuration;
- }
-
- public void setConfiguration(Properties properties) {
- this.configuration = properties;
- }
-
public State getState() {
return state;
}
@@ -174,9 +170,23 @@
buffer.append(pInfo + "\n");
}
+ buffer.append("\n");
+ buffer.append("Asterix Configuration\n");
+ for (Property property : asterixConfiguration.getProperty()) {
+ buffer.append(property.getName() + ":" + property.getValue() + "\n");
+ }
+
}
public State getPreviousState() {
return previousState;
}
+
+ public AsterixConfiguration getAsterixConfiguration() {
+ return asterixConfiguration;
+ }
+
+ public void setAsterixConfiguration(AsterixConfiguration asterixConfiguration) {
+ this.asterixConfiguration = asterixConfiguration;
+ }
}
diff --git a/asterix-installer/src/main/resources/clusters/local/conf/asterix.conf b/asterix-installer/src/main/resources/clusters/local/conf/asterix.conf
deleted file mode 100644
index 659b48e..0000000
--- a/asterix-installer/src/main/resources/clusters/local/conf/asterix.conf
+++ /dev/null
@@ -1 +0,0 @@
-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
index d397bcd..ff5e2f4 100644
--- a/asterix-installer/src/main/resources/clusters/local/local.xml
+++ b/asterix-installer/src/main/resources/clusters/local/local.xml
@@ -1,21 +1,22 @@
<cluster xmlns="cluster">
<name>local</name>
- <workingDir>
+ <working_dir>
<dir>/tmp/asterix-installer</dir>
<NFS>true</NFS>
- </workingDir>
- <logdir>/tmp/asterix/logs</logdir>
+ </working_dir>
+ <log_dir>/tmp/asterix/logs</log_dir>
+ <txn_log_dir>/tmp/asterix/logs</txn_log_dir>
<iodevices>/tmp</iodevices>
<store>asterix/storage</store>
<java_home></java_home>
<java_opts>-Xmx1024m</java_opts>
- <master-node>
+ <master_node>
<id>master</id>
- <client-ip>127.0.0.1</client-ip>
- <cluster-ip>127.0.0.1</cluster-ip>
- </master-node>
+ <client_ip>127.0.0.1</client_ip>
+ <cluster_ip>127.0.0.1</cluster_ip>
+ </master_node>
<node>
<id>node1</id>
- <cluster-ip>127.0.0.1</cluster-ip>
+ <cluster_ip>127.0.0.1</cluster_ip>
</node>
</cluster>
diff --git a/asterix-installer/src/main/resources/conf/asterix-configuration.xml b/asterix-installer/src/main/resources/conf/asterix-configuration.xml
new file mode 100644
index 0000000..89e9466
--- /dev/null
+++ b/asterix-installer/src/main/resources/conf/asterix-configuration.xml
@@ -0,0 +1,134 @@
+<asterixConfiguration xmlns="asterixconf">
+
+ <property>
+ <name>nc_java_opts</name>
+ <value>-Xmx1024m</value>
+ <description>JVM parameters for each Node Contoller (NC)</description>
+ </property>
+
+ <property>
+ <name>cc_java_opts</name>
+ <value>-Xmx1024m</value>
+ <description>JVM parameters for each Cluster Contoller (CC)</description>
+ </property>
+
+ <property>
+ <name>size_memory_component</name>
+ <value>512m</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>total_size_memory_component</name>
+ <value>512m</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>log_buffer_num_pages</name>
+ <value>8</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>log_buffer_page_size</name>
+ <value></value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>log_buffer_page_size</name>
+ <value>128m</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>group_commit_interval</name>
+ <value>200ms</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>sort_op_memory</name>
+ <value>200m</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>join_op_memory</name>
+ <value>200ms</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>web_interface_port</name>
+ <value>19001</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>num_pages_buffer_cache</name>
+ <value>8</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>log_level</name>
+ <value>INFO</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>lsn_threshold</name>
+ <value>64m</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>checkpointTermsInSecs</name>
+ <value>120</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>escalate_threshold_entity_to_dataset</name>
+ <value>8</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>num_pages_buffer_cache</name>
+ <value>1000</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>logPageSize</name>
+ <value>131072</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>numLogPages</name>
+ <value>131072</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>logPartitionSize</name>
+ <value>2147483648</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>shrink_timer_threshold</name>
+ <value>120000</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>numLogPages</name>
+ <value>131072</value>
+ <description></description>
+ </property>
+</asterixConfiguration>
diff --git a/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixInstallerIntegrationUtil.java b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixInstallerIntegrationUtil.java
new file mode 100644
index 0000000..0a058ff
--- /dev/null
+++ b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixInstallerIntegrationUtil.java
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2009-2013 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.test;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import edu.uci.ics.asterix.installer.command.CommandHandler;
+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.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.model.AsterixRuntimeState;
+import edu.uci.ics.asterix.installer.schema.conf.Configuration;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+import edu.uci.ics.hyracks.api.client.HyracksConnection;
+import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
+
+public class AsterixInstallerIntegrationUtil {
+
+ private static String managixHome;
+ private static String clusterConfigurationPath;
+ private static final CommandHandler cmdHandler = new CommandHandler();
+ public static final String ASTERIX_INSTANCE_NAME = "asterix";
+ private static final String CC_IP_ADDRESS = "127.0.0.1";
+ private static final int DEFAULT_HYRACKS_CC_CLIENT_PORT = 1098;
+ private static IHyracksClientConnection hcc;
+
+ private static final Logger LOGGER = Logger.getLogger(AsterixInstallerIntegrationUtil.class.getName());
+
+ public static void deinit() throws Exception {
+ deleteInstance();
+ stopZookeeper();
+ }
+
+ public static void init() throws Exception {
+ File asterixProjectDir = new File(System.getProperty("user.dir"));
+ File installerTargetDir = new File(asterixProjectDir, "target");
+ String managixHomeDirName = installerTargetDir.list(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return new File(dir, name).isDirectory() && name.startsWith("asterix-installer")
+ && name.endsWith("binary-assembly");
+ }
+
+ })[0];
+ managixHome = new File(installerTargetDir, managixHomeDirName).getAbsolutePath();
+ System.setProperty("log4j.configuration", managixHome + File.separator + "conf" + File.separator
+ + "log4j.properties");
+
+ managixHome = AsterixInstallerIntegrationUtil.getManagixHome();
+ clusterConfigurationPath = managixHome + File.separator + "clusters" + File.separator + "local"
+ + File.separator + "local.xml";
+
+ InstallerDriver.setManagixHome(managixHome);
+
+ String command = "configure";
+ cmdHandler.processCommand(command.split(" "));
+ command = "validate -c " + clusterConfigurationPath;
+ cmdHandler.processCommand(command.split(" "));
+
+ startZookeeper();
+ InstallerDriver.initConfig();
+ createInstance();
+ hcc = new HyracksConnection(CC_IP_ADDRESS, DEFAULT_HYRACKS_CC_CLIENT_PORT);
+ }
+
+ public static IHyracksClientConnection getHyracksConnection() {
+ return hcc;
+ }
+
+ private static void startZookeeper() throws IOException, JAXBException, InterruptedException {
+ initZookeeperTestConfiguration();
+ String script = managixHome + File.separator + "bin" + File.separator + "managix";
+
+ // shutdown zookeeper if running
+ ProcessBuilder pb = new ProcessBuilder(script, "shutdown");
+ Map<String, String> env = pb.environment();
+ env.put("MANAGIX_HOME", managixHome);
+ pb.start();
+ Thread.sleep(2000);
+
+ // start zookeeper
+ ProcessBuilder pb2 = new ProcessBuilder(script, "describe");
+ Map<String, String> env2 = pb2.environment();
+ env2.put("MANAGIX_HOME", managixHome);
+ pb2.start();
+
+ Thread.sleep(2000);
+ }
+
+ public static void createInstance() throws Exception {
+
+ String command = null;
+ AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService()
+ .getAsterixInstance(ASTERIX_INSTANCE_NAME);
+ if (instance != null) {
+ transformIntoRequiredState(State.INACTIVE);
+ command = "delete -n " + ASTERIX_INSTANCE_NAME;
+ cmdHandler.processCommand(command.split(" "));
+ }
+
+ command = "create -n " + ASTERIX_INSTANCE_NAME + " " + "-c" + " " + clusterConfigurationPath;
+ cmdHandler.processCommand(command.split(" "));
+
+ instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(ASTERIX_INSTANCE_NAME);
+ AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
+ assert (state.getFailedNCs().isEmpty() && state.isCcRunning());
+ }
+
+ private static void initZookeeperTestConfiguration() throws JAXBException, FileNotFoundException {
+ String installerConfPath = InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_CONF_XML;
+ JAXBContext ctx = JAXBContext.newInstance(Configuration.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ Configuration configuration = (Configuration) unmarshaller.unmarshal(new File(installerConfPath));
+ configuration.getZookeeper().setClientPort(new BigInteger("3945"));
+ Marshaller marshaller = ctx.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ marshaller.marshal(configuration, new FileOutputStream(installerConfPath));
+ }
+
+ public static void transformIntoRequiredState(AsterixInstance.State state) throws Exception {
+ AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService()
+ .getAsterixInstance(ASTERIX_INSTANCE_NAME);
+ assert (instance != null);
+ if (instance.getState().equals(state)) {
+ return;
+ }
+ if (state.equals(AsterixInstance.State.UNUSABLE)) {
+ throw new IllegalArgumentException("Invalid desired state");
+ }
+
+ String command = null;
+ switch (instance.getState()) {
+ case ACTIVE:
+ command = "stop -n " + ASTERIX_INSTANCE_NAME;
+ break;
+ case INACTIVE:
+ command = "start -n " + ASTERIX_INSTANCE_NAME;
+ break;
+ }
+ cmdHandler.processCommand(command.split(" "));
+ }
+
+ private static void stopZookeeper() throws IOException, JAXBException {
+ String script = managixHome + File.separator + "bin" + File.separator + "managix";
+ // shutdown zookeeper if running
+ ProcessBuilder pb = new ProcessBuilder(script, "shutdown");
+ Map<String, String> env = pb.environment();
+ env.put("MANAGIX_HOME", managixHome);
+ pb.start();
+ }
+
+ private static void deleteInstance() throws Exception {
+ String command = null;
+ AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService()
+ .getAsterixInstance(ASTERIX_INSTANCE_NAME);
+
+ if (instance == null) {
+ return;
+ } else {
+ transformIntoRequiredState(State.INACTIVE);
+ command = "delete -n " + ASTERIX_INSTANCE_NAME;
+ cmdHandler.processCommand(command.split(" "));
+ }
+ instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(ASTERIX_INSTANCE_NAME);
+ assert (instance == null);
+ }
+
+ public static String getManagixHome() {
+ return managixHome;
+ }
+
+ public static void installLibrary(String libraryName, String libraryDataverse, String libraryPath) throws Exception {
+ transformIntoRequiredState(State.INACTIVE);
+ String command = "install -n " + ASTERIX_INSTANCE_NAME + " -d " + libraryDataverse + " -l " + libraryName
+ + " -p " + libraryPath;
+ cmdHandler.processCommand(command.split(" "));
+ }
+
+ public static void uninstallLibrary(String dataverseName, String libraryName) throws Exception {
+ transformIntoRequiredState(State.INACTIVE);
+ String command = "uninstall -n " + ASTERIX_INSTANCE_NAME + " -d " + dataverseName + " -l " + "libraryName";
+ cmdHandler.processCommand(command.split(" "));
+ }
+
+ public static void executeCommand(String command) throws Exception {
+ cmdHandler.processCommand(command.trim().split(" "));
+ }
+
+}
diff --git a/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixLifecycleIT.java b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixLifecycleIT.java
new file mode 100644
index 0000000..98c6bf0
--- /dev/null
+++ b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixLifecycleIT.java
@@ -0,0 +1,119 @@
+package edu.uci.ics.asterix.installer.test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runners.Parameterized.Parameters;
+
+import edu.uci.ics.asterix.installer.command.CommandHandler;
+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;
+import edu.uci.ics.asterix.test.aql.TestsUtils;
+import edu.uci.ics.asterix.testframework.context.TestCaseContext;
+
+public class AsterixLifecycleIT {
+
+ private static final int NUM_NC = 1;
+ private static final CommandHandler cmdHandler = new CommandHandler();
+ private static final String PATH_BASE = "src/test/resources/integrationts/lifecycle";
+ private static final String PATH_ACTUAL = "ittest/";
+ private static final Logger LOGGER = Logger.getLogger(AsterixLifecycleIT.class.getName());
+ private static List<TestCaseContext> testCaseCollection;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ AsterixInstallerIntegrationUtil.init();
+ TestCaseContext.Builder b = new TestCaseContext.Builder();
+ testCaseCollection = b.build(new File(PATH_BASE));
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ AsterixInstallerIntegrationUtil.deinit();
+ }
+
+ @Parameters
+ public static Collection<Object[]> tests() throws Exception {
+ Collection<Object[]> testArgs = new ArrayList<Object[]>();
+ return testArgs;
+ }
+
+ @Test
+ public void testStopActiveInstance() throws Exception {
+ try {
+ AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.ACTIVE);
+ String command = "stop -n " + AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME;
+ cmdHandler.processCommand(command.split(" "));
+ AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(
+ AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME);
+ AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
+ assert (state.getFailedNCs().size() == NUM_NC && !state.isCcRunning());
+ LOGGER.info("Test stop active instance PASSED");
+ } catch (Exception e) {
+ throw new Exception("Test configure installer " + "\" FAILED!", e);
+ }
+ }
+
+ @Test
+ public void testStartActiveInstance() throws Exception {
+ try {
+ AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.INACTIVE);
+ String command = "start -n " + AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME;
+ cmdHandler.processCommand(command.split(" "));
+ AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(
+ AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME);
+ AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
+ assert (state.getFailedNCs().size() == 0 && state.isCcRunning());
+ LOGGER.info("Test start active instance PASSED");
+ } catch (Exception e) {
+ throw new Exception("Test configure installer " + "\" FAILED!", e);
+ }
+ }
+
+ @Test
+ public void testDeleteActiveInstance() throws Exception {
+ try {
+ AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.INACTIVE);
+ String command = "delete -n " + AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME;
+ cmdHandler.processCommand(command.split(" "));
+ AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(
+ AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME);
+ assert (instance == null);
+ LOGGER.info("Test delete active instance PASSED");
+ } catch (Exception e) {
+ throw new Exception("Test delete active instance " + "\" FAILED!", e);
+ } finally {
+ // recreate instance
+ AsterixInstallerIntegrationUtil.createInstance();
+ }
+ }
+
+ @Test
+ public void test() throws Exception {
+ for (TestCaseContext testCaseCtx : testCaseCollection) {
+ TestsUtils.executeTest(PATH_ACTUAL, testCaseCtx);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ try {
+ setUp();
+ new AsterixLifecycleIT().test();
+ } catch (Exception e) {
+ e.printStackTrace();
+ LOGGER.info("TEST CASE(S) FAILED");
+ } finally {
+ tearDown();
+ }
+ }
+
+}
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.1.ddl.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.1.ddl.aql
new file mode 100644
index 0000000..87b762b
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.1.ddl.aql
@@ -0,0 +1 @@
+create dataverse backupDataverse;
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.2.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.2.mgx.aql
new file mode 100644
index 0000000..2d8a23e
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.2.mgx.aql
@@ -0,0 +1 @@
+stop -n asterix
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.3.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.3.mgx.aql
new file mode 100644
index 0000000..baf9551
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.3.mgx.aql
@@ -0,0 +1 @@
+backup -n asterix
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.4.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.4.mgx.aql
new file mode 100644
index 0000000..4e99f33
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.4.mgx.aql
@@ -0,0 +1 @@
+start -n asterix
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.5.ddl.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.5.ddl.aql
new file mode 100644
index 0000000..3b6f51b
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.5.ddl.aql
@@ -0,0 +1,2 @@
+drop dataverse backupDataverse;
+
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.6.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.6.mgx.aql
new file mode 100644
index 0000000..2d8a23e
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.6.mgx.aql
@@ -0,0 +1 @@
+stop -n asterix
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.7.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.7.mgx.aql
new file mode 100644
index 0000000..063616b
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.7.mgx.aql
@@ -0,0 +1 @@
+restore -n asterix -b 0
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.8.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.8.mgx.aql
new file mode 100644
index 0000000..4e99f33
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.8.mgx.aql
@@ -0,0 +1 @@
+start -n asterix
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.9.query.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.9.query.aql
new file mode 100644
index 0000000..4833c1b
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.9.query.aql
@@ -0,0 +1,3 @@
+for $x in dataset Metadata.Dataverse
+where $x.DataverseName='backupDataverse'
+return $x
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/results/asterix-lifecycle/backupRestore/backupRestore.1.adm b/asterix-installer/src/test/resources/integrationts/lifecycle/results/asterix-lifecycle/backupRestore/backupRestore.1.adm
new file mode 100644
index 0000000..722abfd
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/results/asterix-lifecycle/backupRestore/backupRestore.1.adm
@@ -0,0 +1 @@
+{ "DataverseName": "backupDataverse", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Wed Apr 24 16:13:46 PDT 2013", "PendingOp": 0 }
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/testsuite.xml b/asterix-installer/src/test/resources/integrationts/lifecycle/testsuite.xml
new file mode 100644
index 0000000..48f548f
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/testsuite.xml
@@ -0,0 +1,10 @@
+<test-suite xmlns="urn:xml.testframework.asterix.ics.uci.edu" ResultOffsetPath="results" QueryOffsetPath="queries" QueryFileExtension=".aql">
+ <test-group name="lifecycle">
+ <test-case FilePath="asterix-lifecycle">
+ <compilation-unit name="backupRestore">
+ <output-dir compare="Text">backupRestore</output-dir>
+ </compilation-unit>
+ </test-case>
+ </test-group>
+</test-suite>
+
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IAsterixStateProxy.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IAsterixStateProxy.java
index 5f772c7..d67cd27 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IAsterixStateProxy.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IAsterixStateProxy.java
@@ -19,7 +19,7 @@
import java.rmi.Remote;
import java.rmi.RemoteException;
-import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
/**
* Interface for setting/getting distributed state of Asterix.
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixProperties.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixProperties.java
deleted file mode 100644
index 71a7de3..0000000
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixProperties.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2009-2010 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.metadata.bootstrap;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-
-import edu.uci.ics.asterix.common.config.GlobalConfig;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-
-/**
- * Holder for Asterix properties values typically set as Java Properties.
- * Intended to live in the AsterixStateProxy so it can be accessed remotely.
- */
-public class AsterixProperties implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private static String metadataNodeName;
- private static Boolean isNewUniverse;
- private static HashSet<String> nodeNames;
- private static Map<String, String[]> stores;
- private static String outputDir;
-
- public static AsterixProperties INSTANCE = new AsterixProperties();
-
- private AsterixProperties() {
- try {
- initializeProperties();
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- private void initializeProperties() throws AlgebricksException {
- Properties p = new Properties();
- String fileName = System.getProperty(GlobalConfig.CONFIG_FILE_PROPERTY);
- if (fileName == null) {
- fileName = GlobalConfig.DEFAULT_CONFIG_FILE_NAME;
- }
-
- InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName);
- if (is == null) {
- try {
- fileName = GlobalConfig.DEFAULT_CONFIG_FILE_NAME;
- is = new FileInputStream(fileName);
- } catch (FileNotFoundException fnf) {
- throw new AlgebricksException("Could not find the configuration file " + fileName);
- }
- }
- try {
- p.load(is);
- is.close();
- } catch (IOException e) {
- throw new AlgebricksException(e);
- }
- Enumeration<String> pNames = (Enumeration<String>) p.propertyNames();
- stores = new HashMap<String, String[]>();
- boolean newUniverseChosen = false;
- String pn;
- String val;
- while (pNames.hasMoreElements()) {
- pn = pNames.nextElement();
- if (pn.equals("MetadataNode")) {
- val = p.getProperty(pn);
- metadataNodeName = val;
- } else if (pn.equals("NewUniverse")) {
- val = p.getProperty(pn);
- newUniverseChosen = true;
- isNewUniverse = Boolean.parseBoolean(val);
- } else if (pn.equals("OutputDir")) {
- val = p.getProperty(pn);
- outputDir = val;
- } else {
- String ncName = pn.substring(0, pn.indexOf('.'));
- val = p.getProperty(pn);
- String[] folderNames = val.split("\\s*,\\s*");
- int i = 0;
- for (String store : folderNames) {
- boolean needsStartSep = !store.startsWith(File.separator);
- boolean needsEndSep = !store.endsWith(File.separator);
- if (needsStartSep && needsEndSep) {
- folderNames[i] = File.separator + store + File.separator;
- } else if (needsStartSep) {
- folderNames[i] = File.separator + store;
- } else if (needsEndSep) {
- folderNames[i] = store + File.separator;
- }
- i++;
- }
- stores.put(ncName, folderNames);
- nodeNames = new HashSet<String>();
- nodeNames.addAll(stores.keySet());
- }
- }
- if (metadataNodeName == null)
- throw new AlgebricksException("You need to specify the metadata node!");
- if (!newUniverseChosen)
- throw new AlgebricksException("You need to specify whether or not you want to start a new universe!");
- }
-
- public Boolean isNewUniverse() {
- return isNewUniverse;
- }
-
- public String getMetadataNodeName() {
- return metadataNodeName;
- }
-
- public String getMetadataStore() {
- return stores.get(metadataNodeName)[0];
- }
-
- public Map<String, String[]> getStores() {
- return stores;
- }
-
- public HashSet<String> getNodeNames() {
- return nodeNames;
- }
-
- public String getOutputDir() {
- return outputDir;
- }
-}
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixStateProxy.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixStateProxy.java
index 3946fa6..55aaf33 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixStateProxy.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixStateProxy.java
@@ -19,6 +19,7 @@
import java.rmi.server.UnicastRemoteObject;
import java.util.logging.Logger;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
import edu.uci.ics.asterix.metadata.api.IAsterixStateProxy;
import edu.uci.ics.asterix.metadata.api.IMetadataNode;
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 73aa6dc..d978f8a 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
@@ -26,6 +26,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
import edu.uci.ics.asterix.common.config.DatasetConfig.IndexType;
import edu.uci.ics.asterix.common.config.GlobalConfig;
@@ -153,11 +154,6 @@
nodeNames = asterixProperties.getNodeNames();
// nodeStores = asterixProperity.getStores();
- outputDir = asterixProperties.getOutputDir();
- if (outputDir != null) {
- (new File(outputDir)).mkdirs();
- }
-
indexLifecycleManager = runtimeContext.getIndexLifecycleManager();
localResourceRepository = runtimeContext.getLocalResourceRepository();
bufferCache = runtimeContext.getBufferCache();
@@ -332,7 +328,7 @@
}
public static void enlistMetadataDataset(IMetadataIndex index, boolean create) throws Exception {
- String filePath = metadataStore + index.getFileNameRelativePath();
+ String filePath = metadataStore + File.separator + index.getFileNameRelativePath();
FileReference file = new FileReference(new File(filePath));
IInMemoryBufferCache memBufferCache = new InMemoryBufferCache(new HeapBufferAllocator(), DEFAULT_MEM_PAGE_SIZE,
DEFAULT_MEM_NUM_PAGES, new TransientFileMapManager());
@@ -395,6 +391,7 @@
MetadataTransactionContext mdTxnCtx = null;
MetadataManager.INSTANCE.acquireWriteLatch();
+
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Starting DDL recovery ...");
}
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlCompiledMetadataDeclarations.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlCompiledMetadataDeclarations.java
index 35a9b83..70383f9 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlCompiledMetadataDeclarations.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlCompiledMetadataDeclarations.java
@@ -22,6 +22,7 @@
import java.util.logging.Logger;
import edu.uci.ics.asterix.common.annotations.TypeDataGen;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.formats.base.IDataFormat;
@@ -29,7 +30,6 @@
import edu.uci.ics.asterix.metadata.MetadataManager;
import edu.uci.ics.asterix.metadata.MetadataTransactionContext;
import edu.uci.ics.asterix.metadata.api.IMetadataManager;
-import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
import edu.uci.ics.asterix.metadata.entities.Dataset;
import edu.uci.ics.asterix.metadata.entities.Datatype;
import edu.uci.ics.asterix.metadata.entities.Dataverse;
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 e1f707c..5e759b1 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
@@ -23,6 +23,7 @@
import java.util.Map;
import java.util.logging.Logger;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
import edu.uci.ics.asterix.common.config.DatasetConfig.IndexType;
import edu.uci.ics.asterix.common.config.GlobalConfig;
@@ -47,7 +48,6 @@
import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.metadata.MetadataManager;
import edu.uci.ics.asterix.metadata.MetadataTransactionContext;
-import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataConstants;
import edu.uci.ics.asterix.metadata.dataset.hints.DatasetHints.DatasetCardinalityHint;
import edu.uci.ics.asterix.metadata.entities.Dataset;
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManagementConstants.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManagementConstants.java
index 3d25e54..7d04f61 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManagementConstants.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManagementConstants.java
@@ -29,7 +29,6 @@
public static final String LOG_CONF_DIR = "log_conf";
public static final String LOG_CONF_FILE = "log.properties";
public static final String ASTERIX_CONF_DIR = "src/main/resources";
- public static final String ASTERIX_CONF_FILE = "test.properties";
public static final String DEFAULT_LOG_DIR = "asterix_logs";
public static final int TERMINAL_LSN = -1;
}