You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by sa...@apache.org on 2018/10/03 16:36:59 UTC

[geode] branch feature/GEODE-5787-dunit-internal updated (307ea0d -> 778220a)

This is an automated email from the ASF dual-hosted git repository.

sai_boorlagadda pushed a change to branch feature/GEODE-5787-dunit-internal
in repository https://gitbox.apache.org/repos/asf/geode.git.


 discard 307ea0d  GEODE-5787: extract inner classes in dunit
     new 778220a  GEODE-5787: extract inner classes in dunit

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (307ea0d)
            \
             N -- N -- N   refs/heads/feature/GEODE-5787-dunit-internal (778220a)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[geode] 01/01: GEODE-5787: extract inner classes in dunit

Posted by sa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sai_boorlagadda pushed a commit to branch feature/GEODE-5787-dunit-internal
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 778220a09de898b69b3bbff849e66c8546b8e496
Author: Sai Boorlagadda <sb...@pivotal.io>
AuthorDate: Wed Oct 3 09:36:32 2018 -0700

    GEODE-5787: extract inner classes in dunit
    
    Signed-off-by: Kirk Lund <kl...@apache.org>
---
 .../geode/test/dunit/standalone/ChildVM.java       |   1 -
 .../geode/test/dunit/standalone/DUnitHost.java     |  99 +++++++++++++
 .../geode/test/dunit/standalone/DUnitLauncher.java | 160 +--------------------
 .../apache/geode/test/dunit/standalone/Master.java |  56 ++++++++
 .../geode/test/dunit/standalone/MasterRemote.java  |  16 +++
 .../geode/test/dunit/standalone/MethExecutor.java  |   2 +-
 .../test/dunit/standalone/ProcessManager.java      |  36 +----
 .../geode/test/dunit/standalone/RemoteDUnitVM.java |   2 +-
 .../test/dunit/standalone/StandAloneDUnitEnv.java  |   1 -
 9 files changed, 177 insertions(+), 196 deletions(-)

diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ChildVM.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ChildVM.java
index fe3277b..3c0e43c 100644
--- a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ChildVM.java
+++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/ChildVM.java
@@ -23,7 +23,6 @@ import org.apache.geode.internal.OSProcess;
 import org.apache.geode.internal.Version;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.dunit.standalone.DUnitLauncher.MasterRemote;
 
 public class ChildVM {
 
diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/DUnitHost.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/DUnitHost.java
new file mode 100644
index 0000000..46f3e24
--- /dev/null
+++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/DUnitHost.java
@@ -0,0 +1,99 @@
+package org.apache.geode.test.dunit.standalone;
+
+import java.io.IOException;
+import java.rmi.AccessException;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.registry.Registry;
+
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.VM;
+
+class DUnitHost extends Host {
+  private static final long serialVersionUID = -8034165624503666383L;
+
+  private final transient VM debuggingVM;
+
+  private transient ProcessManager processManager;
+
+  public DUnitHost(String hostName, ProcessManager processManager) throws RemoteException {
+    super(hostName);
+    this.debuggingVM = new VM(this, -1, new RemoteDUnitVM());
+    this.processManager = processManager;
+  }
+
+  public void init(Registry registry, int numVMs)
+      throws AccessException, RemoteException, NotBoundException, InterruptedException {
+    for (int i = 0; i < numVMs; i++) {
+      RemoteDUnitVMIF remote = processManager.getStub(i);
+      addVM(i, remote);
+    }
+
+    addLocator(DUnitLauncher.LOCATOR_VM_NUM, processManager.getStub(DUnitLauncher.LOCATOR_VM_NUM));
+
+    addHost(this);
+  }
+
+  /**
+   * Retrieves one of this host's VMs based on the specified VM ID. This will not bounce VM to a
+   * different version. It will only get the current running VM or launch a new one if not already
+   * launched.
+   *
+   * @param n ID of the requested VM; a value of <code>-1</code> will return the controller VM,
+   *        which may be useful for debugging.
+   * @return VM for the requested VM ID.
+   */
+  @Override
+  public VM getVM(int n) {
+    if (n < getVMCount() && n != DUnitLauncher.DEBUGGING_VM_NUM) {
+      VM current = super.getVM(n);
+      return getVM(current.getVersion(), n);
+    } else {
+      return getVM(VersionManager.CURRENT_VERSION, n);
+    }
+  }
+
+  @Override
+  public VM getVM(String version, int n) {
+    if (n == DUnitLauncher.DEBUGGING_VM_NUM) {
+      // for ease of debugging, pass -1 to get the local VM
+      return debuggingVM;
+    }
+
+    if (n < getVMCount()) {
+      VM current = super.getVM(n);
+      if (!current.getVersion().equals(version)) {
+        System.out.println(
+            "Bouncing VM" + n + " from version " + current.getVersion() + " to " + version);
+        current.bounce(version);
+      }
+      return current;
+    }
+
+    int oldVMCount = getVMCount();
+    if (n >= oldVMCount) {
+      // If we don't have a VM with that number, dynamically create it.
+      try {
+        // first fill in any gaps, to keep the superclass, Host, happy
+        for (int i = oldVMCount; i < n; i++) {
+          processManager.launchVM(i);
+        }
+        processManager.waitForVMs(DUnitLauncher.STARTUP_TIMEOUT);
+
+        for (int i = oldVMCount; i < n; i++) {
+          addVM(i, processManager.getStub(i));
+        }
+
+        // now create the one we really want
+        processManager.launchVM(version, n, false);
+        processManager.waitForVMs(DUnitLauncher.STARTUP_TIMEOUT);
+        addVM(n, processManager.getStub(n));
+
+      } catch (IOException | InterruptedException | NotBoundException e) {
+        throw new RuntimeException("Could not dynamically launch vm + " + n, e);
+      }
+    }
+
+    return super.getVM(n);
+  }
+}
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 d427896..8052f8c 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
@@ -35,20 +35,15 @@ import java.net.InetAddress;
 import java.net.URISyntaxException;
 import java.nio.channels.FileChannel;
 import java.nio.charset.Charset;
-import java.rmi.AccessException;
 import java.rmi.AlreadyBoundException;
 import java.rmi.NotBoundException;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
-import java.rmi.server.UnicastRemoteObject;
 import java.util.List;
 import java.util.Properties;
 
 import batterytest.greplogs.ExpectedStrings;
 import batterytest.greplogs.LogConsumer;
-import org.apache.geode.test.dunit.standalone.MethExecutorResult;
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.core.LoggerContext;
@@ -66,7 +61,6 @@ import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.test.dunit.DUnitEnv;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.SerializableCallable;
-import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 
 /**
@@ -103,15 +97,15 @@ public class DUnitLauncher {
   /**
    * VM ID for the VM to use for the debugger.
    */
-  private static final int DEBUGGING_VM_NUM = -1;
+  static final int DEBUGGING_VM_NUM = -1;
 
   /**
    * VM ID for the VM to use for the locator.
    */
-  private static final int LOCATOR_VM_NUM = -2;
+  static final int LOCATOR_VM_NUM = -2;
 
   static final long STARTUP_TIMEOUT = 120 * 1000;
-  private static final String STARTUP_TIMEOUT_MESSAGE =
+  static final String STARTUP_TIMEOUT_MESSAGE =
       "VMs did not start up within " + (STARTUP_TIMEOUT / 1000) + " seconds";
 
   private static final String SUSPECT_FILENAME = "dunit_suspect.log";
@@ -417,152 +411,4 @@ public class DUnitLauncher {
   }
 
 
-  public interface MasterRemote extends Remote {
-    public int getLocatorPort() throws RemoteException;
-
-    public void signalVMReady() throws RemoteException;
-
-    public void ping() throws RemoteException;
-
-    public BounceResult bounce(int pid) throws RemoteException;
-
-    public BounceResult bounce(String version, int pid, boolean force) throws RemoteException;
-  }
-
-  public static class Master extends UnicastRemoteObject implements MasterRemote {
-    private static final long serialVersionUID = 1178600200232603119L;
-
-    private final Registry registry;
-    private final ProcessManager processManager;
-
-
-    public Master(Registry registry, ProcessManager processManager) throws RemoteException {
-      this.processManager = processManager;
-      this.registry = registry;
-    }
-
-    public int getLocatorPort() throws RemoteException {
-      return locatorPort;
-    }
-
-    public synchronized void signalVMReady() {
-      processManager.signalVMReady();
-    }
-
-    public void ping() {
-      // do nothing
-    }
-
-    @Override
-    public BounceResult bounce(int pid) {
-      return bounce(VersionManager.CURRENT_VERSION, pid, false);
-    }
-
-    @Override
-    public BounceResult bounce(String version, int pid, boolean force) {
-      processManager.bounce(version, pid, force);
-
-      try {
-        if (!processManager.waitForVMs(STARTUP_TIMEOUT)) {
-          throw new RuntimeException(STARTUP_TIMEOUT_MESSAGE);
-        }
-        RemoteDUnitVMIF remote =
-            (RemoteDUnitVMIF) registry.lookup(VM.getVMName(VersionManager.CURRENT_VERSION, pid));
-        return new BounceResult(pid, remote);
-      } catch (RemoteException | NotBoundException e) {
-        throw new RuntimeException("could not lookup name", e);
-      } catch (InterruptedException e) {
-        throw new RuntimeException("Failed waiting for VM", e);
-      }
-    }
-  }
-
-  private static class DUnitHost extends Host {
-    private static final long serialVersionUID = -8034165624503666383L;
-
-    private final transient VM debuggingVM;
-
-    private transient ProcessManager processManager;
-
-    public DUnitHost(String hostName, ProcessManager processManager) throws RemoteException {
-      super(hostName);
-      this.debuggingVM = new VM(this, -1, new RemoteDUnitVM());
-      this.processManager = processManager;
-    }
-
-    public void init(Registry registry, int numVMs)
-        throws AccessException, RemoteException, NotBoundException, InterruptedException {
-      for (int i = 0; i < numVMs; i++) {
-        RemoteDUnitVMIF remote = processManager.getStub(i);
-        addVM(i, remote);
-      }
-
-      addLocator(LOCATOR_VM_NUM, processManager.getStub(LOCATOR_VM_NUM));
-
-      addHost(this);
-    }
-
-    /**
-     * Retrieves one of this host's VMs based on the specified VM ID. This will not bounce VM to a
-     * different version. It will only get the current running VM or launch a new one if not already
-     * launched.
-     *
-     * @param n ID of the requested VM; a value of <code>-1</code> will return the controller VM,
-     *        which may be useful for debugging.
-     * @return VM for the requested VM ID.
-     */
-    @Override
-    public VM getVM(int n) {
-      if (n < getVMCount() && n != DEBUGGING_VM_NUM) {
-        VM current = super.getVM(n);
-        return getVM(current.getVersion(), n);
-      } else {
-        return getVM(VersionManager.CURRENT_VERSION, n);
-      }
-    }
-
-    @Override
-    public VM getVM(String version, int n) {
-      if (n == DEBUGGING_VM_NUM) {
-        // for ease of debugging, pass -1 to get the local VM
-        return debuggingVM;
-      }
-
-      if (n < getVMCount()) {
-        VM current = super.getVM(n);
-        if (!current.getVersion().equals(version)) {
-          System.out.println(
-              "Bouncing VM" + n + " from version " + current.getVersion() + " to " + version);
-          current.bounce(version);
-        }
-        return current;
-      }
-
-      int oldVMCount = getVMCount();
-      if (n >= oldVMCount) {
-        // If we don't have a VM with that number, dynamically create it.
-        try {
-          // first fill in any gaps, to keep the superclass, Host, happy
-          for (int i = oldVMCount; i < n; i++) {
-            processManager.launchVM(i);
-          }
-          processManager.waitForVMs(STARTUP_TIMEOUT);
-
-          for (int i = oldVMCount; i < n; i++) {
-            addVM(i, processManager.getStub(i));
-          }
-
-          // now create the one we really want
-          processManager.launchVM(version, n, false);
-          processManager.waitForVMs(STARTUP_TIMEOUT);
-          addVM(n, processManager.getStub(n));
-
-        } catch (IOException | InterruptedException | NotBoundException e) {
-          throw new RuntimeException("Could not dynamically launch vm + " + n, e);
-        }
-      }
-
-      return super.getVM(n);
-    }
-  }
 }
diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/Master.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/Master.java
new file mode 100644
index 0000000..f875dc0
--- /dev/null
+++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/Master.java
@@ -0,0 +1,56 @@
+package org.apache.geode.test.dunit.standalone;
+
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+
+import org.apache.geode.test.dunit.VM;
+
+class Master extends UnicastRemoteObject implements MasterRemote {
+  private static final long serialVersionUID = 1178600200232603119L;
+
+  private final Registry registry;
+  private final ProcessManager processManager;
+
+
+  public Master(Registry registry, ProcessManager processManager) throws RemoteException {
+    this.processManager = processManager;
+    this.registry = registry;
+  }
+
+  public int getLocatorPort() throws RemoteException {
+    return DUnitLauncher.locatorPort;
+  }
+
+  public synchronized void signalVMReady() {
+    processManager.signalVMReady();
+  }
+
+  public void ping() {
+    // do nothing
+  }
+
+  @Override
+  public BounceResult bounce(int pid) {
+    return bounce(VersionManager.CURRENT_VERSION, pid, false);
+  }
+
+  @Override
+  public BounceResult bounce(String version, int pid, boolean force) {
+    processManager.bounce(version, pid, force);
+
+    try {
+      if (!processManager.waitForVMs(DUnitLauncher.STARTUP_TIMEOUT)) {
+        throw new RuntimeException(DUnitLauncher.STARTUP_TIMEOUT_MESSAGE);
+      }
+      RemoteDUnitVMIF remote =
+          (RemoteDUnitVMIF) registry.lookup(VM.getVMName(VersionManager.CURRENT_VERSION, pid));
+      return new BounceResult(pid, remote);
+    } catch (RemoteException | NotBoundException e) {
+      throw new RuntimeException("could not lookup name", e);
+    } catch (InterruptedException e) {
+      throw new RuntimeException("Failed waiting for VM", e);
+    }
+  }
+}
diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/MasterRemote.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/MasterRemote.java
new file mode 100644
index 0000000..22b7d32
--- /dev/null
+++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/MasterRemote.java
@@ -0,0 +1,16 @@
+package org.apache.geode.test.dunit.standalone;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+interface MasterRemote extends Remote {
+  int getLocatorPort() throws RemoteException;
+
+  void signalVMReady() throws RemoteException;
+
+  void ping() throws RemoteException;
+
+  BounceResult bounce(int pid) throws RemoteException;
+
+  BounceResult bounce(String version, int pid, boolean force) throws RemoteException;
+}
diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/MethExecutor.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/MethExecutor.java
index 7913739..87a5372 100644
--- a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/MethExecutor.java
+++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/MethExecutor.java
@@ -28,7 +28,7 @@ import org.apache.geode.SystemFailure;
  * TestTasks.
  *
  */
