You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/12/12 22:38:40 UTC

[01/19] geode git commit: GEODE-2190: add FlakyTest category to flaky test [Forced Update!]

Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-1027 65e5450cc -> 1f49cbcc8 (forced update)


GEODE-2190: add FlakyTest category to flaky test


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

Branch: refs/heads/feature/GEODE-1027
Commit: 2075ee348e221d662468ead4c18b56923d3d7329
Parents: ef74181
Author: Kirk Lund <kl...@apache.org>
Authored: Thu Dec 8 09:49:01 2016 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Thu Dec 8 09:49:01 2016 -0800

----------------------------------------------------------------------
 .../cache/wan/parallel/ParallelWANPropagationDUnitTest.java         | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/2075ee34/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelWANPropagationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelWANPropagationDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelWANPropagationDUnitTest.java
index bbd65fe..6a190ef 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelWANPropagationDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelWANPropagationDUnitTest.java
@@ -285,6 +285,7 @@ public class ParallelWANPropagationDUnitTest extends WANTestBase {
    * 
    * @throws Exception
    */
+  @Category(FlakyTest.class)
   @Test
   public void testParallelPropagationWithLocalCacheClosedAndRebuilt() throws Exception {
     Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));


[03/19] geode git commit: GEODE-2175: wait for results from other members is not needed in result collector. It's already handled by Function framework.

Posted by kl...@apache.org.
GEODE-2175: wait for results from other members is not needed in result collector. It's already handled by Function framework.


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

Branch: refs/heads/feature/GEODE-1027
Commit: 1d951e334334393c2052307988a21c1cd1f11985
Parents: f22809a
Author: zhouxh <gz...@pivotal.io>
Authored: Thu Dec 8 14:47:56 2016 -0800
Committer: zhouxh <gz...@pivotal.io>
Committed: Thu Dec 8 14:47:56 2016 -0800

----------------------------------------------------------------------
 .../TopEntriesFunctionCollector.java            |  43 +-----
 .../TopEntriesFunctionCollectorJUnitTest.java   | 137 +------------------
 2 files changed, 4 insertions(+), 176 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/1d951e33/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/TopEntriesFunctionCollector.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/TopEntriesFunctionCollector.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/TopEntriesFunctionCollector.java
index d4a7008..66c4c0a 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/TopEntriesFunctionCollector.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/TopEntriesFunctionCollector.java
@@ -47,9 +47,6 @@ public class TopEntriesFunctionCollector
   // Use this instance to perform reduce operation
   final CollectorManager<TopEntriesCollector> manager;
 
-  // latch to wait till all results are collected
-  private final CountDownLatch waitForResults = new CountDownLatch(1);
-
   final String id;
 
   // Instance of gemfire cache to check status and other utility methods
@@ -83,36 +80,11 @@ public class TopEntriesFunctionCollector
 
   @Override
   public TopEntries getResult() throws FunctionException {
-    try {
-      waitForResults.await();
-    } catch (InterruptedException e) {
-      logger.debug("Interrupted while waiting for result collection", e);
-      Thread.currentThread().interrupt();
-      if (cache != null) {
-        cache.getCancelCriterion().checkCancelInProgress(e);
-      }
-      throw new FunctionException(e);
-    }
-
     return aggregateResults();
   }
 
   @Override
   public TopEntries getResult(long timeout, TimeUnit unit) throws FunctionException {
-    try {
-      boolean result = waitForResults.await(timeout, unit);
-      if (!result) {
-        throw new FunctionException("Did not receive results from all members within wait time");
-      }
-    } catch (InterruptedException e) {
-      logger.debug("Interrupted while waiting for result collection", e);
-      Thread.currentThread().interrupt();
-      if (cache != null) {
-        cache.getCancelCriterion().checkCancelInProgress(e);
-      }
-      throw new FunctionException(e);
-    }
-
     return aggregateResults();
   }
 
@@ -128,20 +100,11 @@ public class TopEntriesFunctionCollector
   }
 
   @Override
-  public void endResults() {
-    synchronized (subResults) {
-      waitForResults.countDown();
-    }
-  }
+  public void endResults() {}
 
   @Override
   public void clearResults() {
     synchronized (subResults) {
-      if (waitForResults.getCount() == 0) {
-        throw new IllegalStateException(
-            "This collector is closed and cannot accept anymore results");
-      }
-
       subResults.clear();
     }
   }
