This is an automated email from the ASF dual-hosted git repository. jensdeppe pushed a commit to branch feature/GEODE-5787-process-holder in repository https://gitbox.apache.org/repos/asf/geode.git
commit 46d3421c513bcb9b3875245747fbf5f5ac357c5d Author: Jens Deppe <jde...@pivotal.io> AuthorDate: Mon Oct 1 15:43:51 2018 -0700 GEODE-5787: extract ProcessHolder to be an outer class * Removed getter on ProcessHolder to get underlying process * Added waitFor to ProcessHolder * Added getters to get underlying process error & input stream Signed-off-by: Sai Boorlagadda <sboorlaga...@pivotal.io> --- .../geode/test/dunit/standalone/DUnitLauncher.java | 3 +- .../geode/test/dunit/standalone/ProcessHolder.java | 44 ++++++++++++++++++++++ .../test/dunit/standalone/ProcessManager.java | 37 ++---------------- 3 files changed, 49 insertions(+), 35 deletions(-) diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/DUnitLauncher.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/DUnitLauncher.java index 58c7c9b..8f82f9b 100644 --- a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/DUnitLauncher.java +++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/DUnitLauncher.java @@ -124,8 +124,9 @@ public class DUnitLauncher { static final String MASTER_PARAM = "DUNIT_MASTER"; public static final String RMI_PORT_PARAM = GEMFIRE_PREFIX + "DUnitLauncher.RMI_PORT"; + public static final String RMI_HOST_PARAM = GEMFIRE_PREFIX + "DUnitLauncher.RMI_HOST"; public static final String VM_NUM_PARAM = GEMFIRE_PREFIX + "DUnitLauncher.VM_NUM"; - static final String VM_VERSION_PARAM = GEMFIRE_PREFIX + "DUnitLauncher.VM_VERSION"; + public static final String VM_VERSION_PARAM = GEMFIRE_PREFIX + "DUnitLauncher.VM_VERSION"; private static final String LAUNCHED_PROPERTY = GEMFIRE_PREFIX + "DUnitLauncher.LAUNCHED"; diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ProcessHolder.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ProcessHolder.java new file mode 100644 index 0000000..0480d6e --- /dev/null +++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ProcessHolder.java @@ -0,0 +1,44 @@ +package org.apache.geode.test.dunit.standalone; + + +import java.io.InputStream; + +//TODO:: Do we need ProcessHolder? +public class ProcessHolder { + private final Process process; + private volatile boolean killed = false; + + public ProcessHolder(Process process) { + this.process = process; + } + + public void kill() { + this.killed = true; + process.destroy(); + } + + public void killForcibly() { + this.killed = true; + process.destroyForcibly(); + } + + public void waitFor() throws InterruptedException { + process.waitFor(); + } + + public InputStream getErrorStream() { + return process.getErrorStream(); + } + + public InputStream getInputStream() { + return process.getInputStream(); + } + + public boolean isKilled() { + return killed; + } + + public boolean isAlive() { + return !killed && process.isAlive(); + } +} diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ProcessManager.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ProcessManager.java index a200f14..79a3dda 100755 --- a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ProcessManager.java +++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ProcessManager.java @@ -95,8 +95,8 @@ public class ProcessManager { pendingVMs++; ProcessHolder holder = new ProcessHolder(process); processes.put(vmNum, holder); - linkStreams(version, vmNum, holder, process.getErrorStream(), System.err); - linkStreams(version, vmNum, holder, process.getInputStream(), System.out); + linkStreams(version, vmNum, holder, holder.getErrorStream(), System.err); + linkStreams(version, vmNum, holder, holder.getInputStream(), System.out); } catch (RuntimeException | Error t) { t.printStackTrace(); throw t; @@ -141,7 +141,7 @@ public class ProcessManager { } else { holder.kill(); } - holder.getProcess().waitFor(); + holder.waitFor(); System.out.println("Old process for vm_" + vmNum + " has exited"); launchVM(version, vmNum, true); } catch (InterruptedException | IOException e) { @@ -328,37 +328,6 @@ public class ProcessManager { return true; } - public static class ProcessHolder { - private final Process process; - private volatile boolean killed = false; - - public ProcessHolder(Process process) { - this.process = process; - } - - public void kill() { - this.killed = true; - process.destroy(); - } - - public void killForcibly() { - this.killed = true; - process.destroyForcibly(); - } - - public Process getProcess() { - return process; - } - - public boolean isKilled() { - return killed; - } - - public boolean isAlive() { - return !killed && process.isAlive(); - } - } - public RemoteDUnitVMIF getStub(int i) throws AccessException, RemoteException, NotBoundException, InterruptedException { return getStub(VersionManager.CURRENT_VERSION, i);