You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ji...@apache.org on 2016/04/22 19:28:09 UTC

[01/25] incubator-geode git commit: Removing snapshot from the version in preparation from the M2 release

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-17-2 7ed7916ca -> da0bbfec0


Removing snapshot from the version in preparation from the M2 release


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

Branch: refs/heads/feature/GEODE-17-2
Commit: fdfd98fbf074b65c24add59119152071d3297ed9
Parents: bf8c716
Author: Dan Smith <up...@apache.org>
Authored: Mon Apr 11 14:28:25 2016 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Mon Apr 11 14:28:25 2016 -0700

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


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fdfd98fb/gradle.properties
----------------------------------------------------------------------
diff --git a/gradle.properties b/gradle.properties
index 6106175..dc3eebd 100755
--- a/gradle.properties
+++ b/gradle.properties
@@ -18,7 +18,7 @@
 # .M?       - milestone release
 # <blank>   - release
 versionNumber = 1.0.0-incubating
-releaseType = .M2-SNAPSHOT
+releaseType = .M2
 
 org.gradle.daemon = true
 org.gradle.jvmargs = -Xmx2048m


[25/25] incubator-geode git commit: Merge branch 'develop' into feature/GEODE-17-2

Posted by ji...@apache.org.
Merge branch 'develop' into feature/GEODE-17-2

# Conflicts:
#	geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
#	geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
#	geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java


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

Branch: refs/heads/feature/GEODE-17-2
Commit: da0bbfec00395062886137a6550fa2ec7e7a0e30
Parents: 183c48a
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Fri Apr 22 10:26:10 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Fri Apr 22 10:26:10 2016 -0700

----------------------------------------------------------------------
 .../cli/commands/CliCommandTestBase.java        | 34 ++++---------
 .../security/ClientAuthorizationTestCase.java   |  2 +-
 .../cli/commands/ClientCommandsDUnitTest.java   | 53 ++++++++++++--------
 3 files changed, 44 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/da0bbfec/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
index 1c6b6b1..9ddfbbb 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
@@ -21,13 +21,12 @@ import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.io.IOException;
 import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -44,22 +43,9 @@ import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
 import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
 import com.gemstone.gemfire.management.internal.security.JSONAuthorization;
 import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.SerializableCallable;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.junit.runners.Parameterized;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
-import static com.gemstone.gemfire.test.dunit.Assert.*;
-import static com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter;
+import org.junit.runners.Parameterized;
 
 /**
  * Base class for all the CLI/gfsh command dunit tests.
@@ -127,14 +113,15 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
     return shell;
   }
 
-  protected void setUpJMXManagerOnVM(int vm, final Properties props){
-    Object[] result = (Object[]) Host.getHost(0).getVM(vm).invoke( "setUpJmxManagerOnVm0ThenConnect", () -> {
+  protected void setUpJMXManagerOnVM(int vm, final Properties props) {
+    Object[] result = (Object[]) Host.getHost(0).getVM(vm).invoke("setUpJmxManagerOnVm0ThenConnect", () -> {
       final Object[] results = new Object[3];
       final Properties localProps = (props != null ? props : new Properties());
 
       try {
         jmxHost = InetAddress.getLocalHost().getHostName();
-      } catch (UnknownHostException ignore) {
+      }
+      catch (UnknownHostException ignore) {
         jmxHost = "localhost";
       }
 
@@ -153,7 +140,7 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
       localProps.setProperty(DistributionConfig.JMX_MANAGER_PORT_NAME, String.valueOf(jmxPort));
       localProps.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
 
-      if(enableAuth){
+      if (enableAuth) {
         localProps.put(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME,
           JSONAuthorization.class.getName() + ".create");
         localProps.put(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME, JSONAuthorization.class.getName() + ".create");
@@ -170,11 +157,12 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
 
       return results;
     });
+  }
+
   /**
    * Destroy all of the components created for the default setup.
    */
-  @SuppressWarnings("serial")
-  protected final void destroyDefaultSetup() {
+    protected final void destroyDefaultSetup() {
     if (this.shell != null) {
       executeCommand(shell, "exit");
       this.shell.terminate();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/da0bbfec/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
index a41f677..58d3442 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
@@ -776,7 +776,7 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
       } else {
         int[] indices = currentOp.getIndices();
         clientVM.invoke("ClientAuthorizationTestCase.doOp",
-            () -> ClientAuthorizationTestCase.doOp( new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
+            () -> ClientAuthorizationTestCase.doOp( opCode, indices, new Integer(opFlags), new Integer(expectedResult) ));
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/da0bbfec/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
index e551dce..a277162 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
@@ -16,8 +16,31 @@
  */
 package com.gemstone.gemfire.management.internal.cli.commands;
 
-import com.gemstone.gemfire.cache.*;
-import com.gemstone.gemfire.cache.client.*;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.DistributedTestUtils.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
+import static com.gemstone.gemfire.test.dunit.NetworkUtils.*;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import javax.management.ObjectName;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.PartitionAttributesFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
+import com.gemstone.gemfire.cache.client.PoolManager;
 import com.gemstone.gemfire.cache.client.internal.PoolImpl;
 import com.gemstone.gemfire.cache.query.CqAttributesFactory;
 import com.gemstone.gemfire.cache.query.QueryService;
@@ -47,23 +70,11 @@ import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import com.gemstone.gemfire.test.junit.categories.FlakyTest;
 import com.jayway.awaitility.Awaitility;
+
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import javax.management.ObjectName;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import static com.gemstone.gemfire.test.dunit.Assert.*;
-import static com.gemstone.gemfire.test.dunit.DistributedTestUtils.getDUnitLocatorPort;
-import static com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter;
-import static com.gemstone.gemfire.test.dunit.NetworkUtils.getServerHostName;
-
 /**
  * Dunit class for testing gemfire Client commands : list client , describe client
  *
@@ -577,7 +588,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
   private void setupSystemForListClient() throws Exception {
     disconnectAllFromDS();
-    createDefaultSetup(getServerProperties());
+    setUpJmxManagerOnVm0ThenConnect(getServerProperties());
 
     final VM server1 = Host.getHost(0).getVM(1);
     final VM client1 = Host.getHost(0).getVM(2);
@@ -590,7 +601,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
   private void setupSystem() throws Exception {
     disconnectAllFromDS();
-    createDefaultSetup(getServerProperties());
+    setUpJmxManagerOnVm0ThenConnect(getServerProperties());
 
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);
@@ -616,7 +627,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
   private void setupSystem2() throws Exception {
     disconnectAllFromDS();
-    createDefaultSetup(getServerProperties());
+    setUpJmxManagerOnVm0ThenConnect(getServerProperties());
 
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);
@@ -644,7 +655,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
   private void setupSystem3() throws Exception {
     disconnectAllFromDS();
-    createDefaultSetup(getServerProperties());
+    setUpJmxManagerOnVm0ThenConnect(getServerProperties());
 
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);
@@ -1001,7 +1012,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
   private void setUpNonSubscribedClient() throws Exception {
     disconnectAllFromDS();
-    createDefaultSetup(getServerProperties());
+    setUpJmxManagerOnVm0ThenConnect(getServerProperties());
 
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);
@@ -1030,7 +1041,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
   private String[] setupSystemWithSubAndNonSubClient() throws Exception {
     disconnectAllFromDS();
-    createDefaultSetup(getServerProperties());
+    setUpJmxManagerOnVm0ThenConnect(getServerProperties());
 
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);


[10/25] incubator-geode git commit: GEODE-1268: Cleanup of multiple AvailablePort.getRandomAvailablePort invocations

Posted by ji...@apache.org.
GEODE-1268: Cleanup of multiple AvailablePort.getRandomAvailablePort invocations


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 9b0026b2f72e5ac0f79afbba4dec9e6ab1231084
Parents: 79b3544
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Thu Apr 21 08:10:49 2016 +1000
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Apr 22 04:22:40 2016 +1000

----------------------------------------------------------------------
 .../gemfire/distributed/LocatorDUnitTest.java   | 431 +++++++++----------
 .../security/ClientAuthorizationDUnitTest.java  |   6 +-
 .../security/ClientAuthorizationTestCase.java   |  24 +-
 .../DeltaClientPostAuthorizationDUnitTest.java  |   6 +-
 .../security/P2PAuthenticationDUnitTest.java    |   2 -
 .../security/ClientAuthzObjectModDUnitTest.java |  36 +-
 .../ClientCQPostAuthorizationDUnitTest.java     |   8 +-
 .../ClientPostAuthorizationDUnitTest.java       |  11 +-
 .../MultiUserDurableCQAuthzDUnitTest.java       |   8 +-
 .../wan/misc/WANConfigurationJUnitTest.java     |  11 +-
 10 files changed, 266 insertions(+), 277 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
index 3b5f23f..71eb68e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
@@ -16,15 +16,6 @@
  */
 package com.gemstone.gemfire.distributed;
 
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.LineNumberReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
 import com.gemstone.gemfire.ForcedDisconnectException;
 import com.gemstone.gemfire.GemFireConfigException;
 import com.gemstone.gemfire.LogWriter;
@@ -47,6 +38,9 @@ import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.internal.logging.LocalLogWriter;
 import com.gemstone.gemfire.internal.tcp.Connection;
+import com.gemstone.gemfire.test.dunit.*;
+import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import org.junit.experimental.categories.Category;
 
 import java.io.File;
 import java.io.IOException;
@@ -55,23 +49,6 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.test.dunit.AsyncInvocation;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.IgnoredException;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
-import com.gemstone.gemfire.test.dunit.NetworkUtils;
-import com.gemstone.gemfire.test.dunit.SerializableCallable;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-import com.gemstone.gemfire.test.dunit.ThreadUtils;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
-import com.gemstone.gemfire.test.dunit.WaitCriterion;
-import com.gemstone.gemfire.test.junit.categories.FlakyTest;
-
 /**
  * Tests the ability of the {@link Locator} API to start and stop
  * locators running in remote VMs.
@@ -158,11 +135,11 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("mcast-port", "0");
     properties.put("start-locator", locators);
     properties.put("log-level", LogWriterUtils.getDUnitLogLevel());
-    properties.put("security-peer-auth-init","com.gemstone.gemfire.distributed.AuthInitializer.create");
-    properties.put("security-peer-authenticator","com.gemstone.gemfire.distributed.MyAuthenticator.create");
+    properties.put("security-peer-auth-init", "com.gemstone.gemfire.distributed.AuthInitializer.create");
+    properties.put("security-peer-authenticator", "com.gemstone.gemfire.distributed.MyAuthenticator.create");
     properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
     properties.put(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "false");
-    system = (InternalDistributedSystem)DistributedSystem.connect(properties);
+    system = (InternalDistributedSystem) DistributedSystem.connect(properties);
     InternalDistributedMember mbr = system.getDistributedMember();
     assertEquals("expected the VM to have NORMAL vmKind",
         DistributionManager.NORMAL_DM_TYPE, system.getDistributedMember().getVmKind());
@@ -172,7 +149,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("locators", locators);
     SerializableRunnable startSystem = new SerializableRunnable("start system") {
       public void run() {
-        system = (InternalDistributedSystem)DistributedSystem.connect(properties);
+        system = (InternalDistributedSystem) DistributedSystem.connect(properties);
       }
     };
     vm1.invoke(startSystem);
@@ -228,15 +205,15 @@ public class LocatorDUnitTest extends DistributedTestCase {
 
       properties.put("start-locator", locators);
       properties.put("log-level", LogWriterUtils.getDUnitLogLevel());
-      system = (InternalDistributedSystem)DistributedSystem.connect(properties);
+      system = (InternalDistributedSystem) DistributedSystem.connect(properties);
       System.out.println("done connecting distributed system.  Membership view is " +
-        MembershipManagerHelper.getMembershipManager(system).getView());
-      
+          MembershipManagerHelper.getMembershipManager(system).getView());
+
       assertEquals("should be the coordinator", system.getDistributedMember(), MembershipManagerHelper.getCoordinator(system));
       NetView view = MembershipManagerHelper.getMembershipManager(system).getView();
       com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("view after becoming coordinator is " + view);
-      assertNotSame("should not be the first member in the view ("+view+")", system.getDistributedMember(), view.get(0));
-      
+      assertNotSame("should not be the first member in the view (" + view + ")", system.getDistributedMember(), view.get(0));
+
       service = DistributedLockService.create("test service", system);
 
       // now force a non-elder VM to get a lock.  This will hang if the bug is not fixed 
@@ -287,7 +264,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     DistributedTestUtils.deleteLocatorStateFile(port2);
     final String host0 = NetworkUtils.getServerHostName(host);
     final String locators = host0 + "[" + port1 + "]," +
-                            host0 + "[" + port2 + "]";
+        host0 + "[" + port2 + "]";
     final Properties properties = new Properties();
     properties.put("mcast-port", "0");
     properties.put("locators", locators);
@@ -510,7 +487,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     DistributedTestUtils.deleteLocatorStateFile(port1, port2);
     final String host0 = NetworkUtils.getServerHostName(host);
     final String locators = host0 + "[" + port1 + "]," +
-                            host0 + "[" + port2 + "]";
+        host0 + "[" + port2 + "]";
     final Properties properties = new Properties();
     properties.put("mcast-port", "0");
     properties.put("locators", locators);
@@ -518,7 +495,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("disable-auto-reconnect", "true");
     properties.put("member-timeout", "2000");
     properties.put("log-level", LogWriterUtils.getDUnitLogLevel());
-//    properties.put("log-level", "fine");
+    //    properties.put("log-level", "fine");
     properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
 
     try {
@@ -533,8 +510,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
           File lf = new File("");
           try {
             Locator.startLocatorAndDS(port2, lf, properties);
-          }
-          catch (IOException ios) {
+          } catch (IOException ios) {
             com.gemstone.gemfire.test.dunit.Assert.fail("Unable to start locator2", ios);
           }
         }
@@ -584,7 +560,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
        * It will take 3 * (3 * member-timeout) milliseconds to detect the full
        * failure and eject the lost members from the view.
        */
-      
+
       com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("waiting for my distributed system to disconnect due to partition detection");
       WaitCriterion ev = new WaitCriterion() {
         public boolean done() {
@@ -644,7 +620,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     DistributedTestUtils.deleteLocatorStateFile(port1, port2);
     final String host0 = NetworkUtils.getServerHostName(host);
     final String locators = host0 + "[" + port1 + "],"
-          + host0 + "[" + port2 + "]";
+        + host0 + "[" + port2 + "]";
     final Properties properties = new Properties();
     properties.put("mcast-port", "0");
     properties.put("locators", locators);
@@ -666,8 +642,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
           try {
             Locator.startLocatorAndDS(port2, lf, properties);
             MembershipManagerHelper.inhibitForcedDisconnectLogging(true);
-          }
-          catch (IOException ios) {
+          } catch (IOException ios) {
             com.gemstone.gemfire.test.dunit.Assert.fail("Unable to start locator2", ios);
           }
         }
@@ -703,7 +678,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
       vm1.invoke(crashSystem);
 
       Wait.pause(4 * 2000); // 4 x the member-timeout
-      
+
       assertTrue("Distributed system should not have disconnected",
           isSystemConnected());
 
@@ -730,8 +705,8 @@ public class LocatorDUnitTest extends DistributedTestCase {
 
       // the remaining non-locator member should now be the lead member
       assertEquals("This test sometimes fails.  If the log contains " +
-      		"'failed to collect all ACKs' it is a false failure.",
-      		mem2, vm2.invoke(() -> LocatorDUnitTest.getLeadMember()));
+              "'failed to collect all ACKs' it is a false failure.",
+          mem2, vm2.invoke(() -> LocatorDUnitTest.getLeadMember()));
 
       SerializableRunnable disconnect =
           new SerializableRunnable("Disconnect from " + locators) {
@@ -865,7 +840,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
       vm2.invokeAsync(crashSystem);
 
       Wait.pause(1000); // 4 x the member-timeout
-      
+
       // request member removal for first peer from second peer.
       vm2.invoke(new SerializableRunnable("Request Member Removal") {
 
@@ -927,7 +902,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     DistributedTestUtils.deleteLocatorStateFile(port1, port2);
     final String host0 = NetworkUtils.getServerHostName(host);
     final String locators = host0 + "[" + port1 + "],"
-          + host0 + "[" + port2 + "]";
+        + host0 + "[" + port2 + "]";
     final Properties properties = new Properties();
     properties.put("mcast-port", "0");
     properties.put("locators", locators);
@@ -992,7 +967,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
       DistributedMember mem2 = (DistributedMember) vm2.invoke(this.getClass(),
           "getDistributedMember", connectArgs);
 
-      DistributedMember loc1Mbr = (DistributedMember)locvm.invoke(() -> this.getLocatorDistributedMember());
+      DistributedMember loc1Mbr = (DistributedMember) locvm.invoke(() -> this.getLocatorDistributedMember());
 
       assertLeadMember(mem1, sys, 5000);
 
@@ -1015,7 +990,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
       // locator notice the failure and continue to run
       vm1.invoke(disconnect);
       Wait.pause(10 * 1000);
-      
+
       assertTrue("Distributed system should not have disconnected",
           vm2.invoke(() -> LocatorDUnitTest.isSystemConnected()));
 
@@ -1041,7 +1016,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     int port =
-      AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     DistributedTestUtils.deleteLocatorStateFile(port1);
     String locators = NetworkUtils.getServerHostName(host) + "[" + port + "]";
     Properties props = new Properties();
@@ -1075,8 +1050,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
       // if you see this fail, determine if unexpected exception is expected
       // if expected then add in a catch block for it above this catch
       com.gemstone.gemfire.test.dunit.Assert.fail("Failed with unexpected exception", ex);
-    }
-    finally {
+    } finally {
       if (oldValue == null) {
         System.getProperties().remove("p2p.joinTimeout");
       } else {
@@ -1106,7 +1080,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     VM vm2 = host.getVM(2);
 
     final int port =
-      AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     DistributedTestUtils.deleteLocatorStateFile(port1);
     final String locators = NetworkUtils.getServerHostName(host) + "[" + port + "]";
     final String uniqueName = getUniqueName();
@@ -1120,12 +1094,12 @@ public class LocatorDUnitTest extends DistributedTestCase {
           locProps.setProperty("member-timeout", "1000");
           locProps.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
 
-            Locator.startLocatorAndDS(port, logFile, locProps);
-          } catch (IOException ex) {
-            com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port, ex);
-          }
+          Locator.startLocatorAndDS(port, logFile, locProps);
+        } catch (IOException ex) {
+          com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port, ex);
         }
-      });
+      }
+    });
     try {
 
       SerializableRunnable connect =
@@ -1147,33 +1121,33 @@ public class LocatorDUnitTest extends DistributedTestCase {
       props.setProperty("locators", locators);
       props.setProperty("member-timeout", "1000");
 
-    system = (InternalDistributedSystem)DistributedSystem.connect(props);
-    
-    final DistributedMember coord = MembershipManagerHelper.getCoordinator(system);
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator before termination of locator is " + coord);
+      system = (InternalDistributedSystem) DistributedSystem.connect(props);
 
-    vm0.invoke(getStopLocatorRunnable());
-    
-    // now ensure that one of the remaining members became the coordinator
-    WaitCriterion ev = new WaitCriterion() {
-      public boolean done() {
-        return !coord.equals(MembershipManagerHelper.getCoordinator(system));
-      }
-      public String description() {
-        return "expected the coordinator to not be " + coord + " but it is " +
-          MembershipManagerHelper.getCoordinator(system);
+      final DistributedMember coord = MembershipManagerHelper.getCoordinator(system);
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator before termination of locator is " + coord);
+
+      vm0.invoke(getStopLocatorRunnable());
+
+      // now ensure that one of the remaining members became the coordinator
+      WaitCriterion ev = new WaitCriterion() {
+        public boolean done() {
+          return !coord.equals(MembershipManagerHelper.getCoordinator(system));
+        }
+
+        public String description() {
+          return "expected the coordinator to not be " + coord + " but it is " +
+              MembershipManagerHelper.getCoordinator(system);
+        }
+      };
+      Wait.waitForCriterion(ev, 15 * 1000, 200, false);
+      DistributedMember newCoord = MembershipManagerHelper.getCoordinator(system);
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator after shutdown of locator was " +
+          newCoord);
+      if (coord.equals(newCoord)) {
+        fail("another member should have become coordinator after the locator was stopped");
       }
-    };
-    Wait.waitForCriterion(ev, 15 * 1000, 200, false);
-    DistributedMember newCoord = MembershipManagerHelper.getCoordinator(system);
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator after shutdown of locator was " +
-        newCoord);
-    if (coord.equals(newCoord)) {
-      fail("another member should have become coordinator after the locator was stopped");
-    }
-      
 
-    system.disconnect();
+      system.disconnect();
 
       vm1.invoke(getDisconnectRunnable(locators));
       vm2.invoke(getDisconnectRunnable(locators));
@@ -1204,11 +1178,11 @@ public class LocatorDUnitTest extends DistributedTestCase {
     VM vm2 = host.getVM(2);
 
     final int port =
-      AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     DistributedTestUtils.deleteLocatorStateFile(port1);
     final String locators = NetworkUtils.getServerHostName(host) + "[" + port + "]";
-    
-    vm0.invoke(getStartSBLocatorRunnable(port, getUniqueName()+"1"));
+
+    vm0.invoke(getStartSBLocatorRunnable(port, getUniqueName() + "1"));
     try {
 
       final Properties props = new Properties();
@@ -1229,51 +1203,52 @@ public class LocatorDUnitTest extends DistributedTestCase {
 
       system = (InternalDistributedSystem) getSystem(props);
 
-    final DistributedMember coord = MembershipManagerHelper.getCoordinator(system);
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator before termination of locator is " + coord);
+      final DistributedMember coord = MembershipManagerHelper.getCoordinator(system);
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator before termination of locator is " + coord);
 
-    vm0.invoke(getStopLocatorRunnable());
-    
-    // now ensure that one of the remaining members became the coordinator
-    WaitCriterion ev = new WaitCriterion() {
-      public boolean done() {
-        return !coord.equals(MembershipManagerHelper.getCoordinator(system));
-      }
-      public String description() {
-        return "expected the coordinator to be " + coord + " but it is " +
-          MembershipManagerHelper.getCoordinator(system);
-      }
-    };
-    Wait.waitForCriterion(ev, 15000, 200, true);
-    DistributedMember newCoord = MembershipManagerHelper.getCoordinator(system);
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator after shutdown of locator was " +
-        newCoord);
-    if (newCoord == null || coord.equals(newCoord)) {
-      fail("another member should have become coordinator after the locator was stopped: "
-          + newCoord);
-    }
-      
-
-    // restart the locator to demonstrate reconnection & make disconnects faster
-    // it should also regain the role of coordinator, so we check to make sure
-    // that the coordinator has changed
-    vm0.invoke(getStartSBLocatorRunnable(port, getUniqueName()+"2"));
-    
-    final DistributedMember tempCoord = newCoord;
-    ev = new WaitCriterion() {
-      public boolean done() {
-        return !tempCoord.equals(MembershipManagerHelper.getCoordinator(system));
-      }
-      public String description() {
-        return null;
+      vm0.invoke(getStopLocatorRunnable());
+
+      // now ensure that one of the remaining members became the coordinator
+      WaitCriterion ev = new WaitCriterion() {
+        public boolean done() {
+          return !coord.equals(MembershipManagerHelper.getCoordinator(system));
+        }
+
+        public String description() {
+          return "expected the coordinator to be " + coord + " but it is " +
+              MembershipManagerHelper.getCoordinator(system);
+        }
+      };
+      Wait.waitForCriterion(ev, 15000, 200, true);
+      DistributedMember newCoord = MembershipManagerHelper.getCoordinator(system);
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator after shutdown of locator was " +
+          newCoord);
+      if (newCoord == null || coord.equals(newCoord)) {
+        fail("another member should have become coordinator after the locator was stopped: "
+            + newCoord);
       }
-    };
-    Wait.waitForCriterion(ev, 5000, 200, true);
-    
-    system.disconnect();
-    LogWriter bgexecLogger =
-      new LocalLogWriter(InternalLogWriter.ALL_LEVEL, System.out);
-    bgexecLogger.info(removeExpected);
+
+      // restart the locator to demonstrate reconnection & make disconnects faster
+      // it should also regain the role of coordinator, so we check to make sure
+      // that the coordinator has changed
+      vm0.invoke(getStartSBLocatorRunnable(port, getUniqueName() + "2"));
+
+      final DistributedMember tempCoord = newCoord;
+      ev = new WaitCriterion() {
+        public boolean done() {
+          return !tempCoord.equals(MembershipManagerHelper.getCoordinator(system));
+        }
+
+        public String description() {
+          return null;
+        }
+      };
+      Wait.waitForCriterion(ev, 5000, 200, true);
+
+      system.disconnect();
+      LogWriter bgexecLogger =
+          new LocalLogWriter(InternalLogWriter.ALL_LEVEL, System.out);
+      bgexecLogger.info(removeExpected);
 
       SerializableRunnable disconnect =
           new SerializableRunnable("Disconnect from " + locators) {
@@ -1298,13 +1273,16 @@ public class LocatorDUnitTest extends DistributedTestCase {
 
   }
 
-  
-  /** set a short locator refresh rate */
+  /**
+   * set a short locator refresh rate
+   */
   public static void setShortRefreshWait() {
     System.setProperty("p2p.gossipRefreshRate", "2000");
   }
-  
-  /** remove shortened locator refresh rate */
+
+  /**
+   * remove shortened locator refresh rate
+   */
   public static void resetRefreshWait() {
     System.getProperties().remove("p2p.gossipRefreshRate");
   }
@@ -1631,49 +1609,47 @@ public class LocatorDUnitTest extends DistributedTestCase {
     this.port2 = port2;
     DistributedTestUtils.deleteLocatorStateFile(port1, port2);
     final int mcastport = AvailablePort.getRandomAvailablePort(AvailablePort.MULTICAST);
-    
+
     final String host0 = NetworkUtils.getServerHostName(host);
     final String locators = host0 + "[" + port1 + "]," +
         host0 + "[" + port2 + "]";
     final String uniqueName = getUniqueName();
 
     vm0.invoke(new SerializableRunnable("Start locator on " + port1) {
-        public void run() {
-          File logFile = new File("");
-          try {
-            Properties props = new Properties();
-            props.setProperty("mcast-port", String.valueOf(mcastport));
-            props.setProperty("locators", locators);
-            props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
-            props.setProperty("mcast-ttl", "0");
-            props.setProperty("enable-network-partition-detection", "true");
-            props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
-
-            Locator.startLocatorAndDS(port1, logFile, null, props);
-          }
-          catch (IOException ex) {
-            com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port1, ex);
-          }
+      public void run() {
+        File logFile = new File("");
+        try {
+          Properties props = new Properties();
+          props.setProperty("mcast-port", String.valueOf(mcastport));
+          props.setProperty("locators", locators);
+          props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
+          props.setProperty("mcast-ttl", "0");
+          props.setProperty("enable-network-partition-detection", "true");
+          props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
+
+          Locator.startLocatorAndDS(port1, logFile, null, props);
+        } catch (IOException ex) {
+          com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port1, ex);
         }
-      });
+      }
+    });
     vm3.invoke(new SerializableRunnable("Start locator on " + port2) {
-        public void run() {
-          File logFile = new File("");
-          try {
-            Properties props = new Properties();
-            props.setProperty("mcast-port", String.valueOf(mcastport));
-            props.setProperty("locators", locators);
-            props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
-            props.setProperty("mcast-ttl", "0");
-            props.setProperty("enable-network-partition-detection", "true");
-            props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
-            Locator.startLocatorAndDS(port2, logFile, null, props);
-          }
-          catch (IOException ex) {
-            com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port2, ex);
-          }
+      public void run() {
+        File logFile = new File("");
+        try {
+          Properties props = new Properties();
+          props.setProperty("mcast-port", String.valueOf(mcastport));
+          props.setProperty("locators", locators);
+          props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
+          props.setProperty("mcast-ttl", "0");
+          props.setProperty("enable-network-partition-detection", "true");
+          props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
+          Locator.startLocatorAndDS(port2, logFile, null, props);
+        } catch (IOException ex) {
+          com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port2, ex);
         }
-      });
+      }
+    });
 
     SerializableRunnable connect =
         new SerializableRunnable("Connect to " + locators) {
@@ -1737,13 +1713,13 @@ public class LocatorDUnitTest extends DistributedTestCase {
     Host host = Host.getHost(0);
 
     port1 =
-      AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     DistributedTestUtils.deleteLocatorStateFile(port1);
     File logFile = new File("");
     Locator locator = Locator.startLocator(port1, logFile);
     try {
 
-    final String locators = NetworkUtils.getServerHostName(host) + "[" + port1 + "]";
+      final String locators = NetworkUtils.getServerHostName(host) + "[" + port1 + "]";
 
       Properties props = new Properties();
       props.setProperty("mcast-port", "0");
@@ -1838,43 +1814,41 @@ public class LocatorDUnitTest extends DistributedTestCase {
     Host host = Host.getHost(0);
     //VM vm = host.getVM(0);
     //VM vm1 = host.getVM(1);
-
-    port1 =
-        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    port1 = randomAvailableTCPPorts[0];
     File logFile1 = new File("");
     DistributedTestUtils.deleteLocatorStateFile(port1);
     Locator locator1 = Locator.startLocator(port1, logFile1);
 
     try {
 
-      int port2 =
-          AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+      int port2 = randomAvailableTCPPorts[1];
       File logFile2 = new File("");
 
-    DistributedTestUtils.deleteLocatorStateFile(port2);
-    
-    try {
-      Locator locator2 = Locator.startLocator(port2, logFile2);
-      fail("expected second locator start to fail.");
-    } catch (IllegalStateException expected) {
-    }
+      DistributedTestUtils.deleteLocatorStateFile(port2);
 
-    final String host0 = NetworkUtils.getServerHostName(host);
-    final String locators = host0 + "[" + port1 + "]," +
-                            host0 + "[" + port2 + "]";
+      try {
+        Locator locator2 = Locator.startLocator(port2, logFile2);
+        fail("expected second locator start to fail.");
+      } catch (IllegalStateException expected) {
+      }
 
-    SerializableRunnable connect =
-      new SerializableRunnable("Connect to " + locators) {
-          public void run() {
-            Properties props = new Properties();
-            props.setProperty("mcast-port", "0");
-            props.setProperty("locators", locators);
-            props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
-            DistributedSystem.connect(props);
-          }
-        };
-    connect.run();
-    //vm1.invoke(connect);
+      final String host0 = NetworkUtils.getServerHostName(host);
+      final String locators = host0 + "[" + port1 + "]," +
+          host0 + "[" + port2 + "]";
+
+      SerializableRunnable connect =
+          new SerializableRunnable("Connect to " + locators) {
+            public void run() {
+              Properties props = new Properties();
+              props.setProperty("mcast-port", "0");
+              props.setProperty("locators", locators);
+              props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
+              DistributedSystem.connect(props);
+            }
+          };
+      connect.run();
+      //vm1.invoke(connect);
 
       SerializableRunnable disconnect = getDisconnectRunnable(locators);
 
@@ -1895,7 +1869,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
   public void testRestartLocator() throws Exception {
     disconnectAllFromDS();
     port1 =
-      AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     DistributedTestUtils.deleteLocatorStateFile(port1);
     File logFile = new File("");
     File stateFile = new File("locator" + port1 + "state.dat");
@@ -1911,34 +1885,36 @@ public class LocatorDUnitTest extends DistributedTestCase {
     com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Starting locator");
     Locator locator = Locator.startLocatorAndDS(port1, logFile, p);
     try {
-    
-    SerializableRunnable connect =
-      new SerializableRunnable("Connect to locator on port " + port1) {
-          public void run() {
-            DistributedSystem.connect(p);
-          }
-        };
-    vm0.invoke(connect);
-    
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Stopping locator");
-    locator.stop();
 
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Starting locator");
-    locator = Locator.startLocatorAndDS(port1, logFile, p);
-    
-    vm0.invoke(new SerializableRunnable("disconnect") {
-      public void run() {
-        DistributedSystem.connect(p).disconnect();
-      }
-    });
-    
+      SerializableRunnable connect =
+          new SerializableRunnable("Connect to locator on port " + port1) {
+            public void run() {
+              DistributedSystem.connect(p);
+            }
+          };
+      vm0.invoke(connect);
+
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Stopping locator");
+      locator.stop();
+
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Starting locator");
+      locator = Locator.startLocatorAndDS(port1, logFile, p);
+
+      vm0.invoke(new SerializableRunnable("disconnect") {
+        public void run() {
+          DistributedSystem.connect(p).disconnect();
+        }
+      });
+
     } finally {
       locator.stop();
     }
 
   }
-  
-  /** return the distributed member id for the ds on this vm */
+
+  /**
+   * return the distributed member id for the ds on this vm
+   */
   public static DistributedMember getDistributedMember(Properties props) {
     props.put("name", "vm_" + VM.getCurrentVMNum());
     DistributedSystem sys = DistributedSystem.connect(props);
@@ -1947,14 +1923,18 @@ public class LocatorDUnitTest extends DistributedTestCase {
     sys.getLogWriter().info("<ExpectedException action=add>com.gemstone.gemfire.ForcedDisconnectException</ExpectedException>");
     return DistributedSystem.connect(props).getDistributedMember();
   }
-  
-  /** find a running locator and return its distributed member id */
+
+  /**
+   * find a running locator and return its distributed member id
+   */
   public static DistributedMember getLocatorDistributedMember() {
     return (Locator.getLocators().iterator().next())
         .getDistributedSystem().getDistributedMember();
   }
-  
-  /** find the lead member and return its id */
+
+  /**
+   * find the lead member and return its id
+   */
   public static DistributedMember getLeadMember() {
     DistributedSystem sys = InternalDistributedSystem.getAnyInstance();
     return MembershipManagerHelper.getLeadMember(sys);
@@ -1986,8 +1966,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
           Locator.startLocatorAndDS(port, logFile, locProps);
         } catch (IOException ex) {
           com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port, ex);
-        }
-        finally {
+        } finally {
           System.getProperties().remove(InternalLocator.LOCATORS_PREFERRED_AS_COORDINATORS);
           System.getProperties().remove("p2p.joinTimeout");
         }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
index 961e844..711be43 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
@@ -29,6 +29,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -355,8 +356,9 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestCase {
     Properties serverProps = buildProperties(authenticator, accessor, false, extraAuthProps, extraAuthzProps);
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 = getRandomAvailablePort(SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
 
     // Perform all the ops on the clients
     List opBlock = new ArrayList();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
index 4cc8155..7a4308f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
@@ -56,6 +56,7 @@ import com.gemstone.gemfire.cache.query.QueryService;
 import com.gemstone.gemfire.cache.query.SelectResults;
 import com.gemstone.gemfire.cache.query.Struct;
 import com.gemstone.gemfire.internal.AvailablePort.*;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.cache.AbstractRegionEntry;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
@@ -756,7 +757,8 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
         if (useThisVM) {
           SecurityTestUtils.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION);
         } else {
-          clientVM.invoke(() -> SecurityTestUtils.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION));
+          clientVM.invoke("SecurityTestUtils.createCacheClientWithDynamicRegion",
+              () -> SecurityTestUtils.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION));
         }
       }
 
@@ -775,7 +777,8 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
       } else {
         byte ordinal = opCode.toOrdinal();
         int[] indices = currentOp.getIndices();
-        clientVM.invoke(() -> ClientAuthorizationTestCase.doOp( new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
+        clientVM.invoke("ClientAuthorizationTestCase.doOp",
+            () -> ClientAuthorizationTestCase.doOp( new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
       }
     }
   }
@@ -828,10 +831,11 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
     Properties serverProps = buildProperties(authenticator, accessor, false, extraAuthProps, extraAuthzProps);
 
     // Get ports for the servers
-    Keeper locator1PortKeeper = getRandomAvailablePortKeeper(SOCKET);
-    Keeper locator2PortKeeper = getRandomAvailablePortKeeper(SOCKET);
-    Keeper port1Keeper = getRandomAvailablePortKeeper(SOCKET);
-    Keeper port2Keeper = getRandomAvailablePortKeeper(SOCKET);
+    List<Keeper> randomAvailableTCPPortKeepers = AvailablePortHelper.getRandomAvailableTCPPortKeepers(4);
+    Keeper locator1PortKeeper = randomAvailableTCPPortKeepers.get(0);
+    Keeper locator2PortKeeper = randomAvailableTCPPortKeepers.get(1);
+    Keeper port1Keeper = randomAvailableTCPPortKeepers.get(2);
+    Keeper port2Keeper = randomAvailableTCPPortKeepers.get(3);
     int locator1Port = locator1PortKeeper.getPort();
     int locator2Port = locator2PortKeeper.getPort();
     int port1 = port1Keeper.getPort();
@@ -852,8 +856,8 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
           port1Keeper.release();
 
           // Start the first server and execute the operation block
-          server1.invoke(() -> ClientAuthorizationTestCase.createCacheServer(locator1Port, port1, serverProps, javaProps ));
-          server2.invoke(() -> closeCache());
+          server1.invoke("createCacheServer", () -> ClientAuthorizationTestCase.createCacheServer(locator1Port, port1, serverProps, javaProps ));
+          server2.invoke("closeCache", () -> closeCache());
 
           executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
 
@@ -862,8 +866,8 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
             locator2PortKeeper.release();
             port2Keeper.release();
 
-            server2.invoke(() -> ClientAuthorizationTestCase.createCacheServer(locator2Port, port2, serverProps, javaProps ));
-            server1.invoke(() -> closeCache());
+            server2.invoke("createCacheServer", () -> ClientAuthorizationTestCase.createCacheServer(locator2Port, port2, serverProps, javaProps ));
+            server1.invoke("closeCache", () -> closeCache());
 
             executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
           }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
index 61ff55a..dcc087b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
@@ -30,6 +30,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Random;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -86,8 +87,9 @@ public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTe
     Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 = getRandomAvailablePort(SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
 
     // Perform all the ops on the clients
     List opBlock = new ArrayList();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
index 56f5186..31184aa 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
@@ -326,8 +326,6 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
   @Ignore("disabled for some reason?")
   @Test
   public void testP2PViewChangeReject() throws Exception {
-    int locatorPort = getRandomAvailablePort(SOCKET);
-
     final Host host = Host.getHost(0);
     final VM peer2 = host.getVM(1);
     final VM peer3 = host.getVM(2);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
index 012ac33..4f121f3 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
@@ -17,15 +17,14 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
-import static com.gemstone.gemfire.internal.AvailablePort.*;
 import static com.gemstone.gemfire.security.SecurityTestUtils.*;
-import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
 import java.util.Random;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -39,7 +38,6 @@ import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.security.generator.DummyAuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
 import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import com.gemstone.gemfire.test.junit.categories.FlakyTest;
 import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@@ -72,13 +70,8 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
     //this would be automatically registered in the static initializer, but with dunit
     //a previous test may have already loaded these classes. We clear the instantiators
     //between each test.
-    SerializableRunnable registerInstantiator = new SerializableRunnable() {
-      public void run() {
-        Instantiator.register(new MyInstantiator(), false);
-      }
-    };
-    server1.invoke(registerInstantiator);
-    server2.invoke(registerInstantiator);
+    server1.invoke("registerInstantiator", () -> Instantiator.register(new MyInstantiator(), false));
+    server2.invoke("registerInstantiator", () -> Instantiator.register(new MyInstantiator(), false));
   }
 
   @Category(FlakyTest.class) // GEODE-1228: random ports, BindException, uses Random
@@ -95,20 +88,21 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
     String authInit = credentialGenerator.getAuthInit();
     String authenticator = credentialGenerator.getAuthenticator();
 
-    getLogWriter().info("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
-    getLogWriter().info("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
-    getLogWriter().info("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
-    getLogWriter().info("testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
+    System.out.println("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
+    System.out.println("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
+    System.out.println("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
+    System.out.println("testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
 
     // Start servers with all required properties
     Properties serverProps = buildProperties(authenticator, extraProps, preAccessor, postAccessor);
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 =getRandomAvailablePort(SOCKET);
+    int[] portsList = AvailablePortHelper.getRandomAvailableTCPPortsForDUnitSite(2);
+    int port1 = portsList[0];
+    int port2 = portsList[1];
 
     // Perform all the ops on the clients
-    List opBlock = new ArrayList();
+    List<OperationWithAction> opBlock = new ArrayList();
     Random rnd = new Random();
 
     for (int opNum = 0; opNum < allOps.length; ++opNum) {
@@ -118,13 +112,13 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
         // End of current operation block; execute all the operations on the servers with failover
         if (opBlock.size() > 0) {
           // Start the first server and execute the operation block
-          server1.invoke(() -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps ));
-          server2.invoke(() -> closeCache());
+          server1.invoke("createCacheServer", () -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps ));
+          server2.invoke("closeCache", () -> closeCache());
           executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
           if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
             // Failover to the second server and run the block again
-            server2.invoke(() -> createCacheServer(getLocatorPort(), port2, serverProps, javaProps ));
-            server1.invoke(() -> closeCache());
+            server2.invoke("createCacheServer", () -> createCacheServer(getLocatorPort(), port2, serverProps, javaProps ));
+            server1.invoke("closeCache", () -> closeCache());
             executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
           }
           opBlock.clear();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
index e3e7886..41019f1 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Random;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -171,9 +172,10 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestC
     }
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 = getRandomAvailablePort(SOCKET);
-    int locatorPort = getRandomAvailablePort(SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(3);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
+    int locatorPort = randomAvailableTCPPorts[2];
 
     // Close down any running servers
     server1.invoke(() -> closeCache());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
index 963d2f0..03528fd 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Random;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -73,8 +74,9 @@ public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestCas
       Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
 
       // Get ports for the servers
-      int port1 = getRandomAvailablePort(SOCKET);
-      int port2 = getRandomAvailablePort(SOCKET);
+      int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+      int port1 = randomAvailableTCPPorts[0];
+      int port2 = randomAvailableTCPPorts[1];
 
       // Close down any running servers
       server1.invoke(() -> closeCache());
@@ -137,8 +139,9 @@ public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestCas
     Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 = getRandomAvailablePort(SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
 
     // Perform all the ops on the clients
     List opBlock = new ArrayList();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
index 3a97b7c..54cf8c2 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Random;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -192,9 +193,10 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestCas
     }
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 = getRandomAvailablePort(SOCKET);
-    int locatorPort = getRandomAvailablePort(SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
+    int locatorPort = randomAvailableTCPPorts[2];
 
     // Close down any running servers
     server1.invoke(() -> closeCache());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANConfigurationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANConfigurationJUnitTest.java b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANConfigurationJUnitTest.java
index 84eb365..22c129e 100644
--- a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANConfigurationJUnitTest.java
+++ b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANConfigurationJUnitTest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.After;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -223,8 +224,9 @@ public class WANConfigurationJUnitTest {
   @Test
   public void test_ValidateGatewayReceiverAttributes() {
     cache = new CacheFactory().set("mcast-port", "0").create();
-    int port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    int port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
     
     GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
     if(port1 < port2){
@@ -264,8 +266,9 @@ public class WANConfigurationJUnitTest {
   @Test
   public void test_ValidateGatewayReceiverStatus() {
     cache = new CacheFactory().set("mcast-port", "0").create();
-    int port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    int port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
     
     GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
     if(port1 < port2){


[14/25] incubator-geode git commit: GEODE-1146: Test cleanup, converting many VM invoke statements to lambda expressions

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e1656b0/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
index 223e4b4..ce08b52 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
@@ -16,25 +16,13 @@
  */
 package com.gemstone.gemfire.cache.query.dunit;
 
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-
 import cacheRunner.Portfolio;
 import cacheRunner.Position;
 import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.DataSerializable;
 import com.gemstone.gemfire.DataSerializer;
-import com.gemstone.gemfire.cache.AttributesFactory;
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheException;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.cache.*;
 import com.gemstone.gemfire.cache.client.PoolFactory;
 import com.gemstone.gemfire.cache.client.PoolManager;
 import com.gemstone.gemfire.cache.query.*;
@@ -43,12 +31,9 @@ import com.gemstone.gemfire.cache.query.internal.QueryObserverAdapter;
 import com.gemstone.gemfire.cache.query.internal.QueryObserverHolder;
 import com.gemstone.gemfire.cache.query.types.ObjectType;
 import com.gemstone.gemfire.cache.server.CacheServer;
-import com.gemstone.gemfire.cache30.ClientServerTestCase;
 import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
 import com.gemstone.gemfire.cache30.CacheTestCase;
-import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.cache30.ClientServerTestCase;
 import com.gemstone.gemfire.internal.cache.tier.sockets.CacheClientNotifier;
 import com.gemstone.gemfire.test.dunit.Assert;
 import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
@@ -68,15 +53,17 @@ import com.gemstone.gemfire.test.junit.categories.FlakyTest;
  */
 public class QueryUsingPoolDUnitTest extends CacheTestCase {
 
-  /** The port on which the bridge server was started in this VM */
+  /**
+   * The port on which the bridge server was started in this VM
+   */
   private static int bridgeServerPort;
-  
+
   final String rootRegionName = "root";
-  
+
   private final String regionName = this.getName();
-  
+
   private final String regName = "/" + rootRegionName + "/" + regionName;
-  
+
   // Used with compiled queries.
   private final String[] queryString = new String[] {
       "SELECT itr.value FROM " + regName + ".entries itr where itr.key = $1", // 0
@@ -108,50 +95,42 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     disconnectAllFromDS();
   }
 
-  public void createPool(VM vm, String poolName, String server, int port, boolean subscriptionEnabled) {
-    createPool(vm, poolName, new String[]{server}, new int[]{port}, subscriptionEnabled);  
+  public void createPool(String poolName, String server, int port, boolean subscriptionEnabled) {
+    createPool(poolName, new String[] { server }, new int[] { port }, subscriptionEnabled);
   }
 
-  public void createPool(VM vm, String poolName, String server, int port) {
-    createPool(vm, poolName, new String[]{server}, new int[]{port}, false);  
+  public void createPool(String poolName, String server, int port) {
+    createPool(poolName, new String[] { server }, new int[] { port }, false);
   }
 
-  public void createPool(VM vm, final String poolName, final String[] servers, final int[] ports,
+  public void createPool(final String poolName, final String[] servers, final int[] ports,
       final boolean subscriptionEnabled) {
-    vm.invoke(new CacheSerializableRunnable("createPool :" + poolName) {
-      public void run2() throws CacheException {
-        // Create Cache.
-        getCache();
-
-        PoolFactory cpf = PoolManager.createFactory();
-        cpf.setSubscriptionEnabled(subscriptionEnabled);
-        for (int i=0; i < servers.length; i++){
-          LogWriterUtils.getLogWriter().info("### Adding to Pool. ### Server : " + servers[i] + " Port : " + ports[i]);
-          cpf.addServer(servers[i], ports[i]);
-        }
+    // Create Cache.
+    getCache();
+
+    PoolFactory cpf = PoolManager.createFactory();
+    cpf.setSubscriptionEnabled(subscriptionEnabled);
+    for (int i = 0; i < servers.length; i++) {
+      LogWriterUtils.getLogWriter().info("### Adding to Pool. ### Server : " + servers[i] + " Port : " + ports[i]);
+      cpf.addServer(servers[i], ports[i]);
+    }
 
-        cpf.create(poolName);
-      }
-    });   
+    cpf.create(poolName);
   }
 
-  public void validateCompiledQuery(VM vm, final long compiledQueryCount) {
-  vm.invoke(new CacheSerializableRunnable("validate compiled query.") {
-    public void run2() throws CacheException {
-      long count = 0;
-      for (int i=0; i < 100; i++) {
-        count = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        if (count == compiledQueryCount){
-          break;
-        } else {
-          Wait.pause(1 * 100);
-        }
+  public void validateCompiledQuery(final long compiledQueryCount) {
+    long count = 0;
+    for (int i = 0; i < 100; i++) {
+      count = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      if (count == compiledQueryCount) {
+        break;
+      } else {
+        Wait.pause(1 * 100);
       }
-      assertEquals(compiledQueryCount, count);
     }
-  });
- }
-  
+    assertEquals(compiledQueryCount, count);
+  }
+
   /**
    * Tests remote import query execution.
    */
@@ -166,127 +145,116 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Properties config = new Properties();
-        config.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
-        InternalDistributedSystem system = getSystem(config);
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        createRegion(name, rootRegionName, factory.create());
-        Wait.pause(1000);
-        try {
-          startBridgeServer(0, false);
-        } catch (Exception ex) {
-          Assert.fail("While starting CacheServer", ex);
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Properties config = new Properties();
+      config.setProperty("locators", "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
+      getSystem(config);
+      AttributesFactory factory = new AttributesFactory();
+      factory.setScope(Scope.LOCAL);
+      createRegion(name, rootRegionName, factory.create());
+      Wait.pause(1000);
+      try {
+        startBridgeServer(0, false);
+      } catch (Exception ex) {
+        Assert.fail("While starting CacheServer", ex);
       }
     });
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
-
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("GetCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
     final String regionName = "/" + rootRegionName + "/" + name;
 
     // Create client pool.
-    final String poolName = "testRemoteImportQueries"; 
-    createPool(vm1, poolName, host0, port);
+    final String poolName = "testRemoteImportQueries";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        String queryString = null;
-        SelectResults results = null;
+    vm1.invoke("Execute queries", () -> {
+      String queryString = null;
+      SelectResults results = null;
 
-        QueryService qService = null;
+      QueryService qService = null;
 
-        try {
-          qService = (PoolManager.find(poolName)).getQueryService();
-        } catch (Exception e) {
-          Assert.fail("Failed to get QueryService.", e);
-        }          
+      try {
+        qService = (PoolManager.find(poolName)).getQueryService();
+      } catch (Exception e) {
+        Assert.fail("Failed to get QueryService.", e);
+      }
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName;
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName;
 
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }          
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
 
-        assertEquals(numberOfEntries, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      assertEquals(numberOfEntries, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where ticker = 'ibm'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where ticker = 'ibm'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where ticker = 'IBM'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(0, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where ticker = 'IBM'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(0, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where price > 49";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries/2, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where price > 49";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries / 2, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where price = 50";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where price = 50";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where ticker = 'ibm' and price = 50";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName
+          + " where ticker = 'ibm' and price = 50";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
       }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
     });
 
-
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -303,124 +271,119 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Properties config = new Properties();
-        config.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
-        getSystem(config);
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        createRegion(name, factory.create());
-        Wait.pause(1000);
-        try {
-          startBridgeServer(0, false);
-        } catch (Exception ex) {
-          Assert.fail("While starting CacheServer", ex);
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Properties config = new Properties();
+      config.setProperty("locators", "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
+      getSystem(config);
+      AttributesFactory factory = new AttributesFactory();
+      factory.setScope(Scope.LOCAL);
+      createRegion(name, factory.create());
+      Wait.pause(1000);
+      try {
+        startBridgeServer(0, false);
+      } catch (Exception ex) {
+        Assert.fail("While starting CacheServer", ex);
       }
     });
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("GetCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
     final String regionName = "/" + rootRegionName + "/" + name;
 
     // Create client pool.
-    final String poolName = "testRemoteStructQueries"; 
-    createPool(vm1, poolName, host0, port);
+    final String poolName = "testRemoteStructQueries";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        String queryString = null;
-        SelectResults results = null;
+    vm1.invoke("Execute queries", () -> {
+      String queryString = null;
+      SelectResults results = null;
 
-        QueryService qService = null;
+      QueryService qService = null;
 
-        try {
-          qService = (PoolManager.find(poolName)).getQueryService();
-        } catch (Exception e) {
-          Assert.fail("Failed to get QueryService.", e);
-        }          
+      try {
+        qService = (PoolManager.find(poolName)).getQueryService();
+      } catch (Exception e) {
+        Assert.fail("Failed to get QueryService.", e);
+      }
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName;
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName;
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where ticker = 'ibm'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString =
+          "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where ticker = 'ibm'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where ticker = 'IBM'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(0, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString =
+          "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where ticker = 'IBM'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(0, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where price > 49";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries/2, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString =
+          "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where price > 49";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries / 2, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where price = 50";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString =
+          "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where price = 50";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where ticker = 'ibm' and price = 50";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName
+          + " where ticker = 'ibm' and price = 50";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
       }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
     });
 
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -432,189 +395,176 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
-//    final int numberOfEntries = 100;
+    //    final int numberOfEntries = 100;
 
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Properties config = new Properties();
-        config.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
-        getSystem(config);
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        createRegion(name, factory.create());
-        Wait.pause(1000);
-        try {
-          startBridgeServer(0, false);
-        } catch (Exception ex) {
-          Assert.fail("While starting CacheServer", ex);
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Properties config = new Properties();
+      config.setProperty("locators", "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
+      getSystem(config);
+      AttributesFactory factory = new AttributesFactory();
+      factory.setScope(Scope.LOCAL);
+      createRegion(name, factory.create());
+      Wait.pause(1000);
+      try {
+        startBridgeServer(0, false);
+      } catch (Exception ex) {
+        Assert.fail("While starting CacheServer", ex);
       }
     });
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        Portfolio portfolio = null;
-        Position position1 = null;
-        Position position2 = null;
-        Properties portfolioProperties= null;
-        Properties position1Properties = null;
-        Properties position2Properties = null;
-
-        // Create portfolio 1
-        portfolio = new Portfolio();
-        portfolioProperties = new Properties();
-        portfolioProperties.put("id", new Integer(1));
-        portfolioProperties.put("type", "type1");
-        portfolioProperties.put("status", "active");
-
-        position1 = new Position();
-        position1Properties = new Properties();
-        position1Properties.put("secId", "SUN");
-        position1Properties.put("qty", new Double(34000.0));
-        position1Properties.put("mktValue", new Double(24.42));
-        position1.init(position1Properties);
-        portfolioProperties.put("position1", position1);
-
-        position2 = new Position();
-        position2Properties = new Properties();
-        position2Properties.put("secId", "IBM");
-        position2Properties.put("qty", new Double(8765.0));
-        position2Properties.put("mktValue", new Double(34.29));
-        position2.init(position2Properties);
-        portfolioProperties.put("position2", position2);
-
-        portfolio.init(portfolioProperties);
-        region.put(new Integer(1), portfolio);
-
-        // Create portfolio 2
-        portfolio = new Portfolio();
-        portfolioProperties = new Properties();
-        portfolioProperties.put("id", new Integer(2));
-        portfolioProperties.put("type", "type2");
-        portfolioProperties.put("status", "inactive");
-
-        position1 = new Position();
-        position1Properties = new Properties();
-        position1Properties.put("secId", "YHOO");
-        position1Properties.put("qty", new Double(9834.0));
-        position1Properties.put("mktValue", new Double(12.925));
-        position1.init(position1Properties);
-        portfolioProperties.put("position1", position1);
-
-        position2 = new Position();
-        position2Properties = new Properties();
-        position2Properties.put("secId", "GOOG");
-        position2Properties.put("qty", new Double(12176.0));
-        position2Properties.put("mktValue", new Double(21.972));
-        position2.init(position2Properties);
-        portfolioProperties.put("position2", position2);
-
-        portfolio.init(portfolioProperties);
-        region.put(new Integer(2), portfolio);
-
-        // Create portfolio 3
-        portfolio = new Portfolio();
-        portfolioProperties = new Properties();
-        portfolioProperties.put("id", new Integer(3));
-        portfolioProperties.put("type", "type3");
-        portfolioProperties.put("status", "active");
-
-        position1 = new Position();
-        position1Properties = new Properties();
-        position1Properties.put("secId", "MSFT");
-        position1Properties.put("qty", new Double(98327.0));
-        position1Properties.put("mktValue", new Double(23.32));
-        position1.init(position1Properties);
-        portfolioProperties.put("position1", position1);
-
-        position2 = new Position();
-        position2Properties = new Properties();
-        position2Properties.put("secId", "AOL");
-        position2Properties.put("qty", new Double(978.0));
-        position2Properties.put("mktValue", new Double(40.373));
-        position2.init(position2Properties);
-        portfolioProperties.put("position2", position2);
-
-        portfolio.init(portfolioProperties);
-        region.put(new Integer(3), portfolio);
-
-        // Create portfolio 4
-        portfolio = new Portfolio();
-        portfolioProperties = new Properties();
-        portfolioProperties.put("id", new Integer(4));
-        portfolioProperties.put("type", "type1");
-        portfolioProperties.put("status", "inactive");
-
-        position1 = new Position();
-        position1Properties = new Properties();
-        position1Properties.put("secId", "APPL");
-        position1Properties.put("qty", new Double(90.0));
-        position1Properties.put("mktValue", new Double(67.356572));
-        position1.init(position1Properties);
-        portfolioProperties.put("position1", position1);
-
-        position2 = new Position();
-        position2Properties = new Properties();
-        position2Properties.put("secId", "ORCL");
-        position2Properties.put("qty", new Double(376.0));
-        position2Properties.put("mktValue", new Double(101.34));
-        position2.init(position2Properties);
-        portfolioProperties.put("position2", position2);
-
-        portfolio.init(portfolioProperties);
-        region.put(new Integer(4), portfolio);
-      }
+    vm0.invoke("Create Bridge Server", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      Portfolio portfolio = null;
+      Position position1 = null;
+      Position position2 = null;
+      Properties portfolioProperties = null;
+      Properties position1Properties = null;
+      Properties position2Properties = null;
+
+      // Create portfolio 1
+      portfolio = new Portfolio();
+      portfolioProperties = new Properties();
+      portfolioProperties.put("id", new Integer(1));
+      portfolioProperties.put("type", "type1");
+      portfolioProperties.put("status", "active");
+
+      position1 = new Position();
+      position1Properties = new Properties();
+      position1Properties.put("secId", "SUN");
+      position1Properties.put("qty", new Double(34000.0));
+      position1Properties.put("mktValue", new Double(24.42));
+      position1.init(position1Properties);
+      portfolioProperties.put("position1", position1);
+
+      position2 = new Position();
+      position2Properties = new Properties();
+      position2Properties.put("secId", "IBM");
+      position2Properties.put("qty", new Double(8765.0));
+      position2Properties.put("mktValue", new Double(34.29));
+      position2.init(position2Properties);
+      portfolioProperties.put("position2", position2);
+
+      portfolio.init(portfolioProperties);
+      region.put(new Integer(1), portfolio);
+
+      // Create portfolio 2
+      portfolio = new Portfolio();
+      portfolioProperties = new Properties();
+      portfolioProperties.put("id", new Integer(2));
+      portfolioProperties.put("type", "type2");
+      portfolioProperties.put("status", "inactive");
+
+      position1 = new Position();
+      position1Properties = new Properties();
+      position1Properties.put("secId", "YHOO");
+      position1Properties.put("qty", new Double(9834.0));
+      position1Properties.put("mktValue", new Double(12.925));
+      position1.init(position1Properties);
+      portfolioProperties.put("position1", position1);
+
+      position2 = new Position();
+      position2Properties = new Properties();
+      position2Properties.put("secId", "GOOG");
+      position2Properties.put("qty", new Double(12176.0));
+      position2Properties.put("mktValue", new Double(21.972));
+      position2.init(position2Properties);
+      portfolioProperties.put("position2", position2);
+
+      portfolio.init(portfolioProperties);
+      region.put(new Integer(2), portfolio);
+
+      // Create portfolio 3
+      portfolio = new Portfolio();
+      portfolioProperties = new Properties();
+      portfolioProperties.put("id", new Integer(3));
+      portfolioProperties.put("type", "type3");
+      portfolioProperties.put("status", "active");
+
+      position1 = new Position();
+      position1Properties = new Properties();
+      position1Properties.put("secId", "MSFT");
+      position1Properties.put("qty", new Double(98327.0));
+      position1Properties.put("mktValue", new Double(23.32));
+      position1.init(position1Properties);
+      portfolioProperties.put("position1", position1);
+
+      position2 = new Position();
+      position2Properties = new Properties();
+      position2Properties.put("secId", "AOL");
+      position2Properties.put("qty", new Double(978.0));
+      position2Properties.put("mktValue", new Double(40.373));
+      position2.init(position2Properties);
+      portfolioProperties.put("position2", position2);
+
+      portfolio.init(portfolioProperties);
+      region.put(new Integer(3), portfolio);
+
+      // Create portfolio 4
+      portfolio = new Portfolio();
+      portfolioProperties = new Properties();
+      portfolioProperties.put("id", new Integer(4));
+      portfolioProperties.put("type", "type1");
+      portfolioProperties.put("status", "inactive");
+
+      position1 = new Position();
+      position1Properties = new Properties();
+      position1Properties.put("secId", "APPL");
+      position1Properties.put("qty", new Double(90.0));
+      position1Properties.put("mktValue", new Double(67.356572));
+      position1.init(position1Properties);
+      portfolioProperties.put("position1", position1);
+
+      position2 = new Position();
+      position2Properties = new Properties();
+      position2Properties.put("secId", "ORCL");
+      position2Properties.put("qty", new Double(376.0));
+      position2Properties.put("mktValue", new Double(101.34));
+      position2.init(position2Properties);
+      portfolioProperties.put("position2", position2);
+
+      portfolio.init(portfolioProperties);
+      region.put(new Integer(4), portfolio);
     });
 
     // Create client region
     final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
-    vm1.invoke(new CacheSerializableRunnable("Create region") {
-      public void run2() throws CacheException {
-        Properties config = new Properties();
-        config.setProperty("mcast-port", "0");
-        getSystem(config);
-        getCache();
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        ClientServerTestCase.configureConnectionPool(factory, host0, port,-1, true, -1, -1, null);
-        createRegion(name, factory.create());
-      }
+    vm1.invoke("Create region", () -> {
+      Properties config = new Properties();
+      config.setProperty("mcast-port", "0");
+      getSystem(config);
+      getCache();
+      AttributesFactory factory = new AttributesFactory();
+      factory.setScope(Scope.LOCAL);
+      ClientServerTestCase.configureConnectionPool(factory, host0, port, -1, true, -1, -1, null);
+      createRegion(name, factory.create());
     });
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        String queryString = null;
-        SelectResults results = null;
+    vm1.invoke("Execute queries", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      String queryString = null;
+      SelectResults results = null;
 
-        queryString =
+      queryString =
           "IMPORT cacheRunner.Position; " +
-          "SELECT DISTINCT id, status FROM " + region.getFullPath() +
-          "WHERE NOT (SELECT DISTINCT * FROM positions.values posnVal TYPE Position " +
-          "WHERE posnVal.secId='AOL' OR posnVal.secId='SAP').isEmpty";
-        try {
-          results = region.query(queryString);
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        LogWriterUtils.getLogWriter().fine("size: " + results.size());
-        //assertEquals(numberOfEntries, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+              "SELECT DISTINCT id, status FROM " + region.getFullPath() +
+              "WHERE NOT (SELECT DISTINCT * FROM positions.values posnVal TYPE Position " +
+              "WHERE posnVal.secId='AOL' OR posnVal.secId='SAP').isEmpty";
+      try {
+        results = region.query(queryString);
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
       }
+      LogWriterUtils.getLogWriter().fine("size: " + results.size());
+      //assertEquals(numberOfEntries, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
     });
 
-
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -631,30 +581,26 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Properties config = new Properties();
-        config.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
-        getSystem(config);
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        createRegion(name, factory.create());
-        Wait.pause(1000);
-        try {
-          startBridgeServer(0, false);
-        } catch (Exception ex) {
-          Assert.fail("While starting CacheServer", ex);
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Properties config = new Properties();
+      config.setProperty("locators", "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
+      getSystem(config);
+      AttributesFactory factory = new AttributesFactory();
+      factory.setScope(Scope.LOCAL);
+      createRegion(name, factory.create());
+      Wait.pause(1000);
+      try {
+        startBridgeServer(0, false);
+      } catch (Exception ex) {
+        Assert.fail("While starting CacheServer", ex);
       }
     });
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
@@ -665,151 +611,143 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final String regionName = "/" + rootRegionName + "/" + name;
 
     // Create client pool.
-    final String poolName = "testRemoteFullRegionQueries"; 
-    createPool(vm1, poolName, host0, port);
-
+    final String poolName = "testRemoteFullRegionQueries";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        String queryString = null;
-        SelectResults results = null;
-        Comparator comparator = null;
-        Object[] resultsArray = null;
-        QueryService qService = null;
-
-        try {
-          qService = (PoolManager.find(poolName)).getQueryService();
-        } catch (Exception e) {
-          Assert.fail("Failed to get QueryService.", e);
-        }          
+    vm1.invoke("Execute queries", () -> {
+      String queryString = null;
+      SelectResults results = null;
+      Comparator comparator = null;
+      Object[] resultsArray = null;
+      QueryService qService = null;
 
-        // value query
-        queryString = "SELECT DISTINCT itr.value FROM " + regionName + ".entries itr where itr.key = 'key-1'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
-        assertTrue(results.asList().get(0) instanceof TestObject);
+      try {
+        qService = (PoolManager.find(poolName)).getQueryService();
+      } catch (Exception e) {
+        Assert.fail("Failed to get QueryService.", e);
+      }
 
-        // key query
-        queryString = "SELECT DISTINCT itr.key FROM " + regionName + ".entries itr where itr.key = 'key-1'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
-        assertEquals("key-1", results.asList().get(0));
+      // value query
+      queryString = "SELECT DISTINCT itr.value FROM " + regionName + ".entries itr where itr.key = 'key-1'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
+      assertTrue(results.asList().get(0) instanceof TestObject);
 
-        // order by value query
-        queryString = "SELECT DISTINCT * FROM " + regionName + " WHERE id < 101 ORDER BY id";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries, results.size());
-        // All order-by query results are stored in a ResultsCollectionWrapper
-        // wrapping a list, so the assertion below is not correct even though
-        // it should be.
-        //assertTrue(!results.getCollectionType().allowsDuplicates());
-        assertTrue(results.getCollectionType().isOrdered());
-        comparator = new IdComparator();
-        resultsArray = results.toArray();
-        for (int i=0; i<resultsArray.length; i++) {
-          if (i+1 != resultsArray.length) {
-            // The id of the current element in the result set must be less
-            // than the id of the next one to pass.
-            assertTrue("The id for " + resultsArray[i] + " should be less than the id for " + resultsArray[i+1], comparator.compare(resultsArray[i], resultsArray[i+1]) == -1);
-          }
-        }
+      // key query
+      queryString = "SELECT DISTINCT itr.key FROM " + regionName + ".entries itr where itr.key = 'key-1'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
+      assertEquals("key-1", results.asList().get(0));
 
-        // order by struct query
-        queryString = "SELECT DISTINCT id, ticker, price FROM " + regionName + " WHERE id < 101 ORDER BY id";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries, results.size());
-        // All order-by query results are stored in a ResultsCollectionWrapper
-        // wrapping a list, so the assertion below is not correct even though
-        // it should be.
-        //assertTrue(!results.getCollectionType().allowsDuplicates());
-        assertTrue(results.getCollectionType().isOrdered());
-        comparator = new StructIdComparator();
-        resultsArray = results.toArray();
-        for (int i=0; i<resultsArray.length; i++) {
-          if (i+1 != resultsArray.length) {
-            // The id of the current element in the result set must be less
-            // than the id of the next one to pass.
-            assertTrue("The id for " + resultsArray[i] + " should be less than the id for " + resultsArray[i+1], comparator.compare(resultsArray[i], resultsArray[i+1]) == -1);
-          }
-        }
+      // order by value query
+      queryString = "SELECT DISTINCT * FROM " + regionName + " WHERE id < 101 ORDER BY id";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries, results.size());
+      // All order-by query results are stored in a ResultsCollectionWrapper
+      // wrapping a list, so the assertion below is not correct even though
+      // it should be.
+      //assertTrue(!results.getCollectionType().allowsDuplicates());
+      assertTrue(results.getCollectionType().isOrdered());
+      comparator = new IdComparator();
+      resultsArray = results.toArray();
+      for (int i = 0; i < resultsArray.length; i++) {
+        if (i + 1 != resultsArray.length) {
+          // The id of the current element in the result set must be less
+          // than the id of the next one to pass.
+          assertTrue("The id for " + resultsArray[i] + " should be less than the id for " + resultsArray[i + 1],
+              comparator.compare(resultsArray[i], resultsArray[i + 1]) == -1);
+        }
+      }
+
+      // order by struct query
+      queryString = "SELECT DISTINCT id, ticker, price FROM " + regionName + " WHERE id < 101 ORDER BY id";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries, results.size());
+      // All order-by query results are stored in a ResultsCollectionWrapper
+      // wrapping a list, so the assertion below is not correct even though
+      // it should be.
+      //assertTrue(!results.getCollectionType().allowsDuplicates());
+      assertTrue(results.getCollectionType().isOrdered());
+      comparator = new StructIdComparator();
+      resultsArray = results.toArray();
+      for (int i = 0; i < resultsArray.length; i++) {
+        if (i + 1 != resultsArray.length) {
+          // The id of the current element in the result set must be less
+          // than the id of the next one to pass.
+          assertTrue("The id for " + resultsArray[i] + " should be less than the id for " + resultsArray[i + 1],
+              comparator.compare(resultsArray[i], resultsArray[i + 1]) == -1);
+        }
+      }
+
+      // size query
+      queryString = "(SELECT DISTINCT * FROM " + regionName + " WHERE id < 101).size";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(1, results.size());
+      Object result = results.iterator().next();
+      assertTrue(result instanceof Integer);
+      int resultInt = ((Integer) result).intValue();
+      assertEquals(resultInt, 100);
 
-        // size query
-        queryString = "(SELECT DISTINCT * FROM " + regionName + " WHERE id < 101).size";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        Object result = results.iterator().next();
-        assertTrue(result instanceof Integer);
-        int resultInt = ((Integer) result).intValue();
-        assertEquals(resultInt, 100);
-
-        // query with leading/trailing spaces
-        queryString = " SELECT DISTINCT itr.key FROM " + regionName + ".entries itr where itr.key = 'key-1' ";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertEquals("key-1", results.asList().get(0));
+      // query with leading/trailing spaces
+      queryString = " SELECT DISTINCT itr.key FROM " + regionName + ".entries itr where itr.key = 'key-1' ";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
       }
+      assertEquals(1, results.size());
+      assertEquals("key-1", results.asList().get(0));
     });
 
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
    * Tests client-server query using parameters (compiled queries).
    */
   public void testClientServerQueriesWithParams() throws CacheException {
-
-    final String name = this.getName();
-
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
 
     final int[] expectedResults = new int[] {
@@ -821,132 +759,106 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
         50, // 5
     };
 
-
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-      }
-    });
+    vm0.invoke("Create Bridge Server", () -> configAndStartBridgeServer());
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create and populate region") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(regionName);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create and populate region", () -> {
+      Region region = getRootRegion().getSubregion(regionName);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
     // Create client region
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
-    final String regionName = "/" + this.rootRegionName + "/" + this.regionName;
-
     // Create client pool.
-    final String poolName = "testClientServerQueriesWithParams"; 
-    createPool(vm1, poolName, host0, port);
-
+    final String poolName = "testClientServerQueriesWithParams";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
     vm1.invoke(new CacheSerializableRunnable("Execute queries") {
       public void run2() throws CacheException {
         SelectResults results = null;
-        Comparator comparator = null;
-        Object[] resultsArray = null;
         QueryService qService = null;
 
         try {
           qService = (PoolManager.find(poolName)).getQueryService();
         } catch (Exception e) {
           Assert.fail("Failed to get QueryService.", e);
-        }          
+        }
 
-        for (int i=0; i < queryString.length; i++){
+        for (int i = 0; i < queryString.length; i++) {
           try {
             LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
             Query query = qService.newQuery(queryString[i]);
-            results = (SelectResults)query.execute(params[i]);
+            results = (SelectResults) query.execute(params[i]);
           } catch (Exception e) {
             Assert.fail("Failed executing " + queryString[i], e);
           }
           try {
             assertEquals(expectedResults[i], results.size());
-          }catch(Throwable th) {
-            fail("Result mismatch for query= " + queryString[i] + " expected = "+expectedResults[i] + " actual="+results.size());
+          } catch (Throwable th) {
+            fail("Result mismatch for query= " + queryString[i] + " expected = " + expectedResults[i] + " actual=" + results.size());
           }
-        }        
+        }
       }
     });
 
     final int useMaintainedCompiledQueries = queryString.length;
 
     // Execute the same compiled queries multiple time
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        SelectResults results = null;
-        Comparator comparator = null;
-        Object[] resultsArray = null;
-        QueryService qService = null;
+    vm1.invoke("Execute queries", () -> {
+      SelectResults results = null;
+      QueryService qService = null;
 
-        try {
-          qService = (PoolManager.find(poolName)).getQueryService();
-        } catch (Exception e) {
-          Assert.fail("Failed to get QueryService.", e);
-        }          
-        for (int x=0; x < useMaintainedCompiledQueries; x++){
-          for (int i=0; i < queryString.length; i++){
-            try {
-              LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
-              Query query = qService.newQuery(queryString[i]);
-              results = (SelectResults)query.execute(params[i]);
-            } catch (Exception e) {
-              Assert.fail("Failed executing " + queryString[i], e);
-            }
-            try {
-              assertEquals(expectedResults[i], results.size());
-            }catch(Throwable th) {
-              fail("Result mismatch for query= " + queryString[i] + " expected = "+expectedResults[i] + " actual="+results.size());
-            }
-          }        
+      try {
+        qService = (PoolManager.find(poolName)).getQueryService();
+      } catch (Exception e) {
+        Assert.fail("Failed to get QueryService.", e);
+      }
+      for (int x = 0; x < useMaintainedCompiledQueries; x++) {
+        for (int i = 0; i < queryString.length; i++) {
+          try {
+            LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
+            Query query = qService.newQuery(queryString[i]);
+            results = (SelectResults) query.execute(params[i]);
+          } catch (Exception e) {
+            Assert.fail("Failed executing " + queryString[i], e);
+          }
+          try {
+            assertEquals(expectedResults[i], results.size());
+          } catch (Throwable th) {
+            fail("Result mismatch for query= " + queryString[i] + " expected = " + expectedResults[i] + " actual=" + results.size());
+          }
         }
       }
     });
 
     // Validate maintained compiled queries.
     // There should be only queryString.length compiled queries registered.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
 
     // Check to see if maintained compiled queries are used.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryUsedCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryUsedCount();
-        int numTimesUsed = (useMaintainedCompiledQueries + 1) * queryString.length;
-        assertEquals(numTimesUsed, compiledQueryUsedCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryUsedCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryUsedCount();
+      int numTimesUsed = (useMaintainedCompiledQueries + 1) * queryString.length;
+      assertEquals(numTimesUsed, compiledQueryUsedCount);
     });
 
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
    * Tests client-server query using parameters (compiled queries).
    */
   public void testMulitipleClientServerQueriesWithParams() throws CacheException {
-    final String name = this.getName();
-
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
@@ -955,12 +867,12 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
 
     final int[] expectedResults = new int[] {
@@ -972,69 +884,59 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
         50, // 5
     };
 
-
     // Start server1
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-        Region region = getRootRegion().getSubregion(regionName);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      configAndStartBridgeServer();
+      Region region = getRootRegion().getSubregion(regionName);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
-
     // Start server2
-    vm1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-        Region region = getRootRegion().getSubregion(regionName);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm1.invoke("Create Bridge Server", () -> {
+      configAndStartBridgeServer();
+      Region region = getRootRegion().getSubregion(regionName);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
     // Create client region
-    final int port0 = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
-    final int port1 = vm1.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port0 = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port1 = vm1.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
 
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
-    final String regionName = "/" + this.rootRegionName + "/" + this.regionName;
-
     // Create client pool.
-    final String poolName = "testClientServerQueriesWithParams"; 
-    createPool(vm2, poolName, new String[]{host0}, new int[]{port0}, true);
-    createPool(vm3, poolName, new String[]{host0}, new int[]{port1}, true);
+    final String poolName = "testClientServerQueriesWithParams";
+    vm2.invoke("createPool", () -> createPool(poolName, new String[] { host0 }, new int[] { port0 }, true));
+    vm3.invoke("createPool", () -> createPool(poolName, new String[] { host0 }, new int[] { port1 }, true));
 
     // Execute client queries
     SerializableRunnable executeQueries = new CacheSerializableRunnable("Execute queries") {
       public void run2() throws CacheException {
         SelectResults results = null;
-        Comparator comparator = null;
-        Object[] resultsArray = null;
         QueryService qService = null;
 
         try {
           qService = (PoolManager.find(poolName)).getQueryService();
         } catch (Exception e) {
           Assert.fail("Failed to get QueryService.", e);
-        }          
-        for (int j=0; j < queryString.length; j++){
-          for (int i=0; i < queryString.length; i++){
+        }
+        for (int j = 0; j < queryString.length; j++) {
+          for (int i = 0; i < queryString.length; i++) {
             try {
               LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
               Query query = qService.newQuery(queryString[i]);
-              results = (SelectResults)query.execute(params[i]);
+              results = (SelectResults) query.execute(params[i]);
             } catch (Exception e) {
               Assert.fail("Failed executing " + queryString[i], e);
             }
             try {
               assertEquals(expectedResults[i], results.size());
-            }catch(Throwable th) {
-              fail("Result mismatch for query= " + queryString[i] + " expected = "+expectedResults[i] + " actual="+results.size());
+            } catch (Throwable th) {
+              fail("Result mismatch for query= " + queryString[i] + " expected = " + expectedResults[i] + " actual=" + results.size());
             }
           }
         }
@@ -1046,68 +948,49 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
 
     // Validate maintained compiled queries.
     // There should be only queryString.length compiled queries registered.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
-    
-    this.closeClient(vm2);
-    this.closeClient(vm3);
-    
+
+    vm2.invoke("closeClient", () -> closeClient());
+    vm3.invoke("closeClient", () -> closeClient());
+
     // Validate maintained compiled queries.
     // All the queries will be still present in the server.
-    // They will be cleaned up periodically.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    // They will be cleaned up periodically1
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
-    
-    vm1.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+
+    vm1.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
- 
+
     // recreate clients and execute queries.
-    createPool(vm2, poolName, new String[]{host0, host0}, new int[]{port1, port0}, true);
-    createPool(vm3, poolName, new String[]{host0, host0}, new int[]{port0, port1}, true);
+    vm2.invoke("createPool", () -> createPool(poolName, new String[] { host0,host0 }, new int[] { port1, port0 }, true));
+    vm3.invoke("createPool", () -> createPool(poolName, new String[] { host0,host0 }, new int[] { port0, port1 }, true));
 
     vm2.invoke(executeQueries);
     vm3.invoke(executeQueries);
-    
+
     // Validate maintained compiled queries.
     // All the queries will be still present in the server.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
-    });
-    
-    vm1.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
-    });
-    
-    // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
-    vm1.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
+
+    vm1.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
 
+    // Stop server
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
+    vm1.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -1116,8 +999,6 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
   public void testClientServerCompiledQueryRegisterAndCleanup() throws CacheException {
 
     final String name = this.getName();
-    final String rootRegionName = "root";
-
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
@@ -1125,77 +1006,55 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
-    
+
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-      }
-    });
+    vm0.invoke("Create Bridge Server", () -> configAndStartBridgeServer());
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create and populate region.") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create and populate region.", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
-    final String regionName = "/" + this.rootRegionName + "/" + this.regionName;
-
     // Create client pool.
-    final String poolName = "testClientServerQueriesWithParams"; 
-    createPool(vm1, poolName, host0, port);
-    createPool(vm2, poolName, host0, port);
+    final String poolName = "testClientServerQueriesWithParams";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
+    vm2.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);      }
-    });
+    vm1.invoke("executeCompiledQueries", () -> executeCompiledQueries(poolName, params));
 
     // Execute client queries
-    vm2.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);      }
-    });
-    
+    vm2.invoke("executeCompiledQueries", () -> executeCompiledQueries(poolName, params));
+
     // Validate maintained compiled queries.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
 
-    closeClient(vm1);
+    vm1.invoke("closeClient", () -> closeClient());
 
     // Validate maintained compiled queries.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
 
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });    
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -1204,7 +1063,6 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
   public void testClientServerCompiledQueryTimeBasedCleanup() throws CacheException {
 
     final String name = this.getName();
-    final String rootRegionName = "root";
 
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
@@ -1213,119 +1071,90 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
-    
+
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-      }
-    });
+    vm0.invoke("Create Bridge Server", () -> configAndStartBridgeServer());
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create and populate region.") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
-        QueryService qs = getCache().getQueryService();
-        DefaultQuery query = (DefaultQuery)qs.newQuery("Select * from " + regName);
-        query.setTestCompiledQueryClearTime(2 * 1000); 
+    vm0.invoke("Create and populate region.", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
+      QueryService qs = getCache().getQueryService();
+      DefaultQuery query = (DefaultQuery) qs.newQuery("Select * from " + regName);
+      query.setTestCompiledQueryClearTime(2 * 1000);
     });
 
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
-    final String regionName = "/" + this.rootRegionName + "/" + this.regionName;
-
     // Create client pool.
-    final String poolName = "testClientServerQueriesWithParams"; 
-    createPool(vm1, poolName, host0, port);
-    createPool(vm2, poolName, host0, port);
+    final String poolName = "testClientServerQueriesWithParams";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
+    vm2.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
+    vm1.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
 
     // Execute client queries
-    vm2.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
-        
+    vm2.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
+
     // Validate maintained compiled queries.
-    this.validateCompiledQuery(vm0, 0);
-        
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(0));
+
     // Recreate compiled queries.
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
+    vm1.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
 
     // Execute client queries
     // The client2 will be using the queries.
-    vm2.invokeAsync(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        for (int i=0; i < 10; i++) {
-          Wait.pause(200);
-          executeCompiledQueries(poolName, params);
-        }
+    vm2.invokeAsync("Execute queries", () -> {
+      for (int i = 0; i < 10; i++) {
+        Wait.pause(200);
+        executeCompiledQueries(poolName, params);
       }
     });
-       
+
     // Validate maintained compiled queries.
-    validateCompiledQuery(vm0, queryString.length);
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(queryString.length));
 
     // Let the compiled queries to be idle (not used).
-    Wait.pause(2 * 1000);    
-    
+    Wait.pause(2 * 1000);
+
     // Validate maintained compiled queries.
-    this.validateCompiledQuery(vm0, 0);
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(0));
 
     // Close clients
-    closeClient(vm2);
-    closeClient(vm1);
-    
+
+    vm1.invoke("closeClient", () -> closeClient());
+    vm2.invoke("closeClient", () -> closeClient());
+
     // Validate maintained compiled queries.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(0, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(0, compiledQueryCount);
     });
-    
+
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });    
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
    * Tests client-server compiled query register and cleanup.
-   * It creates the client connections without the subscription 
+   * It creates the client connections without the subscription
    * enabled. This doesn't create any client proxy on the server.
    */
   public void testClientServerCompiledQueryCleanup() throws CacheException {
 
     final String name = this.getName();
-    final String rootRegionName = "root";
-
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
@@ -1333,124 +1162,89 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
-    
+
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-      }
-    });
+    vm0.invoke("Create Bridge Server", () -> configAndStartBridgeServer());
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create and populate region.") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
-        QueryService qs = getCache().getQueryService();
-        DefaultQuery query = (DefaultQuery)qs.newQuery("Select * from " + regName);
-        query.setTestCompiledQueryClearTime(2 * 1000); 
+    vm0.invoke("Create and populate region.", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
+      QueryService qs = getCache().getQueryService();
+      DefaultQuery query = (DefaultQuery) qs.newQuery("Select * from " + regName);
+      query.setTestCompiledQueryClearTime(2 * 1000);
     });
 
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
-    final String regionName = "/" + this.rootRegionName + "/" + this.regionName;
-
     // Create client pool.
-    final String poolName = "testClientServerQueriesWithParams"; 
+    final String poolName = "testClientServerQueriesWithParams";
     final boolean subscriptiuonEnabled = false;
-    createPool(vm1, poolName, host0, port, subscriptiuonEnabled);
-    createPool(vm2, poolName, host0, port, subscriptiuonEnabled);
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port, subscriptiuonEnabled));
+    vm2.invoke("createPool", () -> createPool(poolName, host0, port, subscriptiuonEnabled));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
+    vm1.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
 
     // Execute client queries
-    vm2.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
-    
+    vm2.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
+
     // Validate maintained compiled queries.
-    this.validateCompiledQuery(vm0, 0);
-    
-    
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(0));
+
     // Recreate compiled queries.
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
+    vm1.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
 
     // Execute client queries
     // The client2 will be using the queries.
-    vm2.invokeAsync(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        for (int i=0; i < 10; i++) {
-          Wait.pause(10);
-          executeCompiledQueries(poolName, params);
-        }
+    vm2.invokeAsync("Execute queries", () -> {
+      for (int i = 0; i < 10; i++) {
+        Wait.pause(10);
+        executeCompiledQueries(poolName, params);
       }
     });
-       
+
     // Validate maintained compiled queries.
-    this.validateCompiledQuery(vm0, queryString.length);
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(queryString.length));
 
     // Close clients
     // Let the compiled queries to be idle (not used).
     //pause(2 * 1000);    
-    
+
     // Validate maintained compiled queries.
-    this.validateCompiledQuery(vm0, 0);
-    
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(0));
+
     // Recreate compiled queries.
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
-    
-    
+    vm1.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
+
     // Validate maintained compiled queries.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
 
     // Close clients
-    closeClient(vm2);
-    closeClient(vm1);
+    vm2.invoke("closeClient", () -> closeClient());
+    vm1.invoke("closeClient", () -> closeClient());
 
     // Validate maintained compiled queries.
     // since not used it should get cleaned up after sometime.
-    this.validateCompiledQuery(vm0, 0);
-    
-    
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(0));
+
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });    
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -1469,12 +1263,12 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
 
     final String[] querys = new String[] {
@@ -1486,67 +1280,54 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
         "SELECT * FROM " + regName + " WHERE id < 50 and Ticker = 'ibm'", // 5
     };
 
-    final int[] expectedResults = new int[] {
-        1, // 0
-        100, // 1
-        100, // 2
-        1, // 3
-        1, // 4
-        50, // 5
-    };
-
     // Start server1
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-        Region region = getRootRegion().getSubregion(regionName);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create Bridge Server

<TRUNCATED>


[08/25] incubator-geode git commit: GEODE-1266: Removed Pivotal License Header and also minor clean up

Posted by ji...@apache.org.
GEODE-1266: Removed Pivotal License Header and also minor clean up

* Removed Pivotal License Header
* Removed unused import
* Removed debug logging


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 79b3544a8f6a5d9fb19e6864babeb5c902fc7373
Parents: 7022135
Author: Jason Huynh <hu...@gmail.com>
Authored: Wed Apr 20 17:12:38 2016 -0700
Committer: Jason Huynh <hu...@gmail.com>
Committed: Thu Apr 21 10:59:32 2016 -0700

----------------------------------------------------------------------
 .../cache/RemoteCQTransactionDUnitTest.java        | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/79b3544a/geode-cq/src/test/java/com/gemstone/gemfire/internal/cache/RemoteCQTransactionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/internal/cache/RemoteCQTransactionDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/internal/cache/RemoteCQTransactionDUnitTest.java
index d617474..020f967 100755
--- a/geode-cq/src/test/java/com/gemstone/gemfire/internal/cache/RemoteCQTransactionDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/internal/cache/RemoteCQTransactionDUnitTest.java
@@ -15,14 +15,6 @@
  * limitations under the License.
  */
 package com.gemstone.gemfire.internal.cache;
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -33,7 +25,6 @@ import java.util.Set;
 import com.gemstone.gemfire.cache.AttributesFactory;
 import com.gemstone.gemfire.cache.CacheEvent;
 import com.gemstone.gemfire.cache.CacheListener;
-import com.gemstone.gemfire.cache.CacheTransactionManager;
 import com.gemstone.gemfire.cache.CacheWriter;
 import com.gemstone.gemfire.cache.CacheWriterException;
 import com.gemstone.gemfire.cache.DataPolicy;
@@ -897,8 +888,7 @@ protected static class ClientListener extends CacheListenerAdapter {
         Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
         Region<CustId,Customer> refRegion = getCache().getRegion(D_REFERENCE);
         ClientListener cl = (ClientListener) custRegion.getAttributes().getCacheListeners()[0];
-        getCache().getLogger().info("SWAP:CLIENTinvoked:"+cl.invoked);
-        
+
         assertTrue(((ClientCQListener)custRegion.getCache().getQueryService().getCqs()[0].getCqAttributes().getCqListener()).invoked);
         assertTrue(cl.invoked);
         return null;
@@ -940,7 +930,6 @@ protected static class ClientListener extends CacheListenerAdapter {
         Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
         Region<CustId,Customer> refRegion = getCache().getRegion(D_REFERENCE);
         ClientListener cl = (ClientListener) custRegion.getAttributes().getCacheListeners()[0];
-        getCache().getLogger().info("SWAP:CLIENTinvoked:"+cl.invoked);
         assertTrue(cl.invoked);
         assertTrue(((ClientCQListener)custRegion.getCache().getQueryService().getCqs()[0].getCqAttributes().getCqListener()).invoked);
         return null;
@@ -982,7 +971,6 @@ protected static class ClientListener extends CacheListenerAdapter {
         Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
         Region<CustId,Customer> refRegion = getCache().getRegion(D_REFERENCE);
         ClientListener cl = (ClientListener) custRegion.getAttributes().getCacheListeners()[0];
-        getCache().getLogger().info("SWAP:CLIENTinvoked:"+cl.invoked);
         assertTrue(cl.invoked);
         assertTrue(((ClientCQListener)custRegion.getCache().getQueryService().getCqs()[0].getCqAttributes().getCqListener()).invoked);
         return null;
@@ -1023,7 +1011,6 @@ protected static class ClientListener extends CacheListenerAdapter {
         Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
         Region<CustId,Customer> refRegion = getCache().getRegion(D_REFERENCE);
         ClientListener cl = (ClientListener) custRegion.getAttributes().getCacheListeners()[0];
-        getCache().getLogger().info("SWAP:CLIENTinvoked:"+cl.invoked);
         assertTrue(cl.invoked);
         assertTrue(((ClientCQListener)custRegion.getCache().getQueryService().getCqs()[0].getCqAttributes().getCqListener()).invoked);
         return null;
@@ -1064,7 +1051,6 @@ protected static class ClientListener extends CacheListenerAdapter {
         Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
         Region<CustId,Customer> refRegion = getCache().getRegion(D_REFERENCE);
         ClientListener cl = (ClientListener) custRegion.getAttributes().getCacheListeners()[0];
-        getCache().getLogger().info("SWAP:CLIENTinvoked:"+cl.invoked);
         assertTrue(cl.invoked);
         assertTrue(((ClientCQListener)custRegion.getCache().getQueryService().getCqs()[0].getCqAttributes().getCqListener()).invoked);
         return null;
@@ -1106,7 +1092,6 @@ protected static class ClientListener extends CacheListenerAdapter {
         Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
         Region<CustId,Customer> refRegion = getCache().getRegion(D_REFERENCE);
         ClientListener cl = (ClientListener) custRegion.getAttributes().getCacheListeners()[0];
-        getCache().getLogger().info("SWAP:CLIENTinvoked:"+cl.invoked);
         assertTrue(cl.invoked);
         assertTrue(((ClientCQListener)custRegion.getCache().getQueryService().getCqs()[0].getCqAttributes().getCqListener()).invoked);
         return null;


[12/25] incubator-geode git commit: GEODE-1227: Replaced all port selections for server with '0' instead of getting the port from the AvailablePortHelper. Some refactoring introducing Lambdas. Some refactoring replacing Wait.wait with Awaitility.

Posted by ji...@apache.org.
GEODE-1227: Replaced all port selections for server with '0' instead of getting the port from the AvailablePortHelper.
Some refactoring introducing Lambdas.
Some refactoring replacing Wait.wait with Awaitility.


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

Branch: refs/heads/feature/GEODE-17-2
Commit: b5ff97423508837bd60c3b19d313f4a96764cedb
Parents: 0d0e706
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Thu Apr 21 11:39:55 2016 +1000
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Apr 22 04:24:57 2016 +1000

----------------------------------------------------------------------
 .../cli/commands/CliCommandTestBase.java        |   93 +-
 .../cli/commands/ClientCommandsDUnitTest.java   | 1757 +++++++-----------
 2 files changed, 753 insertions(+), 1097 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b5ff9742/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
index 4d651a2..acb07ca 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
@@ -16,21 +16,6 @@
  */
 package com.gemstone.gemfire.management.internal.cli.commands;
 
-import static com.gemstone.gemfire.test.dunit.Assert.*;
-import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
@@ -43,10 +28,20 @@ import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
 import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
 import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
 import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.SerializableCallable;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
 
+import java.io.IOException;
+import java.io.PrintStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter;
+
 /**
  * Base class for all the CLI/gfsh command dunit tests.
  */
@@ -72,7 +67,7 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
     preTearDownCliCommandTestBase();
     destroyDefaultSetup();
   }
-  
+
   protected void preTearDownCliCommandTestBase() throws Exception {
   }
 
@@ -89,41 +84,38 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
    */
   @SuppressWarnings("serial")
   protected final HeadlessGfsh createDefaultSetup(final Properties props) {
-    Object[] result = (Object[]) Host.getHost(0).getVM(0).invoke(new SerializableCallable() {
-      public Object call() {
-        final Object[] result = new Object[3];
-        final Properties localProps = (props != null ? props : new Properties());
-
-        try {
-          jmxHost = InetAddress.getLocalHost().getHostName();
-        } catch (UnknownHostException ignore) {
-          jmxHost = "localhost";
-        }
-
-        if (!localProps.containsKey(DistributionConfig.NAME_NAME)) {
-          localProps.setProperty(DistributionConfig.NAME_NAME, "Manager");
-        }
+    Object[] result = Host.getHost(0).getVM(0).invoke("create Default setup",() -> {
+      final Object[] returnValue = new Object[3];
+      final Properties localProps = (props != null ? props : new Properties());
+
+      try {
+        jmxHost = InetAddress.getLocalHost().getHostName();
+      } catch (UnknownHostException ignore) {
+        jmxHost = "localhost";
+      }
 
-        final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+      if (!localProps.containsKey(DistributionConfig.NAME_NAME)) {
+        localProps.setProperty(DistributionConfig.NAME_NAME, "Manager");
+      }
+      final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
 
-        jmxPort = ports[0];
-        httpPort = ports[1];
+      jmxPort = ports[0];
+      httpPort = ports[1];
 
-        localProps.setProperty(DistributionConfig.JMX_MANAGER_NAME, "true");
-        localProps.setProperty(DistributionConfig.JMX_MANAGER_START_NAME, "true");
-        localProps.setProperty(DistributionConfig.JMX_MANAGER_BIND_ADDRESS_NAME, String.valueOf(jmxHost));
-        localProps.setProperty(DistributionConfig.JMX_MANAGER_PORT_NAME, String.valueOf(jmxPort));
-        localProps.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
+      localProps.setProperty(DistributionConfig.JMX_MANAGER_NAME, "true");
+      localProps.setProperty(DistributionConfig.JMX_MANAGER_START_NAME, "true");
+      localProps.setProperty(DistributionConfig.JMX_MANAGER_BIND_ADDRESS_NAME, String.valueOf(jmxHost));
+      localProps.setProperty(DistributionConfig.JMX_MANAGER_PORT_NAME, String.valueOf(jmxPort));
+      localProps.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
 
-        getSystem(localProps);
-        verifyManagementServiceStarted(getCache());
+      getSystem(localProps);
+      verifyManagementServiceStarted(getCache());
 
-        result[0] = jmxHost;
-        result[1] = jmxPort;
-        result[2] = httpPort;
+      returnValue[0] = jmxHost;
+      returnValue[1] = jmxPort;
+      returnValue[2] = httpPort;
 
-        return result;
-      }
+      return returnValue;
     });
 
     this.jmxHost = (String) result[0];
@@ -150,11 +142,7 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
 
     disconnectAllFromDS();
 
-    Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
-      public void run() {
-        verifyManagementServiceStopped();
-      }
-    });
+    Host.getHost(0).getVM(0).invoke("verify service stopped", () -> verifyManagementServiceStopped());
   }
 
   /**
@@ -176,7 +164,6 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
     try {
       manager = CommandManager.getInstance();
       Map<String, CommandTarget> commands = manager.getCommands();
-      Set set = commands.keySet();
       if (commands.size() < 1) {
         return false;
       }


[16/25] incubator-geode git commit: GEODE-1267: Update NOTICE references to Spring dependencies

Posted by ji...@apache.org.
GEODE-1267: Update NOTICE references to Spring dependencies

Improved NOTICE text referencing Spring libraries for LDAP, Shell,
and HATEOS.


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 9023429386d690f315a28c5e6df12f18a50b0787
Parents: 7e1656b
Author: Anthony Baker <ab...@apache.org>
Authored: Wed Apr 20 15:00:25 2016 -0700
Committer: Anthony Baker <ab...@apache.org>
Committed: Thu Apr 21 11:52:23 2016 -0700

----------------------------------------------------------------------
 geode-assembly/src/main/dist/NOTICE           | 36 +++-------------------
 geode-pulse/src/main/webapp/META-INF/NOTICE   | 18 ++---------
 geode-web-api/src/main/webapp/META-INF/NOTICE | 12 +-------
 3 files changed, 7 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/90234293/geode-assembly/src/main/dist/NOTICE
----------------------------------------------------------------------
diff --git a/geode-assembly/src/main/dist/NOTICE b/geode-assembly/src/main/dist/NOTICE
index f054cf5..4556826 100644
--- a/geode-assembly/src/main/dist/NOTICE
+++ b/geode-assembly/src/main/dist/NOTICE
@@ -302,41 +302,13 @@ Copyright (c) [2012-2014] Pivotal Software, Inc.
 
 Spring LDAP Core 1.3.2
 
-   ======================================================================
-   == NOTICE file corresponding to section 4 d of the Apache License,  ==
-   == Version 2.0, for the Spring LDAP distribution.                   ==
-   ======================================================================
-
-   This product includes software developed by
-   the Apache Software Foundation (http://www.apache.org).
-
-   The end-user documentation included with a redistribution, if any,
-   must include the following acknowledgement:
-
-     "This product includes software developed by the Spring LDAP
-      Project (http://www.springframework.org/ldap)."
-
-   Alternately, this acknowledgement may appear in the software itself,
-   if and wherever such third-party acknowledgements normally appear.
+   This product includes software developed by the Spring LDAP
+   Project (http://www.springframework.org/ldap).
 
 Spring Shell 1.1.0
 
-   ======================================================================
-   == NOTICE file corresponding to section 4 d of the Apache License,  ==
-   == Version 2.0, for the Spring Framework distribution.              ==
-   ======================================================================
-
-   This product includes software developed by
-   the Apache Software Foundation (http://www.apache.org).
-
-   The end-user documentation included with a redistribution, if any,
-   must include the following acknowledgement:
-
-     "This product includes software developed by the Spring Framework
-      Project (http://www.springframework.org)."
-
-   Alternately, this acknowledgement may appear in the software itself,
-   if and wherever such third-party acknowledgements normally appear.
+   This product includes software developed by the Spring Framework
+   Project (http://www.springframework.org).
 
    The names "Spring", "Spring Framework", and "Spring Shell" must
    not be used to endorse or promote products derived from this

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/90234293/geode-pulse/src/main/webapp/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/webapp/META-INF/NOTICE b/geode-pulse/src/main/webapp/META-INF/NOTICE
index 25a229d..763788e 100644
--- a/geode-pulse/src/main/webapp/META-INF/NOTICE
+++ b/geode-pulse/src/main/webapp/META-INF/NOTICE
@@ -72,19 +72,5 @@ Copyright (c) 2002-2015 Pivotal, Inc.
 
 Spring LDAP Core 1.3.2.RELEASE
 
-   ======================================================================
-   == NOTICE file corresponding to section 4 d of the Apache License,  ==
-   == Version 2.0, for the Spring LDAP distribution.                   ==
-   ======================================================================
-
-   This product includes software developed by
-   the Apache Software Foundation (http://www.apache.org).
-
-   The end-user documentation included with a redistribution, if any,
-   must include the following acknowledgement:
-
-     "This product includes software developed by the Spring LDAP
-      Project (http://www.springframework.org/ldap)."
-
-   Alternately, this acknowledgement may appear in the software itself,
-   if and wherever such third-party acknowledgements normally appear.
+   This product includes software developed by the Spring LDAP
+   Project (http://www.springframework.org/ldap).

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/90234293/geode-web-api/src/main/webapp/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/webapp/META-INF/NOTICE b/geode-web-api/src/main/webapp/META-INF/NOTICE
index b62c5dc..7cd12aa 100644
--- a/geode-web-api/src/main/webapp/META-INF/NOTICE
+++ b/geode-web-api/src/main/webapp/META-INF/NOTICE
@@ -76,14 +76,4 @@ Copyright (c) [2012-2014] Pivotal Software, Inc.
   This product may include a number of subcomponents with
   separate copyright notices and license terms. Your use of the source
   code for the these subcomponents is subject to the terms and
-  conditions of the subcomponent's license, as noted in the LICENSE file.Spring Framework 4.2.4.RELEASE
-  Copyright (c) 2002-2015 Pivotal, Inc.
-  
-  This product is licensed to you under the Apache License, Version 2.0
-  (the "License"). You may not use this product except in compliance with
-  the License.
-  
-  This product may include a number of subcomponents with separate
-  copyright notices and license terms. Your use of the source code for
-  these subcomponents is subject to the terms and conditions of the
-  subcomponent's license, as noted in the license.txt file.
+  conditions of the subcomponent's license, as noted in the LICENSE file.


[04/25] incubator-geode git commit: GEODE-1213: Enable signing archives on geode-assembly

Posted by ji...@apache.org.
GEODE-1213: Enable signing archives on geode-assembly

The disableMavenPublishing task was used on both geode-modules-assembly
and geode-assembly. But geode-assembly does have archives that need to
be signed, so we should not disable signing for this module.

Adding a separate disableSigning method to disable signing, which is
used only in the geode-modules-assembly.


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 3ac74a4e2c72677ef7c85df77922c645c7cce598
Parents: 124f978
Author: Dan Smith <up...@apache.org>
Authored: Wed Apr 13 11:37:56 2016 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Wed Apr 13 11:37:56 2016 -0700

----------------------------------------------------------------------
 extensions/geode-modules-assembly/build.gradle | 1 +
 gradle/utilities.gradle                        | 5 +++++
 2 files changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3ac74a4e/extensions/geode-modules-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/build.gradle b/extensions/geode-modules-assembly/build.gradle
index fe01717..960d924 100644
--- a/extensions/geode-modules-assembly/build.gradle
+++ b/extensions/geode-modules-assembly/build.gradle
@@ -38,6 +38,7 @@ extraArchive {
 }
 
 disableMavenPublishing()
+disableSigning()
 
 def getJarArtifact(module) {
   project(module).configurations.archives.artifacts.findAll {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3ac74a4e/gradle/utilities.gradle
----------------------------------------------------------------------
diff --git a/gradle/utilities.gradle b/gradle/utilities.gradle
index fa77839..5f597f6 100644
--- a/gradle/utilities.gradle
+++ b/gradle/utilities.gradle
@@ -33,6 +33,11 @@ allprojects {
       afterEvaluate {
         install.enabled = false
         uploadArchives.enabled = false
+      }
+    }
+    disableSigning = {
+      // Use this closure when a project should not publish anything to maven.
+      afterEvaluate {
         signArchives.enabled = false
       }
     }


[03/25] incubator-geode git commit: GEODE-1218: Marking jna as not optional

Posted by ji...@apache.org.
GEODE-1218: Marking jna as not optional

JNA is used for common features like offheap memory and disk stores, so
it should not be marked optional.

Cherry picked from develop to the release branch in order to avoid
possible issues with missing this jar.


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 124f978631db443c3ee29f290838b64be2c108d1
Parents: d33fee0
Author: Dan Smith <up...@apache.org>
Authored: Tue Apr 12 13:43:14 2016 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Wed Apr 13 10:58:21 2016 -0700

----------------------------------------------------------------------
 geode-core/build.gradle | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/124f9786/geode-core/build.gradle
----------------------------------------------------------------------
diff --git a/geode-core/build.gradle b/geode-core/build.gradle
index 526f22a..7d13114 100755
--- a/geode-core/build.gradle
+++ b/geode-core/build.gradle
@@ -61,9 +61,7 @@ dependencies {
   compile ('mx4j:mx4j-tools:' + project.'mx4j.version') { 
     ext.optional = true;
   }
-  compile ('net.java.dev.jna:jna:' + project.'jna.version') {
-    ext.optional = true
-  }
+  compile ('net.java.dev.jna:jna:' + project.'jna.version')
   provided ('org.apache.hadoop:hadoop-common:' + project.'hadoop.version') {
     transitive=false
   }


[22/25] incubator-geode git commit: GEODE-1188: Lucene indexes can be created with partition redundant regions

Posted by ji...@apache.org.
GEODE-1188: Lucene indexes can be created with partition redundant regions

Added a test to test against all partition region types, not including proxy types

When specific region types need more robust/specific tests, we can add specific tests
for the type and eventually remove this test if/when all types are covered


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

Branch: refs/heads/feature/GEODE-17-2
Commit: a194b03fc9a8a0e4691cb62d008a3dc3026ae5e7
Parents: 7de1d32
Author: Jason Huynh <hu...@gmail.com>
Authored: Wed Apr 20 15:24:07 2016 -0700
Committer: Jason Huynh <hu...@gmail.com>
Committed: Thu Apr 21 15:50:22 2016 -0700

----------------------------------------------------------------------
 .../LuceneIndexForPartitionedRegion.java        |  30 ++--
 .../internal/LuceneServiceImplJUnitTest.java    | 146 +++++++++++++------
 2 files changed, 116 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a194b03f/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index 4145459..0d257e3 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -138,13 +138,14 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
 
   Region createFileRegion(final RegionShortcut regionShortCut,
                                 final String fileRegionName,
-                                final PartitionAttributes partitionAttributes)
-  {
+                                final PartitionAttributes partitionAttributes) {
+    PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory<String, File>();
+    partitionAttributesFactory.setColocatedWith(regionPath);
+    configureLuceneRegionAttributesFactory(partitionAttributesFactory, partitionAttributes);
+
     return cache.<String, File> createRegionFactory(regionShortCut)
-        .setPartitionAttributes(new PartitionAttributesFactory<String, File>().setColocatedWith(regionPath)
-            .setTotalNumBuckets(partitionAttributes.getTotalNumBuckets())
-            .create())
-            .create(fileRegionName);
+        .setPartitionAttributes(partitionAttributesFactory.create())
+        .create(fileRegionName);
   }
 
   String createFileRegionName() {
@@ -157,12 +158,13 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
 
   Region<ChunkKey, byte[]> createChunkRegion(final RegionShortcut regionShortCut,
                            final String fileRegionName,
-                           final PartitionAttributes partitionAttributes, final String chunkRegionName)
-  {
+                           final PartitionAttributes partitionAttributes, final String chunkRegionName) {
+    PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory<String, File>();
+    partitionAttributesFactory.setColocatedWith(fileRegionName);
+    configureLuceneRegionAttributesFactory(partitionAttributesFactory, partitionAttributes);
+
     return cache.<ChunkKey, byte[]> createRegionFactory(regionShortCut)
-      .setPartitionAttributes(new PartitionAttributesFactory<ChunkKey, byte[]>().setColocatedWith(fileRegionName)
-        .setTotalNumBuckets(partitionAttributes.getTotalNumBuckets())
-        .create())
+      .setPartitionAttributes(partitionAttributesFactory.create())
       .create(chunkRegionName);
   }
 
@@ -170,7 +172,11 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     return LuceneServiceImpl.getUniqueIndexName(indexName, regionPath) + ".chunks";
   }
 
-
+  private PartitionAttributesFactory configureLuceneRegionAttributesFactory(PartitionAttributesFactory attributesFactory, PartitionAttributes dataRegionAttributes) {
+    attributesFactory.setTotalNumBuckets(dataRegionAttributes.getTotalNumBuckets());
+    attributesFactory.setRedundantCopies(dataRegionAttributes.getRedundantCopies());
+    return attributesFactory;
+  }
 
   public void close() {
     // TODO Auto-generated method stub

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a194b03f/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImplJUnitTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImplJUnitTest.java
index a85e617..1beea0f 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImplJUnitTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImplJUnitTest.java
@@ -26,6 +26,8 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import com.gemstone.gemfire.cache.Region;
+
 import org.apache.logging.log4j.Logger;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
@@ -63,6 +65,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
 public class LuceneServiceImplJUnitTest {
+
   Cache cache;
   ClientCache clientCache;
   private LuceneIndexImpl repo;
@@ -96,6 +99,13 @@ public class LuceneServiceImplJUnitTest {
   }
 
   @After
+  public void destroyService() {
+    if (null != service) {
+      service = null;
+    }
+  }
+
+  @After
   public void destroyCache() {
     if (null != cache && !cache.isClosed()) {
       cache.close();
@@ -134,28 +144,34 @@ public class LuceneServiceImplJUnitTest {
     return service;
   }
 
+
+  private Region createRegion(String regionName, RegionShortcut shortcut) {
+    return cache.createRegionFactory(shortcut).create(regionName);
+  }
+
   private LocalRegion createPR(String regionName, boolean isSubRegion) {
     if (isSubRegion) {
-      LocalRegion root = (LocalRegion)cache.createRegionFactory(RegionShortcut.PARTITION).create("root");
-      LocalRegion region = (LocalRegion)cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT).
+      LocalRegion root = (LocalRegion) cache.createRegionFactory(RegionShortcut.PARTITION).create("root");
+      LocalRegion region = (LocalRegion) cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT).
         createSubregion(root, regionName);
       return region;
-    } else {
-      LocalRegion region = (LocalRegion)cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT).
-        create(regionName);
+    }
+    else {
+      LocalRegion region = (LocalRegion) createRegion(regionName, RegionShortcut.PARTITION_PERSISTENT);
       return region;
     }
   }
 
   private LocalRegion createRR(String regionName, boolean isSubRegion) {
     if (isSubRegion) {
-      LocalRegion root = (LocalRegion)cache.createRegionFactory(RegionShortcut.REPLICATE).create("root");
-      LocalRegion region = (LocalRegion)cache.createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT).
+
+      LocalRegion root = (LocalRegion) cache.createRegionFactory(RegionShortcut.REPLICATE).create("root");
+      LocalRegion region = (LocalRegion) cache.createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT).
         createSubregion(root, regionName);
       return region;
-    } else {
-      LocalRegion region = (LocalRegion)cache.createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT).
-        create(regionName);
+    }
+    else {
+      LocalRegion region = (LocalRegion) createRegion(regionName, RegionShortcut.REPLICATE_PERSISTENT);
       return region;
     }
   }
@@ -169,38 +185,6 @@ public class LuceneServiceImplJUnitTest {
   }
 
   @Test
-  public void canCreateLuceneIndexForPR() throws IOException, ParseException {
-    getService();
-    service.createIndex("index1", "PR1", "field1", "field2", "field3");
-    LocalRegion userRegion = createPR("PR1", false);
-    LuceneIndexImpl index1 = (LuceneIndexImpl) service.getIndex("index1", "PR1");
-    assertTrue(index1 instanceof LuceneIndexForPartitionedRegion);
-    LuceneIndexForPartitionedRegion index1PR = (LuceneIndexForPartitionedRegion)index1;
-    assertEquals("index1", index1.getName());
-    assertEquals("/PR1", index1.getRegionPath());
-    String[] fields1 = index1.getFieldNames();
-    assertEquals(3, fields1.length);
-    Analyzer analyzer = index1PR.getAnalyzer();
-    assertTrue(analyzer instanceof StandardAnalyzer);
-    RepositoryManager RepositoryManager = index1PR.getRepositoryManager();
-    assertTrue(RepositoryManager != null);
-
-    final String fileRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1")+".files";
-    final String chunkRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1")+".chunks";
-    PartitionedRegion filePR = (PartitionedRegion)cache.getRegion(fileRegionName);
-    PartitionedRegion chunkPR = (PartitionedRegion)cache.getRegion(chunkRegionName);
-    assertTrue(filePR != null);
-    assertTrue(chunkPR != null);
-
-    String aeqId = LuceneServiceImpl.getUniqueIndexName(index1.getName(), index1.getRegionPath());
-    AsyncEventQueueImpl aeq = (AsyncEventQueueImpl)cache.getAsyncEventQueue(aeqId);
-    assertTrue(aeq != null);
-
-    //Make sure our queue doesn't show up in the list of async event queues 
-    assertEquals(Collections.emptySet(), cache.getAsyncEventQueues());
-  }
-
-  @Test
   public void canCreateLuceneIndexForPRWithAnalyzer() throws IOException, ParseException {
     getService();
     StandardAnalyzer sa = new StandardAnalyzer();
@@ -214,9 +198,9 @@ public class LuceneServiceImplJUnitTest {
 
     service.createIndex("index1", "PR1", analyzerPerField);
     createPR("PR1", false);
-    LuceneIndexImpl index1 = (LuceneIndexImpl)service.getIndex("index1", "PR1");
+    LuceneIndexImpl index1 = (LuceneIndexImpl) service.getIndex("index1", "PR1");
     assertTrue(index1 instanceof LuceneIndexForPartitionedRegion);
-    LuceneIndexForPartitionedRegion index1PR = (LuceneIndexForPartitionedRegion)index1;
+    LuceneIndexForPartitionedRegion index1PR = (LuceneIndexForPartitionedRegion) index1;
     assertEquals("index1", index1.getName());
     assertEquals("/PR1", index1.getRegionPath());
     String[] fields1 = index1.getFieldNames();
@@ -226,10 +210,10 @@ public class LuceneServiceImplJUnitTest {
     RepositoryManager RepositoryManager = index1PR.getRepositoryManager();
     assertTrue(RepositoryManager != null);
 
-    final String fileRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1")+".files";
-    final String chunkRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1")+".chunks";
-    PartitionedRegion filePR = (PartitionedRegion)cache.getRegion(fileRegionName);
-    PartitionedRegion chunkPR = (PartitionedRegion)cache.getRegion(chunkRegionName);
+    final String fileRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1") + ".files";
+    final String chunkRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1") + ".chunks";
+    PartitionedRegion filePR = (PartitionedRegion) cache.getRegion(fileRegionName);
+    PartitionedRegion chunkPR = (PartitionedRegion) cache.getRegion(chunkRegionName);
     assertTrue(filePR != null);
     assertTrue(chunkPR != null);
   }
@@ -243,4 +227,70 @@ public class LuceneServiceImplJUnitTest {
     createRR("RR1", false);
   }
 
+  @Test
+  public void canCreateIndexForAllNonProxyPartitionRegionTypes() {
+    for (RegionShortcut shortcut : RegionShortcut.values()) {
+      String sname = shortcut.name().toLowerCase();
+      if (sname.contains("partition") && !sname.contains("proxy")) {
+        canCreateLuceneIndexForPRType(shortcut);
+        //Destroying cache and service for now because aeq's are not completely being cleaned up correctly after
+        // being destroyed.  Instead we should close the aeq and clean up any regions associated with this lucene
+        //index but only after aeq destroy works properly
+        destroyCache();
+        destroyService();
+      }
+    }
+  }
+
+  public void canCreateLuceneIndexForPRType(RegionShortcut regionShortcut) {
+    getService();
+    service.createIndex("index1", "PR1", "field1", "field2", "field3");
+    Region region = null;
+    AsyncEventQueueImpl aeq = null;
+    try {
+      region = createRegion("PR1", regionShortcut);
+      LuceneIndexImpl index1 = (LuceneIndexImpl) service.getIndex("index1", "PR1");
+      assertTrue(index1 instanceof LuceneIndexForPartitionedRegion);
+      LuceneIndexForPartitionedRegion index1PR = (LuceneIndexForPartitionedRegion) index1;
+      assertEquals("index1", index1.getName());
+      assertEquals("/PR1", index1.getRegionPath());
+      String[] fields1 = index1.getFieldNames();
+      assertEquals(3, fields1.length);
+      Analyzer analyzer = index1PR.getAnalyzer();
+      assertTrue(analyzer instanceof StandardAnalyzer);
+      RepositoryManager RepositoryManager = index1PR.getRepositoryManager();
+      assertTrue(RepositoryManager != null);
+
+      final String fileRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1") + ".files";
+      final String chunkRegionName = LuceneServiceImpl.getUniqueIndexName("index1", "/PR1") + ".chunks";
+      PartitionedRegion filePR = (PartitionedRegion) cache.getRegion(fileRegionName);
+      PartitionedRegion chunkPR = (PartitionedRegion) cache.getRegion(chunkRegionName);
+      assertTrue(filePR != null);
+      assertTrue(chunkPR != null);
+
+      String aeqId = LuceneServiceImpl.getUniqueIndexName(index1.getName(), index1.getRegionPath());
+      aeq = (AsyncEventQueueImpl) cache.getAsyncEventQueue(aeqId);
+      assertTrue(aeq != null);
+
+      //Make sure our queue doesn't show up in the list of async event queues
+      assertEquals(Collections.emptySet(), cache.getAsyncEventQueues());
+    }
+    finally {
+      String aeqId = LuceneServiceImpl.getUniqueIndexName("index1", "PR1");
+      PartitionedRegion chunkRegion = (PartitionedRegion) cache.getRegion(aeqId + ".chunks");
+      if (chunkRegion != null) {
+        chunkRegion.destroyRegion();
+      }
+      PartitionedRegion fileRegion = (PartitionedRegion) cache.getRegion(aeqId + ".files");
+      if (fileRegion != null) {
+        fileRegion.destroyRegion();
+      }
+      ((GemFireCacheImpl) cache).removeAsyncEventQueue(aeq);
+      if (aeq != null) {
+        aeq.destroy();
+      }
+      region.destroyRegion();
+    }
+  }
+
 }


[23/25] incubator-geode git commit: Merge branch 'release/1.0.0-incubating.M2' into develop

Posted by ji...@apache.org.
Merge branch 'release/1.0.0-incubating.M2' into develop


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 70c5467e2721cf693b9d546a611db43993103293
Parents: a194b03 3ac74a4
Author: Dan Smith <up...@apache.org>
Authored: Thu Apr 21 17:44:35 2016 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Thu Apr 21 17:44:35 2016 -0700

----------------------------------------------------------------------
 extensions/geode-modules-assembly/build.gradle | 1 +
 gradle/utilities.gradle                        | 5 +++++
 2 files changed, 6 insertions(+)
----------------------------------------------------------------------



[06/25] incubator-geode git commit: GEODE-1238: ensure EntryEventImpls are released

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
index 049f7df..c75286e 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
@@ -252,6 +252,7 @@ import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.LoggingThreadGroup;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.internal.sequencelog.RegionLogger;
 import com.gemstone.gemfire.internal.util.TransformUtils;
@@ -2341,7 +2342,7 @@ public class PartitionedRegion extends LocalRegion implements
         if (isDebugEnabled) {
           logger.debug("PR.postPutAll encountered exception at sendMsgByBucket, ",ex);
         }
-        EntryEventImpl firstEvent = prMsg.getFirstEvent(this);
+        @Released EntryEventImpl firstEvent = prMsg.getFirstEvent(this);
         try {
           partialKeys.saveFailedKey(firstEvent.getKey(), ex);
         } finally {
@@ -2442,7 +2443,7 @@ public class PartitionedRegion extends LocalRegion implements
         if (isDebugEnabled) {
           logger.debug("PR.postRemoveAll encountered exception at sendMsgByBucket, ",ex);
         }
-        EntryEventImpl firstEvent = prMsg.getFirstEvent(this);
+        @Released EntryEventImpl firstEvent = prMsg.getFirstEvent(this);
         try {
           partialKeys.saveFailedKey(firstEvent.getKey(), ex);
         } finally {
@@ -2489,7 +2490,7 @@ public class PartitionedRegion extends LocalRegion implements
     final boolean isDebugEnabled = logger.isDebugEnabled();
     
     // retry the put remotely until it finds the right node managing the bucket
-    EntryEventImpl event = prMsg.getFirstEvent(this);
+    @Released EntryEventImpl event = prMsg.getFirstEvent(this);
     try {
     RetryTimeKeeper retryTime = null;
     InternalDistributedMember currentTarget = getNodeForBucketWrite(bucketId.intValue(), null);
@@ -2626,7 +2627,8 @@ public class PartitionedRegion extends LocalRegion implements
   private VersionedObjectList sendMsgByBucket(final Integer bucketId, RemoveAllPRMessage prMsg)
   {
     // retry the put remotely until it finds the right node managing the bucket
-    EntryEventImpl event = prMsg.getFirstEvent(this);
+    @Released EntryEventImpl event = prMsg.getFirstEvent(this);
+    try {
     RetryTimeKeeper retryTime = null;
     InternalDistributedMember currentTarget = getNodeForBucketWrite(bucketId.intValue(), null);
     if (logger.isDebugEnabled()) {
@@ -2751,6 +2753,9 @@ public class PartitionedRegion extends LocalRegion implements
       this.prStats.incRemoveAllRetries();
     } // for
     // NOTREACHED
+    } finally {
+      event.release();
+    }
   }
 
   public VersionedObjectList tryToSendOnePutAllMessage(PutAllPRMessage prMsg,InternalDistributedMember currentTarget) throws DataLocationException {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/ProxyRegionMap.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/ProxyRegionMap.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/ProxyRegionMap.java
index 7b4504d..f0a6543 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/ProxyRegionMap.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/ProxyRegionMap.java
@@ -44,6 +44,7 @@ import com.gemstone.gemfire.internal.cache.versions.VersionSource;
 import com.gemstone.gemfire.internal.cache.versions.VersionStamp;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 /**
  * Internal implementation of {@link RegionMap}for regions whose DataPolicy is
@@ -279,7 +280,7 @@ final class ProxyRegionMap implements RegionMap {
       if (AbstractRegionMap.shouldCreateCBEvent(this.owner,
                                                 !inTokenMode)) {
         // fix for bug 39526
-        EntryEventImpl e = AbstractRegionMap.createCBEvent(this.owner, op,
+        @Released EntryEventImpl e = AbstractRegionMap.createCBEvent(this.owner, op,
             key, null, txId, txEvent, eventId, aCallbackArgument,filterRoutingInfo,bridgeContext, txEntryState, versionTag, tailKey);
         boolean cbEventInPending = false;
         try {
@@ -310,7 +311,7 @@ final class ProxyRegionMap implements RegionMap {
                                                 this.owner.isInitialized())) {
         // fix for bug 39526
         boolean cbEventInPending = false;
-        EntryEventImpl e = AbstractRegionMap.createCBEvent(this.owner, 
+        @Released EntryEventImpl e = AbstractRegionMap.createCBEvent(this.owner, 
             localOp ? Operation.LOCAL_INVALIDATE : Operation.INVALIDATE,
             key, newValue, txId, txEvent, eventId, aCallbackArgument,filterRoutingInfo,bridgeContext, txEntryState, versionTag, tailKey);
         try {
@@ -344,7 +345,7 @@ final class ProxyRegionMap implements RegionMap {
                                                 this.owner.isInitialized())) {
         // fix for bug 39526
         boolean cbEventInPending = false;
-        EntryEventImpl e = AbstractRegionMap.createCBEvent(this.owner, putOp, key, 
+        @Released EntryEventImpl e = AbstractRegionMap.createCBEvent(this.owner, putOp, key, 
             newValue, txId, txEvent, eventId, aCallbackArgument,filterRoutingInfo,bridgeContext, txEntryState, versionTag, tailKey);
         try {
         AbstractRegionMap.switchEventOwnerAndOriginRemote(e, txEntryState == null);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/QueuedOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/QueuedOperation.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/QueuedOperation.java
index fa7aea1..2d5a698 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/QueuedOperation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/QueuedOperation.java
@@ -18,6 +18,7 @@ package com.gemstone.gemfire.internal.cache;
 
 import com.gemstone.gemfire.internal.cache.versions.ConcurrentCacheModificationException;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.*;
 import com.gemstone.gemfire.cache.*;
 import com.gemstone.gemfire.distributed.DistributedMember;
@@ -80,7 +81,7 @@ public class QueuedOperation
     else {
       // it is an entry operation
       //TODO :EventID should be passed from the sender & should be reused here
-      EntryEventImpl ee = EntryEventImpl.create(
+      @Released EntryEventImpl ee = EntryEventImpl.create(
           lr, this.op, this.key, null,
           this.cbArg, true, src);
       try {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteDestroyMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteDestroyMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteDestroyMessage.java
index 4a8c101..750953a 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteDestroyMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteDestroyMessage.java
@@ -57,6 +57,7 @@ import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import static com.gemstone.gemfire.internal.offheap.annotations.OffHeapIdentifier.ENTRY_EVENT_OLD_VALUE;
 import static com.gemstone.gemfire.internal.cache.DistributedCacheOperation.VALUE_IS_BYTES;
@@ -359,7 +360,7 @@ public class RemoteDestroyMessage extends RemoteOperationMessageWithDirectReply
     if (r.keyRequiresRegionContext()) {
       ((KeyWithRegionContext)this.key).setRegionContext(r);
     }
-    EntryEventImpl event = null;
+    @Released EntryEventImpl event = null;
     try {
     if (this.bridgeContext != null) {
       event = EntryEventImpl.create(r, getOperation(), getKey(), null/*newValue*/,

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteInvalidateMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteInvalidateMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteInvalidateMessage.java
index ee01c9b..c4ed1cc 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteInvalidateMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteInvalidateMessage.java
@@ -51,6 +51,8 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
+
 import static com.gemstone.gemfire.internal.cache.DistributedCacheOperation.VALUE_IS_BYTES;
 import static com.gemstone.gemfire.internal.cache.DistributedCacheOperation.VALUE_IS_SERIALIZED_OBJECT;
 
@@ -189,7 +191,7 @@ public final class RemoteInvalidateMessage extends RemoteDestroyMessage {
     if (r.keyRequiresRegionContext()) {
       ((KeyWithRegionContext)key).setRegionContext(r);
     }
-    final EntryEventImpl event = EntryEventImpl.create(
+    @Released final EntryEventImpl event = EntryEventImpl.create(
         r,
         getOperation(),
         key,

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemotePutAllMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemotePutAllMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemotePutAllMessage.java
index c706e4f..ff09af9 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemotePutAllMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemotePutAllMessage.java
@@ -59,6 +59,7 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 /**
  * A Replicate Region putAll message.  Meant to be sent only to
@@ -356,7 +357,7 @@ public final class RemotePutAllMessage extends RemoteOperationMessageWithDirectR
     final DistributedRegion dr = (DistributedRegion)r;
     
     // create a base event and a DPAO for PutAllMessage distributed btw redundant buckets
-    EntryEventImpl baseEvent = EntryEventImpl.create(
+    @Released EntryEventImpl baseEvent = EntryEventImpl.create(
         r, Operation.PUTALL_CREATE,
         null, null, this.callbackArg, false, eventSender, !skipCallbacks);
     try {
@@ -383,7 +384,7 @@ public final class RemotePutAllMessage extends RemoteOperationMessageWithDirectR
 //        final boolean requiresRegionContext = dr.keyRequiresRegionContext();
         InternalDistributedMember myId = r.getDistributionManager().getDistributionManagerId();
         for (int i = 0; i < putAllDataCount; ++i) {
-          EntryEventImpl ev = PutAllPRMessage.getEventFromEntry(r, myId, eventSender, i, putAllData, false, bridgeContext, posDup, !skipCallbacks, isPutDML);
+          @Released EntryEventImpl ev = PutAllPRMessage.getEventFromEntry(r, myId, eventSender, i, putAllData, false, bridgeContext, posDup, !skipCallbacks, isPutDML);
           try {
           ev.setPutAllOperation(dpao);
           if (logger.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemotePutMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemotePutMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemotePutMessage.java
index 9f51b39..3fccc9a 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemotePutMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemotePutMessage.java
@@ -57,6 +57,7 @@ import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.internal.util.BlobHelper;
 import com.gemstone.gemfire.internal.util.Breadcrumbs;
@@ -683,7 +684,7 @@ public final class RemotePutMessage extends RemoteOperationMessageWithDirectRepl
     if (r.keyRequiresRegionContext()) {
       ((KeyWithRegionContext)this.key).setRegionContext(r);
     }
-    this.event = EntryEventImpl.create(
+    @Released EntryEventImpl eei = EntryEventImpl.create(
         r,
         getOperation(),
         getKey(),
@@ -693,6 +694,7 @@ public final class RemotePutMessage extends RemoteOperationMessageWithDirectRepl
         eventSender,
         true/*generateCallbacks*/,
         false/*initializeId*/);
+    this.event = eei;
     try {
     if (this.versionTag != null) {
       this.versionTag.replaceNullIDs(getSender());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteRemoveAllMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteRemoveAllMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteRemoveAllMessage.java
index 7f3a138..01e8d9e 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteRemoveAllMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/RemoteRemoveAllMessage.java
@@ -59,6 +59,7 @@ import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 /**
  * A Replicate Region removeAll message.  Meant to be sent only to
@@ -340,7 +341,7 @@ public final class RemoteRemoveAllMessage extends RemoteOperationMessageWithDire
     final DistributedRegion dr = (DistributedRegion)r;
     
     // create a base event and a op for RemoveAllMessage distributed btw redundant buckets
-    EntryEventImpl baseEvent = EntryEventImpl.create(
+    @Released EntryEventImpl baseEvent = EntryEventImpl.create(
         r, Operation.REMOVEALL_DESTROY,
         null, null, this.callbackArg, false, eventSender, true);
     try {
@@ -365,7 +366,7 @@ public final class RemoteRemoveAllMessage extends RemoteOperationMessageWithDire
       public void run() {
         InternalDistributedMember myId = r.getDistributionManager().getDistributionManagerId();
         for (int i = 0; i < removeAllDataCount; ++i) {
-          EntryEventImpl ev = RemoveAllPRMessage.getEventFromEntry(r, myId, eventSender, i, removeAllData, false, bridgeContext, posDup, false);
+          @Released EntryEventImpl ev = RemoveAllPRMessage.getEventFromEntry(r, myId, eventSender, i, removeAllData, false, bridgeContext, posDup, false);
           try {
           ev.setRemoveAllOperation(op);
           if (logger.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
index d9729a7..6642ec6 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
@@ -222,8 +222,7 @@ public class SearchLoadAndWriteProcessor implements MembershipListener {
     if (scope == Scope.LOCAL && (region.getPartitionAttributes() == null)) {
       return false;
     }
-    @Released
-    CacheEvent listenerEvent = getEventForListener(event);
+    @Released CacheEvent listenerEvent = getEventForListener(event);
     try {
     if (action == BEFOREUPDATE && listenerEvent.getOperation().isCreate()) {
       action = BEFORECREATE;
@@ -870,8 +869,7 @@ public class SearchLoadAndWriteProcessor implements MembershipListener {
         return false;
       }
     }
-    @Released
-    CacheEvent event = getEventForListener(pevent);
+    @Released CacheEvent event = getEventForListener(pevent);
     
     int action = paction;
     if (event.getOperation().isCreate() && action == BEFOREUPDATE) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXCommitMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXCommitMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXCommitMessage.java
index d1644c7..4908e09 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXCommitMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXCommitMessage.java
@@ -75,6 +75,7 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.LoggingThreadGroup;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 /** TXCommitMessage is the message that contains all the information
  * that needs to be distributed, on commit, to other cache members.
@@ -1307,6 +1308,7 @@ public class TXCommitMessage extends PooledDistributionMessage implements Member
         /*
          * This happens when we don't have the bucket and are getting adjunct notification
          */
+        // No need to release because it is added to pendingCallbacks and they will be released later
         EntryEventImpl eei = AbstractRegionMap.createCBEvent(this.r, entryOp.op, entryOp.key, entryOp.value, this.msg.txIdent, txEvent, getEventId(entryOp), entryOp.callbackArg,entryOp.filterRoutingInfo,this.msg.bridgeContext, null, entryOp.versionTag, entryOp.tailKey);
         if(entryOp.filterRoutingInfo!=null) {
           eei.setLocalFilterInfo(entryOp.filterRoutingInfo.getFilterInfo(this.r.getCache().getMyId()));
@@ -1407,7 +1409,7 @@ public class TXCommitMessage extends PooledDistributionMessage implements Member
         /*
          * This happens when we don't have the bucket and are getting adjunct notification
          */
-        EntryEventImpl eei = AbstractRegionMap.createCBEvent(this.r, entryOp.op, entryOp.key, entryOp.value, this.msg.txIdent, txEvent, getEventId(entryOp), entryOp.callbackArg,entryOp.filterRoutingInfo,this.msg.bridgeContext, null, entryOp.versionTag, entryOp.tailKey);
+        @Released EntryEventImpl eei = AbstractRegionMap.createCBEvent(this.r, entryOp.op, entryOp.key, entryOp.value, this.msg.txIdent, txEvent, getEventId(entryOp), entryOp.callbackArg,entryOp.filterRoutingInfo,this.msg.bridgeContext, null, entryOp.versionTag, entryOp.tailKey);
         try {
         if(entryOp.filterRoutingInfo!=null) {
           eei.setLocalFilterInfo(entryOp.filterRoutingInfo.getFilterInfo(this.r.getCache().getMyId()));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryState.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryState.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryState.java
index 1964c28..a4c6004 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryState.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryState.java
@@ -948,16 +948,15 @@ public class TXEntryState implements Releasable
   //                       + " isDis=" + isLocalEventDistributed());
   //    System.out.flush();
   //  }
+  @Retained
   EntryEvent getEvent(LocalRegion r, Object key, TXState txs)
   {
     // dumpOp();
-    //TODO:ASIF : Shopuld we generate EventID ? At this point not generating
     LocalRegion eventRegion = r;
     if (r.isUsedForPartitionedRegionBucket()) {
       eventRegion = r.getPartitionedRegion();
     }
-    EntryEventImpl result = new TxEntryEventImpl(eventRegion, key);
-    // OFFHEAP: freeOffHeapResources on this event is called from TXEvent.freeOffHeapResources.
+    @Retained EntryEventImpl result = new TxEntryEventImpl(eventRegion, key);
     boolean returnedResult = false;
     try {
     if (this.destroy == DESTROY_NONE || isOpDestroy()) {
@@ -2065,6 +2064,7 @@ public class TXEntryState implements Releasable
     /**
      * Creates a local tx entry event
      */
+    @Retained
     TxEntryEventImpl(LocalRegion r, Object key) {
       //TODO:ASIF :Check if the eventID should be created. Currently not
       // creating it

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRegionState.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRegionState.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRegionState.java
index c948f55..116edf7 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRegionState.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRegionState.java
@@ -477,6 +477,7 @@ public class TXRegionState {
         Object eKey = me.getKey();
         TXEntryState txes = (TXEntryState)me.getValue();
         if (txes.isDirty() && txes.isOpAnyEvent(r)) {
+          // OFFHEAP: these events are released when TXEvent.release is called
           events.add(txes.getEvent(r, eKey, txs));
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRmtEvent.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRmtEvent.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRmtEvent.java
index c0493ac..a19ce92 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRmtEvent.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRmtEvent.java
@@ -28,6 +28,8 @@ import com.gemstone.gemfire.cache.Operation;
 import com.gemstone.gemfire.cache.TransactionEvent;
 import com.gemstone.gemfire.cache.TransactionId;
 import com.gemstone.gemfire.distributed.DistributedMember;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * <p>
@@ -44,6 +46,8 @@ public class TXRmtEvent implements TransactionEvent
 
   private Cache cache;
 
+  // This list of EntryEventImpls are released by calling freeOffHeapResources
+  @Released
   private List events;
   
   TXRmtEvent(TransactionId txId, Cache cache) {
@@ -204,6 +208,7 @@ public class TXRmtEvent implements TransactionEvent
     return (events == null) || events.isEmpty();
   }
 
+  @Retained
   private EntryEventImpl createEvent(LocalRegion r, Operation op,
       RegionEntry re, Object key, Object newValue,Object aCallbackArgument)
   {
@@ -214,7 +219,7 @@ public class TXRmtEvent implements TransactionEvent
     if (r.isUsedForPartitionedRegionBucket()) {
       eventRegion = r.getPartitionedRegion();
     }
-    EntryEventImpl event = EntryEventImpl.create(
+    @Retained EntryEventImpl event = EntryEventImpl.create(
         eventRegion, op, key, newValue,
         aCallbackArgument, // callbackArg
         true, // originRemote
@@ -264,7 +269,5 @@ public class TXRmtEvent implements TransactionEvent
         e.release();
       }
     }
-    // TODO Auto-generated method stub
-    
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
index 3bec397..a67d3cc 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
@@ -62,6 +62,7 @@ import com.gemstone.gemfire.internal.cache.tier.sockets.VersionedObjectList;
 import com.gemstone.gemfire.internal.cache.tx.TransactionalOperation.ServerRegionOperation;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /** TXState is the entity that tracks the transaction state on a per
@@ -487,7 +488,7 @@ public class TXState implements TXStateInterface {
             /*
              * The event must contain the bucket region
              */
-            EntryEventImpl ev = (EntryEventImpl)o.es.getEvent(o.r, o.key, o.es.getTXRegionState().getTXState());
+            @Released EntryEventImpl ev = (EntryEventImpl)o.es.getEvent(o.r, o.key, o.es.getTXRegionState().getTXState());
             try {
             /*
              * The routing information is derived from the PR advisor, not the bucket advisor.
@@ -1755,7 +1756,7 @@ public class TXState implements TXStateInterface {
 //	        final boolean requiresRegionContext = theRegion.keyRequiresRegionContext();
 	        InternalDistributedMember myId = theRegion.getDistributionManager().getDistributionManagerId();
 	        for (int i = 0; i < putallOp.putAllDataSize; ++i) {
-	          EntryEventImpl ev = PutAllPRMessage.getEventFromEntry(theRegion, myId,myId, i, putallOp.putAllData, false, putallOp.getBaseEvent().getContext(), false, !putallOp.getBaseEvent().isGenerateCallbacks(), false);
+	          @Released EntryEventImpl ev = PutAllPRMessage.getEventFromEntry(theRegion, myId,myId, i, putallOp.putAllData, false, putallOp.getBaseEvent().getContext(), false, !putallOp.getBaseEvent().isGenerateCallbacks(), false);
 	          try {
 	          ev.setPutAllOperation(putallOp);
 	          if (theRegion.basicPut(ev, false, false, null, false)) {
@@ -1786,11 +1787,13 @@ public class TXState implements TXStateInterface {
         public void run() {
           InternalDistributedMember myId = theRegion.getDistributionManager().getDistributionManagerId();
           for (int i = 0; i < op.removeAllDataSize; ++i) {
-            EntryEventImpl ev = RemoveAllPRMessage.getEventFromEntry(theRegion, myId, myId, i, op.removeAllData, false, op.getBaseEvent().getContext(), false, !op.getBaseEvent().isGenerateCallbacks());
+            @Released EntryEventImpl ev = RemoveAllPRMessage.getEventFromEntry(theRegion, myId, myId, i, op.removeAllData, false, op.getBaseEvent().getContext(), false, !op.getBaseEvent().isGenerateCallbacks());
             ev.setRemoveAllOperation(op);
             try {
               theRegion.basicDestroy(ev, true/* should we invoke cacheWriter? */, null);
             } catch (EntryNotFoundException ignore) {
+            } finally {
+              ev.release();
             }
             successfulOps.addKeyAndVersion(op.removeAllData[i].key, null);
           }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TimestampedEntryEventImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TimestampedEntryEventImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TimestampedEntryEventImpl.java
index fca7d62..ce5cfab 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TimestampedEntryEventImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TimestampedEntryEventImpl.java
@@ -17,6 +17,7 @@
 package com.gemstone.gemfire.internal.cache;
 
 import com.gemstone.gemfire.cache.util.TimestampedEntryEvent;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * A subclass of EntryEventImpl used in WAN conflict resolution
@@ -30,6 +31,7 @@ public class TimestampedEntryEventImpl extends EntryEventImpl implements
   private long newTimestamp;
   private long oldTimestamp;
 
+  @Retained
   public TimestampedEntryEventImpl(EntryEventImpl event, int newDSID, int oldDSID, long newTimestamp, long oldTimestamp) {
     super(event);
     this.newDSID = newDSID;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateEntryVersionOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateEntryVersionOperation.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateEntryVersionOperation.java
index a3d1c19..fce4dee 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateEntryVersionOperation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateEntryVersionOperation.java
@@ -35,6 +35,7 @@ import com.gemstone.gemfire.distributed.internal.DistributionManager;
 import com.gemstone.gemfire.internal.cache.versions.ConcurrentCacheModificationException;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * This operation updates Version stamp of an entry if entry is available and
@@ -90,6 +91,7 @@ public class UpdateEntryVersionOperation extends DistributedCacheOperation {
     }
 
     @Override
+    @Retained
     protected InternalCacheEvent createEvent(DistributedRegion rgn)
         throws EntryNotFoundException {
       
@@ -97,7 +99,7 @@ public class UpdateEntryVersionOperation extends DistributedCacheOperation {
         ((KeyWithRegionContext)this.key).setRegionContext(rgn);
       }
       
-      EntryEventImpl ev = EntryEventImpl.create(rgn, getOperation(), this.key,
+      @Retained EntryEventImpl ev = EntryEventImpl.create(rgn, getOperation(), this.key,
          null /* newValue */, this.callbackArg /*callbackArg*/, true /* originRemote*/ , getSender(), false /*generateCallbacks*/);
       ev.setEventId(this.eventId);
       ev.setVersionTag(this.versionTag);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateOperation.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateOperation.java
index 452c38f..fc9c7ff 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateOperation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateOperation.java
@@ -45,6 +45,7 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.internal.util.BlobHelper;
 import com.gemstone.gemfire.internal.util.Breadcrumbs;
@@ -198,6 +199,7 @@ public class UpdateOperation extends AbstractUpdateOperation
     }
 
     @Override
+    @Retained
     protected InternalCacheEvent createEvent(DistributedRegion rgn)
         throws EntryNotFoundException {
       EntryEventImpl ev = createEntryEvent(rgn);
@@ -325,6 +327,7 @@ public class UpdateOperation extends AbstractUpdateOperation
       }
     }
 
+    @Retained
     protected EntryEventImpl createEntryEvent(DistributedRegion rgn)
     {
       Object argNewValue = null;
@@ -333,7 +336,7 @@ public class UpdateOperation extends AbstractUpdateOperation
       if (rgn.keyRequiresRegionContext()) {
         ((KeyWithRegionContext)this.key).setRegionContext(rgn);
       }
-      EntryEventImpl result = EntryEventImpl.create(rgn, getOperation(), this.key,
+      @Retained EntryEventImpl result = EntryEventImpl.create(rgn, getOperation(), this.key,
           argNewValue, // oldValue,
           this.callbackArg, originRemote, getSender(), generateCallbacks);
       setOldValueInEvent(result);
@@ -568,6 +571,7 @@ public class UpdateOperation extends AbstractUpdateOperation
     protected transient ClientProxyMembershipID clientID;
 
     @Override
+    @Retained
     final public EntryEventImpl createEntryEvent(DistributedRegion rgn)
     {
       // Object oldValue = null;
@@ -579,7 +583,7 @@ public class UpdateOperation extends AbstractUpdateOperation
       if (rgn.keyRequiresRegionContext()) {
         ((KeyWithRegionContext)this.key).setRegionContext(rgn);
       }
-      EntryEventImpl ev = EntryEventImpl.create(rgn, getOperation(), this.key,
+      @Retained EntryEventImpl ev = EntryEventImpl.create(rgn, getOperation(), this.key,
           argNewValue, this.callbackArg, originRemote, getSender(),
           generateCallbacks);
       ev.setContext(this.clientID);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/VersionTagHolder.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/VersionTagHolder.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/VersionTagHolder.java
new file mode 100644
index 0000000..48258df
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/VersionTagHolder.java
@@ -0,0 +1,34 @@
+/*
+ * 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 com.gemstone.gemfire.internal.cache;
+
+import com.gemstone.gemfire.internal.cache.versions.VersionTag;
+
+/**
+ * This class is just used to hold the version tag for an operation.
+ * It does need release to be called (unlike other EntryEventImpls)
+ * because it never has off-heap value references.
+ */
+public class VersionTagHolder extends EntryEventImpl {
+  public VersionTagHolder(VersionTag<?> tag) {
+    setVersionTag(tag);
+    disallowOffHeapValues();
+  }
+  public VersionTagHolder() {
+    this(null);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/DestroyMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/DestroyMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/DestroyMessage.java
index a30b9f2..3a6f04e 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/DestroyMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/DestroyMessage.java
@@ -59,6 +59,8 @@ import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * A class that specifies a destroy operation.
@@ -249,7 +251,7 @@ public class DestroyMessage extends PartitionMessageWithDirectReply {
     if (eventSender == null) {
        eventSender = getSender();
     }
-    EntryEventImpl event = null;
+    @Released EntryEventImpl event = null;
     try {
     if (r.keyRequiresRegionContext()) {
       ((KeyWithRegionContext)this.key).setRegionContext(r);
@@ -323,7 +325,7 @@ public class DestroyMessage extends PartitionMessageWithDirectReply {
       }
     }
     else {
-      EntryEventImpl e2 = createListenerEvent(event, r, dm.getDistributionManagerId());
+      @Released EntryEventImpl e2 = createListenerEvent(event, r, dm.getDistributionManagerId());
       try {
       r.invokeDestroyCallbacks(EnumListenerEvent.AFTER_DESTROY, e2, r.isInitialized(), true);
       } finally {
@@ -411,7 +413,10 @@ public class DestroyMessage extends PartitionMessageWithDirectReply {
     return this.eventId;
   }
 
-  /** create a new EntryEvent to be used in notifying listeners, bridge servers, etc. */
+  /** create a new EntryEvent to be used in notifying listeners, bridge servers, etc.
+   * Caller must release result if it is != to sourceEvent
+   */
+  @Retained
   EntryEventImpl createListenerEvent(EntryEventImpl sourceEvent, PartitionedRegion r,
       InternalDistributedMember member) {
     final EntryEventImpl e2;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/FetchBulkEntriesMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/FetchBulkEntriesMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/FetchBulkEntriesMessage.java
index 93501aa..d3078a9 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/FetchBulkEntriesMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/FetchBulkEntriesMessage.java
@@ -55,6 +55,7 @@ import com.gemstone.gemfire.internal.cache.InitialImageOperation;
 import com.gemstone.gemfire.internal.cache.KeyWithRegionContext;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.PartitionedRegionDataStore;
+import com.gemstone.gemfire.internal.cache.VersionTagHolder;
 import com.gemstone.gemfire.internal.cache.tier.InterestType;
 import com.gemstone.gemfire.internal.cache.versions.VersionSource;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
@@ -296,8 +297,7 @@ public final class FetchBulkEntriesMessage extends PartitionMessage
 
           while (it.hasNext()) {
             Object key = it.next();
-            EntryEventImpl clientEvent = EntryEventImpl
-                .createVersionTagHolder();
+            VersionTagHolder clientEvent = new VersionTagHolder();
             Object value = map.get(key, null, true, true, true, null,
                 clientEvent, allowTombstones, false);
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/GetMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/GetMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/GetMessage.java
index 047d1c7..d7e50f1 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/GetMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/GetMessage.java
@@ -58,6 +58,7 @@ import com.gemstone.gemfire.internal.cache.PrimaryBucketException;
 import com.gemstone.gemfire.internal.cache.TXManagerImpl;
 import com.gemstone.gemfire.internal.cache.TXStateProxy;
 import com.gemstone.gemfire.internal.cache.Token;
+import com.gemstone.gemfire.internal.cache.VersionTagHolder;
 import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
@@ -182,7 +183,7 @@ public final class GetMessage extends PartitionMessageWithDirectReply
     Object val = null;
     try {
     if (ds != null) {
-      EntryEventImpl event = EntryEventImpl.createVersionTagHolder();
+      VersionTagHolder event = new VersionTagHolder();
       try {
         if (r.keyRequiresRegionContext()) {
           ((KeyWithRegionContext)this.key).setRegionContext(r);
@@ -214,8 +215,6 @@ public final class GetMessage extends PartitionMessageWithDirectReply
       catch (DataLocationException e) {
         sendReply(getSender(), getProcessorId(), dm, new ReplyException(e), r, startTime);
         return false;
-      } finally {
-        event.release();
       }
 
       if (logger.isTraceEnabled(LogMarker.DM)) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/InvalidateMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/InvalidateMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/InvalidateMessage.java
index 8c14e49..60508c1 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/InvalidateMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/InvalidateMessage.java
@@ -54,6 +54,7 @@ import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 public final class InvalidateMessage extends DestroyMessage {
   private static final Logger logger = LogService.getLogger();
@@ -179,7 +180,7 @@ public final class InvalidateMessage extends DestroyMessage {
     if (r.keyRequiresRegionContext()) {
       ((KeyWithRegionContext)key).setRegionContext(r);
     }
-    final EntryEventImpl event = EntryEventImpl.create(
+    @Released final EntryEventImpl event = EntryEventImpl.create(
         r,
         getOperation(),
         key,

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PRUpdateEntryVersionMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PRUpdateEntryVersionMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PRUpdateEntryVersionMessage.java
index 7fcb031..e1766dc 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PRUpdateEntryVersionMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PRUpdateEntryVersionMessage.java
@@ -130,6 +130,7 @@ public class PRUpdateEntryVersionMessage extends
       ((KeyWithRegionContext) key).setRegionContext(pr);
     }
 
+    // release not needed because disallowOffHeapValues called
     final EntryEventImpl event = EntryEventImpl.create(pr, getOperation(),
         getKey(), null, /* newValue */
         null, /* callbackargs */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PutAllPRMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PutAllPRMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PutAllPRMessage.java
index cace5cc..a88f96f 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PutAllPRMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PutAllPRMessage.java
@@ -72,6 +72,8 @@ import com.gemstone.gemfire.internal.cache.versions.ConcurrentCacheModificationE
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * A Partitioned Region update message.  Meant to be sent only to
@@ -359,12 +361,13 @@ public final class PutAllPRMessage extends PartitionMessageWithDirectReply
   }
 
   /* we need a event with content for waitForNodeOrCreateBucket() */
+  @Retained
   public EntryEventImpl getFirstEvent(PartitionedRegion r) {
     if (putAllPRDataSize == 0) {
       return null;
     }
     
-    EntryEventImpl ev = EntryEventImpl.create(r, 
+    @Retained EntryEventImpl ev = EntryEventImpl.create(r, 
         putAllPRData[0].getOp(),
         putAllPRData[0].getKey(), 
         putAllPRData[0].getValue(), 
@@ -408,7 +411,7 @@ public final class PutAllPRMessage extends PartitionMessageWithDirectReply
     }
     
     DistributedPutAllOperation dpao = null;
-    EntryEventImpl baseEvent = null;
+    @Released EntryEventImpl baseEvent = null;
     BucketRegion bucketRegion = null;
     PartitionedRegionDataStore ds = r.getDataStore();
     InternalDistributedMember myId = r.getDistributionManager().getDistributionManagerId();
@@ -486,7 +489,7 @@ public final class PutAllPRMessage extends PartitionMessageWithDirectReply
            * in this request, because these request will be blocked by foundKey
            */
           for (int i=0; i<putAllPRDataSize; i++) {
-            EntryEventImpl ev = getEventFromEntry(r, myId, eventSender, i,putAllPRData,notificationOnly,bridgeContext,posDup,skipCallbacks, this.isPutDML);
+            @Released EntryEventImpl ev = getEventFromEntry(r, myId, eventSender, i,putAllPRData,notificationOnly,bridgeContext,posDup,skipCallbacks, this.isPutDML);
             try {
             key = ev.getKey();
 
@@ -596,6 +599,7 @@ public final class PutAllPRMessage extends PartitionMessageWithDirectReply
 	return true;
   }
   
+  @Retained
   public static EntryEventImpl getEventFromEntry(LocalRegion r,
       InternalDistributedMember myId, InternalDistributedMember eventSender,
       int idx, DistributedPutAllOperation.PutAllEntryData[] data,
@@ -610,7 +614,7 @@ public final class PutAllPRMessage extends PartitionMessageWithDirectReply
       //  true/* generate Callbacks */,
       //  prd.getEventID());
     
-    EntryEventImpl ev = EntryEventImpl.create(r, prd.getOp(), prd.getKey(), prd
+    @Retained EntryEventImpl ev = EntryEventImpl.create(r, prd.getOp(), prd.getKey(), prd
         .getValue(), null, false, eventSender, !skipCallbacks, prd.getEventID());
     boolean evReturned = false;
     try {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PutMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PutMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PutMessage.java
index 77a47b7..db11a8e 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PutMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/PutMessage.java
@@ -67,6 +67,8 @@ import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.internal.util.BlobHelper;
 
@@ -450,7 +452,10 @@ public final class PutMessage extends PartitionMessageWithDirectReply implements
 //  }
 
 
-  /** create a new EntryEvent to be used in notifying listeners, bridge servers, etc. */
+  /** create a new EntryEvent to be used in notifying listeners, bridge servers, etc.
+   * Caller must release result if it is != to sourceEvent
+   */
+  @Retained
   EntryEventImpl createListenerEvent(EntryEventImpl sourceEvent, PartitionedRegion r,
       InternalDistributedMember member) {
     final EntryEventImpl e2;
@@ -795,7 +800,7 @@ public final class PutMessage extends PartitionMessageWithDirectReply implements
     if (r.keyRequiresRegionContext()) {
       ((KeyWithRegionContext)this.key).setRegionContext(r);
     }
-    final EntryEventImpl ev = EntryEventImpl.create(
+    @Released final EntryEventImpl ev = EntryEventImpl.create(
         r,
         getOperation(),
         getKey(),
@@ -906,7 +911,7 @@ public final class PutMessage extends PartitionMessageWithDirectReply implements
       }
     }
     else { // notificationOnly
-      EntryEventImpl e2 = createListenerEvent(ev, r, dm.getDistributionManagerId());
+      @Released EntryEventImpl e2 = createListenerEvent(ev, r, dm.getDistributionManagerId());
       final EnumListenerEvent le;
       try {
       if (e2.getOperation().isCreate()) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/RemoveAllPRMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/RemoveAllPRMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/RemoveAllPRMessage.java
index c907943..fb46e0c 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/RemoveAllPRMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/RemoveAllPRMessage.java
@@ -73,6 +73,8 @@ import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * PR removeAll
@@ -339,12 +341,13 @@ public final class RemoveAllPRMessage extends PartitionMessageWithDirectReply
   }
 
   /* we need a event with content for waitForNodeOrCreateBucket() */
+  @Retained
   public EntryEventImpl getFirstEvent(PartitionedRegion r) {
     if (removeAllPRDataSize == 0) {
       return null;
     }
     
-    EntryEventImpl ev = EntryEventImpl.create(r, 
+    @Retained EntryEventImpl ev = EntryEventImpl.create(r, 
         removeAllPRData[0].getOp(),
         removeAllPRData[0].getKey(), 
         null /*value*/, 
@@ -388,7 +391,7 @@ public final class RemoveAllPRMessage extends PartitionMessageWithDirectReply
     }
     
     DistributedRemoveAllOperation op = null;
-    EntryEventImpl baseEvent = null;
+    @Released EntryEventImpl baseEvent = null;
     BucketRegion bucketRegion = null;
     PartitionedRegionDataStore ds = r.getDataStore();
     InternalDistributedMember myId = r.getDistributionManager().getDistributionManagerId();
@@ -466,7 +469,7 @@ public final class RemoveAllPRMessage extends PartitionMessageWithDirectReply
            * in this request, because these request will be blocked by foundKey
            */
           for (int i=0; i<removeAllPRDataSize; i++) {
-            EntryEventImpl ev = getEventFromEntry(r, myId, eventSender, i,removeAllPRData,notificationOnly,bridgeContext,posDup,skipCallbacks);
+            @Released EntryEventImpl ev = getEventFromEntry(r, myId, eventSender, i,removeAllPRData,notificationOnly,bridgeContext,posDup,skipCallbacks);
             try {
             key = ev.getKey();
 
@@ -574,14 +577,14 @@ public final class RemoveAllPRMessage extends PartitionMessageWithDirectReply
   public boolean canStartRemoteTransaction() {
         return true;
   }
-  
+  @Retained
   public static EntryEventImpl getEventFromEntry(LocalRegion r,
       InternalDistributedMember myId, InternalDistributedMember eventSender,
       int idx, DistributedRemoveAllOperation.RemoveAllEntryData[] data,
       boolean notificationOnly, ClientProxyMembershipID bridgeContext,
       boolean posDup, boolean skipCallbacks) {
     RemoveAllEntryData dataItem = data[idx];
-    EntryEventImpl ev = EntryEventImpl.create(r, dataItem.getOp(), dataItem.getKey(), null, null, false, eventSender, !skipCallbacks, dataItem.getEventID());
+    @Retained EntryEventImpl ev = EntryEventImpl.create(r, dataItem.getOp(), dataItem.getKey(), null, null, false, eventSender, !skipCallbacks, dataItem.getEventID());
     boolean evReturned = false;
     try {
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/BaseCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/BaseCommand.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/BaseCommand.java
index 0be56f9..c264616 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/BaseCommand.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/BaseCommand.java
@@ -69,6 +69,7 @@ import com.gemstone.gemfire.internal.cache.PartitionedRegionHelper;
 import com.gemstone.gemfire.internal.cache.TXManagerImpl;
 import com.gemstone.gemfire.internal.cache.TXStateProxy;
 import com.gemstone.gemfire.internal.cache.Token;
+import com.gemstone.gemfire.internal.cache.VersionTagHolder;
 import com.gemstone.gemfire.internal.cache.tier.CachedRegionHelper;
 import com.gemstone.gemfire.internal.cache.tier.Command;
 import com.gemstone.gemfire.internal.cache.tier.InterestType;
@@ -1141,7 +1142,7 @@ public abstract class BaseCommand implements Command {
 
     if (region != null) {
       if (region.containsKey(entryKey) || region.containsTombstone(entryKey)) {
-        EntryEventImpl versionHolder = EntryEventImpl.createVersionTagHolder();
+        VersionTagHolder versionHolder = new VersionTagHolder();
         ClientProxyMembershipID id = servConn == null ? null : servConn.getProxyID();
         // From Get70.getValueAndIsObject()
         Object data = region.get(entryKey, null, true, true, true, id, versionHolder, true, false);
@@ -1237,7 +1238,7 @@ public abstract class BaseCommand implements Command {
       }
 
       for (Object key : region.keySet(true)) {
-        EntryEventImpl versionHolder = EntryEventImpl.createVersionTagHolder();
+        VersionTagHolder versionHolder = new VersionTagHolder();
         if (keyPattern != null) {
           if (!(key instanceof String)) {
             // key is not a String, cannot apply regex to this entry
@@ -1338,11 +1339,11 @@ public abstract class BaseCommand implements Command {
       VersionedObjectList values, Object riKeys, Set keySet, ServerConnection servConn)
       throws IOException {
     Object key = null;
-    EntryEventImpl versionHolder = null;
+    VersionTagHolder versionHolder = null;
     ClientProxyMembershipID requestingClient = servConn == null ? null : servConn.getProxyID();
     for (Iterator it = keySet.iterator(); it.hasNext();) {
       key = it.next();
-      versionHolder = EntryEventImpl.createVersionTagHolder();
+      versionHolder = new VersionTagHolder();
 
       Object value = region.get(key, null, true, true, true, requestingClient, versionHolder, true, false);
       
@@ -1545,8 +1546,7 @@ public abstract class BaseCommand implements Command {
       for (Iterator it = keyList.iterator(); it.hasNext();) {
         Object key = it.next();
         if (region.containsKey(key) || region.containsTombstone(key)) {
-          EntryEventImpl versionHolder = EntryEventImpl
-              .createVersionTagHolder();
+          VersionTagHolder versionHolder = new VersionTagHolder();
 
           ClientProxyMembershipID id = servConn == null ? null : servConn
               .getProxyID();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientUpdater.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientUpdater.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientUpdater.java
index 8968f62..ce067d7 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientUpdater.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientUpdater.java
@@ -90,6 +90,7 @@ import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.LoggingThreadGroup;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.sequencelog.EntryLogger;
 import com.gemstone.gemfire.security.AuthenticationFailedException;
 import com.gemstone.gemfire.security.AuthenticationRequiredException;
@@ -771,7 +772,7 @@ public class CacheClientUpdater extends Thread implements ClientUpdater,
       else if (region.hasServerProxy()
           && ServerResponseMatrix.checkForValidStateAfterNotification(region,
               key, m.getMessageType()) && (withInterest || !withCQs)) {
-        EntryEventImpl newEvent = null;
+        @Released EntryEventImpl newEvent = null;
         try {
           // Create an event and put the entry
           newEvent = EntryEventImpl.create(

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy.java
index 888cf62..593cc08 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy.java
@@ -21,6 +21,7 @@ package com.gemstone.gemfire.internal.cache.tier.sockets.command;
 
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
+import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.tier.CachedRegionHelper;
@@ -152,7 +153,7 @@ public class Destroy extends BaseCommand {
             }
           }
           region.basicBridgeDestroy(key, callbackArg, servConn.getProxyID(),
-              true, new EntryEventImpl(eventId));
+              true, new EventIDHolder(eventId));
           servConn.setModificationInfo(true, regionName, key);
         }
         catch (EntryNotFoundException e) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy65.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy65.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy65.java
index 513e902..1da422a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy65.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy65.java
@@ -24,6 +24,7 @@ import com.gemstone.gemfire.internal.cache.Token;
 import com.gemstone.gemfire.internal.cache.OpType;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
+import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.tier.CachedRegionHelper;
@@ -201,7 +202,7 @@ public class Destroy65 extends BaseCommand {
             .readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
         EventID eventId = new EventID(servConn.getEventMemberIDByteArray(),
             threadId, sequenceId);
-        EntryEventImpl clientEvent = new EntryEventImpl(eventId);
+        EventIDHolder clientEvent = new EventIDHolder(eventId);
         
         Breadcrumbs.setEventId(eventId);
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/GatewayReceiverCommand.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
index e2fb686..fce1175 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
@@ -37,6 +37,7 @@ import com.gemstone.gemfire.i18n.LogWriterI18n;
 import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
+import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.cache.KeyWithRegionContext;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
@@ -194,7 +195,7 @@ public class GatewayReceiverCommand extends BaseCommand {
       int actionType = actionTypePart.getInt();
       
       long versionTimeStamp = VersionTag.ILLEGAL_VERSION_TIMESTAMP;
-      EntryEventImpl clientEvent = null;
+      EventIDHolder clientEvent = null;
       
       boolean callbackArgExists = false;
 
@@ -306,7 +307,7 @@ public class GatewayReceiverCommand extends BaseCommand {
           if (region == null) {
             handleRegionNull(servConn, regionName, batchId);
           } else {
-            clientEvent = new EntryEventImpl(eventId);
+            clientEvent = new EventIDHolder(eventId);
             if (versionTimeStamp > 0) {
               VersionTag tag = VersionTag.create(region.getVersionMember());
               tag.setIsGatewayTag(true);
@@ -415,7 +416,7 @@ public class GatewayReceiverCommand extends BaseCommand {
           if (region == null) {
             handleRegionNull(servConn, regionName, batchId);
           } else {
-            clientEvent = new EntryEventImpl(eventId);
+            clientEvent = new EventIDHolder(eventId);
             if (versionTimeStamp > 0) {
               VersionTag tag = VersionTag.create(region.getVersionMember());
               tag.setIsGatewayTag(true);
@@ -514,7 +515,7 @@ public class GatewayReceiverCommand extends BaseCommand {
           if (region == null) {
             handleRegionNull(servConn, regionName, batchId);
           } else {
-            clientEvent = new EntryEventImpl(eventId);
+            clientEvent = new EventIDHolder(eventId);
             if (versionTimeStamp > 0) {
               VersionTag tag = VersionTag.create(region.getVersionMember());
               tag.setIsGatewayTag(true);
@@ -596,7 +597,7 @@ public class GatewayReceiverCommand extends BaseCommand {
               handleRegionNull(servConn, regionName, batchId);
             } else {
 
-              clientEvent = new EntryEventImpl(eventId);
+              clientEvent = new EventIDHolder(eventId);
               
               if (versionTimeStamp > 0) {
                 VersionTag tag = VersionTag.create(region.getVersionMember());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Get70.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Get70.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Get70.java
index e382c57..b2be3c3 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Get70.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Get70.java
@@ -30,6 +30,7 @@ import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.Token;
+import com.gemstone.gemfire.internal.cache.VersionTagHolder;
 import com.gemstone.gemfire.internal.cache.tier.CachedRegionHelper;
 import com.gemstone.gemfire.internal.cache.tier.Command;
 import com.gemstone.gemfire.internal.cache.tier.MessageType;
@@ -303,13 +304,9 @@ public class Get70 extends BaseCommand {
 //      }
 //    } else {
       ClientProxyMembershipID id = servConn == null ? null : servConn.getProxyID();
-      EntryEventImpl versionHolder = EntryEventImpl.createVersionTagHolder();
-      try {
+      VersionTagHolder versionHolder = new VersionTagHolder();
         // TODO OFFHEAP: optimize
       data  = ((LocalRegion) region).get(key, callbackArg, true, true, true, id, versionHolder, true, true /*allowReadFromHDFS*/);
-      }finally {
-        versionHolder.release();
-      }
 //    }
     versionTag = versionHolder.getVersionTag();
     
@@ -368,12 +365,8 @@ public class Get70 extends BaseCommand {
     @Retained Object data = null;
 
     ClientProxyMembershipID id = servConn == null ? null : servConn.getProxyID();
-    EntryEventImpl versionHolder = EntryEventImpl.createVersionTagHolder();
-    try {
-      data = ((LocalRegion) region).getRetained(key, callbackArg, true, true, id, versionHolder, true);
-    }finally {
-      versionHolder.release();
-    }
+    VersionTagHolder versionHolder = new VersionTagHolder();
+    data = ((LocalRegion) region).getRetained(key, callbackArg, true, true, id, versionHolder, true);
     versionTag = versionHolder.getVersionTag();
     
     // If it is Token.REMOVED, Token.DESTROYED,

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Invalidate.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Invalidate.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Invalidate.java
index b037a88..3f313c9 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Invalidate.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Invalidate.java
@@ -28,6 +28,7 @@ import com.gemstone.gemfire.cache.operations.InvalidateOperationContext;
 import com.gemstone.gemfire.distributed.internal.DistributionStats;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
+import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.tier.CachedRegionHelper;
@@ -153,7 +154,7 @@ public class Invalidate extends BaseCommand {
                 .invalidateAuthorize(regionName, key, callbackArg);
             callbackArg = invalidateContext.getCallbackArg();
           }
-          EntryEventImpl clientEvent = new EntryEventImpl(eventId);
+          EventIDHolder clientEvent = new EventIDHolder(eventId);
 
           // msg.isRetry might be set by v7.0 and later clients
           if (msg.isRetry()) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put.java
index 46f4471..35cc085 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put.java
@@ -21,6 +21,7 @@ package com.gemstone.gemfire.internal.cache.tier.sockets.command;
 
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
+import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.tier.CachedRegionHelper;
 import com.gemstone.gemfire.internal.cache.tier.Command;
@@ -192,12 +193,12 @@ public class Put extends BaseCommand {
             // isObject
             // the true after null doesn't matter and is not used.
             result = region.basicBridgeCreate(key, null, true, callbackArg,
-                servConn.getProxyID(), true, new EntryEventImpl(eventId), false);
+                servConn.getProxyID(), true, new EventIDHolder(eventId), false);
           }
           else {
             // Put the entry
             result = region.basicBridgePut(key, value, null, isObject, callbackArg,
-                servConn.getProxyID(), true, new EntryEventImpl(eventId), servConn.isSqlFabricSystem());
+                servConn.getProxyID(), true, new EventIDHolder(eventId), servConn.isSqlFabricSystem());
           }
           if (result) {
             servConn.setModificationInfo(true, regionName, key);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put61.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put61.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put61.java
index 2943091..cc4c1d6 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put61.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put61.java
@@ -30,6 +30,7 @@ import com.gemstone.gemfire.cache.operations.PutOperationContext;
 import com.gemstone.gemfire.distributed.internal.DistributionStats;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
+import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.tier.CachedRegionHelper;
@@ -223,7 +224,7 @@ public class Put61 extends BaseCommand {
             // isObject
             // the true after null doesn't matter and is not used.
             result = region.basicBridgeCreate(key, null, true, callbackArg,
-                servConn.getProxyID(), true, new EntryEventImpl(eventId), false);
+                servConn.getProxyID(), true, new EventIDHolder(eventId), false);
           }
           else {
             // Put the entry
@@ -232,7 +233,7 @@ public class Put61 extends BaseCommand {
               delta = valuePart.getSerializedForm();              
             }
             result = region.basicBridgePut(key, value, delta, isObject,
-                callbackArg, servConn.getProxyID(), true, new EntryEventImpl(eventId), servConn
+                callbackArg, servConn.getProxyID(), true, new EventIDHolder(eventId), servConn
                     .isSqlFabricSystem());
           }
           if (result) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put65.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put65.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put65.java
index 092e2ee..9be1390 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put65.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Put65.java
@@ -37,6 +37,7 @@ import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.internal.cache.CachedDeserializable;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
+import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.TXManagerImpl;
@@ -220,7 +221,7 @@ public class Put65 extends BaseCommand {
         long sequenceId = EventID
             .readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
 
-        EntryEventImpl clientEvent = new EntryEventImpl(
+        EventIDHolder clientEvent = new EventIDHolder(
             new EventID(servConn.getEventMemberIDByteArray(),
               threadId, sequenceId));
         

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tx/DistTxEntryEvent.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tx/DistTxEntryEvent.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tx/DistTxEntryEvent.java
index a108965..6e7c21c 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tx/DistTxEntryEvent.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tx/DistTxEntryEvent.java
@@ -36,6 +36,7 @@ import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.DistributedPutAllOperation.EntryVersionsList;
 import com.gemstone.gemfire.internal.cache.DistributedPutAllOperation.PutAllEntryData;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * 
@@ -46,7 +47,13 @@ public class DistTxEntryEvent extends EntryEventImpl {
   protected static final byte HAS_PUTALL_OP = 0x1;
   protected static final byte HAS_REMOVEALL_OP = 0x2;
 
-  // For Serialization
+  /**
+   * TODO DISTTX: callers of this constructor need to
+   * make sure that release is called. In general
+   * the distributed tx code needs to be reviewed to
+   * see if it correctly handles off-heap.
+   */
+  @Retained
   public DistTxEntryEvent(EntryEventImpl entry) {
     super(entry);
   }
@@ -179,7 +186,7 @@ public class DistTxEntryEvent extends EntryEventImpl {
         }
       }
     }
-    
+    // TODO DISTTX: release this event?
     EntryEventImpl e = EntryEventImpl.create(
         this.region, Operation.PUTALL_CREATE,
         null, null, null, true, this.getDistributedMember(), true, true);
@@ -246,7 +253,7 @@ public class DistTxEntryEvent extends EntryEventImpl {
         removeAllData[i].versionTag = versionTags.get(i);
       }
     }
-    
+    // TODO DISTTX: release this event
     EntryEventImpl e = EntryEventImpl.create(
         this.region, Operation.REMOVEALL_DESTROY,
         null, null, null, true, this.getDistributedMember(), true, true);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tx/PartitionedTXRegionStub.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tx/PartitionedTXRegionStub.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tx/PartitionedTXRegionStub.java
index 323dcc4..6723646 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tx/PartitionedTXRegionStub.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tx/PartitionedTXRegionStub.java
@@ -46,6 +46,7 @@ import com.gemstone.gemfire.internal.cache.partitioned.RemoveAllPRMessage;
 import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID;
 import com.gemstone.gemfire.internal.cache.tier.sockets.VersionedObjectList;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -386,7 +387,7 @@ public class PartitionedTXRegionStub extends AbstractPeerTXRegionStub {
         partialKeys.consolidate(pre.getResult());
       } catch (Exception ex) {
         // If failed at other exception
-        EntryEventImpl firstEvent = prMsg.getFirstEvent(pr);
+        @Released EntryEventImpl firstEvent = prMsg.getFirstEvent(pr);
         try {
           partialKeys.saveFailedKey(firstEvent.getKey(), ex);
         } finally {
@@ -444,8 +445,12 @@ public class PartitionedTXRegionStub extends AbstractPeerTXRegionStub {
         partialKeys.consolidate(pre.getResult());
       } catch (Exception ex) {
         // If failed at other exception
-        EntryEventImpl firstEvent = prMsg.getFirstEvent(pr);
+        @Released EntryEventImpl firstEvent = prMsg.getFirstEvent(pr);
+        try {
           partialKeys.saveFailedKey(firstEvent.getKey(), ex);
+        } finally {
+          firstEvent.release();
+        }
       }
     }
     pr.prStats.endRemoveAll(startTime);
@@ -477,7 +482,7 @@ public class PartitionedTXRegionStub extends AbstractPeerTXRegionStub {
     // retry the put remotely until it finds the right node managing the bucket
     InternalDistributedMember currentTarget = pr.getOrCreateNodeForBucketWrite(bucketId.intValue(), null);
     if(!currentTarget.equals(this.state.getTarget())) {
-      EntryEventImpl firstEvent = prMsg.getFirstEvent(pr);
+      @Released EntryEventImpl firstEvent = prMsg.getFirstEvent(pr);
       try {
         throw new TransactionDataNotColocatedException(LocalizedStrings.PartitionedRegion_KEY_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(firstEvent.getKey()));
       } finally {
@@ -507,8 +512,12 @@ public class PartitionedTXRegionStub extends AbstractPeerTXRegionStub {
     // retry the put remotely until it finds the right node managing the bucket
     InternalDistributedMember currentTarget = pr.getOrCreateNodeForBucketWrite(bucketId.intValue(), null);
     if(!currentTarget.equals(this.state.getTarget())) {
-      EntryEventImpl firstEvent = prMsg.getFirstEvent(pr);
+      @Released EntryEventImpl firstEvent = prMsg.getFirstEvent(pr);
+      try {
         throw new TransactionDataNotColocatedException(LocalizedStrings.PartitionedRegion_KEY_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(firstEvent.getKey()));
+      } finally {
+        firstEvent.release();
+      }
     }
     try {
       return pr.tryToSendOneRemoveAllMessage(prMsg,currentTarget);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/AbstractGatewaySender.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/AbstractGatewaySender.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/AbstractGatewaySender.java
index 4f3488b..94524bd 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/AbstractGatewaySender.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/AbstractGatewaySender.java
@@ -74,6 +74,7 @@ import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.LoggingThreadGroup;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.offheap.Releasable;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 
@@ -875,8 +876,8 @@ public abstract class AbstractGatewaySender implements GatewaySender,
       getStatistics().incEventsFiltered();
       return;
     }
-    
-    EntryEventImpl clonedEvent = new EntryEventImpl(event, false);
+    // released by this method or transfers ownership to TmpQueueEvent
+    @Released EntryEventImpl clonedEvent = new EntryEventImpl(event, false);
     boolean freeClonedEvent = true;
     try {
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/AbstractGatewaySenderEventProcessor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
index 9cde6dd..2ef5e19 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
@@ -816,10 +816,12 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread {
     if (pdxRegion != null && pdxRegion.size() != pdxEventsMap.size()) {
       for (Map.Entry<Object, Object> typeEntry : pdxRegion.entrySet()) {
         if(!pdxEventsMap.containsKey(typeEntry.getKey())){
+          // event should never be off-heap so it does not need to be released
           EntryEventImpl event = EntryEventImpl.create(
               (LocalRegion) pdxRegion, Operation.UPDATE,
               typeEntry.getKey(), typeEntry.getValue(), null, false,
               cache.getMyId());
+          event.disallowOffHeapValues();
           event.setEventId(new EventID(cache.getSystem()));
           List<Integer> allRemoteDSIds = new ArrayList<Integer>();
           for (GatewaySender sender : cache.getGatewaySenders()) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/BatchDestroyOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/BatchDestroyOperation.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/BatchDestroyOperation.java
index 988c526..717253e 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/BatchDestroyOperation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/BatchDestroyOperation.java
@@ -44,6 +44,7 @@ import com.gemstone.gemfire.internal.cache.RegionQueue;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * Handles distribution messaging for destroying a batch of entry in a queue region.
@@ -157,6 +158,7 @@ public class BatchDestroyOperation extends DistributedCacheOperation {
     }
 
     @Override
+    @Retained
     protected final InternalCacheEvent createEvent(DistributedRegion rgn)
         throws EntryNotFoundException {
       EntryEventImpl ev = createEntryEvent(rgn);
@@ -176,8 +178,9 @@ public class BatchDestroyOperation extends DistributedCacheOperation {
       }
     }
 
+    @Retained
     EntryEventImpl createEntryEvent(DistributedRegion rgn) {
-      EntryEventImpl event = EntryEventImpl.create(rgn, getOperation(), this.key,
+      @Retained EntryEventImpl event = EntryEventImpl.create(rgn, getOperation(), this.key,
           null, this.callbackArg, true, getSender());
       // event.setNewEventId(); Don't set the event here...
       setOldValueInEvent(event);



[21/25] incubator-geode git commit: Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/incubator-geode into develop

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


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 7de1d32b1a794356f3cdddbd5bd4cc4a92230c44
Parents: ada13a3 f810d62
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Apr 22 05:30:45 2016 +1000
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Apr 22 05:30:45 2016 +1000

----------------------------------------------------------------------
 LICENSE                                       | 60 ++++++++++++++++++++++
 geode-assembly/src/main/dist/LICENSE          |  8 ++-
 geode-assembly/src/main/dist/NOTICE           | 36 ++-----------
 geode-pulse/src/main/webapp/META-INF/NOTICE   | 18 +------
 geode-web-api/src/main/webapp/META-INF/NOTICE | 12 +----
 5 files changed, 74 insertions(+), 60 deletions(-)
----------------------------------------------------------------------



[20/25] incubator-geode git commit: GEODE-1164: Fixing import issues

Posted by ji...@apache.org.
GEODE-1164: Fixing import issues


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

Branch: refs/heads/feature/GEODE-17-2
Commit: ada13a36593d6ace7d1f6e1f6df53a9a12a49b5c
Parents: 7e1656b
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Apr 22 05:30:01 2016 +1000
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Apr 22 05:30:01 2016 +1000

----------------------------------------------------------------------
 .../gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java   | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ada13a36/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
index ce08b52..4e94e8b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
@@ -46,6 +46,14 @@ import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.Wait;
 import com.gemstone.gemfire.test.junit.categories.FlakyTest;
 
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
 /**
  * Tests remote (client/server) query execution.
  *


[15/25] incubator-geode git commit: GEODE-1146: Test cleanup, converting many VM invoke statements to lambda expressions

Posted by ji...@apache.org.
GEODE-1146: Test cleanup, converting many VM invoke statements to lambda expressions


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 7e1656b0847ddc1f1f5f7fdba60513ba7e814d43
Parents: b5ff974
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Tue Apr 19 05:59:40 2016 +1000
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Apr 22 04:49:14 2016 +1000

----------------------------------------------------------------------
 .../query/dunit/QueryUsingPoolDUnitTest.java    | 2701 ++++++++----------
 .../internal/JUnit4DistributedTestCase.java     |    2 +-
 .../test/dunit/standalone/ProcessManager.java   |    7 +-
 3 files changed, 1200 insertions(+), 1510 deletions(-)
----------------------------------------------------------------------



[18/25] incubator-geode git commit: GEODE-1265: Add Droid fonts to LICENSE

Posted by ji...@apache.org.
GEODE-1265: Add Droid fonts to LICENSE


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

Branch: refs/heads/feature/GEODE-17-2
Commit: f810d62d0695c95ff56d32855eb2c80a7098213f
Parents: 14d0cf5
Author: Anthony Baker <ab...@apache.org>
Authored: Wed Apr 20 15:37:35 2016 -0700
Committer: Anthony Baker <ab...@apache.org>
Committed: Thu Apr 21 11:52:23 2016 -0700

----------------------------------------------------------------------
 LICENSE                              | 3 +++
 geode-assembly/src/main/dist/LICENSE | 3 +++
 2 files changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f810d62d/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 3413a7c..f067970 100644
--- a/LICENSE
+++ b/LICENSE
@@ -208,6 +208,9 @@ Apache Geode includes a number of components and libraries with separate
 copyright notices and license terms. Your use of those components are
 subject to the terms and conditions of the following licenses.
 
+Apache Geode bundles the Droid fonts (http://www.droidfonts.com) under
+the Apache License v2.0.
+
 ---------------------------------------------------------------------------
 The BSD 3-Clause License (http://opensource.org/licenses/BSD-3-Clause)
 ---------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f810d62d/geode-assembly/src/main/dist/LICENSE
----------------------------------------------------------------------
diff --git a/geode-assembly/src/main/dist/LICENSE b/geode-assembly/src/main/dist/LICENSE
index 3ed1e9a..9c2580a 100644
--- a/geode-assembly/src/main/dist/LICENSE
+++ b/geode-assembly/src/main/dist/LICENSE
@@ -208,6 +208,9 @@ Apache Geode includes a number of components and libraries with separate
 copyright notices and license terms. Your use of those components are
 subject to the terms and conditions of the following licenses.
 
+Apache Geode bundles the Droid fonts (http://www.droidfonts.com) under
+the Apache License v2.0.
+
 ---------------------------------------------------------------------------
 The BSD 3-Clause License (http://opensource.org/licenses/BSD-3-Clause)
 ---------------------------------------------------------------------------


[05/25] incubator-geode git commit: GEODE-1238: ensure EntryEventImpls are released

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessor.java
index 2cb98ea..ff810ec 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessor.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessor.java
@@ -54,6 +54,7 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.LoggingThreadGroup;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 /**
  * 
@@ -130,7 +131,7 @@ public class ConcurrentSerialGatewaySenderEventProcessor extends
     if (sender.getOrderPolicy() == OrderPolicy.KEY || sender.getOrderPolicy() == OrderPolicy.PARTITION) {
       // Create copy since the event id will be changed, otherwise the same
       // event will be changed for multiple gateways. Fix for bug 44471.
-      EntryEventImpl clonedEvent = new EntryEventImpl((EntryEventImpl)event);
+      @Released EntryEventImpl clonedEvent = new EntryEventImpl((EntryEventImpl)event);
       try {
       EventID originalEventId = clonedEvent.getEventId();
       if (logger.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueue.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueue.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueue.java
index 7c492db..312fc4b 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueue.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueue.java
@@ -1134,7 +1134,7 @@ public class SerialGatewaySenderQueue implements RegionQueue {
               }
               if (wasEmpty) continue;
             }
-            
+            // release not needed since disallowOffHeapValues called
             EntryEventImpl event = EntryEventImpl.create((LocalRegion)region,
                 Operation.DESTROY, (lastDestroyedKey + 1) , null/* newValue */, null, false,
                 cache.getMyId());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedAckRegionCCEDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedAckRegionCCEDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedAckRegionCCEDUnitTest.java
index d642888..8f922a0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedAckRegionCCEDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedAckRegionCCEDUnitTest.java
@@ -56,7 +56,8 @@ import com.gemstone.gemfire.internal.cache.RegionClearedException;
 import com.gemstone.gemfire.internal.cache.RegionEntry;
 import com.gemstone.gemfire.internal.cache.Token;
 import com.gemstone.gemfire.internal.cache.TombstoneService;
-import com.gemstone.gemfire.internal.cache.UpdateOperation;
+import com.gemstone.gemfire.internal.cache.UpdateOperation;
+import com.gemstone.gemfire.internal.cache.VersionTagHolder;
 import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID;
 import com.gemstone.gemfire.internal.cache.versions.VMVersionTag;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
@@ -472,10 +473,9 @@ public class DistributedAckRegionCCEDUnitTest extends DistributedAckRegionDUnitT
       tag.setEntryVersion(0xFFFFFF);
       tag.setDistributedSystemId(1);
       tag.setRegionVersion(CCRegion.getVersionVector().getNextVersion());
-      EntryEventImpl holder = EntryEventImpl.createVersionTagHolder(tag);
+      VersionTagHolder holder = new VersionTagHolder(tag);
       ClientProxyMembershipID id = ClientProxyMembershipID.getNewProxyMembership(CCRegion.getDistributionManager().getSystem());
       CCRegion.basicBridgePut("cckey0", "newvalue", null, true, null, id, true, holder, false);
-      holder.release();
       vm0.invoke(new SerializableRunnable("check conflation count") {
         public void run() {
           assertEquals("expected one conflated event", 1, CCRegion.getCachePerfStats().getConflatedEventsCount());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/UpdateVersionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/UpdateVersionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/UpdateVersionJUnitTest.java
index 99d3973..6c53855 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/UpdateVersionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/UpdateVersionJUnitTest.java
@@ -51,8 +51,8 @@ public class UpdateVersionJUnitTest {
 
   private static final String regionName = "versionedregion";
 
-  private EntryEventImpl createNewEvent(LocalRegion region, VersionTag tag, Object key) {
-    EntryEventImpl updateTimeStampEvent = EntryEventImpl.createVersionTagHolder(tag);
+  private VersionTagHolder createNewEvent(LocalRegion region, VersionTag tag, Object key) {
+    VersionTagHolder updateTimeStampEvent = new VersionTagHolder(tag);
     updateTimeStampEvent.setOperation(Operation.UPDATE_VERSION_STAMP);
     updateTimeStampEvent.setRegion(region);
     if (region instanceof PartitionedRegion) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/EventIdOptimizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/EventIdOptimizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/EventIdOptimizationDUnitTest.java
index 3c3f052..8096f7d 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/EventIdOptimizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/EventIdOptimizationDUnitTest.java
@@ -41,6 +41,7 @@ import com.gemstone.gemfire.distributed.DistributedSystem;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
+import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
 import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.LogWriterUtils;
@@ -326,9 +327,9 @@ public class EventIdOptimizationDUnitTest extends DistributedTestCase
     ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);
 
     for (int i = 0; i < eventIds.length; i++) {
-      srp.destroyOnForTestsOnly(connection, "KEY-" + i, null, Operation.DESTROY, new EntryEventImpl(eventIds[i]), null);
+      srp.destroyOnForTestsOnly(connection, "KEY-" + i, null, Operation.DESTROY, new EventIDHolder(eventIds[i]), null);
     }
-    srp.destroyOnForTestsOnly(connection, LAST_KEY, null, Operation.DESTROY, new EntryEventImpl(eventIdForLastKey), null);
+    srp.destroyOnForTestsOnly(connection, LAST_KEY, null, Operation.DESTROY, new EventIDHolder(eventIdForLastKey), null);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
index 38fcdd3..9a7d5a4 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java
@@ -39,6 +39,7 @@ import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
+import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.test.dunit.Assert;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
 import com.gemstone.gemfire.test.dunit.Host;
@@ -270,8 +271,8 @@ public class DestroyEntryPropagationDUnitTest extends DistributedTestCase {
       assertNotNull(conn1);
       assertEquals(PORT2, conn1.getServer().getPort());
       ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR+REGION_NAME, pool);
-      srp.destroyOnForTestsOnly(conn1, "key1", null, Operation.DESTROY, new EntryEventImpl(new EventID(new byte[] {1},100000,1)), null);
-      srp.destroyOnForTestsOnly(conn1, "key2", null, Operation.DESTROY, new EntryEventImpl(new EventID(new byte[] {1},100000,2)), null);
+      srp.destroyOnForTestsOnly(conn1, "key1", null, Operation.DESTROY, new EventIDHolder(new EventID(new byte[] {1},100000,1)), null);
+      srp.destroyOnForTestsOnly(conn1, "key2", null, Operation.DESTROY, new EventIDHolder(new EventID(new byte[] {1},100000,2)), null);
     }
     catch (Exception ex) {
       throw new TestException("Failed while setting acquireConnectionsAndDestroyEntry  ", ex);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/UpdateVersionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/UpdateVersionDUnitTest.java b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/UpdateVersionDUnitTest.java
index cabacbc..18a89f8 100644
--- a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/UpdateVersionDUnitTest.java
+++ b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/UpdateVersionDUnitTest.java
@@ -629,8 +629,8 @@ public class UpdateVersionDUnitTest extends DistributedTestCase {
   }
   
   
-  private EntryEventImpl createNewEvent(LocalRegion region, VersionTag tag, Object key, Object value) {
-    EntryEventImpl updateEvent = EntryEventImpl.createVersionTagHolder(tag);
+  private VersionTagHolder createNewEvent(LocalRegion region, VersionTag tag, Object key, Object value) {
+    VersionTagHolder updateEvent = new VersionTagHolder(tag);
     updateEvent.setOperation(Operation.UPDATE);
     updateEvent.setRegion(region);
     if (region instanceof PartitionedRegion) {


[24/25] incubator-geode git commit: Merge branch 'develop' into feature/GEODE-17-2

Posted by ji...@apache.org.
Merge branch 'develop' into feature/GEODE-17-2

# Conflicts:
#	geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
#	geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
#	geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 183c48ae20647077f461af6cc24541137281e671
Parents: 7ed7916 70c5467
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Fri Apr 22 10:25:38 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Fri Apr 22 10:25:38 2016 -0700

----------------------------------------------------------------------
 LICENSE                                         |   60 +
 extensions/geode-modules-assembly/build.gradle  |    1 +
 geode-assembly/src/main/dist/LICENSE            |    8 +-
 geode-assembly/src/main/dist/NOTICE             |   36 +-
 .../client/internal/ServerRegionProxy.java      |    3 +-
 .../internal/admin/ClientStatsManager.java      |    3 +-
 .../cache/AbstractBucketRegionQueue.java        |    3 +-
 .../internal/cache/AbstractLRURegionMap.java    |    4 +
 .../internal/cache/AbstractRegionEntry.java     |    2 +-
 .../internal/cache/AbstractRegionMap.java       |   15 +-
 .../gemfire/internal/cache/BucketRegion.java    |   14 +-
 .../internal/cache/BucketRegionQueue.java       |    7 +-
 .../internal/cache/DestroyOperation.java        |    6 +-
 .../internal/cache/DistPeerTXStateStub.java     |    2 +
 .../gemfire/internal/cache/DistTXState.java     |    9 +-
 .../cache/DistTXStateOnCoordinator.java         |    2 +
 .../DistTXStateProxyImplOnCoordinator.java      |    2 +
 .../cache/DistributedCacheOperation.java        |    4 +-
 .../cache/DistributedPutAllOperation.java       |   23 +-
 .../internal/cache/DistributedRegion.java       |    9 +-
 .../cache/DistributedRemoveAllOperation.java    |   22 +-
 .../gemfire/internal/cache/EntryEventImpl.java  |   41 +-
 .../gemfire/internal/cache/EntryExpiryTask.java |    9 +-
 .../gemfire/internal/cache/EventIDHolder.java   |   35 +
 .../gemfire/internal/cache/FilterProfile.java   |   13 +-
 .../gemfire/internal/cache/HARegion.java        |    5 +-
 .../internal/cache/InitialImageOperation.java   |    2 +-
 .../internal/cache/InvalidateOperation.java     |    5 +-
 .../gemfire/internal/cache/LocalRegion.java     |  141 +-
 .../internal/cache/PartitionedRegion.java       |   13 +-
 .../gemfire/internal/cache/ProxyRegionMap.java  |    7 +-
 .../gemfire/internal/cache/QueuedOperation.java |    3 +-
 .../internal/cache/RemoteDestroyMessage.java    |    3 +-
 .../internal/cache/RemoteInvalidateMessage.java |    4 +-
 .../internal/cache/RemotePutAllMessage.java     |    5 +-
 .../internal/cache/RemotePutMessage.java        |    4 +-
 .../internal/cache/RemoteRemoveAllMessage.java  |    5 +-
 .../cache/SearchLoadAndWriteProcessor.java      |    6 +-
 .../gemfire/internal/cache/TXCommitMessage.java |    4 +-
 .../gemfire/internal/cache/TXEntryState.java    |    6 +-
 .../gemfire/internal/cache/TXRegionState.java   |    1 +
 .../gemfire/internal/cache/TXRmtEvent.java      |    9 +-
 .../gemfire/internal/cache/TXState.java         |    9 +-
 .../cache/TimestampedEntryEventImpl.java        |    2 +
 .../cache/UpdateEntryVersionOperation.java      |    4 +-
 .../gemfire/internal/cache/UpdateOperation.java |    8 +-
 .../internal/cache/VersionTagHolder.java        |   34 +
 .../cache/partitioned/DestroyMessage.java       |   11 +-
 .../partitioned/FetchBulkEntriesMessage.java    |    4 +-
 .../internal/cache/partitioned/GetMessage.java  |    5 +-
 .../cache/partitioned/InvalidateMessage.java    |    3 +-
 .../PRUpdateEntryVersionMessage.java            |    1 +
 .../cache/partitioned/PutAllPRMessage.java      |   12 +-
 .../internal/cache/partitioned/PutMessage.java  |   11 +-
 .../cache/partitioned/RemoveAllPRMessage.java   |   13 +-
 .../cache/tier/sockets/BaseCommand.java         |   12 +-
 .../cache/tier/sockets/CacheClientUpdater.java  |    3 +-
 .../cache/tier/sockets/command/Destroy.java     |    3 +-
 .../cache/tier/sockets/command/Destroy65.java   |    3 +-
 .../sockets/command/GatewayReceiverCommand.java |   11 +-
 .../cache/tier/sockets/command/Get70.java       |   15 +-
 .../cache/tier/sockets/command/Invalidate.java  |    3 +-
 .../cache/tier/sockets/command/Put.java         |    5 +-
 .../cache/tier/sockets/command/Put61.java       |    5 +-
 .../cache/tier/sockets/command/Put65.java       |    3 +-
 .../internal/cache/tx/DistTxEntryEvent.java     |   13 +-
 .../cache/tx/PartitionedTXRegionStub.java       |   17 +-
 .../cache/wan/AbstractGatewaySender.java        |    5 +-
 .../AbstractGatewaySenderEventProcessor.java    |    2 +
 .../cache/wan/serial/BatchDestroyOperation.java |    5 +-
 ...urrentSerialGatewaySenderEventProcessor.java |    3 +-
 .../wan/serial/SerialGatewaySenderQueue.java    |    2 +-
 .../query/dunit/QueryUsingPoolDUnitTest.java    | 2711 ++++++++----------
 .../DistributedAckRegionCCEDUnitTest.java       |    6 +-
 .../gemfire/distributed/LocatorDUnitTest.java   |  431 ++-
 .../internal/cache/UpdateVersionJUnitTest.java  |    4 +-
 .../cache/ha/EventIdOptimizationDUnitTest.java  |    5 +-
 .../DestroyEntryPropagationDUnitTest.java       |    5 +-
 .../cli/commands/CliCommandTestBase.java        |   32 +-
 .../security/ClientAuthorizationDUnitTest.java  |    6 +-
 .../security/ClientAuthorizationTestCase.java   |   24 +-
 .../DeltaClientPostAuthorizationDUnitTest.java  |    6 +-
 .../security/P2PAuthenticationDUnitTest.java    |    2 -
 .../internal/JUnit4DistributedTestCase.java     |    2 +-
 .../test/dunit/standalone/ProcessManager.java   |    7 +-
 .../cache/RemoteCQTransactionDUnitTest.java     |   17 +-
 .../cli/commands/ClientCommandsDUnitTest.java   | 1730 +++++------
 .../security/ClientAuthzObjectModDUnitTest.java |   36 +-
 .../ClientCQPostAuthorizationDUnitTest.java     |    8 +-
 .../ClientPostAuthorizationDUnitTest.java       |   11 +-
 .../MultiUserDurableCQAuthzDUnitTest.java       |    8 +-
 .../LuceneIndexForPartitionedRegion.java        |   30 +-
 .../internal/LuceneServiceImplJUnitTest.java    |  146 +-
 geode-pulse/src/main/webapp/META-INF/NOTICE     |   18 +-
 .../internal/cache/UpdateVersionDUnitTest.java  |    4 +-
 .../wan/misc/WANConfigurationJUnitTest.java     |   11 +-
 geode-web-api/src/main/webapp/META-INF/NOTICE   |   12 +-
 gradle/utilities.gradle                         |    5 +
 98 files changed, 2825 insertions(+), 3235 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/183c48ae/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
index b60cf6f,acb07ca..1c6b6b1
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
@@@ -16,23 -16,6 +16,21 @@@
   */
  package com.gemstone.gemfire.management.internal.cli.commands;
  
 +import static com.gemstone.gemfire.test.dunit.Assert.*;
 +import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 +
 +import java.io.IOException;
 +import java.io.PrintStream;
 +import java.io.PrintWriter;
 +import java.io.StringWriter;
 +import java.net.InetAddress;
 +import java.net.UnknownHostException;
- import java.util.Arrays;
- import java.util.Collection;
 +import java.util.Map;
 +import java.util.Properties;
 +import java.util.Set;
 +import java.util.regex.Matcher;
 +import java.util.regex.Pattern;
 +
  import com.gemstone.gemfire.cache.Cache;
  import com.gemstone.gemfire.distributed.internal.DistributionConfig;
  import com.gemstone.gemfire.internal.AvailablePortHelper;
@@@ -44,12 -27,21 +42,25 @@@ import com.gemstone.gemfire.management.
  import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
  import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
  import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
 +import com.gemstone.gemfire.management.internal.security.JSONAuthorization;
  import com.gemstone.gemfire.test.dunit.Host;
++import com.gemstone.gemfire.test.dunit.SerializableCallable;
 +import com.gemstone.gemfire.test.dunit.SerializableRunnable;
  import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
 +import org.junit.runners.Parameterized;
  
+ import java.io.IOException;
+ import java.io.PrintStream;
+ import java.net.InetAddress;
+ import java.net.UnknownHostException;
+ import java.util.Map;
+ import java.util.Properties;
+ import java.util.regex.Matcher;
+ import java.util.regex.Pattern;
+ 
+ import static com.gemstone.gemfire.test.dunit.Assert.*;
+ import static com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter;
+ 
  /**
   * Base class for all the CLI/gfsh command dunit tests.
   */
@@@ -142,29 -108,27 +153,23 @@@ public abstract class CliCommandTestBas
        localProps.setProperty(DistributionConfig.JMX_MANAGER_PORT_NAME, String.valueOf(jmxPort));
        localProps.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
  
 +      if(enableAuth){
 +        localProps.put(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME,
-             JSONAuthorization.class.getName() + ".create");
++          JSONAuthorization.class.getName() + ".create");
 +        localProps.put(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME, JSONAuthorization.class.getName() + ".create");
 +
 +        JSONAuthorization.setUpWithJsonFile(jsonAuthorization);
 +      }
 +
        getSystem(localProps);
        verifyManagementServiceStarted(getCache());
  
 -      returnValue[0] = jmxHost;
 -      returnValue[1] = jmxPort;
 -      returnValue[2] = httpPort;
 +      results[0] = jmxHost;
 +      results[1] = jmxPort;
 +      results[2] = httpPort;
  
 -      return returnValue;
 +      return results;
      });
--
--    this.jmxHost = (String) result[0];
--    this.jmxPort = (Integer) result[1];
--    this.httpPort = (Integer) result[2];
 -
 -    return defaultShellConnect();
 -  }
 -
 -  protected boolean useHTTPByTest() {
 -    return false;
--  }
--
    /**
     * Destroy all of the components created for the default setup.
     */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/183c48ae/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/183c48ae/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
index d5d62d2,7a4308f..a41f677
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
@@@ -770,10 -773,12 +772,11 @@@ public abstract class ClientAuthorizati
  
        // Perform the operation from selected client
        if (useThisVM) {
 -        doOp(opCode.toOrdinal(), currentOp.getIndices(), new Integer(opFlags), new Integer(expectedResult));
 +        doOp(opCode, currentOp.getIndices(), new Integer(opFlags), new Integer(expectedResult));
        } else {
 -        byte ordinal = opCode.toOrdinal();
          int[] indices = currentOp.getIndices();
-         clientVM.invoke(() -> ClientAuthorizationTestCase.doOp(opCode, indices, new Integer(opFlags), new Integer(expectedResult) ));
+         clientVM.invoke("ClientAuthorizationTestCase.doOp",
+             () -> ClientAuthorizationTestCase.doOp( new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
        }
      }
    }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/183c48ae/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------


[09/25] incubator-geode git commit: GEODE-1268: Fixed some potential bugs

Posted by ji...@apache.org.
GEODE-1268: Fixed some potential bugs


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 0d0e706a4b83dfad0374910939bd3d8a0c0e12d5
Parents: 9b0026b
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Thu Apr 21 11:56:17 2016 +1000
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Apr 22 04:22:40 2016 +1000

----------------------------------------------------------------------
 .../gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java   | 2 +-
 .../gemfire/security/MultiUserDurableCQAuthzDUnitTest.java         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0d0e706a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
index 4f121f3..c47fd5b 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
@@ -97,7 +97,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
     Properties serverProps = buildProperties(authenticator, extraProps, preAccessor, postAccessor);
 
     // Get ports for the servers
-    int[] portsList = AvailablePortHelper.getRandomAvailableTCPPortsForDUnitSite(2);
+    int[] portsList = AvailablePortHelper.getRandomAvailableTCPPorts(2);
     int port1 = portsList[0];
     int port2 = portsList[1];
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0d0e706a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
index 54cf8c2..1ef4321 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
@@ -193,7 +193,7 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestCas
     }
 
     // Get ports for the servers
-    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(3);
     int port1 = randomAvailableTCPPorts[0];
     int port2 = randomAvailableTCPPorts[1];
     int locatorPort = randomAvailableTCPPorts[2];


[11/25] incubator-geode git commit: GEODE-1227: Replaced all port selections for server with '0' instead of getting the port from the AvailablePortHelper. Some refactoring introducing Lambdas. Some refactoring replacing Wait.wait with Awaitility.

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b5ff9742/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
index bc80563..e551dce 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommandsDUnitTest.java
@@ -16,44 +16,14 @@
  */
 package com.gemstone.gemfire.management.internal.cli.commands;
 
-import static com.gemstone.gemfire.test.dunit.Assert.*;
-import static com.gemstone.gemfire.test.dunit.DistributedTestUtils.*;
-import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
-import static com.gemstone.gemfire.test.dunit.NetworkUtils.*;
-import static com.gemstone.gemfire.test.dunit.Wait.*;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import javax.management.ObjectName;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.cache.AttributesFactory;
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheException;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.DataPolicy;
-import com.gemstone.gemfire.cache.PartitionAttributesFactory;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.Scope;
-import com.gemstone.gemfire.cache.client.ClientCache;
-import com.gemstone.gemfire.cache.client.ClientCacheFactory;
-import com.gemstone.gemfire.cache.client.ClientRegionFactory;
-import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
-import com.gemstone.gemfire.cache.client.PoolManager;
+import com.gemstone.gemfire.cache.*;
+import com.gemstone.gemfire.cache.client.*;
 import com.gemstone.gemfire.cache.client.internal.PoolImpl;
 import com.gemstone.gemfire.cache.query.CqAttributesFactory;
 import com.gemstone.gemfire.cache.query.QueryService;
 import com.gemstone.gemfire.cache.server.CacheServer;
-import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
 import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.OSProcess;
 import com.gemstone.gemfire.internal.cache.DistributedRegion;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
@@ -73,14 +43,30 @@ import com.gemstone.gemfire.management.internal.cli.result.CompositeResultData.S
 import com.gemstone.gemfire.management.internal.cli.result.TabularResultData;
 import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.SerializableCallable;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.WaitCriterion;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import com.jayway.awaitility.Awaitility;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import javax.management.ObjectName;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.DistributedTestUtils.getDUnitLocatorPort;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter;
+import static com.gemstone.gemfire.test.dunit.NetworkUtils.getServerHostName;
 
 /**
- * Dunit class for testing gemfire Client commands : list client , describe client 
+ * Dunit class for testing gemfire Client commands : list client , describe client
+ *
  * @since 8.0
  */
 @Category(DistributedTest.class)
@@ -91,508 +77,370 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
   final String cq1 = "cq1";
   final String cq2 = "cq2";
   final String cq3 = "cq3";
-  final String clientName = "dc1";
   String clientId = "";
   int port0 = 0;
-  int port1= 0;
-  
-  public void waitForListClientMbean(){
-    
+  int port1 = 0;
+
+  public void waitForListClientMbean() {
+
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);
-    
-    final DistributedMember serverMember = getMember(server1);
-    
-    assertNotNull(serverMember);   
-    
-    manager.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        final WaitCriterion waitForMaangerMBean = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
-            if (service == null) {
-              getLogWriter().info("waitForListClientMbean Still probing for service");
-              return false;
-            } else {      
-              final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);                            
-              CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);              
-              try {
-                if(bean != null){                  
-                  if( bean.getClientIds().length > 1){
-                    return true;
-                  }
-                }
-                return false; 
-                
-              } catch (Exception e) {
-                LogWrapper.getInstance().warning("waitForListClientMbean Exception in waitForListClientMbean ::: " + CliUtil.stackTraceAsString(e));
-              }
-              return false;
-            }
-          }
 
-          @Override
-          public String description() {
-            return "waitForListClientMbean Probing ...";
-          }
-        };
-        waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
-      }
-    }); 
-    
-  }
+    final DistributedMember serverMember = getMember(server1);
 
+    assertNotNull(serverMember);
 
-public void waitForListClientMbean2(){
-  
-  final VM manager = Host.getHost(0).getVM(0);
-  final VM server1 = Host.getHost(0).getVM(1);
-  
-  final DistributedMember serverMember = getMember(server1);
-  
-  assertNotNull(serverMember);   
-  
-  manager.invoke(new SerializableRunnable() {
-    @Override
-    public void run() {
-      final WaitCriterion waitForMaangerMBean = new WaitCriterion() {
-        @Override
-        public boolean done() {
-          final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
-          if (service == null) {
-            getLogWriter().info("waitForListClientMbean2 Still probing for service");
-            return false;
-          } else {      
-            final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);                            
-            CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);              
-            try {
-              if(bean != null){                
-                if( bean.getClientIds().length > 0){
-                  return true;
-                }
+    manager.invoke(() -> {
+      Awaitility.waitAtMost(2 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
+        final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
+        if (service == null) {
+          getLogWriter().info("waitForListClientMbean Still probing for service");
+          return false;
+        } else {
+          final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
+          CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+          try {
+            if (bean != null) {
+              if (bean.getClientIds().length > 1) {
+                return true;
               }
-              return false; 
-              
-            } catch (Exception e) {
-              LogWrapper.getInstance().warning("waitForListClientMbean2 Exception in waitForListClientMbean ::: " + CliUtil.stackTraceAsString(e));
             }
             return false;
+
+          } catch (Exception e) {
+            LogWrapper.getInstance().warning("waitForListClientMbean Exception in waitForListClientMbean ::: " + CliUtil.stackTraceAsString(e));
           }
+          return false;
         }
+      });
+    });
+  }
+
+  public void waitForMbean() {
 
-        @Override
-        public String description() {
-          return "waitForListClientMbean2 Probing ...";
-        }
-      };
-      waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
-    }
-  }); 
-  
-}
-  
-  public void waitForMbean(){
-    
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);
-    
-    
-    
+
     final DistributedMember serverMember = getMember(server1);
-    
-    assertNotNull(serverMember);   
-    
-    manager.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        final WaitCriterion waitForMaangerMBean = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
-            if (service == null) {
-              getLogWriter().info("waitForMbean Still probing for service");
-              return false;
-            } else {      
-              final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);                            
-              CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);              
-              try {              
-                ClientHealthStatus stats = bean.showClientStats(bean.getClientIds()[0]);
-                Map<String,String> poolStats = stats.getPoolStats();
-                if(poolStats.size() > 0){       
-                  Iterator<Entry<String, String>> it = poolStats.entrySet().iterator();
-                  while(it.hasNext()){
-                    Entry<String, String> entry = it.next();
-                    String poolStatsStr = entry.getValue();
-                    String str[] = poolStatsStr.split(";");                   
-                    int numCqs = Integer.parseInt(str[3].substring(str[3].indexOf("=")+1 ));
-                    if(numCqs == 3){
-                      return true;
-                    }
-                  }
+
+    assertNotNull(serverMember);
+
+    manager.invoke(() -> {
+      Awaitility.waitAtMost(2 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
+        final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
+        if (service == null) {
+          getLogWriter().info("waitForMbean Still probing for service");
+          return false;
+        } else {
+          final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
+          CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+          try {
+            ClientHealthStatus stats = bean.showClientStats(bean.getClientIds()[0]);
+            Map<String, String> poolStats = stats.getPoolStats();
+            if (poolStats.size() > 0) {
+              Iterator<Entry<String, String>> it = poolStats.entrySet().iterator();
+              while (it.hasNext()) {
+                Entry<String, String> entry = it.next();
+                String poolStatsStr = entry.getValue();
+                String str[] = poolStatsStr.split(";");
+                int numCqs = Integer.parseInt(str[3].substring(str[3].indexOf("=") + 1));
+                if (numCqs == 3) {
+                  return true;
                 }
-                return false;
-                
-              } catch (Exception e) {
-                LogWrapper.getInstance().warning("waitForMbean Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
               }
-              return false;
-              
             }
-          }
+            return false;
 
-          @Override
-          public String description() {
-            return "waitForMbean Probing for ";
+          } catch (Exception e) {
+            LogWrapper.getInstance().warning("waitForMbean Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
           }
-        };
-        waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
-      }
-    }); 
-    
+          return false;
+
+        }
+      });
+    });
   }
-  
-  public void waitForListClientMbean3(){
-    
+
+  public void waitForListClientMbean3() {
+
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);
     final VM server2 = Host.getHost(0).getVM(3);
-    
+
     final DistributedMember serverMember1 = getMember(server1);
     final DistributedMember serverMember2 = getMember(server2);
-    
-    assertNotNull(serverMember1);   
-    
-    manager.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        final WaitCriterion waitForMaangerMBean = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
-            if (service == null) {
-              getLogWriter().info("waitForListClientMbean3 Still probing for service");
-              return false;
-            } else {      
-              final ObjectName cacheServerMBeanName1 = service.getCacheServerMBeanName(port0,serverMember1);                            
-              final ObjectName cacheServerMBeanName2 = service.getCacheServerMBeanName(port1,serverMember2);
-              CacheServerMXBean bean1 = service.getMBeanProxy(cacheServerMBeanName1, CacheServerMXBean.class);
-              CacheServerMXBean bean2 = service.getMBeanProxy(cacheServerMBeanName2, CacheServerMXBean.class);
-              try {
-                if(bean1 != null && bean2 != null){                
-                  if( bean1.getClientIds().length > 0 && bean2.getClientIds().length > 0){
-                    return true;
-                  }
-                }
-                return false; 
-                
-              } catch (Exception e) {
-                LogWrapper.getInstance().warning("waitForListClientMbean3 Exception in waitForListClientMbean ::: " + CliUtil.stackTraceAsString(e));
+
+    assertNotNull(serverMember1);
+
+    manager.invoke(() -> {
+      Awaitility.waitAtMost(2 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
+        final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
+        if (service == null) {
+          getLogWriter().info("waitForListClientMbean3 Still probing for service");
+          return false;
+        } else {
+          final ObjectName cacheServerMBeanName1 = service.getCacheServerMBeanName(port0, serverMember1);
+          final ObjectName cacheServerMBeanName2 = service.getCacheServerMBeanName(port1, serverMember2);
+          CacheServerMXBean bean1 = service.getMBeanProxy(cacheServerMBeanName1, CacheServerMXBean.class);
+          CacheServerMXBean bean2 = service.getMBeanProxy(cacheServerMBeanName2, CacheServerMXBean.class);
+          try {
+            if (bean1 != null && bean2 != null) {
+              if (bean1.getClientIds().length > 0 && bean2.getClientIds().length > 0) {
+                return true;
               }
-              return false;
             }
-          }
+            return false;
 
-          @Override
-          public String description() {
-            return "waitForListClientMbean3 Probing ...";
+          } catch (Exception e) {
+            LogWrapper.getInstance().warning("waitForListClientMbean3 Exception in waitForListClientMbean ::: " + CliUtil.stackTraceAsString(e));
           }
-        };
-        waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
-      }
-    }); 
-    
+          return false;
+        }
+      });
+    });
   }
 
   @Ignore("disabled for unknown reason")
   @Test
   public void testDescribeClientWithServers3() throws Exception {
-    setupSystem3();    
-    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId + "\"" ;
+    setupSystem3();
+    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId + "\"";
     final VM server1 = Host.getHost(0).getVM(1);
     final VM server2 = Host.getHost(0).getVM(3);
     final VM manager = Host.getHost(0).getVM(0);
-    String serverName1 = (String) server1.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
-          
-      }
-    });
-    
-    String serverName2 = (String) server2.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
-          
-      }
-    });
-    
+    String serverName1 = (String) server1.invoke("get DistributedMemberID ", () ->
+        getDistributedMemberId());
+
+    String serverName2 = (String) server2.invoke("get DistributedMemberID ", () ->
+        getDistributedMemberId());
+
     final DistributedMember serverMember1 = getMember(server1);
-    
-    String[] clientIds = (String[]) manager.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
-      
-          final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember1);                            
-          CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);              
-          
-          return bean.getClientIds();
-          
-      }
+
+    String[] clientIds = (String[]) manager.invoke("get Client Ids", () -> {
+      final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
+
+      final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember1);
+      CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+
+      return bean.getClientIds();
     });
-     
+
     String clientId1 = "";
-    
-    for(String str : clientIds){
+
+    for (String str : clientIds) {
       clientId1 = str;
-      getLogWriter().info("testDescribeClientWithServers clientIds for server1 ="+str);
+      getLogWriter().info("testDescribeClientWithServers clientIds for server1 =" + str);
     }
-    
+
     final DistributedMember serverMember2 = getMember(server2);
-    
-    
-    String[] clientIds2 = (String[]) manager.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
-      
-          final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port1,serverMember2);                            
-          CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);              
-          
-          return bean.getClientIds();
-          
-      }
+
+    String[] clientIds2 = (String[]) manager.invoke("get Client Ids", () -> {
+      final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
+
+      final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port1, serverMember2);
+      CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+
+      return bean.getClientIds();
     });
-    
+
     String clientId2 = "";
-    
-    for(String str : clientIds2){
+
+    for (String str : clientIds2) {
       clientId2 = str;
-      getLogWriter().info("testDescribeClientWithServers clientIds for server2 ="+str);
+      getLogWriter().info("testDescribeClientWithServers clientIds for server2 =" + str);
     }
-    
-    
-    commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId1 + "\"" ;
-    
-    getLogWriter().info("testDescribeClientWithServers commandStr clientId1 ="+commandString);    
-    
-    
+
+    commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId1 + "\"";
+
+    getLogWriter().info("testDescribeClientWithServers commandStr clientId1 =" + commandString);
+
     CommandResult commandResultForClient1 = executeCommand(commandString);
-    getLogWriter().info("testDescribeClientWithServers commandStr clientId1="+commandResultForClient1);    
-    
-    
+    getLogWriter().info("testDescribeClientWithServers commandStr clientId1=" + commandResultForClient1);
+
     String resultAsString = commandResultToString(commandResultForClient1);
-    getLogWriter().info("testDescribeClientWithServers commandStr clientId1 ="+resultAsString);   
+    getLogWriter().info("testDescribeClientWithServers commandStr clientId1 =" + resultAsString);
     assertTrue(Status.OK.equals(commandResultForClient1.getStatus()));
-    
+
     verifyClientStats(commandResultForClient1, serverName1);
-    
-    
-    
-    commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId2 + "\"" ;
-    
-    getLogWriter().info("testDescribeClientWithServers commandStr1="+commandString);    
-    
-    
+
+    commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId2 + "\"";
+
+    getLogWriter().info("testDescribeClientWithServers commandStr1=" + commandString);
+
     CommandResult commandResultForClient2 = executeCommand(commandString);
-    getLogWriter().info("testDescribeClientWithServers commandResult1="+commandResultForClient2);    
-    
-    
+    getLogWriter().info("testDescribeClientWithServers commandResult1=" + commandResultForClient2);
+
     resultAsString = commandResultToString(commandResultForClient2);
-    getLogWriter().info("testDescribeClientWithServers resultAsString1="+resultAsString);   
+    getLogWriter().info("testDescribeClientWithServers resultAsString1=" + resultAsString);
     assertTrue(Status.OK.equals(commandResultForClient2.getStatus()));
-    
+
     verifyClientStats(commandResultForClient2, serverName2);
-    
-    
+
     closeNonDurableClient(Host.getHost(0).getVM(2));
     closeCacheServer(Host.getHost(0).getVM(3));
     closeCacheServer(Host.getHost(0).getVM(1));
-  
+
+  }
+
+  public void verifyClientStats(CommandResult commandResultForClient, String serverName) {
+    CompositeResultData resultData = (CompositeResultData) commandResultForClient.getResultData();
+    SectionResultData section = resultData.retrieveSection("InfoSection");
+    assertNotNull(section);
+    for (int i = 0; i < 1; i++) {
+      TabularResultData tableRsultData = section.retrieveTableByIndex(i);
+      getLogWriter().info("testDescribeClientWithServers getHeader=" + tableRsultData.getHeader());
+      assertNotNull(tableRsultData);
+
+      List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
+      List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
+      List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
+      List<String> numCqs = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
+
+      getLogWriter().info("testDescribeClientWithServers getHeader numCqs =" + numCqs);
+
+      assertTrue(minConn.contains("1"));
+      assertTrue(maxConn.contains("-1"));
+      assertTrue(redudancy.contains("1"));
+      assertTrue(numCqs.contains("3"));
+      String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
+      assertTrue(puts.equals("2"));
+      String queue = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_QUEUE_SIZE);
+      assertTrue(queue.equals("1"));
+      String calls = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_LISTNER_CALLS);
+      assertTrue(calls.equals("1"));
+      String primServer = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PRIMARY_SERVERS);
+      assertTrue(primServer.equals(serverName));
+      String durable = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_DURABLE);
+      assertTrue(durable.equals("No"));
+      String threads = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_THREADS);
+      assertTrue(Integer.parseInt(threads) > 0);
+      String cpu = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_CPU);
+      assertTrue(Integer.parseInt(cpu) > 0);
+      String upTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_UP_TIME);
+      assertTrue(Integer.parseInt(upTime) >= 0);
+      String prcTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PROCESS_CPU_TIME);
+      assertTrue(Long.parseLong(prcTime) > 0);
+
+    }
   }
- 
- public void verifyClientStats(CommandResult commandResultForClient, String serverName){
-   CompositeResultData resultData = (CompositeResultData) commandResultForClient.getResultData();
-   SectionResultData section =resultData.retrieveSection("InfoSection");
-   assertNotNull(section);    
-   for(int i = 0 ; i < 1 ; i++){
-     TabularResultData tableRsultData = section.retrieveTableByIndex(i);
-     getLogWriter().info("testDescribeClientWithServers getHeader="+tableRsultData.getHeader());
-     assertNotNull(tableRsultData);
-     
-     List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
-     List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
-     List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
-     List<String> numCqs = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
-     
-     
-     getLogWriter().info("testDescribeClientWithServers getHeader numCqs ="+ numCqs);
-     
-     assertTrue(minConn.contains("1"));
-     assertTrue(maxConn.contains("-1"));
-     assertTrue(redudancy.contains("1"));
-     assertTrue(numCqs.contains("3"));   
-     String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
-     assertTrue(puts.equals("2"));    
-     String queue = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_QUEUE_SIZE);
-     assertTrue(queue.equals("1"));    
-     String calls = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_LISTNER_CALLS);
-     assertTrue(calls.equals("1"));
-     String primServer = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PRIMARY_SERVERS);
-     assertTrue(primServer.equals(serverName));
-     String durable = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_DURABLE);
-     assertTrue(durable.equals("No"));   
-     String threads = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_THREADS);
-     assertTrue(Integer.parseInt(threads) > 0);
-     String cpu = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_CPU);
-     assertTrue(Integer.parseInt(cpu) > 0);   
-     String upTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_UP_TIME);
-     assertTrue(Integer.parseInt(upTime) >= 0);   
-     String prcTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PROCESS_CPU_TIME);
-     assertTrue(Long.parseLong(prcTime) > 0); 
-     
-   }
- }
 
   @Ignore("disabled for unknown reason")
   @Test
   public void testDescribeClient() throws Exception {
     setupSystem();
-    
-    getLogWriter().info("testDescribeClient clientId="+clientId);    
+
+    getLogWriter().info("testDescribeClient clientId=" + clientId);
     assertNotNull(clientId);
-    
-    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId + "\"" ;
-    getLogWriter().info("testDescribeClient commandStr="+commandString);
-    
+
+    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId + "\"";
+    getLogWriter().info("testDescribeClient commandStr=" + commandString);
+
     final VM server1 = Host.getHost(0).getVM(1);
-    String serverName = (String) server1.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
-          
-      }
-    });
-    
-    
-    
+    String serverName = (String) server1.invoke("get distributed member Id", () -> getDistributedMemberId());
+
     CommandResult commandResult = executeCommand(commandString);
-    getLogWriter().info("testDescribeClient commandResult="+commandResult);    
-    
-    
+    getLogWriter().info("testDescribeClient commandResult=" + commandResult);
+
     String resultAsString = commandResultToString(commandResult);
-    getLogWriter().info("testDescribeClient resultAsString="+resultAsString);   
+    getLogWriter().info("testDescribeClient resultAsString=" + resultAsString);
     assertTrue(Status.OK.equals(commandResult.getStatus()));
-    
+
     CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
-    SectionResultData section =resultData.retrieveSection("InfoSection");
-    assertNotNull(section);    
+    SectionResultData section = resultData.retrieveSection("InfoSection");
+    assertNotNull(section);
     TabularResultData tableRsultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
     assertNotNull(tableRsultData);
-    
+
     List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
     List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
     List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
     List<String> numCqs = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
-    
+
     assertTrue(minConn.contains("1"));
     assertTrue(maxConn.contains("-1"));
     assertTrue(redudancy.contains("1"));
-    assertTrue(numCqs.contains("3"));   
+    assertTrue(numCqs.contains("3"));
     String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
-    assertTrue(puts.equals("2"));    
+    assertTrue(puts.equals("2"));
     String queue = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_QUEUE_SIZE);
-    assertTrue(queue.equals("1"));    
+    assertTrue(queue.equals("1"));
     String calls = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_LISTNER_CALLS);
     assertTrue(calls.equals("1"));
     String primServer = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PRIMARY_SERVERS);
     assertTrue(primServer.equals(serverName));
     String durable = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_DURABLE);
-    assertTrue(durable.equals("No"));   
+    assertTrue(durable.equals("No"));
     String threads = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_THREADS);
     assertTrue(Integer.parseInt(threads) > 0);
     String cpu = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_CPU);
-    assertTrue(Integer.parseInt(cpu) > 0);   
+    assertTrue(Integer.parseInt(cpu) > 0);
     String upTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_UP_TIME);
-    assertTrue(Integer.parseInt(upTime) >= 0);   
+    assertTrue(Integer.parseInt(upTime) >= 0);
     String prcTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PROCESS_CPU_TIME);
     assertTrue(Long.parseLong(prcTime) > 0);
-    
-    
+
     closeNonDurableClient(Host.getHost(0).getVM(2));
     closeCacheServer(Host.getHost(0).getVM(1));
     closeCacheServer(Host.getHost(0).getVM(3));
-    
-    
+
   }
 
   @Test
   public void testDescribeClientWithServers() throws Exception {
     setupSystem2();
-    
-    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId + "\"" ;
-    getLogWriter().info("testDescribeClientWithServers commandStr="+commandString);    
-    
-    
+
+    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId + "\"";
+    getLogWriter().info("testDescribeClientWithServers commandStr=" + commandString);
+
     final VM server1 = Host.getHost(0).getVM(1);
-    String serverName = (String) server1.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
-          
-      }
-    });
-    
-    
+    String serverName = (String) server1.invoke("get Distributed Member Id", () ->
+        getDistributedMemberId());
+
     CommandResult commandResult = executeCommand(commandString);
-    getLogWriter().info("testDescribeClientWithServers commandResult="+commandResult);    
-    
-    
+    getLogWriter().info("testDescribeClientWithServers commandResult=" + commandResult);
+
     String resultAsString = commandResultToString(commandResult);
-    getLogWriter().info("testDescribeClientWithServers resultAsString="+resultAsString);   
+    getLogWriter().info("testDescribeClientWithServers resultAsString=" + resultAsString);
     assertTrue(Status.OK.equals(commandResult.getStatus()));
-    
+
     CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
-    SectionResultData section =resultData.retrieveSection("InfoSection");
-    assertNotNull(section);    
+    SectionResultData section = resultData.retrieveSection("InfoSection");
+    assertNotNull(section);
     TabularResultData tableRsultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
     assertNotNull(tableRsultData);
-    
+
     List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
     List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
     List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
     List<String> numCqs = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
-    
+
     assertTrue(minConn.contains("1"));
     assertTrue(maxConn.contains("-1"));
     assertTrue(redudancy.contains("1"));
-    assertTrue(numCqs.contains("3"));   
+    assertTrue(numCqs.contains("3"));
     String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
-    assertTrue(puts.equals("2"));    
+    assertTrue(puts.equals("2"));
     String queue = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_QUEUE_SIZE);
-    assertTrue(queue.equals("1"));    
+    assertTrue(queue.equals("1"));
     String calls = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_LISTNER_CALLS);
     assertTrue(calls.equals("1"));
     String primServer = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PRIMARY_SERVERS);
     assertTrue(primServer.equals(serverName));
     String durable = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_DURABLE);
-    assertTrue(durable.equals("No"));   
+    assertTrue(durable.equals("No"));
     String threads = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_THREADS);
     assertTrue(Integer.parseInt(threads) > 0);
     String cpu = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_CPU);
-    assertTrue(Integer.parseInt(cpu) > 0);   
+    assertTrue(Integer.parseInt(cpu) > 0);
     String upTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_UP_TIME);
-    assertTrue(Integer.parseInt(upTime) >= 0);   
+    assertTrue(Integer.parseInt(upTime) >= 0);
     String prcTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PROCESS_CPU_TIME);
     assertTrue(Long.parseLong(prcTime) > 0);
-    
+
     closeNonDurableClient(Host.getHost(0).getVM(2));
     closeNonDurableClient(Host.getHost(0).getVM(3));
     closeCacheServer(Host.getHost(0).getVM(1));
-  
+
   }
 
   @Category(FlakyTest.class) // GEODE-908: random ports, BindException, time sensitive, HeadlessGfsh
@@ -600,845 +448,666 @@ public void waitForListClientMbean2(){
   public void testListClient() throws Exception {
     setupSystemForListClient();
 
-    
-    final VM manager = Host.getHost(0).getVM(0);   
-    
-    String commandString = CliStrings.LIST_CLIENTS ;
-    getLogWriter().info("testListClient commandStr="+commandString);
-    
-    waitForListClientMbean();  
-    
+    final VM manager = Host.getHost(0).getVM(0);
+
+    String commandString = CliStrings.LIST_CLIENTS;
+    getLogWriter().info("testListClient commandStr=" + commandString);
+
+    waitForListClientMbean();
+
     final VM server1 = Host.getHost(0).getVM(1);
-    
+
     final DistributedMember serverMember = getMember(server1);
-    
-    String[] clientIds = (String[]) manager.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
-      
-          final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);                            
-          CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);              
-          
-          return bean.getClientIds();
-          
-      }
-    });
-    
-    String serverName = (String) server1.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
-          
-      }
+
+    String[] clientIds = (String[]) manager.invoke("get client Ids", () -> {
+      final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
+      final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
+      CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+      return bean.getClientIds();
     });
-    
+
+    String serverName = (String) server1.invoke("get distributed member Id", () ->
+        getDistributedMemberId());
+
     CommandResult commandResult = executeCommand(commandString);
-    getLogWriter().info("testListClient commandResult="+commandResult);    
-    
-    
+    getLogWriter().info("testListClient commandResult=" + commandResult);
+
     String resultAsString = commandResultToString(commandResult);
-    getLogWriter().info("testListClient resultAsString="+resultAsString);   
+    getLogWriter().info("testListClient resultAsString=" + resultAsString);
     assertTrue(Status.OK.equals(commandResult.getStatus()));
-    
-    
+
     CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
-    SectionResultData section =resultData.retrieveSection("section1");
-    assertNotNull(section);    
+    SectionResultData section = resultData.retrieveSection("section1");
+    assertNotNull(section);
     TabularResultData tableRsultData = section.retrieveTable("TableForClientList");
     assertNotNull(tableRsultData);
-    
+
     List<String> serverNames = tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_SERVERS);
     List<String> clientNames = tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_Clients);
-    
-    
-    getLogWriter().info("testListClients serverNames : " + serverNames);    
-    getLogWriter().info("testListClients clientNames : " + clientNames);  
+
+    getLogWriter().info("testListClients serverNames : " + serverNames);
+    getLogWriter().info("testListClients clientNames : " + clientNames);
     assertEquals(2, serverNames.size());
-    assertEquals(2, clientNames.size());    
+    assertEquals(2, clientNames.size());
     assertTrue(clientNames.contains(clientIds[0]));
     assertTrue(clientNames.contains(clientIds[1]));
     serverName = serverName.replace(":", "-");
     getLogWriter().info("testListClients serverName : " + serverName);
-    for(String str : serverNames){
+    for (String str : serverNames) {
       assertTrue(str.contains(serverName));
-    }    
+    }
     closeNonDurableClient(Host.getHost(0).getVM(2));
     closeCacheServer(Host.getHost(0).getVM(1));
     closeCacheServer(Host.getHost(0).getVM(3));
-    
-    
+
   }
 
   @Test
   public void testListClientForServers() throws Exception {
     setupSystem3();
 
-    
-    final VM manager = Host.getHost(0).getVM(0);   
-    
-    String commandString = CliStrings.LIST_CLIENTS ;
-    getLogWriter().info("testListClientForServers commandStr="+commandString);
-    
-    
-    
+    final VM manager = Host.getHost(0).getVM(0);
+
+    String commandString = CliStrings.LIST_CLIENTS;
+    System.out.println("testListClientForServers commandStr=" + commandString);
+
     final VM server1 = Host.getHost(0).getVM(1);
     final VM server2 = Host.getHost(0).getVM(3);
-    
+
     final DistributedMember serverMember = getMember(server1);
-    
-    String[] clientIds = (String[]) manager.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
-      
-          final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);                            
-          CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);      
-          return bean.getClientIds();
-          
-      }
-    });
-    
 
-    
-    String serverName1 = (String) server1.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
-          
-      }
-    });
-    
-    String serverName2 = (String) server2.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
-          
-      }
+    String[] clientIds = (String[]) manager.invoke("get client Ids", () -> {
+      final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
+      final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
+      CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+      return bean.getClientIds();
     });
-    
+
+    String serverName1 = (String) server1.invoke("get distributed member Id", () ->
+        getDistributedMemberId());
+
+    String serverName2 = (String) server2.invoke("get distributed member Id", () ->
+        getDistributedMemberId());
+
     CommandResult commandResult = executeCommand(commandString);
-    getLogWriter().info("testListClientForServers commandResult="+commandResult);    
-    
-    
+    System.out.println("testListClientForServers commandResult=" + commandResult);
+
     String resultAsString = commandResultToString(commandResult);
-    getLogWriter().info("testListClientForServers resultAsString="+resultAsString);   
+    System.out.println("testListClientForServers resultAsString=" + resultAsString);
     assertTrue(Status.OK.equals(commandResult.getStatus()));
-    
-    
+
     CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
-    SectionResultData section =resultData.retrieveSection("section1");
-    assertNotNull(section);       
+    SectionResultData section = resultData.retrieveSection("section1");
+    assertNotNull(section);
     TabularResultData tableRsultData = section.retrieveTable("TableForClientList");
-    assertNotNull(tableRsultData);   
-    
+    assertNotNull(tableRsultData);
+
     List<String> serverNames = tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_SERVERS);
     List<String> clientNames = tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_Clients);
-    
+
     serverName1 = serverName1.replace(":", "-");
     serverName2 = serverName2.replace(":", "-");
-    
-    
-    getLogWriter().info("testListClientForServers serverNames : " + serverNames);
-    getLogWriter().info("testListClientForServers serverName1 : " + serverName1);
-    getLogWriter().info("testListClientForServers serverName2 : " + serverName2);
-    getLogWriter().info("testListClientForServers clientNames : " + clientNames);
-    
-    for(String client : clientIds){
+
+    System.out.println("testListClientForServers serverNames : " + serverNames);
+    System.out.println("testListClientForServers serverName1 : " + serverName1);
+    System.out.println("testListClientForServers serverName2 : " + serverName2);
+    System.out.println("testListClientForServers clientNames : " + clientNames);
+
+    for (String client : clientIds) {
       assertTrue(clientNames.contains(client));
     }
-    
-    for(String server : serverNames){
+
+    for (String server : serverNames) {
       assertTrue(server.contains(serverName1) || server.contains(serverName2));
     }
-    
+
     closeNonDurableClient(Host.getHost(0).getVM(2));
     closeCacheServer(Host.getHost(0).getVM(1));
     closeCacheServer(Host.getHost(0).getVM(3));
-    
-    
-  } 
 
-  
-  public DistributedMember getMember(final VM vm) {
-    SerializableCallable getMember = new SerializableCallable("Get Member") {
-      public Object call() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        return cache.getDistributedSystem().getDistributedMember();
+  }
 
-      }
-    };
-    return (DistributedMember) vm.invoke(getMember);
+  private String getDistributedMemberId() {
+    return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
   }
-  
+
+  public DistributedMember getMember(final VM vm) {
+    return (DistributedMember) vm.invoke("Get Member", () -> GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember());
+  }
+
   private void setupSystemForListClient() throws Exception {
     disconnectAllFromDS();
-    final int[] port = AvailablePortHelper.getRandomAvailableTCPPorts(3);
     createDefaultSetup(getServerProperties());
-    
+
     final VM server1 = Host.getHost(0).getVM(1);
     final VM client1 = Host.getHost(0).getVM(2);
     final VM client2 = Host.getHost(0).getVM(3);
-    
-    startCacheServer(server1, port[0], false, regionName);
-    port0 = port[0];   
-    startNonDurableClient(client1, server1, port[0]);   
-    startNonDurableClient(client2, server1, port[0]);    
-     
-    
+
+    port0 = startCacheServer(server1, 0, false, regionName);
+    startNonDurableClient(client1, server1, port0);
+    startNonDurableClient(client2, server1, port0);
   }
-  
-  
-  
+
   private void setupSystem() throws Exception {
     disconnectAllFromDS();
-    final int[] port = AvailablePortHelper.getRandomAvailableTCPPorts(2);
     createDefaultSetup(getServerProperties());
-    
+
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);
     final VM client1 = Host.getHost(0).getVM(2);
     final VM server2 = Host.getHost(0).getVM(3);
-    
-    port0 = port[0];
-    
-    startCacheServer(server1, port[0], false, regionName);
-    startCacheServer(server2, port[1], false, regionName);    
-    
-    startNonDurableClient(client1, server1, port[0]);
+
+    port0 = startCacheServer(server1, 0, false, regionName);
+    startCacheServer(server2, 0, false, regionName);
+
+    startNonDurableClient(client1, server1, port0);
     setupCqsOnVM(client1);
     waitForMbean();
-    
-    
-    
-    clientId =  (String) manager.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        Cache cache = GemFireCacheImpl.getInstance();       
-        SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
-        DistributedMember serverMember = getMember(server1);
-        final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port[0],serverMember);
-        CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
-        return bean.getClientIds()[0]; 
-      }
+
+    clientId = (String) manager.invoke("get client Id", () -> {
+      Cache cache = GemFireCacheImpl.getInstance();
+      SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
+      DistributedMember serverMember = getMember(server1);
+      final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
+      CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+      return bean.getClientIds()[0];
     });
   }
-  
-  
+
   private void setupSystem2() throws Exception {
     disconnectAllFromDS();
-    final int[] port = AvailablePortHelper.getRandomAvailableTCPPorts(3);
     createDefaultSetup(getServerProperties());
-    
+
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);
     final VM client1 = Host.getHost(0).getVM(2);
     final VM client2 = Host.getHost(0).getVM(3);
-    
-    startCacheServer(server1, port[0], false, regionName);    
-    port0 = port[0];
-    startNonDurableClient(client1, server1, port[0]);
-    startNonDurableClient(client2, server1, port[0]);    
-    
+
+    port0 = startCacheServer(server1, 0, false, regionName);
+    startNonDurableClient(client1, server1, port0);
+    startNonDurableClient(client2, server1, port0);
+
     setupCqsOnVM(client1);
     setupCqsOnVM(client2);
-    
+
     waitForMbean();
-    
-    clientId =  (String) manager.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        Cache cache = GemFireCacheImpl.getInstance();       
-        SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
-        DistributedMember serverMember = getMember(server1);
-        final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port[0],serverMember);     
-        CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
-        return bean.getClientIds()[0]; 
-      }
+
+    clientId = (String) manager.invoke("get client Id", () -> {
+      Cache cache = GemFireCacheImpl.getInstance();
+      SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
+      DistributedMember serverMember = getMember(server1);
+      final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
+      CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+      return bean.getClientIds()[0];
     });
-    
-    
   }
-   private void setupSystem3() throws Exception {
+
+  private void setupSystem3() throws Exception {
     disconnectAllFromDS();
-    final int[] port = AvailablePortHelper.getRandomAvailableTCPPorts(3);
     createDefaultSetup(getServerProperties());
-    
+
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);
     final VM client1 = Host.getHost(0).getVM(2);
     final VM server2 = Host.getHost(0).getVM(3);
-    
-    port0 = port[0];
-    port1 = port[1];
-    
-    String cacheserverport1 = (String) startCacheServer(server1, port[0], false, regionName);   
-    String cacheserverport2 = (String) startCacheServer(server2, port[1], false, regionName);
-    startNonDurableClient(client1, server1, Integer.parseInt(cacheserverport1));
-    startNonDurableClient(client1, server2, Integer.parseInt(cacheserverport2));
-    
+
+    port0 = startCacheServer(server1, 0, false, regionName);
+    port1 = startCacheServer(server2, 0, false, regionName);
+    startNonDurableClient(client1, server1, port0);
+    startNonDurableClient(client1, server2, port1);
+
     setupCqsOnVM(client1);
-    
     waitForListClientMbean3();
-    
-    
-    clientId =  (String) manager.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        Cache cache = GemFireCacheImpl.getInstance();       
-        SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
-        DistributedMember serverMember = getMember(server1);
-        final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port[0],serverMember);
-        CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
-        return bean.getClientIds()[0]; 
-      }
-    });
-    
-    
-  }
 
-  
-  private void setupCqs() {
-    final VM vm2 = Host.getHost(0).getVM(2);
-    vm2.invoke(new SerializableCallable() {
-      public Object call() {        
-        Cache cache = GemFireCacheImpl.getInstance();
-        QueryService qs = cache.getQueryService();
-        CqAttributesFactory cqAf = new CqAttributesFactory();
-        try {
-          qs.newCq(cq1, "select * from /" + regionName, cqAf.create(), true).execute();
-          qs.newCq(cq2, "select * from /" + regionName + " where id = 1", cqAf.create(), true).execute();
-          qs.newCq(cq3, "select * from /" + regionName + " where id > 2", cqAf.create(), true).execute();        
-          cache.getLogger().info("setupCqs created cqs = " +cache.getQueryService().getCqs().length);
-        } catch(Exception e){
-          cache.getLogger().info("setupCqs Exception " + CliUtil.stackTraceAsString(e));
-        }
-        return true;
-      }
+    clientId = (String) manager.invoke("get client Id", () -> {
+      Cache cache = GemFireCacheImpl.getInstance();
+      SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
+      DistributedMember serverMember = getMember(server1);
+      final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
+      CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+      return bean.getClientIds()[0];
     });
+
   }
-  
-  private void setupCqsOnVM(VM vm) {    
-    vm.invoke(new SerializableCallable() {
-      public Object call() {        
-        Cache cache = GemFireCacheImpl.getInstance();
-        QueryService qs = cache.getQueryService();
-        CqAttributesFactory cqAf = new CqAttributesFactory();
-        try {
-          qs.newCq(cq1, "select * from /" + regionName, cqAf.create(), true).execute();
-          qs.newCq(cq2, "select * from /" + regionName + " where id = 1", cqAf.create(), true).execute();
-          qs.newCq(cq3, "select * from /" + regionName + " where id > 2", cqAf.create(), true).execute();          
-          cache.getLogger().info("setupCqs on vm created cqs = " +cache.getQueryService().getCqs().length);
-        } catch(Exception e){
-          cache.getLogger().info("setupCqs on vm Exception " + CliUtil.stackTraceAsString(e));
-        }
-        return true;
+
+  private void setupCqsOnVM(VM vm) {
+    vm.invoke("setup CQs", () -> {
+      Cache cache = GemFireCacheImpl.getInstance();
+      QueryService qs = cache.getQueryService();
+      CqAttributesFactory cqAf = new CqAttributesFactory();
+      try {
+        qs.newCq(cq1, "select * from /" + regionName, cqAf.create(), true).execute();
+        qs.newCq(cq2, "select * from /" + regionName + " where id = 1", cqAf.create(), true).execute();
+        qs.newCq(cq3, "select * from /" + regionName + " where id > 2", cqAf.create(), true).execute();
+        cache.getLogger().info("setupCqs on vm created cqs = " + cache.getQueryService().getCqs().length);
+      } catch (Exception e) {
+        cache.getLogger().info("setupCqs on vm Exception " + CliUtil.stackTraceAsString(e));
       }
+      return true;
     });
   }
-  
-  private String startCacheServer(VM server, final int port, 
+
+  private int startCacheServer(VM server, final int port,
       final boolean createPR, final String regionName) throws Exception {
 
-    String cacheserverport = (String) server.invoke(new SerializableCallable() {
-      public Object call() throws Exception {
-        getSystem(getServerProperties());
-        
-        GemFireCacheImpl cache = (GemFireCacheImpl)getCache();
-        AttributesFactory factory = new AttributesFactory();
-        if (createPR) {
-          PartitionAttributesFactory paf = new PartitionAttributesFactory();
-          paf.setRedundantCopies(1);
-          paf.setTotalNumBuckets(11);
-          factory.setPartitionAttributes(paf.create());
-        } else {
-          factory.setScope(Scope.DISTRIBUTED_ACK);
-          factory.setDataPolicy(DataPolicy.REPLICATE);
-        }
-        Region region = createRootRegion(regionName, factory.create());
-        if (createPR) {
-          assertTrue(region instanceof PartitionedRegion);
-        } else {
-          assertTrue(region instanceof DistributedRegion);
-        }
-        CacheServer cacheServer = cache.addCacheServer();
-        cacheServer.setPort(port);
-        cacheServer.start();       
-        return ""+cacheServer.getPort();
+    return server.invoke("setup CacheServer", () -> {
+      getSystem(getServerProperties());
+
+      GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
+      AttributesFactory factory = new AttributesFactory();
+      if (createPR) {
+        PartitionAttributesFactory paf = new PartitionAttributesFactory();
+        paf.setRedundantCopies(1);
+        paf.setTotalNumBuckets(11);
+        factory.setPartitionAttributes(paf.create());
+      } else {
+        factory.setScope(Scope.DISTRIBUTED_ACK);
+        factory.setDataPolicy(DataPolicy.REPLICATE);
       }
+      Region region = createRootRegion(regionName, factory.create());
+      if (createPR) {
+        assertTrue(region instanceof PartitionedRegion);
+      } else {
+        assertTrue(region instanceof DistributedRegion);
+      }
+      CacheServer cacheServer = cache.addCacheServer();
+      cacheServer.setPort(port);
+      cacheServer.start();
+      return cacheServer.getPort();
     });
-    return cacheserverport;
-  } 
-  
+  }
+
   private void startNonDurableClient(VM client, final VM server, final int port) {
-    client.invoke(new CacheSerializableRunnable("Start client") {
-      public void run2() throws CacheException {        
-        Cache cache = GemFireCacheImpl.getInstance();
-        if(cache == null ){
-          
-          Properties props = getNonDurableClientProps();
-          props.setProperty("log-file", "client_" + OSProcess.getId() + ".log");
-          props.setProperty("log-level", "fine");
-          props.setProperty("statistic-archive-file", "client_" + OSProcess.getId() + ".gfs");
-          props.setProperty("statistic-sampling-enabled", "true");
-          
-          getSystem(props);
-          
-          final ClientCacheFactory ccf = new ClientCacheFactory(props);
-          ccf.addPoolServer(getServerHostName(server.getHost()), port);
-          ccf.setPoolSubscriptionEnabled(true);
-          ccf.setPoolPingInterval(1);
-          ccf.setPoolStatisticInterval(1);
-          ccf.setPoolSubscriptionRedundancy(1);
-          ccf.setPoolMinConnections(1);
-          
-          ClientCache clientCache = (ClientCache)getClientCache(ccf);
-          //Create region
-          if( clientCache.getRegion(Region.SEPARATOR + regionName) == null && clientCache.getRegion( regionName) == null){     
-            ClientRegionFactory regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.LOCAL).setPoolName(clientCache.getDefaultPool().getName()) ;
-            Region dataRegion = regionFactory.create(regionName);       
-            assertNotNull(dataRegion);           
-            dataRegion.put("k1", "v1");
-            dataRegion.put("k2", "v2");
-            
-          }
-        }else{
-          String poolName = "new_pool_" + System.currentTimeMillis();
-          try{                      
-            PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(getServerHostName(server.getHost()), port)
+    client.invoke("start non-durable client", () -> {
+      Cache cache = GemFireCacheImpl.getInstance();
+      if (cache == null) {
+
+        Properties props = getNonDurableClientProps();
+        props.setProperty("log-file", "client_" + OSProcess.getId() + ".log");
+        props.setProperty("log-level", "fine");
+        props.setProperty("statistic-archive-file", "client_" + OSProcess.getId() + ".gfs");
+        props.setProperty("statistic-sampling-enabled", "true");
+
+        getSystem(props);
+
+        final ClientCacheFactory ccf = new ClientCacheFactory(props);
+        ccf.addPoolServer(getServerHostName(server.getHost()), port);
+        ccf.setPoolSubscriptionEnabled(true);
+        ccf.setPoolPingInterval(1);
+        ccf.setPoolStatisticInterval(1);
+        ccf.setPoolSubscriptionRedundancy(1);
+        ccf.setPoolMinConnections(1);
+
+        ClientCache clientCache = (ClientCache) getClientCache(ccf);
+        //Create region
+        if (clientCache.getRegion(Region.SEPARATOR + regionName) == null && clientCache.getRegion(regionName) == null) {
+          ClientRegionFactory regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.LOCAL)
+              .setPoolName(clientCache.getDefaultPool().getName());
+          Region dataRegion = regionFactory.create(regionName);
+          assertNotNull(dataRegion);
+          dataRegion.put("k1", "v1");
+          dataRegion.put("k2", "v2");
+
+        }
+      } else {
+        String poolName = "new_pool_" + System.currentTimeMillis();
+        try {
+          PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(getServerHostName(server.getHost()), port)
               .setThreadLocalConnections(true)
               .setMinConnections(1)
               .setSubscriptionEnabled(true)
               .setPingInterval(1)
-              .setStatisticInterval(1)   
+              .setStatisticInterval(1)
               .setMinConnections(1)
               .setSubscriptionRedundancy(1)
               .create(poolName);
-            cache.getLogger().info("Created new pool pool " + poolName  );            
-            assertNotNull(p);
-          }catch(Exception eee){
-            cache.getLogger().info("Exception in creating pool " + poolName + "    Exception ==" + CliUtil.stackTraceAsString(eee));
-          }
-        }        
+          System.out.println("Created new pool pool " + poolName);
+          assertNotNull(p);
+        } catch (Exception eee) {
+          System.err.println("Exception in creating pool " + poolName + "    Exception ==" + CliUtil.stackTraceAsString(eee));
+        }
       }
     });
   }
-  
-  
+
   //Closes the non-durable-client from the client side.
-  private void closeNonDurableClient(VM vm) {
-    final VM client = vm ;
-      client.invoke(new CacheSerializableRunnable("Stop client") {
-        public void run2() throws CacheException {
-          ClientCacheFactory.getAnyInstance().close(true);
-        }
-      });
+  private void closeNonDurableClient(final VM vm) {
+    vm.invoke("Stop client", () -> ClientCacheFactory.getAnyInstance().close(true));
   }
-  
-  private void closeCacheServer(VM vm) {
-    final VM client = vm ;
-      client.invoke(new CacheSerializableRunnable("Stop client") {
-        public void run2() throws CacheException {
-          
-          Iterator<CacheServer> it = CacheFactory.getAnyInstance().getCacheServers().iterator();
-          while(it.hasNext()){
-            CacheServer cacheServer = it.next();
-            cacheServer.stop();
-          }
-        }
-      });
-  }  
-  
+
+  private void closeCacheServer(final VM vm) {
+    vm.invoke("Stop client", () -> {
+      Iterator<CacheServer> it = CacheFactory.getAnyInstance().getCacheServers().iterator();
+      while (it.hasNext()) {
+        CacheServer cacheServer = it.next();
+        cacheServer.stop();
+      }
+    });
+  }
+
   protected Properties getNonDurableClientProps() {
     Properties p = new Properties();
     p.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    p.setProperty(DistributionConfig.LOCATORS_NAME, "");    
+    p.setProperty(DistributionConfig.LOCATORS_NAME, "");
     return p;
   }
 
   protected Properties getServerProperties() {
     Properties p = new Properties();
-    p.setProperty(DistributionConfig.LOCATORS_NAME, "localhost["+getDUnitLocatorPort()+"]");
+    p.setProperty(DistributionConfig.LOCATORS_NAME, "localhost[" + getDUnitLocatorPort() + "]");
     return p;
   }
-  
-  
-  
-public void waitForNonSubCliMBean(){    
+
+  public void waitForNonSubCliMBean() {
     final VM manager = Host.getHost(0).getVM(0);
-    final VM server1 = Host.getHost(0).getVM(1);    
-    final DistributedMember serverMember = getMember(server1);    
-    assertNotNull(serverMember);   
-    
-    manager.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        final WaitCriterion waitForMaangerMBean = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            try {         
-              final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
-              if (service == null) {
-                getLogWriter().info("waitForNonSubScribedClientMBean Still probing for service");
-                return false;
-              } else {      
-                getLogWriter().info("waitForNonSubScribedClientMBean 1");
-                final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);
-                getLogWriter().info("waitForNonSubScribedClientMBean 2 cacheServerMBeanName " + cacheServerMBeanName);
-                CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
-                getLogWriter().info("waitForNonSubScribedClientMBean 2 bean " + bean);
-                if(bean.getClientIds().length > 0){
-                  return true;
-                }               
-              }
-            } catch (Exception e) {
-              LogWrapper.getInstance().warning("waitForNonSubScribedClientMBean Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
-            }
-            return false;
-          }
+    final VM server1 = Host.getHost(0).getVM(1);
+    final DistributedMember serverMember = getMember(server1);
+    assertNotNull(serverMember);
 
-          @Override
-          public String description() {
-            return "waitForNonSubScribedClientMBean Probing for ";
+    manager.invoke(() -> {
+      Awaitility.waitAtMost(5 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
+        try {
+          final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
+          if (service == null) {
+            getLogWriter().info("waitForNonSubScribedClientMBean Still probing for service");
+            return false;
+          } else {
+            getLogWriter().info("waitForNonSubScribedClientMBean 1");
+            final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
+            getLogWriter().info("waitForNonSubScribedClientMBean 2 cacheServerMBeanName " + cacheServerMBeanName);
+            CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+            getLogWriter().info("waitForNonSubScribedClientMBean 2 bean " + bean);
+            if (bean.getClientIds().length > 0) {
+              return true;
+            }
           }
-        };
-        waitForCriterion(waitForMaangerMBean, 5* 60 * 1000, 2000, true);
-      }
-    }); 
-    
+        } catch (Exception e) {
+          LogWrapper.getInstance().warning("waitForNonSubScribedClientMBean Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
+        }
+        return false;
+      });
+    });
   }
-  
-  
-public void waitForMixedClients(){
-    
+
+  public void waitForMixedClients() {
+
     final VM manager = Host.getHost(0).getVM(0);
-    final VM server1 = Host.getHost(0).getVM(1);   
-    
+    final VM server1 = Host.getHost(0).getVM(1);
+
     final DistributedMember serverMember = getMember(server1);
-    
-    assertNotNull(serverMember);   
-    
-    manager.invoke(new SerializableRunnable() {
-      @Override
-      public void run() {
-        final WaitCriterion waitForMaangerMBean = new WaitCriterion() {
-          @Override
-          public boolean done() {
-            try {         
-              final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
-              if (service == null) {
-                getLogWriter().info("waitForMixedClients Still probing for service");
-                return false;
-              } else {      
-                getLogWriter().info("waitForMixedClients 1");
-                final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0,serverMember);
-                getLogWriter().info("waitForMixedClients 2 cacheServerMBeanName " + cacheServerMBeanName);
-                CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
-                getLogWriter().info("waitForMixedClients 2 bean " + bean);
-                if(bean.getClientIds().length > 1){
-                  return true;
-                }                
-              }
-            } catch (Exception e) {
-              LogWrapper.getInstance().warning("waitForMixedClients Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
-            }
-            return false;
-          }
 
-          @Override
-          public String description() {
-            return "waitForMixedClients Probing for ";
+    assertNotNull(serverMember);
+
+    manager.invoke(() -> {
+      Awaitility.waitAtMost(5 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
+        try {
+          final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
+          if (service == null) {
+            getLogWriter().info("waitForMixedClients Still probing for service");
+            return false;
+          } else {
+            getLogWriter().info("waitForMixedClients 1");
+            final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
+            getLogWriter().info("waitForMixedClients 2 cacheServerMBeanName " + cacheServerMBeanName);
+            CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+            getLogWriter().info("waitForMixedClients 2 bean " + bean);
+            if (bean.getClientIds().length > 1) {
+              return true;
+            }
           }
-        };
-        waitForCriterion(waitForMaangerMBean, 5* 60 * 1000, 2000, true);
-      }
-    }); 
-    
+        } catch (Exception e) {
+          LogWrapper.getInstance().warning("waitForMixedClients Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
+        }
+        return false;
+      });
+    });
   }
 
   @Category(FlakyTest.class) // GEODE-910: random ports, HeadlessGfsh
   @Test
   public void testDescribeClientForNonSubscribedClient() throws Exception {
     setUpNonSubscribedClient();
-    
-    getLogWriter().info("testDescribeClientForNonSubscribedClient clientId="+clientId);    
+
+    getLogWriter().info("testDescribeClientForNonSubscribedClient clientId=" + clientId);
     assertNotNull(clientId);
-    
-    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientId + "\"" ;
-    getLogWriter().info("testDescribeClientForNonSubscribedClient commandStr="+commandString);
-    
-    final VM server1 = Host.getHost(0).getVM(1);
-    String serverName = (String) server1.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
-          
-      }
-    });
-    
-    
+
+    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId + "\"";
+    getLogWriter().info("testDescribeClientForNonSubscribedClient commandStr=" + commandString);
+
     CommandResult commandResult = executeCommand(commandString);
-    getLogWriter().info("testDescribeClientForNonSubscribedClient commandResult="+commandResult);    
-    
-    
+    getLogWriter().info("testDescribeClientForNonSubscribedClient commandResult=" + commandResult);
+
     String resultAsString = commandResultToString(commandResult);
-    getLogWriter().info("testDescribeClientForNonSubscribedClient resultAsString="+resultAsString);   
+    getLogWriter().info("testDescribeClientForNonSubscribedClient resultAsString=" + resultAsString);
     assertTrue(Status.OK.equals(commandResult.getStatus()));
-    
+
     CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
-    SectionResultData section =resultData.retrieveSection("InfoSection");
-    assertNotNull(section);    
+    SectionResultData section = resultData.retrieveSection("InfoSection");
+    assertNotNull(section);
     TabularResultData tableRsultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
     assertNotNull(tableRsultData);
-    
+
     List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
     List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
     List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
-    
-    
+
     assertTrue(minConn.contains("1"));
     assertTrue(maxConn.contains("-1"));
     assertTrue(redudancy.contains("1"));
-    
+
     String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
-    assertTrue(puts.equals("2"));   
-    
+    assertTrue(puts.equals("2"));
+
     String calls = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_LISTNER_CALLS);
     assertTrue(calls.equals("1"));
-    
+
     String primServer = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PRIMARY_SERVERS);
     assertTrue(primServer.equals("N.A."));
-    
+
     String durable = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_DURABLE);
-    assertTrue(durable.equals("No"));   
-    
+    assertTrue(durable.equals("No"));
+
     String threads = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_THREADS);
     assertTrue(Integer.parseInt(threads) > 0);
-    
+
     String cpu = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_CPU);
-    assertTrue(Integer.parseInt(cpu) > 0);   
-    
+    assertTrue(Integer.parseInt(cpu) > 0);
+
     String upTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_UP_TIME);
-    assertTrue(Integer.parseInt(upTime) == 0);  
-    
+    assertTrue(Integer.parseInt(upTime) == 0);
+
     String prcTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PROCESS_CPU_TIME);
     assertTrue(Long.parseLong(prcTime) > 0);
-    
-    
+
     closeNonDurableClient(Host.getHost(0).getVM(2));
     closeCacheServer(Host.getHost(0).getVM(1));
     closeCacheServer(Host.getHost(0).getVM(3));
-    
-    
+
   }
 
   @Category(FlakyTest.class) // GEODE-1227: HeadlessGFSH, random ports, BindException
   @Test
   public void testDescribeMixClientWithServers() throws Exception {
-    String[] clientIds = setupSystemWithSubAndNonSubClient();    
-    
+    String[] clientIds = setupSystemWithSubAndNonSubClient();
+
     final VM server1 = Host.getHost(0).getVM(1);
-    String serverName = (String) server1.invoke(new SerializableCallable(){
-      @Override
-      public Object call() throws Exception {
-        return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
-          
-      }
-    });
-    
-    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientIds[0] + "\"" ;
-    getLogWriter().info("testDescribeMixClientWithServers commandStr="+commandString);
-    
-    
-    executeAndVerifyResultsForMixedClients(commandString, serverName );    
-    
-    String commandString2 = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\""+ clientIds[1] + "\"" ;
-    getLogWriter().info("testDescribeMixClientWithServers commandString2="+commandString2);   
-    
-    
-    executeAndVerifyResultsForMixedClients(commandString2,serverName );
-    
+    String serverName = (String) server1.invoke("Get DistributedMember Id", () ->
+        getDistributedMemberId());
+
+    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientIds[0] + "\"";
+    getLogWriter().info("testDescribeMixClientWithServers commandStr=" + commandString);
+
+    executeAndVerifyResultsForMixedClients(commandString, serverName);
+
+    String commandString2 = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientIds[1] + "\"";
+    getLogWriter().info("testDescribeMixClientWithServers commandString2=" + commandString2);
+
+    executeAndVerifyResultsForMixedClients(commandString2, serverName);
+
     closeNonDurableClient(Host.getHost(0).getVM(2));
     closeNonDurableClient(Host.getHost(0).getVM(3));
     closeCacheServer(Host.getHost(0).getVM(1));
-  
+
   }
-  
-void executeAndVerifyResultsForMixedClients(String commandString, String serverName){
-  CommandResult commandResult = executeCommand(commandString);
-  getLogWriter().info("testDescribeMixClientWithServers commandResult="+commandResult);    
-  
-  
-  String resultAsString = commandResultToString(commandResult);
-  getLogWriter().info("testDescribeMixClientWithServers resultAsString="+resultAsString);
-  
-  
-  assertTrue(Status.OK.equals(commandResult.getStatus()));
-  
-  CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
-  SectionResultData section =resultData.retrieveSection("InfoSection");
-  assertNotNull(section);    
-  TabularResultData tableRsultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
-  assertNotNull(tableRsultData);
-  
-  List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
-  List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
-  List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
-  
-  
-  assertTrue(minConn.contains("1"));
-  assertTrue(maxConn.contains("-1"));
-  assertTrue(redudancy.contains("1"));
-  
-  String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
-  assertTrue(puts.equals("2"));    
-  
-  String calls = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_LISTNER_CALLS);
-  assertTrue(calls.equals("1"));
-  
-  String primServer = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PRIMARY_SERVERS);
-  assertTrue(primServer.equals(serverName) || primServer.equals("N.A."));
-  
-  String durable = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_DURABLE);
-  assertTrue(durable.equals("No"));   
-  
-  String threads = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_THREADS);
-  assertTrue(Integer.parseInt(threads) > 0);
-  
-  String cpu = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_CPU);
-  assertTrue(Integer.parseInt(cpu) > 0);   
-  
-  String upTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_UP_TIME);
-  assertTrue(Integer.parseInt(upTime) >= 0);   
-  
-  String prcTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PROCESS_CPU_TIME);
-  assertTrue(Long.parseLong(prcTime) > 0);
-  
-}
 
-private void setUpNonSubscribedClient() throws Exception {
-  disconnectAllFromDS();
-  final int[] port = AvailablePortHelper.getRandomAvailableTCPPorts(2);
-  createDefaultSetup(getServerProperties());
-  
-  final VM manager = Host.getHost(0).getVM(0);
-  final VM server1 = Host.getHost(0).getVM(1);
-  final VM client1 = Host.getHost(0).getVM(2);
-  final VM server2 = Host.getHost(0).getVM(3);
-  
-  port0 = port[0];
-  
-  startCacheServer(server1, port[0], false, regionName);
-  startCacheServer(server2, port[1], false, regionName);    
-  
-  startNonSubscribedClient(client1, server1, port[0]);
-  setupCqsOnVM(client1);
-  waitForNonSubCliMBean();
-  
-  
-  
-  clientId =  (String) manager.invoke(new SerializableCallable(){
-    @Override
-    public Object call() throws Exception {
-      Cache cache = GemFireCacheImpl.getInstance();       
-      SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
-      DistributedMember serverMember = getMember(server1);
-      final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port[0],serverMember);
-      CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
-      return bean.getClientIds()[0]; 
-    }
-  });
-}
+  void executeAndVerifyResultsForMixedClients(String commandString, String serverName) {
+    CommandResult commandResult = executeCommand(commandString);
+    getLogWriter().info("testDescribeMixClientWithServers commandResult=" + commandResult);
+
+    String resultAsString = commandResultToString(commandResult);
+    getLogWriter().info("testDescribeMixClientWithServers resultAsString=" + resultAsString);
 
+    assertTrue(Status.OK.equals(commandResult.getStatus()));
+
+    CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
+    SectionResultData section = resultData.retrieveSection("InfoSection");
+    assertNotNull(section);
+    TabularResultData tableResultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
+    assertNotNull(tableResultData);
 
+    List<String> minConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
+    List<String> maxConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
+    List<String> redudancy = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
 
-  private String[] setupSystemWithSubAndNonSubClient() throws Exception {
-    String[] cliendIds = new String[2];
+    assertTrue(minConn.contains("1"));
+    assertTrue(maxConn.contains("-1"));
+    assertTrue(redudancy.contains("1"));
+
+    String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
+    assertTrue(puts.equals("2"));
+
+    String calls = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_LISTNER_CALLS);
+    assertTrue(calls.equals("1"));
+
+    String primServer = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PRIMARY_SERVERS);
+    assertTrue(primServer.equals(serverName) || primServer.equals("N.A."));
+
+    String durable = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_DURABLE);
+    assertTrue(durable.equals("No"));
+
+    String threads = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_THREADS);
+    assertTrue(Integer.parseInt(threads) > 0);
+
+    String cpu = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_CPU);
+    assertTrue(Integer.parseInt(cpu) > 0);
+
+    String upTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_UP_TIME);
+    assertTrue(Integer.parseInt(upTime) >= 0);
+
+    String prcTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PROCESS_CPU_TIME);
+    assertTrue(Long.parseLong(prcTime) > 0);
+
+  }
+
+  private void setUpNonSubscribedClient() throws Exception {
     disconnectAllFromDS();
-    final int[] port = AvailablePortHelper.getRandomAvailableTCPPorts(3);
     createDefaultSetup(getServerProperties());
-    
+
     final VM manager = Host.getHost(0).getVM(0);
     final VM server1 = Host.getHost(0).getVM(1);
     final VM client1 = Host.getHost(0).getVM(2);
-    final VM client2 = Host.getHost(0).getVM(3);
-    
-    startCacheServer(server1, port[0], false, regionName);    
-    port0 = port[0];
-    startNonDurableClient(client1, server1, port[0]);
-    startNonSubscribedClient(client2, server1, port[0]);
-    
-    waitForMixedClients();
-    
-    cliendIds =  (String[]) manager.invoke(new SerializableCallable(){
+    final VM server2 = Host.getHost(0).getVM(3);
+
+    port0 = startCacheServer(server1, 0, false, regionName);
+    startCacheServer(server2, 0, false, regionName);
+
+    startNonSubscribedClient(client1, server1, port0);
+    setupCqsOnVM(client1);
+    waitForNonSubCliMBean();
+
+    clientId = (String) manager.invoke(new SerializableCallable() {
       @Override
       public Object call() throws Exception {
-        Cache cache = GemFireCacheImpl.getInstance();       
+        Cache cache = GemFireCacheImpl.getInstance();
         SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
         DistributedMember serverMember = getMember(server1);
-        final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port[0],serverMember);     
+        final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
         CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
-        return bean.getClientIds(); 
+        return bean.getClientIds()[0];
       }
-    });   
-    
+    });
+  }
+
+  private String[] setupSystemWithSubAndNonSubClient() throws Exception {
+    disconnectAllFromDS();
+    createDefaultSetup(getServerProperties());
+
+    final VM manager = Host.getHost(0).getVM(0);
+    final VM server1 = Host.getHost(0).getVM(1);
+    final VM client1 = Host.getHost(0).getVM(2);
+    final VM client2 = Host.getHost(0).getVM(3);
+
+    port0 = startCacheServer(server1, 0, false, regionName);
+    startNonDurableClient(client1, server1, port0);
+    startNonSubscribedClient(client2, server1, port0);
+
+    waitForMixedClients();
+
+    String[] cliendIds = (String[]) manager.invoke("get client Ids", () -> {
+      Cache cache = GemFireCacheImpl.getInstance();
+      SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
+      DistributedMember serverMember = getMember(server1);
+      final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
+      CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+      return bean.getClientIds();
+    });
+
     return cliendIds;
-    
   }
-  private void startNonSubscribedClient  (VM client, final VM server, final int port) {
-    client.invoke(new CacheSerializableRunnable("Start client") {
-      public void run2() throws CacheException {        
-        Cache cache = GemFireCacheImpl.getInstance();
-        if(cache == null ){
-          
-          Properties props = getNonDurableClientProps();
-          props.setProperty("log-file", "client_" + OSProcess.getId() + ".log");
-          props.setProperty("log-level", "fine");
-          props.setProperty("statistic-archive-file", "client_" + OSProcess.getId() + ".gfs");
-          props.setProperty("statistic-sampling-enabled", "true");
-          
-          getSystem(props);
-          
-          final ClientCacheFactory ccf = new ClientCacheFactory(props);
-          ccf.addPoolServer(getServerHostName(server.getHost()), port);
-          ccf.setPoolSubscriptionEnabled(false);
-          ccf.setPoolPingInterval(1);
-        

<TRUNCATED>


[17/25] incubator-geode git commit: GEODE-1264: Add MX4J to LICENSE

Posted by ji...@apache.org.
GEODE-1264: Add MX4J to LICENSE


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 14d0cf50ab8cebf6748f82e0c54709aac5dc5770
Parents: bc24aef
Author: Anthony Baker <ab...@apache.org>
Authored: Wed Apr 20 15:31:53 2016 -0700
Committer: Anthony Baker <ab...@apache.org>
Committed: Thu Apr 21 11:52:23 2016 -0700

----------------------------------------------------------------------
 LICENSE                              | 55 +++++++++++++++++++++++++++++++
 geode-assembly/src/main/dist/LICENSE |  3 +-
 2 files changed, 57 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/14d0cf50/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 970a2ff..3413a7c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -389,6 +389,61 @@ DEALINGS IN THE SOFTWARE.
 
 
 ---------------------------------------------------------------------------
+The MX4J License (http://mx4j.sourceforge.net/docs/ch01s06.html)
+---------------------------------------------------------------------------
+
+Apache Geode bundles the following files under the MX4J License:
+
+  - MX4JModelMBean.java (http://mx4j.sourceforge.net)
+
+Version 1.0
+
+Copyright (c) 2001-2004 by the MX4J contributors.  All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in
+   the documentation and/or other materials provided with the
+   distribution.
+
+3. The end-user documentation included with the redistribution,
+   if any, must include the following acknowledgment:
+      "This product includes software developed by the
+       MX4J project (http://mx4j.sourceforge.net)."
+   Alternately, this acknowledgment may appear in the software itself,
+   if and wherever such third-party acknowledgments normally appear.
+
+4. The name "MX4J" must not be used to endorse or promote
+   products derived from this software without prior written
+   permission.
+   For written permission, please contact
+   biorn_steedom [at] users [dot] sourceforge [dot] net
+
+5. Products derived from this software may not be called "MX4J",
+   nor may "MX4J" appear in their name, without prior written
+   permission of Simone Bordet.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED.  IN NO EVENT SHALL THE MX4J CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+
+---------------------------------------------------------------------------
 Public Domain
 ---------------------------------------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/14d0cf50/geode-assembly/src/main/dist/LICENSE
----------------------------------------------------------------------
diff --git a/geode-assembly/src/main/dist/LICENSE b/geode-assembly/src/main/dist/LICENSE
index 9c906dd..3ed1e9a 100644
--- a/geode-assembly/src/main/dist/LICENSE
+++ b/geode-assembly/src/main/dist/LICENSE
@@ -736,8 +736,9 @@ DEALINGS IN THE SOFTWARE.
 The MX4J License (http://mx4j.sourceforge.net/docs/ch01s06.html)
 ---------------------------------------------------------------------------
 
-Apache Geode bundles the following file under the MIT license:
+Apache Geode bundles the following file under the MX4J license:
 
+  - MX4JModelMBean.java (http://mx4j.sourceforge.net)
   - MX4J v3.0.1 (http://mx4j.sourceforge.net), Copyright (c) MX4J
 
 Version 1.0


[07/25] incubator-geode git commit: GEODE-1238: ensure EntryEventImpls are released

Posted by ji...@apache.org.
GEODE-1238: ensure EntryEventImpls are released

-- reviewed all EntryEventImpl creators
-- created two new subclasses to mark ones that are never off-heap
-- added annotations and comments on all creators
-- added missing release calls


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 7022135035f5a1804eff38c2a159c0352728373d
Parents: ff914bd
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Fri Apr 15 11:42:19 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Thu Apr 21 10:53:30 2016 -0700

----------------------------------------------------------------------
 .../client/internal/ServerRegionProxy.java      |   3 +-
 .../internal/admin/ClientStatsManager.java      |   3 +-
 .../cache/AbstractBucketRegionQueue.java        |   3 +-
 .../internal/cache/AbstractLRURegionMap.java    |   4 +
 .../internal/cache/AbstractRegionEntry.java     |   2 +-
 .../internal/cache/AbstractRegionMap.java       |  15 +-
 .../gemfire/internal/cache/BucketRegion.java    |  14 +-
 .../internal/cache/BucketRegionQueue.java       |   7 +-
 .../internal/cache/DestroyOperation.java        |   6 +-
 .../internal/cache/DistPeerTXStateStub.java     |   2 +
 .../gemfire/internal/cache/DistTXState.java     |   9 +-
 .../cache/DistTXStateOnCoordinator.java         |   2 +
 .../DistTXStateProxyImplOnCoordinator.java      |   2 +
 .../cache/DistributedCacheOperation.java        |   4 +-
 .../cache/DistributedPutAllOperation.java       |  23 ++-
 .../internal/cache/DistributedRegion.java       |   9 +-
 .../cache/DistributedRemoveAllOperation.java    |  22 ++-
 .../gemfire/internal/cache/EntryEventImpl.java  |  41 +-----
 .../gemfire/internal/cache/EntryExpiryTask.java |   9 +-
 .../gemfire/internal/cache/EventIDHolder.java   |  35 +++++
 .../gemfire/internal/cache/FilterProfile.java   |  13 +-
 .../gemfire/internal/cache/HARegion.java        |   5 +-
 .../internal/cache/InitialImageOperation.java   |   2 +-
 .../internal/cache/InvalidateOperation.java     |   5 +-
 .../gemfire/internal/cache/LocalRegion.java     | 141 ++++++++++---------
 .../internal/cache/PartitionedRegion.java       |  13 +-
 .../gemfire/internal/cache/ProxyRegionMap.java  |   7 +-
 .../gemfire/internal/cache/QueuedOperation.java |   3 +-
 .../internal/cache/RemoteDestroyMessage.java    |   3 +-
 .../internal/cache/RemoteInvalidateMessage.java |   4 +-
 .../internal/cache/RemotePutAllMessage.java     |   5 +-
 .../internal/cache/RemotePutMessage.java        |   4 +-
 .../internal/cache/RemoteRemoveAllMessage.java  |   5 +-
 .../cache/SearchLoadAndWriteProcessor.java      |   6 +-
 .../gemfire/internal/cache/TXCommitMessage.java |   4 +-
 .../gemfire/internal/cache/TXEntryState.java    |   6 +-
 .../gemfire/internal/cache/TXRegionState.java   |   1 +
 .../gemfire/internal/cache/TXRmtEvent.java      |   9 +-
 .../gemfire/internal/cache/TXState.java         |   9 +-
 .../cache/TimestampedEntryEventImpl.java        |   2 +
 .../cache/UpdateEntryVersionOperation.java      |   4 +-
 .../gemfire/internal/cache/UpdateOperation.java |   8 +-
 .../internal/cache/VersionTagHolder.java        |  34 +++++
 .../cache/partitioned/DestroyMessage.java       |  11 +-
 .../partitioned/FetchBulkEntriesMessage.java    |   4 +-
 .../internal/cache/partitioned/GetMessage.java  |   5 +-
 .../cache/partitioned/InvalidateMessage.java    |   3 +-
 .../PRUpdateEntryVersionMessage.java            |   1 +
 .../cache/partitioned/PutAllPRMessage.java      |  12 +-
 .../internal/cache/partitioned/PutMessage.java  |  11 +-
 .../cache/partitioned/RemoveAllPRMessage.java   |  13 +-
 .../cache/tier/sockets/BaseCommand.java         |  12 +-
 .../cache/tier/sockets/CacheClientUpdater.java  |   3 +-
 .../cache/tier/sockets/command/Destroy.java     |   3 +-
 .../cache/tier/sockets/command/Destroy65.java   |   3 +-
 .../sockets/command/GatewayReceiverCommand.java |  11 +-
 .../cache/tier/sockets/command/Get70.java       |  15 +-
 .../cache/tier/sockets/command/Invalidate.java  |   3 +-
 .../cache/tier/sockets/command/Put.java         |   5 +-
 .../cache/tier/sockets/command/Put61.java       |   5 +-
 .../cache/tier/sockets/command/Put65.java       |   3 +-
 .../internal/cache/tx/DistTxEntryEvent.java     |  13 +-
 .../cache/tx/PartitionedTXRegionStub.java       |  17 ++-
 .../cache/wan/AbstractGatewaySender.java        |   5 +-
 .../AbstractGatewaySenderEventProcessor.java    |   2 +
 .../cache/wan/serial/BatchDestroyOperation.java |   5 +-
 ...urrentSerialGatewaySenderEventProcessor.java |   3 +-
 .../wan/serial/SerialGatewaySenderQueue.java    |   2 +-
 .../DistributedAckRegionCCEDUnitTest.java       |   6 +-
 .../internal/cache/UpdateVersionJUnitTest.java  |   4 +-
 .../cache/ha/EventIdOptimizationDUnitTest.java  |   5 +-
 .../DestroyEntryPropagationDUnitTest.java       |   5 +-
 .../internal/cache/UpdateVersionDUnitTest.java  |   4 +-
 73 files changed, 437 insertions(+), 265 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ServerRegionProxy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ServerRegionProxy.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ServerRegionProxy.java
index 40f240f..23e04fd 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ServerRegionProxy.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ServerRegionProxy.java
@@ -42,6 +42,7 @@ import com.gemstone.gemfire.internal.cache.ClientServerObserver;
 import com.gemstone.gemfire.internal.cache.ClientServerObserverHolder;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
+import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.TXCommitMessage;
 import com.gemstone.gemfire.internal.cache.TXManagerImpl;
@@ -192,7 +193,7 @@ public class ServerRegionProxy extends ServerProxy implements ServerRegionDataAc
                     EventID eventId,
                     Object callbackArg)
   {
-    EntryEventImpl event = new EntryEventImpl(eventId);
+    EventIDHolder event = new EventIDHolder(eventId);
     PutOp.execute(con, this.pool, this.regionName, key, value, event, callbackArg, this.pool.getPRSingleHopEnabled());
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/ClientStatsManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/ClientStatsManager.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/ClientStatsManager.java
index 20f6dbf..2db7eb1 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/ClientStatsManager.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/ClientStatsManager.java
@@ -36,6 +36,7 @@ import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.management.internal.cli.CliUtil;
 
 /**
@@ -84,7 +85,7 @@ public class ClientStatsManager {
       ServerRegionProxy regionProxy = new ServerRegionProxy(ClientHealthMonitoringRegion.ADMIN_REGION_NAME, pool);
       
       EventID eventId = new EventID(ds);
-      EntryEventImpl event = new EntryEventImpl((Object)null);
+      @Released EntryEventImpl event = new EntryEventImpl((Object)null);
       try {
       event.setEventId(eventId);
       regionProxy.putForMetaRegion(ds.getMemberId(), stats, null, event, null, true);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractBucketRegionQueue.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractBucketRegionQueue.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractBucketRegionQueue.java
index 2c8f493..1f8da88 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractBucketRegionQueue.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractBucketRegionQueue.java
@@ -48,6 +48,7 @@ import com.gemstone.gemfire.internal.concurrent.ConcurrentHashSet;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.offheap.OffHeapRegionEntryHelper;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 public abstract class AbstractBucketRegionQueue extends BucketRegion {
   protected static final Logger logger = LogService.getLogger();
@@ -232,7 +233,7 @@ public abstract class AbstractBucketRegionQueue extends BucketRegion {
     if (logger.isDebugEnabled()) {
       logger.debug(" destroying primary key {}", key);
     }
-    EntryEventImpl event = getPartitionedRegion().newDestroyEntryEvent(key,
+    @Released EntryEventImpl event = getPartitionedRegion().newDestroyEntryEvent(key,
         null);
     event.setEventId(new EventID(cache.getSystem()));
     try {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java
index a19ee66..2cc7a55 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java
@@ -177,6 +177,10 @@ public abstract class AbstractLRURegionMap extends AbstractRegionMap {
     // make sure this cached deserializable is still in the entry
     // @todo what if a clear is done and this entry is no longer in the region?
     {
+      if (_getCCHelper().getEvictionAlgorithm().isLRUEntry()) {
+        // no need to worry about the value changing form with entry LRU.
+        return false;
+      }
       Object curVal = le._getValue(); // OFFHEAP: _getValue ok
       if (curVal != cd) {
         if (cd instanceof StoredObject) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
index e78c8eb..debc3da 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
@@ -2070,7 +2070,7 @@ public abstract class AbstractRegionEntry implements RegionEntry,
           newValue[0] = v;
         }
       };
-      TimestampedEntryEventImpl timestampedEvent =
+      @Released TimestampedEntryEventImpl timestampedEvent =
         (TimestampedEntryEventImpl)event.getTimestampedEvent(tagDsid, stampDsid, tagTime, stampTime);
 
       // gateway conflict resolvers will usually want to see the old value

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
index 1cb7a20..3286373 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
@@ -1626,7 +1626,7 @@ public abstract class AbstractRegionMap implements RegionMap {
               // a receipt of a TXCommitMessage AND there are callbacks installed
               // for this region
               boolean invokeCallbacks = shouldCreateCBEvent(owner, isRegionReady || inRI);
-              EntryEventImpl cbEvent = createCBEvent(owner, op,
+              @Released EntryEventImpl cbEvent = createCBEvent(owner, op,
                   key, null, txId, txEvent, eventId, aCallbackArgument, filterRoutingInfo, bridgeContext, txEntryState, versionTag, tailKey);
               try {
               
@@ -1858,7 +1858,7 @@ public abstract class AbstractRegionMap implements RegionMap {
         // the destroy is already applied on the Initial image provider, thus 
         // causing region entry to be absent. 
         // Notify clients with client events.
-        EntryEventImpl cbEvent = createCBEvent(owner, op,
+        @Released EntryEventImpl cbEvent = createCBEvent(owner, op,
             key, null, txId, txEvent, eventId, aCallbackArgument, 
             filterRoutingInfo, bridgeContext, txEntryState, versionTag, tailKey);
         try {
@@ -2397,7 +2397,7 @@ public abstract class AbstractRegionMap implements RegionMap {
     final LocalRegion owner = _getOwner();
     owner.checkBeforeEntrySync(txEvent);
     
-    EntryEventImpl cbEvent = null;
+    @Released EntryEventImpl cbEvent = null;
     boolean forceNewEntry = !owner.isInitialized() && owner.isAllEvents();
 
     final boolean hasRemoteOrigin = !((TXId)txId).getMemberId().equals(owner.getMyId());
@@ -2997,7 +2997,7 @@ public abstract class AbstractRegionMap implements RegionMap {
                       stats.incEvictionsInProgress();
                       // set the flag on event saying the entry should be evicted 
                       // and not indexed
-                      EntryEventImpl destroyEvent = EntryEventImpl.create (owner, Operation.DESTROY, event.getKey(),
+                      @Released EntryEventImpl destroyEvent = EntryEventImpl.create (owner, Operation.DESTROY, event.getKey(),
                           null/* newValue */, null, false, owner.getMyId());
                       try {
 
@@ -3340,8 +3340,8 @@ public abstract class AbstractRegionMap implements RegionMap {
     final boolean isTXHost = txEntryState != null;
     final boolean isClientTXOriginator = owner.cache.isClient() && !hasRemoteOrigin;
     final boolean isRegionReady = owner.isInitialized();
-    EntryEventImpl cbEvent = null;
-    EntryEventImpl sqlfEvent = null;
+    @Released EntryEventImpl cbEvent = null;
+    @Released EntryEventImpl sqlfEvent = null;
     boolean invokeCallbacks = shouldCreateCBEvent(owner, isRegionReady);
     boolean cbEventInPending = false;
     cbEvent = createCBEvent(owner, putOp, key, newValue, txId, 
@@ -3785,6 +3785,7 @@ public abstract class AbstractRegionMap implements RegionMap {
   }
 
   /** create a callback event for applying a transactional change to the local cache */
+  @Retained
   public static final EntryEventImpl createCBEvent(final LocalRegion re,
       Operation op, Object key, Object newValue, TransactionId txId, 
       TXRmtEvent txEvent,EventID eventId, Object aCallbackArgument,FilterRoutingInfo filterRoutingInfo,ClientProxyMembershipID bridgeContext, TXEntryState txEntryState, VersionTag versionTag, long tailKey)
@@ -3799,7 +3800,7 @@ public abstract class AbstractRegionMap implements RegionMap {
       eventRegion = re.getPartitionedRegion();
     }
     
-    EntryEventImpl retVal = EntryEventImpl.create(
+    @Retained EntryEventImpl retVal = EntryEventImpl.create(
         re, op, key, newValue,
         aCallbackArgument,
         txEntryState == null, originator);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java
index 3946fda..e0f043b 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java
@@ -97,6 +97,8 @@ import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.internal.concurrent.AtomicLong5;
 
@@ -1118,6 +1120,7 @@ implements Bucket
    * @return an event for EVICT_DESTROY
    */
   @Override
+  @Retained
   protected EntryEventImpl generateEvictDestroyEvent(Object key) {
     EntryEventImpl event = super.generateEvictDestroyEvent(key);
     event.setInvokePRCallbacks(true);   //see bug 40797
@@ -1620,6 +1623,7 @@ implements Bucket
     //we already distributed this info.
   }
   
+  @Retained
   EntryEventImpl createEventForPR(EntryEventImpl sourceEvent) {
     EntryEventImpl e2 = new EntryEventImpl(sourceEvent);
     boolean returned = false;
@@ -1663,7 +1667,7 @@ implements Bucket
       }
       super.invokeTXCallbacks(eventType, event, callThem);
     }
-    final EntryEventImpl prevent = createEventForPR(event);
+    @Released final EntryEventImpl prevent = createEventForPR(event);
     try {
       this.partitionedRegion.invokeTXCallbacks(eventType, prevent, this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false);
     } finally {
@@ -1691,7 +1695,7 @@ implements Bucket
       }
       super.invokeDestroyCallbacks(eventType, event, callThem, notifyGateways);
     }
-    final EntryEventImpl prevent = createEventForPR(event);
+    @Released final EntryEventImpl prevent = createEventForPR(event);
     try {
       this.partitionedRegion.invokeDestroyCallbacks(eventType, prevent, this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false, false);
     } finally {
@@ -1718,7 +1722,7 @@ implements Bucket
       }
       super.invokeInvalidateCallbacks(eventType, event, callThem);
     }
-    final EntryEventImpl prevent = createEventForPR(event);
+    @Released final EntryEventImpl prevent = createEventForPR(event);
     try {
       this.partitionedRegion.invokeInvalidateCallbacks(eventType, prevent, this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false);
     } finally {
@@ -1749,7 +1753,7 @@ implements Bucket
       super.invokePutCallbacks(eventType, event, callThem, notifyGateways);
     }
 
-    final EntryEventImpl prevent = createEventForPR(event);
+    @Released final EntryEventImpl prevent = createEventForPR(event);
     try {
       this.partitionedRegion.invokePutCallbacks(eventType, prevent,
               this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false, false);
@@ -2577,7 +2581,7 @@ implements Bucket
   public boolean customEvictDestroy(Object key)
   {
     checkReadiness();
-    final EntryEventImpl event = 
+    @Released final EntryEventImpl event = 
           generateCustomEvictDestroyEvent(key);
     event.setCustomEviction(true);
     boolean locked = false;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegionQueue.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegionQueue.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegionQueue.java
index 6b76c31..8b4f240 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegionQueue.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegionQueue.java
@@ -53,6 +53,7 @@ import com.gemstone.gemfire.internal.concurrent.Atomics;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.offheap.OffHeapRegionEntryHelper;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 /**
  * 
@@ -504,10 +505,10 @@ public class BucketRegionQueue extends AbstractBucketRegionQueue {
     if (logger.isDebugEnabled()) {
       logger.debug(" destroying primary key {}", key);
     }
-	EntryEventImpl event = getPartitionedRegion().newDestroyEntryEvent(key,
+	@Released EntryEventImpl event = getPartitionedRegion().newDestroyEntryEvent(key,
 	  null);
-	event.setEventId(new EventID(cache.getSystem()));
 	try {
+	  event.setEventId(new EventID(cache.getSystem()));
 	  event.setRegion(this);
 	  basicDestroy(event, true, null);
 	  checkReadiness();
@@ -531,8 +532,6 @@ public class BucketRegionQueue extends AbstractBucketRegionQueue {
             + key, rde);
       }
     } finally {
-	  //merge42180: are we considering offheap in cedar. Comment freeOffHeapReference intentionally
-	  //event.freeOffHeapReferences();
       event.release();
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DestroyOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DestroyOperation.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DestroyOperation.java
index b0ac963..e267190 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DestroyOperation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DestroyOperation.java
@@ -34,6 +34,7 @@ import com.gemstone.gemfire.distributed.internal.DistributionManager;
 import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID;
 import com.gemstone.gemfire.internal.cache.versions.ConcurrentCacheModificationException;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * Handles distribution messaging for destroying an entry in a region.
@@ -125,6 +126,7 @@ public class DestroyOperation extends DistributedCacheOperation
     }
 
     @Override
+    @Retained
     protected final InternalCacheEvent createEvent(DistributedRegion rgn)
         throws EntryNotFoundException {
       if (rgn.keyRequiresRegionContext()) {
@@ -151,9 +153,10 @@ public class DestroyOperation extends DistributedCacheOperation
       }
     }
 
+    @Retained
     EntryEventImpl createEntryEvent(DistributedRegion rgn)
     {
-      EntryEventImpl event = EntryEventImpl.create(rgn,
+      @Retained EntryEventImpl event = EntryEventImpl.create(rgn,
           getOperation(), this.key, null, this.callbackArg, true, getSender());
 //      event.setNewEventId(); Don't set the event here...
       setOldValueInEvent(event);
@@ -258,6 +261,7 @@ public class DestroyOperation extends DistributedCacheOperation
     }
     
     @Override
+    @Retained
     EntryEventImpl createEntryEvent(DistributedRegion rgn)
     {
       EntryEventImpl event = EntryEventImpl.create(rgn, getOperation(), 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistPeerTXStateStub.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistPeerTXStateStub.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistPeerTXStateStub.java
index cd17770..5c53df1 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistPeerTXStateStub.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistPeerTXStateStub.java
@@ -259,6 +259,7 @@ public final class DistPeerTXStateStub extends PeerTXStateStub implements
   public void postPutAll(DistributedPutAllOperation putallOp,
       VersionedObjectList successfulPuts, LocalRegion region) {
     super.postPutAll(putallOp, successfulPuts, region);
+    // TODO DISTTX: event is never released
     EntryEventImpl event = EntryEventImpl.createPutAllEvent(putallOp, region,
         Operation.PUTALL_CREATE, putallOp.getBaseEvent().getKey(), putallOp
             .getBaseEvent().getValue());
@@ -271,6 +272,7 @@ public final class DistPeerTXStateStub extends PeerTXStateStub implements
   public void postRemoveAll(DistributedRemoveAllOperation removeAllOp,
       VersionedObjectList successfulOps, LocalRegion region) {
     super.postRemoveAll(removeAllOp, successfulOps, region);
+    // TODO DISTTX: event is never released
     EntryEventImpl event = EntryEventImpl.createRemoveAllEvent(removeAllOp,
         region, removeAllOp.getBaseEvent().getKey());
     event.setEventId(removeAllOp.getBaseEvent().getEventId());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXState.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXState.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXState.java
index 19cc175..f8475ae 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXState.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXState.java
@@ -44,6 +44,7 @@ import com.gemstone.gemfire.internal.cache.tx.DistTxKeyInfo;
 import com.gemstone.gemfire.internal.cache.tx.DistTxEntryEvent;
 import com.gemstone.gemfire.internal.cache.versions.RegionVersionVector;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 /**
  * TxState on a datanode VM
@@ -568,7 +569,7 @@ public class DistTXState extends TXState {
         InternalDistributedMember myId = theRegion.getDistributionManager()
             .getDistributionManagerId();
         for (int i = 0; i < putallOp.putAllDataSize; ++i) {
-          EntryEventImpl ev = PutAllPRMessage.getEventFromEntry(theRegion,
+          @Released EntryEventImpl ev = PutAllPRMessage.getEventFromEntry(theRegion,
               myId, myId, i, putallOp.putAllData, false, putallOp
                   .getBaseEvent().getContext(), false, !putallOp.getBaseEvent()
                   .isGenerateCallbacks(), false);
@@ -628,10 +629,11 @@ public class DistTXState extends TXState {
         InternalDistributedMember myId = theRegion.getDistributionManager()
             .getDistributionManagerId();
         for (int i = 0; i < op.removeAllDataSize; ++i) {
-          EntryEventImpl ev = RemoveAllPRMessage.getEventFromEntry(theRegion,
+          @Released EntryEventImpl ev = RemoveAllPRMessage.getEventFromEntry(theRegion,
               myId, myId, i, op.removeAllData, false, op.getBaseEvent()
                   .getContext(), false, !op.getBaseEvent()
                   .isGenerateCallbacks());
+          try {
           ev.setRemoveAllOperation(op);
           // below if condition returns true on secondary when TXState is
           // updated in preCommit only on secondary
@@ -664,6 +666,9 @@ public class DistTXState extends TXState {
           } catch (EntryNotFoundException ignore) {
           }
           successfulOps.addKeyAndVersion(op.removeAllData[i].key, null);
+          } finally {
+            ev.release();
+          }
         }
       }
     }, op.getBaseEvent().getEventId());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXStateOnCoordinator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXStateOnCoordinator.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXStateOnCoordinator.java
index 10d892a..33bec1c 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXStateOnCoordinator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXStateOnCoordinator.java
@@ -240,6 +240,7 @@ public final class DistTXStateOnCoordinator extends DistTXState implements
   public void postPutAll(DistributedPutAllOperation putallOp,
       VersionedObjectList successfulPuts, LocalRegion region) {
     super.postPutAll(putallOp, successfulPuts, region);
+    // TODO DISTTX: event is never released
     EntryEventImpl event = EntryEventImpl.createPutAllEvent(putallOp, region,
         Operation.PUTALL_CREATE, putallOp.getBaseEvent().getKey(), putallOp
             .getBaseEvent().getValue());
@@ -252,6 +253,7 @@ public final class DistTXStateOnCoordinator extends DistTXState implements
   public void postRemoveAll(DistributedRemoveAllOperation removeAllOp,
       VersionedObjectList successfulOps, LocalRegion region) {
     super.postRemoveAll(removeAllOp, successfulOps, region);
+    // TODO DISTTX: event is never released
     EntryEventImpl event = EntryEventImpl.createRemoveAllEvent(removeAllOp,
         region, removeAllOp.getBaseEvent().getKey());
     event.setEventId(removeAllOp.getBaseEvent().getEventId());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXStateProxyImplOnCoordinator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXStateProxyImplOnCoordinator.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXStateProxyImplOnCoordinator.java
index 75a1df7..67d63b1 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXStateProxyImplOnCoordinator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistTXStateProxyImplOnCoordinator.java
@@ -896,6 +896,7 @@ public class DistTXStateProxyImplOnCoordinator extends DistTXStateProxyImpl {
         DistributedPutAllOperation putAllForBucket = 
             bucketToPutallMap.get(bucketId);;
         if (putAllForBucket == null) {
+          // TODO DISTTX: event is never released
           EntryEventImpl event = EntryEventImpl.createPutAllEvent(null, region,
               Operation.PUTALL_CREATE, key,
               putallOp.putAllData[i].getValue());
@@ -976,6 +977,7 @@ public class DistTXStateProxyImplOnCoordinator extends DistTXStateProxyImpl {
         DistributedRemoveAllOperation removeAllForBucket = 
             bucketToRemoveAllMap.get(bucketId);
         if (removeAllForBucket == null) {
+          // TODO DISTTX: event is never released
           EntryEventImpl event = EntryEventImpl.createRemoveAllEvent(op, region, key);
           event.setEventId(op.removeAllData[i].getEventID());
           removeAllForBucket = new DistributedRemoveAllOperation(

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedCacheOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedCacheOperation.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedCacheOperation.java
index 79ae4ee..063f823 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedCacheOperation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedCacheOperation.java
@@ -74,6 +74,7 @@ import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.internal.sequencelog.EntryLogger;
 
@@ -1104,7 +1105,6 @@ public abstract class DistributedCacheOperation {
     protected void basicProcess(DistributionManager dm, LocalRegion lclRgn) {
       Throwable thr = null;
       boolean sendReply = true;
-      InternalCacheEvent event = null;
 
       if (logger.isTraceEnabled()) {
         logger.trace("DistributedCacheOperation.basicProcess: {}", this);
@@ -1140,7 +1140,7 @@ public abstract class DistributedCacheOperation {
           return;
         }
 
-        event = createEvent(rgn);
+        @Released InternalCacheEvent event = createEvent(rgn);
         try {
         boolean isEntry = event.getOperation().isEntry();
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedPutAllOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedPutAllOperation.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedPutAllOperation.java
index 2e83cb8..4b4d4d3 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedPutAllOperation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedPutAllOperation.java
@@ -61,6 +61,8 @@ import com.gemstone.gemfire.internal.cache.versions.VersionSource;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * Handles distribution of a Region.putall operation.
@@ -193,8 +195,9 @@ public class DistributedPutAllOperation extends AbstractUpdateOperation
       public boolean hasNext() {
         return DistributedPutAllOperation.this.putAllDataSize > position;
       };
+      @Retained
       public Object next() {
-        EntryEventImpl ev = getEventForPosition(position);
+        @Retained EntryEventImpl ev = getEventForPosition(position);
         position++;
         return ev;
       };
@@ -214,7 +217,7 @@ public class DistributedPutAllOperation extends AbstractUpdateOperation
     }
   }
   
-  
+  @Retained
   public EntryEventImpl getEventForPosition(int position) {
     PutAllEntryData entry = this.putAllData[position];
     if (entry == null) {
@@ -224,7 +227,7 @@ public class DistributedPutAllOperation extends AbstractUpdateOperation
       return entry.event;
     }
     LocalRegion region = (LocalRegion)this.event.getRegion();
-    EntryEventImpl ev = EntryEventImpl.create(
+    @Retained EntryEventImpl ev = EntryEventImpl.create(
         region,
         entry.getOp(),
         entry.getKey(), null/* value */, this.event.getCallbackArgument(),
@@ -813,13 +816,17 @@ public class DistributedPutAllOperation extends AbstractUpdateOperation
     }
     FilterRoutingInfo consolidated = new FilterRoutingInfo();
     for (int i=0; i<this.putAllData.length; i++) {
-      EntryEventImpl ev = getEventForPosition(i);
+      @Released EntryEventImpl ev = getEventForPosition(i);
       if (ev != null) {
+        try {
         FilterRoutingInfo eventRouting = advisor.adviseFilterRouting(ev, cacheOpRecipients);
         if (eventRouting != null) {
           consolidated.addFilterInfo(eventRouting);
         }
         putAllData[i].filterRouting = eventRouting;
+        } finally {
+          ev.release();
+        }
       }
     }
     // we need to create routing information for each PUT event
@@ -1093,11 +1100,12 @@ public class DistributedPutAllOperation extends AbstractUpdateOperation
      * basicOperateOnRegion
      */
     @Override
+    @Retained
     protected InternalCacheEvent createEvent(DistributedRegion rgn)
     throws EntryNotFoundException
     {
       // Gester: We have to specify eventId for the message of MAP
-      EntryEventImpl event = EntryEventImpl.create(
+      @Retained EntryEventImpl event = EntryEventImpl.create(
           rgn,
           Operation.PUTALL_UPDATE /* op */, null /* key */, null/* value */,
           this.callbackArg, true /* originRemote */, getSender());
@@ -1133,7 +1141,7 @@ public class DistributedPutAllOperation extends AbstractUpdateOperation
      */
     public void doEntryPut(PutAllEntryData entry, DistributedRegion rgn,
         boolean requiresRegionContext, boolean fetchFromHDFS, boolean isPutDML) {
-      EntryEventImpl ev = PutAllMessage.createEntryEvent(entry, getSender(), 
+      @Released EntryEventImpl ev = PutAllMessage.createEntryEvent(entry, getSender(), 
           this.context, rgn,
           requiresRegionContext, this.possibleDuplicate,
           this.needsRouting, this.callbackArg, true, skipCallbacks);
@@ -1164,6 +1172,7 @@ public class DistributedPutAllOperation extends AbstractUpdateOperation
      * @param callbackArg
      * @return the event to be used in applying the element
      */
+    @Retained
     public static EntryEventImpl createEntryEvent(PutAllEntryData entry,
         InternalDistributedMember sender, ClientProxyMembershipID context,
         DistributedRegion rgn, boolean requiresRegionContext, 
@@ -1174,7 +1183,7 @@ public class DistributedPutAllOperation extends AbstractUpdateOperation
         ((KeyWithRegionContext)key).setRegionContext(rgn);
       }
       EventID evId = entry.getEventID();
-      EntryEventImpl ev = EntryEventImpl.create(rgn, entry.getOp(),
+      @Retained EntryEventImpl ev = EntryEventImpl.create(rgn, entry.getOp(),
           key, null/* value */, callbackArg,
           originRemote, sender, !skipCallbacks,
           evId);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
index 467efc6..addba8e 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
@@ -121,6 +121,7 @@ import com.gemstone.gemfire.internal.cache.wan.parallel.ConcurrentParallelGatewa
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 import com.gemstone.gemfire.internal.sequencelog.RegionLogger;
 import com.gemstone.gemfire.internal.util.concurrent.StoppableCountDownLatch;
@@ -2442,13 +2443,12 @@ public class DistributedRegion extends LocalRegion implements
     }
     long lastModified = 0L;
     boolean fromServer = false;
-    EntryEventImpl event = null;
+    @Released EntryEventImpl event = null;
     @Retained Object result = null;
     try {
     {
       if (this.srp != null) {
-        EntryEventImpl holder = EntryEventImpl.createVersionTagHolder();
-        try {
+        VersionTagHolder holder = new VersionTagHolder();
         Object value = this.srp.get(key, aCallbackArgument, holder);
         fromServer = value != null;
         if (fromServer) {
@@ -2461,9 +2461,6 @@ public class DistributedRegion extends LocalRegion implements
             clientEvent.setVersionTag(holder.getVersionTag());
           }
         }
-        } finally {
-          holder.release();
-        }
       }
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRemoveAllOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRemoveAllOperation.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRemoveAllOperation.java
index 70d39dc..34889aa 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRemoveAllOperation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRemoveAllOperation.java
@@ -55,6 +55,8 @@ import com.gemstone.gemfire.internal.cache.versions.DiskVersionTag;
 import com.gemstone.gemfire.internal.cache.versions.VersionSource;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * Handles distribution of a Region.removeAll operation.
@@ -175,8 +177,9 @@ public class DistributedRemoveAllOperation extends AbstractUpdateOperation // TO
       public boolean hasNext() {
         return DistributedRemoveAllOperation.this.removeAllDataSize > position;
       };
+      @Retained
       public Object next() {
-        EntryEventImpl ev = getEventForPosition(position);
+        @Retained EntryEventImpl ev = getEventForPosition(position);
         position++;
         return ev;
       };
@@ -196,6 +199,7 @@ public class DistributedRemoveAllOperation extends AbstractUpdateOperation // TO
     }
   }
 
+  @Retained
   public EntryEventImpl getEventForPosition(int position) {
     RemoveAllEntryData entry = this.removeAllData[position];
     if (entry == null) {
@@ -205,7 +209,7 @@ public class DistributedRemoveAllOperation extends AbstractUpdateOperation // TO
       return entry.event;
     }
     LocalRegion region = (LocalRegion)this.event.getRegion();
-    EntryEventImpl ev = EntryEventImpl.create(
+    @Retained EntryEventImpl ev = EntryEventImpl.create(
         region,
         entry.getOp(),
         entry.getKey(), null/* value */, this.event.getCallbackArgument(),
@@ -568,13 +572,17 @@ public class DistributedRemoveAllOperation extends AbstractUpdateOperation // TO
     }
     FilterRoutingInfo consolidated = new FilterRoutingInfo();
     for (int i=0; i<this.removeAllData.length; i++) {
-      EntryEventImpl ev = getEventForPosition(i);
+      @Released EntryEventImpl ev = getEventForPosition(i);
       if (ev != null) {
+        try {
         FilterRoutingInfo eventRouting = advisor.adviseFilterRouting(ev, cacheOpRecipients);
         if (eventRouting != null) {
           consolidated.addFilterInfo(eventRouting);
         }
         removeAllData[i].filterRouting = eventRouting;
+        } finally {
+          ev.release();
+        }
       }
     }
     // we need to create routing information for each PUT event
@@ -838,11 +846,12 @@ public class DistributedRemoveAllOperation extends AbstractUpdateOperation // TO
      * basicOperateOnRegion
      */
     @Override
+    @Retained
     protected InternalCacheEvent createEvent(DistributedRegion rgn)
     throws EntryNotFoundException
     {
       // Gester: We have to specify eventId for the message of MAP
-      EntryEventImpl event = EntryEventImpl.create(
+      @Retained EntryEventImpl event = EntryEventImpl.create(
           rgn,
           Operation.REMOVEALL_DESTROY, null /* key */, null/* value */,
           this.callbackArg, true /* originRemote */, getSender());
@@ -878,7 +887,7 @@ public class DistributedRemoveAllOperation extends AbstractUpdateOperation // TO
      */
     public void doEntryRemove(RemoveAllEntryData entry, DistributedRegion rgn,
         boolean requiresRegionContext) {
-      EntryEventImpl ev = RemoveAllMessage.createEntryEvent(entry, getSender(), 
+      @Released EntryEventImpl ev = RemoveAllMessage.createEntryEvent(entry, getSender(), 
           this.context, rgn,
           requiresRegionContext, this.possibleDuplicate,
           this.needsRouting, this.callbackArg, true, skipCallbacks);
@@ -918,6 +927,7 @@ public class DistributedRemoveAllOperation extends AbstractUpdateOperation // TO
      * @param callbackArg
      * @return the event to be used in applying the element
      */
+    @Retained
     public static EntryEventImpl createEntryEvent(RemoveAllEntryData entry,
         InternalDistributedMember sender, ClientProxyMembershipID context,
         DistributedRegion rgn, boolean requiresRegionContext, 
@@ -928,7 +938,7 @@ public class DistributedRemoveAllOperation extends AbstractUpdateOperation // TO
         ((KeyWithRegionContext)key).setRegionContext(rgn);
       }
       EventID evId = entry.getEventID();
-      EntryEventImpl ev = EntryEventImpl.create(rgn, entry.getOp(),
+      @Retained EntryEventImpl ev = EntryEventImpl.create(rgn, entry.getOp(),
           key, null/* value */, callbackArg,
           originRemote, sender, !skipCallbacks,
           evId);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
index 3c87654..e3458e7 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
@@ -214,29 +214,6 @@ public class EntryEventImpl
   }
   
   /**
-   * create a new entry event that will be used for conveying version information
-   * and anything else of use while processing another event
-   * @return the empty event object
-   */
-  @Retained
-  public static EntryEventImpl createVersionTagHolder() {
-    return createVersionTagHolder(null);
-  }
-  
-  /**
-   * create a new entry event that will be used for conveying version information
-   * and anything else of use while processing another event
-   * @return the empty event object
-   */
-  @Retained
-  public static EntryEventImpl createVersionTagHolder(VersionTag tag) {
-    EntryEventImpl result = new EntryEventImpl();
-    result.setVersionTag(tag);
-    result.disallowOffHeapValues();
-    return result;
-  }
-
-  /**
    * Reads the contents of this message from the given input.
    */
   public void fromData(DataInput in) throws IOException, ClassNotFoundException {
@@ -389,18 +366,6 @@ public class EntryEventImpl
   public EntryEventImpl(Object key2) {
     this.keyInfo = new KeyInfo(key2, null, null);
   }
-  
-  /**
-   * This constructor is used to create a bridge event in server-side
-   * command classes.  Events created with this are not intended to be
-   * used in cache operations.
-   * @param id the identity of the client's event
-   */
-  @Retained
-  public EntryEventImpl(EventID id) {
-    this.eventID = id;
-    this.offHeapOk = false;
-  }
 
   /**
    * Creates and returns an EntryEventImpl.  Generates and assigns a bucket id to the
@@ -493,7 +458,7 @@ public class EntryEventImpl
       DistributedPutAllOperation putAllOp, LocalRegion region,
       Operation entryOp, Object entryKey, @Retained(ENTRY_EVENT_NEW_VALUE) Object entryNewValue)
   {
-    EntryEventImpl e;
+    @Retained EntryEventImpl e;
     if (putAllOp != null) {
       EntryEventImpl event = putAllOp.getBaseEvent();
       if (event.isBridgeEvent()) {
@@ -515,11 +480,12 @@ public class EntryEventImpl
     return e;
   }
   
+  @Retained
   protected static EntryEventImpl createRemoveAllEvent(
       DistributedRemoveAllOperation op, 
       LocalRegion region,
       Object entryKey) {
-    EntryEventImpl e;
+    @Retained EntryEventImpl e;
     final Operation entryOp = Operation.REMOVEALL_DESTROY;
     if (op != null) {
       EntryEventImpl event = op.getBaseEvent();
@@ -2995,6 +2961,7 @@ public class EntryEventImpl
   }
   
   /** returns a copy of this event with the additional fields for WAN conflict resolution */
+  @Retained
   public TimestampedEntryEvent getTimestampedEvent(
       final int newDSID, final int oldDSID,
       final long newTimestamp, final long oldTimestamp) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryExpiryTask.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryExpiryTask.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryExpiryTask.java
index cba7802..64b669a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryExpiryTask.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryExpiryTask.java
@@ -35,6 +35,7 @@ import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.TimeoutException;
 import com.gemstone.gemfire.internal.InternalStatisticsDisabledException;
 import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 public class EntryExpiryTask extends ExpiryTask {
 
@@ -120,7 +121,7 @@ public class EntryExpiryTask extends ExpiryTask {
     RegionEntry re = getCheckedRegionEntry();
     Object key = re.getKey();
     LocalRegion lr = getLocalRegion();
-    EntryEventImpl event = EntryEventImpl.create(
+    @Released EntryEventImpl event = EntryEventImpl.create(
         lr, Operation.EXPIRE_DESTROY, key, null,
         createExpireEntryCallback(lr, key), false, lr.getMyId());
     try {
@@ -142,7 +143,7 @@ public class EntryExpiryTask extends ExpiryTask {
     RegionEntry re = getCheckedRegionEntry();
     Object key = re.getKey();
     LocalRegion lr = getLocalRegion();
-    EntryEventImpl event = EntryEventImpl.create(lr,
+    @Released EntryEventImpl event = EntryEventImpl.create(lr,
         Operation.EXPIRE_INVALIDATE, key, null,
         createExpireEntryCallback(lr, key), false, lr.getMyId());
     try {
@@ -162,7 +163,7 @@ public class EntryExpiryTask extends ExpiryTask {
     RegionEntry re = getCheckedRegionEntry();
     Object key = re.getKey();
     LocalRegion lr = getLocalRegion();
-    EntryEventImpl event = EntryEventImpl.create(lr,
+    @Released EntryEventImpl event = EntryEventImpl.create(lr,
         Operation.EXPIRE_LOCAL_DESTROY, key, null,
         createExpireEntryCallback(lr, key), false, lr.getMyId());
     try {
@@ -182,7 +183,7 @@ public class EntryExpiryTask extends ExpiryTask {
     RegionEntry re = getCheckedRegionEntry();
     Object key = re.getKey();
     LocalRegion lr = getLocalRegion();
-    EntryEventImpl event = EntryEventImpl.create(lr,
+    @Released EntryEventImpl event = EntryEventImpl.create(lr,
         Operation.EXPIRE_LOCAL_INVALIDATE, key, null,
         createExpireEntryCallback(lr, key), false, lr.getMyId());
     try {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EventIDHolder.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EventIDHolder.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EventIDHolder.java
new file mode 100644
index 0000000..6dd8586
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EventIDHolder.java
@@ -0,0 +1,35 @@
+/*
+ * 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 com.gemstone.gemfire.internal.cache;
+
+/**
+ * This class is an event that just holds an EventID.
+ * Unlike other EntryEventImpls this class does not need to be released
+ * since its values are never off-heap.
+ */
+public class EventIDHolder extends EntryEventImpl {
+  /*
+   * This constructor is used to create a bridge event in server-side
+   * command classes.  Events created with this are not intended to be
+   * used in cache operations.
+   * @param id the identity of the client's event
+   */
+  public EventIDHolder(EventID id) {
+    setEventId(id);
+    disallowOffHeapValues();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/FilterProfile.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/FilterProfile.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/FilterProfile.java
index 90c4dc0..65e7a84 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/FilterProfile.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/FilterProfile.java
@@ -73,6 +73,7 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.util.concurrent.CopyOnWriteHashMap;
 
 /**
@@ -1173,7 +1174,8 @@ public class FilterProfile implements DataSerializableFixedID {
       for (int idx=0; idx < size; idx++) {
         PutAllEntryData pEntry = putAllData[idx];
         if (pEntry != null) {
-          final EntryEventImpl ev = dpao.getEventForPosition(idx);
+          @Released final EntryEventImpl ev = dpao.getEventForPosition(idx);
+          try {
           FilterRoutingInfo fri = pEntry.filterRouting;
           FilterInfo fi = null;
           if (fri != null) {
@@ -1212,6 +1214,9 @@ public class FilterProfile implements DataSerializableFixedID {
             fi.setInterestedClientsInv(clientsInv);
           }
           ev.setLocalFilterInfo(fi);
+          } finally {
+            ev.release();
+          }
         }
       }
     }
@@ -1230,7 +1235,8 @@ public class FilterProfile implements DataSerializableFixedID {
      for (int idx=0; idx < size; idx++) {
        RemoveAllEntryData pEntry = removeAllData[idx];
        if (pEntry != null) {
-         final EntryEventImpl ev = op.getEventForPosition(idx);
+         @Released final EntryEventImpl ev = op.getEventForPosition(idx);
+         try {
          FilterRoutingInfo fri = pEntry.filterRouting;
          FilterInfo fi = null;
          if (fri != null) {
@@ -1272,6 +1278,9 @@ public class FilterProfile implements DataSerializableFixedID {
          //          this.region.getLogWriterI18n().fine("setting event routing to " + fi);
          //        }
          ev.setLocalFilterInfo(fi);
+         } finally {
+           ev.release();
+         }
        }
      }
    }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/HARegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/HARegion.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/HARegion.java
index fa29bf3..3896800 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/HARegion.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/HARegion.java
@@ -47,6 +47,7 @@ import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID;
 import com.gemstone.gemfire.internal.cache.tier.sockets.HAEventWrapper;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 
 /**
  * This region is being implemented to suppress distribution of puts and to
@@ -229,7 +230,7 @@ public final class HARegion extends DistributedRegion
       throws TimeoutException, CacheWriterException {
     checkReadiness();
 
-    EntryEventImpl event = EntryEventImpl.create(this, Operation.UPDATE, key,
+    @Released EntryEventImpl event = EntryEventImpl.create(this, Operation.UPDATE, key,
         value, aCallbackArgument, false, getMyId());
     try {
 
@@ -409,7 +410,7 @@ public final class HARegion extends DistributedRegion
             op = Operation.LOCAL_LOAD_UPDATE;
           }
 
-          EntryEventImpl event = EntryEventImpl.create(
+          @Released EntryEventImpl event = EntryEventImpl.create(
               this, op, key, value,
               aCallbackArgument, false, getMyId(), generateCallbacks);
           try {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/InitialImageOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/InitialImageOperation.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/InitialImageOperation.java
index a72ca8e..b43ba2d 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/InitialImageOperation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/InitialImageOperation.java
@@ -931,7 +931,7 @@ public class InitialImageOperation  {
                           .create((byte[])tmpValue);
                     }
                     // dummy EntryEvent to pass for SQLF index maintenance
-                    final EntryEventImpl ev = EntryEventImpl.create(this.region,
+                    @Released final EntryEventImpl ev = EntryEventImpl.create(this.region,
                         Operation.CREATE, null, null, null, true, null, false, false);
                     try {
                     ev.setKeyInfo(this.region.getKeyInfo(entry.key,

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/InvalidateOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/InvalidateOperation.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/InvalidateOperation.java
index de6adda..6e1d91e 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/InvalidateOperation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/InvalidateOperation.java
@@ -34,6 +34,7 @@ import com.gemstone.gemfire.distributed.internal.DistributionManager;
 import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID;
 import com.gemstone.gemfire.internal.cache.versions.ConcurrentCacheModificationException;
 import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 /**
  * Handles distribution messaging for invalidating an entry in a region.
@@ -108,12 +109,13 @@ public class InvalidateOperation extends DistributedCacheOperation
     }
 
     @Override
+    @Retained
     protected InternalCacheEvent createEvent(DistributedRegion rgn)
         throws EntryNotFoundException {
       if (rgn.keyRequiresRegionContext()) {
         ((KeyWithRegionContext)this.key).setRegionContext(rgn);
       }
-      EntryEventImpl ev = EntryEventImpl.create(
+      @Retained EntryEventImpl ev = EntryEventImpl.create(
          rgn, getOperation(), this.key,
          null, this.callbackArg, true, getSender());
       ev.setEventId(this.eventId);
@@ -194,6 +196,7 @@ public class InvalidateOperation extends DistributedCacheOperation
     transient ClientProxyMembershipID context;
 
     @Override
+    @Retained
     protected InternalCacheEvent createEvent(DistributedRegion rgn)
       throws EntryNotFoundException  {
       EntryEventImpl event = (EntryEventImpl)super.createEvent(rgn);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70221350/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
index 3ff48bb..4360b2a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
@@ -206,6 +206,7 @@ import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.internal.sequencelog.EntryLogger;
@@ -1119,12 +1120,12 @@ public class LocalRegion extends AbstractRegion
   public final void create(Object key, Object value, Object aCallbackArgument)
       throws TimeoutException, EntryExistsException, CacheWriterException {
     long startPut = CachePerfStats.getStatTime();
-    EntryEventImpl event = newCreateEntryEvent(key, value, aCallbackArgument);
+    @Released EntryEventImpl event = newCreateEntryEvent(key, value, aCallbackArgument);
     validatedCreate(event, startPut);
-    // TODO OFFHEAP: validatedCreate calls freeOffHeapResources
+    // TODO OFFHEAP: validatedCreate calls release
   }
 
-  public final void validatedCreate(EntryEventImpl event, long startPut)
+  public final void validatedCreate(@Released EntryEventImpl event, long startPut)
       throws TimeoutException, EntryExistsException, CacheWriterException {
 
     try {
@@ -1152,14 +1153,13 @@ public class LocalRegion extends AbstractRegion
         }
       }
     } finally {
-
       event.release();
-
     }
   }
 
   // split into a separate newCreateEntryEvent since SQLFabric may need to
   // manipulate event before doing the put (e.g. posDup flag)
+  @Retained
   public final EntryEventImpl newCreateEntryEvent(Object key, Object value,
       Object aCallbackArgument) {
 
@@ -1191,16 +1191,16 @@ public class LocalRegion extends AbstractRegion
 
   public final Object destroy(Object key, Object aCallbackArgument)
       throws TimeoutException, EntryNotFoundException, CacheWriterException {
-    EntryEventImpl event = newDestroyEntryEvent(key, aCallbackArgument);
+    @Released EntryEventImpl event = newDestroyEntryEvent(key, aCallbackArgument);
     return validatedDestroy(key, event);
-    // TODO OFFHEAP: validatedDestroy calls freeOffHeapResources
+    // TODO OFFHEAP: validatedDestroy calls release
   }
 
   /**
    * Destroys entry without performing validations. Call this after validating
    * key, callback arg, and runtime state.
    */
-  public Object validatedDestroy(Object key, EntryEventImpl event)
+  public Object validatedDestroy(Object key, @Released EntryEventImpl event)
       throws TimeoutException, EntryNotFoundException, CacheWriterException
  {
     try {
@@ -1221,6 +1221,7 @@ public class LocalRegion extends AbstractRegion
 
   // split into a separate newDestroyEntryEvent since SQLFabric may need to
   // manipulate event before doing the put (e.g. posDup flag)
+  @Retained
   public final EntryEventImpl newDestroyEntryEvent(Object key,
       Object aCallbackArgument) {
     validateKey(key);
@@ -1731,15 +1732,15 @@ public class LocalRegion extends AbstractRegion
   public Object put(Object key, Object value, Object aCallbackArgument)
       throws TimeoutException, CacheWriterException {
     long startPut = CachePerfStats.getStatTime();
-    EntryEventImpl event = newUpdateEntryEvent(key, value, aCallbackArgument);
+    @Released EntryEventImpl event = newUpdateEntryEvent(key, value, aCallbackArgument);
      //Since Sqlfire directly calls validatedPut, the freeing is done in
     // validatedPut
      return validatedPut(event, startPut);
-     // TODO OFFHEAP: validatedPut calls freeOffHeapResources
+     // TODO OFFHEAP: validatedPut calls release
     
   }
 
-  public final Object validatedPut(EntryEventImpl event, long startPut)
+  public final Object validatedPut(@Released EntryEventImpl event, long startPut)
       throws TimeoutException, CacheWriterException {
 
     try {
@@ -1776,6 +1777,7 @@ public class LocalRegion extends AbstractRegion
 
   // split into a separate newUpdateEntryEvent since SQLFabric may need to
   // manipulate event before doing the put (e.g. posDup flag)
+  @Retained
   public final EntryEventImpl newUpdateEntryEvent(Object key, Object value,
       Object aCallbackArgument) {
 
@@ -1792,7 +1794,7 @@ public class LocalRegion extends AbstractRegion
     // was modified to call the other EntryEventImpl constructor so that
     // an id will be generated by default. Null was passed in anyway.
     //   generate EventID
-    final EntryEventImpl event = EntryEventImpl.create(
+    @Retained final EntryEventImpl event = EntryEventImpl.create(
         this, Operation.UPDATE, key,
         value, aCallbackArgument, false, getMyId());
     boolean eventReturned = false;
@@ -1808,6 +1810,7 @@ public class LocalRegion extends AbstractRegion
    * Creates an EntryEventImpl that is optimized to not fetch data from HDFS.
    * This is meant to be used by PUT dml from GemFireXD.
    */
+  @Retained
   public final EntryEventImpl newPutEntryEvent(Object key, Object value,
       Object aCallbackArgument) {
     EntryEventImpl ev = newUpdateEntryEvent(key, value, aCallbackArgument);
@@ -2392,7 +2395,7 @@ public class LocalRegion extends AbstractRegion
   protected void validatedInvalidate(Object key, Object aCallbackArgument)
       throws TimeoutException, EntryNotFoundException
   {
-    EntryEventImpl event = EntryEventImpl.create(
+    @Released EntryEventImpl event = EntryEventImpl.create(
         this, Operation.INVALIDATE,
         key, null, aCallbackArgument, false, getMyId());
     try {
@@ -2411,7 +2414,7 @@ public class LocalRegion extends AbstractRegion
     validateKey(key);
     checkReadiness();
     checkForNoAccess();
-    EntryEventImpl event = EntryEventImpl.create(
+    @Released EntryEventImpl event = EntryEventImpl.create(
         this,
         Operation.LOCAL_DESTROY, key, null, aCallbackArgument, false, getMyId());
     if (generateEventID()) {
@@ -2482,7 +2485,7 @@ public class LocalRegion extends AbstractRegion
     checkReadiness();
     checkForNoAccess();
 
-    EntryEventImpl event = EntryEventImpl.create(
+    @Released EntryEventImpl event = EntryEventImpl.create(
         this,
         Operation.LOCAL_INVALIDATE, key, null/* newValue */, callbackArgument,
         false, getMyId());
@@ -3020,7 +3023,7 @@ public class LocalRegion extends AbstractRegion
     final Object aCallbackArgument = keyInfo.getCallbackArg();
     Object value = null;
     boolean fromServer = false;
-    EntryEventImpl holder = null;
+    VersionTagHolder holder = null;
     
     /*
      * First lets try the server
@@ -3028,13 +3031,9 @@ public class LocalRegion extends AbstractRegion
     {
       ServerRegionProxy mySRP = getServerProxy();
       if (mySRP != null) {
-        holder = EntryEventImpl.createVersionTagHolder();
-        try {
-          value = mySRP.get(key, aCallbackArgument, holder);
-          fromServer = value != null;
-        } finally {
-          holder.release();
-        }
+        holder = new VersionTagHolder();
+        value = mySRP.get(key, aCallbackArgument, holder);
+        fromServer = value != null;
       }
     }
     
@@ -3085,7 +3084,7 @@ public class LocalRegion extends AbstractRegion
         op = Operation.LOCAL_LOAD_UPDATE;
       }
 
-      EntryEventImpl event
+      @Released EntryEventImpl event
         = EntryEventImpl.create(this, op, key, value, aCallbackArgument,
                              false, getMyId(), generateCallbacks);
       try {
@@ -4434,7 +4433,7 @@ public class LocalRegion extends AbstractRegion
     }
     checkReadiness();
     validateKey(key);
-    EntryEventImpl event = EntryEventImpl.create(this, Operation.LOCAL_DESTROY,
+    @Released EntryEventImpl event = EntryEventImpl.create(this, Operation.LOCAL_DESTROY,
         key, false, getMyId(), false /* generateCallbacks */, true);
     try {
       basicDestroy(event,
@@ -5580,7 +5579,7 @@ public class LocalRegion extends AbstractRegion
     //to get Hash. If the partitioning column is different from primary key, 
     //the resolver for Sqlfabric is not able to obtain the hash object used for creation of KeyInfo  
      
-    final EntryEventImpl event = EntryEventImpl.create(this, Operation.CREATE, key,
+    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.CREATE, key,
        value, callbackArg,  false /* origin remote */, client.getDistributedMember(),
         true /* generateCallbacks */,
         eventId);
@@ -5654,7 +5653,7 @@ public class LocalRegion extends AbstractRegion
       }
     }
    
-    final EntryEventImpl event = EntryEventImpl.create(this, Operation.UPDATE, key,
+    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.UPDATE, key,
         null /* new value */, callbackArg,
         false /* origin remote */, memberId.getDistributedMember(),
         true /* generateCallbacks */,
@@ -5801,7 +5800,7 @@ public class LocalRegion extends AbstractRegion
       concurrencyConfigurationCheck(versionTag);
 
       // Create an event and put the entry
-      EntryEventImpl event =
+      @Released EntryEventImpl event =
         EntryEventImpl.create(this,
                            Operation.INVALIDATE,
                            key, null /* newValue */,
@@ -5856,7 +5855,7 @@ public class LocalRegion extends AbstractRegion
       concurrencyConfigurationCheck(versionTag);
 
       // Create an event and destroy the entry
-      EntryEventImpl event =
+      @Released EntryEventImpl event =
         EntryEventImpl.create(this,
                            Operation.DESTROY,
                            key, null /* newValue */,
@@ -5938,7 +5937,7 @@ public class LocalRegion extends AbstractRegion
     }
 
     // Create an event and put the entry
-    final EntryEventImpl event = EntryEventImpl.create(this, Operation.DESTROY, key,
+    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.DESTROY, key,
         null /* new value */, callbackArg,
         false /* origin remote */, memberId.getDistributedMember(),
         true /* generateCallbacks */,
@@ -5978,7 +5977,7 @@ public class LocalRegion extends AbstractRegion
     }
 
     // Create an event and put the entry
-    final EntryEventImpl event = EntryEventImpl.create(this, Operation.INVALIDATE, key,
+    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.INVALIDATE, key,
         null /* new value */, callbackArg,
         false /* origin remote */, memberId.getDistributedMember(),
         true /* generateCallbacks */,
@@ -6004,7 +6003,7 @@ public class LocalRegion extends AbstractRegion
       ClientProxyMembershipID memberId, boolean fromClient, EntryEventImpl clientEvent) {
  
     // Create an event and update version stamp of the entry
-    EntryEventImpl event = EntryEventImpl.create(this, Operation.UPDATE_VERSION_STAMP, key,
+    @Released EntryEventImpl event = EntryEventImpl.create(this, Operation.UPDATE_VERSION_STAMP, key,
         null /* new value */, null /*callbackArg*/,
         false /* origin remote */, memberId.getDistributedMember(),
         false /* generateCallbacks */,
@@ -6368,8 +6367,7 @@ public class LocalRegion extends AbstractRegion
   protected void notifyTimestampsToGateways(EntryEventImpl event) {
     
     // Create updateTimeStampEvent from event.
-    EntryEventImpl updateTimeStampEvent = EntryEventImpl.createVersionTagHolder(event.getVersionTag());
-    try {
+    VersionTagHolder updateTimeStampEvent = new VersionTagHolder(event.getVersionTag());
     updateTimeStampEvent.setOperation(Operation.UPDATE_VERSION_STAMP);
     updateTimeStampEvent.setKeyInfo(event.getKeyInfo());
     updateTimeStampEvent.setGenerateCallbacks(false);
@@ -6394,9 +6392,6 @@ public class LocalRegion extends AbstractRegion
       updateTimeStampEvent.setRegion(event.getRegion());
       notifyGatewaySender(EnumListenerEvent.TIMESTAMP_UPDATE, updateTimeStampEvent);
     }
-    } finally {
-      updateTimeStampEvent.release();
-    }
   }
 
 
@@ -7276,8 +7271,9 @@ public class LocalRegion extends AbstractRegion
    * @param key - the key that this event is related to 
    * @return an event for EVICT_DESTROY
    */
+  @Retained
   protected EntryEventImpl generateEvictDestroyEvent(final Object key) {
-    EntryEventImpl event = EntryEventImpl.create(
+    @Retained EntryEventImpl event = EntryEventImpl.create(
         this, Operation.EVICT_DESTROY, key, null/* newValue */,
         null, false, getMyId());
     // Fix for bug#36963
@@ -7287,8 +7283,10 @@ public class LocalRegion extends AbstractRegion
     event.setFetchFromHDFS(false);
     return event;
   }
-    protected EntryEventImpl generateCustomEvictDestroyEvent(final Object key) {
-    EntryEventImpl event =  EntryEventImpl.create(
+  
+  @Retained
+  protected EntryEventImpl generateCustomEvictDestroyEvent(final Object key) {
+    @Retained EntryEventImpl event =  EntryEventImpl.create(
         this, Operation.CUSTOM_EVICT_DESTROY, key, null/* newValue */,
         null, false, getMyId());
     
@@ -7307,7 +7305,7 @@ public class LocalRegion extends AbstractRegion
   {
     
     checkReadiness();
-    final EntryEventImpl event = 
+    @Released final EntryEventImpl event = 
           generateEvictDestroyEvent(entry.getKey());
     try {
       return mapDestroy(event,
@@ -8207,7 +8205,7 @@ public class LocalRegion extends AbstractRegion
     for (Iterator itr = keySet().iterator(); itr.hasNext();) {
       try {
         //EventID will not be generated by this constructor
-        EntryEventImpl event = EntryEventImpl.create(
+        @Released EntryEventImpl event = EntryEventImpl.create(
             this, op, itr.next() /*key*/,
             null/* newValue */, null/* callbackArg */, rgnEvent.isOriginRemote(),
             rgnEvent.getDistributedMember());
@@ -9267,6 +9265,10 @@ public class LocalRegion extends AbstractRegion
 
   class EventDispatcher implements Runnable
   {
+    /**
+     * released by the release method
+     */
+    @Retained
     InternalCacheEvent event;
 
     EnumListenerEvent op;
@@ -10091,7 +10093,7 @@ public class LocalRegion extends AbstractRegion
           // correct events will be delivered to any callbacks we have.
           long startPut = CachePerfStats.getStatTime();
           validateKey(key);
-          EntryEventImpl event = EntryEventImpl.create(
+          @Released EntryEventImpl event = EntryEventImpl.create(
               this, Operation.LOCAL_LOAD_CREATE, key, value,
               callback, false, getMyId(), true);
           try {
@@ -10186,7 +10188,7 @@ public class LocalRegion extends AbstractRegion
       callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
     }
   
-    final EntryEventImpl event = EntryEventImpl.create(this, Operation.PUTALL_CREATE, null,
+    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.PUTALL_CREATE, null,
         null /* new value */, callbackArg,
         false /* origin remote */, memberId.getDistributedMember(),
         !skipCallbacks /* generateCallbacks */,
@@ -10222,7 +10224,7 @@ public class LocalRegion extends AbstractRegion
       callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
     }
   
-    final EntryEventImpl event = EntryEventImpl.create(this, Operation.REMOVEALL_DESTROY, null,
+    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.REMOVEALL_DESTROY, null,
         null /* new value */, callbackArg,
         false /* origin remote */, memberId.getDistributedMember(),
         true /* generateCallbacks */,
@@ -10246,7 +10248,7 @@ public class LocalRegion extends AbstractRegion
     long startPut = CachePerfStats.getStatTime();
 
     // generateCallbacks == false
-    EntryEventImpl event = EntryEventImpl.create(this, Operation.PUTALL_CREATE,
+    @Released EntryEventImpl event = EntryEventImpl.create(this, Operation.PUTALL_CREATE,
         null, null, null, true, getMyId(), !skipCallbacks);
     try {
     DistributedPutAllOperation putAllOp = new DistributedPutAllOperation(event, map.size(), false);
@@ -10394,7 +10396,7 @@ public class LocalRegion extends AbstractRegion
       Runnable r = new Runnable() {
         public void run() {
           int offset = 0;
-          EntryEventImpl tagHolder = EntryEventImpl.createVersionTagHolder();
+          VersionTagHolder tagHolder = new VersionTagHolder();
           while (iterator.hasNext()) {
             stopper.checkCancelInProgress(null);
             Map.Entry mapEntry = (Map.Entry)iterator.next();
@@ -10445,11 +10447,7 @@ public class LocalRegion extends AbstractRegion
               }
               
               if (!overwritten) {
-                try {
-                  basicEntryPutAll(key, value, dpao, offset, tagHolder);
-                } finally {
-                  tagHolder.release();
-                }
+                basicEntryPutAll(key, value, dpao, offset, tagHolder);
               }
               // now we must check again since the cache may have closed during
               // distribution (causing this process to not receive and queue the
@@ -10613,7 +10611,7 @@ public class LocalRegion extends AbstractRegion
       Runnable r = new Runnable() {
         public void run() {
           int offset = 0;
-          EntryEventImpl tagHolder = EntryEventImpl.createVersionTagHolder();
+          VersionTagHolder tagHolder = new VersionTagHolder();
           while (iterator.hasNext()) {
             stopper.checkCancelInProgress(null);
             Object key;
@@ -10766,6 +10764,7 @@ public class LocalRegion extends AbstractRegion
     // Create a dummy event for the PutAll operation.  Always create a
     // PutAll operation, even if there is no distribution, so that individual
     // events can be tracked and handed off to callbacks in postPutAll
+    // No need for release since disallowOffHeapValues called.
     final EntryEventImpl event = EntryEventImpl.create(this,
         Operation.PUTALL_CREATE, null, null, callbackArg, true, getMyId());
 
@@ -10795,6 +10794,7 @@ public class LocalRegion extends AbstractRegion
     // Create a dummy event for the removeAll operation.  Always create a
     // removeAll operation, even if there is no distribution, so that individual
     // events can be tracked and handed off to callbacks in postRemoveAll
+    // No need for release since disallowOffHeapValues called.
     final EntryEventImpl event = EntryEventImpl.create(this, Operation.REMOVEALL_DESTROY, null,
         null/* newValue */, callbackArg, false, getMyId());
     event.disallowOffHeapValues();
@@ -10826,7 +10826,7 @@ public class LocalRegion extends AbstractRegion
     validateArguments(key, value, null);
     // event is marked as a PUTALL_CREATE but if the entry exists it
     // will be changed to a PUTALL_UPDATE later on.
-    EntryEventImpl event = EntryEventImpl.createPutAllEvent(
+    @Released EntryEventImpl event = EntryEventImpl.createPutAllEvent(
         putallOp, this, Operation.PUTALL_CREATE, key, value);
 
     try {
@@ -10864,7 +10864,7 @@ public class LocalRegion extends AbstractRegion
     assert op != null;
     checkReadiness();
     validateKey(key);
-    EntryEventImpl event = EntryEventImpl.createRemoveAllEvent(op, this, key);
+    @Released EntryEventImpl event = EntryEventImpl.createRemoveAllEvent(op, this, key);
     try {
     if (tagHolder != null) {
       event.setVersionTag(tagHolder.getVersionTag());
@@ -10918,13 +10918,17 @@ public class LocalRegion extends AbstractRegion
       successfulKeys.add(key);
     }
     for (Iterator it=putallOp.eventIterator(); it.hasNext(); ) {
-      EntryEventImpl event = (EntryEventImpl)it.next();
+      @Released EntryEventImpl event = (EntryEventImpl)it.next();
+      try {
       if (successfulKeys.contains(event.getKey())) {
         EnumListenerEvent op = event.getOperation().isCreate() ? EnumListenerEvent.AFTER_CREATE
             : EnumListenerEvent.AFTER_UPDATE; 
         invokePutCallbacks(op, event, !event.callbacksInvoked() && !event.isPossibleDuplicate(),
             false /* We must notify gateways inside RegionEntry lock, NOT here, to preserve the order of events sent by gateways for same key*/);
       }
+      } finally {
+        event.release();
+      }
     }
   }
   
@@ -10941,11 +10945,15 @@ public class LocalRegion extends AbstractRegion
       successfulKeys.add(key);
     }
     for (Iterator it=op.eventIterator(); it.hasNext(); ) {
-      EntryEventImpl event = (EntryEventImpl)it.next();
+      @Released EntryEventImpl event = (EntryEventImpl)it.next();
+      try {
       if (successfulKeys.contains(event.getKey())) {
         invokeDestroyCallbacks(EnumListenerEvent.AFTER_DESTROY, event, !event.callbacksInvoked() && !event.isPossibleDuplicate(),
             false /* We must notify gateways inside RegionEntry lock, NOT here, to preserve the order of events sent by gateways for same key*/);
       }
+      } finally {
+        event.release();
+      }
     }
   }
   
@@ -11607,8 +11615,7 @@ public class LocalRegion extends AbstractRegion
   }
   
   public void destroyRecoveredEntry(Object key) {
-    EntryEventImpl event = EntryEventImpl.create(
-        this,
+    @Released EntryEventImpl event = EntryEventImpl.create(this,
         Operation.LOCAL_DESTROY, key, null, null, false, getMyId(), false);
     try {
     event.inhibitCacheListenerNotification(true);
@@ -12337,7 +12344,7 @@ public class LocalRegion extends AbstractRegion
      // was modified to call the other EntryEventImpl constructor so that
      // an id will be generated by default. Null was passed in anyway.
      //   generate EventID
-     EntryEventImpl event = EntryEventImpl.create(
+     @Released EntryEventImpl event = EntryEventImpl.create(
          this, Operation.PUT_IF_ABSENT, key,
          value, callbackArgument, false, getMyId());
      final Object oldValue = null;
@@ -12398,7 +12405,7 @@ public class LocalRegion extends AbstractRegion
     if (value == null) {
       value = Token.INVALID;
     }
-    EntryEventImpl event = EntryEventImpl.create(this,
+    @Released EntryEventImpl event = EntryEventImpl.create(this,
                                               Operation.REMOVE,
                                               key,
                                               null, // newValue
@@ -12455,7 +12462,7 @@ public class LocalRegion extends AbstractRegion
     validateArguments(key, newValue, callbackArg);
     checkReadiness();
     checkForLimitedOrNoAccess();
-    EntryEventImpl event = EntryEventImpl.create(this,
+    @Released EntryEventImpl event = EntryEventImpl.create(this,
                                               Operation.REPLACE,
                                               key,
                                               newValue,
@@ -12523,7 +12530,7 @@ public class LocalRegion extends AbstractRegion
     validateArguments(key, value, callbackArg);
     checkReadiness();
     checkForLimitedOrNoAccess();
-    EntryEventImpl event = EntryEventImpl.create(this,
+    @Released EntryEventImpl event = EntryEventImpl.create(this,
                                               Operation.REPLACE,
                                               key,
                                               value,
@@ -12571,7 +12578,7 @@ public class LocalRegion extends AbstractRegion
         callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
       }
     }
-    final EntryEventImpl event = EntryEventImpl.create(this, Operation.PUT_IF_ABSENT, key,
+    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.PUT_IF_ABSENT, key,
         null /* new value */, callbackArg,
         false /* origin remote */, client.getDistributedMember(),
         true /* generateCallbacks */,
@@ -12648,7 +12655,7 @@ public class LocalRegion extends AbstractRegion
         callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
       }
     }
-    final EntryEventImpl event = EntryEventImpl.create(this, Operation.REPLACE, key,
+    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.REPLACE, key,
         null /* new value */, callbackArg,
         false /* origin remote */, client.getDistributedMember(),
         true /* generateCallbacks */,
@@ -12705,7 +12712,7 @@ public class LocalRegion extends AbstractRegion
         callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
       }
     }
-    final EntryEventImpl event = EntryEventImpl.create(this, Operation.REPLACE, key,
+    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.REPLACE, key,
         null /* new value */, callbackArg,
         false /* origin remote */, client.getDistributedMember(),
         true /* generateCallbacks */,
@@ -12771,7 +12778,7 @@ public class LocalRegion extends AbstractRegion
     }
 
     // Create an event and put the entry
-    final EntryEventImpl event = EntryEventImpl.create(this, Operation.REMOVE, key,
+    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.REMOVE, key,
         null /* new value */, callbackArg,
         false /* origin remote */, memberId.getDistributedMember(),
         true /* generateCallbacks */,


[19/25] incubator-geode git commit: GEODE-1263: Add jit.js to LICENSE

Posted by ji...@apache.org.
GEODE-1263: Add jit.js to LICENSE


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

Branch: refs/heads/feature/GEODE-17-2
Commit: bc24aefa96502e7b6de83c2caaec626432e7f8e0
Parents: 9023429
Author: Anthony Baker <ab...@apache.org>
Authored: Wed Apr 20 15:16:39 2016 -0700
Committer: Anthony Baker <ab...@apache.org>
Committed: Thu Apr 21 11:52:23 2016 -0700

----------------------------------------------------------------------
 LICENSE                              | 2 ++
 geode-assembly/src/main/dist/LICENSE | 2 ++
 2 files changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bc24aefa/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index e1fc3cb..970a2ff 100644
--- a/LICENSE
+++ b/LICENSE
@@ -322,6 +322,8 @@ Apache Geode bundles the following files under the MIT license:
     (c) 2014 Alexander Farkas (aFarkas)
   - iCheck v0.8 (http://icheck.fronteed.com/), Copyright (c) 2013 Damir
     Foy, http://damirfoy.com
+  - JavaScript InfoVis Toolkit v2.0.1 (http://philogb.github.io/jit/), 
+    Copyright (c) 2011 Sencha Inc.
   - JOpt Simple (http://pholser.github.io/jopt-simple/), Copyright (c)
     2004-2015 Paul R. Holser, Jr.
   - jQuery JavaScript Library v.1.7.2 (https://jquery.com), Copyright (c)

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bc24aefa/geode-assembly/src/main/dist/LICENSE
----------------------------------------------------------------------
diff --git a/geode-assembly/src/main/dist/LICENSE b/geode-assembly/src/main/dist/LICENSE
index 5ea39ca..9c906dd 100644
--- a/geode-assembly/src/main/dist/LICENSE
+++ b/geode-assembly/src/main/dist/LICENSE
@@ -666,6 +666,8 @@ Apache Geode bundles the following files under the MIT license:
     (c) 2014 Alexander Farkas (aFarkas)
   - iCheck v0.8 (http://icheck.fronteed.com/), Copyright (c) 2013 Damir
     Foy, http://damirfoy.com
+  - JavaScript InfoVis Toolkit v2.0.1 (http://philogb.github.io/jit/),
+    Copyright (c) 2011 Sencha Inc.
   - JOpt Simple (http://pholser.github.io/jopt-simple/), Copyright (c)
     2004-2015 Paul R. Holser, Jr.
   - jQuery JavaScript Library v.1.7.2 (https://jquery.com), Copyright (c)


[13/25] incubator-geode git commit: GEODE-1146: Test cleanup, converting many VM invoke statements to lambda expressions

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e1656b0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java
index d016843..c06f4db 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/internal/JUnit4DistributedTestCase.java
@@ -375,7 +375,7 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur
       Host host = Host.getHost(hostIndex);
       for (int vmIndex = 0; vmIndex < host.getVMCount(); vmIndex++) {
         final String vmDefaultDiskStoreName = getDefaultDiskStoreName(hostIndex, vmIndex, className, methodName);
-        host.getVM(vmIndex).invoke(()->setUpVM(methodName, vmDefaultDiskStoreName));
+        host.getVM(vmIndex).invoke("setupVM", ()->setUpVM(methodName, vmDefaultDiskStoreName));
       }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e1656b0/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ProcessManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ProcessManager.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ProcessManager.java
index 705663d..dd532c4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ProcessManager.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ProcessManager.java
@@ -54,10 +54,6 @@ public class ProcessManager {
     this.registry = registry;
   }
   
-  public void launchVMs() throws IOException, NotBoundException {
-    log4jConfig = LogService.findLog4jConfigInCurrentDir();
-  }
-
   public synchronized void launchVM(int vmNum) throws IOException {
     if(processes.containsKey(vmNum)) {
       throw new IllegalStateException("VM " + vmNum + " is already running.");
@@ -178,8 +174,7 @@ public class ProcessManager {
       "-Xmx512m",
       "-Dgemfire.DEFAULT_MAX_OPLOG_SIZE=10",
       "-Dgemfire.disallowMcastDefaults=true",
-      "-ea",
-        "-XX:+PrintGC", "-XX:+PrintGCDetails","-XX:+PrintGCTimeStamps",
+      "-ea", "-XX:+PrintGC", "-XX:+PrintGCDetails","-XX:+PrintGCTimeStamps",
       agent,
       ChildVM.class.getName()
     };


[02/25] incubator-geode git commit: GEODE-1213: Disables signing task on geode-modules-assembly

Posted by ji...@apache.org.
GEODE-1213: Disables signing task on geode-modules-assembly

The signArchives task was not getting disabled on geode-modules-
assembly project.  This was causing a build error since the
project did not generate a jar artifact. This error was only
seen when enabling signing by setting properties in your
~/.gradle/gradle.properties file.


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

Branch: refs/heads/feature/GEODE-17-2
Commit: d33fee0040603e650ce8842efd8f72bbd70871d3
Parents: fdfd98f
Author: Anthony Baker <ab...@apache.org>
Authored: Mon Apr 11 22:45:30 2016 -0700
Committer: Anthony Baker <ab...@apache.org>
Committed: Tue Apr 12 09:03:38 2016 -0700

----------------------------------------------------------------------
 gradle/utilities.gradle | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d33fee00/gradle/utilities.gradle
----------------------------------------------------------------------
diff --git a/gradle/utilities.gradle b/gradle/utilities.gradle
index 6a6df04..fa77839 100644
--- a/gradle/utilities.gradle
+++ b/gradle/utilities.gradle
@@ -29,12 +29,11 @@ allprojects {
     }
 
     disableMavenPublishing = {
-      // Use this closure when a project should not publish anything to maven. It appears that the nexus
-      // upload task still needs to exist, which is why an empty one is created.
+      // Use this closure when a project should not publish anything to maven.
       afterEvaluate {
-        tasks.remove(install)
-        tasks.remove(uploadArchives)
-        task uploadArchives << { }
+        install.enabled = false
+        uploadArchives.enabled = false
+        signArchives.enabled = false
       }
     }
   }