@@ -149,10 +112,6 @@ public class TopEntriesFunctionCollector
   @Override
   public void addResult(DistributedMember memberID, TopEntriesCollector resultOfSingleExecution) {
     synchronized (subResults) {
-      if (waitForResults.getCount() == 0) {
-        throw new IllegalStateException(
-            "This collector is closed and cannot accept anymore results");
-      }
       subResults.add(resultOfSingleExecution);
     }
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/1d951e33/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/TopEntriesFunctionCollectorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/TopEntriesFunctionCollectorJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/TopEntriesFunctionCollectorJUnitTest.java
index af868e2..bf08877 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/TopEntriesFunctionCollectorJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/TopEntriesFunctionCollectorJUnitTest.java
@@ -63,25 +63,8 @@ public class TopEntriesFunctionCollectorJUnitTest {
   @Test
   public void testGetResultsBlocksTillEnd() throws Exception {
     final TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector();
-    final CountDownLatch insideThread = new CountDownLatch(1);
-    final CountDownLatch resultReceived = new CountDownLatch(1);
-    Thread resultClient = new Thread(new Runnable() {
-      @Override
-      public void run() {
-        insideThread.countDown();
-        collector.getResult();
-        resultReceived.countDown();
-      }
-    });
-    resultClient.start();
-
-    insideThread.await(1, TimeUnit.SECONDS);
-    assertEquals(0, insideThread.getCount());
-    assertEquals(1, resultReceived.getCount());
-
-    collector.endResults();
-    resultReceived.await(1, TimeUnit.SECONDS);
-    assertEquals(0, resultReceived.getCount());
+    TopEntries merged = collector.getResult();
+    assertEquals(0, merged.size());
   }
 
   @Test
@@ -94,111 +77,11 @@ public class TopEntriesFunctionCollectorJUnitTest {
     final CountDownLatch resultReceived = new CountDownLatch(1);
 
     final AtomicReference<TopEntries> result = new AtomicReference<>();
-
-    Thread resultClient = new Thread(new Runnable() {
-      @Override
-      public void run() {
-        insideThread.countDown();
-        result.set(collector.getResult(1, TimeUnit.SECONDS));
-        resultReceived.countDown();
-      }
-    });
-    resultClient.start();
-
-    insideThread.await(1, TimeUnit.SECONDS);
-    assertEquals(0, insideThread.getCount());
-    assertEquals(1, resultReceived.getCount());
-
-    collector.endResults();
-
-    resultReceived.await(1, TimeUnit.SECONDS);
-    assertEquals(0, resultReceived.getCount());
-
-    TopEntries merged = result.get();
+    TopEntries merged = collector.getResult(1, TimeUnit.SECONDS);
     assertEquals(4, merged.size());
     TopEntriesJUnitTest.verifyResultOrder(merged.getHits(), r1_1, r2_1, r1_2, r2_2);
   }
 
-  @Test(expected = FunctionException.class)
-  public void testGetResultsWaitInterrupted() throws Exception {
-    interruptWhileWaiting(false);
-  }
-
-  @Test(expected = FunctionException.class)
-  public void testGetResultsTimedWaitInterrupted() throws Exception {
-    interruptWhileWaiting(false);
-  }
-
-  private void interruptWhileWaiting(final boolean timedWait)
-      throws InterruptedException, Exception {
-    GemFireCacheImpl mockCache = mock(GemFireCacheImpl.class);
-    final TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector(null, mockCache);
-
-    final CountDownLatch insideThread = new CountDownLatch(1);
-    final CountDownLatch endGetResult = new CountDownLatch(1);
-    final AtomicReference<Exception> exception = new AtomicReference<>();
-
-    Thread resultClient = new Thread(new Runnable() {
-      @Override
-      public void run() {
-        insideThread.countDown();
-        try {
-          if (timedWait) {
-            collector.getResult(1, TimeUnit.SECONDS);
-          } else {
-            collector.getResult();
-          }
-        } catch (FunctionException e) {
-          exception.set(e);
-          endGetResult.countDown();
-        }
-      }
-    });
-    resultClient.start();
-
-    insideThread.await(1, TimeUnit.SECONDS);
-    assertEquals(0, insideThread.getCount());
-    assertEquals(1, endGetResult.getCount());
-
-    CancelCriterion mockCriterion = mock(CancelCriterion.class);
-    when(mockCache.getCancelCriterion()).thenReturn(mockCriterion);
-    resultClient.interrupt();
-    endGetResult.await(1, TimeUnit.SECONDS);
-    assertEquals(0, endGetResult.getCount());
-    throw exception.get();
-  }
-
-  @Test(expected = FunctionException.class)
-  public void expectErrorAfterWaitTime() throws Exception {
-    final TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector(null);
-
-    final CountDownLatch insideThread = new CountDownLatch(1);
-    final CountDownLatch endGetResult = new CountDownLatch(1);
-    final AtomicReference<Exception> exception = new AtomicReference<>();
-
-    Thread resultClient = new Thread(new Runnable() {
-      @Override
-      public void run() {
-        insideThread.countDown();
-        try {
-          collector.getResult(10, TimeUnit.MILLISECONDS);
-        } catch (FunctionException e) {
-          exception.set(e);
-          endGetResult.countDown();
-        }
-      }
-    });
-    resultClient.start();
-
-    insideThread.await(1, TimeUnit.SECONDS);
-    assertEquals(0, insideThread.getCount());
-    assertEquals(1, endGetResult.getCount());
-
-    endGetResult.await(1, TimeUnit.SECONDS);
-    assertEquals(0, endGetResult.getCount());
-    throw exception.get();
-  }
-
   @Test
   public void mergeShardAndLimitResults() throws Exception {
     LuceneFunctionContext<TopEntriesCollector> context =
@@ -299,20 +182,6 @@ public class TopEntriesFunctionCollectorJUnitTest {
     collector.getResult();
   }
 
-  @Test(expected = IllegalStateException.class)
-  public void addResultDisallowedAfterEndResult() {
-    TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector();
-    collector.endResults();
-    collector.addResult(null, new TopEntriesCollector(null));
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void clearResultDisallowedAfterEndResult() {
-    TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector();
-    collector.endResults();
-    collector.clearResults();
-  }
-
   @Test
   public void testCollectorName() {
     GemFireCacheImpl mockCache = mock(GemFireCacheImpl.class);


[06/19] geode git commit: GEODE-1984: Fix Issue Make GatewaySender destroy a public API

Posted by kl...@apache.org.
GEODE-1984: Fix Issue Make GatewaySender destroy a public API

    1. Making destory API public
    2. Added a new gfsh WAN command destroyGatewaySender
    3. Impleted GatewaySenderDestroyFunction, which first stop gatewaysender
       and then call destroy on the same.
    4. Added a WAN Rest Controller for destroy gatewaysender
    5. Removed the need of explicit casting of sender to AbstractGatewaySender for calling
       destroy API
    6. Renamed Test WanCommandCreateGatewaySenderDUnitTest to WanCommandCreateDestroyGatewaySenderDUnitTest
    7. Each applicable test now also calls destroy gfsh command and verfies the result
    8. Minor changes in the logging for each tests


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

Branch: refs/heads/feature/GEODE-1027
Commit: 0eb952a6e5524c66c8520c9e0d8cf09780ef8624
Parents: 1d951e3
Author: adongre <ad...@apache.org>
Authored: Sat Dec 3 19:38:39 2016 +0530
Committer: adongre <ad...@apache.org>
Committed: Fri Dec 9 05:08:36 2016 +0530

----------------------------------------------------------------------
 .../internal/AsyncEventQueueImpl.java           |   2 +-
 .../apache/geode/cache/wan/GatewaySender.java   |  15 +
 .../cache/wan/AbstractGatewaySender.java        |   1 +
 .../internal/cli/commands/WanCommands.java      |  59 +-
 .../functions/GatewaySenderDestroyFunction.java |  90 ++
 .../GatewaySenderDestroyFunctionArgs.java       |  33 +
 .../internal/cli/i18n/CliStrings.java           |  18 +
 .../controllers/ShellCommandsController.java    |   2 +
 .../web/controllers/WanCommandsController.java  |  24 +
 .../codeAnalysis/sanctionedSerializables.txt    |   2 +
 .../cli/commands/golden-help-offline.properties |  21 +
 .../cli/commands/golden-help-online.properties  |   6 +
 .../geode/internal/cache/wan/WANTestBase.java   |   2 +-
 .../wan/wancommand/WANCommandTestBase.java      |  35 +
 ...mandCreateDestroyGatewaySenderDUnitTest.java | 921 +++++++++++++++++++
 .../WanCommandCreateGatewaySenderDUnitTest.java | 663 -------------
 16 files changed, 1223 insertions(+), 671 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-core/src/main/java/org/apache/geode/cache/asyncqueue/internal/AsyncEventQueueImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/asyncqueue/internal/AsyncEventQueueImpl.java b/geode-core/src/main/java/org/apache/geode/cache/asyncqueue/internal/AsyncEventQueueImpl.java
index a5f0497..2eb53be 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/asyncqueue/internal/AsyncEventQueueImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/asyncqueue/internal/AsyncEventQueueImpl.java
@@ -191,7 +191,7 @@ public class AsyncEventQueueImpl implements AsyncEventQueue {
   }
 
   public void destroy() {
-    ((AbstractGatewaySender) this.sender).destroy();
+    this.sender.destroy();
   }
 
   public boolean isBucketSorted() {

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-core/src/main/java/org/apache/geode/cache/wan/GatewaySender.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/wan/GatewaySender.java b/geode-core/src/main/java/org/apache/geode/cache/wan/GatewaySender.java
index d950ef3..f9f8f91 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/wan/GatewaySender.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/wan/GatewaySender.java
@@ -400,4 +400,19 @@ public interface GatewaySender {
 
   public int getMaxParallelismForReplicatedRegion();
 
+
+  /**
+   * Destroys the GatewaySender. Before destroying the sender, caller needs to to ensure that the
+   * sender is stopped so that all the resources (threads, connection pool etc.) will be released
+   * properly. Stopping the sender is not handled in the destroy. Destroy is carried out in
+   * following steps: 1. Take the lifeCycleLock. 2. If the sender is attached to any application
+   * region, throw an exception. 3. Close the GatewaySenderAdvisor. 4. Remove the sender from the
+   * cache. 5. Destroy the region underlying the GatewaySender.
+   * <p>
+   * In case of ParallelGatewaySender, the destroy operation does distributed destroy of the QPR. In
+   * case of SerialGatewaySender, the queue region is destroyed locally.
+   */
+  public void destroy();
+
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySender.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySender.java b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySender.java
index e1c9010..c4d503e 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySender.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySender.java
@@ -510,6 +510,7 @@ public abstract class AbstractGatewaySender implements GatewaySender, Distributi
    * In case of ParallelGatewaySender, the destroy operation does distributed destroy of the QPR. In
    * case of SerialGatewaySender, the queue region is destroyed locally.
    */
+  @Override
   public void destroy() {
     try {
       this.getLifeCycleLock().writeLock().lock();

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
index db1087d..dd6a327 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
@@ -44,11 +44,7 @@ import org.apache.geode.management.internal.MBeanJMXAdapter;
 import org.apache.geode.management.internal.SystemManagementService;
 import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.LogWrapper;
-import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
-import org.apache.geode.management.internal.cli.functions.GatewayReceiverCreateFunction;
-import org.apache.geode.management.internal.cli.functions.GatewayReceiverFunctionArgs;
-import org.apache.geode.management.internal.cli.functions.GatewaySenderCreateFunction;
-import org.apache.geode.management.internal.cli.functions.GatewaySenderFunctionArgs;
+import org.apache.geode.management.internal.cli.functions.*;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.CommandResultException;
 import org.apache.geode.management.internal.cli.result.CompositeResultData;
@@ -1071,6 +1067,57 @@ public class WanCommands implements CommandMarker {
     return result;
   }
 
+
+  @CliCommand(value = CliStrings.DESTROY_GATEWAYSENDER,
+      help = CliStrings.DESTROY_GATEWAYSENDER__HELP)
+  @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN, writesToSharedConfiguration = true)
+  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  public Result destroyGatewaySender(
+      @CliOption(key = CliStrings.DESTROY_GATEWAYSENDER__GROUP,
+          optionContext = ConverterHint.MEMBERGROUP,
+          help = CliStrings.DESTROY_GATEWAYSENDER__GROUP__HELP) @CliMetaData(
+              valueSeparator = ",") String[] onGroups,
+      @CliOption(key = CliStrings.DESTROY_GATEWAYSENDER__MEMBER,
+          optionContext = ConverterHint.MEMBERIDNAME,
+          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+          help = CliStrings.DESTROY_GATEWAYSENDER__MEMBER__HELP) @CliMetaData(
+              valueSeparator = ",") String onMember,
+      @CliOption(key = CliStrings.DESTROY_GATEWAYSENDER__ID, mandatory = true,
+          optionContext = ConverterHint.GATEWAY_SENDER_ID,
+          help = CliStrings.DESTROY_GATEWAYSENDER__ID__HELP) String id) {
+    Result result = null;
+    try {
+      GatewaySenderDestroyFunctionArgs gatewaySenderDestroyFunctionArgs =
+          new GatewaySenderDestroyFunctionArgs(id);
+
+      Set<DistributedMember> membersToDestroyGatewaySenderOn =
+          CliUtil.findAllMatchingMembers(onGroups, onMember == null ? null : onMember.split(","));
+
+      ResultCollector<?, ?> resultCollector =
+          CliUtil.executeFunction(GatewaySenderDestroyFunction.INSTANCE,
+              gatewaySenderDestroyFunctionArgs, membersToDestroyGatewaySenderOn);
+      @SuppressWarnings("unchecked")
+      List<CliFunctionResult> gatewaySenderDestroyResults =
+          (List<CliFunctionResult>) resultCollector.getResult();
+
+      TabularResultData tabularResultData = ResultBuilder.createTabularResultData();
+      final String errorPrefix = "ERROR: ";
+      for (CliFunctionResult gatewaySenderDestroyResult : gatewaySenderDestroyResults) {
+        boolean success = gatewaySenderDestroyResult.isSuccessful();
+        tabularResultData.accumulate("Member", gatewaySenderDestroyResult.getMemberIdOrName());
+        tabularResultData.accumulate("Status",
+            (success ? "" : errorPrefix) + gatewaySenderDestroyResult.getMessage());
+      }
+      result = ResultBuilder.buildResult(tabularResultData);
+    } catch (IllegalArgumentException e) {
+      LogWrapper.getInstance().info(e.getMessage());
+      result = ResultBuilder.createUserErrorResult(e.getMessage());
+    } catch (CommandResultException crex) {
+      result = handleCommandResultException(crex);
+    }
+    return result;
+  }
+
   private TabularResultData buildReceiverStatus(String memberId, GatewayReceiverMXBean bean,
       TabularResultData resultData) {
     resultData.accumulate(CliStrings.RESULT_HOST_MEMBER, memberId);
@@ -1179,7 +1226,7 @@ public class WanCommands implements CommandMarker {
       CliStrings.STOP_GATEWAYSENDER, CliStrings.CREATE_GATEWAYRECEIVER,
       CliStrings.START_GATEWAYRECEIVER, CliStrings.STOP_GATEWAYRECEIVER, CliStrings.LIST_GATEWAY,
       CliStrings.STATUS_GATEWAYSENDER, CliStrings.STATUS_GATEWAYRECEIVER,
-      CliStrings.LOAD_BALANCE_GATEWAYSENDER})
+      CliStrings.LOAD_BALANCE_GATEWAYSENDER, CliStrings.DESTROY_GATEWAYSENDER})
   public boolean isWanCommandsAvailable() {
     boolean isAvailable = true; // always available on server
     if (CliUtil.isGfshVM()) {

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
new file mode 100644
index 0000000..ba393fe
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
@@ -0,0 +1,90 @@
+/*
+ * 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 org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.execute.FunctionAdapter;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.ResultSender;
+import org.apache.geode.cache.wan.GatewaySender;
+import org.apache.geode.internal.InternalEntity;
+import org.apache.geode.internal.cache.wan.GatewaySenderException;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.management.internal.cli.CliUtil;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.logging.log4j.Logger;
+
+public class GatewaySenderDestroyFunction extends FunctionAdapter implements InternalEntity {
+  private static final long serialVersionUID = 1459761440357690134L;
+
+  private static final Logger logger = LogService.getLogger();
+  private static final String ID = GatewaySenderDestroyFunction.class.getName();
+  public static GatewaySenderDestroyFunction INSTANCE = new GatewaySenderDestroyFunction();
+
+  @Override
+  public void execute(FunctionContext context) {
+    ResultSender<Object> resultSender = context.getResultSender();
+
+    Cache cache = CacheFactory.getAnyInstance();
+    String memberNameOrId =
+        CliUtil.getMemberNameOrId(cache.getDistributedSystem().getDistributedMember());
+
+    GatewaySenderDestroyFunctionArgs gatewaySenderDestroyFunctionArgs =
+        (GatewaySenderDestroyFunctionArgs) context.getArguments();
+
+    try {
+      GatewaySender gatewaySender =
+          cache.getGatewaySender(gatewaySenderDestroyFunctionArgs.getId());
+      if (gatewaySender != null) {
+        gatewaySender.stop();
+        gatewaySender.destroy();
+      } else {
+        throw new GatewaySenderException(
+            "GateWaySender with Id  " + gatewaySenderDestroyFunctionArgs.getId() + " not found");
+      }
+      resultSender.lastResult(new CliFunctionResult(memberNameOrId, true,
+          CliStrings.format(CliStrings.DESTROY_GATEWAYSENDER__MSG__GATEWAYSENDER_0_DESTROYED_ON_1,
+              new Object[] {gatewaySenderDestroyFunctionArgs.getId(), memberNameOrId})));
+
+    } catch (GatewaySenderException gse) {
+      resultSender.lastResult(handleException(memberNameOrId, gse.getMessage(), gse));
+    } catch (Exception e) {
+      String exceptionMsg = e.getMessage();
+      if (exceptionMsg == null) {
+        exceptionMsg = CliUtil.stackTraceAsString(e);
+      }
+      resultSender.lastResult(handleException(memberNameOrId, exceptionMsg, e));
+    }
+  }
+
+  private CliFunctionResult handleException(final String memberNameOrId, final String exceptionMsg,
+      final Exception e) {
+    if (e != null && logger.isDebugEnabled()) {
+      logger.debug(e.getMessage(), e);
+    }
+    if (exceptionMsg != null) {
+      return new CliFunctionResult(memberNameOrId, false, exceptionMsg);
+    }
+
+    return new CliFunctionResult(memberNameOrId);
+  }
+
+  @Override
+  public String getId() {
+    return ID;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunctionArgs.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunctionArgs.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunctionArgs.java
new file mode 100644
index 0000000..cf3fa24
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunctionArgs.java
@@ -0,0 +1,33 @@
+/*
+ * 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.Serializable;
+
+public class GatewaySenderDestroyFunctionArgs implements Serializable {
+
+  private static final long serialVersionUID = 3848480256348119530L;
+  private String id;
+
+
+  public GatewaySenderDestroyFunctionArgs(String id) {
+    this.id = id;
+  }
+
+  public String getId() {
+    return id;
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/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 68dd438..c53b309 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
@@ -2235,6 +2235,24 @@ public class CliStrings {
   public static final String START_GATEWAYSENDER__MEMBER__HELP =
       "Name/Id of the member on which to start the Gateway Sender.";
 
+
+  /* destroy gateway-sender */
+  public static final String DESTROY_GATEWAYSENDER = "destroy gateway-sender";
+  public static final String DESTROY_GATEWAYSENDER__HELP =
+      "Destroy the Gateway Sender on a member or members.";
+  public static final String DESTROY_GATEWAYSENDER__GROUP = "group";
+  public static final String DESTROY_GATEWAYSENDER__GROUP__HELP =
+      "Group(s) of members on which to destroy the Gateway Sender.";
+  public static final String DESTROY_GATEWAYSENDER__MEMBER = "member";
+  public static final String DESTROY_GATEWAYSENDER__MEMBER__HELP =
+      "Name/Id of the member on which to destroy the Gateway Sender.";
+  public static final String DESTROY_GATEWAYSENDER__ID = "id";
+  public static final String DESTROY_GATEWAYSENDER__ID__HELP = "Id of the GatewaySender.";
+  public static final String DESTROY_GATEWAYSENDER__MSG__GATEWAYSENDER_0_DESTROYED_ON_1 =
+      "GatewaySender \"{0}\" destroyed on \"{1}\"";
+
+
+
   /* start gfmon command */
   public static final String START_PULSE = "start pulse";
   public static final String START_PULSE__ERROR =

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
index 577aed6..0ecb77f 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
@@ -273,6 +273,8 @@ public class ShellCommandsController extends AbstractCommandsController {
             HttpMethod.POST))
         .add(new Link(CliStrings.CREATE_GATEWAYSENDER, toUri("/gateways/senders", scheme),
             HttpMethod.POST))
+        .add(new Link(CliStrings.DESTROY_GATEWAYSENDER, toUri("/gateways/senders/{id}", scheme),
+            HttpMethod.DELETE))
         .add(new Link(CliStrings.LOAD_BALANCE_GATEWAYSENDER,
             toUri("/gateways/senders/{id}?op=load-balance", scheme), HttpMethod.POST))
         .add(new Link(CliStrings.PAUSE_GATEWAYSENDER,

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/WanCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/WanCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/WanCommandsController.java
index 03dc5d0..fa5aa57 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/WanCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/WanCommandsController.java
@@ -268,6 +268,30 @@ public class WanCommandsController extends AbstractCommandsController {
     return processCommand(command.toString());
   }
 
+
+  @RequestMapping(method = RequestMethod.DELETE, value = "/gateways/senders/{id}")
+  @ResponseBody
+  public String destroyGatewaySender(@PathVariable("id") final String gatewaySenderId,
+      @RequestParam(value = CliStrings.DESTROY_GATEWAYSENDER__GROUP,
+          required = false) final String[] groups,
+      @RequestParam(value = CliStrings.DESTROY_GATEWAYSENDER__MEMBER,
+          required = false) final String[] members) {
+    CommandStringBuilder command = new CommandStringBuilder(CliStrings.DESTROY_GATEWAYSENDER);
+    command.addOption(CliStrings.CREATE_GATEWAYSENDER__ID, gatewaySenderId);
+
+    if (hasValue(groups)) {
+      command.addOption(CliStrings.CREATE_GATEWAYSENDER__GROUP,
+          StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
+    }
+
+    if (hasValue(members)) {
+      command.addOption(CliStrings.CREATE_GATEWAYSENDER__MEMBER,
+          StringUtils.concat(members, StringUtils.COMMA_DELIMITER));
+    }
+    return processCommand(command.toString());
+  }
+
+
   @RequestMapping(method = RequestMethod.POST, value = "/gateways/senders/{id}",
       params = "op=load-balance")
   @ResponseBody

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/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 3f92148..5ce46bf 100644
--- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
+++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
@@ -569,6 +569,8 @@ org/apache/geode/management/internal/cli/functions/GarbageCollectionFunction,tru
 org/apache/geode/management/internal/cli/functions/GatewayReceiverCreateFunction,true,8746830191680509335
 org/apache/geode/management/internal/cli/functions/GatewayReceiverFunctionArgs,true,-5158224572470173267,bindAddress:java/lang/String,endPort:java/lang/Integer,gatewayTransportFilters:java/lang/String[],manualStart:java/lang/Boolean,maximumTimeBetweenPings:java/lang/Integer,socketBufferSize:java/lang/Integer,startPort:java/lang/Integer
 org/apache/geode/management/internal/cli/functions/GatewaySenderCreateFunction,true,8746830191680509335
+org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction,true,1459761440357690134
+org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunctionArgs,true,3848480256348119530,id:java/lang/String
 org/apache/geode/management/internal/cli/functions/GatewaySenderFunctionArgs,true,-5158224572470173267,alertThreshold:java/lang/Integer,batchSize:java/lang/Integer,batchTimeInterval:java/lang/Integer,diskStoreName:java/lang/String,diskSynchronous:java/lang/Boolean,dispatcherThreads:java/lang/Integer,enableBatchConflation:java/lang/Boolean,enablePersistence:java/lang/Boolean,gatewayEventFilters:java/lang/String[],gatewayTransportFilters:java/lang/String[],id:java/lang/String,manualStart:java/lang/Boolean,maxQueueMemory:java/lang/Integer,orderPolicy:java/lang/String,parallel:java/lang/Boolean,remoteDSId:java/lang/Integer,socketBufferSize:java/lang/Integer,socketReadTimeout:java/lang/Integer
 org/apache/geode/management/internal/cli/functions/GetMemberConfigInformationFunction,true,1
 org/apache/geode/management/internal/cli/functions/GetMemberInformationFunction,true,1

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/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 786dd40..f352f3d 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
@@ -835,6 +835,27 @@ PARAMETERS\n\
 \ \ \ \ \ \ \ \ The fully qualified class name of GatewayTransportFilter to be added to the GatewaySender. \n\
 \ \ \ \ \ \ \ \ Required: false\n\
 
+destroy-gateway-sender.help=\
+NAME\n\
+\ \ \ \ destroy gateway-sender\n\
+IS AVAILABLE\n\
+\ \ \ \ false\n\
+SYNOPSIS\n\
+\ \ \ \ Destroy the Gateway Sender on a member or members.\n\
+SYNTAX\n\
+\ \ \ \ destroy gateway-sender --id=value [--group=value(,value)*] [--member=value(,value)*]\n\
+PARAMETERS\n\
+\ \ \ \ group\n\
+\ \ \ \ \ \ \ \ Group(s) of members on which to destroy the Gateway Sender.\n\
+\ \ \ \ \ \ \ \ Required: false\n\
+\ \ \ \ member\n\
+\ \ \ \ \ \ \ \ Name/Id of the member on which to destroy the Gateway Sender.\n\
+\ \ \ \ \ \ \ \ Required: false\n\
+\ \ \ \ id\n\
+\ \ \ \ \ \ \ \ Id of the GatewaySender.\n\
+\ \ \ \ \ \ \ \ Required: true\n\
+
+
 create-index.help=\
 NAME\n\
 \ \ \ \ create index\n\

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-online.properties
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-online.properties b/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-online.properties
index 57f8f37..2b22650 100644
--- a/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-online.properties
+++ b/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-online.properties
@@ -140,6 +140,12 @@ NAME\n\
 IS AVAILABLE\n\
 \ \ \ \ true\n\
 
+destroy-gateway-sender.help=\
+NAME\n\
+\ \ \ \ destroy gateway-sender\n\
+IS AVAILABLE\n\
+\ \ \ \ true\n\
+
 create-index.help=\
 NAME\n\
 \ \ \ \ create index\n\

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/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 9b9ef2b..b0cece0 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
@@ -3418,7 +3418,7 @@ public class WANTestBase extends JUnit4DistributedTestCase {
         break;
       }
     }
-    ((AbstractGatewaySender) sender).destroy();
+    sender.destroy();
   }
 
   public static void verifySenderDestroyed(String senderId, boolean isParallel) {

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
index caa235e..f364ba3 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
@@ -25,7 +25,10 @@ import org.apache.geode.distributed.Locator;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.LocalRegion;
 import org.apache.geode.internal.cache.wan.AbstractGatewaySender;
+import org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderQueue;
 import org.apache.geode.management.ManagementService;
 import org.apache.geode.management.internal.cli.commands.CliCommandTestBase;
 import org.apache.geode.test.dunit.*;
@@ -41,6 +44,7 @@ import java.util.Set;
 import static org.apache.geode.distributed.ConfigurationProperties.*;
 import static org.apache.geode.test.dunit.Assert.assertEquals;
 import static org.apache.geode.test.dunit.Assert.fail;
+import static org.junit.Assert.assertNull;
 
 public abstract class WANCommandTestBase extends CliCommandTestBase {
 
@@ -448,6 +452,37 @@ public abstract class WANCommandTestBase extends CliCommandTestBase {
     }
   }
 
+  // Added for gateway destroy command
+  // Copied from WANTestBase.java
+
+  public static void verifySenderDestroyed(String senderId, boolean isParallel) {
+    Set<GatewaySender> senders = cache.getGatewaySenders();
+    AbstractGatewaySender sender = null;
+    for (GatewaySender s : senders) {
+      if (s.getId().equals(senderId)) {
+        sender = (AbstractGatewaySender) s;
+        break;
+      }
+    }
+    assertNull(sender);
+
+    String queueRegionNameSuffix = null;
+    if (isParallel) {
+      queueRegionNameSuffix = ParallelGatewaySenderQueue.QSTRING;
+    } else {
+      queueRegionNameSuffix = "_SERIAL_GATEWAY_SENDER_QUEUE";
+    }
+
+    Set<LocalRegion> allRegions = ((GemFireCacheImpl) cache).getAllRegions();
+    for (LocalRegion region : allRegions) {
+      if (region.getName().indexOf(senderId + queueRegionNameSuffix) != -1) {
+        fail("Region underlying the sender is not destroyed.");
+      }
+    }
+  }
+
+
+
   @Override
   public final void postTearDownCacheTestCase() throws Exception {
     closeCacheAndDisconnect();

http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
new file mode 100644
index 0000000..d095764
--- /dev/null
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
@@ -0,0 +1,921 @@
+/*
+ * 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.wan.wancommand;
+
+import org.apache.geode.cache.wan.GatewaySender;
+import org.apache.geode.cache.wan.GatewaySender.OrderPolicy;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.internal.cache.wan.GatewaySenderException;
+import org.apache.geode.management.cli.Result;
+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.result.TabularResultData;
+import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.test.dunit.Assert.*;
+import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
+
+@Category(DistributedTest.class)
+public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTestBase {
+
+  private static final long serialVersionUID = 1L;
+
+  private CommandResult executeCommandWithIgnoredExceptions(String command) {
+    final IgnoredException exln = IgnoredException.addIgnoredException("Could not connect");
+    try {
+      CommandResult commandResult = executeCommand(command);
+      return commandResult;
+    } finally {
+      exln.remove();
+    }
+  }
+
+
+  /**
+   * GatewaySender with all default attributes
+   */
+  @Test
+  public void testCreateDestroyGatewaySenderWithDefault() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCache(punePort));
+    vm4.invoke(() -> createCache(punePort));
+    vm5.invoke(() -> createCache(punePort));
+
+    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2";
+    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info(
+          "testCreateDestroyGatewaySenderWithDefault stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender creation failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail("testCreateDestroyGatewaySenderWithDefault failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderState("ln", true, false));
+    vm4.invoke(() -> verifySenderState("ln", true, false));
+    vm5.invoke(() -> verifySenderState("ln", true, false));
+
+    // Test Destroy Command.
+    command =
+        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
+    cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info(
+          "testCreateDestroyGatewaySenderWithDefault stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+
+    } else {
+      fail("testCreateDestroyGatewaySenderWithDefault failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderDestroyed("ln", false));
+    vm4.invoke(() -> verifySenderDestroyed("ln", false));
+    vm5.invoke(() -> verifySenderDestroyed("ln", false));
+  }
+
+  /**
+   * + * GatewaySender with given attribute values +
+   */
+  @Test
+  public void testCreateDestroyGatewaySender() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCache(punePort));
+    vm4.invoke(() -> createCache(punePort));
+    vm5.invoke(() -> createCache(punePort));
+
+    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
+    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD";
+    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info("testCreateDestroyGatewaySender stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender creation failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail("testCreateDestroyGatewaySender failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderState("ln", false, false));
+    vm4.invoke(() -> verifySenderState("ln", false, false));
+    vm5.invoke(() -> verifySenderState("ln", false, false));
+
+    vm3.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
+        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, null));
+    vm4.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
+        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, null));
+    vm5.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
+        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, null));
+
+    // Test Destroy Command.
+    command =
+        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
+    cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info("testCreateDestroyGatewaySender stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail("testCreateDestroyGatewaySender failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderDestroyed("ln", false));
+    vm4.invoke(() -> verifySenderDestroyed("ln", false));
+    vm5.invoke(() -> verifySenderDestroyed("ln", false));
+  }
+
+  /**
+   * GatewaySender with given attribute values. Error scenario where dispatcher threads is set to
+   * more than 1 and no order policy provided.
+   */
+  @Test
+  public void testCreateGatewaySender_Error() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCache(punePort));
+    vm4.invoke(() -> createCache(punePort));
+    vm5.invoke(() -> createCache(punePort));
+
+    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
+    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2";
+    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info("testCreateDestroyGatewaySender stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender creation should fail", status.get(i).indexOf("ERROR:") != -1);
+      }
+    } else {
+      fail("testCreateDestroyGatewaySender failed as did not get CommandResult");
+    }
+
+  }
+
+  /**
+   * GatewaySender with given attribute values and event filters.
+   */
+  @Test
+  public void testCreateDestroyGatewaySenderWithGatewayEventFilters() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCache(punePort));
+    vm4.invoke(() -> createCache(punePort));
+    vm5.invoke(() -> createCache(punePort));
+
+    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
+    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__GATEWAYEVENTFILTER
+        + "=org.apache.geode.cache30.MyGatewayEventFilter1,org.apache.geode.cache30.MyGatewayEventFilter2";
+    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info("testCreateDestroyGatewaySenderWithGatewayEventFilters stringResult : "
+          + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender creation failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail(
+          "testCreateDestroyGatewaySenderWithGatewayEventFilters failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderState("ln", false, false));
+    vm4.invoke(() -> verifySenderState("ln", false, false));
+    vm5.invoke(() -> verifySenderState("ln", false, false));
+
+    List<String> eventFilters = new ArrayList<String>();
+    eventFilters.add("org.apache.geode.cache30.MyGatewayEventFilter1");
+    eventFilters.add("org.apache.geode.cache30.MyGatewayEventFilter2");
+    vm3.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
+        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, eventFilters, null));
+    vm4.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
+        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, eventFilters, null));
+    vm5.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
+        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, eventFilters, null));
+
+    // Test Destroy Command.
+    command =
+        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
+    cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info("testCreateDestroyGatewaySenderWithGatewayEventFilters stringResult : "
+          + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail(
+          "testCreateDestroyGatewaySenderWithGatewayEventFilters failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderDestroyed("ln", false));
+    vm4.invoke(() -> verifySenderDestroyed("ln", false));
+    vm5.invoke(() -> verifySenderDestroyed("ln", false));
+
+  }
+
+  /**
+   * GatewaySender with given attribute values and transport filters.
+   */
+  @Test
+  public void testCreateDestroyGatewaySenderWithGatewayTransportFilters() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCache(punePort));
+    vm4.invoke(() -> createCache(punePort));
+    vm5.invoke(() -> createCache(punePort));
+
+    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
+    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__GATEWAYTRANSPORTFILTER
+        + "=org.apache.geode.cache30.MyGatewayTransportFilter1";
+    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter()
+          .info("testCreateDestroyGatewaySenderWithGatewayTransportFilters stringResult : "
+              + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender creation failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail(
+          "testCreateDestroyGatewaySenderWithGatewayTransportFilters failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderState("ln", false, false));
+    vm4.invoke(() -> verifySenderState("ln", false, false));
+    vm5.invoke(() -> verifySenderState("ln", false, false));
+
+    List<String> transportFilters = new ArrayList<String>();
+    transportFilters.add("org.apache.geode.cache30.MyGatewayTransportFilter1");
+    vm3.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
+        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, transportFilters));
+    vm4.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
+        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, transportFilters));
+    vm5.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
+        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, transportFilters));
+
+    // Test Destroy Command.
+    command =
+        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
+    cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter()
+          .info("testCreateDestroyGatewaySenderWithGatewayTransportFilters stringResult : "
+              + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+
+    } else {
+      fail(
+          "testCreateDestroyGatewaySenderWithGatewayTransportFilters failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderDestroyed("ln", false));
+    vm4.invoke(() -> verifySenderDestroyed("ln", false));
+    vm5.invoke(() -> verifySenderDestroyed("ln", false));
+  }
+
+  /**
+   * GatewaySender with given attribute values on given member.
+   */
+  @Test
+  public void testCreateDestroyGatewaySender_OnMember() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCache(punePort));
+    vm4.invoke(() -> createCache(punePort));
+    vm5.invoke(() -> createCache(punePort));
+
+    final DistributedMember vm3Member = (DistributedMember) vm3.invoke(() -> getMember());
+
+    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
+    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__MEMBER + "=" + vm3Member.getId() + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD";
+    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter()
+          .info("testCreateDestroyGatewaySender_OnMember stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(1, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender creation failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail("testCreateDestroyGatewaySender_OnMember failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderState("ln", false, false));
+
+    vm3.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
+        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, null));
+
+    // Test Destroy Command.
+    command = CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__MEMBER + "=" + vm3Member.getId();
+    cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter()
+          .info("testCreateDestroyGatewaySender_OnMember stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(1, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+
+    } else {
+      fail("testCreateDestroyGatewaySender_OnMember failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderDestroyed("ln", false));
+  }
+
+  /**
+   * GatewaySender with given attribute values on given group
+   */
+  @Test
+  public void testCreateDestroyGatewaySender_Group() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCacheWithGroups(punePort, "SenderGroup1"));
+    vm4.invoke(() -> createCacheWithGroups(punePort, "SenderGroup1"));
+    vm5.invoke(() -> createCacheWithGroups(punePort, "SenderGroup1"));
+
+    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
+    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__GROUP + "=SenderGroup1" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD";
+    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter()
+          .info("testCreateDestroyGatewaySender_Group stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(3, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender creation failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail("testCreateDestroyGatewaySender_Group failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderState("ln", true, false));
+    vm4.invoke(() -> verifySenderState("ln", true, false));
+    vm5.invoke(() -> verifySenderState("ln", true, false));
+
+    // Test Destroy Command
+    command = CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.DESTROY_GATEWAYSENDER__GROUP + "=SenderGroup1";
+
+    cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter()
+          .info("testCreateDestroyGatewaySender_Group stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(3, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail("testCreateDestroyGatewaySender_Group failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderDestroyed("ln", false));
+    vm4.invoke(() -> verifySenderDestroyed("ln", false));
+    vm5.invoke(() -> verifySenderDestroyed("ln", false));
+
+  }
+
+  /**
+   * GatewaySender with given attribute values on given group. Only 2 of 3 members are part of the
+   * group.
+   */
+  @Test
+  public void testCreateDestroyGatewaySender_Group_Scenario2() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCacheWithGroups(punePort, "SenderGroup1"));
+    vm4.invoke(() -> createCacheWithGroups(punePort, "SenderGroup1"));
+    vm5.invoke(() -> createCacheWithGroups(punePort, "SenderGroup2"));
+
+    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
+    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__GROUP + "=SenderGroup1" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD";
+    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info(
+          "testCreateDestroyGatewaySender_Group_Scenario2 stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(2, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender creation failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail("testCreateDestroyGatewaySender_Group_Scenario2 failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderState("ln", true, false));
+    vm4.invoke(() -> verifySenderState("ln", true, false));
+
+
+    // Test Destroy Command
+    command = CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.DESTROY_GATEWAYSENDER__GROUP + "=SenderGroup1";
+
+    cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info(
+          "testCreateDestroyGatewaySender_Group_Scenario2 stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(2, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail("testCreateDestroyGatewaySender_Group_Scenario2 failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderDestroyed("ln", false));
+    vm4.invoke(() -> verifySenderDestroyed("ln", false));
+
+  }
+
+  /**
+   * + * Parallel GatewaySender with given attribute values +
+   */
+  @Test
+  public void testCreateDestroyParallelGatewaySender() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCache(punePort));
+    vm4.invoke(() -> createCache(punePort));
+    vm5.invoke(() -> createCache(punePort));
+
+    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
+    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100";
+    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter()
+          .info("testCreateDestroyParallelGatewaySender stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender creation failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+    } else {
+      fail("testCreateDestroyParallelGatewaySender failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifySenderState("ln", false, false));
+    vm4.invoke(() -> verifySenderState("ln", false, false));
+    vm5.invoke(() -> verifySenderState("ln", false, false));
+
+    vm3.invoke(
+        () -> verifySenderAttributes("ln", 2, true, true, 1000, socketReadTimeout, true, 1000, 5000,
+            true, false, 1000, 100, GatewaySender.DEFAULT_DISPATCHER_THREADS, null, null, null));
+    vm4.invoke(
+        () -> verifySenderAttributes("ln", 2, true, true, 1000, socketReadTimeout, true, 1000, 5000,
+            true, false, 1000, 100, GatewaySender.DEFAULT_DISPATCHER_THREADS, null, null, null));
+    vm5.invoke(
+        () -> verifySenderAttributes("ln", 2, true, true, 1000, socketReadTimeout, true, 1000, 5000,
+            true, false, 1000, 100, GatewaySender.DEFAULT_DISPATCHER_THREADS, null, null, null));
+
+    // Test Destroy Command
+    command =
+        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
+    cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter()
+          .info("testCreateDestroyParallelGatewaySender stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+
+    } else {
+      fail("testCreateDestroyParallelGatewaySender failed as did not get CommandResult");
+    }
+    vm3.invoke(() -> verifySenderDestroyed("ln", true));
+    vm4.invoke(() -> verifySenderDestroyed("ln", true));
+    vm5.invoke(() -> verifySenderDestroyed("ln", true));
+  }
+
+  /**
+   * Parallel GatewaySender with given attribute values. Provide dispatcherThreads as 2 which is not
+   * valid for Parallel sender.
+   */
+  @Test
+  public void testCreateParallelGatewaySender_Error() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCache(punePort));
+    vm4.invoke(() -> createCache(punePort));
+    vm5.invoke(() -> createCache(punePort));
+
+    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
+    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
+        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD";
+    IgnoredException exp =
+        IgnoredException.addIgnoredException(GatewaySenderException.class.getName());
+    try {
+      CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+      if (cmdResult != null) {
+        String strCmdResult = commandResultToString(cmdResult);
+        getLogWriter()
+            .info("testCreateParallelGatewaySender_Error stringResult : " + strCmdResult + ">>>>");
+        assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+        TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+        List<String> status = resultData.retrieveAllValues("Status");
+        assertEquals(5, status.size());
+        for (int i = 0; i < status.size(); i++) {
+          assertTrue("GatewaySender creation should have failed",
+              status.get(i).indexOf("ERROR:") != -1);
+        }
+      } else {
+        fail("testCreateParallelGatewaySender_Error failed as did not get CommandResult");
+      }
+    } finally {
+      exp.remove();
+    }
+
+  }
+
+  @Test
+  public void testDestroyGatewaySender_NotCreatedSender() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCache(punePort));
+    vm4.invoke(() -> createCache(punePort));
+    vm5.invoke(() -> createCache(punePort));
+
+    // Test Destroy Command
+    String command =
+        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
+    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info(
+          "testDestroyGatewaySender_NotCreatedSender stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy should fail", status.get(i).indexOf("ERROR:") != -1);
+      }
+
+    } else {
+      fail("testCreateDestroyParallelGatewaySender failed as did not get CommandResult");
+    }
+  }
+}


