You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2017/08/22 16:39:20 UTC

[01/14] geode git commit: GEODE-3322: delete empty javadocs to fix javadoc warning [Forced Update!]

Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-3416 c6b20a91f -> 26dcf4364 (forced update)


GEODE-3322: delete empty javadocs to fix javadoc warning


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

Branch: refs/heads/feature/GEODE-3416
Commit: 9b52ee6626d948bfaab9618c8f7756fb6cf30f97
Parents: b43f502
Author: Kirk Lund <kl...@apache.org>
Authored: Mon Aug 21 10:43:29 2017 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon Aug 21 10:43:29 2017 -0700

----------------------------------------------------------------------
 .../distributed/internal/locks/DLockRequestProcessor.java     | 7 -------
 1 file changed, 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/9b52ee66/geode-core/src/main/java/org/apache/geode/distributed/internal/locks/DLockRequestProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/locks/DLockRequestProcessor.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/locks/DLockRequestProcessor.java
index 96f692b..3f42adb 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/locks/DLockRequestProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/locks/DLockRequestProcessor.java
@@ -196,13 +196,6 @@ public class DLockRequestProcessor extends ReplyProcessor21 {
     return this.response.leaseExpireTime;
   }
 
-  /**
-   *
-   * @param interruptible
-   * @param lockId
-   * @return
-   * @throws InterruptedException only possible if interruptible is true.
-   */
   protected boolean requestLock(boolean interruptible, int lockId) throws InterruptedException {
     final boolean isDebugEnabled_DLS = logger.isTraceEnabled(LogMarker.DLS);
 


[06/14] geode git commit: GEODE-1279: rename tests with old bug system numbers

Posted by ud...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit4DistributedTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit4DistributedTestCase.java b/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit4DistributedTestCase.java
index 3572e3f..a2a0518 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit4DistributedTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit4DistributedTestCase.java
@@ -18,13 +18,16 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
+import static org.apache.geode.test.dunit.DistributedTestUtils.getAllDistributedSystemProperties;
+import static org.apache.geode.test.dunit.DistributedTestUtils.unregisterInstantiatorsInThisVM;
+import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
+import static org.apache.geode.test.dunit.Invoke.invokeInLocator;
+import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
 import static org.junit.Assert.assertNotNull;
 
 import java.io.Serializable;
-import java.text.DecimalFormat;
-import java.util.Iterator;
 import java.util.LinkedHashSet;
-import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.Set;
 
@@ -65,11 +68,8 @@ import org.apache.geode.internal.net.SocketCreator;
 import org.apache.geode.internal.net.SocketCreatorFactory;
 import org.apache.geode.management.internal.cli.LogWrapper;
 import org.apache.geode.test.dunit.DUnitBlackboard;
-import org.apache.geode.test.dunit.DistributedTestUtils;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.IgnoredException;
-import org.apache.geode.test.dunit.Invoke;
-import org.apache.geode.test.dunit.LogWriterUtils;
 import org.apache.geode.test.dunit.standalone.DUnitLauncher;
 import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
 
@@ -77,10 +77,9 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
  * This class is the base class for all distributed tests using JUnit 4.
  */
 public abstract class JUnit4DistributedTestCase implements DistributedTestFixture, Serializable {
-
   private static final Logger logger = LogService.getLogger();
 
-  private static final Set<String> testHistory = new LinkedHashSet<String>();
+  private static final Set<String> testHistory = new LinkedHashSet<>();
 
   /** This VM's connection to the distributed system */
   private static InternalDistributedSystem system;
@@ -88,10 +87,7 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
   private static Properties lastSystemProperties;
   private static volatile String testMethodName;
 
-  /** For formatting timing info */
-  private static final DecimalFormat format = new DecimalFormat("###.###");
-
-  private static boolean reconnect = false;
+  private static DUnitBlackboard blackboard;
 
   private static final boolean logPerTest = Boolean.getBoolean("dunitLogPerTest");
 
@@ -118,17 +114,6 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
   @Rule
   public SerializableTestName testNameForDistributedTestCase = new SerializableTestName();
 
-  private static DUnitBlackboard blackboard;
-
-  /**
-   * Returns a DUnitBlackboard that can be used to pass data between VMs and synchronize actions.
-   * 
-   * @return the blackboard
-   */
-  public DUnitBlackboard getBlackboard() {
-    return blackboard;
-  }
-
   @BeforeClass
   public static final void initializeDistributedTestCase() {
     DUnitLauncher.launchIfNeeded();
@@ -149,19 +134,12 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
     return this.distributedTestFixture.getClass();
   }
 
-  // ---------------------------------------------------------------------------
-  // methods for tests
-  // ---------------------------------------------------------------------------
-
   /**
    * @deprecated Please override {@link #getDistributedSystemProperties()} instead.
    */
   @Deprecated
-  public final void setSystem(final Properties props, final DistributedSystem ds) { // TODO:
-                                                                                    // override
-                                                                                    // getDistributedSystemProperties
-                                                                                    // and then
-                                                                                    // delete
+  public final void setSystem(final Properties props, final DistributedSystem ds) {
+    // TODO: override getDistributedSystemProperties and then delete
     system = (InternalDistributedSystem) ds;
     lastSystemProperties = props;
     lastSystemCreatedInTest = getTestClass(); // used to be getDeclaringClass()
@@ -185,9 +163,10 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
     if (system == null) {
       system = InternalDistributedSystem.getAnyInstance();
     }
+
     if (system == null || !system.isConnected()) {
       // Figure out our distributed system properties
-      Properties p = DistributedTestUtils.getAllDistributedSystemProperties(props);
+      Properties p = getAllDistributedSystemProperties(props);
       lastSystemCreatedInTest = getTestClass(); // used to be getDeclaringClass()
       if (logPerTest) {
         String testMethod = getTestMethodName();
@@ -199,36 +178,37 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
       }
       system = (InternalDistributedSystem) DistributedSystem.connect(p);
       lastSystemProperties = p;
+
     } else {
       boolean needNewSystem = false;
       if (!getTestClass().equals(lastSystemCreatedInTest)) { // used to be getDeclaringClass()
-        Properties newProps = DistributedTestUtils.getAllDistributedSystemProperties(props);
+        Properties newProps = getAllDistributedSystemProperties(props);
         needNewSystem = !newProps.equals(lastSystemProperties);
         if (needNewSystem) {
-          LogWriterUtils.getLogWriter()
+          getLogWriter()
               .info("Test class has changed and the new DS properties are not an exact match. "
                   + "Forcing DS disconnect. Old props = " + lastSystemProperties + "new props="
                   + newProps);
         }
+
       } else {
         Properties activeProps = system.getProperties();
-        for (Map.Entry<Object, Object> objectObjectEntry : props.entrySet()) {
-          Map.Entry entry = objectObjectEntry;
+        for (Entry<Object, Object> entry : props.entrySet()) {
           String key = (String) entry.getKey();
           String value = (String) entry.getValue();
           if (!value.equals(activeProps.getProperty(key))) {
             needNewSystem = true;
-            LogWriterUtils.getLogWriter().info("Forcing DS disconnect. For property " + key
-                + " old value = " + activeProps.getProperty(key) + " new value = " + value);
+            getLogWriter().info("Forcing DS disconnect. For property " + key + " old value = "
+                + activeProps.getProperty(key) + " new value = " + value);
             break;
           }
         }
       }
+
       if (needNewSystem) {
         // the current system does not meet our needs to disconnect and
         // call recursively to get a new system.
-        LogWriterUtils.getLogWriter()
-            .info("Disconnecting from current DS in order to make a new one");
+        getLogWriter().info("Disconnecting from current DS in order to make a new one");
         disconnectFromDS();
         getSystem(props);
       }
@@ -307,14 +287,13 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
 
   public static final void disconnectAllFromDS() {
     disconnectFromDS();
-    Invoke.invokeInEveryVM("disconnectFromDS", () -> disconnectFromDS());
+    invokeInEveryVM("disconnectFromDS", () -> disconnectFromDS());
   }
 
   /**
    * Disconnects this VM from the distributed system
    */
   public static final void disconnectFromDS() {
-    // setTestMethodName(null);
     GemFireCacheImpl.testCacheXml = null;
     if (system != null) {
       system.disconnect();
@@ -328,20 +307,24 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
       }
       try {
         ds.disconnect();
-      } catch (Exception e) {
-        // ignore
+      } catch (Exception ignore) {
       }
     }
 
     AdminDistributedSystemImpl ads = AdminDistributedSystemImpl.getConnectedInstance();
-    if (ads != null) {// && ads.isConnected()) {
+    if (ads != null) {
       ads.disconnect();
     }
   }
 
-  // ---------------------------------------------------------------------------
-  // name methods
-  // ---------------------------------------------------------------------------
+  /**
+   * Returns a DUnitBlackboard that can be used to pass data between VMs and synchronize actions.
+   *
+   * @return the blackboard
+   */
+  public DUnitBlackboard getBlackboard() {
+    return blackboard;
+  }
 
   public static final String getTestMethodName() {
     return testMethodName;
@@ -360,10 +343,6 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
     return getTestClass().getSimpleName() + "_" + getName();
   }
 
-  // ---------------------------------------------------------------------------
-  // setup methods
-  // ---------------------------------------------------------------------------
-
   /**
    * Sets up the DistributedTestCase.
    *
@@ -372,9 +351,9 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
    * setUp() or override {@link #postSetUp()} with work that needs to occur after setUp().
    */
   @Before
-  public final void setUp() throws Exception {
+  public final void setUpDistributedTestCase() throws Exception {
     preSetUp();
-    setUpDistributedTestCase();
+    doSetUpDistributedTestCase();
     postSetUp();
   }
 
@@ -386,7 +365,7 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
    * <p>
    * Do not override this method.
    */
-  private final void setUpDistributedTestCase() {
+  private final void doSetUpDistributedTestCase() {
     final String className = getTestClass().getCanonicalName();
     final String methodName = getName();
 
@@ -407,7 +386,7 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
   }
 
   /**
-   * {@code preSetUp()} is invoked before {@link #setUpDistributedTestCase()}.
+   * {@code preSetUp()} is invoked before {@link #doSetUpDistributedTestCase()}.
    *
    * <p>
    * Override this as needed. Default implementation is empty.
@@ -420,7 +399,7 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
   }
 
   /**
-   * {@code postSetUp()} is invoked after {@link #setUpDistributedTestCase()}.
+   * {@code postSetUp()} is invoked after {@link #doSetUpDistributedTestCase()}.
    *
    * <p>
    * Override this as needed. Default implementation is empty.
@@ -457,11 +436,10 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
         .set(new InternalDistributedSystem.CreationStackGenerator() {
           @Override
           public Throwable generateCreationStack(final DistributionConfig config) {
-            final StringBuilder sb = new StringBuilder();
-            final String[] validAttributeNames = config.getAttributeNames();
-            for (int i = 0; i < validAttributeNames.length; i++) {
-              final String attName = validAttributeNames[i];
-              final Object actualAtt = config.getAttributeObject(attName);
+            StringBuilder sb = new StringBuilder();
+            String[] validAttributeNames = config.getAttributeNames();
+            for (String attName : validAttributeNames) {
+              Object actualAtt = config.getAttributeObject(attName);
               String actualAttStr = actualAtt.toString();
               sb.append("  ");
               sb.append(attName);
@@ -489,10 +467,6 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
     System.out.println("Previously run tests: " + testHistory);
   }
 
-  // ---------------------------------------------------------------------------
-  // teardown methods
-  // ---------------------------------------------------------------------------
-
   /**
    * Tears down the DistributedTestCase.
    *
@@ -502,13 +476,13 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
    * tearDown().
    */
   @After
-  public final void tearDown() throws Exception {
+  public final void tearDownDistributedTestCase() throws Exception {
     try {
       try {
         preTearDownAssertions();
       } finally {
         preTearDown();
-        tearDownDistributedTestCase();
+        doTearDownDistributedTestCase();
       }
     } finally {
       postTearDown();
@@ -516,9 +490,8 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
     }
   }
 
-  private final void tearDownDistributedTestCase() throws Exception {
-    Invoke.invokeInEveryVM("tearDownCreationStackGenerator",
-        () -> tearDownCreationStackGenerator());
+  private final void doTearDownDistributedTestCase() throws Exception {
+    invokeInEveryVM("tearDownCreationStackGenerator", () -> tearDownCreationStackGenerator());
     if (logPerTest) {
       disconnectAllFromDS();
     }
@@ -526,11 +499,10 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
     if (!getDistributedSystemProperties().isEmpty()) {
       disconnectAllFromDS();
     }
-
   }
 
   /**
-   * {@code preTearDown()} is invoked before {@link #tearDownDistributedTestCase()}.
+   * {@code preTearDown()} is invoked before {@link #doTearDownDistributedTestCase()}.
    *
    * <p>
    * Override this as needed. Default implementation is empty.
@@ -543,7 +515,7 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
   }
 
   /**
-   * {@code postTearDown()} is invoked after {@link #tearDownDistributedTestCase()}.
+   * {@code postTearDown()} is invoked after {@link #doTearDownDistributedTestCase()}.
    *
    * <p>
    * Override this as needed. Default implementation is empty.
@@ -571,10 +543,10 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
 
   private static final void cleanupAllVms() {
     tearDownVM();
-    Invoke.invokeInEveryVM("tearDownVM", () -> tearDownVM());
-    Invoke.invokeInLocator(() -> {
+    invokeInEveryVM("tearDownVM", () -> tearDownVM());
+    invokeInLocator(() -> {
       DistributionMessageObserver.setInstance(null);
-      DistributedTestUtils.unregisterInstantiatorsInThisVM();
+      unregisterInstantiatorsInThisVM();
     });
     DUnitLauncher.closeAndCheckForSuspects();
   }
@@ -582,6 +554,7 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
   private static final void tearDownVM() {
     closeCache();
     disconnectFromDS();
+
     // keep alphabetized to detect duplicate lines
     CacheCreation.clearThreadLocals();
     CacheServerLauncher.clearStatics();
@@ -590,7 +563,7 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
     ClientServerTestCase.AUTO_LOAD_BALANCE = false;
     ClientStatsManager.cleanupForTests();
     DiskStoreObserver.setInstance(null);
-    DistributedTestUtils.unregisterInstantiatorsInThisVM();
+    unregisterInstantiatorsInThisVM();
     DistributionMessageObserver.setInstance(null);
     GlobalLockingDUnitTest.region_testBug32356 = null;
     InitialImageOperation.slowImageProcessing = 0;
@@ -617,7 +590,8 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
     SocketCreatorFactory.close();
   }
 
-  private static final void closeCache() { // TODO: this should move to CacheTestCase
+  // TODO: this should move to CacheTestCase
+  private static final void closeCache() {
     GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
     if (cache != null && !cache.isClosed()) {
       destroyRegions(cache);
@@ -625,12 +599,11 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
     }
   }
 
-  protected static final void destroyRegions(final Cache cache) { // TODO: this should move to
-                                                                  // CacheTestCase
+  // TODO: this should move to CacheTestCase
+  protected static final void destroyRegions(final Cache cache) {
     if (cache != null && !cache.isClosed()) {
       // try to destroy the root regions first so that we clean up any persistent files.
-      for (Iterator itr = cache.rootRegions().iterator(); itr.hasNext();) {
-        Region root = (Region) itr.next();
+      for (Region<?, ?> root : cache.rootRegions()) {
         String regionFullPath = root == null ? null : root.getFullPath();
         // for colocated regions you can't locally destroy a partitioned region.
         if (root.isDestroyed() || root instanceof HARegion || root instanceof PartitionedRegion) {


[05/14] geode git commit: Don't download geode 1.2 every time a build runs

Posted by ud...@apache.org.
Don't download geode 1.2 every time a build runs

Setting the overwrite flag on the download tasks to false so that we
don't download the old version of geode for every build.

This closes #728


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

Branch: refs/heads/feature/GEODE-3416
Commit: d9394e39a3066890e1638d3518615c085496e1e1
Parents: 6a17c9b
Author: Dan Smith <up...@apache.org>
Authored: Mon Aug 21 13:30:22 2017 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Mon Aug 21 14:24:26 2017 -0700

----------------------------------------------------------------------
 geode-old-versions/build.gradle | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d9394e39/geode-old-versions/build.gradle
----------------------------------------------------------------------
diff --git a/geode-old-versions/build.gradle b/geode-old-versions/build.gradle
index 2e9257c..3b7c2e5 100644
--- a/geode-old-versions/build.gradle
+++ b/geode-old-versions/build.gradle
@@ -43,11 +43,13 @@ def addOldVersion(def source, def geodeVersion, def downloadInstall) {
   task "downloadZipFile${source}" (type: Download) {
     src "https://www.apache.org/dyn/closer.cgi?action=download&filename=geode/$geodeVersion/apache-geode-${geodeVersion}.tar.gz"
     dest new File(buildDir, "apache-geode-${geodeVersion}.tar.gz")
+    overwrite false
   }
 
   task "downloadSHA${source}" (type: Download) {
     src "https://www.apache.org/dist/geode/${geodeVersion}/apache-geode-${geodeVersion}.tar.gz.sha256"
     dest new File(buildDir, "apache-geode-${geodeVersion}.tar.gz.sha256")
+    overwrite false
   }
 
 

[07/14] geode git commit: GEODE-1279: rename tests with old bug system numbers

Posted by ud...@apache.org.
GEODE-1279: rename tests with old bug system numbers

* Bug34387DUnitTest -> CreateAndLocalDestroyInTXRegressionTest
* Bug35214DUnitTest -> EntriesDoNotExpireDuringGIIRegressionTest
* Bug38013DUnitTest -> RemotePRValuesAreNotDeserializedRegressionTest
* Bug34948DUnitTest -> ValuesAreLazilyDeserializedRegressionTest

* cleanup setUp and tearDown in dunit framework


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

Branch: refs/heads/feature/GEODE-3416
Commit: 2924ef1d0e70a1d67fc4b32dd922fcb0571a4a92
Parents: d9394e3
Author: Kirk Lund <kl...@apache.org>
Authored: Wed May 24 13:09:11 2017 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon Aug 21 14:38:46 2017 -0700

----------------------------------------------------------------------
 .../apache/geode/cache30/Bug34387DUnitTest.java | 188 ----------------
 .../apache/geode/cache30/Bug34948DUnitTest.java | 157 -------------
 .../apache/geode/cache30/Bug35214DUnitTest.java | 220 -------------------
 .../apache/geode/cache30/Bug38013DUnitTest.java | 150 -------------
 ...CreateAndLocalDestroyInTXRegressionTest.java | 167 ++++++++++++++
 ...triesDoNotExpireDuringGIIRegressionTest.java | 210 ++++++++++++++++++
 ...RValuesAreNotDeserializedRegressionTest.java | 168 ++++++++++++++
 ...luesAreLazilyDeserializedRegressionTest.java | 169 ++++++++++++++
 .../cache/ConnectDisconnectDUnitTest.java       | 148 +++++--------
 .../dunit/cache/internal/CacheTestFixture.java  |   4 +-
 .../cache/internal/JUnit3CacheTestCase.java     |   9 +-
 .../cache/internal/JUnit4CacheTestCase.java     |   7 +-
 .../dunit/internal/DistributedTestFixture.java  |  16 +-
 .../internal/JUnit3DistributedTestCase.java     |  72 +++---
 .../internal/JUnit4DistributedTestCase.java     | 141 +++++-------
 15 files changed, 865 insertions(+), 961 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/cache30/Bug34387DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/Bug34387DUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache30/Bug34387DUnitTest.java
deleted file mode 100644
index d43be83..0000000
--- a/geode-core/src/test/java/org/apache/geode/cache30/Bug34387DUnitTest.java
+++ /dev/null
@@ -1,188 +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.cache30;
-
-import org.junit.experimental.categories.Category;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.CacheException;
-import org.apache.geode.cache.CacheListener;
-import org.apache.geode.cache.CacheTransactionManager;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.EntryEvent;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.Scope;
-import org.apache.geode.cache.UnsupportedOperationInTransactionException;
-import org.apache.geode.cache.util.CacheListenerAdapter;
-import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.VM;
-
-/**
- * Test create + localDestroy for bug 34387
- *
- * @since GemFire 5.0
- */
-@Category(DistributedTest.class)
-public class Bug34387DUnitTest extends JUnit4CacheTestCase {
-
-  // private transient Region r;
-  // private transient DistributedMember otherId;
-  protected transient int invokeCount;
-
-  static volatile boolean callbackFailure;
-
-  public Bug34387DUnitTest() {
-    super();
-  }
-
-  protected static void callbackAssertEquals(String message, Object expected, Object actual) {
-    if (expected == null && actual == null)
-      return;
-    if (expected != null && expected.equals(actual))
-      return;
-    callbackFailure = true;
-    // Throws an error that is ignored, but...
-    assertEquals(message, expected, actual);
-  }
-
-
-  private VM getOtherVm() {
-    Host host = Host.getHost(0);
-    return host.getVM(0);
-  }
-
-  private void initOtherId() {
-    VM vm = getOtherVm();
-    vm.invoke(new CacheSerializableRunnable("Connect") {
-      public void run2() throws CacheException {
-        getCache();
-      }
-    });
-    vm.invoke(() -> Bug34387DUnitTest.getVMDistributedMember());
-  }
-
-  private void doCommitOtherVm(final boolean doDestroy) {
-    VM vm = getOtherVm();
-    vm.invoke(new CacheSerializableRunnable("create root") {
-      public void run2() throws CacheException {
-        AttributesFactory af = new AttributesFactory();
-        af.setScope(Scope.DISTRIBUTED_ACK);
-        af.setConcurrencyChecksEnabled(true);
-        Region r1 = createRootRegion("r1", af.create());
-        CacheTransactionManager ctm = getCache().getCacheTransactionManager();
-        ctm.begin();
-        r1.create("createKey", "createValue");
-        if (doDestroy) {
-          try {
-            r1.localDestroy("createKey");
-            fail("expected exception not thrown");
-          } catch (UnsupportedOperationInTransactionException e) {
-            assertEquals(e.getMessage(),
-                LocalizedStrings.TXStateStub_LOCAL_DESTROY_NOT_ALLOWED_IN_TRANSACTION
-                    .toLocalizedString());
-          }
-        } else {
-          try {
-            r1.localInvalidate("createKey");
-            fail("expected exception not thrown");
-          } catch (UnsupportedOperationInTransactionException e) {
-            assertEquals(e.getMessage(),
-                LocalizedStrings.TXStateStub_LOCAL_INVALIDATE_NOT_ALLOWED_IN_TRANSACTION
-                    .toLocalizedString());
-          }
-        }
-        ctm.commit();
-      }
-    });
-  }
-
-  public static DistributedMember getVMDistributedMember() {
-    return InternalDistributedSystem.getAnyInstance().getDistributedMember();
-  }
-
-  ////////////////////// Test Methods //////////////////////
-
-  /**
-   * test create followed by localDestroy
-   */
-  @Test
-  public void testCreateAndLD() throws CacheException {
-    initOtherId();
-    AttributesFactory af = new AttributesFactory();
-    af.setDataPolicy(DataPolicy.REPLICATE);
-    af.setScope(Scope.DISTRIBUTED_ACK);
-    af.setConcurrencyChecksEnabled(true);
-    callbackFailure = false;
-
-    CacheListener cl1 = new CacheListenerAdapter() {
-      public void afterCreate(EntryEvent e) {
-        callbackAssertEquals("Keys not equal", "createKey", e.getKey());
-        callbackAssertEquals("Values not equal", "createValue", e.getNewValue());
-        Bug34387DUnitTest.this.invokeCount++;
-      }
-    };
-    af.addCacheListener(cl1);
-    Region r1 = createRootRegion("r1", af.create());
-
-    this.invokeCount = 0;
-    assertNull(r1.getEntry("createKey"));
-    doCommitOtherVm(true);
-    assertNotNull(r1.getEntry("createKey"));
-    assertEquals("createValue", r1.getEntry("createKey").getValue());
-    assertEquals(1, this.invokeCount);
-    assertFalse("Errors in callbacks; check logs for details", callbackFailure);
-  }
-
-  /**
-   * test create followed by localInvalidate
-   */
-  @Test
-  public void testCreateAndLI() throws CacheException {
-    initOtherId();
-    AttributesFactory af = new AttributesFactory();
-    af.setDataPolicy(DataPolicy.REPLICATE);
-    af.setScope(Scope.DISTRIBUTED_ACK);
-    af.setConcurrencyChecksEnabled(true);
-    callbackFailure = false;
-
-    CacheListener cl1 = new CacheListenerAdapter() {
-      public void afterCreate(EntryEvent e) {
-        callbackAssertEquals("key not equal", "createKey", e.getKey());
-        callbackAssertEquals("value not equal", "createValue", e.getNewValue());
-        Bug34387DUnitTest.this.invokeCount++;
-      }
-    };
-    af.addCacheListener(cl1);
-    Region r1 = createRootRegion("r1", af.create());
-
-    this.invokeCount = 0;
-    assertNull(r1.getEntry("createKey"));
-    doCommitOtherVm(false);
-    assertNotNull(r1.getEntry("createKey"));
-    assertEquals("createValue", r1.getEntry("createKey").getValue());
-    assertEquals(1, this.invokeCount);
-    assertFalse("Errors in callbacks; check logs for details", callbackFailure);
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/cache30/Bug34948DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/Bug34948DUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache30/Bug34948DUnitTest.java
deleted file mode 100644
index 8b98cd3..0000000
--- a/geode-core/src/test/java/org/apache/geode/cache30/Bug34948DUnitTest.java
+++ /dev/null
@@ -1,157 +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.cache30;
-
-import org.junit.experimental.categories.Category;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.geode.DataSerializable;
-import org.apache.geode.DataSerializer;
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.CacheException;
-import org.apache.geode.cache.CacheListener;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.EntryEvent;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.Scope;
-import org.apache.geode.cache.util.CacheListenerAdapter;
-import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.DistributedSystem;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.VM;
-
-/**
- * Test to make sure cache values are lazily deserialized
- *
- * @since GemFire 5.0
- */
-@Category(DistributedTest.class)
-public class Bug34948DUnitTest extends JUnit4CacheTestCase {
-
-  public Bug34948DUnitTest() {
-    super();
-  }
-
-  ////////////////////// Test Methods //////////////////////
-
-  private VM getOtherVm() {
-    Host host = Host.getHost(0);
-    return host.getVM(0);
-  }
-
-  static protected Object lastCallback = null;
-
-  private void doCreateOtherVm() {
-    VM vm = getOtherVm();
-    vm.invoke(new CacheSerializableRunnable("create root") {
-      public void run2() throws CacheException {
-        getSystem();
-        AttributesFactory af = new AttributesFactory();
-        af.setScope(Scope.DISTRIBUTED_ACK);
-        af.setDataPolicy(DataPolicy.PRELOADED);
-        CacheListener cl = new CacheListenerAdapter() {
-          public void afterCreate(EntryEvent event) {
-            // getLogWriter().info("afterCreate " + event.getKey());
-            if (event.getCallbackArgument() != null) {
-              lastCallback = event.getCallbackArgument();
-            }
-          }
-
-          public void afterUpdate(EntryEvent event) {
-            // getLogWriter().info("afterUpdate " + event.getKey());
-            if (event.getCallbackArgument() != null) {
-              lastCallback = event.getCallbackArgument();
-            }
-          }
-
-          public void afterInvalidate(EntryEvent event) {
-            if (event.getCallbackArgument() != null) {
-              lastCallback = event.getCallbackArgument();
-            }
-          }
-
-          public void afterDestroy(EntryEvent event) {
-            if (event.getCallbackArgument() != null) {
-              lastCallback = event.getCallbackArgument();
-            }
-          }
-        };
-        af.setCacheListener(cl);
-        createRootRegion("bug34948", af.create());
-      }
-    });
-  }
-
-  /**
-   * Make sure that value is only deserialized in cache whose application asks for the value.
-   */
-  @Test
-  public void testBug34948() throws CacheException {
-    final AttributesFactory factory = new AttributesFactory();
-    factory.setScope(Scope.DISTRIBUTED_ACK);
-    factory.setDataPolicy(DataPolicy.PRELOADED);
-    final Region r = createRootRegion("bug34948", factory.create());
-
-    // before gii
-    r.put("key1", new HomeBoy());
-
-    doCreateOtherVm();
-
-    // after gii
-    r.put("key2", new HomeBoy());
-
-    r.localDestroy("key1");
-    r.localDestroy("key2");
-
-    Object o = r.get("key1");
-    assertTrue(r.get("key1") instanceof HomeBoy);
-    assertTrue(r.get("key2") == null); // preload will not distribute
-
-    // @todo darrel: add putAll test once it does not deserialize
-  }
-
-  public static class HomeBoy implements DataSerializable {
-    public HomeBoy() {}
-
-    public void toData(DataOutput out) throws IOException {
-      DistributedMember me = InternalDistributedSystem.getAnyInstance().getDistributedMember();
-      DataSerializer.writeObject(me, out);
-    }
-
-    public void fromData(DataInput in) throws IOException, ClassNotFoundException {
-      DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
-      DistributedMember me = ds.getDistributedMember();
-      DistributedMember hb = (DistributedMember) DataSerializer.readObject(in);
-      if (me.equals(hb)) {
-        ds.getLogWriter().info("HomeBoy was deserialized on his home");
-      } else {
-        String msg = "HomeBoy was deserialized on " + me + " instead of his home " + hb;
-        ds.getLogWriter().error(msg);
-        throw new IllegalStateException(msg);
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/cache30/Bug35214DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/Bug35214DUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache30/Bug35214DUnitTest.java
deleted file mode 100644
index ed25b26..0000000
--- a/geode-core/src/test/java/org/apache/geode/cache30/Bug35214DUnitTest.java
+++ /dev/null
@@ -1,220 +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.cache30;
-
-import org.junit.experimental.categories.Category;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-import org.apache.geode.SystemFailure;
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.CacheException;
-import org.apache.geode.cache.CacheListener;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.EntryEvent;
-import org.apache.geode.cache.ExpirationAction;
-import org.apache.geode.cache.ExpirationAttributes;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionEvent;
-import org.apache.geode.cache.Scope;
-import org.apache.geode.cache.util.CacheListenerAdapter;
-import org.apache.geode.internal.cache.LocalRegion;
-import org.apache.geode.test.dunit.Assert;
-import org.apache.geode.test.dunit.AsyncInvocation;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.LogWriterUtils;
-import org.apache.geode.test.dunit.ThreadUtils;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.Wait;
-import org.apache.geode.test.dunit.WaitCriterion;
-
-/**
- * Make sure entry expiration does not happen during gii for bug 35214
- *
- * @since GemFire 5.0
- */
-@Category(DistributedTest.class)
-public class Bug35214DUnitTest extends JUnit4CacheTestCase {
-
-  protected volatile int expirationCount = 0;
-
-  private final static int ENTRY_COUNT = 100;
-
-  protected static volatile boolean callbackFailure;
-
-  public Bug35214DUnitTest() {
-    super();
-  }
-
-  private VM getOtherVm() {
-    Host host = Host.getHost(0);
-    return host.getVM(0);
-  }
-
-  private void initOtherVm() {
-    VM vm = getOtherVm();
-    vm.invoke(new CacheSerializableRunnable("init") {
-      public void run2() throws CacheException {
-        getCache();
-        AttributesFactory af = new AttributesFactory();
-        af.setScope(Scope.DISTRIBUTED_ACK);
-        Region r1 = createRootRegion("r1", af.create());
-        for (int i = 1; i <= ENTRY_COUNT; i++) {
-          r1.put("key" + i, "value" + i);
-        }
-      }
-    });
-  }
-
-  private AsyncInvocation updateOtherVm() throws Throwable {
-    VM vm = getOtherVm();
-    AsyncInvocation otherUpdater = vm.invokeAsync(new CacheSerializableRunnable("update") {
-      public void run2() throws CacheException {
-        Region r1 = getRootRegion("r1");
-        // let the main guys gii get started; we want to do updates
-        // during his gii
-        {
-          // wait for profile of getInitialImage cache to show up
-          org.apache.geode.internal.cache.CacheDistributionAdvisor adv =
-              ((org.apache.geode.internal.cache.DistributedRegion) r1)
-                  .getCacheDistributionAdvisor();
-          int numProfiles;
-          int expectedProfiles = 1;
-          for (;;) {
-            numProfiles = adv.adviseInitialImage(null).getReplicates().size();
-            if (numProfiles < expectedProfiles) {
-              // getLogWriter().info("PROFILE CHECK: Found " + numProfiles +
-              // " getInitialImage Profiles (waiting for " + expectedProfiles + ")");
-              // pause(5);
-            } else {
-              LogWriterUtils.getLogWriter()
-                  .info("PROFILE CHECK: Found " + numProfiles + " getInitialImage Profiles (OK)");
-              break;
-            }
-          }
-        }
-        // start doing updates of the keys to see if we can get deadlocked
-        int updateCount = 1;
-        do {
-          for (int i = 1; i <= ENTRY_COUNT; i++) {
-            String key = "key" + i;
-            if (r1.containsKey(key)) {
-              r1.destroy(key);
-            } else {
-              r1.put(key, "value" + i + "uc" + updateCount);
-            }
-          }
-        } while (updateCount++ < 20);
-        // do one more loop with no destroys
-        for (int i = 1; i <= ENTRY_COUNT; i++) {
-          String key = "key" + i;
-          if (!r1.containsKey(key)) {
-            r1.put(key, "value" + i + "uc" + updateCount);
-          }
-        }
-      }
-    });
-
-    // FIXME this thread does not terminate
-    // DistributedTestCase.join(otherUpdater, 5 * 60 * 1000, getLogWriter());
-    // if(otherUpdater.exceptionOccurred()){
-    // fail("otherUpdater failed", otherUpdater.getException());
-    // }
-
-    return otherUpdater;
-  }
-
-  ////////////////////// Test Methods //////////////////////
-
-  protected boolean afterRegionCreateSeen = false;
-
-  protected static void callbackAssertTrue(String msg, boolean cond) {
-    if (cond)
-      return;
-    callbackFailure = true;
-    // Throws ignored error, but...
-    assertTrue(msg, cond);
-  }
-
-
-  /**
-   * make sure entries do not expire during a GII
-   */
-  @Test
-  public void testNoEntryExpireDuringGII() throws Exception {
-    initOtherVm();
-    AsyncInvocation updater = null;
-    try {
-      updater = updateOtherVm();
-    } catch (VirtualMachineError e) {
-      SystemFailure.initiateFailure(e);
-      throw e;
-    } catch (Throwable e1) {
-      Assert.fail("failed due to " + e1, e1);
-    }
-    System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true");
-    org.apache.geode.internal.cache.InitialImageOperation.slowImageProcessing = 30;
-    callbackFailure = false;
-
-    try {
-      AttributesFactory af = new AttributesFactory();
-      af.setDataPolicy(DataPolicy.REPLICATE);
-      af.setScope(Scope.DISTRIBUTED_ACK);
-      af.setStatisticsEnabled(true);
-      af.setEntryIdleTimeout(new ExpirationAttributes(1, ExpirationAction.INVALIDATE));
-      CacheListener cl1 = new CacheListenerAdapter() {
-        public void afterRegionCreate(RegionEvent re) {
-          afterRegionCreateSeen = true;
-        }
-
-        public void afterInvalidate(EntryEvent e) {
-          callbackAssertTrue("afterregionCreate not seen", afterRegionCreateSeen);
-          // make sure region is initialized
-          callbackAssertTrue("not initialized", ((LocalRegion) e.getRegion()).isInitialized());
-          expirationCount++;
-          org.apache.geode.internal.cache.InitialImageOperation.slowImageProcessing = 0;
-        }
-      };
-      af.addCacheListener(cl1);
-      final Region r1 = createRootRegion("r1", af.create());
-      ThreadUtils.join(updater, 60 * 1000);
-      WaitCriterion ev = new WaitCriterion() {
-        public boolean done() {
-          return r1.values().size() == 0;
-        }
-
-        public String description() {
-          return "region never became empty";
-        }
-      };
-      Wait.waitForCriterion(ev, 2 * 1000, 200, true);
-      {
-        assertEquals(0, r1.values().size());
-        assertEquals(ENTRY_COUNT, r1.keySet().size());
-      }
-
-    } finally {
-      org.apache.geode.internal.cache.InitialImageOperation.slowImageProcessing = 0;
-      System.getProperties().remove(LocalRegion.EXPIRY_MS_PROPERTY);
-      assertEquals(null, System.getProperty(LocalRegion.EXPIRY_MS_PROPERTY));
-    }
-    assertFalse("Errors in callbacks; check logs for details", callbackFailure);
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/cache30/Bug38013DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/Bug38013DUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache30/Bug38013DUnitTest.java
deleted file mode 100644
index a0e8021..0000000
--- a/geode-core/src/test/java/org/apache/geode/cache30/Bug38013DUnitTest.java
+++ /dev/null
@@ -1,150 +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.cache30;
-
-import org.junit.experimental.categories.Category;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.geode.DataSerializable;
-import org.apache.geode.DataSerializer;
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.CacheException;
-import org.apache.geode.cache.CacheListener;
-import org.apache.geode.cache.EntryEvent;
-import org.apache.geode.cache.PartitionAttributesFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.util.CacheListenerAdapter;
-import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.DistributedSystem;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.VM;
-
-/**
- * Test to make sure PR cache values are lazily deserialized
- *
- * @since GemFire 5.0
- */
-@Category(DistributedTest.class)
-public class Bug38013DUnitTest extends JUnit4CacheTestCase {
-
-  public Bug38013DUnitTest() {
-    super();
-  }
-
-  ////////////////////// Test Methods //////////////////////
-
-  private VM getOtherVm() {
-    Host host = Host.getHost(0);
-    return host.getVM(0);
-  }
-
-  static protected Object lastCallback = null;
-
-  private void doCreateOtherVm() {
-    VM vm = getOtherVm();
-    vm.invoke(new CacheSerializableRunnable("create root") {
-      public void run2() throws CacheException {
-        getSystem();
-        AttributesFactory af = new AttributesFactory();
-        CacheListener cl = new CacheListenerAdapter() {
-          public void afterCreate(EntryEvent event) {
-            // getLogWriter().info("afterCreate " + event.getKey());
-            if (event.getCallbackArgument() != null) {
-              lastCallback = event.getCallbackArgument();
-            }
-          }
-
-          public void afterUpdate(EntryEvent event) {
-            // getLogWriter().info("afterUpdate " + event.getKey());
-            if (event.getCallbackArgument() != null) {
-              lastCallback = event.getCallbackArgument();
-            }
-          }
-
-          public void afterInvalidate(EntryEvent event) {
-            if (event.getCallbackArgument() != null) {
-              lastCallback = event.getCallbackArgument();
-            }
-          }
-
-          public void afterDestroy(EntryEvent event) {
-            if (event.getCallbackArgument() != null) {
-              lastCallback = event.getCallbackArgument();
-            }
-          }
-        };
-        af.setCacheListener(cl);
-        // create a pr with a data store
-        PartitionAttributesFactory paf = new PartitionAttributesFactory();
-        paf.setRedundantCopies(0);
-        // use defaults so this is a data store
-        af.setPartitionAttributes(paf.create());
-        createRootRegion("bug38013", af.create());
-      }
-    });
-  }
-
-  /**
-   * Make sure that value is only deserialized in cache whose application asks for the value.
-   */
-  @Test
-  public void testBug38013() throws CacheException {
-    final AttributesFactory factory = new AttributesFactory();
-    PartitionAttributesFactory paf = new PartitionAttributesFactory();
-    paf.setRedundantCopies(0);
-    paf.setLocalMaxMemory(0); // make it an accessor
-    factory.setPartitionAttributes(paf.create());
-    final Region r = createRootRegion("bug38013", factory.create());
-
-    doCreateOtherVm();
-
-    r.put("key1", new HomeBoy());
-
-    assertTrue(r.get("key1") instanceof HomeBoy);
-  }
-
-  public static class HomeBoy implements DataSerializable {
-    public HomeBoy() {}
-
-    public void toData(DataOutput out) throws IOException {
-      DistributedMember me = InternalDistributedSystem.getAnyInstance().getDistributedMember();
-      DataSerializer.writeObject(me, out);
-    }
-
-    public void fromData(DataInput in) throws IOException, ClassNotFoundException {
-      DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
-      DistributedMember me = ds.getDistributedMember();
-      DistributedMember hb = (DistributedMember) DataSerializer.readObject(in);
-      if (me.equals(hb)) {
-        ds.getLogWriter().info("HomeBoy was deserialized on his home");
-      } else {
-        String msg = "HomeBoy was deserialized on " + me + " instead of his home " + hb;
-        ds.getLogWriter().error(msg);
-        throw new IllegalStateException(msg);
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/cache30/CreateAndLocalDestroyInTXRegressionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/CreateAndLocalDestroyInTXRegressionTest.java b/geode-core/src/test/java/org/apache/geode/cache30/CreateAndLocalDestroyInTXRegressionTest.java
new file mode 100644
index 0000000..a3fba22
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/cache30/CreateAndLocalDestroyInTXRegressionTest.java
@@ -0,0 +1,167 @@
+/*
+ * 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.cache30;
+
+import static org.apache.geode.internal.i18n.LocalizedStrings.TXStateStub_LOCAL_DESTROY_NOT_ALLOWED_IN_TRANSACTION;
+import static org.apache.geode.internal.i18n.LocalizedStrings.TXStateStub_LOCAL_INVALIDATE_NOT_ALLOWED_IN_TRANSACTION;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.CacheException;
+import org.apache.geode.cache.CacheListener;
+import org.apache.geode.cache.CacheTransactionManager;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.EntryEvent;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.UnsupportedOperationInTransactionException;
+import org.apache.geode.cache.util.CacheListenerAdapter;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.rules.serializable.SerializableErrorCollector;
+
+/**
+ * Test create + localDestroy for bug 34387
+ *
+ * <p>
+ * TRAC #34387: TX in Proxy Regions with create followed by localDestroy on same key results in
+ * remote VMs receiving create events with null getNewValue().
+ *
+ * <p>
+ * Create and LocalDestroy/LocalInvalidate should create event with NewValue
+ *
+ * @since GemFire 5.0
+ */
+@Category(DistributedTest.class)
+public class CreateAndLocalDestroyInTXRegressionTest extends CacheTestCase {
+
+  private static final String REGION_NAME = "r1";
+
+  private int invokeCount;
+  private VM otherVM;
+  private transient Region region;
+
+  @Rule
+  public SerializableErrorCollector errorCollector = new SerializableErrorCollector();
+
+  @Before
+  public void setUp() throws Exception {
+    this.invokeCount = 0;
+    this.otherVM = Host.getHost(0).getVM(0);
+
+    initOtherVM(this.otherVM);
+    AttributesFactory af = new AttributesFactory();
+    af.setDataPolicy(DataPolicy.REPLICATE);
+    af.setScope(Scope.DISTRIBUTED_ACK);
+    af.setConcurrencyChecksEnabled(true);
+
+    CacheListener cl1 = new CacheListenerAdapter() {
+      @Override
+      public void afterCreate(EntryEvent e) {
+        errorCollector.checkThat("Keys not equal", "createKey", equalTo(e.getKey()));
+        errorCollector.checkThat("Values not equal", "createValue", equalTo(e.getNewValue()));
+        CreateAndLocalDestroyInTXRegressionTest.this.invokeCount++;
+      }
+    };
+
+    af.addCacheListener(cl1);
+    this.region = createRootRegion(REGION_NAME, af.create());
+
+    assertNull(this.region.getEntry("createKey"));
+  }
+
+  /**
+   * test create followed by localDestroy
+   */
+  @Test
+  public void createAndLocalDestroyShouldCreateEventWithNewValue() throws CacheException {
+    doCommitInOtherVm(otherVM, true);
+
+    assertNotNull(this.region.getEntry("createKey"));
+    assertEquals("createValue", this.region.getEntry("createKey").getValue());
+    assertEquals(1, this.invokeCount);
+  }
+
+  /**
+   * test create followed by localInvalidate
+   */
+  @Test
+  public void createAndLocalInvalidateShouldCreateEventWithNewValue() throws CacheException {
+    doCommitInOtherVm(this.otherVM, false);
+
+    assertNotNull(this.region.getEntry("createKey"));
+    assertEquals("createValue", this.region.getEntry("createKey").getValue());
+    assertEquals(1, this.invokeCount);
+  }
+
+  private void initOtherVM(VM otherVM) {
+    otherVM.invoke(new CacheSerializableRunnable("Connect") {
+      @Override
+      public void run2() throws CacheException {
+        getCache();
+      }
+    });
+  }
+
+  private void doCommitInOtherVm(VM otherVM, boolean doDestroy) {
+    otherVM.invoke(new CacheSerializableRunnable("create root") {
+      @Override
+      public void run2() throws CacheException {
+        AttributesFactory factory = new AttributesFactory();
+        factory.setScope(Scope.DISTRIBUTED_ACK);
+        factory.setConcurrencyChecksEnabled(true);
+
+        Region region = createRootRegion(REGION_NAME, factory.create());
+
+        CacheTransactionManager transactionManager = getCache().getCacheTransactionManager();
+        transactionManager.begin();
+
+        region.create("createKey", "createValue");
+
+        if (doDestroy) {
+          try {
+            region.localDestroy("createKey");
+            fail("expected exception not thrown");
+          } catch (UnsupportedOperationInTransactionException e) {
+            assertEquals(TXStateStub_LOCAL_DESTROY_NOT_ALLOWED_IN_TRANSACTION.toLocalizedString(),
+                e.getMessage());
+          }
+        } else {
+          try {
+            region.localInvalidate("createKey");
+            fail("expected exception not thrown");
+          } catch (UnsupportedOperationInTransactionException e) {
+            assertEquals(
+                TXStateStub_LOCAL_INVALIDATE_NOT_ALLOWED_IN_TRANSACTION.toLocalizedString(),
+                e.getMessage());
+          }
+        }
+
+        transactionManager.commit();
+      }
+    });
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/cache30/EntriesDoNotExpireDuringGIIRegressionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/EntriesDoNotExpireDuringGIIRegressionTest.java b/geode-core/src/test/java/org/apache/geode/cache30/EntriesDoNotExpireDuringGIIRegressionTest.java
new file mode 100644
index 0000000..d2189fa
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/cache30/EntriesDoNotExpireDuringGIIRegressionTest.java
@@ -0,0 +1,210 @@
+/*
+ * 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.cache30;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.core.Is.is;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.awaitility.Awaitility;
+import org.awaitility.core.ConditionFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.CacheException;
+import org.apache.geode.cache.CacheListener;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.EntryEvent;
+import org.apache.geode.cache.ExpirationAction;
+import org.apache.geode.cache.ExpirationAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionEvent;
+import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.util.CacheListenerAdapter;
+import org.apache.geode.internal.cache.CacheDistributionAdvisor;
+import org.apache.geode.internal.cache.DistributedRegion;
+import org.apache.geode.internal.cache.InitialImageOperation;
+import org.apache.geode.internal.cache.LocalRegion;
+import org.apache.geode.test.dunit.AsyncInvocation;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.rules.serializable.SerializableErrorCollector;
+
+/**
+ * Make sure entry expiration does not happen during gii for bug 35214
+ *
+ * <p>
+ * TRAC #35214: hang during getInitialImage due to entry expiration
+ *
+ * <p>
+ * Entries should not expire during GII
+ *
+ * @since GemFire 5.0
+ */
+@Category(DistributedTest.class)
+public class EntriesDoNotExpireDuringGIIRegressionTest extends CacheTestCase {
+
+  private static final int ENTRY_COUNT = 100;
+  private static final String REGION_NAME = "r1";
+
+  // TODO: value of expirationCount is not validated
+  private AtomicInteger expirationCount;
+  private AtomicBoolean afterRegionCreateInvoked;
+  private VM otherVM;
+
+  @Rule
+  public DistributedRestoreSystemProperties restoreSystemProperties =
+      new DistributedRestoreSystemProperties();
+
+  @Rule
+  public SerializableErrorCollector errorCollector = new SerializableErrorCollector();
+
+  @Before
+  public void setUp() throws Exception {
+    this.expirationCount = new AtomicInteger(0);
+    this.afterRegionCreateInvoked = new AtomicBoolean(false);
+    this.otherVM = Host.getHost(0).getVM(0);
+    initOtherVm(this.otherVM);
+
+    System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true");
+    InitialImageOperation.slowImageProcessing = 30;
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    InitialImageOperation.slowImageProcessing = 0;
+  }
+
+  /**
+   * make sure entries do not expire during a GII
+   */
+  @Test
+  public void entriesShouldNotExpireDuringGII() throws Exception {
+    AsyncInvocation updater = updateOtherVm(this.otherVM);
+
+    AttributesFactory factory = new AttributesFactory();
+    factory.setDataPolicy(DataPolicy.REPLICATE);
+    factory.setScope(Scope.DISTRIBUTED_ACK);
+    factory.setStatisticsEnabled(true);
+    factory.setEntryIdleTimeout(new ExpirationAttributes(1, ExpirationAction.INVALIDATE));
+    factory.addCacheListener(createCacheListener());
+
+    Region region = createRootRegion(REGION_NAME, factory.create());
+
+    updater.await();
+
+    await().until(() -> region.values().size() == 0);
+
+    assertThat(region.values().size()).isEqualTo(0);
+    assertThat(region.keySet().size()).isEqualTo(ENTRY_COUNT);
+  }
+
+  private void initOtherVm(final VM otherVM) {
+    otherVM.invoke(new CacheSerializableRunnable("init") {
+
+      @Override
+      public void run2() throws CacheException {
+        getCache();
+
+        AttributesFactory factory = new AttributesFactory();
+        factory.setScope(Scope.DISTRIBUTED_ACK);
+
+        Region region = createRootRegion(REGION_NAME, factory.create());
+
+        for (int i = 1; i <= ENTRY_COUNT; i++) {
+          region.put("key" + i, "value" + i);
+        }
+      }
+    });
+  }
+
+  private AsyncInvocation updateOtherVm(final VM otherVM) {
+    return otherVM.invokeAsync(new CacheSerializableRunnable("update") {
+
+      @Override
+      public void run2() throws CacheException {
+        Region region = getRootRegion(REGION_NAME);
+        // let the main guys gii get started; we want to do updates during his gii
+
+        // wait for profile of getInitialImage cache to show up
+        CacheDistributionAdvisor advisor =
+            ((DistributedRegion) region).getCacheDistributionAdvisor();
+        int expectedProfiles = 1;
+        await().until(
+            () -> assertThat(numberProfiles(advisor)).isGreaterThanOrEqualTo(expectedProfiles));
+
+        // start doing updates of the keys to see if we can get deadlocked
+        int updateCount = 1;
+        do {
+          for (int i = 1; i <= ENTRY_COUNT; i++) {
+            String key = "key" + i;
+            if (region.containsKey(key)) {
+              region.destroy(key);
+            } else {
+              region.put(key, "value" + i + "uc" + updateCount);
+            }
+          }
+        } while (updateCount++ < 20);
+
+        // do one more loop with no destroys
+        for (int i = 1; i <= ENTRY_COUNT; i++) {
+          String key = "key" + i;
+          if (!region.containsKey(key)) {
+            region.put(key, "value" + i + "uc" + updateCount);
+          }
+        }
+      }
+    });
+  }
+
+  private int numberProfiles(final CacheDistributionAdvisor advisor) {
+    return advisor.adviseInitialImage(null).getReplicates().size();
+  }
+
+  private CacheListener createCacheListener() {
+    return new CacheListenerAdapter() {
+
+      @Override
+      public void afterRegionCreate(final RegionEvent event) {
+        afterRegionCreateInvoked.set(true);
+      }
+
+      @Override
+      public void afterInvalidate(final EntryEvent event) {
+        errorCollector.checkThat("afterRegionCreate should have been seen",
+            afterRegionCreateInvoked.get(), is(true));
+        errorCollector.checkThat("Region should have been initialized",
+            ((LocalRegion) event.getRegion()).isInitialized(), is(true));
+
+        expirationCount.incrementAndGet();
+
+        InitialImageOperation.slowImageProcessing = 0;
+      }
+    };
+  }
+
+  private ConditionFactory await() {
+    return Awaitility.await().atMost(2, MINUTES);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/cache30/RemotePRValuesAreNotDeserializedRegressionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/RemotePRValuesAreNotDeserializedRegressionTest.java b/geode-core/src/test/java/org/apache/geode/cache30/RemotePRValuesAreNotDeserializedRegressionTest.java
new file mode 100644
index 0000000..3c5ad4b
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/cache30/RemotePRValuesAreNotDeserializedRegressionTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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.cache30;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.DataSerializable;
+import org.apache.geode.DataSerializer;
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.CacheException;
+import org.apache.geode.cache.CacheListener;
+import org.apache.geode.cache.EntryEvent;
+import org.apache.geode.cache.PartitionAttributesFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.util.CacheListenerAdapter;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+
+/**
+ * Test to make sure PR cache values are lazily deserialized
+ *
+ * <p>
+ * TRAC #38013: PR regions do deserialization on remote bucket during get causing
+ * NoClassDefFoundError
+ *
+ * <p>
+ * Remote PartitionedRegion values should not be deserialized
+ *
+ * @since GemFire 5.0
+ */
+@Category(DistributedTest.class)
+public class RemotePRValuesAreNotDeserializedRegressionTest extends CacheTestCase {
+
+  private static final String REGION_NAME = "bug38013";
+
+  // TODO: value of lastCallback is not validated
+  private static Object lastCallback = null;
+
+  private VM otherVM;
+
+  @Before
+  public void setUp() throws Exception {
+    this.otherVM = Host.getHost(0).getVM(0);
+  }
+
+  /**
+   * Make sure that value is only deserialized in cache whose application asks for the value.
+   */
+  @Test
+  public void remotePRValuesShouldNotBeDeserialized() throws Exception {
+    PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory();
+    partitionAttributesFactory.setRedundantCopies(0);
+    partitionAttributesFactory.setLocalMaxMemory(0); // make it an accessor
+
+    AttributesFactory factory = new AttributesFactory();
+    factory.setPartitionAttributes(partitionAttributesFactory.create());
+
+    Region<String, HomeBoy> region = createRootRegion(REGION_NAME, factory.create());
+
+    doCreateOtherVm(this.otherVM);
+
+    region.put("key1", new HomeBoy());
+
+    assertTrue(region.get("key1") instanceof HomeBoy);
+  }
+
+  private void doCreateOtherVm(final VM otherVM) {
+    otherVM.invoke(new CacheSerializableRunnable("create root") {
+
+      @Override
+      public void run2() throws CacheException {
+        getSystem();
+
+        CacheListener listener = new CacheListenerAdapter() {
+          @Override
+          public void afterCreate(final EntryEvent event) {
+            if (event.getCallbackArgument() != null) {
+              lastCallback = event.getCallbackArgument();
+            }
+          }
+
+          @Override
+          public void afterUpdate(final EntryEvent event) {
+            if (event.getCallbackArgument() != null) {
+              lastCallback = event.getCallbackArgument();
+            }
+          }
+
+          @Override
+          public void afterInvalidate(final EntryEvent event) {
+            if (event.getCallbackArgument() != null) {
+              lastCallback = event.getCallbackArgument();
+            }
+          }
+
+          @Override
+          public void afterDestroy(final EntryEvent event) {
+            if (event.getCallbackArgument() != null) {
+              lastCallback = event.getCallbackArgument();
+            }
+          }
+        };
+
+        AttributesFactory factory = new AttributesFactory();
+        factory.setCacheListener(listener);
+
+        // create a pr with a data store
+        PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory();
+        partitionAttributesFactory.setRedundantCopies(0);
+
+        // use defaults so this is a data store
+        factory.setPartitionAttributes(partitionAttributesFactory.create());
+        createRootRegion(REGION_NAME, factory.create());
+      }
+    });
+  }
+
+  private static class HomeBoy implements DataSerializable {
+
+    public HomeBoy() {
+      // nothing
+    }
+
+    @Override
+    public void toData(final DataOutput out) throws IOException {
+      DistributedMember me = InternalDistributedSystem.getAnyInstance().getDistributedMember();
+      DataSerializer.writeObject(me, out);
+    }
+
+    @Override
+    public void fromData(final DataInput in) throws IOException, ClassNotFoundException {
+      DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
+      DistributedMember me = ds.getDistributedMember();
+      DistributedMember hb = DataSerializer.readObject(in);
+      if (me.equals(hb)) {
+        ds.getLogWriter().info("HomeBoy was deserialized on his home");
+      } else {
+        String msg = "HomeBoy was deserialized on " + me + " instead of his home " + hb;
+        ds.getLogWriter().error(msg);
+        throw new IllegalStateException(msg);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/cache30/ValuesAreLazilyDeserializedRegressionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/ValuesAreLazilyDeserializedRegressionTest.java b/geode-core/src/test/java/org/apache/geode/cache30/ValuesAreLazilyDeserializedRegressionTest.java
new file mode 100644
index 0000000..d40c960
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/cache30/ValuesAreLazilyDeserializedRegressionTest.java
@@ -0,0 +1,169 @@
+/*
+ * 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.cache30;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.DataSerializable;
+import org.apache.geode.DataSerializer;
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.CacheException;
+import org.apache.geode.cache.CacheListener;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.EntryEvent;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.util.CacheListenerAdapter;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+
+/**
+ * Test to make sure cache values are lazily deserialized
+ *
+ * <p>
+ * TRAC #34948: distributed cache values are always getting deserialized
+ *
+ * @since GemFire 5.0
+ */
+@Category(DistributedTest.class)
+public class ValuesAreLazilyDeserializedRegressionTest extends CacheTestCase {
+
+  private static final String REGION_NAME = "bug34948";
+
+  // TODO: value of lastCallback is not validated
+  private static Object lastCallback = null;
+
+  private VM otherVM;
+
+  @Before
+  public void setUp() throws Exception {
+    this.otherVM = Host.getHost(0).getVM(0);
+  }
+
+  /**
+   * Make sure that value is only deserialized in cache whose application asks for the value.
+   */
+  @Test
+  public void valueShouldBeLazilyDeserialized() throws Exception {
+    AttributesFactory factory = new AttributesFactory();
+    factory.setScope(Scope.DISTRIBUTED_ACK);
+    factory.setDataPolicy(DataPolicy.PRELOADED);
+
+    Region<String, HomeBoy> region = createRootRegion(REGION_NAME, factory.create());
+
+    // before gii
+    region.put("key1", new HomeBoy());
+
+    doCreateOtherVm(this.otherVM);
+
+    // after gii
+    region.put("key2", new HomeBoy());
+
+    region.localDestroy("key1");
+    region.localDestroy("key2");
+
+    Object value = region.get("key1");
+    assertTrue(region.get("key1") instanceof HomeBoy);
+    assertTrue(region.get("key2") == null); // preload will not distribute
+
+    // TODO: add putAll test once it does not deserialize
+  }
+
+  private void doCreateOtherVm(final VM otherVM) {
+    otherVM.invoke(new CacheSerializableRunnable("create root") {
+
+      @Override
+      public void run2() throws CacheException {
+        getSystem();
+
+        CacheListener<String, HomeBoy> listener = new CacheListenerAdapter<String, HomeBoy>() {
+          @Override
+          public void afterCreate(final EntryEvent event) {
+            if (event.getCallbackArgument() != null) {
+              lastCallback = event.getCallbackArgument();
+            }
+          }
+
+          @Override
+          public void afterUpdate(final EntryEvent event) {
+            if (event.getCallbackArgument() != null) {
+              lastCallback = event.getCallbackArgument();
+            }
+          }
+
+          @Override
+          public void afterInvalidate(final EntryEvent event) {
+            if (event.getCallbackArgument() != null) {
+              lastCallback = event.getCallbackArgument();
+            }
+          }
+
+          @Override
+          public void afterDestroy(final EntryEvent event) {
+            if (event.getCallbackArgument() != null) {
+              lastCallback = event.getCallbackArgument();
+            }
+          }
+        };
+
+        AttributesFactory<String, HomeBoy> factory = new AttributesFactory<>();
+        factory.setScope(Scope.DISTRIBUTED_ACK);
+        factory.setDataPolicy(DataPolicy.PRELOADED);
+        factory.setCacheListener(listener);
+
+        createRootRegion(REGION_NAME, factory.create());
+      }
+    });
+  }
+
+  private static class HomeBoy implements DataSerializable {
+
+    public HomeBoy() {
+      // nothing
+    }
+
+    @Override
+    public void toData(final DataOutput out) throws IOException {
+      DistributedMember me = InternalDistributedSystem.getAnyInstance().getDistributedMember();
+      DataSerializer.writeObject(me, out);
+    }
+
+    @Override
+    public void fromData(final DataInput in) throws IOException, ClassNotFoundException {
+      DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
+      DistributedMember me = ds.getDistributedMember();
+      DistributedMember hb = DataSerializer.readObject(in);
+      if (me.equals(hb)) {
+        ds.getLogWriter().info("HomeBoy was deserialized on his home");
+      } else {
+        String msg = "HomeBoy was deserialized on " + me + " instead of his home " + hb;
+        ds.getLogWriter().error(msg);
+        throw new IllegalStateException(msg);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/internal/cache/ConnectDisconnectDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ConnectDisconnectDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/ConnectDisconnectDUnitTest.java
index de63433..b52fe4d 100755
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/ConnectDisconnectDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ConnectDisconnectDUnitTest.java
@@ -14,105 +14,87 @@
  */
 package org.apache.geode.internal.cache;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
-import java.util.Properties;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import static org.apache.geode.distributed.ConfigurationProperties.CONSERVE_SOCKETS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.test.dunit.AsyncInvocation;
-import org.apache.geode.test.dunit.DistributedTestUtils;
 import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.IgnoredException;
-import org.apache.geode.test.dunit.LogWriterUtils;
 import org.apache.geode.test.dunit.SerializableRunnable;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
+import org.apache.geode.test.junit.Repeat;
 import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.rules.RepeatRule;
+import org.apache.logging.log4j.Logger;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.Properties;
 
-/** A test of 46438 - missing response to an update attributes message */
+/**
+ * A test of 46438 - missing response to an update attributes message
+ *
+ * see bugs #50785 and #46438
+ */
 @Category(DistributedTest.class)
 public class ConnectDisconnectDUnitTest extends JUnit4CacheTestCase {
+  private static final Logger logger = LogService.getLogger();
 
-  private IgnoredException ex;
+  private static int count;
 
-  // see bugs #50785 and #46438
-  @Test
-  public void testManyConnectsAndDisconnects() throws Throwable {
-    // invokeInEveryVM(new SerializableRunnable() {
-    //
-    // @Override
-    // public void run() {
-    // Log.setLogWriterLevel("info");
-    // }
-    // });
-
-    // uncomment these lines to use stand-alone locators
-    // int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(4);
-    // setLocatorPorts(ports);
-
-    for (int i = 0; i < 20; i++) {
-      LogWriterUtils.getLogWriter().info("Test run: " + i);
-      runOnce();
-      tearDown();
-      setUp();
-    }
+  @Rule
+  public RepeatRule repeat = new RepeatRule();
+
+  @BeforeClass
+  public static void beforeClass() {
+    count = 0;
   }
 
+  @Before
+  public void before() {
+    count++;
+  }
 
-  static int LOCATOR_PORT;
-  static String LOCATORS_STRING;
+  @After
+  public void after() {
+    disconnectAllFromDS();
 
-  static int[] locatorPorts;
+  }
 
-  public void setLocatorPorts(int[] ports) {
-    DistributedTestUtils.deleteLocatorStateFile(ports);
-    String locators = "";
-    for (int i = 0; i < ports.length; i++) {
-      if (i > 0) {
-        locators += ",";
-      }
-      locators += "localhost[" + ports[i] + "]";
-    }
-    final String locators_string = locators;
-    for (int i = 0; i < ports.length; i++) {
-      final int port = ports[i];
-      Host.getHost(0).getVM(i).invoke(new SerializableRunnable("set locator port") {
-        public void run() {
-          LOCATOR_PORT = port;
-          LOCATORS_STRING = locators_string;
-        }
-      });
-    }
-    locatorPorts = ports;
+  @AfterClass
+  public static void afterClass() {
+    assertThat(count).isEqualTo(20);
   }
 
   @Override
-  public final void postTearDownCacheTestCase() throws Exception {
-    if (locatorPorts != null) {
-      DistributedTestUtils.deleteLocatorStateFile(locatorPorts);
-    }
+  public Properties getDistributedSystemProperties() {
+    Properties props = super.getDistributedSystemProperties();
+    props.setProperty(LOG_LEVEL, "info");
+    props.setProperty(CONSERVE_SOCKETS, "false");
+    return props;
   }
 
   /**
    * This test creates 4 vms and starts a cache in each VM. If that doesn't hang, it destroys the DS
    * in all vms and recreates the cache.
-   * 
-   * @throws Throwable
    */
-  public void runOnce() throws Throwable {
+  @Test
+  @Repeat(20)
+  public void testManyConnectsAndDisconnects() throws Exception {
+    logger.info("Test run: {}", count);
 
     int numVMs = 4;
-
     VM[] vms = new VM[numVMs];
 
     for (int i = 0; i < numVMs; i++) {
-      // if(i == 0) {
-      // vms[i] = Host.getHost(0).getVM(4);
-      // } else {
       vms[i] = Host.getHost(0).getVM(i);
-      // }
     }
 
     AsyncInvocation[] asyncs = new AsyncInvocation[numVMs];
@@ -120,44 +102,14 @@ public class ConnectDisconnectDUnitTest extends JUnit4CacheTestCase {
       asyncs[i] = vms[i].invokeAsync(new SerializableRunnable("Create a cache") {
         @Override
         public void run() {
-          // try {
-          // JGroupMembershipManager.setDebugJGroups(true);
           getCache();
-          // } finally {
-          // JGroupMembershipManager.setDebugJGroups(false);
-          // }
         }
       });
     }
 
-
     for (int i = 0; i < numVMs; i++) {
-      asyncs[i].getResult();
-      // try {
-      // asyncs[i].getResult(30 * 1000);
-      // } catch(TimeoutException e) {
-      // getLogWriter().severe("DAN DEBUG - we have a hang");
-      // dumpAllStacks();
-      // fail("DAN - WE HIT THE ISSUE",e);
-      // throw e;
-      // }
-    }
-
-    disconnectAllFromDS();
-  }
-
-
-  @Override
-  public Properties getDistributedSystemProperties() {
-    Properties props = super.getDistributedSystemProperties();
-    props.setProperty(LOG_LEVEL, "info");
-    props.setProperty(CONSERVE_SOCKETS, "false");
-    if (LOCATOR_PORT > 0) {
-      props.setProperty(START_LOCATOR, "localhost[" + LOCATOR_PORT + "]");
-      props.setProperty(LOCATORS, LOCATORS_STRING);
+      asyncs[i].await();
     }
-    return props;
   }
 
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/CacheTestFixture.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/CacheTestFixture.java b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/CacheTestFixture.java
index b785434..053604d 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/CacheTestFixture.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/CacheTestFixture.java
@@ -28,7 +28,7 @@ public interface CacheTestFixture extends DistributedTestFixture {
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void preTearDownCacheTestCase() throws Exception;
+  void preTearDownCacheTestCase() throws Exception;
 
   /**
    * {@code postTearDownCacheTestCase()} is invoked after
@@ -37,6 +37,6 @@ public interface CacheTestFixture extends DistributedTestFixture {
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void postTearDownCacheTestCase() throws Exception;
+  void postTearDownCacheTestCase() throws Exception;
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit3CacheTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit3CacheTestCase.java b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit3CacheTestCase.java
index 73d4042..012cec2 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit3CacheTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit3CacheTestCase.java
@@ -26,7 +26,6 @@ import org.apache.geode.cache.RegionExistsException;
 import org.apache.geode.cache.TimeoutException;
 import org.apache.geode.cache.client.ClientCache;
 import org.apache.geode.cache.client.ClientCacheFactory;
-import org.apache.geode.cache.client.internal.InternalClientCache;
 import org.apache.geode.cache30.CacheSerializableRunnable;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.InternalCache;
@@ -143,10 +142,14 @@ public abstract class JUnit3CacheTestCase extends JUnit3DistributedTestCase
   }
 
   @Override
-  public void preTearDownCacheTestCase() throws Exception {}
+  public void preTearDownCacheTestCase() throws Exception {
+    // nothing
+  }
 
   @Override
-  public void postTearDownCacheTestCase() throws Exception {}
+  public void postTearDownCacheTestCase() throws Exception {
+    // nothing
+  }
 
   /**
    * Local destroy all root regions and close the cache.

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
index 8a63126..bc6136f 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
@@ -14,6 +14,8 @@
  */
 package org.apache.geode.test.dunit.cache.internal;
 
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -39,7 +41,6 @@ import org.apache.geode.cache.TimeoutException;
 import org.apache.geode.cache.client.ClientCache;
 import org.apache.geode.cache.client.ClientCacheFactory;
 import org.apache.geode.cache.client.PoolManager;
-import org.apache.geode.cache.client.internal.InternalClientCache;
 import org.apache.geode.cache30.CacheSerializableRunnable;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.DistributionMessageObserver;
@@ -59,13 +60,9 @@ import org.apache.geode.test.dunit.Wait;
 import org.apache.geode.test.dunit.WaitCriterion;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-
 /**
  * This class is the base class for all distributed tests using JUnit 4 that require the creation of
  * a {@link Cache}.
- *
- * TODO: make this class abstract when JUnit3CacheTestCase is deleted
  */
 public abstract class JUnit4CacheTestCase extends JUnit4DistributedTestCase
     implements CacheTestFixture {

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/test/dunit/internal/DistributedTestFixture.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/internal/DistributedTestFixture.java b/geode-core/src/test/java/org/apache/geode/test/dunit/internal/DistributedTestFixture.java
index 4175e81..b372696 100755
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/internal/DistributedTestFixture.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/internal/DistributedTestFixture.java
@@ -28,7 +28,7 @@ public interface DistributedTestFixture extends Serializable {
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void preSetUp() throws Exception;
+  void preSetUp() throws Exception;
 
   /**
    * {@code postSetUp()} is invoked after {@code DistributedTestCase#setUp()}.
@@ -36,7 +36,7 @@ public interface DistributedTestFixture extends Serializable {
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void postSetUp() throws Exception;
+  void postSetUp() throws Exception;
 
   /**
    * {@code preTearDown()} is invoked before {@code DistributedTestCase#tearDown()}.
@@ -44,7 +44,7 @@ public interface DistributedTestFixture extends Serializable {
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void preTearDown() throws Exception;
+  void preTearDown() throws Exception;
 
   /**
    * {@code postTearDown()} is invoked after {@code DistributedTestCase#tearDown()}.
@@ -52,7 +52,7 @@ public interface DistributedTestFixture extends Serializable {
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void postTearDown() throws Exception;
+  void postTearDown() throws Exception;
 
   /**
    * {@code preTearDownAssertions()} is invoked before any tear down methods have been invoked. If
@@ -61,7 +61,7 @@ public interface DistributedTestFixture extends Serializable {
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void preTearDownAssertions() throws Exception;
+  void preTearDownAssertions() throws Exception;
 
   /**
    * {@code postTearDownAssertions()} is invoked after all tear down methods have completed. This
@@ -70,7 +70,7 @@ public interface DistributedTestFixture extends Serializable {
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void postTearDownAssertions() throws Exception;
+  void postTearDownAssertions() throws Exception;
 
   /**
    * Returns the {@code Properties} used to define the {@code DistributedSystem}.
@@ -79,11 +79,11 @@ public interface DistributedTestFixture extends Serializable {
    * Override this as needed. This method is called by various {@code getSystem} methods in
    * {@code DistributedTestCase}.
    */
-  public Properties getDistributedSystemProperties();
+  Properties getDistributedSystemProperties();
 
   /**
    * Returns the {@code name} of the test method being executed.
    */
-  public String getName();
+  String getName();
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/2924ef1d/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit3DistributedTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit3DistributedTestCase.java b/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit3DistributedTestCase.java
index abdac89..107aa8b 100755
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit3DistributedTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit3DistributedTestCase.java
@@ -18,13 +18,10 @@ import java.io.Serializable;
 import java.util.Properties;
 
 import junit.framework.TestCase;
-import org.apache.logging.log4j.Logger;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.cache.Cache;
 import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.test.junit.categories.DistributedTest;
 
 /**
@@ -34,8 +31,6 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 public abstract class JUnit3DistributedTestCase extends TestCase
     implements DistributedTestFixture, Serializable {
 
-  private static final Logger logger = LogService.getLogger();
-
   private final JUnit4DistributedTestCase delegate = new JUnit4DistributedTestCase(this) {};
 
   /**
@@ -47,19 +42,12 @@ public abstract class JUnit3DistributedTestCase extends TestCase
     JUnit4DistributedTestCase.initializeDistributedTestCase();
   }
 
-  // ---------------------------------------------------------------------------
-  // methods for tests
-  // ---------------------------------------------------------------------------
-
   /**
    * @deprecated Please override {@link #getDistributedSystemProperties()} instead.
    */
   @Deprecated
-  public final void setSystem(final Properties props, final DistributedSystem ds) { // TODO:
-                                                                                    // override
-                                                                                    // getDistributedSystemProperties
-                                                                                    // and then
-                                                                                    // delete
+  public final void setSystem(final Properties props, final DistributedSystem ds) {
+    // TODO: override getDistributedSystemProperties and then delete
     delegate.setSystem(props, ds);
   }
 
@@ -100,10 +88,6 @@ public abstract class JUnit3DistributedTestCase extends TestCase
     return delegate.basicGetSystem();
   }
 
-  public final void nullSystem() { // TODO: delete
-    delegate.nullSystem();
-  }
-
   public static final InternalDistributedSystem getSystemStatic() {
     return JUnit4DistributedTestCase.getSystemStatic();
   }
@@ -146,10 +130,6 @@ public abstract class JUnit3DistributedTestCase extends TestCase
     JUnit4DistributedTestCase.disconnectFromDS();
   }
 
-  // ---------------------------------------------------------------------------
-  // name methods
-  // ---------------------------------------------------------------------------
-
   public static final String getTestMethodName() {
     return JUnit4DistributedTestCase.getTestMethodName();
   }
@@ -162,10 +142,6 @@ public abstract class JUnit3DistributedTestCase extends TestCase
     return delegate.getUniqueName();
   }
 
-  // ---------------------------------------------------------------------------
-  // setup methods
-  // ---------------------------------------------------------------------------
-
   /**
    * Sets up the DistributedTestCase.
    * <p>
@@ -174,30 +150,30 @@ public abstract class JUnit3DistributedTestCase extends TestCase
    */
   @Override
   public final void setUp() throws Exception {
-    delegate.setUp();
+    delegate.setUpDistributedTestCase();
   }
 
   /**
    * {@code preSetUp()} is invoked before
-   * {@link JUnit4DistributedTestCase#setUpDistributedTestCase()}.
+   * {@link JUnit4DistributedTestCase#doSetUpDistributedTestCase()}.
    *
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void preSetUp() throws Exception {}
+  public void preSetUp() throws Exception {
+    // nothing by default
+  }
 
   /**
    * {@code postSetUp()} is invoked after
-   * {@link JUnit4DistributedTestCase#setUpDistributedTestCase()}.
+   * {@link JUnit4DistributedTestCase#doSetUpDistributedTestCase()}.
    *
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void postSetUp() throws Exception {}
-
-  // ---------------------------------------------------------------------------
-  // teardown methods
-  // ---------------------------------------------------------------------------
+  public void postSetUp() throws Exception {
+    // nothing by default
+  }
 
   /**
    * Tears down the DistributedTestCase.
@@ -209,26 +185,30 @@ public abstract class JUnit3DistributedTestCase extends TestCase
    */
   @Override
   public final void tearDown() throws Exception {
-    delegate.tearDown();
+    delegate.tearDownDistributedTestCase();
   }
 
   /**
    * {@code preTearDown()} is invoked before
-   * {@link JUnit4DistributedTestCase#tearDownDistributedTestCase()}.
+   * {@link JUnit4DistributedTestCase#doTearDownDistributedTestCase()}.
    *
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void preTearDown() throws Exception {}
+  public void preTearDown() throws Exception {
+    // nothing by default
+  }
 
   /**
    * {@code postTearDown()} is invoked after
-   * {@link JUnit4DistributedTestCase#tearDownDistributedTestCase()}.
+   * {@link JUnit4DistributedTestCase#doTearDownDistributedTestCase()}.
    *
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void postTearDown() throws Exception {}
+  public void postTearDown() throws Exception {
+    // nothing by default
+  }
 
   /**
    * {@code preTearDownAssertions()} is invoked before any tear down methods have been invoked. If
@@ -237,7 +217,9 @@ public abstract class JUnit3DistributedTestCase extends TestCase
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void preTearDownAssertions() throws Exception {}
+  public void preTearDownAssertions() throws Exception {
+    // nothing by default
+  }
 
   /**
    * {@code postTearDownAssertions()} is invoked after all tear down methods have completed. This
@@ -246,10 +228,8 @@ public abstract class JUnit3DistributedTestCase extends TestCase
    * <p>
    * Override this as needed. Default implementation is empty.
    */
-  public void postTearDownAssertions() throws Exception {}
-
-  protected static final void destroyRegions(final Cache cache) { // TODO: this should move to
-                                                                  // CacheTestCase
-    JUnit4DistributedTestCase.destroyRegions(cache);
+  public void postTearDownAssertions() throws Exception {
+    // nothing by default
   }
+
 }

[13/14] geode git commit: GEODE-2859: Fix ShowDeadlockDUnitTest

Posted by ud...@apache.org.
GEODE-2859: Fix ShowDeadlockDUnitTest


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

Branch: refs/heads/feature/GEODE-3416
Commit: d11e1b9ee9a209e130263dcf40c898c1be9e855a
Parents: 68e8b7e
Author: Jared Stewart <js...@pivotal.io>
Authored: Fri Aug 18 14:36:40 2017 -0700
Committer: Jared Stewart <js...@pivotal.io>
Committed: Mon Aug 21 15:38:03 2017 -0700

----------------------------------------------------------------------
 .../cli/commands/ShowDeadlockDUnitTest.java     | 39 +++++++++++---------
 1 file changed, 22 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d11e1b9e/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java
index 8b5c80e..cd68350 100755
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java
@@ -18,6 +18,25 @@ import static org.apache.geode.test.dunit.Assert.assertEquals;
 import static org.apache.geode.test.dunit.Assert.assertTrue;
 import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.apache.commons.io.FileUtils;
+import org.awaitility.Awaitility;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.FunctionService;
@@ -36,23 +55,6 @@ import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
-import org.awaitility.Awaitility;
-import org.junit.After;
-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.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
 
 /**
  * This DUnit tests uses same code as GemFireDeadlockDetectorDUnitTest and uses the command
@@ -106,6 +108,7 @@ public class ShowDeadlockDUnitTest extends JUnit4CacheTestCase {
     assertEquals(null, detect.find().findCycle());
 
     File outputFile = new File(temporaryFolder.getRoot(), "dependency.txt");
+
     String showDeadlockCommand = new CommandStringBuilder(CliStrings.SHOW_DEADLOCK)
         .addOption(CliStrings.SHOW_DEADLOCK__DEPENDENCIES__FILE, outputFile.getName()).toString();
 
@@ -130,12 +133,14 @@ public class ShowDeadlockDUnitTest extends JUnit4CacheTestCase {
     lockTheLocks(vm1, member0);
 
     File outputFile = new File(temporaryFolder.getRoot(), "dependency.txt");
+
     String showDeadlockCommand = new CommandStringBuilder(CliStrings.SHOW_DEADLOCK)
         .addOption(CliStrings.SHOW_DEADLOCK__DEPENDENCIES__FILE, outputFile.getName()).toString();
     CommandStatement showDeadlocksCommand =
         new CommandProcessor().createCommandStatement(showDeadlockCommand, Collections.emptyMap());
 
     Awaitility.await().atMost(1, TimeUnit.MINUTES).until(() -> {
+      FileUtils.deleteQuietly(outputFile);
       Result result = showDeadlocksCommand.process();
       try {
         result.saveIncomingFiles(temporaryFolder.getRoot().getAbsolutePath());

[12/14] geode git commit: GEODE-3471: Identify NPE in MBeanProxyFactory

Posted by ud...@apache.org.
GEODE-3471: Identify NPE in MBeanProxyFactory


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

Branch: refs/heads/feature/GEODE-3416
Commit: 68e8b7e7ffe3d337f947f212c35b9a35305a8346
Parents: 6a7f362
Author: Jared Stewart <js...@pivotal.io>
Authored: Fri Aug 18 14:54:34 2017 -0700
Committer: Jared Stewart <js...@pivotal.io>
Committed: Mon Aug 21 15:33:55 2017 -0700

----------------------------------------------------------------------
 .../management/internal/MBeanProxyFactory.java      | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/68e8b7e7/geode-core/src/main/java/org/apache/geode/management/internal/MBeanProxyFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/MBeanProxyFactory.java b/geode-core/src/main/java/org/apache/geode/management/internal/MBeanProxyFactory.java
index 0cce0be..4f8366a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/MBeanProxyFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/MBeanProxyFactory.java
@@ -32,14 +32,12 @@ import org.apache.geode.management.ManagementException;
 
 /**
  * Instance of this class is responsible for proxy creation/deletion etc.
- * 
+ *
  * If a member is added/removed proxy factory is responsible for creating removing the corresponding
  * proxies for that member.
- * 
+ *
  * It also maintains a proxy repository {@link MBeanProxyInfoRepository} for quick access to the
  * proxy instances
- * 
- * 
  */
 public class MBeanProxyFactory {
   private static final Logger logger = LogService.getLogger();
@@ -80,10 +78,11 @@ public class MBeanProxyFactory {
       Region<String, Object> monitoringRegion, Object newVal) {
 
     try {
+      String name = objectName.toString();
+      FederationComponent federationComponent = (FederationComponent) monitoringRegion.get(name);
+      String interfaceClassName = federationComponent.getMBeanInterfaceClass();
 
-      Class interfaceClass = ClassLoadUtil
-          .classFromName(((FederationComponent) monitoringRegion.get(objectName.toString()))
-              .getMBeanInterfaceClass());
+      Class interfaceClass = ClassLoadUtil.classFromName(interfaceClassName);
 
       Object object = MBeanProxyInvocationHandler.newProxyInstance(member, monitoringRegion,
           objectName, interfaceClass);
@@ -112,7 +111,7 @@ public class MBeanProxyFactory {
   /**
    * This method will create all the proxies for a given DistributedMember. It does not throw any
    * exception to its caller. It handles the error and logs error messages
-   * 
+   *
    * It will be called from GII or when a member joins the system
    * 
    * @param member {@link org.apache.geode.distributed.DistributedMember}
@@ -234,7 +233,6 @@ public class MBeanProxyFactory {
    */
   public <T> T findProxy(ObjectName objectName, Class<T> interfaceClass) {
 
-
     return proxyRepo.findProxyByName(objectName, interfaceClass);
 
 

[14/14] geode git commit: GEODE-3416: Reduce synchronization blockages in SocketCloser. Remove synchronization blocks around HashMap. Replace that implementation with simpler ThreadPool that is not unbounded and does not grow as the number of remoteAddre

Posted by ud...@apache.org.
GEODE-3416: Reduce synchronization blockages in SocketCloser.
Remove synchronization blocks around HashMap. Replace that implementation
with simpler ThreadPool that is not unbounded and does not grow as the
number of remoteAddress (clients/peers) are added


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

Branch: refs/heads/feature/GEODE-3416
Commit: 26dcf43647117c1729cc7a7f010de2774785c183
Parents: d11e1b9
Author: Dave Barnes <db...@pivotal.io>
Authored: Thu Aug 10 17:11:50 2017 -0700
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Tue Aug 22 09:38:51 2017 -0700

----------------------------------------------------------------------
 .../cache/tier/sockets/CacheClientProxy.java    |  47 +-----
 .../apache/geode/internal/net/SocketCloser.java | 165 +++++++++++--------
 .../internal/net/SocketCloserJUnitTest.java     | 155 ++++++-----------
 3 files changed, 141 insertions(+), 226 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/26dcf436/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
index d7e3548..34f232d 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxy.java
@@ -181,11 +181,7 @@ public class CacheClientProxy implements ClientSession {
    * True if we are connected to a client.
    */
   private volatile boolean connected = false;
-  // /**
-  // * A string representing interest in all keys
-  // */
-  // protected static final String ALL_KEYS = "ALL_KEYS";
-  //
+
   /**
    * True if a marker message is still in the ha queue.
    */
@@ -459,47 +455,6 @@ public class CacheClientProxy implements ClientSession {
     return this.proxyID;
   }
 
-  // the following code was commented out simply because it was not used
-  // /**
-  // * Determines if the proxy represents the client host (and only the host, not
-  // * necessarily the exact VM running on the host)
-  // *
-  // * @return Whether the proxy represents the client host
-  // */
-  // protected boolean representsClientHost(String clientHost)
-  // {
-  // // [bruce] TODO BUGBUGBUG: this should compare InetAddresses, not Strings
-  // return this._remoteHostAddress.equals(clientHost);
-  // }
-
-  // protected boolean representsClientVM(DistributedMember remoteMember)
-  // {
-  // // logger.warn("Is input port " + clientPort + " contained in " +
-  // // logger.warn("Does input host " + clientHost + " equal " +
-  // // this._remoteHostAddress+ ": " + representsClientHost(clientHost));
-  // // logger.warn("representsClientVM: " +
-  // // (representsClientHost(clientHost) && containsPort(clientPort)));
-  // return (proxyID.getDistributedMember().equals(remoteMember));
-  // }
-
-  // /**
-  // * Determines if the CacheClientUpdater proxied by this instance is listening
-  // * on the input clientHost and clientPort
-  // *
-  // * @param clientHost
-  // * The host name of the client to compare
-  // * @param clientPort
-  // * The port number of the client to compare
-  // *
-  // * @return Whether the CacheClientUpdater proxied by this instance is
-  // * listening on the input clientHost and clientPort
-  // */
-  // protected boolean representsCacheClientUpdater(String clientHost,
-  // int clientPort)
-  // {
-  // return (clientPort == this._socket.getPort() && representsClientHost(clientHost));
-  // }
-
   protected boolean isMember(ClientProxyMembershipID memberId) {
     return this.proxyID.equals(memberId);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/26dcf436/geode-core/src/main/java/org/apache/geode/internal/net/SocketCloser.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/net/SocketCloser.java b/geode-core/src/main/java/org/apache/geode/internal/net/SocketCloser.java
index 6d86fd8..0a9a903 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/net/SocketCloser.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/net/SocketCloser.java
@@ -14,11 +14,17 @@
  */
 package org.apache.geode.internal.net;
 
+import org.apache.geode.SystemFailure;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.internal.logging.LoggingThreadGroup;
+import org.apache.logging.log4j.Logger;
+
 import java.io.IOException;
 import java.net.Socket;
-import java.util.HashMap;
-import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadFactory;
@@ -26,12 +32,6 @@ import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.apache.logging.log4j.Logger;
-
-import org.apache.geode.SystemFailure;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.internal.logging.LoggingThreadGroup;
-
 /**
  * This class allows sockets to be closed without blocking. In some cases we have seen a call of
  * socket.close block for minutes. This class maintains a thread pool for every other member we have
@@ -57,7 +57,7 @@ public class SocketCloser {
    * will queue up waiting for a thread.
    */
   static final int ASYNC_CLOSE_POOL_MAX_THREADS =
-      Integer.getInteger("p2p.ASYNC_CLOSE_POOL_MAX_THREADS", 8).intValue();
+      Integer.getInteger("p2p.ASYNC_CLOSE_POOL_MAX_THREADS", 4).intValue();
   /**
    * How many milliseconds the synchronous requester waits for the async close to happen. Default is
    * 0. Prior releases waited 50ms.
@@ -66,13 +66,16 @@ public class SocketCloser {
       Long.getLong("p2p.ASYNC_CLOSE_WAIT_MILLISECONDS", 0).longValue();
 
 
-  /** map of thread pools of async close threads */
-  private final HashMap<String, ThreadPoolExecutor> asyncCloseExecutors = new HashMap<>();
+  /**
+   * map of thread pools of async close threads
+   */
+  private final ConcurrentHashMap<String, ExecutorService> asyncCloseExecutors =
+      new ConcurrentHashMap<>();
   private final long asyncClosePoolKeepAliveSeconds;
   private final int asyncClosePoolMaxThreads;
   private final long asyncCloseWaitTime;
   private final TimeUnit asyncCloseWaitUnits;
-  private boolean closed;
+  private Boolean closed = Boolean.FALSE;
 
   public SocketCloser() {
     this(ASYNC_CLOSE_POOL_KEEP_ALIVE_SECONDS, ASYNC_CLOSE_POOL_MAX_THREADS,
@@ -96,26 +99,47 @@ public class SocketCloser {
     return this.asyncClosePoolMaxThreads;
   }
 
-  private ThreadPoolExecutor getAsyncThreadExecutor(String address) {
-    synchronized (asyncCloseExecutors) {
-      ThreadPoolExecutor pool = asyncCloseExecutors.get(address);
-      if (pool == null) {
-        final ThreadGroup tg = LoggingThreadGroup.createThreadGroup("Socket asyncClose", logger);
-        ThreadFactory tf = new ThreadFactory() {
-          public Thread newThread(final Runnable command) {
-            Thread thread = new Thread(tg, command);
-            thread.setDaemon(true);
-            return thread;
-          }
-        };
-        BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>();
-        pool = new ThreadPoolExecutor(this.asyncClosePoolMaxThreads, this.asyncClosePoolMaxThreads,
-            this.asyncClosePoolKeepAliveSeconds, TimeUnit.SECONDS, workQueue, tf);
-        pool.allowCoreThreadTimeOut(true);
-        asyncCloseExecutors.put(address, pool);
+  private ExecutorService getAsyncThreadExecutor(String address) {
+    ExecutorService executorService = asyncCloseExecutors.get(address);
+    if (executorService == null) {
+      // To be used for pre-1.8 jdk releases.
+      // executorService = createThreadPoolExecutor();
+
+      executorService = getWorkStealingPool(asyncClosePoolMaxThreads);
+
+      ExecutorService previousThreadPoolExecutor =
+          asyncCloseExecutors.putIfAbsent(address, executorService);
+
+      if (previousThreadPoolExecutor != null) {
+        executorService.shutdownNow();
+        return previousThreadPoolExecutor;
       }
-      return pool;
     }
+    return executorService;
+  }
+
+  private ExecutorService getWorkStealingPool(int maxParallelThreads) {
+    return Executors.newWorkStealingPool(maxParallelThreads);
+  }
+
+  /**
+   * @deprecated since GEODE 1.3.0. Use @link{getWorkStealingPool}
+   */
+  @Deprecated
+  private ExecutorService createThreadPoolExecutor() {
+    final ThreadGroup threadGroup =
+        LoggingThreadGroup.createThreadGroup("Socket asyncClose", logger);
+    ThreadFactory threadFactory = new ThreadFactory() {
+      public Thread newThread(final Runnable command) {
+        Thread thread = new Thread(threadGroup, command);
+        thread.setDaemon(true);
+        return thread;
+      }
+    };
+
+    return new ThreadPoolExecutor(asyncClosePoolMaxThreads, asyncClosePoolMaxThreads,
+        asyncClosePoolKeepAliveSeconds, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
+        threadFactory);
   }
 
   /**
@@ -123,19 +147,11 @@ public class SocketCloser {
    * longer needed. Currently a thread pool is kept for each address and if you know that an address
    * no longer needs its pool then you should call this method.
    */
-  public void releaseResourcesForAddress(String address) {
-    synchronized (asyncCloseExecutors) {
-      ThreadPoolExecutor pool = asyncCloseExecutors.get(address);
-      if (pool != null) {
-        pool.shutdown();
-        asyncCloseExecutors.remove(address);
-      }
-    }
-  }
 
-  private boolean isClosed() {
-    synchronized (asyncCloseExecutors) {
-      return this.closed;
+  public void releaseResourcesForAddress(String address) {
+    ExecutorService executorService = asyncCloseExecutors.remove(address);
+    if (executorService != null) {
+      executorService.shutdown();
     }
   }
 
@@ -144,35 +160,22 @@ public class SocketCloser {
    * called then the asyncClose will be done synchronously.
    */
   public void close() {
-    synchronized (asyncCloseExecutors) {
+    synchronized (closed) {
       if (!this.closed) {
         this.closed = true;
-        for (ThreadPoolExecutor pool : asyncCloseExecutors.values()) {
-          pool.shutdown();
-        }
-        asyncCloseExecutors.clear();
+      } else {
+        return;
       }
     }
+    for (ExecutorService executorService : asyncCloseExecutors.values()) {
+      executorService.shutdown();
+    }
+    asyncCloseExecutors.clear();
   }
 
-  private void asyncExecute(String address, Runnable r) {
-    // Waiting 50ms for the async close request to complete is what the old (close per thread)
-    // code did. But now that we will not create a thread for every close request
-    // it seems better to let the thread that requested the close to move on quickly.
-    // So the default has changed to not wait. The system property p2p.ASYNC_CLOSE_WAIT_MILLISECONDS
-    // can be set to how many milliseconds to wait.
-    if (this.asyncCloseWaitTime == 0) {
-      getAsyncThreadExecutor(address).execute(r);
-    } else {
-      Future<?> future = getAsyncThreadExecutor(address).submit(r);
-      try {
-        future.get(this.asyncCloseWaitTime, this.asyncCloseWaitUnits);
-      } catch (InterruptedException | ExecutionException | TimeoutException e) {
-        // We want this code to wait at most 50ms for the close to happen.
-        // It is ok to ignore these exception and let the close continue
-        // in the background.
-      }
-    }
+  private Future asyncExecute(String address, Runnable runnableToExecute) {
+    ExecutorService asyncThreadExecutor = getAsyncThreadExecutor(address);
+    return asyncThreadExecutor.submit(runnableToExecute);
   }
 
   /**
@@ -181,29 +184,30 @@ public class SocketCloser {
    * this method may block for a certain amount of time. If it is called after the SocketCloser is
    * closed then a normal synchronous close is done.
    * 
-   * @param sock the socket to close
+   * @param socket the socket to close
    * @param address identifies who the socket is connected to
    * @param extra an optional Runnable with stuff to execute in the async thread
    */
-  public void asyncClose(final Socket sock, final String address, final Runnable extra) {
-    if (sock == null || sock.isClosed()) {
+  public void asyncClose(final Socket socket, final String address, final Runnable extra) {
+    if (socket == null || socket.isClosed()) {
       return;
     }
     boolean doItInline = false;
     try {
-      synchronized (asyncCloseExecutors) {
-        if (isClosed()) {
+      Future submittedTask = null;
+      synchronized (closed) {
+        if (closed) {
           // this SocketCloser has been closed so do a synchronous, inline, close
           doItInline = true;
         } else {
-          asyncExecute(address, new Runnable() {
+          submittedTask = asyncExecute(address, new Runnable() {
             public void run() {
               Thread.currentThread().setName("AsyncSocketCloser for " + address);
               try {
                 if (extra != null) {
                   extra.run();
                 }
-                inlineClose(sock);
+                inlineClose(socket);
               } finally {
                 Thread.currentThread().setName("unused AsyncSocketCloser");
               }
@@ -211,6 +215,9 @@ public class SocketCloser {
           });
         }
       }
+      if (submittedTask != null) {
+        waitForFutureTaskWithTimeout(submittedTask);
+      }
     } catch (OutOfMemoryError ignore) {
       // If we can't start a thread to close the socket just do it inline.
       // See bug 50573.
@@ -220,16 +227,28 @@ public class SocketCloser {
       if (extra != null) {
         extra.run();
       }
-      inlineClose(sock);
+      inlineClose(socket);
     }
   }
 
+  private void waitForFutureTaskWithTimeout(Future submittedTask) {
+    if (this.asyncCloseWaitTime != 0) {
+      try {
+        submittedTask.get(this.asyncCloseWaitTime, this.asyncCloseWaitUnits);
+      } catch (InterruptedException | ExecutionException | TimeoutException e) {
+        // We want this code to wait at most the asyncCloseWaitTime for the close to happen.
+        // It is ok to ignore these exception and let the close continue
+        // in the background.
+      }
+    }
+  }
 
   /**
    * Closes the specified socket
    * 
    * @param sock the socket to close
    */
+
   private static void inlineClose(final Socket sock) {
     // the next two statements are a mad attempt to fix bug
     // 36041 - segv in jrockit in pthread signaling code. This

http://git-wip-us.apache.org/repos/asf/geode/blob/26dcf436/geode-core/src/test/java/org/apache/geode/internal/net/SocketCloserJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/net/SocketCloserJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/net/SocketCloserJUnitTest.java
index 942cad4..a8b1d48 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/net/SocketCloserJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/net/SocketCloserJUnitTest.java
@@ -14,22 +14,21 @@
  */
 package org.apache.geode.internal.net;
 
-import static org.junit.Assert.*;
-
-import java.net.Socket;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.awaitility.Awaitility;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.internal.net.SocketCloser;
-import org.apache.geode.test.dunit.Wait;
-import org.apache.geode.test.dunit.WaitCriterion;
-import org.apache.geode.test.junit.categories.UnitTest;
+import java.net.Socket;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Tests the default SocketCloser.
@@ -62,86 +61,49 @@ public class SocketCloserJUnitTest {
    */
   @Test
   public void testAsync() {
-    final CountDownLatch cdl = new CountDownLatch(1);
+    final CountDownLatch countDownLatch = new CountDownLatch(1);
     final AtomicInteger waitingToClose = new AtomicInteger(0);
-    Runnable r = new Runnable() {
-      @Override
-      public void run() {
-        try {
-          waitingToClose.incrementAndGet();
-          cdl.await();
-        } catch (InterruptedException e) {
-        }
-      }
-    };
 
     final int SOCKET_COUNT = 100;
-    final Socket[] aSockets = new Socket[SOCKET_COUNT];
-    for (int i = 0; i < SOCKET_COUNT; i++) {
-      aSockets[i] = createClosableSocket();
-    }
-    // Schedule a 100 sockets for async close.
-    // They should all be stuck on cdl.
-    for (int i = 0; i < SOCKET_COUNT; i++) {
-      this.socketCloser.asyncClose(aSockets[i], "A", r);
-    }
-    // Make sure the sockets have not been closed
-    for (int i = 0; i < SOCKET_COUNT; i++) {
-      assertEquals(false, aSockets[i].isClosed());
-    }
-    final Socket[] bSockets = new Socket[SOCKET_COUNT];
-    for (int i = 0; i < SOCKET_COUNT; i++) {
-      bSockets[i] = createClosableSocket();
-    }
+    final int REMOTE_CLIENT_COUNT = 200;
+
+    List<Socket> trackedSockets = new ArrayList<>();
     // Schedule a 100 sockets for async close.
-    // They should all be stuck on cdl.
-    for (int i = 0; i < SOCKET_COUNT; i++) {
-      this.socketCloser.asyncClose(bSockets[i], "B", r);
-    }
-    // Make sure the sockets have not been closed
-    for (int i = 0; i < SOCKET_COUNT; i++) {
-      assertEquals(false, bSockets[i].isClosed());
+    // They should all be stuck on countDownLatch.
+    for (int i = 0; i < REMOTE_CLIENT_COUNT; i++) {
+      Socket[] aSockets = new Socket[SOCKET_COUNT];
+      String address = i + "";
+      for (int j = 0; j < SOCKET_COUNT; j++) {
+        aSockets[j] = createClosableSocket();
+        trackedSockets.add(aSockets[j]);
+        this.socketCloser.asyncClose(aSockets[j], address, () -> {
+          try {
+            waitingToClose.incrementAndGet();
+            countDownLatch.await();
+          } catch (InterruptedException e) {
+          }
+        });
+      }
     }
+
     // close the socketCloser first to verify that the sockets
     // that have already been scheduled will be still be closed.
-    this.socketCloser.releaseResourcesForAddress("A");
     this.socketCloser.close();
-    // Each thread pool (one for A and one for B) has a max of 8 threads.
-    // So verify that this many are currently waiting on cdl.
-    {
-      final int maxThreads = this.socketCloser.getMaxThreads();
-      WaitCriterion wc = new WaitCriterion() {
-        public boolean done() {
-          return waitingToClose.get() == 2 * maxThreads;
-        }
-
-        public String description() {
-          return "expected " + 2 * maxThreads + " waiters but found only " + waitingToClose.get();
-        }
-      };
-      Wait.waitForCriterion(wc, 5000, 10, true);
-    }
-    // now count down the latch that allows the sockets to close
-    cdl.countDown();
+    countDownLatch.countDown();
     // now all the sockets should get closed; use a wait criteria
     // since a thread pool is doing to closes
-    {
-      WaitCriterion wc = new WaitCriterion() {
-        public boolean done() {
-          for (int i = 0; i < SOCKET_COUNT; i++) {
-            if (!aSockets[i].isClosed() || !bSockets[i].isClosed()) {
-              return false;
-            }
-          }
-          return true;
+    Awaitility.await().atMost(5, TimeUnit.SECONDS).until(() -> {
+      boolean areAllClosed = true;
+      for (Iterator<Socket> iterator = trackedSockets.iterator(); iterator.hasNext();) {
+        Socket socket = iterator.next();
+        if (socket.isClosed()) {
+          iterator.remove();
+          continue;
         }
-
-        public String description() {
-          return "one or more sockets did not close";
-        }
-      };
-      Wait.waitForCriterion(wc, 5000, 10, true);
-    }
+        areAllClosed = false;
+      }
+      return areAllClosed;
+    });
   }
 
   /**
@@ -150,18 +112,11 @@ public class SocketCloserJUnitTest {
   @Test
   public void testClosedSocket() throws Exception {
     final AtomicBoolean runnableCalled = new AtomicBoolean();
-    Runnable r = new Runnable() {
-      @Override
-      public void run() {
-        runnableCalled.set(true);
-      }
-    };
 
     Socket s = createClosableSocket();
     s.close();
-    this.socketCloser.asyncClose(s, "A", r);
-    Wait.pause(10);
-    assertEquals(false, runnableCalled.get());
+    this.socketCloser.asyncClose(s, "A", () -> runnableCalled.set(true));
+    Awaitility.await().atMost(1, TimeUnit.SECONDS).until(() -> !runnableCalled.get());
   }
 
   /**
@@ -170,25 +125,11 @@ public class SocketCloserJUnitTest {
   @Test
   public void testClosedSocketCloser() {
     final AtomicBoolean runnableCalled = new AtomicBoolean();
-    Runnable r = new Runnable() {
-      @Override
-      public void run() {
-        runnableCalled.set(true);
-      }
-    };
 
-    final Socket s = createClosableSocket();
+    final Socket closableSocket = createClosableSocket();
     this.socketCloser.close();
-    this.socketCloser.asyncClose(s, "A", r);
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        return runnableCalled.get() && s.isClosed();
-      }
-
-      public String description() {
-        return "runnable was not called or socket was not closed";
-      }
-    };
-    Wait.waitForCriterion(wc, 5000, 10, true);
+    this.socketCloser.asyncClose(closableSocket, "A", () -> runnableCalled.set(true));
+    Awaitility.await().atMost(5, TimeUnit.SECONDS)
+        .until(() -> runnableCalled.get() && closableSocket.isClosed());
   }
 }

[02/14] geode git commit: GEODE-3495 Bump log4j to v2.8.2

Posted by ud...@apache.org.
GEODE-3495 Bump log4j to v2.8.2


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

Branch: refs/heads/feature/GEODE-3416
Commit: 99aa7c1f6701eb120e8cf9de7f87df5e6bc735b3
Parents: 9b52ee6
Author: Anthony Baker <ab...@apache.org>
Authored: Tue Aug 15 16:42:47 2017 -0700
Committer: Anthony Baker <ab...@apache.org>
Committed: Mon Aug 21 12:29:07 2017 -0700

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


http://git-wip-us.apache.org/repos/asf/geode/blob/99aa7c1f/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index 4dd3f34..121ec28 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -64,7 +64,7 @@ json-path-assert.version = 2.2.0
 junit.version = 4.12
 junit-quickcheck.version = 0.7
 JUnitParams.version = 1.0.6
-log4j.version = 2.7
+log4j.version = 2.8.2
 lucene.version = 6.4.1
 mockito-core.version = 2.8.9
 mockrunner.version = 1.1.2

[03/14] geode git commit: GEODE-2708: Update Gradle Wrapper To 3.5.1

Posted by ud...@apache.org.
GEODE-2708: Update Gradle Wrapper To 3.5.1

While updating the Gradle wrapper from 2.14.1 to 3.5.1, it was found that the
ANTLR plugin causing an issue inside the Eclipse IDE. The fix was to declare the
ANTLR dependency version for the antlr configuration. If no version is set for
the antlr plugin, it will default to 2.7.7. However, this was causing an issue
for Eclipse and other IDE's because the plugin was modifying the antlr
configuration after the initial dependency resolution was done.

- Updated Gradle Wrapper to 3.5.1
- Added antlr dependency to the antlr configuration

Verified by importing project into Eclipse and also running build from
command-line


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

Branch: refs/heads/feature/GEODE-3416
Commit: 7038eb90200d64fb499aca6a2d01f84e19c88c5d
Parents: 99aa7c1
Author: Mark Bretl <mb...@apache.org>
Authored: Mon Aug 21 13:20:46 2017 -0700
Committer: Mark Bretl <mb...@kollective.com>
Committed: Mon Aug 21 13:32:08 2017 -0700

----------------------------------------------------------------------
 geode-core/build.gradle                  | 4 +++-
 gradle.properties                        | 2 +-
 gradle/wrapper/gradle-wrapper.properties | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/7038eb90/geode-core/build.gradle
----------------------------------------------------------------------
diff --git a/geode-core/build.gradle b/geode-core/build.gradle
index 9ecb0f9..795c124 100755
--- a/geode-core/build.gradle
+++ b/geode-core/build.gradle
@@ -31,7 +31,9 @@ configurations {
 }
 
 dependencies {
-   // Source Dependencies
+  // Source Dependencies
+  antlr 'antlr:antlr:' + project.'antlr.version'
+
   // External
   provided files("${System.getProperty('java.home')}/../lib/tools.jar")
   compile 'com.github.stephenc.findbugs:findbugs-annotations:' + project.'stephenc-findbugs.version'

http://git-wip-us.apache.org/repos/asf/geode/blob/7038eb90/gradle.properties
----------------------------------------------------------------------
diff --git a/gradle.properties b/gradle.properties
index 9462295..042cf42 100755
--- a/gradle.properties
+++ b/gradle.properties
@@ -42,7 +42,7 @@ productOrg = Apache Software Foundation (ASF)
 org.gradle.daemon = true
 org.gradle.jvmargs = -Xmx2048m
 
-minimumGradleVersion = 2.14.1
+minimumGradleVersion = 3.5.1
 # Set this on the command line with -P or in ~/.gradle/gradle.properties
 # to change the buildDir location.  Use an absolute path.
 buildRoot=

http://git-wip-us.apache.org/repos/asf/geode/blob/7038eb90/gradle/wrapper/gradle-wrapper.properties
----------------------------------------------------------------------
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index d57b5d9..2fad278 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-bin.zip

[10/14] geode git commit: GEODE-3474: Fixed failing tests

Posted by ud...@apache.org.
GEODE-3474: Fixed failing tests


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

Branch: refs/heads/feature/GEODE-3416
Commit: 5863fd5aa36a95676b45eb8e6ab88621ecdd58b6
Parents: 28616a2
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Mon Aug 21 15:24:37 2017 -0700
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Mon Aug 21 15:24:37 2017 -0700

----------------------------------------------------------------------
 .../apache/geode/protocol/AuthenticationIntegrationTest.java    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/5863fd5a/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
index 794375e..f138538 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
@@ -19,6 +19,7 @@ import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.management.internal.security.ResourceConstants;
 import org.apache.geode.protocol.protobuf.AuthenticationAPI;
 import org.apache.geode.protocol.protobuf.ClientProtocol;
 import org.apache.geode.protocol.protobuf.ProtobufSerializationService;
@@ -70,8 +71,8 @@ public class AuthenticationIntegrationTest {
   public void setUp(String authenticationMode)
       throws IOException, CodecAlreadyRegisteredForTypeException {
     Properties expectedAuthProperties = new Properties();
-    expectedAuthProperties.setProperty("username", TEST_USERNAME);
-    expectedAuthProperties.setProperty("password", TEST_PASSWORD);
+    expectedAuthProperties.setProperty(ResourceConstants.USER_NAME, TEST_USERNAME);
+    expectedAuthProperties.setProperty(ResourceConstants.PASSWORD, TEST_PASSWORD);
 
     securityPrincipal = new Object();
     mockSecurityManager = mock(SecurityManager.class);

[04/14] geode git commit: GEODE-3470: Increased serial gateway sender token timeout

Posted by ud...@apache.org.
GEODE-3470: Increased serial gateway sender token timeout


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

Branch: refs/heads/feature/GEODE-3416
Commit: 6a17c9b1b2f4c3148afc88829c40eaf355e4293a
Parents: 7038eb9
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Fri Aug 18 16:41:26 2017 -0700
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Mon Aug 21 14:03:01 2017 -0700

----------------------------------------------------------------------
 .../cache/wan/AbstractGatewaySender.java        |   2 +-
 .../SerialGatewaySenderEventProcessor.java      |   4 +-
 .../ParallelQueueRemovalMessageJUnitTest.java   |  11 +-
 ...ialGatewaySenderEventProcessorJUnitTest.java | 114 +++++++++++++++++++
 .../TestSerialGatewaySenderEventProcessor.java  |  32 ++++++
 5 files changed, 151 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/6a17c9b1/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 c38d547..2154ffe 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
@@ -188,7 +188,7 @@ public abstract class AbstractGatewaySender implements GatewaySender, Distributi
       Integer.getInteger("GatewaySender.QUEUE_SIZE_THRESHOLD", 5000).intValue();
 
   public static int TOKEN_TIMEOUT =
-      Integer.getInteger("GatewaySender.TOKEN_TIMEOUT", 15000).intValue();
+      Integer.getInteger("GatewaySender.TOKEN_TIMEOUT", 120000).intValue();
 
   /**
    * The name of the DistributedLockService used when accessing the GatewaySender's meta data

http://git-wip-us.apache.org/repos/asf/geode/blob/6a17c9b1/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessor.java
index 0aa0ed9..150b5ac 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessor.java
@@ -84,7 +84,7 @@ public class SerialGatewaySenderEventProcessor extends AbstractGatewaySenderEven
    * to keep track. Note: unprocessedEventsLock MUST be synchronized before using this map. This is
    * not a cut and paste error. sync unprocessedEventsLock when using unprocessedTokens.
    */
-  private Map<EventID, Long> unprocessedTokens;
+  protected Map<EventID, Long> unprocessedTokens;
 
   private ExecutorService executor;
 
@@ -98,7 +98,7 @@ public class SerialGatewaySenderEventProcessor extends AbstractGatewaySenderEven
    * When the Number of unchecked events exceeds this threshold and the number of tokens in the map
    * exceeds this threshold then a check will be done for old tokens.
    */
-  static private final int REAP_THRESHOLD = 1000;
+  static protected final int REAP_THRESHOLD = 1000;
 
   /*
    * How many events have happened without a reap check being done?

http://git-wip-us.apache.org/repos/asf/geode/blob/6a17c9b1/geode-core/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelQueueRemovalMessageJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelQueueRemovalMessageJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelQueueRemovalMessageJUnitTest.java
index e45a06b..1a49cfd 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelQueueRemovalMessageJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelQueueRemovalMessageJUnitTest.java
@@ -28,7 +28,6 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.mockito.invocation.InvocationOnMock;
@@ -49,7 +48,6 @@ import org.apache.geode.internal.cache.BucketAdvisor;
 import org.apache.geode.internal.cache.BucketRegionQueue;
 import org.apache.geode.internal.cache.BucketRegionQueueHelper;
 import org.apache.geode.internal.cache.EntryEventImpl;
-import org.apache.geode.internal.cache.EventID;
 import org.apache.geode.internal.cache.EvictionAttributesImpl;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.InternalRegionArguments;
@@ -156,10 +154,7 @@ public class ParallelQueueRemovalMessageJUnitTest {
 
     when(pa.getColocatedWith()).thenReturn(null);
 
-    // classes cannot be mocked
-    ProxyBucketRegion pbr = new ProxyBucketRegion(BUCKET_ID, this.queueRegion, pbrIra);
-
-    when(ba.getProxyBucketRegion()).thenReturn(pbr);
+    when(ba.getProxyBucketRegion()).thenReturn(mock(ProxyBucketRegion.class));
 
     // Create RegionAttributes
     AttributesFactory factory = new AttributesFactory();
@@ -175,7 +170,7 @@ public class ParallelQueueRemovalMessageJUnitTest {
     this.bucketRegionQueue = spy(realBucketRegionQueue);
     // (this.queueRegion.getBucketName(BUCKET_ID), attributes, this.rootRegion, this.cache, ira);
     EntryEventImpl entryEvent = EntryEventImpl.create(this.bucketRegionQueue, Operation.DESTROY,
-        mock(EventID.class), "value", null, false, mock(DistributedMember.class));
+        KEY, "value", null, false, mock(DistributedMember.class));
     doReturn(entryEvent).when(this.bucketRegionQueue).newDestroyEntryEvent(any(), any());
     // when(this.bucketRegionQueue.newDestroyEntryEvent(any(), any())).thenReturn();
 
@@ -203,7 +198,6 @@ public class ParallelQueueRemovalMessageJUnitTest {
     assertEquals(1, this.bucketRegionQueue.getFailedBatchRemovalMessageKeys().size());
   }
 
-  @Ignore
   @Test
   public void validateDestroyKeyFromBucketQueueInUninitializedBucketRegionQueue() throws Exception {
     // Validate initial BucketRegionQueue state
@@ -245,7 +239,6 @@ public class ParallelQueueRemovalMessageJUnitTest {
     assertEquals(0, tempQueue.size());
   }
 
-  @Ignore
   @Test
   public void validateDestroyFromBucketQueueAndTempQueueInUninitializedBucketRegionQueue() {
     // Validate initial BucketRegionQueue state

http://git-wip-us.apache.org/repos/asf/geode/blob/6a17c9b1/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessorJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessorJUnitTest.java
new file mode 100644
index 0000000..f21634e
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessorJUnitTest.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.wan.serial;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.Operation;
+import org.apache.geode.internal.cache.EntryEventImpl;
+import org.apache.geode.internal.cache.EventID;
+import org.apache.geode.internal.cache.LocalRegion;
+import org.apache.geode.internal.cache.wan.AbstractGatewaySender;
+import org.apache.geode.internal.cache.wan.GatewaySenderEventImpl;
+import org.apache.geode.internal.cache.wan.GatewaySenderStats;
+import org.apache.geode.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class SerialGatewaySenderEventProcessorJUnitTest {
+
+  private AbstractGatewaySender sender;
+
+  private TestSerialGatewaySenderEventProcessor processor;
+
+  @Before
+  public void setUp() throws Exception {
+    this.sender = mock(AbstractGatewaySender.class);
+    this.processor = new TestSerialGatewaySenderEventProcessor(this.sender, "ny");
+  }
+
+  @Test
+  public void validateUnprocessedTokensMapUpdated() throws Exception {
+    GatewaySenderStats gss = mock(GatewaySenderStats.class);
+    when(sender.getStatistics()).thenReturn(gss);
+
+    // Handle primary event
+    EventID id = handlePrimaryEvent();
+
+    // Verify the token was added by checking the correct stat methods were called and the size of
+    // the unprocessedTokensMap.
+    verify(gss).incUnprocessedTokensAddedByPrimary();
+    verify(gss, never()).incUnprocessedEventsRemovedByPrimary();
+    assertEquals(1, this.processor.getUnprocessedTokensSize());
+
+    // Handle the event from the secondary. The call to enqueueEvent is necessary to synchronize the
+    // unprocessedEventsLock and prevent the assertion error in basicHandleSecondaryEvent.
+    EntryEventImpl event = mock(EntryEventImpl.class);
+    when(event.getRegion()).thenReturn(mock(LocalRegion.class));
+    when(event.getEventId()).thenReturn(id);
+    when(event.getOperation()).thenReturn(Operation.CREATE);
+    this.processor.enqueueEvent(null, event, null);
+
+    // Verify the token was removed by checking the correct stat methods were called and the size of
+    // the unprocessedTokensMap.
+    verify(gss).incUnprocessedTokensRemovedBySecondary();
+    verify(gss, never()).incUnprocessedEventsAddedBySecondary();
+    assertEquals(0, this.processor.getUnprocessedTokensSize());
+  }
+
+  @Test
+  public void validateUnprocessedTokensMapReaping() throws Exception {
+    // Set the token timeout low
+    int originalTokenTimeout = AbstractGatewaySender.TOKEN_TIMEOUT;
+    AbstractGatewaySender.TOKEN_TIMEOUT = 500;
+    try {
+      GatewaySenderStats gss = mock(GatewaySenderStats.class);
+      when(sender.getStatistics()).thenReturn(gss);
+
+      // Add REAP_THRESHOLD + 1 events to the unprocessed tokens map. This causes the uncheckedCount
+      // in the reaper to be REAP_THRESHOLD. The next event will cause the reaper to run.\
+      int numEvents = SerialGatewaySenderEventProcessor.REAP_THRESHOLD + 1;
+      for (int i = 0; i < numEvents; i++) {
+        handlePrimaryEvent();
+      }
+      assertEquals(numEvents, this.processor.getUnprocessedTokensSize());
+
+      // Wait for the timeout
+      Thread.sleep(AbstractGatewaySender.TOKEN_TIMEOUT + 1000);
+
+      // Add one more event to the unprocessed tokens map. This will reap all of the previous
+      // tokens.
+      handlePrimaryEvent();
+      assertEquals(1, this.processor.getUnprocessedTokensSize());
+    } finally {
+      AbstractGatewaySender.TOKEN_TIMEOUT = originalTokenTimeout;
+    }
+  }
+
+  private EventID handlePrimaryEvent() {
+    GatewaySenderEventImpl gsei = mock(GatewaySenderEventImpl.class);
+    EventID id = mock(EventID.class);
+    when(gsei.getEventId()).thenReturn(id);
+    this.processor.basicHandlePrimaryEvent(gsei);
+    return id;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/6a17c9b1/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/TestSerialGatewaySenderEventProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/TestSerialGatewaySenderEventProcessor.java b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/TestSerialGatewaySenderEventProcessor.java
new file mode 100644
index 0000000..cf453e6
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/serial/TestSerialGatewaySenderEventProcessor.java
@@ -0,0 +1,32 @@
+/*
+ * 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.serial;
+
+import org.apache.geode.internal.cache.wan.AbstractGatewaySender;
+
+public class TestSerialGatewaySenderEventProcessor extends SerialGatewaySenderEventProcessor {
+
+  public TestSerialGatewaySenderEventProcessor(AbstractGatewaySender sender, String id) {
+    super(sender, id);
+  }
+
+  protected void initializeMessageQueue(String id) {
+    // Overridden to not create the RegionQueue in the constructor.
+  }
+
+  protected int getUnprocessedTokensSize() {
+    return this.unprocessedTokens.size();
+  }
+}

[08/14] geode git commit: GEODE-3430: fix varargs usage

Posted by ud...@apache.org.
GEODE-3430: fix varargs usage

Also, general cleanup of ConnectCommandTest.

This closes #727


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

Branch: refs/heads/feature/GEODE-3416
Commit: c4def6bbb3d8c438cdc8d4b6d31e3e3875f6ab2b
Parents: 2924ef1
Author: Kirk Lund <kl...@apache.org>
Authored: Mon Aug 21 10:12:08 2017 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon Aug 21 14:44:53 2017 -0700

----------------------------------------------------------------------
 .../cli/commands/ConnectCommandTest.java        | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c4def6bb/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConnectCommandTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConnectCommandTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConnectCommandTest.java
index 3a5c584..80bd705 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConnectCommandTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConnectCommandTest.java
@@ -54,9 +54,7 @@ public class ConnectCommandTest {
   public static GfshParserRule gfshParserRule = new GfshParserRule();
 
   private ConnectCommand connectCommand;
-
-  private Gfsh gfsh = mock(Gfsh.class);
-
+  private Gfsh gfsh;
   private CommandResult result;
   private Properties properties;
   private ArgumentCaptor<File> fileCaptor;
@@ -64,6 +62,7 @@ public class ConnectCommandTest {
   @Before
   public void before() throws Exception {
     properties = new Properties();
+    gfsh = mock(Gfsh.class);
     when(gfsh.getOperationInvoker()).thenReturn(mock(OperationInvoker.class));
     // using spy instead of mock because we want to call the real method when we do connect
     connectCommand = spy(ConnectCommand.class);
@@ -107,8 +106,8 @@ public class ConnectCommandTest {
   }
 
   @Test
-  public void notPromptForPasswordIfuserNameisGivenInFile() throws Exception {
-    // username specified in property file won't promot for password
+  public void notPromptForPasswordIfuserNameIsGivenInFile() throws Exception {
+    // username specified in property file won't prompt for password
     properties.setProperty("security-username", "user");
     doReturn(properties).when(connectCommand).loadProperties(any(File.class));
 
@@ -245,25 +244,25 @@ public class ConnectCommandTest {
   @Test
   public void containsLegacySSLConfigTest_ssl() throws Exception {
     properties.setProperty(SSL_KEYSTORE, "keystore");
-    assertThat(connectCommand.containsLegacySSLConfig(properties)).isFalse();
+    assertThat(ConnectCommand.containsLegacySSLConfig(properties)).isFalse();
   }
 
   @Test
   public void containsLegacySSLConfigTest_cluster() throws Exception {
     properties.setProperty(CLUSTER_SSL_KEYSTORE, "cluster-keystore");
-    assertThat(connectCommand.containsLegacySSLConfig(properties)).isTrue();
+    assertThat(ConnectCommand.containsLegacySSLConfig(properties)).isTrue();
   }
 
   @Test
   public void containsLegacySSLConfigTest_jmx() throws Exception {
     properties.setProperty(JMX_MANAGER_SSL_KEYSTORE, "jmx-keystore");
-    assertThat(connectCommand.containsLegacySSLConfig(properties)).isTrue();
+    assertThat(ConnectCommand.containsLegacySSLConfig(properties)).isTrue();
   }
 
   @Test
   public void containsLegacySSLConfigTest_http() throws Exception {
     properties.setProperty(HTTP_SERVICE_SSL_KEYSTORE, "http-keystore");
-    assertThat(connectCommand.containsLegacySSLConfig(properties)).isTrue();
+    assertThat(ConnectCommand.containsLegacySSLConfig(properties)).isTrue();
   }
 
   @Test
@@ -274,7 +273,8 @@ public class ConnectCommandTest {
 
   @Test
   public void isSslImpliedByOptions() throws Exception {
-    assertThat(connectCommand.isSslImpliedBySslOptions(null)).isFalse();
+    assertThat(connectCommand.isSslImpliedBySslOptions((String) null)).isFalse();
+    assertThat(connectCommand.isSslImpliedBySslOptions((String[]) null)).isFalse();
 
     assertThat(connectCommand.isSslImpliedBySslOptions(null, null, null)).isFalse();
 

[09/14] geode git commit: GEODE-3469: prevent zero pid from AvailablePid for tests

Posted by ud...@apache.org.
GEODE-3469: prevent zero pid from AvailablePid for tests

This closes #724


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

Branch: refs/heads/feature/GEODE-3416
Commit: 28616a27ec79c0693fb2fbb1a135cf3df3ad4150
Parents: c4def6b
Author: Kirk Lund <kl...@apache.org>
Authored: Fri Aug 18 14:33:25 2017 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon Aug 21 14:59:26 2017 -0700

----------------------------------------------------------------------
 .../internal/process/lang/AvailablePid.java     | 119 ++++++++++++++++---
 .../internal/process/lang/AvailablePidTest.java |  81 +++++++++++--
 2 files changed, 170 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/28616a27/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePid.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePid.java b/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePid.java
index d26f73e..c74bd10 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePid.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePid.java
@@ -12,55 +12,107 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.internal.process.lang;
 
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static org.apache.geode.internal.process.ProcessUtils.isProcessAlive;
 
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Random;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.apache.geode.internal.util.StopWatch;
+import com.google.common.base.Stopwatch;
 
 /**
  * Finds unused pids for use in tests.
  */
 public class AvailablePid {
 
-  static final int LOWER_BOUND = 1;
-  static final int UPPER_BOUND = 64000;
+  static final int DEFAULT_LOWER_BOUND = 1;
+  static final int DEFAULT_UPPER_BOUND = 64000;
   static final int DEFAULT_TIMEOUT_MILLIS = 60 * 1000;
 
+  private final int lowerBound;
+  private final int upperBound;
   private final Random random;
   private final int timeoutMillis;
 
   /**
-   * Construct with no seed and default timeout of 1 minute.
+   * Construct with:
+   * <ul>
+   * <li>default {@link Bounds} of {@link #DEFAULT_LOWER_BOUND} (inclusive) and
+   * {@link #DEFAULT_UPPER_BOUND} (inclusive)
+   * <li>Random with no see
+   * <li>default timeout of 1 minute.
+   * </ul>
    */
   public AvailablePid() {
-    this(new Random(), DEFAULT_TIMEOUT_MILLIS);
+    this(new Bounds(DEFAULT_LOWER_BOUND, DEFAULT_UPPER_BOUND), new Random(),
+        DEFAULT_TIMEOUT_MILLIS);
+  }
+
+  /**
+   * Construct with:
+   * <ul>
+   * <li>default {@link Bounds} of {@link #DEFAULT_LOWER_BOUND} (inclusive) and
+   * {@link #DEFAULT_UPPER_BOUND} (inclusive)
+   * <li>Random with specified seed
+   * <li>default timeout of 1 minute
+   * </ul>
+   */
+  public AvailablePid(final long seed) {
+    this(new Bounds(DEFAULT_LOWER_BOUND, DEFAULT_UPPER_BOUND), new Random(seed),
+        DEFAULT_TIMEOUT_MILLIS);
   }
 
   /**
-   * Construct with specified seed and timeout.
+   * Construct with:
+   * <ul>
+   * <li>default {@link Bounds} of {@link #DEFAULT_LOWER_BOUND} (inclusive) and
+   * {@link #DEFAULT_UPPER_BOUND} (inclusive)
+   * <li>specified Random instance
+   * <li>default timeout of 1 minute
+   * </ul>
    */
-  public AvailablePid(final long seed, final int timeoutMillis) {
-    this(new Random(seed), timeoutMillis);
+  public AvailablePid(final Random random) {
+    this(new Bounds(DEFAULT_LOWER_BOUND, DEFAULT_UPPER_BOUND), random, DEFAULT_TIMEOUT_MILLIS);
   }
 
   /**
-   * Construct with specified Random implementation.
+   * Construct with:
+   * <ul>
+   * <li>specified {@link Bounds} of {@code lowerBound} (inclusive) and {@code upperBound}
+   * (inclusive)
+   * <li>Random with no seed
+   * <li>default timeout of 1 minute
+   * </ul>
    */
-  public AvailablePid(final Random random, final int timeoutMillis) {
+  public AvailablePid(final Bounds bounds) {
+    this(bounds, new Random(), DEFAULT_TIMEOUT_MILLIS);
+  }
+
+  /**
+   * Construct with:
+   * <ul>
+   * <li>specified {@link Bounds} of {@code lowerBound} (inclusive) and {@code upperBound}
+   * (inclusive)
+   * <li>specified Random instance
+   * <li>specified default timeout millis
+   * </ul>
+   */
+  public AvailablePid(final Bounds bounds, final Random random, final int timeoutMillis) {
+    this.lowerBound = bounds.lowerBound;
+    this.upperBound = bounds.upperBound;
     this.random = random;
     this.timeoutMillis = timeoutMillis;
   }
 
   /**
-   * Returns specified pid if it's unused. Else returns randomly unused pid.
+   * Returns specified pid if it's unused. Else returns randomly unused pid between
+   * {@code lowerBound} (inclusive) and {@code upperBound} (inclusive).
    */
   public int findAvailablePid(final int pid) throws TimeoutException {
     if (isProcessAlive(pid)) {
@@ -70,13 +122,14 @@ public class AvailablePid {
   }
 
   /**
-   * Returns randomly unused pid.
+   * Returns randomly unused pid between {@code lowerBound} (inclusive) and {@code upperBound}
+   * (inclusive).
    */
   public int findAvailablePid() throws TimeoutException {
-    StopWatch stopWatch = new StopWatch(true);
+    Stopwatch stopwatch = Stopwatch.createStarted();
     int pid = random();
     while (isProcessAlive(pid)) {
-      if (stopWatch.elapsedTimeMillis() > timeoutMillis) {
+      if (stopwatch.elapsed(MILLISECONDS) > timeoutMillis) {
         throw new TimeoutException(
             "Failed to find available pid within " + timeoutMillis + " millis.");
       }
@@ -86,7 +139,8 @@ public class AvailablePid {
   }
 
   /**
-   * Returns specified number of randomly unused pids.
+   * Returns specified number of unique, randomly unused pids between {@code lowerBound} (inclusive)
+   * and {@code upperBound} (inclusive).
    */
   public int[] findAvailablePids(final int number) throws TimeoutException {
     Set<Integer> pids = new HashSet<>();
@@ -99,8 +153,37 @@ public class AvailablePid {
     return Arrays.stream(pids.toArray(new Integer[0])).mapToInt(Integer::intValue).toArray();
   }
 
-  private int random() {
-    return random.nextInt(UPPER_BOUND - LOWER_BOUND);
+  /**
+   * Returns a value between {@code lowerBound} (inclusive) and {@code upperBound} (inclusive)
+   */
+  int random() {
+    return random.nextInt(upperBound + 1 - lowerBound) + lowerBound;
+  }
+
+  /**
+   * Lower and upper bounds for desired PIDs. Both are inclusive -- if you specify
+   * {@code new Bounds(1, 100)} then {@code AvailablePid} will return values of 1 through 100.
+   *
+   * <ul>
+   * <li>{@code lowerBound} must be an integer greater than zero.
+   * <li>{@code upperBound} must be an integer greater than {@code lowerBound}.
+   * </ul>
+   */
+  static class Bounds {
+    final int lowerBound;
+    final int upperBound;
+
+    Bounds(final int lowerBound, final int upperBound) {
+      if (lowerBound < 1) {
+        throw new IllegalArgumentException("lowerBound must be greater than '0'");
+      }
+      if (upperBound <= lowerBound) {
+        throw new IllegalArgumentException(
+            "upperBound must be greater than lowerBound '" + lowerBound + "'");
+      }
+      this.lowerBound = lowerBound;
+      this.upperBound = upperBound;
+    }
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/28616a27/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePidTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePidTest.java b/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePidTest.java
index 00beb67..48ba235 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePidTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePidTest.java
@@ -12,13 +12,16 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.internal.process.lang;
 
+import static java.util.concurrent.TimeUnit.SECONDS;
 import static org.apache.geode.internal.process.ProcessUtils.identifyPid;
 import static org.apache.geode.internal.process.ProcessUtils.isProcessAlive;
-import static org.apache.geode.internal.process.lang.AvailablePid.DEFAULT_TIMEOUT_MILLIS;
+import static org.apache.geode.internal.process.lang.AvailablePid.DEFAULT_LOWER_BOUND;
+import static org.apache.geode.internal.process.lang.AvailablePid.DEFAULT_UPPER_BOUND;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.awaitility.Awaitility.await;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.spy;
@@ -29,9 +32,12 @@ import java.util.Random;
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import com.google.common.base.Stopwatch;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.rules.Timeout;
 
 import org.apache.geode.test.junit.categories.UnitTest;
 
@@ -43,6 +49,9 @@ public class AvailablePidTest {
 
   private AvailablePid availablePid;
 
+  @Rule
+  public Timeout timeout = Timeout.builder().withTimeout(20, SECONDS).build();
+
   @Before
   public void before() throws Exception {
     availablePid = new AvailablePid();
@@ -50,39 +59,39 @@ public class AvailablePidTest {
 
   @Test
   public void lowerBoundShouldBeLegalPid() throws Exception {
-    assertThat(isProcessAlive(AvailablePid.LOWER_BOUND)).isIn(true, false);
+    assertThat(isProcessAlive(DEFAULT_LOWER_BOUND)).isIn(true, false);
   }
 
   @Test
   public void upperBoundShouldBeLegalPid() throws Exception {
-    assertThat(isProcessAlive(AvailablePid.UPPER_BOUND)).isIn(true, false);
+    assertThat(isProcessAlive(DEFAULT_UPPER_BOUND)).isIn(true, false);
   }
 
-  @Test(timeout = DEFAULT_TIMEOUT_MILLIS)
+  @Test
   public void findAvailablePidShouldNotReturnLocalPid() throws Exception {
     int pid = availablePid.findAvailablePid();
 
     assertThat(pid).isNotEqualTo(identifyPid());
   }
 
-  @Test(timeout = DEFAULT_TIMEOUT_MILLIS)
+  @Test
   public void findAvailablePidShouldNotReturnLivePid() throws Exception {
     int pid = availablePid.findAvailablePid();
 
     assertThat(isProcessAlive(pid)).isFalse();
   }
 
-  @Test(timeout = DEFAULT_TIMEOUT_MILLIS)
-  public void findAvailablePidShouldReturnRandomPid() throws Exception {
+  @Test
+  public void findAvailablePidShouldUseRandom() throws Exception {
     Random random = spy(new Random());
-    availablePid = new AvailablePid(random, DEFAULT_TIMEOUT_MILLIS);
+    availablePid = new AvailablePid(random);
 
     availablePid.findAvailablePid();
 
     verify(random, atLeastOnce()).nextInt(anyInt());
   }
 
-  @Test(timeout = DEFAULT_TIMEOUT_MILLIS)
+  @Test
   public void findAvailablePidsShouldReturnSpecifiedNumberOfPids() throws Exception {
     assertThat(availablePid.findAvailablePids(1)).hasSize(1);
     assertThat(availablePid.findAvailablePids(2)).hasSize(2);
@@ -91,7 +100,7 @@ public class AvailablePidTest {
     assertThat(availablePid.findAvailablePids(8)).hasSize(8);
   }
 
-  @Test(timeout = DEFAULT_TIMEOUT_MILLIS)
+  @Test
   public void findAvailablePidsShouldReturnNoDuplicatedPids() throws Exception {
     assertThatNoPidIsDuplicated(availablePid.findAvailablePids(1));
     assertThatNoPidIsDuplicated(availablePid.findAvailablePids(2));
@@ -100,7 +109,55 @@ public class AvailablePidTest {
     assertThatNoPidIsDuplicated(availablePid.findAvailablePids(8));
   }
 
-  private void assertThatNoPidIsDuplicated(int[] pids) {
+  @Test
+  public void findAvailablePidShouldReturnGreaterThanOrEqualToLowerBound() throws Exception {
+    availablePid = new AvailablePid(new AvailablePid.Bounds(1, 10));
+    Stopwatch stopwatch = Stopwatch.createStarted();
+
+    do {
+      assertThat(availablePid.findAvailablePid()).isGreaterThanOrEqualTo(1);
+    } while (stopwatch.elapsed(SECONDS) < 2);
+  }
+
+  @Test
+  public void findAvailablePidShouldReturnLessThanOrEqualToUpperBound() throws Exception {
+    availablePid = new AvailablePid(new AvailablePid.Bounds(1, 10));
+    Stopwatch stopwatch = Stopwatch.createStarted();
+
+    do {
+      assertThat(availablePid.findAvailablePid()).isLessThanOrEqualTo(10);
+    } while (stopwatch.elapsed(SECONDS) < 2);
+  }
+
+  @Test
+  public void randomLowerBoundIsInclusive() throws Exception {
+    availablePid = new AvailablePid(new AvailablePid.Bounds(1, 3));
+
+    await().atMost(10, SECONDS).until(() -> assertThat(availablePid.random()).isEqualTo(1));
+  }
+
+  @Test
+  public void randomUpperBoundIsInclusive() throws Exception {
+    availablePid = new AvailablePid(new AvailablePid.Bounds(1, 3));
+
+    await().atMost(10, SECONDS).until(() -> assertThat(availablePid.random()).isEqualTo(3));
+  }
+
+  @Test
+  public void lowerBoundMustBeGreaterThanZero() throws Exception {
+    assertThatThrownBy(() -> new AvailablePid(new AvailablePid.Bounds(0, 1)))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("lowerBound must be greater than '0'");
+  }
+
+  @Test
+  public void upperBoundMustBeGreaterThanLowerBound() throws Exception {
+    assertThatThrownBy(() -> new AvailablePid(new AvailablePid.Bounds(1, 1)))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("upperBound must be greater than lowerBound '1'");
+  }
+
+  private void assertThatNoPidIsDuplicated(final int[] pids) {
     Set<Integer> pidSet = Arrays.stream(pids).boxed().collect(Collectors.toSet());
     assertThat(pidSet).hasSize(pids.length);
   }

[11/14] geode git commit: Don't download geode 1.2 every time a build runs

Posted by ud...@apache.org.
Don't download geode 1.2 every time a build runs

Removing the override flag, adding a onlyIf check


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

Branch: refs/heads/feature/GEODE-3416
Commit: 6a7f3625e08875eb6ab886e6ff11f50e76393bec
Parents: 5863fd5
Author: Dan Smith <up...@apache.org>
Authored: Mon Aug 21 15:28:50 2017 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Mon Aug 21 15:29:10 2017 -0700

----------------------------------------------------------------------
 geode-old-versions/build.gradle | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/6a7f3625/geode-old-versions/build.gradle
----------------------------------------------------------------------
diff --git a/geode-old-versions/build.gradle b/geode-old-versions/build.gradle
index 3b7c2e5..7defb69 100644
--- a/geode-old-versions/build.gradle
+++ b/geode-old-versions/build.gradle
@@ -42,14 +42,16 @@ def addOldVersion(def source, def geodeVersion, def downloadInstall) {
 
   task "downloadZipFile${source}" (type: Download) {
     src "https://www.apache.org/dyn/closer.cgi?action=download&filename=geode/$geodeVersion/apache-geode-${geodeVersion}.tar.gz"
-    dest new File(buildDir, "apache-geode-${geodeVersion}.tar.gz")
-    overwrite false
+    def destFile = new File(buildDir, "apache-geode-${geodeVersion}.tar.gz")
+    dest destFile
+    onlyIf {!destFile.exists()}
   }
 
   task "downloadSHA${source}" (type: Download) {
     src "https://www.apache.org/dist/geode/${geodeVersion}/apache-geode-${geodeVersion}.tar.gz.sha256"
-    dest new File(buildDir, "apache-geode-${geodeVersion}.tar.gz.sha256")
-    overwrite false
+    def destFile =  new File(buildDir, "apache-geode-${geodeVersion}.tar.gz.sha256")
+    dest destFile
+    onlyIf {!destFile.exists()}
   }