support for configurable parameters for an asterix instance
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>