support for configurable parameters for an asterix instance
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
index caa16d4..0f01466 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
@@ -72,6 +72,7 @@
import edu.uci.ics.asterix.aql.expression.WriteStatement;
import edu.uci.ics.asterix.aql.expression.visitor.IAqlExpressionVisitor;
import edu.uci.ics.asterix.aql.util.FunctionUtils;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.common.functions.FunctionConstants;
@@ -79,7 +80,6 @@
import edu.uci.ics.asterix.formats.base.IDataFormat;
import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.metadata.MetadataManager;
-import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
import edu.uci.ics.asterix.metadata.declared.AqlDataSource;
import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
import edu.uci.ics.asterix.metadata.declared.AqlSourceId;
@@ -185,7 +185,6 @@
new EmptyTupleSourceOperator()));
ArrayList<Mutable<ILogicalOperator>> globalPlanRoots = new ArrayList<Mutable<ILogicalOperator>>();
- boolean isTransactionalWrite = false;
ILogicalOperator topOp = p.first;
ProjectOperator project = (ProjectOperator) topOp;
LogicalVariable resVar = project.getVariables().get(0);
@@ -244,7 +243,6 @@
insertOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
leafOperator = new SinkOperator();
leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(insertOp));
- isTransactionalWrite = true;
break;
}
case DELETE: {
@@ -253,7 +251,6 @@
deleteOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
leafOperator = new SinkOperator();
leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(deleteOp));
- isTransactionalWrite = true;
break;
}
case BEGIN_FEED: {
@@ -262,7 +259,6 @@
insertOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
leafOperator = new SinkOperator();
leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(insertOp));
- isTransactionalWrite = false;
break;
}
}
@@ -291,12 +287,9 @@
}
private FileSplit getDefaultOutputFileLocation() throws MetadataException {
- if (AsterixProperties.INSTANCE.getOutputDir() == null) {
- throw new MetadataException(
- "Output location for query result not specified at the time of deployment, must specify explicitly using 'write output to ..' statement");
- }
- String filePath = AsterixProperties.INSTANCE.getOutputDir() + System.getProperty("file.separator")
- + OUTPUT_FILE_PREFIX + outputFileID.incrementAndGet();
+ String outputDir = System.getProperty("java.io.tmpDir");
+ String filePath = outputDir + System.getProperty("file.separator") + OUTPUT_FILE_PREFIX
+ + outputFileID.incrementAndGet();
return new FileSplit(AsterixProperties.INSTANCE.getMetadataNodeName(), new FileReference(new File(filePath)));
}
diff --git a/asterix-app/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 b9f81d6..68c6271 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
@@ -22,6 +22,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.logging.Logger;
import org.json.JSONArray;
import org.json.JSONException;
@@ -59,6 +60,7 @@
import edu.uci.ics.asterix.aql.expression.TypeDropStatement;
import edu.uci.ics.asterix.aql.expression.WriteFromQueryResultStatement;
import edu.uci.ics.asterix.aql.expression.WriteStatement;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
import edu.uci.ics.asterix.common.config.GlobalConfig;
import edu.uci.ics.asterix.common.exceptions.AsterixException;
@@ -130,6 +132,8 @@
private Dataverse activeDefaultDataverse;
private List<FunctionDecl> declaredFunctions;
+ private static Logger LOGGER = Logger.getLogger(AqlTranslator.class.getName());
+
public AqlTranslator(List<Statement> aqlStatements, PrintWriter out, SessionConfig pc, DisplayFormat pdf)
throws MetadataException, AsterixException {
this.aqlStatements = aqlStatements;
@@ -171,6 +175,10 @@
Map<String, String> config = new HashMap<String, String>();
List<JobSpecification> jobsToExecute = new ArrayList<JobSpecification>();
+ String numLogPages = AsterixProperties.INSTANCE.getProperty("log_buffer_num_pages", "4");
+ LOGGER.info("Number of log pages (info)" + numLogPages);
+ LOGGER.severe("Number of log pages (severe)" + numLogPages);
+
for (Statement stmt : aqlStatements) {
validateOperation(activeDefaultDataverse, stmt);
AqlMetadataProvider metadataProvider = new AqlMetadataProvider(activeDefaultDataverse);
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
index 5ab94f3..25ef5da 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
@@ -14,10 +14,10 @@
import edu.uci.ics.asterix.api.http.servlet.QueryStatusAPIServlet;
import edu.uci.ics.asterix.api.http.servlet.UpdateAPIServlet;
import edu.uci.ics.asterix.common.api.AsterixAppContextInfoImpl;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
import edu.uci.ics.asterix.common.config.GlobalConfig;
import edu.uci.ics.asterix.metadata.MetadataManager;
import edu.uci.ics.asterix.metadata.api.IAsterixStateProxy;
-import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
import edu.uci.ics.asterix.metadata.bootstrap.AsterixStateProxy;
import edu.uci.ics.hyracks.api.application.ICCApplicationContext;
import edu.uci.ics.hyracks.api.application.ICCApplicationEntryPoint;
@@ -79,11 +79,8 @@
}
private void setupWebServer() throws Exception {
- String portStr = System.getProperty(GlobalConfig.WEB_SERVER_PORT_PROPERTY);
- int port = DEFAULT_WEB_SERVER_PORT;
- if (portStr != null) {
- port = Integer.parseInt(portStr);
- }
+ int port = Integer.parseInt((String) AsterixProperties.INSTANCE.getProperty(
+ AsterixProperties.AsterixConfigurationKeys.WEB_INTERFACE_PORT, "" + DEFAULT_WEB_SERVER_PORT));
webServer = new Server(port);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
index f332155..61a7fdc 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
@@ -18,153 +18,134 @@
import edu.uci.ics.hyracks.api.application.INCApplicationEntryPoint;
public class NCApplicationEntryPoint implements INCApplicationEntryPoint {
- private static final Logger LOGGER = Logger
- .getLogger(NCApplicationEntryPoint.class.getName());
+ private static final Logger LOGGER = Logger.getLogger(NCApplicationEntryPoint.class.getName());
- private INCApplicationContext ncApplicationContext = null;
- private AsterixAppRuntimeContext runtimeContext;
- private String nodeId;
- private boolean isMetadataNode = false;
- private boolean stopInitiated = false;
- private SystemState systemState = SystemState.NEW_UNIVERSE;
+ private INCApplicationContext ncApplicationContext = null;
+ private AsterixAppRuntimeContext runtimeContext;
+ private String nodeId;
+ private boolean isMetadataNode = false;
+ private boolean stopInitiated = false;
+ private SystemState systemState = SystemState.NEW_UNIVERSE;
- @Override
- public void start(INCApplicationContext ncAppCtx, String[] args)
- throws Exception {
- ncApplicationContext = ncAppCtx;
- nodeId = ncApplicationContext.getNodeId();
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Starting Asterix node controller: " + nodeId);
- }
+ @Override
+ public void start(INCApplicationContext ncAppCtx, String[] args) throws Exception {
+ ncApplicationContext = ncAppCtx;
+ nodeId = ncApplicationContext.getNodeId();
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Starting Asterix node controller: " + nodeId);
+ }
- runtimeContext = new AsterixAppRuntimeContext(ncApplicationContext);
- runtimeContext.initialize();
- ncApplicationContext.setApplicationObject(runtimeContext);
- JVMShutdownHook sHook = new JVMShutdownHook(this);
- Runtime.getRuntime().addShutdownHook(sHook);
+ runtimeContext = new AsterixAppRuntimeContext(ncApplicationContext);
+ runtimeContext.initialize();
+ ncApplicationContext.setApplicationObject(runtimeContext);
+ JVMShutdownHook sHook = new JVMShutdownHook(this);
+ Runtime.getRuntime().addShutdownHook(sHook);
- // #. recover if the system is corrupted by checking system state.
- IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem()
- .getRecoveryManager();
- systemState = recoveryMgr.getSystemState();
- if (systemState != SystemState.NEW_UNIVERSE) {
- PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
- .getLocalResourceRepository();
- localResourceRepository.initialize(nodeId, null, false,
- runtimeContext.getResourceIdFactory());
- }
- if (systemState == SystemState.CORRUPTED) {
- recoveryMgr.startRecovery(true);
- } else if (systemState == SystemState.NEW_UNIVERSE) {
- recoveryMgr.checkpoint(true);
- }
- }
+ // #. recover if the system is corrupted by checking system state.
+ IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
+ systemState = recoveryMgr.getSystemState();
+ if (systemState != SystemState.NEW_UNIVERSE) {
+ PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
+ .getLocalResourceRepository();
+ localResourceRepository.initialize(nodeId, null, false, runtimeContext.getResourceIdFactory());
+ }
+ if (systemState == SystemState.CORRUPTED) {
+ recoveryMgr.startRecovery(true);
+ } else if (systemState == SystemState.NEW_UNIVERSE) {
+ recoveryMgr.checkpoint(true);
+ }
+ }
- @Override
- public void stop() throws Exception {
- if (!stopInitiated) {
- runtimeContext.setShuttingdown(true);
- stopInitiated = true;
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Stopping Asterix node controller: " + nodeId);
- }
+ @Override
+ public void stop() throws Exception {
+ if (!stopInitiated) {
+ runtimeContext.setShuttingdown(true);
+ stopInitiated = true;
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Stopping Asterix node controller: " + nodeId);
+ }
- IRecoveryManager recoveryMgr = runtimeContext
- .getTransactionSubsystem().getRecoveryManager();
- recoveryMgr.checkpoint(true);
+ IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
+ recoveryMgr.checkpoint(true);
- if (isMetadataNode) {
- MetadataBootstrap.stopUniverse();
- }
- runtimeContext.deinitialize();
- } else {
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Duplicate attempt to stop ignored: " + nodeId);
- }
- }
- }
+ if (isMetadataNode) {
+ MetadataBootstrap.stopUniverse();
+ }
+ runtimeContext.deinitialize();
+ } else {
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Duplicate attempt to stop ignored: " + nodeId);
+ }
+ }
+ }
- @Override
- public void notifyStartupComplete() throws Exception {
- IAsterixStateProxy proxy = (IAsterixStateProxy) ncApplicationContext
- .getDistributedState();
+ @Override
+ public void notifyStartupComplete() throws Exception {
+ IAsterixStateProxy proxy = (IAsterixStateProxy) ncApplicationContext.getDistributedState();
- if (systemState == SystemState.NEW_UNIVERSE) {
- PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
- .getLocalResourceRepository();
- System.out.println("nodeid" + nodeId);
- System.out.println("proxy" + proxy);
- System.out.println("stores"
- + proxy.getAsterixProperties().getStores());
- System.out.println("store"
- + proxy.getAsterixProperties().getStores().get(nodeId)[0]);
+ if (systemState == SystemState.NEW_UNIVERSE) {
+ PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
+ .getLocalResourceRepository();
- localResourceRepository.initialize(nodeId, proxy
- .getAsterixProperties().getStores().get(nodeId)[0], true,
- null);
- }
+ localResourceRepository.initialize(nodeId, proxy.getAsterixProperties().getStores().get(nodeId)[0], true,
+ null);
+ }
- isMetadataNode = nodeId.equals(proxy.getAsterixProperties()
- .getMetadataNodeName());
- if (isMetadataNode) {
- registerRemoteMetadataNode(proxy);
+ isMetadataNode = nodeId.equals(proxy.getAsterixProperties().getMetadataNodeName());
+ if (isMetadataNode) {
+ registerRemoteMetadataNode(proxy);
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Bootstrapping metadata");
- }
- MetadataManager.INSTANCE = new MetadataManager(proxy);
- MetadataManager.INSTANCE.init();
- MetadataBootstrap.startUniverse(proxy.getAsterixProperties(),
- ncApplicationContext,
- systemState == SystemState.NEW_UNIVERSE);
- MetadataBootstrap.startDDLRecovery();
- }
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Bootstrapping metadata");
+ }
+ MetadataManager.INSTANCE = new MetadataManager(proxy);
+ MetadataManager.INSTANCE.init();
+ MetadataBootstrap.startUniverse(proxy.getAsterixProperties(), ncApplicationContext,
+ systemState == SystemState.NEW_UNIVERSE);
+ MetadataBootstrap.startDDLRecovery();
+ }
- IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem()
- .getRecoveryManager();
- recoveryMgr.checkpoint(true);
+ IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
+ recoveryMgr.checkpoint(true);
- // TODO
- // reclaim storage for orphaned index artifacts in NCs.
- }
+ // TODO
+ // reclaim storage for orphaned index artifacts in NCs.
+ }
- public void registerRemoteMetadataNode(IAsterixStateProxy proxy)
- throws RemoteException {
- IMetadataNode stub = null;
- MetadataNode.INSTANCE.initialize(runtimeContext);
- stub = (IMetadataNode) UnicastRemoteObject.exportObject(
- MetadataNode.INSTANCE, 0);
- proxy.setMetadataNode(stub);
+ public void registerRemoteMetadataNode(IAsterixStateProxy proxy) throws RemoteException {
+ IMetadataNode stub = null;
+ MetadataNode.INSTANCE.initialize(runtimeContext);
+ stub = (IMetadataNode) UnicastRemoteObject.exportObject(MetadataNode.INSTANCE, 0);
+ proxy.setMetadataNode(stub);
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Metadata node bound");
- }
- }
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Metadata node bound");
+ }
+ }
- /**
- * Shutdown hook that invokes {@link NCApplicationEntryPoint#stop() stop}
- * method.
- */
- private static class JVMShutdownHook extends Thread {
+ /**
+ * Shutdown hook that invokes {@link NCApplicationEntryPoint#stop() stop} method.
+ */
+ private static class JVMShutdownHook extends Thread {
- private final NCApplicationEntryPoint ncAppEntryPoint;
+ private final NCApplicationEntryPoint ncAppEntryPoint;
- public JVMShutdownHook(NCApplicationEntryPoint ncAppEntryPoint) {
- this.ncAppEntryPoint = ncAppEntryPoint;
- }
+ public JVMShutdownHook(NCApplicationEntryPoint ncAppEntryPoint) {
+ this.ncAppEntryPoint = ncAppEntryPoint;
+ }
- public void run() {
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Shutdown hook in progress");
- }
- try {
- ncAppEntryPoint.stop();
- } catch (Exception e) {
- if (LOGGER.isLoggable(Level.WARNING)) {
- LOGGER.warning("Exception in executing shutdown hook" + e);
- }
- }
- }
- }
+ public void run() {
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Shutdown hook in progress");
+ }
+ try {
+ ncAppEntryPoint.stop();
+ } catch (Exception e) {
+ if (LOGGER.isLoggable(Level.WARNING)) {
+ LOGGER.warning("Exception in executing shutdown hook" + e);
+ }
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/asterix-app/src/main/resources/asterix-configuration.xml b/asterix-app/src/main/resources/asterix-configuration.xml
new file mode 100644
index 0000000..877ab6e
--- /dev/null
+++ b/asterix-app/src/main/resources/asterix-configuration.xml
@@ -0,0 +1,11 @@
+<configuration xmlns="configuration">
+ <metadataNode>nc1</metadataNode>
+ <store>
+ <ncId>nc1</ncId>
+ <storeDirs>nc1data</storeDirs>
+ </store>
+ <store>
+ <ncId>nc2</ncId>
+ <storeDirs>nc2data</storeDirs>
+ </store>
+</configuration>
diff --git a/asterix-common/pom.xml b/asterix-common/pom.xml
index bb2b97f..79f7dff 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,46 @@
<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>
</plugins>
</build>
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..d361224
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixProperties.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2009-2010 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package edu.uci.ics.asterix.common.config;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
+import edu.uci.ics.asterix.common.configuration.Property;
+import edu.uci.ics.asterix.common.configuration.Store;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+/**
+ * Holder for Asterix properties values typically set as Java Properties.
+ * Intended to live in the AsterixStateProxy so it can be accessed remotely.
+ */
+public class AsterixProperties implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private static String metadataNodeName;
+ private static HashSet<String> nodeNames;
+ private static Map<String, String[]> stores;
+ private static Map<String, String> asterixConfigurationParams;
+
+ public static AsterixProperties INSTANCE = new AsterixProperties();
+
+ public static class AsterixConfigurationKeys {
+
+ //JVM parameters for each Node Contoller (NC)
+ public static final String NC_JAVA_OPTS = "nc_java_opts"; // default "-Xmx1024m"
+
+ //JVM parameters for the Cluster Contoller (CC)
+ public static final String CC_JAVA_OPTS = "cc_java_opts"; // default "-Xmx1024m"
+
+ public static final String SIZE_MEMORY_COMPONENT = "size_memory_component"; // default "512m"
+
+ public static final String TOTAL_SIZE_MEMORY_COMPONENT = "total_size_memory_component"; // default "512m"
+
+ public static final String LOG_BUFFER_NUM_PAGES = "log_buffer_num_pages"; // default "8"
+
+ public static final String LOG_BUFFER_PAGE_SIZE = "log_buffer_page_size"; // default "131072 (128K)"
+
+ public static final String LOG_PARTITION_SIZE = "log_partition_size"; // default "2147483648 (2GB)"
+
+ public static final String GROUP_COMMIT_INTERVAL = "group_commit_interval"; // default "200ms (128K)"
+
+ public static final String SORT_OP_MEMORY = "sort_op_memory"; // default "512m"
+
+ public static final String JOIN_OP_MEMORY = "join_op_memory"; // default "512m"
+
+ public static final String WEB_INTERFACE_PORT = "web_interface_port"; // default "19001"
+
+ public static final String NC_PORT = "nc_port"; // default "14601"
+
+ public static final String NUM_PAGES_BUFFER_CACHE = "num_pages_buffer_cache"; // default "1000"
+
+ public static final String LOG_LEVEL = "log_level"; // default "INFO"
+
+ public static final String LSN_THRESHOLD = "lsn_threshold"; // default "64m"
+
+ public static final String CHECKPOINT_TERMS_IN_SECS = "checkpoint_terms_in_secs"; // default "120"
+
+ public static final String ESCALATE_THRSHOLD_ENTITY_TO_DATASET = "escalate_threshold_entity_to_dataset"; // default "8"
+
+ public static final String SHRINK_TIMER_THRESHOLD = "shrink_timer_threshold"; // default "120000"
+
+ }
+
+ private AsterixProperties() {
+ try {
+ String fileName = System.getProperty(GlobalConfig.CONFIG_FILE_PROPERTY);
+ if (fileName == null) {
+ fileName = GlobalConfig.DEFAULT_CONFIG_FILE_NAME;
+ }
+ InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName);
+ if (is == null) {
+ try {
+ fileName = GlobalConfig.DEFAULT_CONFIG_FILE_NAME;
+ is = new FileInputStream(fileName);
+ } catch (FileNotFoundException fnf) {
+ throw new AlgebricksException("Could not find the configuration file " + fileName);
+ }
+ }
+ JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ AsterixConfiguration asterixConfiguration = (AsterixConfiguration) unmarshaller.unmarshal(is);
+ metadataNodeName = asterixConfiguration.getMetadataNode();
+ stores = new HashMap<String, String[]>();
+ List<Store> configuredStores = asterixConfiguration.getStore();
+ nodeNames = new HashSet<String>();
+ for (Store store : configuredStores) {
+ String trimmedStoreDirs = store.getStoreDirs().trim();
+ stores.put(store.getNcId(), trimmedStoreDirs.split(","));
+ nodeNames.add(store.getNcId());
+ }
+ asterixConfigurationParams = new HashMap<String, String>();
+ for (Property p : asterixConfiguration.getProperty()) {
+ asterixConfigurationParams.put(p.getName(), p.getValue());
+ }
+
+ initializeLogLevel(asterixConfigurationParams.get("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 defaultValue) {
+ String propValue = asterixConfigurationParams.get(property);
+ return (propValue != null && propValue.length() > 0) ? propValue : defaultValue;
+ }
+
+ private void initializeLogLevel(String configuredLogLevel) {
+ Level level = null;
+ switch (configuredLogLevel.toLowerCase()) {
+ case "info":
+ level = Level.INFO;
+ break;
+ case "fine":
+ level = Level.FINE;
+ break;
+ case "finer":
+ level = Level.FINER;
+ break;
+ case "finest":
+ level = Level.FINEST;
+ break;
+ case "severe":
+ level = Level.SEVERE;
+ break;
+ case "fatal":
+ level = Level.SEVERE;
+ 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..b69d529 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
@@ -11,7 +11,7 @@
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";
diff --git a/asterix-installer/pom.xml b/asterix-installer/pom.xml
index e0986d9..535843f 100644
--- a/asterix-installer/pom.xml
+++ b/asterix-installer/pom.xml
@@ -164,6 +164,13 @@
</dependency>
<dependency>
<groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-common</artifactId>
+ <version>0.0.5-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
<artifactId>asterix-server</artifactId>
<version>0.0.5-SNAPSHOT</version>
<type>zip</type>
diff --git a/asterix-installer/src/main/assembly/binary-assembly.xml b/asterix-installer/src/main/assembly/binary-assembly.xml
index 6a0c130..72631ba 100644
--- a/asterix-installer/src/main/assembly/binary-assembly.xml
+++ b/asterix-installer/src/main/assembly/binary-assembly.xml
@@ -61,6 +61,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 3a1d641..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
@@ -18,11 +18,11 @@
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;
import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
-import edu.uci.ics.asterix.installer.schema.asterixconf.AsterixConfiguration;
import edu.uci.ics.asterix.installer.service.ILookupService;
import edu.uci.ics.asterix.installer.service.ServiceProvider;
@@ -41,7 +41,8 @@
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
@@ -53,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/CreateCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java
index 05d6777..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;
@@ -32,7 +29,6 @@
import edu.uci.ics.asterix.installer.events.PatternCreator;
import edu.uci.ics.asterix.installer.model.AsterixInstance;
import edu.uci.ics.asterix.installer.model.AsterixRuntimeState;
-import edu.uci.ics.asterix.installer.schema.asterixconf.AsterixConfiguration;
import edu.uci.ics.asterix.installer.service.ServiceProvider;
public class CreateCommand extends AbstractCommand {
@@ -57,7 +53,7 @@
AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(asterixInstanceName, cluster,
asterixConfiguration);
InstallerUtil.evaluateConflictWithOtherInstances(asterixInstance);
- InstallerUtil.createAsterixZip(asterixInstance, true);
+ InstallerUtil.createAsterixZip(asterixInstance);
InstallerUtil.createClusterProperties(cluster, asterixConfiguration);
EventrixClient eventrixClient = InstallerUtil.getEventrixClient(cluster);
PatternCreator pc = new PatternCreator();
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 f5119a5..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
@@ -36,11 +36,11 @@
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());
+ Patterns asterixBinaryTransferPattern = pc.getAsterixBinaryTransferPattern(asterixInstanceName,
+ instance.getCluster());
client.submit(asterixBinaryTransferPattern);
InstallerUtil.createClusterProperties(instance.getCluster(), instance.getAsterixConfiguration());
Patterns patterns = pc.getStartAsterixPattern(asterixInstanceName, instance.getCluster());
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 80e522b..df49b0e 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,8 +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 = "clusters" + File.separator + "local"
- + File.separator + "conf" + File.separator + "asterix-conf.xml";
+ 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";
@@ -127,13 +127,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 484d206..af68614 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
@@ -42,10 +42,13 @@
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;
@@ -56,31 +59,31 @@
import edu.uci.ics.asterix.installer.error.OutputHandler;
import edu.uci.ics.asterix.installer.model.AsterixInstance;
import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
-import edu.uci.ics.asterix.installer.schema.asterixconf.AsterixConfiguration;
import edu.uci.ics.asterix.installer.service.ServiceProvider;
public class InstallerUtil {
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,
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, asterixConfiguration, metadataNode
- .getId(), asterixVersion);
+ String asterixVersion = asterixZipName.substring("asterix-server-".length(),
+ asterixZipName.indexOf("-binary-assembly"));
+ 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 {
- String modifiedZipPath = injectAsterixPropertyFile(InstallerDriver.getAsterixZip(), asterixInstance,
- newDeployment);
+ String modifiedZipPath = injectAsterixPropertyFile(InstallerDriver.getAsterixZip(), asterixInstance);
injectAsterixLogPropertyFile(modifiedZipPath, asterixInstance);
}
@@ -92,7 +95,7 @@
} else {
clusterProperties = new ArrayList<Property>();
}
- for (edu.uci.ics.asterix.installer.schema.asterixconf.Property property : asterixConfiguration.getProperty()) {
+ 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)) {
@@ -109,17 +112,16 @@
cluster.setEnv(new Env(clusterProperties));
}
- private static String injectAsterixPropertyFile(String origZipFile, AsterixInstance asterixInstance,
- boolean newDeployment) throws IOException {
- writeAsterixConfigurationFile(asterixInstance, newDeployment);
+ 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));
@@ -132,10 +134,9 @@
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);
}
@@ -145,7 +146,7 @@
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(
@@ -204,33 +205,31 @@
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));
}
-
- AsterixConfiguration asterixConf = asterixInstance.getAsterixConfiguration();
- /*for (Property property : asterixConf.getProperty()){
-
- }*/
-
- conf.append("OutputDir=" + "dummy");
+ 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,
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 d4b2a0b..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
@@ -19,10 +19,10 @@
import java.util.Date;
import java.util.List;
+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;
-import edu.uci.ics.asterix.installer.schema.asterixconf.AsterixConfiguration;
-import edu.uci.ics.asterix.installer.schema.asterixconf.Property;
public class AsterixInstance implements Serializable {
diff --git a/asterix-installer/src/main/resources/clusters/local/conf/asterix-conf.xml b/asterix-installer/src/main/resources/conf/asterix-configuration.xml
similarity index 95%
rename from asterix-installer/src/main/resources/clusters/local/conf/asterix-conf.xml
rename to asterix-installer/src/main/resources/conf/asterix-configuration.xml
index b94e491..89e9466 100644
--- a/asterix-installer/src/main/resources/clusters/local/conf/asterix-conf.xml
+++ b/asterix-installer/src/main/resources/conf/asterix-configuration.xml
@@ -67,12 +67,6 @@
</property>
<property>
- <name>nc_port</name>
- <value>14601</value>
- <description></description>
- </property>
-
- <property>
<name>num_pages_buffer_cache</name>
<value>8</value>
<description></description>
diff --git a/asterix-installer/src/main/resources/schema/asterix-conf.xsd b/asterix-installer/src/main/resources/schema/asterix-conf.xsd
deleted file mode 100644
index 9ebc5ed..0000000
--- a/asterix-installer/src/main/resources/schema/asterix-conf.xsd
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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="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="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:property" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
-</xs:schema>
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 805a550..9d43c5c 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
@@ -25,6 +25,7 @@
import java.util.List;
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;
@@ -125,8 +126,8 @@
MetadataSecondaryIndexes.DATATYPENAME_ON_DATATYPE_INDEX };
}
- public static void startUniverse(AsterixProperties asterixProperties, INCApplicationContext ncApplicationContext, boolean isNewUniverse)
- throws Exception {
+ public static void startUniverse(AsterixProperties asterixProperties, INCApplicationContext ncApplicationContext,
+ boolean isNewUniverse) throws Exception {
runtimeContext = (AsterixAppRuntimeContext) ncApplicationContext.getApplicationObject();
// Initialize static metadata objects, such as record types and metadata
@@ -152,11 +153,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();
@@ -233,7 +229,8 @@
primaryIndexes[i].getNodeGroupName());
MetadataManager.INSTANCE.addDataset(mdTxnCtx, new Dataset(primaryIndexes[i].getDataverseName(),
primaryIndexes[i].getIndexedDatasetName(), primaryIndexes[i].getPayloadRecordType().getTypeName(),
- id, new HashMap<String,String>(), DatasetType.INTERNAL, primaryIndexes[i].getDatasetId().getId(), IMetadataEntity.PENDING_NO_OP));
+ id, new HashMap<String, String>(), DatasetType.INTERNAL, primaryIndexes[i].getDatasetId().getId(),
+ IMetadataEntity.PENDING_NO_OP));
}
}
@@ -318,7 +315,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());
@@ -331,8 +328,8 @@
LSMBTree lsmBtree = null;
long resourceID = -1;
if (create) {
- lsmBtree = LSMBTreeUtils.createLSMTree(memBufferCache, memFreePageManager, ioManager, file,
- bufferCache, fileMapProvider, typeTraits, comparatorFactories, bloomFilterKeyFields,
+ lsmBtree = LSMBTreeUtils.createLSMTree(memBufferCache, memFreePageManager, ioManager, file, bufferCache,
+ fileMapProvider, typeTraits, comparatorFactories, bloomFilterKeyFields,
runtimeContext.getLSMMergePolicy(), runtimeContext.getLSMBTreeOperationTrackerFactory(),
runtimeContext.getLSMIOScheduler(), AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER);
lsmBtree.create();
@@ -358,13 +355,11 @@
indexLifecycleManager.register(resourceID, lsmBtree);
}
}
-
+
index.setResourceID(resourceID);
index.setFile(file);
indexLifecycleManager.open(resourceID);
}
-
-
public static String getOutputDir() {
return outputDir;
@@ -381,9 +376,9 @@
String datasetName = null;
String indexName = null;
MetadataTransactionContext mdTxnCtx = null;
-
+
MetadataManager.INSTANCE.acquireWriteLatch();
-
+
try {
mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
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;