Till Westmann has uploaded a new change for review.
https://asterix-gerrit.ics.uci.edu/1249
Change subject: remove ini file on abnormal termination
......................................................................
remove ini file on abnormal termination
Change-Id: I963825969bbe9e6e1ce686222b42d6e0f5769d28
---
M
hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCService.java
1 file changed, 19 insertions(+), 6 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/49/1249/1
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 848bdd2..67f55f3 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
@@ -72,7 +72,7 @@
*/
private static Process proc = null;
- private static List<String> buildCommand() throws IOException {
+ private static List<String> buildCommand(File tempIni) throws IOException {
List<String> cList = new ArrayList<>();
// Find the command to run. For now, we allow overriding the name, but
@@ -91,9 +91,6 @@
}
cList.add("-config-file");
- // Store the Ini file from the CC locally so NCConfig can read it.
- File tempIni = File.createTempFile("ncconf", ".conf");
- tempIni.deleteOnExit();
ini.store(tempIni);
cList.add(tempIni.getCanonicalPath());
@@ -126,9 +123,11 @@
* prevented the process from being launched or the process returned
* a non-0 (abnormal) exit code.
*/
- private static boolean launchNCProcess() {
+ private static boolean launchNCProcess() throws IOException {
+ // Store the Ini file from the CC locally so NCConfig can read it.
+ File tempIni = File.createTempFile("ncconf", ".conf");
try {
- ProcessBuilder pb = new ProcessBuilder(buildCommand());
+ ProcessBuilder pb = new ProcessBuilder(buildCommand(tempIni));
configEnvironment(pb.environment());
// QQQ inheriting probably isn't right
pb.inheritIO();
@@ -163,6 +162,7 @@
try {
retval = proc.waitFor();
waiting = false;
+ tempIni = delete(tempIni);
} catch (InterruptedException ignored) {
}
}
@@ -177,9 +177,22 @@
LOGGER.log(Level.SEVERE, "Configuration from CC broken", e);
}
return false;
+ } finally {
+ delete(tempIni);
}
}
+ static private File delete(File tmpFile) {
+ if (tmpFile == null) {
+ return null;
+ }
+ if (!tmpFile.delete()) {
+ LOGGER.warning(tmpFile.toString() + "not deleted");
+ return tmpFile;
+ }
+ return null;
+ }
+
private static boolean acceptConnection(InputStream is) {
// Simple on-wire protocol:
// magic cookie (string)
--
To view, visit https://asterix-gerrit.ics.uci.edu/1249
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I963825969bbe9e6e1ce686222b42d6e0f5769d28
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Till Westmann <[email protected]>