You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2017/03/09 20:48:40 UTC

[01/50] [abbrv] geode git commit: GEODE-2267: Enhance server/locator startup rules to include workingDir - add missed checkin

Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-1969 4d1ded8df -> 40ff2a132


GEODE-2267: Enhance server/locator startup rules to include workingDir - add missed checkin


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/9766cf23
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/9766cf23
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/9766cf23

Branch: refs/heads/feature/GEODE-1969
Commit: 9766cf2334a8f84c5b90fc29d8e73fd1c49858dc
Parents: a9f0d22
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Thu Mar 2 11:22:12 2017 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Thu Mar 2 11:22:56 2017 -0800

----------------------------------------------------------------------
 .../geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/9766cf23/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
index c4bb152..9cfb5ec 100644
--- a/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
@@ -64,7 +64,7 @@ public class PeerSecurityWithEmbeddedLocatorDUnitTest {
       ServerStarterRule serverStarter = new ServerStarterRule();
       serverStarter.before();
       LocatorServerStartupRule.serverStarter = serverStarter;
-      assertThatThrownBy(() -> serverStarter.startServer(locatorPort))
+      assertThatThrownBy(() -> serverStarter.startServer(server2Props, locatorPort))
           .isInstanceOf(GemFireSecurityException.class)
           .hasMessageContaining("Security check failed. Authentication error");
     });


[24/50] [abbrv] geode git commit: GEODE-1198: refactor test with before/after and cleanup use of ports

Posted by ds...@apache.org.
GEODE-1198: refactor test with before/after and cleanup use of ports


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/5630d4b9
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/5630d4b9
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/5630d4b9

Branch: refs/heads/feature/GEODE-1969
Commit: 5630d4b9c9c54a1c51d81421e63316b3857e0d35
Parents: e94e233
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Mar 7 12:32:36 2017 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Mar 7 14:07:19 2017 -0800

----------------------------------------------------------------------
 .../distributed/DistributedSystemDUnitTest.java | 513 +++++++++----------
 1 file changed, 230 insertions(+), 283 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/5630d4b9/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
index c1ea5e6..dfe4588 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
@@ -14,20 +14,39 @@
  */
 package org.apache.geode.distributed;
 
+import static java.lang.Integer.parseInt;
+import static java.net.NetworkInterface.getNetworkInterfaces;
 import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.internal.DistributionConfig.*;
+import static org.apache.geode.distributed.internal.DistributionManager.*;
 import static org.apache.geode.internal.AvailablePort.*;
-import static org.junit.Assert.*;
+import static org.apache.geode.internal.AvailablePortHelper.*;
+import static org.apache.geode.internal.net.SocketCreator.getLocalHost;
+import static org.apache.geode.test.dunit.DistributedTestUtils.getDUnitLocatorPort;
+import static org.apache.geode.test.dunit.Host.getHost;
+import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
+import static org.assertj.core.api.Assertions.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Enumeration;
+import java.util.Properties;
 
 import org.apache.geode.CancelException;
 import org.apache.geode.GemFireConfigException;
-import org.apache.geode.SystemConnectException;
 import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
-import org.apache.geode.cache30.CacheSerializableRunnable;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.DistributionException;
 import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.SerialDistributionMessage;
@@ -36,41 +55,33 @@ import org.apache.geode.distributed.internal.membership.InternalDistributedMembe
 import org.apache.geode.distributed.internal.membership.gms.MembershipManagerHelper;
 import org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger;
 import org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager;
-import org.apache.geode.internal.AvailablePort;
-import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.internal.net.SocketCreator;
-import org.apache.geode.test.dunit.DistributedTestUtils;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.LogWriterUtils;
-import org.apache.geode.test.dunit.RMIException;
-import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.geode.test.junit.categories.MembershipTest;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.concurrent.TimeoutException;
-
 /**
  * Tests the functionality of the {@link DistributedSystem} class.
  */
 @Category({DistributedTest.class, MembershipTest.class})
 public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
 
+  private int mcastPort;
+  private int locatorPort;
+  private int tcpPort;
+  private int lowerBoundOfPortRange;
+  private int upperBoundOfPortRange;
+
   @Before
   public void before() throws Exception {
     disconnectAllFromDS();
+
+    this.mcastPort = getRandomAvailablePort(MULTICAST);
+    this.locatorPort = getRandomAvailablePort(SOCKET);
+    this.tcpPort = getRandomAvailablePort(SOCKET);
+
+    int[] portRange = getRandomAvailableTCPPortRange(3, true);
+    this.lowerBoundOfPortRange = portRange[0];
+    this.upperBoundOfPortRange = portRange[portRange.length - 1];
   }
 
   @After
@@ -84,75 +95,37 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
    */
   @Test
   public void testWaitForDeparture() throws Exception {
-    disconnectAllFromDS();
-    int locatorPort = AvailablePort.getRandomAvailablePort(SOCKET);
-    Properties p = getDistributedSystemProperties();
-    p.put(LOCATORS, "");
-    p.put(START_LOCATOR, "localhost[" + locatorPort + "]");
-    p.put(DISABLE_TCP, "true");
-    InternalDistributedSystem ds = (InternalDistributedSystem) DistributedSystem.connect(p);
-    try {
-      // construct a member ID that will represent a departed member
-      InternalDistributedMember mbr = new InternalDistributedMember("localhost", 12345, "", "",
-          DistributionManager.NORMAL_DM_TYPE, null, null);
-      final DistributionManager mgr = (DistributionManager) ds.getDistributionManager();
-      // schedule a message in order to create a queue for the fake member
-      final FakeMessage msg = new FakeMessage(null);
-      mgr.getExecutor(DistributionManager.SERIAL_EXECUTOR, mbr).execute(new SizeableRunnable(100) {
-        public void run() {
-          msg.doAction(mgr, false);
-        }
+    Properties config = new Properties();
+    config.put(LOCATORS, "");
+    config.put(START_LOCATOR, "localhost[" + this.locatorPort + "]");
+    config.put(DISABLE_TCP, "true");
 
-        public String toString() {
-          return "Processing fake message";
-        }
-      });
-      try {
-        assertTrue("expected the serial queue to be flushed",
-            mgr.getMembershipManager().waitForDeparture(mbr));
-      } catch (InterruptedException e) {
-        fail("interrupted");
-      } catch (TimeoutException e) {
-        fail("timed out - increase this test's member-timeout setting");
-      }
-    } finally {
-      ds.disconnect();
-    }
-  }
+    InternalDistributedSystem system =
+        (InternalDistributedSystem) DistributedSystem.connect(config);
 
-  private static class FakeMessage extends SerialDistributionMessage {
-    volatile boolean[] blocked;
-    volatile boolean processed;
+    // construct a member ID that will represent a departed member
+    InternalDistributedMember member =
+        new InternalDistributedMember("localhost", 12345, "", "", NORMAL_DM_TYPE, null, null);
 
-    FakeMessage(boolean[] blocked) {
-      this.blocked = blocked;
-    }
+    // schedule a message in order to create a queue for the fake member
+    DistributionManager distributionManager = (DistributionManager) system.getDistributionManager();
+    FakeMessage message = new FakeMessage(null);
 
-    public void doAction(DistributionManager dm, boolean block) {
-      processed = true;
-      if (block) {
-        synchronized (blocked) {
-          blocked[0] = true;
-          blocked.notify();
-          try {
-            blocked.wait(60000);
-          } catch (InterruptedException e) {
-          }
-        }
-      }
-    }
+    distributionManager.getExecutor(SERIAL_EXECUTOR, member).execute(new SizeableRunnable(100) {
 
-    public int getDSFID() {
-      return 0; // never serialized
-    }
+      @Override
+      public void run() { // always throws NullPointerException
+        message.doAction(distributionManager, false);
+      }
 
-    protected void process(DistributionManager dm) {
-      // this is never called
-    }
+      @Override
+      public String toString() {
+        return "Processing fake message";
+      }
+    });
 
-    public String toString() {
-      return "FakeMessage(blocking=" + (blocked != null) + ")";
-    }
+    assertThat(distributionManager.getMembershipManager().waitForDeparture(member))
+        .as("expected the serial queue to be flushed").isTrue();
   }
 
   /**
@@ -160,16 +133,15 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
    */
   @Test
   public void testGetSameSystemTwice() {
-    Properties config = new Properties();
-    config.setProperty(MCAST_PORT, "0");
-    config.setProperty(LOCATORS, "");
+    Properties config = createLonerConfig();
+
     // set a flow-control property for the test (bug 37562)
     config.setProperty(MCAST_FLOW_CONTROL, "3000000,0.20,3000");
 
     DistributedSystem system1 = DistributedSystem.connect(config);
     DistributedSystem system2 = DistributedSystem.connect(config);
-    assertSame(system1, system2);
-    system1.disconnect();
+
+    assertThat(system2).isSameAs(system1);
   }
 
   /**
@@ -178,24 +150,15 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
    */
   @Test
   public void testGetDifferentSystem() {
-    Properties config = new Properties();
-    config.setProperty(MCAST_PORT, "0");
-    config.setProperty(LOCATORS, "");
+    Properties config = createLonerConfig();
     config.setProperty(MCAST_FLOW_CONTROL, "3000000,0.20,3000");
 
+    DistributedSystem.connect(config);
 
-    DistributedSystem system1 = DistributedSystem.connect(config);
     config.setProperty(MCAST_ADDRESS, "224.0.0.1");
-    try {
-      DistributedSystem.connect(config);
-      if (System.getProperty(DistributionConfig.GEMFIRE_PREFIX + "mcast-address") == null) {
-        fail("Should have thrown an IllegalStateException");
-      }
-    } catch (IllegalStateException ex) {
-      // pass...
-    } finally {
-      system1.disconnect();
-    }
+
+    assertThatThrownBy(() -> DistributedSystem.connect(config))
+        .isInstanceOf(IllegalStateException.class);
   }
 
   /**
@@ -203,70 +166,61 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
    */
   @Test
   public void testGetDifferentSystemAfterClose() {
-    Properties config = new Properties();
-    config.setProperty(MCAST_PORT, "0");
-    config.setProperty(LOCATORS, "");
+    Properties config = createLonerConfig();
 
     DistributedSystem system1 = DistributedSystem.connect(config);
     system1.disconnect();
-    int time = DistributionConfig.DEFAULT_ACK_WAIT_THRESHOLD + 17;
+
+    int time = DEFAULT_ACK_WAIT_THRESHOLD + 17;
     config.put(ACK_WAIT_THRESHOLD, String.valueOf(time));
+
     DistributedSystem system2 = DistributedSystem.connect(config);
     system2.disconnect();
   }
 
-
   @Test
   public void testGetProperties() {
-    Properties config = new Properties();
-    // a loner is all this test needs
     int unusedPort = 0;
-    config.setProperty(MCAST_PORT, "0");
-    config.setProperty(LOCATORS, "");
 
-    DistributedSystem system1 = DistributedSystem.connect(config);
+    Properties config = createLonerConfig();
+    DistributedSystem system = DistributedSystem.connect(config);
 
-    assertTrue(config != system1.getProperties());
-    assertEquals(unusedPort, Integer.parseInt(system1.getProperties().getProperty(MCAST_PORT)));
+    assertThat(system.getProperties()).isNotSameAs(config);
+    assertThat(parseInt(system.getProperties().getProperty(MCAST_PORT))).isEqualTo(unusedPort);
 
-    system1.disconnect();
+    system.disconnect();
 
-    assertTrue(config != system1.getProperties());
-    assertEquals(unusedPort, Integer.parseInt(system1.getProperties().getProperty(MCAST_PORT)));
+    assertThat(system.getProperties()).isNotSameAs(config);
+    assertThat(parseInt(system.getProperties().getProperty(MCAST_PORT))).isEqualTo(unusedPort);
   }
 
-
   @Test
   public void testIsolatedDistributedSystem() throws Exception {
-    Properties config = new Properties();
-    config.setProperty(MCAST_PORT, "0");
-    config.setProperty(LOCATORS, "");
-    getSystem(config);
-    try {
-      // make sure isolated distributed system can still create a cache and region
-      Cache cache = CacheFactory.create(getSystem());
-      Region r = cache.createRegion(getUniqueName(), new AttributesFactory().create());
-      r.put("test", "value");
-      assertEquals("value", r.get("test"));
-    } finally {
-      getSystem().disconnect();
-    }
-  }
+    Properties config = createLonerConfig();
+    InternalDistributedSystem system = getSystem(config);
 
+    // make sure isolated distributed system can still create a cache and region
+    Cache cache = CacheFactory.create(system);
+    Region region = cache.createRegion(getUniqueName(), new AttributesFactory().create());
+    region.put("test", "value");
 
-  /** test the ability to set the port used to listen for tcp/ip connections */
+    assertThat(region.get("test")).isEqualTo("value");
+  }
+
+  /**
+   * test the ability to set the port used to listen for tcp/ip connections
+   */
   @Test
   public void testSpecificTcpPort() throws Exception {
     Properties config = new Properties();
-    int tcpPort = AvailablePort.getRandomAvailablePort(SOCKET);
-    config.put(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
-    config.setProperty(TCP_PORT, String.valueOf(tcpPort));
+    config.put(LOCATORS, "localhost[" + getDUnitLocatorPort() + "]");
+    config.setProperty(TCP_PORT, String.valueOf(this.tcpPort));
+
     InternalDistributedSystem system = getSystem(config);
+
     DistributionManager dm = (DistributionManager) system.getDistributionManager();
     GMSMembershipManager mgr = (GMSMembershipManager) dm.getMembershipManager();
-    int actualPort = mgr.getDirectChannelPort();
-    system.disconnect();
-    assertEquals(tcpPort, actualPort);
+    assertThat(mgr.getDirectChannelPort()).isEqualTo(this.tcpPort);
   }
 
   /**
@@ -275,186 +229,179 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
    */
   @Test
   public void testLoopbackNotAllowed() throws Exception {
-    // DISABLED for bug #49926
-    InetAddress loopback = null;
-    for (Enumeration<NetworkInterface> it = NetworkInterface.getNetworkInterfaces(); it
-        .hasMoreElements();) {
-      NetworkInterface nif = it.nextElement();
-      for (Enumeration<InetAddress> ait = nif.getInetAddresses(); ait.hasMoreElements();) {
-        InetAddress a = ait.nextElement();
-        Class theClass = SocketCreator.getLocalHost() instanceof Inet4Address ? Inet4Address.class
-            : Inet6Address.class;
-        if (a.isLoopbackAddress() && (a.getClass().isAssignableFrom(theClass))) {
-          loopback = a;
-          break;
-        }
-      }
-    }
-    if (loopback != null) {
-      Properties config = new Properties();
-      config.put(MCAST_PORT, "0");
-      String locators = InetAddress.getLocalHost().getHostName() + "["
-          + DistributedTestUtils.getDUnitLocatorPort() + "]";
-      config.put(LOCATORS, locators);
-      config.setProperty(BIND_ADDRESS, loopback.getHostAddress());
-      LogWriterUtils.getLogWriter()
-          .info("attempting to connect with " + loopback + " and locators=" + locators);
-      try {
-        InternalDistributedSystem system = getSystem(config);
-        system.disconnect();
-        fail("expected a configuration exception disallowing use of loopback address");
-      } catch (GemFireConfigException e) {
-        // expected
-      } catch (DistributionException e) {
-        // expected
-      }
-    }
+    // assert or assume that loopback is not null
+    InetAddress loopback = getLoopback();
+    assertThat(loopback).isNotNull();
+
+    String locators = getLocalHost().getHostName() + "[" + getDUnitLocatorPort() + "]";
+
+    Properties config = new Properties();
+    config.put(LOCATORS, locators);
+    config.setProperty(BIND_ADDRESS, loopback.getHostAddress());
+
+    getLogWriter().info("attempting to connect with " + loopback + " and locators=" + locators);
+
+    assertThatThrownBy(() -> getSystem(config)).isInstanceOf(GemFireConfigException.class);
   }
 
   @Test
   public void testUDPPortRange() throws Exception {
-    int[] unicastPort = AvailablePortHelper.getRandomAvailableTCPPortRange(3, true);
-
     Properties config = new Properties();
-    config.put(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
-    // Minimum 3 ports required in range for UDP, FD_SOCK and TcpConduit.
-    config.setProperty(MEMBERSHIP_PORT_RANGE, unicastPort[0] + "-" + unicastPort[2]);
+    config.put(LOCATORS, "localhost[" + getDUnitLocatorPort() + "]");
+    config.setProperty(MEMBERSHIP_PORT_RANGE,
+        this.lowerBoundOfPortRange + "-" + this.upperBoundOfPortRange);
 
     InternalDistributedSystem system = getSystem(config);
     DistributionManager dm = (DistributionManager) system.getDistributionManager();
-    InternalDistributedMember idm = dm.getDistributionManagerId();
-
-    assertTrue(unicastPort[0] <= idm.getPort() && idm.getPort() <= unicastPort[2]);
-    assertTrue(unicastPort[0] <= idm.getPort() && idm.getDirectChannelPort() <= unicastPort[2]);
+    InternalDistributedMember member = dm.getDistributionManagerId();
 
-    system.disconnect();
-  }
-
-  /***
-   * this will return starting port, from it "range" of port will available
-   * 
-   * @param range
-   * @return
-   */
-  private int getPortRange(int range) {
-    int port = DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[0] + 10000;
-    int startPort = port;
-    int found = 0;
-    while (port <= DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1]) {
-      if (AvailablePort.isPortAvailable(port, SOCKET)) {
-        found++;
-        if (found == range) {
-          break;
-        }
-        port++;
-      } else {
-        port++;
-        startPort = port;
-        found = 0;
-      }
-    }
-    if (port > DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1]) {
-      fail("Unable to find port range " + range);
-    }
-    return startPort;
+    verifyMembershipPortsInRange(member, this.lowerBoundOfPortRange, this.upperBoundOfPortRange);
   }
 
   @Test
   public void testMembershipPortRangeWithExactThreeValues() throws Exception {
     Properties config = new Properties();
-    config.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
-    int portRange = 3;
-    int portStartRange = getPortRange(portRange);
-    int portEndRange = portStartRange + portRange - 1;
-    config.setProperty(MEMBERSHIP_PORT_RANGE, "" + (portStartRange) + "-" + (portEndRange));
+    config.setProperty(LOCATORS, "localhost[" + getDUnitLocatorPort() + "]");
+    config.setProperty(MEMBERSHIP_PORT_RANGE,
+        this.lowerBoundOfPortRange + "-" + this.upperBoundOfPortRange);
+
     InternalDistributedSystem system = getSystem(config);
     Cache cache = CacheFactory.create(system);
     cache.addCacheServer();
+
     DistributionManager dm = (DistributionManager) system.getDistributionManager();
-    InternalDistributedMember idm = dm.getDistributionManagerId();
-    GMSMembershipManager manager =
+    InternalDistributedMember member = dm.getDistributionManagerId();
+    GMSMembershipManager gms =
         (GMSMembershipManager) MembershipManagerHelper.getMembershipManager(system);
-    JGroupsMessenger messenger = (JGroupsMessenger) manager.getServices().getMessenger();
+    JGroupsMessenger messenger = (JGroupsMessenger) gms.getServices().getMessenger();
     String jgConfig = messenger.getJGroupsStackConfig();
-    system.disconnect();
-    assertTrue("expected to find port_range=\"2\" in " + jgConfig,
-        jgConfig.contains("port_range=\"2\""));
-    assertTrue(idm.getPort() <= portEndRange);
-    assertTrue(idm.getPort() >= portStartRange);
-    assertTrue(idm.getDirectChannelPort() <= portEndRange);
-    assertTrue(idm.getDirectChannelPort() >= portStartRange);
+
+    assertThat(jgConfig).as("expected to find port_range=\"2\" in " + jgConfig)
+        .contains("port_range=\"2\"");
+
+    verifyMembershipPortsInRange(member, this.lowerBoundOfPortRange, this.upperBoundOfPortRange);
   }
 
-  @Category(FlakyTest.class) // GEODE-1198
   @Test
   public void testConflictingUDPPort() throws Exception {
-    final Properties config = new Properties();
-    final int mcastPort = AvailablePort.getRandomAvailablePort(AvailablePort.MULTICAST);
-    final int[] socketPorts = AvailablePortHelper.getRandomAvailableTCPPorts(1, true);
-    final int unicastPort = getPortRange(3);
-    config.setProperty(MCAST_PORT, String.valueOf(mcastPort));
-    config.setProperty(START_LOCATOR, "localhost[" + socketPorts[0] + "]");
-    config.setProperty(MEMBERSHIP_PORT_RANGE, "" + unicastPort + "-" + (unicastPort + 2));
-    InternalDistributedSystem system =
-        (InternalDistributedSystem) DistributedSystem.connect(config);
-    try {
-      DistributionManager dm = (DistributionManager) system.getDistributionManager();
-      InternalDistributedMember idm = dm.getDistributionManagerId();
-      VM vm = Host.getHost(0).getVM(1);
-      vm.invoke(new CacheSerializableRunnable("start conflicting system") {
-        public void run2() {
-          try {
-            String locators = (String) config.remove(START_LOCATOR);
-            config.put(LOCATORS, locators);
-            DistributedSystem system = DistributedSystem.connect(config);
-            system.disconnect();
-          } catch (GemFireConfigException e) {
-            return; //
-          } catch (RMIException e) {
-            if (e.getCause() instanceof SystemConnectException) {
-              // GEODE-1198: for this test, the membership-port-range has only 3 ports available.
-              // If in some rare cases, one of the ports is used by others, it will get this
-              // exception. So just ignore it. Since adding one more port will also fail the test.
-              return;
-            }
-          }
-          fail("expected a GemFireConfigException but didn't get one");
-        }
-      });
-    } finally {
-      system.disconnect();
-    }
+    Properties config = new Properties();
+    config.setProperty(MCAST_PORT, String.valueOf(this.mcastPort));
+    config.setProperty(START_LOCATOR, "localhost[" + this.locatorPort + "]");
+    config.setProperty(MEMBERSHIP_PORT_RANGE,
+        this.lowerBoundOfPortRange + "-" + this.upperBoundOfPortRange);
+
+    DistributedSystem.connect(config);
+
+    getHost(0).getVM(1).invoke(() -> {
+      String locators = (String) config.remove(START_LOCATOR);
+
+      config.put(LOCATORS, locators);
+
+      assertThatThrownBy(() -> DistributedSystem.connect(config))
+          .isInstanceOf(GemFireConfigException.class);
+    });
   }
 
   /**
    * Tests that configuring a distributed system with a cache-xml-file of "" does not initialize a
-   * cache. See bug 32254.
+   * cache.
+   *
+   * Verifies: "Allow the cache-xml-file specification to be an empty string"
    *
    * @since GemFire 4.0
    */
   @Test
   public void testEmptyCacheXmlFile() throws Exception {
+    Properties config = createLonerConfig();
+    config.setProperty(CACHE_XML_FILE, "");
+
+    DistributedSystem system = DistributedSystem.connect(config);
+
+    assertThatThrownBy(() -> CacheFactory.getInstance(system)).isInstanceOf(CancelException.class);
+
+    // now make sure we can create the cache
+    Cache cache = CacheFactory.create(system);
+
+    assertThat(cache).isNotNull();
+    assertThat(cache.isClosed()).isFalse();
+  }
+
+  private Properties createLonerConfig() {
     Properties config = new Properties();
     config.setProperty(MCAST_PORT, "0");
     config.setProperty(LOCATORS, "");
-    config.setProperty(CACHE_XML_FILE, "");
+    return config;
+  }
 
-    DistributedSystem sys = DistributedSystem.connect(config);
+  private void verifyMembershipPortsInRange(final InternalDistributedMember member,
+      final int lowerBound, final int upperBound) {
+    assertThat(member.getPort()).isGreaterThanOrEqualTo(lowerBound);
+    assertThat(member.getPort()).isLessThanOrEqualTo(upperBound);
+    assertThat(member.getDirectChannelPort()).isGreaterThanOrEqualTo(lowerBound);
+    assertThat(member.getDirectChannelPort()).isLessThanOrEqualTo(upperBound);
+  }
 
-    try {
-      try {
-        CacheFactory.getInstance(sys);
-        fail("Should have thrown a CancelException");
-      } catch (CancelException expected) {
-      }
-      // now make sure we can create the cache
-      CacheFactory.create(sys);
+  private InetAddress getLoopback() throws SocketException, UnknownHostException {
+    for (Enumeration<NetworkInterface> networkInterfaceEnumeration =
+        getNetworkInterfaces(); networkInterfaceEnumeration.hasMoreElements();) {
+
+      NetworkInterface networkInterface = networkInterfaceEnumeration.nextElement();
 
-    } finally {
-      sys.disconnect();
+      for (Enumeration<InetAddress> addressEnum = networkInterface.getInetAddresses(); addressEnum
+          .hasMoreElements();) {
+
+        InetAddress address = addressEnum.nextElement();
+        Class theClass =
+            getLocalHost() instanceof Inet4Address ? Inet4Address.class : Inet6Address.class;
+
+        if (address.isLoopbackAddress() && address.getClass().isAssignableFrom(theClass)) {
+          return address;
+        }
+      }
     }
+    return null;
   }
 
+  /**
+   * What is the point of this FakeMessage? Member variables are unused and doAction actually throws
+   * NullPointerException.
+   */
+  private static class FakeMessage extends SerialDistributionMessage {
+    private volatile boolean[] blocked; // always null
+    private volatile boolean processed; // unused
+
+    FakeMessage(boolean[] blocked) { // null is always passed in
+      this.blocked = blocked;
+    }
+
+    public void doAction(DistributionManager dm, boolean block) {
+      this.processed = true;
+      if (block) {
+        synchronized (this.blocked) { // throws NullPointerException here
+          this.blocked[0] = true;
+          this.blocked.notify();
+          try {
+            this.blocked.wait(60000);
+          } catch (InterruptedException e) {
+          }
+        }
+      }
+    }
 
+    @Override
+    public int getDSFID() {
+      return 0; // never serialized
+    }
+
+    @Override
+    protected void process(DistributionManager dm) {
+      // this is never called
+    }
+
+    @Override
+    public String toString() {
+      return "FakeMessage(blocking=" + (this.blocked != null) + ")";
+    }
+  }
 
 }


[31/50] [abbrv] geode git commit: GEODE-2614: fix javadoc warnings - spotless

Posted by ds...@apache.org.
GEODE-2614: fix javadoc warnings - spotless


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/cb8f0c40
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/cb8f0c40
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/cb8f0c40

Branch: refs/heads/feature/GEODE-1969
Commit: cb8f0c40e4b15c22cf0ebaa584efc8e9aa6f7fc2
Parents: 9ad65d6
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Wed Mar 8 10:28:39 2017 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Wed Mar 8 10:28:39 2017 -0800

----------------------------------------------------------------------
 .../apache/geode/management/internal/cli/CliAroundInterceptor.java  | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/cb8f0c40/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
index f552460..7a95306 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
@@ -38,6 +38,7 @@ public interface CliAroundInterceptor {
 
   /**
    * called by the OperationInvoker after the command is executed
+   * 
    * @param tempFile if the command's isFileDownloadOverHttp is true, the is the File downloaded
    *        after the http response is processed.
    */


[30/50] [abbrv] geode git commit: GEODE-2614: fix javadoc warnings

Posted by ds...@apache.org.
GEODE-2614: fix javadoc warnings


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/9ad65d6a
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/9ad65d6a
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/9ad65d6a

Branch: refs/heads/feature/GEODE-1969
Commit: 9ad65d6a33c1aa0d27fb16039d065f477c47f121
Parents: 7a16a7f
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Wed Mar 8 09:50:06 2017 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Wed Mar 8 09:50:06 2017 -0800

----------------------------------------------------------------------
 .../geode/management/internal/cli/CliAroundInterceptor.java    | 3 +--
 .../apache/geode/management/internal/cli/util/LogExporter.java | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/9ad65d6a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
index 99114f0..f552460 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
@@ -38,8 +38,7 @@ public interface CliAroundInterceptor {
 
   /**
    * called by the OperationInvoker after the command is executed
-   * 
-   * @param tempFile: if the command's isFileDownloadOverHttp is true, the is the File downloaded
+   * @param tempFile if the command's isFileDownloadOverHttp is true, the is the File downloaded
    *        after the http response is processed.
    */
   default Result postExecution(GfshParseResult parseResult, Result commandResult, Path tempFile) {

http://git-wip-us.apache.org/repos/asf/geode/blob/9ad65d6a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
index a4bef75..a0be7fb 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
@@ -48,9 +48,9 @@ public class LogExporter {
   private final File baseStatsFile;
 
   /**
-   * @param logFilter: the filter that's used to check if we need to accept the file or the logLine
-   * @param baseLogFile: if not null, we will export the logs in that directory
-   * @param baseStatsFile: if not null, we will export stats in that directory
+   * @param logFilter the filter that's used to check if we need to accept the file or the logLine
+   * @param baseLogFile if not null, we will export the logs in that directory
+   * @param baseStatsFile if not null, we will export stats in that directory
    * @throws ParseException
    */
   public LogExporter(LogFilter logFilter, File baseLogFile, File baseStatsFile)


[10/50] [abbrv] geode git commit: GEODE-2416: Collect together artifacts from individual servers into a single zip file

Posted by ds...@apache.org.
GEODE-2416: Collect together artifacts from individual servers into a single zip file

 - GEODE-2414: Determine a mechanism to stream a zip file from server to locator
 - GEODE-2415: Write a function to return a zip file for a single server


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/4c6f3695
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/4c6f3695
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/4c6f3695

Branch: refs/heads/feature/GEODE-1969
Commit: 4c6f3695db9ca69f5c1952128eda91ea5dfe3ede
Parents: e5121ab
Author: Jared Stewart <js...@pivotal.io>
Authored: Sun Feb 12 11:30:58 2017 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Fri Mar 3 16:03:49 2017 -0800

----------------------------------------------------------------------
 .../geode/management/internal/cli/CliUtil.java  |  29 +-
 .../cli/commands/MiscellaneousCommands.java     | 368 ++++---------------
 .../cli/functions/ExportLogsFunction.java       | 203 ++++++++++
 .../cli/util/ExportLogsCacheWriter.java         |  78 ++++
 .../internal/cli/util/ExportLogsRepository.java |  39 ++
 .../internal/cli/util/LogExporter.java          | 136 +++++++
 .../management/internal/cli/util/LogFilter.java | 113 ++++++
 .../internal/cli/util/LogLevelExtractor.java    |  65 ++++
 .../management/internal/cli/util/MergeLogs.java |  89 ++++-
 .../internal/configuration/utils/ZipUtils.java  |   8 +-
 .../internal/cli/commands/ExportLogsDUnit.java  | 363 ++++++++++++++++++
 ...laneousCommandsExportLogsPart1DUnitTest.java | 138 -------
 ...laneousCommandsExportLogsPart2DUnitTest.java | 141 -------
 ...laneousCommandsExportLogsPart3DUnitTest.java | 156 --------
 ...laneousCommandsExportLogsPart4DUnitTest.java | 138 -------
 .../ExportLogsFunctionIntegrationTest.java      | 143 +++++++
 .../internal/cli/util/LogExporterTest.java      | 104 ++++++
 .../internal/cli/util/LogFilterTest.java        | 126 +++++++
 .../cli/util/LogLevelExtractorTest.java         |  61 +++
 .../internal/cli/util/MergeLogsTest.java        | 114 ++++++
 .../configuration/EventTestCacheWriter.java     |  36 ++
 .../configuration/ZipUtilsJUnitTest.java        |  16 +
 .../dunit/rules/GfshShellConnectionRule.java    |   4 +
 .../test/dunit/rules/LocatorStarterRule.java    |   1 +
 .../apache/geode/test/dunit/rules/Member.java   |   2 +-
 .../cli/commands/CommandOverHttpDUnitTest.java  |   6 +-
 26 files changed, 1772 insertions(+), 905 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
index 8cd098d..87a07a6 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
@@ -301,7 +301,27 @@ public class CliUtil {
     return matchingMembers;
   }
 
+  /**
+   * Finds all Members (including both servers and locators) which belong to the given arrays of groups or members.
+   */
+  public static Set<DistributedMember> findMembersIncludingLocators(String[] groups, String[] members) {
+    Cache cache = CacheFactory.getAnyInstance();
+    Set<DistributedMember> allMembers = getAllMembers(cache);
+
+    return findMembers(allMembers, groups, members);
+  }
+
+  /**
+   * Finds all Servers which belong to the given arrays of groups or members.  Does not include locators.
+   */
   public static Set<DistributedMember> findMembers(String[] groups, String[] members) {
+    Cache cache = CacheFactory.getAnyInstance();
+    Set<DistributedMember> allNormalMembers = getAllNormalMembers(cache);
+
+    return findMembers(allNormalMembers, groups, members);
+  }
+
+  private static Set<DistributedMember> findMembers(Set<DistributedMember> membersToConsider, String[] groups, String[] members) {
     if (groups == null) {
       groups = new String[] {};
     }
@@ -310,21 +330,18 @@ public class CliUtil {
       members = new String[] {};
     }
 
-    Cache cache = CacheFactory.getAnyInstance();
-
     if ((members.length > 0) && (groups.length > 0)) {
       throw new IllegalArgumentException(CliStrings.PROVIDE_EITHER_MEMBER_OR_GROUP_MESSAGE);
     }
 
-    Set<DistributedMember> allNormalMembers = getAllNormalMembers(cache);
     if (members.length == 0 && groups.length == 0) {
-      return allNormalMembers;
+      return membersToConsider;
     }
 
     Set<DistributedMember> matchingMembers = new HashSet<DistributedMember>();
     // it will either go into this loop or the following loop, not both.
     for (String memberNameOrId : members) {
-      for (DistributedMember member : allNormalMembers) {
+      for (DistributedMember member : membersToConsider) {
         if (memberNameOrId.equalsIgnoreCase(member.getId())
             || memberNameOrId.equals(member.getName())) {
           matchingMembers.add(member);
@@ -333,7 +350,7 @@ public class CliUtil {
     }
 
     for (String group : groups) {
-      for (DistributedMember member : allNormalMembers) {
+      for (DistributedMember member : membersToConsider) {
         if (member.getGroups().contains(group)) {
           matchingMembers.add(member);
         }

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
index bbf0542..e720d09 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
@@ -24,10 +24,10 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.PrintWriter;
-import java.sql.Time;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.text.MessageFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -38,7 +38,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-import java.util.StringTokenizer;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
@@ -50,9 +49,11 @@ import java.util.zip.DataFormatException;
 import java.util.zip.GZIPInputStream;
 import javax.management.ObjectName;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.geode.LogWriter;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionException;
@@ -65,8 +66,7 @@ import org.apache.geode.distributed.internal.deadlock.Dependency;
 import org.apache.geode.distributed.internal.deadlock.DependencyGraph;
 import org.apache.geode.distributed.internal.deadlock.GemFireDeadlockDetector;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.logging.InternalLogWriter;
+import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.logging.LogWriterImpl;
 import org.apache.geode.management.CacheServerMXBean;
 import org.apache.geode.management.DistributedRegionMXBean;
@@ -89,9 +89,9 @@ import org.apache.geode.management.internal.cli.GfshParser;
 import org.apache.geode.management.internal.cli.LogWrapper;
 import org.apache.geode.management.internal.cli.domain.StackTracesPerMember;
 import org.apache.geode.management.internal.cli.functions.ChangeLogLevelFunction;
+import org.apache.geode.management.internal.cli.functions.ExportLogsFunction;
 import org.apache.geode.management.internal.cli.functions.GarbageCollectionFunction;
 import org.apache.geode.management.internal.cli.functions.GetStackTracesFunction;
-import org.apache.geode.management.internal.cli.functions.LogFileFunction;
 import org.apache.geode.management.internal.cli.functions.NetstatFunction;
 import org.apache.geode.management.internal.cli.functions.NetstatFunction.NetstatFunctionArgument;
 import org.apache.geode.management.internal.cli.functions.NetstatFunction.NetstatFunctionResult;
@@ -109,17 +109,19 @@ import org.apache.geode.management.internal.cli.result.ResultDataException;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.cli.util.MergeLogs;
+import org.apache.geode.management.internal.cli.util.ExportLogsCacheWriter;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
 
+import org.apache.logging.log4j.Logger;
 import org.springframework.shell.core.CommandMarker;
 import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
 /**
- *
  * @since GemFire 7.0
  */
 public class MiscellaneousCommands implements CommandMarker {
@@ -145,8 +147,6 @@ public class MiscellaneousCommands implements CommandMarker {
 
       logger.info("Gfsh executing shutdown on members " + includeMembers);
 
-
-
       Callable<String> shutdownNodes = new Callable<String>() {
 
         @Override
@@ -210,8 +210,6 @@ public class MiscellaneousCommands implements CommandMarker {
 
       locators.removeAll(dataNodes);
 
-
-
       if (!shutdownLocators && numDataNodes == 0) {
         return ResultBuilder.createInfoResult(CliStrings.SHUTDOWN__MSG__NO_DATA_NODE_FOUND);
       }
@@ -248,8 +246,8 @@ public class MiscellaneousCommands implements CommandMarker {
       }
 
       if (locators.contains(manager) && !shutdownLocators) { // This means manager is a locator and
-                                                             // shutdownLocators is false. Hence we
-                                                             // should not stop the manager
+        // shutdownLocators is false. Hence we
+        // should not stop the manager
         return ResultBuilder.createInfoResult("Shutdown is triggered");
       }
       // now shut down this manager
@@ -272,12 +270,9 @@ public class MiscellaneousCommands implements CommandMarker {
   }
 
   /**
-   * 
    * @param timeout user specified timeout
    * @param nodesToBeStopped list of nodes to be stopped
    * @return Elapsed time to shutdown the given nodes;
-   * @throws ExecutionException
-   * @throws InterruptedException
    */
   private long shutDownNodeWithTimeOut(long timeout, Set<DistributedMember> nodesToBeStopped)
       throws TimeoutException, InterruptedException, ExecutionException {
@@ -290,9 +285,9 @@ public class MiscellaneousCommands implements CommandMarker {
     long timeElapsed = shutDownTimeEnd - shutDownTimeStart;
 
     if (timeElapsed > timeout || Boolean.getBoolean("ThrowTimeoutException")) { // The second check
-                                                                                // for
-                                                                                // ThrowTimeoutException
-                                                                                // is a test hook
+      // for
+      // ThrowTimeoutException
+      // is a test hook
       throw new TimeoutException();
     }
     return timeElapsed;
@@ -532,7 +527,7 @@ public class MiscellaneousCommands implements CommandMarker {
         }
         resultData.addAsFile(saveToFile, resultInfo.toString(),
             CliStrings.NETSTAT__MSG__SAVED_OUTPUT_IN_0, false); // Note: substitution for {0} will
-                                                                // happen on client side.
+        // happen on client side.
       } else {
         resultData.addLine(resultInfo.toString());
       }
@@ -694,87 +689,6 @@ public class MiscellaneousCommands implements CommandMarker {
     return result;
   }
 
-  Result exportLogsPreprocessing(String dirName, String[] groups, String memberId, String logLevel,
-      boolean onlyLogLevel, boolean mergeLog, String start, String end,
-      int numOfLogFilesForTesting) {
-    Result result = null;
-    try {
-      LogWrapper.getInstance().fine("Exporting logs");
-      Cache cache = CacheFactory.getAnyInstance();
-      Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
-      Time startTime = null, endTime = null;
-
-      if (logLevel == null || logLevel.length() == 0) {
-        // set default log level
-        logLevel = LogWriterImpl.levelToString(InternalLogWriter.INFO_LEVEL);
-      }
-      if (start != null && end == null) {
-        startTime = parseDate(start);
-        endTime = new Time(System.currentTimeMillis());
-      }
-
-      if (end != null && start == null) {
-        endTime = parseDate(end);
-        startTime = new Time(0);
-      }
-      if (start != null && end != null) {
-        startTime = parseDate(start);
-        endTime = parseDate(end);
-        if (endTime.getTime() - startTime.getTime() <= 0) {
-          result =
-              ResultBuilder.createUserErrorResult(CliStrings.EXPORT_LOGS__MSG__INVALID_TIMERANGE);
-        }
-      }
-      if (end == null && start == null) {
-        // set default time range as 1 day.
-        endTime = new Time(System.currentTimeMillis());
-        startTime = new Time(endTime.getTime() - 24 * 60 * 60 * 1000);
-      }
-      LogWrapper.getInstance().fine(
-          "Exporting logs startTime=" + startTime.toGMTString() + " " + startTime.toLocaleString());
-      LogWrapper.getInstance()
-          .fine("Exporting logs endTime=" + endTime.toGMTString() + " " + endTime.toLocaleString());
-      if (groups != null && memberId != null) {
-        result =
-            ResultBuilder.createUserErrorResult(CliStrings.EXPORT_LOGS__MSG__SPECIFY_ONE_OF_OPTION);
-      } else if (groups != null && groups.length > 0) {
-        for (String group : groups) {
-          Set<DistributedMember> groupMembers = cache.getDistributedSystem().getGroupMembers(group);
-          if (groupMembers != null && groupMembers.size() > 0) {
-            dsMembers.addAll(groupMembers);
-          }
-        }
-        if (dsMembers.size() == 0) {
-          result = ResultBuilder
-              .createUserErrorResult(CliStrings.EXPORT_LOGS__MSG__NO_GROUPMEMBER_FOUND);
-        }
-        result = export(cache, dsMembers, dirName, logLevel, onlyLogLevel ? "true" : "false",
-            mergeLog, startTime, endTime, numOfLogFilesForTesting);
-      } else if (memberId != null) {
-        DistributedMember member = CliUtil.getDistributedMemberByNameOrId(memberId);
-        if (member == null) {
-          result = ResultBuilder.createUserErrorResult(
-              CliStrings.format(CliStrings.EXPORT_LOGS__MSG__INVALID_MEMBERID, memberId));
-        }
-        dsMembers.add(member);
-        result = export(cache, dsMembers, dirName, logLevel, onlyLogLevel ? "true" : "false",
-            mergeLog, startTime, endTime, numOfLogFilesForTesting);
-      } else {
-        // run in entire DS members and get all including locators
-        dsMembers.addAll(CliUtil.getAllMembers(cache));
-        result = export(cache, dsMembers, dirName, logLevel, onlyLogLevel ? "true" : "false",
-            mergeLog, startTime, endTime, numOfLogFilesForTesting);
-      }
-    } catch (ParseException ex) {
-      LogWrapper.getInstance().fine(ex.getMessage());
-      result = ResultBuilder.createUserErrorResult(ex.getMessage());
-    } catch (Exception ex) {
-      LogWrapper.getInstance().fine(ex.getMessage());
-      result = ResultBuilder.createUserErrorResult(ex.getMessage());
-    }
-    return result;
-  }
-
   @CliCommand(value = CliStrings.EXPORT_LOGS, help = CliStrings.EXPORT_LOGS__HELP)
   @CliMetaData(shellOnly = false,
       relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_DEBUG_UTIL})
@@ -789,7 +703,7 @@ public class MiscellaneousCommands implements CommandMarker {
       @CliOption(key = CliStrings.EXPORT_LOGS__MEMBER,
           unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.ALL_MEMBER_IDNAME,
-          help = CliStrings.EXPORT_LOGS__MEMBER__HELP) String memberId,
+          help = CliStrings.EXPORT_LOGS__MEMBER__HELP) String[] memberIds,
       @CliOption(key = CliStrings.EXPORT_LOGS__LOGLEVEL,
           unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.LOG_LEVEL,
@@ -805,207 +719,63 @@ public class MiscellaneousCommands implements CommandMarker {
           unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.EXPORT_LOGS__ENDTIME__HELP) String end) {
     Result result = null;
-    try {
-      result = exportLogsPreprocessing(dirName, groups, memberId, logLevel, onlyLogLevel, mergeLog,
-          start, end, 0);
-    } catch (Exception ex) {
-      LogWrapper.getInstance().fine(ex.getMessage());
-      result = ResultBuilder.createUserErrorResult(ex.getMessage());
-    }
-    LogWrapper.getInstance().fine("Exporting logs returning =" + result);
-    return result;
-  }
+    Logger logger = LogService.getLogger();
 
-  Time parseDate(String dateString) throws ParseException {
-    Time time = null;
     try {
-      SimpleDateFormat df = new SimpleDateFormat(MiscellaneousCommands.FORMAT);
-      time = new Time(df.parse(dateString).getTime());
-    } catch (Exception e) {
-      SimpleDateFormat df = new SimpleDateFormat(MiscellaneousCommands.ONLY_DATE_FORMAT);
-      time = new Time(df.parse(dateString).getTime());
-    }
-    return time;
-  }
+      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
 
-  Result export(Cache cache, Set<DistributedMember> dsMembers, String dirName, String logLevel,
-      String onlyLogLevel, boolean mergeLog, Time startTime, Time endTime,
-      int numOfLogFilesForTesting) {
-    LogWrapper.getInstance()
-        .fine("Exporting logs in export membersize = " + dsMembers.size() + " dirname=" + dirName
-            + " logLevel=" + logLevel + " onlyLogLevel=" + onlyLogLevel + " mergeLog=" + mergeLog
-            + " startTime=" + startTime.toGMTString() + "endTime=" + endTime.toGMTString());
-    Function function = new LogFileFunction();
-    FunctionService.registerFunction(function);
-    try {
-      List<?> resultList = null;
+      Set<DistributedMember> targetMembers = CliUtil.findMembersIncludingLocators(groups, memberIds);
 
-      List<String> logsToMerge = new ArrayList<String>();
-
-      Iterator<DistributedMember> it = dsMembers.iterator();
-      Object[] args = new Object[6];
-      args[0] = dirName;
-      args[1] = logLevel;
-      args[2] = onlyLogLevel;
-      args[3] = startTime.getTime();
-      args[4] = endTime.getTime();
-      args[5] = numOfLogFilesForTesting;
-
-      while (it.hasNext()) {
-        boolean toContinueForRestOfmembers = false;
-        DistributedMember member = it.next();
-        LogWrapper.getInstance().fine("Exporting logs copy the logs for member=" + member.getId());
-        try {
-          resultList = (ArrayList<?>) CliUtil.executeFunction(function, args, member).getResult();
-        } catch (Exception ex) {
-          LogWrapper.getInstance()
-              .fine(CliStrings.format(
-                  CliStrings.EXPORT_LOGS__MSG__FAILED_TO_EXPORT_LOG_FILES_FOR_MEMBER_0,
-                  member.getId()), ex);
-          // try for other members
-          continue;
-        }
 
-        if (resultList != null && !resultList.isEmpty()) {
-          for (int i = 0; i < resultList.size(); i++) {
-            Object object = resultList.get(i);
-            if (object instanceof Exception) {
-              ResultBuilder.createGemFireErrorResult(CliStrings.format(
-                  CliStrings.EXPORT_LOGS__MSG__FAILED_TO_EXPORT_LOG_FILES_FOR_MEMBER_0,
-                  member.getId()));
-              LogWrapper.getInstance().fine("Exporting logs for member=" + member.getId()
-                  + " exception=" + ((Throwable) object).getMessage(), ((Throwable) object));
-              toContinueForRestOfmembers = true;
-              break;
-            } else if (object instanceof Throwable) {
-              ResultBuilder.createGemFireErrorResult(CliStrings.format(
-                  CliStrings.EXPORT_LOGS__MSG__FAILED_TO_EXPORT_LOG_FILES_FOR_MEMBER_0,
-                  member.getId()));
-
-              Throwable th = (Throwable) object;
-              LogWrapper.getInstance().fine(CliUtil.stackTraceAsString((th)));
-              LogWrapper.getInstance().fine("Exporting logs for member=" + member.getId()
-                  + " exception=" + ((Throwable) object).getMessage(), ((Throwable) object));
-              toContinueForRestOfmembers = true;
-              break;
-            }
-          }
-        } else {
-          LogWrapper.getInstance().fine("Exporting logs for member=" + member.getId()
-              + " resultList is either null or empty");
-          continue;
-        }
+      Map<String, Path> zipFilesFromMembers = new HashMap<>();
+      for (DistributedMember server : targetMembers) {
+        Region region = ExportLogsFunction.createOrGetExistingExportLogsRegion(true);
 
-        if (toContinueForRestOfmembers == true) {
-          LogWrapper.getInstance().fine("Exporting logs for member=" + member.getId()
-              + " toContinueForRestOfmembers=" + toContinueForRestOfmembers);
-          // proceed for rest of the member
-          continue;
-        }
+        ExportLogsCacheWriter cacheWriter =
+            (ExportLogsCacheWriter) region.getAttributes().getCacheWriter();
 
-        String rstList = (String) resultList.get(0);
-        LogWrapper.getInstance().fine("for member=" + member.getId()
-            + "Successfully exported to directory=" + dirName + " rstList=" + rstList);
-        if (rstList == null || rstList.length() == 0) {
-          ResultBuilder.createGemFireErrorResult(CliStrings.format(
-              CliStrings.EXPORT_LOGS__MSG__FAILED_TO_EXPORT_LOG_FILES_FOR_MEMBER_0,
-              member.getId()));
-          LogWrapper.getInstance().fine("for member=" + member.getId() + "rstList is null");
-          continue;
-        } else if (rstList.contains("does not exist or cannot be created")) {
-          LogWrapper.getInstance()
-              .fine("for member=" + member.getId() + " does not exist or cannot be created");
-          return ResultBuilder.createInfoResult(CliStrings
-              .format(CliStrings.EXPORT_LOGS__MSG__TARGET_DIR_CANNOT_BE_CREATED, dirName));
-        } else if (rstList.contains(
-            LocalizedStrings.InternalDistributedSystem_THIS_CONNECTION_TO_A_DISTRIBUTED_SYSTEM_HAS_BEEN_DISCONNECTED
-                .toLocalizedString())) {
-          LogWrapper.getInstance()
-              .fine("for member=" + member.getId()
-                  + LocalizedStrings.InternalDistributedSystem_THIS_CONNECTION_TO_A_DISTRIBUTED_SYSTEM_HAS_BEEN_DISCONNECTED
-                      .toLocalizedString());
-          // proceed for rest of the members
-          continue;
-        }
+        cacheWriter.startFile(server.getName());
 
-        // maintain list of log files to merge only when merge option is true.
-        if (mergeLog == true) {
-          StringTokenizer st = new StringTokenizer(rstList, ";");
-          while (st.hasMoreTokens()) {
-            logsToMerge.add(st.nextToken());
-          }
-        }
+        CliUtil.executeFunction(new ExportLogsFunction(),
+                new ExportLogsFunction.Args(start, end, logLevel, onlyLogLevel), server)
+            .getResult();
+        Path zipFile = cacheWriter.endFile();
+        ExportLogsFunction.destroyExportLogsRegion();
+        logger.info("Recieved zip file from member " + server.getId() + ": " + zipFile.toString());
+        zipFilesFromMembers.put(server.getId(), zipFile);
       }
-      // merge log files
-      if (mergeLog == true) {
-        LogWrapper.getInstance().fine("Successfully exported to directory=" + dirName
-            + " and now merging logsToMerge=" + logsToMerge.size());
-        mergeLogs(logsToMerge);
-        return ResultBuilder
-            .createInfoResult("Successfully exported and merged in directory " + dirName);
+
+      Path tempDir = Files.createTempDirectory("exportedLogs");
+      Path exportedLogsDir = tempDir.resolve("exportedLogs");
+
+      for (Path zipFile : zipFilesFromMembers.values()) {
+        Path unzippedMemberDir =
+            exportedLogsDir.resolve(zipFile.getFileName().toString().replace(".zip", ""));
+        ZipUtils.unzip(zipFile.toAbsolutePath().toString(), unzippedMemberDir.toString());
+        FileUtils.deleteQuietly(zipFile.toFile());
       }
-      LogWrapper.getInstance().fine("Successfully exported to directory without merging" + dirName);
-      return ResultBuilder.createInfoResult("Successfully exported to directory " + dirName);
+
+      Path workingDir = Paths.get(System.getProperty("user.dir"));
+      Path exportedLogsZipFile = workingDir.resolve("exportedLogs[" + System.currentTimeMillis() + "].zip").toAbsolutePath();
+
+      logger.info("Zipping into: " + exportedLogsZipFile.toString());
+      ZipUtils.zipDirectory(exportedLogsDir, exportedLogsZipFile);
+      FileUtils.deleteDirectory(tempDir.toFile());
+      result = ResultBuilder.createInfoResult("File exported to: " + exportedLogsZipFile.toString());
     } catch (Exception ex) {
-      LogWrapper.getInstance().info(ex.getMessage(), ex);
-      return ResultBuilder.createUserErrorResult(
-          CliStrings.EXPORT_LOGS__MSG__FUNCTION_EXCEPTION + ((LogFileFunction) function).getId());
+      ex.printStackTrace();
+      logger.error(ex, ex);
+      result = ResultBuilder.createUserErrorResult(ex.getMessage());
+    } finally {
+      ExportLogsFunction.destroyExportLogsRegion();
     }
-  }
 
-  Result mergeLogs(List<String> logsToMerge) {
-    // create a new process for merging
-    LogWrapper.getInstance().fine("Exporting logs merging logs" + logsToMerge.size());
-    if (logsToMerge.size() > 1) {
-      List<String> commandList = new ArrayList<String>();
-      commandList.add(System.getProperty("java.home") + File.separatorChar + "bin"
-          + File.separatorChar + "java");
-      commandList.add("-classpath");
-      commandList.add(System.getProperty("java.class.path", "."));
-      commandList.add(MergeLogs.class.getName());
-
-      commandList
-          .add(logsToMerge.get(0).substring(0, logsToMerge.get(0).lastIndexOf(File.separator) + 1));
-
-      ProcessBuilder procBuilder = new ProcessBuilder(commandList);
-      StringBuilder output = new StringBuilder();
-      String errorString = new String();
-      try {
-        LogWrapper.getInstance().fine("Exporting logs now merging logs");
-        Process mergeProcess = procBuilder.redirectErrorStream(true).start();
-
-        mergeProcess.waitFor();
-
-        InputStream inputStream = mergeProcess.getInputStream();
-        BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
-        String line = null;
-
-        while ((line = br.readLine()) != null) {
-          output.append(line).append(GfshParser.LINE_SEPARATOR);
-        }
-        mergeProcess.destroy();
-      } catch (Exception e) {
-        LogWrapper.getInstance().fine(e.getMessage());
-        return ResultBuilder.createUserErrorResult(
-            CliStrings.EXPORT_LOGS__MSG__FUNCTION_EXCEPTION + "Could not merge");
-      } finally {
-        if (errorString != null) {
-          output.append(errorString).append(GfshParser.LINE_SEPARATOR);
-          LogWrapper.getInstance().fine("Exporting logs after merging logs " + output);
-        }
-      }
-      if (output.toString().contains("Sucessfully merged logs")) {
-        LogWrapper.getInstance().fine("Exporting logs Sucessfully merged logs");
-        return ResultBuilder.createInfoResult("Successfully merged");
-      } else {
-        LogWrapper.getInstance().fine("Could not merge");
-        return ResultBuilder.createUserErrorResult(
-            CliStrings.EXPORT_LOGS__MSG__FUNCTION_EXCEPTION + "Could not merge");
-      }
-    }
-    return ResultBuilder.createInfoResult("Only one log file, nothing to merge");
+    LogWrapper.getInstance().fine("Exporting logs returning =" + result);
+    return result;
   }
 
+
+
   /****
    * Current implementation supports writing it to a file and returning the location of the file
    *
@@ -1112,7 +882,7 @@ public class MiscellaneousCommands implements CommandMarker {
 
   /***
    * Writes the Stack traces member-wise to a text file
-   * 
+   *
    * @param dumps - Map containing key : member , value : zipped stack traces
    * @param fileName - Name of the file to which the stack-traces are written to
    * @return Canonical path of the file which contains the stack-traces
@@ -1266,7 +1036,6 @@ public class MiscellaneousCommands implements CommandMarker {
         csvBuilder.append('\n');
       }
 
-
       CompositeResultData crd = ResultBuilder.createCompositeResultData();
       SectionResultData section = crd.addSection();
       TabularResultData metricsTable = section.addTable();
@@ -1410,7 +1179,6 @@ public class MiscellaneousCommands implements CommandMarker {
         Set<String> checkSet = new HashSet<String>(categoriesMap.keySet());
         Set<String> userCategories = getSetDifference(categories, checkSet);
 
-
         // Checking if the categories specified by the user are valid or not
         if (userCategories.isEmpty()) {
           for (String category : checkSet) {
@@ -1604,7 +1372,7 @@ public class MiscellaneousCommands implements CommandMarker {
             memberMxBean.getDiskFlushAvgLatency(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "totalQueueSize",
             memberMxBean.getTotalDiskTasksWaiting(), csvBuilder); // deadcoded to workaround bug
-                                                                  // 46397
+        // 46397
         writeToTableAndCsv(metricsTable, "", "totalBackupInProgress",
             memberMxBean.getTotalBackupInProgress(), csvBuilder);
       }
@@ -2059,7 +1827,7 @@ public class MiscellaneousCommands implements CommandMarker {
 
   /***
    * Writes an entry to a TabularResultData and writes a comma separated entry to a string builder
-   * 
+   *
    * @param metricsTable
    * @param type
    * @param metricName
@@ -2116,7 +1884,7 @@ public class MiscellaneousCommands implements CommandMarker {
 
   /****
    * Defines and returns map of categories for System metrics.
-   * 
+   *
    * @return map with categories for system metrics and display flag set to true
    */
   private Map<String, Boolean> getSystemMetricsCategories() {
@@ -2130,7 +1898,7 @@ public class MiscellaneousCommands implements CommandMarker {
 
   /****
    * Defines and returns map of categories for Region Metrics
-   * 
+   *
    * @return map with categories for region metrics and display flag set to true
    */
   private Map<String, Boolean> getRegionMetricsCategories() {
@@ -2149,7 +1917,7 @@ public class MiscellaneousCommands implements CommandMarker {
 
   /****
    * Defines and returns map of categories for system-wide region metrics
-   * 
+   *
    * @return map with categories for system wide region metrics and display flag set to true
    */
   private Map<String, Boolean> getSystemRegionMetricsCategories() {
@@ -2160,7 +1928,7 @@ public class MiscellaneousCommands implements CommandMarker {
 
   /*****
    * Defines and returns map of categories for member metrics
-   * 
+   *
    * @return map with categories for member metrics and display flag set to true
    */
   private Map<String, Boolean> getMemberMetricsCategories() {
@@ -2214,7 +1982,7 @@ public class MiscellaneousCommands implements CommandMarker {
 
   /***
    * Writes to a TabularResultData and also appends a CSV string to a String builder
-   * 
+   *
    * @param metricsTable
    * @param type
    * @param metricName
@@ -2280,7 +2048,6 @@ public class MiscellaneousCommands implements CommandMarker {
       Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
       Set<DistributedMember> ds = CliUtil.getAllMembers(cache);
 
-
       if (grps != null && grps.length > 0) {
         for (String grp : grps) {
           dsMembers.addAll(cache.getDistributedSystem().getGroupMembers(grp));
@@ -2359,7 +2126,6 @@ public class MiscellaneousCommands implements CommandMarker {
   }
 
 
-
   @CliAvailabilityIndicator({CliStrings.SHUTDOWN, CliStrings.GC, CliStrings.SHOW_DEADLOCK,
       CliStrings.SHOW_METRICS, CliStrings.SHOW_LOG, CliStrings.EXPORT_STACKTRACE,
       CliStrings.NETSTAT, CliStrings.EXPORT_LOGS, CliStrings.CHANGE_LOGLEVEL})

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
new file mode 100644
index 0000000..1dc89e9
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
@@ -0,0 +1,203 @@
+/*
+ * 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.management.internal.cli.functions;
+
+import static java.util.stream.Collectors.toSet;
+import static org.apache.geode.distributed.internal.DistributionManager.LOCATOR_DM_TYPE;
+
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.internal.InternalEntity;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalRegionArguments;
+import org.apache.geode.internal.lang.StringUtils;
+import org.apache.geode.internal.logging.InternalLogWriter;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.internal.logging.LogWriterImpl;
+import org.apache.geode.management.internal.cli.commands.MiscellaneousCommands;
+import org.apache.geode.management.internal.cli.util.ExportLogsCacheWriter;
+import org.apache.geode.management.internal.cli.util.LogExporter;
+import org.apache.geode.management.internal.cli.util.LogFilter;
+import org.apache.geode.management.internal.configuration.domain.Configuration;
+import org.apache.logging.log4j.Logger;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.Serializable;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.stream.Stream;
+
+public class ExportLogsFunction implements Function, InternalEntity {
+  public static final String EXPORT_LOGS_REGION = "__exportLogsRegion";
+  private static final Logger LOGGER = LogService.getLogger();
+  private static final long serialVersionUID = 1L;
+  private static final int BUFFER_SIZE = 1024;
+
+
+  @Override
+  public void execute(final FunctionContext context) {
+    try {
+      // TODO: change this to get cache from FunctionContext when it becomes available
+      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+
+      String memberId = cache.getDistributedSystem().getMemberId();
+      LOGGER.info("ExportLogsFunction started for member {}", memberId);
+
+      Region exportLogsRegion = createOrGetExistingExportLogsRegion(false);
+
+      Args args = (Args) context.getArguments();
+      LogFilter logFilter =
+          new LogFilter(args.getPermittedLogLevels(), args.getStartTime(), args.getEndTime());
+      Path workingDir = Paths.get(System.getProperty("user.dir"));
+
+      Path exportedZipFile = new LogExporter(logFilter).export(workingDir);
+
+      LOGGER.info("Streaming zipped file: " + exportedZipFile.toString());
+      try (FileInputStream inputStream = new FileInputStream(exportedZipFile.toFile())) {
+        byte[] buffer = new byte[BUFFER_SIZE];
+
+        int bytesRead;
+        while ((bytesRead = inputStream.read(buffer)) > 0) {
+          if (bytesRead == BUFFER_SIZE) {
+            exportLogsRegion.put(memberId, buffer);
+          } else {
+            exportLogsRegion.put(memberId, Arrays.copyOfRange(buffer, 0, bytesRead));
+          }
+        }
+      }
+
+      context.getResultSender().lastResult(null);
+
+    } catch (Exception e) {
+      LOGGER.error(e);
+      context.getResultSender().sendException(e);
+    }
+  }
+
+  protected static boolean isLocator(GemFireCacheImpl cache) {
+    return cache.getMyId().getVmKind() == LOCATOR_DM_TYPE;
+  }
+
+  public static Region createOrGetExistingExportLogsRegion(boolean isInitiatingMember)
+      throws IOException, ClassNotFoundException {
+    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+
+    Region exportLogsRegion = cache.getRegion(EXPORT_LOGS_REGION);
+    if (exportLogsRegion == null) {
+      AttributesFactory<String, Configuration> regionAttrsFactory =
+          new AttributesFactory<String, Configuration>();
+      regionAttrsFactory.setDataPolicy(DataPolicy.EMPTY);
+      regionAttrsFactory.setScope(Scope.DISTRIBUTED_ACK);
+
+      if (isInitiatingMember) {
+        regionAttrsFactory.setCacheWriter(new ExportLogsCacheWriter());
+      }
+      InternalRegionArguments internalArgs = new InternalRegionArguments();
+      internalArgs.setIsUsedForMetaRegion(true);
+      exportLogsRegion =
+          cache.createVMRegion(EXPORT_LOGS_REGION, regionAttrsFactory.create(), internalArgs);
+    }
+
+    return exportLogsRegion;
+  }
+
+  public static void destroyExportLogsRegion() {
+    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+
+    Region exportLogsRegion = cache.getRegion(EXPORT_LOGS_REGION);
+    if (exportLogsRegion == null) {
+      return;
+    }
+
+      exportLogsRegion.destroyRegion();
+
+  }
+
+  @Override
+  public boolean isHA() {
+    return false;
+  }
+
+  public static class Args implements Serializable {
+    private String startTime;
+    private String endTime;
+    private String logLevel;
+    private boolean logLevelOnly;
+
+    public Args(String startTime, String endTime, String logLevel, boolean logLevelOnly) {
+      this.startTime = startTime;
+      this.endTime = endTime;
+      this.logLevel = logLevel;
+      this.logLevelOnly = logLevelOnly;
+    }
+
+    public LocalDateTime getStartTime() {
+      return parseTime(startTime);
+    }
+
+    public LocalDateTime getEndTime() {
+      return parseTime(endTime);
+    }
+
+    public Set<String> getPermittedLogLevels() {
+      if (logLevel == null || StringUtils.isBlank(logLevel)) {
+        return LogFilter.allLogLevels();
+      }
+
+      if (logLevelOnly) {
+        return Stream.of(logLevel).collect(toSet());
+      }
+
+      // Return all log levels lower than or equal to the specified logLevel
+      return Arrays.stream(InternalLogWriter.levelNames).filter((String level) -> {
+        int logLevelCode = LogWriterImpl.levelNameToCode(level);
+        int logLevelCodeThreshold = LogWriterImpl.levelNameToCode(logLevel);
+
+        return logLevelCode >= logLevelCodeThreshold;
+      }).collect(toSet());
+    }
+
+    private static LocalDateTime parseTime(String dateString) {
+      if (dateString == null) {
+        return null;
+      }
+
+      try {
+        SimpleDateFormat df = new SimpleDateFormat(MiscellaneousCommands.FORMAT);
+        return df.parse(dateString).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+      } catch (ParseException e) {
+        try {
+          SimpleDateFormat df = new SimpleDateFormat(MiscellaneousCommands.ONLY_DATE_FORMAT);
+          return df.parse(dateString).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+        } catch (ParseException e1) {
+          return null;
+        }
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java
new file mode 100644
index 0000000..a8b7225
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java
@@ -0,0 +1,78 @@
+/*
+ * 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.management.internal.cli.util;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.geode.cache.CacheWriterException;
+import org.apache.geode.cache.EntryEvent;
+import org.apache.geode.cache.util.CacheWriterAdapter;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Map;
+
+public class ExportLogsCacheWriter extends CacheWriterAdapter implements Serializable {
+  private Path currentFile;
+  private BufferedOutputStream currentOutputStream;
+
+  @Override
+  public void beforeCreate(EntryEvent event) throws CacheWriterException {
+    if (currentFile.getFileName().endsWith("server-2.zip")) {
+      System.out.println("We got data from server 2");
+    }
+    if (currentOutputStream == null) {
+      throw new IllegalStateException("No outputStream is open.  You must call startFile before sending data.");
+    }
+
+    try {
+      Object newValue = event.getNewValue();
+      if (!(newValue instanceof byte[])) {
+        throw new IllegalArgumentException(
+            "Value must be a byte[].  Recieved " + newValue.getClass().getCanonicalName());
+      }
+      currentOutputStream.write((byte[]) newValue);
+    } catch (IOException e) {
+      throw new CacheWriterException(e);
+    }
+  }
+
+  public void startFile(String memberId) throws IOException {
+    if (currentFile != null || currentOutputStream != null) {
+      throw new IllegalStateException("Cannot open more than one file at once");
+    }
+
+    currentFile = Files.createTempDirectory(memberId).resolve(memberId + ".zip");
+    currentOutputStream = new BufferedOutputStream(new FileOutputStream(currentFile.toFile()));
+  }
+
+  public Path endFile() {
+    Path completedFile = currentFile;
+
+    IOUtils.closeQuietly(currentOutputStream);
+    currentOutputStream = null;
+    currentFile = null;
+
+    return completedFile;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java
new file mode 100644
index 0000000..9a79fc0
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java
@@ -0,0 +1,39 @@
+/*
+ * 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.management.internal.cli.util;
+
+import java.util.Map;
+
+public class ExportLogsRepository {
+
+
+  Map exportFiles;
+
+  public void addFile() {
+
+  }
+
+  public void deleteFile() {
+
+  }
+
+  private void cleanUpExpiredFiles() {
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
new file mode 100644
index 0000000..f30d686
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
@@ -0,0 +1,136 @@
+/*
+ * 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.management.internal.cli.util;
+
+import static java.util.stream.Collectors.toList;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.Scope;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalRegionArguments;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.management.internal.configuration.domain.Configuration;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
+import org.apache.logging.log4j.Logger;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.text.ParseException;
+import java.util.List;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+
+public class LogExporter {
+  private static final Logger LOGGER = LogService.getLogger();
+
+  private final LogFilter logFilter;
+
+  public LogExporter(LogFilter logFilter) throws ParseException {
+    this.logFilter = logFilter;
+  }
+
+  public Path export(Path workingDir) throws IOException {
+    LOGGER.debug("Working directory is {}", workingDir);
+
+    Path tempDirectory = Files.createTempDirectory("exportLogs");
+
+    for (Path logFile : findLogFiles(workingDir)) {
+      Path filteredLogFile = tempDirectory.resolve(logFile.getFileName());
+
+      if (this.logFilter == null) {
+        Files.copy(logFile, filteredLogFile);
+      } else {
+        writeFilteredLogFile(logFile, filteredLogFile);
+      }
+    }
+
+    for (Path statFile : findStatFiles(workingDir)) {
+      Files.copy(statFile, tempDirectory);
+    }
+
+    Path zipFile = Files.createTempFile("logExport", ".zip");
+    ZipUtils.zipDirectory(tempDirectory, zipFile);
+    LOGGER.info("Zipped files to: " + zipFile);
+
+
+    FileUtils.deleteDirectory(tempDirectory.toFile());
+
+    return zipFile;
+  }
+
+  protected void writeFilteredLogFile(Path originalLogFile, Path filteredLogFile)
+      throws IOException {
+    this.logFilter.startNewFile();
+
+    try (BufferedReader reader = new BufferedReader(new FileReader(originalLogFile.toFile()))) {
+      try (BufferedWriter writer = new BufferedWriter(new FileWriter(filteredLogFile.toFile()))) {
+
+        String line;
+        while ((line = reader.readLine()) != null) {
+          LogFilter.LineFilterResult result = this.logFilter.acceptsLine(line);
+
+          if (result == LogFilter.LineFilterResult.REMAINDER_OF_FILE_REJECTED) {
+            break;
+          }
+
+          if (result == LogFilter.LineFilterResult.LINE_ACCEPTED) {
+            writeLine(line, writer);
+          }
+        }
+      }
+    }
+  }
+
+  private void writeLine(String line, BufferedWriter writer) {
+    try {
+      writer.write(line);
+      writer.newLine();
+    } catch (IOException e) {
+      throw new RuntimeException("Unable to write to log file", e);
+    }
+  }
+
+  protected List<Path> findLogFiles(Path workingDir) throws IOException {
+    Predicate<Path> logFileSelector = (Path file) -> file.toString().toLowerCase().endsWith(".log");
+    return findFiles(workingDir, logFileSelector);
+  }
+
+
+  protected List<Path> findStatFiles(Path workingDir) throws IOException {
+    Predicate<Path> statFileSelector =
+        (Path file) -> file.toString().toLowerCase().endsWith(".gfs");
+    return findFiles(workingDir, statFileSelector);
+  }
+
+  private List<Path> findFiles(Path workingDir, Predicate<Path> fileSelector) throws IOException {
+    Stream<Path> selectedFiles =
+        Files.list(workingDir).filter(fileSelector).filter(this.logFilter::acceptsFile);
+
+    return selectedFiles.collect(toList());
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java
new file mode 100644
index 0000000..2436530
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java
@@ -0,0 +1,113 @@
+/*
+ * 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.management.internal.cli.util;
+
+import static java.util.stream.Collectors.toSet;
+
+import org.apache.geode.internal.logging.InternalLogWriter;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.logging.log4j.Logger;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.Arrays;
+import java.util.Set;
+
+public class LogFilter {
+  public enum LineFilterResult {
+    LINE_ACCEPTED, LINE_REJECTED, REMAINDER_OF_FILE_REJECTED
+  }
+
+  private static final Logger LOGGER = LogService.getLogger();
+
+  private final Set<String> permittedLogLevels;
+  private final LocalDateTime startDate;
+  private final LocalDateTime endDate;
+
+  private LineFilterResult resultOfPreviousLine = LineFilterResult.LINE_ACCEPTED;
+
+  public LogFilter(Set<String> permittedLogLevels, LocalDateTime startDate, LocalDateTime endDate) {
+    this.permittedLogLevels = (permittedLogLevels == null || permittedLogLevels.isEmpty())
+        ? allLogLevels() : permittedLogLevels;
+    this.startDate = startDate;
+    this.endDate = endDate;
+  }
+
+  public void startNewFile() {
+    this.resultOfPreviousLine = LineFilterResult.LINE_ACCEPTED;
+  }
+
+  public LineFilterResult acceptsLine(String logLine) {
+    LogLevelExtractor.Result result = LogLevelExtractor.extract(logLine);
+
+    return acceptsLogEntry(result);
+  }
+
+  protected LineFilterResult acceptsLogEntry(LogLevelExtractor.Result result) {
+    if (result == null) {
+      return resultOfPreviousLine;
+    }
+
+    return acceptsLogEntry(result.getLogLevel(), result.getLogTimestamp());
+  }
+
+  protected LineFilterResult acceptsLogEntry(String logLevel, LocalDateTime logTimestamp) {
+    if (logTimestamp == null || logLevel == null) {
+      throw new IllegalArgumentException();
+    }
+
+    LineFilterResult result;
+
+    if (endDate != null && logTimestamp.isAfter(endDate)) {
+      result = LineFilterResult.REMAINDER_OF_FILE_REJECTED;
+    } else if (startDate != null && logTimestamp.isBefore(startDate)) {
+      result = LineFilterResult.LINE_REJECTED;
+    } else {
+      result = permittedLogLevels.contains(logLevel) ? LineFilterResult.LINE_ACCEPTED
+          : LineFilterResult.LINE_REJECTED;
+    }
+
+    resultOfPreviousLine = result;
+
+    return result;
+  }
+
+  public boolean acceptsFile(Path file) {
+    if (startDate == null) {
+      return true;
+    }
+    try {
+      return (getEndTimeOf(file).isAfter(startDate));
+    } catch (IOException e) {
+      LOGGER.error("Unable to determine lastModified time", e);
+      return true;
+    }
+  }
+
+  private static LocalDateTime getEndTimeOf(Path file) throws IOException {
+    long lastModifiedMillis = file.toFile().lastModified();
+    return Instant.ofEpochMilli(lastModifiedMillis).atZone(ZoneId.systemDefault())
+        .toLocalDateTime();
+  }
+
+  public static Set<String> allLogLevels() {
+    return Arrays.stream(InternalLogWriter.levelNames).collect(toSet());
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java
new file mode 100644
index 0000000..6c15d15
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java
@@ -0,0 +1,65 @@
+/*
+ * 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.management.internal.cli.util;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class LogLevelExtractor {
+  private static Pattern LOG_PATTERN =
+      Pattern.compile("^\\[(\\S*)\\s+([\\d\\/]+)\\s+([\\d:\\.]+)\\s+(\\S+)");
+
+  private static DateTimeFormatter LOG_TIMESTAMP_FORMATTER =
+      DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss.SSS zzz");
+  private static final String SPACE = " ";
+
+  public static Result extract(String logLine) {
+    Matcher m = LOG_PATTERN.matcher(logLine);
+    if (!m.find()) {
+      return null;
+    }
+
+    String logLevel = m.group(1);
+    String logTimestamp = m.group(2) + SPACE + m.group(3) + SPACE + m.group(4);
+
+    LocalDateTime timestamp = LocalDateTime.parse(logTimestamp, LOG_TIMESTAMP_FORMATTER);
+
+    return new Result(logLevel, timestamp);
+  }
+
+  public static class Result {
+    private String logLevel;
+    private LocalDateTime logTimestamp;
+
+    public Result(String logLevel, LocalDateTime logTimestamp) {
+      this.logLevel = logLevel;
+      this.logTimestamp = logTimestamp;
+    }
+
+    public String getLogLevel() {
+      return logLevel;
+    }
+
+    public LocalDateTime getLogTimestamp() {
+      return logTimestamp;
+    }
+
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
index 8d2ef45..67d5473 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
@@ -14,17 +14,30 @@
  */
 package org.apache.geode.management.internal.cli.util;
 
+import static java.util.stream.Collectors.toList;
+
+import java.io.BufferedReader;
 import java.io.File;
 
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FilenameFilter;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.PrintWriter;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.geode.internal.logging.MergeLogFiles;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.GfshParser;
+import org.apache.geode.management.internal.cli.LogWrapper;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
 
 /**
  * 
@@ -32,17 +45,54 @@ import org.apache.geode.management.internal.cli.i18n.CliStrings;
  */
 
 public class MergeLogs {
-  /**
-   * @param args
-   */
+
+  public static void mergeLogsInNewProcess(Path logDirectory) {
+    // create a new process for merging
+    LogWrapper.getInstance().fine("Exporting logs merging logs" + logDirectory);
+    List<String> commandList = new ArrayList<String>();
+    commandList.add(System.getProperty("java.home") + File.separatorChar + "bin"
+        + File.separatorChar + "java");
+    commandList.add("-classpath");
+    commandList.add(System.getProperty("java.class.path", "."));
+    commandList.add(MergeLogs.class.getName());
+
+    commandList
+        .add(logDirectory.toAbsolutePath().toString());
+
+    ProcessBuilder procBuilder = new ProcessBuilder(commandList);
+    StringBuilder output = new StringBuilder();
+    String errorString = new String();
+    try {
+      LogWrapper.getInstance().fine("Exporting logs now merging logs");
+      Process mergeProcess = procBuilder.redirectErrorStream(true).start();
+
+      mergeProcess.waitFor();
+
+      InputStream inputStream = mergeProcess.getInputStream();
+      BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+      String line = null;
+
+      while ((line = br.readLine()) != null) {
+        output.append(line).append(GfshParser.LINE_SEPARATOR);
+      }
+      mergeProcess.destroy();
+    } catch (Exception e) {
+      LogWrapper.getInstance().severe(e.getMessage());
+    }
+    if (output.toString().contains("Merged logs to: ")) {
+      LogWrapper.getInstance().fine("Exporting logs Sucessfully merged logs");
+    } else {
+      LogWrapper.getInstance().severe("Could not merge");
+    }
+  }
 
   public static void main(String[] args) {
     if (args.length < 1 || args.length > 1) {
       throw new IllegalArgumentException("Requires only 1  arguments : <targetDirName>");
     }
     try {
-      String result = mergeLogFile(args[0]);
-      System.out.println(result);
+      String result = mergeLogFile(args[0]).getCanonicalPath();
+      System.out.println("Merged logs to: " + result);
     } catch (Exception e) {
       System.out.println(e.getMessage());
     }
@@ -50,27 +100,32 @@ public class MergeLogs {
 
   }
 
-  static String mergeLogFile(String dirName) throws Exception {
-    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
-    File dir = new File(dirName);
-    String[] logsToMerge = dir.list();
-    InputStream[] logFiles = new FileInputStream[logsToMerge.length];
+  protected static List<File> findLogFilesToMerge (File dir) {
+    return FileUtils.listFiles(dir, new String[]{"log"}, true).stream().collect(toList());
+  }
+
+  static File mergeLogFile(String dirName) throws Exception {
+    Path dir = Paths.get(dirName);
+    List<File> logsToMerge = findLogFilesToMerge(dir.toFile());
+    InputStream[] logFiles = new FileInputStream[logsToMerge.size()];
     String[] logFileNames = new String[logFiles.length];
-    for (int i = 0; i < logsToMerge.length; i++) {
+    for (int i = 0; i < logsToMerge.size(); i++) {
       try {
-        logFiles[i] = new FileInputStream(dirName + File.separator + logsToMerge[i]);
-        logFileNames[i] = dirName + File.separator + logsToMerge[i];
+        logFiles[i] = new FileInputStream(logsToMerge.get(i));
+        logFileNames[i] = dir.relativize(logsToMerge.get(i).toPath()).toString();
       } catch (FileNotFoundException e) {
         throw new Exception(
-            logsToMerge[i] + " " + CliStrings.EXPORT_LOGS__MSG__FILE_DOES_NOT_EXIST);
+            logsToMerge.get(i) + " " + CliStrings.EXPORT_LOGS__MSG__FILE_DOES_NOT_EXIST);
       }
     }
 
     PrintWriter mergedLog = null;
+    File mergedLogFile = null;
     try {
       String mergeLog =
-          dirName + File.separator + "merge_" + sdf.format(new java.util.Date()) + ".log";
-      mergedLog = new PrintWriter(mergeLog);
+          dirName + File.separator + "merge_" + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new java.util.Date()) + ".log";
+      mergedLogFile = new File(mergeLog);
+      mergedLog = new PrintWriter(mergedLogFile);
       boolean flag = MergeLogFiles.mergeLogFiles(logFiles, logFileNames, mergedLog);
     } catch (FileNotFoundException e) {
       throw new Exception(
@@ -79,7 +134,7 @@ public class MergeLogs {
       throw new Exception("Exception in creating PrintWriter in MergeLogFiles" + e.getMessage());
     }
 
-    return "Sucessfully merged logs";
+    return mergedLogFile;
   }
 
 

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/ZipUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/ZipUtils.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/ZipUtils.java
index 81161d6..e32803a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/ZipUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/ZipUtils.java
@@ -41,8 +41,12 @@ import org.apache.commons.io.IOUtils;
 public class ZipUtils {
 
   public static void zipDirectory(Path sourceDirectory, Path targetFile) throws IOException {
-    Path p = Files.createFile(targetFile);
-    try (ZipOutputStream zs = new ZipOutputStream(Files.newOutputStream(p))) {
+    Path parentDir = targetFile.getParent();
+    if (parentDir != null && !parentDir.toFile().exists()) {
+      parentDir.toFile().mkdirs();
+    }
+
+    try (ZipOutputStream zs = new ZipOutputStream(Files.newOutputStream(targetFile))) {
       Files.walk(sourceDirectory).filter(path -> !Files.isDirectory(path)).forEach(path -> {
         ZipEntry zipEntry = new ZipEntry(sourceDirectory.relativize(path).toString());
         try {

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
new file mode 100644
index 0000000..43ee742
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
@@ -0,0 +1,363 @@
+/*
+ * 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.management.internal.cli.commands;
+
+import static java.util.stream.Collectors.joining;
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toSet;
+import static org.apache.geode.management.internal.cli.commands.MiscellaneousCommands.FORMAT;
+import static org.apache.geode.management.internal.cli.commands.MiscellaneousCommands.ONLY_DATE_FORMAT;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.management.internal.cli.functions.ExportLogsFunction;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
+import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.Locator;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.Member;
+import org.apache.geode.test.dunit.rules.Server;
+import org.apache.logging.log4j.Logger;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Stream;
+
+
+public class ExportLogsDUnit {
+  private static final String ERROR_LOG_PREFIX = "[IGNORE]";
+
+  @Rule
+  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+
+  @Rule
+  public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
+
+  private Locator locator;
+  private Server server1;
+  private Server server2;
+
+  private Map<Member, List<LogLine>> expectedMessages;
+
+  @Before
+  public void setup() throws Exception {
+    Properties properties = new Properties();
+    properties.setProperty(ConfigurationProperties.LOG_LEVEL, "debug");
+
+    locator = lsRule.startLocatorVM(0, properties);
+    server1 = lsRule.startServerVM(1, properties, locator.getPort());
+    server2 = lsRule.startServerVM(2, properties, locator.getPort());
+
+    IgnoredException.addIgnoredException(ERROR_LOG_PREFIX);
+
+    expectedMessages = new HashMap<>();
+    expectedMessages.put(locator, listOfLogLines(locator, "info", "error", "debug"));
+    expectedMessages.put(server1, listOfLogLines(server1, "info", "error", "debug"));
+    expectedMessages.put(server2, listOfLogLines(server2, "info", "error", "debug"));
+
+    // log the messages in each of the members
+    for (Member member : expectedMessages.keySet()) {
+      List<LogLine> logLines = expectedMessages.get(member);
+
+      member.invoke(() -> {
+        Logger logger = LogService.getLogger();
+        logLines.forEach((LogLine logLine) -> logLine.writeLog(logger));
+      });
+    }
+
+    gfshConnector.connectAndVerify(locator);
+  }
+
+  @Test
+  public void startAndEndDateCanExcludeLogs() throws Exception {
+    ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault());
+    ZonedDateTime yesterday = now.minusDays(1);
+    ZonedDateTime twoDaysAgo = now.minusDays(2);
+
+    DateTimeFormatter dateTimeFormatter =  DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
+
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
+    commandStringBuilder.addOption("start-time", dateTimeFormatter.format(twoDaysAgo));
+    commandStringBuilder.addOption("end-time", dateTimeFormatter.format(yesterday));
+    commandStringBuilder.addOption("log-level", "debug");
+    commandStringBuilder.addOption("dir", "someDir");
+
+    gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString());
+
+    Set<String> acceptedLogLevels = new HashSet<>();
+    verifyZipFileContents(acceptedLogLevels);
+  }
+
+  @Test
+  public void startAndEndDateCanIncludeLogs() throws Exception {
+    ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault());
+    ZonedDateTime yesterday = now.minusDays(1);
+    ZonedDateTime tomorrow = now.plusDays(1);
+
+    DateTimeFormatter dateTimeFormatter =  DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
+
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
+    commandStringBuilder.addOption("start-time", dateTimeFormatter.format(yesterday));
+    commandStringBuilder.addOption("end-time", dateTimeFormatter.format(tomorrow));
+    commandStringBuilder.addOption("log-level", "debug");
+    commandStringBuilder.addOption("dir", "someDir");
+
+    gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString());
+
+    Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
+    verifyZipFileContents(acceptedLogLevels);
+  }
+
+  @Test
+  public void testExportWithStartAndEndDateTimeFiltering() throws Exception {
+    ZonedDateTime cutoffTime = LocalDateTime.now().atZone(ZoneId.systemDefault());
+
+    String messageAfterCutoffTime = "[this message should not show up since it is after cutoffTime]";
+    LogLine logLineAfterCutoffTime = new LogLine(messageAfterCutoffTime, "info",  true);
+    server1.invoke(() -> {
+      Logger logger = LogService.getLogger();
+      logLineAfterCutoffTime.writeLog(logger);
+    });
+
+    DateTimeFormatter dateTimeFormatter =  DateTimeFormatter.ofPattern(FORMAT);
+    String cutoffTimeString = dateTimeFormatter.format(cutoffTime);
+
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
+    commandStringBuilder.addOption("start-time", dateTimeFormatter.format(cutoffTime.minusHours(1)));
+    commandStringBuilder.addOption("end-time", cutoffTimeString);
+    commandStringBuilder.addOption("log-level", "debug");
+    commandStringBuilder.addOption("dir", "someDir");
+
+    gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString());
+
+    expectedMessages.get(server1).add(logLineAfterCutoffTime);
+    Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
+    verifyZipFileContents(acceptedLogLevels);
+  }
+
+  @Test
+  public void testExportWithThresholdLogLevelFilter() throws Exception {
+
+    CommandResult result = gfshConnector.executeAndVerifyCommand(
+        "export logs --log-level=info --only-log-level=false --dir=" + lsRule.getTempFolder()
+            .getRoot().getCanonicalPath());
+
+    Set<String> acceptedLogLevels = Stream.of("info", "error").collect(toSet());
+    verifyZipFileContents(acceptedLogLevels);
+
+  }
+
+  @Test
+  public void testExportWithExactLogLevelFilter() throws Exception {
+    CommandResult result = gfshConnector.executeAndVerifyCommand(
+        "export logs --log-level=info --only-log-level=true --dir=" + lsRule.getTempFolder()
+            .getRoot().getCanonicalPath());
+
+
+    Set<String> acceptedLogLevels = Stream.of("info").collect(toSet());
+    verifyZipFileContents(acceptedLogLevels);
+  }
+
+  @Test
+  public void testExportWithNoFilters() throws Exception {
+    CommandResult result = gfshConnector.executeAndVerifyCommand(
+        "export logs  --dir=" + "someDir" /*  lsRule.getTempFolder().getRoot().getCanonicalPath() */);
+
+    Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
+    verifyZipFileContents(acceptedLogLevels);
+
+    // Ensure export logs region gets cleaned up
+    server1.invoke(ExportLogsDUnit::verifyExportLogsRegionWasDestroyed);
+    server2.invoke(ExportLogsDUnit::verifyExportLogsRegionWasDestroyed);
+    locator.invoke(ExportLogsDUnit::verifyExportLogsRegionWasDestroyed);
+  }
+
+@Test
+public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFoundException {
+    locator.invoke(() -> {
+      ExportLogsFunction.createOrGetExistingExportLogsRegion(true);
+      Cache cache = GemFireCacheImpl.getInstance();
+      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
+    });
+
+    server1.invoke(() -> {
+      ExportLogsFunction.createOrGetExistingExportLogsRegion(false);
+      Cache cache = GemFireCacheImpl.getInstance();
+      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
+    });
+
+    locator.invoke(() -> {
+      ExportLogsFunction.destroyExportLogsRegion();
+
+      Cache cache = GemFireCacheImpl.getInstance();
+      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
+    });
+
+    server1.invoke(() -> {
+      Cache cache = GemFireCacheImpl.getInstance();
+      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
+    });
+}
+
+
+  public void verifyZipFileContents(Set<String> acceptedLogLevels)
+      throws IOException {
+    File unzippedLogFileDir = unzipExportedLogs();
+
+    Set<File> dirsFromZipFile =
+        Stream.of(unzippedLogFileDir.listFiles()).filter(File::isDirectory).collect(toSet());
+    assertThat(dirsFromZipFile).hasSize(expectedMessages.keySet().size());
+
+    Set<String> expectedDirNames =
+        expectedMessages.keySet().stream().map(Member::getName).collect(toSet());
+    Set<String> actualDirNames = dirsFromZipFile.stream().map(File::getName).collect(toSet());
+    assertThat(actualDirNames).isEqualTo(expectedDirNames);
+
+    System.out.println("Unzipped artifacts:");
+    for (File dir : dirsFromZipFile) {
+      verifyLogFileContents(acceptedLogLevels, dir);
+    }
+  }
+
+  public void verifyLogFileContents(Set<String> acceptedLogLevels, File dirForMember)
+      throws IOException {
+
+    String memberName = dirForMember.getName();
+    Member member = expectedMessages.keySet().stream()
+        .filter((Member aMember) -> aMember.getName().equals(memberName))
+        .findFirst()
+        .get();
+
+    assertThat(member).isNotNull();
+
+    Set<String> fileNamesInDir =
+        Stream.of(dirForMember.listFiles()).map(File::getName).collect(toSet());
+
+    System.out.println(dirForMember.getCanonicalPath() + " : " + fileNamesInDir);
+
+    File logFileForMember = new File(dirForMember, memberName + ".log");
+    assertThat(logFileForMember).exists();
+    assertThat(fileNamesInDir).hasSize(1);
+
+    String logFileContents =
+        FileUtils.readLines(logFileForMember, Charset.defaultCharset()).stream()
+            .collect(joining("\n"));
+
+    for (LogLine logLine : expectedMessages.get(member)) {
+      boolean shouldExpectLogLine = acceptedLogLevels.contains(logLine.level) && !logLine.shouldBeIgnoredDueToTimestamp;
+
+      if (shouldExpectLogLine) {
+        assertThat(logFileContents).contains(logLine.getMessage());
+      } else {
+        assertThat(logFileContents).doesNotContain(logLine.getMessage());
+      }
+    }
+
+  }
+
+  private File unzipExportedLogs() throws IOException {
+    File locatorWorkingDir = locator.getWorkingDir();
+    List<File> filesInDir = Stream.of(locatorWorkingDir.listFiles()).collect(toList());
+    assertThat(filesInDir).isNotEmpty();
+
+
+    List<File> zipFilesInDir = Stream.of(locatorWorkingDir.listFiles())
+        .filter(f -> f.getName().endsWith(".zip")).collect(toList());
+    assertThat(zipFilesInDir).describedAs(filesInDir.stream().map(File::getAbsolutePath).collect(joining(","))).hasSize(1);
+
+    File unzippedLogFileDir = lsRule.getTempFolder().newFolder("unzippedLogs");
+    ZipUtils.unzip(zipFilesInDir.get(0).getCanonicalPath(), unzippedLogFileDir.getCanonicalPath());
+    return unzippedLogFileDir;
+  }
+
+  private List<LogLine> listOfLogLines(Member member, String... levels) {
+    return Stream.of(levels).map(level -> new LogLine(member, level)).collect(toList());
+  }
+
+  private static void verifyExportLogsRegionWasDestroyed() {
+    Cache cache = GemFireCacheImpl.getInstance();
+    assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
+  }
+
+  public static class LogLine implements Serializable {
+    String level;
+    String message;
+    boolean shouldBeIgnoredDueToTimestamp;
+
+    public LogLine(String message, String level, boolean shouldBeIgnoredDueToTimestamp) {
+      this.message = message;
+      this.level = level;
+      this.shouldBeIgnoredDueToTimestamp = shouldBeIgnoredDueToTimestamp;
+    }
+
+    public LogLine(Member member, String level) {
+      this.level = level;
+      this.message = buildMessage(member.getName());
+    }
+
+    public String getMessage() {
+      return message;
+    }
+
+    private String buildMessage(String memberName) {
+      StringBuilder stringBuilder = new StringBuilder();
+      if (Objects.equals(level, "error")) {
+        stringBuilder.append(ERROR_LOG_PREFIX);
+      }
+      stringBuilder.append(level);
+
+      return stringBuilder.append(memberName).toString();
+    }
+
+
+    public void writeLog(Logger logger) {
+      switch (this.level) {
+        case "info":
+          logger.info(getMessage());
+          break;
+        case "error":
+          logger.error(getMessage());
+          break;
+        case "debug":
+          logger.debug(getMessage());
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart1DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart1DUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart1DUnitTest.java
deleted file mode 100644
index cb9a8c6..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart1DUnitTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.management.internal.cli.commands;
-
-import static org.apache.geode.test.dunit.Assert.assertEquals;
-import static org.apache.geode.test.dunit.Assert.fail;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.internal.logging.LogWriterImpl;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.SerializableRunnable;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Dunit class for testing gemfire function commands : export logs
- */
-@Category(DistributedTest.class)
-public class MiscellaneousCommandsExportLogsPart1DUnitTest extends CliCommandTestBase {
-
-  private static final long serialVersionUID = 1L;
-
-  void setupForExportLogs() {
-    final VM vm1 = Host.getHost(0).getVM(1);
-    setUpJmxManagerOnVm0ThenConnect(null);
-
-    vm1.invoke(new SerializableRunnable() {
-      public void run() {
-        // no need to close cache as it will be closed as part of teardown2
-        Cache cache = getCache();
-
-        RegionFactory<Integer, Integer> dataRegionFactory =
-            cache.createRegionFactory(RegionShortcut.PARTITION);
-        Region region = dataRegionFactory.create("testRegion");
-        for (int i = 0; i < 5; i++) {
-          region.put("key" + (i + 200), "value" + (i + 200));
-        }
-      }
-    });
-  }
-
-  String getCurrentTimeString() {
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_SSS_z");
-    Date startDate = new Date(System.currentTimeMillis());
-    String formattedStartDate = sf.format(startDate);
-    return ("_" + formattedStartDate);
-  }
-
-  @Test
-  public void testExportLogs() throws IOException {
-    Date startDate = new Date(System.currentTimeMillis() - 2 * 60 * 1000);
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd");
-    String start = sf.format(startDate);
-
-    Date enddate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000);
-    String end = sf.format(enddate);
-    String dir = getCurrentTimeString();
-
-    setupForExportLogs();
-    String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL);
-
-    MiscellaneousCommands misc = new MiscellaneousCommands();
-    getCache();
-
-    Result cmdResult = misc.exportLogsPreprocessing("./testExportLogs" + dir, null, null, logLevel,
-        false, false, start, end, 1);
-
-    getLogWriter().info("testExportLogs command result =" + cmdResult);
-
-    if (cmdResult != null) {
-      String cmdStringRsult = commandResultToString((CommandResult) cmdResult);
-      getLogWriter().info("testExportLogs cmdStringRsult=" + cmdStringRsult);
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-    } else {
-      fail("testExportLogs failed as did not get CommandResult");
-    }
-    FileUtils.deleteDirectory(new File("./testExportLogs" + dir));
-  }
-
-  @Category(FlakyTest.class) // GEODE-1477 (http)
-  @Test
-  public void testExportLogsForMerge() throws IOException {
-    setupForExportLogs();
-    Date startDate = new Date(System.currentTimeMillis() - 2 * 60 * 1000);
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd");
-    String start = sf.format(startDate);
-
-    Date enddate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000);
-    String end = sf.format(enddate);
-    String dir = getCurrentTimeString();
-
-    String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL);
-
-    MiscellaneousCommands misc = new MiscellaneousCommands();
-    getCache();
-
-    Result cmdResult = misc.exportLogsPreprocessing("./testExportLogsForMerge" + dir, null, null,
-        logLevel, false, true, start, end, 1);
-    getLogWriter().info("testExportLogsForMerge command=" + cmdResult);
-
-    if (cmdResult != null) {
-      String cmdStringRsult = commandResultToString((CommandResult) cmdResult);
-      getLogWriter().info("testExportLogsForMerge cmdStringRsult=" + cmdStringRsult);
-
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-    } else {
-      fail("testExportLogsForMerge failed as did not get CommandResult");
-    }
-    FileUtils.deleteDirectory(new File("./testExportLogsForMerge" + dir));
-  }
-}


[09/50] [abbrv] geode git commit: GEODE-2416: Collect together artifacts from individual servers into a single zip file

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart2DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart2DUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart2DUnitTest.java
deleted file mode 100644
index 2b2e524..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart2DUnitTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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.management.internal.cli.commands;
-
-import static org.apache.geode.test.dunit.Assert.assertEquals;
-import static org.apache.geode.test.dunit.Assert.fail;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.internal.logging.LogWriterImpl;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.SerializableRunnable;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Dunit class for testing gemfire function commands : export logs
- */
-@Category(DistributedTest.class)
-public class MiscellaneousCommandsExportLogsPart2DUnitTest extends CliCommandTestBase {
-
-  private static final long serialVersionUID = 1L;
-
-  void setupForExportLogs() {
-    final VM vm1 = Host.getHost(0).getVM(1);
-    setUpJmxManagerOnVm0ThenConnect(null);
-
-    vm1.invoke(new SerializableRunnable() {
-      public void run() {
-        // no need to close cache as it will be closed as part of teardown2
-        Cache cache = getCache();
-
-        RegionFactory<Integer, Integer> dataRegionFactory =
-            cache.createRegionFactory(RegionShortcut.PARTITION);
-        Region region = dataRegionFactory.create("testRegion");
-        for (int i = 0; i < 5; i++) {
-          region.put("key" + (i + 200), "value" + (i + 200));
-        }
-      }
-    });
-  }
-
-  String getCurrentTimeString() {
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_SSS_z");
-    Date startDate = new Date(System.currentTimeMillis());
-    String formattedStartDate = sf.format(startDate);
-    return ("_" + formattedStartDate);
-  }
-
-  @Test
-  public void testExportLogsForLogLevel() throws IOException {
-    setupForExportLogs();
-
-    Date startDate = new Date(System.currentTimeMillis() - 60 * 1000);
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd");
-    String start = sf.format(startDate);
-
-    Date enddate = new Date(System.currentTimeMillis() + 60 * 1000);
-    String end = sf.format(enddate);
-    String dir = getCurrentTimeString();
-
-    String logLevel = LogWriterImpl.levelToString(LogWriterImpl.CONFIG_LEVEL);
-
-    MiscellaneousCommands misc = new MiscellaneousCommands();
-    getCache();
-
-    Result cmdResult = misc.exportLogsPreprocessing("./testExportLogsForLogLevel" + dir, null, null,
-        logLevel, false, false, start, end, 1);
-
-    getLogWriter().info("testExportLogsForLogLevel command=" + cmdResult);
-
-    if (cmdResult != null) {
-      String cmdStringRsult = commandResultToString((CommandResult) cmdResult);
-      getLogWriter().info("testExportLogsForLogLevel cmdStringRsult=" + cmdStringRsult);
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-    } else {
-      fail("testExportLogsForLogLevel failed as did not get CommandResult");
-    }
-    FileUtils.deleteDirectory(new File("testExportLogsForLogLevel" + dir));
-  }
-
-  @Test
-  public void testExportLogsForLogLevelWithUPTOLOGLEVEL() throws IOException {
-    setupForExportLogs();
-
-    Date startDate = new Date(System.currentTimeMillis() - 2 * 60 * 1000);
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd");
-    String start = sf.format(startDate);
-
-    Date enddate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000);
-    String end = sf.format(enddate);
-    String dir = getCurrentTimeString();
-
-    String logLevel = LogWriterImpl.levelToString(LogWriterImpl.SEVERE_LEVEL);
-
-    MiscellaneousCommands misc = new MiscellaneousCommands();
-    getCache();
-
-    Result cmdResult =
-        misc.exportLogsPreprocessing("./testExportLogsForLogLevelWithUPTOLOGLEVEL" + dir, null,
-            null, logLevel, true, false, start, end, 1);
-
-    getLogWriter().info("testExportLogsForLogLevelWithUPTOLOGLEVEL command=" + cmdResult);
-
-    if (cmdResult != null) {
-      String cmdStringRsult = commandResultToString((CommandResult) cmdResult);
-      getLogWriter()
-          .info("testExportLogsForLogLevelWithUPTOLOGLEVEL cmdStringRsult=" + cmdStringRsult);
-
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-    } else {
-      fail("testExportLogsForLogLevelWithUPTOLOGLEVEL failed as did not get CommandResult");
-    }
-    FileUtils.deleteDirectory(new File("testExportLogsForLogLevelWithUPTOLOGLEVEL" + dir));
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart3DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart3DUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart3DUnitTest.java
deleted file mode 100644
index efef2c4..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart3DUnitTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * 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.management.internal.cli.commands;
-
-import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static org.apache.geode.test.dunit.Assert.assertEquals;
-import static org.apache.geode.test.dunit.Assert.fail;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.internal.logging.LogWriterImpl;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.SerializableRunnable;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Properties;
-
-/**
- * Dunit class for testing gemfire function commands : export logs
- */
-@Category(DistributedTest.class)
-public class MiscellaneousCommandsExportLogsPart3DUnitTest extends CliCommandTestBase {
-
-  private static final long serialVersionUID = 1L;
-
-  public String getMemberId() {
-    Cache cache = getCache();
-    return cache.getDistributedSystem().getDistributedMember().getId();
-  }
-
-  void setupForExportLogs() {
-    final VM vm1 = Host.getHost(0).getVM(1);
-    setUpJmxManagerOnVm0ThenConnect(null);
-
-    vm1.invoke(new SerializableRunnable() {
-      public void run() {
-        // no need to close cache as it will be closed as part of teardown2
-        Cache cache = getCache();
-
-        RegionFactory<Integer, Integer> dataRegionFactory =
-            cache.createRegionFactory(RegionShortcut.PARTITION);
-        Region region = dataRegionFactory.create("testRegion");
-        for (int i = 0; i < 5; i++) {
-          region.put("key" + (i + 200), "value" + (i + 200));
-        }
-      }
-    });
-  }
-
-  String getCurrentTimeString() {
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_SSS_z");
-    Date startDate = new Date(System.currentTimeMillis());
-    String formattedStartDate = sf.format(startDate);
-    return ("_" + formattedStartDate);
-  }
-
-  @Category(FlakyTest.class) // GEODE-672: random ports, java.rmi.server.ExportException: Port
-                             // already in use, HeadlessGfsh, disk IO
-  @Test
-  public void testExportLogsForGroup() throws IOException {
-    Properties localProps = new Properties();
-    localProps.setProperty(NAME, "Manager");
-    localProps.setProperty(GROUPS, "Group1");
-    setUpJmxManagerOnVm0ThenConnect(localProps);
-    String dir = getCurrentTimeString();
-
-    Date startDate = new Date(System.currentTimeMillis() - 2 * 60 * 1000);
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd");
-    String start = sf.format(startDate);
-
-    Date enddate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000);
-    String end = sf.format(enddate);
-
-    String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL);
-
-    MiscellaneousCommands misc = new MiscellaneousCommands();
-    getCache();
-    String[] groups = new String[1];
-    groups[0] = "Group1";
-
-    Result cmdResult = misc.exportLogsPreprocessing("./testExportLogsForGroup" + dir, groups, null,
-        logLevel, false, false, start, end, 1);
-
-    getLogWriter().info("testExportLogsForGroup command result =" + cmdResult);
-    if (cmdResult != null) {
-      String cmdStringRsult = commandResultToString((CommandResult) cmdResult);
-      getLogWriter().info("testExportLogsForGroup cmdStringRsult=" + cmdStringRsult);
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-    } else {
-      fail("testExportLogsForGroup failed as did not get CommandResult");
-    }
-    FileUtils.deleteQuietly(new File("testExportLogsForGroup" + dir));
-  }
-
-  @Test
-  public void testExportLogsForMember() throws IOException {
-    setUpJmxManagerOnVm0ThenConnect(null);
-
-    Date startDate = new Date(System.currentTimeMillis() - 2 * 60 * 1000);
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd");
-    String start = sf.format(startDate);
-
-    Date enddate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000);
-    String end = sf.format(enddate);
-
-    final VM vm1 = Host.getHost(0).getVM(1);
-    final String vm1MemberId = (String) vm1.invoke(() -> getMemberId());
-    String dir = getCurrentTimeString();
-
-    String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL);
-
-    MiscellaneousCommands misc = new MiscellaneousCommands();
-    getCache();
-
-    Result cmdResult = misc.exportLogsPreprocessing("./testExportLogsForMember" + dir, null,
-        vm1MemberId, logLevel, false, false, start, end, 1);
-
-    getLogWriter().info("testExportLogsForMember command result =" + cmdResult);
-
-    if (cmdResult != null) {
-      String cmdStringRsult = commandResultToString((CommandResult) cmdResult);
-      getLogWriter().info("testExportLogsForMember cmdStringRsult=" + cmdStringRsult);
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-    } else {
-      fail("testExportLogsForMember failed as did not get CommandResult");
-    }
-    FileUtils.deleteQuietly(new File("testExportLogsForMember" + dir));
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart4DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart4DUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart4DUnitTest.java
deleted file mode 100644
index 9d64bd9..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart4DUnitTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.management.internal.cli.commands;
-
-import static org.apache.geode.test.dunit.Assert.assertEquals;
-import static org.apache.geode.test.dunit.Assert.fail;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.internal.logging.LogWriterImpl;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.SerializableRunnable;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Dunit class for testing gemfire function commands : export logs
- */
-@Category(DistributedTest.class)
-public class MiscellaneousCommandsExportLogsPart4DUnitTest extends CliCommandTestBase {
-
-  private static final long serialVersionUID = 1L;
-
-  void setupForExportLogs() {
-    final VM vm1 = Host.getHost(0).getVM(1);
-    setUpJmxManagerOnVm0ThenConnect(null);
-
-    vm1.invoke(new SerializableRunnable() {
-      public void run() {
-        // no need to close cache as it will be closed as part of teardown2
-        Cache cache = getCache();
-
-        RegionFactory<Integer, Integer> dataRegionFactory =
-            cache.createRegionFactory(RegionShortcut.PARTITION);
-        Region region = dataRegionFactory.create("testRegion");
-        for (int i = 0; i < 5; i++) {
-          region.put("key" + (i + 200), "value" + (i + 200));
-        }
-      }
-    });
-  }
-
-  String getCurrentTimeString() {
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_SSS_z");
-    Date startDate = new Date(System.currentTimeMillis());
-    String formattedStartDate = sf.format(startDate);
-    return ("_" + formattedStartDate);
-  }
-
-  @Test
-  public void testExportLogsForTimeRange1() throws IOException {
-    setupForExportLogs();
-    Date startDate = new Date(System.currentTimeMillis() - 1 * 60 * 1000);
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd");
-    String start = sf.format(startDate);
-
-    Date enddate = new Date(System.currentTimeMillis() + 1 * 60 * 60 * 1000);
-    String end = sf.format(enddate);
-    String dir = getCurrentTimeString();
-
-    String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL);
-
-    MiscellaneousCommands misc = new MiscellaneousCommands();
-    getCache();
-
-    Result cmdResult = misc.exportLogsPreprocessing("./testExportLogsForTimeRange1" + dir, null,
-        null, logLevel, false, false, start, end, 1);
-
-    getLogWriter().info("testExportLogsForTimeRange1 command result =" + cmdResult);
-
-    if (cmdResult != null) {
-      String cmdStringRsult = commandResultToString((CommandResult) cmdResult);
-      getLogWriter().info("testExportLogsForTimeRange1 cmdStringRsult=" + cmdStringRsult);
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-    } else {
-      fail("testExportLogsForTimeRange1 failed as did not get CommandResult");
-    }
-    FileUtils.deleteQuietly(new File("testExportLogsForTimeRange1" + dir));
-  }
-
-  @Category(FlakyTest.class) // GEODE-1500 (http)
-  @Test
-  public void testExportLogsForTimeRangeForOnlyStartTime() throws IOException {
-    setupForExportLogs();
-    Date date = new Date();
-    date.setTime(System.currentTimeMillis() - 30 * 1000);
-    SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd/HH:mm");
-    String s = sf.format(date);
-    String dir = getCurrentTimeString();
-
-    String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL);
-
-    MiscellaneousCommands misc = new MiscellaneousCommands();
-    getCache();
-
-    Result cmdResult =
-        misc.exportLogsPreprocessing("./testExportLogsForTimeRangeForOnlyStartTime" + dir, null,
-            null, logLevel, false, false, s, null, 1);
-
-    getLogWriter().info("testExportLogsForTimeRangeForOnlyStartTime command result =" + cmdResult);
-
-    if (cmdResult != null) {
-      String cmdStringRsult = commandResultToString((CommandResult) cmdResult);
-      getLogWriter()
-          .info("testExportLogsForTimeRangeForOnlyStartTime cmdStringRsult=" + cmdStringRsult);
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-    } else {
-      fail("testExportLogsForTimeRangeForOnlyStartTime failed as did not get CommandResult");
-    }
-    FileUtils.deleteQuietly(new File("testExportLogsForTimeRangeForOnlyStartTime" + dir));
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
new file mode 100644
index 0000000..abae1de
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
@@ -0,0 +1,143 @@
+/*
+ * 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.management.internal.cli.functions;
+
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.ResultSender;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.execute.FunctionContextImpl;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+import java.io.IOException;
+
+@Category(IntegrationTest.class)
+public class ExportLogsFunctionIntegrationTest {
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @Rule
+  public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
+  @Rule
+  public ServerStarterRule serverStarterRule = new ServerStarterRule();
+
+  private File serverWorkingDir;
+
+  @Before
+  public void setup() throws Exception {
+    serverWorkingDir = temporaryFolder.newFolder("serverWorkingDir");
+    System.setProperty("user.dir", serverWorkingDir.getCanonicalPath());
+
+    serverStarterRule.startServer();
+  }
+
+  @After
+  public void teardown() {
+    serverStarterRule.after();
+  }
+
+  @Test
+  public void exportLogsFunctionDoesNotBlowUp() throws Throwable {
+    File logFile1 = new File(serverWorkingDir, "server1.log");
+    FileUtils.writeStringToFile(logFile1, "some log for server1 \n some other log line");
+    File logFile2 = new File(serverWorkingDir, "server2.log");
+    FileUtils.writeStringToFile(logFile2, "some log for server2 \n some other log line");
+
+    File notALogFile = new File(serverWorkingDir, "foo.txt");
+    FileUtils.writeStringToFile(notALogFile, "some text");
+
+    ExportLogsFunction.Args args = new ExportLogsFunction.Args(null, null, "info", false);
+
+    CapturingResultSender resultSender = new CapturingResultSender();
+    FunctionContext context = new FunctionContextImpl("functionId", args, resultSender);
+
+    new ExportLogsFunction().execute(context);
+
+    if (resultSender.getThrowable() != null) {
+      throw resultSender.getThrowable();
+    }
+
+    Cache cache = GemFireCacheImpl.getInstance();
+    assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
+  }
+
+  @Test
+  public void createOrGetExistingExportLogsRegionDoesNotBlowUp() throws Exception {
+    ExportLogsFunction.createOrGetExistingExportLogsRegion(false);
+
+    Cache cache = GemFireCacheImpl.getInstance();
+    assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
+  }
+
+  @Test
+  public void destroyExportLogsRegionWorksAsExpectedForInitiatingMember() throws IOException, ClassNotFoundException {
+    ExportLogsFunction.createOrGetExistingExportLogsRegion(true);
+    Cache cache = GemFireCacheImpl.getInstance();
+    assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
+
+    ExportLogsFunction.destroyExportLogsRegion();
+    assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
+  }
+
+
+  @Test
+  public void argsCorrectlyBuildALogLevelFilter() {
+    ExportLogsFunction.Args args = new ExportLogsFunction.Args(null, null, "info", false);
+
+    assertThat(args.getPermittedLogLevels()).contains("info");
+    assertThat(args.getPermittedLogLevels()).contains("error");
+    assertThat(args.getPermittedLogLevels()).doesNotContain("fine");
+  }
+
+  private static class CapturingResultSender implements ResultSender {
+    private Throwable t;
+
+    public Throwable getThrowable() {
+      return t;
+    }
+
+    @Override
+    public void sendResult(Object oneResult) {
+
+    }
+
+    @Override
+    public void lastResult(Object lastResult) {
+
+    }
+
+    @Override
+    public void sendException(Throwable t) {
+      this.t = t;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java
new file mode 100644
index 0000000..bd8a6ac
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.management.internal.cli.util;
+
+import static java.util.stream.Collectors.toList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.text.ParseException;
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Stream;
+
+@Category(IntegrationTest.class)
+public class LogExporterTest {
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  private LogExporter logExporter;
+
+  @Before
+  public void setup() throws ParseException {
+    LogFilter logFilter = mock(LogFilter.class);
+
+    when(logFilter.acceptsFile(any())).thenReturn(true);
+    when(logFilter.acceptsLine(any())).thenReturn(LogFilter.LineFilterResult.LINE_ACCEPTED);
+
+    logExporter = new LogExporter(logFilter);
+  }
+
+
+  @Test
+  public void exportBuildsZipCorrectlyWithTwoLogFiles() throws Exception {
+    File serverWorkingDir = temporaryFolder.newFolder("serverWorkingDir");
+    File logFile1 = new File(serverWorkingDir, "server1.log");
+    FileUtils.writeStringToFile(logFile1, "some log for server1 \n some other log line");
+    File logFile2 = new File(serverWorkingDir, "server2.log");
+    FileUtils.writeStringToFile(logFile2, "some log for server2 \n some other log line");
+
+    File notALogFile = new File(serverWorkingDir, "foo.txt");
+    FileUtils.writeStringToFile(notALogFile, "some text");
+
+
+    Path zippedExport = logExporter.export(serverWorkingDir.toPath());
+
+    File unzippedExportDir = temporaryFolder.newFolder("unzippedExport");
+    ZipUtils.unzip(zippedExport.toString(), unzippedExportDir.getCanonicalPath());
+
+    assertThat(unzippedExportDir.listFiles()).hasSize(2);
+    List<File> exportedFiles = Stream.of(unzippedExportDir.listFiles())
+        .sorted(Comparator.comparing(File::getName)).collect(toList());
+
+    assertThat(exportedFiles.get(0)).hasSameContentAs(logFile1);
+    assertThat(exportedFiles.get(1)).hasSameContentAs(logFile2);
+  }
+
+  @Test
+  public void findLogFilesExcludesFilesWithIncorrectExtension() throws Exception {
+    File workingDir = temporaryFolder.newFolder("workingDir");
+    File logFile = new File(workingDir, "server.log");
+
+    FileUtils.writeStringToFile(logFile, "some log line");
+
+    File notALogFile = new File(workingDir, "foo.txt");
+    FileUtils.writeStringToFile(notALogFile, "some text");
+
+    assertThat(logExporter.findLogFiles(workingDir.toPath())).contains(logFile.toPath());
+    assertThat(logExporter.findLogFiles(workingDir.toPath())).doesNotContain(notALogFile.toPath());
+  }
+
+  @Test
+  public void findStatFiles() throws Exception {
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java
new file mode 100644
index 0000000..ca94fb6
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.management.internal.cli.util;
+
+import static java.util.stream.Collectors.toSet;
+import static org.apache.geode.management.internal.cli.util.LogFilter.LineFilterResult.LINE_ACCEPTED;
+import static org.apache.geode.management.internal.cli.util.LogFilter.LineFilterResult.LINE_REJECTED;
+import static org.apache.geode.management.internal.cli.util.LogFilter.LineFilterResult.REMAINDER_OF_FILE_REJECTED;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.time.LocalDateTime;
+import java.util.Set;
+import java.util.stream.Stream;
+
+@Category(UnitTest.class)
+public class LogFilterTest {
+  @Test
+  public void permittedLogLevelsCanFilterLines() throws Exception {
+    Set<String> permittedLogLevels = Stream.of("info", "finest").collect(toSet());
+
+    LogFilter logFilter = new LogFilter(permittedLogLevels, null, null);
+
+    LocalDateTime now = LocalDateTime.now();
+    assertThat(logFilter.acceptsLogEntry("info", now)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry("finest", now)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry("fine", now)).isEqualTo(LINE_REJECTED);
+    assertThat(logFilter.acceptsLogEntry("error", now)).isEqualTo(LINE_REJECTED);
+  }
+
+
+  @Test
+  public void startDateCanFilterLines() {
+    LocalDateTime startDate = LocalDateTime.now().minusDays(2);
+
+    LogFilter logFilter = new LogFilter(null, startDate, null);
+
+    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now())).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry("info", startDate)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry("fine", startDate)).isEqualTo(LINE_ACCEPTED);
+
+    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(3)))
+        .isEqualTo(LINE_REJECTED);
+  }
+
+  @Test
+  public void endDateCanFilterLines() {
+    LocalDateTime endDate = LocalDateTime.now().minusDays(2);
+
+    LogFilter logFilter = new LogFilter(null, null, endDate);
+
+    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(3)))
+        .isEqualTo(LINE_ACCEPTED);
+
+    assertThat(logFilter.acceptsLogEntry("info", endDate)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry("fine", endDate)).isEqualTo(LINE_ACCEPTED);
+
+    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now()))
+        .isEqualTo(REMAINDER_OF_FILE_REJECTED);
+  }
+
+  @Test
+  public void filterWorksWithLevelBasedAndTimeBasedFiltering() {
+    LocalDateTime startDate = LocalDateTime.now().minusDays(5);
+    LocalDateTime endDate = LocalDateTime.now().minusDays(2);
+
+    Set<String> permittedLogLevels = Stream.of("info", "finest").collect(toSet());
+
+    LogFilter logFilter = new LogFilter(permittedLogLevels, startDate, endDate);
+
+
+    assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now().minusDays(6)))
+        .isEqualTo(LINE_REJECTED);
+    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(6)))
+        .isEqualTo(LINE_REJECTED);
+
+    assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_REJECTED);
+
+
+    assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now().minusDays(4)))
+        .isEqualTo(LINE_REJECTED);
+    assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_REJECTED);
+
+    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(4)))
+        .isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_ACCEPTED);
+
+
+
+    assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now().minusDays(1)))
+        .isEqualTo(REMAINDER_OF_FILE_REJECTED);
+    assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(REMAINDER_OF_FILE_REJECTED);
+
+    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(1)))
+        .isEqualTo(REMAINDER_OF_FILE_REJECTED);
+  }
+
+  @Test
+  public void firstLinesAreAcceptedIfParsableLineHasNotBeenSeenYet() {
+    LogFilter logFilter = new LogFilter(Stream.of("info").collect(toSet()), null, null);
+
+    assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_ACCEPTED);
+
+    assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now())).isEqualTo(LINE_REJECTED);
+    assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_REJECTED);
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java
new file mode 100644
index 0000000..320a3bc
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.management.internal.cli.util;
+
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.time.LocalDateTime;
+
+@Category(UnitTest.class)
+public class LogLevelExtractorTest {
+  @Test
+  public void extractWorksCorrectlyForLineFromLogFile() throws Exception {
+    String logLine =
+        "[info 2017/02/07 11:16:36.694 PST locator1 <locator request thread[1]> tid=0x27] Mapped \"{[/v1/async-event-queues],methods=[GET]}\" onto public java.lang.String";
+
+    LogLevelExtractor.Result result = LogLevelExtractor.extract(logLine);
+
+    assertThat(result).isNotNull();
+    assertThat(result.getLogLevel()).isEqualTo("info");
+
+    assertThat(result.getLogTimestamp().toString()).isEqualTo("2017-02-07T11:16:36.694");
+  }
+
+  @Test
+  public void extractReturnsNullIfNoTimestamp() throws Exception {
+    String logLine = "[info (this line is not a valid log statement since it has no timestamp)";
+
+    LogLevelExtractor.Result result = LogLevelExtractor.extract(logLine);
+
+    assertThat(result).isNull();
+  }
+
+  @Test
+  public void extractReturnsNullIfLineDoesNotMatchPattern() throws Exception {
+    String logLine = "some line containing a date like 2017/02/07 11:16:36.694 PST ";
+
+    LogLevelExtractor.Result result = LogLevelExtractor.extract(logLine);
+
+    assertThat(result).isNull();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java
new file mode 100644
index 0000000..7f4ffd4
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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.management.internal.cli.util;
+
+import static java.util.stream.Collectors.joining;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.test.dunit.rules.Locator;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.Properties;
+
+@Category(DistributedTest.class)
+public class MergeLogsTest {
+  @Rule
+  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+  private Locator locator;
+
+  private static final String MESSAGE_1 = "MergeLogsMessage1";
+  private static final String MESSAGE_2 = "MergeLogsMessage2";
+  private static final String MESSAGE_3 = "MergeLogsMessage3";
+  private static final String MESSAGE_4 = "MergeLogsMessage4";
+  private static final String MESSAGE_5 = "MergeLogsMessage5";
+  private static final String MESSAGE_6 = "MergeLogsMessage6";
+
+  @Before
+  public void setup() throws Exception {
+    Properties properties = new Properties();
+    properties.setProperty(DistributionConfig.LOG_LEVEL_NAME, "info");
+    locator = lsRule.startLocatorVM(0, properties);
+
+    properties
+        .setProperty(DistributionConfig.LOCATORS_NAME, "localhost[" + locator.getPort() + "]");
+
+    Server server = lsRule.startServerVM(1, properties);
+    Server server2 = lsRule.startServerVM(2, properties);
+
+    locator.invoke(() -> LogService.getLogger().info(MESSAGE_1));
+    server.invoke(() -> LogService.getLogger().info(MESSAGE_2));
+    server2.invoke(() -> LogService.getLogger().info(MESSAGE_3));
+
+    locator.invoke(() -> LogService.getLogger().info(MESSAGE_4));
+    server.invoke(() -> LogService.getLogger().info(MESSAGE_5));
+    server2.invoke(() -> LogService.getLogger().info(MESSAGE_6));
+  }
+
+  @Test
+  public void testExportInProcess() throws Exception {
+    assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempFolder().getRoot())).hasSize(3);
+
+    File result = MergeLogs.mergeLogFile(lsRule.getTempFolder().getRoot().getCanonicalPath());
+    assertOnLogContents(result);
+  }
+    @Test
+  public void testExportInNewProcess() throws Throwable {
+    assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempFolder().getRoot())).hasSize(3);
+
+    MergeLogs.mergeLogsInNewProcess(lsRule.getTempFolder().getRoot().toPath());
+      File result = Arrays.stream(lsRule.getTempFolder().getRoot().listFiles()).filter((File f) -> f.getName().startsWith("merge"))
+            .findFirst().orElseThrow(() -> {throw new AssertionError("No merged log file found");});
+    assertOnLogContents(result);
+
+  }
+
+  private void assertOnLogContents (File mergedLogFile) throws IOException {
+    String
+        mergedLines =
+        FileUtils.readLines(mergedLogFile, Charset.defaultCharset()).stream().collect(joining("\n"));
+
+    assertThat(mergedLines).contains(MESSAGE_1);
+    assertThat(mergedLines).contains(MESSAGE_2);
+    assertThat(mergedLines).contains(MESSAGE_3);
+    assertThat(mergedLines).contains(MESSAGE_4);
+    assertThat(mergedLines).contains(MESSAGE_5);
+    assertThat(mergedLines).contains(MESSAGE_6);
+
+    //Make sure that our merged log file contains the proper ordering
+    assertThat(mergedLines.indexOf(MESSAGE_1)).isLessThan(mergedLines.indexOf(MESSAGE_2));
+    assertThat(mergedLines.indexOf(MESSAGE_2)).isLessThan(mergedLines.indexOf(MESSAGE_3));
+    assertThat(mergedLines.indexOf(MESSAGE_3)).isLessThan(mergedLines.indexOf(MESSAGE_4));
+    assertThat(mergedLines.indexOf(MESSAGE_4)).isLessThan(mergedLines.indexOf(MESSAGE_5));
+    assertThat(mergedLines.indexOf(MESSAGE_5)).isLessThan(mergedLines.indexOf(MESSAGE_6));
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/configuration/EventTestCacheWriter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/EventTestCacheWriter.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/EventTestCacheWriter.java
new file mode 100644
index 0000000..27459c9
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/EventTestCacheWriter.java
@@ -0,0 +1,36 @@
+/*
+ * 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.management.internal.configuration;
+
+import org.apache.geode.cache.CacheWriter;
+import org.apache.geode.cache.CacheWriterException;
+import org.apache.geode.cache.EntryEvent;
+import org.apache.geode.cache.RegionEvent;
+import org.apache.geode.cache.util.CacheWriterAdapter;
+
+import java.io.Serializable;
+
+public class EventTestCacheWriter extends CacheWriterAdapter implements Serializable {
+  public static boolean hasResult = false;
+
+  @Override
+  public void beforeCreate(EntryEvent event) throws CacheWriterException {
+    System.out.println("key: " + event.getKey());
+    System.out.println("value: " + event.getNewValue());
+    hasResult = true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ZipUtilsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ZipUtilsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ZipUtilsJUnitTest.java
index 1791574..6f13f62 100755
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ZipUtilsJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ZipUtilsJUnitTest.java
@@ -17,6 +17,7 @@ package org.apache.geode.management.internal.configuration;
 import static org.junit.Assert.*;
 
 import java.io.File;
+import java.io.IOException;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
@@ -107,4 +108,19 @@ public class ZipUtilsJUnitTest {
     assertTrue(clusterText.equals(FileUtils.readFileToString(destinationClusterTextFile)));
     assertTrue(groupText.equals(FileUtils.readFileToString(destinationGroupTextFile)));
   }
+
+  @Test
+  public void zipUtilsCanCreateParentDirsIfNecessary() throws IOException {
+    File newFolder = new File(zipFolder, "newFolder");
+    assertFalse(newFolder.exists());
+
+    File zipFile = new File(newFolder, "target.zip");
+    assertFalse(zipFile.exists());
+    assertFalse(zipFile.isFile());
+
+    ZipUtils.zipDirectory(sourceFolder.getCanonicalPath(), zipFile.getCanonicalPath());
+    assertTrue(newFolder.exists());
+    assertTrue(zipFile.exists());
+    assertTrue(zipFile.isFile());
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index 4729be3..93572fe 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -164,6 +164,10 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
 
   public CommandResult executeAndVerifyCommand(String command) throws Exception {
     CommandResult result = executeCommand(command);
+
+    if (result.getStatus() != Result.Status.OK) {
+      System.out.println("broken");
+    }
     assertThat(result.getStatus()).describedAs(result.getContent().toString())
         .isEqualTo(Result.Status.OK);
     return result;

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
index 84c660c..2ec2088 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
@@ -114,6 +114,7 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
         }
       }
     }
+
     locator = (InternalLocator) Locator.startLocatorAndDS(0, null, properties);
     int locatorPort = locator.getPort();
     locator.resetInternalLocatorFileNamesWithCorrectPortNumber(locatorPort);

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
index 5f46da2..59215a3 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
@@ -26,7 +26,7 @@ import java.io.Serializable;
  * A server or locator inside a DUnit {@link VM}.
  */
 public abstract class Member implements Serializable {
-  private VM vm;
+  private transient VM vm;
   private int port;
   private File workingDir;
   private String name;

http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
index d4869c2..3f3358d 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
@@ -31,11 +31,7 @@ import org.apache.geode.test.junit.runner.SuiteRunner;
     GemfireDataCommandsDUnitTest.class,
     GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.class, IndexCommandsDUnitTest.class,
     ListAndDescribeDiskStoreCommandsDUnitTest.class, ListIndexCommandDUnitTest.class,
-    MemberCommandsDUnitTest.class, MiscellaneousCommandsDUnitTest.class,
-    MiscellaneousCommandsExportLogsPart1DUnitTest.class,
-    MiscellaneousCommandsExportLogsPart2DUnitTest.class,
-    MiscellaneousCommandsExportLogsPart3DUnitTest.class,
-    MiscellaneousCommandsExportLogsPart4DUnitTest.class, QueueCommandsDUnitTest.class,
+    MemberCommandsDUnitTest.class, MiscellaneousCommandsDUnitTest.class,QueueCommandsDUnitTest.class,
     ShellCommandsDUnitTest.class, ShowDeadlockDUnitTest.class, ShowMetricsDUnitTest.class,
     ShowStackTraceDUnitTest.class, UserCommandsDUnitTest.class})
 public class CommandOverHttpDUnitTest {


[27/50] [abbrv] geode git commit: GEODE-2267: Enhance server/locator startup rules

Posted by ds...@apache.org.
GEODE-2267: Enhance server/locator startup rules

* be able to return the rule itself so that we can start the server/locator at rule declaration time.
* rearrange the class structure
* do not delete the workingDir if the rule is created with a workingDir (then it's up for the caller to delete it)


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/aae5aa50
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/aae5aa50
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/aae5aa50

Branch: refs/heads/feature/GEODE-1969
Commit: aae5aa5002cc898a725711c5cebeadae3b4d65ff
Parents: b6cca5f
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Thu Mar 2 15:58:18 2017 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Tue Mar 7 15:03:25 2017 -0800

----------------------------------------------------------------------
 .../web/RestSecurityIntegrationTest.java        |  5 +-
 .../web/RestSecurityPostProcessorTest.java      |  5 +-
 .../geode/tools/pulse/PulseDataExportTest.java  |  6 +-
 .../ConnectToLocatorSSLDUnitTest.java           |  4 +-
 .../internal/cli/NetstatDUnitTest.java          |  4 +-
 .../cli/commands/ExportLogsDUnitTest.java       | 15 ++--
 .../ExportLogsOnServerManagerDUnit.java         |  7 +-
 .../cli/commands/ExportStatsDUnitTest.java      |  4 +-
 .../internal/cli/util/MergeLogsDUnitTest.java   |  9 +-
 .../internal/configuration/ClusterConfig.java   | 28 +++---
 .../ClusterConfigDeployJarDUnitTest.java        | 29 +++---
 .../ClusterConfigDistributionDUnitTest.java     |  9 +-
 .../ClusterConfigImportDUnitTest.java           | 45 +++++-----
 .../ClusterConfigStartMemberDUnitTest.java      | 19 ++--
 .../ClusterConfigWithSecurityDUnitTest.java     | 10 +--
 .../security/CacheServerStartupRule.java        |  6 +-
 .../security/GfshCommandsPostProcessorTest.java |  6 +-
 .../security/GfshCommandsSecurityTest.java      |  5 +-
 .../security/AbstractSecureServerDUnitTest.java |  8 +-
 .../ClusterConfigWithoutSecurityDUnitTest.java  |  2 +-
 .../SecurityClusterConfigDUnitTest.java         |  4 +-
 .../SecurityWithoutClusterConfigDUnitTest.java  |  2 +-
 .../security/StartServerAuthorizationTest.java  |  3 +-
 .../dunit/rules/GfshShellConnectionRule.java    |  4 +-
 .../apache/geode/test/dunit/rules/Locator.java  |  9 +-
 .../dunit/rules/LocatorServerStartupRule.java   | 34 ++++---
 .../test/dunit/rules/LocatorStarterRule.java    | 54 ++++-------
 .../apache/geode/test/dunit/rules/Member.java   | 53 ++---------
 .../test/dunit/rules/MemberStarterRule.java     | 84 +++++++++++++++++
 .../apache/geode/test/dunit/rules/MemberVM.java | 67 ++++++++++++++
 .../apache/geode/test/dunit/rules/Server.java   | 12 +--
 .../test/dunit/rules/ServerStarterRule.java     | 95 ++++++++++----------
 .../LuceneClusterConfigurationDUnitTest.java    | 51 ++++++-----
 33 files changed, 391 insertions(+), 307 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
index 75a3c2c..85fc5be 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
@@ -58,13 +58,12 @@ public class RestSecurityIntegrationTest {
   };
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
   private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
 
   @BeforeClass
   public static void before() throws Exception {
-    serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
+    serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
index 933f7b2..82e9b7f 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
@@ -65,14 +65,13 @@ public class RestSecurityPostProcessorTest {
   };
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
   private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
 
   @BeforeClass
   public static void before() throws Exception {
-    serverStarter.startServer(properties);
     Region region =
-        serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("customers");
+        serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("customers");
     region.put("1", new Customer(1L, "John", "Doe", "555555555"));
     region.put("2", new Customer(2L, "Richard", "Roe", "222533554"));
     region.put("3", new Customer(3L, "Jane", "Doe", "555223333"));

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
index fa98ce6..b9e90b6 100644
--- a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
@@ -23,8 +23,8 @@ import org.apache.geode.cache.client.ClientCacheFactory;
 import org.apache.geode.cache.client.ClientRegionShortcut;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.http.Consts;
@@ -64,8 +64,8 @@ public class PulseDataExportTest {
   @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
 
-  private Locator locator;
-  private org.apache.geode.test.dunit.rules.Server server;
+  private MemberVM locator;
+  private MemberVM server;
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
   private HttpClient httpClient;

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
index 101c8f5..1033b6c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
@@ -39,8 +39,8 @@ import static org.apache.geode.util.test.TestUtil.getResourcePath;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.security.SecurableCommunicationChannels;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
 import org.junit.After;
@@ -83,7 +83,7 @@ public class ConnectToLocatorSSLDUnitTest {
   }
 
   private void setUpLocatorAndConnect(Properties securityProps) throws Exception {
-    Locator locator = lsRule.startLocatorVM(0, securityProps);
+    MemberVM locator = lsRule.startLocatorVM(0, securityProps);
 
     // saving the securityProps to a file
     OutputStream out = new FileOutputStream(securityPropsFile);

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
index 8ac993b..5b2d302 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
@@ -18,7 +18,7 @@ package org.apache.geode.management.internal.cli;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.junit.After;
@@ -58,7 +58,7 @@ public class NetstatDUnitTest {
     // start server with jmx Manager as well
     properties.remove("start-locator");
     properties.setProperty("jmx-manager-port", ports[2] + "");
-    Server server = lsRule.startServerVM(1, properties);
+    MemberVM server = lsRule.startServerVM(1, properties);
 
     // start server with no jmx Manager
     properties.setProperty("jmx-manager", "false");

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
index e882cce..bf1d9ea 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
@@ -34,10 +34,9 @@ import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.Member;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.logging.log4j.Logger;
@@ -72,11 +71,11 @@ public class ExportLogsDUnitTest {
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
 
-  private Locator locator;
-  private Server server1;
-  private Server server2;
+  private MemberVM locator;
+  private MemberVM server1;
+  private MemberVM server2;
 
-  private Map<Member, List<LogLine>> expectedMessages;
+  private Map<MemberVM, List<LogLine>> expectedMessages;
 
   @Before
   public void setup() throws Exception {
@@ -95,7 +94,7 @@ public class ExportLogsDUnitTest {
     expectedMessages.put(server2, listOfLogLines(server2, "info", "error", "debug"));
 
     // log the messages in each of the members
-    for (Member member : expectedMessages.keySet()) {
+    for (MemberVM member : expectedMessages.keySet()) {
       List<LogLine> logLines = expectedMessages.get(member);
 
       member.invoke(() -> {
@@ -241,7 +240,7 @@ public class ExportLogsDUnitTest {
       throws IOException {
 
     String memberName = dirForMember.getName();
-    Member member = expectedMessages.keySet().stream()
+    MemberVM member = expectedMessages.keySet().stream()
         .filter((Member aMember) -> aMember.getName().equals(memberName)).findFirst().get();
 
     assertThat(member).isNotNull();

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
index 92ef5f5..c2fde4d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
@@ -22,6 +22,7 @@ import com.google.common.collect.Sets;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.dunit.rules.Server;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Rule;
@@ -46,7 +47,7 @@ public class ExportLogsOnServerManagerDUnit {
   @Test
   public void testExportWithOneServer() throws Exception {
     int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
-    Server server0 = lsRule.startServerAsJmxManager(0, jmxPort);
+    MemberVM server0 = lsRule.startServerAsJmxManager(0, jmxPort);
     gfshConnector.connect(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
     gfshConnector.executeAndVerifyCommand("export logs");
 
@@ -66,8 +67,8 @@ public class ExportLogsOnServerManagerDUnit {
     int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
     int locatorPort = ports[0];
     int jmxPort = ports[1];
-    Server server0 = lsRule.startServerAsEmbededLocator(0, locatorPort, jmxPort);
-    Server server1 = lsRule.startServerVM(1, locatorPort);
+    MemberVM server0 = lsRule.startServerAsEmbededLocator(0, locatorPort, jmxPort);
+    MemberVM server1 = lsRule.startServerVM(1, locatorPort);
     gfshConnector.connect(locatorPort, GfshShellConnectionRule.PortType.locator);
     gfshConnector.executeAndVerifyCommand("export logs");
 

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
index f1ba7ef..b7f8c2a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
@@ -28,8 +28,8 @@ import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
@@ -58,7 +58,7 @@ public class ExportStatsDUnitTest {
 
   protected static int jmxPort, httpPort;
   protected static Set<String> expectedZipEntries = new HashSet<>();
-  protected static Locator locator;
+  protected static MemberVM locator;
 
   @BeforeClass
   public static void beforeClass() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
index 80b9868..9166642 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
@@ -22,9 +22,8 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.commons.io.FileUtils;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -41,7 +40,7 @@ import java.util.Properties;
 public class MergeLogsDUnitTest {
   @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
-  private Locator locator;
+  private MemberVM locator;
 
   private static final String MESSAGE_1 = "MergeLogsMessage1";
   private static final String MESSAGE_2 = "MergeLogsMessage2";
@@ -59,8 +58,8 @@ public class MergeLogsDUnitTest {
     properties.setProperty(DistributionConfig.LOCATORS_NAME,
         "localhost[" + locator.getPort() + "]");
 
-    Server server = lsRule.startServerVM(1, properties);
-    Server server2 = lsRule.startServerVM(2, properties);
+    MemberVM server = lsRule.startServerVM(1, properties);
+    MemberVM server2 = lsRule.startServerVM(2, properties);
 
     locator.invoke(() -> LogService.getLogger().info(MESSAGE_1));
     server.invoke(() -> LogService.getLogger().info(MESSAGE_2));

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
index 4ac9886..c3d7f5e 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
@@ -21,8 +21,8 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.geode.cache.Cache;
-import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
+import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.internal.ClassPathLoader;
 import org.apache.geode.internal.JarClassLoader;
 import org.apache.geode.internal.JarDeployer;
@@ -31,7 +31,7 @@ import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.internal.configuration.domain.Configuration;
 import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Member;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.dunit.rules.Server;
 
 import java.io.File;
@@ -77,21 +77,21 @@ public class ClusterConfig implements Serializable {
     return Collections.unmodifiableList(groups);
   }
 
-  public void verify(Locator locator) {
-    verifyLocator(locator);
-  }
 
-  public void verify(Server server) throws ClassNotFoundException {
-    verifyServer(server);
+  public void verify(MemberVM memberVM) throws ClassNotFoundException {
+    if (memberVM.isLocator())
+      verifyLocator(memberVM);
+    else
+      verifyServer(memberVM);
   }
 
-  public void verifyLocator(Member locator) {
+  public void verifyLocator(MemberVM<Locator> locatorVM) {
     Set<String> expectedGroupConfigs =
         this.getGroups().stream().map(ConfigGroup::getName).collect(Collectors.toSet());
 
     // verify info exists in memeory
-    locator.invoke(() -> {
-      InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.locator;
+    locatorVM.invoke(() -> {
+      InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.getLocator();
       ClusterConfigurationService sc = internalLocator.getSharedConfiguration();
 
       // verify no extra configs exist in memory
@@ -120,7 +120,7 @@ public class ClusterConfig implements Serializable {
 
     });
 
-    File clusterConfigDir = new File(locator.getWorkingDir(), "/cluster_config");
+    File clusterConfigDir = new File(locatorVM.getWorkingDir(), "/cluster_config");
 
     for (ConfigGroup configGroup : this.getGroups()) {
       Set<String> actualFiles =
@@ -131,16 +131,16 @@ public class ClusterConfig implements Serializable {
     }
   }
 
-  public void verifyServer(Member server) throws ClassNotFoundException {
+  public void verifyServer(MemberVM<Server> serverVM) throws ClassNotFoundException {
     // verify files exist in filesystem
     Set<String> expectedJarNames = this.getJarNames().stream().map(ClusterConfig::getServerJarName)
         .collect(Collectors.toSet());
     Set<String> actualJarNames = toSetIgnoringHiddenFiles(
-        server.getWorkingDir().list((dir, filename) -> filename.contains(".jar")));
+        serverVM.getWorkingDir().list((dir, filename) -> filename.contains(".jar")));
     assertThat(actualJarNames).isEqualTo(expectedJarNames);
 
     // verify config exists in memory
-    server.invoke(() -> {
+    serverVM.invoke(() -> {
       Cache cache = GemFireCacheImpl.getInstance();
 
       // TODO: set compare to fail if there are extra regions

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
index 15e6ea6..7cc84d6 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
@@ -20,8 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -47,7 +46,7 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
   public void testDeployToNoServer() throws Exception {
     String clusterJarPath = clusterJar;
     // set up the locator/servers
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
 
     gfshConnector.connect(locator);
     assertThat(gfshConnector.isConnected()).isTrue();
@@ -59,18 +58,18 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
     expectedClusterConfig.verify(locator);
 
     // start a server and verify that the server gets the jar
-    Server server1 = lsRule.startServerVM(1, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, locator.getPort());
     expectedClusterConfig.verify(server1);
   }
 
   @Test
   public void testDeployToMultipleLocators() throws Exception {
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
     locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "]");
-    Locator locator2 = lsRule.startLocatorVM(1, locatorProps);
+    MemberVM locator2 = lsRule.startLocatorVM(1, locatorProps);
     locatorProps.setProperty(LOCATORS,
         "localhost[" + locator.getPort() + "],localhost[" + locator2.getPort() + "]");
-    Locator locator3 = lsRule.startLocatorVM(2, locatorProps);
+    MemberVM locator3 = lsRule.startLocatorVM(2, locatorProps);
 
     // has to start a server in order to run deploy command
     lsRule.startServerVM(3, serverProps, locator.getPort());
@@ -92,15 +91,15 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
   @Test
   public void testDeploy() throws Exception {
     // set up the locator/servers
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
     // server1 in no group
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
     // server2 in group1
     serverProps.setProperty(GROUPS, "group1");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
     // server3 in group1 and group2
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
 
     gfshConnector.connect(locator);
     assertThat(gfshConnector.isConnected()).isTrue();
@@ -138,13 +137,13 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
   @Test
   public void testUndeploy() throws Exception {
     // set up the locator/servers
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
     serverProps.setProperty(GROUPS, "group1");
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
     serverProps.setProperty(GROUPS, "group2");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
 
     ConfigGroup cluster = new ConfigGroup("cluster");
     ConfigGroup group1 = new ConfigGroup("group1");

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
index e134c42..abbc5c0 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
@@ -30,9 +30,8 @@ import org.apache.geode.internal.ClassBuilder;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -51,7 +50,7 @@ public class ClusterConfigDistributionDUnitTest {
   private static final String INDEX2 = "ID2";
   private static final String AsyncEventQueue1 = "Q1";
 
-  private Locator locator;
+  private MemberVM locator;
 
   @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
@@ -110,10 +109,10 @@ public class ClusterConfigDistributionDUnitTest {
     // Start a new member which receives the shared configuration
     // Verify the config creation on this member
 
-    Server server = lsRule.startServerVM(2, new Properties(), locator.getPort());
+    MemberVM server = lsRule.startServerVM(2, new Properties(), locator.getPort());
 
     server.invoke(() -> {
-      Cache cache = LocatorServerStartupRule.serverStarter.cache;
+      Cache cache = LocatorServerStartupRule.serverStarter.getCache();
       assertNotNull(cache);
       assertTrue(cache.getCopyOnRead());
 

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
index 72daf0d..696d22c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
@@ -25,9 +25,8 @@ import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -49,27 +48,27 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
 
   public static final ClusterConfig INITIAL_CONFIG = new ClusterConfig(new ConfigGroup("cluster"));
 
-  private Locator locator;
+  private MemberVM locatorVM;
 
   @Before
   public void before() throws Exception {
     super.before();
-    locator = lsRule.startLocatorVM(0, locatorProps);
-    INITIAL_CONFIG.verify(locator);
+    locatorVM = lsRule.startLocatorVM(0, locatorProps);
+    INITIAL_CONFIG.verify(locatorVM);
 
-    gfshConnector.connect(locator);
+    gfshConnector.connect(locatorVM);
     assertThat(gfshConnector.isConnected()).isTrue();
   }
 
   @Test
   public void testImportWithRunningServerWithRegion() throws Exception {
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
     // create another server as well
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locatorVM.getPort());
     String regionName = "regionA";
     server1.invoke(() -> {
       // this region will be created on both servers, but we should only be getting the name once.
-      Cache cache = LocatorServerStartupRule.serverStarter.cache;
+      Cache cache = LocatorServerStartupRule.serverStarter.getCache();
       cache.createRegionFactory(RegionShortcut.REPLICATE).create(regionName);
     });
 
@@ -82,10 +81,10 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
 
   @Test
   public void testImportWithRunningServer() throws Exception {
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
 
     serverProps.setProperty("groups", "group2");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locatorVM.getPort());
 
     // even though we have a region recreated, we can still import since there is no data
     // in the region
@@ -105,39 +104,39 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
         "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
     // Make sure that a backup of the old clusterConfig was created
-    assertThat(locator.getWorkingDir().listFiles())
+    assertThat(locatorVM.getWorkingDir().listFiles())
         .filteredOn((File file) -> file.getName().contains("cluster_config")).hasSize(2);
 
-    CONFIG_FROM_ZIP.verify(locator);
+    CONFIG_FROM_ZIP.verify(locatorVM);
 
     // start server1 with no group
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
     new ClusterConfig(CLUSTER).verify(server1);
 
     // start server2 in group1
     serverProps.setProperty(GROUPS, "group1");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locatorVM.getPort());
     new ClusterConfig(CLUSTER, GROUP1).verify(server2);
 
     // start server3 in group1 and group2
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM server3 = lsRule.startServerVM(3, serverProps, locatorVM.getPort());
     new ClusterConfig(CLUSTER, GROUP1, GROUP2).verify(server3);
   }
 
   @Test
   public void testImportWithMultipleLocators() throws Exception {
-    locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "]");
-    Locator locator1 = lsRule.startLocatorVM(1, locatorProps);
+    locatorProps.setProperty(LOCATORS, "localhost[" + locatorVM.getPort() + "]");
+    MemberVM locator1 = lsRule.startLocatorVM(1, locatorProps);
 
     locatorProps.setProperty(LOCATORS,
-        "localhost[" + locator.getPort() + "],localhost[" + locator1.getPort() + "]");
-    Locator locator2 = lsRule.startLocatorVM(2, locatorProps);
+        "localhost[" + locatorVM.getPort() + "],localhost[" + locator1.getPort() + "]");
+    MemberVM locator2 = lsRule.startLocatorVM(2, locatorProps);
 
     gfshConnector.executeAndVerifyCommand(
         "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
-    CONFIG_FROM_ZIP.verify(locator);
+    CONFIG_FROM_ZIP.verify(locatorVM);
     REPLICATED_CONFIG_FROM_ZIP.verify(locator1);
     REPLICATED_CONFIG_FROM_ZIP.verify(locator2);
   }
@@ -156,7 +155,7 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
   }
 
   public void testExportClusterConfig(String zipFilePath) throws Exception {
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
 
 
     gfshConnector.executeAndVerifyCommand("create region --name=myRegion --type=REPLICATE");
@@ -164,7 +163,7 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
     ConfigGroup cluster = new ConfigGroup("cluster").regions("myRegion");
     ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
     expectedClusterConfig.verify(server1);
-    expectedClusterConfig.verify(locator);
+    expectedClusterConfig.verify(locatorVM);
 
     gfshConnector
         .executeAndVerifyCommand("export cluster-configuration --zip-file-name=" + zipFilePath);

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
index c0d22bf..652ec60 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
@@ -23,8 +23,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOAD_CLUSTER_
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
-import org.apache.geode.test.dunit.rules.Locator;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Test;
@@ -35,7 +34,7 @@ import java.util.Properties;
 
 @Category(DistributedTest.class)
 public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
-  protected Locator locator;
+  protected MemberVM locator;
 
   @Before
   public void before() throws Exception {
@@ -46,7 +45,7 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
   @Test
   public void testStartLocator() throws Exception {
     locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "]");
-    Locator secondLocator = lsRule.startLocatorVM(1, locatorProps);
+    MemberVM secondLocator = lsRule.startLocatorVM(1, locatorProps);
 
     REPLICATED_CONFIG_FROM_ZIP.verify(secondLocator);
   }
@@ -57,15 +56,15 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
     ClusterConfig expectedGroup1Config = new ClusterConfig(CLUSTER, GROUP1);
     ClusterConfig expectedGroup2Config = new ClusterConfig(CLUSTER, GROUP2);
 
-    Server serverWithNoGroup = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM serverWithNoGroup = lsRule.startServerVM(1, serverProps, locator.getPort());
     expectedNoGroupConfig.verify(serverWithNoGroup);
 
     serverProps.setProperty(GROUPS, "group1");
-    Server serverForGroup1 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM serverForGroup1 = lsRule.startServerVM(2, serverProps, locator.getPort());
     expectedGroup1Config.verify(serverForGroup1);
 
     serverProps.setProperty(GROUPS, "group2");
-    Server serverForGroup2 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM serverForGroup2 = lsRule.startServerVM(3, serverProps, locator.getPort());
     expectedGroup2Config.verify(serverForGroup2);
   }
 
@@ -74,12 +73,12 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
     ClusterConfig expectedGroup1And2Config = new ClusterConfig(CLUSTER, GROUP1, GROUP2);
 
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server = lsRule.startServerVM(1, serverProps, locator.getPort());
 
     expectedGroup1And2Config.verify(server);
   }
 
-  private Locator startLocatorWithLoadCCFromDir() throws Exception {
+  private MemberVM startLocatorWithLoadCCFromDir() throws Exception {
     File locatorDir = lsRule.getTempFolder().newFolder("locator-0");
     File configDir = new File(locatorDir, "cluster_config");
 
@@ -96,7 +95,7 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
     properties.setProperty(LOAD_CLUSTER_CONFIGURATION_FROM_DIR, "true");
     properties.setProperty(CLUSTER_CONFIGURATION_DIR, locatorDir.getCanonicalPath());
 
-    Locator locator = lsRule.startLocatorVM(0, properties);
+    MemberVM locator = lsRule.startLocatorVM(0, properties);
     CONFIG_FROM_ZIP.verify(locator);
 
     return locator;

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
index 4d67fb0..c551ca9 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
@@ -28,8 +28,8 @@ import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.security.SimpleTestSecurityManager;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
 import org.junit.Before;
@@ -51,7 +51,7 @@ public class ClusterConfigWithSecurityDUnitTest {
   @Rule
   public GfshShellConnectionRule connector = new GfshShellConnectionRule();
 
-  Locator locator0;
+  MemberVM locator0;
   Properties locatorProps;
 
   @Before
@@ -70,11 +70,11 @@ public class ClusterConfigWithSecurityDUnitTest {
     locatorProps.setProperty(LOCATORS, "localhost[" + locator0.getPort() + "]");
     locatorProps.setProperty("security-username", "cluster");
     locatorProps.setProperty("security-password", "cluster");
-    Locator locator1 = lsRule.startLocatorVM(1, locatorProps);
+    MemberVM locator1 = lsRule.startLocatorVM(1, locatorProps);
 
     // the second locator should inherit the first locator's security props
     locator1.invoke(() -> {
-      InternalLocator locator = LocatorServerStartupRule.locatorStarter.locator;
+      InternalLocator locator = LocatorServerStartupRule.locatorStarter.getLocator();
       ClusterConfigurationService sc = locator.getSharedConfiguration();
       Properties clusterConfigProps = sc.getConfiguration("cluster").getGemfireProperties();
       assertThat(clusterConfigProps.getProperty(SECURITY_MANAGER))
@@ -92,7 +92,7 @@ public class ClusterConfigWithSecurityDUnitTest {
         "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
     locator0.invoke(() -> {
-      InternalLocator locator = LocatorServerStartupRule.locatorStarter.locator;
+      InternalLocator locator = LocatorServerStartupRule.locatorStarter.getLocator();
       ClusterConfigurationService sc = locator.getSharedConfiguration();
       Properties properties = sc.getConfiguration("cluster").getGemfireProperties();
       assertThat(properties.getProperty(MCAST_PORT)).isEqualTo("0");

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
index 30e1df8..1107779 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
@@ -56,7 +56,7 @@ public class CacheServerStartupRule extends ExternalResource implements Serializ
   public void before() throws Throwable {
     serverStarter.before();
     serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory().create("region1");
+    serverStarter.getCache().createRegionFactory().create("region1");
   }
 
   @After
@@ -65,10 +65,10 @@ public class CacheServerStartupRule extends ExternalResource implements Serializ
   }
 
   public Cache getCache() {
-    return serverStarter.cache;
+    return serverStarter.getCache();
   }
 
   public int getServerPort() {
-    return serverStarter.server.getPort();
+    return serverStarter.getPort();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
index 6468195..62c0b85 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
@@ -53,15 +53,15 @@ public class GfshCommandsPostProcessorTest {
 
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
+
   @Rule
   public GfshShellConnectionRule gfshConnection =
       new GfshShellConnectionRule(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("region1");
+    serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("region1");
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
index ef8b7f1..45d437a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
@@ -78,12 +78,11 @@ public class GfshCommandsSecurityTest {
       new GfshShellConnectionRule(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("region1");
+    serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("region1");
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
index b6d1080..f8d90db 100644
--- a/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
@@ -53,7 +53,8 @@ public abstract class AbstractSecureServerDUnitTest extends JUnit4DistributedTes
   protected boolean pdxPersistent = false;
 
   @Rule
-  public transient ServerStarterRule serverStarter = new ServerStarterRule();
+  public transient ServerStarterRule serverStarter =
+      new ServerStarterRule().startServer(getProperties(), 0, pdxPersistent);
 
   // overwrite this in child classes
   public Properties getProperties() {
@@ -77,10 +78,9 @@ public abstract class AbstractSecureServerDUnitTest extends JUnit4DistributedTes
 
   @Before
   public void before() throws Exception {
-    serverStarter.startServer(getProperties(), 0, pdxPersistent);
-    serverPort = serverStarter.server.getPort();
+    serverPort = serverStarter.getServer().getPort();
     Region region =
-        serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
+        serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
     for (Entry entry : getData().entrySet()) {
       region.put(entry.getKey(), entry.getValue());
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
index 5d713f6..805d000 100644
--- a/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
@@ -72,7 +72,7 @@ public class ClusterConfigWithoutSecurityDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
 
     // after cache is created, the configuration won't chagne
     Properties secProps = ds.getSecurityProperties();

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
index 12c2da3..4f84f7b 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
@@ -75,7 +75,7 @@ public class SecurityClusterConfigDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
 
     // after cache is created, we got the security props passed in by cluster config
     Properties secProps = ds.getSecurityProperties();
@@ -96,7 +96,7 @@ public class SecurityClusterConfigDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
 
     // after cache is created, we got the security props passed in by cluster config
     Properties secProps = ds.getSecurityProperties();

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
index 092e82b..52a4ce4 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
@@ -73,7 +73,7 @@ public class SecurityWithoutClusterConfigDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
     assertEquals(3, ds.getSecurityProperties().size());
 
     // after cache is created, we got the security props passed in by cluster config

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java b/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
index f5cfff6..ef25ace 100644
--- a/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
@@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
@@ -36,7 +37,7 @@ public class StartServerAuthorizationTest {
 
   @ClassRule
   public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
-  private static Locator locator = null;
+  private static MemberVM<Locator> locator = null;
 
   @Rule
   public ServerStarterRule serverStarter = new ServerStarterRule();

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index f35e3e9..f367458 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -86,11 +86,11 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
 
   }
 
-  public void connect(Locator locator, String... options) throws Exception {
+  public void connect(MemberVM locator, String... options) throws Exception {
     connect(locator.getPort(), PortType.locator, options);
   }
 
-  public void connectAndVerify(Locator locator, String... options) throws Exception {
+  public void connectAndVerify(MemberVM locator, String... options) throws Exception {
     connect(locator.getPort(), PortType.locator, options);
     assertThat(this.connected).isTrue();
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
index b1004b9..59f1506 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
@@ -16,11 +16,8 @@
 
 package org.apache.geode.test.dunit.rules;
 
-import java.io.File;
+import org.apache.geode.distributed.internal.InternalLocator;
 
-public class Locator extends Member {
-
-  public Locator(int port, File workingDir, String name) {
-    super(port, workingDir, name);
-  }
+public interface Locator extends Member {
+  InternalLocator getLocator();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
index d5a4dfb..01e346a 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
@@ -55,7 +55,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
       new DistributedRestoreSystemProperties();
 
   private TemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
-  private Member[] members;
+  private MemberVM[] members;
 
   public LocatorServerStartupRule() {
     DUnitLauncher.launchIfNeeded();
@@ -66,7 +66,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     restoreSystemProperties.before();
     temporaryFolder.create();
     Invoke.invokeInEveryVM("Stop each VM", this::cleanupVm);
-    members = new Member[4];
+    members = new MemberVM[4];
   }
 
   @Override
@@ -77,7 +77,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     temporaryFolder.delete();
   }
 
-  public Locator startLocatorVM(int index) throws IOException {
+  public MemberVM startLocatorVM(int index) throws IOException {
     return startLocatorVM(index, new Properties());
   }
 
@@ -87,7 +87,8 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
    *
    * @return VM locator vm
    */
-  public Locator startLocatorVM(int index, Properties locatorProperties) throws IOException {
+  public MemberVM<Locator> startLocatorVM(int index, Properties locatorProperties)
+      throws IOException {
     String name = "locator-" + index;
     locatorProperties.setProperty(NAME, name);
     File workingDir = createWorkingDirForMember(name);
@@ -97,12 +98,11 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
       locatorStarter.before();
       return locatorStarter.startLocator(locatorProperties);
     });
-    locator.setVM(locatorVM);
-    members[index] = locator;
-    return locator;
+    members[index] = new MemberVM(locator, locatorVM);
+    return members[index];
   }
 
-  public Server startServerVM(int index) throws IOException {
+  public MemberVM startServerVM(int index) throws IOException {
     return startServerVM(index, new Properties(), -1);
   }
 
@@ -111,24 +111,21 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
    * 
    * @return VM node vm
    */
-  public Server startServerVM(int index, Properties properties) throws IOException {
+  public MemberVM startServerVM(int index, Properties properties) throws IOException {
     return startServerVM(index, properties, -1);
   }
 
-  /**
-   * start a server that connects to this locatorPort
-   */
-  public Server startServerVM(int index, int locatorPort) throws IOException {
+  public MemberVM startServerVM(int index, int locatorPort) throws IOException {
     return startServerVM(index, new Properties(), locatorPort);
   }
 
-  public Server startServerAsJmxManager(int index, int jmxManagerPort) throws IOException {
+  public MemberVM startServerAsJmxManager(int index, int jmxManagerPort) throws IOException {
     Properties properties = new Properties();
     properties.setProperty(JMX_MANAGER_PORT, jmxManagerPort + "");
     return startServerVM(index, properties);
   }
 
-  public Server startServerAsEmbededLocator(int index, int locatorPort, int jmxManagerPort)
+  public MemberVM startServerAsEmbededLocator(int index, int locatorPort, int jmxManagerPort)
       throws IOException {
     Properties properties = new Properties();
     properties.setProperty("start-locator", "localhost[" + locatorPort + "]");
@@ -141,7 +138,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
   /**
    * Starts a cache server that connect to the locator running at the given port.
    */
-  public Server startServerVM(int index, Properties properties, int locatorPort)
+  public MemberVM startServerVM(int index, Properties properties, int locatorPort)
       throws IOException {
 
     String name = "server-" + index;
@@ -154,9 +151,8 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
       serverStarter.before();
       return serverStarter.startServer(properties, locatorPort);
     });
-    server.setVM(serverVM);
-    members[index] = server;
-    return server;
+    members[index] = new MemberVM(server, serverVM);
+    return members[index];
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
index 2ec2088..5d6a0be 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
@@ -21,17 +21,14 @@ import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_S
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.distributed.Locator.startLocatorAndDS;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.commons.io.FileUtils;
-import org.apache.geode.distributed.Locator;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.awaitility.Awaitility;
-import org.junit.rules.ExternalResource;
 
 import java.io.File;
-import java.io.Serializable;
-import java.nio.file.Files;
+import java.io.IOException;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
@@ -47,12 +44,9 @@ import java.util.concurrent.TimeUnit;
  * use {@link LocatorServerStartupRule}.
  */
 
-public class LocatorStarterRule extends ExternalResource implements Serializable {
+public class LocatorStarterRule extends MemberStarterRule implements Locator {
 
-  public InternalLocator locator;
-
-  private File workingDir;
-  private String oldUserDir;
+  private transient InternalLocator locator;
 
   public LocatorStarterRule() {}
 
@@ -60,42 +54,29 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
     this.workingDir = workingDir.getAbsoluteFile();
   }
 
-  @Override
-  protected void before() throws Exception {
-    oldUserDir = System.getProperty("user.dir");
-    if (workingDir == null) {
-      workingDir = Files.createTempDirectory("locator").toAbsolutePath().toFile();
-    }
-    System.setProperty("user.dir", workingDir.toString());
+  public InternalLocator getLocator() {
+    return locator;
   }
 
   @Override
-  protected void after() {
+  protected void stopMember() {
     if (locator != null) {
       locator.stop();
     }
-    FileUtils.deleteQuietly(workingDir);
-    if (oldUserDir == null) {
-      System.clearProperty("user.dir");
-    } else {
-      System.setProperty("user.dir", oldUserDir);
-    }
   }
 
-
-  public org.apache.geode.test.dunit.rules.Locator startLocator() throws Exception {
+  public LocatorStarterRule startLocator() {
     return startLocator(new Properties());
   }
 
-  public org.apache.geode.test.dunit.rules.Locator startLocator(Properties properties)
-      throws Exception {
+  public LocatorStarterRule startLocator(Properties properties) {
     if (properties == null)
       properties = new Properties();
     if (!properties.containsKey(NAME)) {
       properties.setProperty(NAME, "locator");
     }
 
-    String name = properties.getProperty(NAME);
+    name = properties.getProperty(NAME);
     if (!properties.containsKey(LOG_FILE)) {
       properties.setProperty(LOG_FILE, new File(name + ".log").getAbsolutePath());
     }
@@ -104,7 +85,7 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
       properties.setProperty(MCAST_PORT, "0");
     }
     if (properties.containsKey(JMX_MANAGER_PORT)) {
-      int jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
+      jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
       if (jmxPort > 0) {
         if (!properties.containsKey(JMX_MANAGER)) {
           properties.put(JMX_MANAGER, "true");
@@ -114,15 +95,18 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
         }
       }
     }
-
-    locator = (InternalLocator) Locator.startLocatorAndDS(0, null, properties);
-    int locatorPort = locator.getPort();
-    locator.resetInternalLocatorFileNamesWithCorrectPortNumber(locatorPort);
+    try {
+      locator = (InternalLocator) startLocatorAndDS(0, null, properties);
+    } catch (IOException e) {
+      throw new RuntimeException("unable to start up locator.", e);
+    }
+    memberPort = locator.getPort();
+    locator.resetInternalLocatorFileNamesWithCorrectPortNumber(memberPort);
 
     if (locator.getConfig().getEnableClusterConfiguration()) {
       Awaitility.await().atMost(65, TimeUnit.SECONDS)
           .until(() -> assertTrue(locator.isSharedConfigurationRunning()));
     }
-    return new org.apache.geode.test.dunit.rules.Locator(locatorPort, workingDir, name);
+    return this;
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
index 59215a3..6165c84 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
@@ -11,62 +11,19 @@
  * 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.rules;
 
-import org.apache.geode.test.dunit.SerializableRunnableIF;
-import org.apache.geode.test.dunit.VM;
-
 import java.io.File;
 import java.io.Serializable;
 
-/**
- * A server or locator inside a DUnit {@link VM}.
- */
-public abstract class Member implements Serializable {
-  private transient VM vm;
-  private int port;
-  private File workingDir;
-  private String name;
-
-  public Member(int port, File workingDir, String name) {
-    this.vm = vm;
-    this.port = port;
-    this.workingDir = workingDir;
-    this.name = name;
-  }
-
-  /**
-   * The VM object is an RMI stub which lets us execute code in the JVM of this member.
-   * 
-   * @return the {@link VM}
-   */
-  public VM getVM() {
-    return vm;
-  }
-
-  public void setVM(VM vm) {
-    this.vm = vm;
-  }
-
-  public int getPort() {
-    return port;
-  }
+public interface Member extends Serializable {
+  File getWorkingDir();
 
-  public File getWorkingDir() {
-    return workingDir;
-  }
+  int getPort();
 
-  public String getName() {
-    return name;
-  }
+  int getJmxPort();
 
-  /**
-   * Invokes {@code runnable.run()} in the {@code VM} of this member.
-   */
-  public void invoke(final SerializableRunnableIF runnable) {
-    this.vm.invoke(runnable);
-  }
+  String getName();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
new file mode 100644
index 0000000..7591616
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
@@ -0,0 +1,84 @@
+/*
+ * 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.rules;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.test.dunit.VM;
+import org.junit.rules.ExternalResource;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+
+/**
+ * A server or locator inside a DUnit {@link VM}.
+ */
+public abstract class MemberStarterRule extends ExternalResource implements Member {
+  protected TemporaryFolder temporaryFolder;
+  protected String oldUserDir;
+
+  protected File workingDir;
+  protected int memberPort = -1;
+  protected int jmxPort = -1;
+  protected String name;
+
+  @Override
+  public void before() throws Exception {
+    oldUserDir = System.getProperty("user.dir");
+    if (workingDir == null) {
+      temporaryFolder = new TemporaryFolder();
+      temporaryFolder.create();
+      workingDir = temporaryFolder.newFolder("locator").getAbsoluteFile();
+    }
+    System.setProperty("user.dir", workingDir.toString());
+  }
+
+  @Override
+  public void after() {
+    stopMember();
+    FileUtils.deleteQuietly(workingDir);
+    if (oldUserDir == null) {
+      System.clearProperty("user.dir");
+    } else {
+      System.setProperty("user.dir", oldUserDir);
+    }
+    if (temporaryFolder != null) {
+      temporaryFolder.delete();
+    }
+  }
+
+  abstract void stopMember();
+
+  @Override
+  public File getWorkingDir() {
+    return workingDir;
+  }
+
+  @Override
+  public int getPort() {
+    return memberPort;
+  }
+
+  @Override
+  public int getJmxPort() {
+    return jmxPort;
+  }
+
+  @Override
+  public String getName() {
+    return name;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
new file mode 100644
index 0000000..988f5d4
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
@@ -0,0 +1,67 @@
+/*
+ * 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.rules;
+
+import org.apache.geode.test.dunit.SerializableRunnableIF;
+import org.apache.geode.test.dunit.VM;
+
+import java.io.File;
+
+public class MemberVM<T extends Member> implements Member {
+  private T member;
+  private VM vm;
+
+  public MemberVM(T member, VM vm) {
+    this.member = member;
+    this.vm = vm;
+  }
+
+  public boolean isLocator() {
+    return (member instanceof Locator);
+  }
+
+  public VM getVM() {
+    return vm;
+  }
+
+  public void invoke(final SerializableRunnableIF runnable) {
+    vm.invoke(runnable);
+  }
+
+  public T getMember() {
+    return member;
+  }
+
+  @Override
+  public File getWorkingDir() {
+    return member.getWorkingDir();
+  }
+
+  @Override
+  public int getPort() {
+    return member.getPort();
+  }
+
+  @Override
+  public int getJmxPort() {
+    return member.getJmxPort();
+  }
+
+  @Override
+  public String getName() {
+    return member.getName();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
index 83093c4..fb8630a 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
@@ -16,10 +16,12 @@
 
 package org.apache.geode.test.dunit.rules;
 
-import java.io.File;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.server.CacheServer;
+
+public interface Server extends Member {
+  Cache getCache();
+
+  CacheServer getServer();
 
-public class Server extends Member {
-  public Server(int port, File workingDir, String name) {
-    super(port, workingDir, name);
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
index df37579..0454340 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
@@ -23,16 +23,13 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.junit.rules.ExternalResource;
 
 import java.io.File;
-import java.io.Serializable;
-import java.nio.file.Files;
+import java.io.IOException;
 import java.util.Properties;
 
 
@@ -50,61 +47,79 @@ import java.util.Properties;
  * If you need a rule to start a server/locator in different VMs for Distributed tests, You should
  * use {@link LocatorServerStartupRule}.
  */
-public class ServerStarterRule extends ExternalResource implements Serializable {
+public class ServerStarterRule extends MemberStarterRule implements Server {
 
-  public Cache cache;
-  public CacheServer server;
-
-  private File workingDir;
-  private String oldUserDir;
+  private transient Cache cache;
+  private transient CacheServer server;
 
   /**
-   * Default constructor, if used, the rule won't start the server for you, you will need to
-   * manually start it. The rule will handle stop the server for you.
+   * Default constructor, if used, the rule will create a temporary folder as the server's working
+   * dir, and will delete it when the test is done.
    */
   public ServerStarterRule() {}
 
+  /**
+   * if constructed this way, the rule won't be deleting the workingDir after the test is done. It's
+   * up to the caller's responsibility to delete it.
+   * 
+   * @param workingDir: the working dir this server should be writing the artifacts to.
+   */
   public ServerStarterRule(File workingDir) {
     this.workingDir = workingDir;
   }
 
-  public void before() throws Exception {
-    oldUserDir = System.getProperty("user.dir");
-    if (workingDir == null) {
-      workingDir = Files.createTempDirectory("server").toAbsolutePath().toFile();
+  public Cache getCache() {
+    return cache;
+  }
+
+  public CacheServer getServer() {
+    return server;
+  }
+
+  @Override
+  void stopMember() {
+    // make sure this cache is the one currently open. A server cache can be recreated due to
+    // importing a new set of cluster configuration.
+    cache = GemFireCacheImpl.getInstance();
+    if (cache != null) {
+      cache.close();
+      cache = null;
+    }
+    if (server != null) {
+      server.stop();
+      server = null;
     }
-    System.setProperty("user.dir", workingDir.toString());
   }
 
-  public Server startServer() throws Exception {
+  public ServerStarterRule startServer() {
     return startServer(new Properties(), -1, false);
   }
 
-  public Server startServer(int locatorPort) throws Exception {
+  public ServerStarterRule startServer(int locatorPort) {
     return startServer(new Properties(), locatorPort, false);
   }
 
-  public Server startServer(int locatorPort, boolean pdxPersistent) throws Exception {
+  public ServerStarterRule startServer(int locatorPort, boolean pdxPersistent) {
     return startServer(new Properties(), locatorPort, pdxPersistent);
   }
 
-  public Server startServer(Properties properties) throws Exception {
+  public ServerStarterRule startServer(Properties properties) {
     return startServer(properties, -1, false);
   }
 
-  public Server startServer(Properties properties, int locatorPort) throws Exception {
+  public ServerStarterRule startServer(Properties properties, int locatorPort) {
     return startServer(properties, locatorPort, false);
   }
 
-  public Server startServer(Properties properties, int locatorPort, boolean pdxPersistent)
-      throws Exception {
+  public ServerStarterRule startServer(Properties properties, int locatorPort,
+      boolean pdxPersistent) {
     if (properties == null) {
       properties = new Properties();
     }
     if (!properties.containsKey(NAME)) {
       properties.setProperty(NAME, "server");
     }
-    String name = properties.getProperty(NAME);
+    name = properties.getProperty(NAME);
     if (!properties.containsKey(LOG_FILE)) {
       properties.setProperty(LOG_FILE, new File(name + ".log").getAbsolutePath().toString());
     }
@@ -120,7 +135,7 @@ public class ServerStarterRule extends ExternalResource implements Serializable
       properties.setProperty(LOCATORS, "");
     }
     if (properties.containsKey(JMX_MANAGER_PORT)) {
-      int jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
+      jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
       if (jmxPort > 0) {
         if (!properties.containsKey(JMX_MANAGER))
           properties.put(JMX_MANAGER, "true");
@@ -134,28 +149,12 @@ public class ServerStarterRule extends ExternalResource implements Serializable
     cache = cf.create();
     server = cache.addCacheServer();
     server.setPort(0);
-    server.start();
-    return new Server(server.getPort(), workingDir, name);
-  }
-
-  @Override
-  public void after() {
-    // make sure this cache is the one currently open. A server cache can be recreated due to
-    // importing a new set of cluster configuration.
-    cache = GemFireCacheImpl.getInstance();
-    if (cache != null) {
-      cache.close();
-      cache = null;
-    }
-    if (server != null) {
-      server.stop();
-      server = null;
-    }
-    FileUtils.deleteQuietly(workingDir);
-    if (oldUserDir == null) {
-      System.clearProperty("user.dir");
-    } else {
-      System.setProperty("user.dir", oldUserDir);
+    try {
+      server.start();
+    } catch (IOException e) {
+      throw new RuntimeException("unable to start server", e);
     }
+    memberPort = server.getPort();
+    return this;
   }
 }


[25/50] [abbrv] geode git commit: GEODE-2617: make LuceneResultStruct serializable

Posted by ds...@apache.org.
GEODE-2617: make LuceneResultStruct serializable


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/b6cca5ff
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/b6cca5ff
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/b6cca5ff

Branch: refs/heads/feature/GEODE-1969
Commit: b6cca5ffc28247e735bc9ad3f75f624b01186fd4
Parents: 5630d4b
Author: zhouxh <gz...@pivotal.io>
Authored: Tue Mar 7 14:02:09 2017 -0800
Committer: zhouxh <gz...@pivotal.io>
Committed: Tue Mar 7 14:30:28 2017 -0800

----------------------------------------------------------------------
 .../java/org/apache/geode/cache/lucene/LuceneResultStruct.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/b6cca5ff/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
index 4a6481f..5d2184e 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
@@ -14,6 +14,8 @@
  */
 package org.apache.geode.cache.lucene;
 
+import java.io.Serializable;
+
 import org.apache.geode.annotations.Experimental;
 
 /**
@@ -21,7 +23,7 @@ import org.apache.geode.annotations.Experimental;
  * 
  */
 @Experimental
-public interface LuceneResultStruct<K, V> {
+public interface LuceneResultStruct<K, V> extends Serializable {
 
   /**
    * @return The region key of the entry matching the query


[45/50] [abbrv] geode git commit: GEODE-2616: fix leak in colocated region removal

Posted by ds...@apache.org.
GEODE-2616: fix leak in colocated region removal

postDestroyRegion now removes itself from colocated parent colocatedByList


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/a0716a57
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/a0716a57
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/a0716a57

Branch: refs/heads/feature/GEODE-1969
Commit: a0716a57b19f330c991d8bc8d77a8b7b4352ed86
Parents: 4018543
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Fri Jan 20 16:05:41 2017 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed Mar 8 13:26:41 2017 -0800

----------------------------------------------------------------------
 .../cache/query/internal/DefaultQuery.java      |  4 +-
 .../geode/internal/cache/PartitionedRegion.java | 12 ++---
 .../internal/cache/ColocatedPRJUnitTest.java    | 47 ++++++++++++++++++++
 .../cache/PartitionedRegionTestHelper.java      | 11 ++++-
 4 files changed, 65 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/a0716a57/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQuery.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQuery.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQuery.java
index 8bfd4fa..a721091 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQuery.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQuery.java
@@ -650,8 +650,8 @@ public class DefaultQuery implements Query {
             continue;
           }
           other = allPRs;
-          if ((((PartitionedRegion) eachPR).colocatedByList.contains(allPRs)
-              || ((PartitionedRegion) allPRs).colocatedByList.contains(eachPR))) {
+          if ((((PartitionedRegion) eachPR).getColocatedByList().contains(allPRs)
+              || ((PartitionedRegion) allPRs).getColocatedByList().contains(eachPR))) {
             colocated = true;
             break;
           }

http://git-wip-us.apache.org/repos/asf/geode/blob/a0716a57/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
index 9374d4b..173f35c 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
@@ -600,7 +600,8 @@ public class PartitionedRegion extends LocalRegion
 
   private byte fixedPASet;
 
-  public List<PartitionedRegion> colocatedByList = new CopyOnWriteArrayList<PartitionedRegion>();
+  private final List<PartitionedRegion> colocatedByList =
+      new CopyOnWriteArrayList<PartitionedRegion>();
 
   private final PartitionListener[] partitionListeners;
 
@@ -670,9 +671,7 @@ public class PartitionedRegion extends LocalRegion
     this.colocatedWithRegion = ColocationHelper.getColocatedRegion(this);
 
     if (colocatedWithRegion != null) {
-      synchronized (colocatedWithRegion.colocatedByList) {
-        colocatedWithRegion.colocatedByList.add(this);
-      }
+      colocatedWithRegion.getColocatedByList().add(this);
     }
 
     if (colocatedWithRegion != null && !internalRegionArgs.isUsedForParallelGatewaySenderQueue()) {
@@ -786,7 +785,7 @@ public class PartitionedRegion extends LocalRegion
     return parallelGatewaySenderIds;
   }
 
-  List<PartitionedRegion> getColocatedByList() {
+  public List<PartitionedRegion> getColocatedByList() {
     return this.colocatedByList;
   }
 
@@ -7922,6 +7921,9 @@ public class PartitionedRegion extends LocalRegion
         }
       }
     }
+    if (colocatedWithRegion != null) {
+      colocatedWithRegion.getColocatedByList().remove(this);
+    }
 
     RegionLogger.logDestroy(getName(), cache.getMyId(), null, op.isClose());
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/a0716a57/geode-core/src/test/java/org/apache/geode/internal/cache/ColocatedPRJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ColocatedPRJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/ColocatedPRJUnitTest.java
new file mode 100644
index 0000000..66484d9
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ColocatedPRJUnitTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.internal.cache;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.PartitionAttributes;
+import org.apache.geode.cache.PartitionAttributesFactory;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class ColocatedPRJUnitTest {
+  @SuppressWarnings("rawtypes")
+  @Test
+  public void destroyColocatedPRCheckForLeak() {
+    PartitionedRegion parent =
+        (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("PARENT");
+    List<PartitionedRegion> colocatedList = parent.getColocatedByList();
+    assertEquals(0, colocatedList.size());
+    PartitionAttributes PRatts =
+        new PartitionAttributesFactory().setColocatedWith("/PARENT").create();
+    PartitionedRegion child =
+        (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("CHILD", PRatts);
+    assertTrue(colocatedList.contains(child));
+    child.destroyRegion();
+    assertFalse(colocatedList.contains(child));
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/a0716a57/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionTestHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionTestHelper.java b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionTestHelper.java
index 42c48ac..2824d74 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionTestHelper.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionTestHelper.java
@@ -49,9 +49,16 @@ public class PartitionedRegionTestHelper
    */
 
   public static Region createPartionedRegion(String regionname) throws RegionExistsException {
+    return createPartionedRegion(regionname, new PartitionAttributesFactory().create());
+  }
+
+  /**
+   * This method creates a partitioned region with the given PR attributes. The cache created is a
+   * loner, so this is only suitable for single VM tests.
+   */
+  public static Region createPartionedRegion(String regionname, PartitionAttributes prattribs)
+      throws RegionExistsException {
     AttributesFactory attribFactory = new AttributesFactory();
-    PartitionAttributesFactory paf = new PartitionAttributesFactory();
-    PartitionAttributes prattribs = paf.create();
     attribFactory.setDataPolicy(DataPolicy.PARTITION);
     attribFactory.setPartitionAttributes(prattribs);
     RegionAttributes regionAttribs = attribFactory.create();


[11/50] [abbrv] geode git commit: GEODE-2267: add validation to the arguments and include export stats in the command

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java
index 320a3bc..fd7d68b 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java
@@ -20,11 +20,10 @@ package org.apache.geode.management.internal.cli.util;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.logging.log4j.Level;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.time.LocalDateTime;
-
 @Category(UnitTest.class)
 public class LogLevelExtractorTest {
   @Test
@@ -35,12 +34,49 @@ public class LogLevelExtractorTest {
     LogLevelExtractor.Result result = LogLevelExtractor.extract(logLine);
 
     assertThat(result).isNotNull();
-    assertThat(result.getLogLevel()).isEqualTo("info");
+    assertThat(result.getLogLevel()).isEqualTo(Level.INFO);
 
     assertThat(result.getLogTimestamp().toString()).isEqualTo("2017-02-07T11:16:36.694");
   }
 
   @Test
+  public void extractWorksForFine() throws Exception {
+    String logLine =
+        "[fine 2017/02/07 11:16:36.694 PST locator1 <locator request thread[1]> tid=0x27] Mapped \"{[/v1/async-event-queues],methods=[GET]}\" onto public java.lang.String";
+
+    LogLevelExtractor.Result result = LogLevelExtractor.extract(logLine);
+
+    assertThat(result).isNotNull();
+    assertThat(result.getLogLevel()).isEqualTo(Level.DEBUG);
+
+    assertThat(result.getLogTimestamp().toString()).isEqualTo("2017-02-07T11:16:36.694");
+  }
+
+  @Test
+  public void extractWorksForFiner() throws Exception {
+    String logLine =
+        "[finer 2017/02/07 11:16:36.694 PST locator1 <locator request thread[1]> tid=0x27] Mapped \"{[/v1/async-event-queues],methods=[GET]}\" onto public java.lang.String";
+
+    LogLevelExtractor.Result result = LogLevelExtractor.extract(logLine);
+
+    assertThat(result).isNotNull();
+    assertThat(result.getLogLevel()).isEqualTo(Level.TRACE);
+    assertThat(result.getLogTimestamp().toString()).isEqualTo("2017-02-07T11:16:36.694");
+  }
+
+  @Test
+  public void extractWorksForFinest() throws Exception {
+    String logLine =
+        "[finest 2017/02/07 11:16:36.694 PST locator1 <locator request thread[1]> tid=0x27] Mapped \"{[/v1/async-event-queues],methods=[GET]}\" onto public java.lang.String";
+
+    LogLevelExtractor.Result result = LogLevelExtractor.extract(logLine);
+
+    assertThat(result).isNotNull();
+    assertThat(result.getLogLevel()).isEqualTo(Level.TRACE);
+    assertThat(result.getLogTimestamp().toString()).isEqualTo("2017-02-07T11:16:36.694");
+  }
+
+  @Test
   public void extractReturnsNullIfNoTimestamp() throws Exception {
     String logLine = "[info (this line is not a valid log statement since it has no timestamp)";
 
@@ -58,4 +94,24 @@ public class LogLevelExtractorTest {
     assertThat(result).isNull();
   }
 
+  @Test
+  public void testGetLevel() {
+    assertThat(LogLevelExtractor.getLevel("all")).isEqualTo(Level.ALL);
+    assertThat(LogLevelExtractor.getLevel("fatal")).isEqualTo(Level.FATAL);
+    assertThat(LogLevelExtractor.getLevel("severe")).isEqualTo(Level.FATAL);
+    assertThat(LogLevelExtractor.getLevel("error")).isEqualTo(Level.ERROR);
+    assertThat(LogLevelExtractor.getLevel("warn")).isEqualTo(Level.WARN);
+    assertThat(LogLevelExtractor.getLevel("warning")).isEqualTo(Level.WARN);
+    assertThat(LogLevelExtractor.getLevel("info")).isEqualTo(Level.INFO);
+    assertThat(LogLevelExtractor.getLevel("config")).isEqualTo(Level.DEBUG);
+    assertThat(LogLevelExtractor.getLevel("debug")).isEqualTo(Level.DEBUG);
+    assertThat(LogLevelExtractor.getLevel("fine")).isEqualTo(Level.DEBUG);
+    assertThat(LogLevelExtractor.getLevel("finer")).isEqualTo(Level.TRACE);
+    assertThat(LogLevelExtractor.getLevel("finest")).isEqualTo(Level.TRACE);
+    assertThat(LogLevelExtractor.getLevel("all")).isEqualTo(Level.ALL);
+    assertThat(LogLevelExtractor.getLevel("none")).isEqualTo(Level.OFF);
+    assertThat(LogLevelExtractor.getLevel("notrecognizable")).isEqualTo(Level.OFF);
+
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiUserDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiUserDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiUserDUnitTest.java
index 37e7f45..255048d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiUserDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiUserDUnitTest.java
@@ -14,19 +14,11 @@
  */
 package org.apache.geode.management.internal.security;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import org.awaitility.Awaitility;
-import org.apache.geode.security.TestSecurityManager;
-import org.json.JSONException;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.cli.Result.Status;
@@ -35,6 +27,7 @@ import org.apache.geode.management.internal.cli.commands.CliCommandTestBase;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.management.internal.cli.result.ErrorResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.security.TestSecurityManager;
 import org.apache.geode.test.dunit.AsyncInvocation;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.IgnoredException;
@@ -42,6 +35,15 @@ import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
+import org.awaitility.Awaitility;
+import org.json.JSONException;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
 
 @Category({DistributedTest.class, SecurityTest.class})
 public class MultiUserDUnitTest extends CliCommandTestBase {
@@ -49,6 +51,8 @@ public class MultiUserDUnitTest extends CliCommandTestBase {
   @Category(FlakyTest.class) // GEODE-1579
   @Test
   public void testMultiUser() throws IOException, JSONException, InterruptedException {
+    IgnoredException.addIgnoredException("java.util.zip.ZipException: zip file is empty");
+
     Properties properties = new Properties();
     properties.put(NAME, MultiUserDUnitTest.class.getSimpleName());
     properties.put(SECURITY_MANAGER, TestSecurityManager.class.getName());

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index dd0939e..f35e3e9 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -169,12 +169,16 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
   public CommandResult executeCommand(String command) throws Exception {
     gfsh.executeCommand(command);
     CommandResult result = (CommandResult) gfsh.getResult();
-    if (StringUtils.isBlank(gfsh.outputString)) {
-      // print out the message body as the command result
-      JSONArray messages = ((JSONArray) result.getContent().get("message"));
-      if (messages != null) {
-        for (int i = 0; i < messages.length(); i++) {
-          gfsh.outputString += messages.getString(i) + "\n";
+    if (StringUtils.isBlank(gfsh.outputString) && result != null && result.getContent() != null) {
+      if (result.getStatus() == Result.Status.ERROR) {
+        gfsh.outputString = result.toString();
+      } else {
+        // print out the message body as the command result
+        JSONArray messages = ((JSONArray) result.getContent().get("message"));
+        if (messages != null) {
+          for (int i = 0; i < messages.length(); i++) {
+            gfsh.outputString += messages.getString(i) + "\n";
+          }
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
index ad8c033..d5a4dfb 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
@@ -107,8 +107,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
   }
 
   /**
-   * starts a cache server that does not connect to a locator, unless the properties it passes in
-   * has "locators" property.
+   * starts a cache server that does not connect to a locator
    * 
    * @return VM node vm
    */
@@ -118,11 +117,6 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
 
   /**
    * start a server that connects to this locatorPort
-   *
-   * @param index
-   * @param locatorPort
-   * @return
-   * @throws IOException
    */
   public Server startServerVM(int index, int locatorPort) throws IOException {
     return startServerVM(index, new Properties(), locatorPort);
@@ -149,6 +143,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
    */
   public Server startServerVM(int index, Properties properties, int locatorPort)
       throws IOException {
+
     String name = "server-" + index;
     properties.setProperty(NAME, name);
 

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
index b1d6887..a11c7ad 100755
--- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
+++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
@@ -564,7 +564,7 @@ org/apache/geode/management/internal/cli/functions/DestroyIndexFunction,true,1
 org/apache/geode/management/internal/cli/functions/ExportConfigFunction,true,1
 org/apache/geode/management/internal/cli/functions/ExportDataFunction,true,1
 org/apache/geode/management/internal/cli/functions/ExportLogsFunction,true,1
-org/apache/geode/management/internal/cli/functions/ExportLogsFunction$Args,false,endTime:java/lang/String,logLevel:java/lang/String,logLevelOnly:boolean,startTime:java/lang/String
+org/apache/geode/management/internal/cli/functions/ExportLogsFunction$Args,false,endTime:java/time/LocalDateTime,includeLogs:boolean,includeStats:boolean,logLevel:org/apache/logging/log4j/Level,startTime:java/time/LocalDateTime,thisLogLevelOnly:boolean
 org/apache/geode/management/internal/cli/functions/FetchRegionAttributesFunction,true,4366812590788342070
 org/apache/geode/management/internal/cli/functions/FetchRegionAttributesFunction$FetchRegionAttributesFunctionResult,true,-3970828263897978845,cacheListenerClasses:java/lang/String[],cacheLoaderClass:java/lang/String,cacheWriterClass:java/lang/String,regionAttributes:org/apache/geode/cache/RegionAttributes
 org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction,true,1
@@ -620,7 +620,7 @@ org/apache/geode/management/internal/cli/shell/JMXInvocationException,true,-4265
 org/apache/geode/management/internal/cli/shell/jline/ANSIHandler$ANSIStyle,false
 org/apache/geode/management/internal/cli/util/DiskStoreNotFoundException,true,-5184836041554948093
 org/apache/geode/management/internal/cli/util/EvictionAttributesInfo,true,1,evictionAction:java/lang/String,evictionAlgorithm:java/lang/String,evictionMaxValue:int
-org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter,false,currentFile:java/nio/file/Path,currentOutputStream:java/io/BufferedOutputStream
+org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter,false,currentFile:java/nio/file/Path,currentOutputStream:java/io/BufferedOutputStream,isEmpty:boolean
 org/apache/geode/management/internal/cli/util/FixedPartitionAttributesInfo,false,isPrimary:boolean,numBuckets:int,partitionName:java/lang/String
 org/apache/geode/management/internal/cli/util/JConsoleNotFoundException,true,-1485615321440327206
 org/apache/geode/management/internal/cli/util/LogFilter$LineFilterResult,false

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties b/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
index 2c27654..8e21a3a 100644
--- a/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
+++ b/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
@@ -1470,7 +1470,7 @@ SYNOPSIS\n\
 SYNTAX\n\
 \ \ \ \ export logs [--dir=value] [--group=value(nullvalue)*] [--member=value(nullvalue)*]\n\
 \ \ \ \ [--log-level=value] [--only-log-level=value] [--merge-log=value] [--start-time=value]\n\
-\ \ \ \ [--end-time=value]\n\
+\ \ \ \ [--end-time=value] [--logs-only(=value)?] [--stats-only(=value)?]\n\
 PARAMETERS\n\
 \ \ \ \ dir\n\
 \ \ \ \ \ \ \ \ Local directory to which log files will be written. This is only used when you are\n\
@@ -1483,9 +1483,10 @@ PARAMETERS\n\
 \ \ \ \ \ \ \ \ Name/Id of the member whose log files will be exported.\n\
 \ \ \ \ \ \ \ \ Required: false\n\
 \ \ \ \ log-level\n\
-\ \ \ \ \ \ \ \ Minimum level of log entries to export. Valid values are: none, error, info, config , fine,\n\
-\ \ \ \ \ \ \ \ finer and finest.  The default is "info".\n\
+\ \ \ \ \ \ \ \ Minimum level of log entries to export. Valid values are: fatal, error, warn, info, debug,\n\
+\ \ \ \ \ \ \ \ trace and all.  The default is "INFO".\n\
 \ \ \ \ \ \ \ \ Required: false\n\
+\ \ \ \ \ \ \ \ Default (if the parameter is not specified): INFO\n\
 \ \ \ \ only-log-level\n\
 \ \ \ \ \ \ \ \ Whether to only include those entries that exactly match the --log-level specified.\n\
 \ \ \ \ \ \ \ \ Required: false\n\
@@ -1502,6 +1503,16 @@ PARAMETERS\n\
 \ \ \ \ \ \ \ \ Log entries that occurred before this time will be exported. The default is no limit.\n\
 \ \ \ \ \ \ \ \ Format: yyyy/MM/dd/HH/mm/ss/SSS/z OR yyyy/MM/dd\n\
 \ \ \ \ \ \ \ \ Required: false\n\
+\ \ \ \ logs-only\n\
+\ \ \ \ \ \ \ \ Whether to only export logs\n\
+\ \ \ \ \ \ \ \ Required: false\n\
+\ \ \ \ \ \ \ \ Default (if the parameter is specified without value): true\n\
+\ \ \ \ \ \ \ \ Default (if the parameter is not specified): false\n\
+\ \ \ \ stats-only\n\
+\ \ \ \ \ \ \ \ Whether to only export statistics\n\
+\ \ \ \ \ \ \ \ Required: false\n\
+\ \ \ \ \ \ \ \ Default (if the parameter is specified without value): true\n\
+\ \ \ \ \ \ \ \ Default (if the parameter is not specified): false\n\
 
 export-offline-disk-store.help=\
 NAME\n\

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
index 8f8342f..8c9442a 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
@@ -15,102 +15,52 @@
 
 package org.apache.geode.management.internal.cli.commands;
 
-import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
-import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
 import static org.assertj.core.api.Assertions.assertThat;
 
-import com.google.common.collect.Sets;
-
-import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.TemporaryFolder;
 
 import java.io.File;
-import java.util.HashSet;
-import java.util.Properties;
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
 @Category(DistributedTest.class)
-public class ExportLogsOverHttpDUnitTest {
+public class ExportLogsOverHttpDUnitTest extends ExportStatsDUnitTest {
 
   @Rule
   public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
-  @ClassRule
-  public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
-
-  @ClassRule
-  public static GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
-
-  private static int jmxPort, httpPort;
-  private static Properties locatorProperties;
-  private static Set<String> expectedZipEntries = new HashSet<>();
-
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
-    httpPort = ports[0];
-    jmxPort = ports[1];
-    locatorProperties = new Properties();
-    locatorProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
-    locatorProperties.setProperty(HTTP_SERVICE_PORT, httpPort + "");
-    locatorProperties.setProperty(JMX_MANAGER_PORT, jmxPort + "");
-
-    // start the locator in vm0 and then connect to it over http
-    Locator locator = lsRule.startLocatorVM(0, locatorProperties);
-    lsRule.startServerVM(1, locator.getPort());
-    gfshConnector.connectAndVerify(httpPort, GfshShellConnectionRule.PortType.http);
-
-    expectedZipEntries = Sets.newHashSet("locator-0/locator-0.log", "server-1/server-1.log");
-  }
-
-  @Test
-  public void testExportWithNoDir() throws Exception {
-    // export the logs
-    gfshConnector.executeCommand("export logs");
-    // verify that the message contains a path to the user.dir
-    String message = gfshConnector.getGfshOutput();
-    assertThat(message).contains("Logs exported to: ");
-    assertThat(message).contains(System.getProperty("user.dir"));
-
-    String zipPath = getZipPathFromCommandResult(message);
-    verifyZipContent(zipPath);
+  @Override
+  public void connectIfNeeded() throws Exception {
+    if (!connector.isConnected())
+      connector.connect(httpPort, GfshShellConnectionRule.PortType.http);
   }
 
   @Test
   public void testExportWithDir() throws Exception {
+    connectIfNeeded();
     File dir = temporaryFolder.newFolder();
     // export the logs
-    gfshConnector.executeCommand("export logs --dir=" + dir.getAbsolutePath());
+    connector.executeCommand("export logs --dir=" + dir.getAbsolutePath());
     // verify that the message contains a path to the user.dir
-    String message = gfshConnector.getGfshOutput();
+    String message = connector.getGfshOutput();
     assertThat(message).contains("Logs exported to: ");
     assertThat(message).contains(dir.getAbsolutePath());
 
     String zipPath = getZipPathFromCommandResult(message);
-    verifyZipContent(zipPath);
-  }
-
-  private void verifyZipContent(String zipPath) throws Exception {
-    Set<String> actualZipEnries =
+    Set<String> actualZipEntries =
         new ZipFile(zipPath).stream().map(ZipEntry::getName).collect(Collectors.toSet());
 
-    assertThat(actualZipEnries).isEqualTo(expectedZipEntries);
+    assertThat(actualZipEntries).isEqualTo(expectedZipEntries);
   }
 
-  private String getZipPathFromCommandResult(String message) {
+  protected String getZipPathFromCommandResult(String message) {
     return message.replaceAll("Logs exported to: ", "").trim();
   }
 }


[17/50] [abbrv] geode git commit: GEODE-2488: Remove test from flaky category

Posted by ds...@apache.org.
GEODE-2488: Remove test from flaky category

Removed FlakyTest category.
Made note of this JIRA in the @Ignore annoations. This annotation can be
removed when the underlying problem (accumulating large repsonse data on
remote casuing OOME) is fixed.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/eb59268b
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/eb59268b
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/eb59268b

Branch: refs/heads/feature/GEODE-1969
Commit: eb59268bc5308c5de7339e0dbca8d107d879ac76
Parents: 41f1b27
Author: Ken Howe <kh...@pivotal.io>
Authored: Fri Mar 3 13:33:22 2017 -0800
Committer: Ken Howe <kh...@pivotal.io>
Committed: Mon Mar 6 13:56:36 2017 -0800

----------------------------------------------------------------------
 .../geode/management/internal/cli/NetstatDUnitTest.java      | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/eb59268b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
index e987fc2..8ac993b 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
@@ -30,7 +30,7 @@ import org.junit.experimental.categories.Category;
 
 import java.util.Properties;
 
-@Category({DistributedTest.class, FlakyTest.class})
+@Category(DistributedTest.class)
 public class NetstatDUnitTest {
   @ClassRule
   public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
@@ -91,21 +91,21 @@ public class NetstatDUnitTest {
     gfshConnector.executeAndVerifyCommand(netStatCommand);
   }
 
-  @Ignore
+  @Ignore("GEODE-2488")
   @Test
   public void testConnectToLocatorWithLargeCommandResponse() throws Exception {
     gfshConnector.connect(ports[0], GfshShellConnectionRule.PortType.locator);
     gfshConnector.executeAndVerifyCommand(netStatLsofCommand);
   }
 
-  @Ignore
+  @Ignore("GEODE-2488")
   @Test
   public void testConnectToJmxManagerOneWithLargeCommandResponse() throws Exception {
     gfshConnector.connect(ports[1], GfshShellConnectionRule.PortType.jmxManger);
     gfshConnector.executeAndVerifyCommand(netStatLsofCommand);
   }
 
-  @Ignore
+  @Ignore("GEODE-2488")
   @Test
   public void testConnectToJmxManagerTwoWithLargeCommandResponse() throws Exception {
     gfshConnector.connect(ports[2], GfshShellConnectionRule.PortType.jmxManger);


[07/50] [abbrv] geode git commit: GEODE-2591 User guide: Lucene headings should be reflected in navigation pane

Posted by ds...@apache.org.
GEODE-2591 User guide: Lucene headings should be reflected in navigation pane


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/15587b22
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/15587b22
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/15587b22

Branch: refs/heads/feature/GEODE-1969
Commit: 15587b22c92c3df85d0c9249eac56f42fc0bf931
Parents: 21a9b5e
Author: Dave Barnes <db...@pivotal.io>
Authored: Fri Mar 3 14:19:35 2017 -0800
Committer: Dave Barnes <db...@pivotal.io>
Committed: Fri Mar 3 14:19:35 2017 -0800

----------------------------------------------------------------------
 geode-book/master_middleman/source/subnavs/geode-subnav.erb | 8 +++++++-
 geode-docs/tools_modules/lucene_integration.html.md.erb     | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/15587b22/geode-book/master_middleman/source/subnavs/geode-subnav.erb
----------------------------------------------------------------------
diff --git a/geode-book/master_middleman/source/subnavs/geode-subnav.erb b/geode-book/master_middleman/source/subnavs/geode-subnav.erb
index 5f03ee6..d3472de 100644
--- a/geode-book/master_middleman/source/subnavs/geode-subnav.erb
+++ b/geode-book/master_middleman/source/subnavs/geode-subnav.erb
@@ -30,7 +30,7 @@ limitations under the License.
                         <a href="/docs/guide/11/getting_started/geode_overview.html">About Apache Geode</a>
                     </li>
                     <li>
-                        <a href="/docs/guide/11/getting_started/product_intro.html">Main Features</a>
+                        <a href="/docs/guide/11/getting_started/product_intro.html">Main Features of Apache Geode</a>
                     </li>
                     <li class="has_submenu">
                         <a href="/docs/guide/11/prereq_and_install.html">Prerequisites and Installation Instructions</a>
@@ -2293,8 +2293,14 @@ gfsh</a>
                                 <a href="/docs/guide/11/tools_modules/lucene_integration.html#java-api-example">Java API Example</a>
                             </li>
                             <li>
+                                <a href="/docs/guide/11/tools_modules/lucene_integration.html#search-example">Search Example</a>
+                            </li>
+                            <li>
                                 <a href="/docs/guide/11/tools_modules/lucene_integration.html#gfsh-api">Gfsh API</a>
                             </li>
+                            <li>
+                                <a href="/docs/guide/11/tools_modules/lucene_integration.html#xml-configuration">XML Configuration</a>
+                            </li>
                         </ul>
                     </li>
                 </ul>

http://git-wip-us.apache.org/repos/asf/geode/blob/15587b22/geode-docs/tools_modules/lucene_integration.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/tools_modules/lucene_integration.html.md.erb b/geode-docs/tools_modules/lucene_integration.html.md.erb
index 6361650..aa19e43 100644
--- a/geode-docs/tools_modules/lucene_integration.html.md.erb
+++ b/geode-docs/tools_modules/lucene_integration.html.md.erb
@@ -69,7 +69,7 @@ Region region = cache.createRegionFactory(RegionShutcut.PARTITION).create(region
  
 ```
 
-## Search Example
+## <a id="search-example" class="no-quick-link"></a>Search Example
 
 ``` pre
 LuceneQuery<String, Person> query = luceneService.createLuceneQueryFactory()
@@ -111,7 +111,7 @@ gfsh> lucene search --regionName=/orders -queryStrings="John*" --defaultField=fi
 ```
 
 
-## XML Configuration
+## <a id="xml-configuration" class="no-quick-link"></a>XML Configuration
 
 ``` pre
 <cache


[36/50] [abbrv] geode git commit: GEODE-2267: Enhance server/locator startup rules

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
index 1a344db..58f1870 100755
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
@@ -17,7 +17,12 @@ package org.apache.geode.cache.lucene.internal.configuration;
 import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
 import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.lucene.LuceneIndex;
@@ -34,9 +39,9 @@ import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.management.internal.configuration.domain.Configuration;
 import org.apache.geode.test.dunit.SerializableRunnableIF;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.Member;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.lucene.analysis.Analyzer;
 import org.junit.Before;
@@ -60,7 +65,7 @@ public class LuceneClusterConfigurationDUnitTest {
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
 
-  private Locator locator = null;
+  private MemberVM locator = null;
 
   @Before
   public void before() throws Exception {
@@ -81,10 +86,10 @@ public class LuceneClusterConfigurationDUnitTest {
 
     // Start vm2. This should have lucene index created using cluster
     // configuration.
-    Member vm2 = startNodeUsingClusterConfiguration(2, false);
+    MemberVM vm2 = startNodeUsingClusterConfiguration(2, false);
     vm2.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
       validateIndexFields(new String[] {"field1", "field2", "field3"}, index);
@@ -107,10 +112,10 @@ public class LuceneClusterConfigurationDUnitTest {
 
     // Start vm2. This should have lucene index created using cluster
     // configuration.
-    Member vm2 = startNodeUsingClusterConfiguration(2, false);
+    MemberVM vm2 = startNodeUsingClusterConfiguration(2, false);
     vm2.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
       String[] fields = new String[] {"field1", "field2", "field3"};
@@ -128,11 +133,11 @@ public class LuceneClusterConfigurationDUnitTest {
   public void indexGetsCreatedOnGroupOfNodes() throws Exception {
 
     // Start vm1, vm2 in group
-    Member vm1 = startNodeUsingClusterConfiguration(1, true);
-    Member vm2 = startNodeUsingClusterConfiguration(2, true);
+    MemberVM vm1 = startNodeUsingClusterConfiguration(1, true);
+    MemberVM vm2 = startNodeUsingClusterConfiguration(2, true);
 
     // Start vm3 outside the group. The Lucene index should not be present here.
-    Member vm3 = startNodeUsingClusterConfiguration(3, true);
+    MemberVM vm3 = startNodeUsingClusterConfiguration(3, true);
 
     // Connect Gfsh to locator.
     gfshConnector.connectAndVerify(locator);
@@ -146,7 +151,7 @@ public class LuceneClusterConfigurationDUnitTest {
     // VM2 should have lucene index created using gfsh execution.
     vm2.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
       validateIndexFields(new String[] {"field1", "field2", "field3"}, index);
@@ -155,7 +160,7 @@ public class LuceneClusterConfigurationDUnitTest {
     // The Lucene index is present in vm3.
     vm3.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
     });
@@ -164,11 +169,11 @@ public class LuceneClusterConfigurationDUnitTest {
   @Test
   public void indexNotCreatedOnNodeOutSideTheGroup() throws Exception {
     // Start vm1, vm2 in group
-    Member vm1 = startNodeUsingClusterConfiguration(1, true);
-    Member vm2 = startNodeUsingClusterConfiguration(2, true);
+    MemberVM vm1 = startNodeUsingClusterConfiguration(1, true);
+    MemberVM vm2 = startNodeUsingClusterConfiguration(2, true);
 
     // Start vm3 outside the group. The Lucene index should not be present here.
-    Member vm3 = startNodeUsingClusterConfiguration(3, false);
+    MemberVM vm3 = startNodeUsingClusterConfiguration(3, false);
 
     // Connect Gfsh to locator.
     gfshConnector.connectAndVerify(locator);
@@ -182,7 +187,7 @@ public class LuceneClusterConfigurationDUnitTest {
     // VM2 should have lucene index created using gfsh execution
     vm2.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
       validateIndexFields(new String[] {"field1", "field2", "field3"}, index);
@@ -191,7 +196,7 @@ public class LuceneClusterConfigurationDUnitTest {
     // The Lucene index should not be present in vm3.
     vm3.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNull(index);
     });
@@ -210,15 +215,15 @@ public class LuceneClusterConfigurationDUnitTest {
     createRegionUsingGfsh(REGION_NAME, RegionShortcut.PARTITION, groupName);
 
     // Start vm2 in group
-    Member vm2 = startNodeUsingClusterConfiguration(2, true);
+    MemberVM vm2 = startNodeUsingClusterConfiguration(2, true);
 
     // Start vm3 outside the group. The Lucene index should not be present here.
-    Member vm3 = startNodeUsingClusterConfiguration(3, false);
+    MemberVM vm3 = startNodeUsingClusterConfiguration(3, false);
 
     // VM2 should have lucene index created using gfsh execution
     vm2.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
       validateIndexFields(new String[] {"field1", "field2", "field3"}, index);
@@ -227,7 +232,7 @@ public class LuceneClusterConfigurationDUnitTest {
     // The Lucene index should not be present in vm3.
     vm3.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNull(index);
     });
@@ -286,7 +291,7 @@ public class LuceneClusterConfigurationDUnitTest {
 
   private SerializableRunnableIF verifyClusterConfiguration(boolean verifyIndexesExist) {
     return () -> {
-      InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.locator;
+      InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.getLocator();
       ClusterConfigurationService sc = internalLocator.getSharedConfiguration();
       Configuration config = sc.getConfiguration(ClusterConfigurationService.CLUSTER_CONFIG);
       String xmlContent = config.getCacheXmlContent();
@@ -306,7 +311,7 @@ public class LuceneClusterConfigurationDUnitTest {
     };
   }
 
-  private Member startNodeUsingClusterConfiguration(int vmIndex, boolean addGroup)
+  private MemberVM startNodeUsingClusterConfiguration(int vmIndex, boolean addGroup)
       throws Exception {
     Properties nodeProperties = new Properties();
     if (addGroup) {


[43/50] [abbrv] geode git commit: GEODE-2614: fix javadoc warnings

Posted by ds...@apache.org.
GEODE-2614: fix javadoc warnings


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/0ca3fe27
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/0ca3fe27
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/0ca3fe27

Branch: refs/heads/feature/GEODE-1969
Commit: 0ca3fe271bc4e30a352f5a9b600b5a58bb2c4a92
Parents: 3bde1a7
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Wed Mar 8 09:50:06 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:30 2017 -0800

----------------------------------------------------------------------
 .../geode/management/internal/cli/CliAroundInterceptor.java    | 3 +--
 .../apache/geode/management/internal/cli/util/LogExporter.java | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/0ca3fe27/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
index 99114f0..f552460 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
@@ -38,8 +38,7 @@ public interface CliAroundInterceptor {
 
   /**
    * called by the OperationInvoker after the command is executed
-   * 
-   * @param tempFile: if the command's isFileDownloadOverHttp is true, the is the File downloaded
+   * @param tempFile if the command's isFileDownloadOverHttp is true, the is the File downloaded
    *        after the http response is processed.
    */
   default Result postExecution(GfshParseResult parseResult, Result commandResult, Path tempFile) {

http://git-wip-us.apache.org/repos/asf/geode/blob/0ca3fe27/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
index a4bef75..a0be7fb 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
@@ -48,9 +48,9 @@ public class LogExporter {
   private final File baseStatsFile;
 
   /**
-   * @param logFilter: the filter that's used to check if we need to accept the file or the logLine
-   * @param baseLogFile: if not null, we will export the logs in that directory
-   * @param baseStatsFile: if not null, we will export stats in that directory
+   * @param logFilter the filter that's used to check if we need to accept the file or the logLine
+   * @param baseLogFile if not null, we will export the logs in that directory
+   * @param baseStatsFile if not null, we will export stats in that directory
    * @throws ParseException
    */
   public LogExporter(LogFilter logFilter, File baseLogFile, File baseStatsFile)


[12/50] [abbrv] geode git commit: GEODE-2267: add validation to the arguments and include export stats in the command

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
index e2f5307..d19aee1 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
@@ -16,12 +16,7 @@ package org.apache.geode.management.internal.web.controllers;
 
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-import org.springframework.core.io.InputStreamResource;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -29,9 +24,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import java.io.File;
-import java.io.FileInputStream;
-
 /**
  * The MiscellaneousCommandsController class implements GemFire Management REST API web service
  * endpoints for the Gfsh Miscellaneous Commands.
@@ -51,68 +43,6 @@ import java.io.FileInputStream;
 @RequestMapping(AbstractCommandsController.REST_API_VERSION)
 @SuppressWarnings("unused")
 public class MiscellaneousCommandsController extends AbstractCommandsController {
-
-  @RequestMapping(method = RequestMethod.GET, value = "/logs")
-  public ResponseEntity<InputStreamResource> exportLogs(
-      @RequestParam(value = CliStrings.EXPORT_LOGS__DIR, required = false) final String directory,
-      @RequestParam(value = CliStrings.EXPORT_LOGS__GROUP, required = false) final String[] groups,
-      @RequestParam(value = CliStrings.EXPORT_LOGS__MEMBER,
-          required = false) final String memberNameId,
-      @RequestParam(value = CliStrings.EXPORT_LOGS__LOGLEVEL,
-          required = false) final String logLevel,
-      @RequestParam(value = CliStrings.EXPORT_LOGS__UPTO_LOGLEVEL,
-          defaultValue = "false") final Boolean onlyLogLevel,
-      @RequestParam(value = CliStrings.EXPORT_LOGS__MERGELOG,
-          defaultValue = "false") final Boolean mergeLog,
-      @RequestParam(value = CliStrings.EXPORT_LOGS__STARTTIME,
-          required = false) final String startTime,
-      @RequestParam(value = CliStrings.EXPORT_LOGS__ENDTIME,
-          required = false) final String endTime) {
-    final CommandStringBuilder command = new CommandStringBuilder(CliStrings.EXPORT_LOGS);
-
-    command.addOption(CliStrings.EXPORT_LOGS__DIR, decode(directory));
-
-    if (hasValue(groups)) {
-      command.addOption(CliStrings.EXPORT_LOGS__GROUP,
-          StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
-    }
-
-    if (hasValue(memberNameId)) {
-      command.addOption(CliStrings.EXPORT_LOGS__MEMBER, memberNameId);
-    }
-
-    if (hasValue(logLevel)) {
-      command.addOption(CliStrings.EXPORT_LOGS__LOGLEVEL, logLevel);
-    }
-
-    command.addOption(CliStrings.EXPORT_LOGS__UPTO_LOGLEVEL,
-        String.valueOf(Boolean.TRUE.equals(onlyLogLevel)));
-    command.addOption(CliStrings.EXPORT_LOGS__MERGELOG,
-        String.valueOf(Boolean.TRUE.equals(mergeLog)));
-
-    if (hasValue(startTime)) {
-      command.addOption(CliStrings.EXPORT_LOGS__STARTTIME, startTime);
-    }
-
-    if (hasValue(endTime)) {
-      command.addOption(CliStrings.EXPORT_LOGS__ENDTIME, endTime);
-    }
-
-    // the result is json string from CommandResult
-    String result = processCommand(command.toString());
-
-    // parse the result to get the file path
-    String filePath = ResultBuilder.fromJson(result).nextLine().trim();
-
-    HttpHeaders respHeaders = new HttpHeaders();
-    try {
-      InputStreamResource isr = new InputStreamResource(new FileInputStream(new File(filePath)));
-      return new ResponseEntity<InputStreamResource>(isr, respHeaders, HttpStatus.OK);
-    } catch (Exception ex) {
-      throw new RuntimeException("IOError writing file to output stream", ex);
-    }
-  }
-
   // TODO determine whether Async functionality is required
   @RequestMapping(method = RequestMethod.GET, value = "/stacktraces")
   @ResponseBody

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/internal/statistics/SimpleStatSamplerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/statistics/SimpleStatSamplerIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/internal/statistics/SimpleStatSamplerIntegrationTest.java
index 167fa3d..ae052c1 100755
--- a/geode-core/src/test/java/org/apache/geode/internal/statistics/SimpleStatSamplerIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/statistics/SimpleStatSamplerIntegrationTest.java
@@ -14,12 +14,18 @@
  */
 package org.apache.geode.internal.statistics;
 
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
+import org.apache.geode.CancelCriterion;
+import org.apache.geode.Statistics;
+import org.apache.geode.StatisticsType;
+import org.apache.geode.internal.net.SocketCreator;
+import org.apache.geode.internal.stats50.VMStats50;
+import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -29,12 +35,9 @@ import org.junit.experimental.categories.Category;
 import org.junit.rules.TemporaryFolder;
 import org.junit.rules.TestName;
 
-import org.apache.geode.CancelCriterion;
-import org.apache.geode.Statistics;
-import org.apache.geode.StatisticsType;
-import org.apache.geode.internal.net.SocketCreator;
-import org.apache.geode.internal.stats50.VMStats50;
-import org.apache.geode.test.junit.categories.IntegrationTest;
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.List;
 
 /**
  * Integration tests for {@link SimpleStatSampler}.

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
index 83a367e..101c8f5 100644
--- a/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
@@ -26,10 +26,10 @@ import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_S
 import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_KEYSTORE_TYPE;
 import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_TRUSTSTORE;
 import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_TRUSTSTORE_PASSWORD;
+import static org.apache.geode.distributed.ConfigurationProperties.SSL_CIPHERS;
 import static org.apache.geode.distributed.ConfigurationProperties.SSL_ENABLED_COMPONENTS;
 import static org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE;
 import static org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE_PASSWORD;
-import static org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE_TYPE;
 import static org.apache.geode.distributed.ConfigurationProperties.SSL_PROTOCOLS;
 import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE;
 import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD;
@@ -100,10 +100,11 @@ public class ConnectToLocatorSSLDUnitTest {
     securityProps.setProperty(SSL_ENABLED_COMPONENTS, SecurableCommunicationChannels.JMX);
     securityProps.setProperty(SSL_KEYSTORE, jks.getCanonicalPath());
     securityProps.setProperty(SSL_KEYSTORE_PASSWORD, "password");
-    securityProps.setProperty(SSL_KEYSTORE_TYPE, "JKS");
+    // securityProps.setProperty(SSL_KEYSTORE_TYPE, "JKS");
     securityProps.setProperty(SSL_TRUSTSTORE, jks.getCanonicalPath());
     securityProps.setProperty(SSL_TRUSTSTORE_PASSWORD, "password");
-    securityProps.setProperty(SSL_PROTOCOLS, "TLSv1.2,TLSv1.1");
+    securityProps.setProperty(SSL_PROTOCOLS, "TLSv1.2");
+    securityProps.setProperty(SSL_CIPHERS, "any");
 
     setUpLocatorAndConnect(securityProps);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/AbstractCliAroundInterceptorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/AbstractCliAroundInterceptorJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/AbstractCliAroundInterceptorJUnitTest.java
index c938f07..82fd4a6 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/AbstractCliAroundInterceptorJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/AbstractCliAroundInterceptorJUnitTest.java
@@ -23,6 +23,8 @@ import org.junit.experimental.categories.Category;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.test.junit.categories.UnitTest;
 
+import java.nio.file.Path;
+
 /**
  * AbstractCliAroundInterceptor Tester.
  */
@@ -38,7 +40,8 @@ public class AbstractCliAroundInterceptorJUnitTest {
       }
 
       @Override
-      public Result postExecution(final GfshParseResult parseResult, final Result commandResult) {
+      public Result postExecution(final GfshParseResult parseResult, final Result commandResult,
+          final Path tempFile) {
         return null;
       }
     };

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
index 76e986d..9ea22da 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
@@ -95,14 +95,18 @@ public class HeadlessGfsh implements ResultHandler {
 
   // TODO : Have non-blocking method also where we move executeCommand call to separate thread-pool
   public boolean executeCommand(String command) {
-    boolean status = false;
+    boolean success = false;
     try {
       outputString = null;
-      status = shell.executeScriptLine(command);
+      success = shell.executeScriptLine(command);
     } catch (Exception e) {
       outputString = e.getMessage();
     }
-    return status;
+    if (!success && shell.output != null) {
+      outputString = shell.output.toString();
+      shell.output.reset();
+    }
+    return success;
   }
 
   public int getCommandExecutionStatus() {

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
index 21426d6..165f664 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CliCommandTestBase.java
@@ -14,22 +14,17 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.test.dunit.Assert.*;
-import static org.apache.geode.test.dunit.LogWriterUtils.*;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.geode.security.TestSecurityManager;
-import org.junit.Rule;
-import org.junit.rules.TemporaryFolder;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.test.dunit.Assert.assertEquals;
+import static org.apache.geode.test.dunit.Assert.assertFalse;
+import static org.apache.geode.test.dunit.Assert.assertNotNull;
+import static org.apache.geode.test.dunit.Assert.assertTrue;
+import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.internal.AvailablePortHelper;
@@ -41,13 +36,27 @@ import org.apache.geode.management.internal.cli.parser.CommandTarget;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.security.TestSecurityManager;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
 import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * Base class for all the CLI/gfsh command dunit tests.
+ * 
+ * @deprecated use LocatorServerStartupRule and GfshShellConnectorRule instead.
  */
 public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
 

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
deleted file mode 100644
index a64620a..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * 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.management.internal.cli.commands;
-
-import static java.util.stream.Collectors.joining;
-import static java.util.stream.Collectors.toList;
-import static java.util.stream.Collectors.toSet;
-import static org.apache.geode.management.internal.cli.commands.MiscellaneousCommands.FORMAT;
-import static org.apache.geode.management.internal.cli.commands.MiscellaneousCommands.ONLY_DATE_FORMAT;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.management.internal.cli.functions.ExportLogsFunction;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-import org.apache.geode.management.internal.configuration.utils.ZipUtils;
-import org.apache.geode.test.dunit.IgnoredException;
-import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Member;
-import org.apache.geode.test.dunit.rules.Server;
-import org.apache.logging.log4j.Logger;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Serializable;
-import java.nio.charset.Charset;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.Set;
-import java.util.stream.Stream;
-
-
-public class ExportLogsDUnit {
-  private static final String ERROR_LOG_PREFIX = "[IGNORE]";
-
-  @Rule
-  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
-
-  @Rule
-  public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
-
-  private Locator locator;
-  private Server server1;
-  private Server server2;
-
-  private Map<Member, List<LogLine>> expectedMessages;
-
-  @Before
-  public void setup() throws Exception {
-    Properties properties = new Properties();
-    properties.setProperty(ConfigurationProperties.LOG_LEVEL, "debug");
-
-    locator = lsRule.startLocatorVM(0, properties);
-    server1 = lsRule.startServerVM(1, properties, locator.getPort());
-    server2 = lsRule.startServerVM(2, properties, locator.getPort());
-
-    IgnoredException.addIgnoredException(ERROR_LOG_PREFIX);
-
-    expectedMessages = new HashMap<>();
-    expectedMessages.put(locator, listOfLogLines(locator, "info", "error", "debug"));
-    expectedMessages.put(server1, listOfLogLines(server1, "info", "error", "debug"));
-    expectedMessages.put(server2, listOfLogLines(server2, "info", "error", "debug"));
-
-    // log the messages in each of the members
-    for (Member member : expectedMessages.keySet()) {
-      List<LogLine> logLines = expectedMessages.get(member);
-
-      member.invoke(() -> {
-        Logger logger = LogService.getLogger();
-        logLines.forEach((LogLine logLine) -> logLine.writeLog(logger));
-      });
-    }
-
-    gfshConnector.connectAndVerify(locator);
-  }
-
-  @Test
-  public void startAndEndDateCanExcludeLogs() throws Exception {
-    ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault());
-    ZonedDateTime yesterday = now.minusDays(1);
-    ZonedDateTime twoDaysAgo = now.minusDays(2);
-
-    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
-
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
-    commandStringBuilder.addOption("start-time", dateTimeFormatter.format(twoDaysAgo));
-    commandStringBuilder.addOption("end-time", dateTimeFormatter.format(yesterday));
-    commandStringBuilder.addOption("log-level", "debug");
-    commandStringBuilder.addOption("dir", "someDir");
-
-    gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString());
-
-    Set<String> acceptedLogLevels = new HashSet<>();
-    verifyZipFileContents(acceptedLogLevels);
-  }
-
-  @Test
-  public void startAndEndDateCanIncludeLogs() throws Exception {
-    ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault());
-    ZonedDateTime yesterday = now.minusDays(1);
-    ZonedDateTime tomorrow = now.plusDays(1);
-
-    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
-
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
-    commandStringBuilder.addOption("start-time", dateTimeFormatter.format(yesterday));
-    commandStringBuilder.addOption("end-time", dateTimeFormatter.format(tomorrow));
-    commandStringBuilder.addOption("log-level", "debug");
-    commandStringBuilder.addOption("dir", "someDir");
-
-    gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString());
-
-    Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
-    verifyZipFileContents(acceptedLogLevels);
-  }
-
-  @Test
-  public void testExportWithStartAndEndDateTimeFiltering() throws Exception {
-    ZonedDateTime cutoffTime = LocalDateTime.now().atZone(ZoneId.systemDefault());
-
-    String messageAfterCutoffTime =
-        "[this message should not show up since it is after cutoffTime]";
-    LogLine logLineAfterCutoffTime = new LogLine(messageAfterCutoffTime, "info", true);
-    server1.invoke(() -> {
-      Logger logger = LogService.getLogger();
-      logLineAfterCutoffTime.writeLog(logger);
-    });
-
-    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(FORMAT);
-    String cutoffTimeString = dateTimeFormatter.format(cutoffTime);
-
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
-    commandStringBuilder.addOption("start-time",
-        dateTimeFormatter.format(cutoffTime.minusHours(1)));
-    commandStringBuilder.addOption("end-time", cutoffTimeString);
-    commandStringBuilder.addOption("log-level", "debug");
-    commandStringBuilder.addOption("dir", "someDir");
-
-    gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString());
-
-    expectedMessages.get(server1).add(logLineAfterCutoffTime);
-    Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
-    verifyZipFileContents(acceptedLogLevels);
-  }
-
-  @Test
-  public void testExportWithThresholdLogLevelFilter() throws Exception {
-
-    CommandResult result = gfshConnector
-        .executeAndVerifyCommand("export logs --log-level=info --only-log-level=false --dir="
-            + lsRule.getTempFolder().getRoot().getCanonicalPath());
-
-    Set<String> acceptedLogLevels = Stream.of("info", "error").collect(toSet());
-    verifyZipFileContents(acceptedLogLevels);
-
-  }
-
-  @Test
-  public void testExportWithExactLogLevelFilter() throws Exception {
-    CommandResult result = gfshConnector
-        .executeAndVerifyCommand("export logs --log-level=info --only-log-level=true --dir="
-            + lsRule.getTempFolder().getRoot().getCanonicalPath());
-
-
-    Set<String> acceptedLogLevels = Stream.of("info").collect(toSet());
-    verifyZipFileContents(acceptedLogLevels);
-  }
-
-  @Test
-  public void testExportWithNoFilters() throws Exception {
-    CommandResult result = gfshConnector.executeAndVerifyCommand("export logs  --dir="
-        + "someDir" /* lsRule.getTempFolder().getRoot().getCanonicalPath() */);
-
-    Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
-    verifyZipFileContents(acceptedLogLevels);
-
-    // Ensure export logs region gets cleaned up
-    server1.invoke(ExportLogsDUnit::verifyExportLogsRegionWasDestroyed);
-    server2.invoke(ExportLogsDUnit::verifyExportLogsRegionWasDestroyed);
-    locator.invoke(ExportLogsDUnit::verifyExportLogsRegionWasDestroyed);
-  }
-
-  @Test
-  public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFoundException {
-    locator.invoke(() -> {
-      ExportLogsFunction.createOrGetExistingExportLogsRegion(true);
-      Cache cache = GemFireCacheImpl.getInstance();
-      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
-    });
-
-    server1.invoke(() -> {
-      ExportLogsFunction.createOrGetExistingExportLogsRegion(false);
-      Cache cache = GemFireCacheImpl.getInstance();
-      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
-    });
-
-    locator.invoke(() -> {
-      ExportLogsFunction.destroyExportLogsRegion();
-
-      Cache cache = GemFireCacheImpl.getInstance();
-      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
-    });
-
-    server1.invoke(() -> {
-      Cache cache = GemFireCacheImpl.getInstance();
-      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
-    });
-  }
-
-
-  public void verifyZipFileContents(Set<String> acceptedLogLevels) throws IOException {
-    File unzippedLogFileDir = unzipExportedLogs();
-
-    Set<File> dirsFromZipFile =
-        Stream.of(unzippedLogFileDir.listFiles()).filter(File::isDirectory).collect(toSet());
-    assertThat(dirsFromZipFile).hasSize(expectedMessages.keySet().size());
-
-    Set<String> expectedDirNames =
-        expectedMessages.keySet().stream().map(Member::getName).collect(toSet());
-    Set<String> actualDirNames = dirsFromZipFile.stream().map(File::getName).collect(toSet());
-    assertThat(actualDirNames).isEqualTo(expectedDirNames);
-
-    System.out.println("Unzipped artifacts:");
-    for (File dir : dirsFromZipFile) {
-      verifyLogFileContents(acceptedLogLevels, dir);
-    }
-  }
-
-  public void verifyLogFileContents(Set<String> acceptedLogLevels, File dirForMember)
-      throws IOException {
-
-    String memberName = dirForMember.getName();
-    Member member = expectedMessages.keySet().stream()
-        .filter((Member aMember) -> aMember.getName().equals(memberName)).findFirst().get();
-
-    assertThat(member).isNotNull();
-
-    Set<String> fileNamesInDir =
-        Stream.of(dirForMember.listFiles()).map(File::getName).collect(toSet());
-
-    System.out.println(dirForMember.getCanonicalPath() + " : " + fileNamesInDir);
-
-    File logFileForMember = new File(dirForMember, memberName + ".log");
-    assertThat(logFileForMember).exists();
-    assertThat(fileNamesInDir).hasSize(1);
-
-    String logFileContents = FileUtils.readLines(logFileForMember, Charset.defaultCharset())
-        .stream().collect(joining("\n"));
-
-    for (LogLine logLine : expectedMessages.get(member)) {
-      boolean shouldExpectLogLine =
-          acceptedLogLevels.contains(logLine.level) && !logLine.shouldBeIgnoredDueToTimestamp;
-
-      if (shouldExpectLogLine) {
-        assertThat(logFileContents).contains(logLine.getMessage());
-      } else {
-        assertThat(logFileContents).doesNotContain(logLine.getMessage());
-      }
-    }
-
-  }
-
-  private File unzipExportedLogs() throws IOException {
-    File locatorWorkingDir = locator.getWorkingDir();
-    List<File> filesInDir = Stream.of(locatorWorkingDir.listFiles()).collect(toList());
-    assertThat(filesInDir).isNotEmpty();
-
-
-    List<File> zipFilesInDir = Stream.of(locatorWorkingDir.listFiles())
-        .filter(f -> f.getName().endsWith(".zip")).collect(toList());
-    assertThat(zipFilesInDir)
-        .describedAs(filesInDir.stream().map(File::getAbsolutePath).collect(joining(",")))
-        .hasSize(1);
-
-    File unzippedLogFileDir = lsRule.getTempFolder().newFolder("unzippedLogs");
-    ZipUtils.unzip(zipFilesInDir.get(0).getCanonicalPath(), unzippedLogFileDir.getCanonicalPath());
-    return unzippedLogFileDir;
-  }
-
-  private List<LogLine> listOfLogLines(Member member, String... levels) {
-    return Stream.of(levels).map(level -> new LogLine(member, level)).collect(toList());
-  }
-
-  private static void verifyExportLogsRegionWasDestroyed() {
-    Cache cache = GemFireCacheImpl.getInstance();
-    assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
-  }
-
-  public static class LogLine implements Serializable {
-    String level;
-    String message;
-    boolean shouldBeIgnoredDueToTimestamp;
-
-    public LogLine(String message, String level, boolean shouldBeIgnoredDueToTimestamp) {
-      this.message = message;
-      this.level = level;
-      this.shouldBeIgnoredDueToTimestamp = shouldBeIgnoredDueToTimestamp;
-    }
-
-    public LogLine(Member member, String level) {
-      this.level = level;
-      this.message = buildMessage(member.getName());
-    }
-
-    public String getMessage() {
-      return message;
-    }
-
-    private String buildMessage(String memberName) {
-      StringBuilder stringBuilder = new StringBuilder();
-      if (Objects.equals(level, "error")) {
-        stringBuilder.append(ERROR_LOG_PREFIX);
-      }
-      stringBuilder.append(level);
-
-      return stringBuilder.append(memberName).toString();
-    }
-
-
-    public void writeLog(Logger logger) {
-      switch (this.level) {
-        case "info":
-          logger.info(getMessage());
-          break;
-        case "error":
-          logger.error(getMessage());
-          break;
-        case "debug":
-          logger.debug(getMessage());
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
new file mode 100644
index 0000000..19198f2
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
@@ -0,0 +1,342 @@
+/*
+ * 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.management.internal.cli.commands;
+
+import static java.util.stream.Collectors.joining;
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toSet;
+import static org.apache.geode.management.internal.cli.commands.ExportLogCommand.FORMAT;
+import static org.apache.geode.management.internal.cli.commands.ExportLogCommand.ONLY_DATE_FORMAT;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.management.internal.cli.functions.ExportLogsFunction;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
+import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.Locator;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.Member;
+import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.logging.log4j.Logger;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Stream;
+
+@Category(DistributedTest.class)
+public class ExportLogsDUnitTest {
+  private static final String ERROR_LOG_PREFIX = "[IGNORE]";
+
+  @Rule
+  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+
+  @Rule
+  public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
+
+  private Locator locator;
+  private Server server1;
+  private Server server2;
+
+  private Map<Member, List<LogLine>> expectedMessages;
+
+  @Before
+  public void setup() throws Exception {
+    Properties properties = new Properties();
+    properties.setProperty(ConfigurationProperties.LOG_LEVEL, "debug");
+
+    locator = lsRule.startLocatorVM(0, properties);
+    server1 = lsRule.startServerVM(1, properties, locator.getPort());
+    server2 = lsRule.startServerVM(2, properties, locator.getPort());
+
+    IgnoredException.addIgnoredException(ERROR_LOG_PREFIX);
+
+    expectedMessages = new HashMap<>();
+    expectedMessages.put(locator, listOfLogLines(locator, "info", "error", "debug"));
+    expectedMessages.put(server1, listOfLogLines(server1, "info", "error", "debug"));
+    expectedMessages.put(server2, listOfLogLines(server2, "info", "error", "debug"));
+
+    // log the messages in each of the members
+    for (Member member : expectedMessages.keySet()) {
+      List<LogLine> logLines = expectedMessages.get(member);
+
+      member.invoke(() -> {
+        Logger logger = LogService.getLogger();
+        logLines.forEach((LogLine logLine) -> logLine.writeLog(logger));
+      });
+    }
+
+    gfshConnector.connectAndVerify(locator);
+  }
+
+  @Test
+  public void startAndEndDateCanIncludeLogs() throws Exception {
+    ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault());
+    ZonedDateTime yesterday = now.minusDays(1);
+    ZonedDateTime tomorrow = now.plusDays(1);
+
+    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
+
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
+    commandStringBuilder.addOption("start-time", dateTimeFormatter.format(yesterday));
+    commandStringBuilder.addOption("end-time", dateTimeFormatter.format(tomorrow));
+    commandStringBuilder.addOption("log-level", "debug");
+    commandStringBuilder.addOption("dir", "someDir");
+
+    gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString());
+
+    Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
+    verifyZipFileContents(acceptedLogLevels);
+  }
+
+  @Test
+  public void testExportWithStartAndEndDateTimeFiltering() throws Exception {
+    ZonedDateTime cutoffTime = LocalDateTime.now().atZone(ZoneId.systemDefault());
+
+    String messageAfterCutoffTime =
+        "[this message should not show up since it is after cutoffTime]";
+    LogLine logLineAfterCutoffTime = new LogLine(messageAfterCutoffTime, "info", true);
+    server1.invoke(() -> {
+      Logger logger = LogService.getLogger();
+      logLineAfterCutoffTime.writeLog(logger);
+    });
+
+    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(FORMAT);
+    String cutoffTimeString = dateTimeFormatter.format(cutoffTime);
+
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
+    commandStringBuilder.addOption("start-time",
+        dateTimeFormatter.format(cutoffTime.minusHours(1)));
+    commandStringBuilder.addOption("end-time", cutoffTimeString);
+    commandStringBuilder.addOption("log-level", "debug");
+    commandStringBuilder.addOption("dir", "someDir");
+
+    gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString());
+
+    expectedMessages.get(server1).add(logLineAfterCutoffTime);
+    Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
+    verifyZipFileContents(acceptedLogLevels);
+  }
+
+  @Test
+  public void testExportWithThresholdLogLevelFilter() throws Exception {
+
+    CommandResult result = gfshConnector
+        .executeAndVerifyCommand("export logs --log-level=info --only-log-level=false");
+
+    Set<String> acceptedLogLevels = Stream.of("info", "error").collect(toSet());
+    verifyZipFileContents(acceptedLogLevels);
+
+  }
+
+  @Test
+  public void testExportWithExactLogLevelFilter() throws Exception {
+    CommandResult result =
+        gfshConnector.executeAndVerifyCommand("export logs --log-level=info --only-log-level=true");
+
+
+    Set<String> acceptedLogLevels = Stream.of("info").collect(toSet());
+    verifyZipFileContents(acceptedLogLevels);
+  }
+
+  @Test
+  public void testExportWithNoFilters() throws Exception {
+    gfshConnector.executeAndVerifyCommand("export logs --log-level=all");
+
+    Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
+    verifyZipFileContents(acceptedLogLevels);
+
+    // Ensure export logs region gets cleaned up
+    server1.invoke(ExportLogsDUnitTest::verifyExportLogsRegionWasDestroyed);
+    server2.invoke(ExportLogsDUnitTest::verifyExportLogsRegionWasDestroyed);
+    locator.invoke(ExportLogsDUnitTest::verifyExportLogsRegionWasDestroyed);
+  }
+
+  @Test
+  public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFoundException {
+    locator.invoke(() -> {
+      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+      ExportLogsFunction.createOrGetExistingExportLogsRegion(true, cache);
+      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
+    });
+
+    server1.invoke(() -> {
+      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+      ExportLogsFunction.createOrGetExistingExportLogsRegion(false, cache);
+      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
+    });
+
+    locator.invoke(() -> {
+      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+      ExportLogsFunction.destroyExportLogsRegion(cache);
+
+      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
+    });
+
+    server1.invoke(() -> {
+      Cache cache = GemFireCacheImpl.getInstance();
+      assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
+    });
+  }
+
+
+  public void verifyZipFileContents(Set<String> acceptedLogLevels) throws IOException {
+    File unzippedLogFileDir = unzipExportedLogs();
+
+    Set<File> dirsFromZipFile =
+        Stream.of(unzippedLogFileDir.listFiles()).filter(File::isDirectory).collect(toSet());
+    assertThat(dirsFromZipFile).hasSize(expectedMessages.keySet().size());
+
+    Set<String> expectedDirNames =
+        expectedMessages.keySet().stream().map(Member::getName).collect(toSet());
+    Set<String> actualDirNames = dirsFromZipFile.stream().map(File::getName).collect(toSet());
+    assertThat(actualDirNames).isEqualTo(expectedDirNames);
+
+    System.out.println("Unzipped artifacts:");
+    for (File dir : dirsFromZipFile) {
+      verifyLogFileContents(acceptedLogLevels, dir);
+    }
+  }
+
+  public void verifyLogFileContents(Set<String> acceptedLogLevels, File dirForMember)
+      throws IOException {
+
+    String memberName = dirForMember.getName();
+    Member member = expectedMessages.keySet().stream()
+        .filter((Member aMember) -> aMember.getName().equals(memberName)).findFirst().get();
+
+    assertThat(member).isNotNull();
+
+    Set<String> fileNamesInDir =
+        Stream.of(dirForMember.listFiles()).map(File::getName).collect(toSet());
+
+    System.out.println(dirForMember.getCanonicalPath() + " : " + fileNamesInDir);
+
+    File logFileForMember = new File(dirForMember, memberName + ".log");
+    assertThat(logFileForMember).exists();
+    assertThat(fileNamesInDir).hasSize(1);
+
+    String logFileContents = FileUtils.readLines(logFileForMember, Charset.defaultCharset())
+        .stream().collect(joining("\n"));
+
+    for (LogLine logLine : expectedMessages.get(member)) {
+      boolean shouldExpectLogLine =
+          acceptedLogLevels.contains(logLine.level) && !logLine.shouldBeIgnoredDueToTimestamp;
+
+      if (shouldExpectLogLine) {
+        assertThat(logFileContents).contains(logLine.getMessage());
+      } else {
+        assertThat(logFileContents).doesNotContain(logLine.getMessage());
+      }
+    }
+
+  }
+
+  private File unzipExportedLogs() throws IOException {
+    File locatorWorkingDir = locator.getWorkingDir();
+    List<File> filesInDir = Stream.of(locatorWorkingDir.listFiles()).collect(toList());
+    assertThat(filesInDir).isNotEmpty();
+
+
+    List<File> zipFilesInDir = Stream.of(locatorWorkingDir.listFiles())
+        .filter(f -> f.getName().endsWith(".zip")).collect(toList());
+    assertThat(zipFilesInDir)
+        .describedAs(filesInDir.stream().map(File::getAbsolutePath).collect(joining(",")))
+        .hasSize(1);
+
+    File unzippedLogFileDir = lsRule.getTempFolder().newFolder("unzippedLogs");
+    ZipUtils.unzip(zipFilesInDir.get(0).getCanonicalPath(), unzippedLogFileDir.getCanonicalPath());
+    return unzippedLogFileDir;
+  }
+
+  private List<LogLine> listOfLogLines(Member member, String... levels) {
+    return Stream.of(levels).map(level -> new LogLine(member, level)).collect(toList());
+  }
+
+  private static void verifyExportLogsRegionWasDestroyed() {
+    Cache cache = GemFireCacheImpl.getInstance();
+    assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
+  }
+
+  public static class LogLine implements Serializable {
+    String level;
+    String message;
+    boolean shouldBeIgnoredDueToTimestamp;
+
+    public LogLine(String message, String level, boolean shouldBeIgnoredDueToTimestamp) {
+      this.message = message;
+      this.level = level;
+      this.shouldBeIgnoredDueToTimestamp = shouldBeIgnoredDueToTimestamp;
+    }
+
+    public LogLine(Member member, String level) {
+      this.level = level;
+      this.message = buildMessage(member.getName());
+    }
+
+    public String getMessage() {
+      return message;
+    }
+
+    private String buildMessage(String memberName) {
+      StringBuilder stringBuilder = new StringBuilder();
+      if (Objects.equals(level, "error")) {
+        stringBuilder.append(ERROR_LOG_PREFIX + "-");
+      }
+      stringBuilder.append(level + "-");
+
+      return stringBuilder.append(memberName).toString();
+    }
+
+
+    public void writeLog(Logger logger) {
+      switch (this.level) {
+        case "info":
+          logger.info(getMessage());
+          break;
+        case "error":
+          logger.error(getMessage());
+          break;
+        case "debug":
+          logger.debug(getMessage());
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptorJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptorJUnitTest.java
new file mode 100644
index 0000000..97ed686
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptorJUnitTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.management.internal.cli.commands;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.GfshParseResult;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.Mockito;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Category(UnitTest.class)
+public class ExportLogsInterceptorJUnitTest {
+  private ExportLogCommand.ExportLogsInterceptor interceptor;
+  private GfshParseResult parseResult;
+  private Map<String, String> arguments;
+  private Result result;
+
+  @Before
+  public void before() {
+    interceptor = new ExportLogCommand.ExportLogsInterceptor();
+    parseResult = Mockito.mock(GfshParseResult.class);
+    arguments = new HashMap<>();
+    arguments.put("log-level", "info");
+    when(parseResult.getParamValueStrings()).thenReturn(arguments);
+  }
+
+  @Test
+  public void testGroupAndMember() {
+    arguments.put("group", "group");
+    arguments.put("member", "member");
+    result = interceptor.preExecution(parseResult);
+    assertThat(result.nextLine()).contains("Can't specify both group and member");
+  }
+
+  @Test
+  public void testLogLevel() {
+    arguments.put("log-level", "test");
+    result = interceptor.preExecution(parseResult);
+    assertThat(result.nextLine()).contains("Invalid log level: test");
+  }
+
+  @Test
+  public void testStartEnd() {
+    arguments.put("start-time", "2000/01/01");
+    arguments.put("end-time", "2000/01/02");
+    result = interceptor.preExecution(parseResult);
+    assertThat(result.nextLine()).isEmpty();
+
+    arguments.put("start-time", "2000/01/02");
+    arguments.put("end-time", "2000/01/01");
+    result = interceptor.preExecution(parseResult);
+    assertThat(result.nextLine()).contains("start-time has to be earlier than end-time");
+  }
+
+  @Test
+  public void testInclideStats() {
+    arguments.put("logs-only", "true");
+    arguments.put("stats-only", "false");
+    result = interceptor.preExecution(parseResult);
+    assertThat(result.nextLine()).isEmpty();
+
+    arguments.put("logs-only", "true");
+    arguments.put("stats-only", "true");
+    result = interceptor.preExecution(parseResult);
+    assertThat(result.nextLine()).contains("logs-only and stats-only can't both be true");
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
new file mode 100644
index 0000000..f1ba7ef
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
@@ -0,0 +1,153 @@
+/*
+ * 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.management.internal.cli.commands;
+
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
+import static org.apache.geode.management.internal.cli.commands.ExportLogCommand.ONLY_DATE_FORMAT;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.google.common.collect.Sets;
+
+import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.Locator;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+@Category(DistributedTest.class)
+public class ExportStatsDUnitTest {
+  @ClassRule
+  public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+
+  @ClassRule
+  public static GfshShellConnectionRule connector = new GfshShellConnectionRule();
+
+  protected static int jmxPort, httpPort;
+  protected static Set<String> expectedZipEntries = new HashSet<>();
+  protected static Locator locator;
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    httpPort = ports[0];
+    jmxPort = ports[1];
+    Properties locatorProperties = new Properties();
+    locatorProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
+    locatorProperties.setProperty(HTTP_SERVICE_PORT, httpPort + "");
+    locatorProperties.setProperty(JMX_MANAGER_PORT, jmxPort + "");
+
+    // start the locator in vm0 and then connect to it over http
+    locator = lsRule.startLocatorVM(0, locatorProperties);
+
+    Properties serverProperties = new Properties();
+    serverProperties.setProperty(ConfigurationProperties.STATISTIC_SAMPLING_ENABLED, "true");
+    serverProperties.setProperty(STATISTIC_ARCHIVE_FILE, "statistics.gfs");
+    lsRule.startServerVM(1, serverProperties, locator.getPort());
+
+    expectedZipEntries = Sets.newHashSet("locator-0/locator-0.log", "server-1/server-1.log",
+        "server-1/statistics.gfs");
+  }
+
+  protected void connectIfNeeded() throws Exception {
+    if (!connector.isConnected()) {
+      connector.connect(locator);
+    }
+  }
+
+  @Test
+  public void testExportLogsAndStats() throws Exception {
+    connectIfNeeded();
+    connector.executeAndVerifyCommand("export logs");
+    String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
+    Set<String> actualZipEnries = getZipEntries(zipPath);
+
+    Set<String> expectedFiles = Sets.newHashSet("locator-0/locator-0.log", "server-1/server-1.log",
+        "server-1/statistics.gfs");
+    assertThat(actualZipEnries).isEqualTo(expectedFiles);
+  }
+
+  @Test
+  public void testExportLogsOnly() throws Exception {
+    connectIfNeeded();
+    connector.executeAndVerifyCommand("export logs --logs-only");
+    String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
+    Set<String> actualZipEnries = getZipEntries(zipPath);
+
+    Set<String> expectedFiles = Sets.newHashSet("locator-0/locator-0.log", "server-1/server-1.log");
+    assertThat(actualZipEnries).isEqualTo(expectedFiles);
+  }
+
+  @Test
+  public void testExportStatsOnly() throws Exception {
+    connectIfNeeded();
+    connector.executeAndVerifyCommand("export logs --stats-only");
+    String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
+    Set<String> actualZipEnries = getZipEntries(zipPath);
+
+    Set<String> expectedFiles = Sets.newHashSet("server-1/statistics.gfs");
+    assertThat(actualZipEnries).isEqualTo(expectedFiles);
+  }
+
+  @Test
+  public void startAndEndDateCanExcludeLogs() throws Exception {
+    connectIfNeeded();
+    ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault());
+    ZonedDateTime yesterday = now.minusDays(1);
+    ZonedDateTime twoDaysAgo = now.minusDays(2);
+
+    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
+
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
+    commandStringBuilder.addOption("start-time", dateTimeFormatter.format(twoDaysAgo));
+    commandStringBuilder.addOption("end-time", dateTimeFormatter.format(yesterday));
+    commandStringBuilder.addOption("log-level", "debug");
+
+    connector.executeAndVerifyCommand(commandStringBuilder.toString());
+    String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
+
+    Set<String> actualZipEnries = getZipEntries(zipPath);
+    assertThat(actualZipEnries).hasSize(0);
+  }
+
+  protected String getZipPathFromCommandResult(String message) {
+    return message.replaceAll("Logs exported to the connected member's file system: ", "").trim();
+  }
+
+  private static Set<String> getZipEntries(String zipFilePath) throws IOException {
+    return new ZipFile(zipFilePath).stream().map(ZipEntry::getName).collect(Collectors.toSet());
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
index bb083be..72c39dc 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
@@ -25,15 +25,14 @@ import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.ResultSender;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.execute.FunctionContextImpl;
+import org.apache.geode.test.dunit.rules.Server;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.junit.After;
+import org.apache.logging.log4j.Level;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
 
 import java.io.File;
 import java.io.IOException;
@@ -42,28 +41,15 @@ import java.io.IOException;
 public class ExportLogsFunctionIntegrationTest {
 
   @Rule
-  public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
-  @Rule
-  public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-
-  @Rule
   public ServerStarterRule serverStarterRule = new ServerStarterRule();
 
+  private Server server;
   private File serverWorkingDir;
 
   @Before
   public void setup() throws Exception {
-    serverWorkingDir = temporaryFolder.newFolder("serverWorkingDir");
-    System.setProperty("user.dir", serverWorkingDir.getCanonicalPath());
-    // fix a ci pipeline glitch
-    System.clearProperty("user.home");
-    serverStarterRule.startServer();
-  }
-
-  @After
-  public void teardown() {
-    serverStarterRule.after();
+    server = serverStarterRule.startServer();
+    serverWorkingDir = server.getWorkingDir();
   }
 
   @Test
@@ -76,7 +62,15 @@ public class ExportLogsFunctionIntegrationTest {
     File notALogFile = new File(serverWorkingDir, "foo.txt");
     FileUtils.writeStringToFile(notALogFile, "some text");
 
-    ExportLogsFunction.Args args = new ExportLogsFunction.Args(null, null, "info", false);
+    verifyExportLogsFunctionDoesNotBlowUp();
+
+    Cache cache = GemFireCacheImpl.getInstance();
+    assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isEmpty();
+  }
+
+  public static void verifyExportLogsFunctionDoesNotBlowUp() throws Throwable {
+    ExportLogsFunction.Args args =
+        new ExportLogsFunction.Args(null, null, "info", false, false, false);
 
     CapturingResultSender resultSender = new CapturingResultSender();
     FunctionContext context = new FunctionContextImpl("functionId", args, resultSender);
@@ -86,38 +80,45 @@ public class ExportLogsFunctionIntegrationTest {
     if (resultSender.getThrowable() != null) {
       throw resultSender.getThrowable();
     }
-
-    Cache cache = GemFireCacheImpl.getInstance();
-    assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isEmpty();
   }
 
   @Test
   public void createOrGetExistingExportLogsRegionDoesNotBlowUp() throws Exception {
-    ExportLogsFunction.createOrGetExistingExportLogsRegion(false);
-
-    Cache cache = GemFireCacheImpl.getInstance();
+    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    ExportLogsFunction.createOrGetExistingExportLogsRegion(false, cache);
     assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
   }
 
   @Test
   public void destroyExportLogsRegionWorksAsExpectedForInitiatingMember()
       throws IOException, ClassNotFoundException {
-    ExportLogsFunction.createOrGetExistingExportLogsRegion(true);
-    Cache cache = GemFireCacheImpl.getInstance();
+    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    ExportLogsFunction.createOrGetExistingExportLogsRegion(true, cache);
     assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
 
-    ExportLogsFunction.destroyExportLogsRegion();
+    ExportLogsFunction.destroyExportLogsRegion(cache);
     assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
   }
 
 
   @Test
   public void argsCorrectlyBuildALogLevelFilter() {
-    ExportLogsFunction.Args args = new ExportLogsFunction.Args(null, null, "info", false);
+    ExportLogsFunction.Args args =
+        new ExportLogsFunction.Args(null, null, "info", false, false, false);
+    assertThat(args.getLogLevel().toString()).isEqualTo("INFO");
+    assertThat(args.isThisLogLevelOnly()).isFalse();
+    assertThat(args.isIncludeLogs()).isTrue();
+    assertThat(args.isIncludeStats()).isTrue();
+  }
 
-    assertThat(args.getPermittedLogLevels()).contains("info");
-    assertThat(args.getPermittedLogLevels()).contains("error");
-    assertThat(args.getPermittedLogLevels()).doesNotContain("fine");
+  @Test
+  public void argsCorrectlyBuilt() {
+    ExportLogsFunction.Args args =
+        new ExportLogsFunction.Args(null, null, "error", true, true, false);
+    assertThat(args.getLogLevel()).isEqualTo(Level.ERROR);
+    assertThat(args.isThisLogLevelOnly()).isTrue();
+    assertThat(args.isIncludeLogs()).isTrue();
+    assertThat(args.isIncludeStats()).isFalse();
   }
 
   private static class CapturingResultSender implements ResultSender {

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriterUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriterUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriterUnitTest.java
new file mode 100644
index 0000000..27becc5
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriterUnitTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.management.internal.cli.util;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.geode.cache.EntryEvent;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class ExportLogsCacheWriterUnitTest {
+  private ExportLogsCacheWriter writer = new ExportLogsCacheWriter();
+
+  @Test
+  public void writerReturnNullIfNoWrite() throws Exception {
+    writer.startFile("server-1");
+    assertThat(writer.endFile()).isNull();
+  }
+
+  @Test
+  public void writerReturnsPathIfWritten() throws Exception {
+    writer.startFile("server-1");
+    EntryEvent event = mock(EntryEvent.class);
+    when(event.getNewValue()).thenReturn(new byte[] {});
+    writer.beforeCreate(event);
+    assertThat(writer.endFile()).isNotNull();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
new file mode 100644
index 0000000..0df00b0
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
@@ -0,0 +1,164 @@
+/*
+ * 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.management.internal.cli.util;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.google.common.collect.Sets;
+
+import org.apache.geode.management.internal.cli.functions.ExportLogsFunctionIntegrationTest;
+import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.logging.log4j.Level;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+@Category(IntegrationTest.class)
+public class LogExporterIntegrationTest {
+
+  @Rule
+  public ServerStarterRule serverStarterRule = new ServerStarterRule();
+
+  private LogExporter logExporter;
+
+  private Properties properties;
+
+  private LogFilter filter = new LogFilter(Level.INFO, null, null);
+
+  @Before
+  public void before() throws Exception {
+    properties = new Properties();
+  }
+
+  @Test
+  public void serverStartedWithWrongSuffix() throws Exception {
+    properties.setProperty(LOG_FILE, new File("test.txt").getAbsolutePath());
+    properties.setProperty(STATISTIC_ARCHIVE_FILE, "archive.archive");
+    Server server = serverStarterRule.startServer(properties);
+    File serverWorkingDir = server.getWorkingDir();
+
+    logExporter = new LogExporter(filter, new File(serverWorkingDir, "test.log"),
+        new File(serverWorkingDir, "stats.gfs"));
+    List<Path> logFiles = logExporter.findLogFiles(serverWorkingDir.toPath());
+    assertThat(logFiles).isEmpty();
+
+    List<Path> statsFiles = logExporter.findStatFiles(serverWorkingDir.toPath());
+    assertThat(statsFiles).isEmpty();
+  }
+
+  @Test
+  public void serverStartedWithCorrectSuffix() throws Exception {
+    // ("relative log file is problematic in the test environment")
+    properties.setProperty(LOG_FILE, new File("test.log").getAbsolutePath());
+    properties.setProperty(STATISTIC_ARCHIVE_FILE, "archive.gfs");
+    Server server = serverStarterRule.startServer(properties);
+    File serverWorkingDir = server.getWorkingDir();
+
+    logExporter = new LogExporter(filter, new File(serverWorkingDir, "test.log"),
+        new File(serverWorkingDir, "archive.gfs"));
+    List<Path> logFiles = logExporter.findLogFiles(serverWorkingDir.toPath());
+    assertThat(logFiles).hasSize(1);
+    assertThat(logFiles.get(0)).hasFileName("test.log");
+
+    List<Path> statsFiles = logExporter.findStatFiles(serverWorkingDir.toPath());
+    assertThat(statsFiles).hasSize(1);
+    assertThat(statsFiles.get(0)).hasFileName("archive.gfs");
+  }
+
+  @Test
+  @Ignore("fix .gz suffix")
+  public void serverStartedWithGZSuffix() throws Exception {
+    properties.setProperty(LOG_FILE, "test.log.gz");
+    properties.setProperty(STATISTIC_ARCHIVE_FILE, "archive.gfs.gz");
+    Server server = serverStarterRule.startServer(properties);
+    File serverWorkingDir = server.getWorkingDir();
+
+    logExporter = new LogExporter(filter, new File(serverWorkingDir, "test.log"),
+        new File(serverWorkingDir, "stats.gfs"));
+    List<Path> logFiles = logExporter.findLogFiles(serverWorkingDir.toPath());
+    assertThat(logFiles).hasSize(1);
+
+    List<Path> statsFiles = logExporter.findStatFiles(serverWorkingDir.toPath());
+    assertThat(statsFiles).hasSize(1);
+  }
+
+  @Test
+  public void testNoStatsFile() throws Throwable {
+    Path logsFile = Files.createTempFile("server", ".log");
+    properties.setProperty(LOG_FILE, logsFile.toString());
+    serverStarterRule.startServer(properties);
+
+    ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp();
+  }
+
+  @Test
+  public void testWithRelativeStatsFile() throws Throwable {
+    Path logsFile = Files.createTempFile("server", ".log");
+    // Path statsFile = Files.createTempFile("stats", ".gfs");
+    properties.setProperty(LOG_FILE, logsFile.toString());
+    properties.setProperty(STATISTIC_ARCHIVE_FILE, "stats.gfs");
+    serverStarterRule.startServer(properties);
+
+    ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp();
+  }
+
+  @Test
+  public void testWithRelativeLogsFile() throws Throwable {
+    Path statsFile = Files.createTempFile("stats", ".gfs");
+    properties.setProperty(LOG_FILE, "sever.log");
+    properties.setProperty(STATISTIC_ARCHIVE_FILE, statsFile.toString());
+    Server server = serverStarterRule.startServer(properties);
+
+    ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp();
+  }
+
+  @Test
+  public void testWithAbsoluteLogsStatsFile() throws Exception {
+    File logsDir = Files.createTempDirectory("logs").toFile();
+    File statsDir = Files.createTempDirectory("stats").toFile();
+
+    File logFile = new File(logsDir, "server.log");
+    File statsFile = new File(statsDir, "stats.gfs");
+
+    properties.setProperty(LOG_FILE, logFile.getAbsolutePath());
+    properties.setProperty(STATISTIC_ARCHIVE_FILE, statsFile.getAbsolutePath());
+
+    serverStarterRule.startServer(properties);
+
+    logExporter = new LogExporter(filter, logFile, statsFile);
+    Path exportedZip = logExporter.export();
+    Set<String> actualFiles = LogExporterTest.getZipEntries(exportedZip.toString());
+    Set<String> expectedFiles = Sets.newHashSet("server.log", "stats.gfs");
+
+    assertThat(actualFiles).isEqualTo(expectedFiles);
+
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java
index 4cb76d3..a387af3 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java
@@ -31,12 +31,18 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.TemporaryFolder;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
 import java.nio.file.Path;
-import java.text.ParseException;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
 
 @Category(IntegrationTest.class)
 public class LogExporterTest {
@@ -44,31 +50,56 @@ public class LogExporterTest {
   public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
   private LogExporter logExporter;
+  LogFilter logFilter;
+  private File workingDir;
 
   @Before
-  public void setup() throws ParseException {
-    LogFilter logFilter = mock(LogFilter.class);
+  public void setup() throws Exception {
+    logFilter = mock(LogFilter.class);
 
     when(logFilter.acceptsFile(any())).thenReturn(true);
     when(logFilter.acceptsLine(any())).thenReturn(LogFilter.LineFilterResult.LINE_ACCEPTED);
 
-    logExporter = new LogExporter(logFilter);
+    workingDir = temporaryFolder.newFolder("workingDir");
+    logExporter = new LogExporter(logFilter, new File(workingDir, "server.log"),
+        new File(workingDir, "stats.gfs"));
   }
 
+  @Test
+  public void exporterShouldReturnNullIfNoFile() throws Exception {
+    assertThat(logExporter.export()).isNull();
+  }
+
+  @Test
+  public void exporterShouldStillReturnFilefNoAcceptableLogs() throws Exception {
+    File logFile1 = new File(workingDir, "server1.log");
+    FileUtils.writeStringToFile(logFile1, "some log for server1 \n some other log line");
+    when(logFilter.acceptsLine(any())).thenReturn(LogFilter.LineFilterResult.LINE_REJECTED);
+    Path exportedZip = logExporter.export();
+    assertThat(exportedZip).isNotNull();
+
+    File unzippedExportDir = temporaryFolder.newFolder("unzippedExport");
+    ZipUtils.unzip(exportedZip.toString(), unzippedExportDir.getCanonicalPath());
+    assertThat(unzippedExportDir.listFiles()).hasSize(1);
+
+    // check the exported file has no content
+    BufferedReader br =
+        new BufferedReader(new FileReader(new File(unzippedExportDir, "server1.log")));
+    assertThat(br.readLine()).isNull();
+  }
 
   @Test
   public void exportBuildsZipCorrectlyWithTwoLogFiles() throws Exception {
-    File serverWorkingDir = temporaryFolder.newFolder("serverWorkingDir");
-    File logFile1 = new File(serverWorkingDir, "server1.log");
+    File logFile1 = new File(workingDir, "server1.log");
     FileUtils.writeStringToFile(logFile1, "some log for server1 \n some other log line");
-    File logFile2 = new File(serverWorkingDir, "server2.log");
+    File logFile2 = new File(workingDir, "server2.log");
     FileUtils.writeStringToFile(logFile2, "some log for server2 \n some other log line");
 
-    File notALogFile = new File(serverWorkingDir, "foo.txt");
+    File notALogFile = new File(workingDir, "foo.txt");
     FileUtils.writeStringToFile(notALogFile, "some text");
 
 
-    Path zippedExport = logExporter.export(serverWorkingDir.toPath());
+    Path zippedExport = logExporter.export();
 
     File unzippedExportDir = temporaryFolder.newFolder("unzippedExport");
     ZipUtils.unzip(zippedExport.toString(), unzippedExportDir.getCanonicalPath());
@@ -83,7 +114,6 @@ public class LogExporterTest {
 
   @Test
   public void findLogFilesExcludesFilesWithIncorrectExtension() throws Exception {
-    File workingDir = temporaryFolder.newFolder("workingDir");
     File logFile = new File(workingDir, "server.log");
 
     FileUtils.writeStringToFile(logFile, "some log line");
@@ -95,4 +125,21 @@ public class LogExporterTest {
     assertThat(logExporter.findLogFiles(workingDir.toPath())).doesNotContain(notALogFile.toPath());
   }
 
+  @Test
+  public void findStatFiles() throws Exception {
+    File statFile = new File(workingDir, "server.gfs");
+
+    FileUtils.writeStringToFile(statFile, "some stat line");
+
+    File notALogFile = new File(workingDir, "foo.txt");
+    FileUtils.writeStringToFile(notALogFile, "some text");
+
+    assertThat(logExporter.findStatFiles(workingDir.toPath())).contains(statFile.toPath());
+    assertThat(logExporter.findStatFiles(workingDir.toPath())).doesNotContain(notALogFile.toPath());
+  }
+
+  public static Set<String> getZipEntries(String zipFilePath) throws IOException {
+    return new ZipFile(zipFilePath).stream().map(ZipEntry::getName).collect(Collectors.toSet());
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java
index ca94fb6..d29e4de 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java
@@ -16,33 +16,59 @@
 
 package org.apache.geode.management.internal.cli.util;
 
-import static java.util.stream.Collectors.toSet;
 import static org.apache.geode.management.internal.cli.util.LogFilter.LineFilterResult.LINE_ACCEPTED;
 import static org.apache.geode.management.internal.cli.util.LogFilter.LineFilterResult.LINE_REJECTED;
 import static org.apache.geode.management.internal.cli.util.LogFilter.LineFilterResult.REMAINDER_OF_FILE_REJECTED;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.logging.log4j.Level;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import java.io.File;
+import java.nio.file.FileSystem;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.FileTime;
+import java.nio.file.spi.FileSystemProvider;
 import java.time.LocalDateTime;
-import java.util.Set;
-import java.util.stream.Stream;
 
 @Category(UnitTest.class)
 public class LogFilterTest {
   @Test
   public void permittedLogLevelsCanFilterLines() throws Exception {
-    Set<String> permittedLogLevels = Stream.of("info", "finest").collect(toSet());
+    LogFilter logFilter = new LogFilter(Level.INFO, null, null);
 
-    LogFilter logFilter = new LogFilter(permittedLogLevels, null, null);
+    LocalDateTime now = LocalDateTime.now();
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, now)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(Level.WARN, now)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(Level.DEBUG, now)).isEqualTo(LINE_REJECTED);
+    assertThat(logFilter.acceptsLogEntry(Level.TRACE, now)).isEqualTo(LINE_REJECTED);
+  }
+
+  @Test
+  public void permittedOnlyLogLevels() throws Exception {
+    LogFilter logFilter = new LogFilter(Level.INFO, true, null, null);
+
+    LocalDateTime now = LocalDateTime.now();
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, now)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(Level.WARN, now)).isEqualTo(LINE_REJECTED);
+    assertThat(logFilter.acceptsLogEntry(Level.DEBUG, now)).isEqualTo(LINE_REJECTED);
+    assertThat(logFilter.acceptsLogEntry(Level.TRACE, now)).isEqualTo(LINE_REJECTED);
+  }
+
+  @Test
+  public void permittedLogLevelsALL() throws Exception {
+    LogFilter logFilter = new LogFilter(Level.ALL, null, null);
 
     LocalDateTime now = LocalDateTime.now();
-    assertThat(logFilter.acceptsLogEntry("info", now)).isEqualTo(LINE_ACCEPTED);
-    assertThat(logFilter.acceptsLogEntry("finest", now)).isEqualTo(LINE_ACCEPTED);
-    assertThat(logFilter.acceptsLogEntry("fine", now)).isEqualTo(LINE_REJECTED);
-    assertThat(logFilter.acceptsLogEntry("error", now)).isEqualTo(LINE_REJECTED);
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, now)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(Level.WARN, now)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(Level.DEBUG, now)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(Level.TRACE, now)).isEqualTo(LINE_ACCEPTED);
   }
 
 
@@ -50,13 +76,13 @@ public class LogFilterTest {
   public void startDateCanFilterLines() {
     LocalDateTime startDate = LocalDateTime.now().minusDays(2);
 
-    LogFilter logFilter = new LogFilter(null, startDate, null);
+    LogFilter logFilter = new LogFilter(Level.ALL, startDate, null);
 
-    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now())).isEqualTo(LINE_ACCEPTED);
-    assertThat(logFilter.acceptsLogEntry("info", startDate)).isEqualTo(LINE_ACCEPTED);
-    assertThat(logFilter.acceptsLogEntry("fine", startDate)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, LocalDateTime.now())).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, startDate)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(Level.DEBUG, startDate)).isEqualTo(LINE_ACCEPTED);
 
-    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(3)))
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, LocalDateTime.now().minusDays(3)))
         .isEqualTo(LINE_REJECTED);
   }
 
@@ -64,15 +90,15 @@ public class LogFilterTest {
   public void endDateCanFilterLines() {
     LocalDateTime endDate = LocalDateTime.now().minusDays(2);
 
-    LogFilter logFilter = new LogFilter(null, null, endDate);
+    LogFilter logFilter = new LogFilter(Level.ALL, null, endDate);
 
-    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(3)))
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, LocalDateTime.now().minusDays(3)))
         .isEqualTo(LINE_ACCEPTED);
 
-    assertThat(logFilter.acceptsLogEntry("info", endDate)).isEqualTo(LINE_ACCEPTED);
-    assertThat(logFilter.acceptsLogEntry("fine", endDate)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, endDate)).isEqualTo(LINE_ACCEPTED);
+    assertThat(logFilter.acceptsLogEntry(Level.DEBUG, endDate)).isEqualTo(LINE_ACCEPTED);
 
-    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now()))
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, LocalDateTime.now()))
         .isEqualTo(REMAINDER_OF_FILE_REJECTED);
   }
 
@@ -81,46 +107,107 @@ public class LogFilterTest {
     LocalDateTime startDate = LocalDateTime.now().minusDays(5);
     LocalDateTime endDate = LocalDateTime.now().minusDays(2);
 
-    Set<String> permittedLogLevels = Stream.of("info", "finest").collect(toSet());
+    LogFilter logFilter = new LogFilter(Level.INFO, startDate, endDate);
 
-    LogFilter logFilter = new LogFilter(permittedLogLevels, startDate, endDate);
-
-
-    assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now().minusDays(6)))
+    assertThat(logFilter.acceptsLogEntry(Level.ERROR, LocalDateTime.now().minusDays(6)))
         .isEqualTo(LINE_REJECTED);
-    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(6)))
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, LocalDateTime.now().minusDays(6)))
         .isEqualTo(LINE_REJECTED);
 
     assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_REJECTED);
 
 
-    assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now().minusDays(4)))
+    assertThat(logFilter.acceptsLogEntry(Level.ERROR, LocalDateTime.now().minusDays(6)))
         .isEqualTo(LINE_REJECTED);
     assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_REJECTED);
 
-    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(4)))
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, LocalDateTime.now().minusDays(4)))
         .isEqualTo(LINE_ACCEPTED);
     assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_ACCEPTED);
 
 
 
-    assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now().minusDays(1)))
+    assertThat(logFilter.acceptsLogEntry(Level.ERROR, LocalDateTime.now().minusDays(1)))
         .isEqualTo(REMAINDER_OF_FILE_REJECTED);
     assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(REMAINDER_OF_FILE_REJECTED);
 
-    assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(1)))
+    assertThat(logFilter.acceptsLogEntry(Level.INFO, LocalDateTime.now().minusDays(1)))
         .isEqualTo(REMAINDER_OF_FILE_REJECTED);
   }
 
   @Test
   public void firstLinesAreAcceptedIfParsableLineHasNotBeenSeenYet() {
-    LogFilter logFilter = new LogFilter(Stream.of("info").collect(toSet()), null, null);
+    LogFilter logFilter = new LogFilter(Level.INFO, null, null);
 
     assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_ACCEPTED);
     assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_ACCEPTED);
 
-    assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now())).isEqualTo(LINE_REJECTED);
+    assertThat(logFilter.acceptsLogEntry(Level.DEBUG, LocalDateTime.now()))
+        .isEqualTo(LINE_REJECTED);
     assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_REJECTED);
+  }
 
+  @Test
+  public void testAcceptFileWithCreateTimeNotAvailale() throws Exception {
+    Path path = mock(Path.class);
+    when(path.toFile()).thenReturn(mock(File.class));
+    when(path.toFile().lastModified()).thenReturn(System.currentTimeMillis());
+    when(path.getFileSystem()).thenThrow(SecurityException.class);
+
+    // a filter with no start/end date should accept this file
+    LogFilter filter = new LogFilter(Level.INFO, null, null);
+    assertThat(filter.acceptsFile(path)).isTrue();
+
+    // a filter with a start date of now should not accept the file
+    filter = new LogFilter(Level.INFO, LocalDateTime.now(), null);
+    assertThat(filter.acceptsFile(path)).isFalse();
+
+    // a filter with a start date of now minus an hour should not accept the file
+    filter = new LogFilter(Level.INFO, LocalDateTime.now().minusHours(1), null);
+    assertThat(filter.acceptsFile(path)).isTrue();
+
+    // a filter with an end date of now should accept the file
+    filter = new LogFilter(Level.INFO, null, LocalDateTime.now());
+    assertThat(filter.acceptsFile(path)).isTrue();
+
+    // a filter with an end date of an hour ago should also accept the file, because we only
+    // know the last modified time of the file, when don't know what time this file is created, it
+    // may still be created more than an hour ago.
+    filter = new LogFilter(Level.INFO, null, LocalDateTime.now().minusHours(1));
+    assertThat(filter.acceptsFile(path)).isTrue();
+  }
+
+  @Test
+  public void testAcceptFileWithCreateTimeAvailable() throws Exception {
+    long now = System.currentTimeMillis();
+    Path path = mock(Path.class);
+    when(path.toFile()).thenReturn(mock(File.class));
+    when(path.toFile().lastModified()).thenReturn(System.currentTimeMillis());
+    BasicFileAttributes attributes = mock(BasicFileAttributes.class);
+    when(path.getFileSystem()).thenReturn(mock(FileSystem.class));
+    when(path.getFileSystem().provider()).thenReturn(mock(FileSystemProvider.class));
+    when(path.getFileSystem().provider().readAttributes(path, BasicFileAttributes.class))
+        .thenReturn(attributes);
+    when(attributes.creationTime()).thenReturn(FileTime.fromMillis(now - 10000));
+
+    // a filter with no start/end date should accept this file
+    LogFilter filter = new LogFilter(Level.INFO, null, null);
+    assertThat(filter.acceptsFile(path)).isTrue();
+
+    // a filter with a start date of now should not accept the file
+    filter = new LogFilter(Level.INFO, LocalDateTime.now(), null);
+    assertThat(filter.acceptsFile(path)).isFalse();
+
+    // a filter with a start date of now minus an hour should not accept the file
+    filter = new LogFilter(Level.INFO, LocalDateTime.now().minusHours(1), null);
+    assertThat(filter.acceptsFile(path)).isTrue();
+
+    // a filter with an end date of now should accept the file
+    filter = new LogFilter(Level.INFO, null, LocalDateTime.now());
+    assertThat(filter.acceptsFile(path)).isTrue();
+
+    // a filter with an end date of an hour ago should not accept the file
+    filter = new LogFilter(Level.INFO, null, LocalDateTime.now().minusHours(1));
+    assertThat(filter.acceptsFile(path)).isFalse();
   }
 }


[37/50] [abbrv] geode git commit: GEODE-2267: Enhance server/locator startup rules

Posted by ds...@apache.org.
GEODE-2267: Enhance server/locator startup rules

* be able to return the rule itself so that we can start the server/locator at rule declaration time.
* rearrange the class structure
* do not delete the workingDir if the rule is created with a workingDir (then it's up for the caller to delete it)


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/5ca8dda8
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/5ca8dda8
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/5ca8dda8

Branch: refs/heads/feature/GEODE-1969
Commit: 5ca8dda8e8f10f7f548e075a352b63051a6904cf
Parents: c7c28f0
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Thu Mar 2 15:58:18 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:29 2017 -0800

----------------------------------------------------------------------
 .../web/RestSecurityIntegrationTest.java        |  5 +-
 .../web/RestSecurityPostProcessorTest.java      |  5 +-
 .../geode/tools/pulse/PulseDataExportTest.java  |  6 +-
 .../ConnectToLocatorSSLDUnitTest.java           |  4 +-
 .../internal/cli/NetstatDUnitTest.java          |  4 +-
 .../cli/commands/ExportLogsDUnitTest.java       | 15 ++--
 .../ExportLogsOnServerManagerDUnit.java         |  7 +-
 .../cli/commands/ExportStatsDUnitTest.java      |  4 +-
 .../internal/cli/util/MergeLogsDUnitTest.java   |  9 +-
 .../internal/configuration/ClusterConfig.java   | 28 +++---
 .../ClusterConfigDeployJarDUnitTest.java        | 29 +++---
 .../ClusterConfigDistributionDUnitTest.java     |  9 +-
 .../ClusterConfigImportDUnitTest.java           | 45 +++++-----
 .../ClusterConfigStartMemberDUnitTest.java      | 19 ++--
 .../ClusterConfigWithSecurityDUnitTest.java     | 10 +--
 .../security/CacheServerStartupRule.java        |  6 +-
 .../security/GfshCommandsPostProcessorTest.java |  6 +-
 .../security/GfshCommandsSecurityTest.java      |  5 +-
 .../security/AbstractSecureServerDUnitTest.java |  8 +-
 .../ClusterConfigWithoutSecurityDUnitTest.java  |  2 +-
 .../SecurityClusterConfigDUnitTest.java         |  4 +-
 .../SecurityWithoutClusterConfigDUnitTest.java  |  2 +-
 .../security/StartServerAuthorizationTest.java  |  3 +-
 .../dunit/rules/GfshShellConnectionRule.java    |  4 +-
 .../apache/geode/test/dunit/rules/Locator.java  |  9 +-
 .../dunit/rules/LocatorServerStartupRule.java   | 34 ++++---
 .../test/dunit/rules/LocatorStarterRule.java    | 54 ++++-------
 .../apache/geode/test/dunit/rules/Member.java   | 53 ++---------
 .../test/dunit/rules/MemberStarterRule.java     | 84 +++++++++++++++++
 .../apache/geode/test/dunit/rules/MemberVM.java | 67 ++++++++++++++
 .../apache/geode/test/dunit/rules/Server.java   | 12 +--
 .../test/dunit/rules/ServerStarterRule.java     | 95 ++++++++++----------
 .../LuceneClusterConfigurationDUnitTest.java    | 51 ++++++-----
 33 files changed, 391 insertions(+), 307 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
index 75a3c2c..85fc5be 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
@@ -58,13 +58,12 @@ public class RestSecurityIntegrationTest {
   };
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
   private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
 
   @BeforeClass
   public static void before() throws Exception {
-    serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
+    serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
index 933f7b2..82e9b7f 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
@@ -65,14 +65,13 @@ public class RestSecurityPostProcessorTest {
   };
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
   private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
 
   @BeforeClass
   public static void before() throws Exception {
-    serverStarter.startServer(properties);
     Region region =
-        serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("customers");
+        serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("customers");
     region.put("1", new Customer(1L, "John", "Doe", "555555555"));
     region.put("2", new Customer(2L, "Richard", "Roe", "222533554"));
     region.put("3", new Customer(3L, "Jane", "Doe", "555223333"));

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
index fa98ce6..b9e90b6 100644
--- a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
@@ -23,8 +23,8 @@ import org.apache.geode.cache.client.ClientCacheFactory;
 import org.apache.geode.cache.client.ClientRegionShortcut;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.http.Consts;
@@ -64,8 +64,8 @@ public class PulseDataExportTest {
   @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
 
-  private Locator locator;
-  private org.apache.geode.test.dunit.rules.Server server;
+  private MemberVM locator;
+  private MemberVM server;
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
   private HttpClient httpClient;

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
index 101c8f5..1033b6c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
@@ -39,8 +39,8 @@ import static org.apache.geode.util.test.TestUtil.getResourcePath;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.security.SecurableCommunicationChannels;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
 import org.junit.After;
@@ -83,7 +83,7 @@ public class ConnectToLocatorSSLDUnitTest {
   }
 
   private void setUpLocatorAndConnect(Properties securityProps) throws Exception {
-    Locator locator = lsRule.startLocatorVM(0, securityProps);
+    MemberVM locator = lsRule.startLocatorVM(0, securityProps);
 
     // saving the securityProps to a file
     OutputStream out = new FileOutputStream(securityPropsFile);

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
index 8ac993b..5b2d302 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
@@ -18,7 +18,7 @@ package org.apache.geode.management.internal.cli;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.junit.After;
@@ -58,7 +58,7 @@ public class NetstatDUnitTest {
     // start server with jmx Manager as well
     properties.remove("start-locator");
     properties.setProperty("jmx-manager-port", ports[2] + "");
-    Server server = lsRule.startServerVM(1, properties);
+    MemberVM server = lsRule.startServerVM(1, properties);
 
     // start server with no jmx Manager
     properties.setProperty("jmx-manager", "false");

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
index e882cce..bf1d9ea 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
@@ -34,10 +34,9 @@ import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.Member;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.logging.log4j.Logger;
@@ -72,11 +71,11 @@ public class ExportLogsDUnitTest {
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
 
-  private Locator locator;
-  private Server server1;
-  private Server server2;
+  private MemberVM locator;
+  private MemberVM server1;
+  private MemberVM server2;
 
-  private Map<Member, List<LogLine>> expectedMessages;
+  private Map<MemberVM, List<LogLine>> expectedMessages;
 
   @Before
   public void setup() throws Exception {
@@ -95,7 +94,7 @@ public class ExportLogsDUnitTest {
     expectedMessages.put(server2, listOfLogLines(server2, "info", "error", "debug"));
 
     // log the messages in each of the members
-    for (Member member : expectedMessages.keySet()) {
+    for (MemberVM member : expectedMessages.keySet()) {
       List<LogLine> logLines = expectedMessages.get(member);
 
       member.invoke(() -> {
@@ -241,7 +240,7 @@ public class ExportLogsDUnitTest {
       throws IOException {
 
     String memberName = dirForMember.getName();
-    Member member = expectedMessages.keySet().stream()
+    MemberVM member = expectedMessages.keySet().stream()
         .filter((Member aMember) -> aMember.getName().equals(memberName)).findFirst().get();
 
     assertThat(member).isNotNull();

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
index 92ef5f5..c2fde4d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
@@ -22,6 +22,7 @@ import com.google.common.collect.Sets;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.dunit.rules.Server;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Rule;
@@ -46,7 +47,7 @@ public class ExportLogsOnServerManagerDUnit {
   @Test
   public void testExportWithOneServer() throws Exception {
     int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
-    Server server0 = lsRule.startServerAsJmxManager(0, jmxPort);
+    MemberVM server0 = lsRule.startServerAsJmxManager(0, jmxPort);
     gfshConnector.connect(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
     gfshConnector.executeAndVerifyCommand("export logs");
 
@@ -66,8 +67,8 @@ public class ExportLogsOnServerManagerDUnit {
     int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
     int locatorPort = ports[0];
     int jmxPort = ports[1];
-    Server server0 = lsRule.startServerAsEmbededLocator(0, locatorPort, jmxPort);
-    Server server1 = lsRule.startServerVM(1, locatorPort);
+    MemberVM server0 = lsRule.startServerAsEmbededLocator(0, locatorPort, jmxPort);
+    MemberVM server1 = lsRule.startServerVM(1, locatorPort);
     gfshConnector.connect(locatorPort, GfshShellConnectionRule.PortType.locator);
     gfshConnector.executeAndVerifyCommand("export logs");
 

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
index f1ba7ef..b7f8c2a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
@@ -28,8 +28,8 @@ import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
@@ -58,7 +58,7 @@ public class ExportStatsDUnitTest {
 
   protected static int jmxPort, httpPort;
   protected static Set<String> expectedZipEntries = new HashSet<>();
-  protected static Locator locator;
+  protected static MemberVM locator;
 
   @BeforeClass
   public static void beforeClass() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
index 80b9868..9166642 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
@@ -22,9 +22,8 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.commons.io.FileUtils;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -41,7 +40,7 @@ import java.util.Properties;
 public class MergeLogsDUnitTest {
   @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
-  private Locator locator;
+  private MemberVM locator;
 
   private static final String MESSAGE_1 = "MergeLogsMessage1";
   private static final String MESSAGE_2 = "MergeLogsMessage2";
@@ -59,8 +58,8 @@ public class MergeLogsDUnitTest {
     properties.setProperty(DistributionConfig.LOCATORS_NAME,
         "localhost[" + locator.getPort() + "]");
 
-    Server server = lsRule.startServerVM(1, properties);
-    Server server2 = lsRule.startServerVM(2, properties);
+    MemberVM server = lsRule.startServerVM(1, properties);
+    MemberVM server2 = lsRule.startServerVM(2, properties);
 
     locator.invoke(() -> LogService.getLogger().info(MESSAGE_1));
     server.invoke(() -> LogService.getLogger().info(MESSAGE_2));

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
index 4ac9886..c3d7f5e 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
@@ -21,8 +21,8 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.geode.cache.Cache;
-import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
+import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.internal.ClassPathLoader;
 import org.apache.geode.internal.JarClassLoader;
 import org.apache.geode.internal.JarDeployer;
@@ -31,7 +31,7 @@ import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.internal.configuration.domain.Configuration;
 import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Member;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.dunit.rules.Server;
 
 import java.io.File;
@@ -77,21 +77,21 @@ public class ClusterConfig implements Serializable {
     return Collections.unmodifiableList(groups);
   }
 
-  public void verify(Locator locator) {
-    verifyLocator(locator);
-  }
 
-  public void verify(Server server) throws ClassNotFoundException {
-    verifyServer(server);
+  public void verify(MemberVM memberVM) throws ClassNotFoundException {
+    if (memberVM.isLocator())
+      verifyLocator(memberVM);
+    else
+      verifyServer(memberVM);
   }
 
-  public void verifyLocator(Member locator) {
+  public void verifyLocator(MemberVM<Locator> locatorVM) {
     Set<String> expectedGroupConfigs =
         this.getGroups().stream().map(ConfigGroup::getName).collect(Collectors.toSet());
 
     // verify info exists in memeory
-    locator.invoke(() -> {
-      InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.locator;
+    locatorVM.invoke(() -> {
+      InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.getLocator();
       ClusterConfigurationService sc = internalLocator.getSharedConfiguration();
 
       // verify no extra configs exist in memory
@@ -120,7 +120,7 @@ public class ClusterConfig implements Serializable {
 
     });
 
-    File clusterConfigDir = new File(locator.getWorkingDir(), "/cluster_config");
+    File clusterConfigDir = new File(locatorVM.getWorkingDir(), "/cluster_config");
 
     for (ConfigGroup configGroup : this.getGroups()) {
       Set<String> actualFiles =
@@ -131,16 +131,16 @@ public class ClusterConfig implements Serializable {
     }
   }
 
-  public void verifyServer(Member server) throws ClassNotFoundException {
+  public void verifyServer(MemberVM<Server> serverVM) throws ClassNotFoundException {
     // verify files exist in filesystem
     Set<String> expectedJarNames = this.getJarNames().stream().map(ClusterConfig::getServerJarName)
         .collect(Collectors.toSet());
     Set<String> actualJarNames = toSetIgnoringHiddenFiles(
-        server.getWorkingDir().list((dir, filename) -> filename.contains(".jar")));
+        serverVM.getWorkingDir().list((dir, filename) -> filename.contains(".jar")));
     assertThat(actualJarNames).isEqualTo(expectedJarNames);
 
     // verify config exists in memory
-    server.invoke(() -> {
+    serverVM.invoke(() -> {
       Cache cache = GemFireCacheImpl.getInstance();
 
       // TODO: set compare to fail if there are extra regions

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
index 15e6ea6..7cc84d6 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
@@ -20,8 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -47,7 +46,7 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
   public void testDeployToNoServer() throws Exception {
     String clusterJarPath = clusterJar;
     // set up the locator/servers
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
 
     gfshConnector.connect(locator);
     assertThat(gfshConnector.isConnected()).isTrue();
@@ -59,18 +58,18 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
     expectedClusterConfig.verify(locator);
 
     // start a server and verify that the server gets the jar
-    Server server1 = lsRule.startServerVM(1, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, locator.getPort());
     expectedClusterConfig.verify(server1);
   }
 
   @Test
   public void testDeployToMultipleLocators() throws Exception {
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
     locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "]");
-    Locator locator2 = lsRule.startLocatorVM(1, locatorProps);
+    MemberVM locator2 = lsRule.startLocatorVM(1, locatorProps);
     locatorProps.setProperty(LOCATORS,
         "localhost[" + locator.getPort() + "],localhost[" + locator2.getPort() + "]");
-    Locator locator3 = lsRule.startLocatorVM(2, locatorProps);
+    MemberVM locator3 = lsRule.startLocatorVM(2, locatorProps);
 
     // has to start a server in order to run deploy command
     lsRule.startServerVM(3, serverProps, locator.getPort());
@@ -92,15 +91,15 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
   @Test
   public void testDeploy() throws Exception {
     // set up the locator/servers
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
     // server1 in no group
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
     // server2 in group1
     serverProps.setProperty(GROUPS, "group1");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
     // server3 in group1 and group2
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
 
     gfshConnector.connect(locator);
     assertThat(gfshConnector.isConnected()).isTrue();
@@ -138,13 +137,13 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
   @Test
   public void testUndeploy() throws Exception {
     // set up the locator/servers
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
     serverProps.setProperty(GROUPS, "group1");
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
     serverProps.setProperty(GROUPS, "group2");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
 
     ConfigGroup cluster = new ConfigGroup("cluster");
     ConfigGroup group1 = new ConfigGroup("group1");

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
index e134c42..abbc5c0 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
@@ -30,9 +30,8 @@ import org.apache.geode.internal.ClassBuilder;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -51,7 +50,7 @@ public class ClusterConfigDistributionDUnitTest {
   private static final String INDEX2 = "ID2";
   private static final String AsyncEventQueue1 = "Q1";
 
-  private Locator locator;
+  private MemberVM locator;
 
   @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
@@ -110,10 +109,10 @@ public class ClusterConfigDistributionDUnitTest {
     // Start a new member which receives the shared configuration
     // Verify the config creation on this member
 
-    Server server = lsRule.startServerVM(2, new Properties(), locator.getPort());
+    MemberVM server = lsRule.startServerVM(2, new Properties(), locator.getPort());
 
     server.invoke(() -> {
-      Cache cache = LocatorServerStartupRule.serverStarter.cache;
+      Cache cache = LocatorServerStartupRule.serverStarter.getCache();
       assertNotNull(cache);
       assertTrue(cache.getCopyOnRead());
 

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
index 72daf0d..696d22c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
@@ -25,9 +25,8 @@ import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -49,27 +48,27 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
 
   public static final ClusterConfig INITIAL_CONFIG = new ClusterConfig(new ConfigGroup("cluster"));
 
-  private Locator locator;
+  private MemberVM locatorVM;
 
   @Before
   public void before() throws Exception {
     super.before();
-    locator = lsRule.startLocatorVM(0, locatorProps);
-    INITIAL_CONFIG.verify(locator);
+    locatorVM = lsRule.startLocatorVM(0, locatorProps);
+    INITIAL_CONFIG.verify(locatorVM);
 
-    gfshConnector.connect(locator);
+    gfshConnector.connect(locatorVM);
     assertThat(gfshConnector.isConnected()).isTrue();
   }
 
   @Test
   public void testImportWithRunningServerWithRegion() throws Exception {
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
     // create another server as well
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locatorVM.getPort());
     String regionName = "regionA";
     server1.invoke(() -> {
       // this region will be created on both servers, but we should only be getting the name once.
-      Cache cache = LocatorServerStartupRule.serverStarter.cache;
+      Cache cache = LocatorServerStartupRule.serverStarter.getCache();
       cache.createRegionFactory(RegionShortcut.REPLICATE).create(regionName);
     });
 
@@ -82,10 +81,10 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
 
   @Test
   public void testImportWithRunningServer() throws Exception {
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
 
     serverProps.setProperty("groups", "group2");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locatorVM.getPort());
 
     // even though we have a region recreated, we can still import since there is no data
     // in the region
@@ -105,39 +104,39 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
         "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
     // Make sure that a backup of the old clusterConfig was created
-    assertThat(locator.getWorkingDir().listFiles())
+    assertThat(locatorVM.getWorkingDir().listFiles())
         .filteredOn((File file) -> file.getName().contains("cluster_config")).hasSize(2);
 
-    CONFIG_FROM_ZIP.verify(locator);
+    CONFIG_FROM_ZIP.verify(locatorVM);
 
     // start server1 with no group
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
     new ClusterConfig(CLUSTER).verify(server1);
 
     // start server2 in group1
     serverProps.setProperty(GROUPS, "group1");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locatorVM.getPort());
     new ClusterConfig(CLUSTER, GROUP1).verify(server2);
 
     // start server3 in group1 and group2
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM server3 = lsRule.startServerVM(3, serverProps, locatorVM.getPort());
     new ClusterConfig(CLUSTER, GROUP1, GROUP2).verify(server3);
   }
 
   @Test
   public void testImportWithMultipleLocators() throws Exception {
-    locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "]");
-    Locator locator1 = lsRule.startLocatorVM(1, locatorProps);
+    locatorProps.setProperty(LOCATORS, "localhost[" + locatorVM.getPort() + "]");
+    MemberVM locator1 = lsRule.startLocatorVM(1, locatorProps);
 
     locatorProps.setProperty(LOCATORS,
-        "localhost[" + locator.getPort() + "],localhost[" + locator1.getPort() + "]");
-    Locator locator2 = lsRule.startLocatorVM(2, locatorProps);
+        "localhost[" + locatorVM.getPort() + "],localhost[" + locator1.getPort() + "]");
+    MemberVM locator2 = lsRule.startLocatorVM(2, locatorProps);
 
     gfshConnector.executeAndVerifyCommand(
         "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
-    CONFIG_FROM_ZIP.verify(locator);
+    CONFIG_FROM_ZIP.verify(locatorVM);
     REPLICATED_CONFIG_FROM_ZIP.verify(locator1);
     REPLICATED_CONFIG_FROM_ZIP.verify(locator2);
   }
@@ -156,7 +155,7 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
   }
 
   public void testExportClusterConfig(String zipFilePath) throws Exception {
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
 
 
     gfshConnector.executeAndVerifyCommand("create region --name=myRegion --type=REPLICATE");
@@ -164,7 +163,7 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
     ConfigGroup cluster = new ConfigGroup("cluster").regions("myRegion");
     ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
     expectedClusterConfig.verify(server1);
-    expectedClusterConfig.verify(locator);
+    expectedClusterConfig.verify(locatorVM);
 
     gfshConnector
         .executeAndVerifyCommand("export cluster-configuration --zip-file-name=" + zipFilePath);

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
index c0d22bf..652ec60 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
@@ -23,8 +23,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOAD_CLUSTER_
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
-import org.apache.geode.test.dunit.rules.Locator;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Test;
@@ -35,7 +34,7 @@ import java.util.Properties;
 
 @Category(DistributedTest.class)
 public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
-  protected Locator locator;
+  protected MemberVM locator;
 
   @Before
   public void before() throws Exception {
@@ -46,7 +45,7 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
   @Test
   public void testStartLocator() throws Exception {
     locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "]");
-    Locator secondLocator = lsRule.startLocatorVM(1, locatorProps);
+    MemberVM secondLocator = lsRule.startLocatorVM(1, locatorProps);
 
     REPLICATED_CONFIG_FROM_ZIP.verify(secondLocator);
   }
@@ -57,15 +56,15 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
     ClusterConfig expectedGroup1Config = new ClusterConfig(CLUSTER, GROUP1);
     ClusterConfig expectedGroup2Config = new ClusterConfig(CLUSTER, GROUP2);
 
-    Server serverWithNoGroup = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM serverWithNoGroup = lsRule.startServerVM(1, serverProps, locator.getPort());
     expectedNoGroupConfig.verify(serverWithNoGroup);
 
     serverProps.setProperty(GROUPS, "group1");
-    Server serverForGroup1 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM serverForGroup1 = lsRule.startServerVM(2, serverProps, locator.getPort());
     expectedGroup1Config.verify(serverForGroup1);
 
     serverProps.setProperty(GROUPS, "group2");
-    Server serverForGroup2 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM serverForGroup2 = lsRule.startServerVM(3, serverProps, locator.getPort());
     expectedGroup2Config.verify(serverForGroup2);
   }
 
@@ -74,12 +73,12 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
     ClusterConfig expectedGroup1And2Config = new ClusterConfig(CLUSTER, GROUP1, GROUP2);
 
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server = lsRule.startServerVM(1, serverProps, locator.getPort());
 
     expectedGroup1And2Config.verify(server);
   }
 
-  private Locator startLocatorWithLoadCCFromDir() throws Exception {
+  private MemberVM startLocatorWithLoadCCFromDir() throws Exception {
     File locatorDir = lsRule.getTempFolder().newFolder("locator-0");
     File configDir = new File(locatorDir, "cluster_config");
 
@@ -96,7 +95,7 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
     properties.setProperty(LOAD_CLUSTER_CONFIGURATION_FROM_DIR, "true");
     properties.setProperty(CLUSTER_CONFIGURATION_DIR, locatorDir.getCanonicalPath());
 
-    Locator locator = lsRule.startLocatorVM(0, properties);
+    MemberVM locator = lsRule.startLocatorVM(0, properties);
     CONFIG_FROM_ZIP.verify(locator);
 
     return locator;

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
index 4d67fb0..c551ca9 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
@@ -28,8 +28,8 @@ import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.security.SimpleTestSecurityManager;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
 import org.junit.Before;
@@ -51,7 +51,7 @@ public class ClusterConfigWithSecurityDUnitTest {
   @Rule
   public GfshShellConnectionRule connector = new GfshShellConnectionRule();
 
-  Locator locator0;
+  MemberVM locator0;
   Properties locatorProps;
 
   @Before
@@ -70,11 +70,11 @@ public class ClusterConfigWithSecurityDUnitTest {
     locatorProps.setProperty(LOCATORS, "localhost[" + locator0.getPort() + "]");
     locatorProps.setProperty("security-username", "cluster");
     locatorProps.setProperty("security-password", "cluster");
-    Locator locator1 = lsRule.startLocatorVM(1, locatorProps);
+    MemberVM locator1 = lsRule.startLocatorVM(1, locatorProps);
 
     // the second locator should inherit the first locator's security props
     locator1.invoke(() -> {
-      InternalLocator locator = LocatorServerStartupRule.locatorStarter.locator;
+      InternalLocator locator = LocatorServerStartupRule.locatorStarter.getLocator();
       ClusterConfigurationService sc = locator.getSharedConfiguration();
       Properties clusterConfigProps = sc.getConfiguration("cluster").getGemfireProperties();
       assertThat(clusterConfigProps.getProperty(SECURITY_MANAGER))
@@ -92,7 +92,7 @@ public class ClusterConfigWithSecurityDUnitTest {
         "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
     locator0.invoke(() -> {
-      InternalLocator locator = LocatorServerStartupRule.locatorStarter.locator;
+      InternalLocator locator = LocatorServerStartupRule.locatorStarter.getLocator();
       ClusterConfigurationService sc = locator.getSharedConfiguration();
       Properties properties = sc.getConfiguration("cluster").getGemfireProperties();
       assertThat(properties.getProperty(MCAST_PORT)).isEqualTo("0");

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
index 30e1df8..1107779 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
@@ -56,7 +56,7 @@ public class CacheServerStartupRule extends ExternalResource implements Serializ
   public void before() throws Throwable {
     serverStarter.before();
     serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory().create("region1");
+    serverStarter.getCache().createRegionFactory().create("region1");
   }
 
   @After
@@ -65,10 +65,10 @@ public class CacheServerStartupRule extends ExternalResource implements Serializ
   }
 
   public Cache getCache() {
-    return serverStarter.cache;
+    return serverStarter.getCache();
   }
 
   public int getServerPort() {
-    return serverStarter.server.getPort();
+    return serverStarter.getPort();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
index 6468195..62c0b85 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
@@ -53,15 +53,15 @@ public class GfshCommandsPostProcessorTest {
 
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
+
   @Rule
   public GfshShellConnectionRule gfshConnection =
       new GfshShellConnectionRule(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("region1");
+    serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("region1");
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
index ef8b7f1..45d437a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
@@ -78,12 +78,11 @@ public class GfshCommandsSecurityTest {
       new GfshShellConnectionRule(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("region1");
+    serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("region1");
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
index b6d1080..f8d90db 100644
--- a/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
@@ -53,7 +53,8 @@ public abstract class AbstractSecureServerDUnitTest extends JUnit4DistributedTes
   protected boolean pdxPersistent = false;
 
   @Rule
-  public transient ServerStarterRule serverStarter = new ServerStarterRule();
+  public transient ServerStarterRule serverStarter =
+      new ServerStarterRule().startServer(getProperties(), 0, pdxPersistent);
 
   // overwrite this in child classes
   public Properties getProperties() {
@@ -77,10 +78,9 @@ public abstract class AbstractSecureServerDUnitTest extends JUnit4DistributedTes
 
   @Before
   public void before() throws Exception {
-    serverStarter.startServer(getProperties(), 0, pdxPersistent);
-    serverPort = serverStarter.server.getPort();
+    serverPort = serverStarter.getServer().getPort();
     Region region =
-        serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
+        serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
     for (Entry entry : getData().entrySet()) {
       region.put(entry.getKey(), entry.getValue());
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
index 5d713f6..805d000 100644
--- a/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
@@ -72,7 +72,7 @@ public class ClusterConfigWithoutSecurityDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
 
     // after cache is created, the configuration won't chagne
     Properties secProps = ds.getSecurityProperties();

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
index 12c2da3..4f84f7b 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
@@ -75,7 +75,7 @@ public class SecurityClusterConfigDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
 
     // after cache is created, we got the security props passed in by cluster config
     Properties secProps = ds.getSecurityProperties();
@@ -96,7 +96,7 @@ public class SecurityClusterConfigDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
 
     // after cache is created, we got the security props passed in by cluster config
     Properties secProps = ds.getSecurityProperties();

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
index 092e82b..52a4ce4 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
@@ -73,7 +73,7 @@ public class SecurityWithoutClusterConfigDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
     assertEquals(3, ds.getSecurityProperties().size());
 
     // after cache is created, we got the security props passed in by cluster config

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java b/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
index f5cfff6..ef25ace 100644
--- a/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
@@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
@@ -36,7 +37,7 @@ public class StartServerAuthorizationTest {
 
   @ClassRule
   public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
-  private static Locator locator = null;
+  private static MemberVM<Locator> locator = null;
 
   @Rule
   public ServerStarterRule serverStarter = new ServerStarterRule();

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index f35e3e9..f367458 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -86,11 +86,11 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
 
   }
 
-  public void connect(Locator locator, String... options) throws Exception {
+  public void connect(MemberVM locator, String... options) throws Exception {
     connect(locator.getPort(), PortType.locator, options);
   }
 
-  public void connectAndVerify(Locator locator, String... options) throws Exception {
+  public void connectAndVerify(MemberVM locator, String... options) throws Exception {
     connect(locator.getPort(), PortType.locator, options);
     assertThat(this.connected).isTrue();
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
index b1004b9..59f1506 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
@@ -16,11 +16,8 @@
 
 package org.apache.geode.test.dunit.rules;
 
-import java.io.File;
+import org.apache.geode.distributed.internal.InternalLocator;
 
-public class Locator extends Member {
-
-  public Locator(int port, File workingDir, String name) {
-    super(port, workingDir, name);
-  }
+public interface Locator extends Member {
+  InternalLocator getLocator();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
index d5a4dfb..01e346a 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
@@ -55,7 +55,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
       new DistributedRestoreSystemProperties();
 
   private TemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
-  private Member[] members;
+  private MemberVM[] members;
 
   public LocatorServerStartupRule() {
     DUnitLauncher.launchIfNeeded();
@@ -66,7 +66,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     restoreSystemProperties.before();
     temporaryFolder.create();
     Invoke.invokeInEveryVM("Stop each VM", this::cleanupVm);
-    members = new Member[4];
+    members = new MemberVM[4];
   }
 
   @Override
@@ -77,7 +77,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     temporaryFolder.delete();
   }
 
-  public Locator startLocatorVM(int index) throws IOException {
+  public MemberVM startLocatorVM(int index) throws IOException {
     return startLocatorVM(index, new Properties());
   }
 
@@ -87,7 +87,8 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
    *
    * @return VM locator vm
    */
-  public Locator startLocatorVM(int index, Properties locatorProperties) throws IOException {
+  public MemberVM<Locator> startLocatorVM(int index, Properties locatorProperties)
+      throws IOException {
     String name = "locator-" + index;
     locatorProperties.setProperty(NAME, name);
     File workingDir = createWorkingDirForMember(name);
@@ -97,12 +98,11 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
       locatorStarter.before();
       return locatorStarter.startLocator(locatorProperties);
     });
-    locator.setVM(locatorVM);
-    members[index] = locator;
-    return locator;
+    members[index] = new MemberVM(locator, locatorVM);
+    return members[index];
   }
 
-  public Server startServerVM(int index) throws IOException {
+  public MemberVM startServerVM(int index) throws IOException {
     return startServerVM(index, new Properties(), -1);
   }
 
@@ -111,24 +111,21 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
    * 
    * @return VM node vm
    */
-  public Server startServerVM(int index, Properties properties) throws IOException {
+  public MemberVM startServerVM(int index, Properties properties) throws IOException {
     return startServerVM(index, properties, -1);
   }
 
-  /**
-   * start a server that connects to this locatorPort
-   */
-  public Server startServerVM(int index, int locatorPort) throws IOException {
+  public MemberVM startServerVM(int index, int locatorPort) throws IOException {
     return startServerVM(index, new Properties(), locatorPort);
   }
 
-  public Server startServerAsJmxManager(int index, int jmxManagerPort) throws IOException {
+  public MemberVM startServerAsJmxManager(int index, int jmxManagerPort) throws IOException {
     Properties properties = new Properties();
     properties.setProperty(JMX_MANAGER_PORT, jmxManagerPort + "");
     return startServerVM(index, properties);
   }
 
-  public Server startServerAsEmbededLocator(int index, int locatorPort, int jmxManagerPort)
+  public MemberVM startServerAsEmbededLocator(int index, int locatorPort, int jmxManagerPort)
       throws IOException {
     Properties properties = new Properties();
     properties.setProperty("start-locator", "localhost[" + locatorPort + "]");
@@ -141,7 +138,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
   /**
    * Starts a cache server that connect to the locator running at the given port.
    */
-  public Server startServerVM(int index, Properties properties, int locatorPort)
+  public MemberVM startServerVM(int index, Properties properties, int locatorPort)
       throws IOException {
 
     String name = "server-" + index;
@@ -154,9 +151,8 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
       serverStarter.before();
       return serverStarter.startServer(properties, locatorPort);
     });
-    server.setVM(serverVM);
-    members[index] = server;
-    return server;
+    members[index] = new MemberVM(server, serverVM);
+    return members[index];
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
index 2ec2088..5d6a0be 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
@@ -21,17 +21,14 @@ import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_S
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.distributed.Locator.startLocatorAndDS;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.commons.io.FileUtils;
-import org.apache.geode.distributed.Locator;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.awaitility.Awaitility;
-import org.junit.rules.ExternalResource;
 
 import java.io.File;
-import java.io.Serializable;
-import java.nio.file.Files;
+import java.io.IOException;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
@@ -47,12 +44,9 @@ import java.util.concurrent.TimeUnit;
  * use {@link LocatorServerStartupRule}.
  */
 
-public class LocatorStarterRule extends ExternalResource implements Serializable {
+public class LocatorStarterRule extends MemberStarterRule implements Locator {
 
-  public InternalLocator locator;
-
-  private File workingDir;
-  private String oldUserDir;
+  private transient InternalLocator locator;
 
   public LocatorStarterRule() {}
 
@@ -60,42 +54,29 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
     this.workingDir = workingDir.getAbsoluteFile();
   }
 
-  @Override
-  protected void before() throws Exception {
-    oldUserDir = System.getProperty("user.dir");
-    if (workingDir == null) {
-      workingDir = Files.createTempDirectory("locator").toAbsolutePath().toFile();
-    }
-    System.setProperty("user.dir", workingDir.toString());
+  public InternalLocator getLocator() {
+    return locator;
   }
 
   @Override
-  protected void after() {
+  protected void stopMember() {
     if (locator != null) {
       locator.stop();
     }
-    FileUtils.deleteQuietly(workingDir);
-    if (oldUserDir == null) {
-      System.clearProperty("user.dir");
-    } else {
-      System.setProperty("user.dir", oldUserDir);
-    }
   }
 
-
-  public org.apache.geode.test.dunit.rules.Locator startLocator() throws Exception {
+  public LocatorStarterRule startLocator() {
     return startLocator(new Properties());
   }
 
-  public org.apache.geode.test.dunit.rules.Locator startLocator(Properties properties)
-      throws Exception {
+  public LocatorStarterRule startLocator(Properties properties) {
     if (properties == null)
       properties = new Properties();
     if (!properties.containsKey(NAME)) {
       properties.setProperty(NAME, "locator");
     }
 
-    String name = properties.getProperty(NAME);
+    name = properties.getProperty(NAME);
     if (!properties.containsKey(LOG_FILE)) {
       properties.setProperty(LOG_FILE, new File(name + ".log").getAbsolutePath());
     }
@@ -104,7 +85,7 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
       properties.setProperty(MCAST_PORT, "0");
     }
     if (properties.containsKey(JMX_MANAGER_PORT)) {
-      int jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
+      jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
       if (jmxPort > 0) {
         if (!properties.containsKey(JMX_MANAGER)) {
           properties.put(JMX_MANAGER, "true");
@@ -114,15 +95,18 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
         }
       }
     }
-
-    locator = (InternalLocator) Locator.startLocatorAndDS(0, null, properties);
-    int locatorPort = locator.getPort();
-    locator.resetInternalLocatorFileNamesWithCorrectPortNumber(locatorPort);
+    try {
+      locator = (InternalLocator) startLocatorAndDS(0, null, properties);
+    } catch (IOException e) {
+      throw new RuntimeException("unable to start up locator.", e);
+    }
+    memberPort = locator.getPort();
+    locator.resetInternalLocatorFileNamesWithCorrectPortNumber(memberPort);
 
     if (locator.getConfig().getEnableClusterConfiguration()) {
       Awaitility.await().atMost(65, TimeUnit.SECONDS)
           .until(() -> assertTrue(locator.isSharedConfigurationRunning()));
     }
-    return new org.apache.geode.test.dunit.rules.Locator(locatorPort, workingDir, name);
+    return this;
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
index 59215a3..6165c84 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
@@ -11,62 +11,19 @@
  * 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.rules;
 
-import org.apache.geode.test.dunit.SerializableRunnableIF;
-import org.apache.geode.test.dunit.VM;
-
 import java.io.File;
 import java.io.Serializable;
 
-/**
- * A server or locator inside a DUnit {@link VM}.
- */
-public abstract class Member implements Serializable {
-  private transient VM vm;
-  private int port;
-  private File workingDir;
-  private String name;
-
-  public Member(int port, File workingDir, String name) {
-    this.vm = vm;
-    this.port = port;
-    this.workingDir = workingDir;
-    this.name = name;
-  }
-
-  /**
-   * The VM object is an RMI stub which lets us execute code in the JVM of this member.
-   * 
-   * @return the {@link VM}
-   */
-  public VM getVM() {
-    return vm;
-  }
-
-  public void setVM(VM vm) {
-    this.vm = vm;
-  }
-
-  public int getPort() {
-    return port;
-  }
+public interface Member extends Serializable {
+  File getWorkingDir();
 
-  public File getWorkingDir() {
-    return workingDir;
-  }
+  int getPort();
 
-  public String getName() {
-    return name;
-  }
+  int getJmxPort();
 
-  /**
-   * Invokes {@code runnable.run()} in the {@code VM} of this member.
-   */
-  public void invoke(final SerializableRunnableIF runnable) {
-    this.vm.invoke(runnable);
-  }
+  String getName();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
new file mode 100644
index 0000000..7591616
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
@@ -0,0 +1,84 @@
+/*
+ * 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.rules;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.test.dunit.VM;
+import org.junit.rules.ExternalResource;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+
+/**
+ * A server or locator inside a DUnit {@link VM}.
+ */
+public abstract class MemberStarterRule extends ExternalResource implements Member {
+  protected TemporaryFolder temporaryFolder;
+  protected String oldUserDir;
+
+  protected File workingDir;
+  protected int memberPort = -1;
+  protected int jmxPort = -1;
+  protected String name;
+
+  @Override
+  public void before() throws Exception {
+    oldUserDir = System.getProperty("user.dir");
+    if (workingDir == null) {
+      temporaryFolder = new TemporaryFolder();
+      temporaryFolder.create();
+      workingDir = temporaryFolder.newFolder("locator").getAbsoluteFile();
+    }
+    System.setProperty("user.dir", workingDir.toString());
+  }
+
+  @Override
+  public void after() {
+    stopMember();
+    FileUtils.deleteQuietly(workingDir);
+    if (oldUserDir == null) {
+      System.clearProperty("user.dir");
+    } else {
+      System.setProperty("user.dir", oldUserDir);
+    }
+    if (temporaryFolder != null) {
+      temporaryFolder.delete();
+    }
+  }
+
+  abstract void stopMember();
+
+  @Override
+  public File getWorkingDir() {
+    return workingDir;
+  }
+
+  @Override
+  public int getPort() {
+    return memberPort;
+  }
+
+  @Override
+  public int getJmxPort() {
+    return jmxPort;
+  }
+
+  @Override
+  public String getName() {
+    return name;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
new file mode 100644
index 0000000..988f5d4
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
@@ -0,0 +1,67 @@
+/*
+ * 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.rules;
+
+import org.apache.geode.test.dunit.SerializableRunnableIF;
+import org.apache.geode.test.dunit.VM;
+
+import java.io.File;
+
+public class MemberVM<T extends Member> implements Member {
+  private T member;
+  private VM vm;
+
+  public MemberVM(T member, VM vm) {
+    this.member = member;
+    this.vm = vm;
+  }
+
+  public boolean isLocator() {
+    return (member instanceof Locator);
+  }
+
+  public VM getVM() {
+    return vm;
+  }
+
+  public void invoke(final SerializableRunnableIF runnable) {
+    vm.invoke(runnable);
+  }
+
+  public T getMember() {
+    return member;
+  }
+
+  @Override
+  public File getWorkingDir() {
+    return member.getWorkingDir();
+  }
+
+  @Override
+  public int getPort() {
+    return member.getPort();
+  }
+
+  @Override
+  public int getJmxPort() {
+    return member.getJmxPort();
+  }
+
+  @Override
+  public String getName() {
+    return member.getName();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
index 83093c4..fb8630a 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
@@ -16,10 +16,12 @@
 
 package org.apache.geode.test.dunit.rules;
 
-import java.io.File;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.server.CacheServer;
+
+public interface Server extends Member {
+  Cache getCache();
+
+  CacheServer getServer();
 
-public class Server extends Member {
-  public Server(int port, File workingDir, String name) {
-    super(port, workingDir, name);
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
index df37579..0454340 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
@@ -23,16 +23,13 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.junit.rules.ExternalResource;
 
 import java.io.File;
-import java.io.Serializable;
-import java.nio.file.Files;
+import java.io.IOException;
 import java.util.Properties;
 
 
@@ -50,61 +47,79 @@ import java.util.Properties;
  * If you need a rule to start a server/locator in different VMs for Distributed tests, You should
  * use {@link LocatorServerStartupRule}.
  */
-public class ServerStarterRule extends ExternalResource implements Serializable {
+public class ServerStarterRule extends MemberStarterRule implements Server {
 
-  public Cache cache;
-  public CacheServer server;
-
-  private File workingDir;
-  private String oldUserDir;
+  private transient Cache cache;
+  private transient CacheServer server;
 
   /**
-   * Default constructor, if used, the rule won't start the server for you, you will need to
-   * manually start it. The rule will handle stop the server for you.
+   * Default constructor, if used, the rule will create a temporary folder as the server's working
+   * dir, and will delete it when the test is done.
    */
   public ServerStarterRule() {}
 
+  /**
+   * if constructed this way, the rule won't be deleting the workingDir after the test is done. It's
+   * up to the caller's responsibility to delete it.
+   * 
+   * @param workingDir: the working dir this server should be writing the artifacts to.
+   */
   public ServerStarterRule(File workingDir) {
     this.workingDir = workingDir;
   }
 
-  public void before() throws Exception {
-    oldUserDir = System.getProperty("user.dir");
-    if (workingDir == null) {
-      workingDir = Files.createTempDirectory("server").toAbsolutePath().toFile();
+  public Cache getCache() {
+    return cache;
+  }
+
+  public CacheServer getServer() {
+    return server;
+  }
+
+  @Override
+  void stopMember() {
+    // make sure this cache is the one currently open. A server cache can be recreated due to
+    // importing a new set of cluster configuration.
+    cache = GemFireCacheImpl.getInstance();
+    if (cache != null) {
+      cache.close();
+      cache = null;
+    }
+    if (server != null) {
+      server.stop();
+      server = null;
     }
-    System.setProperty("user.dir", workingDir.toString());
   }
 
-  public Server startServer() throws Exception {
+  public ServerStarterRule startServer() {
     return startServer(new Properties(), -1, false);
   }
 
-  public Server startServer(int locatorPort) throws Exception {
+  public ServerStarterRule startServer(int locatorPort) {
     return startServer(new Properties(), locatorPort, false);
   }
 
-  public Server startServer(int locatorPort, boolean pdxPersistent) throws Exception {
+  public ServerStarterRule startServer(int locatorPort, boolean pdxPersistent) {
     return startServer(new Properties(), locatorPort, pdxPersistent);
   }
 
-  public Server startServer(Properties properties) throws Exception {
+  public ServerStarterRule startServer(Properties properties) {
     return startServer(properties, -1, false);
   }
 
-  public Server startServer(Properties properties, int locatorPort) throws Exception {
+  public ServerStarterRule startServer(Properties properties, int locatorPort) {
     return startServer(properties, locatorPort, false);
   }
 
-  public Server startServer(Properties properties, int locatorPort, boolean pdxPersistent)
-      throws Exception {
+  public ServerStarterRule startServer(Properties properties, int locatorPort,
+      boolean pdxPersistent) {
     if (properties == null) {
       properties = new Properties();
     }
     if (!properties.containsKey(NAME)) {
       properties.setProperty(NAME, "server");
     }
-    String name = properties.getProperty(NAME);
+    name = properties.getProperty(NAME);
     if (!properties.containsKey(LOG_FILE)) {
       properties.setProperty(LOG_FILE, new File(name + ".log").getAbsolutePath().toString());
     }
@@ -120,7 +135,7 @@ public class ServerStarterRule extends ExternalResource implements Serializable
       properties.setProperty(LOCATORS, "");
     }
     if (properties.containsKey(JMX_MANAGER_PORT)) {
-      int jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
+      jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
       if (jmxPort > 0) {
         if (!properties.containsKey(JMX_MANAGER))
           properties.put(JMX_MANAGER, "true");
@@ -134,28 +149,12 @@ public class ServerStarterRule extends ExternalResource implements Serializable
     cache = cf.create();
     server = cache.addCacheServer();
     server.setPort(0);
-    server.start();
-    return new Server(server.getPort(), workingDir, name);
-  }
-
-  @Override
-  public void after() {
-    // make sure this cache is the one currently open. A server cache can be recreated due to
-    // importing a new set of cluster configuration.
-    cache = GemFireCacheImpl.getInstance();
-    if (cache != null) {
-      cache.close();
-      cache = null;
-    }
-    if (server != null) {
-      server.stop();
-      server = null;
-    }
-    FileUtils.deleteQuietly(workingDir);
-    if (oldUserDir == null) {
-      System.clearProperty("user.dir");
-    } else {
-      System.setProperty("user.dir", oldUserDir);
+    try {
+      server.start();
+    } catch (IOException e) {
+      throw new RuntimeException("unable to start server", e);
     }
+    memberPort = server.getPort();
+    return this;
   }
 }


[26/50] [abbrv] geode git commit: GEODE-2267: Enhance server/locator startup rules

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/aae5aa50/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
index 1a344db..58f1870 100755
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
@@ -17,7 +17,12 @@ package org.apache.geode.cache.lucene.internal.configuration;
 import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
 import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.lucene.LuceneIndex;
@@ -34,9 +39,9 @@ import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.management.internal.configuration.domain.Configuration;
 import org.apache.geode.test.dunit.SerializableRunnableIF;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.Member;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.lucene.analysis.Analyzer;
 import org.junit.Before;
@@ -60,7 +65,7 @@ public class LuceneClusterConfigurationDUnitTest {
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
 
-  private Locator locator = null;
+  private MemberVM locator = null;
 
   @Before
   public void before() throws Exception {
@@ -81,10 +86,10 @@ public class LuceneClusterConfigurationDUnitTest {
 
     // Start vm2. This should have lucene index created using cluster
     // configuration.
-    Member vm2 = startNodeUsingClusterConfiguration(2, false);
+    MemberVM vm2 = startNodeUsingClusterConfiguration(2, false);
     vm2.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
       validateIndexFields(new String[] {"field1", "field2", "field3"}, index);
@@ -107,10 +112,10 @@ public class LuceneClusterConfigurationDUnitTest {
 
     // Start vm2. This should have lucene index created using cluster
     // configuration.
-    Member vm2 = startNodeUsingClusterConfiguration(2, false);
+    MemberVM vm2 = startNodeUsingClusterConfiguration(2, false);
     vm2.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
       String[] fields = new String[] {"field1", "field2", "field3"};
@@ -128,11 +133,11 @@ public class LuceneClusterConfigurationDUnitTest {
   public void indexGetsCreatedOnGroupOfNodes() throws Exception {
 
     // Start vm1, vm2 in group
-    Member vm1 = startNodeUsingClusterConfiguration(1, true);
-    Member vm2 = startNodeUsingClusterConfiguration(2, true);
+    MemberVM vm1 = startNodeUsingClusterConfiguration(1, true);
+    MemberVM vm2 = startNodeUsingClusterConfiguration(2, true);
 
     // Start vm3 outside the group. The Lucene index should not be present here.
-    Member vm3 = startNodeUsingClusterConfiguration(3, true);
+    MemberVM vm3 = startNodeUsingClusterConfiguration(3, true);
 
     // Connect Gfsh to locator.
     gfshConnector.connectAndVerify(locator);
@@ -146,7 +151,7 @@ public class LuceneClusterConfigurationDUnitTest {
     // VM2 should have lucene index created using gfsh execution.
     vm2.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
       validateIndexFields(new String[] {"field1", "field2", "field3"}, index);
@@ -155,7 +160,7 @@ public class LuceneClusterConfigurationDUnitTest {
     // The Lucene index is present in vm3.
     vm3.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
     });
@@ -164,11 +169,11 @@ public class LuceneClusterConfigurationDUnitTest {
   @Test
   public void indexNotCreatedOnNodeOutSideTheGroup() throws Exception {
     // Start vm1, vm2 in group
-    Member vm1 = startNodeUsingClusterConfiguration(1, true);
-    Member vm2 = startNodeUsingClusterConfiguration(2, true);
+    MemberVM vm1 = startNodeUsingClusterConfiguration(1, true);
+    MemberVM vm2 = startNodeUsingClusterConfiguration(2, true);
 
     // Start vm3 outside the group. The Lucene index should not be present here.
-    Member vm3 = startNodeUsingClusterConfiguration(3, false);
+    MemberVM vm3 = startNodeUsingClusterConfiguration(3, false);
 
     // Connect Gfsh to locator.
     gfshConnector.connectAndVerify(locator);
@@ -182,7 +187,7 @@ public class LuceneClusterConfigurationDUnitTest {
     // VM2 should have lucene index created using gfsh execution
     vm2.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
       validateIndexFields(new String[] {"field1", "field2", "field3"}, index);
@@ -191,7 +196,7 @@ public class LuceneClusterConfigurationDUnitTest {
     // The Lucene index should not be present in vm3.
     vm3.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNull(index);
     });
@@ -210,15 +215,15 @@ public class LuceneClusterConfigurationDUnitTest {
     createRegionUsingGfsh(REGION_NAME, RegionShortcut.PARTITION, groupName);
 
     // Start vm2 in group
-    Member vm2 = startNodeUsingClusterConfiguration(2, true);
+    MemberVM vm2 = startNodeUsingClusterConfiguration(2, true);
 
     // Start vm3 outside the group. The Lucene index should not be present here.
-    Member vm3 = startNodeUsingClusterConfiguration(3, false);
+    MemberVM vm3 = startNodeUsingClusterConfiguration(3, false);
 
     // VM2 should have lucene index created using gfsh execution
     vm2.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNotNull(index);
       validateIndexFields(new String[] {"field1", "field2", "field3"}, index);
@@ -227,7 +232,7 @@ public class LuceneClusterConfigurationDUnitTest {
     // The Lucene index should not be present in vm3.
     vm3.invoke(() -> {
       LuceneService luceneService =
-          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.cache);
+          LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
       assertNull(index);
     });
@@ -286,7 +291,7 @@ public class LuceneClusterConfigurationDUnitTest {
 
   private SerializableRunnableIF verifyClusterConfiguration(boolean verifyIndexesExist) {
     return () -> {
-      InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.locator;
+      InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.getLocator();
       ClusterConfigurationService sc = internalLocator.getSharedConfiguration();
       Configuration config = sc.getConfiguration(ClusterConfigurationService.CLUSTER_CONFIG);
       String xmlContent = config.getCacheXmlContent();
@@ -306,7 +311,7 @@ public class LuceneClusterConfigurationDUnitTest {
     };
   }
 
-  private Member startNodeUsingClusterConfiguration(int vmIndex, boolean addGroup)
+  private MemberVM startNodeUsingClusterConfiguration(int vmIndex, boolean addGroup)
       throws Exception {
     Properties nodeProperties = new Properties();
     if (addGroup) {


[08/50] [abbrv] geode git commit: GEODE-2568: The JMX MBean is now removed when its AsyncEventQueue is removed

Posted by ds...@apache.org.
GEODE-2568: The JMX MBean is now removed when its AsyncEventQueue is removed


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/e5121aba
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/e5121aba
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/e5121aba

Branch: refs/heads/feature/GEODE-1969
Commit: e5121abad3b4c11620b0be037ada4484e7248875
Parents: 4e61799
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Wed Mar 1 13:20:31 2017 -0800
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Fri Mar 3 15:08:53 2017 -0800

----------------------------------------------------------------------
 .../distributed/internal/ResourceEvent.java     |  1 +
 .../geode/internal/cache/GemFireCacheImpl.java  |  1 +
 .../geode/management/JMXNotificationType.java   |  8 ++
 .../internal/ManagementConstants.java           |  2 +
 .../internal/beans/AsyncEventQueueMBean.java    |  3 +
 .../beans/AsyncEventQueueMBeanBridge.java       |  3 +
 .../internal/beans/ManagementAdapter.java       | 36 ++++++++
 .../internal/beans/ManagementListener.java      |  4 +
 .../geode/internal/cache/wan/WANTestBase.java   |  6 ++
 .../management/WANManagementDUnitTest.java      | 92 ++++++++++++++------
 10 files changed, 131 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/e5121aba/geode-core/src/main/java/org/apache/geode/distributed/internal/ResourceEvent.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/ResourceEvent.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/ResourceEvent.java
index acfb157..b004113 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/ResourceEvent.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/ResourceEvent.java
@@ -34,6 +34,7 @@ public enum ResourceEvent {
   MANAGER_STOP,
   LOCATOR_START,
   ASYNCEVENTQUEUE_CREATE,
+  ASYNCEVENTQUEUE_REMOVE,
   SYSTEM_ALERT,
   CACHE_SERVER_START,
   CACHE_SERVER_STOP,

http://git-wip-us.apache.org/repos/asf/geode/blob/e5121aba/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index 66f1a4a..fcf7a2a 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -4131,6 +4131,7 @@ public class GemFireCacheImpl
       this.allAsyncEventQueues.remove(asyncQueue);
       this.allVisibleAsyncEventQueues.remove(asyncQueue);
     }
+    system.handleResourceEvent(ResourceEvent.ASYNCEVENTQUEUE_REMOVE, asyncQueue);
   }
 
   /* Cache API - get the conflict resolver for WAN */

http://git-wip-us.apache.org/repos/asf/geode/blob/e5121aba/geode-core/src/main/java/org/apache/geode/management/JMXNotificationType.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/JMXNotificationType.java b/geode-core/src/main/java/org/apache/geode/management/JMXNotificationType.java
index 3fb8ba2..ba3daeb 100644
--- a/geode-core/src/main/java/org/apache/geode/management/JMXNotificationType.java
+++ b/geode-core/src/main/java/org/apache/geode/management/JMXNotificationType.java
@@ -167,6 +167,14 @@ public interface JMXNotificationType {
       DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.asycn.event.queue.created";
 
   /**
+   * Notification type which indicates that an async queue has been closed. <BR>
+   * The value of this type string is
+   * <CODE>gemfire.distributedsystem.async.event.queue.closed</CODE>.
+   */
+  public static final String ASYNC_EVENT_QUEUE_CLOSED =
+      DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.async.event.queue.closed";
+
+  /**
    * Notification type which indicates a GemFire system generated alert <BR>
    * The value of this type string is <CODE>system.alert</CODE>.
    */

http://git-wip-us.apache.org/repos/asf/geode/blob/e5121aba/geode-core/src/main/java/org/apache/geode/management/internal/ManagementConstants.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/ManagementConstants.java b/geode-core/src/main/java/org/apache/geode/management/internal/ManagementConstants.java
index d5bfedb..151aa9d 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/ManagementConstants.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/ManagementConstants.java
@@ -187,6 +187,8 @@ public interface ManagementConstants {
 
   public static final String ASYNC_EVENT_QUEUE_CREATED_PREFIX =
       "Async Event Queue is Created  in the VM ";
+  public static final String ASYNC_EVENT_QUEUE_CLOSED_PREFIX =
+      "Async Event Queue is Closed in the VM ";
 
   public static final String CACHE_SERVICE_CREATED_PREFIX = "Cache Service Created With Name ";
 

http://git-wip-us.apache.org/repos/asf/geode/blob/e5121aba/geode-core/src/main/java/org/apache/geode/management/internal/beans/AsyncEventQueueMBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/AsyncEventQueueMBean.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/AsyncEventQueueMBean.java
index 2f2757f..7cea8e9 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/AsyncEventQueueMBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/AsyncEventQueueMBean.java
@@ -107,4 +107,7 @@ public class AsyncEventQueueMBean extends NotificationBroadcasterSupport
     return bridge.getEventQueueSize();
   }
 
+  public void stopMonitor() {
+    bridge.stopMonitor();
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/e5121aba/geode-core/src/main/java/org/apache/geode/management/internal/beans/AsyncEventQueueMBeanBridge.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/AsyncEventQueueMBeanBridge.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/AsyncEventQueueMBeanBridge.java
index e57bc55..83cfb88 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/AsyncEventQueueMBeanBridge.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/AsyncEventQueueMBeanBridge.java
@@ -114,4 +114,7 @@ public class AsyncEventQueueMBeanBridge {
     }
   }
 
+  public void stopMonitor() {
+    monitor.stopListener();
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/e5121aba/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementAdapter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementAdapter.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementAdapter.java
index f601a9a..183a5a8 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementAdapter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementAdapter.java
@@ -592,6 +592,42 @@ public class ManagementAdapter {
   }
 
   /**
+   * Handles AsyncEventQueue Removal
+   *
+   * @param queue The AsyncEventQueue being removed
+   */
+  public void handleAsyncEventQueueRemoval(AsyncEventQueue queue) throws ManagementException {
+    if (!isServiceInitialised("handleAsyncEventQueueRemoval")) {
+      return;
+    }
+
+    ObjectName asycnEventQueueMBeanName = MBeanJMXAdapter.getAsycnEventQueueMBeanName(
+        cacheImpl.getDistributedSystem().getDistributedMember(), queue.getId());
+    AsyncEventQueueMBean bean = null;
+    try {
+      bean = (AsyncEventQueueMBean) service.getLocalAsyncEventQueueMXBean(queue.getId());
+      if (bean == null) {
+        return;
+      }
+    } catch (ManagementException e) {
+      // If no bean found its a NO-OP
+      if (logger.isDebugEnabled()) {
+        logger.debug(e.getMessage(), e);
+      }
+      return;
+    }
+
+    bean.stopMonitor();
+
+    service.unregisterMBean(asycnEventQueueMBeanName);
+
+    Notification notification = new Notification(JMXNotificationType.ASYNC_EVENT_QUEUE_CLOSED,
+        memberSource, SequenceNumber.next(), System.currentTimeMillis(),
+        ManagementConstants.ASYNC_EVENT_QUEUE_CLOSED_PREFIX + queue.getId());
+    memberLevelNotifEmitter.sendNotification(notification);
+  }
+
+  /**
    * Sends the alert with the Object source as member. This notification will get filtered out for
    * particular alert level
    * 

http://git-wip-us.apache.org/repos/asf/geode/blob/e5121aba/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementListener.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementListener.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementListener.java
index 12392b5..d841122 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementListener.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/ManagementListener.java
@@ -185,6 +185,10 @@ public class ManagementListener implements ResourceEventsListener {
         AsyncEventQueue queue = (AsyncEventQueue) resource;
         adapter.handleAsyncEventQueueCreation(queue);
         break;
+      case ASYNCEVENTQUEUE_REMOVE:
+        AsyncEventQueue removedQueue = (AsyncEventQueue) resource;
+        adapter.handleAsyncEventQueueRemoval(removedQueue);
+        break;
       case SYSTEM_ALERT:
         AlertDetails details = (AlertDetails) resource;
         adapter.handleSystemNotification(details);

http://git-wip-us.apache.org/repos/asf/geode/blob/e5121aba/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java
index f0704e8..c8de7dc 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java
@@ -3470,6 +3470,12 @@ public class WANTestBase extends JUnit4DistributedTestCase {
     }
   }
 
+  public static void destroyAsyncEventQueue(String id) {
+    AsyncEventQueueImpl aeq = (AsyncEventQueueImpl) cache.getAsyncEventQueue(id);
+    assertNotNull(aeq);
+    aeq.destroy();
+  }
+
   protected static void verifyListenerEvents(final long expectedNumEvents) {
     Awaitility.await().atMost(60, TimeUnit.SECONDS)
         .until(() -> listener1.getNumEvents() == expectedNumEvents);

http://git-wip-us.apache.org/repos/asf/geode/blob/e5121aba/geode-wan/src/test/java/org/apache/geode/management/WANManagementDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/management/WANManagementDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/management/WANManagementDUnitTest.java
index 03c0d62..880648d 100644
--- a/geode-wan/src/test/java/org/apache/geode/management/WANManagementDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/management/WANManagementDUnitTest.java
@@ -14,21 +14,19 @@
  */
 package org.apache.geode.management;
 
+import org.apache.geode.management.internal.SystemManagementService;
 import org.junit.experimental.categories.Category;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
 
 import org.awaitility.Awaitility;
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
-import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
 import org.apache.geode.cache.Cache;
@@ -36,7 +34,6 @@ import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.Locator;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.wan.WANTestBase;
-import org.apache.geode.management.internal.MBeanJMXAdapter;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.SerializableRunnable;
 import org.apache.geode.test.dunit.VM;
@@ -215,16 +212,50 @@ public class WANManagementDUnitTest extends ManagementTestBase {
         1, 100, false));
     nyReceiver.invoke(() -> WANTestBase.createReceiver());
 
-    checkAsyncQueueMBean(puneSender);
-    checkAsyncQueueMBean(managing);
+    checkAsyncQueueMBean(puneSender, true);
+    checkAsyncQueueMBean(managing, true);
 
     DistributedMember puneMember =
         (DistributedMember) puneSender.invoke(() -> WANManagementDUnitTest.getMember());
 
-    checkProxyAsyncQueue(managing, puneMember);
+    checkProxyAsyncQueue(managing, puneMember, true);
 
   }
 
+  @Test
+  public void testCreateDestroyAsyncEventQueue() throws Exception {
+    VM memberVM = getManagedNodeList().get(2);
+    VM managerVm = getManagingNode();
+    VM locatorVm = Host.getLocator();
+
+    int locatorPort = (Integer) locatorVm.invoke(() -> WANManagementDUnitTest.getLocatorPort());
+
+    memberVM.invoke(() -> WANTestBase.createCache(locatorPort));
+    managerVm.invoke(() -> WANTestBase.createManagementCache(locatorPort));
+    startManagingNode(managerVm);
+
+    // Create AsyncEventQueue
+    String aeqId = "pn";
+    memberVM.invoke(
+        () -> WANTestBase.createAsyncEventQueue(aeqId, false, 100, 100, false, false, null, false));
+    managerVm.invoke(
+        () -> WANTestBase.createAsyncEventQueue(aeqId, false, 100, 100, false, false, null, false));
+
+    // Verify AsyncEventQueueMXBean exists
+    checkAsyncQueueMBean(memberVM, true);
+    checkAsyncQueueMBean(managerVm, true);
+    DistributedMember member = memberVM.invoke(() -> WANManagementDUnitTest.getMember());
+    checkProxyAsyncQueue(managerVm, member, true);
+
+    // Destroy AsyncEventQueue
+    memberVM.invoke(() -> WANTestBase.destroyAsyncEventQueue(aeqId));
+    managerVm.invoke(() -> WANTestBase.destroyAsyncEventQueue(aeqId));
+
+    // Verify AsyncEventQueueMXBean no longer exists
+    checkAsyncQueueMBean(memberVM, false);
+    checkAsyncQueueMBean(managerVm, false);
+    checkProxyAsyncQueue(managerVm, member, false);
+  }
 
   @SuppressWarnings("serial")
   protected void checkSenderNavigationAPIS(final VM vm, final DistributedMember senderMember) {
@@ -448,15 +479,18 @@ public class WANManagementDUnitTest extends ManagementTestBase {
    * @param vm reference to VM
    */
   @SuppressWarnings("serial")
-  protected void checkAsyncQueueMBean(final VM vm) {
+  protected void checkAsyncQueueMBean(final VM vm, final boolean shouldExist) {
     SerializableRunnable checkAsyncQueueMBean =
         new SerializableRunnable("Check Async Queue MBean") {
           public void run() {
             Cache cache = GemFireCacheImpl.getInstance();
             ManagementService service = ManagementService.getManagementService(cache);
             AsyncEventQueueMXBean bean = service.getLocalAsyncEventQueueMXBean("pn");
-            assertNotNull(bean);
-            // Already in started State
+            if (shouldExist) {
+              assertNotNull(bean);
+            } else {
+              assertNull(bean);
+            }
           }
         };
     vm.invoke(checkAsyncQueueMBean);
@@ -468,28 +502,36 @@ public class WANManagementDUnitTest extends ManagementTestBase {
    * @param vm reference to VM
    */
   @SuppressWarnings("serial")
-  protected void checkProxyAsyncQueue(final VM vm, final DistributedMember senderMember) {
+  protected void checkProxyAsyncQueue(final VM vm, final DistributedMember senderMember,
+      final boolean shouldExist) {
     SerializableRunnable checkProxyAsyncQueue =
         new SerializableRunnable("Check Proxy Async Queue") {
           public void run() {
             Cache cache = GemFireCacheImpl.getInstance();
-            ManagementService service = ManagementService.getManagementService(cache);
-            AsyncEventQueueMXBean bean = null;
-            try {
-              bean = MBeanUtil.getAsyncEventQueueMBeanProxy(senderMember, "pn");
-            } catch (Exception e) {
-              fail("Could not obtain Sender Proxy in desired time " + e);
-            }
-            assertNotNull(bean);
+            SystemManagementService service =
+                (SystemManagementService) ManagementService.getManagementService(cache);
             final ObjectName queueMBeanName =
                 service.getAsyncEventQueueMBeanName(senderMember, "pn");
-
-            try {
-              MBeanUtil.printBeanDetails(queueMBeanName);
-            } catch (Exception e) {
-              fail("Error while Printing Bean Details " + e);
+            AsyncEventQueueMXBean bean = null;
+            if (shouldExist) {
+              // Verify the MBean proxy exists
+              try {
+                bean = MBeanUtil.getAsyncEventQueueMBeanProxy(senderMember, "pn");
+              } catch (Exception e) {
+                fail("Could not obtain Sender Proxy in desired time " + e);
+              }
+              assertNotNull(bean);
+
+              try {
+                MBeanUtil.printBeanDetails(queueMBeanName);
+              } catch (Exception e) {
+                fail("Error while Printing Bean Details " + e);
+              }
+            } else {
+              // Verify the MBean proxy doesn't exist
+              bean = service.getMBeanProxy(queueMBeanName, AsyncEventQueueMXBean.class);
+              assertNull(bean);
             }
-
           }
         };
     vm.invoke(checkProxyAsyncQueue);


[33/50] [abbrv] geode git commit: GEODE-2591 User guide: Lucene headings should be reflected in navigation pane

Posted by ds...@apache.org.
GEODE-2591 User guide: Lucene headings should be reflected in navigation pane


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/22d8b407
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/22d8b407
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/22d8b407

Branch: refs/heads/feature/GEODE-1969
Commit: 22d8b4077065152191a8c2d8f88b5143b0b70097
Parents: 9321c0e
Author: Dave Barnes <db...@pivotal.io>
Authored: Fri Mar 3 14:19:35 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:28 2017 -0800

----------------------------------------------------------------------
 geode-book/master_middleman/source/subnavs/geode-subnav.erb | 8 +++++++-
 geode-docs/tools_modules/lucene_integration.html.md.erb     | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/22d8b407/geode-book/master_middleman/source/subnavs/geode-subnav.erb
----------------------------------------------------------------------
diff --git a/geode-book/master_middleman/source/subnavs/geode-subnav.erb b/geode-book/master_middleman/source/subnavs/geode-subnav.erb
index 5f03ee6..d3472de 100644
--- a/geode-book/master_middleman/source/subnavs/geode-subnav.erb
+++ b/geode-book/master_middleman/source/subnavs/geode-subnav.erb
@@ -30,7 +30,7 @@ limitations under the License.
                         <a href="/docs/guide/11/getting_started/geode_overview.html">About Apache Geode</a>
                     </li>
                     <li>
-                        <a href="/docs/guide/11/getting_started/product_intro.html">Main Features</a>
+                        <a href="/docs/guide/11/getting_started/product_intro.html">Main Features of Apache Geode</a>
                     </li>
                     <li class="has_submenu">
                         <a href="/docs/guide/11/prereq_and_install.html">Prerequisites and Installation Instructions</a>
@@ -2293,8 +2293,14 @@ gfsh</a>
                                 <a href="/docs/guide/11/tools_modules/lucene_integration.html#java-api-example">Java API Example</a>
                             </li>
                             <li>
+                                <a href="/docs/guide/11/tools_modules/lucene_integration.html#search-example">Search Example</a>
+                            </li>
+                            <li>
                                 <a href="/docs/guide/11/tools_modules/lucene_integration.html#gfsh-api">Gfsh API</a>
                             </li>
+                            <li>
+                                <a href="/docs/guide/11/tools_modules/lucene_integration.html#xml-configuration">XML Configuration</a>
+                            </li>
                         </ul>
                     </li>
                 </ul>

http://git-wip-us.apache.org/repos/asf/geode/blob/22d8b407/geode-docs/tools_modules/lucene_integration.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/tools_modules/lucene_integration.html.md.erb b/geode-docs/tools_modules/lucene_integration.html.md.erb
index 6361650..aa19e43 100644
--- a/geode-docs/tools_modules/lucene_integration.html.md.erb
+++ b/geode-docs/tools_modules/lucene_integration.html.md.erb
@@ -69,7 +69,7 @@ Region region = cache.createRegionFactory(RegionShutcut.PARTITION).create(region
  
 ```
 
-## Search Example
+## <a id="search-example" class="no-quick-link"></a>Search Example
 
 ``` pre
 LuceneQuery<String, Person> query = luceneService.createLuceneQueryFactory()
@@ -111,7 +111,7 @@ gfsh> lucene search --regionName=/orders -queryStrings="John*" --defaultField=fi
 ```
 
 
-## XML Configuration
+## <a id="xml-configuration" class="no-quick-link"></a>XML Configuration
 
 ``` pre
 <cache


[02/50] [abbrv] geode git commit: GEODE-2488: Remove lsof from netstat command tests

Posted by ds...@apache.org.
GEODE-2488: Remove lsof from netstat command tests

Removed the --with-lsof option from netstat command to reduce the
command response size. Avoids OOME's on JVMs in the test environment
with small heaps.

The original tests with lsof have been retained, but annotated with
@Ignore.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/6118d54c
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/6118d54c
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/6118d54c

Branch: refs/heads/feature/GEODE-1969
Commit: 6118d54c88401d52a9cd829252349a62e84a8afb
Parents: 9766cf2
Author: Ken Howe <kh...@pivotal.io>
Authored: Thu Mar 2 09:40:55 2017 -0800
Committer: Ken Howe <kh...@pivotal.io>
Committed: Thu Mar 2 13:52:26 2017 -0800

----------------------------------------------------------------------
 .../internal/cli/NetstatDUnitTest.java          | 26 +++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/6118d54c/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
index c6248e0..e987fc2 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
@@ -24,6 +24,7 @@ import org.apache.geode.test.junit.categories.FlakyTest;
 import org.junit.After;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -40,6 +41,7 @@ public class NetstatDUnitTest {
   private static int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
 
   private static String netStatCommand = null;
+  private static String netStatLsofCommand = null;
 
   @BeforeClass
   public static void beforeClass() throws Exception {
@@ -67,7 +69,8 @@ public class NetstatDUnitTest {
     // start another server
     lsRule.startServerVM(3, properties);
 
-    netStatCommand = "netstat --with-lsof=true --member=" + server.getName();
+    netStatCommand = "netstat --with-lsof=false --member=" + server.getName();
+    netStatLsofCommand = "netstat --with-lsof=true --member=" + server.getName();
   }
 
   @Test
@@ -88,6 +91,27 @@ public class NetstatDUnitTest {
     gfshConnector.executeAndVerifyCommand(netStatCommand);
   }
 
+  @Ignore
+  @Test
+  public void testConnectToLocatorWithLargeCommandResponse() throws Exception {
+    gfshConnector.connect(ports[0], GfshShellConnectionRule.PortType.locator);
+    gfshConnector.executeAndVerifyCommand(netStatLsofCommand);
+  }
+
+  @Ignore
+  @Test
+  public void testConnectToJmxManagerOneWithLargeCommandResponse() throws Exception {
+    gfshConnector.connect(ports[1], GfshShellConnectionRule.PortType.jmxManger);
+    gfshConnector.executeAndVerifyCommand(netStatLsofCommand);
+  }
+
+  @Ignore
+  @Test
+  public void testConnectToJmxManagerTwoWithLargeCommandResponse() throws Exception {
+    gfshConnector.connect(ports[2], GfshShellConnectionRule.PortType.jmxManger);
+    gfshConnector.executeAndVerifyCommand(netStatLsofCommand);
+  }
+
   @After
   public void after() throws Exception {
     gfshConnector.disconnect();


[15/50] [abbrv] geode git commit: GEODE-2267: enable gfsh to download file from http connection (GEODE-2418)

Posted by ds...@apache.org.
GEODE-2267: enable gfsh to download file from http connection (GEODE-2418)


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/92582fbd
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/92582fbd
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/92582fbd

Branch: refs/heads/feature/GEODE-1969
Commit: 92582fbde6e8feb2c119bbdf937ee91a62946277
Parents: 4c6f369
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Tue Feb 21 15:54:12 2017 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Fri Mar 3 16:03:50 2017 -0800

----------------------------------------------------------------------
 .../geode/management/cli/CliMetaData.java       |   8 +
 .../cli/AbstractCliAroundInterceptor.java       |   4 +-
 .../internal/cli/CliAroundInterceptor.java      |  26 +++-
 .../geode/management/internal/cli/CliUtil.java  |  12 +-
 .../management/internal/cli/CommandRequest.java |  15 +-
 .../cli/commands/MiscellaneousCommands.java     | 137 ++++++++++-------
 .../cli/functions/ExportLogsFunction.java       |   7 +-
 .../internal/cli/i18n/CliStrings.java           |  30 +++-
 .../cli/shell/GfshExecutionStrategy.java        |  59 +++++---
 .../cli/util/ExportLogsCacheWriter.java         |  10 +-
 .../internal/cli/util/ExportLogsRepository.java |  22 ++-
 .../management/internal/cli/util/MergeLogs.java |  15 +-
 .../MiscellaneousCommandsController.java        |  27 +++-
 .../web/shell/AbstractHttpOperationInvoker.java |  51 +++++--
 .../web/shell/RestHttpOperationInvoker.java     |  34 +++--
 .../web/shell/SimpleHttpOperationInvoker.java   |  12 +-
 .../internal/cli/CommandRequestTest.java        |  16 +-
 .../internal/cli/commands/ExportLogsDUnit.java  |  55 +++----
 .../ExportLogsOnServerManagerDUnit.java         |  91 +++++++++++
 .../ExportLogsFunctionIntegrationTest.java      |   8 +-
 .../internal/cli/util/LogExporterTest.java      |   6 -
 .../internal/cli/util/MergeLogsDUnitTest.java   | 113 ++++++++++++++
 .../internal/cli/util/MergeLogsTest.java        | 114 --------------
 .../security/GfshCommandsSecurityTest.java      |   6 +-
 .../dunit/rules/GfshShellConnectionRule.java    |  36 ++++-
 .../rules/LocatorServerConfigurationRule.java   | 151 -------------------
 .../dunit/rules/LocatorServerStartupRule.java   |  29 +++-
 .../codeAnalysis/sanctionedSerializables.txt    |   4 +
 .../cli/commands/golden-help-offline.properties |  10 +-
 geode-web/build.gradle                          |   4 +
 .../cli/commands/CommandOverHttpDUnitTest.java  |   6 +-
 .../commands/ExportLogsOverHttpDUnitTest.java   | 116 ++++++++++++++
 .../RestHttpOperationInvokerJUnitTest.java      |  50 +++---
 .../SimpleHttpOperationInvokerJUnitTest.java    |  20 ++-
 34 files changed, 766 insertions(+), 538 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java b/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
index a20fba5..e69d78a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
+++ b/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
@@ -44,6 +44,14 @@ public @interface CliMetaData {
   boolean shellOnly() default false;
 
   /**
+   * Indicates when executed over http, is this command downloading files from the member. When this
+   * is set to true, the RestHttpOperationInvoker will use an extractor to extract the inputstream
+   * in the response to a temporary file and it's up to your command's interceptor's postExecution
+   * to use that temp file to fit your need.
+   **/
+  boolean isFileDownloadOverHttp() default false;
+
+  /**
    * Indicates that the effect of the command is persisted or the commands affects the persistent
    * configuration
    */

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/cli/AbstractCliAroundInterceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/AbstractCliAroundInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/AbstractCliAroundInterceptor.java
index de24727..3e1357d 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/AbstractCliAroundInterceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/AbstractCliAroundInterceptor.java
@@ -14,10 +14,10 @@
  */
 package org.apache.geode.management.internal.cli;
 
-import java.io.IOException;
-
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 
+import java.io.IOException;
+
 /**
  * Semi-complete implementation of {@link CliAroundInterceptor} for convenience for implementors.
  * 

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
index 11d74c1..2e26efd 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
@@ -15,8 +15,11 @@
 package org.apache.geode.management.internal.cli;
 
 import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.shell.GfshExecutionStrategy;
 
+import java.nio.file.Path;
+
 /**
  * Interceptor interface which {@link GfshExecutionStrategy} can use to intercept before & after
  * actual command execution.
@@ -26,8 +29,27 @@ import org.apache.geode.management.internal.cli.shell.GfshExecutionStrategy;
  */
 public interface CliAroundInterceptor {
 
-  public Result preExecution(GfshParseResult parseResult);
+  /**
+   * called by the OperationInvoker before the command is executed
+   */
+  default public Result preExecution(GfshParseResult parseResult) {
+    return ResultBuilder.createInfoResult("");
+  }
+
+  @Deprecated
+  default public Result postExecution(GfshParseResult parseResult, Result commandResult) {
+    return commandResult;
+  }
 
-  public Result postExecution(GfshParseResult parseResult, Result commandResult);
+  /**
+   * called by the OperationInvoker after the command is executed
+   * 
+   * @param tempFile: if the command's isFileDownloadOverHttp is true, the is the File downloaded
+   *        after the http response is processed.
+   */
+  default public Result postExecution(GfshParseResult parseResult, Result commandResult,
+      Path tempFile) {
+    return postExecution(parseResult, commandResult);
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
index 87a07a6..ad3f3df 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
@@ -302,9 +302,11 @@ public class CliUtil {
   }
 
   /**
-   * Finds all Members (including both servers and locators) which belong to the given arrays of groups or members.
+   * Finds all Members (including both servers and locators) which belong to the given arrays of
+   * groups or members.
    */
-  public static Set<DistributedMember> findMembersIncludingLocators(String[] groups, String[] members) {
+  public static Set<DistributedMember> findMembersIncludingLocators(String[] groups,
+      String[] members) {
     Cache cache = CacheFactory.getAnyInstance();
     Set<DistributedMember> allMembers = getAllMembers(cache);
 
@@ -312,7 +314,8 @@ public class CliUtil {
   }
 
   /**
-   * Finds all Servers which belong to the given arrays of groups or members.  Does not include locators.
+   * Finds all Servers which belong to the given arrays of groups or members. Does not include
+   * locators.
    */
   public static Set<DistributedMember> findMembers(String[] groups, String[] members) {
     Cache cache = CacheFactory.getAnyInstance();
@@ -321,7 +324,8 @@ public class CliUtil {
     return findMembers(allNormalMembers, groups, members);
   }
 
-  private static Set<DistributedMember> findMembers(Set<DistributedMember> membersToConsider, String[] groups, String[] members) {
+  private static Set<DistributedMember> findMembers(Set<DistributedMember> membersToConsider,
+      String[] groups, String[] members) {
     if (groups == null) {
       groups = new String[] {};
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
index b0242c9..046499e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
@@ -14,12 +14,13 @@
  */
 package org.apache.geode.management.internal.cli;
 
+import org.apache.geode.internal.lang.StringUtils;
+import org.apache.geode.management.cli.CliMetaData;
+
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.geode.internal.lang.StringUtils;
-
 /**
  * The CommandRequest class encapsulates information pertaining to the command the user entered in
  * Gfsh.
@@ -39,6 +40,7 @@ public class CommandRequest {
 
   private final Map<String, String> customParameters = new HashMap<String, String>();
   private final Map<String, String> env;
+  private boolean downloadFile = false;
 
   private String customInput;
 
@@ -65,6 +67,11 @@ public class CommandRequest {
     this.env = env;
     this.fileData = fileData;
     this.parseResult = parseResult;
+
+    CliMetaData metaData = parseResult.getMethod().getDeclaredAnnotation(CliMetaData.class);
+    if (metaData != null && metaData.isFileDownloadOverHttp()) {
+      downloadFile = true;
+    }
   }
 
   public String getName() {
@@ -88,6 +95,10 @@ public class CommandRequest {
     return customInput;
   }
 
+  public boolean isDownloadFile() {
+    return downloadFile;
+  }
+
   public void setCustomInput(final String input) {
     this.customInput = input;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
index e720d09..e921031 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
@@ -14,42 +14,8 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.zip.DataFormatException;
-import java.util.zip.GZIPInputStream;
-import javax.management.ObjectName;
-
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.geode.LogWriter;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
@@ -108,19 +74,49 @@ import org.apache.geode.management.internal.cli.result.ResultData;
 import org.apache.geode.management.internal.cli.result.ResultDataException;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
-import org.apache.geode.management.internal.cli.util.MergeLogs;
 import org.apache.geode.management.internal.cli.util.ExportLogsCacheWriter;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-
 import org.apache.logging.log4j.Logger;
 import org.springframework.shell.core.CommandMarker;
 import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.zip.DataFormatException;
+import java.util.zip.GZIPInputStream;
+import javax.management.ObjectName;
+
 /**
  * @since GemFire 7.0
  */
@@ -129,6 +125,7 @@ public class MiscellaneousCommands implements CommandMarker {
   public final static String FORMAT = "yyyy/MM/dd/HH/mm/ss/SSS/z";
   public final static String ONLY_DATE_FORMAT = "yyyy/MM/dd";
   public final static String DEFAULT_TIME_OUT = "10";
+  private final static Logger logger = LogService.getLogger();
 
   private final GetStackTracesFunction getStackTracesFunction = new GetStackTracesFunction();
 
@@ -139,8 +136,6 @@ public class MiscellaneousCommands implements CommandMarker {
 
   public void shutdownNode(final long timeout, final Set<DistributedMember> includeMembers)
       throws TimeoutException, InterruptedException, ExecutionException {
-    Cache cache = CacheFactory.getAnyInstance();
-    LogWriter logger = cache.getLogger();
     ExecutorService exec = Executors.newSingleThreadExecutor();
     try {
       final Function shutDownFunction = new ShutDownFunction();
@@ -690,12 +685,13 @@ public class MiscellaneousCommands implements CommandMarker {
   }
 
   @CliCommand(value = CliStrings.EXPORT_LOGS, help = CliStrings.EXPORT_LOGS__HELP)
-  @CliMetaData(shellOnly = false,
+  @CliMetaData(shellOnly = false, isFileDownloadOverHttp = true,
+      interceptor = "org.apache.geode.management.internal.cli.commands.MiscellaneousCommands$ExportLogsInterceptor",
       relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_DEBUG_UTIL})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result exportLogs(
       @CliOption(key = CliStrings.EXPORT_LOGS__DIR, help = CliStrings.EXPORT_LOGS__DIR__HELP,
-          mandatory = true) String dirName,
+          mandatory = false) String dirName,
       @CliOption(key = CliStrings.EXPORT_LOGS__GROUP,
           unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.MEMBERGROUP,
@@ -719,12 +715,9 @@ public class MiscellaneousCommands implements CommandMarker {
           unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.EXPORT_LOGS__ENDTIME__HELP) String end) {
     Result result = null;
-    Logger logger = LogService.getLogger();
-
     try {
-      GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-
-      Set<DistributedMember> targetMembers = CliUtil.findMembersIncludingLocators(groups, memberIds);
+      Set<DistributedMember> targetMembers =
+          CliUtil.findMembersIncludingLocators(groups, memberIds);
 
 
       Map<String, Path> zipFilesFromMembers = new HashMap<>();
@@ -736,7 +729,8 @@ public class MiscellaneousCommands implements CommandMarker {
 
         cacheWriter.startFile(server.getName());
 
-        CliUtil.executeFunction(new ExportLogsFunction(),
+        CliUtil
+            .executeFunction(new ExportLogsFunction(),
                 new ExportLogsFunction.Args(start, end, logLevel, onlyLogLevel), server)
             .getResult();
         Path zipFile = cacheWriter.endFile();
@@ -756,25 +750,57 @@ public class MiscellaneousCommands implements CommandMarker {
       }
 
       Path workingDir = Paths.get(System.getProperty("user.dir"));
-      Path exportedLogsZipFile = workingDir.resolve("exportedLogs[" + System.currentTimeMillis() + "].zip").toAbsolutePath();
+      Path exportedLogsZipFile = workingDir
+          .resolve("exportedLogs_" + System.currentTimeMillis() + ".zip").toAbsolutePath();
 
       logger.info("Zipping into: " + exportedLogsZipFile.toString());
       ZipUtils.zipDirectory(exportedLogsDir, exportedLogsZipFile);
       FileUtils.deleteDirectory(tempDir.toFile());
-      result = ResultBuilder.createInfoResult("File exported to: " + exportedLogsZipFile.toString());
+      result = ResultBuilder.createInfoResult(exportedLogsZipFile.toString());
     } catch (Exception ex) {
-      ex.printStackTrace();
       logger.error(ex, ex);
       result = ResultBuilder.createUserErrorResult(ex.getMessage());
     } finally {
       ExportLogsFunction.destroyExportLogsRegion();
     }
-
-    LogWrapper.getInstance().fine("Exporting logs returning =" + result);
+    logger.debug("Exporting logs returning = {}", result);
     return result;
   }
 
-
+  /**
+   * after the export logs, will need to copy the tempFile to the desired location and delete the
+   * temp file.
+   */
+  public static class ExportLogsInterceptor extends AbstractCliAroundInterceptor {
+    @Override
+    public Result postExecution(GfshParseResult parseResult, Result commandResult, Path tempFile) {
+      // in the command over http case, the command result is in the downloaded temp file
+      if (tempFile != null) {
+        Path dirPath;
+        String dirName = parseResult.getParamValueStrings().get("dir");
+        if (StringUtils.isBlank(dirName)) {
+          dirPath = Paths.get(System.getProperty("user.dir"));
+        } else {
+          dirPath = Paths.get(dirName);
+        }
+        String fileName = "exportedLogs_" + System.currentTimeMillis() + ".zip";
+        File exportedLogFile = dirPath.resolve(fileName).toFile();
+        try {
+          FileUtils.copyFile(tempFile.toFile(), exportedLogFile);
+          FileUtils.deleteQuietly(tempFile.toFile());
+          commandResult = ResultBuilder
+              .createInfoResult("Logs exported to: " + exportedLogFile.getAbsolutePath());
+        } catch (IOException e) {
+          logger.error(e.getMessage(), e);
+          commandResult = ResultBuilder.createGemFireErrorResult(e.getMessage());
+        }
+      } else {
+        commandResult = ResultBuilder.createInfoResult(
+            "Logs exported to the connected member's file system: " + commandResult.nextLine());
+      }
+      return commandResult;
+    }
+  }
 
   /****
    * Current implementation supports writing it to a file and returning the location of the file
@@ -996,16 +1022,15 @@ public class MiscellaneousCommands implements CommandMarker {
           result = ResultBuilder.buildResult(erd);
         }
       } else {
-
         if (!org.apache.geode.internal.lang.StringUtils.isBlank(cacheServerPortString)) {
           return ResultBuilder
               .createUserErrorResult(CliStrings.SHOW_METRICS__CANNOT__USE__CACHESERVERPORT);
         }
-
         result = ResultBuilder.buildResult(getSystemWideMetrics(export_to_report_to, categories));
       }
     } catch (Exception e) {
-      return ResultBuilder.createGemFireErrorResult("#SB" + CliUtil.stackTraceAsString(e));
+      logger.error(e.getMessage(), e);
+      return ResultBuilder.createGemFireErrorResult(CliUtil.stackTraceAsString(e));
     }
     return result;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
index 1dc89e9..560e8aa 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
@@ -17,7 +17,6 @@
 package org.apache.geode.management.internal.cli.functions;
 
 import static java.util.stream.Collectors.toSet;
-import static org.apache.geode.distributed.internal.DistributionManager.LOCATOR_DM_TYPE;
 
 import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.DataPolicy;
@@ -99,10 +98,6 @@ public class ExportLogsFunction implements Function, InternalEntity {
     }
   }
 
-  protected static boolean isLocator(GemFireCacheImpl cache) {
-    return cache.getMyId().getVmKind() == LOCATOR_DM_TYPE;
-  }
-
   public static Region createOrGetExistingExportLogsRegion(boolean isInitiatingMember)
       throws IOException, ClassNotFoundException {
     GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
@@ -134,7 +129,7 @@ public class ExportLogsFunction implements Function, InternalEntity {
       return;
     }
 
-      exportLogsRegion.destroyRegion();
+    exportLogsRegion.destroyRegion();
 
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
index c536e8e..3dc42d6 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
@@ -14,18 +14,38 @@
  */
 package org.apache.geode.management.internal.cli.i18n;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
-import java.text.MessageFormat;
+import static org.apache.geode.distributed.ConfigurationProperties.ARCHIVE_DISK_SPACE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.ARCHIVE_FILE_SIZE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.DURABLE_CLIENT_ID;
+import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
+import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_TIME_STATISTICS;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_DISK_SPACE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.MEMCACHED_BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.MEMCACHED_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.MEMCACHED_PROTOCOL;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.SOCKET_BUFFER_SIZE;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLE_RATE;
+import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION;
 
 import org.apache.geode.cache.PartitionAttributesFactory;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
+import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 
+import java.text.MessageFormat;
+
 /**
  * - * Contains 'String' constants used as key to the Localized strings to be used in classes under
  * <code>org.apache.geode.management.internal.cli</code> for Command Line Interface (CLI). NOTES: 1.
@@ -1371,7 +1391,7 @@ public class CliStrings {
   public static final String EXPORT_LOGS__HELP = "Export the log files for a member or members.";
   public static final String EXPORT_LOGS__DIR = "dir";
   public static final String EXPORT_LOGS__DIR__HELP =
-      "Directory to which log files will be written.";
+      "Local directory to which log files will be written. This is only used when you are exporting logs using http connection. If not specified, user.dir will be used.";
   public static final String EXPORT_LOGS__MEMBER = "member";
   public static final String EXPORT_LOGS__MEMBER__HELP =
       "Name/Id of the member whose log files will be exported.";

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
index b53c53f..6445454 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
@@ -14,10 +14,7 @@
  */
 package org.apache.geode.management.internal.cli.shell;
 
-import static org.apache.geode.management.internal.cli.multistep.CLIMultiStepHelper.*;
-
-import java.lang.reflect.Method;
-import java.util.Map;
+import static org.apache.geode.management.internal.cli.multistep.CLIMultiStepHelper.execCLISteps;
 
 import org.apache.geode.internal.ClassPathLoader;
 import org.apache.geode.management.cli.CliMetaData;
@@ -35,13 +32,16 @@ import org.apache.geode.management.internal.cli.multistep.MultiStepCommand;
 import org.apache.geode.management.internal.cli.result.FileResult;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.security.NotAuthorizedException;
-
 import org.springframework.shell.core.ExecutionStrategy;
 import org.springframework.shell.core.Shell;
 import org.springframework.shell.event.ParseResult;
 import org.springframework.util.Assert;
 import org.springframework.util.ReflectionUtils;
 
+import java.lang.reflect.Method;
+import java.nio.file.Path;
+import java.util.Map;
+
 /**
  * Defines the {@link ExecutionStrategy} for commands that are executed in GemFire SHell (gfsh).
  * 
@@ -235,9 +235,12 @@ public class GfshExecutionStrategy implements ExecutionStrategy {
     try {
       response = shell.getOperationInvoker()
           .processCommand(new CommandRequest(parseResult, env, fileData));
+
     } catch (NotAuthorizedException e) {
       return ResultBuilder
           .createGemFireUnAuthorizedErrorResult("Unauthorized. Reason : " + e.getMessage());
+    } catch (Exception e) {
+      shell.logSevere(e.getMessage(), e);
     } finally {
       env.clear();
     }
@@ -250,33 +253,39 @@ public class GfshExecutionStrategy implements ExecutionStrategy {
               + "Please check manager logs for error.");
     }
 
-    if (logWrapper.fineEnabled()) {
-      logWrapper.fine("Received response :: " + response);
-    }
-    CommandResponse commandResponse =
-        CommandResponseBuilder.prepareCommandResponseFromJson((String) response);
+    // the response could be a string which is a json respresentation of the CommandResult object
+    // it can also be a Path to a temp file downloaded from the rest http request
+    if (response instanceof String) {
+      CommandResponse commandResponse =
+          CommandResponseBuilder.prepareCommandResponseFromJson((String) response);
 
-    if (commandResponse.isFailedToPersist()) {
-      shell.printAsSevere(CliStrings.SHARED_CONFIGURATION_FAILED_TO_PERSIST_COMMAND_CHANGES);
-      logWrapper.severe(CliStrings.SHARED_CONFIGURATION_FAILED_TO_PERSIST_COMMAND_CHANGES);
+      if (commandResponse.isFailedToPersist()) {
+        shell.printAsSevere(CliStrings.SHARED_CONFIGURATION_FAILED_TO_PERSIST_COMMAND_CHANGES);
+        logWrapper.severe(CliStrings.SHARED_CONFIGURATION_FAILED_TO_PERSIST_COMMAND_CHANGES);
+      }
+
+      String debugInfo = commandResponse.getDebugInfo();
+      if (debugInfo != null && !debugInfo.trim().isEmpty()) {
+        // TODO - Abhishek When debug is ON, log response in gfsh logs
+        // TODO - Abhishek handle \n better. Is it coming from GemFire formatter
+        debugInfo = debugInfo.replaceAll("\n\n\n", "\n");
+        debugInfo = debugInfo.replaceAll("\n\n", "\n");
+        debugInfo =
+            debugInfo.replaceAll("\n", "\n[From Manager : " + commandResponse.getSender() + "]");
+        debugInfo = "[From Manager : " + commandResponse.getSender() + "]" + debugInfo;
+        LogWrapper.getInstance().info(debugInfo);
+      }
+      commandResult = ResultBuilder.fromJson((String) response);
     }
 
-    String debugInfo = commandResponse.getDebugInfo();
-    if (debugInfo != null && !debugInfo.trim().isEmpty()) {
-      // TODO - Abhishek When debug is ON, log response in gfsh logs
-      // TODO - Abhishek handle \n better. Is it coming from GemFire formatter
-      debugInfo = debugInfo.replaceAll("\n\n\n", "\n");
-      debugInfo = debugInfo.replaceAll("\n\n", "\n");
-      debugInfo =
-          debugInfo.replaceAll("\n", "\n[From Manager : " + commandResponse.getSender() + "]");
-      debugInfo = "[From Manager : " + commandResponse.getSender() + "]" + debugInfo;
-      LogWrapper.getInstance().info(debugInfo);
+    Path tempFile = null;
+    if (response instanceof Path) {
+      tempFile = (Path) response;
     }
-    commandResult = ResultBuilder.fromJson((String) response);
 
     // 3. Post Remote Execution
     if (interceptor != null) {
-      Result postExecResult = interceptor.postExecution(parseResult, commandResult);
+      Result postExecResult = interceptor.postExecution(parseResult, commandResult, tempFile);
       if (postExecResult != null) {
         if (Status.ERROR.equals(postExecResult.getStatus())) {
           if (logWrapper.infoEnabled()) {

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java
index a8b7225..178bb4a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java
@@ -22,15 +22,11 @@ import org.apache.geode.cache.EntryEvent;
 import org.apache.geode.cache.util.CacheWriterAdapter;
 
 import java.io.BufferedOutputStream;
-import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.OutputStream;
 import java.io.Serializable;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Map;
 
 public class ExportLogsCacheWriter extends CacheWriterAdapter implements Serializable {
   private Path currentFile;
@@ -38,11 +34,9 @@ public class ExportLogsCacheWriter extends CacheWriterAdapter implements Seriali
 
   @Override
   public void beforeCreate(EntryEvent event) throws CacheWriterException {
-    if (currentFile.getFileName().endsWith("server-2.zip")) {
-      System.out.println("We got data from server 2");
-    }
     if (currentOutputStream == null) {
-      throw new IllegalStateException("No outputStream is open.  You must call startFile before sending data.");
+      throw new IllegalStateException(
+          "No outputStream is open.  You must call startFile before sending data.");
     }
 
     try {

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java
index 9a79fc0..85ce1ad 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java
@@ -1,18 +1,16 @@
 /*
- * 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
+ * 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
+ * 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.
+ * 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.
  *
  */
 

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
index 67d5473..04a649b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
@@ -50,14 +50,13 @@ public class MergeLogs {
     // create a new process for merging
     LogWrapper.getInstance().fine("Exporting logs merging logs" + logDirectory);
     List<String> commandList = new ArrayList<String>();
-    commandList.add(System.getProperty("java.home") + File.separatorChar + "bin"
-        + File.separatorChar + "java");
+    commandList.add(
+        System.getProperty("java.home") + File.separatorChar + "bin" + File.separatorChar + "java");
     commandList.add("-classpath");
     commandList.add(System.getProperty("java.class.path", "."));
     commandList.add(MergeLogs.class.getName());
 
-    commandList
-        .add(logDirectory.toAbsolutePath().toString());
+    commandList.add(logDirectory.toAbsolutePath().toString());
 
     ProcessBuilder procBuilder = new ProcessBuilder(commandList);
     StringBuilder output = new StringBuilder();
@@ -100,8 +99,8 @@ public class MergeLogs {
 
   }
 
-  protected static List<File> findLogFilesToMerge (File dir) {
-    return FileUtils.listFiles(dir, new String[]{"log"}, true).stream().collect(toList());
+  protected static List<File> findLogFilesToMerge(File dir) {
+    return FileUtils.listFiles(dir, new String[] {"log"}, true).stream().collect(toList());
   }
 
   static File mergeLogFile(String dirName) throws Exception {
@@ -122,8 +121,8 @@ public class MergeLogs {
     PrintWriter mergedLog = null;
     File mergedLogFile = null;
     try {
-      String mergeLog =
-          dirName + File.separator + "merge_" + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new java.util.Date()) + ".log";
+      String mergeLog = dirName + File.separator + "merge_"
+          + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new java.util.Date()) + ".log";
       mergedLogFile = new File(mergeLog);
       mergedLog = new PrintWriter(mergedLogFile);
       boolean flag = MergeLogFiles.mergeLogFiles(logFiles, logFileNames, mergedLog);

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
index ac912c8..e2f5307 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
@@ -14,11 +14,13 @@
  */
 package org.apache.geode.management.internal.web.controllers;
 
-import java.util.concurrent.Callable;
-
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -27,6 +29,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import java.io.File;
+import java.io.FileInputStream;
+
 /**
  * The MiscellaneousCommandsController class implements GemFire Management REST API web service
  * endpoints for the Gfsh Miscellaneous Commands.
@@ -48,8 +53,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
 public class MiscellaneousCommandsController extends AbstractCommandsController {
 
   @RequestMapping(method = RequestMethod.GET, value = "/logs")
-  public Callable<ResponseEntity<String>> exportLogs(
-      @RequestParam(CliStrings.EXPORT_LOGS__DIR) final String directory,
+  public ResponseEntity<InputStreamResource> exportLogs(
+      @RequestParam(value = CliStrings.EXPORT_LOGS__DIR, required = false) final String directory,
       @RequestParam(value = CliStrings.EXPORT_LOGS__GROUP, required = false) final String[] groups,
       @RequestParam(value = CliStrings.EXPORT_LOGS__MEMBER,
           required = false) final String memberNameId,
@@ -93,7 +98,19 @@ public class MiscellaneousCommandsController extends AbstractCommandsController
       command.addOption(CliStrings.EXPORT_LOGS__ENDTIME, endTime);
     }
 
-    return getProcessCommandCallable(command.toString());
+    // the result is json string from CommandResult
+    String result = processCommand(command.toString());
+
+    // parse the result to get the file path
+    String filePath = ResultBuilder.fromJson(result).nextLine().trim();
+
+    HttpHeaders respHeaders = new HttpHeaders();
+    try {
+      InputStreamResource isr = new InputStreamResource(new FileInputStream(new File(filePath)));
+      return new ResponseEntity<InputStreamResource>(isr, respHeaders, HttpStatus.OK);
+    } catch (Exception ex) {
+      throw new RuntimeException("IOError writing file to output stream", ex);
+    }
   }
 
   // TODO determine whether Async functionality is required

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/AbstractHttpOperationInvoker.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/AbstractHttpOperationInvoker.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/AbstractHttpOperationInvoker.java
index fa05248..f60aabc 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/AbstractHttpOperationInvoker.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/AbstractHttpOperationInvoker.java
@@ -15,6 +15,7 @@
 
 package org.apache.geode.management.internal.web.shell;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.geode.internal.GemFireVersion;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.internal.logging.LogService;
@@ -34,6 +35,7 @@ import org.apache.geode.management.internal.web.util.UriUtils;
 import org.apache.geode.security.AuthenticationFailedException;
 import org.apache.geode.security.NotAuthorizedException;
 import org.apache.logging.log4j.Logger;
+import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
@@ -41,14 +43,18 @@ import org.springframework.http.client.ClientHttpResponse;
 import org.springframework.http.client.SimpleClientHttpRequestFactory;
 import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.web.client.RequestCallback;
 import org.springframework.web.client.ResourceAccessException;
 import org.springframework.web.client.ResponseErrorHandler;
+import org.springframework.web.client.ResponseExtractor;
 import org.springframework.web.client.RestTemplate;
 
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
@@ -583,8 +589,7 @@ public abstract class AbstractHttpOperationInvoker implements HttpOperationInvok
    * @see org.apache.geode.management.internal.web.http.ClientHttpRequest
    * @see org.springframework.http.ResponseEntity
    */
-  protected <T> ResponseEntity<T> send(final ClientHttpRequest request,
-      final Class<T> responseType) {
+  protected <T> T send(final ClientHttpRequest request, final Class<T> responseType) {
     return send(request, responseType, Collections.<String, Object>emptyMap());
   }
 
@@ -603,10 +608,9 @@ public abstract class AbstractHttpOperationInvoker implements HttpOperationInvok
    * @see org.springframework.web.client.RestTemplate#exchange(java.net.URI,
    *      org.springframework.http.HttpMethod, org.springframework.http.HttpEntity, Class)
    */
-  protected <T> ResponseEntity<T> send(final ClientHttpRequest request, final Class<T> responseType,
+  protected <T> T send(final ClientHttpRequest request, final Class<T> responseType,
       final Map<String, ?> uriVariables) {
     final URI url = request.getURL(uriVariables);
-
     if (isDebugEnabled()) {
       printInfo("Link: %1$s", request.getLink().toHttpRequestLine());
       printInfo("HTTP URL: %1$s", url);
@@ -626,7 +630,31 @@ public abstract class AbstractHttpOperationInvoker implements HttpOperationInvok
       printInfo("HTTP response body: ", response.getBody());
     }
 
-    return response;
+    return response.getBody();
+  }
+
+  protected Path downloadResponseToTempFile(ClientHttpRequest request,
+      Map<String, ?> uriVariables) {
+    final URI url = request.getURL(uriVariables);
+
+    // Optional Accept header
+    RequestCallback requestCallback = r -> {
+      r.getHeaders().setAccept(Arrays.asList(MediaType.APPLICATION_OCTET_STREAM));
+      HttpHeaders header = request.getHeaders();
+      r.getHeaders().setAll(request.getHeaders().toSingleValueMap());
+    };
+
+    // Streams the response instead of loading it all in memory
+    ResponseExtractor<Path> responseExtractor = resp -> {
+      Path tempFile = Files.createTempFile("fileDownload", "");
+      if (tempFile.toFile().exists()) {
+        FileUtils.deleteQuietly(tempFile.toFile());
+      }
+      Files.copy(resp.getBody(), tempFile);
+      return tempFile;
+    };
+    return getRestTemplate().execute(url, org.springframework.http.HttpMethod.GET, requestCallback,
+        responseExtractor);
   }
 
   /**
@@ -680,10 +708,8 @@ public abstract class AbstractHttpOperationInvoker implements HttpOperationInvok
       request.addParameterValues("resourceName", resourceName);
       request.addParameterValues("attributeName", attributeName);
 
-      final ResponseEntity<byte[]> response = send(request, byte[].class);
-
       try {
-        return IOUtils.deserializeObject(response.getBody());
+        return IOUtils.deserializeObject(send(request, byte[].class));
       } catch (IOException e) {
         throw new MBeanAccessException(String.format(
             "De-serializing the result of accessing attribute (%1$s) on MBean (%2$s) failed!",
@@ -785,10 +811,8 @@ public abstract class AbstractHttpOperationInvoker implements HttpOperationInvok
       request.addParameterValues("parameters", params); // TODO may need to convert method parameter
                                                         // arguments
 
-      final ResponseEntity<byte[]> response = send(request, byte[].class);
-
       try {
-        return IOUtils.deserializeObject(response.getBody());
+        return IOUtils.deserializeObject(send(request, byte[].class));
       } catch (IOException e) {
         throw new MBeanAccessException(String.format(
             "De-serializing the result from invoking operation (%1$s) on MBean (%2$s) failed!",
@@ -831,11 +855,8 @@ public abstract class AbstractHttpOperationInvoker implements HttpOperationInvok
       final ClientHttpRequest request = createHttpRequest(link);
 
       request.setContent(new QueryParameterSource(objectName, queryExpression));
-
-      final ResponseEntity<byte[]> response = send(request, byte[].class);
-
       try {
-        return (Set<ObjectName>) IOUtils.deserializeObject(response.getBody());
+        return (Set<ObjectName>) IOUtils.deserializeObject(send(request, byte[].class));
       } catch (Exception e) {
         throw new MBeanAccessException(String.format(
             "An error occurred while querying for MBean names using ObjectName pattern (%1$s) and Query expression (%2$s)!",

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
index 82b2b1f..eeedf40 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
@@ -15,14 +15,6 @@
 
 package org.apache.geode.management.internal.web.shell;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
 import org.apache.geode.internal.lang.Filter;
 import org.apache.geode.internal.lang.Initable;
 import org.apache.geode.internal.lang.StringUtils;
@@ -36,15 +28,21 @@ import org.apache.geode.management.internal.web.domain.LinkIndex;
 import org.apache.geode.management.internal.web.http.ClientHttpRequest;
 import org.apache.geode.management.internal.web.http.HttpHeader;
 import org.apache.geode.management.internal.web.util.ConvertUtils;
-
 import org.apache.logging.log4j.Logger;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
 import org.springframework.http.client.ClientHttpResponse;
 import org.springframework.web.client.ResourceAccessException;
 import org.springframework.web.util.UriTemplate;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
 /**
  * The RestHttpOperationInvoker class is an implementation of the OperationInvoker interface that
  * translates (adapts) GemFire shell command invocations into HTTP requests to a corresponding REST
@@ -376,7 +374,8 @@ public class RestHttpOperationInvoker extends AbstractHttpOperationInvoker imple
    * (execution).
    * 
    * @param command the command requested/entered by the user to be processed.
-   * @return the result of the command execution.
+   * @return either a json string of the CommandResult or a Path to a temp file if the response is a
+   *         InputStream
    * @see #createHttpRequest(org.apache.geode.management.internal.cli.CommandRequest)
    * @see #handleResourceAccessException(org.springframework.web.client.ResourceAccessException)
    * @see #isConnected()
@@ -388,15 +387,18 @@ public class RestHttpOperationInvoker extends AbstractHttpOperationInvoker imple
    * @see org.springframework.http.ResponseEntity
    */
   @Override
-  public String processCommand(final CommandRequest command) {
+  public Object processCommand(final CommandRequest command) {
     assertState(isConnected(),
         "Gfsh must be connected to the GemFire Manager in order to process commands remotely!");
 
+    Object result = null;
     try {
-      ResponseEntity<String> response =
-          send(createHttpRequest(command), String.class, command.getParameters());
-
-      return response.getBody();
+      if (command.isDownloadFile()) {
+        result = downloadResponseToTempFile(createHttpRequest(command), command.getParameters());
+      } else {
+        result = send(createHttpRequest(command), String.class, command.getParameters());
+      }
+      return result;
     } catch (RestApiCallForCommandNotFoundException e) {
       return simpleProcessCommand(command, e);
     } catch (ResourceAccessException e) {

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvoker.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvoker.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvoker.java
index dcda27b..d11d824 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvoker.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvoker.java
@@ -15,19 +15,17 @@
 
 package org.apache.geode.management.internal.web.shell;
 
-import java.net.URI;
-import java.util.Map;
-
 import org.apache.geode.management.internal.cli.CommandRequest;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.web.domain.Link;
 import org.apache.geode.management.internal.web.http.ClientHttpRequest;
 import org.apache.geode.management.internal.web.http.HttpMethod;
-
-import org.springframework.http.ResponseEntity;
 import org.springframework.web.client.ResourceAccessException;
 import org.springframework.web.util.UriComponentsBuilder;
 
+import java.net.URI;
+import java.util.Map;
+
 /**
  * The SimpleHttpOperationInvoker class is an implementation of the OperationInvoker interface that
  * issues commands to the GemFire Manager via HTTP. The SimpleHttpOperationInvoker uses a single URL
@@ -156,9 +154,7 @@ public class SimpleHttpOperationInvoker extends AbstractHttpOperationInvoker {
         "Gfsh must be connected to the GemFire Manager in order to process commands remotely!");
 
     try {
-      final ResponseEntity<String> response = send(createHttpRequest(command), String.class);
-
-      return response.getBody();
+      return send(createHttpRequest(command), String.class);
     } catch (ResourceAccessException e) {
       return handleResourceAccessException(e);
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/java/org/apache/geode/management/internal/cli/CommandRequestTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/CommandRequestTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/CommandRequestTest.java
index 5436237..5e60f0b 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/CommandRequestTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/CommandRequestTest.java
@@ -15,18 +15,18 @@
 package org.apache.geode.management.internal.cli;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
-
-import java.util.HashMap;
-import java.util.Map;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
+import org.apache.geode.management.internal.cli.commands.DataCommands;
 import org.apache.geode.test.junit.categories.UnitTest;
-
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.experimental.categories.Categories.ExcludeCategory;
 import org.junit.experimental.categories.Category;
 
+import java.util.HashMap;
+import java.util.Map;
+
 @Category(UnitTest.class)
 public class CommandRequestTest {
 
@@ -36,12 +36,14 @@ public class CommandRequestTest {
   private CommandRequest commandRequest;
 
   @Before
-  public void setUp() {
+  public void setUp() throws Exception {
     this.paramValues = new HashMap<>();
 
     this.mockParseResult = mock(GfshParseResult.class);
     when(this.mockParseResult.getUserInput()).thenReturn("rebalance --simulate=true --time-out=-1");
     when(this.mockParseResult.getParamValueStrings()).thenReturn(this.paramValues);
+    when(this.mockParseResult.getMethod()).thenReturn(DataCommands.class.getMethod("rebalance",
+        String[].class, String[].class, long.class, boolean.class));
 
     this.mockEnvironment = new HashMap<>();
     this.commandRequest = new CommandRequest(this.mockParseResult, this.mockEnvironment, null);

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
index 43ee742..a64620a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
@@ -111,7 +111,7 @@ public class ExportLogsDUnit {
     ZonedDateTime yesterday = now.minusDays(1);
     ZonedDateTime twoDaysAgo = now.minusDays(2);
 
-    DateTimeFormatter dateTimeFormatter =  DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
+    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
 
     CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
     commandStringBuilder.addOption("start-time", dateTimeFormatter.format(twoDaysAgo));
@@ -131,7 +131,7 @@ public class ExportLogsDUnit {
     ZonedDateTime yesterday = now.minusDays(1);
     ZonedDateTime tomorrow = now.plusDays(1);
 
-    DateTimeFormatter dateTimeFormatter =  DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
+    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
 
     CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
     commandStringBuilder.addOption("start-time", dateTimeFormatter.format(yesterday));
@@ -149,18 +149,20 @@ public class ExportLogsDUnit {
   public void testExportWithStartAndEndDateTimeFiltering() throws Exception {
     ZonedDateTime cutoffTime = LocalDateTime.now().atZone(ZoneId.systemDefault());
 
-    String messageAfterCutoffTime = "[this message should not show up since it is after cutoffTime]";
-    LogLine logLineAfterCutoffTime = new LogLine(messageAfterCutoffTime, "info",  true);
+    String messageAfterCutoffTime =
+        "[this message should not show up since it is after cutoffTime]";
+    LogLine logLineAfterCutoffTime = new LogLine(messageAfterCutoffTime, "info", true);
     server1.invoke(() -> {
       Logger logger = LogService.getLogger();
       logLineAfterCutoffTime.writeLog(logger);
     });
 
-    DateTimeFormatter dateTimeFormatter =  DateTimeFormatter.ofPattern(FORMAT);
+    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(FORMAT);
     String cutoffTimeString = dateTimeFormatter.format(cutoffTime);
 
     CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
-    commandStringBuilder.addOption("start-time", dateTimeFormatter.format(cutoffTime.minusHours(1)));
+    commandStringBuilder.addOption("start-time",
+        dateTimeFormatter.format(cutoffTime.minusHours(1)));
     commandStringBuilder.addOption("end-time", cutoffTimeString);
     commandStringBuilder.addOption("log-level", "debug");
     commandStringBuilder.addOption("dir", "someDir");
@@ -175,9 +177,9 @@ public class ExportLogsDUnit {
   @Test
   public void testExportWithThresholdLogLevelFilter() throws Exception {
 
-    CommandResult result = gfshConnector.executeAndVerifyCommand(
-        "export logs --log-level=info --only-log-level=false --dir=" + lsRule.getTempFolder()
-            .getRoot().getCanonicalPath());
+    CommandResult result = gfshConnector
+        .executeAndVerifyCommand("export logs --log-level=info --only-log-level=false --dir="
+            + lsRule.getTempFolder().getRoot().getCanonicalPath());
 
     Set<String> acceptedLogLevels = Stream.of("info", "error").collect(toSet());
     verifyZipFileContents(acceptedLogLevels);
@@ -186,9 +188,9 @@ public class ExportLogsDUnit {
 
   @Test
   public void testExportWithExactLogLevelFilter() throws Exception {
-    CommandResult result = gfshConnector.executeAndVerifyCommand(
-        "export logs --log-level=info --only-log-level=true --dir=" + lsRule.getTempFolder()
-            .getRoot().getCanonicalPath());
+    CommandResult result = gfshConnector
+        .executeAndVerifyCommand("export logs --log-level=info --only-log-level=true --dir="
+            + lsRule.getTempFolder().getRoot().getCanonicalPath());
 
 
     Set<String> acceptedLogLevels = Stream.of("info").collect(toSet());
@@ -197,8 +199,8 @@ public class ExportLogsDUnit {
 
   @Test
   public void testExportWithNoFilters() throws Exception {
-    CommandResult result = gfshConnector.executeAndVerifyCommand(
-        "export logs  --dir=" + "someDir" /*  lsRule.getTempFolder().getRoot().getCanonicalPath() */);
+    CommandResult result = gfshConnector.executeAndVerifyCommand("export logs  --dir="
+        + "someDir" /* lsRule.getTempFolder().getRoot().getCanonicalPath() */);
 
     Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
     verifyZipFileContents(acceptedLogLevels);
@@ -209,8 +211,8 @@ public class ExportLogsDUnit {
     locator.invoke(ExportLogsDUnit::verifyExportLogsRegionWasDestroyed);
   }
 
-@Test
-public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFoundException {
+  @Test
+  public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFoundException {
     locator.invoke(() -> {
       ExportLogsFunction.createOrGetExistingExportLogsRegion(true);
       Cache cache = GemFireCacheImpl.getInstance();
@@ -234,11 +236,10 @@ public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFo
       Cache cache = GemFireCacheImpl.getInstance();
       assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
     });
-}
+  }
 
 
-  public void verifyZipFileContents(Set<String> acceptedLogLevels)
-      throws IOException {
+  public void verifyZipFileContents(Set<String> acceptedLogLevels) throws IOException {
     File unzippedLogFileDir = unzipExportedLogs();
 
     Set<File> dirsFromZipFile =
@@ -261,9 +262,7 @@ public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFo
 
     String memberName = dirForMember.getName();
     Member member = expectedMessages.keySet().stream()
-        .filter((Member aMember) -> aMember.getName().equals(memberName))
-        .findFirst()
-        .get();
+        .filter((Member aMember) -> aMember.getName().equals(memberName)).findFirst().get();
 
     assertThat(member).isNotNull();
 
@@ -276,12 +275,12 @@ public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFo
     assertThat(logFileForMember).exists();
     assertThat(fileNamesInDir).hasSize(1);
 
-    String logFileContents =
-        FileUtils.readLines(logFileForMember, Charset.defaultCharset()).stream()
-            .collect(joining("\n"));
+    String logFileContents = FileUtils.readLines(logFileForMember, Charset.defaultCharset())
+        .stream().collect(joining("\n"));
 
     for (LogLine logLine : expectedMessages.get(member)) {
-      boolean shouldExpectLogLine = acceptedLogLevels.contains(logLine.level) && !logLine.shouldBeIgnoredDueToTimestamp;
+      boolean shouldExpectLogLine =
+          acceptedLogLevels.contains(logLine.level) && !logLine.shouldBeIgnoredDueToTimestamp;
 
       if (shouldExpectLogLine) {
         assertThat(logFileContents).contains(logLine.getMessage());
@@ -300,7 +299,9 @@ public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFo
 
     List<File> zipFilesInDir = Stream.of(locatorWorkingDir.listFiles())
         .filter(f -> f.getName().endsWith(".zip")).collect(toList());
-    assertThat(zipFilesInDir).describedAs(filesInDir.stream().map(File::getAbsolutePath).collect(joining(","))).hasSize(1);
+    assertThat(zipFilesInDir)
+        .describedAs(filesInDir.stream().map(File::getAbsolutePath).collect(joining(",")))
+        .hasSize(1);
 
     File unzippedLogFileDir = lsRule.getTempFolder().newFolder("unzippedLogs");
     ZipUtils.unzip(zipFilesInDir.get(0).getCanonicalPath(), unzippedLogFileDir.getCanonicalPath());

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
new file mode 100644
index 0000000..92ef5f5
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
@@ -0,0 +1,91 @@
+/*
+ * 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.management.internal.cli.commands;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.google.common.collect.Sets;
+
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+
+@Category(DistributedTest.class)
+public class ExportLogsOnServerManagerDUnit {
+
+  @Rule
+  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+
+  @Rule
+  public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
+
+  @Test
+  public void testExportWithOneServer() throws Exception {
+    int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    Server server0 = lsRule.startServerAsJmxManager(0, jmxPort);
+    gfshConnector.connect(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
+    gfshConnector.executeAndVerifyCommand("export logs");
+
+    String message = gfshConnector.getGfshOutput();
+    assertThat(message).contains(server0.getWorkingDir().getAbsolutePath());
+
+    String zipPath = getZipPathFromCommandResult(message);
+
+    Set<String> expectedZipEntries = Sets.newHashSet("server-0/server-0.log");
+    Set<String> actualZipEnries =
+        new ZipFile(zipPath).stream().map(ZipEntry::getName).collect(Collectors.toSet());
+    assertThat(actualZipEnries).isEqualTo(expectedZipEntries);
+  }
+
+  @Test
+  public void testExportWithPeerLocator() throws Exception {
+    int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int locatorPort = ports[0];
+    int jmxPort = ports[1];
+    Server server0 = lsRule.startServerAsEmbededLocator(0, locatorPort, jmxPort);
+    Server server1 = lsRule.startServerVM(1, locatorPort);
+    gfshConnector.connect(locatorPort, GfshShellConnectionRule.PortType.locator);
+    gfshConnector.executeAndVerifyCommand("export logs");
+
+    String message = gfshConnector.getGfshOutput();
+    assertThat(message).contains(server0.getWorkingDir().getAbsolutePath());
+
+    String zipPath = getZipPathFromCommandResult(message);
+
+    Set<String> expectedZipEntries =
+        Sets.newHashSet("server-0/server-0.log", "server-1/server-1.log");
+    Set<String> actualZipEnries =
+        new ZipFile(zipPath).stream().map(ZipEntry::getName).collect(Collectors.toSet());
+    assertThat(actualZipEnries).isEqualTo(expectedZipEntries);
+
+  }
+
+  private String getZipPathFromCommandResult(String message) {
+    return message.replaceAll("Logs exported to the connected member's file system: ", "").trim();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
index abae1de..bb083be 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
@@ -56,7 +56,8 @@ public class ExportLogsFunctionIntegrationTest {
   public void setup() throws Exception {
     serverWorkingDir = temporaryFolder.newFolder("serverWorkingDir");
     System.setProperty("user.dir", serverWorkingDir.getCanonicalPath());
-
+    // fix a ci pipeline glitch
+    System.clearProperty("user.home");
     serverStarterRule.startServer();
   }
 
@@ -87,7 +88,7 @@ public class ExportLogsFunctionIntegrationTest {
     }
 
     Cache cache = GemFireCacheImpl.getInstance();
-    assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
+    assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isEmpty();
   }
 
   @Test
@@ -99,7 +100,8 @@ public class ExportLogsFunctionIntegrationTest {
   }
 
   @Test
-  public void destroyExportLogsRegionWorksAsExpectedForInitiatingMember() throws IOException, ClassNotFoundException {
+  public void destroyExportLogsRegionWorksAsExpectedForInitiatingMember()
+      throws IOException, ClassNotFoundException {
     ExportLogsFunction.createOrGetExistingExportLogsRegion(true);
     Cache cache = GemFireCacheImpl.getInstance();
     assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java
index bd8a6ac..4cb76d3 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java
@@ -32,7 +32,6 @@ import org.junit.experimental.categories.Category;
 import org.junit.rules.TemporaryFolder;
 
 import java.io.File;
-import java.nio.file.Files;
 import java.nio.file.Path;
 import java.text.ParseException;
 import java.util.Comparator;
@@ -96,9 +95,4 @@ public class LogExporterTest {
     assertThat(logExporter.findLogFiles(workingDir.toPath())).doesNotContain(notALogFile.toPath());
   }
 
-  @Test
-  public void findStatFiles() throws Exception {
-
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
new file mode 100644
index 0000000..80b9868
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.management.internal.cli.util;
+
+import static java.util.stream.Collectors.joining;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.test.dunit.rules.Locator;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.Properties;
+
+@Category(DistributedTest.class)
+public class MergeLogsDUnitTest {
+  @Rule
+  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+  private Locator locator;
+
+  private static final String MESSAGE_1 = "MergeLogsMessage1";
+  private static final String MESSAGE_2 = "MergeLogsMessage2";
+  private static final String MESSAGE_3 = "MergeLogsMessage3";
+  private static final String MESSAGE_4 = "MergeLogsMessage4";
+  private static final String MESSAGE_5 = "MergeLogsMessage5";
+  private static final String MESSAGE_6 = "MergeLogsMessage6";
+
+  @Before
+  public void setup() throws Exception {
+    Properties properties = new Properties();
+    properties.setProperty(DistributionConfig.LOG_LEVEL_NAME, "info");
+    locator = lsRule.startLocatorVM(0, properties);
+
+    properties.setProperty(DistributionConfig.LOCATORS_NAME,
+        "localhost[" + locator.getPort() + "]");
+
+    Server server = lsRule.startServerVM(1, properties);
+    Server server2 = lsRule.startServerVM(2, properties);
+
+    locator.invoke(() -> LogService.getLogger().info(MESSAGE_1));
+    server.invoke(() -> LogService.getLogger().info(MESSAGE_2));
+    server2.invoke(() -> LogService.getLogger().info(MESSAGE_3));
+
+    locator.invoke(() -> LogService.getLogger().info(MESSAGE_4));
+    server.invoke(() -> LogService.getLogger().info(MESSAGE_5));
+    server2.invoke(() -> LogService.getLogger().info(MESSAGE_6));
+  }
+
+  @Test
+  public void testExportInProcess() throws Exception {
+    assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempFolder().getRoot())).hasSize(3);
+
+    File result = MergeLogs.mergeLogFile(lsRule.getTempFolder().getRoot().getCanonicalPath());
+    assertOnLogContents(result);
+  }
+
+  @Test
+  public void testExportInNewProcess() throws Throwable {
+    assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempFolder().getRoot())).hasSize(3);
+
+    MergeLogs.mergeLogsInNewProcess(lsRule.getTempFolder().getRoot().toPath());
+    File result = Arrays.stream(lsRule.getTempFolder().getRoot().listFiles())
+        .filter((File f) -> f.getName().startsWith("merge")).findFirst().orElseThrow(() -> {
+          throw new AssertionError("No merged log file found");
+        });
+    assertOnLogContents(result);
+
+  }
+
+  private void assertOnLogContents(File mergedLogFile) throws IOException {
+    String mergedLines = FileUtils.readLines(mergedLogFile, Charset.defaultCharset()).stream()
+        .collect(joining("\n"));
+
+    assertThat(mergedLines).contains(MESSAGE_1);
+    assertThat(mergedLines).contains(MESSAGE_2);
+    assertThat(mergedLines).contains(MESSAGE_3);
+    assertThat(mergedLines).contains(MESSAGE_4);
+    assertThat(mergedLines).contains(MESSAGE_5);
+    assertThat(mergedLines).contains(MESSAGE_6);
+
+    // Make sure that our merged log file contains the proper ordering
+    assertThat(mergedLines.indexOf(MESSAGE_1)).isLessThan(mergedLines.indexOf(MESSAGE_2));
+    assertThat(mergedLines.indexOf(MESSAGE_2)).isLessThan(mergedLines.indexOf(MESSAGE_3));
+    assertThat(mergedLines.indexOf(MESSAGE_3)).isLessThan(mergedLines.indexOf(MESSAGE_4));
+    assertThat(mergedLines.indexOf(MESSAGE_4)).isLessThan(mergedLines.indexOf(MESSAGE_5));
+    assertThat(mergedLines.indexOf(MESSAGE_5)).isLessThan(mergedLines.indexOf(MESSAGE_6));
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java
deleted file mode 100644
index 7f4ffd4..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.management.internal.cli.util;
-
-import static java.util.stream.Collectors.joining;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.test.dunit.rules.Locator;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.Properties;
-
-@Category(DistributedTest.class)
-public class MergeLogsTest {
-  @Rule
-  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
-  private Locator locator;
-
-  private static final String MESSAGE_1 = "MergeLogsMessage1";
-  private static final String MESSAGE_2 = "MergeLogsMessage2";
-  private static final String MESSAGE_3 = "MergeLogsMessage3";
-  private static final String MESSAGE_4 = "MergeLogsMessage4";
-  private static final String MESSAGE_5 = "MergeLogsMessage5";
-  private static final String MESSAGE_6 = "MergeLogsMessage6";
-
-  @Before
-  public void setup() throws Exception {
-    Properties properties = new Properties();
-    properties.setProperty(DistributionConfig.LOG_LEVEL_NAME, "info");
-    locator = lsRule.startLocatorVM(0, properties);
-
-    properties
-        .setProperty(DistributionConfig.LOCATORS_NAME, "localhost[" + locator.getPort() + "]");
-
-    Server server = lsRule.startServerVM(1, properties);
-    Server server2 = lsRule.startServerVM(2, properties);
-
-    locator.invoke(() -> LogService.getLogger().info(MESSAGE_1));
-    server.invoke(() -> LogService.getLogger().info(MESSAGE_2));
-    server2.invoke(() -> LogService.getLogger().info(MESSAGE_3));
-
-    locator.invoke(() -> LogService.getLogger().info(MESSAGE_4));
-    server.invoke(() -> LogService.getLogger().info(MESSAGE_5));
-    server2.invoke(() -> LogService.getLogger().info(MESSAGE_6));
-  }
-
-  @Test
-  public void testExportInProcess() throws Exception {
-    assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempFolder().getRoot())).hasSize(3);
-
-    File result = MergeLogs.mergeLogFile(lsRule.getTempFolder().getRoot().getCanonicalPath());
-    assertOnLogContents(result);
-  }
-    @Test
-  public void testExportInNewProcess() throws Throwable {
-    assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempFolder().getRoot())).hasSize(3);
-
-    MergeLogs.mergeLogsInNewProcess(lsRule.getTempFolder().getRoot().toPath());
-      File result = Arrays.stream(lsRule.getTempFolder().getRoot().listFiles()).filter((File f) -> f.getName().startsWith("merge"))
-            .findFirst().orElseThrow(() -> {throw new AssertionError("No merged log file found");});
-    assertOnLogContents(result);
-
-  }
-
-  private void assertOnLogContents (File mergedLogFile) throws IOException {
-    String
-        mergedLines =
-        FileUtils.readLines(mergedLogFile, Charset.defaultCharset()).stream().collect(joining("\n"));
-
-    assertThat(mergedLines).contains(MESSAGE_1);
-    assertThat(mergedLines).contains(MESSAGE_2);
-    assertThat(mergedLines).contains(MESSAGE_3);
-    assertThat(mergedLines).contains(MESSAGE_4);
-    assertThat(mergedLines).contains(MESSAGE_5);
-    assertThat(mergedLines).contains(MESSAGE_6);
-
-    //Make sure that our merged log file contains the proper ordering
-    assertThat(mergedLines.indexOf(MESSAGE_1)).isLessThan(mergedLines.indexOf(MESSAGE_2));
-    assertThat(mergedLines.indexOf(MESSAGE_2)).isLessThan(mergedLines.indexOf(MESSAGE_3));
-    assertThat(mergedLines.indexOf(MESSAGE_3)).isLessThan(mergedLines.indexOf(MESSAGE_4));
-    assertThat(mergedLines.indexOf(MESSAGE_4)).isLessThan(mergedLines.indexOf(MESSAGE_5));
-    assertThat(mergedLines.indexOf(MESSAGE_5)).isLessThan(mergedLines.indexOf(MESSAGE_6));
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
index d1750c3..ef8b7f1 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
@@ -156,9 +156,7 @@ public class GfshCommandsSecurityTest {
     List<TestCommand> allPermitted =
         TestCommand.getPermittedCommands(new WildcardPermission(permission, true));
     for (TestCommand permitted : allPermitted) {
-      LogService.getLogger().info("Processing authorized command: " + permitted.getCommand());
-
-
+      System.out.println("Processing authorized command: " + permitted.getCommand());
       CommandResult result = gfshConnection.executeCommand(permitted.getCommand());
       assertNotNull(result);
 
@@ -177,7 +175,7 @@ public class GfshCommandsSecurityTest {
       if (other.getPermission() == null)
         continue;
 
-      LogService.getLogger().info("Processing unauthorized command: " + other.getCommand());
+      System.out.println("Processing unauthorized command: " + other.getCommand());
       CommandResult result = (CommandResult) gfshConnection.executeCommand(other.getCommand());
       int errorCode = ((ErrorResultData) result.getResultData()).getErrorCode();
 


[03/50] [abbrv] geode git commit: Overhauling the javadocs for the LuceneService

Posted by ds...@apache.org.
Overhauling the javadocs for the LuceneService

Enhancing the javadocs with more detailed descriptions of what the
classes do, adding links to lucene classes where appropriate, and
removing some cruft that didn't match the current implementation.

This closes #410


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/c0633c8d
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/c0633c8d
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/c0633c8d

Branch: refs/heads/feature/GEODE-1969
Commit: c0633c8d612847fc284cd8b3f09a4aac214c8a1f
Parents: 6118d54
Author: Dan Smith <up...@apache.org>
Authored: Fri Feb 24 17:58:09 2017 -0800
Committer: Dan Smith <up...@apache.org>
Committed: Thu Mar 2 14:46:35 2017 -0800

----------------------------------------------------------------------
 geode-assembly/build.gradle                     |   2 +
 .../apache/geode/cache/lucene/LuceneIndex.java  |  17 ++-
 .../apache/geode/cache/lucene/LuceneQuery.java  |  41 +++++-
 .../cache/lucene/LuceneQueryException.java      |   2 +-
 .../geode/cache/lucene/LuceneQueryFactory.java  |  63 +++++---
 .../geode/cache/lucene/LuceneQueryProvider.java |  24 +--
 .../geode/cache/lucene/LuceneResultStruct.java  |  17 +--
 .../geode/cache/lucene/LuceneService.java       | 145 ++++++++++++-------
 .../cache/lucene/LuceneServiceProvider.java     |   2 +-
 .../lucene/PageableLuceneQueryResults.java      |  22 +--
 .../lucene/internal/LuceneQueryFactoryImpl.java |   8 +
 .../apache/geode/cache/lucene/package-info.java |   8 +-
 12 files changed, 226 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/geode-assembly/build.gradle b/geode-assembly/build.gradle
index cce5245..1900896 100755
--- a/geode-assembly/build.gradle
+++ b/geode-assembly/build.gradle
@@ -214,6 +214,8 @@ task gfshDepsJar (type: Jar, dependsOn: ':geode-core:classes') {
 def docsDir = file("$buildDir/javadocs")
 task docs(type: Javadoc) {
     options.addStringOption('Xdoclint:none', '-quiet')
+    options.links("https://lucene.apache.org/core/6_4_1/core/")
+    options.links("https://lucene.apache.org/core/6_4_1/queryparser/")
     options.encoding='UTF-8'
     source parent.subprojects*.javadoc*.source
     classpath = files(parent.subprojects*.javadoc*.classpath)

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneIndex.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneIndex.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneIndex.java
index 1069f74..f13c8b3 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneIndex.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneIndex.java
@@ -23,34 +23,35 @@ import org.apache.geode.annotations.Experimental;
 
 
 /**
- * An lucene index is built over the data stored in a GemFire Region.
  * <p>
- * An index is specified using a index name, field names, region name.
- * <p>
- * The index name and region name together uniquely identifies the lucene index.
+ * An Lucene index is built over the data stored in a GemFire Region.
+ * </p>
  * <p>
+ * An index is specified using a index name, field names, region name.
+ * </p>
+ * The index name and region name together uniquely identifies the Lucene index.
  * 
  */
 @Experimental
 public interface LuceneIndex {
 
   /**
-   * @return the index name of this index
+   * @return the name of this index
    */
   public String getName();
 
   /**
-   * @return the region name for this index
+   * @return the name of the region that is being indexed
    */
   public String getRegionPath();
 
   /**
-   * @return the indexed field names in a Set
+   * @return the indexed field names
    */
   public String[] getFieldNames();
 
   /**
-   * @return the field to analyzer map
+   * @return a map of what {@link Analyzer} is being used for each indexed field.
    */
   public Map<String, Analyzer> getFieldAnalyzers();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQuery.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQuery.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQuery.java
index 1afb35a..1218dcc 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQuery.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQuery.java
@@ -20,30 +20,57 @@ import java.util.List;
 import org.apache.geode.annotations.Experimental;
 
 /**
- * Provides wrapper object of Lucene's Query object and execute the search.
  * <p>
- * Instances of this interface are created using {@link LuceneQueryFactory#create}.
- * 
+ * A query on a Lucene index. Instances of this interface are created using
+ * {@link LuceneQueryFactory#create}. Once this query is constructed, use one of the find methods to
+ * find region entries that match this query.
+ * </p>
+ * <p>
+ * Instances obtained from {@link LuceneQueryFactory} are immutable, so they are safe for reuse and
+ * can be shared by multiple threads.
+ * </p>
+ * <p>
+ * Because Lucene indexes are maintained asynchronously, results returned from the find methods may
+ * not reflect the most recent updates to the region.
+ * </p>
+ * <p>
+ * Results are returned in order of their score with respect to this query. See
+ * {@link org.apache.lucene.search} for details on how Lucene scores entries.
+ * </p>
  */
 @Experimental
 public interface LuceneQuery<K, V> {
   /**
-   * Execute search and return keys.
+   * Execute the query and return the region keys that match this query, up to the limit specified
+   * by {@link #getLimit()}.
+   * 
+   * @throws LuceneQueryException if the query could not be parsed or executed.
    */
   public Collection<K> findKeys() throws LuceneQueryException;
 
   /**
-   * Execute search and return values.
+   * Execute the query and return the region values that match this query, up to the limit specified
+   * by {@link #getLimit()}
+   * 
+   * @throws LuceneQueryException if the query could not be parsed or executed.
    */
   public Collection<V> findValues() throws LuceneQueryException;
 
   /**
-   * Execute search and return list of LuceneResultStruct.
+   * Execute the query and return a list of {@link LuceneResultStruct}s that match this query, up to
+   * the limit specified by {@link #getLimit()} A {@link LuceneResultStruct} contains the region
+   * key, value, and a score for that entry.
+   *
+   * @throws LuceneQueryException if the query could not be parsed or executed.
    */
   public List<LuceneResultStruct<K, V>> findResults() throws LuceneQueryException;
 
   /**
-   * Execute the search and get results.
+   * Execute the query and get a {@link PageableLuceneQueryResults}. The
+   * {@link PageableLuceneQueryResults} provides the ability to fetch a page of results at a time,
+   * as specified by {@link #getPageSize()}
+   *
+   * @throws LuceneQueryException if the query could not be parsed or executed.
    */
   public PageableLuceneQueryResults<K, V> findPages() throws LuceneQueryException;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryException.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryException.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryException.java
index 98c313e..dde8f9a 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryException.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryException.java
@@ -18,7 +18,7 @@ package org.apache.geode.cache.lucene;
 import org.apache.geode.GemFireCheckedException;
 
 /**
- * Thrown when a lucene query fails.
+ * Thrown when a Lucene query fails.
  */
 public class LuceneQueryException extends GemFireCheckedException {
 

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryFactory.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryFactory.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryFactory.java
index 174e7e1..f4bd21c 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryFactory.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryFactory.java
@@ -14,17 +14,22 @@
  */
 package org.apache.geode.cache.lucene;
 
+import org.apache.geode.cache.query.Query;
 import org.apache.lucene.queryparser.classic.ParseException;
 
 import org.apache.geode.annotations.Experimental;
+import org.apache.lucene.queryparser.flexible.standard.StandardQueryParser;
 
 /**
- * Factory for creating instances of {@link LuceneQuery}. To get an instance of this factory call
+ * Factory for configuring a Lucene query. Use this factory to set parameters of the query such as
+ * page size, result limit, and query expression. To get an instance of this factory call
  * {@link LuceneService#createLuceneQueryFactory}.
  * <P>
- * To use this factory configure it with the <code>set</code> methods and then call {@link #create}
- * to produce a {@link LuceneQuery} instance.
- * 
+ * To use this factory configure it with the <code>set</code> methods and then call one of the
+ * create methods on this class. {@link #create(String, String, String, String)} creates a query by
+ * parsing a query string. {@link #create(String, String, LuceneQueryProvider)} creates a query
+ * based on a custom Lucene {@link Query} object.
+ *
  */
 @Experimental
 public interface LuceneQueryFactory {
@@ -40,32 +45,34 @@ public interface LuceneQueryFactory {
   public static final int DEFAULT_PAGESIZE = 0;
 
   /**
-   * Set page size for a query result. The default page size is 0 which means no pagination. If
-   * specified negative value, throw IllegalArgumentException
-   * 
+   * Set page size for a query result. The default page size is 0 which means no pagination.
+   *
    * @param pageSize
    * @return itself
+   * @throws IllegalArgumentException if the value is less than 0
    */
   LuceneQueryFactory setPageSize(int pageSize);
 
   /**
-   * Set max limit of result for a query If specified limit is less or equal to zero, throw
-   * IllegalArgumentException
-   * 
+   * Set maximum number of results for a query. By default, the limit is set to
+   * {@link #DEFAULT_LIMIT} which is 100.
+   *
    * @param limit
    * @return itself
+   * @throws IllegalArgumentException if the value is less than or equal to zero.
    */
   LuceneQueryFactory setResultLimit(int limit);
 
   /**
-   * Create wrapper object for lucene's QueryParser object using default standard analyzer. The
-   * queryString is using lucene QueryParser's syntax. QueryParser is for easy-to-use with human
-   * understandable syntax.
-   * 
+   * Creates a query based on a query string which is parsed by Lucene's
+   * {@link StandardQueryParser}. See the javadocs for {@link StandardQueryParser} for details on
+   * the syntax of the query string. The query string and default field as passed as is to
+   * {@link StandardQueryParser#parse(String, String)}
+   *
    * @param regionName region name
    * @param indexName index name
-   * @param queryString query string in lucene QueryParser's syntax
-   * @param defaultField default field used by the Lucene Query Parser
+   * @param queryString Query string parsed by Lucene's StandardQueryParser
+   * @param defaultField default field used by the Lucene's StandardQueryParser
    * @param <K> the key type in the query results
    * @param <V> the value type in the query results
    * @return LuceneQuery object
@@ -74,13 +81,29 @@ public interface LuceneQueryFactory {
       String defaultField);
 
   /**
-   * Creates a wrapper object for Lucene's Query object. This {@link LuceneQuery} builder method
-   * could be used in advanced cases, such as cases where Lucene's Query object construction needs
-   * Lucene's API over query string.
+   * <p>
+   * Create a query based on a programatically constructed Lucene {@link Query}. This can be used
+   * for queries that are not covered by {@link StandardQueryParser}, such as range queries.
+   * </p>
+   * <p>
+   * Because Geode may execute the Lucene query on multiple nodes in parallel and {@link Query} is
+   * not serializable, this method requires a serializable {@link LuceneQueryProvider} that can
+   * create a {@link Query} on the nodes hosting the Lucene index.
+   * </p>
+   * <p>
+   * Here's an example of using this method to create a range query on an integer field called
+   * "age."
+   * </p>
    * 
+   * <pre>
+   * {@code
+   *   LuceneQuery query = factory.create("index", "region", index -> IntPoint.newRangeQuery("age", 20, 30))
+   * }
+   * </pre>
+   *
    * @param indexName index name
    * @param regionName region name
-   * @param provider constructs and provides a Lucene Query object
+   * @param provider constructs and provides a Lucene {@link Query}.
    * @param <K> the key type in the query results
    * @param <V> the value type in the query results
    * @return LuceneQuery object

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryProvider.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryProvider.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryProvider.java
index 8b1064e..2611293 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryProvider.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryProvider.java
@@ -15,28 +15,32 @@
 
 package org.apache.geode.cache.lucene;
 
+import java.io.DataOutput;
 import java.io.Serializable;
 
+import org.apache.geode.DataSerializer;
 import org.apache.lucene.search.Query;
 
 import org.apache.geode.annotations.Experimental;
 import org.apache.geode.cache.query.QueryException;
 
 /**
- * The instances of this class will be used for distributing Lucene Query objects and
- * re-constructing the Query object. If necessary the implementation needs to take care of
- * serializing and de-serializing Lucene Query object. Geode respects the DataSerializable contract
- * to provide optimal object serialization. For instance, {@link LuceneQueryProvider}'s toData
- * method will be used to serialize it when it is sent to another member of the distributed system.
- * Implementation of DataSerializable can provide a zero-argument constructor that will be invoked
- * when they are read with DataSerializer.readObject.
+ * <p>
+ * A factory for {@link Query} objects. An implementation of this interface is required by
+ * {@link LuceneQueryFactory#create(String, String, LuceneQueryProvider)} so that a query can be
+ * serialized and distributed to multiple nodes.
+ * </p>
+ * Instances of this interface are serialized using the standard
+ * {@link DataSerializer#writeObject(Object, DataOutput)},
  */
 @Experimental
+@FunctionalInterface
 public interface LuceneQueryProvider extends Serializable {
   /**
-   * @return A Lucene Query object which could be used for executing Lucene Search on indexed data
-   * @param index local lucene index the query is being constructed against.
-   * @throws LuceneQueryException if the provider fails to construct the query object
+   * @return A {@link Query} which will be executed against a Lucene index.
+   * @param index The {@link LuceneIndex} the query is being executed against.
+   * @throws LuceneQueryException if the provider fails to construct the query object. This will be
+   *         propagated to callers of the {@link LuceneQuery} find methods.
    */
 
   public Query getQuery(LuceneIndex index) throws LuceneQueryException;

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
index b922185..4a6481f 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
@@ -17,34 +17,29 @@ package org.apache.geode.cache.lucene;
 import org.apache.geode.annotations.Experimental;
 
 /**
- * <p>
- * Abstract data structure for one item in query result.
+ * A single result of a Lucene query.
  * 
  */
 @Experimental
 public interface LuceneResultStruct<K, V> {
 
   /**
-   * Return key of the entry
+   * @return The region key of the entry matching the query
    *
-   * @return key
-   * @throws IllegalArgumentException If this struct does not contain key
    */
   public K getKey();
 
   /**
-   * Return value of the entry
+   * @return the region value of the entry matching the query.
    *
-   * @return value the whole domain object
-   * @throws IllegalArgumentException If this struct does not contain value
    */
   public V getValue();
 
   /**
-   * Return score of the query
+   * Return score the score of the entry matching the query. Scores are computed by Lucene based on
+   * how closely documents match the query. See {@link org.apache.lucene.search} for details on how
+   * scores are computed.
    *
-   * @return score
-   * @throws IllegalArgumentException If this struct does not contain score
    */
   public float getScore();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
index 704abcd..f035442 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
@@ -19,6 +19,7 @@ import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.DataPolicy;
 import org.apache.lucene.analysis.Analyzer;
 
 import org.apache.geode.annotations.Experimental;
@@ -26,82 +27,110 @@ import org.apache.geode.cache.GemFireCache;
 import org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile;
 
 /**
- * LuceneService instance is a singleton for each cache.
- * 
- * It provides handle for managing the {@link LuceneIndex} and create the {@link LuceneQuery} via
- * {@link LuceneQueryFactory}
- * 
+ *
+ * The LuceneService provides the capability to create Lucene indexes and execute lucene queries on
+ * data stored in Geode regions. The Lucene indexes are automatically maintained by Geode whenever
+ * entries are updated in the associated regions.
+ *
+ * <p>
+ * To obtain an instance of LuceneService, use {@link LuceneServiceProvider#get(GemFireCache)}.
+ * </p>
+ * <p>
+ * Lucene indexes can be created using gfsh, xml, or the java API. Below is an example of creating a
+ * Lucene index with the java API. The Lucene index created on each member that will host data for
+ * the region.
  * </p>
- * Example: <br>
  * 
  * <pre>
- * At client and server JVM, initializing cache will create the LuceneServiceImpl object, 
- * which is a singleton at each JVM. 
- * 
- * At each server JVM, for data region to create index, create the index on fields with default analyzer:
- * LuceneIndex index = luceneService.createIndex(indexName, regionName, "field1", "field2", "field3"); 
- * or create index on fields with specified analyzer:
- * LuceneIndex index = luceneService.createIndex(indexName, regionName, analyzerPerField);
- * 
- * We can also create index via cache.xml or gfsh.
- * 
- * At client side, create query and run the search:
- * 
- * LuceneQuery query = luceneService.createLuceneQueryFactory().setLimit(200).setPageSize(20)
- * .setResultTypes(SCORE, VALUE, KEY).setFieldProjection("field1", "field2")
- * .create(indexName, regionName, querystring, analyzer);
- * 
- * The querystring is using lucene's queryparser syntax, such as "field1:zhou* AND field2:gzhou@pivotal.io"
- *  
- * PageableLuceneQueryResults results = query.search();
- * 
- * If pagination is not specified:
- * List list = results.getNextPage(); // return all results in one getNextPage() call
- * or if paging is specified:
- * if (results.hasNextPage()) {
- *   List page = results.nextPage(); // return resules page by page
+ * {
+ *   &#64;code
+ *   LuceneIndex index =
+ *       luceneService.createIndex(indexName, regionName, "field1", "field2", "field3");
  * }
- * 
- * The item of the list is either the domain object or instance of {@link LuceneResultStruct}
  * </pre>
+ * <p>
+ * You can also specify what {@link Analyzer} to use for each field.
+ * </p>
  * 
+ * <pre>
+ * {
+ *   &#64;code
+ *   LuceneIndex index = luceneService.createIndex(indexName, regionName, analyzerPerField);
+ * }
+ * </pre>
+ *
+ * Indexes should be created on all peers that host the region being indexed. Clients do not need to
+ * define the index, they can directly execute queries using this service.
+ *
+ * <p>
+ * Queries on this service can return either the region keys, values, or both that match a Lucene
+ * query expression. To execute a query, start with the {@link #createLuceneQueryFactory()} method.
+ * </p>
  *
+ * <pre>
+ * {
+ *   &#64;code
+ *   LuceneQuery query = luceneService.createLuceneQueryFactory().setLimit(200).create(indexName,
+ *       regionName, "name:John AND zipcode:97006", defaultField);
+ *   Collection<Object> results = query.findValues();
+ * }
+ * </pre>
+ *
+ * <p>
+ * The Lucene index data is colocated with the region that is indexed. This means that the index
+ * data will be partitioned, copied, or persisted using the same configuration options you provide
+ * for the region that is indexed. Queries will automatically be distributed in parallel to cover
+ * all partitions of a partitioned region.
+ * </p>
+ * <p>
+ * Indexes are maintained asynchronously, so changes to regions may not be immediately reflected in
+ * the index. This means that queries executed using this service may return stale results. Use the
+ * {@link #waitUntilFlushed(String, String, long, TimeUnit)} method if you need to wait for your
+ * changes to be indexed before executing a query, however this method should be used sparingly
+ * because it is an expensive operation.
+ * </p>
+ *
+ * <p>
+ * Currently, only partitioned regions are supported. Creating an index on a region with
+ * {@link DataPolicy#REPLICATE} will fail.
+ * </p>
+ * 
  */
 @Experimental
 public interface LuceneService {
 
   /**
    * A special field name that indicates that the entire region value should be indexed. This will
-   * only work if the region value is a String or Number, in which case a lucene document will be
+   * only work if the region value is a String or Number, in which case a Lucene document will be
    * created with a single field with this name.
    */
-  String REGION_VALUE_FIELD = "__REGION_VALUE_FIELD";
+  public String REGION_VALUE_FIELD = "__REGION_VALUE_FIELD";
 
   /**
-   * Create a lucene index using default analyzer.
+   * Create a Lucene index using default analyzer.
    * 
    * @param fields The fields of the object to index. Only fields listed here will be stored in the
    *        index. Fields should map to PDX fieldNames if the object is serialized with PDX, or to
-   *        java fields on the object otherwise. The special field name
-   *        {{@link #REGION_VALUE_FIELD}} indicates that the entire value should be stored as a
-   *        single field in the index.
+   *        java fields on the object otherwise. The special field name {@link #REGION_VALUE_FIELD}
+   *        indicates that the entire value should be stored as a single field in the index.
    */
   public void createIndex(String indexName, String regionPath, String... fields);
 
   /**
-   * Create a lucene index using specified analyzer per field
+   * Create a Lucene index using specified {@link Analyzer} per field. Analyzers are used by Lucene
+   * to tokenize your field into individual words.
    * 
    * @param indexName index name
    * @param regionPath region name
    * @param analyzerPerField A map of fields to analyzers. See
-   *        {{@link #createIndex(String, String, String...)}} for details on valid values for
-   *        fields. Each field will be tokenized using the provided Analyzer.
+   *        {@link #createIndex(String, String, String...)} for details on valid values for fields.
+   *        Each field will be tokenized using the provided Analyzer.
    */
   public void createIndex(String indexName, String regionPath,
       Map<String, Analyzer> analyzerPerField);
 
   /**
-   * Destroy the lucene index
+   * Destroy the Lucene index
    *
    * @param indexName the name of the index to destroy
    * @param regionPath the path of the region whose index to destroy
@@ -109,14 +138,14 @@ public interface LuceneService {
   public void destroyIndex(String indexName, String regionPath);
 
   /**
-   * Destroy all the lucene indexes for the region
+   * Destroy all the Lucene indexes for the region
    *
    * @param regionPath The path of the region on which to destroy the indexes
    */
   public void destroyIndexes(String regionPath);
 
   /**
-   * Get the lucene index object specified by region name and index name
+   * Get the Lucene index object specified by region name and index name
    * 
    * @param indexName index name
    * @param regionPath region name
@@ -125,16 +154,14 @@ public interface LuceneService {
   public LuceneIndex getIndex(String indexName, String regionPath);
 
   /**
-   * get all the lucene indexes.
+   * get all the Lucene indexes.
    * 
    * @return all index objects in a Collection
    */
   public Collection<LuceneIndex> getAllIndexes();
 
   /**
-   * create LuceneQueryFactory
-   * 
-   * @return LuceneQueryFactory object
+   * Create a factory for building a Lucene query.
    */
   public LuceneQueryFactory createLuceneQueryFactory();
 
@@ -146,14 +173,24 @@ public interface LuceneService {
   public Cache getCache();
 
 
-  /**
-   * wait until the current entries in cache are indexed
-   * 
+  /*
+   * Wait until the current entries in cache are indexed.
+   *
+   * Lucene indexes are maintained asynchronously. This means that updates to the region will not be
+   * immediately reflected in the Lucene index. This method will either timeout or wait until any
+   * data put into the region before this method call is flushed to the lucene index.
+   *
+   * This method is an expensive operation, so using it before every query is highly discouraged.
+   *
    * @param indexName index name
+   * 
    * @param regionPath region name
+   * 
    * @param timeout max wait time
-   * @param unit granularity of the timeout
-   * @return if entries are flushed within timeout
+   * 
+   * @param unit Time unit associated with the max wait time
+   * 
+   * @return true if entries are flushed within timeout, false if the timeout has elapsed
    */
   public boolean waitUntilFlushed(String indexName, String regionPath, long timeout, TimeUnit unit)
       throws InterruptedException;

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneServiceProvider.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneServiceProvider.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneServiceProvider.java
index a1f73da..798b5c3 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneServiceProvider.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneServiceProvider.java
@@ -27,7 +27,7 @@ import org.apache.geode.internal.cache.InternalCache;
 @Experimental
 public class LuceneServiceProvider {
   /**
-   * Retrieve or create the lucene service for this cache
+   * Retrieve or create the Lucene service for this cache
    */
   public static LuceneService get(GemFireCache cache) {
     InternalCache internalCache = (InternalCache) cache;

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/PageableLuceneQueryResults.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/PageableLuceneQueryResults.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/PageableLuceneQueryResults.java
index da04d01..9c68ce4 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/PageableLuceneQueryResults.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/PageableLuceneQueryResults.java
@@ -15,30 +15,34 @@
 
 package org.apache.geode.cache.lucene;
 
+import org.apache.geode.annotations.Experimental;
+
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.geode.annotations.Experimental;
-
 /**
  * <p>
- * Defines the interface for a container of lucene query result collected from function
- * execution.<br>
- * 
- * 
+ * This interface allows you to retrieve a page of query results at a time, using the
+ * {@link #hasNext()} and {@link #next()} methods.
+ * </p>
+ *
+ * Each page is fetched individually from the server, so {@link PageableLuceneQueryResults} cannot
+ * be serialized and sent to other members.
+ *
+ * @see LuceneQuery#findPages()
+ *
  * @param <K> The type of the key
  * @param <V> The type of the value
  */
 @Experimental
 public interface PageableLuceneQueryResults<K, V> extends Iterator<List<LuceneResultStruct<K, V>>> {
   /**
-   * @return total number of hits for this query
+   * @return total number of hits for this query across all pages.
    */
   public int size();
 
   /**
-   * Returns the maximum score value encountered. Note that in case scores are not tracked, this
-   * returns {@link Float#NaN}.
+   * Returns the maximum score value across all pages.
    */
   public float getMaxScore();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryFactoryImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryFactoryImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryFactoryImpl.java
index b798e30..5c088dc 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryFactoryImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryFactoryImpl.java
@@ -32,12 +32,20 @@ public class LuceneQueryFactoryImpl implements LuceneQueryFactory {
 
   @Override
   public LuceneQueryFactory setPageSize(int pageSize) {
+    if (pageSize < 0) {
+      throw new IllegalArgumentException("Page size is negative: " + pageSize);
+    }
+
     this.pageSize = pageSize;
     return this;
   }
 
   @Override
   public LuceneQueryFactory setResultLimit(int limit) {
+    if (limit <= 0) {
+      throw new IllegalArgumentException("Limit is <= 0: " + limit);
+    }
+
     this.limit = limit;
     return this;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/package-info.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/package-info.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/package-info.java
index 9541fee..3c2becb 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/package-info.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/package-info.java
@@ -18,14 +18,14 @@
  * <p>
  * All indexing and query operations are performed through the
  * {@link org.apache.geode.cache.lucene.LuceneService} class. See
- * {@link org.apache.geode.cache.lucene.LuceneService} for an example of how to add a lucene index
- * to a geode region.
+ * {@link org.apache.geode.cache.lucene.LuceneService} for an example of how to add a Lucene index
+ * to a Geode region.
  * <p>
  *
- * The Lucene indexes created using this API are stored in geode and colocated with the indexed
+ * The Lucene indexes created using this API are stored in Geode and colocated with the indexed
  * region, which means they have the same availability guarantees as the underlying region. The
  * indexes are maintained asynchronously, so changes to the region may not be immediately visible in
- * the lucene index.
+ * the Lucene index.
  */
 
 package org.apache.geode.cache.lucene;


[05/50] [abbrv] geode git commit: GEODE-2589, GEODE-2590 lucene index region attributes should be based on data region

Posted by ds...@apache.org.
GEODE-2589, GEODE-2590 lucene index region attributes should be based on data region

- lucene index region now inherits recoveryDelay and startupRecoveryDelay from data region
- lucene index region now only sets diskStoreName (in RegionAttributes) when data region has persistence.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/24d02a58
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/24d02a58
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/24d02a58

Branch: refs/heads/feature/GEODE-1969
Commit: 24d02a5862851ceffa715233f245c46651776cf4
Parents: 21a9b5e
Author: Lynn Hughes-Godfrey <lh...@pivotal.io>
Authored: Fri Mar 3 13:11:53 2017 -0800
Committer: Lynn Hughes-Godfrey <lh...@pivotal.io>
Committed: Fri Mar 3 13:11:53 2017 -0800

----------------------------------------------------------------------
 .../LuceneIndexForPartitionedRegion.java        |  6 ++-
 ...IndexCreationPersistenceIntegrationTest.java | 44 +++++++++++++++++++-
 2 files changed, 48 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/24d02a58/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index f45d94d..4aa24b5 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -158,6 +158,8 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     attributesFactory.setTotalNumBuckets(dataRegionAttributes.getTotalNumBuckets());
     attributesFactory.setRedundantCopies(dataRegionAttributes.getRedundantCopies());
     attributesFactory.setPartitionResolver(getPartitionResolver(dataRegionAttributes));
+    attributesFactory.setRecoveryDelay(dataRegionAttributes.getRecoveryDelay());
+    attributesFactory.setStartupRecoveryDelay(dataRegionAttributes.getStartupRecoveryDelay());
     return attributesFactory;
   }
 
@@ -185,7 +187,9 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     RegionAttributes baseAttributes = this.cache.getRegionAttributes(regionShortCut.toString());
     AttributesFactory factory = new AttributesFactory(baseAttributes);
     factory.setPartitionAttributes(partitionAttributesFactory.create());
-    factory.setDiskStoreName(regionAttributes.getDiskStoreName());
+    if (regionAttributes.getDataPolicy().withPersistence()) {
+      factory.setDiskStoreName(regionAttributes.getDiskStoreName());
+    }
     RegionAttributes<K, V> attributes = factory.create();
 
     return createRegion(regionName, attributes);

http://git-wip-us.apache.org/repos/asf/geode/blob/24d02a58/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
index 81e76f5..4b27ee6 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
@@ -31,7 +31,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
-
+import org.apache.geode.cache.PartitionAttributesFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
@@ -69,6 +69,48 @@ public class LuceneIndexCreationPersistenceIntegrationTest extends LuceneIntegra
   }
 
   @Test
+  public void shouldInheritRecoveryDelayFromUserRegion() {
+    createIndex(cache, "text");
+
+    PartitionAttributesFactory paf = new PartitionAttributesFactory();
+    paf.setRecoveryDelay(0);
+
+    cache.createRegionFactory(RegionShortcut.PARTITION).setPartitionAttributes(paf.create())
+        .create(REGION_NAME);
+    verifyInternalRegions(region -> {
+      assertEquals(0, region.getAttributes().getPartitionAttributes().getRecoveryDelay());
+    });
+  }
+
+  @Test
+  public void shouldInheritStartupRecoveryDelayFromUserRegion() {
+    createIndex(cache, "text");
+
+    PartitionAttributesFactory paf = new PartitionAttributesFactory();
+    paf.setStartupRecoveryDelay(1);
+
+    cache.createRegionFactory(RegionShortcut.PARTITION).setPartitionAttributes(paf.create())
+        .create(REGION_NAME);
+    verifyInternalRegions(region -> {
+      assertEquals(1, region.getAttributes().getPartitionAttributes().getStartupRecoveryDelay());
+    });
+  }
+
+  @Test
+  public void shouldNotUseDiskStoreWhenUserRegionIsNotPersistent() {
+    createIndex(cache, "text");
+    String diskStoreName = "diskStore";
+    cache.createDiskStoreFactory().setDiskDirs(new File[] {diskDirRule.get()})
+        .create(diskStoreName);
+    cache.createRegionFactory(RegionShortcut.PARTITION_OVERFLOW).setDiskStoreName(diskStoreName)
+        .create(REGION_NAME);
+    verifyInternalRegions(region -> {
+      assertTrue(region.getAttributes().getDiskStoreName() == null);
+      assertTrue(region.getAttributes().getEvictionAttributes().getAction().isNone());
+    });
+  }
+
+  @Test
   @Parameters({"true", "false"})
   public void shouldUseDiskSynchronousWhenUserRegionHasDiskSynchronous(boolean synchronous) {
     createIndex(cache, "text");


[19/50] [abbrv] geode git commit: GEODE-2604: Added javadoc comments to LuceneIndexMetrics.java

Posted by ds...@apache.org.
GEODE-2604: Added javadoc comments to LuceneIndexMetrics.java


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/9d597dce
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/9d597dce
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/9d597dce

Branch: refs/heads/feature/GEODE-1969
Commit: 9d597dce47c3f9edc52cab0b70d9ca912a0c94d2
Parents: 946ff6e
Author: nabarun <nn...@pivotal.io>
Authored: Mon Mar 6 16:51:01 2017 -0800
Committer: nabarun <nn...@pivotal.io>
Committed: Mon Mar 6 16:51:01 2017 -0800

----------------------------------------------------------------------
 .../lucene/management/LuceneIndexMetrics.java   | 102 +++++++++++++++++++
 1 file changed, 102 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/9d597dce/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java
index de89758..8b69ed5 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java
@@ -14,6 +14,8 @@
  */
 package org.apache.geode.cache.lucene.management;
 
+import org.apache.geode.cache.lucene.LuceneIndex;
+
 import java.beans.ConstructorProperties;
 
 public class LuceneIndexMetrics {
@@ -92,82 +94,182 @@ public class LuceneIndexMetrics {
     this.documents = documents;
   }
 
+  /**
+   * Returns the {@link String} path for the region on which the {@link LuceneIndex} is created
+   *
+   * @return String value of the region path on the Lucene Index is created
+   */
   public String getRegionPath() {
     return this.regionPath;
   }
 
+  /**
+   * Returns the {@link String} name of the {@link LuceneIndex} created
+   *
+   * @return String value of the index name
+   */
   public String getIndexName() {
     return this.indexName;
   }
 
+  /**
+   * Returns the number of query executions using the {@link LuceneIndex}
+   *
+   * @return Number of queries executed using this Lucene index
+   */
   public int getQueryExecutions() {
     return this.queryExecutions;
   }
 
+  /**
+   * Returns the time duration for execution of queries using the {@link LuceneIndex}
+   *
+   * @return long value for the time consumed in the execution of queries using this Lucene Index
+   */
   public long getQueryExecutionTime() {
     return this.queryExecutionTime;
   }
 
+  /**
+   * Returns the rate of query execution using the {@link LuceneIndex}
+   *
+   * @return the rate of query execution using the Lucene Index
+   */
   public float getQueryRate() {
     return this.queryRate;
   }
 
+  /**
+   * Returns the average latency for query executions using the {@link LuceneIndex}
+   *
+   * @return the average latency for query executions using the Lucene Index
+   */
   public long getQueryRateAverageLatency() {
     return this.queryRateAverageLatency;
   }
 
+  /**
+   * Returns the number of query executions in progress which are using the {@link LuceneIndex}
+   *
+   * @return the number of query executions in progress which are using the Lucene Index
+   */
   public int getQueryExecutionsInProgress() {
     return this.queryExecutionsInProgress;
   }
 
+  /**
+   * Returns the number of hits for the query execution using the {@link LuceneIndex}
+   *
+   * @return the number of hit for the query execution using the Lucene Index
+   */
   public long getQueryExecutionTotalHits() {
     return this.queryExecutionTotalHits;
   }
 
+  /**
+   * Returns the number of update operations on the {@link LuceneIndex}
+   *
+   * @return the number of update operations on the Lucene Index
+   */
   public int getUpdates() {
     return this.updates;
   }
 
+  /**
+   * Returns the time consumed for the update operations on the {@link LuceneIndex}
+   *
+   * @return the time consumed for the update operations on the Lucene Index
+   */
   public long getUpdateTime() {
     return this.updateTime;
   }
 
+  /**
+   * Returns the rate at which update operations are executed on the {@link LuceneIndex}
+   *
+   * @return rate at which update operations are executed on the {@link LuceneIndex}
+   */
   public float getUpdateRate() {
     return this.updateRate;
   }
 
+  /**
+   * Returns the average latency for the update operations on the {@link LuceneIndex}
+   *
+   * @return the average latency for the update operations on the Lucene Index
+   */
   public long getUpdateRateAverageLatency() {
     return this.updateRateAverageLatency;
   }
 
+  /**
+   * Returns the number of update operations in progress for the {@link LuceneIndex}
+   *
+   * @return the number of update operations in progress for the Lucene Index
+   */
   public int getUpdatesInProgress() {
     return this.updatesInProgress;
   }
 
+  /**
+   * Returns the number of commit operation executed on the {@link LuceneIndex}
+   *
+   * @return the number of commit operation executed on the Lucene Index
+   */
   public int getCommits() {
     return this.commits;
   }
 
+  /**
+   * Returns the time consumed by the commit operations on the {@link LuceneIndex}
+   *
+   * @return the time consumed by the commit operations on the Lucene Index
+   */
   public long getCommitTime() {
     return this.commitTime;
   }
 
+  /**
+   * Returns the rate of commit operations on the {@link LuceneIndex}
+   *
+   * @return the rate of commit operations on the Lucene Index
+   */
   public float getCommitRate() {
     return this.commitRate;
   }
 
+  /**
+   * Returns the average latency for the commit operations using the {@link LuceneIndex}
+   *
+   * @return Returns the average latency for the commit operations using the Lucene Index
+   */
   public long getCommitRateAverageLatency() {
     return this.commitRateAverageLatency;
   }
 
+  /**
+   * Returns the number of commit operations in progress for the {@link LuceneIndex}
+   *
+   * @return Returns the number of commit operations in progress for the Lucene Indexes
+   */
   public int getCommitsInProgress() {
     return this.commitsInProgress;
   }
 
+  /**
+   * Returns the number of documents indexed by {@link LuceneIndex}
+   *
+   * @return Returns the number of documents indexed by Lucene
+   */
   public int getDocuments() {
     return documents;
   }
 
+  /**
+   * Outputs the string message containing all the stats stored for the {@link LuceneIndex}
+   *
+   * @return the string message containing all the stats stored for the {@link LuceneIndex}
+   */
   @Override
   public String toString() {
     return new StringBuilder().append(getClass().getSimpleName()).append("[").append("regionPath=")


[42/50] [abbrv] geode git commit: GEODE-2539: Upgrading Jetty causes RestSecurityItegrationTest to fail

Posted by ds...@apache.org.
GEODE-2539: Upgrading Jetty causes RestSecurityItegrationTest to fail


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/3bde1a74
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/3bde1a74
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/3bde1a74

Branch: refs/heads/feature/GEODE-1969
Commit: 3bde1a748c4e1dbb4580032e8144cd6fa697d85d
Parents: 168f4ce
Author: Kevin J. Duling <kd...@pivotal.io>
Authored: Mon Mar 6 12:08:28 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:30 2017 -0800

----------------------------------------------------------------------
 .../web/RestSecurityIntegrationTest.java        | 144 ++++++++++---------
 .../web/RestSecurityPostProcessorTest.java      |  20 ++-
 gradle/dependency-versions.properties           |   2 +-
 3 files changed, 90 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/3bde1a74/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
index 85fc5be..dee004f 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
@@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_
 import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -71,104 +72,107 @@ public class RestSecurityIntegrationTest {
     String json = "{\"@type\":\"double\",\"@value\":210}";
 
     HttpResponse response = restClient.doGet("/functions", "unknown-user", "1234567");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
     response = restClient.doGet("/functions", "stranger", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
     response = restClient.doGet("/functions", "dataReader", "1234567");
-    assertEquals(200, restClient.getCode(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
     response.getEntity();
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, restClient.getContentType(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
 
     response = restClient.doPost("/functions/AddFreeItemsToOrder", "unknown-user", "1234567", json);
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
     response = restClient.doPost("/functions/AddFreeItemsToOrder", "dataReader", "1234567", json);
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
     response = restClient.doPost("/functions/AddFreeItemsToOrder?onRegion=" + REGION_NAME,
         "dataWriter", "1234567", json);
     // because we're only testing the security of the endpoint, not the endpoint functionality, a
     // 500 is acceptable
-    assertEquals(500, restClient.getCode(response));
+    assertEquals(500, GeodeRestClient.getCode(response));
   }
 
   @Test
   public void testQueries() throws Exception {
     HttpResponse response = restClient.doGet("/queries", "unknown-user", "1234567");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
     response = restClient.doGet("/queries", "stranger", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
     response = restClient.doGet("/queries", "dataReader", "1234567");
-    assertEquals(200, restClient.getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, restClient.getContentType(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
   }
 
   @Test
   public void testAdhocQuery() throws Exception {
     HttpResponse response = restClient.doGet("/queries/adhoc?q=", "unknown-user", "1234567");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
     response = restClient.doGet("/queries/adhoc?q=", "stranger", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
     response = restClient.doGet("/queries/adhoc?q=", "dataReader", "1234567");
     // because we're only testing the security of the endpoint, not the endpoint functionality, a
     // 500 is acceptable
-    assertEquals(500, restClient.getCode(response));
+    assertEquals(500, GeodeRestClient.getCode(response));
   }
 
   @Test
   public void testPostQuery() throws Exception {
     HttpResponse response = restClient.doPost("/queries?id=0&q=", "unknown-user", "1234567", "");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
     response = restClient.doPost("/queries?id=0&q=", "stranger", "1234567", "");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
     response = restClient.doPost("/queries?id=0&q=", "dataReader", "1234567", "");
     // because we're only testing the security of the endpoint, not the endpoint functionality, a
     // 500 is acceptable
-    assertEquals(500, restClient.getCode(response));
+    assertEquals(500, GeodeRestClient.getCode(response));
   }
 
   @Test
   public void testPostQuery2() throws Exception {
     HttpResponse response =
         restClient.doPost("/queries/id", "unknown-user", "1234567", "{\"id\" : \"foo\"}");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
     response = restClient.doPost("/queries/id", "stranger", "1234567", "{\"id\" : \"foo\"}");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
     response = restClient.doPost("/queries/id", "dataReader", "1234567", "{\"id\" : \"foo\"}");
     // We should get a 404 because we're trying to update a query that doesn't exist
-    assertEquals(404, restClient.getCode(response));
+    assertEquals(404, GeodeRestClient.getCode(response));
   }
 
   @Test
   public void testPutQuery() throws Exception {
     HttpResponse response =
         restClient.doPut("/queries/id", "unknown-user", "1234567", "{\"id\" : \"foo\"}");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
     response = restClient.doPut("/queries/id", "stranger", "1234567", "{\"id\" : \"foo\"}");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
     response = restClient.doPut("/queries/id", "dataReader", "1234567", "{\"id\" : \"foo\"}");
     // We should get a 404 because we're trying to update a query that doesn't exist
-    assertEquals(404, restClient.getCode(response));
+    assertEquals(404, GeodeRestClient.getCode(response));
   }
 
   @Test
   public void testDeleteQuery() throws Exception {
     HttpResponse response = restClient.doDelete("/queries/id", "unknown-user", "1234567");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
     response = restClient.doDelete("/queries/id", "stranger", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
     response = restClient.doDelete("/queries/id", "dataWriter", "1234567");
     // We should get a 404 because we're trying to delete a query that doesn't exist
-    assertEquals(404, restClient.getCode(response));
+    assertEquals(404, GeodeRestClient.getCode(response));
   }
 
   @Test
   public void testServers() throws Exception {
     HttpResponse response = restClient.doGet("/servers", "unknown-user", "1234567");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
     response = restClient.doGet("/servers", "stranger", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
     response = restClient.doGet("/servers", "super-user", "1234567");
-    assertEquals(200, restClient.getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, restClient.getContentType(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
   }
 
   /**
@@ -178,14 +182,14 @@ public class RestSecurityIntegrationTest {
   @Test
   public void testPing() throws Exception {
     HttpResponse response = restClient.doHEAD("/ping", "stranger", "1234567");
-    assertEquals(200, restClient.getCode(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
     response = restClient.doGet("/ping", "stranger", "1234567");
-    assertEquals(200, restClient.getCode(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
 
     response = restClient.doHEAD("/ping", "super-user", "1234567");
-    assertEquals(200, restClient.getCode(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
     response = restClient.doGet("/ping", "super-user", "1234567");
-    assertEquals(200, restClient.getCode(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
   }
 
   /**
@@ -194,10 +198,11 @@ public class RestSecurityIntegrationTest {
   @Test
   public void getRegions() throws Exception {
     HttpResponse response = restClient.doGet("", "dataReader", "1234567");
-    assertEquals("A '200 - OK' was expected", 200, restClient.getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, restClient.getContentType(response));
+    assertEquals("A '200 - OK' was expected", 200, GeodeRestClient.getCode(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
 
-    JSONObject jsonObject = restClient.getJsonObject(response);
+    JSONObject jsonObject = GeodeRestClient.getJsonObject(response);
     JSONArray regions = jsonObject.getJSONArray("regions");
     assertNotNull(regions);
     assertTrue(regions.length() > 0);
@@ -207,11 +212,11 @@ public class RestSecurityIntegrationTest {
 
     // List regions with an unknown user - 401
     response = restClient.doGet("", "unknown-user", "badpassword");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
 
     // list regions with insufficent rights - 403
     response = restClient.doGet("", "authRegionReader", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
   }
 
   /**
@@ -221,16 +226,17 @@ public class RestSecurityIntegrationTest {
   public void getRegion() throws Exception {
     // Test an unknown user - 401 error
     HttpResponse response = restClient.doGet("/" + REGION_NAME, "unknown-user", "1234567");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
 
     // Test a user with insufficient rights - 403
     response = restClient.doGet("/" + REGION_NAME, "stranger", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
 
     // Test an authorized user - 200
     response = restClient.doGet("/" + REGION_NAME, "super-user", "1234567");
-    assertEquals(200, restClient.getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, restClient.getContentType(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
   }
 
   /**
@@ -240,15 +246,15 @@ public class RestSecurityIntegrationTest {
   public void headRegion() throws Exception {
     // Test an unknown user - 401 error
     HttpResponse response = restClient.doHEAD("/" + REGION_NAME, "unknown-user", "1234567");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
 
     // Test a user with insufficient rights - 403
     response = restClient.doHEAD("/" + REGION_NAME, "stranger", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
 
     // Test an authorized user - 200
     response = restClient.doHEAD("/" + REGION_NAME, "super-user", "1234567");
-    assertEquals(200, restClient.getCode(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
   }
 
   /**
@@ -258,11 +264,11 @@ public class RestSecurityIntegrationTest {
   public void deleteRegion() throws Exception {
     // Test an unknown user - 401 error
     HttpResponse response = restClient.doDelete("/" + REGION_NAME, "unknown-user", "1234567");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
 
     // Test a user with insufficient rights - 403
     response = restClient.doDelete("/" + REGION_NAME, "dataReader", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
   }
 
   /**
@@ -272,11 +278,12 @@ public class RestSecurityIntegrationTest {
   public void getRegionKeys() throws Exception {
     // Test an authorized user
     HttpResponse response = restClient.doGet("/" + REGION_NAME + "/keys", "super-user", "1234567");
-    assertEquals(200, restClient.getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, restClient.getContentType(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
     // Test an unauthorized user
     response = restClient.doGet("/" + REGION_NAME + "/keys", "dataWriter", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
   }
 
   /**
@@ -286,12 +293,13 @@ public class RestSecurityIntegrationTest {
   public void getRegionKey() throws Exception {
     // Test an authorized user
     HttpResponse response = restClient.doGet("/" + REGION_NAME + "/key1", "key1User", "1234567");
-    assertEquals(200, restClient.getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, restClient.getContentType(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
 
     // Test an unauthorized user
     response = restClient.doGet("/" + REGION_NAME + "/key1", "dataWriter", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
   }
 
   /**
@@ -302,15 +310,15 @@ public class RestSecurityIntegrationTest {
     // Test an unknown user - 401 error
     HttpResponse response =
         restClient.doDelete("/" + REGION_NAME + "/key1", "unknown-user", "1234567");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
 
     // Test a user with insufficient rights - 403
     response = restClient.doDelete("/" + REGION_NAME + "/key1", "dataReader", "1234567");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
 
     // Test an authorized user - 200
     response = restClient.doDelete("/" + REGION_NAME + "/key1", "key1User", "1234567");
-    assertEquals(200, restClient.getCode(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
   }
 
   /**
@@ -321,17 +329,17 @@ public class RestSecurityIntegrationTest {
     // Test an unknown user - 401 error
     HttpResponse response = restClient.doPost("/" + REGION_NAME + "?key9", "unknown", "1234567",
         "{ \"key9\" : \"foo\" }");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
 
     // Test a user with insufficient rights - 403
     response = restClient.doPost("/" + REGION_NAME + "?key9", "dataReader", "1234567",
         "{ \"key9\" : \"foo\" }");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
 
     // Test an authorized user - 200
     response = restClient.doPost("/" + REGION_NAME + "?key9", "dataWriter", "1234567",
         "{ \"key9\" : \"foo\" }");
-    assertEquals(201, restClient.getCode(response));
+    assertEquals(201, GeodeRestClient.getCode(response));
   }
 
   /**
@@ -347,33 +355,33 @@ public class RestSecurityIntegrationTest {
     // Test an unknown user - 401 error
     HttpResponse response = restClient.doPut("/" + REGION_NAME + "/key1?op=PUT", "unknown-user",
         "1234567", "{ \"key9\" : \"foo\" }");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
 
     response = restClient.doPut("/" + REGION_NAME + "/key1?op=CAS", "unknown-user", "1234567",
         "{ \"key9\" : \"foo\" }");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
     response = restClient.doPut("/" + REGION_NAME + "/key1?op=REPLACE", "unknown-user", "1234567",
         "{ \"@old\" : \"value1\", \"@new\" : \"CASvalue\" }");
-    assertEquals(401, restClient.getCode(response));
+    assertEquals(401, GeodeRestClient.getCode(response));
 
     response = restClient.doPut("/" + REGION_NAME + "/key1?op=PUT", "dataReader", "1234567",
         "{ \"key1\" : \"foo\" }");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
 
     response = restClient.doPut("/" + REGION_NAME + "/key1?op=REPLACE", "dataReader", "1234567",
         "{ \"key1\" : \"foo\" }");
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
 
     response =
         restClient.doPut("/" + REGION_NAME + "/key1?op=CAS", "dataReader", "1234567", casJSON);
-    assertEquals(403, restClient.getCode(response));
+    assertEquals(403, GeodeRestClient.getCode(response));
 
     response = restClient.doPut("/" + REGION_NAME + "/key1?op=PUT", "key1User", "1234567",
         "{ \"key1\" : \"foo\" }");
-    assertEquals(200, restClient.getCode(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
 
     response =
         restClient.doPut("/" + REGION_NAME + "/key1?op=REPLACE", "key1User", "1234567", json);
-    assertEquals(200, restClient.getCode(response));
+    assertEquals(200, GeodeRestClient.getCode(response));
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/3bde1a74/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
index 82e9b7f..ab21094 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
@@ -20,9 +20,9 @@ import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANA
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_POST_PROCESSOR;
 import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
 import static org.apache.geode.rest.internal.web.GeodeRestClient.getCode;
-import static org.apache.geode.rest.internal.web.GeodeRestClient.getContentType;
 import static org.apache.geode.rest.internal.web.GeodeRestClient.getJsonArray;
 import static org.apache.geode.rest.internal.web.GeodeRestClient.getJsonObject;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -86,7 +86,8 @@ public class RestSecurityPostProcessorTest {
     // Test a single key
     HttpResponse response = restClient.doGet("/customers/1", "dataReader", "1234567");
     assertEquals(200, getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getContentType(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
 
     // Ensure SSN is hidden
     JSONObject jsonObject = getJsonObject(response);
@@ -96,7 +97,8 @@ public class RestSecurityPostProcessorTest {
     // Try with super-user
     response = restClient.doGet("/customers/1", "super-user", "1234567");
     assertEquals(200, getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getContentType(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
 
     // ensure SSN is readable
     jsonObject = getJsonObject(response);
@@ -109,7 +111,8 @@ public class RestSecurityPostProcessorTest {
   public void getMultipleRegionKeys() throws Exception {
     HttpResponse response = restClient.doGet("/customers/1,3", "dataReader", "1234567");
     assertEquals(200, getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getContentType(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
 
     JSONObject jsonObject = getJsonObject(response);
     JSONArray jsonArray = jsonObject.getJSONArray("customers");
@@ -127,7 +130,8 @@ public class RestSecurityPostProcessorTest {
   public void getRegion() throws Exception {
     HttpResponse response = restClient.doGet("/customers", "dataReader", "1234567");
     assertEquals(200, getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getContentType(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
 
     JSONObject jsonObject = getJsonObject(response);
     JSONArray jsonArray = jsonObject.getJSONArray("customers");
@@ -145,7 +149,8 @@ public class RestSecurityPostProcessorTest {
         + URLEncoder.encode("SELECT * FROM /customers order by customerId", "UTF-8");
     HttpResponse response = restClient.doGet(query, "dataReader", "1234567");
     assertEquals(200, getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getContentType(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
 
     JSONArray jsonArray = getJsonArray(response);
     final int length = jsonArray.length();
@@ -171,7 +176,8 @@ public class RestSecurityPostProcessorTest {
     String query = "/queries";
     response = restClient.doGet(query, "dataReader", "1234567");
     assertEquals(200, getCode(response));
-    assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getContentType(response));
+    assertThat(GeodeRestClient.getContentType(response))
+        .containsIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE);
 
     // Execute the query
     response = restClient.doPost("/queries/selectCustomer", "dataReader", "1234567",

http://git-wip-us.apache.org/repos/asf/geode/blob/3bde1a74/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index 34e5d67..90601ac 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -52,7 +52,7 @@ javax.resource-api.version = 1.7
 javax.servlet-api.version = 3.1.0
 javax.transaction-api.version = 1.2
 jedis.version = 2.9.0
-jetty.version = 9.3.6.v20151106
+jetty.version = 9.4.2.v20170220
 jgroups.version = 3.6.10.Final
 jmock.version = 2.8.2
 jna.version = 4.0.0


[14/50] [abbrv] geode git commit: GEODE-2267: enable gfsh to download file from http connection (GEODE-2418)

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index 93572fe..dd0939e 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -16,6 +16,7 @@ package org.apache.geode.test.dunit.rules;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.HeadlessGfsh;
@@ -23,6 +24,8 @@ import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.test.junit.rules.DescribedExternalResource;
+import org.json.JSONArray;
+import org.junit.rules.TemporaryFolder;
 import org.junit.runner.Description;
 
 /**
@@ -53,6 +56,7 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
   private PortType portType = PortType.jmxManger;
   private HeadlessGfsh gfsh = null;
   private boolean connected = false;
+  private TemporaryFolder temporaryFolder = new TemporaryFolder();
 
   public GfshShellConnectionRule() {}
 
@@ -63,7 +67,9 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
 
   @Override
   protected void before(Description description) throws Throwable {
-    this.gfsh = new HeadlessGfsh(getClass().getName(), 30, "gfsh_files");
+    temporaryFolder.create();
+    this.gfsh = new HeadlessGfsh(getClass().getName(), 30,
+        temporaryFolder.newFolder("gfsh_files").getAbsolutePath());
     // do not auto connect if no port initialized
     if (port < 0) {
       return;
@@ -89,6 +95,11 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
     assertThat(this.connected).isTrue();
   }
 
+  public void connectAndVerify(int port, PortType type, String... options) throws Exception {
+    connect(port, type, options);
+    assertThat(this.connected).isTrue();
+  }
+
   public void connect(int port, PortType type, String... options) throws Exception {
     CliUtil.isGfshVM = true;
     final CommandStringBuilder connectCommand = new CommandStringBuilder(CliStrings.CONNECT);
@@ -131,6 +142,7 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
 
   @Override
   protected void after(Description description) throws Throwable {
+    temporaryFolder.delete();
     if (connected) {
       disconnect();
     }
@@ -157,19 +169,27 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
   public CommandResult executeCommand(String command) throws Exception {
     gfsh.executeCommand(command);
     CommandResult result = (CommandResult) gfsh.getResult();
-    System.out.println("Command Result: \n" + gfsh.outputString);
+    if (StringUtils.isBlank(gfsh.outputString)) {
+      // print out the message body as the command result
+      JSONArray messages = ((JSONArray) result.getContent().get("message"));
+      if (messages != null) {
+        for (int i = 0; i < messages.length(); i++) {
+          gfsh.outputString += messages.getString(i) + "\n";
+        }
+      }
+    }
+    System.out.println("Command result for <" + command + ">: \n" + gfsh.outputString);
     return result;
   }
 
+  public String getGfshOutput() {
+    return gfsh.outputString;
+  }
+
 
   public CommandResult executeAndVerifyCommand(String command) throws Exception {
     CommandResult result = executeCommand(command);
-
-    if (result.getStatus() != Result.Status.OK) {
-      System.out.println("broken");
-    }
-    assertThat(result.getStatus()).describedAs(result.getContent().toString())
-        .isEqualTo(Result.Status.OK);
+    assertThat(result.getStatus()).isEqualTo(Result.Status.OK);
     return result;
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerConfigurationRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerConfigurationRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerConfigurationRule.java
deleted file mode 100644
index 0a63962..0000000
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerConfigurationRule.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * 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.rules;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.test.dunit.Host.*;
-import static org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase.*;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import org.awaitility.Awaitility;
-import org.junit.rules.ExternalResource;
-
-import org.apache.geode.distributed.Locator;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-
-
-public class LocatorServerConfigurationRule extends ExternalResource implements Serializable {
-
-  private int locatorPort = 0;
-
-  private boolean locatorInitialized = false;
-
-  private JUnit4DistributedTestCase testCase;
-
-  public LocatorServerConfigurationRule(JUnit4DistributedTestCase testCase) {
-    this.testCase = testCase;
-  }
-
-  Host host = getHost(0);
-  VM locator = host.getVM(0);
-
-  @Override
-  protected void before() {
-    // Add initialization requirement if any.
-    disconnectAllFromDS();
-  }
-
-  @Override
-  protected void after() {
-    disconnectAllFromDS();
-  }
-
-  /**
-   * Returns getHost(0).getVM(0) as a locator instance with the given configuration properties.
-   * 
-   * @param locatorProperties
-   *
-   * @return VM locator vm
-   *
-   * @throws IOException
-   */
-  public VM getLocatorVM(Properties locatorProperties) throws IOException {
-    if (!locatorProperties.containsKey(MCAST_PORT)) {
-      locatorProperties.setProperty(MCAST_PORT, "0");
-    }
-
-    locatorPort = locator.invoke(() -> {
-      InternalLocator locator =
-          (InternalLocator) Locator.startLocatorAndDS(0, null, locatorProperties);
-      locator.resetInternalLocatorFileNamesWithCorrectPortNumber(locatorPort);
-
-      if (locator.getConfig().getEnableClusterConfiguration()) {
-        Awaitility.await().atMost(65, TimeUnit.SECONDS)
-            .until(() -> assertTrue(locator.isSharedConfigurationRunning()));
-      }
-      return locator.getPort();
-    });
-
-    this.locatorInitialized = true;
-    return locator;
-  }
-
-  /**
-   * Returns a node VM with given configuration properties.
-   * 
-   * @param index valid 1 to 3 (returns getHist(0).getVM(index)
-   * @param properties
-   *
-   * @return VM node vm
-   */
-  public VM getServerVM(int index, Properties properties) {
-    assertTrue("Locator not initialized. Initialize locator by calling getLocatorVM()",
-        this.locatorInitialized);
-    assertTrue("VM with index 0 is used for locator service.", (index != 0));
-    VM nodeVM = getNodeVM(index);
-    nodeVM.invoke(() -> {
-      getSystem(properties);
-    });
-    return nodeVM;
-  }
-
-  /**
-   * this will simply returns the node
-   * 
-   * @param index
-   * @return
-   */
-  public VM getNodeVM(int index) {
-    return host.getVM(index);
-  }
-
-  public InternalDistributedSystem getSystem(Properties properties) {
-    if (!properties.containsKey(MCAST_PORT)) {
-      properties.setProperty(MCAST_PORT, "0");
-    }
-    properties.setProperty(LOCATORS, getHostName() + "[" + locatorPort + "]");
-    InternalDistributedSystem ds = testCase.getSystem(properties);
-    if (testCase instanceof JUnit4CacheTestCase) {
-      ((JUnit4CacheTestCase) testCase).getCache();
-    }
-    return ds;
-  }
-
-  public int getLocatorPort() {
-    return locatorPort;
-  }
-
-  private String getHostName() {
-    try {
-      return InetAddress.getLocalHost().getHostName();
-    } catch (UnknownHostException ignore) {
-      return "localhost";
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
index 39c13d0..ad8c033 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
@@ -16,6 +16,7 @@
 
 package org.apache.geode.test.dunit.rules;
 
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 import static org.apache.geode.test.dunit.Host.getHost;
 
@@ -106,7 +107,8 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
   }
 
   /**
-   * starts a cache server that does not connect to a locator
+   * starts a cache server that does not connect to a locator, unless the properties it passes in
+   * has "locators" property.
    * 
    * @return VM node vm
    */
@@ -114,16 +116,39 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     return startServerVM(index, properties, -1);
   }
 
+  /**
+   * start a server that connects to this locatorPort
+   *
+   * @param index
+   * @param locatorPort
+   * @return
+   * @throws IOException
+   */
   public Server startServerVM(int index, int locatorPort) throws IOException {
     return startServerVM(index, new Properties(), locatorPort);
   }
 
+  public Server startServerAsJmxManager(int index, int jmxManagerPort) throws IOException {
+    Properties properties = new Properties();
+    properties.setProperty(JMX_MANAGER_PORT, jmxManagerPort + "");
+    return startServerVM(index, properties);
+  }
+
+  public Server startServerAsEmbededLocator(int index, int locatorPort, int jmxManagerPort)
+      throws IOException {
+    Properties properties = new Properties();
+    properties.setProperty("start-locator", "localhost[" + locatorPort + "]");
+    if (jmxManagerPort > 0) {
+      properties.setProperty(JMX_MANAGER_PORT, jmxManagerPort + "");
+    }
+    return startServerVM(index, properties);
+  }
+
   /**
    * Starts a cache server that connect to the locator running at the given port.
    */
   public Server startServerVM(int index, Properties properties, int locatorPort)
       throws IOException {
-
     String name = "server-" + index;
     properties.setProperty(NAME, name);
 

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
index 8c0fb45..b1d6887 100755
--- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
+++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
@@ -563,6 +563,8 @@ org/apache/geode/management/internal/cli/functions/DestroyDiskStoreFunction,true
 org/apache/geode/management/internal/cli/functions/DestroyIndexFunction,true,1
 org/apache/geode/management/internal/cli/functions/ExportConfigFunction,true,1
 org/apache/geode/management/internal/cli/functions/ExportDataFunction,true,1
+org/apache/geode/management/internal/cli/functions/ExportLogsFunction,true,1
+org/apache/geode/management/internal/cli/functions/ExportLogsFunction$Args,false,endTime:java/lang/String,logLevel:java/lang/String,logLevelOnly:boolean,startTime:java/lang/String
 org/apache/geode/management/internal/cli/functions/FetchRegionAttributesFunction,true,4366812590788342070
 org/apache/geode/management/internal/cli/functions/FetchRegionAttributesFunction$FetchRegionAttributesFunctionResult,true,-3970828263897978845,cacheListenerClasses:java/lang/String[],cacheLoaderClass:java/lang/String,cacheWriterClass:java/lang/String,regionAttributes:org/apache/geode/cache/RegionAttributes
 org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction,true,1
@@ -618,8 +620,10 @@ org/apache/geode/management/internal/cli/shell/JMXInvocationException,true,-4265
 org/apache/geode/management/internal/cli/shell/jline/ANSIHandler$ANSIStyle,false
 org/apache/geode/management/internal/cli/util/DiskStoreNotFoundException,true,-5184836041554948093
 org/apache/geode/management/internal/cli/util/EvictionAttributesInfo,true,1,evictionAction:java/lang/String,evictionAlgorithm:java/lang/String,evictionMaxValue:int
+org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter,false,currentFile:java/nio/file/Path,currentOutputStream:java/io/BufferedOutputStream
 org/apache/geode/management/internal/cli/util/FixedPartitionAttributesInfo,false,isPrimary:boolean,numBuckets:int,partitionName:java/lang/String
 org/apache/geode/management/internal/cli/util/JConsoleNotFoundException,true,-1485615321440327206
+org/apache/geode/management/internal/cli/util/LogFilter$LineFilterResult,false
 org/apache/geode/management/internal/cli/util/MemberInformation,true,1,cacheXmlFilePath:java/lang/String,cpuUsage:java/lang/String,groups:java/lang/String,heapUsage:java/lang/String,host:java/lang/String,id:java/lang/String,initHeapSize:java/lang/String,locatorBindAddress:java/lang/String,locatorPort:int,locators:java/lang/String,logFilePath:java/lang/String,maxHeapSize:java/lang/String,name:java/lang/String,processId:java/lang/String,serverBindAddress:java/lang/String,statArchiveFilePath:java/lang/String,workingDirPath:java/lang/String
 org/apache/geode/management/internal/cli/util/MemberNotFoundException,true,5686788909239181174
 org/apache/geode/management/internal/cli/util/VisualVmNotFoundException,true,-8491645604829510102

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties b/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
index 694d4ff..2c27654 100644
--- a/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
+++ b/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
@@ -1468,12 +1468,14 @@ IS AVAILABLE\n\
 SYNOPSIS\n\
 \ \ \ \ Export the log files for a member or members.\n\
 SYNTAX\n\
-\ \ \ \ export logs --dir=value [--group=value(nullvalue)*] [--member=value] [--log-level=value]\n\
-\ \ \ \ [--only-log-level=value] [--merge-log=value] [--start-time=value] [--end-time=value]\n\
+\ \ \ \ export logs [--dir=value] [--group=value(nullvalue)*] [--member=value(nullvalue)*]\n\
+\ \ \ \ [--log-level=value] [--only-log-level=value] [--merge-log=value] [--start-time=value]\n\
+\ \ \ \ [--end-time=value]\n\
 PARAMETERS\n\
 \ \ \ \ dir\n\
-\ \ \ \ \ \ \ \ Directory to which log files will be written.\n\
-\ \ \ \ \ \ \ \ Required: true\n\
+\ \ \ \ \ \ \ \ Local directory to which log files will be written. This is only used when you are\n\
+\ \ \ \ \ \ \ \ exporting logs using http connection. If not specified, user.dir will be used.\n\
+\ \ \ \ \ \ \ \ Required: false\n\
 \ \ \ \ group\n\
 \ \ \ \ \ \ \ \ Group of members whose log files will be exported.\n\
 \ \ \ \ \ \ \ \ Required: false\n\

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-web/build.gradle
----------------------------------------------------------------------
diff --git a/geode-web/build.gradle b/geode-web/build.gradle
index ffab391..d6de656 100755
--- a/geode-web/build.gradle
+++ b/geode-web/build.gradle
@@ -54,6 +54,10 @@ dependencies {
   testRuntime project(':geode-core')
   testCompile files(project(':geode-core').sourceSets.test.output)
 
+  testCompile 'com.pholser:junit-quickcheck-core:' + project.'junit-quickcheck.version'
+  testCompile 'com.pholser:junit-quickcheck-generators:' + project.'junit-quickcheck.version'
+  testCompile 'com.pholser:junit-quickcheck-guava:' + project.'junit-quickcheck.version'
+
   testRuntime files(war.destinationDir)
 }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
index 3f3358d..5f4cd74 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
@@ -31,9 +31,9 @@ import org.apache.geode.test.junit.runner.SuiteRunner;
     GemfireDataCommandsDUnitTest.class,
     GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.class, IndexCommandsDUnitTest.class,
     ListAndDescribeDiskStoreCommandsDUnitTest.class, ListIndexCommandDUnitTest.class,
-    MemberCommandsDUnitTest.class, MiscellaneousCommandsDUnitTest.class,QueueCommandsDUnitTest.class,
-    ShellCommandsDUnitTest.class, ShowDeadlockDUnitTest.class, ShowMetricsDUnitTest.class,
-    ShowStackTraceDUnitTest.class, UserCommandsDUnitTest.class})
+    MemberCommandsDUnitTest.class, MiscellaneousCommandsDUnitTest.class,
+    QueueCommandsDUnitTest.class, ShellCommandsDUnitTest.class, ShowDeadlockDUnitTest.class,
+    ShowMetricsDUnitTest.class, ShowStackTraceDUnitTest.class, UserCommandsDUnitTest.class})
 public class CommandOverHttpDUnitTest {
   @ClassRule
   public static ProvideSystemProperty provideSystemProperty =

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
new file mode 100644
index 0000000..8f8342f
--- /dev/null
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
@@ -0,0 +1,116 @@
+/*
+ * 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.management.internal.cli.commands;
+
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.google.common.collect.Sets;
+
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.Locator;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+@Category(DistributedTest.class)
+public class ExportLogsOverHttpDUnitTest {
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @ClassRule
+  public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+
+  @ClassRule
+  public static GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
+
+  private static int jmxPort, httpPort;
+  private static Properties locatorProperties;
+  private static Set<String> expectedZipEntries = new HashSet<>();
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    httpPort = ports[0];
+    jmxPort = ports[1];
+    locatorProperties = new Properties();
+    locatorProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
+    locatorProperties.setProperty(HTTP_SERVICE_PORT, httpPort + "");
+    locatorProperties.setProperty(JMX_MANAGER_PORT, jmxPort + "");
+
+    // start the locator in vm0 and then connect to it over http
+    Locator locator = lsRule.startLocatorVM(0, locatorProperties);
+    lsRule.startServerVM(1, locator.getPort());
+    gfshConnector.connectAndVerify(httpPort, GfshShellConnectionRule.PortType.http);
+
+    expectedZipEntries = Sets.newHashSet("locator-0/locator-0.log", "server-1/server-1.log");
+  }
+
+  @Test
+  public void testExportWithNoDir() throws Exception {
+    // export the logs
+    gfshConnector.executeCommand("export logs");
+    // verify that the message contains a path to the user.dir
+    String message = gfshConnector.getGfshOutput();
+    assertThat(message).contains("Logs exported to: ");
+    assertThat(message).contains(System.getProperty("user.dir"));
+
+    String zipPath = getZipPathFromCommandResult(message);
+    verifyZipContent(zipPath);
+  }
+
+  @Test
+  public void testExportWithDir() throws Exception {
+    File dir = temporaryFolder.newFolder();
+    // export the logs
+    gfshConnector.executeCommand("export logs --dir=" + dir.getAbsolutePath());
+    // verify that the message contains a path to the user.dir
+    String message = gfshConnector.getGfshOutput();
+    assertThat(message).contains("Logs exported to: ");
+    assertThat(message).contains(dir.getAbsolutePath());
+
+    String zipPath = getZipPathFromCommandResult(message);
+    verifyZipContent(zipPath);
+  }
+
+  private void verifyZipContent(String zipPath) throws Exception {
+    Set<String> actualZipEnries =
+        new ZipFile(zipPath).stream().map(ZipEntry::getName).collect(Collectors.toSet());
+
+    assertThat(actualZipEnries).isEqualTo(expectedZipEntries);
+  }
+
+  private String getZipPathFromCommandResult(String message) {
+    return message.replaceAll("Logs exported to: ", "").trim();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
index 808c78f..1ebe89a 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
@@ -14,22 +14,12 @@
  */
 package org.apache.geode.management.internal.web.shell;
 
-import static org.junit.Assert.*;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.springframework.core.io.Resource;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.ResourceAccessException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.internal.cli.CommandRequest;
@@ -39,6 +29,18 @@ import org.apache.geode.management.internal.web.domain.LinkIndex;
 import org.apache.geode.management.internal.web.http.ClientHttpRequest;
 import org.apache.geode.management.internal.web.http.HttpMethod;
 import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.springframework.core.io.Resource;
+import org.springframework.web.client.ResourceAccessException;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
 
 /**
  * The RestHttpOperationInvokerJUnitTest class is a test suite of test cases testing the contract
@@ -315,13 +317,13 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
 
       @Override
       @SuppressWarnings("unchecked")
-      protected <T> ResponseEntity<T> send(final ClientHttpRequest request,
-          final Class<T> responseType, final Map<String, ?> uriVariables) {
-        return new ResponseEntity(expectedResult, HttpStatus.OK);
+      protected <T> T send(final ClientHttpRequest request, final Class<T> responseType,
+          final Map<String, ?> uriVariables) {
+        return (T) expectedResult;
       }
     };
 
-    final String actualResult = operationInvoker.processCommand(
+    final Object actualResult = operationInvoker.processCommand(
         createCommandRequest("list-libraries", Collections.<String, String>emptyMap()));
 
     assertEquals(expectedResult, actualResult);
@@ -351,7 +353,7 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
       protected void printWarning(final String message, final Object... args) {}
     };
 
-    final String actualResult = operationInvoker.processCommand(
+    final Object actualResult = operationInvoker.processCommand(
         createCommandRequest("get resource", Collections.<String, String>emptyMap()));
 
     assertEquals(expectedResult, actualResult);
@@ -371,8 +373,8 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
       protected void printWarning(final String message, final Object... args) {}
 
       @Override
-      protected <T> ResponseEntity<T> send(final ClientHttpRequest request,
-          final Class<T> responseType, final Map<String, ?> uriVariables) {
+      protected <T> T send(final ClientHttpRequest request, final Class<T> responseType,
+          final Map<String, ?> uriVariables) {
         throw new ResourceAccessException("test");
       }
 
@@ -389,7 +391,7 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
             + "Please try reconnecting or see the GemFire Manager's log file for further details.",
         operationInvoker.getBaseUrl(), "test");
 
-    final String actualResult = operationInvoker.processCommand(
+    final Object actualResult = operationInvoker.processCommand(
         createCommandRequest("list-libraries", Collections.<String, String>emptyMap()));
 
     assertFalse(operationInvoker.isConnected());

http://git-wip-us.apache.org/repos/asf/geode/blob/92582fbd/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java
index 8afbcf6..a704654 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java
@@ -14,9 +14,10 @@
  */
 package org.apache.geode.management.internal.web.shell;
 
-import static org.junit.Assert.*;
-
-import java.util.Collections;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.geode.management.internal.cli.CommandRequest;
 import org.apache.geode.management.internal.web.AbstractWebTestCase;
@@ -25,15 +26,14 @@ import org.apache.geode.management.internal.web.http.ClientHttpRequest;
 import org.apache.geode.management.internal.web.http.HttpHeader;
 import org.apache.geode.management.internal.web.http.HttpMethod;
 import org.apache.geode.test.junit.categories.UnitTest;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
 import org.springframework.web.client.ResourceAccessException;
 
+import java.util.Collections;
+
 /**
  * The SimpleHttpOperationInvokerJUnitTest class is a test suite of test cases testing the contract
  * and functionality of the SimpleHttpOperationInvoker class.
@@ -128,9 +128,8 @@ public class SimpleHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
 
       @Override
       @SuppressWarnings("unchecked")
-      protected <T> ResponseEntity<T> send(final ClientHttpRequest request,
-          final Class<T> responseType) {
-        return new ResponseEntity(expectedResult, HttpStatus.OK);
+      protected <T> T send(final ClientHttpRequest request, final Class<T> responseType) {
+        return (T) expectedResult;
       }
     };
 
@@ -151,8 +150,7 @@ public class SimpleHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
       }
 
       @Override
-      protected <T> ResponseEntity<T> send(final ClientHttpRequest request,
-          final Class<T> responseType) {
+      protected <T> T send(final ClientHttpRequest request, final Class<T> responseType) {
         throw new ResourceAccessException("test");
       }
 


[23/50] [abbrv] geode git commit: GEODE-2579: ClassCastException cannot cast CompiledIn to CompiledJunction

Posted by ds...@apache.org.
GEODE-2579: ClassCastException cannot cast CompiledIn to CompiledJunction

*  AbstractGroupOrRangeJunction does not incorrectly cast when creating junction with in clause
*  In clause will be handled like a compiled comparison


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/e94e2332
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/e94e2332
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/e94e2332

Branch: refs/heads/feature/GEODE-1969
Commit: e94e233287a3741de975479af3eebae692778642
Parents: 47697d4
Author: Jason Huynh <hu...@gmail.com>
Authored: Fri Mar 3 09:20:11 2017 -0800
Committer: Jason Huynh <hu...@gmail.com>
Committed: Tue Mar 7 11:29:44 2017 -0800

----------------------------------------------------------------------
 .../internal/AbstractGroupOrRangeJunction.java  |  2 +-
 .../geode/cache/query/QueryJUnitTest.java       | 52 ++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/e94e2332/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
index a499346..5ed4d86 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
@@ -68,7 +68,7 @@ public abstract class AbstractGroupOrRangeJunction extends AbstractCompiledValue
     this.completeExpansion = completeExpansion;
     this.indpndntItr = indpnds;
     if (iterOp != null) {
-      if (iterOp instanceof CompiledComparison) {
+      if (iterOp instanceof CompiledComparison || iterOp instanceof CompiledIn) {
         int finalSize = 1 + oldGJ._operands.length;
         this._operands = new CompiledValue[finalSize];
         System.arraycopy(oldGJ._operands, 0, this._operands, 0, finalSize - 1);

http://git-wip-us.apache.org/repos/asf/geode/blob/e94e2332/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
index 7333212..f08eef5 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
@@ -26,6 +26,7 @@ package org.apache.geode.cache.query;
 import static org.junit.Assert.*;
 import static org.junit.runners.MethodSorters.*;
 
+import java.io.Serializable;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -34,6 +35,8 @@ import java.util.Set;
 import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.query.internal.index.IndexProtocol;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.FixMethodOrder;
@@ -308,6 +311,55 @@ public class QueryJUnitTest {
     }
   }
 
+  @Test
+  public void creatingACompiledJunctionWithACompiledInClauseDoesNotThrowException()
+      throws Exception {
+    Cache cache = CacheUtils.getCache();
+    RegionFactory<Integer, Portfolio> rf = cache.createRegionFactory(RegionShortcut.REPLICATE);
+    Region regionA = rf.create("regionA");
+    Region regionB = rf.create("regionB");
+
+    for (int i = 1; i <= 100; i++) {
+      regionA.put(Integer.toString(i), new TestUserObject("" + i, "" + i, "" + i, "" + i));
+      regionB.put(Integer.toString(i), new TestUserObject("" + i, "" + i, "" + i, "" + i));
+    }
+    QueryService qs = CacheUtils.getQueryService();
+
+    Index regionAUserCodeIndex = (IndexProtocol) qs.createIndex("regionAUserCodeIndex",
+        IndexType.FUNCTIONAL, "userId", "/regionA ");
+    Index regionBUserCodeIndex = (IndexProtocol) qs.createIndex("regionAUserCodeIndex",
+        IndexType.FUNCTIONAL, "userId", "/regionB ");
+
+    Index regionAUserNameIndex = (IndexProtocol) qs.createIndex("regionAUserNameIndex",
+        IndexType.FUNCTIONAL, "userName", "/regionA ");
+    Index regionBUserNameIndex = (IndexProtocol) qs.createIndex("regionBUserNameIndex",
+        IndexType.FUNCTIONAL, "userName", "/regionB ");
+
+    Query query = qs.newQuery(
+        "select regionB.userId,regionA.professionCode,regionB.postCode,regionB.userName from /regionA regionA,/regionB regionB where regionA.userId = regionB.userId and regionA.professionCode in Set('1','2','3') and regionB.postCode = '1' and regionB.userId='1'");
+    SelectResults results = (SelectResults) query.execute();
+    assertTrue(results.size() > 0);
+  }
+
+  public static class TestUserObject implements Serializable {
+    public String professionCode;
+    public String userId;
+    public String postCode;
+    public String userName;
+
+    public TestUserObject() {
+
+    }
+
+    public TestUserObject(final String professionCode, final String userId, final String postCode,
+        final String userName) {
+      this.professionCode = professionCode;
+      this.userId = userId;
+      this.postCode = postCode;
+      this.userName = userName;
+    }
+  }
+
   private class QueryRunnable implements Runnable {
     private Query q;
     private Object[] params;


[16/50] [abbrv] geode git commit: GEODE-2267: mark local time sensitive tests as flaky

Posted by ds...@apache.org.
GEODE-2267: mark local time sensitive tests as flaky


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/41f1b27b
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/41f1b27b
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/41f1b27b

Branch: refs/heads/feature/GEODE-1969
Commit: 41f1b27b0374a90fc129f093b2e9d90e55acc93d
Parents: bf78817
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Mon Mar 6 09:02:18 2017 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Mon Mar 6 09:02:18 2017 -0800

----------------------------------------------------------------------
 .../management/internal/cli/commands/ExportLogsDUnitTest.java      | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/41f1b27b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
index 19198f2..e882cce 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
@@ -39,6 +39,7 @@ import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.Member;
 import org.apache.geode.test.dunit.rules.Server;
 import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.logging.log4j.Logger;
 import org.junit.Before;
 import org.junit.Rule;
@@ -127,6 +128,7 @@ public class ExportLogsDUnitTest {
   }
 
   @Test
+  @Category(FlakyTest.class) // time sensitive
   public void testExportWithStartAndEndDateTimeFiltering() throws Exception {
     ZonedDateTime cutoffTime = LocalDateTime.now().atZone(ZoneId.systemDefault());
 


[49/50] [abbrv] geode git commit: GEODE-2612: Added option to invoke callbacks during snapshot

Posted by ds...@apache.org.
GEODE-2612: Added option to invoke callbacks during snapshot


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/63d565b5
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/63d565b5
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/63d565b5

Branch: refs/heads/feature/GEODE-1969
Commit: 63d565b5a02d1a4246f5a40f6acf7e47897a73e2
Parents: f1d4291
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Wed Mar 8 14:35:23 2017 -0800
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Thu Mar 9 09:59:07 2017 -0800

----------------------------------------------------------------------
 .../geode/cache/snapshot/SnapshotOptions.java   |  16 ++
 .../snapshot/RegionSnapshotServiceImpl.java     |   4 +-
 .../cache/snapshot/SnapshotOptionsImpl.java     |  15 ++
 .../geode/cache/snapshot/SnapshotDUnitTest.java | 208 +++++++++++++++++--
 .../codeAnalysis/sanctionedSerializables.txt    |   2 +-
 .../LuceneIndexForPartitionedRegion.java        |   2 +-
 .../cache/lucene/internal/LuceneIndexImpl.java  |  10 +-
 .../lucene/LuceneIndexDestroyDUnitTest.java     | 201 ++++++++++++++++--
 .../geode/cache/lucene/test/TestObject.java     |   4 +
 9 files changed, 424 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/63d565b5/geode-core/src/main/java/org/apache/geode/cache/snapshot/SnapshotOptions.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/snapshot/SnapshotOptions.java b/geode-core/src/main/java/org/apache/geode/cache/snapshot/SnapshotOptions.java
index 1562b3a..4c819b8 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/snapshot/SnapshotOptions.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/snapshot/SnapshotOptions.java
@@ -55,4 +55,20 @@ public interface SnapshotOptions<K, V> extends Serializable {
    * @return the filter, or null if the filter is not set
    */
   SnapshotFilter<K, V> getFilter();
+
+  /**
+   * Sets whether to invoke callbacks when loading a snapshot. The default is false.
+   *
+   * @param invokeCallbacks
+   *
+   * @return the snapshot options
+   */
+  SnapshotOptions<K, V> invokeCallbacks(boolean invokeCallbacks);
+
+  /**
+   * Returns whether loading a snapshot causes callbacks to be invoked
+   *
+   * @return whether loading a snapshot causes callbacks to be invoked
+   */
+  boolean shouldInvokeCallbacks();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/63d565b5/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl.java
index e8b28c4..bfdef05 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl.java
@@ -257,7 +257,7 @@ public class RegionSnapshotServiceImpl<K, V> implements RegionSnapshotService<K,
                 .getDistributionManager().getWaitingThreadPool().submit(new Runnable() {
                   @Override
                   public void run() {
-                    local.basicImportPutAll(copy, true);
+                    local.basicImportPutAll(copy, !options.shouldInvokeCallbacks());
                   }
                 });
 
@@ -270,7 +270,7 @@ public class RegionSnapshotServiceImpl<K, V> implements RegionSnapshotService<K,
 
       // send off any remaining entries
       if (!buffer.isEmpty()) {
-        local.basicImportPutAll(buffer, true);
+        local.basicImportPutAll(buffer, !options.shouldInvokeCallbacks());
       }
 
       // wait for completion and check for errors

http://git-wip-us.apache.org/repos/asf/geode/blob/63d565b5/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/SnapshotOptionsImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/SnapshotOptionsImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/SnapshotOptionsImpl.java
index d56535f..9f4fcd8 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/SnapshotOptionsImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/SnapshotOptionsImpl.java
@@ -30,6 +30,9 @@ public class SnapshotOptionsImpl<K, V> implements SnapshotOptions<K, V> {
   /** the entry filter */
   private volatile SnapshotFilter<K, V> filter;
 
+  /** true if callbacks should be invoked on load */
+  private volatile boolean invokeCallbacks;
+
   /** true if parallel mode is enabled */
   private volatile boolean parallel;
 
@@ -38,6 +41,7 @@ public class SnapshotOptionsImpl<K, V> implements SnapshotOptions<K, V> {
 
   public SnapshotOptionsImpl() {
     filter = null;
+    invokeCallbacks = false;
   }
 
   @Override
@@ -51,6 +55,17 @@ public class SnapshotOptionsImpl<K, V> implements SnapshotOptions<K, V> {
     return filter;
   }
 
+  @Override
+  public SnapshotOptions<K, V> invokeCallbacks(boolean invokeCallbacks) {
+    this.invokeCallbacks = invokeCallbacks;
+    return this;
+  }
+
+  @Override
+  public boolean shouldInvokeCallbacks() {
+    return this.invokeCallbacks;
+  }
+
   /**
    * Enables parallel mode for snapshot operations. This will cause each member of a partitioned
    * region to save its local data set (ignoring redundant copies) to a separate snapshot file.

http://git-wip-us.apache.org/repos/asf/geode/blob/63d565b5/geode-core/src/test/java/org/apache/geode/cache/snapshot/SnapshotDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/snapshot/SnapshotDUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/snapshot/SnapshotDUnitTest.java
index 1b6d426..196a88b 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/snapshot/SnapshotDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/snapshot/SnapshotDUnitTest.java
@@ -14,21 +14,29 @@
  */
 package org.apache.geode.cache.snapshot;
 
+import org.apache.geode.cache.AttributesMutator;
+import org.apache.geode.cache.DiskStoreFactory;
+import org.apache.geode.cache.asyncqueue.AsyncEvent;
+import org.apache.geode.cache.asyncqueue.AsyncEventListener;
+import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
+import org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory;
+import org.awaitility.Awaitility;
 import org.junit.experimental.categories.Category;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
 
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
 
 import java.io.File;
-import java.io.FilenameFilter;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import com.examples.snapshot.MyObject;
 import com.examples.snapshot.MyPdxSerializer;
@@ -42,12 +50,14 @@ import org.apache.geode.cache.snapshot.RegionGenerator.SerializationType;
 import org.apache.geode.cache.snapshot.SnapshotOptions.SnapshotFormat;
 import org.apache.geode.cache.util.CacheListenerAdapter;
 import org.apache.geode.cache.util.CacheWriterAdapter;
-import org.apache.geode.cache30.CacheTestCase;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.SerializableCallable;
 
 @Category(DistributedTest.class)
 public class SnapshotDUnitTest extends JUnit4CacheTestCase {
+
+  private static final int NUM_ENTRIES = 1000;
+
   public SnapshotDUnitTest() {
     super();
   }
@@ -60,17 +70,8 @@ public class SnapshotDUnitTest extends JUnit4CacheTestCase {
     // save all regions
     getCache().getSnapshotService().save(dir, SnapshotFormat.GEMFIRE);
 
-    for (final RegionType rt : RegionType.values()) {
-      for (final SerializationType st : SerializationType.values()) {
-        String name = "test-" + rt.name() + "-" + st.name();
-
-        // overwrite region with bad data
-        Region<Integer, MyObject> region = getCache().getRegion(name);
-        for (Entry<Integer, MyObject> entry : region.entrySet()) {
-          region.put(entry.getKey(), new MyObject(Integer.MAX_VALUE, "bad!!"));
-        }
-      }
-    }
+    // update regions with data to be overwritten by import
+    updateRegions();
 
     SerializableCallable callbacks = new SerializableCallable() {
       @Override
@@ -106,8 +107,83 @@ public class SnapshotDUnitTest extends JUnit4CacheTestCase {
     forEachVm(callbacks, true);
 
     // load all regions
+    loadRegions(dir, null);
+  }
+
+  @Test
+  public void testExportAndImportWithInvokeCallbacksEnabled() throws Exception {
+    File dir = new File(getDiskDirs()[0], "callbacks");
+    dir.mkdir();
+
+    // save all regions
+    CacheSnapshotService service = getCache().getSnapshotService();
+    service.save(dir, SnapshotFormat.GEMFIRE);
+
+    // update regions with data to be overwritten by import
+    updateRegions();
+
+    SerializableCallable callbacks = new SerializableCallable() {
+      @Override
+      public Object call() throws Exception {
+        for (final RegionType rt : RegionType.values()) {
+          for (final SerializationType st : SerializationType.values()) {
+            String name = "test-" + rt.name() + "-" + st.name();
+            Cache cache = getCache();
+            Region<Integer, MyObject> region = cache.getRegion(name);
+            // add CacheWriter and CacheListener
+            AttributesMutator mutator = region.getAttributesMutator();
+            mutator.setCacheWriter(new CountingCacheWriter());
+            mutator.addCacheListener(new CountingCacheListener());
+            // add AsyncEventQueue
+            addAsyncEventQueue(region, name);
+          }
+        }
+        return null;
+      }
+    };
+
+    // add callbacks
+    forEachVm(callbacks, true);
+
+    // load all regions with invoke callbacks enabled
+    SnapshotOptions options = service.createOptions();
+    options.invokeCallbacks(true);
+    loadRegions(dir, options);
+
+    // verify callbacks were invoked
+    verifyCallbacksInvoked();
+  }
+
+  private void addAsyncEventQueue(Region region, String name) {
+    DiskStoreFactory dsFactory = getCache().createDiskStoreFactory();
+    dsFactory.create(name);
+    AsyncEventQueueFactory aeqFactory = getCache().createAsyncEventQueueFactory();
+    aeqFactory.setDiskStoreName(name);
+    aeqFactory.create(name, new CountingAsyncEventListener());
+    region.getAttributesMutator().addAsyncEventQueueId(name);
+  }
+
+  private void updateRegions() {
+    for (final RegionType rt : RegionType.values()) {
+      for (final SerializationType st : SerializationType.values()) {
+        String name = "test-" + rt.name() + "-" + st.name();
+
+        // overwrite region with bad data
+        Region<Integer, MyObject> region = getCache().getRegion(name);
+        for (Entry<Integer, MyObject> entry : region.entrySet()) {
+          region.put(entry.getKey(), new MyObject(Integer.MAX_VALUE, "bad!!"));
+        }
+      }
+    }
+  }
+
+  private void loadRegions(File dir, SnapshotOptions options) throws Exception {
     RegionGenerator rgen = new RegionGenerator();
-    getCache().getSnapshotService().load(dir, SnapshotFormat.GEMFIRE);
+    if (options != null) {
+      getCache().getSnapshotService().load(dir.listFiles(), SnapshotFormat.GEMFIRE, options);
+    } else {
+      getCache().getSnapshotService().load(dir, SnapshotFormat.GEMFIRE);
+    }
     for (final RegionType rt : RegionType.values()) {
       for (final SerializationType st : SerializationType.values()) {
         Region<Integer, MyObject> region =
@@ -120,6 +196,51 @@ public class SnapshotDUnitTest extends JUnit4CacheTestCase {
     }
   }
 
+  private void verifyCallbacksInvoked() throws Exception {
+    for (final RegionType rt : RegionType.values()) {
+      for (final SerializationType st : SerializationType.values()) {
+        SerializableCallable counts = new SerializableCallable() {
+          @Override
+          public Object call() throws Exception {
+            String name = "test-" + rt.name() + "-" + st.name();
+            Region<Integer, MyObject> region = getCache().getRegion(name);
+            // get CacheWriter and CacheListener events
+            CountingCacheWriter writer =
+                (CountingCacheWriter) region.getAttributes().getCacheWriter();
+            CountingCacheListener listener =
+                (CountingCacheListener) region.getAttributes().getCacheListener();
+            // get AsyncEventListener events
+            int numAeqEvents = 0;
+            AsyncEventQueue aeq = getCache().getAsyncEventQueue(name);
+            CountingAsyncEventListener aeqListener =
+                (CountingAsyncEventListener) aeq.getAsyncEventListener();
+            if (aeq.isPrimary()) {
+              Awaitility.waitAtMost(60, TimeUnit.SECONDS)
+                  .until(() -> aeqListener.getEvents() == NUM_ENTRIES);
+              numAeqEvents = aeqListener.getEvents();
+            }
+            return new int[] {writer.getEvents(), listener.getEvents(), numAeqEvents};
+          }
+        };
+        Object result = forEachVm(counts, true);
+        int totalWriterUpdates = 0, totalListenerUpdates = 0, totalAeqEvents = 0;
+        List<int[]> list = (List) result;
+        for (int[] vmResult : list) {
+          totalWriterUpdates += vmResult[0];
+          totalListenerUpdates += vmResult[1];
+          totalAeqEvents += vmResult[2];
+        }
+        if (rt.name().contains("PARTITION")) {
+          assertEquals(NUM_ENTRIES, totalListenerUpdates);
+        } else {
+          assertEquals(NUM_ENTRIES * (Host.getHost(0).getVMCount() + 1), totalListenerUpdates);
+        }
+        assertEquals(NUM_ENTRIES, totalWriterUpdates);
+        assertEquals(NUM_ENTRIES, totalAeqEvents);
+      }
+    }
+  }
+
   @Test
   public void testCacheExportFilterException() throws Exception {
     SnapshotFilter<Object, Object> oops = new SnapshotFilter<Object, Object>() {
@@ -190,7 +311,7 @@ public class SnapshotDUnitTest extends JUnit4CacheTestCase {
   public static Map<Integer, MyObject> createExpected(SerializationType type,
       RegionGenerator rgen) {
     Map<Integer, MyObject> expected = new HashMap<Integer, MyObject>();
-    for (int i = 0; i < 1000; i++) {
+    for (int i = 0; i < NUM_ENTRIES; i++) {
       expected.put(i, rgen.createData(type, i, "The number is " + i));
     }
     return expected;
@@ -222,16 +343,63 @@ public class SnapshotDUnitTest extends JUnit4CacheTestCase {
   }
 
   public static Object forEachVm(SerializableCallable call, boolean local) throws Exception {
+    List result = new ArrayList();
     Host host = Host.getHost(0);
     int vms = host.getVMCount();
 
     for (int i = 0; i < vms; ++i) {
-      host.getVM(i).invoke(call);
+      result.add(host.getVM(i).invoke(call));
     }
 
     if (local) {
-      return call.call();
+      result.add(call.call());
     }
-    return null;
+    return result;
+  }
+
+  private static class CountingCacheListener extends CacheListenerAdapter<Integer, MyObject> {
+
+    private final AtomicInteger events = new AtomicInteger();
+
+    @Override
+    public void afterUpdate(EntryEvent<Integer, MyObject> event) {
+      events.incrementAndGet();
+    }
+
+    private int getEvents() {
+      return events.get();
+    }
+  }
+
+  private static class CountingCacheWriter extends CacheWriterAdapter<Integer, MyObject> {
+
+    private final AtomicInteger events = new AtomicInteger();
+
+    @Override
+    public void beforeUpdate(EntryEvent<Integer, MyObject> event) {
+      events.incrementAndGet();
+    }
+
+    private int getEvents() {
+      return events.get();
+    }
+  }
+
+  private static final class CountingAsyncEventListener implements AsyncEventListener {
+
+    private final AtomicInteger events = new AtomicInteger();
+
+    @Override
+    public boolean processEvents(final List<AsyncEvent> list) {
+      events.addAndGet(list.size());
+      return true;
+    }
+
+    private int getEvents() {
+      return events.get();
+    }
+
+    @Override
+    public void close() {}
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/63d565b5/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
index a11c7ad..397ec14 100755
--- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
+++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
@@ -335,7 +335,7 @@ org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl$1,true,1
 org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl$ParallelArgs,true,1,file:java/io/File,format:org/apache/geode/cache/snapshot/SnapshotOptions$SnapshotFormat,options:org/apache/geode/internal/cache/snapshot/SnapshotOptionsImpl
 org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl$ParallelExportFunction,false
 org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl$ParallelImportFunction,false
-org/apache/geode/internal/cache/snapshot/SnapshotOptionsImpl,true,1,filter:org/apache/geode/cache/snapshot/SnapshotFilter,mapper:org/apache/geode/internal/cache/snapshot/SnapshotFileMapper,parallel:boolean
+org/apache/geode/internal/cache/snapshot/SnapshotOptionsImpl,true,1,filter:org/apache/geode/cache/snapshot/SnapshotFilter,invokeCallbacks:boolean,mapper:org/apache/geode/internal/cache/snapshot/SnapshotFileMapper,parallel:boolean
 org/apache/geode/internal/cache/snapshot/WindowedExporter$WindowedArgs,true,1,exporter:org/apache/geode/distributed/DistributedMember,options:org/apache/geode/cache/snapshot/SnapshotOptions
 org/apache/geode/internal/cache/snapshot/WindowedExporter$WindowedExportFunction,true,1
 org/apache/geode/internal/cache/tier/BatchException,true,-6707074107791305564,_index:int

http://git-wip-us.apache.org/repos/asf/geode/blob/63d565b5/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index f24c6d6..7274d6a 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -251,7 +251,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
   private void destroyOnRemoteMembers() {
     PartitionedRegion pr = (PartitionedRegion) getDataRegion();
     DM dm = pr.getDistributionManager();
-    Set<InternalDistributedMember> recipients = pr.getRegionAdvisor().adviseDataStore();
+    Set<InternalDistributedMember> recipients = pr.getRegionAdvisor().adviseAllPRNodes();
     if (!recipients.isEmpty()) {
       if (logger.isDebugEnabled()) {
         logger.debug("LuceneIndexForPartitionedRegion: About to send destroy message recipients="

http://git-wip-us.apache.org/repos/asf/geode/blob/63d565b5/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
index b5b13c1..0c9d220 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
@@ -244,7 +244,10 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
     AsyncEventQueueImpl aeq = (AsyncEventQueueImpl) cache.getAsyncEventQueue(aeqId);
 
     // Stop the AsyncEventQueue (this stops the AsyncEventQueue's underlying GatewaySender)
-    aeq.stop();
+    // The AsyncEventQueue can be null in an accessor member
+    if (aeq != null) {
+      aeq.stop();
+    }
 
     // Remove the id from the dataRegion's AsyncEventQueue ids
     // Note: The region may already have been destroyed by a remote member
@@ -254,7 +257,10 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
     }
 
     // Destroy the aeq (this also removes it from the GemFireCacheImpl)
-    aeq.destroy();
+    // The AsyncEventQueue can be null in an accessor member
+    if (aeq != null) {
+      aeq.destroy();
+    }
     if (logger.isDebugEnabled()) {
       logger.debug("Destroyed aeqId=" + aeqId);
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/63d565b5/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java
index 1afde6a..496cdeb 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java
@@ -20,10 +20,13 @@ import org.apache.geode.cache.Region;
 import org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion;
 import org.apache.geode.cache.lucene.internal.LuceneServiceImpl;
 import org.apache.geode.cache.lucene.test.TestObject;
+import org.apache.geode.cache.snapshot.RegionSnapshotService;
+import org.apache.geode.cache.snapshot.SnapshotOptions;
 import org.apache.geode.internal.cache.LocalRegion;
 import org.apache.geode.test.dunit.AsyncInvocation;
+import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.SerializableRunnableIF;
-import org.apache.geode.test.dunit.ThreadUtils;
+import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.awaitility.Awaitility;
 import org.junit.Ignore;
@@ -31,12 +34,14 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
 
-import java.io.InterruptedIOException;
+import java.io.File;
+import java.util.Collection;
 import java.util.concurrent.TimeUnit;
 
 import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
 import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
 import static org.apache.geode.internal.Assert.fail;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -48,6 +53,14 @@ public class LuceneIndexDestroyDUnitTest extends LuceneDUnitTest {
 
   private volatile boolean STOP_PUTS = false;
 
+  protected VM accessor;
+
+  @Override
+  public void postSetUp() throws Exception {
+    super.postSetUp();
+    accessor = Host.getHost(0).getVM(3);
+  }
+
   private final Object[] parametersForIndexDestroys() {
     String[] destroyDataRegionParameters = {"true", "false"};
     RegionTestableType[] regionTestTypes = getListOfRegionTestTypes();
@@ -146,17 +159,31 @@ public class LuceneIndexDestroyDUnitTest extends LuceneDUnitTest {
 
   @Test
   @Parameters(method = "getListOfRegionTestTypes")
-  public void verifyDestroyRecreateSingleIndex(RegionTestableType regionType) {
+  public void verifyDestroyRecreateIndexSameName(RegionTestableType regionType) {
     // Create index and region
-    dataStore1.invoke(() -> initDataStore(createIndex(), regionType));
-    dataStore2.invoke(() -> initDataStore(createIndex(), regionType));
+    SerializableRunnableIF createIndex = createIndex();
+    dataStore1.invoke(() -> initDataStore(createIndex, regionType));
+    dataStore2.invoke(() -> initDataStore(createIndex, regionType));
+    accessor.invoke(() -> initAccessor(createIndex, regionType));
 
     // Verify index created
     dataStore1.invoke(() -> verifyIndexCreated());
     dataStore2.invoke(() -> verifyIndexCreated());
+    accessor.invoke(() -> verifyIndexCreated());
 
     // Do puts to cause IndexRepositories to be created
-    dataStore1.invoke(() -> doPuts(10));
+    int numPuts = 10;
+    accessor.invoke(() -> doPuts(numPuts));
+
+    // Wait until queue is flushed
+    dataStore1.invoke(() -> waitUntilFlushed(INDEX_NAME));
+    dataStore2.invoke(() -> waitUntilFlushed(INDEX_NAME));
+
+    // Execute query and verify results
+    accessor.invoke(() -> executeQuery(INDEX_NAME, "field1Value", "field1", numPuts));
+
+    // Export entries from region
+    accessor.invoke(() -> exportData(regionType));
 
     // Destroy indexes (only needs to be done on one member)
     dataStore1.invoke(() -> destroyIndexes());
@@ -169,22 +196,142 @@ public class LuceneIndexDestroyDUnitTest extends LuceneDUnitTest {
     dataStore1.invoke(() -> destroyDataRegion(true));
 
     // Recreate index and region
-    dataStore1.invoke(() -> initDataStore(createIndex(), regionType));
-    dataStore2.invoke(() -> initDataStore(createIndex(), regionType));
+    dataStore1.invoke(() -> initDataStore(createIndex, regionType));
+    dataStore2.invoke(() -> initDataStore(createIndex, regionType));
+    accessor.invoke(() -> initAccessor(createIndex, regionType));
 
-    // Do puts to cause IndexRepositories to be recreated
-    dataStore1.invoke(() -> doPuts(10));
+    // Import entries into region
+    accessor.invoke(() -> importData(regionType, numPuts));
 
     // Wait until queue is flushed
     // This verifies there are no deadlocks
     dataStore1.invoke(() -> waitUntilFlushed(INDEX_NAME));
     dataStore2.invoke(() -> waitUntilFlushed(INDEX_NAME));
+
+    // re-execute query and verify results
+    accessor.invoke(() -> executeQuery(INDEX_NAME, "field1Value", "field1", numPuts));
+  }
+
+  @Test
+  @Parameters(method = "getListOfRegionTestTypes")
+  public void verifyDestroyRecreateIndexDifferentName(RegionTestableType regionType) {
+    // Create index and region
+    SerializableRunnableIF createIndex = createIndex();
+    dataStore1.invoke(() -> initDataStore(createIndex, regionType));
+    dataStore2.invoke(() -> initDataStore(createIndex, regionType));
+    accessor.invoke(() -> initAccessor(createIndex, regionType));
+
+    // Verify index created
+    dataStore1.invoke(() -> verifyIndexCreated());
+    dataStore2.invoke(() -> verifyIndexCreated());
+    accessor.invoke(() -> verifyIndexCreated());
+
+    // Do puts to cause IndexRepositories to be created
+    int numPuts = 10;
+    accessor.invoke(() -> doPuts(numPuts));
+
+    // Wait until queue is flushed
+    dataStore1.invoke(() -> waitUntilFlushed(INDEX_NAME));
+    dataStore2.invoke(() -> waitUntilFlushed(INDEX_NAME));
+
+    // Execute query and verify results
+    accessor.invoke(() -> executeQuery(INDEX_NAME, "field1Value", "field1", numPuts));
+
+    // Export entries from region
+    accessor.invoke(() -> exportData(regionType));
+
+    // Destroy indexes (only needs to be done on one member)
+    dataStore1.invoke(() -> destroyIndexes());
+
+    // Verify indexes destroyed
+    dataStore1.invoke(() -> verifyIndexesDestroyed());
+    dataStore2.invoke(() -> verifyIndexesDestroyed());
+
+    // Destroy data region
+    dataStore1.invoke(() -> destroyDataRegion(true));
+
+    // Recreate index and region
+    String newIndexName = INDEX_NAME + "+_1";
+    SerializableRunnableIF createIndexNewName = createIndex(newIndexName, "field1");
+    dataStore1.invoke(() -> initDataStore(createIndexNewName, regionType));
+    dataStore2.invoke(() -> initDataStore(createIndexNewName, regionType));
+    accessor.invoke(() -> initAccessor(createIndexNewName, regionType));
+
+    // Import entries into region
+    accessor.invoke(() -> importData(regionType, numPuts));
+
+    // Wait until queue is flushed
+    // This verifies there are no deadlocks
+    dataStore1.invoke(() -> waitUntilFlushed(newIndexName));
+    dataStore2.invoke(() -> waitUntilFlushed(newIndexName));
+
+    // re-execute query and verify results
+    accessor.invoke(() -> executeQuery(newIndexName, "field1Value", "field1", numPuts));
+  }
+
+  @Test
+  @Parameters(method = "getListOfRegionTestTypes")
+  public void verifyDestroyRecreateDifferentIndex(RegionTestableType regionType) {
+    SerializableRunnableIF createIndex = createIndex();
+    dataStore1.invoke(() -> initDataStore(createIndex, regionType));
+    dataStore2.invoke(() -> initDataStore(createIndex, regionType));
+    accessor.invoke(() -> initAccessor(createIndex, regionType));
+
+    // Verify index created
+    dataStore1.invoke(() -> verifyIndexCreated());
+    dataStore2.invoke(() -> verifyIndexCreated());
+    accessor.invoke(() -> verifyIndexCreated());
+
+    // Do puts to cause IndexRepositories to be created
+    int numPuts = 10;
+    accessor.invoke(() -> doPuts(numPuts));
+
+    // Wait until queue is flushed
+    dataStore1.invoke(() -> waitUntilFlushed(INDEX_NAME));
+    dataStore2.invoke(() -> waitUntilFlushed(INDEX_NAME));
+
+    // Execute query and verify results
+    accessor.invoke(() -> executeQuery(INDEX_NAME, "field1Value", "field1", numPuts));
+
+    // Export entries from region
+    accessor.invoke(() -> exportData(regionType));
+
+    // Destroy indexes (only needs to be done on one member)
+    dataStore1.invoke(() -> destroyIndexes());
+
+    // Verify indexes destroyed
+    dataStore1.invoke(() -> verifyIndexesDestroyed());
+    dataStore2.invoke(() -> verifyIndexesDestroyed());
+
+    // Destroy data region
+    dataStore1.invoke(() -> destroyDataRegion(true));
+
+    // Create new index and region
+    SerializableRunnableIF createNewIndex = createIndex(INDEX_NAME, "field2");
+    dataStore1.invoke(() -> initDataStore(createNewIndex, regionType));
+    dataStore2.invoke(() -> initDataStore(createNewIndex, regionType));
+    accessor.invoke(() -> initAccessor(createNewIndex, regionType));
+
+    // Import entries into region
+    accessor.invoke(() -> importData(regionType, numPuts));
+
+    // Wait until queue is flushed
+    // This verifies there are no deadlocks
+    dataStore1.invoke(() -> waitUntilFlushed(INDEX_NAME));
+    dataStore2.invoke(() -> waitUntilFlushed(INDEX_NAME));
+
+    // re-execute query and verify results
+    accessor.invoke(() -> executeQuery(INDEX_NAME, "field2Value", "field2", numPuts));
   }
 
   private SerializableRunnableIF createIndex() {
+    return createIndex(INDEX_NAME, "field1");
+  }
+
+  private SerializableRunnableIF createIndex(String indexName, String field) {
     return () -> {
       LuceneService luceneService = LuceneServiceProvider.get(getCache());
-      luceneService.createIndex(INDEX_NAME, REGION_NAME, "text");
+      luceneService.createIndex(indexName, REGION_NAME, field);
     };
   }
 
@@ -216,7 +363,7 @@ public class LuceneIndexDestroyDUnitTest extends LuceneDUnitTest {
   private void doPuts(int numPuts) throws Exception {
     Region region = getCache().getRegion(REGION_NAME);
     for (int i = 0; i < numPuts; i++) {
-      region.put(i, new TestObject());
+      region.put(i, new TestObject("field1Value", "field2Value"));
     }
   }
 
@@ -238,6 +385,15 @@ public class LuceneIndexDestroyDUnitTest extends LuceneDUnitTest {
         .until(() -> getCache().getRegion(REGION_NAME).size() > 0);
   }
 
+  private void executeQuery(String indexName, String queryString, String field,
+      int expectedResultsSize) throws LuceneQueryException {
+    LuceneService luceneService = LuceneServiceProvider.get(getCache());
+    LuceneQuery query =
+        luceneService.createLuceneQueryFactory().create(indexName, REGION_NAME, queryString, field);
+    Collection results = query.findValues();
+    assertEquals(expectedResultsSize, results.size());
+  }
+
   private void destroyDataRegion(boolean shouldSucceed) {
     Region region = getCache().getRegion(REGION_NAME);
     assertNotNull(region);
@@ -296,4 +452,25 @@ public class LuceneIndexDestroyDUnitTest extends LuceneDUnitTest {
     LocalRegion region = (LocalRegion) getCache().getRegion(REGION_NAME);
     assertFalse(region.getExtensionPoint().getExtensions().iterator().hasNext());
   }
+
+  private void exportData(RegionTestableType regionType) throws Exception {
+    Region region = getCache().getRegion(REGION_NAME);
+    RegionSnapshotService service = region.getSnapshotService();
+    service.save(getSnapshotFile(getDiskDirs()[0], regionType),
+        SnapshotOptions.SnapshotFormat.GEMFIRE);
+  }
+
+  private void importData(RegionTestableType regionType, int expectedRegionSize) throws Exception {
+    Region region = getCache().getRegion(REGION_NAME);
+    RegionSnapshotService service = region.getSnapshotService();
+    SnapshotOptions options = service.createOptions();
+    options.invokeCallbacks(true);
+    service.load(getSnapshotFile(getDiskDirs()[0], regionType),
+        SnapshotOptions.SnapshotFormat.GEMFIRE, options);
+    assertEquals(expectedRegionSize, region.size());
+  }
+
+  private File getSnapshotFile(File baseDirectory, RegionTestableType regionType) {
+    return new File(baseDirectory, REGION_NAME + "_" + regionType.name() + "_snapshot.gfd");
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/63d565b5/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/TestObject.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/TestObject.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/TestObject.java
index be91b6d..24e330b 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/TestObject.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/TestObject.java
@@ -52,4 +52,8 @@ public class TestObject implements Serializable {
     return (testObject.field1.equals(field1) && testObject.field2.equals(field2));
   }
 
+  public String toString() {
+    return new StringBuilder().append(getClass().getSimpleName()).append("[").append("field1=")
+        .append(field1).append("; field2=").append(field2).append("]").toString();
+  }
 }


[29/50] [abbrv] geode git commit: GEODE-1198: add todo comment to dubious test

Posted by ds...@apache.org.
GEODE-1198: add todo comment to dubious test


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/7a16a7f1
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/7a16a7f1
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/7a16a7f1

Branch: refs/heads/feature/GEODE-1969
Commit: 7a16a7f167d93f6ffb0716ac94ef028ef63bec1d
Parents: 55564a3
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Mar 7 14:34:47 2017 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Mar 7 16:16:04 2017 -0800

----------------------------------------------------------------------
 .../org/apache/geode/distributed/DistributedSystemDUnitTest.java   | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/7a16a7f1/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
index dfe4588..9a64f53 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
@@ -124,6 +124,8 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
       }
     });
 
+    // TODO: assert that queue was created or this test is just broken
+
     assertThat(distributionManager.getMembershipManager().waitForDeparture(member))
         .as("expected the serial queue to be flushed").isTrue();
   }


[18/50] [abbrv] geode git commit: GEODE-2596: Lucene metrics moved to public API

Posted by ds...@apache.org.
GEODE-2596: Lucene metrics moved to public API

	* LuceneIndexMetrics and LuceneServiceMXBean were moved to org.apache.geode.cache.lucene.management
	* They are now public API

	This closes #414


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/946ff6ee
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/946ff6ee
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/946ff6ee

Branch: refs/heads/feature/GEODE-1969
Commit: 946ff6ee49f8061dc7f3c11b43bf823b4314b109
Parents: eb59268
Author: nabarun <nn...@pivotal.io>
Authored: Mon Mar 6 11:59:33 2017 -0800
Committer: nabarun <nn...@pivotal.io>
Committed: Mon Mar 6 16:25:24 2017 -0800

----------------------------------------------------------------------
 .../internal/management/LuceneIndexMetrics.java | 190 -------------------
 .../management/LuceneIndexStatsMonitor.java     |   2 +-
 .../management/LuceneServiceBridge.java         |   2 +-
 .../internal/management/LuceneServiceMBean.java |   2 +
 .../management/LuceneServiceMXBean.java         |  58 ------
 .../lucene/management/LuceneIndexMetrics.java   | 190 +++++++++++++++++++
 .../lucene/management/LuceneServiceMXBean.java  |  58 ++++++
 .../management/LuceneManagementDUnitTest.java   |   2 +
 8 files changed, 254 insertions(+), 250 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/946ff6ee/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneIndexMetrics.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneIndexMetrics.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneIndexMetrics.java
deleted file mode 100644
index 999d8b3..0000000
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneIndexMetrics.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * 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.cache.lucene.internal.management;
-
-import java.beans.ConstructorProperties;
-
-public class LuceneIndexMetrics {
-
-  private final String regionPath;
-
-  private final String indexName;
-
-  private final int queryExecutions;
-
-  private final long queryExecutionTime;
-
-  private final float queryRate;
-
-  private final long queryRateAverageLatency;
-
-  private final int queryExecutionsInProgress;
-
-  private final long queryExecutionTotalHits;
-
-  private final int updates;
-
-  private final long updateTime;
-
-  private final float updateRate;
-
-  private final long updateRateAverageLatency;
-
-  private final int updatesInProgress;
-
-  private final int commits;
-
-  private final long commitTime;
-
-  private final float commitRate;
-
-  private final long commitRateAverageLatency;
-
-  private final int commitsInProgress;
-
-  private final int documents;
-
-  /**
-   * This constructor is to be used by internal JMX framework only. A user should not try to create
-   * an instance of this class.
-   */
-  @ConstructorProperties({"regionPath", "indexName", "queryExecutions", "queryExecutionTime",
-      "queryRate", "queryRateAverageLatency", "queryExecutionsInProgress",
-      "queryExecutionTotalHits", "updates", "updateTime", "updateRate", "updateRateAverageLatency",
-      "updatesInProgress", "commits", "commitTime", "commitRate", "commitRateAverageLatency",
-      "commitsInProgress", "documents"})
-  public LuceneIndexMetrics(String regionPath, String indexName, int queryExecutions,
-      long queryExecutionTime, float queryRate, long queryRateAverageLatency,
-      int queryExecutionsInProgress, long queryExecutionTotalHits, int updates, long updateTime,
-      float updateRate, long updateRateAverageLatency, int updatesInProgress, int commits,
-      long commitTime, float commitRate, long commitRateAverageLatency, int commitsInProgress,
-      int documents) {
-    this.regionPath = regionPath;
-    this.indexName = indexName;
-    this.queryExecutions = queryExecutions;
-    this.queryExecutionTime = queryExecutionTime;
-    this.queryRate = queryRate;
-    this.queryRateAverageLatency = queryRateAverageLatency;
-    this.queryExecutionsInProgress = queryExecutionsInProgress;
-    this.queryExecutionTotalHits = queryExecutionTotalHits;
-    this.updates = updates;
-    this.updateTime = updateTime;
-    this.updateRate = updateRate;
-    this.updateRateAverageLatency = updateRateAverageLatency;
-    this.updatesInProgress = updatesInProgress;
-    this.commits = commits;
-    this.commitTime = commitTime;
-    this.commitRate = commitRate;
-    this.commitRateAverageLatency = commitRateAverageLatency;
-    this.commitsInProgress = commitsInProgress;
-    this.documents = documents;
-  }
-
-  public String getRegionPath() {
-    return this.regionPath;
-  }
-
-  public String getIndexName() {
-    return this.indexName;
-  }
-
-  public int getQueryExecutions() {
-    return this.queryExecutions;
-  }
-
-  public long getQueryExecutionTime() {
-    return this.queryExecutionTime;
-  }
-
-  public float getQueryRate() {
-    return this.queryRate;
-  }
-
-  public long getQueryRateAverageLatency() {
-    return this.queryRateAverageLatency;
-  }
-
-  public int getQueryExecutionsInProgress() {
-    return this.queryExecutionsInProgress;
-  }
-
-  public long getQueryExecutionTotalHits() {
-    return this.queryExecutionTotalHits;
-  }
-
-  public int getUpdates() {
-    return this.updates;
-  }
-
-  public long getUpdateTime() {
-    return this.updateTime;
-  }
-
-  public float getUpdateRate() {
-    return this.updateRate;
-  }
-
-  public long getUpdateRateAverageLatency() {
-    return this.updateRateAverageLatency;
-  }
-
-  public int getUpdatesInProgress() {
-    return this.updatesInProgress;
-  }
-
-  public int getCommits() {
-    return this.commits;
-  }
-
-  public long getCommitTime() {
-    return this.commitTime;
-  }
-
-  public float getCommitRate() {
-    return this.commitRate;
-  }
-
-  public long getCommitRateAverageLatency() {
-    return this.commitRateAverageLatency;
-  }
-
-  public int getCommitsInProgress() {
-    return this.commitsInProgress;
-  }
-
-  public int getDocuments() {
-    return documents;
-  }
-
-  @Override
-  public String toString() {
-    return new StringBuilder().append(getClass().getSimpleName()).append("[").append("regionPath=")
-        .append(this.regionPath).append("; indexName=").append(this.indexName)
-        .append("; queryExecutions=").append(this.queryExecutions).append("; queryExecutionTime=")
-        .append(this.queryExecutionTime).append("; queryRate=").append(this.queryRate)
-        .append("; queryRateAverageLatency=").append(this.queryRateAverageLatency)
-        .append("; queryExecutionsInProgress=").append(this.queryExecutionsInProgress)
-        .append("; queryExecutionTotalHits=").append(this.queryExecutionTotalHits)
-        .append("; updates=").append(this.updates).append("; updateTime=").append(this.updateTime)
-        .append("; updateRate=").append(this.updateRate).append("; updateRateAverageLatency=")
-        .append(this.updateRateAverageLatency).append("; updatesInProgress=")
-        .append(this.updatesInProgress).append("; commits=").append(this.commits)
-        .append("; commitTime=").append(this.commitTime).append("; commitRate=")
-        .append(this.commitRate).append("; commitRateAverageLatency=")
-        .append(this.commitRateAverageLatency).append("; commitsInProgress=")
-        .append(this.commitsInProgress).append("; documents=").append(this.documents).append("]")
-        .toString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/946ff6ee/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneIndexStatsMonitor.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneIndexStatsMonitor.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneIndexStatsMonitor.java
index b28541f..8d7d7ca 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneIndexStatsMonitor.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneIndexStatsMonitor.java
@@ -16,7 +16,7 @@ package org.apache.geode.cache.lucene.internal.management;
 
 import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
-import org.apache.geode.management.internal.ManagementStrings;
+import org.apache.geode.cache.lucene.management.LuceneIndexMetrics;
 import org.apache.geode.management.internal.beans.stats.MBeanStatsMonitor;
 import org.apache.geode.management.internal.beans.stats.StatType;
 import org.apache.geode.management.internal.beans.stats.StatsAverageLatency;

http://git-wip-us.apache.org/repos/asf/geode/blob/946ff6ee/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceBridge.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceBridge.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceBridge.java
index b18b376..eff503a 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceBridge.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceBridge.java
@@ -18,7 +18,7 @@ import org.apache.geode.cache.Region;
 import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.LuceneService;
 import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
-import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
+import org.apache.geode.cache.lucene.management.LuceneIndexMetrics;
 
 import java.util.ArrayList;
 import java.util.Collection;

http://git-wip-us.apache.org/repos/asf/geode/blob/946ff6ee/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceMBean.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceMBean.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceMBean.java
index d2739fe..2cfc42e 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceMBean.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceMBean.java
@@ -16,6 +16,8 @@ package org.apache.geode.cache.lucene.internal.management;
 
 import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.LuceneService;
+import org.apache.geode.cache.lucene.management.LuceneIndexMetrics;
+import org.apache.geode.cache.lucene.management.LuceneServiceMXBean;
 import org.apache.geode.management.internal.beans.CacheServiceMBeanBase;
 
 import javax.management.NotificationBroadcasterSupport;

http://git-wip-us.apache.org/repos/asf/geode/blob/946ff6ee/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceMXBean.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceMXBean.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceMXBean.java
deleted file mode 100644
index 23be091..0000000
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceMXBean.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.cache.lucene.internal.management;
-
-import org.apache.geode.management.internal.security.ResourceOperation;
-import org.apache.geode.security.ResourcePermission.Operation;
-import org.apache.geode.security.ResourcePermission.Resource;
-
-/**
- * MBean that provides access to the {@link org.apache.geode.cache.lucene.LuceneService}.
- */
-@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
-public interface LuceneServiceMXBean {
-
-  /**
-   * Returns an array of {@link LuceneIndexMetrics} for the
-   * {@link org.apache.geode.cache.lucene.LuceneIndex} instances defined in this member
-   *
-   * @return an array of LuceneIndexMetrics for the LuceneIndexes defined in this member
-   */
-  public LuceneIndexMetrics[] listIndexMetrics();
-
-  /**
-   * Returns an array of {@link LuceneIndexMetrics} for the
-   * {@link org.apache.geode.cache.lucene.LuceneIndex} instances defined on the input region in this
-   * member
-   *
-   * @param regionPath The full path of the region to retrieve
-   *
-   * @return an array of LuceneIndexMetrics for the LuceneIndex instances defined on the input
-   *         region in this member
-   */
-  public LuceneIndexMetrics[] listIndexMetrics(String regionPath);
-
-  /**
-   * Returns a {@link LuceneIndexMetrics} for the {@link org.apache.geode.cache.lucene.LuceneIndex}
-   * with the input index name defined on the input region in this member.
-   *
-   * @param regionPath The full path of the region to retrieve
-   * @param indexName The name of the index to retrieve
-   *
-   * @return a LuceneIndexMetrics for the LuceneIndex with the input index name defined on the input
-   *         region in this member.
-   */
-  public LuceneIndexMetrics listIndexMetrics(String regionPath, String indexName);
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/946ff6ee/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java
new file mode 100644
index 0000000..de89758
--- /dev/null
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java
@@ -0,0 +1,190 @@
+/*
+ * 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.cache.lucene.management;
+
+import java.beans.ConstructorProperties;
+
+public class LuceneIndexMetrics {
+
+  private final String regionPath;
+
+  private final String indexName;
+
+  private final int queryExecutions;
+
+  private final long queryExecutionTime;
+
+  private final float queryRate;
+
+  private final long queryRateAverageLatency;
+
+  private final int queryExecutionsInProgress;
+
+  private final long queryExecutionTotalHits;
+
+  private final int updates;
+
+  private final long updateTime;
+
+  private final float updateRate;
+
+  private final long updateRateAverageLatency;
+
+  private final int updatesInProgress;
+
+  private final int commits;
+
+  private final long commitTime;
+
+  private final float commitRate;
+
+  private final long commitRateAverageLatency;
+
+  private final int commitsInProgress;
+
+  private final int documents;
+
+  /**
+   * This constructor is to be used by internal JMX framework only. A user should not try to create
+   * an instance of this class.
+   */
+  @ConstructorProperties({"regionPath", "indexName", "queryExecutions", "queryExecutionTime",
+      "queryRate", "queryRateAverageLatency", "queryExecutionsInProgress",
+      "queryExecutionTotalHits", "updates", "updateTime", "updateRate", "updateRateAverageLatency",
+      "updatesInProgress", "commits", "commitTime", "commitRate", "commitRateAverageLatency",
+      "commitsInProgress", "documents"})
+  public LuceneIndexMetrics(String regionPath, String indexName, int queryExecutions,
+      long queryExecutionTime, float queryRate, long queryRateAverageLatency,
+      int queryExecutionsInProgress, long queryExecutionTotalHits, int updates, long updateTime,
+      float updateRate, long updateRateAverageLatency, int updatesInProgress, int commits,
+      long commitTime, float commitRate, long commitRateAverageLatency, int commitsInProgress,
+      int documents) {
+    this.regionPath = regionPath;
+    this.indexName = indexName;
+    this.queryExecutions = queryExecutions;
+    this.queryExecutionTime = queryExecutionTime;
+    this.queryRate = queryRate;
+    this.queryRateAverageLatency = queryRateAverageLatency;
+    this.queryExecutionsInProgress = queryExecutionsInProgress;
+    this.queryExecutionTotalHits = queryExecutionTotalHits;
+    this.updates = updates;
+    this.updateTime = updateTime;
+    this.updateRate = updateRate;
+    this.updateRateAverageLatency = updateRateAverageLatency;
+    this.updatesInProgress = updatesInProgress;
+    this.commits = commits;
+    this.commitTime = commitTime;
+    this.commitRate = commitRate;
+    this.commitRateAverageLatency = commitRateAverageLatency;
+    this.commitsInProgress = commitsInProgress;
+    this.documents = documents;
+  }
+
+  public String getRegionPath() {
+    return this.regionPath;
+  }
+
+  public String getIndexName() {
+    return this.indexName;
+  }
+
+  public int getQueryExecutions() {
+    return this.queryExecutions;
+  }
+
+  public long getQueryExecutionTime() {
+    return this.queryExecutionTime;
+  }
+
+  public float getQueryRate() {
+    return this.queryRate;
+  }
+
+  public long getQueryRateAverageLatency() {
+    return this.queryRateAverageLatency;
+  }
+
+  public int getQueryExecutionsInProgress() {
+    return this.queryExecutionsInProgress;
+  }
+
+  public long getQueryExecutionTotalHits() {
+    return this.queryExecutionTotalHits;
+  }
+
+  public int getUpdates() {
+    return this.updates;
+  }
+
+  public long getUpdateTime() {
+    return this.updateTime;
+  }
+
+  public float getUpdateRate() {
+    return this.updateRate;
+  }
+
+  public long getUpdateRateAverageLatency() {
+    return this.updateRateAverageLatency;
+  }
+
+  public int getUpdatesInProgress() {
+    return this.updatesInProgress;
+  }
+
+  public int getCommits() {
+    return this.commits;
+  }
+
+  public long getCommitTime() {
+    return this.commitTime;
+  }
+
+  public float getCommitRate() {
+    return this.commitRate;
+  }
+
+  public long getCommitRateAverageLatency() {
+    return this.commitRateAverageLatency;
+  }
+
+  public int getCommitsInProgress() {
+    return this.commitsInProgress;
+  }
+
+  public int getDocuments() {
+    return documents;
+  }
+
+  @Override
+  public String toString() {
+    return new StringBuilder().append(getClass().getSimpleName()).append("[").append("regionPath=")
+        .append(this.regionPath).append("; indexName=").append(this.indexName)
+        .append("; queryExecutions=").append(this.queryExecutions).append("; queryExecutionTime=")
+        .append(this.queryExecutionTime).append("; queryRate=").append(this.queryRate)
+        .append("; queryRateAverageLatency=").append(this.queryRateAverageLatency)
+        .append("; queryExecutionsInProgress=").append(this.queryExecutionsInProgress)
+        .append("; queryExecutionTotalHits=").append(this.queryExecutionTotalHits)
+        .append("; updates=").append(this.updates).append("; updateTime=").append(this.updateTime)
+        .append("; updateRate=").append(this.updateRate).append("; updateRateAverageLatency=")
+        .append(this.updateRateAverageLatency).append("; updatesInProgress=")
+        .append(this.updatesInProgress).append("; commits=").append(this.commits)
+        .append("; commitTime=").append(this.commitTime).append("; commitRate=")
+        .append(this.commitRate).append("; commitRateAverageLatency=")
+        .append(this.commitRateAverageLatency).append("; commitsInProgress=")
+        .append(this.commitsInProgress).append("; documents=").append(this.documents).append("]")
+        .toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/946ff6ee/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneServiceMXBean.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneServiceMXBean.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneServiceMXBean.java
new file mode 100644
index 0000000..80ad575
--- /dev/null
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneServiceMXBean.java
@@ -0,0 +1,58 @@
+/*
+ * 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.cache.lucene.management;
+
+import org.apache.geode.management.internal.security.ResourceOperation;
+import org.apache.geode.security.ResourcePermission.Operation;
+import org.apache.geode.security.ResourcePermission.Resource;
+
+/**
+ * MBean that provides access to the {@link org.apache.geode.cache.lucene.LuceneService}.
+ */
+@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
+public interface LuceneServiceMXBean {
+
+  /**
+   * Returns an array of {@link LuceneIndexMetrics} for the
+   * {@link org.apache.geode.cache.lucene.LuceneIndex} instances defined in this member
+   *
+   * @return an array of LuceneIndexMetrics for the LuceneIndexes defined in this member
+   */
+  public LuceneIndexMetrics[] listIndexMetrics();
+
+  /**
+   * Returns an array of {@link LuceneIndexMetrics} for the
+   * {@link org.apache.geode.cache.lucene.LuceneIndex} instances defined on the input region in this
+   * member
+   *
+   * @param regionPath The full path of the region to retrieve
+   *
+   * @return an array of LuceneIndexMetrics for the LuceneIndex instances defined on the input
+   *         region in this member
+   */
+  public LuceneIndexMetrics[] listIndexMetrics(String regionPath);
+
+  /**
+   * Returns a {@link LuceneIndexMetrics} for the {@link org.apache.geode.cache.lucene.LuceneIndex}
+   * with the input index name defined on the input region in this member.
+   *
+   * @param regionPath The full path of the region to retrieve
+   * @param indexName The name of the index to retrieve
+   *
+   * @return a LuceneIndexMetrics for the LuceneIndex with the input index name defined on the input
+   *         region in this member.
+   */
+  public LuceneIndexMetrics listIndexMetrics(String regionPath, String indexName);
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/946ff6ee/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/management/LuceneManagementDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/management/LuceneManagementDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/management/LuceneManagementDUnitTest.java
index 73c4183..36a8e55 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/management/LuceneManagementDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/management/LuceneManagementDUnitTest.java
@@ -19,6 +19,8 @@ import org.apache.geode.cache.lucene.LuceneQuery;
 import org.apache.geode.cache.lucene.LuceneQueryException;
 import org.apache.geode.cache.lucene.LuceneService;
 import org.apache.geode.cache.lucene.LuceneServiceProvider;
+import org.apache.geode.cache.lucene.management.LuceneIndexMetrics;
+import org.apache.geode.cache.lucene.management.LuceneServiceMXBean;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.management.ManagementTestBase;


[50/50] [abbrv] geode git commit: Merge remote-tracking branch 'origin/develop' into feature/GEODE-1969

Posted by ds...@apache.org.
Merge remote-tracking branch 'origin/develop' into feature/GEODE-1969


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/40ff2a13
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/40ff2a13
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/40ff2a13

Branch: refs/heads/feature/GEODE-1969
Commit: 40ff2a1324636aa8441564da89be82b9fe2d8cf9
Parents: 4d1ded8 63d565b
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Thu Mar 9 12:46:04 2017 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Thu Mar 9 12:46:04 2017 -0800

----------------------------------------------------------------------
 .travis.yml                                     |    4 +-
 BUILDING.md                                     |   70 +-
 DISCLAIMER                                      |    6 -
 KEYS                                            |  326 +-
 LICENSE                                         |  140 +-
 NOTICE                                          |    6 +-
 README.md                                       |  176 +-
 build.gradle                                    |   19 +-
 dev-tools/docker/base/Dockerfile                |    4 +-
 dev-tools/docker/compile/Dockerfile             |    4 +-
 dev-tools/docker/docs/Dockerfile                |    4 +-
 docker/Dockerfile                               |    8 +-
 etc/eclipse-java-google-style.xml               |    2 +-
 .../release/conf/cache-client.xml               |   80 +-
 .../release/conf/cache-peer.xml                 |   96 +-
 .../release/conf/cache-server.xml               |  144 +-
 .../internal/filter/ListenerEventType.java      |    7 +-
 .../session/installer/InstallerJUnitTest.java   |   29 +-
 .../SessionReplicationIntegrationJUnitTest.java |   16 +-
 extensions/geode-modules-tomcat8/build.gradle   |    2 +-
 extensions/geode-modules/build.gradle           |    1 +
 .../util/ClassLoaderObjectInputStream.java      |    8 +-
 .../session/Tomcat6SessionsJUnitTest.java       |    3 +-
 .../util/ClassLoaderObjectInputStreamTest.java  |  169 +
 geode-assembly/.gitignore                       |    1 +
 geode-assembly/build.gradle                     |   12 +-
 geode-assembly/src/main/dist/DISCLAIMER         |    6 -
 geode-assembly/src/main/dist/LICENSE            |  139 +-
 geode-assembly/src/main/dist/NOTICE             |  147 +-
 .../org/apache/geode/BundledJarsJUnitTest.java  |   27 +-
 .../management/internal/AgentUtilJUnitTest.java |   11 +-
 .../LauncherLifecycleCommandsDUnitTest.java     |   51 +
 .../LauncherLifecycleCommandsJUnitTest.java     |   43 +
 ...erConfigurationServiceEndToEndDUnitTest.java |  468 +++
 .../SharedConfigurationEndToEndDUnitTest.java   |  464 ---
 .../web/RestSecurityIntegrationTest.java        |  151 +-
 .../web/RestSecurityPostProcessorTest.java      |   24 +-
 .../internal/web/RestSecurityWithSSLTest.java   |   16 +-
 .../rest/internal/web/RestServersJUnitTest.java |    3 +-
 .../internal/web/SwaggerVerificationTest.java   |   13 +-
 .../web/controllers/NoArgumentFunction.java     |  114 +
 ...stAPIOnRegionFunctionExecutionDUnitTest.java |   20 +-
 .../web/controllers/RestAPITestBase.java        |   23 +-
 .../RestAPIsAndInterOpsDUnitTest.java           |   46 +-
 ...tAPIsOnGroupsFunctionExecutionDUnitTest.java |   17 +-
 ...APIsOnMembersFunctionExecutionDUnitTest.java |   93 +-
 .../RestAPIsQueryAndFEJUnitTest.java            |   18 +-
 .../geode/tools/pulse/PulseDataExportTest.java  |  172 +
 .../src/test/resources/expected_jars.txt        |    1 -
 geode-benchmarks/build.gradle                   |    2 +
 geode-book/README.md                            |   29 +-
 geode-book/config.yml                           |   20 +-
 .../source/archive_menus/_default.erb           |   28 +
 .../source/subnavs/geode-subnav.erb             | 1776 +++++----
 geode-book/redirects.rb                         |    7 +-
 geode-core/build.gradle                         |   19 +-
 .../geode/cache/query/internal/parse/oql.g      | 1195 ++++++
 .../java/org/apache/geode/DataSerializer.java   |   69 +
 .../java/org/apache/geode/cache/Operation.java  |   16 +
 .../java/org/apache/geode/cache/Region.java     |    2 -
 .../internal/AsyncEventQueueImpl.java           |   16 +-
 .../client/internal/ConnectionFactoryImpl.java  |    3 +
 .../cache/client/internal/ConnectionImpl.java   |    2 +-
 .../cache/client/internal/ConnectionStats.java  |    4 +
 .../client/internal/EndpointManagerImpl.java    |    4 +-
 .../cache/client/internal/OpExecutorImpl.java   |    4 +-
 .../cache/client/internal/QueueManagerImpl.java |    3 +
 .../internal/SingleHopClientExecutor.java       |    8 +-
 .../geode/cache/execute/FunctionContext.java    |    3 +
 .../cache/partition/PartitionListener.java      |   59 +-
 .../partition/PartitionListenerAdapter.java     |    4 +-
 .../query/internal/AbstractCompiledValue.java   |    2 +-
 .../internal/AbstractGroupOrRangeJunction.java  |    2 +-
 .../query/internal/CompiledBindArgument.java    |   18 +-
 .../geode/cache/query/internal/CompiledIn.java  |    2 +-
 .../cache/query/internal/CompiledLike.java      |    2 -
 .../query/internal/CompiledSortCriterion.java   |    6 -
 .../query/internal/CompositeGroupJunction.java  |    1 -
 .../cache/query/internal/DefaultQuery.java      |   13 +-
 .../geode/cache/query/internal/DerivedInfo.java |    5 -
 .../geode/cache/query/internal/IndexInfo.java   |    2 -
 .../internal/IndexTrackingQueryObserver.java    |   33 +-
 .../geode/cache/query/internal/PathUtils.java   |    2 +-
 .../geode/cache/query/internal/QCompiler.java   |   11 +-
 .../geode/cache/query/internal/QueryUtils.java  |    2 +-
 .../cache/query/internal/RangeJunction.java     |    2 +-
 .../query/internal/index/AbstractIndex.java     |    4 +-
 .../query/internal/index/CompactRangeIndex.java |    2 +
 .../index/FunctionalIndexCreationHelper.java    |    3 -
 .../cache/query/internal/index/HashIndex.java   |    3 +-
 .../query/internal/index/IndexManager.java      |    3 +
 .../query/internal/index/MapIndexStore.java     |    4 -
 .../query/internal/index/MemoryIndexStore.java  |   12 +-
 .../cache/query/internal/index/RangeIndex.java  |    1 -
 .../cache/query/internal/parse/OQLLexer.java    | 3471 -----------------
 .../internal/parse/OQLLexerTokenTypes.java      |  156 -
 .../query/internal/parse/OQLLexerTokenTypes.txt |  147 -
 .../cache/query/internal/parse/OQLParser.java   | 3650 ------------------
 .../geode/cache/query/internal/parse/oql.g      | 1195 ------
 .../geode/cache/snapshot/SnapshotOptions.java   |   16 +
 .../apache/geode/cache/wan/GatewaySender.java   |   13 +
 .../geode/distributed/AbstractLauncher.java     |  109 +-
 .../distributed/ConfigurationProperties.java    |   17 +-
 .../geode/distributed/DistributedSystem.java    |   14 +-
 .../org/apache/geode/distributed/Locator.java   |   20 +-
 .../geode/distributed/LocatorLauncher.java      |   24 +-
 .../geode/distributed/ServerLauncher.java       |    8 +-
 .../internal/AbstractDistributionConfig.java    |   27 +-
 .../internal/ClusterConfigurationService.java   |  788 ++++
 .../apache/geode/distributed/internal/DM.java   |    2 +
 .../internal/DefaultPropertiesGenerator.java    |   52 +
 .../internal/DistributionAdvisor.java           |   22 +
 .../internal/DistributionConfig.java            |    2 +-
 .../internal/DistributionConfigImpl.java        |   25 +-
 .../internal/DistributionManager.java           |   12 +-
 .../distributed/internal/DistributionStats.java |    9 +-
 .../FunctionExecutionPooledExecutor.java        |    2 +-
 .../internal/InternalDistributedSystem.java     |   47 +-
 .../distributed/internal/InternalLocator.java   |  148 +-
 .../distributed/internal/ResourceEvent.java     |   29 +-
 .../distributed/internal/ServerLocator.java     |    2 +-
 .../internal/SharedConfiguration.java           |  979 -----
 .../internal/StartupMessageReplyProcessor.java  |   11 -
 .../StartupResponseWithVersionMessage.java      |    2 +-
 .../internal/deadlock/LocalThread.java          |    5 +-
 .../internal/direct/DirectChannel.java          |    4 +-
 .../internal/locks/Collaboration.java           |  454 ---
 .../membership/InternalDistributedMember.java   |   48 +-
 .../internal/membership/NetView.java            |   50 +-
 .../internal/membership/gms/Services.java       |   12 +-
 .../gms/locator/FindCoordinatorResponse.java    |    2 +-
 .../membership/gms/locator/GMSLocator.java      |   42 +-
 .../membership/gms/membership/GMSJoinLeave.java |   93 +-
 .../gms/messages/JoinResponseMessage.java       |    7 +
 .../gms/mgr/GMSMembershipManager.java           |  183 +-
 .../tcpserver/LocatorCancelException.java       |   15 +-
 .../internal/tcpserver/TcpClient.java           |   10 +-
 .../internal/tcpserver/TcpHandler.java          |    5 +-
 .../internal/tcpserver/TcpServer.java           |  326 +-
 .../security/ExampleSecurityManager.java        |   66 +-
 .../java/org/apache/geode/internal/Banner.java  |   37 +-
 .../org/apache/geode/internal/DSFIDFactory.java |    6 +-
 .../geode/internal/DataSerializableFixedID.java |    5 +-
 .../geode/internal/DistributionLocator.java     |    3 +-
 .../org/apache/geode/internal/FileUtil.java     |  328 --
 .../apache/geode/internal/GemFireVersion.java   |   13 +-
 .../geode/internal/InternalDataSerializer.java  |    5 +-
 .../org/apache/geode/internal/JarDeployer.java  |   41 +-
 .../java/org/apache/geode/internal/Version.java |    3 +
 .../admin/remote/DistributionLocatorId.java     |   30 +-
 .../geode/internal/cache/AbstractRegion.java    |    4 +-
 .../geode/internal/cache/BucketAdvisor.java     |   15 +-
 .../geode/internal/cache/BucketRegion.java      |    4 +-
 .../geode/internal/cache/BucketRegionQueue.java |   52 +
 .../geode/internal/cache/CacheServerImpl.java   |    8 +-
 .../cache/ClusterConfigurationLoader.java       |   38 +-
 .../geode/internal/cache/DestroyOperation.java  |    6 -
 .../geode/internal/cache/DiskInitFile.java      |   60 +-
 .../geode/internal/cache/DiskStoreImpl.java     |  242 +-
 .../cache/DistributedCacheOperation.java        |   32 +-
 .../cache/DistributedPutAllOperation.java       |   27 -
 .../geode/internal/cache/DistributedRegion.java |  100 +-
 .../cache/DistributedRemoveAllOperation.java    |   15 -
 .../cache/DistributedTombstoneOperation.java    |   12 +
 .../geode/internal/cache/FilterProfile.java     |   15 +-
 .../geode/internal/cache/GemFireCacheImpl.java  |   41 +-
 .../internal/cache/InitialImageOperation.java   |   23 +-
 .../internal/cache/InvalidateOperation.java     |    8 -
 .../geode/internal/cache/LocalDataSet.java      |    4 +-
 .../geode/internal/cache/LocalRegion.java       |   58 +-
 .../org/apache/geode/internal/cache/OpType.java |    2 +
 .../org/apache/geode/internal/cache/Oplog.java  |  163 +-
 .../internal/cache/PRHARedundancyProvider.java  |    2 +-
 .../geode/internal/cache/PartitionedRegion.java |   29 +-
 .../internal/cache/PersistentOplogSet.java      |   40 +-
 .../cache/ReliableDistributionData.java         |   41 -
 .../internal/cache/ReliableMessageQueue.java    |   69 -
 .../cache/ReliableMessageQueueFactory.java      |   41 -
 .../cache/ReliableMessageQueueFactoryImpl.java  |  246 --
 .../internal/cache/SendQueueOperation.java      |  190 -
 .../geode/internal/cache/TXCommitMessage.java   |   41 +-
 .../geode/internal/cache/TombstoneService.java  |   33 +-
 .../cache/UpdateEntryVersionOperation.java      |    6 -
 .../geode/internal/cache/UpdateOperation.java   |   13 -
 .../geode/internal/cache/ha/HARegionQueue.java  |   24 +-
 .../internal/cache/ha/ThreadIdentifier.java     |    9 +-
 .../geode/internal/cache/lru/HeapEvictor.java   |    2 +-
 .../cache/partitioned/PRTombstoneMessage.java   |    2 +-
 .../cache/partitioned/RegionAdvisor.java        |   22 +
 .../cache/persistence/BackupManager.java        |   57 +-
 .../cache/persistence/RestoreScript.java        |    6 +-
 .../snapshot/RegionSnapshotServiceImpl.java     |    4 +-
 .../cache/snapshot/SnapshotOptionsImpl.java     |   15 +
 .../geode/internal/cache/tier/Acceptor.java     |    5 +
 .../cache/tier/sockets/AcceptorImpl.java        |  180 +-
 .../internal/cache/tier/sockets/AuthIds.java    |   48 +
 .../cache/tier/sockets/BaseCommand.java         |   23 +-
 .../cache/tier/sockets/BaseCommandQuery.java    |    1 +
 .../cache/tier/sockets/CacheClientProxy.java    |   34 +-
 .../cache/tier/sockets/CacheClientUpdater.java  |    2 +-
 .../cache/tier/sockets/ClientHealthMonitor.java |   27 +-
 .../tier/sockets/ClientUpdateMessageImpl.java   |   22 +-
 .../internal/cache/tier/sockets/HandShake.java  |  130 +-
 .../cache/tier/sockets/MessageIdExtractor.java  |   43 +
 .../cache/tier/sockets/ServerConnection.java    |   94 +-
 .../tier/sockets/command/DestroyRegion.java     |    2 +
 .../sockets/command/GatewayReceiverCommand.java |   50 +-
 .../sockets/command/GetFunctionAttribute.java   |    6 +-
 .../internal/cache/tx/ClientTXStateStub.java    |    6 +
 .../cache/tx/TransactionalOperation.java        |   16 +-
 .../cache/wan/AbstractGatewaySender.java        |   47 +-
 .../AbstractGatewaySenderEventProcessor.java    |    4 -
 .../cache/wan/GatewaySenderAdvisor.java         |    5 +-
 .../cache/wan/GatewaySenderEventImpl.java       |    4 +-
 ...aitUntilGatewaySenderFlushedCoordinator.java |   43 +
 .../parallel/ParallelGatewaySenderQueue.java    |    6 +-
 ...ParallelGatewaySenderFlushedCoordinator.java |  181 +
 .../cache/wan/serial/BatchDestroyOperation.java |    7 -
 .../SerialGatewaySenderEventProcessor.java      |    2 +-
 .../wan/serial/SerialGatewaySenderQueue.java    |    4 -
 .../cache/xmlcache/CacheXmlVersion.java         |   43 +-
 .../geode/internal/i18n/LocalizedStrings.java   |   38 +-
 .../io/MainWithChildrenRollingFileHandler.java  |   29 +-
 .../geode/internal/jta/TransactionImpl.java     |    4 +
 .../apache/geode/internal/lang/SystemUtils.java |   39 +-
 .../geode/internal/logging/GemFireLevel.java    |    6 +-
 .../internal/logging/InternalLogWriter.java     |    3 +
 .../geode/internal/logging/LogService.java      |   20 +-
 .../geode/internal/logging/MergeLogFiles.java   |   29 +-
 .../internal/logging/log4j/AlertAppender.java   |   19 +-
 .../internal/net/SSLConfigurationFactory.java   |   28 +-
 .../offheap/annotations/OffHeapIdentifier.java  |   22 +-
 .../geode/internal/process/ProcessUtils.java    |    2 +-
 .../geode/internal/process/signal/Signal.java   |  114 +-
 .../internal/process/signal/SignalType.java     |   12 +-
 .../security/IntegratedSecurityService.java     |   35 +-
 .../security/SecurableCommunicationChannel.java |   13 +-
 .../internal/security/SecurityService.java      |    2 -
 .../internal/statistics/SampleCollector.java    |    4 +-
 .../internal/statistics/StatArchiveHandler.java |    8 +-
 .../internal/statistics/StatArchiveReader.java  |    4 +-
 .../internal/statistics/StatisticsMonitor.java  |   28 +-
 .../geode/internal/statistics/ValueMonitor.java |   20 +-
 .../platform/LinuxProcFsStatistics.java         |    8 +-
 .../apache/geode/internal/tcp/Connection.java   |   36 +-
 .../geode/internal/tcp/ConnectionTable.java     |    6 +-
 .../apache/geode/internal/tcp/TCPConduit.java   |   29 +-
 .../geode/internal/util/ArgumentRedactor.java   |  154 +
 .../CustomEntryConcurrentHashMap.java           |    2 +-
 .../internal/util/concurrent/FutureResult.java  |    8 +
 .../geode/management/JMXNotificationType.java   |    8 +
 .../org/apache/geode/management/JVMMetrics.java |    3 +-
 .../org/apache/geode/management/OSMetrics.java  |    3 +-
 .../geode/management/cli/CliMetaData.java       |   16 +-
 .../management/internal/FederatingManager.java  |   26 +-
 .../management/internal/JmxManagerLocator.java  |    4 +-
 .../internal/ManagementConstants.java           |    2 +
 .../internal/SystemManagementService.java       |    3 +-
 .../internal/beans/AsyncEventQueueMBean.java    |    3 +
 .../beans/AsyncEventQueueMBeanBridge.java       |    3 +
 .../internal/beans/DistributedSystemBridge.java |    4 +-
 .../internal/beans/LocatorMBeanBridge.java      |    4 +-
 .../internal/beans/ManagementAdapter.java       |   36 +
 .../internal/beans/ManagementListener.java      |    4 +
 .../internal/beans/stats/MBeanStatsMonitor.java |   61 +-
 .../cli/AbstractCliAroundInterceptor.java       |    4 +-
 .../internal/cli/CliAroundInterceptor.java      |   20 +-
 .../geode/management/internal/cli/CliUtil.java  |  164 +-
 .../management/internal/cli/CommandRequest.java |   15 +-
 .../cli/commands/AbstractCommandsSupport.java   |   23 +-
 .../internal/cli/commands/ConfigCommands.java   |   49 +-
 .../CreateAlterDestroyRegionCommands.java       |   97 +-
 .../internal/cli/commands/DataCommands.java     |    8 +-
 .../internal/cli/commands/DeployCommands.java   |   83 +-
 .../cli/commands/DiskStoreCommands.java         |   77 +-
 .../cli/commands/DurableClientCommands.java     |    8 +-
 ...xportImportClusterConfigurationCommands.java |  298 ++
 ...ExportImportSharedConfigurationCommands.java |  311 --
 .../internal/cli/commands/ExportLogCommand.java |  229 ++
 .../internal/cli/commands/FunctionCommands.java |   26 +-
 .../internal/cli/commands/IndexCommands.java    |   88 +-
 .../cli/commands/LauncherLifecycleCommands.java |   40 +-
 .../cli/commands/MiscellaneousCommands.java     |  490 +--
 .../internal/cli/commands/PDXCommands.java      |   30 +-
 .../internal/cli/commands/QueueCommands.java    |   37 +-
 .../internal/cli/commands/RegionCommands.java   |    2 +-
 .../internal/cli/commands/ShellCommands.java    |   75 +-
 .../internal/cli/commands/WanCommands.java      |  143 +-
 .../cli/functions/DataCommandFunction.java      |    2 +-
 .../cli/functions/ExportLogsFunction.java       |  221 ++
 .../ExportSharedConfigurationFunction.java      |   69 -
 .../functions/GatewaySenderDestroyFunction.java |   90 +
 .../GatewaySenderDestroyFunctionArgs.java       |   33 +
 ...ortSharedConfigurationArtifactsFunction.java |   78 -
 .../LoadSharedConfigurationFunction.java        |   64 -
 .../internal/cli/functions/LogFileFunction.java |  315 --
 .../internal/cli/functions/NetstatFunction.java |  136 +-
 .../cli/functions/RegionAlterFunction.java      |    3 +
 .../internal/cli/i18n/CliStrings.java           |   85 +-
 .../internal/cli/json/GfJsonObject.java         |   36 -
 .../internal/cli/parser/ParserUtils.java        |    2 +-
 .../cli/remote/RemoteExecutionStrategy.java     |   53 +-
 .../internal/cli/result/AbstractResultData.java |   74 +-
 .../internal/cli/result/ResultBuilder.java      |   30 -
 .../management/internal/cli/shell/Gfsh.java     |   95 +-
 .../cli/shell/GfshExecutionStrategy.java        |   64 +-
 .../cli/util/ExportLogsCacheWriter.java         |   76 +
 .../internal/cli/util/ExportLogsRepository.java |   37 +
 .../management/internal/cli/util/JsonUtil.java  |    2 +-
 .../internal/cli/util/LogExporter.java          |  150 +
 .../management/internal/cli/util/LogFilter.java |  140 +
 .../internal/cli/util/LogLevelExtractor.java    |   94 +
 .../management/internal/cli/util/MergeLogs.java |   90 +-
 .../internal/cli/util/ThreePhraseGenerator.java |   50 +
 .../SharedConfigurationWriter.java              |  184 -
 .../callbacks/ConfigurationChangeListener.java  |   70 +-
 .../configuration/domain/Configuration.java     |   84 +-
 .../configuration/functions/AddJarFunction.java |   65 -
 .../functions/AddXmlEntityFunction.java         |   58 -
 .../functions/DeleteJarFunction.java            |   65 -
 .../functions/DeleteXmlEntityFunction.java      |   63 -
 .../functions/GetAllJarsFunction.java           |   63 -
 .../functions/GetRegionNamesFunction.java       |   43 +
 .../functions/ModifyPropertiesFunction.java     |   63 -
 .../functions/RecreateCacheFunction.java        |   50 +
 .../functions/UploadJarFunction.java            |   62 +
 .../handlers/ConfigurationRequestHandler.java   |    8 +-
 ...SharedConfigurationStatusRequestHandler.java |    5 +-
 .../internal/configuration/utils/XmlUtils.java  |   43 +-
 .../internal/configuration/utils/ZipUtils.java  |   62 +-
 .../controllers/ConfigCommandsController.java   |   10 +-
 .../web/controllers/ExportLogController.java    |  101 +
 .../MiscellaneousCommandsController.java        |   68 +-
 .../controllers/ShellCommandsController.java    |    2 +
 .../web/controllers/WanCommandsController.java  |   24 +
 .../support/LoginHandlerInterceptor.java        |   33 +-
 .../internal/web/http/HttpHeader.java           |   80 +-
 .../web/shell/AbstractHttpOperationInvoker.java |   51 +-
 .../web/shell/RestHttpOperationInvoker.java     |   34 +-
 .../web/shell/SimpleHttpOperationInvoker.java   |   12 +-
 .../java/org/apache/geode/pdx/FieldType.java    |   65 +-
 .../org/apache/geode/pdx/JSONFormatter.java     |  141 +-
 .../org/apache/geode/pdx/internal/EnumInfo.java |    4 +
 .../geode/pdx/internal/PdxInstanceImpl.java     |    5 +-
 .../pdx/internal/PdxInstanceInputStream.java    |  111 -
 .../geode/pdx/internal/PdxReaderImpl.java       |   33 +-
 .../org/apache/geode/pdx/internal/PdxType.java  |    6 +-
 .../pdx/internal/PeerTypeRegistration.java      |   15 +
 .../apache/geode/pdx/internal/TypeRegistry.java |    5 +-
 .../pdx/internal/json/JSONToPdxMapper.java      |   62 +
 .../pdx/internal/json/PdxInstanceHelper.java    |   14 +-
 .../internal/json/PdxInstanceSortedHelper.java  |  381 ++
 .../geode/pdx/internal/json/PdxListHelper.java  |    2 +-
 .../membership/gms/messenger/jgroups-config.xml |  142 +-
 .../apache/geode/SystemFailureJUnitTest.java    |    2 +-
 ...ventQueueEvictionAndExpirationJUnitTest.java |    2 +-
 .../client/ClientCacheFactoryJUnitTest.java     |   17 +-
 .../AutoConnectionSourceImplJUnitTest.java      |    8 +-
 .../internal/LocatorLoadBalancingDUnitTest.java |    6 +-
 .../cache/client/internal/LocatorTestBase.java  |   26 +-
 ...ientExecutorSubmitTaskWithExceptionTest.java |   61 +
 .../management/MemoryThresholdsDUnitTest.java   |    6 +
 .../BaseLineAndCompareQueryPerfJUnitTest.java   |    5 +-
 .../apache/geode/cache/query/BugJUnitTest.java  |    5 -
 .../cache/query/LocalQueryServiceJUnitTest.java |   97 +
 .../geode/cache/query/QueryJUnitTest.java       |   52 +
 .../geode/cache/query/QueryTestUtils.java       |   30 +-
 .../geode/cache/query/RegionJUnitTest.java      |   38 +-
 .../cache/query/TypedIteratorJUnitTest.java     |    4 -
 .../query/cq/dunit/CqQueryTestListener.java     |    2 +-
 .../geode/cache/query/data/Instrument.java      |   60 +
 .../geode/cache/query/data/TradingLine.java     |   41 +
 .../dunit/QueryIndexUsingXMLDUnitTest.java      |   31 +-
 .../query/dunit/QueryUsingPoolDUnitTest.java    |    2 +-
 .../cache/query/dunit/RemoteQueryDUnitTest.java |    2 +-
 .../query/dunit/SelectStarQueryDUnitTest.java   |    4 +-
 .../query/functional/FunctionJUnitTest.java     |    2 +-
 .../query/functional/INOperatorJUnitTest.java   |   14 -
 .../functional/IUM6Bug32345ReJUnitTest.java     |    9 +-
 .../cache/query/functional/IUMJUnitTest.java    |    1 -
 .../IUMRCompositeIteratorJUnitTest.java         |    2 -
 ...ependentOperandsInWhereClause2JUnitTest.java |    2 -
 .../functional/IndexCreationJUnitTest.java      |   62 +-
 .../IndexMaintenanceAsynchJUnitTest.java        |   93 +-
 .../functional/IndexOnEntrySetJUnitTest.java    |   89 +-
 .../functional/IndexOperatorJUnitTest.java      |    3 -
 .../IndexPrimaryKeyUsageJUnitTest.java          |   33 +-
 .../IndexUsageInNestedQueryJUnitTest.java       |    6 +-
 .../IndexUseMultFrmSnglCondJUnitTest.java       |   10 +-
 ...ndexWithSngleFrmAndMultCondQryJUnitTest.java |   30 +-
 .../functional/IteratorTypeDefEmpJUnitTest.java |    1 -
 .../functional/IteratorTypeDefJUnitTest.java    |    4 -
 .../IteratorTypeDefaultTypesJUnitTest.java      |   13 -
 .../query/functional/NestedQueryJUnitTest.java  |   23 +-
 .../functional/StructMemberAccessJUnitTest.java |   10 +-
 .../TestNewFunctionSSorRSIntegrationTest.java   |    9 +-
 .../CompiledAggregateFunctionJUnitTest.java     |    2 +-
 .../CompiledJunctionInternalsJUnitTest.java     |    2 +-
 .../query/internal/QCompilerJUnitTest.java      |    2 +-
 .../SelectResultsComparatorJUnitTest.java       |    2 +-
 .../index/IndexMaintainceJUnitTest.java         |    1 -
 .../MapRangeIndexMaintenanceJUnitTest.java      |   67 +
 .../internal/index/RangeIndexAPIJUnitTest.java  |    2 +-
 .../query/internal/types/TypeUtilTest.java      |    2 +-
 .../partitioned/PRInvalidQueryJUnitTest.java    |   51 -
 .../geode/cache/snapshot/RegionGenerator.java   |    7 +-
 .../geode/cache/snapshot/SnapshotDUnitTest.java |  208 +-
 .../apache/geode/cache30/Bug44418JUnitTest.java |    4 +-
 .../cache30/ClientMembershipDUnitTest.java      |    2 +-
 .../geode/cache30/ClientServerCCEDUnitTest.java |  123 +-
 .../geode/cache30/ReconnectDUnitTest.java       |  161 +-
 .../AbstractLauncherIntegrationTestCase.java    |   16 +-
 ...tractLocatorLauncherIntegrationTestCase.java |    4 +-
 .../distributed/DistributedSystemDUnitTest.java |  525 ++-
 .../geode/distributed/LocatorDUnitTest.java     |  148 +-
 .../geode/distributed/LocatorJUnitTest.java     |   80 +-
 .../LocatorUDPSecurityDUnitTest.java            |    2 +-
 .../geode/distributed/ServerLauncherTest.java   |   11 -
 ...faultPropertiesGeneratorIntegrationTest.java |  128 +
 .../internal/DistributionManagerDUnitTest.java  |   80 +-
 .../InternalDistributedSystemJUnitTest.java     |    3 -
 .../internal/SharedConfigurationJUnitTest.java  |   56 -
 .../GemFireDeadlockDetectorDUnitTest.java       |   75 +-
 .../internal/locks/CollaborationJUnitTest.java  |  615 ---
 .../membership/MembershipJUnitTest.java         |   93 +-
 .../internal/membership/NetViewJUnitTest.java   |   16 +
 .../auth/AbstractGMSAuthenticatorTestCase.java  |   15 +-
 .../gms/fd/GMSHealthMonitorJUnitTest.java       |    2 +-
 .../locator/GMSLocatorRecoveryJUnitTest.java    |    2 +-
 .../gms/membership/GMSJoinLeaveJUnitTest.java   |   67 +-
 .../internal/tcpserver/TcpServerJUnitTest.java  |    6 +-
 .../apache/geode/disttx/PRDistTXDUnitTest.java  |   10 +-
 .../disttx/PRDistTXWithVersionsDUnitTest.java   |   10 +-
 .../geode/internal/AvailablePortHelper.java     |   64 +-
 .../AvailablePortHelperIntegrationTest.java     |  264 ++
 .../internal/DataSerializableJUnitTest.java     |   64 +-
 .../geode/internal/FileUtilJUnitTest.java       |  101 -
 .../GemFireVersionIntegrationJUnitTest.java     |   50 -
 ...ernalDataSerializerQuickcheckStringTest.java |   63 +
 .../geode/internal/JarDeployerDUnitTest.java    |  260 +-
 .../internal/JarDeployerIntegrationTest.java    |  183 +
 .../org/apache/geode/internal/JavaExec.java     |   71 -
 .../org/apache/geode/internal/LongBuffer.java   |   96 -
 .../geode/internal/PdxDeleteFieldDUnitTest.java |   30 +-
 .../geode/internal/PdxDeleteFieldJUnitTest.java |   32 +-
 .../geode/internal/PdxRenameDUnitTest.java      |   30 +-
 .../geode/internal/PdxRenameJUnitTest.java      |   20 +-
 ...hreadPoolExecutorWithKeepAliveJUnitTest.java |    2 +-
 .../apache/geode/internal/VersionJUnitTest.java |    8 +
 .../geode/internal/cache/BackupDUnitTest.java   |  113 +-
 .../geode/internal/cache/BackupJUnitTest.java   |   58 +-
 .../internal/cache/ClearTXLockingDUnitTest.java |    3 +
 .../cache/ClientServerTransactionDUnitTest.java |  134 +-
 .../internal/cache/ColocatedPRJUnitTest.java    |   47 +
 .../cache/DiskLruRegRecoveryJUnitTest.java      |  294 ++
 .../cache/DiskRegRecoveryJUnitTest.java         |   10 +-
 .../cache/DiskRegionAsyncRecoveryJUnitTest.java |   28 +-
 .../internal/cache/DiskRegionHelperFactory.java |   26 +
 .../internal/cache/DiskRegionProperties.java    |   12 +-
 .../internal/cache/DiskRegionTestingBase.java   |   36 +-
 .../internal/cache/EntryEventImplTest.java      |    2 +-
 .../internal/cache/EvictionStatsDUnitTest.java  |   25 +
 ...eAndForgetFunctionOnAllServersDUnitTest.java |    2 +-
 .../cache/FixedPRSinglehopDUnitTest.java        |   50 +-
 .../internal/cache/GemFireCacheImplTest.java    |    2 +-
 .../cache/IncrementalBackupDUnitTest.java       |  167 +-
 .../MultipleOplogsRollingFeatureJUnitTest.java  |    2 +-
 .../cache/NetSearchMessagingDUnitTest.java      |   11 +-
 .../geode/internal/cache/OplogFlushTest.java    |  169 +
 .../geode/internal/cache/OplogJUnitTest.java    |    2 +-
 .../geode/internal/cache/OplogRVVJUnitTest.java |   42 +-
 .../cache/PartitionListenerDUnitTest.java       |  166 +-
 .../PartitionedRegionEvictionDUnitTest.java     |    7 +
 .../cache/PartitionedRegionQueryDUnitTest.java  |  239 +-
 .../PartitionedRegionSingleHopDUnitTest.java    |    2 +-
 .../cache/PartitionedRegionStatsJUnitTest.java  |   25 +-
 .../cache/PartitionedRegionTestHelper.java      |   11 +-
 .../PersistentPartitionedRegionJUnitTest.java   |  163 +-
 .../internal/cache/SingleHopStatsDUnitTest.java |    2 +-
 .../geode/internal/cache/TXManagerImplTest.java |    2 +-
 .../cache/execute/PRTransactionDUnitTest.java   |  189 +-
 .../extension/mock/MockExtensionCommands.java   |   33 +-
 .../ha/BlockingHARegionQueueJUnitTest.java      |    2 +-
 .../cache/ha/HARegionQueueJUnitTest.java        |    2 +-
 .../cache/locks/TXLockServiceDUnitTest.java     |    2 +-
 ...tentColocatedPartitionedRegionDUnitTest.java |   57 +-
 .../PersistentPartitionedRegionDUnitTest.java   |    2 +-
 .../PersistentPartitionedRegionTestBase.java    |   33 +-
 .../cache/partitioned/ShutdownAllDUnitTest.java |    2 +-
 .../fixed/FixedPartitioningTestBase.java        |   40 +-
 .../persistence/BackupInspectorJUnitTest.java   |   18 +-
 .../PersistentReplicatedTestBase.java           |   26 +-
 .../RollingUpgrade2DUnitTest.java               | 1817 +++++++++
 .../rollingupgrade/RollingUpgradeDUnitTest.java | 1056 +++++
 .../tier/sockets/AcceptorImplDUnitTest.java     |  248 ++
 .../sockets/ClientInterestNotifyDUnitTest.java  |    2 +-
 .../ClientServerForceInvalidateDUnitTest.java   |    2 +-
 .../sockets/ClientServerMiscBCDUnitTest.java    |   49 +
 .../tier/sockets/ClientServerMiscDUnitTest.java |   95 +-
 .../ClientServerMiscSelectorDUnitTest.java      |   11 +-
 .../DurableClientQueueSizeDUnitTest.java        |  127 +-
 .../cache/tier/sockets/HABug36738DUnitTest.java |    4 +-
 .../sockets/HAStartupAndFailoverDUnitTest.java  |    2 +-
 .../cache/tier/sockets/HandShakeTest.java       |   52 +
 .../tier/sockets/InterestListDUnitTest.java     |   99 +
 .../tier/sockets/MessageIdExtractorTest.java    |   83 +
 .../tier/sockets/ServerConnectionTest.java      |  124 +
 .../sockets/UpdatePropagationDUnitTest.java     |    2 +-
 .../tier/sockets/command/CreateRegionTest.java  |    8 -
 .../tier/sockets/command/DestroyRegionTest.java |    4 -
 .../geode/internal/cache/wan/QueueListener.java |    4 +
 ...atewaySenderFlushedCoordinatorJUnitTest.java |   62 +
 .../asyncqueue/AsyncEventListenerDUnitTest.java |    4 +-
 .../AsyncEventQueueValidationsJUnitTest.java    |    2 +-
 .../ParallelGatewaySenderQueueJUnitTest.java    |   21 +
 ...atewaySenderFlushedCoordinatorJUnitTest.java |  124 +
 ...ildrenRollingFileHandlerIntegrationTest.java |   96 +
 .../internal/lang/SystemUtilsJUnitTest.java     |   78 +-
 .../logging/log4j/Log4J2PerformanceTest.java    |   27 +-
 .../log4j/LogWriterLoggerPerformanceTest.java   |   27 +-
 .../log4j/custom/CustomConfiguration.java       |   10 +-
 .../net/SSLConfigurationFactoryJUnitTest.java   |  111 +-
 .../internal/net/SSLSocketIntegrationTest.java  |   51 +-
 .../offheap/OutOfOffHeapMemoryDUnitTest.java    |    2 +-
 ...leProcessControllerIntegrationJUnitTest.java |    2 +-
 .../DiskSpaceLimitIntegrationTest.java          |  245 +-
 .../internal/statistics/FakeValueMonitor.java   |   37 +
 .../GemFireStatSamplerIntegrationTest.java      |    2 +
 .../SimpleStatSamplerIntegrationTest.java       |   25 +-
 .../StatArchiveHandlerIntegrationTest.java      |  243 ++
 ...veWithMissingResourceTypeRegressionTest.java |    3 +-
 .../statistics/StatSamplerIntegrationTest.java  |    2 +-
 .../statistics/StatisticsDistributedTest.java   |    2 +-
 .../geode/internal/tcp/ConnectionJUnitTest.java |    3 +-
 .../util/ArgumentRedactorJUnitTest.java         |  125 +
 .../util/concurrent/FutureResultJUnitTest.java  |   79 +
 .../management/CacheManagementDUnitTest.java    | 1008 +++--
 .../management/ClientHealthStatsDUnitTest.java  |  576 ++-
 .../management/CompositeTypeTestDUnitTest.java  |  190 +-
 .../ConnectToLocatorSSLDUnitTest.java           |   53 +-
 .../management/DLockManagementDUnitTest.java    |  547 +--
 .../management/DiskManagementDUnitTest.java     |  787 ++--
 .../management/DistributedSystemDUnitTest.java  |  998 ++---
 .../geode/management/JMXMBeanDUnitTest.java     |  380 +-
 .../management/LocatorManagementDUnitTest.java  |   79 +-
 .../geode/management/ManagementTestBase.java    |  544 +--
 .../geode/management/ManagementTestRule.java    |  445 +++
 .../org/apache/geode/management/Manager.java    |   29 +
 .../org/apache/geode/management/Member.java     |   29 +
 .../management/OffHeapManagementDUnitTest.java  |  347 +-
 .../geode/management/QueryDataDUnitTest.java    | 1309 +++----
 .../management/RegionManagementDUnitTest.java   | 1807 ++++-----
 ...ersalMembershipListenerAdapterDUnitTest.java |   60 +-
 .../stats/DistributedSystemStatsDUnitTest.java  |  132 +-
 .../beans/stats/MBeanStatsMonitorTest.java      |  117 +
 .../AbstractCliAroundInterceptorJUnitTest.java  |    5 +-
 .../internal/cli/CliUtilDUnitTest.java          |   33 +-
 .../internal/cli/CommandRequestTest.java        |   16 +-
 .../management/internal/cli/HeadlessGfsh.java   |   34 +-
 .../cli/HeadlessGfshIntegrationTest.java        |   69 +-
 .../internal/cli/NetstatDUnitTest.java          |  119 +
 .../cli/commands/CliCommandTestBase.java        |   41 +-
 .../cli/commands/ConfigCommandsDUnitTest.java   |   91 +-
 ...eateAlterDestroyRegionCommandsDUnitTest.java |  277 +-
 .../cli/commands/DeployCommandsDUnitTest.java   |  105 +-
 .../commands/DiskStoreCommandsDUnitTest.java    |   81 +-
 .../cli/commands/ExportLogsDUnitTest.java       |  342 ++
 .../ExportLogsInterceptorJUnitTest.java         |   89 +
 .../ExportLogsOnServerManagerDUnit.java         |   92 +
 .../cli/commands/ExportStatsDUnitTest.java      |  153 +
 .../commands/GemfireDataCommandsDUnitTest.java  |   89 +-
 .../cli/commands/IndexCommandsDUnitTest.java    |   84 +-
 ...laneousCommandsExportLogsPart1DUnitTest.java |  137 -
 ...laneousCommandsExportLogsPart2DUnitTest.java |  141 -
 ...laneousCommandsExportLogsPart3DUnitTest.java |  155 -
 ...laneousCommandsExportLogsPart4DUnitTest.java |  137 -
 .../cli/commands/QueueCommandsDUnitTest.java    |   77 +-
 .../SharedConfigurationCommandsDUnitTest.java   |  343 --
 .../cli/commands/ShowStackTraceDUnitTest.java   |  158 +-
 .../cli/commands/UserCommandsDUnitTest.java     |   10 +-
 .../DescribeDiskStoreFunctionJUnitTest.java     |   58 +-
 .../ExportLogsFunctionIntegrationTest.java      |  146 +
 .../cli/util/ExportLogsCacheWriterUnitTest.java |   46 +
 .../cli/util/LogExporterIntegrationTest.java    |  164 +
 .../internal/cli/util/LogExporterTest.java      |  145 +
 .../internal/cli/util/LogFilterTest.java        |  213 +
 .../cli/util/LogLevelExtractorTest.java         |  117 +
 .../internal/cli/util/MergeLogsDUnitTest.java   |  112 +
 .../cli/util/ThreePhraseGeneratorTest.java      |   35 +
 .../internal/configuration/ClusterConfig.java   |  203 +
 .../configuration/ClusterConfigBaseTest.java    |  127 +
 .../ClusterConfigDeployJarDUnitTest.java        |  204 +
 .../ClusterConfigDistributionDUnitTest.java     |  175 +
 .../ClusterConfigImportDUnitTest.java           |  192 +
 .../ClusterConfigStartMemberDUnitTest.java      |  103 +
 .../ClusterConfigWithSecurityDUnitTest.java     |  119 +
 .../ClusterConfigurationServiceDUnitTest.java   |  407 ++
 ...erConfigurationServiceUsingDirDUnitTest.java |  334 ++
 .../internal/configuration/ConfigGroup.java     |  116 +
 .../configuration/EventTestCacheWriter.java     |   36 +
 .../SharedConfigurationDUnitTest.java           |  441 ---
 .../SharedConfigurationTestUtils.java           |    4 +-
 .../SharedConfigurationUsingDirDUnitTest.java   |  326 --
 .../configuration/ZipUtilsJUnitTest.java        |   18 +-
 .../utils/XmlUtilsAddNewNodeJUnitTest.java      |    8 +-
 .../configuration/utils/XmlUtilsJUnitTest.java  |   18 +
 .../internal/pulse/TestClientIdsDUnitTest.java  |  320 +-
 .../pulse/TestSubscriptionsDUnitTest.java       |  288 +-
 .../CacheServerMBeanShiroJUnitTest.java         |    8 +-
 .../security/CacheServerStartupRule.java        |   29 +-
 .../security/DeployCommandsSecurityTest.java    |   12 +-
 .../security/GfshCommandsPostProcessorTest.java |   39 +-
 .../security/GfshCommandsSecurityTest.java      |   36 +-
 ...atedSecurityServiceWithIniFileJUnitTest.java |   36 +-
 .../security/JavaRmiServerNameTest.java         |   11 +-
 .../security/MemberMBeanSecurityJUnitTest.java  |   22 +-
 .../internal/security/MultiUserDUnitTest.java   |   30 +-
 .../geode/pdx/AutoSerializableJUnitTest.java    |    5 +-
 .../java/org/apache/geode/pdx/Employee.java     |   48 +-
 .../geode/pdx/JSONFormatterJUnitTest.java       |  129 +-
 .../geode/pdx/JSONPdxClientServerDUnitTest.java |   53 +-
 .../geode/pdx/PdxAttributesJUnitTest.java       |   19 +-
 .../geode/pdx/PdxClientServerDUnitTest.java     |  343 +-
 .../geode/pdx/PdxSerializableDUnitTest.java     |  215 +-
 .../geode/pdx/PdxSerializableJUnitTest.java     |   72 +-
 .../apache/geode/pdx/PdxStringJUnitTest.java    |   27 +
 .../geode/pdx/TestObjectForJSONFormatter.java   |   27 +-
 .../org/apache/geode/redis/SetsJUnitTest.java   |   14 +-
 .../security/AbstractSecureServerDUnitTest.java |   11 +-
 .../ClusterConfigWithoutSecurityDUnitTest.java  |   42 +-
 .../security/ExampleSecurityManagerTest.java    |  104 +
 ...lientExecuteFunctionAuthDistributedTest.java |   15 +-
 ...edSecurityCacheLifecycleDistributedTest.java |  131 -
 .../PDXGfshPostProcessorOnRemoteServerTest.java |    2 +-
 .../security/PDXPostProcessorDUnitTest.java     |    3 +-
 .../security/PeerAuthenticatorDUnitTest.java    |   34 +-
 ...eerSecurityWithEmbeddedLocatorDUnitTest.java |   44 +-
 .../security/SampleSecurityManagerTest.java     |  103 -
 .../SecurityClusterConfigDUnitTest.java         |   34 +-
 ...SecurityManagerCallbacksDistributedTest.java |  132 +
 .../SecurityWithoutClusterConfigDUnitTest.java  |   33 +-
 .../geode/security/SpySecurityManager.java      |    6 +-
 .../security/StartServerAuthorizationTest.java  |   58 +-
 .../geode/security/TestSecurityManager.java     |   11 +-
 .../geode/test/dunit/AsyncInvocation.java       |   56 +-
 .../geode/test/dunit/DUnitBlackboard.java       |  112 +
 .../org/apache/geode/test/dunit/DUnitEnv.java   |    4 +-
 .../java/org/apache/geode/test/dunit/Host.java  |   42 +
 .../org/apache/geode/test/dunit/Invoke.java     |   20 +-
 .../geode/test/dunit/RepeatableRunnable.java    |    3 +-
 .../test/dunit/StoppableWaitCriterion.java      |    2 +-
 .../java/org/apache/geode/test/dunit/VM.java    |   47 +-
 .../java/org/apache/geode/test/dunit/Wait.java  |   30 +-
 .../apache/geode/test/dunit/WaitCriterion.java  |    8 +-
 .../cache/internal/JUnit4CacheTestCase.java     |   15 +-
 .../internal/DUnitBlackboardDUnitTest.java      |   97 +
 .../test/dunit/internal/InternalBlackboard.java |   72 +
 .../dunit/internal/InternalBlackboardImpl.java  |  122 +
 .../internal/JUnit4DistributedTestCase.java     |   57 +-
 .../dunit/rules/DistributedDisconnectRule.java  |    4 +-
 .../DistributedRestoreSystemProperties.java     |   20 +-
 .../DistributedUseJacksonForJsonPathRule.java   |   50 +
 .../dunit/rules/GfshShellConnectionRule.java    |  163 +-
 .../apache/geode/test/dunit/rules/Locator.java  |   23 +
 .../dunit/rules/LocatorServerStartupRule.java   |  171 +-
 .../test/dunit/rules/LocatorStarterRule.java    |   83 +-
 .../dunit/rules/MBeanServerConnectionRule.java  |  101 +-
 .../apache/geode/test/dunit/rules/Member.java   |   29 +
 .../test/dunit/rules/MemberStarterRule.java     |   84 +
 .../apache/geode/test/dunit/rules/MemberVM.java |   67 +
 .../geode/test/dunit/rules/RemoteInvoker.java   |   22 +-
 .../apache/geode/test/dunit/rules/Server.java   |   27 +
 .../test/dunit/rules/ServerStarterRule.java     |  134 +-
 .../geode/test/dunit/standalone/ChildVM.java    |   10 +-
 .../test/dunit/standalone/DUnitLauncher.java    |  138 +-
 .../test/dunit/standalone/ProcessManager.java   |  132 +-
 .../dunit/standalone/StandAloneDUnitEnv.java    |   11 +-
 .../test/dunit/standalone/VersionManager.java   |  147 +
 .../standalone/VersionManagerJUnitTest.java     |   47 +
 ...hTimeoutOfWaitForOutputToMatchJUnitTest.java |   67 -
 .../golden/GoldenTestFrameworkTestSuite.java    |    6 +-
 .../geode/test/process/ProcessStreamReader.java |   15 +-
 .../org/apache/geode/util/test/TestUtil.java    |   15 +-
 .../geode/codeAnalysis/excludedClasses.txt      |    1 +
 .../sanctionedDataSerializables.txt             |   32 +-
 .../codeAnalysis/sanctionedSerializables.txt    | 1687 ++++----
 .../internal/SharedConfigurationJUnitTest.xml   |   23 -
 ...ntQueueConfiguredFromXmlUsesFilter.cache.xml |   80 +-
 ...ntQueueConfiguredFromXmlUsesFilter.cache.xml |   80 +-
 .../cli/commands/golden-help-offline.properties |   89 +-
 .../cli/commands/golden-help-online.properties  |    6 +
 .../internal/configuration/cluster-region.xml   |    2 +-
 .../utils/SharedConfigurationJUnitTest.xml      |   23 +
 .../org/apache/geode/pdx/jsonStrings/array.txt  |   42 +-
 .../apache/geode/pdx/jsonStrings/attachment.txt |   20 +-
 .../geode/pdx/jsonStrings/attachment2.txt       |   24 +-
 .../org/apache/geode/pdx/jsonStrings/book.txt   |   32 +-
 .../org/apache/geode/pdx/jsonStrings/image.txt  |   24 +-
 .../org/apache/geode/pdx/jsonStrings/json1.txt  |   42 +-
 .../org/apache/geode/pdx/jsonStrings/json10.txt |   38 +-
 .../org/apache/geode/pdx/jsonStrings/json11.txt |   62 +-
 .../org/apache/geode/pdx/jsonStrings/json12.txt |   60 +-
 .../org/apache/geode/pdx/jsonStrings/json13.txt |   80 +-
 .../org/apache/geode/pdx/jsonStrings/json14.txt |   28 +-
 .../org/apache/geode/pdx/jsonStrings/json16.txt |   58 +-
 .../apache/geode/pdx/jsonStrings/json16_2.txt   |   60 +-
 .../org/apache/geode/pdx/jsonStrings/json17.txt |   50 +-
 .../org/apache/geode/pdx/jsonStrings/json18.txt |  138 +-
 .../org/apache/geode/pdx/jsonStrings/json19.txt |   32 +-
 .../org/apache/geode/pdx/jsonStrings/json2.txt  |   20 +-
 .../org/apache/geode/pdx/jsonStrings/json20.txt |   68 +-
 .../org/apache/geode/pdx/jsonStrings/json21.txt |   68 +-
 .../org/apache/geode/pdx/jsonStrings/json22.txt |   68 +-
 .../org/apache/geode/pdx/jsonStrings/json23.txt |   42 +-
 .../org/apache/geode/pdx/jsonStrings/json24.txt |   26 +-
 .../org/apache/geode/pdx/jsonStrings/json25.txt |   62 +-
 .../org/apache/geode/pdx/jsonStrings/json26.txt |   22 +-
 .../org/apache/geode/pdx/jsonStrings/json27.txt |   46 +-
 .../org/apache/geode/pdx/jsonStrings/json28.txt |  168 +-
 .../org/apache/geode/pdx/jsonStrings/json29.txt |   20 +-
 .../org/apache/geode/pdx/jsonStrings/json3.txt  |   50 +-
 .../org/apache/geode/pdx/jsonStrings/json31.txt |   16 +-
 .../org/apache/geode/pdx/jsonStrings/json4.txt  |  174 +-
 .../org/apache/geode/pdx/jsonStrings/json5.txt  |   52 +-
 .../org/apache/geode/pdx/jsonStrings/json6.txt  |   20 +-
 .../org/apache/geode/pdx/jsonStrings/json7.txt  |   62 +-
 .../org/apache/geode/pdx/jsonStrings/json8.txt  |  104 +-
 .../org/apache/geode/pdx/jsonStrings/json9.txt  |  152 +-
 .../pdx/jsonStrings/jsonListInsideList.txt      |   94 +-
 .../apache/geode/pdx/jsonStrings/jsonMongo.txt  |   16 +-
 .../pdx/jsonStrings/jsonMongoSingleQuote.tx0    |   16 +-
 .../geode/pdx/jsonStrings/jsonProductdb.txt     |   62 +-
 .../geode/pdx/jsonStrings/json_google.txt       |   62 +-
 .../geode/pdx/jsonStrings/jsoncustomer.txt      |   44 +-
 .../geode/pdx/jsonStrings/jsonemptyobject.txo   |   84 +-
 .../geode/pdx/jsonStrings/jsonemptyobject.txt   |   42 +-
 .../geode/pdx/jsonStrings/jsonfacebook.txt      |   86 +-
 .../apache/geode/pdx/jsonStrings/jsonfeed.txt   |   62 +-
 .../apache/geode/pdx/jsonStrings/jsonfeed2.txt  |   90 +-
 .../geode/pdx/jsonStrings/jsonflicker.txt       |   38 +-
 .../apache/geode/pdx/jsonStrings/jsoniphone.txt |  152 +-
 .../pdx/jsonStrings/jsonsolrwithcomment.tx0     |   54 +-
 .../pdx/jsonStrings/jsonsolrwithcomment.txt     |   54 +-
 .../geode/pdx/jsonStrings/jsontwitter1.txt      |  856 ++--
 .../geode/pdx/jsonStrings/jsontwitter2.txt      | 1144 +++---
 .../geode/pdx/jsonStrings/jsontwitter3.txt      |  136 +-
 .../apache/geode/pdx/jsonStrings/jsonyahoo.txt  |   18 +-
 .../geode/pdx/jsonStrings/jsonyoutube.txt       |  104 +-
 .../apache/geode/pdx/jsonStrings/linkden1.txt   |   32 +-
 .../org/apache/geode/pdx/jsonStrings/odata.txt  |   28 +-
 .../org/apache/geode/pdx/jsonStrings/odata2.txt |   32 +-
 .../cache/client/internal/GetDurableCQsOp.java  |    2 +-
 .../query/cq/dunit/PrCqUsingPoolDUnitTest.java  |   17 +-
 .../sockets/DurableClientSimpleDUnitTest.java   |  250 +-
 .../cli/commands/ClientCommandsDUnitTest.java   |    2 +-
 .../geode/security/CQClientAuthDunitTest.java   |   14 +-
 .../security/CQPDXPostProcessorDUnitTest.java   |    2 +-
 .../sanctionedDataSerializables.txt             |    2 +-
 .../codeAnalysis/sanctionedSerializables.txt    |    2 +-
 geode-docs/CONTRIBUTE.md                        |   17 +
 geode-docs/about_geode.html.md.erb              |    4 +-
 .../setting_distributed_properties.html.md.erb  |    7 +-
 .../deploying_application_jars.html.md.erb      |    2 +-
 .../running/running_the_locator.html.md.erb     |    2 +-
 .../starting_up_shutting_down.html.md.erb       |    2 +-
 .../auto_serialization.html.md.erb              |   11 +-
 .../jsonformatter_pdxinstances.html.md.erb      |   13 +-
 ...ache_transactions_by_region_type.html.md.erb |   10 +-
 .../transactions/chapter_overview.html.md.erb   |    6 +-
 ...data_location_cache_transactions.html.md.erb |   15 +-
 .../15_minute_quickstart_gfsh.html.md.erb       |    6 +-
 .../getting_started/book_intro.html.md.erb      |    2 +-
 .../installation/install_standalone.html.md.erb |   16 +-
 .../getting_started/product_intro.html.md.erb   |   46 +-
 .../querying_quick_reference.html.md.erb        |    2 -
 geode-docs/images/Statistics-implementation.png |  Bin 0 -> 28057 bytes
 geode-docs/images/Statistics-interfaces.png     |  Bin 0 -> 28312 bytes
 geode-docs/images/statistics-1.gif              |  Bin 8644 -> 0 bytes
 .../developing_persistence_and_overflow.svg     |    4 +-
 .../autoreconnect/member-reconnect.html.md.erb  |   28 +-
 .../managing_disk_stores_cmds.html.md.erb       |    2 +-
 .../logging/configuring_log4j2.html.md.erb      |    6 +-
 .../monitor_tune/chapter_overview.html.md.erb   |    2 +-
 .../gemfire_performance_on_vsphere.html.md.erb  |   64 -
 ...erformance_on_vsphere_guidelines.html.md.erb |  136 -
 .../performance_on_vsphere.html.md.erb          |  135 +
 .../authentication_examples.html.md.erb         |    2 +-
 .../security/authorization_example.html.md.erb  |    2 +-
 .../implementing_authorization.html.md.erb      |    4 +-
 .../managing/security/ssl_example.html.md.erb   |    2 +-
 .../application_defined_statistics.html.md.erb  |   28 +-
 geode-docs/prereq_and_install.html.md.erb       |    2 +-
 .../topics/gemfire_properties.html.md.erb       |  100 +-
 .../region_shortcuts_reference.html.md.erb      |    2 +-
 .../rest_apps/delete_named_query.html.md.erb    |    4 +-
 .../get_execute_adhoc_query.html.md.erb         |   12 +
 geode-docs/rest_apps/get_queries.html.md.erb    |   30 +-
 .../rest_apps/post_create_query.html.md.erb     |   16 +-
 .../rest_apps/post_execute_query.html.md.erb    |   18 +-
 .../rest_apps/put_update_query.html.md.erb      |   34 +-
 .../rest_apps/troubleshooting.html.md.erb       |    5 +-
 geode-docs/tools_modules/book_intro.html.md.erb |    4 +-
 .../gfsh/chapter_overview.html.md.erb           |   10 +-
 .../gfsh/command-pages/connect.html.md.erb      |    2 +-
 .../gfsh/command-pages/history.html.md.erb      |    4 +-
 .../gfsh/command-pages/start.html.md.erb        |   15 +-
 .../gfsh/command_scripting.html.md.erb          |    2 +-
 .../gfsh/getting_started_gfsh.html.md.erb       |    3 +-
 .../tools_modules/gfsh/tour_of_gfsh.html.md.erb |   15 +-
 .../tc_installing_the_module.html.md.erb        |   10 -
 .../tomcat_installing_the_module.html.md.erb    |    2 +-
 .../lucene_integration.html.md.erb              |    4 +-
 ...nt_server_example_configurations.html.md.erb |    2 +-
 geode-examples/.gitignore                       |    1 -
 geode-examples/README.md                        |   72 -
 geode-examples/build.gradle                     |   59 -
 geode-examples/gradle.properties                |   21 -
 .../gradle/wrapper/gradle-wrapper.jar           |  Bin 53639 -> 0 bytes
 .../gradle/wrapper/gradle-wrapper.properties    |    6 -
 geode-examples/gradlew                          |  160 -
 geode-examples/gradlew.bat                      |   90 -
 geode-examples/replicated/.gitignore            |    2 -
 geode-examples/replicated/README.md             |   45 -
 geode-examples/replicated/build.gradle          |   20 -
 geode-examples/replicated/scripts/.gitignore    |    2 -
 geode-examples/replicated/scripts/pidkiller.sh  |   35 -
 geode-examples/replicated/scripts/setEnv.sh     |   33 -
 geode-examples/replicated/scripts/startAll.sh   |   45 -
 geode-examples/replicated/scripts/stopAll.sh    |   28 -
 .../geode/examples/replicated/BaseClient.java   |   63 -
 .../geode/examples/replicated/Consumer.java     |   40 -
 .../geode/examples/replicated/Producer.java     |   40 -
 .../geode/examples/replicated/ConsumerTest.java |   71 -
 .../geode/examples/replicated/ProducerTest.java |   70 -
 .../examples/replicated/ReplicatedTest.java     |  164 -
 geode-examples/settings.gradle                  |   21 -
 .../apache/geode/example/utils/ShellUtil.java   |  106 -
 geode-json/build.gradle                         |   20 +
 geode-json/src/main/java/org/json/CDL.java      |  272 --
 geode-json/src/main/java/org/json/Cookie.java   |  162 -
 .../src/main/java/org/json/CookieList.java      |   87 -
 geode-json/src/main/java/org/json/HTTP.java     |  185 -
 .../src/main/java/org/json/HTTPTokener.java     |   77 -
 geode-json/src/main/java/org/json/JSON.java     |  112 +
 .../src/main/java/org/json/JSONArray.java       | 1137 +++---
 .../src/main/java/org/json/JSONException.java   |   62 +-
 geode-json/src/main/java/org/json/JSONML.java   |  454 ---
 .../src/main/java/org/json/JSONObject.java      | 1915 ++++-----
 .../src/main/java/org/json/JSONStringer.java    |  492 ++-
 .../src/main/java/org/json/JSONTokener.java     |  852 ++--
 .../src/main/java/org/json/JSONWriter.java      |  321 --
 geode-json/src/main/java/org/json/XML.java      |  504 ---
 .../src/main/java/org/json/XMLTokener.java      |  362 --
 geode-json/src/test/resources/sample-01.json    |  227 ++
 geode-junit/build.gradle                        |    1 +
 .../categories/BackwardCompatibilityTest.java   |   22 +
 .../junit/rules/UseJacksonForJsonPathRule.java  |  128 +
 .../SerializableExternalResource.java           |   22 +
 .../serializable/SerializableStatement.java     |   25 +
 geode-lucene/build.gradle                       |    2 +
 .../apache/geode/cache/lucene/LuceneIndex.java  |   26 +-
 .../apache/geode/cache/lucene/LuceneQuery.java  |   46 +-
 .../cache/lucene/LuceneQueryException.java      |    2 +-
 .../geode/cache/lucene/LuceneQueryFactory.java  |   74 +-
 .../geode/cache/lucene/LuceneQueryProvider.java |   24 +-
 .../geode/cache/lucene/LuceneResultStruct.java  |   25 +-
 .../geode/cache/lucene/LuceneService.java       |  170 +-
 .../cache/lucene/LuceneServiceProvider.java     |    2 +-
 .../lucene/PageableLuceneQueryResults.java      |   22 +-
 .../AbstractPartitionedRepositoryManager.java   |   50 +-
 .../internal/DestroyLuceneIndexMessage.java     |  109 +
 .../lucene/internal/IndexRepositoryFactory.java |   89 +-
 .../lucene/internal/InternalLuceneIndex.java    |    5 +
 .../lucene/internal/LuceneBucketListener.java   |   60 +
 .../lucene/internal/LuceneEventListener.java    |   45 +-
 .../internal/LuceneExceptionObserver.java       |   25 +
 .../LuceneIndexForPartitionedRegion.java        |  141 +-
 .../cache/lucene/internal/LuceneIndexImpl.java  |   90 +-
 .../cache/lucene/internal/LuceneIndexStats.java |   40 +-
 .../lucene/internal/LuceneQueryFactoryImpl.java |   16 +-
 .../cache/lucene/internal/LuceneQueryImpl.java  |   33 +-
 .../cache/lucene/internal/LuceneRawIndex.java   |    2 +
 .../lucene/internal/LuceneResultStructImpl.java |   42 +-
 .../lucene/internal/LuceneServiceImpl.java      |  105 +-
 .../PageableLuceneQueryResultsImpl.java         |   23 +-
 .../internal/PartitionedRepositoryManager.java  |    8 +-
 .../internal/RawIndexRepositoryFactory.java     |   13 +-
 .../internal/RawLuceneRepositoryManager.java    |   26 +-
 .../lucene/internal/cli/LuceneCliStrings.java   |   28 +-
 .../cli/LuceneFunctionSerializable.java         |   36 +
 .../internal/cli/LuceneIndexCommands.java       |  146 +-
 .../lucene/internal/cli/LuceneIndexDetails.java |   33 +-
 .../lucene/internal/cli/LuceneIndexInfo.java    |   15 +-
 .../lucene/internal/cli/LuceneQueryInfo.java    |   15 +-
 .../functions/LuceneDescribeIndexFunction.java  |    9 +-
 .../functions/LuceneDestroyIndexFunction.java   |   57 +
 .../cli/functions/LuceneListIndexFunction.java  |    6 +-
 .../internal/directory/FileIndexInput.java      |    1 +
 .../internal/directory/RegionDirectory.java     |   34 +-
 .../internal/distributed/LuceneFunction.java    |  124 -
 .../distributed/LuceneQueryFunction.java        |  160 +
 .../TopEntriesFunctionCollector.java            |   43 +-
 .../distributed/WaitUntilFlushedFunction.java   |  103 +
 .../WaitUntilFlushedFunctionContext.java        |   93 +
 .../internal/distributed/package-info.java      |    4 +-
 .../cache/lucene/internal/filesystem/File.java  |    5 +-
 .../lucene/internal/filesystem/FileSystem.java  |   67 +-
 .../internal/management/LuceneIndexMetrics.java |  190 -
 .../management/LuceneIndexStatsMonitor.java     |    2 +-
 .../management/LuceneServiceBridge.java         |    2 +-
 .../internal/management/LuceneServiceMBean.java |    2 +
 .../management/LuceneServiceMXBean.java         |   58 -
 .../partition/BucketTargetingFixedResolver.java |   79 +
 .../internal/partition/BucketTargetingMap.java  |  118 +
 .../partition/BucketTargetingResolver.java      |   39 +
 .../repository/IndexRepositoryImpl.java         |   44 +-
 .../internal/repository/RepositoryManager.java  |    5 +
 .../HeterogeneousLuceneSerializer.java          |    4 +
 .../internal/results/LuceneGetPageFunction.java |   83 +
 .../internal/results/MapResultCollector.java    |   58 +
 .../lucene/internal/results/PageEntry.java      |   98 +
 .../lucene/internal/results/PageResults.java    |   60 +
 .../internal/xml/LuceneIndexCreation.java       |    5 +-
 .../lucene/management/LuceneIndexMetrics.java   |  294 ++
 .../lucene/management/LuceneServiceMXBean.java  |   58 +
 .../apache/geode/cache/lucene/package-info.java |    8 +-
 .../geode/cache/lucene/LuceneDUnitTest.java     |  122 +-
 .../lucene/LuceneIndexCreationDUnitTest.java    |  197 +-
 .../LuceneIndexCreationIntegrationTest.java     |    2 +-
 .../LuceneIndexCreationOnFixedPRDUnitTest.java  |   51 +
 ...IndexCreationPersistenceIntegrationTest.java |   46 +-
 .../lucene/LuceneIndexDestroyDUnitTest.java     |  476 +++
 .../LuceneIndexMaintenanceIntegrationTest.java  |   53 +-
 .../cache/lucene/LuceneQueriesAccessorBase.java |  211 +
 .../geode/cache/lucene/LuceneQueriesBase.java   |  208 -
 .../lucene/LuceneQueriesClientDUnitTest.java    |   18 +-
 .../cache/lucene/LuceneQueriesDUnitTest.java    |  142 +
 .../lucene/LuceneQueriesIntegrationTest.java    |   63 +-
 .../geode/cache/lucene/LuceneQueriesPRBase.java |  198 -
 .../lucene/LuceneQueriesPeerPRDUnitTest.java    |   41 -
 .../LuceneQueriesPeerPROverflowDUnitTest.java   |   44 -
 .../LuceneQueriesPeerPRRedundancyDUnitTest.java |  144 -
 ...LuceneQueriesPersistenceIntegrationTest.java |    3 +-
 .../geode/cache/lucene/PaginationDUnitTest.java |  210 +
 .../geode/cache/lucene/RebalanceDUnitTest.java  |  197 +
 .../RebalanceWithRedundancyDUnitTest.java       |  180 +
 .../internal/LuceneEventListenerJUnitTest.java  |   26 +
 .../lucene/internal/LuceneIndexFactorySpy.java  |   80 +
 .../LuceneIndexForPartitionedRegionTest.java    |   54 +-
 .../internal/LuceneIndexImplJUnitTest.java      |   32 -
 .../LuceneIndexRecoveryHAIntegrationTest.java   |   14 +-
 .../internal/LuceneIndexStatsJUnitTest.java     |   14 +
 .../LuceneQueryFactoryImplJUnitTest.java        |    3 -
 .../internal/LuceneQueryImplJUnitTest.java      |   58 +-
 .../LuceneServiceImplIntegrationTest.java       |   15 +-
 .../internal/LuceneServiceImplJUnitTest.java    |   30 +-
 ...PageableLuceneQueryResultsImplJUnitTest.java |   39 +-
 .../PartitionedRepositoryManagerJUnitTest.java  |   35 +-
 .../RawLuceneRepositoryManagerJUnitTest.java    |   41 +-
 .../cli/LuceneIndexCommandsDUnitTest.java       |   56 +-
 .../cli/LuceneIndexCommandsJUnitTest.java       |   86 +-
 .../LuceneDescribeIndexFunctionJUnitTest.java   |    8 +-
 .../LuceneDestroyIndexFunctionJUnitTest.java    |   93 +
 .../LuceneListIndexFunctionJUnitTest.java       |    6 +-
 .../LuceneClusterConfigurationDUnitTest.java    |  272 +-
 .../DumpDirectoryFilesIntegrationTest.java      |    3 +-
 .../directory/RegionDirectoryJUnitTest.java     |    7 +
 .../DistributedScoringJUnitTest.java            |    2 +-
 .../LuceneFunctionContextJUnitTest.java         |   59 -
 .../distributed/LuceneFunctionJUnitTest.java    |  295 --
 .../LuceneQueryFunctionContextJUnitTest.java    |   59 +
 .../LuceneQueryFunctionJUnitTest.java           |  319 ++
 .../TopEntriesFunctionCollectorJUnitTest.java   |  137 +-
 .../WaitUntilFlushedFunctionJUnitTest.java      |  106 +
 .../filesystem/FileSystemJUnitTest.java         |   35 +-
 .../management/LuceneManagementDUnitTest.java   |   30 +-
 .../BucketTargetingFixedResolverTest.java       |   66 +
 .../partition/BucketTargetingMapTest.java       |   66 +
 .../IndexRepositoryImplJUnitTest.java           |   17 +-
 .../results/LuceneGetPageFunctionJUnitTest.java |   65 +
 .../internal/results/PageEntryJUnitTest.java    |   93 +
 .../internal/results/PageResultsJUnitTest.java  |   44 +
 .../cache/lucene/test/IndexRepositorySpy.java   |   19 +-
 .../cache/lucene/test/LuceneTestUtilities.java  |  117 +-
 .../geode/cache/lucene/test/TestObject.java     |    4 +
 ...ifferentFieldAnalyzerSizesFails1.1.cache.xml |   74 +-
 ...ifferentFieldAnalyzerSizesFails1.2.cache.xml |   72 +-
 ...ifferentFieldAnalyzerSizesFails2.1.cache.xml |   72 +-
 ...ifferentFieldAnalyzerSizesFails2.2.cache.xml |   74 +-
 ...ifyDifferentFieldAnalyzersFails1.1.cache.xml |   72 +-
 ...ifyDifferentFieldAnalyzersFails1.2.cache.xml |   72 +-
 ...ifyDifferentFieldAnalyzersFails2.1.cache.xml |   74 +-
 ...ifyDifferentFieldAnalyzersFails2.2.cache.xml |   74 +-
 ...ifyDifferentFieldAnalyzersFails3.1.cache.xml |   74 +-
 ...ifyDifferentFieldAnalyzersFails3.2.cache.xml |   74 +-
 ...tTest.verifyDifferentFieldsFails.1.cache.xml |   72 +-
 ...tTest.verifyDifferentFieldsFails.2.cache.xml |   74 +-
 ...t.verifyDifferentIndexNamesFails.1.cache.xml |   72 +-
 ...t.verifyDifferentIndexNamesFails.2.cache.xml |   72 +-
 ...est.verifyDifferentIndexesFails1.1.cache.xml |   72 +-
 ...est.verifyDifferentIndexesFails1.2.cache.xml |   64 +-
 ...est.verifyDifferentIndexesFails2.1.cache.xml |   72 +-
 ...est.verifyDifferentIndexesFails2.2.cache.xml |   78 +-
 ...nDUnitTest.verifyXMLEmptyIndexList.cache.xml |   66 +-
 ...nitTest.verifyXMLMultipleIndexList.cache.xml |   78 +-
 geode-old-versions/build.gradle                 |   68 +
 geode-pulse/build.gradle                        |    1 +
 .../tools/pulse/internal/PulseAppListener.java  |   15 -
 .../internal/controllers/PulseController.java   |   75 +-
 .../tools/pulse/internal/data/Cluster.java      |   54 +-
 .../pulse/internal/data/JMXDataUpdater.java     |  168 +-
 .../tools/pulse/internal/data/Repository.java   |    4 +-
 .../geode/tools/pulse/internal/json/CDL.java    |  268 --
 .../geode/tools/pulse/internal/json/Cookie.java |  158 -
 .../tools/pulse/internal/json/CookieList.java   |   83 -
 .../geode/tools/pulse/internal/json/HTTP.java   |  181 -
 .../tools/pulse/internal/json/HTTPTokener.java  |   73 -
 .../tools/pulse/internal/json/JSONArray.java    |  864 -----
 .../pulse/internal/json/JSONException.java      |   47 -
 .../geode/tools/pulse/internal/json/JSONML.java |  450 ---
 .../tools/pulse/internal/json/JSONObject.java   | 1503 --------
 .../tools/pulse/internal/json/JSONString.java   |   34 -
 .../tools/pulse/internal/json/JSONStringer.java |   71 -
 .../tools/pulse/internal/json/JSONTokener.java  |  433 ---
 .../tools/pulse/internal/json/JSONWriter.java   |  317 --
 .../geode/tools/pulse/internal/json/README      |   68 -
 .../geode/tools/pulse/internal/json/XML.java    |  500 ---
 .../tools/pulse/internal/json/XMLTokener.java   |  358 --
 .../internal/service/ClusterMemberService.java  |    8 +-
 .../internal/service/ClusterRegionService.java  |   10 +-
 .../internal/service/ClusterRegionsService.java |   13 +-
 .../service/ClusterSelectedRegionService.java   |   18 +-
 .../internal/service/MemberDetailsService.java  |    7 +-
 .../internal/service/MemberRegionsService.java  |    9 +-
 .../src/main/resources/default.properties       |   46 +-
 .../src/main/resources/gemfire.properties       |   94 +-
 .../src/main/resources/sqlfire.properties       |   92 +-
 geode-pulse/src/main/webapp/DataBrowser.html    |    4 +-
 geode-pulse/src/main/webapp/Login.html          |    2 +-
 geode-pulse/src/main/webapp/META-INF/NOTICE     |   12 +-
 geode-pulse/src/main/webapp/MemberDetails.html  | 1206 +++---
 .../src/main/webapp/QueryStatistics.html        |    4 +-
 .../webapp/WEB-INF/mvc-dispatcher-servlet.xml   |    2 +-
 .../src/main/webapp/WEB-INF/spring-security.xml |   17 +-
 geode-pulse/src/main/webapp/WEB-INF/web.xml     |  125 +-
 geode-pulse/src/main/webapp/clusterDetail.html  | 1324 +++----
 .../main/webapp/properties/default.properties   |   42 +-
 .../webapp/properties/default_en.properties     |   42 +-
 .../main/webapp/properties/gemfire.properties   |   90 +-
 .../webapp/properties/gemfire_en.properties     |   90 +-
 .../main/webapp/properties/gemfirexd.properties |   90 +-
 .../webapp/properties/gemfirexd_en.properties   |   90 +-
 .../src/main/webapp/properties/index.properties |   36 +-
 .../main/webapp/properties/sqlfire.properties   |   88 +-
 geode-pulse/src/main/webapp/regionDetail.html   | 1104 +++---
 .../main/webapp/scripts/multiselect/prettify.js | 3044 +++++++--------
 .../webapp/scripts/pulsescript/MemberDetails.js |   27 +-
 .../scripts/pulsescript/PulseFunctions.js       |    2 +-
 .../webapp/scripts/pulsescript/clusterDetail.js |   64 +-
 .../main/webapp/scripts/pulsescript/common.js   |   23 +-
 .../scripts/pulsescript/pages/DataBrowser.js    |   22 +-
 .../pulsescript/pages/DataBrowserQuery.js       |   28 +-
 .../pages/DataBrowserQueryHistory.js            |    2 +-
 .../webapp/scripts/pulsescript/pages/Login.js   |   26 +-
 .../scripts/pulsescript/queryStatistics.js      |    9 +-
 .../webapp/scripts/pulsescript/regionView.js    |   11 +-
 .../controllers/PulseControllerJUnitTest.java   |    9 +-
 .../pulse/tests/junit/BaseServiceTest.java      |    2 -
 .../junit/ClusterSelectedRegionServiceTest.java |    4 +-
 ...ClusterSelectedRegionsMemberServiceTest.java |    2 +-
 .../junit/MemberGatewayHubServiceTest.java      |    4 +-
 .../tools/pulse/tests/rules/ServerRule.java     |    6 +-
 .../tools/pulse/tests/rules/WebDriverRule.java  |   38 +-
 .../pulse/tests/ui/PulseAnonymousUserTest.java  |   34 +-
 .../tools/pulse/tests/ui/PulseAuthTest.java     |    6 +-
 .../pulse/tests/ui/PulseAutomatedTest.java      |   12 +-
 .../geode/tools/pulse/tests/ui/PulseBase.java   |   42 +-
 .../tools/pulse/tests/ui/PulseNoAuthTest.java   |    6 +-
 .../tools/pulse/tests/ui/PulseTestUtils.java    |   54 +-
 geode-pulse/src/test/resources/test.properties  |  652 ++--
 .../util/AutoBalancerIntegrationJUnitTest.java  |    2 +-
 geode-site/.gitignore                           |    1 -
 geode-site/website/.gitignore                   |    1 -
 geode-site/website/README.md                    |  101 -
 geode-site/website/Rules                        |   72 -
 geode-site/website/build.sh                     |   18 -
 .../website/content/bootstrap/bootstrap.min.css |    9 -
 geode-site/website/content/community/index.html |  312 --
 .../website/content/css/bootflat-extensions.css |  356 --
 .../website/content/css/bootflat-square.css     |   69 -
 geode-site/website/content/css/bootflat.css     | 1559 --------
 .../website/content/css/font-awesome.min.css    |    4 -
 geode-site/website/content/css/geode-site.css   | 1612 --------
 geode-site/website/content/docs/index.html      |   47 -
 geode-site/website/content/favicon.ico          |  Bin 20805 -> 0 bytes
 geode-site/website/content/font/FontAwesome.otf |  Bin 124988 -> 0 bytes
 .../content/font/fontawesome-webfont-eot.eot    |  Bin 76518 -> 0 bytes
 .../content/font/fontawesome-webfont-svg.svg    |  685 ----
 .../content/font/fontawesome-webfont-ttf.ttf    |  Bin 152796 -> 0 bytes
 .../content/font/fontawesome-webfont-woff.woff  |  Bin 90412 -> 0 bytes
 .../content/font/fontawesome-webfont.woff2      |  Bin 71896 -> 0 bytes
 .../website/content/img/apache_geode_logo.png   |  Bin 23616 -> 0 bytes
 .../content/img/apache_geode_logo_white.png     |  Bin 22695 -> 0 bytes
 .../img/apache_geode_logo_white_small.png       |  Bin 52948 -> 0 bytes
 .../website/content/img/check_flat/default.png  |  Bin 25851 -> 0 bytes
 geode-site/website/content/img/egg-logo.png     |  Bin 9938 -> 0 bytes
 geode-site/website/content/img/github.png       |  Bin 8936 -> 0 bytes
 geode-site/website/content/index.html           |  173 -
 geode-site/website/content/js/bootstrap.min.js  |    8 -
 geode-site/website/content/js/head.js           |  708 ----
 geode-site/website/content/js/html5shiv.js      |    8 -
 .../website/content/js/jquery-1.10.1.min.js     |    6 -
 geode-site/website/content/js/jquery.icheck.js  |  397 --
 geode-site/website/content/js/respond.min.js    |    6 -
 geode-site/website/content/js/usergrid-site.js  |   66 -
 geode-site/website/content/releases/index.html  |  132 -
 .../website/content/schema/cache/cache-1.0.xsd  | 1469 -------
 .../website/content/schema/cache/lucene-1.0.xsd |   58 -
 geode-site/website/layouts/community.html       |    1 -
 geode-site/website/layouts/default.html         |   12 -
 geode-site/website/layouts/docs.html            |    1 -
 geode-site/website/layouts/footer.html          |   84 -
 geode-site/website/layouts/header.html          |  263 --
 geode-site/website/layouts/releases.html        |    1 -
 geode-site/website/lib/default.rb               |   60 -
 geode-site/website/lib/helpers_.rb              |   16 -
 geode-site/website/lib/pandoc.template          |    4 -
 geode-site/website/nanoc.yaml                   |   96 -
 geode-site/website/run.sh                       |   18 -
 geode-site/website/utilities/map-markers.rb     |   75 -
 geode-site/website/utilities/markers.txt        |  440 ---
 geode-site/website/utilities/snapshot-apigee.rb |   88 -
 geode-spark-connector/doc/2_quick.md            |    4 +-
 .../internal/locator/wan/LocatorHelper.java     |    3 -
 .../wan/GatewaySenderEventRemoteDispatcher.java |    2 +-
 ...ayReceiverAutoConnectionSourceDUnitTest.java |  126 +
 .../internal/cache/UpdateVersionDUnitTest.java  |   12 +-
 .../cache/wan/Simple2CacheServerDUnitTest.java  |    2 +-
 .../geode/internal/cache/wan/WANTestBase.java   |  110 +-
 ...oncurrentParallelGatewaySenderDUnitTest.java |    2 +-
 ...allelGatewaySenderOperation_2_DUnitTest.java |   37 +-
 .../wan/misc/NewWanAuthenticationDUnitTest.java |    2 +-
 ...llelGatewaySenderQueueOverflowDUnitTest.java |    2 +-
 .../ParallelWANPropagationDUnitTest.java        |    1 +
 .../wan/parallel/ParallelWANStatsDUnitTest.java |    2 +-
 ...rialGatewaySenderEventListenerDUnitTest.java |    2 +-
 .../SerialGatewaySenderQueueDUnitTest.java      |   85 +
 .../serial/SerialWANConflationDUnitTest.java    |    2 +-
 .../serial/SerialWANPropagationDUnitTest.java   |   36 +
 .../wan/serial/SerialWANStatsDUnitTest.java     |    2 +-
 .../wan/wancommand/WANCommandTestBase.java      |   33 +
 ...mandCreateDestroyGatewaySenderDUnitTest.java |  794 ++++
 .../WanCommandCreateGatewaySenderDUnitTest.java |  663 ----
 .../management/WANManagementDUnitTest.java      |  148 +-
 .../ClusterConfigurationDUnitTest.java          | 1034 ++---
 .../sanctionedDataSerializables.txt             |   14 +-
 geode-web-api/build.gradle                      |    7 +-
 .../web/controllers/AbstractBaseController.java |   14 +-
 .../controllers/FunctionAccessController.java   |   15 +-
 .../security/GeodeAuthenticationProvider.java   |   13 +-
 geode-web-api/src/main/webapp/META-INF/NOTICE   |   12 +-
 .../AbstractBaseControllerJUnitTest.java        |   80 +
 geode-web/build.gradle                          |    4 +
 geode-web/src/main/webapp/META-INF/NOTICE       |    8 +-
 .../cli/commands/CommandOverHttpDUnitTest.java  |    9 +-
 .../commands/ExportLogsOverHttpDUnitTest.java   |   66 +
 .../commands/QueryNamesOverHttpDUnitTest.java   |   25 +-
 .../LoginHandlerInterceptorJUnitTest.java       |    2 +
 ...andlerInterceptorRequestHeaderJUnitTest.java |   62 +
 .../RestHttpOperationInvokerJUnitTest.java      |   50 +-
 .../SimpleHttpOperationInvokerJUnitTest.java    |   20 +-
 gradle.properties                               |    4 +-
 gradle/dependency-versions.properties           |  113 +-
 gradle/ide.gradle                               |    3 +-
 gradle/publish.gradle                           |   12 +-
 gradle/rat.gradle                               |   26 -
 gradle/sonar.gradle                             |    2 +-
 gradle/test.gradle                              |    8 +-
 settings.gradle                                 |    2 +
 1179 files changed, 53418 insertions(+), 64524 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/40ff2a13/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
----------------------------------------------------------------------


[28/50] [abbrv] geode git commit: GEODE-2621: Reduce time sensitivity of ExportLogsDUnitTest

Posted by ds...@apache.org.
GEODE-2621: Reduce time sensitivity of ExportLogsDUnitTest


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/55564a30
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/55564a30
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/55564a30

Branch: refs/heads/feature/GEODE-1969
Commit: 55564a300571bf4bc50c34527480beaf3451c38d
Parents: aae5aa5
Author: Jared Stewart <js...@pivotal.io>
Authored: Tue Mar 7 15:26:20 2017 -0800
Committer: Jared Stewart <js...@pivotal.io>
Committed: Tue Mar 7 15:26:20 2017 -0800

----------------------------------------------------------------------
 .../management/internal/cli/commands/ExportLogsDUnitTest.java     | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/55564a30/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
index bf1d9ea..95edd42 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
@@ -143,8 +143,7 @@ public class ExportLogsDUnitTest {
     String cutoffTimeString = dateTimeFormatter.format(cutoffTime);
 
     CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
-    commandStringBuilder.addOption("start-time",
-        dateTimeFormatter.format(cutoffTime.minusHours(1)));
+    commandStringBuilder.addOption("start-time", dateTimeFormatter.format(cutoffTime.minusDays(1)));
     commandStringBuilder.addOption("end-time", cutoffTimeString);
     commandStringBuilder.addOption("log-level", "debug");
     commandStringBuilder.addOption("dir", "someDir");


[06/50] [abbrv] geode git commit: GEODE-2590 Fix unit tests related to creating lucene index and chunk regions

Posted by ds...@apache.org.
GEODE-2590 Fix unit tests related to creating lucene index and chunk regions


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/4e61799f
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/4e61799f
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/4e61799f

Branch: refs/heads/feature/GEODE-1969
Commit: 4e61799f918d47340ddb0ecbcf89aaf715723d95
Parents: 24d02a5
Author: Lynn Hughes-Godfrey <lh...@pivotal.io>
Authored: Fri Mar 3 14:03:46 2017 -0800
Committer: Lynn Hughes-Godfrey <lh...@pivotal.io>
Committed: Fri Mar 3 14:03:46 2017 -0800

----------------------------------------------------------------------
 .../cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/4e61799f/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
index 15235eb..93cc0a8 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
@@ -290,6 +290,7 @@ public class LuceneIndexForPartitionedRegionTest {
     String regionPath = "regionName";
     GemFireCacheImpl cache = Fakes.cache();
     RegionAttributes regionAttributes = mock(RegionAttributes.class);
+    when(regionAttributes.getDataPolicy()).thenReturn(DataPolicy.PARTITION);
     PartitionAttributes partitionAttributes = initializeAttributes(cache);
     LuceneIndexForPartitionedRegion index =
         new LuceneIndexForPartitionedRegion(name, regionPath, cache);
@@ -310,6 +311,7 @@ public class LuceneIndexForPartitionedRegionTest {
     GemFireCacheImpl cache = Fakes.cache();
     PartitionAttributes partitionAttributes = initializeAttributes(cache);
     RegionAttributes regionAttributes = mock(RegionAttributes.class);
+    when(regionAttributes.getDataPolicy()).thenReturn(DataPolicy.PARTITION);
     LuceneIndexForPartitionedRegion index =
         new LuceneIndexForPartitionedRegion(name, regionPath, cache);
     LuceneIndexForPartitionedRegion indexSpy = spy(index);


[20/50] [abbrv] geode git commit: GEODE-2604: Added measurement units to the javadoc comments

Posted by ds...@apache.org.
GEODE-2604: Added measurement units to the javadoc comments

	This closes #415


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/9321c0ea
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/9321c0ea
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/9321c0ea

Branch: refs/heads/feature/GEODE-1969
Commit: 9321c0ea46a4e023edebd6c0e14355fda4ec4313
Parents: 9d597dc
Author: nabarun <nn...@pivotal.io>
Authored: Mon Mar 6 17:30:07 2017 -0800
Committer: nabarun <nn...@pivotal.io>
Committed: Mon Mar 6 17:36:04 2017 -0800

----------------------------------------------------------------------
 .../lucene/management/LuceneIndexMetrics.java   | 22 +++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/9321c0ea/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java
index 8b69ed5..24d14c1 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/management/LuceneIndexMetrics.java
@@ -124,7 +124,8 @@ public class LuceneIndexMetrics {
   /**
    * Returns the time duration for execution of queries using the {@link LuceneIndex}
    *
-   * @return long value for the time consumed in the execution of queries using this Lucene Index
+   * @return long value for the time in nanoseconds consumed in the execution of queries using this
+   *         Lucene Index
    */
   public long getQueryExecutionTime() {
     return this.queryExecutionTime;
@@ -142,7 +143,7 @@ public class LuceneIndexMetrics {
   /**
    * Returns the average latency for query executions using the {@link LuceneIndex}
    *
-   * @return the average latency for query executions using the Lucene Index
+   * @return the average latency for query executions in nanoseconds using the Lucene Index
    */
   public long getQueryRateAverageLatency() {
     return this.queryRateAverageLatency;
@@ -160,7 +161,7 @@ public class LuceneIndexMetrics {
   /**
    * Returns the number of hits for the query execution using the {@link LuceneIndex}
    *
-   * @return the number of hit for the query execution using the Lucene Index
+   * @return the number of hits for the query execution using the Lucene Index
    */
   public long getQueryExecutionTotalHits() {
     return this.queryExecutionTotalHits;
@@ -178,7 +179,7 @@ public class LuceneIndexMetrics {
   /**
    * Returns the time consumed for the update operations on the {@link LuceneIndex}
    *
-   * @return the time consumed for the update operations on the Lucene Index
+   * @return the time consumed in nanoseconds for the update operations on the Lucene Index
    */
   public long getUpdateTime() {
     return this.updateTime;
@@ -196,7 +197,7 @@ public class LuceneIndexMetrics {
   /**
    * Returns the average latency for the update operations on the {@link LuceneIndex}
    *
-   * @return the average latency for the update operations on the Lucene Index
+   * @return the average latency for the update operations in nanoseconds on the Lucene Index
    */
   public long getUpdateRateAverageLatency() {
     return this.updateRateAverageLatency;
@@ -212,9 +213,9 @@ public class LuceneIndexMetrics {
   }
 
   /**
-   * Returns the number of commit operation executed on the {@link LuceneIndex}
+   * Returns the number of commit operations executed on the {@link LuceneIndex}
    *
-   * @return the number of commit operation executed on the Lucene Index
+   * @return the number of commit operations executed on the Lucene Index
    */
   public int getCommits() {
     return this.commits;
@@ -223,7 +224,7 @@ public class LuceneIndexMetrics {
   /**
    * Returns the time consumed by the commit operations on the {@link LuceneIndex}
    *
-   * @return the time consumed by the commit operations on the Lucene Index
+   * @return the time consumed in nanoseconds by the commit operations on the Lucene Index
    */
   public long getCommitTime() {
     return this.commitTime;
@@ -241,7 +242,8 @@ public class LuceneIndexMetrics {
   /**
    * Returns the average latency for the commit operations using the {@link LuceneIndex}
    *
-   * @return Returns the average latency for the commit operations using the Lucene Index
+   * @return Returns the average latency for the commit operations in nanoseconds using the Lucene
+   *         Index
    */
   public long getCommitRateAverageLatency() {
     return this.commitRateAverageLatency;
@@ -268,7 +270,7 @@ public class LuceneIndexMetrics {
   /**
    * Outputs the string message containing all the stats stored for the {@link LuceneIndex}
    *
-   * @return the string message containing all the stats stored for the {@link LuceneIndex}
+   * @return the string message containing all the stats stored for the Lucene Index
    */
   @Override
   public String toString() {


[32/50] [abbrv] geode git commit: GEODE-2593: add port range to AvailablePortHelper to fix testUDPPortRange

Posted by ds...@apache.org.
GEODE-2593: add port range to AvailablePortHelper to fix testUDPPortRange


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/9852f640
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/9852f640
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/9852f640

Branch: refs/heads/feature/GEODE-1969
Commit: 9852f640096e324126a53b73f4fbaf6648a89ce0
Parents: 22d8b40
Author: Kirk Lund <kl...@apache.org>
Authored: Fri Mar 3 17:36:07 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:28 2017 -0800

----------------------------------------------------------------------
 .../distributed/DistributedSystemDUnitTest.java |  50 ++--
 .../geode/internal/AvailablePortHelper.java     |  64 ++++-
 .../AvailablePortHelperIntegrationTest.java     | 264 +++++++++++++++++++
 3 files changed, 361 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/9852f640/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
index c57ad17..c1ea5e6 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
@@ -14,6 +14,10 @@
  */
 package org.apache.geode.distributed;
 
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.internal.AvailablePort.*;
+import static org.junit.Assert.*;
+
 import org.apache.geode.CancelException;
 import org.apache.geode.GemFireConfigException;
 import org.apache.geode.SystemConnectException;
@@ -22,7 +26,12 @@ import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache30.CacheSerializableRunnable;
-import org.apache.geode.distributed.internal.*;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.DistributionException;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.distributed.internal.SerialDistributionMessage;
+import org.apache.geode.distributed.internal.SizeableRunnable;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.distributed.internal.membership.gms.MembershipManagerHelper;
 import org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger;
@@ -30,12 +39,19 @@ import org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipMan
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.net.SocketCreator;
-import org.apache.geode.test.dunit.*;
+import org.apache.geode.test.dunit.DistributedTestUtils;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.LogWriterUtils;
+import org.apache.geode.test.dunit.RMIException;
+import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.geode.test.junit.categories.MembershipTest;
-import org.junit.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import java.net.Inet4Address;
@@ -46,20 +62,19 @@ import java.util.Enumeration;
 import java.util.Properties;
 import java.util.concurrent.TimeoutException;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.internal.AvailablePort.SOCKET;
-import static org.junit.Assert.*;
-
 /**
  * Tests the functionality of the {@link DistributedSystem} class.
- *
- * @see InternalDistributedSystemJUnitTest
- *
  */
 @Category({DistributedTest.class, MembershipTest.class})
 public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
 
-  public void postSetUp() throws Exception {
+  @Before
+  public void before() throws Exception {
+    disconnectAllFromDS();
+  }
+
+  @After
+  public void after() throws Exception {
     disconnectAllFromDS();
   }
 
@@ -298,18 +313,21 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
 
   @Test
   public void testUDPPortRange() throws Exception {
+    int[] unicastPort = AvailablePortHelper.getRandomAvailableTCPPortRange(3, true);
+
     Properties config = new Properties();
-    int unicastPort =
-        AvailablePort.getRandomAvailablePort(SOCKET, AvailablePort.getAddress(SOCKET), true);
     config.put(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
     // Minimum 3 ports required in range for UDP, FD_SOCK and TcpConduit.
-    config.setProperty(MEMBERSHIP_PORT_RANGE, "" + unicastPort + "-" + (unicastPort + 2));
+    config.setProperty(MEMBERSHIP_PORT_RANGE, unicastPort[0] + "-" + unicastPort[2]);
+
     InternalDistributedSystem system = getSystem(config);
     DistributionManager dm = (DistributionManager) system.getDistributionManager();
     InternalDistributedMember idm = dm.getDistributionManagerId();
+
+    assertTrue(unicastPort[0] <= idm.getPort() && idm.getPort() <= unicastPort[2]);
+    assertTrue(unicastPort[0] <= idm.getPort() && idm.getDirectChannelPort() <= unicastPort[2]);
+
     system.disconnect();
-    assertTrue(unicastPort <= idm.getPort() && idm.getPort() <= unicastPort + 2);
-    assertTrue(unicastPort <= idm.getPort() && idm.getDirectChannelPort() <= unicastPort + 2);
   }
 
   /***

http://git-wip-us.apache.org/repos/asf/geode/blob/9852f640/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelper.java b/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelper.java
index e09a7a0..6a1c1d4 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelper.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelper.java
@@ -14,6 +14,10 @@
  */
 package org.apache.geode.internal;
 
+import static org.apache.geode.distributed.internal.DistributionConfig.*;
+import static org.apache.geode.internal.AvailablePort.*;
+
+import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -66,11 +70,69 @@ public class AvailablePortHelper {
     List<Keeper> result = new ArrayList<Keeper>();
     while (result.size() < count) {
       result.add(AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET,
-          AvailablePort.getAddress(AvailablePort.SOCKET), useMembershipPortRange));
+          getAddress(AvailablePort.SOCKET), useMembershipPortRange));
+    }
+    return result;
+  }
+
+  public static int[] getRandomAvailableTCPPortRange(final int count) {
+    return getRandomAvailableTCPPortRange(count, false);
+  }
+
+  public static int[] getRandomAvailableTCPPortRange(final int count,
+      final boolean useMembershipPortRange) {
+    List<Keeper> list = getRandomAvailableTCPPortRangeKeepers(count, useMembershipPortRange);
+    int[] ports = new int[list.size()];
+    int i = 0;
+    for (Keeper k : list) {
+      ports[i] = k.getPort();
+      k.release();
+      i++;
+    }
+    return ports;
+  }
+
+  public static List<Keeper> getRandomAvailableTCPPortRangeKeepers(final int count) {
+    return getRandomAvailableTCPPortRangeKeepers(count, false);
+  }
+
+  public static List<Keeper> getRandomAvailableTCPPortRangeKeepers(final int count,
+      final boolean useMembershipPortRange) {
+    List<Keeper> result = new ArrayList<>();
+
+    InetAddress addr = getAddress(AvailablePort.SOCKET);
+
+    int lowerBound =
+        useMembershipPortRange ? DEFAULT_MEMBERSHIP_PORT_RANGE[0] : AVAILABLE_PORTS_LOWER_BOUND;
+
+    int upperBound =
+        useMembershipPortRange ? DEFAULT_MEMBERSHIP_PORT_RANGE[1] : AVAILABLE_PORTS_UPPER_BOUND;
+
+    for (int i = lowerBound; i <= upperBound; i++) {
+      for (int j = 0; j < count && ((i + j) <= upperBound); j++) {
+        int port = i + j;
+        Keeper keeper = isPortKeepable(port, SOCKET, addr);
+        if (keeper == null) {
+          releaseKeepers(result);
+          result.clear();
+          break;
+        }
+        result.add(keeper);
+        if (result.size() == count) {
+          return result;
+        }
+      }
     }
+
     return result;
   }
 
+  private static void releaseKeepers(List<Keeper> keepers) {
+    for (Keeper keeper : keepers) {
+      keeper.release();
+    }
+  }
+
   /**
    * Returns array of unique randomly available tcp ports of specified count.
    */

http://git-wip-us.apache.org/repos/asf/geode/blob/9852f640/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelperIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelperIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelperIntegrationTest.java
new file mode 100644
index 0000000..d6cfddc
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelperIntegrationTest.java
@@ -0,0 +1,264 @@
+/*
+ * 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.internal;
+
+import static org.apache.geode.distributed.internal.DistributionConfig.*;
+import static org.apache.geode.internal.AvailablePort.*;
+import static org.apache.geode.internal.AvailablePortHelper.*;
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.internal.AvailablePort.Keeper;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+@RunWith(JUnitParamsRunner.class)
+public class AvailablePortHelperIntegrationTest {
+
+  private Set<ServerSocket> serverSockets;
+
+  @Before
+  public void before() throws Exception {
+    this.serverSockets = new HashSet<>();
+  }
+
+  @After
+  public void after() throws Exception {
+    for (ServerSocket serverSocket : this.serverSockets) {
+      try {
+        if (serverSocket != null && !serverSocket.isClosed()) {
+          serverSocket.close();
+        }
+      } catch (IOException ignore) {
+        System.err.println("Unable to close " + serverSocket);
+      }
+    }
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_zero(final boolean useMembershipPortRange)
+      throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(0, useMembershipPortRange);
+    assertThat(results).isEmpty();
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_one_returnsOne(final boolean useMembershipPortRange)
+      throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(1, useMembershipPortRange);
+    assertThat(results).hasSize(1);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_two_returnsTwo(final boolean useMembershipPortRange)
+      throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(2, useMembershipPortRange);
+    assertThat(results).hasSize(2);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_many_returnsMany(final boolean useMembershipPortRange)
+      throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(10, useMembershipPortRange);
+    assertThat(results).hasSize(10);
+    assertPortsAreUsable(results);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_returnsUniquePorts(
+      final boolean useMembershipPortRange) throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(10, useMembershipPortRange);
+
+    Set<Integer> ports = new HashSet<>();
+    for (int port : results) {
+      ports.add(port);
+    }
+
+    assertThat(ports).hasSize(results.length);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_returnsConsecutivePorts(
+      final boolean useMembershipPortRange) throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(10, useMembershipPortRange);
+
+    List<Integer> ports = new ArrayList<>();
+    for (int port : results) {
+      if (useMembershipPortRange) {
+        assertThat(port).isGreaterThanOrEqualTo(DEFAULT_MEMBERSHIP_PORT_RANGE[0])
+            .isLessThanOrEqualTo(DEFAULT_MEMBERSHIP_PORT_RANGE[1]);
+      } else {
+        assertThat(port).isGreaterThanOrEqualTo(AVAILABLE_PORTS_LOWER_BOUND)
+            .isLessThanOrEqualTo(AVAILABLE_PORTS_UPPER_BOUND);
+      }
+      ports.add(port);
+    }
+
+    assertThat(ports).hasSize(10);
+
+    int previousPort = 0;
+    for (int port : ports) {
+      if (previousPort != 0) {
+        assertThat(port).isEqualTo(previousPort + 1);
+      }
+      previousPort = port;
+    }
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_zero(final boolean useMembershipPortRange)
+      throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(0, useMembershipPortRange);
+    assertThat(results).isEmpty();
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_one_returnsOne(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(1, useMembershipPortRange);
+    assertThat(results).hasSize(1);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_two_returnsTwo(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(2, useMembershipPortRange);
+    assertThat(results).hasSize(2);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_many_returnsMany(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(10, useMembershipPortRange);
+    assertThat(results).hasSize(10);
+    assertKeepersAreUsable(results);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_returnsUsableKeeper(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(1, useMembershipPortRange);
+    assertKeepersAreUsable(results);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_returnsUniqueKeepers(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(10, useMembershipPortRange);
+
+    Set<Integer> ports = new HashSet<>();
+    for (Keeper keeper : results) {
+      ports.add(keeper.getPort());
+    }
+
+    assertThat(ports).hasSize(results.size());
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_returnsConsecutivePorts(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(10, useMembershipPortRange);
+
+    List<Integer> ports = new ArrayList<>();
+    for (Keeper keeper : results) {
+      assertThat(keeper).isNotNull();
+      int port = keeper.getPort();
+      if (useMembershipPortRange) {
+        assertThat(port).isGreaterThanOrEqualTo(DEFAULT_MEMBERSHIP_PORT_RANGE[0])
+            .isLessThanOrEqualTo(DEFAULT_MEMBERSHIP_PORT_RANGE[1]);
+      } else {
+        assertThat(port).isGreaterThanOrEqualTo(AVAILABLE_PORTS_LOWER_BOUND)
+            .isLessThanOrEqualTo(AVAILABLE_PORTS_UPPER_BOUND);
+      }
+      ports.add(port);
+    }
+
+    assertThat(ports).hasSize(10);
+
+    int previousPort = 0;
+    for (int port : ports) {
+      if (previousPort != 0) {
+        assertThat(port).isEqualTo(previousPort + 1);
+      }
+      previousPort = port;
+    }
+  }
+
+  private void assertPortsAreUsable(int[] ports) throws IOException {
+    for (int port : ports) {
+      assertPortIsUsable(port);
+    }
+  }
+
+  private void assertPortIsUsable(int port) throws IOException {
+    ServerSocket serverSocket = createServerSocket();
+    serverSocket.setReuseAddress(true);
+
+    serverSocket.bind(new InetSocketAddress(port));
+
+    assertThat(serverSocket.isBound()).isTrue();
+    assertThat(serverSocket.isClosed()).isFalse();
+    serverSocket.close();
+    assertThat(serverSocket.isClosed()).isTrue();
+  }
+
+  private void assertKeepersAreUsable(Collection<Keeper> keepers) throws IOException {
+    for (Keeper keeper : keepers) {
+      assertKeeperIsUsable(keeper);
+    }
+  }
+
+  private void assertKeeperIsUsable(Keeper keeper) throws IOException {
+    int port = keeper.getPort();
+    keeper.release();
+    assertPortIsUsable(port);
+  }
+
+  private ServerSocket createServerSocket() throws IOException {
+    ServerSocket serverSocket = new ServerSocket();
+    this.serverSockets.add(serverSocket);
+    return serverSocket;
+  }
+
+}


[35/50] [abbrv] geode git commit: GEODE-2617: make LuceneResultStruct serializable

Posted by ds...@apache.org.
GEODE-2617: make LuceneResultStruct serializable


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/c7c28f07
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/c7c28f07
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/c7c28f07

Branch: refs/heads/feature/GEODE-1969
Commit: c7c28f07c9d92cd443b5bb0779626db15e5c3c3b
Parents: 7b57985
Author: zhouxh <gz...@pivotal.io>
Authored: Tue Mar 7 14:02:09 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:29 2017 -0800

----------------------------------------------------------------------
 .../java/org/apache/geode/cache/lucene/LuceneResultStruct.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c7c28f07/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
index 4a6481f..5d2184e 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
@@ -14,6 +14,8 @@
  */
 package org.apache.geode.cache.lucene;
 
+import java.io.Serializable;
+
 import org.apache.geode.annotations.Experimental;
 
 /**
@@ -21,7 +23,7 @@ import org.apache.geode.annotations.Experimental;
  * 
  */
 @Experimental
-public interface LuceneResultStruct<K, V> {
+public interface LuceneResultStruct<K, V> extends Serializable {
 
   /**
    * @return The region key of the entry matching the query


[39/50] [abbrv] geode git commit: GEODE-2621: Reduce time sensitivity of ExportLogsDUnitTest

Posted by ds...@apache.org.
GEODE-2621: Reduce time sensitivity of ExportLogsDUnitTest


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/fe339587
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/fe339587
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/fe339587

Branch: refs/heads/feature/GEODE-1969
Commit: fe339587bfccbcb264067d2abbc42f85ebda6e5d
Parents: 5ca8dda
Author: Jared Stewart <js...@pivotal.io>
Authored: Tue Mar 7 15:26:20 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:29 2017 -0800

----------------------------------------------------------------------
 .../management/internal/cli/commands/ExportLogsDUnitTest.java     | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/fe339587/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
index bf1d9ea..95edd42 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
@@ -143,8 +143,7 @@ public class ExportLogsDUnitTest {
     String cutoffTimeString = dateTimeFormatter.format(cutoffTime);
 
     CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
-    commandStringBuilder.addOption("start-time",
-        dateTimeFormatter.format(cutoffTime.minusHours(1)));
+    commandStringBuilder.addOption("start-time", dateTimeFormatter.format(cutoffTime.minusDays(1)));
     commandStringBuilder.addOption("end-time", cutoffTimeString);
     commandStringBuilder.addOption("log-level", "debug");
     commandStringBuilder.addOption("dir", "someDir");


[47/50] [abbrv] geode git commit: GEODE-2553: Closed IndexRepositories when deleting an index

Posted by ds...@apache.org.
GEODE-2553: Closed IndexRepositories when deleting an index


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/38cf13ff
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/38cf13ff
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/38cf13ff

Branch: refs/heads/feature/GEODE-1969
Commit: 38cf13ffbbc912f78bdacb1caf835508abe1b5e3
Parents: cfaa0e7
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Wed Mar 1 10:41:03 2017 -0800
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Wed Mar 8 14:30:14 2017 -0800

----------------------------------------------------------------------
 .../AbstractPartitionedRepositoryManager.java   | 16 +++++-
 .../lucene/internal/LuceneBucketListener.java   |  7 +--
 .../LuceneIndexForPartitionedRegion.java        | 31 ++---------
 .../cache/lucene/internal/LuceneIndexImpl.java  | 36 ++++++++++---
 .../internal/RawLuceneRepositoryManager.java    |  6 ---
 .../internal/repository/RepositoryManager.java  |  5 ++
 .../lucene/LuceneIndexDestroyDUnitTest.java     | 56 +++++++++++++++++++-
 7 files changed, 107 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/38cf13ff/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/AbstractPartitionedRepositoryManager.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/AbstractPartitionedRepositoryManager.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/AbstractPartitionedRepositoryManager.java
index 97acea1..26179c7 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/AbstractPartitionedRepositoryManager.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/AbstractPartitionedRepositoryManager.java
@@ -49,11 +49,13 @@ public abstract class AbstractPartitionedRepositoryManager implements Repository
   protected final PartitionedRegion userRegion;
   protected final LuceneSerializer serializer;
   protected final LuceneIndexImpl index;
+  protected volatile boolean closed;
 
   public AbstractPartitionedRepositoryManager(LuceneIndexImpl index, LuceneSerializer serializer) {
     this.index = index;
     this.userRegion = (PartitionedRegion) index.getCache().getRegion(index.getRegionPath());
     this.serializer = serializer;
+    this.closed = false;
   }
 
   @Override
@@ -91,9 +93,13 @@ public abstract class AbstractPartitionedRepositoryManager implements Repository
       LuceneSerializer serializer, LuceneIndexImpl index, PartitionedRegion userRegion,
       IndexRepository oldRepository) throws IOException;
 
-  protected IndexRepository computeRepository(Integer bucketId) throws BucketNotFoundException {
+  protected IndexRepository computeRepository(Integer bucketId) {
     IndexRepository repo = indexRepositories.compute(bucketId, (key, oldRepository) -> {
       try {
+        if (closed && oldRepository != null) {
+          oldRepository.cleanup();
+          return null;
+        }
         return computeRepository(bucketId, serializer, index, userRegion, oldRepository);
       } catch (IOException e) {
         throw new InternalGemFireError("Unable to create index repository", e);
@@ -119,4 +125,12 @@ public abstract class AbstractPartitionedRepositoryManager implements Repository
     }
     return repo;
   }
+
+  @Override
+  public void close() {
+    this.closed = true;
+    for (Integer bucketId : indexRepositories.keySet()) {
+      computeRepository(bucketId);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/38cf13ff/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneBucketListener.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneBucketListener.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneBucketListener.java
index 9532249..32fb3fc 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneBucketListener.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneBucketListener.java
@@ -40,11 +40,6 @@ public class LuceneBucketListener extends PartitionListenerAdapter {
         lucenePartitionRepositoryManager.computeRepository(bucketId);
       } catch (PrimaryBucketException e) {
         logger.info("Index repository could not be created because we are no longer primary?", e);
-      } catch (BucketNotFoundException e) {
-        logger.info(
-            "Index repository could not be created when index chunk region bucket became primary. "
-                + "Deferring index repository to be created lazily during lucene query execution."
-                + e);
       }
     });
   }
@@ -57,7 +52,7 @@ public class LuceneBucketListener extends PartitionListenerAdapter {
     dm.getWaitingThreadPool().execute(() -> {
       try {
         lucenePartitionRepositoryManager.computeRepository(bucketId);
-      } catch (PrimaryBucketException | BucketNotFoundException | AlreadyClosedException e) {
+      } catch (PrimaryBucketException | AlreadyClosedException e) {
         logger.debug("Exception while cleaning up Lucene Index Repository", e);
       }
     });

http://git-wip-us.apache.org/repos/asf/geode/blob/38cf13ff/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index 4aa24b5..f24c6d6 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -217,10 +217,6 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     // Invoke super destroy to remove the extension
     super.destroy(initiator);
 
-    // Destroy the AsyncEventQueue
-    PartitionedRegion pr = (PartitionedRegion) getDataRegion();
-    destroyAsyncEventQueue(pr);
-
     // Destroy the chunk region (colocated with the file region)
     // localDestroyRegion can't be used because locally destroying regions is not supported on
     // colocated regions
@@ -243,7 +239,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
 
     // Destroy index on remote members if necessary
     if (initiator) {
-      destroyOnRemoteMembers(pr);
+      destroyOnRemoteMembers();
     }
 
     if (logger.isDebugEnabled()) {
@@ -252,29 +248,8 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     }
   }
 
-  private void destroyAsyncEventQueue(PartitionedRegion pr) {
-    String aeqId = LuceneServiceImpl.getUniqueIndexName(indexName, regionPath);
-
-    // Get the AsyncEventQueue
-    AsyncEventQueueImpl aeq = (AsyncEventQueueImpl) cache.getAsyncEventQueue(aeqId);
-
-    // Stop the AsyncEventQueue (this stops the AsyncEventQueue's underlying GatewaySender)
-    aeq.stop();
-
-    // Remove the id from the dataRegion's AsyncEventQueue ids
-    // Note: The region may already have been destroyed by a remote member
-    if (!pr.isDestroyed()) {
-      pr.getAttributesMutator().removeAsyncEventQueueId(aeqId);
-    }
-
-    // Destroy the aeq (this also removes it from the GemFireCacheImpl)
-    aeq.destroy();
-    if (logger.isDebugEnabled()) {
-      logger.debug("Destroyed aeqId=" + aeqId);
-    }
-  }
-
-  private void destroyOnRemoteMembers(PartitionedRegion pr) {
+  private void destroyOnRemoteMembers() {
+    PartitionedRegion pr = (PartitionedRegion) getDataRegion();
     DM dm = pr.getDistributionManager();
     Set<InternalDistributedMember> recipients = pr.getRegionAdvisor().adviseDataStore();
     if (!recipients.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/geode/blob/38cf13ff/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
index cf519be..b5b13c1 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
@@ -16,9 +16,7 @@
 package org.apache.geode.cache.lucene.internal;
 
 import java.util.Collections;
-import java.util.List;
 import java.util.Map;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.geode.internal.cache.extension.Extension;
 import org.apache.logging.log4j.Logger;
@@ -33,11 +31,6 @@ import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
 import org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl;
 import org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl;
-import org.apache.geode.cache.execute.Execution;
-import org.apache.geode.cache.execute.FunctionService;
-import org.apache.geode.cache.execute.ResultCollector;
-import org.apache.geode.cache.lucene.internal.distributed.WaitUntilFlushedFunction;
-import org.apache.geode.cache.lucene.internal.distributed.WaitUntilFlushedFunctionContext;
 import org.apache.geode.cache.lucene.internal.repository.RepositoryManager;
 import org.apache.geode.cache.lucene.internal.xml.LuceneIndexCreation;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
@@ -217,6 +210,12 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
     if (extensionToDelete != null) {
       getDataRegion().getExtensionPoint().removeExtension(extensionToDelete);
     }
+
+    // Destroy the async event queue
+    destroyAsyncEventQueue();
+
+    // Close the repository manager
+    repositoryManager.close();
   }
 
   protected <K, V> Region<K, V> createRegion(final String regionName,
@@ -237,4 +236,27 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
       throw ige;
     }
   }
+
+  private void destroyAsyncEventQueue() {
+    String aeqId = LuceneServiceImpl.getUniqueIndexName(indexName, regionPath);
+
+    // Get the AsyncEventQueue
+    AsyncEventQueueImpl aeq = (AsyncEventQueueImpl) cache.getAsyncEventQueue(aeqId);
+
+    // Stop the AsyncEventQueue (this stops the AsyncEventQueue's underlying GatewaySender)
+    aeq.stop();
+
+    // Remove the id from the dataRegion's AsyncEventQueue ids
+    // Note: The region may already have been destroyed by a remote member
+    Region region = getDataRegion();
+    if (!region.isDestroyed()) {
+      region.getAttributesMutator().removeAsyncEventQueueId(aeqId);
+    }
+
+    // Destroy the aeq (this also removes it from the GemFireCacheImpl)
+    aeq.destroy();
+    if (logger.isDebugEnabled()) {
+      logger.debug("Destroyed aeqId=" + aeqId);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/38cf13ff/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManager.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManager.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManager.java
index c31f19c..b9f4de8 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManager.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManager.java
@@ -28,12 +28,6 @@ public class RawLuceneRepositoryManager extends AbstractPartitionedRepositoryMan
     super(index, serializer);
   }
 
-  public void close() {
-    for (IndexRepository repo : indexRepositories.values()) {
-      repo.cleanup();
-    }
-  }
-
   @Override
   protected IndexRepository getRepository(Integer bucketId) throws BucketNotFoundException {
     IndexRepository repo = indexRepositories.get(bucketId);

http://git-wip-us.apache.org/repos/asf/geode/blob/38cf13ff/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/RepositoryManager.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/RepositoryManager.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/RepositoryManager.java
index b569d70..7f4a6c6 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/RepositoryManager.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/RepositoryManager.java
@@ -39,4 +39,9 @@ public interface RepositoryManager {
    */
   Collection<IndexRepository> getRepositories(RegionFunctionContext context)
       throws BucketNotFoundException;
+
+  /**
+   * Closes this {@link RepositoryManager}
+   */
+  void close();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/38cf13ff/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java
index 6260075..1afde6a 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java
@@ -23,6 +23,7 @@ import org.apache.geode.cache.lucene.test.TestObject;
 import org.apache.geode.internal.cache.LocalRegion;
 import org.apache.geode.test.dunit.AsyncInvocation;
 import org.apache.geode.test.dunit.SerializableRunnableIF;
+import org.apache.geode.test.dunit.ThreadUtils;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.awaitility.Awaitility;
 import org.junit.Ignore;
@@ -30,6 +31,7 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
 
+import java.io.InterruptedIOException;
 import java.util.concurrent.TimeUnit;
 
 import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
@@ -38,6 +40,7 @@ import static org.apache.geode.internal.Assert.fail;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 @Category(DistributedTest.class)
 @RunWith(JUnitParamsRunner.class)
@@ -124,7 +127,7 @@ public class LuceneIndexDestroyDUnitTest extends LuceneDUnitTest {
     dataStore2.invoke(() -> verifyIndexCreated());
 
     // Start puts
-    AsyncInvocation putter = dataStore1.invokeAsync(() -> doPuts());
+    AsyncInvocation putter = dataStore1.invokeAsync(() -> doPutsUntilStopped());
 
     // Wait until puts have started
     dataStore1.invoke(() -> waitUntilPutsHaveStarted());
@@ -141,6 +144,42 @@ public class LuceneIndexDestroyDUnitTest extends LuceneDUnitTest {
     putter.join();
   }
 
+  @Test
+  @Parameters(method = "getListOfRegionTestTypes")
+  public void verifyDestroyRecreateSingleIndex(RegionTestableType regionType) {
+    // Create index and region
+    dataStore1.invoke(() -> initDataStore(createIndex(), regionType));
+    dataStore2.invoke(() -> initDataStore(createIndex(), regionType));
+
+    // Verify index created
+    dataStore1.invoke(() -> verifyIndexCreated());
+    dataStore2.invoke(() -> verifyIndexCreated());
+
+    // Do puts to cause IndexRepositories to be created
+    dataStore1.invoke(() -> doPuts(10));
+
+    // Destroy indexes (only needs to be done on one member)
+    dataStore1.invoke(() -> destroyIndexes());
+
+    // Verify indexes destroyed
+    dataStore1.invoke(() -> verifyIndexesDestroyed());
+    dataStore2.invoke(() -> verifyIndexesDestroyed());
+
+    // Destroy data region
+    dataStore1.invoke(() -> destroyDataRegion(true));
+
+    // Recreate index and region
+    dataStore1.invoke(() -> initDataStore(createIndex(), regionType));
+    dataStore2.invoke(() -> initDataStore(createIndex(), regionType));
+
+    // Do puts to cause IndexRepositories to be recreated
+    dataStore1.invoke(() -> doPuts(10));
+
+    // Wait until queue is flushed
+    // This verifies there are no deadlocks
+    dataStore1.invoke(() -> waitUntilFlushed(INDEX_NAME));
+    dataStore2.invoke(() -> waitUntilFlushed(INDEX_NAME));
+  }
 
   private SerializableRunnableIF createIndex() {
     return () -> {
@@ -168,7 +207,20 @@ public class LuceneIndexDestroyDUnitTest extends LuceneDUnitTest {
     assertNotNull(luceneService.getIndex(INDEX_NAME + "1", REGION_NAME));
   }
 
-  private void doPuts() throws Exception {
+  private void waitUntilFlushed(String indexName) throws Exception {
+    LuceneService luceneService = LuceneServiceProvider.get(getCache());
+    assertTrue(
+        luceneService.waitUntilFlushed(indexName, REGION_NAME, 30000, TimeUnit.MILLISECONDS));
+  }
+
+  private void doPuts(int numPuts) throws Exception {
+    Region region = getCache().getRegion(REGION_NAME);
+    for (int i = 0; i < numPuts; i++) {
+      region.put(i, new TestObject());
+    }
+  }
+
+  private void doPutsUntilStopped() throws Exception {
     Region region = getCache().getRegion(REGION_NAME);
     int i = 0;
     while (!STOP_PUTS) {


[04/50] [abbrv] geode git commit: GEODE-2560: Missing disk files (.crf) during backup/restore throws exception

Posted by ds...@apache.org.
GEODE-2560: Missing disk files (.crf) during backup/restore throws exception


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/21a9b5e2
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/21a9b5e2
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/21a9b5e2

Branch: refs/heads/feature/GEODE-1969
Commit: 21a9b5e2c60ddc909ebc28ebfa3b6aeb33b6ee12
Parents: c0633c8
Author: Kevin J. Duling <kd...@pivotal.io>
Authored: Wed Mar 1 09:49:18 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Fri Mar 3 10:21:17 2017 -0800

----------------------------------------------------------------------
 .../main/java/org/apache/geode/internal/cache/Oplog.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/21a9b5e2/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java b/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
index f5aec51..8b0bba5 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
@@ -5804,14 +5804,18 @@ public final class Oplog implements CompactableOplog, Flushable {
   }
 
   public void copyTo(File targetDir) throws IOException {
-    if (this.crf.f != null) { // fixes bug 43951
+    if (this.crf.f != null && this.crf.f.exists()) {
       FileUtils.copyFileToDirectory(this.crf.f, targetDir);
     }
-    FileUtils.copyFileToDirectory(this.drf.f, targetDir);
+    if (this.drf.f.exists()) {
+      FileUtils.copyFileToDirectory(this.drf.f, targetDir);
+    }
 
     // this krf existence check fixes 45089
     if (getParent().getDiskInitFile().hasKrf(this.oplogId)) {
-      FileUtils.copyFileToDirectory(this.getKrfFile(), targetDir);
+      if (this.getKrfFile().exists()) {
+        FileUtils.copyFileToDirectory(this.getKrfFile(), targetDir);
+      }
     }
   }
 


[34/50] [abbrv] geode git commit: GEODE-1198: refactor test with before/after and cleanup use of ports

Posted by ds...@apache.org.
GEODE-1198: refactor test with before/after and cleanup use of ports


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/7b579855
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/7b579855
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/7b579855

Branch: refs/heads/feature/GEODE-1969
Commit: 7b579855785b95e5d39e017e6d0b73007379a028
Parents: d63512f
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Mar 7 12:32:36 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:29 2017 -0800

----------------------------------------------------------------------
 .../distributed/DistributedSystemDUnitTest.java | 513 +++++++++----------
 1 file changed, 230 insertions(+), 283 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/7b579855/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
index c1ea5e6..dfe4588 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
@@ -14,20 +14,39 @@
  */
 package org.apache.geode.distributed;
 
+import static java.lang.Integer.parseInt;
+import static java.net.NetworkInterface.getNetworkInterfaces;
 import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.internal.DistributionConfig.*;
+import static org.apache.geode.distributed.internal.DistributionManager.*;
 import static org.apache.geode.internal.AvailablePort.*;
-import static org.junit.Assert.*;
+import static org.apache.geode.internal.AvailablePortHelper.*;
+import static org.apache.geode.internal.net.SocketCreator.getLocalHost;
+import static org.apache.geode.test.dunit.DistributedTestUtils.getDUnitLocatorPort;
+import static org.apache.geode.test.dunit.Host.getHost;
+import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
+import static org.assertj.core.api.Assertions.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Enumeration;
+import java.util.Properties;
 
 import org.apache.geode.CancelException;
 import org.apache.geode.GemFireConfigException;
-import org.apache.geode.SystemConnectException;
 import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
-import org.apache.geode.cache30.CacheSerializableRunnable;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.DistributionException;
 import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.SerialDistributionMessage;
@@ -36,41 +55,33 @@ import org.apache.geode.distributed.internal.membership.InternalDistributedMembe
 import org.apache.geode.distributed.internal.membership.gms.MembershipManagerHelper;
 import org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger;
 import org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager;
-import org.apache.geode.internal.AvailablePort;
-import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.internal.net.SocketCreator;
-import org.apache.geode.test.dunit.DistributedTestUtils;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.LogWriterUtils;
-import org.apache.geode.test.dunit.RMIException;
-import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.geode.test.junit.categories.MembershipTest;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.concurrent.TimeoutException;
-
 /**
  * Tests the functionality of the {@link DistributedSystem} class.
  */
 @Category({DistributedTest.class, MembershipTest.class})
 public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
 
+  private int mcastPort;
+  private int locatorPort;
+  private int tcpPort;
+  private int lowerBoundOfPortRange;
+  private int upperBoundOfPortRange;
+
   @Before
   public void before() throws Exception {
     disconnectAllFromDS();
+
+    this.mcastPort = getRandomAvailablePort(MULTICAST);
+    this.locatorPort = getRandomAvailablePort(SOCKET);
+    this.tcpPort = getRandomAvailablePort(SOCKET);
+
+    int[] portRange = getRandomAvailableTCPPortRange(3, true);
+    this.lowerBoundOfPortRange = portRange[0];
+    this.upperBoundOfPortRange = portRange[portRange.length - 1];
   }
 
   @After
@@ -84,75 +95,37 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
    */
   @Test
   public void testWaitForDeparture() throws Exception {
-    disconnectAllFromDS();
-    int locatorPort = AvailablePort.getRandomAvailablePort(SOCKET);
-    Properties p = getDistributedSystemProperties();
-    p.put(LOCATORS, "");
-    p.put(START_LOCATOR, "localhost[" + locatorPort + "]");
-    p.put(DISABLE_TCP, "true");
-    InternalDistributedSystem ds = (InternalDistributedSystem) DistributedSystem.connect(p);
-    try {
-      // construct a member ID that will represent a departed member
-      InternalDistributedMember mbr = new InternalDistributedMember("localhost", 12345, "", "",
-          DistributionManager.NORMAL_DM_TYPE, null, null);
-      final DistributionManager mgr = (DistributionManager) ds.getDistributionManager();
-      // schedule a message in order to create a queue for the fake member
-      final FakeMessage msg = new FakeMessage(null);
-      mgr.getExecutor(DistributionManager.SERIAL_EXECUTOR, mbr).execute(new SizeableRunnable(100) {
-        public void run() {
-          msg.doAction(mgr, false);
-        }
+    Properties config = new Properties();
+    config.put(LOCATORS, "");
+    config.put(START_LOCATOR, "localhost[" + this.locatorPort + "]");
+    config.put(DISABLE_TCP, "true");
 
-        public String toString() {
-          return "Processing fake message";
-        }
-      });
-      try {
-        assertTrue("expected the serial queue to be flushed",
-            mgr.getMembershipManager().waitForDeparture(mbr));
-      } catch (InterruptedException e) {
-        fail("interrupted");
-      } catch (TimeoutException e) {
-        fail("timed out - increase this test's member-timeout setting");
-      }
-    } finally {
-      ds.disconnect();
-    }
-  }
+    InternalDistributedSystem system =
+        (InternalDistributedSystem) DistributedSystem.connect(config);
 
-  private static class FakeMessage extends SerialDistributionMessage {
-    volatile boolean[] blocked;
-    volatile boolean processed;
+    // construct a member ID that will represent a departed member
+    InternalDistributedMember member =
+        new InternalDistributedMember("localhost", 12345, "", "", NORMAL_DM_TYPE, null, null);
 
-    FakeMessage(boolean[] blocked) {
-      this.blocked = blocked;
-    }
+    // schedule a message in order to create a queue for the fake member
+    DistributionManager distributionManager = (DistributionManager) system.getDistributionManager();
+    FakeMessage message = new FakeMessage(null);
 
-    public void doAction(DistributionManager dm, boolean block) {
-      processed = true;
-      if (block) {
-        synchronized (blocked) {
-          blocked[0] = true;
-          blocked.notify();
-          try {
-            blocked.wait(60000);
-          } catch (InterruptedException e) {
-          }
-        }
-      }
-    }
+    distributionManager.getExecutor(SERIAL_EXECUTOR, member).execute(new SizeableRunnable(100) {
 
-    public int getDSFID() {
-      return 0; // never serialized
-    }
+      @Override
+      public void run() { // always throws NullPointerException
+        message.doAction(distributionManager, false);
+      }
 
-    protected void process(DistributionManager dm) {
-      // this is never called
-    }
+      @Override
+      public String toString() {
+        return "Processing fake message";
+      }
+    });
 
-    public String toString() {
-      return "FakeMessage(blocking=" + (blocked != null) + ")";
-    }
+    assertThat(distributionManager.getMembershipManager().waitForDeparture(member))
+        .as("expected the serial queue to be flushed").isTrue();
   }
 
   /**
@@ -160,16 +133,15 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
    */
   @Test
   public void testGetSameSystemTwice() {
-    Properties config = new Properties();
-    config.setProperty(MCAST_PORT, "0");
-    config.setProperty(LOCATORS, "");
+    Properties config = createLonerConfig();
+
     // set a flow-control property for the test (bug 37562)
     config.setProperty(MCAST_FLOW_CONTROL, "3000000,0.20,3000");
 
     DistributedSystem system1 = DistributedSystem.connect(config);
     DistributedSystem system2 = DistributedSystem.connect(config);
-    assertSame(system1, system2);
-    system1.disconnect();
+
+    assertThat(system2).isSameAs(system1);
   }
 
   /**
@@ -178,24 +150,15 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
    */
   @Test
   public void testGetDifferentSystem() {
-    Properties config = new Properties();
-    config.setProperty(MCAST_PORT, "0");
-    config.setProperty(LOCATORS, "");
+    Properties config = createLonerConfig();
     config.setProperty(MCAST_FLOW_CONTROL, "3000000,0.20,3000");
 
+    DistributedSystem.connect(config);
 
-    DistributedSystem system1 = DistributedSystem.connect(config);
     config.setProperty(MCAST_ADDRESS, "224.0.0.1");
-    try {
-      DistributedSystem.connect(config);
-      if (System.getProperty(DistributionConfig.GEMFIRE_PREFIX + "mcast-address") == null) {
-        fail("Should have thrown an IllegalStateException");
-      }
-    } catch (IllegalStateException ex) {
-      // pass...
-    } finally {
-      system1.disconnect();
-    }
+
+    assertThatThrownBy(() -> DistributedSystem.connect(config))
+        .isInstanceOf(IllegalStateException.class);
   }
 
   /**
@@ -203,70 +166,61 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
    */
   @Test
   public void testGetDifferentSystemAfterClose() {
-    Properties config = new Properties();
-    config.setProperty(MCAST_PORT, "0");
-    config.setProperty(LOCATORS, "");
+    Properties config = createLonerConfig();
 
     DistributedSystem system1 = DistributedSystem.connect(config);
     system1.disconnect();
-    int time = DistributionConfig.DEFAULT_ACK_WAIT_THRESHOLD + 17;
+
+    int time = DEFAULT_ACK_WAIT_THRESHOLD + 17;
     config.put(ACK_WAIT_THRESHOLD, String.valueOf(time));
+
     DistributedSystem system2 = DistributedSystem.connect(config);
     system2.disconnect();
   }
 
-
   @Test
   public void testGetProperties() {
-    Properties config = new Properties();
-    // a loner is all this test needs
     int unusedPort = 0;
-    config.setProperty(MCAST_PORT, "0");
-    config.setProperty(LOCATORS, "");
 
-    DistributedSystem system1 = DistributedSystem.connect(config);
+    Properties config = createLonerConfig();
+    DistributedSystem system = DistributedSystem.connect(config);
 
-    assertTrue(config != system1.getProperties());
-    assertEquals(unusedPort, Integer.parseInt(system1.getProperties().getProperty(MCAST_PORT)));
+    assertThat(system.getProperties()).isNotSameAs(config);
+    assertThat(parseInt(system.getProperties().getProperty(MCAST_PORT))).isEqualTo(unusedPort);
 
-    system1.disconnect();
+    system.disconnect();
 
-    assertTrue(config != system1.getProperties());
-    assertEquals(unusedPort, Integer.parseInt(system1.getProperties().getProperty(MCAST_PORT)));
+    assertThat(system.getProperties()).isNotSameAs(config);
+    assertThat(parseInt(system.getProperties().getProperty(MCAST_PORT))).isEqualTo(unusedPort);
   }
 
-
   @Test
   public void testIsolatedDistributedSystem() throws Exception {
-    Properties config = new Properties();
-    config.setProperty(MCAST_PORT, "0");
-    config.setProperty(LOCATORS, "");
-    getSystem(config);
-    try {
-      // make sure isolated distributed system can still create a cache and region
-      Cache cache = CacheFactory.create(getSystem());
-      Region r = cache.createRegion(getUniqueName(), new AttributesFactory().create());
-      r.put("test", "value");
-      assertEquals("value", r.get("test"));
-    } finally {
-      getSystem().disconnect();
-    }
-  }
+    Properties config = createLonerConfig();
+    InternalDistributedSystem system = getSystem(config);
 
+    // make sure isolated distributed system can still create a cache and region
+    Cache cache = CacheFactory.create(system);
+    Region region = cache.createRegion(getUniqueName(), new AttributesFactory().create());
+    region.put("test", "value");
 
-  /** test the ability to set the port used to listen for tcp/ip connections */
+    assertThat(region.get("test")).isEqualTo("value");
+  }
+
+  /**
+   * test the ability to set the port used to listen for tcp/ip connections
+   */
   @Test
   public void testSpecificTcpPort() throws Exception {
     Properties config = new Properties();
-    int tcpPort = AvailablePort.getRandomAvailablePort(SOCKET);
-    config.put(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
-    config.setProperty(TCP_PORT, String.valueOf(tcpPort));
+    config.put(LOCATORS, "localhost[" + getDUnitLocatorPort() + "]");
+    config.setProperty(TCP_PORT, String.valueOf(this.tcpPort));
+
     InternalDistributedSystem system = getSystem(config);
+
     DistributionManager dm = (DistributionManager) system.getDistributionManager();
     GMSMembershipManager mgr = (GMSMembershipManager) dm.getMembershipManager();
-    int actualPort = mgr.getDirectChannelPort();
-    system.disconnect();
-    assertEquals(tcpPort, actualPort);
+    assertThat(mgr.getDirectChannelPort()).isEqualTo(this.tcpPort);
   }
 
   /**
@@ -275,186 +229,179 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
    */
   @Test
   public void testLoopbackNotAllowed() throws Exception {
-    // DISABLED for bug #49926
-    InetAddress loopback = null;
-    for (Enumeration<NetworkInterface> it = NetworkInterface.getNetworkInterfaces(); it
-        .hasMoreElements();) {
-      NetworkInterface nif = it.nextElement();
-      for (Enumeration<InetAddress> ait = nif.getInetAddresses(); ait.hasMoreElements();) {
-        InetAddress a = ait.nextElement();
-        Class theClass = SocketCreator.getLocalHost() instanceof Inet4Address ? Inet4Address.class
-            : Inet6Address.class;
-        if (a.isLoopbackAddress() && (a.getClass().isAssignableFrom(theClass))) {
-          loopback = a;
-          break;
-        }
-      }
-    }
-    if (loopback != null) {
-      Properties config = new Properties();
-      config.put(MCAST_PORT, "0");
-      String locators = InetAddress.getLocalHost().getHostName() + "["
-          + DistributedTestUtils.getDUnitLocatorPort() + "]";
-      config.put(LOCATORS, locators);
-      config.setProperty(BIND_ADDRESS, loopback.getHostAddress());
-      LogWriterUtils.getLogWriter()
-          .info("attempting to connect with " + loopback + " and locators=" + locators);
-      try {
-        InternalDistributedSystem system = getSystem(config);
-        system.disconnect();
-        fail("expected a configuration exception disallowing use of loopback address");
-      } catch (GemFireConfigException e) {
-        // expected
-      } catch (DistributionException e) {
-        // expected
-      }
-    }
+    // assert or assume that loopback is not null
+    InetAddress loopback = getLoopback();
+    assertThat(loopback).isNotNull();
+
+    String locators = getLocalHost().getHostName() + "[" + getDUnitLocatorPort() + "]";
+
+    Properties config = new Properties();
+    config.put(LOCATORS, locators);
+    config.setProperty(BIND_ADDRESS, loopback.getHostAddress());
+
+    getLogWriter().info("attempting to connect with " + loopback + " and locators=" + locators);
+
+    assertThatThrownBy(() -> getSystem(config)).isInstanceOf(GemFireConfigException.class);
   }
 
   @Test
   public void testUDPPortRange() throws Exception {
-    int[] unicastPort = AvailablePortHelper.getRandomAvailableTCPPortRange(3, true);
-
     Properties config = new Properties();
-    config.put(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
-    // Minimum 3 ports required in range for UDP, FD_SOCK and TcpConduit.
-    config.setProperty(MEMBERSHIP_PORT_RANGE, unicastPort[0] + "-" + unicastPort[2]);
+    config.put(LOCATORS, "localhost[" + getDUnitLocatorPort() + "]");
+    config.setProperty(MEMBERSHIP_PORT_RANGE,
+        this.lowerBoundOfPortRange + "-" + this.upperBoundOfPortRange);
 
     InternalDistributedSystem system = getSystem(config);
     DistributionManager dm = (DistributionManager) system.getDistributionManager();
-    InternalDistributedMember idm = dm.getDistributionManagerId();
-
-    assertTrue(unicastPort[0] <= idm.getPort() && idm.getPort() <= unicastPort[2]);
-    assertTrue(unicastPort[0] <= idm.getPort() && idm.getDirectChannelPort() <= unicastPort[2]);
+    InternalDistributedMember member = dm.getDistributionManagerId();
 
-    system.disconnect();
-  }
-
-  /***
-   * this will return starting port, from it "range" of port will available
-   * 
-   * @param range
-   * @return
-   */
-  private int getPortRange(int range) {
-    int port = DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[0] + 10000;
-    int startPort = port;
-    int found = 0;
-    while (port <= DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1]) {
-      if (AvailablePort.isPortAvailable(port, SOCKET)) {
-        found++;
-        if (found == range) {
-          break;
-        }
-        port++;
-      } else {
-        port++;
-        startPort = port;
-        found = 0;
-      }
-    }
-    if (port > DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1]) {
-      fail("Unable to find port range " + range);
-    }
-    return startPort;
+    verifyMembershipPortsInRange(member, this.lowerBoundOfPortRange, this.upperBoundOfPortRange);
   }
 
   @Test
   public void testMembershipPortRangeWithExactThreeValues() throws Exception {
     Properties config = new Properties();
-    config.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
-    int portRange = 3;
-    int portStartRange = getPortRange(portRange);
-    int portEndRange = portStartRange + portRange - 1;
-    config.setProperty(MEMBERSHIP_PORT_RANGE, "" + (portStartRange) + "-" + (portEndRange));
+    config.setProperty(LOCATORS, "localhost[" + getDUnitLocatorPort() + "]");
+    config.setProperty(MEMBERSHIP_PORT_RANGE,
+        this.lowerBoundOfPortRange + "-" + this.upperBoundOfPortRange);
+
     InternalDistributedSystem system = getSystem(config);
     Cache cache = CacheFactory.create(system);
     cache.addCacheServer();
+
     DistributionManager dm = (DistributionManager) system.getDistributionManager();
-    InternalDistributedMember idm = dm.getDistributionManagerId();
-    GMSMembershipManager manager =
+    InternalDistributedMember member = dm.getDistributionManagerId();
+    GMSMembershipManager gms =
         (GMSMembershipManager) MembershipManagerHelper.getMembershipManager(system);
-    JGroupsMessenger messenger = (JGroupsMessenger) manager.getServices().getMessenger();
+    JGroupsMessenger messenger = (JGroupsMessenger) gms.getServices().getMessenger();
     String jgConfig = messenger.getJGroupsStackConfig();
-    system.disconnect();
-    assertTrue("expected to find port_range=\"2\" in " + jgConfig,
-        jgConfig.contains("port_range=\"2\""));
-    assertTrue(idm.getPort() <= portEndRange);
-    assertTrue(idm.getPort() >= portStartRange);
-    assertTrue(idm.getDirectChannelPort() <= portEndRange);
-    assertTrue(idm.getDirectChannelPort() >= portStartRange);
+
+    assertThat(jgConfig).as("expected to find port_range=\"2\" in " + jgConfig)
+        .contains("port_range=\"2\"");
+
+    verifyMembershipPortsInRange(member, this.lowerBoundOfPortRange, this.upperBoundOfPortRange);
   }
 
-  @Category(FlakyTest.class) // GEODE-1198
   @Test
   public void testConflictingUDPPort() throws Exception {
-    final Properties config = new Properties();
-    final int mcastPort = AvailablePort.getRandomAvailablePort(AvailablePort.MULTICAST);
-    final int[] socketPorts = AvailablePortHelper.getRandomAvailableTCPPorts(1, true);
-    final int unicastPort = getPortRange(3);
-    config.setProperty(MCAST_PORT, String.valueOf(mcastPort));
-    config.setProperty(START_LOCATOR, "localhost[" + socketPorts[0] + "]");
-    config.setProperty(MEMBERSHIP_PORT_RANGE, "" + unicastPort + "-" + (unicastPort + 2));
-    InternalDistributedSystem system =
-        (InternalDistributedSystem) DistributedSystem.connect(config);
-    try {
-      DistributionManager dm = (DistributionManager) system.getDistributionManager();
-      InternalDistributedMember idm = dm.getDistributionManagerId();
-      VM vm = Host.getHost(0).getVM(1);
-      vm.invoke(new CacheSerializableRunnable("start conflicting system") {
-        public void run2() {
-          try {
-            String locators = (String) config.remove(START_LOCATOR);
-            config.put(LOCATORS, locators);
-            DistributedSystem system = DistributedSystem.connect(config);
-            system.disconnect();
-          } catch (GemFireConfigException e) {
-            return; //
-          } catch (RMIException e) {
-            if (e.getCause() instanceof SystemConnectException) {
-              // GEODE-1198: for this test, the membership-port-range has only 3 ports available.
-              // If in some rare cases, one of the ports is used by others, it will get this
-              // exception. So just ignore it. Since adding one more port will also fail the test.
-              return;
-            }
-          }
-          fail("expected a GemFireConfigException but didn't get one");
-        }
-      });
-    } finally {
-      system.disconnect();
-    }
+    Properties config = new Properties();
+    config.setProperty(MCAST_PORT, String.valueOf(this.mcastPort));
+    config.setProperty(START_LOCATOR, "localhost[" + this.locatorPort + "]");
+    config.setProperty(MEMBERSHIP_PORT_RANGE,
+        this.lowerBoundOfPortRange + "-" + this.upperBoundOfPortRange);
+
+    DistributedSystem.connect(config);
+
+    getHost(0).getVM(1).invoke(() -> {
+      String locators = (String) config.remove(START_LOCATOR);
+
+      config.put(LOCATORS, locators);
+
+      assertThatThrownBy(() -> DistributedSystem.connect(config))
+          .isInstanceOf(GemFireConfigException.class);
+    });
   }
 
   /**
    * Tests that configuring a distributed system with a cache-xml-file of "" does not initialize a
-   * cache. See bug 32254.
+   * cache.
+   *
+   * Verifies: "Allow the cache-xml-file specification to be an empty string"
    *
    * @since GemFire 4.0
    */
   @Test
   public void testEmptyCacheXmlFile() throws Exception {
+    Properties config = createLonerConfig();
+    config.setProperty(CACHE_XML_FILE, "");
+
+    DistributedSystem system = DistributedSystem.connect(config);
+
+    assertThatThrownBy(() -> CacheFactory.getInstance(system)).isInstanceOf(CancelException.class);
+
+    // now make sure we can create the cache
+    Cache cache = CacheFactory.create(system);
+
+    assertThat(cache).isNotNull();
+    assertThat(cache.isClosed()).isFalse();
+  }
+
+  private Properties createLonerConfig() {
     Properties config = new Properties();
     config.setProperty(MCAST_PORT, "0");
     config.setProperty(LOCATORS, "");
-    config.setProperty(CACHE_XML_FILE, "");
+    return config;
+  }
 
-    DistributedSystem sys = DistributedSystem.connect(config);
+  private void verifyMembershipPortsInRange(final InternalDistributedMember member,
+      final int lowerBound, final int upperBound) {
+    assertThat(member.getPort()).isGreaterThanOrEqualTo(lowerBound);
+    assertThat(member.getPort()).isLessThanOrEqualTo(upperBound);
+    assertThat(member.getDirectChannelPort()).isGreaterThanOrEqualTo(lowerBound);
+    assertThat(member.getDirectChannelPort()).isLessThanOrEqualTo(upperBound);
+  }
 
-    try {
-      try {
-        CacheFactory.getInstance(sys);
-        fail("Should have thrown a CancelException");
-      } catch (CancelException expected) {
-      }
-      // now make sure we can create the cache
-      CacheFactory.create(sys);
+  private InetAddress getLoopback() throws SocketException, UnknownHostException {
+    for (Enumeration<NetworkInterface> networkInterfaceEnumeration =
+        getNetworkInterfaces(); networkInterfaceEnumeration.hasMoreElements();) {
+
+      NetworkInterface networkInterface = networkInterfaceEnumeration.nextElement();
 
-    } finally {
-      sys.disconnect();
+      for (Enumeration<InetAddress> addressEnum = networkInterface.getInetAddresses(); addressEnum
+          .hasMoreElements();) {
+
+        InetAddress address = addressEnum.nextElement();
+        Class theClass =
+            getLocalHost() instanceof Inet4Address ? Inet4Address.class : Inet6Address.class;
+
+        if (address.isLoopbackAddress() && address.getClass().isAssignableFrom(theClass)) {
+          return address;
+        }
+      }
     }
+    return null;
   }
 
+  /**
+   * What is the point of this FakeMessage? Member variables are unused and doAction actually throws
+   * NullPointerException.
+   */
+  private static class FakeMessage extends SerialDistributionMessage {
+    private volatile boolean[] blocked; // always null
+    private volatile boolean processed; // unused
+
+    FakeMessage(boolean[] blocked) { // null is always passed in
+      this.blocked = blocked;
+    }
+
+    public void doAction(DistributionManager dm, boolean block) {
+      this.processed = true;
+      if (block) {
+        synchronized (this.blocked) { // throws NullPointerException here
+          this.blocked[0] = true;
+          this.blocked.notify();
+          try {
+            this.blocked.wait(60000);
+          } catch (InterruptedException e) {
+          }
+        }
+      }
+    }
 
+    @Override
+    public int getDSFID() {
+      return 0; // never serialized
+    }
+
+    @Override
+    protected void process(DistributionManager dm) {
+      // this is never called
+    }
+
+    @Override
+    public String toString() {
+      return "FakeMessage(blocking=" + (this.blocked != null) + ")";
+    }
+  }
 
 }


[40/50] [abbrv] geode git commit: GEODE-2614: fix javadoc warnings - spotless

Posted by ds...@apache.org.
GEODE-2614: fix javadoc warnings - spotless


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/886c8080
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/886c8080
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/886c8080

Branch: refs/heads/feature/GEODE-1969
Commit: 886c8080b1383c9e388dd9aa2197c17bd095e758
Parents: 0ca3fe2
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Wed Mar 8 10:28:39 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:30 2017 -0800

----------------------------------------------------------------------
 .../apache/geode/management/internal/cli/CliAroundInterceptor.java  | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/886c8080/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
index f552460..7a95306 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
@@ -38,6 +38,7 @@ public interface CliAroundInterceptor {
 
   /**
    * called by the OperationInvoker after the command is executed
+   * 
    * @param tempFile if the command's isFileDownloadOverHttp is true, the is the File downloaded
    *        after the http response is processed.
    */


[48/50] [abbrv] geode git commit: GEODE-2617: use DataSeriazableFixedID to implement

Posted by ds...@apache.org.
GEODE-2617: use DataSeriazableFixedID to implement


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/f1d4291a
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/f1d4291a
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/f1d4291a

Branch: refs/heads/feature/GEODE-1969
Commit: f1d4291a0777a5d3d42cd1f616f220a4b36d0d96
Parents: 38cf13f
Author: zhouxh <gz...@pivotal.io>
Authored: Thu Mar 9 09:54:42 2017 -0800
Committer: zhouxh <gz...@pivotal.io>
Committed: Thu Mar 9 09:55:16 2017 -0800

----------------------------------------------------------------------
 .../geode/internal/DataSerializableFixedID.java |  1 +
 .../geode/cache/lucene/LuceneResultStruct.java  |  4 +--
 .../lucene/internal/LuceneResultStructImpl.java | 37 +++++++++++++++++++-
 .../lucene/internal/LuceneServiceImpl.java      |  3 ++
 4 files changed, 41 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f1d4291a/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java b/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
index 63a95a5..18f382b 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
@@ -811,6 +811,7 @@ public interface DataSerializableFixedID extends SerializationVersions {
   public static final short WAIT_UNTIL_FLUSHED_FUNCTION_CONTEXT = 2177;
   public static final short DESTROY_LUCENE_INDEX_MESSAGE = 2178;
   public static final short LUCENE_PAGE_RESULTS = 2179;
+  public static final short LUCENE_RESULT_STRUCT = 2180;
 
   // NOTE, codes > 65535 will take 4 bytes to serialize
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f1d4291a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
index 5d2184e..4a6481f 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
@@ -14,8 +14,6 @@
  */
 package org.apache.geode.cache.lucene;
 
-import java.io.Serializable;
-
 import org.apache.geode.annotations.Experimental;
 
 /**
@@ -23,7 +21,7 @@ import org.apache.geode.annotations.Experimental;
  * 
  */
 @Experimental
-public interface LuceneResultStruct<K, V> extends Serializable {
+public interface LuceneResultStruct<K, V> {
 
   /**
    * @return The region key of the entry matching the query

http://git-wip-us.apache.org/repos/asf/geode/blob/f1d4291a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneResultStructImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneResultStructImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneResultStructImpl.java
index 6c31025..708ac1e 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneResultStructImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneResultStructImpl.java
@@ -15,13 +15,23 @@
 
 package org.apache.geode.cache.lucene.internal;
 
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.geode.DataSerializer;
 import org.apache.geode.cache.lucene.LuceneResultStruct;
+import org.apache.geode.internal.DataSerializableFixedID;
+import org.apache.geode.internal.Version;
 
-public class LuceneResultStructImpl<K, V> implements LuceneResultStruct<K, V> {
+public class LuceneResultStructImpl<K, V>
+    implements LuceneResultStruct<K, V>, DataSerializableFixedID {
   K key;
   V value;
   float score;
 
+  public LuceneResultStructImpl() {}
+
   public LuceneResultStructImpl(K key, V value, float score) {
     this.key = key;
     this.value = value;
@@ -81,4 +91,29 @@ public class LuceneResultStructImpl<K, V> implements LuceneResultStruct<K, V> {
   public String toString() {
     return "LuceneResultStructImpl [key=" + key + ", value=" + value + ", score=" + score + "]";
   }
+
+  @Override
+  public Version[] getSerializationVersions() {
+    return null;
+  }
+
+  @Override
+  public int getDSFID() {
+    return LUCENE_RESULT_STRUCT;
+  }
+
+  @Override
+  public void toData(DataOutput out) throws IOException {
+    DataSerializer.writeObject(key, out);
+    DataSerializer.writeObject(value, out);
+    out.writeFloat(score);
+  }
+
+  @Override
+  public void fromData(DataInput in) throws IOException, ClassNotFoundException {
+    key = DataSerializer.readObject(in);
+    value = DataSerializer.readObject(in);
+    score = in.readFloat();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f1d4291a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
index 5c908f5..a212094 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
@@ -381,6 +381,9 @@ public class LuceneServiceImpl implements InternalLuceneService {
         DestroyLuceneIndexMessage.class);
 
     DSFIDFactory.registerDSFID(DataSerializableFixedID.LUCENE_PAGE_RESULTS, PageResults.class);
+
+    DSFIDFactory.registerDSFID(DataSerializableFixedID.LUCENE_RESULT_STRUCT,
+        LuceneResultStructImpl.class);
   }
 
   public Collection<LuceneIndexCreationProfile> getAllDefinedIndexes() {


[21/50] [abbrv] geode git commit: GEODE-2591 User guide: Lucene headings should be reflected in navigation pane. This closes #413

Posted by ds...@apache.org.
GEODE-2591 User guide: Lucene headings should be reflected in navigation pane.
This closes #413


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/950b8d7c
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/950b8d7c
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/950b8d7c

Branch: refs/heads/feature/GEODE-1969
Commit: 950b8d7ce5c0fae2bbb5ef788bb431c0bc94a31b
Parents: 9321c0e 15587b2
Author: Dave Barnes <db...@pivotal.io>
Authored: Tue Mar 7 10:11:07 2017 -0800
Committer: Dave Barnes <db...@pivotal.io>
Committed: Tue Mar 7 10:13:18 2017 -0800

----------------------------------------------------------------------
 geode-book/master_middleman/source/subnavs/geode-subnav.erb | 8 +++++++-
 geode-docs/tools_modules/lucene_integration.html.md.erb     | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------



[44/50] [abbrv] geode git commit: Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/geode into develop

Posted by ds...@apache.org.
Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/geode into develop


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/4018543a
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/4018543a
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/4018543a

Branch: refs/heads/feature/GEODE-1969
Commit: 4018543acd9ea08b9c938283deaeca8da7921a73
Parents: 886c808 cb8f0c4
Author: Kevin J. Duling <kd...@pivotal.io>
Authored: Wed Mar 8 10:43:53 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:53 2017 -0800

----------------------------------------------------------------------

----------------------------------------------------------------------



[46/50] [abbrv] geode git commit: GEODE-2539: revert jetty version change for now

Posted by ds...@apache.org.
GEODE-2539: revert jetty version change for now


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/cfaa0e79
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/cfaa0e79
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/cfaa0e79

Branch: refs/heads/feature/GEODE-1969
Commit: cfaa0e79548f06483b5c036fc3ef04951e6bcef4
Parents: a0716a5
Author: Kevin J. Duling <kd...@pivotal.io>
Authored: Wed Mar 8 14:25:12 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 14:25:12 2017 -0800

----------------------------------------------------------------------
 gradle/dependency-versions.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/cfaa0e79/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index 90601ac..34e5d67 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -52,7 +52,7 @@ javax.resource-api.version = 1.7
 javax.servlet-api.version = 3.1.0
 javax.transaction-api.version = 1.2
 jedis.version = 2.9.0
-jetty.version = 9.4.2.v20170220
+jetty.version = 9.3.6.v20151106
 jgroups.version = 3.6.10.Final
 jmock.version = 2.8.2
 jna.version = 4.0.0


[38/50] [abbrv] geode git commit: GEODE-2579: ClassCastException cannot cast CompiledIn to CompiledJunction

Posted by ds...@apache.org.
GEODE-2579: ClassCastException cannot cast CompiledIn to CompiledJunction

*  AbstractGroupOrRangeJunction does not incorrectly cast when creating junction with in clause
*  In clause will be handled like a compiled comparison


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/d63512fd
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/d63512fd
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/d63512fd

Branch: refs/heads/feature/GEODE-1969
Commit: d63512fdcedd3353ed6d3e9bf7b5449ac5abd88d
Parents: 9852f64
Author: Jason Huynh <hu...@gmail.com>
Authored: Fri Mar 3 09:20:11 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:29 2017 -0800

----------------------------------------------------------------------
 .../internal/AbstractGroupOrRangeJunction.java  |  2 +-
 .../geode/cache/query/QueryJUnitTest.java       | 52 ++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d63512fd/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
index a499346..5ed4d86 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
@@ -68,7 +68,7 @@ public abstract class AbstractGroupOrRangeJunction extends AbstractCompiledValue
     this.completeExpansion = completeExpansion;
     this.indpndntItr = indpnds;
     if (iterOp != null) {
-      if (iterOp instanceof CompiledComparison) {
+      if (iterOp instanceof CompiledComparison || iterOp instanceof CompiledIn) {
         int finalSize = 1 + oldGJ._operands.length;
         this._operands = new CompiledValue[finalSize];
         System.arraycopy(oldGJ._operands, 0, this._operands, 0, finalSize - 1);

http://git-wip-us.apache.org/repos/asf/geode/blob/d63512fd/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
index 7333212..f08eef5 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
@@ -26,6 +26,7 @@ package org.apache.geode.cache.query;
 import static org.junit.Assert.*;
 import static org.junit.runners.MethodSorters.*;
 
+import java.io.Serializable;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -34,6 +35,8 @@ import java.util.Set;
 import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.query.internal.index.IndexProtocol;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.FixMethodOrder;
@@ -308,6 +311,55 @@ public class QueryJUnitTest {
     }
   }
 
+  @Test
+  public void creatingACompiledJunctionWithACompiledInClauseDoesNotThrowException()
+      throws Exception {
+    Cache cache = CacheUtils.getCache();
+    RegionFactory<Integer, Portfolio> rf = cache.createRegionFactory(RegionShortcut.REPLICATE);
+    Region regionA = rf.create("regionA");
+    Region regionB = rf.create("regionB");
+
+    for (int i = 1; i <= 100; i++) {
+      regionA.put(Integer.toString(i), new TestUserObject("" + i, "" + i, "" + i, "" + i));
+      regionB.put(Integer.toString(i), new TestUserObject("" + i, "" + i, "" + i, "" + i));
+    }
+    QueryService qs = CacheUtils.getQueryService();
+
+    Index regionAUserCodeIndex = (IndexProtocol) qs.createIndex("regionAUserCodeIndex",
+        IndexType.FUNCTIONAL, "userId", "/regionA ");
+    Index regionBUserCodeIndex = (IndexProtocol) qs.createIndex("regionAUserCodeIndex",
+        IndexType.FUNCTIONAL, "userId", "/regionB ");
+
+    Index regionAUserNameIndex = (IndexProtocol) qs.createIndex("regionAUserNameIndex",
+        IndexType.FUNCTIONAL, "userName", "/regionA ");
+    Index regionBUserNameIndex = (IndexProtocol) qs.createIndex("regionBUserNameIndex",
+        IndexType.FUNCTIONAL, "userName", "/regionB ");
+
+    Query query = qs.newQuery(
+        "select regionB.userId,regionA.professionCode,regionB.postCode,regionB.userName from /regionA regionA,/regionB regionB where regionA.userId = regionB.userId and regionA.professionCode in Set('1','2','3') and regionB.postCode = '1' and regionB.userId='1'");
+    SelectResults results = (SelectResults) query.execute();
+    assertTrue(results.size() > 0);
+  }
+
+  public static class TestUserObject implements Serializable {
+    public String professionCode;
+    public String userId;
+    public String postCode;
+    public String userName;
+
+    public TestUserObject() {
+
+    }
+
+    public TestUserObject(final String professionCode, final String userId, final String postCode,
+        final String userName) {
+      this.professionCode = professionCode;
+      this.userId = userId;
+      this.postCode = postCode;
+      this.userName = userName;
+    }
+  }
+
   private class QueryRunnable implements Runnable {
     private Query q;
     private Object[] params;


[41/50] [abbrv] geode git commit: GEODE-1198: add todo comment to dubious test

Posted by ds...@apache.org.
GEODE-1198: add todo comment to dubious test


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/168f4ceb
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/168f4ceb
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/168f4ceb

Branch: refs/heads/feature/GEODE-1969
Commit: 168f4cebc43d69859b976580f422abd0128770c2
Parents: fe33958
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Mar 7 14:34:47 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:30 2017 -0800

----------------------------------------------------------------------
 .../org/apache/geode/distributed/DistributedSystemDUnitTest.java   | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/168f4ceb/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
index dfe4588..9a64f53 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
@@ -124,6 +124,8 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
       }
     });
 
+    // TODO: assert that queue was created or this test is just broken
+
     assertThat(distributionManager.getMembershipManager().waitForDeparture(member))
         .as("expected the serial queue to be flushed").isTrue();
   }


[13/50] [abbrv] geode git commit: GEODE-2267: add validation to the arguments and include export stats in the command

Posted by ds...@apache.org.
GEODE-2267:  add validation to the arguments and include export stats in the command

  * use the config to determine where the logs and stats are


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/bf788176
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/bf788176
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/bf788176

Branch: refs/heads/feature/GEODE-1969
Commit: bf788176bc479006dc196bedd04904d8858b26bb
Parents: 92582fb
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Fri Feb 24 15:45:58 2017 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Fri Mar 3 16:03:50 2017 -0800

----------------------------------------------------------------------
 .../geode/internal/logging/GemFireLevel.java    |   6 +-
 .../internal/logging/InternalLogWriter.java     |   3 +
 .../geode/internal/logging/LogService.java      |  20 +-
 .../internal/statistics/StatArchiveHandler.java |   2 +-
 .../internal/cli/CliAroundInterceptor.java      |  12 +-
 .../management/internal/cli/CommandRequest.java |   8 +-
 .../internal/cli/commands/ConfigCommands.java   |   3 +-
 .../internal/cli/commands/DeployCommands.java   |   5 -
 ...xportImportClusterConfigurationCommands.java |   7 +-
 .../internal/cli/commands/ExportLogCommand.java | 229 ++++++++++++
 .../internal/cli/commands/FunctionCommands.java |  24 +-
 .../cli/commands/MiscellaneousCommands.java     | 139 -------
 .../cli/functions/ExportLogsFunction.java       | 141 ++++---
 .../internal/cli/functions/LogFileFunction.java | 315 ----------------
 .../internal/cli/i18n/CliStrings.java           |   6 +-
 .../cli/remote/RemoteExecutionStrategy.java     |   2 +-
 .../cli/shell/GfshExecutionStrategy.java        |   5 -
 .../cli/util/ExportLogsCacheWriter.java         |   6 +-
 .../internal/cli/util/LogExporter.java          |  64 ++--
 .../management/internal/cli/util/LogFilter.java |  77 ++--
 .../internal/cli/util/LogLevelExtractor.java    |  35 +-
 .../web/controllers/ExportLogController.java    | 101 +++++
 .../MiscellaneousCommandsController.java        |  70 ----
 .../SimpleStatSamplerIntegrationTest.java       |  25 +-
 .../ConnectToLocatorSSLDUnitTest.java           |   7 +-
 .../AbstractCliAroundInterceptorJUnitTest.java  |   5 +-
 .../management/internal/cli/HeadlessGfsh.java   |  10 +-
 .../cli/commands/CliCommandTestBase.java        |  41 ++-
 .../internal/cli/commands/ExportLogsDUnit.java  | 364 -------------------
 .../cli/commands/ExportLogsDUnitTest.java       | 342 +++++++++++++++++
 .../ExportLogsInterceptorJUnitTest.java         |  89 +++++
 .../cli/commands/ExportStatsDUnitTest.java      | 153 ++++++++
 .../ExportLogsFunctionIntegrationTest.java      |  67 ++--
 .../cli/util/ExportLogsCacheWriterUnitTest.java |  46 +++
 .../cli/util/LogExporterIntegrationTest.java    | 164 +++++++++
 .../internal/cli/util/LogExporterTest.java      |  67 +++-
 .../internal/cli/util/LogFilterTest.java        | 149 ++++++--
 .../cli/util/LogLevelExtractorTest.java         |  62 +++-
 .../internal/security/MultiUserDUnitTest.java   |  30 +-
 .../dunit/rules/GfshShellConnectionRule.java    |  16 +-
 .../dunit/rules/LocatorServerStartupRule.java   |   9 +-
 .../codeAnalysis/sanctionedSerializables.txt    |   4 +-
 .../cli/commands/golden-help-offline.properties |  17 +-
 .../commands/ExportLogsOverHttpDUnitTest.java   |  72 +---
 44 files changed, 1755 insertions(+), 1264 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/internal/logging/GemFireLevel.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/GemFireLevel.java b/geode-core/src/main/java/org/apache/geode/internal/logging/GemFireLevel.java
index cffd162..0e1dc6e 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/logging/GemFireLevel.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/GemFireLevel.java
@@ -14,13 +14,15 @@
  */
 package org.apache.geode.internal.logging;
 
-import java.util.logging.Level;
-
 import org.apache.geode.i18n.LogWriterI18n;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 
+import java.util.logging.Level;
+
 /**
  * Extension that adds ERROR to the standard JDK logging level class.
+ * 
+ * @deprecated use log4j level
  */
 public class GemFireLevel extends Level {
   private static final long serialVersionUID = -8123818329485173242L;

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/internal/logging/InternalLogWriter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/InternalLogWriter.java b/geode-core/src/main/java/org/apache/geode/internal/logging/InternalLogWriter.java
index 661fce9..4c04ca6 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/logging/InternalLogWriter.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/InternalLogWriter.java
@@ -33,7 +33,10 @@ import org.apache.geode.i18n.StringId;
  * <li>{@link #SEVERE_LEVEL}
  * <li>{@link #NONE_LEVEL}
  * </ol>
+ * 
+ * @deprecated use log4j api instead
  */
+@Deprecated
 public interface InternalLogWriter extends LogWriter, LogWriterI18n {
 
   /**

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/internal/logging/LogService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/LogService.java b/geode-core/src/main/java/org/apache/geode/internal/logging/LogService.java
index 0ad7d84..1f8a564 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/logging/LogService.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/LogService.java
@@ -14,10 +14,12 @@
  */
 package org.apache.geode.internal.logging;
 
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-
+import org.apache.geode.internal.logging.log4j.AppenderContext;
+import org.apache.geode.internal.logging.log4j.ConfigLocator;
+import org.apache.geode.internal.logging.log4j.Configurator;
+import org.apache.geode.internal.logging.log4j.FastLogger;
+import org.apache.geode.internal.logging.log4j.LogWriterLogger;
+import org.apache.geode.internal.logging.log4j.message.GemFireParameterizedMessageFactory;
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -29,12 +31,9 @@ import org.apache.logging.log4j.core.lookup.StrLookup;
 import org.apache.logging.log4j.core.lookup.StrSubstitutor;
 import org.apache.logging.log4j.status.StatusLogger;
 
-import org.apache.geode.internal.logging.log4j.AppenderContext;
-import org.apache.geode.internal.logging.log4j.ConfigLocator;
-import org.apache.geode.internal.logging.log4j.Configurator;
-import org.apache.geode.internal.logging.log4j.FastLogger;
-import org.apache.geode.internal.logging.log4j.LogWriterLogger;
-import org.apache.geode.internal.logging.log4j.message.GemFireParameterizedMessageFactory;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
 
 /**
  * Centralizes log configuration and initialization.
@@ -47,6 +46,7 @@ public class LogService extends LogManager {
   public static final String BASE_LOGGER_NAME = "org.apache.geode";
   public static final String MAIN_LOGGER_NAME = "org.apache.geode";
   public static final String SECURITY_LOGGER_NAME = "org.apache.geode.security";
+  public static final String DEFAULT_LOG_LEVEL = "INFO";
 
   public static final String GEODE_VERBOSE_FILTER = "{GEODE_VERBOSE}";
   public static final String GEMFIRE_VERBOSE_FILTER = "{GEMFIRE_VERBOSE}";

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveHandler.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveHandler.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveHandler.java
index 03b0f89..c96e672 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveHandler.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveHandler.java
@@ -383,7 +383,7 @@ public class StatArchiveHandler implements SampleHandler {
       }
       try {
         StatArchiveDescriptor archiveDescriptor = new StatArchiveDescriptor.Builder()
-            .setArchiveName(newFile.getPath()).setSystemId(this.config.getSystemId())
+            .setArchiveName(newFile.getAbsolutePath()).setSystemId(this.config.getSystemId())
             .setSystemStartTime(this.config.getSystemStartTime())
             .setSystemDirectoryPath(this.config.getSystemDirectoryPath())
             .setProductDescription(this.config.getProductDescription()).build();

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
index 2e26efd..99114f0 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
@@ -32,24 +32,18 @@ public interface CliAroundInterceptor {
   /**
    * called by the OperationInvoker before the command is executed
    */
-  default public Result preExecution(GfshParseResult parseResult) {
+  default Result preExecution(GfshParseResult parseResult) {
     return ResultBuilder.createInfoResult("");
   }
 
-  @Deprecated
-  default public Result postExecution(GfshParseResult parseResult, Result commandResult) {
-    return commandResult;
-  }
-
   /**
    * called by the OperationInvoker after the command is executed
    * 
    * @param tempFile: if the command's isFileDownloadOverHttp is true, the is the File downloaded
    *        after the http response is processed.
    */
-  default public Result postExecution(GfshParseResult parseResult, Result commandResult,
-      Path tempFile) {
-    return postExecution(parseResult, commandResult);
+  default Result postExecution(GfshParseResult parseResult, Result commandResult, Path tempFile) {
+    return commandResult;
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
index 046499e..00a0587 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
@@ -40,7 +40,7 @@ public class CommandRequest {
 
   private final Map<String, String> customParameters = new HashMap<String, String>();
   private final Map<String, String> env;
-  private boolean downloadFile = false;
+  private final boolean downloadFile;
 
   private String customInput;
 
@@ -48,12 +48,14 @@ public class CommandRequest {
     this.env = env;
     this.fileData = null;
     this.parseResult = null;
+    downloadFile = false;
   }
 
   public CommandRequest(final Map<String, String> env, final byte[][] fileData) {
     this.env = env;
     this.fileData = fileData;
     this.parseResult = null;
+    downloadFile = false;
   }
 
   public CommandRequest(final GfshParseResult parseResult, final Map<String, String> env) {
@@ -69,9 +71,7 @@ public class CommandRequest {
     this.parseResult = parseResult;
 
     CliMetaData metaData = parseResult.getMethod().getDeclaredAnnotation(CliMetaData.class);
-    if (metaData != null && metaData.isFileDownloadOverHttp()) {
-      downloadFile = true;
-    }
+    this.downloadFile = (metaData != null && metaData.isFileDownloadOverHttp());
   }
 
   public String getName() {

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
index 12a0a64..8c63382 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
@@ -51,6 +51,7 @@ import org.springframework.shell.core.annotation.CliOption;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -500,7 +501,7 @@ public class ConfigCommands extends AbstractCommandsSupport {
     }
 
     @Override
-    public Result postExecution(GfshParseResult parseResult, Result commandResult) {
+    public Result postExecution(GfshParseResult parseResult, Result commandResult, Path tempFile) {
       if (commandResult.hasIncomingFiles()) {
         try {
           commandResult.saveIncomingFiles(saveDirString);

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
index bd67728..1444088 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
@@ -340,10 +340,5 @@ public final class DeployCommands extends AbstractCommandsSupport {
 
       return fileResult;
     }
-
-    @Override
-    public Result postExecution(GfshParseResult parseResult, Result commandResult) {
-      return null;
-    }
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
index e94af4f..7afb0db 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportImportClusterConfigurationCommands.java
@@ -245,7 +245,7 @@ public class ExportImportClusterConfigurationCommands extends AbstractCommandsSu
     }
 
     @Override
-    public Result postExecution(GfshParseResult parseResult, Result commandResult) {
+    public Result postExecution(GfshParseResult parseResult, Result commandResult, Path tempFile) {
       if (commandResult.hasIncomingFiles()) {
         try {
           commandResult.saveIncomingFiles(System.getProperty("user.dir"));
@@ -293,11 +293,6 @@ public class ExportImportClusterConfigurationCommands extends AbstractCommandsSu
 
       return fileResult;
     }
-
-    @Override
-    public Result postExecution(GfshParseResult parseResult, Result commandResult) {
-      return null;
-    }
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogCommand.java
new file mode 100644
index 0000000..36d071c
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogCommand.java
@@ -0,0 +1,229 @@
+/*
+ * 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.management.internal.cli.commands;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.geode.cache.Region;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.cli.ConverterHint;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.AbstractCliAroundInterceptor;
+import org.apache.geode.management.internal.cli.CliUtil;
+import org.apache.geode.management.internal.cli.GfshParseResult;
+import org.apache.geode.management.internal.cli.functions.ExportLogsFunction;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.util.ExportLogsCacheWriter;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
+import org.apache.geode.management.internal.security.ResourceOperation;
+import org.apache.geode.security.ResourcePermission;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDateTime;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+public class ExportLogCommand implements CommandMarker {
+  public final static String FORMAT = "yyyy/MM/dd/HH/mm/ss/SSS/z";
+  public final static String ONLY_DATE_FORMAT = "yyyy/MM/dd";
+  private final static Logger logger = LogService.getLogger();
+
+  @CliCommand(value = CliStrings.EXPORT_LOGS, help = CliStrings.EXPORT_LOGS__HELP)
+  @CliMetaData(shellOnly = false, isFileDownloadOverHttp = true,
+      interceptor = "org.apache.geode.management.internal.cli.commands.ExportLogCommand$ExportLogsInterceptor",
+      relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_DEBUG_UTIL})
+  @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER,
+      operation = ResourcePermission.Operation.READ)
+  public Result exportLogs(
+      @CliOption(key = CliStrings.EXPORT_LOGS__DIR, help = CliStrings.EXPORT_LOGS__DIR__HELP,
+          mandatory = false) String dirName,
+      @CliOption(key = CliStrings.EXPORT_LOGS__GROUP,
+          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+          optionContext = ConverterHint.MEMBERGROUP,
+          help = CliStrings.EXPORT_LOGS__GROUP__HELP) String[] groups,
+      @CliOption(key = CliStrings.EXPORT_LOGS__MEMBER,
+          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+          optionContext = ConverterHint.ALL_MEMBER_IDNAME,
+          help = CliStrings.EXPORT_LOGS__MEMBER__HELP) String[] memberIds,
+      @CliOption(key = CliStrings.EXPORT_LOGS__LOGLEVEL,
+          unspecifiedDefaultValue = LogService.DEFAULT_LOG_LEVEL,
+          optionContext = ConverterHint.LOG_LEVEL,
+          help = CliStrings.EXPORT_LOGS__LOGLEVEL__HELP) String logLevel,
+      @CliOption(key = CliStrings.EXPORT_LOGS__UPTO_LOGLEVEL, unspecifiedDefaultValue = "false",
+          help = CliStrings.EXPORT_LOGS__UPTO_LOGLEVEL__HELP) boolean onlyLogLevel,
+      @CliOption(key = CliStrings.EXPORT_LOGS__MERGELOG, unspecifiedDefaultValue = "false",
+          help = CliStrings.EXPORT_LOGS__MERGELOG__HELP) boolean mergeLog,
+      @CliOption(key = CliStrings.EXPORT_LOGS__STARTTIME,
+          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+          help = CliStrings.EXPORT_LOGS__STARTTIME__HELP) String start,
+      @CliOption(key = CliStrings.EXPORT_LOGS__ENDTIME,
+          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+          help = CliStrings.EXPORT_LOGS__ENDTIME__HELP) String end,
+      @CliOption(key = CliStrings.EXPORT_LOGS__LOGSONLY, unspecifiedDefaultValue = "false",
+          specifiedDefaultValue = "true",
+          help = CliStrings.EXPORT_LOGS__LOGSONLY__HELP) boolean logsOnly,
+      @CliOption(key = CliStrings.EXPORT_LOGS__STATSONLY, unspecifiedDefaultValue = "false",
+          specifiedDefaultValue = "true",
+          help = CliStrings.EXPORT_LOGS__STATSONLY__HELP) boolean statsOnly) {
+    Result result = null;
+    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    try {
+      Set<DistributedMember> targetMembers =
+          CliUtil.findMembersIncludingLocators(groups, memberIds);
+
+      Map<String, Path> zipFilesFromMembers = new HashMap<>();
+      for (DistributedMember server : targetMembers) {
+        Region region = ExportLogsFunction.createOrGetExistingExportLogsRegion(true, cache);
+
+        ExportLogsCacheWriter cacheWriter =
+            (ExportLogsCacheWriter) region.getAttributes().getCacheWriter();
+
+        cacheWriter.startFile(server.getName());
+
+        CliUtil.executeFunction(new ExportLogsFunction(),
+            new ExportLogsFunction.Args(start, end, logLevel, onlyLogLevel, logsOnly, statsOnly),
+            server).getResult();
+        Path zipFile = cacheWriter.endFile();
+        ExportLogsFunction.destroyExportLogsRegion(cache);
+
+        // only put the zipfile in the map if it is not null
+        if (zipFile != null) {
+          logger.info("Received zip file from member {}: {}", server.getId(), zipFile);
+          zipFilesFromMembers.put(server.getId(), zipFile);
+        }
+      }
+
+      Path tempDir = Files.createTempDirectory("exportedLogs");
+
+      // make sure the directory is created, so that even if there is no files unzipped to this dir,
+      // we can
+      // still zip it and send an empty zip file back to the client
+      Path exportedLogsDir = tempDir.resolve("exportedLogs");
+      FileUtils.forceMkdir(exportedLogsDir.toFile());
+
+      for (Path zipFile : zipFilesFromMembers.values()) {
+        Path unzippedMemberDir =
+            exportedLogsDir.resolve(zipFile.getFileName().toString().replace(".zip", ""));
+        ZipUtils.unzip(zipFile.toAbsolutePath().toString(), unzippedMemberDir.toString());
+        FileUtils.deleteQuietly(zipFile.toFile());
+      }
+
+      Path workingDir = Paths.get(System.getProperty("user.dir"));
+      Path exportedLogsZipFile = workingDir
+          .resolve("exportedLogs_" + System.currentTimeMillis() + ".zip").toAbsolutePath();
+
+      logger.info("Zipping into: " + exportedLogsZipFile.toString());
+      ZipUtils.zipDirectory(exportedLogsDir, exportedLogsZipFile);
+      FileUtils.deleteDirectory(tempDir.toFile());
+      result = ResultBuilder.createInfoResult(exportedLogsZipFile.toString());
+    } catch (Exception ex) {
+      logger.error(ex, ex);
+      result = ResultBuilder.createGemFireErrorResult(ex.getMessage());
+    } finally {
+      ExportLogsFunction.destroyExportLogsRegion(cache);
+    }
+    logger.debug("Exporting logs returning = {}", result);
+    return result;
+  }
+
+  /**
+   * after the export logs, will need to copy the tempFile to the desired location and delete the
+   * temp file.
+   */
+  public static class ExportLogsInterceptor extends AbstractCliAroundInterceptor {
+    @Override
+    public Result preExecution(GfshParseResult parseResult) {
+      // the arguments are in the order of it's being declared
+      Map<String, String> arguments = parseResult.getParamValueStrings();
+
+      // validates groupId and memberIds not both set
+      if (arguments.get("group") != null && arguments.get("member") != null) {
+        return ResultBuilder.createUserErrorResult("Can't specify both group and member.");
+      }
+
+      // validate log level
+      String logLevel = arguments.get("log-level");
+      if (StringUtils.isBlank(logLevel) || Level.getLevel(logLevel.toUpperCase()) == null) {
+        return ResultBuilder.createUserErrorResult("Invalid log level: " + logLevel);
+      }
+
+      // validate start date and end date
+      String start = arguments.get("start-time");
+      String end = arguments.get("end-time");
+      if (start != null && end != null) {
+        // need to make sure end is later than start
+        LocalDateTime startTime = ExportLogsFunction.parseTime(start);
+        LocalDateTime endTime = ExportLogsFunction.parseTime(end);
+        if (startTime.isAfter(endTime)) {
+          return ResultBuilder.createUserErrorResult("start-time has to be earlier than end-time.");
+        }
+      }
+
+      // validate onlyLogs and onlyStats
+      boolean onlyLogs = Boolean.parseBoolean(arguments.get("logs-only"));
+      boolean onlyStats = Boolean.parseBoolean(arguments.get("stats-only"));
+      if (onlyLogs && onlyStats) {
+        return ResultBuilder.createUserErrorResult("logs-only and stats-only can't both be true");
+      }
+
+      return ResultBuilder.createInfoResult("");
+    }
+
+    @Override
+    public Result postExecution(GfshParseResult parseResult, Result commandResult, Path tempFile) {
+      // in the command over http case, the command result is in the downloaded temp file
+      if (tempFile != null) {
+        Path dirPath;
+        String dirName = parseResult.getParamValueStrings().get("dir");
+        if (StringUtils.isBlank(dirName)) {
+          dirPath = Paths.get(System.getProperty("user.dir"));
+        } else {
+          dirPath = Paths.get(dirName);
+        }
+        String fileName = "exportedLogs_" + System.currentTimeMillis() + ".zip";
+        File exportedLogFile = dirPath.resolve(fileName).toFile();
+        try {
+          FileUtils.copyFile(tempFile.toFile(), exportedLogFile);
+          FileUtils.deleteQuietly(tempFile.toFile());
+          commandResult = ResultBuilder
+              .createInfoResult("Logs exported to: " + exportedLogFile.getAbsolutePath());
+        } catch (IOException e) {
+          logger.error(e.getMessage(), e);
+          commandResult = ResultBuilder.createGemFireErrorResult(e.getMessage());
+        }
+      } else if (commandResult.getStatus() == Result.Status.OK) {
+        commandResult = ResultBuilder.createInfoResult(
+            "Logs exported to the connected member's file system: " + commandResult.nextLine());
+      }
+      return commandResult;
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
index 91810e8..c2fb88f 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
@@ -14,15 +14,6 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
@@ -60,12 +51,20 @@ import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-
 import org.springframework.shell.core.CommandMarker;
 import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
 import org.springframework.shell.core.annotation.CliOption;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
 /**
  * 
  * @since GemFire 7.0
@@ -509,11 +508,6 @@ public class FunctionCommands implements CommandMarker {
             .createInfoResult("Destroying " + paramValueMap.get(CliStrings.DESTROY_FUNCTION__ID));
       }
     }
-
-    @Override
-    public Result postExecution(GfshParseResult parseResult, Result commandResult) {
-      return commandResult;
-    }
   }
 
   Result executeFunction(Cache cache, Set<DistributedMember> DsMembers, String functionId) {

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
index e921031..1fc6027 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
@@ -14,12 +14,9 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
 import org.apache.geode.LogWriter;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionException;
@@ -55,7 +52,6 @@ import org.apache.geode.management.internal.cli.GfshParser;
 import org.apache.geode.management.internal.cli.LogWrapper;
 import org.apache.geode.management.internal.cli.domain.StackTracesPerMember;
 import org.apache.geode.management.internal.cli.functions.ChangeLogLevelFunction;
-import org.apache.geode.management.internal.cli.functions.ExportLogsFunction;
 import org.apache.geode.management.internal.cli.functions.GarbageCollectionFunction;
 import org.apache.geode.management.internal.cli.functions.GetStackTracesFunction;
 import org.apache.geode.management.internal.cli.functions.NetstatFunction;
@@ -74,8 +70,6 @@ import org.apache.geode.management.internal.cli.result.ResultData;
 import org.apache.geode.management.internal.cli.result.ResultDataException;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
-import org.apache.geode.management.internal.cli.util.ExportLogsCacheWriter;
-import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
@@ -92,9 +86,6 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintWriter;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -122,8 +113,6 @@ import javax.management.ObjectName;
  */
 public class MiscellaneousCommands implements CommandMarker {
   public static final String NETSTAT_FILE_REQUIRED_EXTENSION = ".txt";
-  public final static String FORMAT = "yyyy/MM/dd/HH/mm/ss/SSS/z";
-  public final static String ONLY_DATE_FORMAT = "yyyy/MM/dd";
   public final static String DEFAULT_TIME_OUT = "10";
   private final static Logger logger = LogService.getLogger();
 
@@ -308,11 +297,6 @@ public class MiscellaneousCommands implements CommandMarker {
         return ResultBuilder.createInfoResult(CliStrings.SHUTDOWN__MSG__SHUTDOWN_ENTIRE_DS);
       }
     }
-
-    @Override
-    public Result postExecution(GfshParseResult parseResult, Result commandResult) {
-      return commandResult;
-    }
   }
 
   @CliCommand(value = CliStrings.GC, help = CliStrings.GC__HELP)
@@ -684,124 +668,6 @@ public class MiscellaneousCommands implements CommandMarker {
     return result;
   }
 
-  @CliCommand(value = CliStrings.EXPORT_LOGS, help = CliStrings.EXPORT_LOGS__HELP)
-  @CliMetaData(shellOnly = false, isFileDownloadOverHttp = true,
-      interceptor = "org.apache.geode.management.internal.cli.commands.MiscellaneousCommands$ExportLogsInterceptor",
-      relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_DEBUG_UTIL})
-  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
-  public Result exportLogs(
-      @CliOption(key = CliStrings.EXPORT_LOGS__DIR, help = CliStrings.EXPORT_LOGS__DIR__HELP,
-          mandatory = false) String dirName,
-      @CliOption(key = CliStrings.EXPORT_LOGS__GROUP,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          optionContext = ConverterHint.MEMBERGROUP,
-          help = CliStrings.EXPORT_LOGS__GROUP__HELP) String[] groups,
-      @CliOption(key = CliStrings.EXPORT_LOGS__MEMBER,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          optionContext = ConverterHint.ALL_MEMBER_IDNAME,
-          help = CliStrings.EXPORT_LOGS__MEMBER__HELP) String[] memberIds,
-      @CliOption(key = CliStrings.EXPORT_LOGS__LOGLEVEL,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          optionContext = ConverterHint.LOG_LEVEL,
-          help = CliStrings.EXPORT_LOGS__LOGLEVEL__HELP) String logLevel,
-      @CliOption(key = CliStrings.EXPORT_LOGS__UPTO_LOGLEVEL, unspecifiedDefaultValue = "false",
-          help = CliStrings.EXPORT_LOGS__UPTO_LOGLEVEL__HELP) boolean onlyLogLevel,
-      @CliOption(key = CliStrings.EXPORT_LOGS__MERGELOG, unspecifiedDefaultValue = "false",
-          help = CliStrings.EXPORT_LOGS__MERGELOG__HELP) boolean mergeLog,
-      @CliOption(key = CliStrings.EXPORT_LOGS__STARTTIME,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          help = CliStrings.EXPORT_LOGS__STARTTIME__HELP) String start,
-      @CliOption(key = CliStrings.EXPORT_LOGS__ENDTIME,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          help = CliStrings.EXPORT_LOGS__ENDTIME__HELP) String end) {
-    Result result = null;
-    try {
-      Set<DistributedMember> targetMembers =
-          CliUtil.findMembersIncludingLocators(groups, memberIds);
-
-
-      Map<String, Path> zipFilesFromMembers = new HashMap<>();
-      for (DistributedMember server : targetMembers) {
-        Region region = ExportLogsFunction.createOrGetExistingExportLogsRegion(true);
-
-        ExportLogsCacheWriter cacheWriter =
-            (ExportLogsCacheWriter) region.getAttributes().getCacheWriter();
-
-        cacheWriter.startFile(server.getName());
-
-        CliUtil
-            .executeFunction(new ExportLogsFunction(),
-                new ExportLogsFunction.Args(start, end, logLevel, onlyLogLevel), server)
-            .getResult();
-        Path zipFile = cacheWriter.endFile();
-        ExportLogsFunction.destroyExportLogsRegion();
-        logger.info("Recieved zip file from member " + server.getId() + ": " + zipFile.toString());
-        zipFilesFromMembers.put(server.getId(), zipFile);
-      }
-
-      Path tempDir = Files.createTempDirectory("exportedLogs");
-      Path exportedLogsDir = tempDir.resolve("exportedLogs");
-
-      for (Path zipFile : zipFilesFromMembers.values()) {
-        Path unzippedMemberDir =
-            exportedLogsDir.resolve(zipFile.getFileName().toString().replace(".zip", ""));
-        ZipUtils.unzip(zipFile.toAbsolutePath().toString(), unzippedMemberDir.toString());
-        FileUtils.deleteQuietly(zipFile.toFile());
-      }
-
-      Path workingDir = Paths.get(System.getProperty("user.dir"));
-      Path exportedLogsZipFile = workingDir
-          .resolve("exportedLogs_" + System.currentTimeMillis() + ".zip").toAbsolutePath();
-
-      logger.info("Zipping into: " + exportedLogsZipFile.toString());
-      ZipUtils.zipDirectory(exportedLogsDir, exportedLogsZipFile);
-      FileUtils.deleteDirectory(tempDir.toFile());
-      result = ResultBuilder.createInfoResult(exportedLogsZipFile.toString());
-    } catch (Exception ex) {
-      logger.error(ex, ex);
-      result = ResultBuilder.createUserErrorResult(ex.getMessage());
-    } finally {
-      ExportLogsFunction.destroyExportLogsRegion();
-    }
-    logger.debug("Exporting logs returning = {}", result);
-    return result;
-  }
-
-  /**
-   * after the export logs, will need to copy the tempFile to the desired location and delete the
-   * temp file.
-   */
-  public static class ExportLogsInterceptor extends AbstractCliAroundInterceptor {
-    @Override
-    public Result postExecution(GfshParseResult parseResult, Result commandResult, Path tempFile) {
-      // in the command over http case, the command result is in the downloaded temp file
-      if (tempFile != null) {
-        Path dirPath;
-        String dirName = parseResult.getParamValueStrings().get("dir");
-        if (StringUtils.isBlank(dirName)) {
-          dirPath = Paths.get(System.getProperty("user.dir"));
-        } else {
-          dirPath = Paths.get(dirName);
-        }
-        String fileName = "exportedLogs_" + System.currentTimeMillis() + ".zip";
-        File exportedLogFile = dirPath.resolve(fileName).toFile();
-        try {
-          FileUtils.copyFile(tempFile.toFile(), exportedLogFile);
-          FileUtils.deleteQuietly(tempFile.toFile());
-          commandResult = ResultBuilder
-              .createInfoResult("Logs exported to: " + exportedLogFile.getAbsolutePath());
-        } catch (IOException e) {
-          logger.error(e.getMessage(), e);
-          commandResult = ResultBuilder.createGemFireErrorResult(e.getMessage());
-        }
-      } else {
-        commandResult = ResultBuilder.createInfoResult(
-            "Logs exported to the connected member's file system: " + commandResult.nextLine());
-      }
-      return commandResult;
-    }
-  }
-
   /****
    * Current implementation supports writing it to a file and returning the location of the file
    *
@@ -899,11 +765,6 @@ public class MiscellaneousCommands implements CommandMarker {
         return ResultBuilder.createInfoResult("");
       }
     }
-
-    @Override
-    public Result postExecution(GfshParseResult parseResult, Result commandResult) {
-      return commandResult;
-    }
   }
 
   /***

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
index 560e8aa..62026fb 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
@@ -16,41 +16,44 @@
 
 package org.apache.geode.management.internal.cli.functions;
 
-import static java.util.stream.Collectors.toSet;
-
+import org.apache.commons.lang.StringUtils;
 import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.Scope;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.InternalRegionArguments;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.logging.InternalLogWriter;
 import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.internal.logging.LogWriterImpl;
-import org.apache.geode.management.internal.cli.commands.MiscellaneousCommands;
+import org.apache.geode.management.internal.cli.commands.ExportLogCommand;
 import org.apache.geode.management.internal.cli.util.ExportLogsCacheWriter;
 import org.apache.geode.management.internal.cli.util.LogExporter;
 import org.apache.geode.management.internal.cli.util.LogFilter;
 import org.apache.geode.management.internal.configuration.domain.Configuration;
+import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.Logger;
 
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.Serializable;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.Arrays;
-import java.util.Set;
-import java.util.stream.Stream;
 
+/**
+ * this function extracts the logs using a LogExporter which creates a zip file, and then writes the
+ * zip file bytes into a replicated region, this in effect, "stream" the zip file bytes to the
+ * locator
+ *
+ * The function only extracts .log and .gfs files under server's working directory
+ */
 public class ExportLogsFunction implements Function, InternalEntity {
   public static final String EXPORT_LOGS_REGION = "__exportLogsRegion";
   private static final Logger LOGGER = LogService.getLogger();
@@ -61,20 +64,34 @@ public class ExportLogsFunction implements Function, InternalEntity {
   @Override
   public void execute(final FunctionContext context) {
     try {
-      // TODO: change this to get cache from FunctionContext when it becomes available
       GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+      DistributionConfig config = cache.getDistributedSystem().getConfig();
 
       String memberId = cache.getDistributedSystem().getMemberId();
       LOGGER.info("ExportLogsFunction started for member {}", memberId);
 
-      Region exportLogsRegion = createOrGetExistingExportLogsRegion(false);
+      Region exportLogsRegion = createOrGetExistingExportLogsRegion(false, cache);
 
       Args args = (Args) context.getArguments();
-      LogFilter logFilter =
-          new LogFilter(args.getPermittedLogLevels(), args.getStartTime(), args.getEndTime());
-      Path workingDir = Paths.get(System.getProperty("user.dir"));
+      File baseLogFile = null;
+      File baseStatsFile = null;
+      if (args.isIncludeLogs() && !config.getLogFile().toString().isEmpty()) {
+        baseLogFile = config.getLogFile().getAbsoluteFile();
+      }
+      if (args.isIncludeStats() && !config.getStatisticArchiveFile().toString().isEmpty()) {
+        baseStatsFile = config.getStatisticArchiveFile().getAbsoluteFile();
+      }
+
+      LogFilter logFilter = new LogFilter(args.getLogLevel(), args.isThisLogLevelOnly(),
+          args.getStartTime(), args.getEndTime());
 
-      Path exportedZipFile = new LogExporter(logFilter).export(workingDir);
+      Path exportedZipFile = new LogExporter(logFilter, baseLogFile, baseStatsFile).export();
+
+      // nothing to return back
+      if (exportedZipFile == null) {
+        context.getResultSender().lastResult(null);
+        return;
+      }
 
       LOGGER.info("Streaming zipped file: " + exportedZipFile.toString());
       try (FileInputStream inputStream = new FileInputStream(exportedZipFile.toFile())) {
@@ -93,14 +110,14 @@ public class ExportLogsFunction implements Function, InternalEntity {
       context.getResultSender().lastResult(null);
 
     } catch (Exception e) {
+      e.printStackTrace();
       LOGGER.error(e);
       context.getResultSender().sendException(e);
     }
   }
 
-  public static Region createOrGetExistingExportLogsRegion(boolean isInitiatingMember)
-      throws IOException, ClassNotFoundException {
-    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+  public static Region createOrGetExistingExportLogsRegion(boolean isInitiatingMember,
+      GemFireCacheImpl cache) throws IOException, ClassNotFoundException {
 
     Region exportLogsRegion = cache.getRegion(EXPORT_LOGS_REGION);
     if (exportLogsRegion == null) {
@@ -121,16 +138,13 @@ public class ExportLogsFunction implements Function, InternalEntity {
     return exportLogsRegion;
   }
 
-  public static void destroyExportLogsRegion() {
-    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+  public static void destroyExportLogsRegion(GemFireCacheImpl cache) {
 
     Region exportLogsRegion = cache.getRegion(EXPORT_LOGS_REGION);
     if (exportLogsRegion == null) {
       return;
     }
-
     exportLogsRegion.destroyRegion();
-
   }
 
   @Override
@@ -139,59 +153,68 @@ public class ExportLogsFunction implements Function, InternalEntity {
   }
 
   public static class Args implements Serializable {
-    private String startTime;
-    private String endTime;
-    private String logLevel;
-    private boolean logLevelOnly;
-
-    public Args(String startTime, String endTime, String logLevel, boolean logLevelOnly) {
-      this.startTime = startTime;
-      this.endTime = endTime;
-      this.logLevel = logLevel;
-      this.logLevelOnly = logLevelOnly;
+    private LocalDateTime startTime;
+    private LocalDateTime endTime;
+    private Level logLevel;
+    private boolean thisLogLevelOnly;
+    private boolean includeLogs;
+    private boolean includeStats;
+
+    public Args(String startTime, String endTime, String logLevel, boolean logLevelOnly,
+        boolean logsOnly, boolean statsOnly) {
+      this.startTime = parseTime(startTime);
+      this.endTime = parseTime(endTime);
+
+      if (StringUtils.isBlank(logLevel)) {
+        this.logLevel = Level.INFO;
+      } else {
+        this.logLevel = Level.getLevel(logLevel.toUpperCase());
+      }
+      this.thisLogLevelOnly = logLevelOnly;
+
+      this.includeLogs = !statsOnly;
+      this.includeStats = !logsOnly;
     }
 
     public LocalDateTime getStartTime() {
-      return parseTime(startTime);
+      return startTime;
     }
 
     public LocalDateTime getEndTime() {
-      return parseTime(endTime);
+      return endTime;
     }
 
-    public Set<String> getPermittedLogLevels() {
-      if (logLevel == null || StringUtils.isBlank(logLevel)) {
-        return LogFilter.allLogLevels();
-      }
+    public Level getLogLevel() {
+      return logLevel;
+    }
 
-      if (logLevelOnly) {
-        return Stream.of(logLevel).collect(toSet());
-      }
+    public boolean isThisLogLevelOnly() {
+      return thisLogLevelOnly;
+    }
 
-      // Return all log levels lower than or equal to the specified logLevel
-      return Arrays.stream(InternalLogWriter.levelNames).filter((String level) -> {
-        int logLevelCode = LogWriterImpl.levelNameToCode(level);
-        int logLevelCodeThreshold = LogWriterImpl.levelNameToCode(logLevel);
+    public boolean isIncludeLogs() {
+      return includeLogs;
+    }
 
-        return logLevelCode >= logLevelCodeThreshold;
-      }).collect(toSet());
+    public boolean isIncludeStats() {
+      return includeStats;
     }
+  }
 
-    private static LocalDateTime parseTime(String dateString) {
-      if (dateString == null) {
-        return null;
-      }
+  public static LocalDateTime parseTime(String dateString) {
+    if (dateString == null) {
+      return null;
+    }
 
+    try {
+      SimpleDateFormat df = new SimpleDateFormat(ExportLogCommand.FORMAT);
+      return df.parse(dateString).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+    } catch (ParseException e) {
       try {
-        SimpleDateFormat df = new SimpleDateFormat(MiscellaneousCommands.FORMAT);
+        SimpleDateFormat df = new SimpleDateFormat(ExportLogCommand.ONLY_DATE_FORMAT);
         return df.parse(dateString).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
-      } catch (ParseException e) {
-        try {
-          SimpleDateFormat df = new SimpleDateFormat(MiscellaneousCommands.ONLY_DATE_FORMAT);
-          return df.parse(dateString).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
-        } catch (ParseException e1) {
-          return null;
-        }
+      } catch (ParseException e1) {
+        return null;
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/LogFileFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/LogFileFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/LogFileFunction.java
deleted file mode 100644
index 41ffeb4..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/LogFileFunction.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * 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.management.internal.cli.functions;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.logging.log4j.Logger;
-
-import org.apache.geode.GemFireIOException;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.execute.Function;
-import org.apache.geode.cache.execute.FunctionContext;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.InternalEntity;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.management.internal.MBeanJMXAdapter;
-import org.apache.geode.management.internal.cli.GfshParser;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.ResultBuilder;
-import org.apache.geode.management.internal.cli.util.ReadWriteFile;
-
-// TODO:LOG:CONVERT: supports log-file only -- update to support Log4J 2 as well?
-/**
- * 
- * @since GemFire 7.0
- */
-public class LogFileFunction implements Function, InternalEntity {
-  private static final Logger logger = LogService.getLogger();
-
-  public static final String ID = LogFileFunction.class.getName();
-  private static final long serialVersionUID = 1L;
-
-  @Override
-  public void execute(final FunctionContext context) {
-
-    Thread waiting = new Thread(new Runnable() {
-      public void run() {
-        final boolean isDebugEnabled = logger.isDebugEnabled();
-        try {
-          Cache cache = CacheFactory.getAnyInstance();
-          if (isDebugEnabled) {
-            logger.debug("Exporting logs LogFileFunction");
-          }
-          Object[] args = (Object[]) context.getArguments();
-          String targetDirName = ((String) args[0]);
-          String logLevel = ((String) args[1]);
-          String onlyLogLevel = ((String) args[2]);
-          int numOfLogFilesForTesting = ((Number) args[5]).intValue();
-
-          InternalDistributedSystem ds = (InternalDistributedSystem) cache.getDistributedSystem();
-          if (ds != null && ds.isConnected()) {
-            // write all the file in the same directory with extension .log
-            String filterString = ds.getConfig().getLogFile().getName();
-            final String filterStr = filterString.substring(0, filterString.lastIndexOf(".") > 0
-                ? filterString.lastIndexOf(".") : filterString.length() - 1);
-
-            File dir = ds.getConfig().getLogFile(); // get log file object
-            if (dir == null) {
-              context.getResultSender()
-                  .lastResult(CliStrings.format(
-                      CliStrings.EXPORT_LOGS__MSG__FAILED_TO_EXPORT_LOG_FILES_FOR_MEMBER_0,
-                      ds.getMemberId()));
-              return;
-            }
-            try {
-              dir = dir.getAbsoluteFile(); // get absolute log file
-            } catch (SecurityException se) {
-              context.getResultSender().lastResult(se.getMessage());
-              return;
-            }
-            String logFileDir = dir.getParent(); // get log file directory
-            if (logFileDir == null)
-              logFileDir = "/"; // this works in Windows too
-            if (isDebugEnabled) {
-              logger.debug(
-                  "For member={}: Exporting logs LogFileFunction logFileDir={}, filterStr={}",
-                  ds.getMemberId(), logFileDir, filterStr);
-            }
-
-            dir = new File(logFileDir); // get log file directory object
-            FilenameFilter filter = new FilenameFilter() {
-              public boolean accept(File dir, String name) {
-                // get those files which start with the name of the log file
-                return name.startsWith(filterStr) && name.endsWith(".log");
-              }
-            };
-            // create target directory if does not exists
-            if (isDebugEnabled) {
-              logger.debug("For member={}: Exporting logs LogFileFunction targetDirName={}",
-                  ds.getMemberId(), targetDirName);
-            }
-            File targetDir = new File(targetDirName);
-            if (targetDir.exists() == false) {
-              if (targetDir.mkdirs() == true) {
-                String logsWritten = processLogs(dir, logFileDir, targetDirName, cache, logLevel,
-                    onlyLogLevel, filter, ((Number) args[3]).toString(),
-                    ((Number) args[4]).toString(), numOfLogFilesForTesting);
-                if (isDebugEnabled) {
-                  logger.debug(
-                      "For member={}: Done with Exporting logs LogFileFunction targetDirName={}",
-                      ds.getMemberId(), targetDirName);
-                }
-                context.getResultSender().lastResult(logsWritten);
-              } else {
-                if (isDebugEnabled) {
-                  logger.debug("For member={}{} {}", ds.getMemberId(),
-                      CliStrings.EXPORT_LOGS__MSG__TARGET_DIR_CANNOT_BE_CREATED, targetDirName);
-                }
-                context.getResultSender().lastResult(ResultBuilder.createInfoResult(CliStrings
-                    .format(CliStrings.EXPORT_LOGS__MSG__TARGET_DIR_CANNOT_BE_CREATED, targetDir)));
-              }
-            } else {
-              String logsWritten = processLogs(dir, logFileDir, targetDirName, cache, logLevel,
-                  onlyLogLevel, filter, ((Number) args[3]).toString(),
-                  ((Number) args[4]).toString(), numOfLogFilesForTesting);
-              if (isDebugEnabled) {
-                logger.debug(
-                    "For member={}: Done with Exporting logs LogFileFunction targetDirName={} logsWritten={}",
-                    ds.getMemberId(), targetDirName, logsWritten);
-              }
-              context.getResultSender().lastResult(logsWritten);
-            }
-          } else {
-            context.getResultSender().lastResult(
-                LocalizedStrings.InternalDistributedSystem_THIS_CONNECTION_TO_A_DISTRIBUTED_SYSTEM_HAS_BEEN_DISCONNECTED
-                    .toLocalizedString());
-          }
-
-        } catch (Exception e) {
-          context.getResultSender().lastResult(e.getMessage());
-        }
-      }
-    });
-    try {
-      final boolean isDebugEnabled = logger.isDebugEnabled();
-      if (isDebugEnabled) {
-        logger.debug("For member={}: started copying log files",
-            ((InternalDistributedSystem) CacheFactory.getAnyInstance().getDistributedSystem())
-                .getMemberId());
-      }
-      waiting.start();
-      waiting.join();
-      if (isDebugEnabled) {
-        logger.debug("For member={}: done with Exporting all log files",
-            ((InternalDistributedSystem) CacheFactory.getAnyInstance().getDistributedSystem())
-                .getMemberId());
-      }
-    } catch (Exception e) {
-      context.getResultSender().lastResult(e.getMessage());
-    } finally {
-      if (waiting.isAlive()) {
-        waiting.interrupt();
-      }
-    }
-  }
-
-  public String processLogs(File dir, String logFileDir, String targetDirName, Cache cache,
-      String logLevel, String onlyLogLevel, FilenameFilter filter, String startTime, String endTime,
-      int numOfLogFilesForTesting) {
-    try {
-      final boolean isDebugEnabled = logger.isDebugEnabled();
-      String[] logsInDir = dir.list(filter);
-      if (isDebugEnabled) {
-        logger.debug("LogFileFunction  processLogs logsInDir={} sample={}", logsInDir.length,
-            logsInDir[0]);
-      }
-      StringBuilder logsWritten = new StringBuilder();
-      if (logsInDir.length > 0) {
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss-ms");
-        // numOfLogFilesForTesting is used to limit the files that get copied while running entire
-        // dunit suite
-        // from user perspective numOfLogFilesForTesting is of no use
-        if (isDebugEnabled) {
-          logger.debug("LogFileFunction  before copy  numOfLogFilesForTesting={}",
-              numOfLogFilesForTesting);
-        }
-
-        for (int i = 0, j = 0; i < logsInDir.length
-            && (j < numOfLogFilesForTesting || numOfLogFilesForTesting == 0); i++, j++) {
-          String fileName = new String(logFileDir + File.separator + logsInDir[i]);
-
-          String logToBeWritten = targetDirName + File.separator
-              + MBeanJMXAdapter
-                  .getMemberNameOrId(cache.getDistributedSystem().getDistributedMember())
-              + "_" + logsInDir[i].substring(0, logsInDir[i].length() - 4) + "_"
-              + sdf.format(new java.util.Date())
-              + logsInDir[i].substring(logsInDir[i].length() - 4, logsInDir[i].length());
-
-          // create a new process for log read and write
-          if (isDebugEnabled) {
-            logger.debug("LogFileFunction  processLogs fileName={} logToBeWritten={}", fileName,
-                logToBeWritten);
-          }
-          List<String> commandList = new ArrayList<String>();
-          commandList.add(System.getProperty("java.home") + File.separatorChar + "bin"
-              + File.separatorChar + "java");
-          commandList.add("-classpath");
-          commandList.add(System.getProperty("java.class.path", "."));
-          commandList.add(ReadWriteFile.class.getName());
-          commandList.add(fileName);
-          commandList.add(logToBeWritten);
-          commandList.add(logLevel);
-          commandList.add(onlyLogLevel);
-          commandList.add(startTime);
-          commandList.add(endTime);
-          ProcessBuilder procBuilder = new ProcessBuilder(commandList);
-
-          StringBuilder output = new StringBuilder();
-          String errorString = new String(), resultString = new String();
-          try {
-            Process copyLogProcess = procBuilder.redirectErrorStream(true).start();
-            if (isDebugEnabled) {
-              logger.debug("LogFileFunction  processLogs fileName before process waitfor");
-            }
-            int compacterProcessStatus = copyLogProcess.waitFor();
-            if (isDebugEnabled) {
-              logger.debug(
-                  "LogFileFunction  processLogs fileName after process waitfor destroy compacterProcessStatus={}",
-                  compacterProcessStatus);
-            }
-            InputStream inputStream = copyLogProcess.getInputStream();
-            BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
-            String line = null;
-
-            while ((line = br.readLine()) != null) {
-              output.append(line).append(GfshParser.LINE_SEPARATOR);
-            }
-            copyLogProcess.destroy();
-            if (isDebugEnabled) {
-              logger.debug(
-                  "LogFileFunction  processLogs fileName after process waitfor after destroy compacterProcessStatus={}",
-                  compacterProcessStatus);
-            }
-
-          } catch (IOException e) {
-            errorString =
-                (new GemFireIOException(" Exception in LogFileFunction is " + e, e)).toString();
-          } finally {
-            if (errorString != null) {
-              output.append(errorString).append(GfshParser.LINE_SEPARATOR);
-            }
-            resultString = output.toString();
-          }
-          // merge files which are written successfully
-          if (resultString.contains("Sucessfully written file")) {
-            if (isDebugEnabled) {
-              logger.debug("LogFileFunction wrote file logToBeWritten={}", logToBeWritten);
-            }
-            logsWritten.append(logToBeWritten + ";");
-          } else {
-            if (isDebugEnabled) {
-              logger.debug("LogFileFunction wrote file logToBeWritten={} resultString={}",
-                  logToBeWritten, resultString);
-            }
-          }
-        }
-
-      } else {
-        if (isDebugEnabled) {
-          logger
-              .debug(CliStrings.format("No file was found for exporting in export logs function"));
-        }
-      }
-      if (isDebugEnabled) {
-        logger.debug(CliStrings.format("logsWritten=" + logsWritten));
-      }
-      return logsWritten.toString();
-    } catch (Exception e) {
-      return ("Exception in LogFileFunction processLogs " + e.getMessage());
-    }
-  }
-
-  @Override
-  public String getId() {
-    return LogFileFunction.ID;
-  }
-
-  @Override
-  public boolean hasResult() {
-    return true;
-  }
-
-  @Override
-  public boolean optimizeForWrite() {
-    // no need of optimization since read-only.
-    return false;
-  }
-
-  @Override
-  public boolean isHA() {
-    return false;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
index 3dc42d6..7696aa8 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
@@ -1401,7 +1401,7 @@ public class CliStrings {
   public static final String EXPORT_LOGS__MSG__CANNOT_EXECUTE = "Cannot execute";
   public static final String EXPORT_LOGS__LOGLEVEL = LOG_LEVEL;
   public static final String EXPORT_LOGS__LOGLEVEL__HELP =
-      "Minimum level of log entries to export. Valid values are: none, error, info, config , fine, finer and finest.  The default is \"info\".";
+      "Minimum level of log entries to export. Valid values are: fatal, error, warn, info, debug, trace and all.  The default is \"INFO\".";
   public static final String EXPORT_LOGS__UPTO_LOGLEVEL = "only-log-level";
   public static final String EXPORT_LOGS__UPTO_LOGLEVEL__HELP =
       "Whether to only include those entries that exactly match the --log-level specified.";
@@ -1430,6 +1430,10 @@ public class CliStrings {
       "Groups specified have no members";
   public static final String EXPORT_LOGS__MSG__FAILED_TO_EXPORT_LOG_FILES_FOR_MEMBER_0 =
       "Could not export log files for member {0}";
+  public static final String EXPORT_LOGS__LOGSONLY = "logs-only";
+  public static final String EXPORT_LOGS__STATSONLY = "stats-only";
+  public static final String EXPORT_LOGS__LOGSONLY__HELP = "Whether to only export logs";
+  public static final String EXPORT_LOGS__STATSONLY__HELP = "Whether to only export statistics";
 
   /* export stack-trace command */
   public static final String EXPORT_STACKTRACE = "export stack-traces";

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java
index 4b827a9..fa0f3b2 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/RemoteExecutionStrategy.java
@@ -97,7 +97,7 @@ public class RemoteExecutionStrategy {
         }
 
         if (interceptor != null) {
-          Result postExecResult = interceptor.postExecution(gfshParseResult, result);
+          Result postExecResult = interceptor.postExecution(gfshParseResult, result, null);
           if (postExecResult != null) {
             if (Status.ERROR.equals(postExecResult.getStatus())) {
               logWrapper.warning(postExecResult.toString(), null);

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
index 6445454..ad78efd 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
@@ -115,11 +115,6 @@ public class GfshExecutionStrategy implements ExecutionStrategy {
       } else {
         logWrapper.warning(e.getMessage());
       }
-    } catch (RuntimeException e) {
-      Gfsh.getCurrentInstance().logWarning("Exception occurred. " + e.getMessage(), e);
-      // Log other runtime exception in gfsh log
-      logWrapper.warning("Error occurred while executing command : "
-          + ((GfshParseResult) parseResult).getUserInput(), e);
     } catch (Exception e) {
       Gfsh.getCurrentInstance().logWarning("Unexpected exception occurred. " + e.getMessage(), e);
       // Log other exceptions in gfsh log

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java
index 178bb4a..f6e42ab 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsCacheWriter.java
@@ -30,6 +30,7 @@ import java.nio.file.Path;
 
 public class ExportLogsCacheWriter extends CacheWriterAdapter implements Serializable {
   private Path currentFile;
+  private boolean isEmpty = true;
   private BufferedOutputStream currentOutputStream;
 
   @Override
@@ -46,6 +47,7 @@ public class ExportLogsCacheWriter extends CacheWriterAdapter implements Seriali
             "Value must be a byte[].  Recieved " + newValue.getClass().getCanonicalName());
       }
       currentOutputStream.write((byte[]) newValue);
+      isEmpty = false;
     } catch (IOException e) {
       throw new CacheWriterException(e);
     }
@@ -58,6 +60,7 @@ public class ExportLogsCacheWriter extends CacheWriterAdapter implements Seriali
 
     currentFile = Files.createTempDirectory(memberId).resolve(memberId + ".zip");
     currentOutputStream = new BufferedOutputStream(new FileOutputStream(currentFile.toFile()));
+    isEmpty = true;
   }
 
   public Path endFile() {
@@ -66,7 +69,8 @@ public class ExportLogsCacheWriter extends CacheWriterAdapter implements Seriali
     IOUtils.closeQuietly(currentOutputStream);
     currentOutputStream = null;
     currentFile = null;
-
+    if (isEmpty)
+      return null;
     return completedFile;
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
index f30d686..a4bef75 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogExporter.java
@@ -19,62 +19,76 @@ package org.apache.geode.management.internal.cli.util;
 import static java.util.stream.Collectors.toList;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.Scope;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.cache.InternalRegionArguments;
 import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.management.internal.configuration.domain.Configuration;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.logging.log4j.Logger;
 
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
+import java.io.File;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.text.ParseException;
 import java.util.List;
 import java.util.function.Predicate;
 import java.util.stream.Stream;
 
+/**
+ * this LogExporter only finds the .log and .gfs files under in the same directory of the base files
+ * it doesn't use the base file's filename patterns to find the related logs/stats yet.
+ */
 public class LogExporter {
   private static final Logger LOGGER = LogService.getLogger();
 
   private final LogFilter logFilter;
-
-  public LogExporter(LogFilter logFilter) throws ParseException {
+  private final File baseLogFile;
+  private final File baseStatsFile;
+
+  /**
+   * @param logFilter: the filter that's used to check if we need to accept the file or the logLine
+   * @param baseLogFile: if not null, we will export the logs in that directory
+   * @param baseStatsFile: if not null, we will export stats in that directory
+   * @throws ParseException
+   */
+  public LogExporter(LogFilter logFilter, File baseLogFile, File baseStatsFile)
+      throws ParseException {
+    assert logFilter != null;
     this.logFilter = logFilter;
+    this.baseLogFile = baseLogFile;
+    this.baseStatsFile = baseStatsFile;
   }
 
-  public Path export(Path workingDir) throws IOException {
-    LOGGER.debug("Working directory is {}", workingDir);
-
+  /**
+   *
+   * @return Path to the zip file that has all the filtered files, null if no files are selected to
+   *         export.
+   * @throws IOException
+   */
+  public Path export() throws IOException {
     Path tempDirectory = Files.createTempDirectory("exportLogs");
 
-    for (Path logFile : findLogFiles(workingDir)) {
-      Path filteredLogFile = tempDirectory.resolve(logFile.getFileName());
-
-      if (this.logFilter == null) {
-        Files.copy(logFile, filteredLogFile);
-      } else {
+    if (baseLogFile != null) {
+      for (Path logFile : findLogFiles(baseLogFile.toPath().getParent())) {
+        Path filteredLogFile = tempDirectory.resolve(logFile.getFileName());
         writeFilteredLogFile(logFile, filteredLogFile);
       }
     }
 
-    for (Path statFile : findStatFiles(workingDir)) {
-      Files.copy(statFile, tempDirectory);
+    if (baseStatsFile != null) {
+      for (Path statFile : findStatFiles(baseStatsFile.toPath().getParent())) {
+        Files.copy(statFile, tempDirectory.resolve(statFile.getFileName()));
+      }
     }
 
-    Path zipFile = Files.createTempFile("logExport", ".zip");
-    ZipUtils.zipDirectory(tempDirectory, zipFile);
-    LOGGER.info("Zipped files to: " + zipFile);
-
+    Path zipFile = null;
+    if (tempDirectory.toFile().listFiles().length > 0) {
+      zipFile = Files.createTempFile("logExport", ".zip");
+      ZipUtils.zipDirectory(tempDirectory, zipFile);
+      LOGGER.info("Zipped files to: " + zipFile);
+    }
 
     FileUtils.deleteDirectory(tempDirectory.toFile());
 

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java
index 2436530..0da6ddf 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogFilter.java
@@ -16,19 +16,16 @@
 
 package org.apache.geode.management.internal.cli.util;
 
-import static java.util.stream.Collectors.toSet;
-
-import org.apache.geode.internal.logging.InternalLogWriter;
 import org.apache.geode.internal.logging.LogService;
+import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.Logger;
 
-import java.io.IOException;
+import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
 import java.time.Instant;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
-import java.util.Arrays;
-import java.util.Set;
 
 public class LogFilter {
   public enum LineFilterResult {
@@ -37,15 +34,22 @@ public class LogFilter {
 
   private static final Logger LOGGER = LogService.getLogger();
 
-  private final Set<String> permittedLogLevels;
+  private final Level thisLogLevel;
+  private final boolean thisLevelOnly;
   private final LocalDateTime startDate;
   private final LocalDateTime endDate;
 
   private LineFilterResult resultOfPreviousLine = LineFilterResult.LINE_ACCEPTED;
 
-  public LogFilter(Set<String> permittedLogLevels, LocalDateTime startDate, LocalDateTime endDate) {
-    this.permittedLogLevels = (permittedLogLevels == null || permittedLogLevels.isEmpty())
-        ? allLogLevels() : permittedLogLevels;
+  public LogFilter(Level logLevel, LocalDateTime startDate, LocalDateTime endDate) {
+    this(logLevel, false, startDate, endDate);
+  }
+
+  public LogFilter(Level logLevel, boolean thisLevelOnly, LocalDateTime startDate,
+      LocalDateTime endDate) {
+    assert logLevel != null;
+    this.thisLogLevel = logLevel;
+    this.thisLevelOnly = thisLevelOnly;
     this.startDate = startDate;
     this.endDate = endDate;
   }
@@ -68,7 +72,7 @@ public class LogFilter {
     return acceptsLogEntry(result.getLogLevel(), result.getLogTimestamp());
   }
 
-  protected LineFilterResult acceptsLogEntry(String logLevel, LocalDateTime logTimestamp) {
+  protected LineFilterResult acceptsLogEntry(Level logLevel, LocalDateTime logTimestamp) {
     if (logTimestamp == null || logLevel == null) {
       throw new IllegalArgumentException();
     }
@@ -80,8 +84,13 @@ public class LogFilter {
     } else if (startDate != null && logTimestamp.isBefore(startDate)) {
       result = LineFilterResult.LINE_REJECTED;
     } else {
-      result = permittedLogLevels.contains(logLevel) ? LineFilterResult.LINE_ACCEPTED
-          : LineFilterResult.LINE_REJECTED;
+      if (thisLevelOnly) {
+        result = logLevel.intLevel() == thisLogLevel.intLevel() ? LineFilterResult.LINE_ACCEPTED
+            : LineFilterResult.LINE_REJECTED;
+      } else {
+        result = logLevel.isMoreSpecificThan(thisLogLevel) ? LineFilterResult.LINE_ACCEPTED
+            : LineFilterResult.LINE_REJECTED;
+      }
     }
 
     resultOfPreviousLine = result;
@@ -90,24 +99,42 @@ public class LogFilter {
   }
 
   public boolean acceptsFile(Path file) {
-    if (startDate == null) {
+    if (startDate == null && endDate == null) {
       return true;
     }
-    try {
-      return (getEndTimeOf(file).isAfter(startDate));
-    } catch (IOException e) {
-      LOGGER.error("Unable to determine lastModified time", e);
-      return true;
+
+    if (endDate == null) {
+      return getEndTimeOf(file).isAfter(startDate);
+    }
+
+    if (startDate == null) {
+      return getStartTimeOf(file).isBefore(endDate);
     }
+
+    return (getEndTimeOf(file).isAfter(startDate) && getStartTimeOf(file).isBefore(endDate));
+
   }
 
-  private static LocalDateTime getEndTimeOf(Path file) throws IOException {
-    long lastModifiedMillis = file.toFile().lastModified();
-    return Instant.ofEpochMilli(lastModifiedMillis).atZone(ZoneId.systemDefault())
-        .toLocalDateTime();
+  private static LocalDateTime getEndTimeOf(Path file) {
+    try {
+      long lastModifiedMillis = file.toFile().lastModified();
+      return Instant.ofEpochMilli(lastModifiedMillis).atZone(ZoneId.systemDefault())
+          .toLocalDateTime();
+    } catch (Exception e) {
+      LOGGER.error("Unable to determine lastModified time", e);
+      return LocalDateTime.MAX;
+    }
   }
 
-  public static Set<String> allLogLevels() {
-    return Arrays.stream(InternalLogWriter.levelNames).collect(toSet());
+  private static LocalDateTime getStartTimeOf(Path file) {
+    try {
+      BasicFileAttributes attributes = Files.readAttributes(file, BasicFileAttributes.class);
+      long lastModifiedMillis = attributes.creationTime().toMillis();
+      return Instant.ofEpochMilli(lastModifiedMillis).atZone(ZoneId.systemDefault())
+          .toLocalDateTime();
+    } catch (Exception e) {
+      LOGGER.error("Unable to determine creation time", e);
+      return LocalDateTime.MIN;
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java
index 6c15d15..bbeb5c7 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java
@@ -16,11 +16,19 @@
 
 package org.apache.geode.management.internal.cli.util;
 
+import org.apache.logging.log4j.Level;
+
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+/**
+ * this will extract convert the deprecated InternalLogWriter's level into log4j level as well.
+ */
 public class LogLevelExtractor {
   private static Pattern LOG_PATTERN =
       Pattern.compile("^\\[(\\S*)\\s+([\\d\\/]+)\\s+([\\d:\\.]+)\\s+(\\S+)");
@@ -44,15 +52,15 @@ public class LogLevelExtractor {
   }
 
   public static class Result {
-    private String logLevel;
+    private Level logLevel;
     private LocalDateTime logTimestamp;
 
     public Result(String logLevel, LocalDateTime logTimestamp) {
-      this.logLevel = logLevel;
+      this.logLevel = LogLevelExtractor.getLevel(logLevel);
       this.logTimestamp = logTimestamp;
     }
 
-    public String getLogLevel() {
+    public Level getLogLevel() {
       return logLevel;
     }
 
@@ -61,5 +69,26 @@ public class LogLevelExtractor {
     }
 
   }
+
+  private static Map<String, Level> LEVELS = new HashMap<>();
+  static {
+    // put all the log4j levels in the map first
+    Arrays.stream(Level.values()).forEach(level -> {
+      LEVELS.put(level.name(), level);
+    });
+    // put all the other levels geode has been using and map them to log4j levels
+    LEVELS.put("SEVERE", Level.FATAL);
+    LEVELS.put("WARNING", Level.WARN);
+    LEVELS.put("CONFIG", Level.DEBUG);
+    LEVELS.put("FINE", Level.DEBUG);
+    LEVELS.put("FINER", Level.TRACE);
+    LEVELS.put("FINEST", Level.TRACE);
+  }
+
+  public static Level getLevel(String level) {
+    Level log4jLevel = LEVELS.get(level.toUpperCase());
+    // make sure any unrecognizable log level is assigned a most specific level
+    return log4jLevel == null ? Level.OFF : log4jLevel;
+  }
 }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/bf788176/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
new file mode 100644
index 0000000..f3a5934
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
@@ -0,0 +1,101 @@
+/*
+ * 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.management.internal.web.controllers;
+
+import org.apache.geode.internal.lang.StringUtils;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+@Controller("exportLogController")
+@RequestMapping(AbstractCommandsController.REST_API_VERSION)
+public class ExportLogController extends AbstractCommandsController {
+
+  @RequestMapping(method = RequestMethod.GET, value = "/logs")
+  public ResponseEntity<InputStreamResource> exportLogs(
+      @RequestParam(value = CliStrings.EXPORT_LOGS__DIR, required = false) final String directory,
+      @RequestParam(value = CliStrings.EXPORT_LOGS__GROUP, required = false) final String[] groups,
+      @RequestParam(value = CliStrings.EXPORT_LOGS__MEMBER,
+          required = false) final String memberNameId,
+      @RequestParam(value = CliStrings.EXPORT_LOGS__LOGLEVEL,
+          required = false) final String logLevel,
+      @RequestParam(value = CliStrings.EXPORT_LOGS__UPTO_LOGLEVEL,
+          defaultValue = "false") final Boolean onlyLogLevel,
+      @RequestParam(value = CliStrings.EXPORT_LOGS__MERGELOG,
+          defaultValue = "false") final Boolean mergeLog,
+      @RequestParam(value = CliStrings.EXPORT_LOGS__STARTTIME,
+          required = false) final String startTime,
+      @RequestParam(value = CliStrings.EXPORT_LOGS__ENDTIME, required = false) final String endTime,
+      @RequestParam(value = CliStrings.EXPORT_LOGS__LOGSONLY,
+          required = false) final boolean logsOnly,
+      @RequestParam(value = CliStrings.EXPORT_LOGS__STATSONLY,
+          required = false) final boolean statsOnly) {
+    final CommandStringBuilder command = new CommandStringBuilder(CliStrings.EXPORT_LOGS);
+
+    command.addOption(CliStrings.EXPORT_LOGS__DIR, decode(directory));
+
+    if (hasValue(groups)) {
+      command.addOption(CliStrings.EXPORT_LOGS__GROUP,
+          StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+    }
+
+    if (hasValue(memberNameId)) {
+      command.addOption(CliStrings.EXPORT_LOGS__MEMBER, memberNameId);
+    }
+
+    if (hasValue(logLevel)) {
+      command.addOption(CliStrings.EXPORT_LOGS__LOGLEVEL, logLevel);
+    }
+
+    command.addOption(CliStrings.EXPORT_LOGS__UPTO_LOGLEVEL, String.valueOf(onlyLogLevel));
+    command.addOption(CliStrings.EXPORT_LOGS__MERGELOG, String.valueOf(mergeLog));
+    command.addOption(CliStrings.EXPORT_LOGS__LOGSONLY, String.valueOf(logsOnly));
+    command.addOption(CliStrings.EXPORT_LOGS__STATSONLY, String.valueOf(statsOnly));
+
+    if (hasValue(startTime)) {
+      command.addOption(CliStrings.EXPORT_LOGS__STARTTIME, startTime);
+    }
+
+    if (hasValue(endTime)) {
+      command.addOption(CliStrings.EXPORT_LOGS__ENDTIME, endTime);
+    }
+
+    // the result is json string from CommandResult
+    String result = processCommand(command.toString());
+
+    // parse the result to get the file path. This file Path should always exist in the file system
+    String filePath = ResultBuilder.fromJson(result).nextLine().trim();
+
+    HttpHeaders respHeaders = new HttpHeaders();
+    try {
+      InputStreamResource isr = new InputStreamResource(new FileInputStream(new File(filePath)));
+      return new ResponseEntity<InputStreamResource>(isr, respHeaders, HttpStatus.OK);
+    } catch (Exception ex) {
+      throw new RuntimeException("IOError writing file to output stream", ex);
+    }
+  }
+}


[22/50] [abbrv] geode git commit: GEODE-2593: add port range to AvailablePortHelper to fix testUDPPortRange

Posted by ds...@apache.org.
GEODE-2593: add port range to AvailablePortHelper to fix testUDPPortRange


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/47697d40
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/47697d40
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/47697d40

Branch: refs/heads/feature/GEODE-1969
Commit: 47697d40acf53cb367ec584ec72efafbb47f4022
Parents: 950b8d7
Author: Kirk Lund <kl...@apache.org>
Authored: Fri Mar 3 17:36:07 2017 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Mar 7 11:16:12 2017 -0800

----------------------------------------------------------------------
 .../distributed/DistributedSystemDUnitTest.java |  50 ++--
 .../geode/internal/AvailablePortHelper.java     |  64 ++++-
 .../AvailablePortHelperIntegrationTest.java     | 264 +++++++++++++++++++
 3 files changed, 361 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/47697d40/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
index c57ad17..c1ea5e6 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java
@@ -14,6 +14,10 @@
  */
 package org.apache.geode.distributed;
 
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.internal.AvailablePort.*;
+import static org.junit.Assert.*;
+
 import org.apache.geode.CancelException;
 import org.apache.geode.GemFireConfigException;
 import org.apache.geode.SystemConnectException;
@@ -22,7 +26,12 @@ import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache30.CacheSerializableRunnable;
-import org.apache.geode.distributed.internal.*;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.DistributionException;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.distributed.internal.SerialDistributionMessage;
+import org.apache.geode.distributed.internal.SizeableRunnable;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.distributed.internal.membership.gms.MembershipManagerHelper;
 import org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger;
@@ -30,12 +39,19 @@ import org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipMan
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.net.SocketCreator;
-import org.apache.geode.test.dunit.*;
+import org.apache.geode.test.dunit.DistributedTestUtils;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.LogWriterUtils;
+import org.apache.geode.test.dunit.RMIException;
+import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.geode.test.junit.categories.MembershipTest;
-import org.junit.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import java.net.Inet4Address;
@@ -46,20 +62,19 @@ import java.util.Enumeration;
 import java.util.Properties;
 import java.util.concurrent.TimeoutException;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.internal.AvailablePort.SOCKET;
-import static org.junit.Assert.*;
-
 /**
  * Tests the functionality of the {@link DistributedSystem} class.
- *
- * @see InternalDistributedSystemJUnitTest
- *
  */
 @Category({DistributedTest.class, MembershipTest.class})
 public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
 
-  public void postSetUp() throws Exception {
+  @Before
+  public void before() throws Exception {
+    disconnectAllFromDS();
+  }
+
+  @After
+  public void after() throws Exception {
     disconnectAllFromDS();
   }
 
@@ -298,18 +313,21 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
 
   @Test
   public void testUDPPortRange() throws Exception {
+    int[] unicastPort = AvailablePortHelper.getRandomAvailableTCPPortRange(3, true);
+
     Properties config = new Properties();
-    int unicastPort =
-        AvailablePort.getRandomAvailablePort(SOCKET, AvailablePort.getAddress(SOCKET), true);
     config.put(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
     // Minimum 3 ports required in range for UDP, FD_SOCK and TcpConduit.
-    config.setProperty(MEMBERSHIP_PORT_RANGE, "" + unicastPort + "-" + (unicastPort + 2));
+    config.setProperty(MEMBERSHIP_PORT_RANGE, unicastPort[0] + "-" + unicastPort[2]);
+
     InternalDistributedSystem system = getSystem(config);
     DistributionManager dm = (DistributionManager) system.getDistributionManager();
     InternalDistributedMember idm = dm.getDistributionManagerId();
+
+    assertTrue(unicastPort[0] <= idm.getPort() && idm.getPort() <= unicastPort[2]);
+    assertTrue(unicastPort[0] <= idm.getPort() && idm.getDirectChannelPort() <= unicastPort[2]);
+
     system.disconnect();
-    assertTrue(unicastPort <= idm.getPort() && idm.getPort() <= unicastPort + 2);
-    assertTrue(unicastPort <= idm.getPort() && idm.getDirectChannelPort() <= unicastPort + 2);
   }
 
   /***

http://git-wip-us.apache.org/repos/asf/geode/blob/47697d40/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelper.java b/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelper.java
index e09a7a0..6a1c1d4 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelper.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelper.java
@@ -14,6 +14,10 @@
  */
 package org.apache.geode.internal;
 
+import static org.apache.geode.distributed.internal.DistributionConfig.*;
+import static org.apache.geode.internal.AvailablePort.*;
+
+import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -66,11 +70,69 @@ public class AvailablePortHelper {
     List<Keeper> result = new ArrayList<Keeper>();
     while (result.size() < count) {
       result.add(AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET,
-          AvailablePort.getAddress(AvailablePort.SOCKET), useMembershipPortRange));
+          getAddress(AvailablePort.SOCKET), useMembershipPortRange));
+    }
+    return result;
+  }
+
+  public static int[] getRandomAvailableTCPPortRange(final int count) {
+    return getRandomAvailableTCPPortRange(count, false);
+  }
+
+  public static int[] getRandomAvailableTCPPortRange(final int count,
+      final boolean useMembershipPortRange) {
+    List<Keeper> list = getRandomAvailableTCPPortRangeKeepers(count, useMembershipPortRange);
+    int[] ports = new int[list.size()];
+    int i = 0;
+    for (Keeper k : list) {
+      ports[i] = k.getPort();
+      k.release();
+      i++;
+    }
+    return ports;
+  }
+
+  public static List<Keeper> getRandomAvailableTCPPortRangeKeepers(final int count) {
+    return getRandomAvailableTCPPortRangeKeepers(count, false);
+  }
+
+  public static List<Keeper> getRandomAvailableTCPPortRangeKeepers(final int count,
+      final boolean useMembershipPortRange) {
+    List<Keeper> result = new ArrayList<>();
+
+    InetAddress addr = getAddress(AvailablePort.SOCKET);
+
+    int lowerBound =
+        useMembershipPortRange ? DEFAULT_MEMBERSHIP_PORT_RANGE[0] : AVAILABLE_PORTS_LOWER_BOUND;
+
+    int upperBound =
+        useMembershipPortRange ? DEFAULT_MEMBERSHIP_PORT_RANGE[1] : AVAILABLE_PORTS_UPPER_BOUND;
+
+    for (int i = lowerBound; i <= upperBound; i++) {
+      for (int j = 0; j < count && ((i + j) <= upperBound); j++) {
+        int port = i + j;
+        Keeper keeper = isPortKeepable(port, SOCKET, addr);
+        if (keeper == null) {
+          releaseKeepers(result);
+          result.clear();
+          break;
+        }
+        result.add(keeper);
+        if (result.size() == count) {
+          return result;
+        }
+      }
     }
+
     return result;
   }
 
+  private static void releaseKeepers(List<Keeper> keepers) {
+    for (Keeper keeper : keepers) {
+      keeper.release();
+    }
+  }
+
   /**
    * Returns array of unique randomly available tcp ports of specified count.
    */

http://git-wip-us.apache.org/repos/asf/geode/blob/47697d40/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelperIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelperIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelperIntegrationTest.java
new file mode 100644
index 0000000..d6cfddc
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/AvailablePortHelperIntegrationTest.java
@@ -0,0 +1,264 @@
+/*
+ * 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.internal;
+
+import static org.apache.geode.distributed.internal.DistributionConfig.*;
+import static org.apache.geode.internal.AvailablePort.*;
+import static org.apache.geode.internal.AvailablePortHelper.*;
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.internal.AvailablePort.Keeper;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+@RunWith(JUnitParamsRunner.class)
+public class AvailablePortHelperIntegrationTest {
+
+  private Set<ServerSocket> serverSockets;
+
+  @Before
+  public void before() throws Exception {
+    this.serverSockets = new HashSet<>();
+  }
+
+  @After
+  public void after() throws Exception {
+    for (ServerSocket serverSocket : this.serverSockets) {
+      try {
+        if (serverSocket != null && !serverSocket.isClosed()) {
+          serverSocket.close();
+        }
+      } catch (IOException ignore) {
+        System.err.println("Unable to close " + serverSocket);
+      }
+    }
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_zero(final boolean useMembershipPortRange)
+      throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(0, useMembershipPortRange);
+    assertThat(results).isEmpty();
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_one_returnsOne(final boolean useMembershipPortRange)
+      throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(1, useMembershipPortRange);
+    assertThat(results).hasSize(1);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_two_returnsTwo(final boolean useMembershipPortRange)
+      throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(2, useMembershipPortRange);
+    assertThat(results).hasSize(2);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_many_returnsMany(final boolean useMembershipPortRange)
+      throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(10, useMembershipPortRange);
+    assertThat(results).hasSize(10);
+    assertPortsAreUsable(results);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_returnsUniquePorts(
+      final boolean useMembershipPortRange) throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(10, useMembershipPortRange);
+
+    Set<Integer> ports = new HashSet<>();
+    for (int port : results) {
+      ports.add(port);
+    }
+
+    assertThat(ports).hasSize(results.length);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRange_returnsConsecutivePorts(
+      final boolean useMembershipPortRange) throws Exception {
+    int[] results = getRandomAvailableTCPPortRange(10, useMembershipPortRange);
+
+    List<Integer> ports = new ArrayList<>();
+    for (int port : results) {
+      if (useMembershipPortRange) {
+        assertThat(port).isGreaterThanOrEqualTo(DEFAULT_MEMBERSHIP_PORT_RANGE[0])
+            .isLessThanOrEqualTo(DEFAULT_MEMBERSHIP_PORT_RANGE[1]);
+      } else {
+        assertThat(port).isGreaterThanOrEqualTo(AVAILABLE_PORTS_LOWER_BOUND)
+            .isLessThanOrEqualTo(AVAILABLE_PORTS_UPPER_BOUND);
+      }
+      ports.add(port);
+    }
+
+    assertThat(ports).hasSize(10);
+
+    int previousPort = 0;
+    for (int port : ports) {
+      if (previousPort != 0) {
+        assertThat(port).isEqualTo(previousPort + 1);
+      }
+      previousPort = port;
+    }
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_zero(final boolean useMembershipPortRange)
+      throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(0, useMembershipPortRange);
+    assertThat(results).isEmpty();
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_one_returnsOne(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(1, useMembershipPortRange);
+    assertThat(results).hasSize(1);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_two_returnsTwo(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(2, useMembershipPortRange);
+    assertThat(results).hasSize(2);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_many_returnsMany(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(10, useMembershipPortRange);
+    assertThat(results).hasSize(10);
+    assertKeepersAreUsable(results);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_returnsUsableKeeper(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(1, useMembershipPortRange);
+    assertKeepersAreUsable(results);
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_returnsUniqueKeepers(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(10, useMembershipPortRange);
+
+    Set<Integer> ports = new HashSet<>();
+    for (Keeper keeper : results) {
+      ports.add(keeper.getPort());
+    }
+
+    assertThat(ports).hasSize(results.size());
+  }
+
+  @Test
+  @Parameters({"true", "false"})
+  public void getRandomAvailableTCPPortRangeKeepers_returnsConsecutivePorts(
+      final boolean useMembershipPortRange) throws Exception {
+    List<Keeper> results = getRandomAvailableTCPPortRangeKeepers(10, useMembershipPortRange);
+
+    List<Integer> ports = new ArrayList<>();
+    for (Keeper keeper : results) {
+      assertThat(keeper).isNotNull();
+      int port = keeper.getPort();
+      if (useMembershipPortRange) {
+        assertThat(port).isGreaterThanOrEqualTo(DEFAULT_MEMBERSHIP_PORT_RANGE[0])
+            .isLessThanOrEqualTo(DEFAULT_MEMBERSHIP_PORT_RANGE[1]);
+      } else {
+        assertThat(port).isGreaterThanOrEqualTo(AVAILABLE_PORTS_LOWER_BOUND)
+            .isLessThanOrEqualTo(AVAILABLE_PORTS_UPPER_BOUND);
+      }
+      ports.add(port);
+    }
+
+    assertThat(ports).hasSize(10);
+
+    int previousPort = 0;
+    for (int port : ports) {
+      if (previousPort != 0) {
+        assertThat(port).isEqualTo(previousPort + 1);
+      }
+      previousPort = port;
+    }
+  }
+
+  private void assertPortsAreUsable(int[] ports) throws IOException {
+    for (int port : ports) {
+      assertPortIsUsable(port);
+    }
+  }
+
+  private void assertPortIsUsable(int port) throws IOException {
+    ServerSocket serverSocket = createServerSocket();
+    serverSocket.setReuseAddress(true);
+
+    serverSocket.bind(new InetSocketAddress(port));
+
+    assertThat(serverSocket.isBound()).isTrue();
+    assertThat(serverSocket.isClosed()).isFalse();
+    serverSocket.close();
+    assertThat(serverSocket.isClosed()).isTrue();
+  }
+
+  private void assertKeepersAreUsable(Collection<Keeper> keepers) throws IOException {
+    for (Keeper keeper : keepers) {
+      assertKeeperIsUsable(keeper);
+    }
+  }
+
+  private void assertKeeperIsUsable(Keeper keeper) throws IOException {
+    int port = keeper.getPort();
+    keeper.release();
+    assertPortIsUsable(port);
+  }
+
+  private ServerSocket createServerSocket() throws IOException {
+    ServerSocket serverSocket = new ServerSocket();
+    this.serverSockets.add(serverSocket);
+    return serverSocket;
+  }
+
+}