refactored configurations into hierarchy and namespaced property names
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 09fc2b9..ff854d1 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,7 +71,8 @@
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.api.AsterixAppContextInfoImpl;
+import edu.uci.ics.asterix.common.config.AsterixMetadataProperties;
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;
@@ -288,7 +289,9 @@
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)));
+ AsterixMetadataProperties metadataProperties = ((AsterixAppContextInfoImpl) AsterixAppContextInfoImpl
+ .getInstance()).getMetadataProperties();
+ return new FileSplit(metadataProperties.getMetadataNodeName(), new FileReference(new File(filePath)));
}
@Override
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
index 862c701..c840ad2 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
@@ -27,7 +27,7 @@
import edu.uci.ics.asterix.aql.expression.visitor.AQLPrintVisitor;
import edu.uci.ics.asterix.aql.rewrites.AqlRewriter;
import edu.uci.ics.asterix.common.api.AsterixAppContextInfoImpl;
-import edu.uci.ics.asterix.common.config.GlobalConfig;
+import edu.uci.ics.asterix.common.config.AsterixCompilerProperties;
import edu.uci.ics.asterix.common.config.OptimizationConfUtil;
import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.dataflow.data.common.AqlExpressionTypeComputer;
@@ -258,7 +258,9 @@
}
}
- int frameSize = GlobalConfig.getFrameSize();
+ AsterixCompilerProperties compilerProperties = ((AsterixAppContextInfoImpl) AsterixAppContextInfoImpl
+ .getInstance()).getCompilerProperties();
+ int frameSize = compilerProperties.getFrameSize();
HeuristicCompilerFactoryBuilder builder = new HeuristicCompilerFactoryBuilder(
AqlOptimizationContextFactory.INSTANCE);
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 d68c569..d92e884 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,7 +14,8 @@
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.AsterixExternalProperties;
+import edu.uci.ics.asterix.common.config.AsterixMetadataProperties;
import edu.uci.ics.asterix.common.config.GlobalConfig;
import edu.uci.ics.asterix.metadata.MetadataManager;
import edu.uci.ics.asterix.metadata.api.IAsterixStateProxy;
@@ -43,11 +44,14 @@
LOGGER.info("Starting Asterix cluster controller");
}
+ AsterixAppContextInfoImpl.initialize(appCtx);
+
proxy = AsterixStateProxy.registerRemoteObject();
- proxy.setAsterixProperties(AsterixProperties.INSTANCE);
appCtx.setDistributedState(proxy);
- MetadataManager.INSTANCE = new MetadataManager(proxy);
+ AsterixMetadataProperties metadataProperties = ((AsterixAppContextInfoImpl) AsterixAppContextInfoImpl
+ .getInstance()).getMetadataProperties();
+ MetadataManager.INSTANCE = new MetadataManager(proxy, metadataProperties);
setupWebServer();
webServer.start();
@@ -55,8 +59,6 @@
// Setup and start the web interface
setupJSONAPIServer();
jsonAPIServer.start();
-
- AsterixAppContextInfoImpl.initialize(appCtx);
}
@Override
@@ -77,9 +79,9 @@
}
private void setupWebServer() throws Exception {
- int port = Integer.parseInt((String) AsterixProperties.INSTANCE
- .getProperty(AsterixProperties.AsterixConfigurationKeys.WEB_INTERFACE_PORT));
- webServer = new Server(port);
+ AsterixExternalProperties externalProperties = ((AsterixAppContextInfoImpl) AsterixAppContextInfoImpl
+ .getInstance()).getExternalProperties();
+ webServer = new Server(externalProperties.getWebInterfacePort());
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
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 8ad8c67..04d5452 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
@@ -5,6 +5,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import edu.uci.ics.asterix.common.config.AsterixMetadataProperties;
import edu.uci.ics.asterix.common.context.AsterixAppRuntimeContext;
import edu.uci.ics.asterix.metadata.MetadataManager;
import edu.uci.ics.asterix.metadata.MetadataNode;
@@ -86,6 +87,7 @@
@Override
public void notifyStartupComplete() throws Exception {
IAsterixStateProxy proxy = (IAsterixStateProxy) ncApplicationContext.getDistributedState();
+ AsterixMetadataProperties metadataProperties = runtimeContext.getMetadataProperties();
if (systemState == SystemState.NEW_UNIVERSE) {
PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
@@ -94,24 +96,23 @@
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("nodeid" + nodeId);
LOGGER.info("proxy" + proxy);
- LOGGER.info("stores" + proxy.getAsterixProperties().getStores());
- LOGGER.info("store" + proxy.getAsterixProperties().getStores().get(nodeId)[0]);
+ LOGGER.info("stores" + metadataProperties.getStores());
+ LOGGER.info("store" + metadataProperties.getStores().get(nodeId)[0]);
}
- localResourceRepository.initialize(nodeId, proxy.getAsterixProperties().getStores().get(nodeId)[0], true,
- null);
+ localResourceRepository.initialize(nodeId, metadataProperties.getStores().get(nodeId)[0], true, null);
}
- isMetadataNode = nodeId.equals(proxy.getAsterixProperties().getMetadataNodeName());
+ isMetadataNode = nodeId.equals(metadataProperties.getMetadataNodeName());
if (isMetadataNode) {
registerRemoteMetadataNode(proxy);
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Bootstrapping metadata");
}
- MetadataManager.INSTANCE = new MetadataManager(proxy);
+ MetadataManager.INSTANCE = new MetadataManager(proxy, metadataProperties);
MetadataManager.INSTANCE.init();
- MetadataBootstrap.startUniverse(proxy.getAsterixProperties(), ncApplicationContext,
+ MetadataBootstrap.startUniverse(metadataProperties, ncApplicationContext,
systemState == SystemState.NEW_UNIVERSE);
MetadataBootstrap.startDDLRecovery();
}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/api/AsterixAppContextInfoImpl.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/api/AsterixAppContextInfoImpl.java
index 0f1de56..c7393b9 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/api/AsterixAppContextInfoImpl.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/api/AsterixAppContextInfoImpl.java
@@ -14,8 +14,18 @@
*/
package edu.uci.ics.asterix.common.api;
+import java.util.logging.Logger;
+
+import edu.uci.ics.asterix.common.config.AsterixCompilerProperties;
+import edu.uci.ics.asterix.common.config.AsterixExternalProperties;
+import edu.uci.ics.asterix.common.config.AsterixMetadataProperties;
+import edu.uci.ics.asterix.common.config.AsterixPropertiesAccessor;
+import edu.uci.ics.asterix.common.config.AsterixStorageProperties;
+import edu.uci.ics.asterix.common.config.AsterixTransactionProperties;
+import edu.uci.ics.asterix.common.config.IAsterixPropertiesProvider;
import edu.uci.ics.asterix.common.context.AsterixRuntimeComponentsProvider;
import edu.uci.ics.asterix.common.dataflow.IAsterixApplicationContextInfo;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.hyracks.api.application.ICCApplicationContext;
import edu.uci.ics.hyracks.storage.am.common.api.IIndexLifecycleManagerProvider;
import edu.uci.ics.hyracks.storage.common.IStorageManagerInterface;
@@ -25,16 +35,30 @@
* instances that are accessed from the NCs. In addition an instance of ICCApplicationContext
* is stored for access by the CC.
*/
-public class AsterixAppContextInfoImpl implements IAsterixApplicationContextInfo {
+public class AsterixAppContextInfoImpl implements IAsterixApplicationContextInfo, IAsterixPropertiesProvider {
private static AsterixAppContextInfoImpl INSTANCE;
private final ICCApplicationContext appCtx;
- public static void initialize(ICCApplicationContext ccAppCtx) {
+ private static AsterixCompilerProperties compilerProperties;
+ private static AsterixExternalProperties externalProperties;
+ private static AsterixMetadataProperties metadataProperties;
+ private static AsterixStorageProperties storageProperties;
+ private static AsterixTransactionProperties txnProperties;
+
+ public static void initialize(ICCApplicationContext ccAppCtx) throws AsterixException {
if (INSTANCE == null) {
INSTANCE = new AsterixAppContextInfoImpl(ccAppCtx);
}
+ AsterixPropertiesAccessor propertiesAccessor = new AsterixPropertiesAccessor();
+ compilerProperties = new AsterixCompilerProperties(propertiesAccessor);
+ externalProperties = new AsterixExternalProperties(propertiesAccessor);
+ metadataProperties = new AsterixMetadataProperties(propertiesAccessor);
+ storageProperties = new AsterixStorageProperties(propertiesAccessor);
+ txnProperties = new AsterixTransactionProperties(propertiesAccessor);
+
+ Logger.getLogger(".").setLevel(externalProperties.getLogLevel());
}
private AsterixAppContextInfoImpl(ICCApplicationContext ccAppCtx) {
@@ -59,4 +83,29 @@
public IIndexLifecycleManagerProvider getIndexLifecycleManagerProvider() {
return AsterixRuntimeComponentsProvider.NOINDEX_PROVIDER;
}
+
+ @Override
+ public AsterixStorageProperties getStorageProperties() {
+ return storageProperties;
+ }
+
+ @Override
+ public AsterixTransactionProperties getTransactionProperties() {
+ return txnProperties;
+ }
+
+ @Override
+ public AsterixCompilerProperties getCompilerProperties() {
+ return compilerProperties;
+ }
+
+ @Override
+ public AsterixMetadataProperties getMetadataProperties() {
+ return metadataProperties;
+ }
+
+ @Override
+ public AsterixExternalProperties getExternalProperties() {
+ return externalProperties;
+ }
}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AbstractAsterixProperties.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AbstractAsterixProperties.java
new file mode 100644
index 0000000..4968f40
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AbstractAsterixProperties.java
@@ -0,0 +1,9 @@
+package edu.uci.ics.asterix.common.config;
+
+public abstract class AbstractAsterixProperties {
+ protected final AsterixPropertiesAccessor accessor;
+
+ public AbstractAsterixProperties(AsterixPropertiesAccessor accessor) {
+ this.accessor = accessor;
+ }
+}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixCompilerProperties.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixCompilerProperties.java
new file mode 100644
index 0000000..e1c80bd
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixCompilerProperties.java
@@ -0,0 +1,28 @@
+package edu.uci.ics.asterix.common.config;
+
+public class AsterixCompilerProperties extends AbstractAsterixProperties {
+ private static final String COMPILER_SORTMEMORY_KEY = "compiler.sortmemory";
+ private static final int COMPILER_SORTMEMORY_DEFAULT = (512 << 20); // 512MB
+
+ private static final String COMPILER_JOINMEMORY_KEY = "compiler.joinmemory";
+ private static final int COMPILER_JOINMEMORY_DEFAULT = (512 << 20); // 512MB
+
+ private static final String COMPILER_FRAMESIZE_KEY = "compiler.framesize";
+ private static int COMPILER_FRAMESIZE_DEFAULT = (32 << 10); // 32KB
+
+ public AsterixCompilerProperties(AsterixPropertiesAccessor accessor) {
+ super(accessor);
+ }
+
+ public int getSortMemorySize() {
+ return accessor.getInt(COMPILER_SORTMEMORY_KEY, COMPILER_SORTMEMORY_DEFAULT);
+ }
+
+ public int getJoinMemorySize() {
+ return accessor.getInt(COMPILER_JOINMEMORY_KEY, COMPILER_JOINMEMORY_DEFAULT);
+ }
+
+ public int getFrameSize() {
+ return accessor.getInt(COMPILER_FRAMESIZE_KEY, COMPILER_FRAMESIZE_DEFAULT);
+ }
+}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixExternalProperties.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixExternalProperties.java
new file mode 100644
index 0000000..958aa7f
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixExternalProperties.java
@@ -0,0 +1,26 @@
+package edu.uci.ics.asterix.common.config;
+
+import java.util.logging.Level;
+
+public class AsterixExternalProperties extends AbstractAsterixProperties {
+
+ private static final String EXTERNAL_WEBPORT_KEY = "external.webport";
+ private static int EXTERNAL_WEBPORT_DEFAULT = 19001;
+
+ private static final String EXTERNAL_LOGLEVEL_KEY = "external.loglevel";
+ private static String EXTERNAL_LOGLEVEL_DEFAULT = "INFO";
+
+ public AsterixExternalProperties(AsterixPropertiesAccessor accessor) {
+ super(accessor);
+ }
+
+ public int getWebInterfacePort() {
+ return accessor.getInt(EXTERNAL_WEBPORT_KEY, EXTERNAL_WEBPORT_DEFAULT);
+ }
+
+ public Level getLogLevel() {
+ String level = accessor.getString(EXTERNAL_LOGLEVEL_KEY, EXTERNAL_LOGLEVEL_DEFAULT);
+ return Level.parse(level);
+ }
+
+}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixMetadataProperties.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixMetadataProperties.java
new file mode 100644
index 0000000..6d47e78
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixMetadataProperties.java
@@ -0,0 +1,28 @@
+package edu.uci.ics.asterix.common.config;
+
+import java.util.Map;
+import java.util.Set;
+
+public class AsterixMetadataProperties extends AbstractAsterixProperties {
+
+ public AsterixMetadataProperties(AsterixPropertiesAccessor accessor) {
+ super(accessor);
+ }
+
+ public String getMetadataNodeName() {
+ return accessor.getMetadataNodeName();
+ }
+
+ public String getMetadataStore() {
+ return accessor.getMetadataStore();
+ }
+
+ public Map<String, String[]> getStores() {
+ return accessor.getStores();
+ }
+
+ public Set<String> getNodeNames() {
+ return accessor.getNodeNames();
+ }
+
+}
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
deleted file mode 100644
index 39dec45..0000000
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixProperties.java
+++ /dev/null
@@ -1,264 +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.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 Logger LOGGER = Logger.getLogger(AsterixProperties.class.getName());
-
- 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 NUM_PAGES_BUFFER_CACHE = "num.pages.buffer.cache";
- public static final String NUM_PAGES_BUFFER_CACHE_DEFAULT = "1000";
-
- 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 MEMORY_COMPONENT_NUM_PAGES = "memory.component.num.pages";
- public static final String MEMORY_COMPONENT_NUM_PAGES_DEFAULT = "1000";
-
- public static final String MEMORY_COMPONENT_PAGE_SIZE = "memory.component.page.size";
- public static final String MEMORY_COMPONENT_PAGE_SIZE_DEFAULT = "32768";
-
- 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 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";
-
- 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 LOG_LEVEL = "log.level";
- public static final String LOG_LEVEL_DEFAULT = "INFO";
-
- }
-
- 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.NUM_PAGES_BUFFER_CACHE:
- propValue = AsterixConfigurationKeys.NUM_PAGES_BUFFER_CACHE_DEFAULT;
- break;
- case AsterixConfigurationKeys.TOTAL_SIZE_MEMORY_COMPONENT:
- propValue = AsterixConfigurationKeys.TOTAL_SIZE_MEMORY_COMPONENT_DEFAULT;
- break;
- case AsterixConfigurationKeys.MEMORY_COMPONENT_NUM_PAGES:
- propValue = AsterixConfigurationKeys.MEMORY_COMPONENT_NUM_PAGES_DEFAULT;
- break;
- case AsterixConfigurationKeys.MEMORY_COMPONENT_PAGE_SIZE:
- propValue = AsterixConfigurationKeys.MEMORY_COMPONENT_PAGE_SIZE_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.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;
- 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.LOG_LEVEL:
- propValue = AsterixConfigurationKeys.LOG_LEVEL_DEFAULT;
- break;
- default:
- if (LOGGER.isLoggable(Level.WARNING)) {
- LOGGER.warning("Cannot find property '" + property + "'");
- }
- }
- }
- 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(".").setLevel(level);
- }
-}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixPropertiesAccessor.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixPropertiesAccessor.java
new file mode 100644
index 0000000..eeec537
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixPropertiesAccessor.java
@@ -0,0 +1,91 @@
+package edu.uci.ics.asterix.common.config;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+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.asterix.common.exceptions.AsterixException;
+
+public class AsterixPropertiesAccessor {
+
+ private final String metadataNodeName;
+ private final Set<String> nodeNames;
+ private final Map<String, String[]> stores;
+ private final Map<String, String> asterixConfigurationParams;
+
+ public AsterixPropertiesAccessor() throws AsterixException {
+ 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 AsterixException("Could not find configuration file " + fileName);
+ }
+ }
+
+ AsterixConfiguration asterixConfiguration = null;
+ try {
+ JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ asterixConfiguration = (AsterixConfiguration) unmarshaller.unmarshal(is);
+ } catch (JAXBException e) {
+ throw new AsterixException("Failed to read configuration file " + fileName);
+ }
+ 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());
+ }
+ }
+
+ public String getMetadataNodeName() {
+ return metadataNodeName;
+ }
+
+ public String getMetadataStore() {
+ return stores.get(metadataNodeName)[0];
+ }
+
+ public Map<String, String[]> getStores() {
+ return stores;
+ }
+
+ public Set<String> getNodeNames() {
+ return nodeNames;
+ }
+
+ public int getInt(String property, int defaultValue) {
+ String propertyValue = asterixConfigurationParams.get(property);
+ return propertyValue == null ? defaultValue : Integer.parseInt(propertyValue);
+ }
+
+ public String getString(String property, String defaultValue) {
+ String propertyValue = asterixConfigurationParams.get(property);
+ return propertyValue == null ? defaultValue : propertyValue;
+ }
+}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixStorageProperties.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixStorageProperties.java
new file mode 100644
index 0000000..1e41ce8
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixStorageProperties.java
@@ -0,0 +1,57 @@
+package edu.uci.ics.asterix.common.config;
+
+public class AsterixStorageProperties extends AbstractAsterixProperties {
+
+ private static final String STORAGE_BUFFERCACHE_PAGESIZE_KEY = "storage.buffercache.pagesize";
+ private static int STORAGE_BUFFERCACHE_PAGESIZE_DEFAULT = (32 << 10); // 32KB
+
+ private static final String STORAGE_BUFFERCACHE_NUMPAGES_KEY = "storage.buffercache.numpages";
+ private static final int STORAGE_BUFFERCACHE_NUMPAGES_DEFAULT = 1024;
+
+ private static final String STORAGE_BUFFERCACHE_MAXOPENFILES_KEY = "storage.buffercache.maxopenfiles";
+ private static int STORAGE_BUFFERCACHE_MAXOPENFILES_DEFAULT = Integer.MAX_VALUE;
+
+ private static final String STORAGE_MEMORYCOMPONENT_PAGESIZE_KEY = "storage.memorycomponent.pagesize";
+ private static final int STORAGE_MEMORYCOMPONENT_PAGESIZE_DEFAULT = (32 << 10); // 32KB
+
+ private static final String STORAGE_MEMORYCOMPONENT_NUMPAGES_KEY = "storage.memorycomponent.numpages";
+ private static final int STORAGE_MEMORYCOMPONENT_NUMPAGES_DEFAULT = 4096; // ... so 128MB components
+
+ private static final String STORAGE_MEMORYCOMPONENT_GLOBALBUDGET_KEY = "storage.memorycomponent.globalbudget";
+ private static final int STORAGE_MEMORYCOMPONENT_GLOBALBUDGET_DEFAULT = (1 << 30); // 1GB
+
+ private static final String STORAGE_LSM_MERGETHRESHOLD_KEY = "storage.lsm.mergethreshold";
+ private static int STORAGE_LSM_MERGETHRESHOLD_DEFAULT = 3;
+
+ public AsterixStorageProperties(AsterixPropertiesAccessor accessor) {
+ super(accessor);
+ }
+
+ public int getBufferCachePageSize() {
+ return accessor.getInt(STORAGE_BUFFERCACHE_PAGESIZE_KEY, STORAGE_BUFFERCACHE_PAGESIZE_DEFAULT);
+ }
+
+ public int getBufferCacheNumPages() {
+ return accessor.getInt(STORAGE_BUFFERCACHE_NUMPAGES_KEY, STORAGE_BUFFERCACHE_NUMPAGES_DEFAULT);
+ }
+
+ public int getBufferCacheMaxOpenFiles() {
+ return accessor.getInt(STORAGE_BUFFERCACHE_MAXOPENFILES_KEY, STORAGE_BUFFERCACHE_MAXOPENFILES_DEFAULT);
+ }
+
+ public int getMemoryComponentPageSize() {
+ return accessor.getInt(STORAGE_MEMORYCOMPONENT_PAGESIZE_KEY, STORAGE_MEMORYCOMPONENT_PAGESIZE_DEFAULT);
+ }
+
+ public int getMemoryComponentNumPages() {
+ return accessor.getInt(STORAGE_MEMORYCOMPONENT_NUMPAGES_KEY, STORAGE_MEMORYCOMPONENT_NUMPAGES_DEFAULT);
+ }
+
+ public int getMemoryComponentGlobalBudget() {
+ return accessor.getInt(STORAGE_MEMORYCOMPONENT_GLOBALBUDGET_KEY, STORAGE_MEMORYCOMPONENT_GLOBALBUDGET_DEFAULT);
+ }
+
+ public int getLSMIndexMergeThreshold() {
+ return accessor.getInt(STORAGE_LSM_MERGETHRESHOLD_KEY, STORAGE_LSM_MERGETHRESHOLD_DEFAULT);
+ }
+}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixTransactionProperties.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixTransactionProperties.java
new file mode 100644
index 0000000..f001e37
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixTransactionProperties.java
@@ -0,0 +1,64 @@
+package edu.uci.ics.asterix.common.config;
+
+public class AsterixTransactionProperties extends AbstractAsterixProperties {
+ private static final String TXN_LOG_BUFFER_NUMPAGES_KEY = "txn.log.buffer.numpages";
+ private static int TXN_LOG_BUFFER_NUMPAGES_DEFAULT = 8;
+
+ private static final String TXN_LOG_BUFFER_PAGESIZE_KEY = "txn.log.buffer.pagesize";
+ private static final int TXN_LOG_BUFFER_PAGESIZE_DEFAULT = (128 << 10); // 128KB
+
+ private static final String TXN_LOG_PARTITIONSIZE_KEY = "txn.log.partitionsize";
+ private static final int TXN_LOG_PARTITIONSIZE_DEFAULT = (2 << 30); // 2GB
+
+ private static final String TXN_LOG_GROUPCOMMITINTERVAL_KEY = "txn.log.groupcommitinterval";
+ private static int TXN_LOG_GROUPCOMMITINTERVAL_DEFAULT = 200; // 200ms
+
+ private static final String TXN_LOG_CHECKPOINT_LSNTHRESHOLD_KEY = "txn.log.checkpoint.lsnthreshold";
+ private static final int TXN_LOG_CHECKPOINT_LSNTHRESHOLD_DEFAULT = (64 << 20); // 64M
+
+ private static final String TXN_LOG_CHECKPOINT_POLLFREQUENCY_KEY = "txn.log.checkpoint.pollfrequency";
+ private static int TXN_LOG_CHECKPOINT_POLLFREQUENCY_DEFAULT = 120; // 120s
+
+ private static final String TXN_LOCK_ESCALATIONTHRESHOLD_KEY = "txn.lock.escalationthreshold";
+ private static int TXN_LOCK_ESCALATIONTHRESHOLD_DEFAULT = 1000;
+
+ private static final String TXN_LOCK_SHRINKTIMER_KEY = "txn.lock.shrinktimer";
+ private static int TXN_LOCK_SHRINKTIMER_DEFAULT = 120000; // 2m
+
+ public AsterixTransactionProperties(AsterixPropertiesAccessor accessor) {
+ super(accessor);
+ }
+
+ public int getLogBufferNumPages() {
+ return accessor.getInt(TXN_LOG_BUFFER_NUMPAGES_KEY, TXN_LOG_BUFFER_NUMPAGES_DEFAULT);
+ }
+
+ public int getLogBufferPageSize() {
+ return accessor.getInt(TXN_LOG_BUFFER_PAGESIZE_KEY, TXN_LOG_BUFFER_PAGESIZE_DEFAULT);
+ }
+
+ public int getLogPartitionSize() {
+ return accessor.getInt(TXN_LOG_PARTITIONSIZE_KEY, TXN_LOG_PARTITIONSIZE_DEFAULT);
+ }
+
+ public int getGroupCommitInterval() {
+ return accessor.getInt(TXN_LOG_GROUPCOMMITINTERVAL_KEY, TXN_LOG_GROUPCOMMITINTERVAL_DEFAULT);
+ }
+
+ public int getCheckpointLSNThreshold() {
+ return accessor.getInt(TXN_LOG_CHECKPOINT_LSNTHRESHOLD_KEY, TXN_LOG_CHECKPOINT_LSNTHRESHOLD_DEFAULT);
+ }
+
+ public int getCheckpointPollFrequency() {
+ return accessor.getInt(TXN_LOG_CHECKPOINT_POLLFREQUENCY_KEY, TXN_LOG_CHECKPOINT_POLLFREQUENCY_DEFAULT);
+ }
+
+ public int getEntityToDatasetLockEscalationThreshold() {
+ return accessor.getInt(TXN_LOCK_ESCALATIONTHRESHOLD_KEY, TXN_LOCK_ESCALATIONTHRESHOLD_DEFAULT);
+ }
+
+ public int getLockManagerShrinkTimer() {
+ return accessor.getInt(TXN_LOCK_SHRINKTIMER_KEY, TXN_LOCK_SHRINKTIMER_DEFAULT);
+ }
+
+}
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 ebce6fe..c41856d 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,61 +3,47 @@
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 DEFAULT_CONFIG_FILE_NAME = "asterix-configuration.xml";
- public static final String DEFAULT_CONFIG_FILE_NAME = "asterix-configuration.xml";
+ public static final String CONFIG_FILE_PROPERTY = "AsterixConfigFileName";
- public static final String TEST_CONFIG_FILE_NAME = "src/main/resources/asterix-configuration.xml";
+ public static final String WEB_SERVER_PORT_PROPERTY = "AsterixWebServerPort";
- public static final String CONFIG_FILE_PROPERTY = "AsterixConfigFileName";
+ public static final String JSON_API_SERVER_PORT_PROPERTY = "AsterixJSONAPIServerPort";
- public static final String WEB_SERVER_PORT_PROPERTY = "AsterixWebServerPort";
+ public static final int DEFAULT_FRAME_SIZE = 32768;
- public static final String JSON_API_SERVER_PORT_PROPERTY = "AsterixJSONAPIServerPort";
+ public static final String FRAME_SIZE_PROPERTY = "FrameSize";
- public static final String BUFFER_CACHE_PAGE_SIZE_PROPERTY = "BufferCachePageSize";
+ public static final float DEFAULT_BTREE_FILL_FACTOR = 1.00f;
- public static final String BUFFER_CACHE_NUM_PAGES_PROPERTY = "BufferCacheNumPages";
+ public static int DEFAULT_INPUT_DATA_COLUMN = 0;
- public static final int DEFAULT_BUFFER_CACHE_NUM_PAGES = 4096;
+ public static int DEFAULT_INDEX_MEM_PAGE_SIZE = 32768;
- public static final int DEFAULT_FRAME_SIZE = 32768;
+ public static int DEFAULT_INDEX_MEM_NUM_PAGES = 1000;
- public static final String FRAME_SIZE_PROPERTY = "FrameSize";
-
- public static final float DEFAULT_BTREE_FILL_FACTOR = 1.00f;
-
- public static int DEFAULT_INPUT_DATA_COLUMN = 0;
-
- public static int DEFAULT_INDEX_MEM_PAGE_SIZE = 32768;
-
- 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/java/edu/uci/ics/asterix/common/config/IAsterixPropertiesProvider.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/IAsterixPropertiesProvider.java
new file mode 100644
index 0000000..e42c827
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/IAsterixPropertiesProvider.java
@@ -0,0 +1,14 @@
+package edu.uci.ics.asterix.common.config;
+
+
+public interface IAsterixPropertiesProvider {
+ public AsterixStorageProperties getStorageProperties();
+
+ public AsterixTransactionProperties getTransactionProperties();
+
+ public AsterixCompilerProperties getCompilerProperties();
+
+ public AsterixMetadataProperties getMetadataProperties();
+
+ public AsterixExternalProperties getExternalProperties();
+}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java
index 5070938..f7c2a59 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java
@@ -1,9 +1,16 @@
package edu.uci.ics.asterix.common.context;
import java.io.IOException;
-import java.util.logging.Level;
+import java.util.logging.Logger;
-import edu.uci.ics.asterix.common.config.GlobalConfig;
+import edu.uci.ics.asterix.common.config.AsterixCompilerProperties;
+import edu.uci.ics.asterix.common.config.AsterixExternalProperties;
+import edu.uci.ics.asterix.common.config.AsterixMetadataProperties;
+import edu.uci.ics.asterix.common.config.AsterixPropertiesAccessor;
+import edu.uci.ics.asterix.common.config.AsterixStorageProperties;
+import edu.uci.ics.asterix.common.config.AsterixTransactionProperties;
+import edu.uci.ics.asterix.common.config.IAsterixPropertiesProvider;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.transaction.management.exception.ACIDException;
import edu.uci.ics.asterix.transaction.management.ioopcallbacks.LSMBTreeIOOperationCallbackFactory;
import edu.uci.ics.asterix.transaction.management.ioopcallbacks.LSMInvertedIndexIOOperationCallbackFactory;
@@ -39,12 +46,15 @@
import edu.uci.ics.hyracks.storage.common.file.ResourceIdFactory;
import edu.uci.ics.hyracks.storage.common.file.ResourceIdFactoryProvider;
-public class AsterixAppRuntimeContext {
- private static final int DEFAULT_BUFFER_CACHE_PAGE_SIZE = 32768;
- private static final int DEFAULT_LIFECYCLEMANAGER_MEMORY_BUDGET = 1024 * 1024 * 1024; // 1GB
- private static final int DEFAULT_MAX_OPEN_FILES = Integer.MAX_VALUE;
+public class AsterixAppRuntimeContext implements IAsterixPropertiesProvider {
private final INCApplicationContext ncApplicationContext;
+ private AsterixCompilerProperties compilerProperties;
+ private AsterixExternalProperties externalProperties;
+ private AsterixMetadataProperties metadataProperties;
+ private AsterixStorageProperties storageProperties;
+ private AsterixTransactionProperties txnProperties;
+
private IIndexLifecycleManager indexLifecycleManager;
private IFileMapManager fileMapManager;
private IBufferCache bufferCache;
@@ -64,24 +74,29 @@
this.ncApplicationContext = ncApplicationContext;
}
- public void initialize() throws IOException, ACIDException {
- int pageSize = getBufferCachePageSize();
- int numPages = getBufferCacheNumPages();
+ public void initialize() throws IOException, ACIDException, AsterixException {
+ AsterixPropertiesAccessor propertiesAccessor = new AsterixPropertiesAccessor();
+ compilerProperties = new AsterixCompilerProperties(propertiesAccessor);
+ externalProperties = new AsterixExternalProperties(propertiesAccessor);
+ metadataProperties = new AsterixMetadataProperties(propertiesAccessor);
+ storageProperties = new AsterixStorageProperties(propertiesAccessor);
+ txnProperties = new AsterixTransactionProperties(propertiesAccessor);
+
+ Logger.getLogger(".").setLevel(externalProperties.getLogLevel());
fileMapManager = new AsterixFileMapManager();
ICacheMemoryAllocator allocator = new HeapBufferAllocator();
IPageReplacementStrategy prs = new ClockPageReplacementStrategy();
- ioManager = ncApplicationContext.getRootContext().getIOManager();
- indexLifecycleManager = new IndexLifecycleManager(DEFAULT_LIFECYCLEMANAGER_MEMORY_BUDGET);
- IAsterixAppRuntimeContextProvider asterixAppRuntimeContextProvider = new AsterixAppRuntimeContextProviderForRecovery(
- this);
- txnSubsystem = new TransactionSubsystem(ncApplicationContext.getNodeId(), asterixAppRuntimeContextProvider);
IPageCleanerPolicy pcp = new DelayPageCleanerPolicy(600000);
- bufferCache = new BufferCache(ioManager, allocator, prs, pcp, fileMapManager, pageSize, numPages,
- DEFAULT_MAX_OPEN_FILES);
+ ioManager = ncApplicationContext.getRootContext().getIOManager();
+ bufferCache = new BufferCache(ioManager, allocator, prs, pcp, fileMapManager,
+ storageProperties.getBufferCachePageSize(), storageProperties.getBufferCacheNumPages(),
+ storageProperties.getBufferCacheMaxOpenFiles());
+
+ indexLifecycleManager = new IndexLifecycleManager(storageProperties.getMemoryComponentGlobalBudget());
lsmIOScheduler = SynchronousScheduler.INSTANCE;
- mergePolicy = new ConstantMergePolicy(3, this);
+ mergePolicy = new ConstantMergePolicy(storageProperties.getLSMIndexMergeThreshold(), this);
lsmBTreeOpTrackerFactory = new IndexOperationTrackerFactory(LSMBTreeIOOperationCallbackFactory.INSTANCE);
lsmRTreeOpTrackerFactory = new IndexOperationTrackerFactory(LSMRTreeIOOperationCallbackFactory.INSTANCE);
lsmInvertedIndexOpTrackerFactory = new IndexOperationTrackerFactory(
@@ -92,6 +107,10 @@
localResourceRepository = (PersistentLocalResourceRepository) persistentLocalResourceRepositoryFactory
.createRepository();
resourceIdFactory = (new ResourceIdFactoryProvider(localResourceRepository)).createResourceIdFactory();
+
+ IAsterixAppRuntimeContextProvider asterixAppRuntimeContextProvider = new AsterixAppRuntimeContextProviderForRecovery(
+ this);
+ txnSubsystem = new TransactionSubsystem(ncApplicationContext.getNodeId(), asterixAppRuntimeContextProvider);
isShuttingdown = false;
}
@@ -103,49 +122,6 @@
this.isShuttingdown = isShuttingdown;
}
- private int getBufferCachePageSize() {
- int pageSize = DEFAULT_BUFFER_CACHE_PAGE_SIZE;
- String pageSizeStr = System.getProperty(GlobalConfig.BUFFER_CACHE_PAGE_SIZE_PROPERTY, null);
- if (pageSizeStr != null) {
- try {
- pageSize = Integer.parseInt(pageSizeStr);
- } catch (NumberFormatException nfe) {
- if (GlobalConfig.ASTERIX_LOGGER.isLoggable(Level.WARNING)) {
- GlobalConfig.ASTERIX_LOGGER.warning("Wrong buffer cache page size argument. "
- + "Using default value: " + pageSize);
- }
- }
- }
-
- if (GlobalConfig.ASTERIX_LOGGER.isLoggable(Level.INFO)) {
- GlobalConfig.ASTERIX_LOGGER.info("Buffer cache page size: " + pageSize);
- }
-
- return pageSize;
- }
-
- private int getBufferCacheNumPages() {
- int numPages = GlobalConfig.DEFAULT_BUFFER_CACHE_NUM_PAGES;
- String numPagesStr = System.getProperty(GlobalConfig.BUFFER_CACHE_NUM_PAGES_PROPERTY, null);
- if (numPagesStr != null) {
- try {
- numPages = Integer.parseInt(numPagesStr);
- } catch (NumberFormatException nfe) {
- if (GlobalConfig.ASTERIX_LOGGER.isLoggable(Level.WARNING)) {
- GlobalConfig.ASTERIX_LOGGER.warning("Wrong buffer cache size argument. " + "Using default value: "
- + numPages);
- }
- return numPages;
- }
- }
-
- if (GlobalConfig.ASTERIX_LOGGER.isLoggable(Level.INFO)) {
- GlobalConfig.ASTERIX_LOGGER.info("Buffer cache size (number of pages): " + numPages);
- }
-
- return numPages;
- }
-
public void deinitialize() throws HyracksDataException {
bufferCache.close();
for (IIndex index : indexLifecycleManager.getOpenIndexes()) {
@@ -216,4 +192,29 @@
public IIOManager getIOManager() {
return ioManager;
}
+
+ @Override
+ public AsterixStorageProperties getStorageProperties() {
+ return storageProperties;
+ }
+
+ @Override
+ public AsterixTransactionProperties getTransactionProperties() {
+ return txnProperties;
+ }
+
+ @Override
+ public AsterixCompilerProperties getCompilerProperties() {
+ return compilerProperties;
+ }
+
+ @Override
+ public AsterixMetadataProperties getMetadataProperties() {
+ return metadataProperties;
+ }
+
+ @Override
+ public AsterixExternalProperties getExternalProperties() {
+ return externalProperties;
+ }
}
\ No newline at end of file
diff --git a/asterix-installer/src/main/resources/conf/asterix-configuration.xml b/asterix-installer/src/main/resources/conf/asterix-configuration.xml
index ba08022..9920ecf 100644
--- a/asterix-installer/src/main/resources/conf/asterix-configuration.xml
+++ b/asterix-installer/src/main/resources/conf/asterix-configuration.xml
@@ -14,100 +14,136 @@
</property>
<property>
- <name>num.pages.buffer.cache</name>
- <value>1000</value>
- <description>The number of pages allocated to the disk buffer cache.</description>
- </property>
-
- <property>
- <name>total.size.memory.component</name>
- <value>512m</value>
- <description>The total size of memory that the sum of all open memory
- components cannot exceed.</description>
- </property>
-
- <property>
- <name>memory.component.num.pages</name>
- <value>1000</value>
- <description>The number of pages to allocate for a memory component.
- </description>
- </property>
-
- <property>
- <name>memory.component.page.size</name>
+ <name>storage.buffercache.pagesize</name>
<value>32768</value>
- <description>The size of buffer pages for memory components.
+ <description>The page size in bytes for pages in the buffer cache.
+ (Default = 32KB)
</description>
</property>
<property>
- <name>log.buffer.num.pages</name>
+ <name>storage.buffercache.numpages</name>
+ <value>1024</value>
+ <description>The number of pages allocated to the disk buffer cache.
+ (Default = 1024)
+ </description>
+ </property>
+
+ <property>
+ <name>storage.buffercache.maxopenfiles</name>
+ <value>214748364</value>
+ <description>The maximum number of open files in the buffer cache.
+ (Default = 214748364)
+ </description>
+ </property>
+
+ <property>
+ <name>storage.memorycomponent.pagesize</name>
+ <value>32768</value>
+ <description>The page size in bytes for pages allocated to memory
+ components. (Default = 32KB)
+ </description>
+ </property>
+
+ <property>
+ <name>storage.memorycomponent.numpages</name>
+ <value>4096</value>
+ <description>The number of pages to allocate for a memory component.
+ (Default = 4096)
+ </description>
+ </property>
+
+ <property>
+ <name>storage.memorycomponent.globalbudget</name>
+ <value>1073741824</value>
+ <description>The total size of memory in bytes that the sum of all
+ open memory
+ components cannot exceed. (Default = 1073741824 // 1GB)
+ </description>
+ </property>
+
+ <property>
+ <name>storage.lsm.mergethreshold</name>
+ <value>3</value>
+ <description>The number of on-disk components an LSM index can have
+ before a merge is triggered. (Default = 3)
+ </description>
+ </property>
+
+ <property>
+ <name>txn.log.buffer.numpages</name>
<value>8</value>
<description></description>
</property>
<property>
- <name>log.buffer.page.size</name>
- <value>128k</value>
+ <name>txn.log.buffer.pagesize</name>
+ <value>131072</value>
<description></description>
</property>
<property>
- <name>log.partition.size</name>
+ <name>txn.log.partitionsize</name>
<value>2147483648</value>
<description></description>
</property>
<property>
- <name>group.commit.interval</name>
- <value>200ms</value>
+ <name>txn.log.groupcommitinterval</name>
+ <value>200</value>
<description></description>
</property>
<property>
- <name>lsn.threshold</name>
- <value>64m</value>
+ <name>txn.log.checkpoint.lsnthreshold</name>
+ <value>67108864</value>
<description></description>
</property>
<property>
- <name>checkpoint.terms.in.secs</name>
+ <name>txn.log.checkpoint.pollfrequency</name>
<value>120</value>
<description></description>
</property>
<property>
- <name>escalate.threshold.entity.to.dataset</name>
- <value>8</value>
+ <name>txn.lock.escalationthreshold</name>
+ <value>1000</value>
<description></description>
</property>
<property>
- <name>shrink.timer.threshold</name>
+ <name>txn.lock.shrinktimer</name>
<value>120000</value>
<description></description>
</property>
-
+
<property>
- <name>sort.op.memory</name>
- <value>200m</value>
+ <name>compiler.sortmemory</name>
+ <value>536870912</value>
<description></description>
</property>
<property>
- <name>join.op.memory</name>
- <value>200m</value>
+ <name>compiler.joinmemory</name>
+ <value>536870912</value>
<description></description>
</property>
<property>
- <name>web.interface.port</name>
+ <name>compiler.framesize</name>
+ <value>32768</value>
+ <description></description>
+ </property>
+
+ <property>
+ <name>external.webport</name>
<value>19001</value>
<description></description>
</property>
<property>
- <name>log.level</name>
+ <name>external.loglevel</name>
<value>INFO</value>
<description></description>
</property>
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java
index 994262d..09ec2f7 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java
@@ -20,11 +20,11 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import edu.uci.ics.asterix.common.config.AsterixMetadataProperties;
import edu.uci.ics.asterix.common.functions.FunctionSignature;
import edu.uci.ics.asterix.metadata.api.IAsterixStateProxy;
import edu.uci.ics.asterix.metadata.api.IMetadataManager;
import edu.uci.ics.asterix.metadata.api.IMetadataNode;
-import edu.uci.ics.asterix.metadata.bootstrap.MetadataConstants;
import edu.uci.ics.asterix.metadata.entities.Dataset;
import edu.uci.ics.asterix.metadata.entities.DatasourceAdapter;
import edu.uci.ics.asterix.metadata.entities.Datatype;
@@ -85,12 +85,14 @@
private IAsterixStateProxy proxy;
private IMetadataNode metadataNode;
private final ReadWriteLock metadataLatch;
+ private final AsterixMetadataProperties metadataProperties;
- public MetadataManager(IAsterixStateProxy proxy) {
+ public MetadataManager(IAsterixStateProxy proxy, AsterixMetadataProperties metadataProperties) {
if (proxy == null) {
throw new Error("Null proxy given to MetadataManager.");
}
this.proxy = proxy;
+ this.metadataProperties = metadataProperties;
this.metadataNode = null;
this.metadataLatch = new ReentrantReadWriteLock(true);
}
@@ -105,7 +107,7 @@
metadataNode = proxy.getMetadataNode();
if (metadataNode == null) {
throw new Error("Failed to get the MetadataNode.\n" + "The MetadataNode was configured to run on NC: "
- + proxy.getAsterixProperties().getMetadataNodeName());
+ + metadataProperties.getMetadataNodeName());
}
}
}
@@ -544,10 +546,10 @@
throw new MetadataException(e);
}
}
-
+
@Override
public int getMostRecentDatasetId() throws MetadataException {
- try {
+ try {
return metadataNode.getMostRecentDatasetId();
} catch (RemoteException e) {
throw new MetadataException(e);
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 d67cd27..7f06c30 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,17 +19,11 @@
import java.rmi.Remote;
import java.rmi.RemoteException;
-import edu.uci.ics.asterix.common.config.AsterixProperties;
-
/**
* Interface for setting/getting distributed state of Asterix.
*/
public interface IAsterixStateProxy extends Remote, Serializable {
public void setMetadataNode(IMetadataNode metadataNode) throws RemoteException;
- public void setAsterixProperties(AsterixProperties asterixProperties) throws RemoteException;
-
public IMetadataNode getMetadataNode() throws RemoteException;
-
- public AsterixProperties getAsterixProperties() throws RemoteException;
}
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 55aaf33..33f6994 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,7 +19,6 @@
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;
@@ -31,7 +30,6 @@
private static final Logger LOGGER = Logger.getLogger(AsterixStateProxy.class.getName());
private IMetadataNode metadataNode;
- private AsterixProperties asterixProperties;
private static final IAsterixStateProxy cc = new AsterixStateProxy();
public static IAsterixStateProxy registerRemoteObject() throws RemoteException {
@@ -54,14 +52,4 @@
public IMetadataNode getMetadataNode() throws RemoteException {
return this.metadataNode;
}
-
- @Override
- public void setAsterixProperties(AsterixProperties asterixProperity) throws RemoteException {
- this.asterixProperties = asterixProperity;
- }
-
- @Override
- public AsterixProperties getAsterixProperties() throws RemoteException {
- return this.asterixProperties;
- }
}
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 d978f8a..8322ae1 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
@@ -20,13 +20,13 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
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.AsterixMetadataProperties;
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;
@@ -110,7 +110,7 @@
private static String metadataNodeName;
private static String metadataStore;
- private static HashSet<String> nodeNames;
+ private static Set<String> nodeNames;
private static String outputDir;
private static IMetadataIndex[] primaryIndexes;
@@ -127,8 +127,8 @@
MetadataSecondaryIndexes.DATATYPENAME_ON_DATATYPE_INDEX };
}
- public static void startUniverse(AsterixProperties asterixProperties, INCApplicationContext ncApplicationContext,
- boolean isNewUniverse) throws Exception {
+ public static void startUniverse(AsterixMetadataProperties metadataProperties,
+ INCApplicationContext ncApplicationContext, boolean isNewUniverse) throws Exception {
runtimeContext = (AsterixAppRuntimeContext) ncApplicationContext.getApplicationObject();
// Initialize static metadata objects, such as record types and metadata
@@ -149,9 +149,9 @@
resourceRepository.registerTransactionalResourceManager(ResourceType.LSM_INVERTED_INDEX,
new IndexResourceManager(ResourceType.LSM_INVERTED_INDEX, runtimeContext.getTransactionSubsystem()));
- metadataNodeName = asterixProperties.getMetadataNodeName();
- metadataStore = asterixProperties.getMetadataStore();
- nodeNames = asterixProperties.getNodeNames();
+ metadataNodeName = metadataProperties.getMetadataNodeName();
+ metadataStore = metadataProperties.getMetadataStore();
+ nodeNames = metadataProperties.getNodeNames();
// nodeStores = asterixProperity.getStores();
indexLifecycleManager = runtimeContext.getIndexLifecycleManager();
@@ -165,7 +165,7 @@
// Begin a transaction against the metadata.
// Lock the metadata in X mode.
MetadataManager.INSTANCE.lock(mdTxnCtx, LockMode.X);
-
+
if (isNewUniverse) {
for (int i = 0; i < primaryIndexes.length; i++) {
enlistMetadataDataset(primaryIndexes[i], true);
@@ -196,7 +196,7 @@
LOGGER.info("Finished enlistment of metadata B-trees.");
}
}
-
+
//#. initialize datasetIdFactory
MetadataManager.INSTANCE.initializeDatasetIdFactory(mdTxnCtx);
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
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 70383f9..51702a7 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,7 +22,8 @@
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.api.AsterixAppContextInfoImpl;
+import edu.uci.ics.asterix.common.config.AsterixMetadataProperties;
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;
@@ -73,8 +74,10 @@
this.dataverseName = dataverseName;
this.outputFile = outputFile;
this.config = config;
+ AsterixMetadataProperties metadataProperties = ((AsterixAppContextInfoImpl) AsterixAppContextInfoImpl
+ .getInstance()).getMetadataProperties();
if (stores == null && online) {
- this.stores = AsterixProperties.INSTANCE.getStores();
+ this.stores = metadataProperties.getStores();
} else {
this.stores = stores;
}
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 8bbddec..22c9013 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,7 +23,8 @@
import java.util.Map;
import java.util.logging.Logger;
-import edu.uci.ics.asterix.common.config.AsterixProperties;
+import edu.uci.ics.asterix.common.api.AsterixAppContextInfoImpl;
+import edu.uci.ics.asterix.common.config.AsterixMetadataProperties;
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;
@@ -171,7 +172,9 @@
public AqlMetadataProvider(Dataverse defaultDataverse) {
this.defaultDataverse = defaultDataverse;
- this.stores = AsterixProperties.INSTANCE.getStores();
+ AsterixMetadataProperties metadataProperties = ((AsterixAppContextInfoImpl) AsterixAppContextInfoImpl
+ .getInstance()).getMetadataProperties();
+ this.stores = metadataProperties.getStores();
}
public void setJobId(JobId jobId) {