-public class MethExecutor {
+class MethExecutor {
 
   // @todo lises add static args method
 
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 79a3dda..799da96 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
@@ -41,7 +41,7 @@ import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.test.dunit.VM;
 
-public class ProcessManager {
+class ProcessManager {
   private int namingPort;
   private Map<Integer, ProcessHolder> processes = new HashMap<>();
   private File log4jConfig;
@@ -338,38 +338,4 @@ public class ProcessManager {
     waitForVMs(DUnitLauncher.STARTUP_TIMEOUT);
     return (RemoteDUnitVMIF) registry.lookup("vm" + i);
   }
-
-  private static class VersionedVMNumber {
-    String version;
-    int number;
-
-    VersionedVMNumber(String version, int number) {
-      this.version = version;
-      this.number = number;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-      if (this == o) {
-        return true;
-      }
-      if (o == null || getClass() != o.getClass()) {
-        return false;
-      }
-
-      VersionedVMNumber that = (VersionedVMNumber) o;
-
-      if (number != that.number) {
-        return false;
-      }
-      return version.equals(that.version);
-    }
-
-    @Override
-    public int hashCode() {
-      int result = version.hashCode();
-      result = 31 * result + number;
-      return result;
-    }
-  }
 }
diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/RemoteDUnitVM.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/RemoteDUnitVM.java
index 382ea04..80c193b 100644
--- a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/RemoteDUnitVM.java
+++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/RemoteDUnitVM.java
@@ -22,7 +22,7 @@ import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.internal.logging.LogService;
 
-public class RemoteDUnitVM extends UnicastRemoteObject implements RemoteDUnitVMIF {
+class RemoteDUnitVM extends UnicastRemoteObject implements RemoteDUnitVMIF {
   private static final Logger logger = LogService.getLogger();
 
   RemoteDUnitVM() throws RemoteException {
diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/StandAloneDUnitEnv.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/StandAloneDUnitEnv.java
index e8920a5..34d3d95 100644
--- a/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/StandAloneDUnitEnv.java
+++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/standalone/StandAloneDUnitEnv.java
@@ -19,7 +19,6 @@ import java.rmi.RemoteException;
 import java.util.Properties;
 
 import org.apache.geode.test.dunit.DUnitEnv;
-import org.apache.geode.test.dunit.standalone.DUnitLauncher.MasterRemote;
 
 public class StandAloneDUnitEnv extends DUnitEnv {