Committing the following:- 1) integration tests for managix 2) support for configurable parameters in Asterix 3) refactoring of test cases (removing code duplication
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 7364728..eed0f80 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
@@ -71,6 +71,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;
@@ -78,7 +79,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;
@@ -183,7 +183,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);
@@ -242,7 +241,6 @@
insertOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
leafOperator = new SinkOperator();
leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(insertOp));
- isTransactionalWrite = true;
break;
}
case DELETE: {
@@ -251,7 +249,6 @@
deleteOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
leafOperator = new SinkOperator();
leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(deleteOp));
- isTransactionalWrite = true;
break;
}
case BEGIN_FEED: {
@@ -260,7 +257,6 @@
insertOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
leafOperator = new SinkOperator();
leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(insertOp));
- isTransactionalWrite = false;
break;
}
}
@@ -289,12 +285,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 12194c5..15af3bc 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>org.apache.hadoop</groupId>
<artifactId>hadoop-core</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 bd8d2b8..428781f 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
@@ -1554,4 +1554,4 @@
throw new IllegalStateException(rootE);
}
}
-}
+}
\ No newline at end of file
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..1b8990b 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));
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-build-configuration.xml b/asterix-app/src/main/resources/asterix-build-configuration.xml
new file mode 100644
index 0000000..8769b43
--- /dev/null
+++ b/asterix-app/src/main/resources/asterix-build-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>INFO</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/aql/TestsUtils.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
deleted file mode 100644
index 04f1aae..0000000
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
+++ /dev/null
@@ -1,198 +0,0 @@
-package edu.uci.ics.asterix.test.aql;
-
-import static org.junit.Assert.fail;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException;
-
-public class TestsUtils {
-
- private static final String EXTENSION_AQL_RESULT = "adm";
-
- /**
- * Probably does not work well with symlinks.
- */
- public static boolean deleteRec(File path) {
- if (path.isDirectory()) {
- for (File f : path.listFiles()) {
- if (!deleteRec(f)) {
- return false;
- }
- }
- }
- return path.delete();
- }
-
- public static void runScriptAndCompareWithResult(File scriptFile, PrintWriter print, File expectedFile,
- File actualFile) throws Exception {
- BufferedReader readerExpected = new BufferedReader(new InputStreamReader(new FileInputStream(expectedFile),
- "UTF-8"));
- BufferedReader readerActual = new BufferedReader(
- new InputStreamReader(new FileInputStream(actualFile), "UTF-8"));
- String lineExpected, lineActual;
- int num = 1;
- try {
- while ((lineExpected = readerExpected.readLine()) != null) {
- lineActual = readerActual.readLine();
- // Assert.assertEquals(lineExpected, lineActual);
- if (lineActual == null) {
- if (lineExpected.isEmpty()) {
- continue;
- }
- throw new Exception("Result for " + scriptFile + " changed at line " + num + ":\n< " + lineExpected
- + "\n> ");
- }
-
- if (!equalStrings(lineExpected.split("Timestamp")[0], lineActual.split("Timestamp")[0])) {
- fail("Result for " + scriptFile + " changed at line " + num + ":\n< " + lineExpected + "\n> "
- + lineActual);
- }
-
- ++num;
- }
- lineActual = readerActual.readLine();
- // Assert.assertEquals(null, lineActual);
- if (lineActual != null) {
- throw new Exception("Result for " + scriptFile + " changed at line " + num + ":\n< \n> " + lineActual);
- }
- // actualFile.delete();
- } finally {
- readerExpected.close();
- readerActual.close();
- }
-
- }
-
- private static boolean equalStrings(String s1, String s2) {
- String[] rowsOne = s1.split("\n");
- String[] rowsTwo = s2.split("\n");
-
- for (int i = 0; i < rowsOne.length; i++) {
- String row1 = rowsOne[i];
- String row2 = rowsTwo[i];
-
- if (row1.equals(row2))
- continue;
-
- String[] fields1 = row1.split(" ");
- String[] fields2 = row2.split(" ");
-
- for (int j = 0; j < fields1.length; j++) {
- if (fields1[j].equals(fields2[j])) {
- continue;
- } else if (fields1[j].indexOf('.') < 0) {
- return false;
- } else {
- fields1[j] = fields1[j].split(",")[0];
- fields2[j] = fields2[j].split(",")[0];
- Double double1 = Double.parseDouble(fields1[j]);
- Double double2 = Double.parseDouble(fields2[j]);
- float float1 = (float) double1.doubleValue();
- float float2 = (float) double2.doubleValue();
-
- if (Math.abs(float1 - float2) == 0)
- continue;
- else {
- return false;
- }
- }
- }
- }
- return true;
- }
-
- public static String aqlExtToResExt(String fname) {
- int dot = fname.lastIndexOf('.');
- return fname.substring(0, dot + 1) + EXTENSION_AQL_RESULT;
- }
-
- public static void writeResultsToFile(File actualFile, JSONObject result) throws IOException, JSONException {
- BufferedWriter writer = new BufferedWriter(new FileWriter(actualFile));
- Results res = new Results(result);
- for (String line : res) {
- writer.write(line);
- writer.newLine();
- }
- writer.close();
- }
-
- public static class Results implements Iterable<String> {
- private final JSONArray chunks;
-
- public Results(JSONObject result) throws JSONException {
- chunks = result.getJSONArray("results");
- }
-
- public Iterator<String> iterator() {
- return new ResultIterator(chunks);
- }
- }
-
- public static class ResultIterator implements Iterator<String> {
- private final JSONArray chunks;
-
- private int chunkCounter = 0;
- private int recordCounter = 0;
-
- public ResultIterator(JSONArray chunks) {
- this.chunks = chunks;
- }
-
- @Override
- public boolean hasNext() {
- JSONArray resultArray;
- try {
- resultArray = chunks.getJSONArray(chunkCounter);
- if (resultArray.getString(recordCounter) != null) {
- return true;
- }
- } catch (JSONException e) {
- return false;
- }
- return false;
- }
-
- @Override
- public String next() throws NoSuchElementException {
- JSONArray resultArray;
- String item = "";
-
- try {
- resultArray = chunks.getJSONArray(chunkCounter);
- item = resultArray.getString(recordCounter);
- if (item == null) {
- throw new NoSuchElementException();
- }
- item = item.trim();
-
- recordCounter++;
- if (recordCounter >= resultArray.length()) {
- chunkCounter++;
- recordCounter = 0;
- }
- } catch (JSONException e) {
- throw new NoSuchElementException(e.getMessage());
- }
- return item;
- }
-
- @Override
- public void remove() {
- throw new NotImplementedException();
- }
- }
-}
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..6339c07 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-build-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..bb66d0d 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-build-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..6478d0a 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-build-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..20a0d11
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixProperties.java
@@ -0,0 +1,252 @@
+/*
+ * 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";
+ public static final String NC_JAVA_OPTS_DEFAULT = "-Xmx1024m";
+
+ // JVM parameters for the Cluster Contoller (CC)
+ public static final String CC_JAVA_OPTS = "cc_java_opts";
+ public static final String CC_JAVA_OPTS_DEFAULT = "-Xmx1024m";
+
+ public static final String SIZE_MEMORY_COMPONENT = "size_memory_component";
+ public static final String SIZE_MEMORY_COMPONENT_DEFAULT = "512m";
+
+ public static final String TOTAL_SIZE_MEMORY_COMPONENT = "total_size_memory_component";
+ public static final String TOTAL_SIZE_MEMORY_COMPONENT_DEFAULT = "512m";
+
+ public static final String LOG_BUFFER_NUM_PAGES = "log_buffer_num_pages";
+ public static final String LOG_BUFFER_NUM_PAGES_DEFAULT = "8";
+
+ public static final String LOG_BUFFER_PAGE_SIZE = "log_buffer_page_size";
+ public static final String LOG_BUFFER_PAGE_SIZE_DEFAULT = "131072";
+
+ public static final String LOG_PARTITION_SIZE = "log_partition_size";
+ public static final String LOG_PARTITION_SIZE_DEFAULT = "2147483648";
+
+ public static final String GROUP_COMMIT_INTERVAL = "group_commit_interval";
+ public static final String GROUP_COMMIT_INTERVAL_DEFAULT = "200ms";
+
+ public static final String SORT_OP_MEMORY = "sort_op_memory";
+ public static final String SORT_OP_MEMORY_DEFAULT = "512m";
+
+ public static final String JOIN_OP_MEMORY = "join_op_memory";
+ public static final String JOIN_OP_MEMORY_DEFAULT = "512m";
+
+ public static final String WEB_INTERFACE_PORT = "web_interface_port";
+ public static final String WEB_INTERFACE_PORT_DEFAULT = "19001";
+
+ public static final String NUM_PAGES_BUFFER_CACHE = "num_pages_buffer_cache";
+ public static final String NUM_PAGES_BUFFER_CACHE_DEFAULT = "1000";
+
+ public static final String LOG_LEVEL = "log_level";
+ public static final String LOG_LEVEL_DEFAULT = "INFO";
+
+ public static final String LSN_THRESHOLD = "lsn_threshold";
+ public static final String LSN_THRESHOLD_DEFAULT = "64m";
+
+ public static final String CHECKPOINT_TERMS_IN_SECS = "checkpoint_terms_in_secs";
+ public static final String CHECKPOINT_TERMS_IN_SECS_DEFAULT = "120";
+
+ public static final String ESCALATE_THRSHOLD_ENTITY_TO_DATASET = "escalate_threshold_entity_to_dataset";
+ public static final String ESCALATE_THRSHOLD_ENTITY_TO_DATASET_DEFAULT = "8";
+
+ public static final String SHRINK_TIMER_THRESHOLD = "shrink_timer_threshold";
+ public static final String 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));
+ } 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 propValue = asterixConfigurationParams.get(property);
+ if (propValue == null) {
+ switch (property) {
+ case AsterixConfigurationKeys.NC_JAVA_OPTS:
+ propValue = AsterixConfigurationKeys.NC_JAVA_OPTS_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.CC_JAVA_OPTS:
+ propValue = AsterixConfigurationKeys.CC_JAVA_OPTS_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.SIZE_MEMORY_COMPONENT:
+ propValue = AsterixConfigurationKeys.SIZE_MEMORY_COMPONENT_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.TOTAL_SIZE_MEMORY_COMPONENT:
+ propValue = AsterixConfigurationKeys.TOTAL_SIZE_MEMORY_COMPONENT_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.LOG_BUFFER_NUM_PAGES:
+ propValue = AsterixConfigurationKeys.LOG_BUFFER_NUM_PAGES_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.LOG_BUFFER_PAGE_SIZE:
+ propValue = AsterixConfigurationKeys.LOG_BUFFER_PAGE_SIZE_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.LOG_PARTITION_SIZE:
+ propValue = AsterixConfigurationKeys.LOG_PARTITION_SIZE_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.GROUP_COMMIT_INTERVAL:
+ propValue = AsterixConfigurationKeys.GROUP_COMMIT_INTERVAL_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.SORT_OP_MEMORY:
+ propValue = AsterixConfigurationKeys.SORT_OP_MEMORY_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.JOIN_OP_MEMORY:
+ propValue = AsterixConfigurationKeys.JOIN_OP_MEMORY_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.WEB_INTERFACE_PORT:
+ propValue = AsterixConfigurationKeys.WEB_INTERFACE_PORT_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.NUM_PAGES_BUFFER_CACHE:
+ propValue = AsterixConfigurationKeys.NUM_PAGES_BUFFER_CACHE_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.LOG_LEVEL:
+ propValue = AsterixConfigurationKeys.LOG_LEVEL_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.LSN_THRESHOLD:
+ propValue = AsterixConfigurationKeys.LSN_THRESHOLD_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.CHECKPOINT_TERMS_IN_SECS:
+ propValue = AsterixConfigurationKeys.CHECKPOINT_TERMS_IN_SECS_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.ESCALATE_THRSHOLD_ENTITY_TO_DATASET:
+ propValue = AsterixConfigurationKeys.ESCALATE_THRSHOLD_ENTITY_TO_DATASET_DEFAULT;
+ break;
+ case AsterixConfigurationKeys.SHRINK_TIMER_THRESHOLD:
+ propValue = AsterixConfigurationKeys.SHRINK_TIMER_THRESHOLD_DEFAULT;
+ break;
+ }
+ }
+ return propValue;
+ }
+
+ 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-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java b/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
new file mode 100644
index 0000000..7e9b08f
--- /dev/null
+++ b/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
@@ -0,0 +1,428 @@
+package edu.uci.ics.asterix.test.aql;
+
+import static org.junit.Assert.fail;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+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.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+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;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException;
+
+public class TestsUtils {
+
+ private static final String EXTENSION_AQL_RESULT = "adm";
+ private static final Logger LOGGER = Logger.getLogger(TestsUtils.class
+ .getName());
+ private static Method managixExecuteMethod = null;
+
+ /**
+ * Probably does not work well with symlinks.
+ */
+ public static boolean deleteRec(File path) {
+ if (path.isDirectory()) {
+ for (File f : path.listFiles()) {
+ if (!deleteRec(f)) {
+ return false;
+ }
+ }
+ }
+ return path.delete();
+ }
+
+ public static void runScriptAndCompareWithResult(File scriptFile,
+ PrintWriter print, File expectedFile, File actualFile)
+ throws Exception {
+ BufferedReader readerExpected = new BufferedReader(
+ new InputStreamReader(new FileInputStream(expectedFile),
+ "UTF-8"));
+ BufferedReader readerActual = new BufferedReader(new InputStreamReader(
+ new FileInputStream(actualFile), "UTF-8"));
+ String lineExpected, lineActual;
+ int num = 1;
+ try {
+ while ((lineExpected = readerExpected.readLine()) != null) {
+ lineActual = readerActual.readLine();
+ // Assert.assertEquals(lineExpected, lineActual);
+ if (lineActual == null) {
+ if (lineExpected.isEmpty()) {
+ continue;
+ }
+ throw new Exception("Result for " + scriptFile
+ + " changed at line " + num + ":\n< "
+ + lineExpected + "\n> ");
+ }
+
+ if (!equalStrings(lineExpected.split("Timestamp")[0],
+ lineActual.split("Timestamp")[0])) {
+ fail("Result for " + scriptFile + " changed at line " + num
+ + ":\n< " + lineExpected + "\n> " + lineActual);
+ }
+
+ ++num;
+ }
+ lineActual = readerActual.readLine();
+ // Assert.assertEquals(null, lineActual);
+ if (lineActual != null) {
+ throw new Exception("Result for " + scriptFile
+ + " changed at line " + num + ":\n< \n> " + lineActual);
+ }
+ // actualFile.delete();
+ } finally {
+ readerExpected.close();
+ readerActual.close();
+ }
+
+ }
+
+ private static boolean equalStrings(String s1, String s2) {
+ String[] rowsOne = s1.split("\n");
+ String[] rowsTwo = s2.split("\n");
+
+ for (int i = 0; i < rowsOne.length; i++) {
+ String row1 = rowsOne[i];
+ String row2 = rowsTwo[i];
+
+ if (row1.equals(row2))
+ continue;
+
+ String[] fields1 = row1.split(" ");
+ String[] fields2 = row2.split(" ");
+
+ for (int j = 0; j < fields1.length; j++) {
+ if (fields1[j].equals(fields2[j])) {
+ continue;
+ } else if (fields1[j].indexOf('.') < 0) {
+ return false;
+ } else {
+ fields1[j] = fields1[j].split(",")[0];
+ fields2[j] = fields2[j].split(",")[0];
+ Double double1 = Double.parseDouble(fields1[j]);
+ Double double2 = Double.parseDouble(fields2[j]);
+ float float1 = (float) double1.doubleValue();
+ float float2 = (float) double2.doubleValue();
+
+ if (Math.abs(float1 - float2) == 0)
+ continue;
+ else {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public static String aqlExtToResExt(String fname) {
+ int dot = fname.lastIndexOf('.');
+ return fname.substring(0, dot + 1) + EXTENSION_AQL_RESULT;
+ }
+
+ public static void writeResultsToFile(File actualFile, JSONObject result)
+ throws IOException, JSONException {
+ BufferedWriter writer = new BufferedWriter(new FileWriter(actualFile));
+ Results res = new Results(result);
+ for (String line : res) {
+ writer.write(line);
+ writer.newLine();
+ }
+ writer.close();
+ }
+
+ public static class Results implements Iterable<String> {
+ private final JSONArray chunks;
+
+ public Results(JSONObject result) throws JSONException {
+ chunks = result.getJSONArray("results");
+ }
+
+ public Iterator<String> iterator() {
+ return new ResultIterator(chunks);
+ }
+ }
+
+ public static class ResultIterator implements Iterator<String> {
+ private final JSONArray chunks;
+
+ private int chunkCounter = 0;
+ private int recordCounter = 0;
+
+ public ResultIterator(JSONArray chunks) {
+ this.chunks = chunks;
+ }
+
+ @Override
+ public boolean hasNext() {
+ JSONArray resultArray;
+ try {
+ resultArray = chunks.getJSONArray(chunkCounter);
+ if (resultArray.getString(recordCounter) != null) {
+ return true;
+ }
+ } catch (JSONException e) {
+ return false;
+ }
+ return false;
+ }
+
+ @Override
+ public String next() throws NoSuchElementException {
+ JSONArray resultArray;
+ String item = "";
+
+ try {
+ resultArray = chunks.getJSONArray(chunkCounter);
+ item = resultArray.getString(recordCounter);
+ if (item == null) {
+ throw new NoSuchElementException();
+ }
+ item = item.trim();
+
+ recordCounter++;
+ if (recordCounter >= resultArray.length()) {
+ chunkCounter++;
+ recordCounter = 0;
+ }
+ } catch (JSONException e) {
+ throw new NoSuchElementException(e.getMessage());
+ }
+ return item;
+ }
+
+ @Override
+ public void remove() {
+ throw new NotImplementedException();
+ }
+ }
+
+ // Executes Query and returns results as JSONArray
+ public static 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;
+ }
+
+ // To execute Update statements
+ // Insert and Delete statements are executed here
+ public static 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);
+
+ // Check if the method was executed successfully.
+ if (statusCode != HttpStatus.SC_OK) {
+ System.err.println("Method failed: " + method.getStatusLine());
+ }
+ }
+
+ // To execute DDL and Update statements
+ // create type statement
+ // create dataset statement
+ // create index statement
+ // create dataverse statement
+ // create function statement
+ public static 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);
+
+ // Check if the method was executed successfully.
+ if (statusCode != HttpStatus.SC_OK) {
+ System.err.println("Method failed: " + method.getStatusLine());
+ }
+ }
+
+ // 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 static 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();
+ }
+
+ public static void executeManagixCommand(String command)
+ throws ClassNotFoundException, NoSuchMethodException,
+ SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ if (managixExecuteMethod == null) {
+ Class clazz = Class
+ .forName("edu.uci.ics.asterix.installer.test.AsterixInstallerIntegrationUtil");
+ managixExecuteMethod = clazz.getMethod("executeCommand",
+ String.class);
+ }
+ managixExecuteMethod.invoke(null, command);
+ }
+
+ public static void executeTest(String actualPath,
+ TestCaseContext testCaseCtx) throws Exception {
+
+ File testFile;
+ File expectedResultFile;
+ String statement;
+ List<TestFileContext> expectedResultFileCtxs;
+ List<TestFileContext> testFileCtxs;
+
+ int queryCount = 0;
+ JSONObject result;
+
+ List<CompilationUnit> cUnits = testCaseCtx.getTestCase()
+ .getCompilationUnit();
+ for (CompilationUnit cUnit : cUnits) {
+ LOGGER.info("[TEST]: " + testCaseCtx.getTestCase().getFilePath()
+ + "/" + cUnit.getName());
+
+ testFileCtxs = testCaseCtx.getTestFiles(cUnit);
+ expectedResultFileCtxs = testCaseCtx.getExpectedResultFiles(cUnit);
+
+ for (TestFileContext ctx : testFileCtxs) {
+ testFile = ctx.getFile();
+ statement = TestsUtils.readTestFile(testFile);
+ try {
+ switch (ctx.getType()) {
+ case "ddl":
+ TestsUtils.executeDDL(statement);
+ break;
+ case "update":
+ TestsUtils.executeUpdate(statement);
+ break;
+ case "query":
+ result = TestsUtils.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(actualPath
+ + File.separator
+ + testCaseCtx.getTestCase().getFilePath()
+ .replace(File.separator, "_") + "_"
+ + cUnit.getName() + ".adm");
+
+ File actualResultFile = testCaseCtx
+ .getActualResultFile(cUnit, new File(
+ actualPath));
+ actualResultFile.getParentFile().mkdirs();
+
+ TestsUtils.writeResultsToFile(actualFile, result);
+
+ TestsUtils.runScriptAndCompareWithResult(testFile,
+ new PrintWriter(System.err),
+ expectedResultFile, actualFile);
+ }
+ queryCount++;
+ break;
+ case "mgx":
+ executeManagixCommand(statement);
+ 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-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..10e7df2 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
@@ -15,7 +15,6 @@
package edu.uci.ics.asterix.installer.command;
import java.io.File;
-import java.net.InetAddress;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -32,7 +31,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 +108,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 +161,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());
@@ -183,7 +181,6 @@
private boolean validateNodeConfiguration(Node node, Cluster cluster) {
boolean valid = true;
- valid = checkNodeReachability(node.getClusterIp());
if (node.getJavaHome() == null || node.getJavaHome().length() == 0) {
if (cluster.getJavaHome() == null || cluster.getJavaHome().length() == 0) {
valid = false;
@@ -191,8 +188,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);
}
@@ -252,33 +249,13 @@
+ File.separator + InstallerDriver.MANAGIX_CONF_XML);
}
- for (String server : zk.getServers().getServer()) {
- valid = valid && checkNodeReachability(server);
- }
-
- if (valid)
+ if (valid) {
valid = valid & checkPasswordLessSSHLogin(System.getProperty("user.name"), zk.getServers().getServer());
- {
}
return valid;
}
- private boolean checkNodeReachability(String server) {
- boolean reachable = true;
- try {
- InetAddress address = InetAddress.getByName(server);
- if (!address.isReachable(1000)) {
- LOGGER.fatal("\n" + "Server: " + server + " unreachable" + ERROR);
- reachable = false;
- }
- } catch (Exception e) {
- reachable = false;
- LOGGER.fatal("\n" + "Server: " + server + " Invalid address" + ERROR);
- }
- return reachable;
- }
-
}
class ValidateConfig extends CommandConfig {
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..dc6f643
--- /dev/null
+++ b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixInstallerIntegrationUtil.java
@@ -0,0 +1,218 @@
+/*
+ * 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.command.ShutdownCommand;
+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 final int zookeeperClientPort = 2900;
+ private static final int zookeeperTestClientPort = 3945;
+
+ 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 Exception {
+ initZookeeperTestConfiguration(zookeeperClientPort);
+ String script = managixHome + File.separator + "bin" + File.separator + "managix";
+
+ // shutdown zookeeper if running
+ String command = "shutdown";
+ cmdHandler.processCommand(command.split(" "));
+
+ Thread.sleep(2000);
+
+ // start zookeeper
+ initZookeeperTestConfiguration(zookeeperTestClientPort);
+ 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(int port) 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("" + port));
+ 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;
}