[07/19] geode git commit: Merge branch 'bugfix/GEODE-1984' into develop

Posted by kl...@apache.org.
Merge branch 'bugfix/GEODE-1984' into develop


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

Branch: refs/heads/feature/GEODE-1027
Commit: 213d8bc1c3ad85365d7860e3a5d8ea334691cdd4
Parents: 1d951e3 f522f6c
Author: adongre <ad...@apache.org>
Authored: Fri Dec 9 05:08:36 2016 +0530
Committer: adongre <ad...@apache.org>
Committed: Fri Dec 9 05:08:36 2016 +0530

----------------------------------------------------------------------
 .../internal/AsyncEventQueueImpl.java           |   2 +-
 .../apache/geode/cache/wan/GatewaySender.java   |  13 +
 .../cache/wan/AbstractGatewaySender.java        |   1 +
 .../internal/cli/commands/WanCommands.java      |  59 +-
 .../functions/GatewaySenderDestroyFunction.java |  90 +++
 .../GatewaySenderDestroyFunctionArgs.java       |  33 +
 .../internal/cli/i18n/CliStrings.java           |  18 +
 .../controllers/ShellCommandsController.java    |   2 +
 .../web/controllers/WanCommandsController.java  |  24 +
 .../codeAnalysis/sanctionedSerializables.txt    |   2 +
 .../cli/commands/golden-help-offline.properties |  21 +
 .../cli/commands/golden-help-online.properties  |   6 +
 .../geode/internal/cache/wan/WANTestBase.java   |   2 +-
 .../wan/wancommand/WANCommandTestBase.java      |  33 +
 ...mandCreateDestroyGatewaySenderDUnitTest.java | 794 +++++++++++++++++++
 .../WanCommandCreateGatewaySenderDUnitTest.java | 663 ----------------
 16 files changed, 1092 insertions(+), 671 deletions(-)
----------------------------------------------------------------------



[02/19] geode git commit: GEODE-2192 Fixed NPE in GMSLocator. Added null check for publickey

Posted by kl...@apache.org.
GEODE-2192 Fixed NPE in GMSLocator. Added null check for publickey


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

Branch: refs/heads/feature/GEODE-1027
Commit: f22809a448ba5ab177be0d1d790f0ec91801d0f0
Parents: 2075ee3
Author: Hitesh Khamesra <hk...@pivotal.io>
Authored: Thu Dec 8 13:40:34 2016 -0800
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Thu Dec 8 13:40:34 2016 -0800

----------------------------------------------------------------------
 .../internal/membership/gms/locator/GMSLocator.java         | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f22809a4/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
