Chris Hillery has uploaded a new change for review.
https://asterix-gerrit.ics.uci.edu/887
Change subject: ASTERIXDB-1428: Config-management improvements for AsterixDB
......................................................................
ASTERIXDB-1428: Config-management improvements for AsterixDB
1. Added ability for NC Service to log NC output to file
2. Improve config communication from CC to NC
3. Allow overriding NC command name from CC config (and removed said
option from NC Service config as that's the wrong place to manage it)
4. Improve finding NC command (don't depend on PATH)
5. Create asterixncservice.bat script for Windows
Change-Id: I0f2ad32d489ffc27adbb06aebcc1f22a9fcf784e
---
M asterixdb/asterix-server/pom.xml
M
hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/TriggerNCWork.java
M
hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/NCConfig.java
M
hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCService.java
M
hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCServiceConfig.java
5 files changed, 69 insertions(+), 28 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/87/887/1
diff --git a/asterixdb/asterix-server/pom.xml b/asterixdb/asterix-server/pom.xml
index f22049b..812fd59 100644
--- a/asterixdb/asterix-server/pom.xml
+++ b/asterixdb/asterix-server/pom.xml
@@ -105,6 +105,13 @@
<commandLineArgument>org.apache.asterix.hyracks.bootstrap.NCApplicationEntryPoint</commandLineArgument>
</commandLineArguments>
</daemon>
+ <daemon>
+ <id>asterixncservice</id>
+
<mainClass>org.apache.hyracks.control.nc.service.NCService</mainClass>
+ <platforms>
+ <platform>booter-windows</platform>
+ </platforms>
+ </daemon>
</daemons>
</configuration>
<executions>
diff --git
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/TriggerNCWork.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/TriggerNCWork.java
index 75d4dd2..497b08a 100644
---
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/TriggerNCWork.java
+++
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/TriggerNCWork.java
@@ -104,14 +104,18 @@
*/
String serializeIni(Ini ccini) throws IOException {
Ini ini = new Ini();
+
+ // First copy the global [nc] section to a new section named for
+ // *this* NC, so that those values serve as defaults.
String ncsection = "nc/" + ncId;
+ copyIniSection(ccini, "nc", ini, ncsection);
+ // Now copy all sections to their same name in the derived config.
for (String section : ccini.keySet()) {
- if (section.equals(ncsection)) {
- copyIniSection(ccini, ncsection, ini, "localnc");
- ini.put("localnc", "id", ncId);
- }
copyIniSection(ccini, section, ini, section);
}
+ // Finally insert "this" NC's name into localnc section - this is a
fixed
+ // entry point so that NCs can determine where all their config is.
+ ini.put("localnc", "id", ncId);
StringWriter iniString = new StringWriter();
ini.store(iniString);
if (LOGGER.isLoggable(Level.FINE)) {
diff --git
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/NCConfig.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/NCConfig.java
index 4240e3a..b741256 100644
---
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/NCConfig.java
+++
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/NCConfig.java
@@ -124,33 +124,35 @@
// that logic really should be handled by the ini file sent from the CC
ccHost = IniUtils.getString(ini, "cc", "cluster.address", ccHost);
ccPort = IniUtils.getInt(ini, "cc", "cluster.port", ccPort);
+
+ // Get ID of *this* NC
nodeId = IniUtils.getString(ini, "localnc", "id", nodeId);
+ String nodeSection = "nc/" + nodeId;
// Network ports
+ ipAddress = IniUtils.getString(ini, nodeSection, "address", ipAddress);
- ipAddress = IniUtils.getString(ini, "localnc", "address", ipAddress);
+ clusterNetIPAddress = IniUtils.getString(ini, nodeSection,
"cluster.address", clusterNetIPAddress);
+ clusterNetPort = IniUtils.getInt(ini, nodeSection, "cluster.port",
clusterNetPort);
+ dataIPAddress = IniUtils.getString(ini, nodeSection, "data.address",
dataIPAddress);
+ dataPort = IniUtils.getInt(ini, nodeSection, "data.port", dataPort);
+ resultIPAddress = IniUtils.getString(ini, nodeSection,
"result.address", resultIPAddress);
+ resultPort = IniUtils.getInt(ini, nodeSection, "result.port",
resultPort);
- clusterNetIPAddress = IniUtils.getString(ini, "localnc",
"cluster.address", clusterNetIPAddress);
- clusterNetPort = IniUtils.getInt(ini, "localnc", "cluster.port",
clusterNetPort);
- dataIPAddress = IniUtils.getString(ini, "localnc", "data.address",
dataIPAddress);
- dataPort = IniUtils.getInt(ini, "localnc", "data.port", dataPort);
- resultIPAddress = IniUtils.getString(ini, "localnc", "result.address",
resultIPAddress);
- resultPort = IniUtils.getInt(ini, "localnc", "result.port",
resultPort);
+ clusterNetPublicIPAddress = IniUtils.getString(ini, nodeSection,
"public.cluster.address", clusterNetPublicIPAddress);
+ clusterNetPublicPort = IniUtils.getInt(ini, nodeSection,
"public.cluster.port", clusterNetPublicPort);
+ dataPublicIPAddress = IniUtils.getString(ini, nodeSection,
"public.data.address", dataPublicIPAddress);
+ dataPublicPort = IniUtils.getInt(ini, nodeSection, "public.data.port",
dataPublicPort);
+ resultPublicIPAddress = IniUtils.getString(ini, nodeSection,
"public.result.address", resultPublicIPAddress);
+ resultPublicPort = IniUtils.getInt(ini, nodeSection,
"public.result.port", resultPublicPort);
- clusterNetPublicIPAddress = IniUtils.getString(ini, "localnc",
"public.cluster.address", clusterNetPublicIPAddress);
- clusterNetPublicPort = IniUtils.getInt(ini, "localnc",
"public.cluster.port", clusterNetPublicPort);
- dataPublicIPAddress = IniUtils.getString(ini, "localnc",
"public.data.address", dataPublicIPAddress);
- dataPublicPort = IniUtils.getInt(ini, "localnc", "public.data.port",
dataPublicPort);
- resultPublicIPAddress = IniUtils.getString(ini, "localnc",
"public.result.address", resultPublicIPAddress);
- resultPublicPort = IniUtils.getInt(ini, "localnc",
"public.result.port", resultPublicPort);
-
- retries = IniUtils.getInt(ini, "localnc", "retries", retries);
+ retries = IniUtils.getInt(ini, nodeSection, "retries", retries);
// Directories
- ioDevices = IniUtils.getString(ini, "localnc", "iodevices", ioDevices);
+ ioDevices = IniUtils.getString(ini, nodeSection, "iodevices",
ioDevices);
// Hyracks client entrypoint
- appNCMainClass = IniUtils.getString(ini, "localnc", "app.class",
appNCMainClass);
+ appNCMainClass = IniUtils.getString(ini, nodeSection, "app.class",
appNCMainClass);
}
/*
diff --git
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCService.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCService.java
index df92d1a..ba63c67 100644
---
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCService.java
+++
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCService.java
@@ -50,6 +50,11 @@
private static Ini ini = new Ini();
/**
+ * The Ini section representing *this* NC
+ */
+ private static String nodeSection = null;
+
+ /**
* The NCServiceConfig
*/
private static NCServiceConfig config;
@@ -73,12 +78,23 @@
private static List<String> buildCommand() throws IOException {
List<String> cList = new ArrayList<String>();
+
+ // Find the command to run. For now, we allow overriding the name, but
+ // still assume it's located in the bin/ directory of the deployment.
+ // Even this is likely more configurability than we need.
+ String command = getStringINIOpt(ini, nodeSection, "command",
"hyracksnc");
+ // app.home is specified by the Maven appassembler plugin. If it isn't
set,
+ // fall back to user's home dir. Again this is likely more flexibility
+ // than we need.
+ String apphome = System.getProperty("app.home",
System.getProperty("user.home"));
+ String path = apphome + File.separator + "bin" + File.separator;
if (SystemUtils.IS_OS_WINDOWS) {
- cList.add(config.command + ".bat");
+ cList.add(path + command + ".bat");
}
else {
- cList.add(config.command);
+ cList.add(path + command);
}
+
cList.add("-config-file");
// Store the Ini file from the CC locally so NCConfig can read it.
// QQQ should arrange to delete this when done
@@ -92,7 +108,7 @@
if (env.containsKey("JAVA_OPTS")) {
return;
}
- String jvmargs = getStringINIOpt(ini, "localnc", "jvm.args",
"-Xmx1536m");
+ String jvmargs = getStringINIOpt(ini, nodeSection, "jvm.args",
"-Xmx1536m");
env.put("JAVA_OPTS", jvmargs);
}
@@ -113,6 +129,13 @@
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Launching NCDriver process");
+ }
+
+ // Logfile
+ if (! "-".equals(config.logfile)) {
+ pb.redirectErrorStream(true);
+ File log = new File(config.logfile);
+ pb.redirectOutput(ProcessBuilder.Redirect.appendTo(log));
}
proc = pb.start();
@@ -155,6 +178,7 @@
}
String iniString = ois.readUTF();
ini = new Ini(new StringReader(iniString));
+ nodeSection = "nc/" + getStringINIOpt(ini, "localnc", "id", "");
return launchNCProcess();
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Error decoding connection from server",
e);
diff --git
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCServiceConfig.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCServiceConfig.java
index bc982f3..9143c9b 100644
---
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCServiceConfig.java
+++
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCServiceConfig.java
@@ -22,6 +22,7 @@
import org.ini4j.Ini;
import org.kohsuke.args4j.Option;
+import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
@@ -47,9 +48,9 @@
usage = "Port to listen on for connections from CC (default:
9090)")
public int port = 9090;
- @Option(name = "-command", required = false,
- usage = "NC command to run (default: 'hyracksnc' on PATH)")
- public String command = "hyracksnc";
+ @Option(name = "-logfile", required = false,
+ usage = "Filename to log NC output ('-' for stdout of NC service;
default: $HOME/nc.log)")
+ public String logfile = null;
private Ini ini = null;
@@ -61,6 +62,7 @@
ini = IniUtils.loadINIFile(configFile);
address = IniUtils.getString(ini, "ncservice", "address", address);
port = IniUtils.getInt(ini, "ncservice", "port", port);
+ logfile = IniUtils.getString(ini, "ncservice", "logfile", logfile);
}
/**
@@ -73,6 +75,8 @@
if (configFile != null) {
loadINIFile();
}
- // No defaults necessary beyond the static ones for this config
+ if (logfile == null) {
+ logfile = System.getProperty("user.home") + File.separator +
"nc.log";
+ }
}
}
--
To view, visit https://asterix-gerrit.ics.uci.edu/887
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f2ad32d489ffc27adbb06aebcc1f22a9fcf784e
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Chris Hillery <[email protected]>