This is an automated email from the ASF dual-hosted git repository.
sai_boorlagadda pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 9622a68 GEODE-5787: extract ProcessHolder to be an outer class (#2550)
9622a68 is described below
commit 9622a68f0288ba926fa91bdd91c5a45c7f226e97
Author: Jens Deppe <[email protected]>
AuthorDate: Tue Oct 2 11:39:06 2018 -0700
GEODE-5787: extract ProcessHolder to be an outer class (#2550)
* 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 <[email protected]>
---
.../geode/test/dunit/standalone/DUnitLauncher.java | 3 +-
.../geode/test/dunit/standalone/ProcessHolder.java | 56 ++++++++++++++++++++++
.../test/dunit/standalone/ProcessManager.java | 37 ++------------
3 files changed, 61 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..ebc0530
--- /dev/null
+++
b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ProcessHolder.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You 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 at
+ *
+ * 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 org.apache.geode.test.dunit.standalone;
+
+import java.io.InputStream;
+
+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);