index 25cb50f..dd73492 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
@@ -188,9 +188,12 @@ public class GMSLocator implements Locator, NetLocator {
         services.getMessenger().setPublicKey(findRequest.getMyPublicKey(),
             findRequest.getMemberID());
       } else {
-        // GMSEncrypt.registerMember(findRequest.getMyPublicKey(), findRequest.getMemberID());
-        registerMbrVsPK.put(new InternalDistributedMemberWrapper(findRequest.getMemberID()),
-            findRequest.getMyPublicKey());
+        // GMSEncrypt.registerMember(findRequest.getMyPublicKey(),
+        // findRequest.getMemberID());
+        if (findRequest.getMyPublicKey() != null) {
+          registerMbrVsPK.put(new InternalDistributedMemberWrapper(findRequest.getMemberID()),
+              findRequest.getMyPublicKey());
+        }
       }
       if (findRequest.getMemberID() != null) {
         InternalDistributedMember coord = null;


[15/19] geode git commit: GEODE-2098 Document that gfsh history is in .geode dir

Posted by kl...@apache.org.
GEODE-2098 Document that gfsh history is in .geode dir


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

Branch: refs/heads/feature/GEODE-1027
Commit: 03c79a68b0eaf3926053f5cb34c0f2c96829bb05
Parents: 0f8ef97
Author: Karen Miller <km...@pivotal.io>
Authored: Fri Dec 9 15:48:25 2016 -0800
Committer: Karen Miller <km...@pivotal.io>
Committed: Mon Dec 12 08:18:18 2016 -0800

----------------------------------------------------------------------
 geode-docs/tools_modules/gfsh/command-pages/history.html.md.erb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/03c79a68/geode-docs/tools_modules/gfsh/command-pages/history.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/tools_modules/gfsh/command-pages/history.html.md.erb b/geode-docs/tools_modules/gfsh/command-pages/history.html.md.erb
index 04e4736..aa625c2 100644
--- a/geode-docs/tools_modules/gfsh/command-pages/history.html.md.erb
+++ b/geode-docs/tools_modules/gfsh/command-pages/history.html.md.erb
@@ -23,7 +23,9 @@ Show or save the command history.
 
 This history can be saved to a file which can also be used as a script later.
 
-A history of commands that have been executed successfully is also logged in `.gfsh.history` file in the home directory of the user running gfsh.
+A history of commands that have been executed successfully is also logged in
+the `.geode/.gfsh.history` file within the home directory of
+the user running gfsh.
 
 **Availability:** Online or offline.
 


[14/19] geode git commit: GEODE-2201 Spotless fix

Posted by kl...@apache.org.
GEODE-2201 Spotless fix


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

Branch: refs/heads/feature/GEODE-1027
Commit: 0f8ef971b8f18bd144646e98468816df88d1d0c9
Parents: df8730d
Author: Jens Deppe <jd...@pivotal.io>
Authored: Sun Dec 11 21:11:08 2016 -0800
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Sun Dec 11 21:11:08 2016 -0800

----------------------------------------------------------------------
 .../java/org/apache/geode/tools/pulse/tests/ui/PulseTestUtils.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/0f8ef971/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseTestUtils.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseTestUtils.java
index 076229e..ce91202 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseTestUtils.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseTestUtils.java
@@ -63,7 +63,7 @@ public final class PulseTestUtils {
 
   public static WebElement waitForElement(By by) {
     WebElement element = (new WebDriverWait(driverProvider.get(), maxWaitTime))
-      .until((ExpectedCondition<WebElement>) d -> d.findElement(by));
+        .until((ExpectedCondition<WebElement>) d -> d.findElement(by));
     assertNotNull(element);
     return element;
   }


[09/19] geode git commit: [GEODE-2196] Add test for Cluster Config. Refactor LocatorServerStartupRule.

Posted by kl...@apache.org.
[GEODE-2196] Add test for Cluster Config. Refactor LocatorServerStartupRule.

* Add ClusterConfigDUnitTest
* Refactor LocatorServerStartupRule
* this closes #309


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

Branch: refs/heads/feature/GEODE-1027
Commit: adfd41f437d2a30255ae8368e355b497d6bb0164
Parents: 213d8bc
Author: Jared Stewart <js...@pivotal.io>
Authored: Thu Dec 8 15:03:54 2016 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Fri Dec 9 09:47:07 2016 -0800

----------------------------------------------------------------------
 .../internal/DistributionConfig.java            |   2 +-
 .../internal/DistributionConfigImpl.java        |   2 +-
 .../ConnectToLocatorSSLDUnitTest.java           |   6 +-
 .../configuration/ClusterConfigDUnitTest.java   | 243 +++++++++++++++++++
 .../ClusterConfigWithoutSecurityDUnitTest.java  |   8 +-
 .../security/PeerAuthenticatorDUnitTest.java    |  12 +-
 ...eerSecurityWithEmbeddedLocatorDUnitTest.java |  18 +-
 .../SecurityClusterConfigDUnitTest.java         |  13 +-
 .../SecurityWithoutClusterConfigDUnitTest.java  |   7 +-
 .../security/StartServerAuthorizationTest.java  |  33 ++-
 .../dunit/rules/LocatorServerStartupRule.java   | 108 +++++----
 .../test/dunit/rules/LocatorStarterRule.java    |  11 +-
 .../apache/geode/test/dunit/rules/Member.java   |  62 +++++
 .../test/dunit/rules/ServerStarterRule.java     |  32 ++-
 .../internal/configuration/cluster_config.zip   | Bin 0 -> 4666 bytes
 .../LuceneClusterConfigurationDUnitTest.java    |  48 ++--
 16 files changed, 474 insertions(+), 131 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java
index 5eb070d..c2a395d 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java
@@ -384,7 +384,7 @@ public interface DistributionConfig extends Config, LogConfig {
    * Default will be the current working directory as determined by
    * <code>System.getProperty("user.dir")</code>.
    */
-  File DEFAULT_DEPLOY_WORKING_DIR = new File(".");
+  File DEFAULT_DEPLOY_WORKING_DIR = new File(System.getProperty("user.dir"));
 
   /**
    * Returns the value of the {@link ConfigurationProperties#USER_COMMAND_PACKAGES} property

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
index 0c6603d..fa6d13f 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
@@ -124,7 +124,7 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
    */
   private File logFile = DEFAULT_LOG_FILE;
 
-  protected File deployWorkingDir = DEFAULT_DEPLOY_WORKING_DIR;
+  protected File deployWorkingDir = new File(System.getProperty("user.dir"));
 
   /**
    * The level at which log messages are logged

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/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 751425a..142ce17 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
@@ -83,14 +83,14 @@ public class ConnectToLocatorSSLDUnitTest extends JUnit4DistributedTestCase {
   }
 
   public void setUpLocatorAndConnect(Properties securityProps) throws Exception {
-    lsRule.getLocatorVM(0, securityProps);
+    lsRule.startLocatorVM(0, securityProps);
 
     // saving the securityProps to a file
     OutputStream out = new FileOutputStream(securityPropsFile);
     securityProps.store(out, "");
 
-    GfshShellConnectionRule gfshConnector =
-        new GfshShellConnectionRule(lsRule.getPort(0), GfshShellConnectionRule.PortType.locator);
+    GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule(
+        lsRule.getMember(0).getPort(), GfshShellConnectionRule.PortType.locator);
 
     // when we connect too soon, we would get "Failed to retrieve RMIServer stub:
     // javax.naming.CommunicationException [Root exception is java.rmi.NoSuchObjectException: no

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDUnitTest.java
new file mode 100644
index 0000000..418999a
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDUnitTest.java
@@ -0,0 +1,243 @@
+/*
+ * 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 static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_CONFIGURATION_DIR;
+import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
+import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOAD_CLUSTER_CONFIGURATION_FROM_DIR;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION;
+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.SharedConfiguration;
+import org.apache.geode.internal.ClassPathLoader;
+import org.apache.geode.internal.JarClassLoader;
+import org.apache.geode.management.internal.configuration.domain.Configuration;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
+import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.Member;
+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.io.Serializable;
+import java.util.Collection;
+import java.util.Properties;
+
+@Category(DistributedTest.class)
+public class ClusterConfigDUnitTest extends JUnit4DistributedTestCase {
+  private static final String EXPORTED_CLUSTER_CONFIG_ZIP_FILENAME = "cluster_config.zip";
+  private static final String[] CONFIG_NAMES = new String[] {"cluster", "group1", "group2"};
+
+  private static final ExpectedConfig NO_GROUP =
+      new ExpectedConfig().maxLogFileSize("5000").regions("regionForCluster").jars("cluster.jar");
+
+  private static final ExpectedConfig GROUP1 = new ExpectedConfig().maxLogFileSize("6000")
+      .regions("regionForCluster", "regionForGroup1").jars("cluster.jar", "group1.jar");
+
+  private static final ExpectedConfig GROUP2 = new ExpectedConfig().maxLogFileSize("7000")
+      .regions("regionForCluster", "regionForGroup2").jars("cluster.jar", "group2.jar");
+
+  private static final ExpectedConfig GROUP1_AND_2 = new ExpectedConfig().maxLogFileSize("7000")
+      .regions("regionForCluster", "regionForGroup1", "regionForGroup2")
+      .jars("cluster.jar", "group1.jar", "group2.jar");
+
+
+  private String locatorString;
+
+  @Rule
+  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+
+  @Before
+  public void setupFirstLocatorWithClusterConfigFromDirectory() throws Exception {
+    File locatorDir = lsRule.getRootFolder().newFolder("locator-0");
+
+    // The unzip should yield a cluster config directory structure like:
+    // tempFolder/locator-0/cluster_config/cluster/cluster.xml
+    // tempFolder/locator-0/cluster_config/cluster/cluster.properties
+    // tempFolder/locator-0/cluster_config/cluster/cluster.jar
+    // tempFolder/locator-0/cluster_config/group1/ {group1.xml, group1.properties, group1.jar}
+    // tempFolder/locator-0/cluster_config/group2/ ...
+    ZipUtils.unzip(getClass().getResource(EXPORTED_CLUSTER_CONFIG_ZIP_FILENAME).getPath(),
+        locatorDir.getCanonicalPath());
+
+    Properties locatorProps = new Properties();
+    locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
+    locatorProps.setProperty(LOAD_CLUSTER_CONFIGURATION_FROM_DIR, "true");
+    locatorProps.setProperty(CLUSTER_CONFIGURATION_DIR, locatorDir.getCanonicalPath());
+
+    Member firstLocator = lsRule.startLocatorVM(0, locatorProps);
+    locatorString = "localhost[" + firstLocator.getPort() + "]";
+
+    verifyLocatorConfigExistsInFileSystem(firstLocator.getWorkingDir());
+    firstLocator.invoke(this::verifyLocatorConfigExistsInInternalRegion);
+  }
+
+  @Test
+  public void secondLocatorLoadsClusterConfigFromFirstLocator() throws IOException {
+    Properties secondLocatorProps = new Properties();
+    secondLocatorProps.setProperty(LOCATORS, locatorString);
+    secondLocatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
+    Member secondLocator = lsRule.startLocatorVM(1, secondLocatorProps);
+
+    verifyLocatorConfig(secondLocator);
+  }
+
+  @Test
+  public void serverWithZeroOrOneGroupsLoadCorrectConfigFromLocator() throws Exception {
+    Properties serverProps = new Properties();
+    serverProps.setProperty(LOCATORS, locatorString);
+    serverProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
+
+    Member serverWithNoGroup = lsRule.startServerVM(1, serverProps);
+    verifyServerConfig(NO_GROUP, serverWithNoGroup);
+
+    serverProps.setProperty(GROUPS, "group1");
+    Member serverForGroup1 = lsRule.startServerVM(2, serverProps);
+    verifyServerConfig(GROUP1, serverForGroup1);
+
+    serverProps.setProperty(GROUPS, "group2");
+    Member serverForGroup2 = lsRule.startServerVM(3, serverProps);
+    verifyServerConfig(GROUP2, serverForGroup2);
+  }
+
+  @Test
+  public void oneServerWithMultipleGroupsLoadsCorrectConfigFromLocator() throws Exception {
+    Properties serverProps = new Properties();
+    serverProps.setProperty(LOCATORS, locatorString);
+    serverProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
+    serverProps.setProperty(GROUPS, "group1,group2");
+    Member serverWithNoGroup = lsRule.startServerVM(1, serverProps);
+
+    serverWithNoGroup.invoke(() -> this.verifyServerConfig(GROUP1_AND_2, serverWithNoGroup));
+  }
+
+  private void verifyLocatorConfig(Member locator) {
+    verifyLocatorConfigExistsInFileSystem(locator.getWorkingDir());
+    locator.invoke(this::verifyLocatorConfigExistsInInternalRegion);
+  }
+
+  private void verifyServerConfig(ExpectedConfig expectedConfig, Member server)
+      throws ClassNotFoundException {
+    verifyServerJarFilesExistInFileSystem(server.getWorkingDir(), expectedConfig.jars);
+    server.invoke(() -> this.verifyServerConfigInMemory(expectedConfig));
+  }
+
+  private void verifyLocatorConfigExistsInFileSystem(File workingDir) {
+    File clusterConfigDir = new File(workingDir, "cluster_config");
+    assertThat(clusterConfigDir).exists();
+
+    for (String configName : CONFIG_NAMES) {
+      File configDir = new File(clusterConfigDir, configName);
+      assertThat(configDir).exists();
+
+      File jar = new File(configDir, configName + ".jar");
+      File properties = new File(configDir, configName + ".properties");
+      File xml = new File(configDir, configName + ".xml");
+      assertThat(configDir.listFiles()).contains(jar, properties, xml);
+    }
+  }
+
+  private void verifyLocatorConfigExistsInInternalRegion() throws Exception {
+    InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.locator;
+    SharedConfiguration sc = internalLocator.getSharedConfiguration();
+
+    for (String configName : CONFIG_NAMES) {
+      Configuration config = sc.getConfiguration(configName);
+      assertThat(config).isNotNull();
+    }
+  }
+
+  private void verifyServerConfigInMemory(ExpectedConfig expectedConfig)
+      throws ClassNotFoundException {
+    Cache cache = LocatorServerStartupRule.serverStarter.cache;
+    for (String region : expectedConfig.regions) {
+      assertThat(cache.getRegion(region)).isNotNull();
+    }
+    Properties props = cache.getDistributedSystem().getProperties();
+    assertThat(props.getProperty(LOG_FILE_SIZE_LIMIT)).isEqualTo(expectedConfig.maxLogFileSize);
+
+    for (String jar : expectedConfig.jars) {
+      JarClassLoader jarClassLoader = findJarClassLoader(jar);
+      assertThat(jarClassLoader).isNotNull();
+      assertThat(jarClassLoader.loadClass(nameOfClassContainedInJar(jar))).isNotNull();
+    }
+  }
+
+  private void verifyServerJarFilesExistInFileSystem(File workingDir, String[] jarNames) {
+    assertThat(workingDir.listFiles()).isNotEmpty();
+
+    for (String jarName : jarNames) {
+      assertThat(workingDir.listFiles()).filteredOn((File file) -> file.getName().contains(jarName))
+          .isNotEmpty();
+    }
+  }
+
+  private String nameOfClassContainedInJar(String jarName) {
+    switch (jarName) {
+      case "cluster.jar":
+        return "Cluster";
+      case "group1.jar":
+        return "Group1";
+      case "group2.jar":
+        return "Group2";
+      default:
+        throw new IllegalArgumentException(
+            EXPORTED_CLUSTER_CONFIG_ZIP_FILENAME + " does not contain a jar named " + jarName);
+    }
+  }
+
+  private JarClassLoader findJarClassLoader(final String jarName) {
+    Collection<ClassLoader> classLoaders = ClassPathLoader.getLatest().getClassLoaders();
+    for (ClassLoader classLoader : classLoaders) {
+      if (classLoader instanceof JarClassLoader
+          && ((JarClassLoader) classLoader).getJarName().equals(jarName)) {
+        return (JarClassLoader) classLoader;
+      }
+    }
+    return null;
+  }
+
+  private static class ExpectedConfig implements Serializable {
+    public String maxLogFileSize;
+    public String[] regions;
+    public String[] jars;
+
+    public ExpectedConfig maxLogFileSize(String maxLogFileSize) {
+      this.maxLogFileSize = maxLogFileSize;
+      return this;
+    }
+
+    public ExpectedConfig regions(String... regions) {
+      this.regions = regions;
+      return this;
+    }
+
+    public ExpectedConfig jars(String... jars) {
+      this.jars = jars;
+      return this;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/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 1ad6799..fe37f9e 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
@@ -21,6 +21,7 @@ import static org.junit.Assert.*;
 
 import java.util.Properties;
 
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.junit.After;
 import org.junit.Before;
@@ -33,7 +34,6 @@ import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
 
@@ -50,7 +50,7 @@ public class ClusterConfigWithoutSecurityDUnitTest extends JUnit4DistributedTest
         .addIgnoredException(LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION.toString());
     IgnoredException
         .addIgnoredException(LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION_2.toString());
-    lsRule.getLocatorVM(0, new Properties());
+    lsRule.startLocatorVM(0, new Properties());
   }
 
   @After
@@ -71,7 +71,7 @@ public class ClusterConfigWithoutSecurityDUnitTest extends JUnit4DistributedTest
 
     // initial security properties should only contain initial set of values
     ServerStarterRule serverStarter = new ServerStarterRule(props);
-    serverStarter.startServer(lsRule.getPort(0));
+    serverStarter.startServer(lsRule.getMember(0).getPort());
     DistributedSystem ds = serverStarter.cache.getDistributedSystem();
 
     // after cache is created, the configuration won't chagne
@@ -93,7 +93,7 @@ public class ClusterConfigWithoutSecurityDUnitTest extends JUnit4DistributedTest
 
     ServerStarterRule serverStarter = new ServerStarterRule(props);
 
-    assertThatThrownBy(() -> serverStarter.startServer(lsRule.getPort(0)))
+    assertThatThrownBy(() -> serverStarter.startServer(lsRule.getMember(0).getPort()))
         .isInstanceOf(GemFireConfigException.class)
         .hasMessage(LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION.toLocalizedString());
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
index 90cc6f1..a7752ae 100644
--- a/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
@@ -16,10 +16,13 @@
 package org.apache.geode.security;
 
 import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.test.dunit.Host.getHost;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.Properties;
 
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.Member;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.junit.Before;
 import org.junit.Rule;
@@ -29,7 +32,6 @@ import org.junit.experimental.categories.Category;
 import org.apache.geode.security.templates.DummyAuthenticator;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
 
@@ -42,23 +44,23 @@ public class PeerAuthenticatorDUnitTest extends JUnit4DistributedTestCase {
   public void before() throws Exception {
     Properties props = new Properties();
     props.setProperty(SECURITY_PEER_AUTHENTICATOR, DummyAuthenticator.class.getName());
-    lsRule.getLocatorVM(0, props);
+    lsRule.startLocatorVM(0, props);
   }
 
   @Test
   public void testPeerAuthenticator() throws Exception {
 
-    int locatorPort = lsRule.getPort(0);
+    int locatorPort = lsRule.getMember(0).getPort();
     Properties server1Props = new Properties();
     server1Props.setProperty("security-username", "user");
     server1Props.setProperty("security-password", "user");
-    lsRule.getServerVM(1, server1Props, locatorPort);
+    lsRule.startServerVM(1, server1Props, locatorPort);
 
 
     Properties server2Props = new Properties();
     server2Props.setProperty("security-username", "bogus");
     server2Props.setProperty("security-password", "user");
-    VM server2 = lsRule.getNodeVM(2);
+    VM server2 = getHost(0).getVM(2);
 
     server2.invoke(() -> {
       ServerStarterRule serverStarter = new ServerStarterRule(server2Props);

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/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 d69e379..66c5be6 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
@@ -16,10 +16,13 @@
 package org.apache.geode.security;
 
 import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.test.dunit.Host.getHost;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.Properties;
 
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -28,7 +31,6 @@ import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.security.templates.DummyAuthenticator;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
@@ -47,19 +49,19 @@ public class PeerSecurityWithEmbeddedLocatorDUnitTest extends JUnit4DistributedT
     Properties server0Props = new Properties();
     server0Props.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
     server0Props.setProperty("start-locator", "localhost[" + locatorPort + "]");
-    lsRule.getServerVM(0, server0Props);
+    lsRule.startServerVM(0, server0Props);
 
 
     Properties server1Props = new Properties();
     server1Props.setProperty("security-username", "cluster");
     server1Props.setProperty("security-password", "cluster");
-    lsRule.getServerVM(1, server1Props, locatorPort);
+    lsRule.startServerVM(1, server1Props, locatorPort);
 
     Properties server2Props = new Properties();
     server2Props.setProperty("security-username", "user");
     server2Props.setProperty("security-password", "wrongPwd");
 
-    VM server2 = lsRule.getNodeVM(2);
+    VM server2 = getHost(0).getVM(2);
     server2.invoke(() -> {
       ServerStarterRule serverStarter = new ServerStarterRule(server2Props);
       assertThatThrownBy(() -> serverStarter.startServer(locatorPort))
@@ -68,6 +70,8 @@ public class PeerSecurityWithEmbeddedLocatorDUnitTest extends JUnit4DistributedT
     });
   }
 
+
+
   @Test
   public void testPeerAuthenticator() throws Exception {
     int locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
@@ -75,19 +79,19 @@ public class PeerSecurityWithEmbeddedLocatorDUnitTest extends JUnit4DistributedT
     Properties server0Props = new Properties();
     server0Props.setProperty(SECURITY_PEER_AUTHENTICATOR, DummyAuthenticator.class.getName());
     server0Props.setProperty("start-locator", "localhost[" + locatorPort + "]");
-    lsRule.getServerVM(0, server0Props);
+    lsRule.startServerVM(0, server0Props);
 
 
     Properties server1Props = new Properties();
     server1Props.setProperty("security-username", "user");
     server1Props.setProperty("security-password", "user");
-    lsRule.getServerVM(1, server1Props, locatorPort);
+    lsRule.startServerVM(1, server1Props, locatorPort);
 
     Properties server2Props = new Properties();
     server2Props.setProperty("security-username", "bogus");
     server2Props.setProperty("security-password", "user");
 
-    VM server2 = lsRule.getNodeVM(2);
+    VM server2 = getHost(0).getVM(2);
     server2.invoke(() -> {
       ServerStarterRule serverStarter = new ServerStarterRule(server2Props);
       assertThatThrownBy(() -> serverStarter.startServer(locatorPort))

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/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 220449d..cd6518e 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
@@ -34,6 +34,7 @@ import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -58,7 +59,7 @@ public class SecurityClusterConfigDUnitTest extends JUnit4DistributedTestCase {
     props.setProperty(JMX_MANAGER_START, "false");
     props.setProperty(JMX_MANAGER_PORT, 0 + "");
     props.setProperty(SECURITY_POST_PROCESSOR, PDXPostProcessor.class.getName());
-    lsRule.getLocatorVM(0, props);
+    lsRule.startLocatorVM(0, props);
   }
 
   @Test
@@ -71,7 +72,7 @@ public class SecurityClusterConfigDUnitTest extends JUnit4DistributedTestCase {
 
     // initial security properties should only contain initial set of values
     ServerStarterRule serverStarter = new ServerStarterRule(props);
-    serverStarter.startServer(lsRule.getPort(0));
+    serverStarter.startServer(lsRule.getMember(0).getPort());
     DistributedSystem ds = serverStarter.cache.getDistributedSystem();
 
     // after cache is created, we got the security props passed in by cluster config
@@ -93,7 +94,7 @@ public class SecurityClusterConfigDUnitTest extends JUnit4DistributedTestCase {
 
     // initial security properties should only contain initial set of values
     ServerStarterRule serverStarter = new ServerStarterRule(props);
-    serverStarter.startServer(lsRule.getPort(0));
+    serverStarter.startServer(lsRule.getMember(0).getPort());
     DistributedSystem ds = serverStarter.cache.getDistributedSystem();
 
     // after cache is created, we got the security props passed in by cluster config
@@ -115,7 +116,7 @@ public class SecurityClusterConfigDUnitTest extends JUnit4DistributedTestCase {
     // initial security properties should only contain initial set of values
     ServerStarterRule serverStarter = new ServerStarterRule(props);
 
-    assertThatThrownBy(() -> serverStarter.startServer(lsRule.getPort(0)))
+    assertThatThrownBy(() -> serverStarter.startServer(lsRule.getMember(0).getPort()))
         .isInstanceOf(GemFireConfigException.class)
         .hasMessage(LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION.toLocalizedString());
 
@@ -134,7 +135,7 @@ public class SecurityClusterConfigDUnitTest extends JUnit4DistributedTestCase {
     // initial security properties should only contain initial set of values
     ServerStarterRule serverStarter = new ServerStarterRule(props);
 
-    assertThatThrownBy(() -> serverStarter.startServer(lsRule.getPort(0)))
+    assertThatThrownBy(() -> serverStarter.startServer(lsRule.getMember(0).getPort()))
         .isInstanceOf(GemFireConfigException.class)
         .hasMessage(LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION.toLocalizedString());
 
@@ -152,7 +153,7 @@ public class SecurityClusterConfigDUnitTest extends JUnit4DistributedTestCase {
 
     ServerStarterRule serverStarter = new ServerStarterRule(props);
 
-    assertThatThrownBy(() -> serverStarter.startServer(lsRule.getPort(0)))
+    assertThatThrownBy(() -> serverStarter.startServer(lsRule.getMember(0).getPort()))
         .isInstanceOf(GemFireConfigException.class)
         .hasMessage(LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION_2.toLocalizedString());
 

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/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 17b1031..72654cb 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
@@ -20,7 +20,9 @@ import static org.junit.Assert.*;
 
 import java.util.Properties;
 
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -29,7 +31,6 @@ import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
@@ -51,7 +52,7 @@ public class SecurityWithoutClusterConfigDUnitTest extends JUnit4DistributedTest
     props.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
     props.setProperty(SECURITY_POST_PROCESSOR, PDXPostProcessor.class.getName());
     props.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
-    lsRule.getLocatorVM(0, props);
+    lsRule.startLocatorVM(0, props);
   }
 
   @Test
@@ -69,7 +70,7 @@ public class SecurityWithoutClusterConfigDUnitTest extends JUnit4DistributedTest
 
     // initial security properties should only contain initial set of values
     ServerStarterRule serverStarter = new ServerStarterRule(props);
-    serverStarter.startServer(lsRule.getPort(0));
+    serverStarter.startServer(lsRule.getMember(0).getPort());
     DistributedSystem ds = serverStarter.cache.getDistributedSystem();
     assertEquals(3, ds.getSecurityProperties().size());
 

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/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 dfa0f3d..24d0db5 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
@@ -15,22 +15,23 @@
 
 package org.apache.geode.security;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.assertj.core.api.Assertions.*;
-
-import java.util.Properties;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.apache.geode.test.dunit.Host.getHost;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
+import java.util.Properties;
 
 @Category({DistributedTest.class, SecurityTest.class})
 public class StartServerAuthorizationTest extends JUnit4DistributedTestCase {
@@ -42,7 +43,7 @@ public class StartServerAuthorizationTest extends JUnit4DistributedTestCase {
   public void before() throws Exception {
     Properties props = new Properties();
     props.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
-    lsRule.getLocatorVM(0, props);
+    lsRule.startLocatorVM(0, props);
   }
 
   @Test
@@ -52,10 +53,10 @@ public class StartServerAuthorizationTest extends JUnit4DistributedTestCase {
     props.setProperty("security-username", "user");
     props.setProperty("security-password", "wrongPswd");
 
-    VM server = lsRule.getNodeVM(1);
+    VM server = getHost(0).getVM(1);
     server.invoke(() -> {
       ServerStarterRule serverStarter = new ServerStarterRule(props);
-      assertThatThrownBy(() -> serverStarter.startServer(lsRule.getPort(0)))
+      assertThatThrownBy(() -> serverStarter.startServer(lsRule.getMember(0).getPort()))
           .isInstanceOf(GemFireSecurityException.class).hasMessageContaining(
               "Security check failed. Authentication error. Please check your credentials");
     });
@@ -69,15 +70,13 @@ public class StartServerAuthorizationTest extends JUnit4DistributedTestCase {
     props.setProperty("security-username", "user");
     props.setProperty("security-password", "user");
 
-    VM server = lsRule.getNodeVM(1);
+    VM server = getHost(0).getVM(1);
     server.invoke(() -> {
       ServerStarterRule serverStarter = new ServerStarterRule(props);
-      assertThatThrownBy(() -> serverStarter.startServer(lsRule.getPort(0)))
+      assertThatThrownBy(() -> serverStarter.startServer(lsRule.getMember(0).getPort()))
           .isInstanceOf(GemFireSecurityException.class)
           .hasMessageContaining("user not authorized for CLUSTER:MANAGE");
     });
-
-
   }
 
   @Test
@@ -88,7 +87,7 @@ public class StartServerAuthorizationTest extends JUnit4DistributedTestCase {
     props.setProperty("security-username", "cluster");
     props.setProperty("security-password", "cluster");
 
-    lsRule.getServerVM(1, props);
+    lsRule.startServerVM(1, props);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/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 6053e1e..c56f7ab 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
@@ -11,6 +11,7 @@
  * 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;
@@ -21,57 +22,72 @@ import static org.apache.geode.test.dunit.Host.getHost;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.Invoke;
 import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.rules.ExternalResource;
+import org.junit.rules.TemporaryFolder;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.Properties;
 
 
 /**
- * this rule can help you start up locator/server in different VMs you can multiple locators/servers
- * combination
+ * A rule to help you start locators and servers inside of a
+ * <a href="https://cwiki.apache.org/confluence/display/GEODE/Distributed-Unit-Tests">DUnit
+ * test</a>. This rule will start Servers and Locators inside of the four remote {@link VM}s created
+ * by the DUnit framework.
  */
 public class LocatorServerStartupRule extends ExternalResource implements Serializable {
 
-  // these are only avaialbe in each VM
+  /**
+   * This is only available in each Locator/Server VM, not in the controller (test) VM.
+   */
   public static ServerStarterRule serverStarter;
+
+  /**
+   * This is only available in each Locator/Server VM, not in the controller (test) VM.
+   */
   public static LocatorStarterRule locatorStarter;
-  public int[] ports = new int[4];
-  private Host host = getHost(0);
+
+  private TemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
+  private Member[] members;
 
   @Before
-  public void before() {
-    after();
+  public void before() throws IOException {
+    temporaryFolder.create();
+    Invoke.invokeInEveryVM("Stop each VM", this::stop);
+    members = new Member[4];
   }
 
   @After
   public void after() {
-    stop();
-    Invoke.invokeInEveryVM("Stop each VM", () -> stop());
+    temporaryFolder.delete();
+    Invoke.invokeInEveryVM("Stop each VM", this::stop);
   }
 
   /**
-   * Returns getHost(0).getVM(0) as a locator instance with the given configuration properties.
-   * 
-   * @param locatorProperties
+   * Starts a locator instance with the given configuration properties inside
+   * {@code getHost(0).getVM(index)}.
    *
    * @return VM locator vm
-   *
-   * @throws IOException
    */
-  public VM getLocatorVM(int index, Properties locatorProperties) throws IOException {
-    VM locatorVM = host.getVM(index);
-    locatorProperties.setProperty(NAME, "locator-" + index);
+  public Member startLocatorVM(int index, Properties locatorProperties) throws IOException {
+    String name = "locator-" + index;
+    locatorProperties.setProperty(NAME, name);
+    File workingDir = createWorkingDirForMember(name);
+
+    VM locatorVM = getHost(0).getVM(index);
     int locatorPort = locatorVM.invoke(() -> {
+      System.setProperty("user.dir", workingDir.getCanonicalPath());
       locatorStarter = new LocatorStarterRule(locatorProperties);
       locatorStarter.startLocator();
       return locatorStarter.locator.getPort();
     });
-    ports[index] = locatorPort;
-    return locatorVM;
+    members[index] = new Member(locatorVM, locatorPort, workingDir);
+    return members[index];
   }
 
   /**
@@ -79,48 +95,41 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
    * 
    * @return VM node vm
    */
-
-  public VM getServerVM(int index, Properties properties) {
-    return getServerVM(index, properties, 0);
+  public Member startServerVM(int index, Properties properties) throws IOException {
+    return startServerVM(index, properties, 0);
   }
 
   /**
-   * starts a cache server that connect to the locator running at the given port.
-   * 
-   * @param index
-   * @param properties
-   * @param locatorPort
-   * @return
+   * Starts a cache server that connect to the locator running at the given port.
    */
-  public VM getServerVM(int index, Properties properties, int locatorPort) {
-    VM nodeVM = getNodeVM(index);
-    properties.setProperty(NAME, "server-" + index);
-    int port = nodeVM.invoke(() -> {
+  public Member startServerVM(int index, Properties properties, int locatorPort)
+      throws IOException {
+    String name = "server-" + index;
+    properties.setProperty(NAME, name);
+    File workingDir = createWorkingDirForMember(name);
+
+    VM serverVM = getHost(0).getVM(index);
+    int port = serverVM.invoke(() -> {
+      System.setProperty("user.dir", workingDir.getCanonicalPath());
       serverStarter = new ServerStarterRule(properties);
       serverStarter.startServer(locatorPort);
       return serverStarter.server.getPort();
     });
-    ports[index] = port;
-    return nodeVM;
+    members[index] = new Member(serverVM, port, workingDir);
+    return members[index];
   }
 
-
-
   /**
-   * this will simply returns the node
-   * 
-   * @param index
-   * @return
+   * Returns the {@link Member} running inside the VM with the specified {@code index}
    */
-  public VM getNodeVM(int index) {
-    return host.getVM(index);
+  public Member getMember(int index) {
+    return members[index];
   }
 
-  public int getPort(int index) {
-    return ports[index];
+  public TemporaryFolder getRootFolder() {
+    return temporaryFolder;
   }
 
-
   public final void stop() {
     if (serverStarter != null) {
       serverStarter.after();
@@ -130,4 +139,13 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     }
   }
 
+  private File createWorkingDirForMember(String dirName) throws IOException {
+    File workingDir = new File(temporaryFolder.getRoot(), dirName);
+    if (!workingDir.exists()) {
+      temporaryFolder.newFolder(dirName);
+    }
+
+    return workingDir;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/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 3329a40..6fc0d03 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
@@ -33,11 +33,14 @@ import java.util.concurrent.TimeUnit;
 /**
  * This is a rule to start up a locator in your current VM. It's useful for your Integration Tests.
  *
- * If you need a rule to start a server/locator in different VM for Distribution tests, You should
- * use LocatorServerStartupRule
+ * If you need a rule to start a server/locator in different VMs for Distributed tests, You should
+ * use {@link LocatorServerStartupRule}.
  *
- * You may choose to use this class not as a rule or use it in your own rule, (see
- * LocatorServerStartupRule) you will need to call startLocator() and after() manually in that case.
+ * <p>
+ * You may choose to use this class not as a rule or use it in your own rule (see
+ * {@link LocatorServerStartupRule}), in which case you will need to call startLocator() and after()
+ * manually.
+ * </p>
  */
 
 public class LocatorStarterRule extends ExternalResource implements Serializable {

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/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
new file mode 100644
index 0000000..10b6743
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
@@ -0,0 +1,62 @@
+/*
+ * 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;
+import java.io.Serializable;
+
+/**
+ * A server or locator inside a DUnit {@link VM}.
+ */
+public class Member implements Serializable {
+  private VM vm;
+  private int port;
+  private File workingDir;
+
+  public Member(VM vm, int port, File workingDir) {
+    this.vm = vm;
+    this.port = port;
+    this.workingDir = workingDir;
+  }
+
+  /**
+   * 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 int getPort() {
+    return port;
+  }
+
+  public File getWorkingDir() {
+    return workingDir;
+  }
+
+  /**
+   * Invokes {@code runnable.run()} in the {@code VM} of this member.
+   */
+  public void invoke(final SerializableRunnableIF runnable) {
+    this.vm.invoke(runnable);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/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 8da0778..c94185a 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
@@ -25,6 +25,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 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.Serializable;
@@ -34,11 +35,13 @@ import java.util.Properties;
 /**
  * This is a rule to start up a server in your current VM. It's useful for your Integration Tests.
  *
- * If you need a rule to start a server/locator in different VM for Distribution tests, You should
- * use LocatorServerStartupRule
- *
- * You may choose to use this class not as a rule or use it in your own rule, (see
- * LocatorServerStartupRule) you will need to call startServer and after() manually in that case.
+ * If you need a rule to start a server/locator in different VMs for Distributed tests, You should
+ * use {@link LocatorServerStartupRule}.
+ * <p>
+ * You may choose to use this class not as a rule or use it in your own rule (see
+ * {@link LocatorServerStartupRule}), in which case you will need to call startLocator() and after()
+ * manually.
+ * </p>
  */
 public class ServerStarterRule extends ExternalResource implements Serializable {
 
@@ -66,10 +69,12 @@ public class ServerStarterRule extends ExternalResource implements Serializable
     if (!properties.containsKey(NAME)) {
       properties.setProperty(NAME, this.getClass().getName());
     }
-    if (locatorPort > 0) {
-      properties.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
-    } else {
-      properties.setProperty(LOCATORS, "");
+    if (!properties.containsKey(LOCATORS)) {
+      if (locatorPort > 0) {
+        properties.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
+      } else {
+        properties.setProperty(LOCATORS, "");
+      }
     }
     if (properties.containsKey(JMX_MANAGER_PORT)) {
       int jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
@@ -84,7 +89,6 @@ public class ServerStarterRule extends ExternalResource implements Serializable
     CacheFactory cf = new CacheFactory(properties);
     cf.setPdxReadSerialized(pdxPersistent);
     cf.setPdxPersistent(pdxPersistent);
-
     cache = cf.create();
     server = cache.addCacheServer();
     server.setPort(0);
@@ -102,9 +106,13 @@ public class ServerStarterRule extends ExternalResource implements Serializable
 
   @Override
   public void after() {
-    if (cache != null)
+    if (cache != null) {
       cache.close();
-    if (server != null)
+      cache = null;
+    }
+    if (server != null) {
       server.stop();
+      server = null;
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config.zip
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config.zip b/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config.zip
new file mode 100644
index 0000000..37cacbf
Binary files /dev/null and b/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config.zip differ

http://git-wip-us.apache.org/repos/asf/geode/blob/adfd41f4/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 02b7fe4..0b0e936 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
@@ -26,6 +26,8 @@ import java.util.Arrays;
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.Member;
 import org.apache.lucene.analysis.Analyzer;
 import org.junit.Rule;
 import org.junit.Test;
@@ -45,7 +47,6 @@ 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.dunit.VM;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 
 
@@ -59,8 +60,8 @@ public class LuceneClusterConfigurationDUnitTest extends CliCommandTestBase {
 
   @Test
   public void indexGetsCreatedUsingClusterConfiguration() throws Exception {
-    VM locator = startLocatorWithClusterConfigurationEnabled();
-    VM vm1 = startNodeUsingClusterConfiguration(1, false);
+    Member locator = startLocatorWithClusterConfigurationEnabled();
+    Member vm1 = startNodeUsingClusterConfiguration(1, false);
 
     // Connect Gfsh to locator.
     createAndConnectGfshToLocator();
@@ -72,7 +73,7 @@ public class LuceneClusterConfigurationDUnitTest extends CliCommandTestBase {
 
     // Start vm2. This should have lucene index created using cluster
     // configuration.
-    VM vm2 = startNodeUsingClusterConfiguration(2, false);
+    Member vm2 = startNodeUsingClusterConfiguration(2, false);
     vm2.invoke(() -> {
       LuceneService luceneService = LuceneServiceProvider.get(ls.serverStarter.cache);
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
@@ -83,8 +84,8 @@ public class LuceneClusterConfigurationDUnitTest extends CliCommandTestBase {
 
   @Test
   public void indexWithAnalyzerGetsCreatedUsingClusterConfiguration() throws Exception {
-    VM locator = startLocatorWithClusterConfigurationEnabled();
-    VM vm1 = startNodeUsingClusterConfiguration(1, false);
+    Member locator = startLocatorWithClusterConfigurationEnabled();
+    Member vm1 = startNodeUsingClusterConfiguration(1, false);
 
     // Connect Gfsh to locator.
     createAndConnectGfshToLocator();
@@ -97,7 +98,7 @@ public class LuceneClusterConfigurationDUnitTest extends CliCommandTestBase {
 
     // Start vm2. This should have lucene index created using cluster
     // configuration.
-    VM vm2 = startNodeUsingClusterConfiguration(2, false);
+    Member vm2 = startNodeUsingClusterConfiguration(2, false);
     vm2.invoke(() -> {
       LuceneService luceneService = LuceneServiceProvider.get(ls.serverStarter.cache);
       final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
@@ -115,14 +116,14 @@ public class LuceneClusterConfigurationDUnitTest extends CliCommandTestBase {
 
   @Test
   public void indexGetsCreatedOnGroupOfNodes() throws Exception {
-    VM locator = startLocatorWithClusterConfigurationEnabled();
+    Member locator = startLocatorWithClusterConfigurationEnabled();
 
     // Start vm1, vm2 in group
-    VM vm1 = startNodeUsingClusterConfiguration(1, true);
-    VM vm2 = startNodeUsingClusterConfiguration(2, true);
+    Member vm1 = startNodeUsingClusterConfiguration(1, true);
+    Member vm2 = startNodeUsingClusterConfiguration(2, true);
 
     // Start vm3 outside the group. The Lucene index should not be present here.
-    VM vm3 = startNodeUsingClusterConfiguration(3, true);
+    Member vm3 = startNodeUsingClusterConfiguration(3, true);
 
     // Connect Gfsh to locator.
     createAndConnectGfshToLocator();
@@ -151,14 +152,14 @@ public class LuceneClusterConfigurationDUnitTest extends CliCommandTestBase {
 
   @Test
   public void indexNotCreatedOnNodeOutSideTheGroup() throws Exception {
-    VM locator = startLocatorWithClusterConfigurationEnabled();
+    Member locator = startLocatorWithClusterConfigurationEnabled();
 
     // Start vm1, vm2 in group
-    VM vm1 = startNodeUsingClusterConfiguration(1, true);
-    VM vm2 = startNodeUsingClusterConfiguration(2, true);
+    Member vm1 = startNodeUsingClusterConfiguration(1, true);
+    Member vm2 = startNodeUsingClusterConfiguration(2, true);
 
     // Start vm3 outside the group. The Lucene index should not be present here.
-    VM vm3 = startNodeUsingClusterConfiguration(3, false);
+    Member vm3 = startNodeUsingClusterConfiguration(3, false);
 
     // Connect Gfsh to locator.
     createAndConnectGfshToLocator();
@@ -187,10 +188,10 @@ public class LuceneClusterConfigurationDUnitTest extends CliCommandTestBase {
 
   @Test
   public void indexAreCreatedInValidGroupOfNodesJoiningLater() throws Exception {
-    VM locator = startLocatorWithClusterConfigurationEnabled();
+    Member locator = startLocatorWithClusterConfigurationEnabled();
 
     // Start vm1 in group
-    VM vm1 = startNodeUsingClusterConfiguration(1, true);
+    Member vm1 = startNodeUsingClusterConfiguration(1, true);
     // Connect Gfsh to locator.
     createAndConnectGfshToLocator();
 
@@ -200,10 +201,10 @@ public class LuceneClusterConfigurationDUnitTest extends CliCommandTestBase {
     createRegionUsingGfsh(REGION_NAME, RegionShortcut.PARTITION, groupName);
 
     // Start vm2 in group
-    VM vm2 = startNodeUsingClusterConfiguration(2, true);
+    Member vm2 = startNodeUsingClusterConfiguration(2, true);
 
     // Start vm3 outside the group. The Lucene index should not be present here.
-    VM vm3 = startNodeUsingClusterConfiguration(3, false);
+    Member vm3 = startNodeUsingClusterConfiguration(3, false);
 
     // VM2 should have lucene index created using gfsh execution
     vm2.invoke(() -> {
@@ -226,7 +227,8 @@ public class LuceneClusterConfigurationDUnitTest extends CliCommandTestBase {
     connect(jmxHost, jmxPort, httpPort, gfsh);
   }
 
-  private VM startNodeUsingClusterConfiguration(int vmIndex, boolean addGroup) throws Exception {
+  private Member startNodeUsingClusterConfiguration(int vmIndex, boolean addGroup)
+      throws Exception {
     File dir = this.temporaryFolder.newFolder();
     Properties nodeProperties = new Properties();
     nodeProperties.setProperty(USE_CLUSTER_CONFIGURATION, "true");
@@ -234,10 +236,10 @@ public class LuceneClusterConfigurationDUnitTest extends CliCommandTestBase {
     if (addGroup) {
       nodeProperties.setProperty(GROUPS, groupName);
     }
-    return ls.getServerVM(vmIndex, nodeProperties, ls.getPort(0));
+    return ls.startServerVM(vmIndex, nodeProperties, ls.getMember(0).getPort());
   }
 
-  private VM startLocatorWithClusterConfigurationEnabled() throws Exception {
+  private Member startLocatorWithClusterConfigurationEnabled() throws Exception {
     try {
       jmxHost = InetAddress.getLocalHost().getHostName();
     } catch (UnknownHostException ignore) {
@@ -258,7 +260,7 @@ public class LuceneClusterConfigurationDUnitTest extends CliCommandTestBase {
     locatorProps.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxPort));
     locatorProps.setProperty(HTTP_SERVICE_PORT, String.valueOf(httpPort));
     locatorProps.setProperty(CLUSTER_CONFIGURATION_DIR, dir.getCanonicalPath());
-    return ls.getLocatorVM(0, locatorProps);
+    return ls.startLocatorVM(0, locatorProps);
   }
 
   private void createLuceneIndexUsingGfsh(boolean addGroup) throws Exception {


[11/19] geode git commit: Update website release references to remove incubator

Posted by kl...@apache.org.
Update website release references to remove incubator

The release location has changed due to TLP. After the next release,
we should also update the archives location on the release page.


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

Branch: refs/heads/feature/GEODE-1027
Commit: ac3a8224170c48358dba706d4704058eaf53608f
Parents: 0918488
Author: Anthony Baker <ab...@apache.org>
Authored: Fri Dec 9 12:47:56 2016 -0800
Committer: Anthony Baker <ab...@apache.org>
Committed: Fri Dec 9 12:49:34 2016 -0800

----------------------------------------------------------------------
 geode-site/website/content/releases/index.html | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/ac3a8224/geode-site/website/content/releases/index.html
----------------------------------------------------------------------
diff --git a/geode-site/website/content/releases/index.html b/geode-site/website/content/releases/index.html
index de0335d..8947839 100644
--- a/geode-site/website/content/releases/index.html
+++ b/geode-site/website/content/releases/index.html
@@ -39,10 +39,10 @@ under the License. -->
         <!-- BINARY -->
         <ul>
             <span class="icon-cloud-download"> <strong>Binaries </strong>
-              [ <a href="http://apache.org/dyn/closer.cgi/incubator/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.zip">ZIP</a>, <a href="https://dist.apache.org/repos/dist/release/incubator/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.zip.sha256">SHA-256</a>,
-              <a href="https://dist.apache.org/repos/dist/release/incubator/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.zip.asc">PGP</a> ] -
-              [<a href="http://apache.org/dyn/closer.cgi/incubator/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.tar.gz">TAR.GZ</a>, <a href="https://dist.apache.org/repos/dist/release/incubator/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.tar.gz.sha256">SHA-256</a>,
-              <a href="https://dist.apache.org/repos/dist/release/incubator/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.tar.gz.asc">PGP</a> ]
+              [ <a href="http://apache.org/dyn/closer.cgi/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.zip">ZIP</a>, <a href="https://dist.apache.org/repos/dist/release/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.zip.sha256">SHA-256</a>,
+              <a href="https://dist.apache.org/repos/dist/release/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.zip.asc">PGP</a> ] -
+              [<a href="http://apache.org/dyn/closer.cgi/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.tar.gz">TAR.GZ</a>, <a href="https://dist.apache.org/repos/dist/release/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.tar.gz.sha256">SHA-256</a>,
+              <a href="https://dist.apache.org/repos/dist/release/geode/1.0.0-incubating/apache-geode-1.0.0-incubating.tar.gz.asc">PGP</a> ]
               </span>
 
               <blockquote>Binary downloads are provided for the convenience of our users and are not official Apache Geode releases. </blockquote>
@@ -51,11 +51,11 @@ under the License. -->
         <!-- SOURCE -->
         <ul>
             <span class="icon-cloud-download"> <strong>Source</strong>
-               [ <a href="http://apache.org/dyn/closer.cgi/incubator/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.zip">ZIP</a>, <a href="https://dist.apache.org/repos/dist/release/incubator/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.zip.sha256">SHA-256</a>,
-               <a href="https://dist.apache.org/repos/dist/release/incubator/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.zip.asc">PGP</a>
+               [ <a href="http://apache.org/dyn/closer.cgi/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.zip">ZIP</a>, <a href="https://dist.apache.org/repos/dist/release/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.zip.sha256">SHA-256</a>,
+               <a href="https://dist.apache.org/repos/dist/release/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.zip.asc">PGP</a>
                 ] -
-               [<a href="http://apache.org/dyn/closer.cgi/incubator/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.tar.gz">TAR.GZ</a>, <a href="https://dist.apache.org/repos/dist/release/incubator/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.tar.gz.sha256">SHA-256</a>,
-               <a href="https://dist.apache.org/repos/dist/release/incubator/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.tar.gz.asc">PGP</a>
+               [<a href="http://apache.org/dyn/closer.cgi/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.tar.gz">TAR.GZ</a>, <a href="https://dist.apache.org/repos/dist/release/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.tar.gz.sha256">SHA-256</a>,
+               <a href="https://dist.apache.org/repos/dist/release/geode/1.0.0-incubating/apache-geode-src-1.0.0-incubating.tar.gz.asc">PGP</a>
                ]
              </span>
             </li>
@@ -98,10 +98,10 @@ under the License. -->
 					Project releases are approved by vote of the Apache Geode Project Management Committee (PMC). Support for a release is provided by project volunteers on the project <a href="http://geode.apache.org/community/#mailing-lists">mailing lists</a>. Bugs found in a release may be discussed on the list and reported through the <a href="https://issues.apache.org/jira/browse/GEODE">issue tracker</a>. The user mailing list and issue tracker are the only support options hosted by the Apache Geode project.
 				</p>
 				<p>
-					<strong>Note</strong>: When downloading from a mirror, please be sure to verify that checksums and signatures are correct. To do so, use the checksum and signature files from the main Apache site at <a href="https://dist.apache.org/repos/dist/release/incubator/geode/">https://dist.apache.org/repos/dist/release/incubator/geode/</a>. Find here the KEYS file, which contains all OpenPGP keys we use to sign releases here: <a href="https://git-wip-us.apache.org/repos/asf?p=geode.git;a=blob;f=KEYS;h=9d13f70a9ce8f8d6a7c3feb1e194ccec123b5868;hb=c26334542fa9e90daff5f58467d6e174b3e0f3e2">KEYS</a>
+					<strong>Note</strong>: When downloading from a mirror, please be sure to verify that checksums and signatures are correct. To do so, use the checksum and signature files from the main Apache site at <a href="https://dist.apache.org/repos/dist/release/geode/">https://dist.apache.org/repos/dist/release/geode/</a>. Find here the KEYS file, which contains all OpenPGP keys we use to sign releases here: <a href="https://git-wip-us.apache.org/repos/asf?p=geode.git;a=blob;f=KEYS;h=9d13f70a9ce8f8d6a7c3feb1e194ccec123b5868;hb=c26334542fa9e90daff5f58467d6e174b3e0f3e2">KEYS</a>
 				</p>
 				<p>
-					The PGP signatures can be verified using PGP or GPG. First download the <a href="https://git-wip-us.apache.org/repos/asf?p=geode.git;a=blob;f=KEYS;h=9d13f70a9ce8f8d6a7c3feb1e194ccec123b5868;hb=c26334542fa9e90daff5f58467d6e174b3e0f3e2">KEYS</a> as well as the <a href="https://dist.apache.org/repos/dist/release/incubator/geode/1.0.0-incubating.M1/">asc signature</a> file for the particular distribution. Then verify the signatures using:
+					The PGP signatures can be verified using PGP or GPG. First download the <a href="https://git-wip-us.apache.org/repos/asf?p=geode.git;a=blob;f=KEYS;h=9d13f70a9ce8f8d6a7c3feb1e194ccec123b5868;hb=c26334542fa9e90daff5f58467d6e174b3e0f3e2">KEYS</a> as well as the <em>asc signature</em> file for the particular distribution. Then verify the signatures using:
 				</p>
 				<p>
        				% pgpk -a KEYS


[17/19] geode git commit: Removed a misplaced occurrence of "Pivotal" from the docs.

Posted by kl...@apache.org.
Removed a misplaced occurrence of "Pivotal" from the docs.


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

Branch: refs/heads/feature/GEODE-1027
Commit: 0f28be98f07e3fc5c6c982fcd3f5cd2c72252c1a
Parents: 5d2f0f6
Author: Dave Barnes <db...@pivotal.io>
Authored: Mon Dec 12 10:20:36 2016 -0800
Committer: Dave Barnes <db...@pivotal.io>
Committed: Mon Dec 12 10:20:36 2016 -0800

----------------------------------------------------------------------
 .../http_session_mgmt/tomcat_installing_the_module.html.md.erb     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/0f28be98/geode-docs/tools_modules/http_session_mgmt/tomcat_installing_the_module.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/tools_modules/http_session_mgmt/tomcat_installing_the_module.html.md.erb b/geode-docs/tools_modules/http_session_mgmt/tomcat_installing_the_module.html.md.erb
index 9840024..b96a254 100644
--- a/geode-docs/tools_modules/http_session_mgmt/tomcat_installing_the_module.html.md.erb
+++ b/geode-docs/tools_modules/http_session_mgmt/tomcat_installing_the_module.html.md.erb
@@ -22,7 +22,7 @@ limitations under the License.
 This topic describes how to install the HTTP session management module for Tomcat.
 
 1.  If you do not already have Tomcat installed, download the desired version from the [Apache Website](http://tomcat.apache.org/).
-2.  The HTTP Session Management Module for Tomcat is included in the Pivotal Geode installation package. After you install Apache Geode, you will find the module in the `tools/Modules` directory of the installation.
+2.  The HTTP Session Management Module for Tomcat is included in the Geode installation package. After you install Apache Geode, you will find the module in the `tools/Modules` directory of the installation.
 
 3.  Unzip the module into the `$CATALINA_HOME` directory or wherever you installed the application server.
 4.  Copy the following jar files to the `lib` directory of your Tomcat server (`$CATALINA_HOME/lib`):


[10/19] geode git commit: GEODE-2186: Changing the gateway status to only looking running status

Posted by kl...@apache.org.
GEODE-2186: Changing the gateway status to only looking running status

Gateway senders may or may not be connected, depending on what is going
on with the underlying queue. If a sender is a secondary, it may be
disconnected because it doesn't need to send anything. Even primaries
may be disconnected for periods of time if the connection is lost when
there is nothing in the queue.


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

Branch: refs/heads/feature/GEODE-1027
Commit: 09184881aec9250fdf2e96f4fced4dedaac0bda7
Parents: adfd41f
Author: Dan Smith <up...@apache.org>
Authored: Tue Dec 6 16:52:24 2016 -0800
Committer: Dan Smith <up...@apache.org>
Committed: Fri Dec 9 11:11:26 2016 -0800

----------------------------------------------------------------------
 .../internal/beans/DistributedSystemBridge.java     |  4 +---
 .../geode/management/WANManagementDUnitTest.java    | 16 +++++++---------
 2 files changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/09184881/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
index 3016277..5b8c115 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
@@ -1566,10 +1566,8 @@ public class DistributedSystemBridge {
         GatewaySenderMXBean bean = it.next();
         Integer dsId = bean.getRemoteDSId();
         if (dsId != null) {
-          senderMap.put(dsId.toString(), bean.isConnected());
+          senderMap.merge(dsId.toString(), bean.isRunning(), Boolean::logicalAnd);
         }
-
-
       }
 
       return senderMap;

http://git-wip-us.apache.org/repos/asf/geode/blob/09184881/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 3cc37eb..dc801be 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
@@ -38,7 +38,6 @@ 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.LogWriterUtils;
 import org.apache.geode.test.dunit.SerializableRunnable;
 import org.apache.geode.test.dunit.VM;
 
@@ -54,9 +53,6 @@ public class WANManagementDUnitTest extends ManagementTestBase {
 
   private static final long serialVersionUID = 1L;
 
-
-  public static MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
-
   public WANManagementDUnitTest() throws Exception {
     super();
   }
@@ -91,6 +87,7 @@ public class WANManagementDUnitTest extends ManagementTestBase {
     managing.invoke(() -> WANTestBase.createManagementCache(punePort));
     startManagingNode(managing);
 
+
     // keep a larger batch to minimize number of exception occurrences in the
     // log
     puneSender
@@ -104,6 +101,7 @@ public class WANManagementDUnitTest extends ManagementTestBase {
     managing.invoke(() -> WANTestBase.createPartitionedRegion(getTestMethodName() + "_PR", "pn", 1,
         100, false));
 
+
     nyReceiver.invoke(() -> WANTestBase.createCache(nyPort));
     nyReceiver.invoke(() -> WANTestBase.createPartitionedRegion(getTestMethodName() + "_PR", null,
         1, 100, false));
@@ -314,11 +312,11 @@ public class WANManagementDUnitTest extends ManagementTestBase {
 
         if (service.isManager()) {
           DistributedSystemMXBean dsBean = service.getDistributedSystemMXBean();
-          Map<String, Boolean> dsMap = dsBean.viewRemoteClusterStatus();
-
-          LogWriterUtils.getLogWriter()
-              .info("<ExpectedString> Ds Map is: " + dsMap + "</ExpectedString> ");
-
+          Awaitility.await().atMost(1, TimeUnit.MINUTES).until(() -> {
+            Map<String, Boolean> dsMap = dsBean.viewRemoteClusterStatus();
+            dsMap.entrySet().stream()
+                .forEach(entry -> assertTrue("Should be true " + entry.getKey(), entry.getValue()));
+          });
         }
 
       }


[19/19] geode git commit: GEODE-1027: add unit test for previously committed fix

Posted by kl...@apache.org.
GEODE-1027: add unit test for previously committed fix


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

Branch: refs/heads/feature/GEODE-1027
Commit: 1f49cbcc8cbaad5c0c2ccb8063a67bd6bb88a9b9
Parents: 8eb09bd
Author: Kirk Lund <kl...@apache.org>
Authored: Wed Dec 7 15:33:51 2016 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon Dec 12 14:38:27 2016 -0800

----------------------------------------------------------------------
 .../internal/statistics/SampleCollector.java    |   4 +-
 .../internal/statistics/StatisticsMonitor.java  |  28 ++---
 .../geode/internal/statistics/ValueMonitor.java |  20 ++--
 .../internal/beans/stats/MBeanStatsMonitor.java |  54 +++++----
 .../internal/statistics/FakeValueMonitor.java   |  37 ++++++
 .../beans/stats/MBeanStatsMonitorTest.java      | 117 +++++++++++++++++++
 6 files changed, 212 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/1f49cbcc/geode-core/src/main/java/org/apache/geode/internal/statistics/SampleCollector.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/SampleCollector.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/SampleCollector.java
index 9f1b343..2abbecd 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/statistics/SampleCollector.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/SampleCollector.java
@@ -115,7 +115,7 @@ public class SampleCollector {
    * 
    * @throws IllegalStateException if no SampleCollector has been created and initialized yet
    */
-  public static StatMonitorHandler getStatMonitorHandler() {
+  static StatMonitorHandler getStatMonitorHandler() {
     // sync SampleCollector.class and then instance.sampleHandlers
     synchronized (SampleCollector.class) {
       if (instance == null) {
@@ -321,7 +321,7 @@ public class SampleCollector {
   }
 
   /** For testing only */
-  public StatArchiveHandler getStatArchiveHandler() {
+  StatArchiveHandler getStatArchiveHandler() {
     synchronized (this.sampleHandlers) {
       return this.statArchiveHandler;
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/1f49cbcc/geode-core/src/main/java/org/apache/geode/internal/statistics/StatisticsMonitor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatisticsMonitor.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatisticsMonitor.java
index 16f71e2..a00a7a3 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatisticsMonitor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatisticsMonitor.java
@@ -29,14 +29,13 @@ public abstract class StatisticsMonitor {
 
   private final Object mutex = new Object();
 
-  private final ConcurrentHashSet<StatisticsListener> listeners =
-      new ConcurrentHashSet<StatisticsListener>();
+  private final ConcurrentHashSet<StatisticsListener> listeners = new ConcurrentHashSet<>();
 
-  private final ConcurrentHashSet<StatisticId> statisticIds = new ConcurrentHashSet<StatisticId>();
+  private final ConcurrentHashSet<StatisticId> statisticIds = new ConcurrentHashSet<>();
 
   public StatisticsMonitor() {}
 
-  public StatisticsMonitor addStatistic(StatisticId statId) {
+  public StatisticsMonitor addStatistic(final StatisticId statId) {
     if (statId == null) {
       throw new NullPointerException("StatisticId is null");
     }
@@ -46,7 +45,7 @@ public abstract class StatisticsMonitor {
     return this;
   }
 
-  public StatisticsMonitor removeStatistic(StatisticId statId) {
+  public StatisticsMonitor removeStatistic(final StatisticId statId) {
     if (statId == null) {
       throw new NullPointerException("StatisticId is null");
     }
@@ -56,7 +55,7 @@ public abstract class StatisticsMonitor {
     return this;
   }
 
-  public final void addListener(StatisticsListener listener) {
+  public void addListener(final StatisticsListener listener) {
     if (listener == null) {
       throw new NullPointerException("StatisticsListener is null");
     }
@@ -68,7 +67,7 @@ public abstract class StatisticsMonitor {
     }
   }
 
-  public final void removeListener(StatisticsListener listener) {
+  public void removeListener(final StatisticsListener listener) {
     if (listener == null) {
       throw new NullPointerException("StatisticsListener is null");
     }
@@ -93,24 +92,25 @@ public abstract class StatisticsMonitor {
    * @param millisTimeStamp the real time in millis of the sample
    * @param resourceInstances resources with one or more updated values
    */
-  protected void monitor(long millisTimeStamp, List<ResourceInstance> resourceInstances) {
+  protected void monitor(final long millisTimeStamp,
+      final List<ResourceInstance> resourceInstances) {
     monitorStatisticIds(millisTimeStamp, resourceInstances);
   }
 
-  private final void monitorStatisticIds(long millisTimeStamp,
-      List<ResourceInstance> resourceInstances) {
+  private void monitorStatisticIds(final long millisTimeStamp,
+      final List<ResourceInstance> resourceInstances) {
     if (!this.statisticIds.isEmpty()) {
       // TODO:
     }
   }
 
-  protected final void notifyListeners(StatisticsNotification notification) {
+  protected void notifyListeners(final StatisticsNotification notification) {
     for (StatisticsListener listener : this.listeners) {
       listener.handleNotification(notification);
     }
   }
 
-  protected final Object mutex() {
+  protected Object mutex() {
     return this.mutex;
   }
 
@@ -137,7 +137,9 @@ public abstract class StatisticsMonitor {
     return sb.toString();
   }
 
-  /** Override to append to toString() */
+  /**
+   * Override to append to toString()
+   */
   protected StringBuilder appendToString() {
     return null;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/1f49cbcc/geode-core/src/main/java/org/apache/geode/internal/statistics/ValueMonitor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/ValueMonitor.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/ValueMonitor.java
index 1dc6fd0..e46723c 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/statistics/ValueMonitor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/ValueMonitor.java
@@ -43,31 +43,31 @@ import org.apache.geode.internal.CopyOnWriteHashSet;
  * @since GemFire 7.0
  * @see org.apache.geode.Statistics
  */
-public final class ValueMonitor extends StatisticsMonitor {
+public class ValueMonitor extends StatisticsMonitor {
 
   public enum Type {
     CHANGE, MATCH, DIFFER
   }
 
-  private final CopyOnWriteHashSet<Statistics> statistics = new CopyOnWriteHashSet<Statistics>();
+  private final CopyOnWriteHashSet<Statistics> statistics = new CopyOnWriteHashSet<>();
 
   public ValueMonitor() {
     super();
   }
 
   @Override
-  public ValueMonitor addStatistic(StatisticId statId) {
+  public ValueMonitor addStatistic(final StatisticId statId) {
     super.addStatistic(statId);
     return this;
   }
 
   @Override
-  public ValueMonitor removeStatistic(StatisticId statId) {
+  public ValueMonitor removeStatistic(final StatisticId statId) {
     super.removeStatistic(statId);
     return this;
   }
 
-  public ValueMonitor addStatistics(Statistics statistics) {
+  public ValueMonitor addStatistics(final Statistics statistics) {
     if (statistics == null) {
       throw new NullPointerException("Statistics is null");
     }
@@ -75,7 +75,7 @@ public final class ValueMonitor extends StatisticsMonitor {
     return this;
   }
 
-  public ValueMonitor removeStatistics(Statistics statistics) {
+  public ValueMonitor removeStatistics(final Statistics statistics) {
     if (statistics == null) {
       throw new NullPointerException("Statistics is null");
     }
@@ -83,14 +83,16 @@ public final class ValueMonitor extends StatisticsMonitor {
     return this;
   }
 
-  protected void monitor(long millisTimeStamp, List<ResourceInstance> resourceInstances) {
+  protected void monitor(final long millisTimeStamp,
+      final List<ResourceInstance> resourceInstances) {
     super.monitor(millisTimeStamp, resourceInstances);
     monitorStatistics(millisTimeStamp, resourceInstances);
   }
 
-  protected void monitorStatistics(long millisTimeStamp, List<ResourceInstance> resourceInstances) {
+  protected void monitorStatistics(final long millisTimeStamp,
+      final List<ResourceInstance> resourceInstances) {
     if (!this.statistics.isEmpty()) {
-      Map<StatisticId, Number> stats = new HashMap<StatisticId, Number>();
+      Map<StatisticId, Number> stats = new HashMap<>();
       for (ResourceInstance resource : resourceInstances) {
         if (this.statistics.contains(resource.getStatistics())) {
           ResourceType resourceType = resource.getResourceType();

http://git-wip-us.apache.org/repos/asf/geode/blob/1f49cbcc/geode-core/src/main/java/org/apache/geode/management/internal/beans/stats/MBeanStatsMonitor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/stats/MBeanStatsMonitor.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/stats/MBeanStatsMonitor.java
index 390fb89..c1744f9 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/stats/MBeanStatsMonitor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/stats/MBeanStatsMonitor.java
@@ -17,11 +17,12 @@ package org.apache.geode.management.internal.beans.stats;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.StatisticDescriptor;
 import org.apache.geode.Statistics;
 import org.apache.geode.StatisticsType;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.i18n.LogWriterI18n;
+import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.statistics.StatisticId;
 import org.apache.geode.internal.statistics.StatisticNotFoundException;
 import org.apache.geode.internal.statistics.StatisticsListener;
@@ -30,11 +31,11 @@ import org.apache.geode.internal.statistics.ValueMonitor;
 
 /**
  * Class to get mappings of stats name to their values
- * 
- * 
  */
 public class MBeanStatsMonitor implements StatisticsListener {
 
+  private static final Logger logger = LogService.getLogger();
+
   protected ValueMonitor monitor;
 
   /**
@@ -44,17 +45,17 @@ public class MBeanStatsMonitor implements StatisticsListener {
 
   protected String monitorName;
 
-  private LogWriterI18n logger;
+  public MBeanStatsMonitor(final String name) {
+    this(name, new ValueMonitor());
+  }
 
-  public MBeanStatsMonitor(String name) {
+  MBeanStatsMonitor(final String name, final ValueMonitor monitor) {
     this.monitorName = name;
-    this.monitor = new ValueMonitor();
+    this.monitor = monitor;
     this.statsMap = new DefaultHashMap();
-    this.logger = InternalDistributedSystem.getLoggerI18n();
-
   }
 
-  public void addStatisticsToMonitor(Statistics stats) {
+  public void addStatisticsToMonitor(final Statistics stats) {
     monitor.addListener(this);// if already listener is added this will be a no-op
     // Initialize the stats with the current values.
     StatisticsType type = stats.getType();
@@ -65,7 +66,7 @@ public class MBeanStatsMonitor implements StatisticsListener {
     monitor.addStatistics(stats);
   }
 
-  public void removeStatisticsFromMonitor(Statistics stats) {
+  public void removeStatisticsFromMonitor(final Statistics stats) {
     statsMap.clear();
   }
 
@@ -73,13 +74,13 @@ public class MBeanStatsMonitor implements StatisticsListener {
     monitor.removeListener(this);
   }
 
-  public Number getStatistic(String statName) {
-    return statsMap.get(statName) != null ? statsMap.get(statName) : 0;
+  public Number getStatistic(final String statName) {
+    Number value = statsMap.get(statName);
+    return value != null ? value : 0;
   }
 
   @Override
-  public void handleNotification(StatisticsNotification notification) {
-
+  public void handleNotification(final StatisticsNotification notification) {
     for (StatisticId statId : notification) {
       StatisticDescriptor descriptor = statId.getStatisticDescriptor();
       String name = descriptor.getName();
@@ -91,33 +92,38 @@ public class MBeanStatsMonitor implements StatisticsListener {
       }
       log(name, value);
       statsMap.put(name, value);
-
     }
   }
 
-  protected void log(String name, Number value) {
-
-    if (logger != null && logger.finestEnabled()) {
-      logger.finest("Monitor = " + monitorName + " descriptor = " + name + " And Value = " + value);
+  protected void log(final String name, final Number value) {
+    if (logger.isTraceEnabled()) {
+      logger.trace("Monitor = {} descriptor = {} And value = {}", monitorName, name, value);
     }
   }
 
-  public static class DefaultHashMap {
-    private Map<String, Number> internalMap = new HashMap<String, Number>();
+  public static class DefaultHashMap { // TODO: delete this class
+    private Map<String, Number> internalMap = new HashMap<>();
 
     public DefaultHashMap() {}
 
-    public Number get(String key) {
+    public Number get(final String key) {
       return internalMap.get(key) != null ? internalMap.get(key) : 0;
     }
 
-    public void put(String key, Number value) {
+    public void put(final String key, final Number value) {
       internalMap.put(key, value);
     }
 
     public void clear() {
       internalMap.clear();
     }
+
+    /**
+     * For testing only
+     */
+    Map<String, Number> getInternalMap() {
+      return this.internalMap;
+    }
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/1f49cbcc/geode-core/src/test/java/org/apache/geode/internal/statistics/FakeValueMonitor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/statistics/FakeValueMonitor.java b/geode-core/src/test/java/org/apache/geode/internal/statistics/FakeValueMonitor.java
new file mode 100644
index 0000000..0b3a27d
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/statistics/FakeValueMonitor.java
@@ -0,0 +1,37 @@
+/*
+ * 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.statistics;
+
+import static org.mockito.Mockito.mock;
+
+/**
+ * Fake ValueMonitor which uses mocked StatMonitorHandler as a collaborator.
+ */
+public class FakeValueMonitor extends ValueMonitor {
+
+  private StatMonitorHandler statMonitorHandler;
+
+  public FakeValueMonitor() {
+    this(mock(StatMonitorHandler.class));
+  }
+
+  public FakeValueMonitor(StatMonitorHandler statMonitorHandler) {
+    this.statMonitorHandler = statMonitorHandler;
+  }
+
+  StatMonitorHandler getStatMonitorHandler() {
+    return this.statMonitorHandler;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/1f49cbcc/geode-core/src/test/java/org/apache/geode/management/internal/beans/stats/MBeanStatsMonitorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/beans/stats/MBeanStatsMonitorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/beans/stats/MBeanStatsMonitorTest.java
new file mode 100644
index 0000000..18d7f81
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/beans/stats/MBeanStatsMonitorTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.beans.stats;
+
+import static org.assertj.core.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+
+import org.apache.geode.StatisticDescriptor;
+import org.apache.geode.Statistics;
+import org.apache.geode.StatisticsType;
+import org.apache.geode.i18n.LogWriterI18n;
+import org.apache.geode.internal.statistics.FakeValueMonitor;
+import org.apache.geode.internal.statistics.ValueMonitor;
+import org.apache.geode.management.internal.beans.stats.MBeanStatsMonitor.DefaultHashMap;
+import org.apache.geode.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class MBeanStatsMonitorTest {
+
+  private ValueMonitor statsMonitor;
+
+  private StatisticDescriptor[] descriptors;
+
+  private Map<String, Number> expectedStatsMap;
+
+  @Spy
+  private DefaultHashMap statsMap;
+  @Mock
+  private LogWriterI18n logWriter;
+  @Mock
+  private Statistics stats;
+  @Mock
+  private StatisticsType statsType;
+
+  @InjectMocks
+  private MBeanStatsMonitor mbeanStatsMonitor;
+
+  @Rule
+  public TestName testName = new TestName();
+
+  @Before
+  public void setUp() throws Exception {
+    this.statsMonitor = spy(new FakeValueMonitor());
+    this.mbeanStatsMonitor =
+        new MBeanStatsMonitor(this.testName.getMethodName(), this.statsMonitor);
+    MockitoAnnotations.initMocks(this);
+
+    this.expectedStatsMap = new HashMap<>();
+    this.descriptors = new StatisticDescriptor[3];
+    for (int i = 0; i < this.descriptors.length; i++) {
+      String key = "stat-" + String.valueOf(i + 1);
+      Number value = i + 1;
+
+      this.expectedStatsMap.put(key, value);
+
+      this.descriptors[i] = mock(StatisticDescriptor.class);
+      when(this.descriptors[i].getName()).thenReturn(key);
+      when(this.stats.get(this.descriptors[i])).thenReturn(value);
+    }
+
+    when(this.statsType.getStatistics()).thenReturn(this.descriptors);
+    when(this.stats.getType()).thenReturn(this.statsType);
+  }
+
+  @Test
+  public void addStatisticsToMonitorShouldAddToInternalMap() throws Exception {
+    this.mbeanStatsMonitor.addStatisticsToMonitor(this.stats);
+
+    assertThat(statsMap.getInternalMap()).containsAllEntriesOf(this.expectedStatsMap);
+  }
+
+  @Test
+  public void addStatisticsToMonitorShouldAddListener() throws Exception {
+    this.mbeanStatsMonitor.addStatisticsToMonitor(this.stats);
+
+    verify(this.statsMonitor, times(1)).addListener(this.mbeanStatsMonitor);
+  }
+
+  @Test
+  public void addStatisticsToMonitorShouldAddStatistics() throws Exception {
+    this.mbeanStatsMonitor.addStatisticsToMonitor(this.stats);
+
+    verify(this.statsMonitor, times(1)).addStatistics(this.stats);
+  }
+
+  @Test
+  public void addNullStatisticsToMonitorShouldThrowNPE() throws Exception {
+    assertThatThrownBy(() -> this.mbeanStatsMonitor.addStatisticsToMonitor(null))
+        .isExactlyInstanceOf(NullPointerException.class);
+  }
+
+}


[04/19] geode git commit: GEODE-1984: Addressed review comments, Removed copy pasted repeating code and moved it into a separate method.

Posted by kl...@apache.org.
GEODE-1984: Addressed review comments,
Removed copy pasted repeating code and moved it into a separate method.


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

Branch: refs/heads/feature/GEODE-1027
Commit: f522f6ca6a3fd362e5d6657ef451743a68a4c0dc
Parents: 0eb952a
Author: adongre <ad...@apache.org>
Authored: Thu Dec 8 12:53:05 2016 +0530
Committer: adongre <ad...@apache.org>
Committed: Fri Dec 9 05:08:36 2016 +0530

----------------------------------------------------------------------
 .../apache/geode/cache/wan/GatewaySender.java   |  16 +-
 .../functions/GatewaySenderDestroyFunction.java |   2 +-
 .../codeAnalysis/sanctionedSerializables.txt    |   2 +-
 .../wan/wancommand/WANCommandTestBase.java      |   4 +-
 ...mandCreateDestroyGatewaySenderDUnitTest.java | 265 +++++--------------
 5 files changed, 79 insertions(+), 210 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f522f6ca/geode-core/src/main/java/org/apache/geode/cache/wan/GatewaySender.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/wan/GatewaySender.java b/geode-core/src/main/java/org/apache/geode/cache/wan/GatewaySender.java
index f9f8f91..1dc1fb1 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/wan/GatewaySender.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/wan/GatewaySender.java
@@ -402,17 +402,15 @@ public interface GatewaySender {
 
 
   /**
-   * Destroys the GatewaySender. Before destroying the sender, caller needs to to ensure that the
-   * sender is stopped so that all the resources (threads, connection pool etc.) will be released
-   * properly. Stopping the sender is not handled in the destroy. Destroy is carried out in
-   * following steps: 1. Take the lifeCycleLock. 2. If the sender is attached to any application
-   * region, throw an exception. 3. Close the GatewaySenderAdvisor. 4. Remove the sender from the
-   * cache. 5. Destroy the region underlying the GatewaySender.
+   * Destroys the GatewaySender.
    * <p>
-   * In case of ParallelGatewaySender, the destroy operation does distributed destroy of the QPR. In
-   * case of SerialGatewaySender, the queue region is destroyed locally.
+   * In case of ParallelGatewaySender, the destroy operation does distributed destroy of the Queue
+   * Region. In case of SerialGatewaySender, the Queue Region is destroyed locally.
+   * 
+   * @since Geode 1.1
+   *
    */
-  public void destroy();
+  void destroy();
 
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f522f6ca/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
index ba393fe..2873633 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
@@ -28,7 +28,7 @@ import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.logging.log4j.Logger;
 
 public class GatewaySenderDestroyFunction extends FunctionAdapter implements InternalEntity {
-  private static final long serialVersionUID = 1459761440357690134L;
+  private static final long serialVersionUID = 1L;
 
   private static final Logger logger = LogService.getLogger();
   private static final String ID = GatewaySenderDestroyFunction.class.getName();

http://git-wip-us.apache.org/repos/asf/geode/blob/f522f6ca/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 5ce46bf..1aac8c2 100644
--- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
+++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
@@ -569,7 +569,7 @@ org/apache/geode/management/internal/cli/functions/GarbageCollectionFunction,tru
 org/apache/geode/management/internal/cli/functions/GatewayReceiverCreateFunction,true,8746830191680509335
 org/apache/geode/management/internal/cli/functions/GatewayReceiverFunctionArgs,true,-5158224572470173267,bindAddress:java/lang/String,endPort:java/lang/Integer,gatewayTransportFilters:java/lang/String[],manualStart:java/lang/Boolean,maximumTimeBetweenPings:java/lang/Integer,socketBufferSize:java/lang/Integer,startPort:java/lang/Integer
 org/apache/geode/management/internal/cli/functions/GatewaySenderCreateFunction,true,8746830191680509335
-org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction,true,1459761440357690134
+org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction,true,1
 org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunctionArgs,true,3848480256348119530,id:java/lang/String
 org/apache/geode/management/internal/cli/functions/GatewaySenderFunctionArgs,true,-5158224572470173267,alertThreshold:java/lang/Integer,batchSize:java/lang/Integer,batchTimeInterval:java/lang/Integer,diskStoreName:java/lang/String,diskSynchronous:java/lang/Boolean,dispatcherThreads:java/lang/Integer,enableBatchConflation:java/lang/Boolean,enablePersistence:java/lang/Boolean,gatewayEventFilters:java/lang/String[],gatewayTransportFilters:java/lang/String[],id:java/lang/String,manualStart:java/lang/Boolean,maxQueueMemory:java/lang/Integer,orderPolicy:java/lang/String,parallel:java/lang/Boolean,remoteDSId:java/lang/Integer,socketBufferSize:java/lang/Integer,socketReadTimeout:java/lang/Integer
 org/apache/geode/management/internal/cli/functions/GetMemberConfigInformationFunction,true,1

http://git-wip-us.apache.org/repos/asf/geode/blob/f522f6ca/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
index f364ba3..5578f76 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
@@ -452,9 +452,6 @@ public abstract class WANCommandTestBase extends CliCommandTestBase {
     }
   }
 
-  // Added for gateway destroy command
-  // Copied from WANTestBase.java
-
   public static void verifySenderDestroyed(String senderId, boolean isParallel) {
     Set<GatewaySender> senders = cache.getGatewaySenders();
     AbstractGatewaySender sender = null;
@@ -473,6 +470,7 @@ public abstract class WANCommandTestBase extends CliCommandTestBase {
       queueRegionNameSuffix = "_SERIAL_GATEWAY_SENDER_QUEUE";
     }
 
+
     Set<LocalRegion> allRegions = ((GemFireCacheImpl) cache).getAllRegions();
     for (LocalRegion region : allRegions) {
       if (region.getName().indexOf(senderId + queueRegionNameSuffix) != -1) {

http://git-wip-us.apache.org/repos/asf/geode/blob/f522f6ca/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
index d095764..8d1f5d8 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
@@ -23,11 +23,13 @@ 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.result.TabularResultData;
 import org.apache.geode.test.dunit.IgnoredException;
+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.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
 
@@ -95,32 +97,11 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
     vm4.invoke(() -> verifySenderState("ln", true, false));
     vm5.invoke(() -> verifySenderState("ln", true, false));
 
-    // Test Destroy Command.
-    command =
-        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
-    cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info(
-          "testCreateDestroyGatewaySenderWithDefault stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(5, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender destroy failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
+    doDestroyAndVerifyGatewaySender("ln", null, null, "testCreateDestroyGatewaySenderWithDefault",
+        Arrays.asList(vm3, vm4, vm5), 5, false);
+  }
 
-    } else {
-      fail("testCreateDestroyGatewaySenderWithDefault failed as did not get CommandResult");
-    }
 
-    vm3.invoke(() -> verifySenderDestroyed("ln", false));
-    vm4.invoke(() -> verifySenderDestroyed("ln", false));
-    vm5.invoke(() -> verifySenderDestroyed("ln", false));
-  }
 
   /**
    * + * GatewaySender with given attribute values +
@@ -186,29 +167,8 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
     vm5.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
         1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, null));
 
-    // Test Destroy Command.
-    command =
-        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
-    cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info("testCreateDestroyGatewaySender stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(5, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender destroy failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail("testCreateDestroyGatewaySender failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderDestroyed("ln", false));
-    vm4.invoke(() -> verifySenderDestroyed("ln", false));
-    vm5.invoke(() -> verifySenderDestroyed("ln", false));
+    doDestroyAndVerifyGatewaySender("ln", null, null, "testCreateDestroyGatewaySender",
+        Arrays.asList(vm3, vm4, vm5), 5, false);
   }
 
   /**
@@ -336,31 +296,9 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
     vm5.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
         1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, eventFilters, null));
 
-    // Test Destroy Command.
-    command =
-        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
-    cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info("testCreateDestroyGatewaySenderWithGatewayEventFilters stringResult : "
-          + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(5, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender destroy failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail(
-          "testCreateDestroyGatewaySenderWithGatewayEventFilters failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderDestroyed("ln", false));
-    vm4.invoke(() -> verifySenderDestroyed("ln", false));
-    vm5.invoke(() -> verifySenderDestroyed("ln", false));
+    doDestroyAndVerifyGatewaySender("ln", null, null,
+        "testCreateDestroyGatewaySenderWithGatewayEventFilters", Arrays.asList(vm3, vm4, vm5), 5,
+        false);
 
   }
 
@@ -435,33 +373,9 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
     vm5.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
         1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, transportFilters));
 
-    // Test Destroy Command.
-    command =
-        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
-    cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter()
-          .info("testCreateDestroyGatewaySenderWithGatewayTransportFilters stringResult : "
-              + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(5, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender destroy failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-
-    } else {
-      fail(
-          "testCreateDestroyGatewaySenderWithGatewayTransportFilters failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderDestroyed("ln", false));
-    vm4.invoke(() -> verifySenderDestroyed("ln", false));
-    vm5.invoke(() -> verifySenderDestroyed("ln", false));
+    doDestroyAndVerifyGatewaySender("ln", null, null,
+        "testCreateDestroyGatewaySenderWithGatewayTransportFilters", Arrays.asList(vm3, vm4, vm5),
+        5, false);
   }
 
   /**
@@ -526,29 +440,8 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
     vm3.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
         1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, null));
 
-    // Test Destroy Command.
-    command = CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__MEMBER + "=" + vm3Member.getId();
-    cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter()
-          .info("testCreateDestroyGatewaySender_OnMember stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(1, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender destroy failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-
-    } else {
-      fail("testCreateDestroyGatewaySender_OnMember failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderDestroyed("ln", false));
+    doDestroyAndVerifyGatewaySender("ln", null, vm3Member,
+        "testCreateDestroyGatewaySender_OnMember", Arrays.asList(vm3), 1, false);
   }
 
   /**
@@ -610,31 +503,8 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
     vm4.invoke(() -> verifySenderState("ln", true, false));
     vm5.invoke(() -> verifySenderState("ln", true, false));
 
-    // Test Destroy Command
-    command = CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.DESTROY_GATEWAYSENDER__GROUP + "=SenderGroup1";
-
-    cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter()
-          .info("testCreateDestroyGatewaySender_Group stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(3, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender destroy failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail("testCreateDestroyGatewaySender_Group failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderDestroyed("ln", false));
-    vm4.invoke(() -> verifySenderDestroyed("ln", false));
-    vm5.invoke(() -> verifySenderDestroyed("ln", false));
+    doDestroyAndVerifyGatewaySender("ln", "SenderGroup1", null,
+        "testCreateDestroyGatewaySender_Group", Arrays.asList(vm3, vm4, vm5), 3, false);
 
   }
 
@@ -697,31 +567,8 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
     vm3.invoke(() -> verifySenderState("ln", true, false));
     vm4.invoke(() -> verifySenderState("ln", true, false));
 
-
-    // Test Destroy Command
-    command = CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.DESTROY_GATEWAYSENDER__GROUP + "=SenderGroup1";
-
-    cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info(
-          "testCreateDestroyGatewaySender_Group_Scenario2 stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(2, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender destroy failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail("testCreateDestroyGatewaySender_Group_Scenario2 failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderDestroyed("ln", false));
-    vm4.invoke(() -> verifySenderDestroyed("ln", false));
+    doDestroyAndVerifyGatewaySender("ln", "SenderGroup1", null,
+        "testCreateDestroyGatewaySender_Group_Scenario2", Arrays.asList(vm3, vm4), 2, false);
 
   }
 
@@ -791,30 +638,8 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
         () -> verifySenderAttributes("ln", 2, true, true, 1000, socketReadTimeout, true, 1000, 5000,
             true, false, 1000, 100, GatewaySender.DEFAULT_DISPATCHER_THREADS, null, null, null));
 
-    // Test Destroy Command
-    command =
-        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=ln";
-    cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter()
-          .info("testCreateDestroyParallelGatewaySender stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(5, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender destroy failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-
-    } else {
-      fail("testCreateDestroyParallelGatewaySender failed as did not get CommandResult");
-    }
-    vm3.invoke(() -> verifySenderDestroyed("ln", true));
-    vm4.invoke(() -> verifySenderDestroyed("ln", true));
-    vm5.invoke(() -> verifySenderDestroyed("ln", true));
+    doDestroyAndVerifyGatewaySender("ln", null, null, "testCreateDestroyParallelGatewaySender",
+        Arrays.asList(vm3, vm4), 5, true);
   }
 
   /**
@@ -918,4 +743,52 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
       fail("testCreateDestroyParallelGatewaySender failed as did not get CommandResult");
     }
   }
+
+  /**
+   * doDestroyAndVerifyGatewaySender helper command.
+   *
+   * @param id if of the Gateway Sender
+   * @param group Group for the GatewaySender
+   * @param member Distributed Member for memeber id.
+   * @param testName testName for the logging
+   * @param vms list of vms where to verify the destroyed gateway sender
+   * @param size command result.
+   * @param isParallel true if parallel , false otherwise.
+   */
+
+  private void doDestroyAndVerifyGatewaySender(final String id, final String group,
+      final DistributedMember member, final String testName, final List<VM> vms, final int size,
+      final boolean isParallel) {
+    String command =
+        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID + "=" + id;
+
+    if (group != null) {
+      command += " --" + CliStrings.DESTROY_GATEWAYSENDER__GROUP + "=" + group;
+    }
+
+    if (member != null) {
+      command += " --" + CliStrings.CREATE_GATEWAYSENDER__MEMBER + "=" + member.getId();
+    }
+
+    final CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info(testName + " stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(size, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+
+    } else {
+      fail(testName + " failed as did not get CommandResult");
+    }
+    for (VM vm : vms) {
+      vm.invoke(() -> verifySenderDestroyed(id, isParallel));
+    }
+  }
 }


[12/19] geode git commit: GEODE-2193 a member is kicked out immediately after joining

Posted by kl...@apache.org.
GEODE-2193 a member is kicked out immediately after joining

The problem is happening because we send a shutdown message, initiating
election of a new coordinator, but the old ViewCreator is allowed to
send out a view announcing a new member.  The new coordinator manages
to send out a new view before the old ViewCreator sends out the new
member's view.  Other members ignore the old ViewCreator's view
because its view ID is old.  Then the reject the new member because
it has an old view ID and it isn't in their membership view.

initial view ID is x

new coordinator prepares view x+10
old coordinator prepares view x+1
other members install x+10, reject view x+1
new member joins in view x+1 when it receives view-prepare message
new member is rejected by other members because x+1 < x+10


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

Branch: refs/heads/feature/GEODE-1027
Commit: ef86239f872c12c0aad38d5ae3044e22fd5e87af
Parents: ac3a822
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Fri Dec 9 14:01:46 2016 -0800
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Fri Dec 9 14:01:46 2016 -0800

----------------------------------------------------------------------
 .../membership/gms/membership/GMSJoinLeave.java | 86 ++++++++++++--------
 .../gms/messages/JoinResponseMessage.java       |  7 ++
 .../geode/distributed/LocatorJUnitTest.java     |  3 +
 .../gms/membership/GMSJoinLeaveJUnitTest.java   | 67 +++++++++++++--
 4 files changed, 119 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/ef86239f/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 6d782b1..4ee3011 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -803,13 +803,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     return newView;
   }
 
-  private void sendJoinResponses(NetView newView, List<InternalDistributedMember> newMbrs) {
-    for (InternalDistributedMember mbr : newMbrs) {
-      JoinResponseMessage response = new JoinResponseMessage(mbr, newView, 0);
-      services.getMessenger().send(response);
-    }
-  }
-
   private void sendRemoveMessages(List<InternalDistributedMember> removals, List<String> reasons,
       Set<InternalDistributedMember> oldIds) {
     Iterator<String> reason = reasons.iterator();
@@ -826,11 +819,19 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
 
   boolean prepareView(NetView view, List<InternalDistributedMember> newMembers)
       throws InterruptedException {
+    if (services.getCancelCriterion().isCancelInProgress()
+        || services.getManager().shutdownInProgress()) {
+      throw new InterruptedException("shutting down");
+    }
     return sendView(view, true, this.prepareProcessor);
   }
 
   void sendView(NetView view, List<InternalDistributedMember> newMembers)
       throws InterruptedException {
+    if (services.getCancelCriterion().isCancelInProgress()
+        || services.getManager().shutdownInProgress()) {
+      throw new InterruptedException("shutting down");
+    }
     sendView(view, false, this.viewProcessor);
   }
 
@@ -1401,7 +1402,9 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
           for (Iterator<DistributionMessage> it = viewRequests.iterator(); it.hasNext();) {
             DistributionMessage m = it.next();
             if (m instanceof JoinRequestMessage) {
-              it.remove();
+              if (currentView.contains(((JoinRequestMessage) m).getMemberID())) {
+                it.remove();
+              }
             } else if (m instanceof LeaveRequestMessage) {
               if (!currentView.contains(((LeaveRequestMessage) m).getMemberID())) {
                 it.remove();
@@ -1500,6 +1503,11 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     if (viewCreator != null && !viewCreator.isShutdown()) {
       logger.debug("Shutting down ViewCreator");
       viewCreator.shutdown();
+      try {
+        viewCreator.join(1000);
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+      }
     }
   }
 
@@ -1641,8 +1649,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     services.getMessenger().addHandler(ViewAckMessage.class, this);
     services.getMessenger().addHandler(LeaveRequestMessage.class, this);
     services.getMessenger().addHandler(RemoveMemberMessage.class, this);
-    services.getMessenger().addHandler(JoinRequestMessage.class, this);
-    services.getMessenger().addHandler(JoinResponseMessage.class, this);
     services.getMessenger().addHandler(FindCoordinatorRequest.class, this);
     services.getMessenger().addHandler(FindCoordinatorResponse.class, this);
     services.getMessenger().addHandler(NetworkPartitionMessage.class, this);
@@ -2133,40 +2139,48 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     }
 
     synchronized boolean informToPendingJoinRequests() {
-      boolean joinResponseSent = false;
+
       if (!shutdown) {
-        return joinResponseSent;
+        return false;
       }
-      ArrayList<DistributionMessage> requests = new ArrayList<>();
+      NetView v = currentView;
+      if (v.getCoordinator().equals(localAddress)) {
+        return false;
+      }
+
+      ArrayList<JoinRequestMessage> requests = new ArrayList<>();
       synchronized (viewRequests) {
-        if (viewRequests.size() > 0) {
-          requests.addAll(viewRequests);
-        } else {
-          return joinResponseSent;
+        if (viewRequests.isEmpty()) {
+          return false;
+        }
+        for (Iterator<DistributionMessage> iterator = viewRequests.iterator(); iterator
+            .hasNext();) {
+          DistributionMessage msg = iterator.next();
+          switch (msg.getDSFID()) {
+            case JOIN_REQUEST:
+              requests.add((JoinRequestMessage) msg);
+              // TODO [bruce] if the view creator is just spinning up I don't think we should do
+              // this remove
+              iterator.remove();
+              break;
+            default:
+              break;
+          }
         }
-        viewRequests.clear();
       }
 
-      NetView v = currentView;
-      for (DistributionMessage msg : requests) {
-        switch (msg.getDSFID()) {
-          case JOIN_REQUEST:
-            logger.debug("Informing to pending join requests {} myid {} coord {}", msg,
-                localAddress, v.getCoordinator());
-            if (!v.getCoordinator().equals(localAddress)) {
-              joinResponseSent = true;
-              // lets inform that coordinator has been changed
-              JoinResponseMessage jrm =
-                  new JoinResponseMessage(((JoinRequestMessage) msg).getMemberID(), v,
-                      ((JoinRequestMessage) msg).getRequestId());
-              services.getMessenger().send(jrm);
-            }
-          default:
-            break;
-        }
+      if (requests.isEmpty()) {
+        return false;
+      }
+
+      for (JoinRequestMessage msg : requests) {
+        logger.debug("Sending coordinator to pending join request from {} myid {} coord {}",
+            msg.getSender(), localAddress, v.getCoordinator());
+        JoinResponseMessage jrm = new JoinResponseMessage(msg.getMemberID(), v, msg.getRequestId());
+        services.getMessenger().send(jrm);
       }
 
-      return joinResponseSent;
+      return true;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/geode/blob/ef86239f/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messages/JoinResponseMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messages/JoinResponseMessage.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messages/JoinResponseMessage.java
index 2a13a5e..4e0bcc8 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messages/JoinResponseMessage.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messages/JoinResponseMessage.java
@@ -30,6 +30,13 @@ import org.apache.geode.distributed.internal.membership.NetView;
 import org.apache.geode.internal.InternalDataSerializer;
 import org.apache.geode.internal.Version;
 
+// TODO this class has been made unintelligible with different combinations of response values.
+// It needs to have an enum that indicates what type of response is in the message or it
+// needs to be broken into multiple message classes.
+// 1. a response saying the member has now joined
+// 2. a response indicating that the coordinator is now a different process
+// 3. a response containing the cluster encryption key
+
 public class JoinResponseMessage extends HighPriorityDistributionMessage {
 
   private NetView currentView;

http://git-wip-us.apache.org/repos/asf/geode/blob/ef86239f/geode-core/src/test/java/org/apache/geode/distributed/LocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LocatorJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/LocatorJUnitTest.java
index 368b037..8be0e7a 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/LocatorJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/LocatorJUnitTest.java
@@ -108,6 +108,7 @@ public class LocatorJUnitTest {
     dsprops.setProperty(JMX_MANAGER_START, "true");
     dsprops.setProperty(JMX_MANAGER_HTTP_PORT, "0");
     dsprops.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
+    dsprops.setProperty(LOG_FILE, "");
     System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "disableManagement", "false"); // not
                                                                                           // needed
     try {
@@ -159,6 +160,8 @@ public class LocatorJUnitTest {
         fail("expected " + threadCount + " threads or fewer but found " + Thread.activeCount()
             + ".  Check log file for a thread dump.");
       }
+    } finally {
+      JGroupsMessenger.THROW_EXCEPTION_ON_START_HOOK = false;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/ef86239f/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
index 453e894..14fedc6 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
@@ -14,6 +14,20 @@
  */
 package org.apache.geode.distributed.internal.membership.gms.membership;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.jayway.awaitility.Awaitility;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
@@ -32,10 +46,15 @@ import org.apache.geode.distributed.internal.membership.gms.membership.GMSJoinLe
 import org.apache.geode.distributed.internal.membership.gms.membership.GMSJoinLeave.TcpClientWrapper;
 import org.apache.geode.distributed.internal.membership.gms.membership.GMSJoinLeave.ViewCreator;
 import org.apache.geode.distributed.internal.membership.gms.membership.GMSJoinLeave.ViewReplyProcessor;
-import org.apache.geode.distributed.internal.membership.gms.messages.*;
+import org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage;
+import org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage;
+import org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage;
+import org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage;
+import org.apache.geode.distributed.internal.membership.gms.messages.NetworkPartitionMessage;
+import org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage;
+import org.apache.geode.distributed.internal.membership.gms.messages.ViewAckMessage;
 import org.apache.geode.internal.Version;
 import org.apache.geode.security.AuthenticationFailedException;
-import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.MembershipTest;
 import org.junit.After;
@@ -50,12 +69,16 @@ import org.mockito.verification.Timeout;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
-import java.util.*;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.isA;
-import static org.mockito.Mockito.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Timer;
+import java.util.concurrent.TimeUnit;
 
 @Category({IntegrationTest.class, MembershipTest.class})
 public class GMSJoinLeaveJUnitTest {
@@ -1062,6 +1085,34 @@ public class GMSJoinLeaveJUnitTest {
   }
 
   @Test
+  public void testViewNotSentWhenShuttingDown() throws Exception {
+    try {
+      initMocks(false);
+      System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
+      gmsJoinLeave.join();
+      installView(1, gmsJoinLeaveMemberId, createMemberList(mockMembers[0], mockMembers[1],
+          mockMembers[2], gmsJoinLeaveMemberId, mockMembers[3]));
+
+      assertTrue(gmsJoinLeave.getViewCreator().isAlive());
+
+      when(manager.shutdownInProgress()).thenReturn(Boolean.TRUE);
+      for (int i = 1; i < 4; i++) {
+        RemoveMemberMessage msg =
+            new RemoveMemberMessage(gmsJoinLeaveMemberId, mockMembers[i], "crashed");
+        msg.setSender(gmsJoinLeaveMemberId);
+        gmsJoinLeave.processMessage(msg);
+      }
+
+      Awaitility.await("waiting for view creator to stop").atMost(5000, TimeUnit.MILLISECONDS)
+          .until(() -> !gmsJoinLeave.getViewCreator().isAlive());
+      assertEquals(1, gmsJoinLeave.getView().getViewId());
+
+    } finally {
+      System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
+    }
+  }
+
+  @Test
   public void testPreparedViewFoundDuringBecomeCoordinator() throws Exception {
     initMocks(false);
     prepareAndInstallView(gmsJoinLeaveMemberId,


[16/19] geode git commit: GEODE-2196: revert changes that broke Jenkins build

Posted by kl...@apache.org.
GEODE-2196: revert changes that broke Jenkins build


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

Branch: refs/heads/feature/GEODE-1027
Commit: 5d2f0f6b56f0fd22b5fd8cea7abc3bccb26117d8
Parents: 03c79a6
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Mon Dec 12 08:43:05 2016 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Mon Dec 12 08:43:05 2016 -0800

----------------------------------------------------------------------
 .../internal/DistributionConfig.java            |   2 +-
 .../internal/DistributionConfigImpl.java        |   2 +-
 .../configuration/ClusterConfigDUnitTest.java   | 243 -------------------
 3 files changed, 2 insertions(+), 245 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/5d2f0f6b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java
index c2a395d..5eb070d 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java
@@ -384,7 +384,7 @@ public interface DistributionConfig extends Config, LogConfig {
    * Default will be the current working directory as determined by
    * <code>System.getProperty("user.dir")</code>.
    */
-  File DEFAULT_DEPLOY_WORKING_DIR = new File(System.getProperty("user.dir"));
+  File DEFAULT_DEPLOY_WORKING_DIR = new File(".");
 
   /**
    * Returns the value of the {@link ConfigurationProperties#USER_COMMAND_PACKAGES} property

http://git-wip-us.apache.org/repos/asf/geode/blob/5d2f0f6b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
index fa6d13f..0c6603d 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
@@ -124,7 +124,7 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
    */
   private File logFile = DEFAULT_LOG_FILE;
 
-  protected File deployWorkingDir = new File(System.getProperty("user.dir"));
+  protected File deployWorkingDir = DEFAULT_DEPLOY_WORKING_DIR;
 
   /**
    * The level at which log messages are logged

http://git-wip-us.apache.org/repos/asf/geode/blob/5d2f0f6b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDUnitTest.java
deleted file mode 100644
index 418999a..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDUnitTest.java
+++ /dev/null
@@ -1,243 +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.configuration;
-
-import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_CONFIGURATION_DIR;
-import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
-import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOAD_CLUSTER_CONFIGURATION_FROM_DIR;
-import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE_LIMIT;
-import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION;
-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.SharedConfiguration;
-import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.JarClassLoader;
-import org.apache.geode.management.internal.configuration.domain.Configuration;
-import org.apache.geode.management.internal.configuration.utils.ZipUtils;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Member;
-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.io.Serializable;
-import java.util.Collection;
-import java.util.Properties;
-
-@Category(DistributedTest.class)
-public class ClusterConfigDUnitTest extends JUnit4DistributedTestCase {
-  private static final String EXPORTED_CLUSTER_CONFIG_ZIP_FILENAME = "cluster_config.zip";
-  private static final String[] CONFIG_NAMES = new String[] {"cluster", "group1", "group2"};
-
-  private static final ExpectedConfig NO_GROUP =
-      new ExpectedConfig().maxLogFileSize("5000").regions("regionForCluster").jars("cluster.jar");
-
-  private static final ExpectedConfig GROUP1 = new ExpectedConfig().maxLogFileSize("6000")
-      .regions("regionForCluster", "regionForGroup1").jars("cluster.jar", "group1.jar");
-
-  private static final ExpectedConfig GROUP2 = new ExpectedConfig().maxLogFileSize("7000")
-      .regions("regionForCluster", "regionForGroup2").jars("cluster.jar", "group2.jar");
-
-  private static final ExpectedConfig GROUP1_AND_2 = new ExpectedConfig().maxLogFileSize("7000")
-      .regions("regionForCluster", "regionForGroup1", "regionForGroup2")
-      .jars("cluster.jar", "group1.jar", "group2.jar");
-
-
-  private String locatorString;
-
-  @Rule
-  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
-
-  @Before
-  public void setupFirstLocatorWithClusterConfigFromDirectory() throws Exception {
-    File locatorDir = lsRule.getRootFolder().newFolder("locator-0");
-
-    // The unzip should yield a cluster config directory structure like:
-    // tempFolder/locator-0/cluster_config/cluster/cluster.xml
-    // tempFolder/locator-0/cluster_config/cluster/cluster.properties
-    // tempFolder/locator-0/cluster_config/cluster/cluster.jar
-    // tempFolder/locator-0/cluster_config/group1/ {group1.xml, group1.properties, group1.jar}
-    // tempFolder/locator-0/cluster_config/group2/ ...
-    ZipUtils.unzip(getClass().getResource(EXPORTED_CLUSTER_CONFIG_ZIP_FILENAME).getPath(),
-        locatorDir.getCanonicalPath());
-
-    Properties locatorProps = new Properties();
-    locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
-    locatorProps.setProperty(LOAD_CLUSTER_CONFIGURATION_FROM_DIR, "true");
-    locatorProps.setProperty(CLUSTER_CONFIGURATION_DIR, locatorDir.getCanonicalPath());
-
-    Member firstLocator = lsRule.startLocatorVM(0, locatorProps);
-    locatorString = "localhost[" + firstLocator.getPort() + "]";
-
-    verifyLocatorConfigExistsInFileSystem(firstLocator.getWorkingDir());
-    firstLocator.invoke(this::verifyLocatorConfigExistsInInternalRegion);
-  }
-
-  @Test
-  public void secondLocatorLoadsClusterConfigFromFirstLocator() throws IOException {
-    Properties secondLocatorProps = new Properties();
-    secondLocatorProps.setProperty(LOCATORS, locatorString);
-    secondLocatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
-    Member secondLocator = lsRule.startLocatorVM(1, secondLocatorProps);
-
-    verifyLocatorConfig(secondLocator);
-  }
-
-  @Test
-  public void serverWithZeroOrOneGroupsLoadCorrectConfigFromLocator() throws Exception {
-    Properties serverProps = new Properties();
-    serverProps.setProperty(LOCATORS, locatorString);
-    serverProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
-
-    Member serverWithNoGroup = lsRule.startServerVM(1, serverProps);
-    verifyServerConfig(NO_GROUP, serverWithNoGroup);
-
-    serverProps.setProperty(GROUPS, "group1");
-    Member serverForGroup1 = lsRule.startServerVM(2, serverProps);
-    verifyServerConfig(GROUP1, serverForGroup1);
-
-    serverProps.setProperty(GROUPS, "group2");
-    Member serverForGroup2 = lsRule.startServerVM(3, serverProps);
-    verifyServerConfig(GROUP2, serverForGroup2);
-  }
-
-  @Test
-  public void oneServerWithMultipleGroupsLoadsCorrectConfigFromLocator() throws Exception {
-    Properties serverProps = new Properties();
-    serverProps.setProperty(LOCATORS, locatorString);
-    serverProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
-    serverProps.setProperty(GROUPS, "group1,group2");
-    Member serverWithNoGroup = lsRule.startServerVM(1, serverProps);
-
-    serverWithNoGroup.invoke(() -> this.verifyServerConfig(GROUP1_AND_2, serverWithNoGroup));
-  }
-
-  private void verifyLocatorConfig(Member locator) {
-    verifyLocatorConfigExistsInFileSystem(locator.getWorkingDir());
-    locator.invoke(this::verifyLocatorConfigExistsInInternalRegion);
-  }
-
-  private void verifyServerConfig(ExpectedConfig expectedConfig, Member server)
-      throws ClassNotFoundException {
-    verifyServerJarFilesExistInFileSystem(server.getWorkingDir(), expectedConfig.jars);
-    server.invoke(() -> this.verifyServerConfigInMemory(expectedConfig));
-  }
-
-  private void verifyLocatorConfigExistsInFileSystem(File workingDir) {
-    File clusterConfigDir = new File(workingDir, "cluster_config");
-    assertThat(clusterConfigDir).exists();
-
-    for (String configName : CONFIG_NAMES) {
-      File configDir = new File(clusterConfigDir, configName);
-      assertThat(configDir).exists();
-
-      File jar = new File(configDir, configName + ".jar");
-      File properties = new File(configDir, configName + ".properties");
-      File xml = new File(configDir, configName + ".xml");
-      assertThat(configDir.listFiles()).contains(jar, properties, xml);
-    }
-  }
-
-  private void verifyLocatorConfigExistsInInternalRegion() throws Exception {
-    InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.locator;
-    SharedConfiguration sc = internalLocator.getSharedConfiguration();
-
-    for (String configName : CONFIG_NAMES) {
-      Configuration config = sc.getConfiguration(configName);
-      assertThat(config).isNotNull();
-    }
-  }
-
-  private void verifyServerConfigInMemory(ExpectedConfig expectedConfig)
-      throws ClassNotFoundException {
-    Cache cache = LocatorServerStartupRule.serverStarter.cache;
-    for (String region : expectedConfig.regions) {
-      assertThat(cache.getRegion(region)).isNotNull();
-    }
-    Properties props = cache.getDistributedSystem().getProperties();
-    assertThat(props.getProperty(LOG_FILE_SIZE_LIMIT)).isEqualTo(expectedConfig.maxLogFileSize);
-
-    for (String jar : expectedConfig.jars) {
-      JarClassLoader jarClassLoader = findJarClassLoader(jar);
-      assertThat(jarClassLoader).isNotNull();
-      assertThat(jarClassLoader.loadClass(nameOfClassContainedInJar(jar))).isNotNull();
-    }
-  }
-
-  private void verifyServerJarFilesExistInFileSystem(File workingDir, String[] jarNames) {
-    assertThat(workingDir.listFiles()).isNotEmpty();
-
-    for (String jarName : jarNames) {
-      assertThat(workingDir.listFiles()).filteredOn((File file) -> file.getName().contains(jarName))
-          .isNotEmpty();
-    }
-  }
-
-  private String nameOfClassContainedInJar(String jarName) {
-    switch (jarName) {
-      case "cluster.jar":
-        return "Cluster";
-      case "group1.jar":
-        return "Group1";
-      case "group2.jar":
-        return "Group2";
-      default:
-        throw new IllegalArgumentException(
-            EXPORTED_CLUSTER_CONFIG_ZIP_FILENAME + " does not contain a jar named " + jarName);
-    }
-  }
-
-  private JarClassLoader findJarClassLoader(final String jarName) {
-    Collection<ClassLoader> classLoaders = ClassPathLoader.getLatest().getClassLoaders();
-    for (ClassLoader classLoader : classLoaders) {
-      if (classLoader instanceof JarClassLoader
-          && ((JarClassLoader) classLoader).getJarName().equals(jarName)) {
-        return (JarClassLoader) classLoader;
-      }
-    }
-    return null;
-  }
-
-  private static class ExpectedConfig implements Serializable {
-    public String maxLogFileSize;
-    public String[] regions;
-    public String[] jars;
-
-    public ExpectedConfig maxLogFileSize(String maxLogFileSize) {
-      this.maxLogFileSize = maxLogFileSize;
-      return this;
-    }
-
-    public ExpectedConfig regions(String... regions) {
-      this.regions = regions;
-      return this;
-    }
-
-    public ExpectedConfig jars(String... jars) {
-      this.jars = jars;
-      return this;
-    }
-  }
-}


[05/19] geode git commit: GEODE-1984: Fix Issue Make GatewaySender destroy a public API

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/0eb952a6/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateGatewaySenderDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateGatewaySenderDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateGatewaySenderDUnitTest.java
deleted file mode 100644
index db9aa91..0000000
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateGatewaySenderDUnitTest.java
+++ /dev/null
@@ -1,663 +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.internal.cache.wan.wancommand;
-
-import org.apache.geode.cache.wan.GatewaySender;
-import org.apache.geode.cache.wan.GatewaySender.OrderPolicy;
-import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.internal.cache.wan.GatewaySenderException;
-import org.apache.geode.management.cli.Result;
-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.result.TabularResultData;
-import org.apache.geode.test.dunit.IgnoredException;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.test.dunit.Assert.*;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
-
-@Category(DistributedTest.class)
-public class WanCommandCreateGatewaySenderDUnitTest extends WANCommandTestBase {
-
-  private static final long serialVersionUID = 1L;
-
-  private CommandResult executeCommandWithIgnoredExceptions(String command) {
-    final IgnoredException exln = IgnoredException.addIgnoredException("Could not connect");
-    try {
-      CommandResult commandResult = executeCommand(command);
-      return commandResult;
-    } finally {
-      exln.remove();
-    }
-  }
-
-
-  /**
-   * GatewaySender with all default attributes
-   */
-  @Test
-  public void testCreateGatewaySenderWithDefault() {
-
-    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
-
-    Properties props = getDistributedSystemProperties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
-    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
-    setUpJmxManagerOnVm0ThenConnect(props);
-
-    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
-
-    vm3.invoke(() -> createCache(punePort));
-    vm4.invoke(() -> createCache(punePort));
-    vm5.invoke(() -> createCache(punePort));
-
-    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2";
-    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info("testCreateGatewaySender stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(5, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender creation failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail("testCreateGatewaySender failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderState("ln", true, false));
-    vm4.invoke(() -> verifySenderState("ln", true, false));
-    vm5.invoke(() -> verifySenderState("ln", true, false));
-  }
-
-  /**
-   * GatewaySender with given attribute values
-   */
-  @Test
-  public void testCreateGatewaySender() {
-
-    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
-
-    Properties props = getDistributedSystemProperties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
-    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
-    setUpJmxManagerOnVm0ThenConnect(props);
-
-    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
-
-    vm3.invoke(() -> createCache(punePort));
-    vm4.invoke(() -> createCache(punePort));
-    vm5.invoke(() -> createCache(punePort));
-
-    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
-    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD";
-    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info("testCreateGatewaySender stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(5, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender creation failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail("testCreateGatewaySender failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderState("ln", false, false));
-    vm4.invoke(() -> verifySenderState("ln", false, false));
-    vm5.invoke(() -> verifySenderState("ln", false, false));
-
-    vm3.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
-        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, null));
-    vm4.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
-        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, null));
-    vm5.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
-        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, null));
-  }
-
-  /**
-   * GatewaySender with given attribute values. Error scenario where dispatcher threads is set to
-   * more than 1 and no order policy provided.
-   */
-  @Test
-  public void testCreateGatewaySender_Error() {
-
-    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
-
-    Properties props = getDistributedSystemProperties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
-    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
-    setUpJmxManagerOnVm0ThenConnect(props);
-
-    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
-
-    vm3.invoke(() -> createCache(punePort));
-    vm4.invoke(() -> createCache(punePort));
-    vm5.invoke(() -> createCache(punePort));
-
-    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
-    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2";
-    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info("testCreateGatewaySender stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(5, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender creation should fail", status.get(i).indexOf("ERROR:") != -1);
-      }
-    } else {
-      fail("testCreateGatewaySender failed as did not get CommandResult");
-    }
-
-  }
-
-  /**
-   * GatewaySender with given attribute values and event filters.
-   */
-  @Test
-  public void testCreateGatewaySenderWithGatewayEventFilters() {
-
-    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
-
-    Properties props = getDistributedSystemProperties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
-    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
-    setUpJmxManagerOnVm0ThenConnect(props);
-
-    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
-
-    vm3.invoke(() -> createCache(punePort));
-    vm4.invoke(() -> createCache(punePort));
-    vm5.invoke(() -> createCache(punePort));
-
-    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
-    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__GATEWAYEVENTFILTER
-        + "=org.apache.geode.cache30.MyGatewayEventFilter1,org.apache.geode.cache30.MyGatewayEventFilter2";
-    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info("testCreateGatewaySender stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(5, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender creation failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail("testCreateGatewaySender failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderState("ln", false, false));
-    vm4.invoke(() -> verifySenderState("ln", false, false));
-    vm5.invoke(() -> verifySenderState("ln", false, false));
-
-    List<String> eventFilters = new ArrayList<String>();
-    eventFilters.add("org.apache.geode.cache30.MyGatewayEventFilter1");
-    eventFilters.add("org.apache.geode.cache30.MyGatewayEventFilter2");
-    vm3.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
-        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, eventFilters, null));
-    vm4.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
-        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, eventFilters, null));
-    vm5.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
-        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, eventFilters, null));
-  }
-
-  /**
-   * GatewaySender with given attribute values and transport filters.
-   */
-  @Test
-  public void testCreateGatewaySenderWithGatewayTransportFilters() {
-
-    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
-
-    Properties props = getDistributedSystemProperties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
-    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
-    setUpJmxManagerOnVm0ThenConnect(props);
-
-    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
-
-    vm3.invoke(() -> createCache(punePort));
-    vm4.invoke(() -> createCache(punePort));
-    vm5.invoke(() -> createCache(punePort));
-
-    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
-    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__GATEWAYTRANSPORTFILTER
-        + "=org.apache.geode.cache30.MyGatewayTransportFilter1";
-    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info("testCreateGatewaySender stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(5, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender creation failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail("testCreateGatewaySender failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderState("ln", false, false));
-    vm4.invoke(() -> verifySenderState("ln", false, false));
-    vm5.invoke(() -> verifySenderState("ln", false, false));
-
-    List<String> transportFilters = new ArrayList<String>();
-    transportFilters.add("org.apache.geode.cache30.MyGatewayTransportFilter1");
-    vm3.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
-        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, transportFilters));
-    vm4.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
-        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, transportFilters));
-    vm5.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
-        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, transportFilters));
-  }
-
-  /**
-   * GatewaySender with given attribute values on given member.
-   */
-  @Test
-  public void testCreateGatewaySender_OnMember() {
-
-    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
-
-    Properties props = getDistributedSystemProperties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
-    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
-    setUpJmxManagerOnVm0ThenConnect(props);
-
-    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
-
-    vm3.invoke(() -> createCache(punePort));
-    vm4.invoke(() -> createCache(punePort));
-    vm5.invoke(() -> createCache(punePort));
-
-    final DistributedMember vm3Member = (DistributedMember) vm3.invoke(() -> getMember());
-
-    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
-    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__MEMBER + "=" + vm3Member.getId() + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD";
-    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info("testCreateGatewaySender stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(1, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender creation failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail("testCreateGatewaySender failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderState("ln", false, false));
-
-    vm3.invoke(() -> verifySenderAttributes("ln", 2, false, true, 1000, socketReadTimeout, true,
-        1000, 5000, true, false, 1000, 100, 2, OrderPolicy.THREAD, null, null));
-  }
-
-  /**
-   * GatewaySender with given attribute values on given group
-   */
-  @Test
-  public void testCreateGatewaySender_Group() {
-
-    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
-
-    Properties props = getDistributedSystemProperties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
-    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
-    setUpJmxManagerOnVm0ThenConnect(props);
-
-    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
-
-    vm3.invoke(() -> createCacheWithGroups(punePort, "SenderGroup1"));
-    vm4.invoke(() -> createCacheWithGroups(punePort, "SenderGroup1"));
-    vm5.invoke(() -> createCacheWithGroups(punePort, "SenderGroup1"));
-
-    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
-    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__GROUP + "=SenderGroup1" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD";
-    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info("testCreateGatewaySender stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(3, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender creation failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail("testCreateGatewaySender failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderState("ln", true, false));
-    vm4.invoke(() -> verifySenderState("ln", true, false));
-    vm5.invoke(() -> verifySenderState("ln", true, false));
-  }
-
-  /**
-   * GatewaySender with given attribute values on given group. Only 2 of 3 members are part of the
-   * group.
-   */
-  @Test
-  public void testCreateGatewaySender_Group_Scenario2() {
-
-    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
-
-    Properties props = getDistributedSystemProperties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
-    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
-    setUpJmxManagerOnVm0ThenConnect(props);
-
-    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
-
-    vm3.invoke(() -> createCacheWithGroups(punePort, "SenderGroup1"));
-    vm4.invoke(() -> createCacheWithGroups(punePort, "SenderGroup1"));
-    vm5.invoke(() -> createCacheWithGroups(punePort, "SenderGroup2"));
-
-    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
-    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__GROUP + "=SenderGroup1" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD";
-    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info("testCreateGatewaySender stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(2, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender creation failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail("testCreateGatewaySender failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderState("ln", true, false));
-    vm4.invoke(() -> verifySenderState("ln", true, false));
-  }
-
-  /**
-   * Parallel GatewaySender with given attribute values
-   */
-  @Test
-  public void testCreateParallelGatewaySender() {
-
-    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
-
-    Properties props = getDistributedSystemProperties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
-    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
-    setUpJmxManagerOnVm0ThenConnect(props);
-
-    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
-
-    vm3.invoke(() -> createCache(punePort));
-    vm4.invoke(() -> createCache(punePort));
-    vm5.invoke(() -> createCache(punePort));
-
-    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
-    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100";
-    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
-    if (cmdResult != null) {
-      String strCmdResult = commandResultToString(cmdResult);
-      getLogWriter().info("testCreateGatewaySender stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(5, status.size());
-      for (int i = 0; i < status.size(); i++) {
-        assertTrue("GatewaySender creation failed with: " + status.get(i),
-            status.get(i).indexOf("ERROR:") == -1);
-      }
-    } else {
-      fail("testCreateGatewaySender failed as did not get CommandResult");
-    }
-
-    vm3.invoke(() -> verifySenderState("ln", false, false));
-    vm4.invoke(() -> verifySenderState("ln", false, false));
-    vm5.invoke(() -> verifySenderState("ln", false, false));
-
-    vm3.invoke(
-        () -> verifySenderAttributes("ln", 2, true, true, 1000, socketReadTimeout, true, 1000, 5000,
-            true, false, 1000, 100, GatewaySender.DEFAULT_DISPATCHER_THREADS, null, null, null));
-    vm4.invoke(
-        () -> verifySenderAttributes("ln", 2, true, true, 1000, socketReadTimeout, true, 1000, 5000,
-            true, false, 1000, 100, GatewaySender.DEFAULT_DISPATCHER_THREADS, null, null, null));
-    vm5.invoke(
-        () -> verifySenderAttributes("ln", 2, true, true, 1000, socketReadTimeout, true, 1000, 5000,
-            true, false, 1000, 100, GatewaySender.DEFAULT_DISPATCHER_THREADS, null, null, null));
-  }
-
-  /**
-   * Parallel GatewaySender with given attribute values. Provide dispatcherThreads as 2 which is not
-   * valid for Parallel sender.
-   */
-  @Test
-  public void testCreateParallelGatewaySender_Error() {
-
-    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
-
-    Properties props = getDistributedSystemProperties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
-    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
-    setUpJmxManagerOnVm0ThenConnect(props);
-
-    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
-
-    vm3.invoke(() -> createCache(punePort));
-    vm4.invoke(() -> createCache(punePort));
-    vm5.invoke(() -> createCache(punePort));
-
-    int socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000;
-    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID
-        + "=ln" + " --" + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + socketReadTimeout + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2" + " --"
-        + CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY + "=THREAD";
-    IgnoredException exp =
-        IgnoredException.addIgnoredException(GatewaySenderException.class.getName());
-    try {
-      CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
-      if (cmdResult != null) {
-        String strCmdResult = commandResultToString(cmdResult);
-        getLogWriter().info("testCreateGatewaySender stringResult : " + strCmdResult + ">>>>");
-        assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-        TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-        List<String> status = resultData.retrieveAllValues("Status");
-        assertEquals(5, status.size());
-        for (int i = 0; i < status.size(); i++) {
-          assertTrue("GatewaySender creation should have failed",
-              status.get(i).indexOf("ERROR:") != -1);
-        }
-      } else {
-        fail("testCreateGatewaySender failed as did not get CommandResult");
-      }
-    } finally {
-      exp.remove();
-    }
-
-  }
-}


[08/19] geode git commit: GEODE-2201 Make UITests a bit more resilient

Posted by kl...@apache.org.
GEODE-2201 Make UITests a bit more resilient

- Increase some timeouts
- Avoid StaleElementReferenceExceptions by retrying the element
  retrieval.


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

Branch: refs/heads/feature/GEODE-1027
Commit: d4276136337d2c9bee7336bafa281f2301af2a40
Parents: 1d951e3
Author: Jens Deppe <jd...@pivotal.io>
Authored: Thu Dec 8 20:56:44 2016 -0800
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Thu Dec 8 20:56:44 2016 -0800

----------------------------------------------------------------------
 .../tests/rules/ScreenshotOnFailureRule.java    |  2 +-
 .../tools/pulse/tests/rules/WebDriverRule.java  |  4 +-
 .../tools/pulse/tests/ui/PulseTestUtils.java    | 54 +++++++++++---------
 3 files changed, 33 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d4276136/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ScreenshotOnFailureRule.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ScreenshotOnFailureRule.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ScreenshotOnFailureRule.java
index 91465f0..3728015 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ScreenshotOnFailureRule.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ScreenshotOnFailureRule.java
@@ -47,7 +47,7 @@ public class ScreenshotOnFailureRule extends TestWatcher {
       try {
         File screenshot = new File("build/screenshots/" + screenshotName + ".png");
         FileUtils.copyFile(tempFile, screenshot);
-        System.out.println("Screenshot saved to: " + screenshot.getCanonicalPath());
+        System.err.println("Screenshot saved to: " + screenshot.getCanonicalPath());
       } catch (IOException e) {
         throw new Error(e);
       }

http://git-wip-us.apache.org/repos/asf/geode/blob/d4276136/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/WebDriverRule.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/WebDriverRule.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/WebDriverRule.java
index e273557..8a4e7f4 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/WebDriverRule.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/WebDriverRule.java
@@ -98,8 +98,8 @@ public class WebDriverRule extends ExternalResource {
 
     driver = new PhantomJSDriver(capabilities);
     driver.manage().window().maximize();
-    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
-    driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
+    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+    driver.manage().timeouts().pageLoadTimeout(300, TimeUnit.SECONDS);
   }
 
   public WebElement waitForElementById(final String id) {

http://git-wip-us.apache.org/repos/asf/geode/blob/d4276136/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseTestUtils.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseTestUtils.java
index c6ed3ff..076229e 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseTestUtils.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseTestUtils.java
@@ -25,7 +25,9 @@ import java.util.TreeMap;
 import java.util.function.Supplier;
 
 import org.openqa.selenium.By;
+import org.openqa.selenium.StaleElementReferenceException;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebDriverException;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.interactions.Actions;
 import org.openqa.selenium.support.ui.ExpectedCondition;
@@ -56,38 +58,42 @@ public final class PulseTestUtils {
   public static int maxWaitTime = 30;
 
   public static WebElement waitForElementWithId(String id) {
+    return waitForElement(By.id(id));
+  }
+
+  public static WebElement waitForElement(By by) {
     WebElement element = (new WebDriverWait(driverProvider.get(), maxWaitTime))
-        .until(new ExpectedCondition<WebElement>() {
-          @Override
-          public WebElement apply(WebDriver d) {
-            return d.findElement(By.id(id));
-          }
-        });
+      .until((ExpectedCondition<WebElement>) d -> d.findElement(by));
     assertNotNull(element);
     return element;
   }
 
-
-  public static WebElement findElementUsingXpath(String xpath) {
-    return getDriver().findElement(By.xpath(xpath));
-  }
-
   public static void clickElementUsingId(String id) {
-    waitForElementWithId(id).click();
+    WebDriverException lastException = null;
+    int attempts = 3;
+    while (attempts > 0) {
+      try {
+        waitForElementWithId(id).click();
+        return;
+      } catch (StaleElementReferenceException sere) {
+        lastException = sere;
+      }
+      attempts++;
+    }
+
+    throw lastException;
   }
 
   public static void clickElementUsingXpath(String xpath) {
-    findElementUsingXpath(xpath).click();
+    findElementByXpath(xpath).click();
   }
 
-
   public static void sendKeysUsingId(String Id, String textToEnter) {
     waitForElementWithId(Id).sendKeys(textToEnter);
   }
 
-
   public static WebElement findElementByXpath(String xpath) {
-    return getDriver().findElement(By.xpath(xpath));
+    return waitForElement(By.xpath(xpath));
   }
 
   public static String getTextUsingXpath(String xpath) {
@@ -99,25 +105,25 @@ public final class PulseTestUtils {
   }
 
   public static String getPersistanceEnabled(Region r) {
-    String persitance = null;
+    String persistence = null;
 
     if (r.getPersistentEnabled()) {
-      persitance = "ON";
+      persistence = "ON";
     } else if (!r.getPersistentEnabled()) {
-      persitance = "OFF";
+      persistence = "OFF";
     }
-    return persitance;
+    return persistence;
   }
 
   public static String getPersistanceEnabled(String trueOrFalse) {
-    String persitance = null;
+    String persistence = null;
 
     if (trueOrFalse.contains("true")) {
-      persitance = "ON";
+      persistence = "ON";
     } else if (trueOrFalse.contains("false")) {
-      persitance = "OFF";
+      persistence = "OFF";
     }
-    return persitance;
+    return persistence;
   }
 
   public static void validateServerGroupGridData() {


[18/19] geode git commit: GEODE-2204: apply FlakyTest category to flaky test

Posted by kl...@apache.org.
GEODE-2204: apply FlakyTest category to flaky test


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

Branch: refs/heads/feature/GEODE-1027
Commit: 8eb09bde832fc48c7a42b73743f102198a4cb311
Parents: 0f28be9
Author: Kirk Lund <kl...@apache.org>
Authored: Mon Dec 12 10:21:14 2016 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon Dec 12 14:34:03 2016 -0800

----------------------------------------------------------------------
 .../java/org/apache/geode/security/PDXPostProcessorDUnitTest.java   | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/8eb09bde/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java
index 897db92..f6105e1 100644
--- a/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java
@@ -149,6 +149,7 @@ public class PDXPostProcessorDUnitTest extends AbstractSecureServerDUnitTest {
     assertEquals(pp.getCount(), 2);
   }
 
+  @Category(FlakyTest.class) // GEODE-2204
   @Test
   public void testRegisterInterest() {
     client1.invoke(() -> {


[13/19] geode git commit: Merge branch 'feature/GEODE-2201' into develop

Posted by kl...@apache.org.
Merge branch 'feature/GEODE-2201' into develop


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

Branch: refs/heads/feature/GEODE-1027
Commit: df8730d9de9eb0a730cf1c61cf845748418747cb
Parents: ef86239 d427613
Author: Jens Deppe <jd...@pivotal.io>
Authored: Sun Dec 11 20:17:41 2016 -0800
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Sun Dec 11 20:17:41 2016 -0800

----------------------------------------------------------------------
 .../tests/rules/ScreenshotOnFailureRule.java    |  2 +-
 .../tools/pulse/tests/rules/WebDriverRule.java  |  4 +-
 .../tools/pulse/tests/ui/PulseTestUtils.java    | 54 +++++++++++---------
 3 files changed, 33 insertions(+), 27 deletions(-)
----------------------------------------------------------------------