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

[01/26] incubator-geode git commit: GEODE-1053: Refactoring some test code.

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-949-2 5dcd68178 -> 2184de4dc


GEODE-1053: Refactoring some test code.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: e22cd9532946322c0a0829b755ab184cd08977fb
Parents: f217552
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Wed Mar 9 20:06:49 2016 +1100
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Wed Mar 16 05:53:57 2016 +1100

----------------------------------------------------------------------
 ...stAPIOnRegionFunctionExecutionDUnitTest.java |  1 -
 ...APIsOnMembersFunctionExecutionDUnitTest.java | 26 ++++++++------------
 2 files changed, 10 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e22cd953/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
index 63bd9fa..de7c97c 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
@@ -36,7 +36,6 @@ import java.util.*;
 /**
  * Dunit Test to validate OnRegion function execution with REST APIs
  *
- * @author Nilkanth Patel
  * @since 8.0
  */
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e22cd953/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
index ac922ad..7a994d6 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
@@ -30,10 +30,6 @@ import org.apache.http.client.methods.CloseableHttpResponse;
 
 import java.util.Properties;
 
-/**
- * @author Nilkanth Patel
- */
-
 public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase {
 
   private static final long serialVersionUID = 1L;
@@ -111,10 +107,7 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase
   }
 
   public void testFunctionExecutionOnAllMembers() {
-    restURLs.add(vm0.invoke(() -> createCacheAndRegisterFunction(vm0, "m1")));
-    restURLs.add(vm1.invoke(() -> createCacheAndRegisterFunction(vm1, "m2")));
-    restURLs.add(vm2.invoke(() -> createCacheAndRegisterFunction(vm2, "m3")));
-    restURLs.add(vm3.invoke(() -> createCacheAndRegisterFunction(vm3, "m4")));
+    createCacheForVMs();
 
     for (int i = 0; i < 10; i++) {
       CloseableHttpResponse response = executeFunctionThroughRestCall("OnMembersFunction",null,null,null,null,null);
@@ -131,11 +124,15 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase
     restURLs.clear();
   }
 
+  private void createCacheForVMs() {
+    restURLs.add(vm0.invoke(() -> createCacheAndRegisterFunction(vm0, "m1")));
+    restURLs.add(vm1.invoke(() -> createCacheAndRegisterFunction(vm1, "m2")));
+    restURLs.add(vm2.invoke(() -> createCacheAndRegisterFunction(vm2, "m3")));
+    restURLs.add(vm3.invoke(() -> createCacheAndRegisterFunction(vm3, "m4")));
+  }
+
   public void testFunctionExecutionEOnSelectedMembers() {
-    restURLs.add((String) vm0.invoke(() -> createCacheAndRegisterFunction(vm0, "m1")));
-    restURLs.add((String) vm1.invoke(() -> createCacheAndRegisterFunction(vm1, "m2")));
-    restURLs.add((String) vm2.invoke(() -> createCacheAndRegisterFunction(vm2, "m3")));
-    restURLs.add((String) vm3.invoke(() -> createCacheAndRegisterFunction(vm3, "m4")));
+    createCacheForVMs();
 
     for (int i = 0; i < 10; i++) {
       CloseableHttpResponse response = executeFunctionThroughRestCall("OnMembersFunction",null,null,null,null,"m1,m2,m3");
@@ -153,10 +150,7 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase
   }
 
   public void testFunctionExecutionOnMembersWithFilter() {
-    restURLs.add((String) vm0.invoke(() -> createCacheAndRegisterFunction(vm0, "m1")));
-    restURLs.add((String) vm1.invoke(() -> createCacheAndRegisterFunction(vm1, "m2")));
-    restURLs.add((String) vm2.invoke(() -> createCacheAndRegisterFunction(vm2, "m3")));
-    restURLs.add((String) vm3.invoke(() -> createCacheAndRegisterFunction(vm3, "m4")));
+    createCacheForVMs();
 
     for (int i = 0; i < 10; i++) {
       CloseableHttpResponse response = executeFunctionThroughRestCall("OnMembersFunction",null,"key2",null,null,"m1,m2,m3");


[05/26] incubator-geode git commit: GEODE-1007 CI Failure: ClientAuthorizationTwoDUnitTest.testAllOpsWithFailover2

Posted by kl...@apache.org.
GEODE-1007 CI Failure: ClientAuthorizationTwoDUnitTest.testAllOpsWithFailover2

The test was initially set up to use multicast discovery.  I had changed
it to use colocated locators but the AvailablePort utility was being used
for these and for the server ports.  The test now uses the dunit locator
and gets the server ports from a wildcard bind.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 3ae26b65fb2d30418ffdd096c384d9dfa8ade311
Parents: c5a8817
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Tue Mar 15 15:35:23 2016 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Tue Mar 15 15:35:23 2016 -0700

----------------------------------------------------------------------
 .../security/ClientAuthorizationTestBase.java   | 51 +++++++++-----------
 1 file changed, 24 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3ae26b65/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
index 55edaa1..cc468e1 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
@@ -31,10 +31,6 @@ import java.util.Properties;
 import java.util.Random;
 import java.util.Set;
 
-import security.AuthzCredentialGenerator;
-import security.CredentialGenerator;
-import security.AuthzCredentialGenerator.ClassCode;
-
 import com.gemstone.gemfire.cache.DynamicRegionFactory;
 import com.gemstone.gemfire.cache.InterestResultPolicy;
 import com.gemstone.gemfire.cache.Operation;
@@ -61,11 +57,13 @@ import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.util.Callable;
 import com.gemstone.gemfire.test.dunit.Assert;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.Wait;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
 
+import security.AuthzCredentialGenerator;
+import security.AuthzCredentialGenerator.ClassCode;
+import security.CredentialGenerator;
 import security.DummyCredentialGenerator;
 import security.XmlAuthzCredentialGenerator;
 
@@ -144,13 +142,13 @@ public class ClientAuthorizationTestBase extends DistributedTestCase {
             SecurityTestUtil.NO_EXCEPTION));
   }
 
-  public static void createCacheServer(Integer locatorPort, Integer serverPort,
+  public static Integer createCacheServer(Integer locatorPort, Integer serverPort,
       Object authProps, Object javaProps) {
     if (locatorPort == null) {
       locatorPort = new Integer(AvailablePort
           .getRandomAvailablePort(AvailablePort.SOCKET));
     }
-    SecurityTestUtil.createCacheServer((Properties)authProps, javaProps,
+    return SecurityTestUtil.createCacheServer((Properties)authProps, javaProps,
         locatorPort, null, serverPort, Boolean.TRUE, new Integer(
             SecurityTestUtil.NO_EXCEPTION));
   }
@@ -267,7 +265,7 @@ public class ClientAuthorizationTestBase extends DistributedTestCase {
       policy = InterestResultPolicy.NONE;
     }
     final int numOps = indices.length;
-    LogWriterUtils.getLogWriter().info(
+    System.out.println(
         "Got doOp for op: " + op.toString() + ", numOps: " + numOps
             + ", indices: " + indicesToString(indices) + ", expect: " + expectedResult);
     boolean exceptionOccured = false;
@@ -307,7 +305,7 @@ public class ClientAuthorizationTestBase extends DistributedTestCase {
               // server
               if ((flags & OpFlags.CHECK_NOKEY) > 0) {
                 AbstractRegionEntry entry = (AbstractRegionEntry)((LocalRegion)region).getRegionEntry(searchKey);
-                LogWriterUtils.getLogWriter().info(""+keyNum+": key is " + searchKey + " and entry is " + entry);
+                System.out.println(""+keyNum+": key is " + searchKey + " and entry is " + entry);
                 assertFalse(region.containsKey(searchKey));
               }
               else {
@@ -648,7 +646,7 @@ public class ClientAuthorizationTestBase extends DistributedTestCase {
               }
               catch (RegionDestroyedException ex) {
                 // harmless to ignore this
-                LogWriterUtils.getLogWriter().info(
+                System.out.println(
                     "doOp: sub-region " + region.getFullPath()
                         + " already destroyed");
                 operationOmitted = true;
@@ -675,14 +673,14 @@ public class ClientAuthorizationTestBase extends DistributedTestCase {
             || ex instanceof QueryInvocationTargetException || ex instanceof CqException)
             && (expectedResult.intValue() == SecurityTestUtil.NOTAUTHZ_EXCEPTION)
             && (ex.getCause() instanceof NotAuthorizedException)) {
-          LogWriterUtils.getLogWriter().info(
+          System.out.println(
               "doOp: Got expected NotAuthorizedException when doing operation ["
                   + op + "] with flags " + OpFlags.description(flags) 
                   + ": " + ex.getCause());
           continue;
         }
         else if (expectedResult.intValue() == SecurityTestUtil.OTHER_EXCEPTION) {
-          LogWriterUtils.getLogWriter().info(
+          System.out.println(
               "doOp: Got expected exception when doing operation: "
                   + ex.toString());
           continue;
@@ -728,7 +726,7 @@ public class ClientAuthorizationTestBase extends DistributedTestCase {
           fail("executeOpBlock: Unknown client number " + clientNum);
           break;
       }
-      LogWriterUtils.getLogWriter().info(
+      System.out.println(
           "executeOpBlock: performing operation number ["
               + currentOp.getOpNum() + "]: " + currentOp);
       if ((opFlags & OpFlags.USE_OLDCONN) == 0) {
@@ -764,7 +762,7 @@ public class ClientAuthorizationTestBase extends DistributedTestCase {
                 extraAuthzProps });
         // Start the client with valid credentials but allowed or disallowed to
         // perform an operation
-        LogWriterUtils.getLogWriter().info(
+        System.out.println(
             "executeOpBlock: For client" + clientNum + credentialsTypeStr
                 + " credentials: " + opCredentials);
         boolean setupDynamicRegionFactory = (opFlags & OpFlags.ENABLE_DRF) > 0;
@@ -849,21 +847,20 @@ public class ClientAuthorizationTestBase extends DistributedTestCase {
       String accessor = gen.getAuthorizationCallback();
       TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
 
-      LogWriterUtils.getLogWriter().info(testName + ": Using authinit: " + authInit);
-      LogWriterUtils.getLogWriter().info(testName + ": Using authenticator: " + authenticator);
-      LogWriterUtils.getLogWriter().info(testName + ": Using accessor: " + accessor);
+      System.out.println(testName + ": Using authinit: " + authInit);
+      System.out.println(testName + ": Using authenticator: " + authenticator);
+      System.out.println(testName + ": Using accessor: " + accessor);
 
       // Start servers with all required properties
       Properties serverProps = buildProperties(authenticator, accessor, false,
           extraAuthProps, extraAuthzProps);
       // Get ports for the servers
-      Keeper port1Keeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
+      int port1 = 0;
       Keeper port2Keeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
-      int port1 = port1Keeper.getPort();
       int port2 = port2Keeper.getPort();
 
       // 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 < opCodes.length; ++opNum) {
         // Start client with valid credentials as specified in
@@ -874,20 +871,20 @@ public class ClientAuthorizationTestBase extends DistributedTestCase {
           // End of current operation block; execute all the operations
           // on the servers with/without failover
           if (opBlock.size() > 0) {
-            port1Keeper.release();
             // Start the first server and execute the operation block
-            server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                    SecurityTestUtil.getLocatorPort(), port1, serverProps,
+            final int locatorPort = 0;
+            port1 = server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
+                    locatorPort, 0, serverProps,
                     javaProps ));
             server2.invoke(() -> SecurityTestUtil.closeCache());
             executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
                 extraAuthzProps, tgen, rnd);
             if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
               // Failover to the second server and run the block again
-              port2Keeper.release();
-              server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                      SecurityTestUtil.getLocatorPort(), port2, serverProps,
-                      javaProps ));
+              final String locatorString = null;
+              port2 = server2.invoke(() -> SecurityTestUtil.createCacheServer(
+                      serverProps, javaProps, null, locatorString, 0, Boolean.TRUE,
+                          SecurityTestUtil.NO_EXCEPTION ));
               server1.invoke(() -> SecurityTestUtil.closeCache());
               executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
                   extraAuthzProps, tgen, rnd);


[22/26] incubator-geode git commit: GEODE-1095: GatewaySenderEventImpl now caches serialized value size

Posted by kl...@apache.org.
GEODE-1095: GatewaySenderEventImpl now caches serialized value size


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 05cd14437ecc3391505acf0ef158be3a5dda619f
Parents: ff69aea
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Wed Mar 16 13:40:31 2016 -0700
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Thu Mar 17 10:11:47 2016 -0700

----------------------------------------------------------------------
 .../internal/cache/wan/GatewaySenderEventImpl.java  | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05cd1443/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
index 6f284b5..d1a887f 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
@@ -213,6 +213,10 @@ public class GatewaySenderEventImpl implements
   
   private static final int OP_DETAIL_REMOVEALL = 14;
 
+  private static final int DEFAULT_SERIALIZED_VALUE_SIZE = -1;
+
+  private volatile int serializedValueSize = DEFAULT_SERIALIZED_VALUE_SIZE;
+
 //  /**
 //   * Is this thread in the process of deserializing this event?
 //   */
@@ -1223,17 +1227,23 @@ public class GatewaySenderEventImpl implements
   }
 
   public int getSerializedValueSize() {
+    int localSerializedValueSize = this.serializedValueSize;
+    if (localSerializedValueSize != DEFAULT_SERIALIZED_VALUE_SIZE) {
+      return localSerializedValueSize;
+    }
     @Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE)
     Object vo = this.valueObj;
     if (vo instanceof StoredObject) {
-      return ((StoredObject) vo).getSizeInBytes();
+      localSerializedValueSize = ((StoredObject) vo).getSizeInBytes();
     } else {
       if (this.substituteValue != null) {
-        return sizeOf(this.substituteValue);
+        localSerializedValueSize = sizeOf(this.substituteValue);
       } else {
-      return CachedDeserializableFactory.calcMemSize(getSerializedValue());
+        localSerializedValueSize = CachedDeserializableFactory.calcMemSize(getSerializedValue());
       }
     }
+    this.serializedValueSize = localSerializedValueSize;
+    return localSerializedValueSize;
   }
   
   @Override


[06/26] incubator-geode git commit: GEODE-639 CI failure: CacheXml80DUnitTest.testCacheServerEnableTcpNoDelay

Posted by kl...@apache.org.
GEODE-639 CI failure: CacheXml80DUnitTest.testCacheServerEnableTcpNoDelay

Use TCP port 0, so that an available port will be automatically assigned


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 44c388efc6f2a475baeb6a83f62926fcb83dc6d2
Parents: 3ae26b6
Author: Jianxia Chen <jc...@pivotal.io>
Authored: Tue Mar 15 16:07:04 2016 -0700
Committer: Jianxia Chen <jc...@pivotal.io>
Committed: Tue Mar 15 16:07:04 2016 -0700

----------------------------------------------------------------------
 .../test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44c388ef/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java
index 98134ce..155fb78 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java
@@ -197,6 +197,7 @@ public class CacheXml80DUnitTest extends CacheXml70DUnitTest {
     CacheCreation cache = new CacheCreation();
 
     CacheServer cs = cache.addCacheServer();
+    cs.setPort(0);
     cs.setTcpNoDelay(true);
     RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
     attrs.setDataPolicy(DataPolicy.NORMAL);


[11/26] incubator-geode git commit: GEODE-1101: rename SimpleMemoryAllocator to MemoryAllocator

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java
deleted file mode 100644
index c61f2f4..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.offheap;
-
-import static org.junit.Assert.*;
-import static com.googlecode.catchexception.CatchException.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-import junit.framework.TestCase;
-
-/**
- * Tests fill pattern validation for the {@link SimpleMemoryAllocatorImpl}.
- * @author rholmes
- */
-@Category(UnitTest.class)
-public class SimpleMemoryAllocatorFillPatternJUnitTest {
-  
-  /** Size of single test slab.*/
-  private static final int SLAB_SIZE = 1024 * 1024 * 50;
-  
-  /** Canned data for write operations. */
-  private static final byte[] WRITE_BYTES = new String("Some string data.").getBytes();
-  
-  /** Chunk size for basic huge allocation test. */
-  private static final int HUGE_CHUNK_SIZE = 1024 * 200;
-  
-  /** The number of chunks to allocate in order to force compaction. */
-  private static final int COMPACTION_CHUNKS = 3;
-  
-  /** Our slab size divided in three (with some padding for safety). */
-  private static final int COMPACTION_CHUNK_SIZE = (SLAB_SIZE / COMPACTION_CHUNKS) - 1024;
-  
-  /** This should force compaction when allocated. */
-  private static final int FORCE_COMPACTION_CHUNK_SIZE = COMPACTION_CHUNK_SIZE * 2;
-
-  /** Our test victim. */
-  private SimpleMemoryAllocatorImpl allocator = null;
-  
-  /** Our test victim's memory slab. */
-  private SlabImpl slab = null;
-
-  /**
-   * Enables fill validation and creates the test victim.
-   */
-  @Before
-  public void setUp() throws Exception {
-    System.setProperty("gemfire.validateOffHeapWithFill", "true");
-    this.slab = new SlabImpl(SLAB_SIZE);
-    this.allocator = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{this.slab});
-  }
-
-  /**
-   * Frees off heap memory.
-   */
-  @After
-  public void tearDown() throws Exception {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-    System.clearProperty("gemfire.validateOffHeapWithFill");
-  }
-
-  /**
-   * This tests the fill pattern for a single tiny Chunk allocation.
-   * @throws Exception
-   */
-  @Test
-  public void testFillPatternBasicForTinyAllocations() throws Exception {
-    doFillPatternBasic(1024);
-  }
-  
-  /**
-   * This tests the fill pattern for a single huge Chunk allocation.
-   * @throws Exception
-   */
-  @Test
-  public void testFillPatternBasicForHugeAllocations() throws Exception {
-    doFillPatternBasic(HUGE_CHUNK_SIZE);
-  }
-  
-  private void doFillPatternBasic(final int chunkSize) {
-    /*
-     * Pull a chunk off the fragment.  This will have no fill because
-     * it is a "fresh" chunk.
-     */
-    OffHeapStoredObject chunk = (OffHeapStoredObject) this.allocator.allocate(chunkSize);
-
-    /*
-     * Chunk should have valid fill from initial fragment allocation.
-     */
-    chunk.validateFill();
-         
-    // "Dirty" the chunk so the release has something to fill over
-    chunk.writeDataBytes(OffHeapStoredObject.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
-
-    // This should free the Chunk (ref count == 1)
-    chunk.release();
-
-    /*
-     * This chunk should have a fill because it was reused from the
-     * free list (assuming no fragmentation at this point...)
-     */
-    chunk = (OffHeapStoredObject) this.allocator.allocate(chunkSize);
-    
-    // Make sure we have a fill this time
-    chunk.validateFill();
-    
-    // Give the fill code something to write over during the release
-    chunk.writeDataBytes(OffHeapStoredObject.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
-    chunk.release();
-
-    // Again, make sure the release implemented the fill
-    chunk.validateFill();
-
-    // "Dirty up" the free chunk
-    chunk.writeDataBytes(OffHeapStoredObject.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
-    
-    catchException(chunk).validateFill();
-    assertTrue(caughtException() instanceof IllegalStateException);
-    assertEquals("Fill pattern violated for chunk " + chunk.getAddress() + " with size " + chunk.getSize(), caughtException().getMessage());
-    
-  }
-
-  /**
-   * This tests that fill validation is working properly on newly created fragments after
-   * a compaction.
-   * @throws Exception
-   */
-  @Test
-  public void testFillPatternAfterCompaction() throws Exception {
-    /*
-     * Stores our allocated memory.
-     */
-    OffHeapStoredObject[] allocatedChunks = new OffHeapStoredObject[COMPACTION_CHUNKS];
-    
-    /*
-     * Use up most of our memory
-     * Our memory looks like [      ][      ][      ]
-     */
-    for(int i =0;i < allocatedChunks.length;++i) {
-      allocatedChunks[i] = (OffHeapStoredObject) this.allocator.allocate(COMPACTION_CHUNK_SIZE);
-      allocatedChunks[i].validateFill();
-    }
-
-    /*
-     * Release some of our allocated chunks.
-     */
-    for(int i=0;i < 2;++i) {
-      allocatedChunks[i].release();
-      allocatedChunks[i].validateFill();      
-    }
-    
-    /*
-     * Now, allocate another chunk that is slightly larger than one of
-     * our initial chunks.  This should force a compaction causing our
-     * memory to look like [            ][      ].
-     */
-    OffHeapStoredObject slightlyLargerChunk = (OffHeapStoredObject) this.allocator.allocate(FORCE_COMPACTION_CHUNK_SIZE);
-    
-    /*
-     * Make sure the compacted memory has the fill validation.
-     */
-    slightlyLargerChunk.validateFill();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
deleted file mode 100644
index 135aba2..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.offheap;
-
-import static org.junit.Assert.*;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.OutOfOffHeapMemoryException;
-import com.gemstone.gemfire.cache.CacheClosedException;
-import com.gemstone.gemfire.internal.logging.NullLogWriter;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class SimpleMemoryAllocatorJUnitTest {
-  @Rule
-  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-
-  private static int round(int multiple, int v) {
-    return ((v+multiple-1)/multiple)*multiple;
-  }
-  @Test
-  public void testNullGetAllocator() {
-    try {
-      SimpleMemoryAllocatorImpl.getAllocator();
-      fail("expected CacheClosedException");
-    } catch (CacheClosedException expected) {
-    }
-  }
-  @Test
-  public void testConstructor() {
-    try {
-      SimpleMemoryAllocatorImpl.createForUnitTest(null, null, null);
-      fail("expected IllegalArgumentException");
-    } catch (IllegalArgumentException expected) {
-    }
-  }
-  @Test
-  public void testCreate() {
-    System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "false");
-    {
-      NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
-      NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
-      try {
-        SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats, 10, 950, 100, new SlabFactory() {
-     @Override
-     public Slab create(int size) {
-        throw new OutOfMemoryError("expected");
-     }
-    });
-      } catch (OutOfMemoryError expected) {
-      }
-      assertTrue(listener.isClosed());
-      assertTrue(stats.isClosed());
-     }
-    {
-      NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
-      NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
-      int MAX_SLAB_SIZE = 100;
-      try {
-        SlabFactory factory = new SlabFactory() {
-          private int createCount = 0;
-          @Override
-          public Slab create(int size) {
-            createCount++;
-            if (createCount == 1) {
-              return new SlabImpl(size);
-            } else {
-              throw new OutOfMemoryError("expected");
-            }
-          }
-        };
-        SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats, 10, 950, MAX_SLAB_SIZE, factory);
-      } catch (OutOfMemoryError expected) {
-      }
-      assertTrue(listener.isClosed());
-      assertTrue(stats.isClosed());
-    }
-    {
-      NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
-      NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
-      SlabFactory factory = new SlabFactory() {
-        @Override
-        public Slab create(int size) {
-          return new SlabImpl(size);
-        }
-      };
-      MemoryAllocator ma = 
-        SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats, 10, 950, 100, factory);
-      try {
-        assertFalse(listener.isClosed());
-        assertFalse(stats.isClosed());
-        ma.close();
-        assertTrue(listener.isClosed());
-        assertFalse(stats.isClosed());
-        listener = new NullOutOfOffHeapMemoryListener();
-        NullOffHeapMemoryStats stats2 = new NullOffHeapMemoryStats();
-        {
-          SlabImpl slab = new SlabImpl(1024);
-          try {
-            SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats2, new SlabImpl[]{slab});
-          } catch (IllegalStateException expected) {
-            assertTrue("unexpected message: " + expected.getMessage(), 
-                expected.getMessage().equals("attempted to reuse existing off-heap memory even though new off-heap memory was allocated"));
-          } finally {
-            slab.free();
-          }
-          assertFalse(stats.isClosed());
-          assertTrue(listener.isClosed());
-          assertTrue(stats2.isClosed());
-        }
-        listener = new NullOutOfOffHeapMemoryListener();
-        stats2 = new NullOffHeapMemoryStats();
-        MemoryAllocator ma2 = SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats2, 10, 950, 100, factory);
-        assertSame(ma, ma2);
-        assertTrue(stats.isClosed());
-        assertFalse(listener.isClosed());
-        assertFalse(stats2.isClosed());
-        stats = stats2;
-        ma.close();
-        assertTrue(listener.isClosed());
-        assertFalse(stats.isClosed());
-      } finally {
-        SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-      }
-      assertTrue(stats.isClosed());
-    }
-  }
-  @Test
-  public void testBasics() {
-    int BATCH_SIZE = 1;
-    int TINY_MULTIPLE = FreeListManager.TINY_MULTIPLE;
-    int HUGE_MULTIPLE = FreeListManager.HUGE_MULTIPLE;
-    int perObjectOverhead = OffHeapStoredObject.HEADER_SIZE;
-    int maxTiny = FreeListManager.MAX_TINY-perObjectOverhead;
-    int minHuge = maxTiny+1;
-    int TOTAL_MEM = (maxTiny+perObjectOverhead)*BATCH_SIZE /*+ (maxBig+perObjectOverhead)*BATCH_SIZE*/ + round(TINY_MULTIPLE, minHuge+1+perObjectOverhead)*BATCH_SIZE + (TINY_MULTIPLE+perObjectOverhead)*BATCH_SIZE /*+ (MIN_BIG_SIZE+perObjectOverhead)*BATCH_SIZE*/ + round(TINY_MULTIPLE, minHuge+perObjectOverhead+1);
-    SlabImpl slab = new SlabImpl(TOTAL_MEM);
-    try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
-      assertEquals(TOTAL_MEM, ma.getFreeMemory());
-      assertEquals(TOTAL_MEM, ma.freeList.getFreeFragmentMemory());
-      assertEquals(0, ma.freeList.getFreeTinyMemory());
-      assertEquals(0, ma.freeList.getFreeHugeMemory());
-      StoredObject tinymc = ma.allocate(maxTiny);
-      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-      assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead)*(BATCH_SIZE-1), ma.freeList.getFreeTinyMemory());
-      StoredObject hugemc = ma.allocate(minHuge);
-      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, minHuge+perObjectOverhead)/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-      long freeSlab = ma.freeList.getFreeFragmentMemory();
-      long oldFreeHugeMemory = ma.freeList.getFreeHugeMemory();
-      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*(BATCH_SIZE-1), oldFreeHugeMemory);
-      hugemc.release();
-      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead), ma.freeList.getFreeHugeMemory()-oldFreeHugeMemory);
-      assertEquals(TOTAL_MEM/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-      long oldFreeTinyMemory = ma.freeList.getFreeTinyMemory();
-      tinymc.release();
-      assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.freeList.getFreeTinyMemory()-oldFreeTinyMemory);
-      assertEquals(TOTAL_MEM, ma.getFreeMemory());
-      // now lets reallocate from the free lists
-      tinymc = ma.allocate(maxTiny);
-      assertEquals(oldFreeTinyMemory, ma.freeList.getFreeTinyMemory());
-      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-      hugemc = ma.allocate(minHuge);
-      assertEquals(oldFreeHugeMemory, ma.freeList.getFreeHugeMemory());
-      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, minHuge+perObjectOverhead)/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-      hugemc.release();
-      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead), ma.freeList.getFreeHugeMemory()-oldFreeHugeMemory);
-      assertEquals(TOTAL_MEM/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-      tinymc.release();
-      assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.freeList.getFreeTinyMemory()-oldFreeTinyMemory);
-      assertEquals(TOTAL_MEM, ma.getFreeMemory());
-      // None of the reallocates should have come from the slab.
-      assertEquals(freeSlab, ma.freeList.getFreeFragmentMemory());
-      tinymc = ma.allocate(1);
-      assertEquals(round(TINY_MULTIPLE, 1+perObjectOverhead), tinymc.getSize());
-      assertEquals(freeSlab-(round(TINY_MULTIPLE, 1+perObjectOverhead)*BATCH_SIZE), ma.freeList.getFreeFragmentMemory());
-      freeSlab = ma.freeList.getFreeFragmentMemory();
-      tinymc.release();
-      assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead)+(round(TINY_MULTIPLE, 1+perObjectOverhead)*BATCH_SIZE), ma.freeList.getFreeTinyMemory()-oldFreeTinyMemory);
-      
-      hugemc = ma.allocate(minHuge+1);
-      assertEquals(round(TINY_MULTIPLE, minHuge+1+perObjectOverhead), hugemc.getSize());
-      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*(BATCH_SIZE-1), ma.freeList.getFreeHugeMemory());
-      hugemc.release();
-      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*BATCH_SIZE, ma.freeList.getFreeHugeMemory());
-      hugemc = ma.allocate(minHuge);
-      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*(BATCH_SIZE-1), ma.freeList.getFreeHugeMemory());
-      if (BATCH_SIZE > 1) {
-        StoredObject hugemc2 = ma.allocate(minHuge);
-        assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*(BATCH_SIZE-2), ma.freeList.getFreeHugeMemory());
-        hugemc2.release();
-        assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*(BATCH_SIZE-1), ma.freeList.getFreeHugeMemory());
-      }
-      hugemc.release();
-      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*BATCH_SIZE, ma.freeList.getFreeHugeMemory());
-      // now that we do compaction the following allocate works.
-      hugemc = ma.allocate(minHuge + HUGE_MULTIPLE + HUGE_MULTIPLE-1);
-    } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-    }
-  }
-  
-  @Test
-  public void testChunkCreateDirectByteBuffer() {
-    SlabImpl slab = new SlabImpl(1024*1024);
-    try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
-      ByteBuffer bb = ByteBuffer.allocate(1024);
-      for (int i=0; i < 1024; i++) {
-        bb.put((byte) i);
-      }
-      bb.position(0);
-      OffHeapStoredObject c = (OffHeapStoredObject) ma.allocateAndInitialize(bb.array(), false, false);
-      assertEquals(1024, c.getDataSize());
-      if (!Arrays.equals(bb.array(), c.getRawBytes())) {
-        fail("arrays are not equal. Expected " + Arrays.toString(bb.array()) + " but found: " + Arrays.toString(c.getRawBytes()));
-      }
-      ByteBuffer dbb = c.createDirectByteBuffer();
-      assertEquals(true, dbb.isDirect());
-      assertEquals(bb, dbb);
-    } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-    }
-  }
-  
-  @Test
-  public void testDebugLog() {
-    SimpleMemoryAllocatorImpl.debugLog("test debug log", false);
-    SimpleMemoryAllocatorImpl.debugLog("test debug log", true);
-  }
-  @Test
-  public void testGetLostChunks() {
-    SlabImpl slab = new SlabImpl(1024*1024);
-    try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
-      assertEquals(Collections.emptyList(), ma.getLostChunks());
-    } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-    }
-  }
-  @Test
-  public void testFindSlab() {
-    final int SLAB_SIZE = 1024*1024;
-    SlabImpl slab = new SlabImpl(SLAB_SIZE);
-    try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
-      assertEquals(0, ma.findSlab(slab.getMemoryAddress()));
-      assertEquals(0, ma.findSlab(slab.getMemoryAddress()+SLAB_SIZE-1));
-      try {
-        ma.findSlab(slab.getMemoryAddress()-1);
-        fail("expected IllegalStateException");
-      } catch (IllegalStateException expected) {
-      }
-      try {
-        ma.findSlab(slab.getMemoryAddress()+SLAB_SIZE);
-        fail("expected IllegalStateException");
-      } catch (IllegalStateException expected) {
-      }
-    } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-    }
-  }
-  @Test
-  public void testValidateAddressAndSize() {
-    final int SLAB_SIZE = 1024*1024;
-    SlabImpl slab = new SlabImpl(SLAB_SIZE);
-    try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
-      try {
-        SimpleMemoryAllocatorImpl.validateAddress(0L);
-        fail("expected IllegalStateException");
-      } catch (IllegalStateException expected) {
-        assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().contains("addr was smaller than expected"));
-      }
-      try {
-        SimpleMemoryAllocatorImpl.validateAddress(1L);
-        fail("expected IllegalStateException");
-      } catch (IllegalStateException expected) {
-        assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().contains("Valid addresses must be in one of the following ranges:"));
-      }
-      SimpleMemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), SLAB_SIZE, false);
-      SimpleMemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), SLAB_SIZE, true);
-      SimpleMemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), -1, true);
-      try {
-        SimpleMemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress()-1, SLAB_SIZE, true);
-        fail("expected IllegalStateException");
-      } catch (IllegalStateException expected) {
-        assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().equals(" address 0x" + Long.toString(slab.getMemoryAddress()-1, 16) + " does not address the original slab memory"));
-      }
-      try {
-        SimpleMemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), SLAB_SIZE+1, true);
-        fail("expected IllegalStateException");
-      } catch (IllegalStateException expected) {
-        assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().equals(" address 0x" + Long.toString(slab.getMemoryAddress()+SLAB_SIZE, 16) + " does not address the original slab memory"));
-      }
-    } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-    }
-  }
-  @Test
-  public void testMemoryInspection() {
-    final int SLAB_SIZE = 1024*1024;
-    SlabImpl slab = new SlabImpl(SLAB_SIZE);
-    try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
-      MemoryInspector inspector = ma.getMemoryInspector();
-      assertNotNull(inspector);
-      assertEquals(null, inspector.getFirstBlock());
-      assertEquals(Collections.emptyList(), inspector.getSnapshot());
-      assertEquals(Collections.emptyList(), inspector.getAllocatedBlocks());
-      assertEquals(null, inspector.getBlockAfter(null));
-      inspector.createSnapshot();
-      // call this twice for code coverage
-      inspector.createSnapshot();
-      try {
-        assertEquals(inspector.getAllBlocks(), inspector.getSnapshot());
-        MemoryBlock firstBlock = inspector.getFirstBlock();
-        assertNotNull(firstBlock);
-        assertEquals(1024*1024, firstBlock.getBlockSize());
-        assertEquals("N/A", firstBlock.getDataType());
-        assertEquals(-1, firstBlock.getFreeListId());
-        assertTrue(firstBlock.getAddress() > 0);
-        assertNull(firstBlock.getNextBlock());
-        assertEquals(0, firstBlock.getRefCount());
-        assertEquals(0, firstBlock.getSlabId());
-        assertEquals(MemoryBlock.State.UNUSED, firstBlock.getState());
-        assertFalse(firstBlock.isCompressed());
-        assertFalse(firstBlock.isSerialized());
-        assertEquals(null, inspector.getBlockAfter(firstBlock));
-      } finally {
-        inspector.clearSnapshot();
-      }
-    } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-    }
-  }
-
-  @Test
-  public void testClose() {
-    System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "false");
-    SlabImpl slab = new SlabImpl(1024*1024);
-    boolean freeSlab = true;
-    SlabImpl[] slabs = new SlabImpl[]{slab};
-    try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), slabs);
-      ma.close();
-      ma.close();
-      System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "true");
-      try {
-        ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), slabs);
-        ma.close();
-        freeSlab = false;
-        ma.close();
-      } finally {
-        System.clearProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY);
-      }
-    } finally {
-      if (freeSlab) {
-        SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-      }
-    }
-    
-  }
-  
-  @Test
-  public void testCompaction() {
-    final int perObjectOverhead = OffHeapStoredObject.HEADER_SIZE;
-    final int BIG_ALLOC_SIZE = 150000;
-    final int SMALL_ALLOC_SIZE = BIG_ALLOC_SIZE/2;
-    final int TOTAL_MEM = BIG_ALLOC_SIZE;
-    SlabImpl slab = new SlabImpl(TOTAL_MEM);
-    try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
-      StoredObject bmc = ma.allocate(BIG_ALLOC_SIZE-perObjectOverhead);
-      try {
-        StoredObject smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
-        fail("Expected out of memory");
-      } catch (OutOfOffHeapMemoryException expected) {
-      }
-      bmc.release();
-      assertEquals(TOTAL_MEM, ma.freeList.getFreeMemory());
-      StoredObject smc1 = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
-      StoredObject smc2 = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
-      smc2.release();
-      assertEquals(TOTAL_MEM-SMALL_ALLOC_SIZE, ma.freeList.getFreeMemory());
-      try {
-        bmc = ma.allocate(BIG_ALLOC_SIZE-perObjectOverhead);
-        fail("Expected out of memory");
-      } catch (OutOfOffHeapMemoryException expected) {
-      }
-      smc1.release();
-      assertEquals(TOTAL_MEM, ma.freeList.getFreeMemory());
-      bmc = ma.allocate(BIG_ALLOC_SIZE-perObjectOverhead);
-      bmc.release();
-      assertEquals(TOTAL_MEM, ma.freeList.getFreeMemory());
-      ArrayList<StoredObject> mcs = new ArrayList<StoredObject>();
-      for (int i=0; i < BIG_ALLOC_SIZE/(8+perObjectOverhead); i++) {
-        mcs.add(ma.allocate(8));
-      }
-      checkMcs(mcs);
-      assertEquals(0, ma.freeList.getFreeMemory());
-      try {
-        ma.allocate(8);
-        fail("expected out of memory");
-      } catch (OutOfOffHeapMemoryException expected) {
-      }
-      mcs.remove(0).release(); // frees 8+perObjectOverhead
-      assertEquals(8+perObjectOverhead, ma.freeList.getFreeMemory());
-      mcs.remove(0).release(); // frees 8+perObjectOverhead
-      assertEquals((8+perObjectOverhead)*2, ma.freeList.getFreeMemory());
-      ma.allocate(16).release(); // allocates and frees 16+perObjectOverhead; still have perObjectOverhead
-      assertEquals((8+perObjectOverhead)*2, ma.freeList.getFreeMemory());
-      mcs.remove(0).release(); // frees 8+perObjectOverhead
-      assertEquals((8+perObjectOverhead)*3, ma.freeList.getFreeMemory());
-      mcs.remove(0).release(); // frees 8+perObjectOverhead
-      assertEquals((8+perObjectOverhead)*4, ma.freeList.getFreeMemory());
-      // At this point I should have 8*4 + perObjectOverhead*4 of free memory
-      ma.allocate(8*4+perObjectOverhead*3).release();
-      assertEquals((8+perObjectOverhead)*4, ma.freeList.getFreeMemory());
-      mcs.remove(0).release(); // frees 8+perObjectOverhead
-      assertEquals((8+perObjectOverhead)*5, ma.freeList.getFreeMemory());
-      // At this point I should have 8*5 + perObjectOverhead*5 of free memory
-      try {
-        ma.allocate((8*5+perObjectOverhead*4)+1);
-        fail("expected out of memory");
-      } catch (OutOfOffHeapMemoryException expected) {
-      }
-      mcs.remove(0).release(); // frees 8+perObjectOverhead
-      assertEquals((8+perObjectOverhead)*6, ma.freeList.getFreeMemory());
-      checkMcs(mcs);
-      // At this point I should have 8*6 + perObjectOverhead*6 of free memory
-      StoredObject mc24 = ma.allocate(24);
-      checkMcs(mcs);
-      assertEquals((8+perObjectOverhead)*6 - (24+perObjectOverhead), ma.freeList.getFreeMemory());
-      // At this point I should have 8*3 + perObjectOverhead*5 of free memory
-      StoredObject mc16 = ma.allocate(16);
-      checkMcs(mcs);
-      assertEquals((8+perObjectOverhead)*6 - (24+perObjectOverhead) - (16+perObjectOverhead), ma.freeList.getFreeMemory());
-      // At this point I should have 8*1 + perObjectOverhead*4 of free memory
-      mcs.add(ma.allocate(8));
-      checkMcs(mcs);
-      assertEquals((8+perObjectOverhead)*6 - (24+perObjectOverhead) - (16+perObjectOverhead) - (8+perObjectOverhead), ma.freeList.getFreeMemory());
-      // At this point I should have 8*0 + perObjectOverhead*3 of free memory
-      StoredObject mcDO = ma.allocate(perObjectOverhead*2);
-      checkMcs(mcs);
-      // At this point I should have 8*0 + perObjectOverhead*0 of free memory
-      assertEquals(0, ma.freeList.getFreeMemory());
-      try {
-        ma.allocate(1);
-        fail("expected out of memory");
-      } catch (OutOfOffHeapMemoryException expected) {
-      }
-      checkMcs(mcs);
-      assertEquals(0, ma.freeList.getFreeMemory());
-      mcDO.release();
-      assertEquals((perObjectOverhead*3), ma.freeList.getFreeMemory());
-      mcs.remove(mcs.size()-1).release();
-      assertEquals((perObjectOverhead*3)+(8+perObjectOverhead), ma.freeList.getFreeMemory());
-      mc16.release();
-      assertEquals((perObjectOverhead*3)+(8+perObjectOverhead)+(16+perObjectOverhead), ma.freeList.getFreeMemory());
-      mc24.release();
-      assertEquals((perObjectOverhead*3)+(8+perObjectOverhead)+(16+perObjectOverhead)+(24+perObjectOverhead), ma.freeList.getFreeMemory());
-      
-      long freeMem = ma.freeList.getFreeMemory();
-      for (StoredObject mc: mcs) {
-        mc.release();
-        assertEquals(freeMem+(8+perObjectOverhead), ma.freeList.getFreeMemory());
-        freeMem += (8+perObjectOverhead);
-      }
-      mcs.clear();
-      assertEquals(TOTAL_MEM, ma.freeList.getFreeMemory());
-      bmc = ma.allocate(BIG_ALLOC_SIZE-perObjectOverhead);
-      bmc.release();
-    } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-    }
-  }
-  
-  long expectedMemoryUsage;
-  boolean memoryUsageEventReceived;
-  @Test
-  public void testUsageEventListener() {
-    final int perObjectOverhead = OffHeapStoredObject.HEADER_SIZE;
-    final int SMALL_ALLOC_SIZE = 1000;
-    SlabImpl slab = new SlabImpl(3000);
-    try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
-      MemoryUsageListener listener = new MemoryUsageListener() {
-        @Override
-        public void updateMemoryUsed(final long bytesUsed) {
-          SimpleMemoryAllocatorJUnitTest.this.memoryUsageEventReceived = true;
-          assertEquals(SimpleMemoryAllocatorJUnitTest.this.expectedMemoryUsage, bytesUsed);
-        }
-      };
-      ma.addMemoryUsageListener(listener);
-      
-      this.expectedMemoryUsage = SMALL_ALLOC_SIZE;
-      this.memoryUsageEventReceived = false;
-      StoredObject smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
-      assertEquals(true, this.memoryUsageEventReceived);
-      
-      this.expectedMemoryUsage = SMALL_ALLOC_SIZE * 2;
-      this.memoryUsageEventReceived = false;
-      smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
-      assertEquals(true, this.memoryUsageEventReceived);
-      
-      MemoryUsageListener unaddedListener = new MemoryUsageListener() {
-        @Override
-        public void updateMemoryUsed(final long bytesUsed) {
-          throw new IllegalStateException("Should never be called");
-        }
-      };
-      ma.removeMemoryUsageListener(unaddedListener);
-      
-      ma.removeMemoryUsageListener(listener);
-      
-      ma.removeMemoryUsageListener(unaddedListener);
-
-      this.expectedMemoryUsage = SMALL_ALLOC_SIZE * 2;
-      this.memoryUsageEventReceived = false;
-      smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
-      assertEquals(false, this.memoryUsageEventReceived);
-      
-    } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-    }
-  }
-  private void checkMcs(ArrayList<StoredObject> mcs) {
-    for (StoredObject mc: mcs) {
-      assertEquals(8+8, mc.getSize());
-    }
-  }
-  
-  @Test
-  public void testOutOfOffHeapMemory() {
-    final int perObjectOverhead = OffHeapStoredObject.HEADER_SIZE;
-    final int BIG_ALLOC_SIZE = 150000;
-    final int SMALL_ALLOC_SIZE = BIG_ALLOC_SIZE/2;
-    final int TOTAL_MEM = BIG_ALLOC_SIZE;
-    final SlabImpl slab = new SlabImpl(TOTAL_MEM);
-    final AtomicReference<OutOfOffHeapMemoryException> ooom = new AtomicReference<OutOfOffHeapMemoryException>();
-    final OutOfOffHeapMemoryListener oooml = new OutOfOffHeapMemoryListener() {
-      @Override
-      public void outOfOffHeapMemory(OutOfOffHeapMemoryException cause) {
-        ooom.set(cause);
-      }
-      @Override
-      public void close() {
-      }
-    };
-    try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(oooml, new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
-      // make a big allocation
-      StoredObject bmc = ma.allocate(BIG_ALLOC_SIZE-perObjectOverhead);
-      assertNull(ooom.get());
-      // drive the ma to ooom with small allocations
-      try {
-        StoredObject smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
-        fail("Expected out of memory");
-      } catch (OutOfOffHeapMemoryException expected) {
-      }
-      assertNotNull(ooom.get());
-      assertTrue(ooom.get().getMessage().contains("Out of off-heap memory. Could not allocate size of "));
-    } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TinyMemoryBlockJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TinyMemoryBlockJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TinyMemoryBlockJUnitTest.java
index d444865..681bec0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TinyMemoryBlockJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TinyMemoryBlockJUnitTest.java
@@ -39,7 +39,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 @Category(UnitTest.class)
 public class TinyMemoryBlockJUnitTest {
 
-  private SimpleMemoryAllocatorImpl ma;
+  private MemoryAllocatorImpl ma;
   private OutOfOffHeapMemoryListener ooohml;
   private OffHeapMemoryStats stats;
 
@@ -50,7 +50,7 @@ public class TinyMemoryBlockJUnitTest {
   };
 
   private static class TestableFreeListManager extends FreeListManager {
-    TestableFreeListManager(SimpleMemoryAllocatorImpl ma, final Slab[] slabs) {
+    TestableFreeListManager(MemoryAllocatorImpl ma, final Slab[] slabs) {
       super (ma, slabs);
     }
   }
@@ -73,12 +73,12 @@ public class TinyMemoryBlockJUnitTest {
   public void setUp() throws Exception {
     ooohml = mock(OutOfOffHeapMemoryListener.class);
     stats = mock(OffHeapMemoryStats.class);
-    ma = (SimpleMemoryAllocatorImpl) SimpleMemoryAllocatorImpl.createForUnitTest(ooohml, stats, slabs);
+    ma = (MemoryAllocatorImpl) MemoryAllocatorImpl.createForUnitTest(ooohml, stats, slabs);
   }
 
   @After
   public void tearDown() throws Exception {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    MemoryAllocatorImpl.freeOffHeapMemory();
   }
 
   protected Object getValue() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TxReleasesOffHeapOnCloseJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TxReleasesOffHeapOnCloseJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TxReleasesOffHeapOnCloseJUnitTest.java
index 2bc5759..d8999fe 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TxReleasesOffHeapOnCloseJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TxReleasesOffHeapOnCloseJUnitTest.java
@@ -49,7 +49,7 @@ public class TxReleasesOffHeapOnCloseJUnitTest {
   @Test
   public void testTxReleasesOffHeapOnClose() {
     createCache();
-    SimpleMemoryAllocatorImpl sma = SimpleMemoryAllocatorImpl.getAllocator();
+    MemoryAllocatorImpl sma = MemoryAllocatorImpl.getAllocator();
     RegionFactory rf = cache.createRegionFactory();
     rf.setOffHeap(true);
     Region r = rf.create("testTxReleasesOffHeapOnClose");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
index 8380f57..28e0439 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
@@ -23,7 +23,7 @@ import java.nio.ByteBuffer;
 import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.internal.offheap.OffHeapStoredObject;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.ByteSource;
 import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.ByteSourceFactory;
@@ -34,7 +34,7 @@ public class OffHeapByteBufferByteSourceJUnitTest extends OffHeapByteSourceJUnit
   
   @Override
   protected ByteSource createByteSource(byte[] bytes) {
-    StoredObject so = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false);
+    StoredObject so = MemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false);
     if (so instanceof OffHeapStoredObject) {
       OffHeapStoredObject c = (OffHeapStoredObject) so;
       ByteBuffer bb = c.createDirectByteBuffer();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
index 2111f79..7946b7e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
@@ -23,7 +23,7 @@ import org.junit.experimental.categories.Category;
 import com.gemstone.gemfire.internal.offheap.OffHeapStoredObject;
 import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
 import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.offheap.SlabImpl;
 import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.ByteSource;
@@ -36,12 +36,12 @@ public class OffHeapByteSourceJUnitTest extends ByteSourceJUnitTest {
 
   @Before
   public void setUp() throws Exception {
-    SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
+    MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
   }
 
   @After
   public void tearDown() throws Exception {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    MemoryAllocatorImpl.freeOffHeapMemory();
   }
 
   @Override
@@ -51,7 +51,7 @@ public class OffHeapByteSourceJUnitTest extends ByteSourceJUnitTest {
   
   @Override
   protected ByteSource createByteSource(byte[] bytes) {
-    StoredObject so = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false);
+    StoredObject so = MemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false);
     if (so instanceof OffHeapStoredObject) {
       // bypass the factory to make sure that OffHeapByteSource is tested
       return new OffHeapByteSource(so);



[21/26] incubator-geode git commit: GEODE-1017: change off-memory from compaction to defragmentation

Posted by kl...@apache.org.
GEODE-1017: change off-memory from compaction to defragmentation

 Replaced references of compaction with `defragmentation`, to better
 convey the intent behind the operation.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 155f87d5ff3b8b5936376c0dce7aba4e214b3672
Parents: 67f0e2c
Author: Sai Boorlagadda <sb...@pivotal.io>
Authored: Wed Mar 16 13:07:49 2016 -0700
Committer: Sai Boorlagadda <sb...@pivotal.io>
Committed: Thu Mar 17 10:07:21 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/offheap/Fragment.java      |  2 +-
 .../internal/offheap/FreeListManager.java       | 36 +++++------
 .../internal/offheap/MemoryAllocatorImpl.java   |  2 +-
 .../internal/offheap/OffHeapMemoryStats.java    |  8 +--
 .../internal/offheap/OffHeapStorage.java        | 58 ++++++++---------
 .../internal/beans/MemberMBeanBridge.java       |  2 +-
 .../internal/offheap/FreeListManagerTest.java   | 66 ++++++++++----------
 .../MemoryAllocatorFillPatternJUnitTest.java    | 24 +++----
 .../offheap/MemoryAllocatorJUnitTest.java       |  4 +-
 .../offheap/NullOffHeapMemoryStats.java         |  8 +--
 .../internal/offheap/OffHeapRegionBase.java     |  4 +-
 .../offheap/OffHeapStorageJUnitTest.java        | 18 +++---
 12 files changed, 116 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
index 0ea6cf8..b4f827b 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
@@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
  * at the end. The freeIdx keeps track of the first byte of free memory in
  * the fragment.
  * The base memory address and the total size of a fragment never change.
- * During compaction fragments go away and are recreated.
+ * During defragmentation fragments go away and are recreated.
  * 
  * @author darrel
  *

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
index c943a7e..6de7be9 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
@@ -223,7 +223,7 @@ public class FreeListManager {
           return result;
         }
       }
-    } while (compact(chunkSize));
+    } while (defragment(chunkSize));
     // We tried all the fragments and didn't find any free memory.
     logOffHeapState(chunkSize);
     final OutOfOffHeapMemoryException failure = new OutOfOffHeapMemoryException("Out of off-heap memory. Could not allocate size of " + chunkSize);
@@ -240,7 +240,7 @@ public class FreeListManager {
 
   void logOffHeapState(Logger lw, int chunkSize) {
     OffHeapMemoryStats stats = this.ma.getStats();
-    lw.info("OutOfOffHeapMemory allocating size of " + chunkSize + ". allocated=" + this.allocatedSize.get() + " compactions=" + this.compactCount.get() + " objects=" + stats.getObjects() + " free=" + stats.getFreeMemory() + " fragments=" + stats.getFragments() + " largestFragment=" + stats.getLargestFragment() + " fragmentation=" + stats.getFragmentation());
+    lw.info("OutOfOffHeapMemory allocating size of " + chunkSize + ". allocated=" + this.allocatedSize.get() + " defragmentations=" + this.defragmentationCount.get() + " objects=" + stats.getObjects() + " free=" + stats.getFreeMemory() + " fragments=" + stats.getFragments() + " largestFragment=" + stats.getLargestFragment() + " fragmentation=" + stats.getFragmentation());
     logFragmentState(lw);
     logTinyState(lw);
     logHugeState(lw);
@@ -268,7 +268,7 @@ public class FreeListManager {
     }
   }
 
-  protected final AtomicInteger compactCount = new AtomicInteger();
+  protected final AtomicInteger defragmentationCount = new AtomicInteger();
   /*
    * Set this to "true" to perform data integrity checks on allocated and reused Chunks.  This may clobber 
    * performance so turn on only when necessary.
@@ -302,24 +302,24 @@ public class FreeListManager {
   }
   public final static int MAX_TINY = TINY_MULTIPLE*TINY_FREE_LIST_COUNT;
   /**
-   * Compacts memory and returns true if enough memory to allocate chunkSize
+   * Defragments memory and returns true if enough memory to allocate chunkSize
    * is freed. Otherwise returns false;
    * TODO OFFHEAP: what should be done about contiguous chunks that end up being bigger than 2G?
    * Currently if we are given slabs bigger than 2G or that just happen to be contiguous and add
-   * up to 2G then the compactor may unify them together into a single Chunk and our 32-bit chunkSize
+   * up to 2G then the FreeListManager may unify them together into a single Chunk and our 32-bit chunkSize
    * field will overflow. This code needs to detect this and just create a chunk of 2G and then start
    * a new one.
    * Or to prevent it from happening we could just check the incoming slabs and throw away a few bytes
    * to keep them from being contiguous.
    */
-  boolean compact(int chunkSize) {
-    final long startCompactionTime = this.ma.getStats().startCompaction();
-    final int countPreSync = this.compactCount.get();
-    afterCompactCountFetched();
+  boolean defragment(int chunkSize) {
+    final long startDefragmentationTime = this.ma.getStats().startDefragmentation();
+    final int countPreSync = this.defragmentationCount.get();
+    afterDefragmentationCountFetched();
     try {
       synchronized (this) {
-        if (this.compactCount.get() != countPreSync) {
-          // someone else did a compaction while we waited on the sync.
+        if (this.defragmentationCount.get() != countPreSync) {
+          // someone else did a defragmentation while we waited on the sync.
           // So just return true causing the caller to retry the allocation.
           return true;
         }
@@ -432,8 +432,8 @@ public class FreeListManager {
 
         fillFragments();
 
-        // Signal any waiters that a compaction happened.
-        this.compactCount.incrementAndGet();
+        // Signal any waiters that a defragmentation happened.
+        this.defragmentationCount.incrementAndGet();
 
         this.ma.getStats().setLargestFragment(largestFragment);
         this.ma.getStats().setFragments(tmp.size());        
@@ -442,14 +442,14 @@ public class FreeListManager {
         return result;
       } // sync
     } finally {
-      this.ma.getStats().endCompaction(startCompactionTime);
+      this.ma.getStats().endDefragmentation(startDefragmentationTime);
     }
   }
 
   /**
    * Unit tests override this method to get better test coverage
    */
-  protected void afterCompactCountFetched() {
+  protected void afterDefragmentationCountFetched() {
   }
   
   static void verifyOffHeapAlignment(int tinyMultiple) {
@@ -519,7 +519,7 @@ public class FreeListManager {
         diff = f.getSize() - offset;
       } while (diff >= OffHeapStoredObject.MIN_CHUNK_SIZE && !f.allocate(offset, offset+diff));
       if (diff < OffHeapStoredObject.MIN_CHUNK_SIZE) {
-        // If diff > 0 then that memory will be lost during compaction.
+        // If diff > 0 then that memory will be lost during defragmentation.
         // This should never happen since we keep the sizes rounded
         // based on MIN_CHUNK_SIZE.
         assert diff == 0;
@@ -531,7 +531,7 @@ public class FreeListManager {
       result.offer(chunkAddr);
     }
     // All the fragments have been turned in to chunks so now clear them
-    // The compaction will create new fragments.
+    // The defragmentation will create new fragments.
     this.fragmentList.clear();
     if (!result.isEmpty()) {
       l.add(result);
@@ -567,7 +567,7 @@ public class FreeListManager {
     try {
       fragment = this.fragmentList.get(fragIdx);
     } catch (IndexOutOfBoundsException ignore) {
-      // A concurrent compaction can cause this.
+      // A concurrent defragmentation can cause this.
       return null;
     }
     boolean retryFragment;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorImpl.java
index 2050dd4..9135efd 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorImpl.java
@@ -47,7 +47,7 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
  * We also keep lists of any chunk that have been allocated and freed.
  * An allocation will always try to find a chunk in a free list that is a close fit to the requested size.
  * If no close fits exist then it allocates the next slice from the front of one the original large chunks.
- * If we can not find enough free memory then all the existing free memory is compacted.
+ * If we can not find enough free memory then all the existing free memory is defragmented.
  * If we still do not have enough to make the allocation an exception is thrown.
  * 
  * @author darrel

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapMemoryStats.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapMemoryStats.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapMemoryStats.java
index 790e43d..f19d509 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapMemoryStats.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapMemoryStats.java
@@ -33,8 +33,8 @@ public interface OffHeapMemoryStats {
   public void incReads();
   public void setFragments(long value);
   public void setLargestFragment(int value);
-  public long startCompaction();
-  public void endCompaction(long start);
+  public long startDefragmentation();
+  public void endDefragmentation(long start);
   public void setFragmentation(int value);
   
   public long getFreeMemory();
@@ -42,11 +42,11 @@ public interface OffHeapMemoryStats {
   public long getUsedMemory();
   public long getReads();
   public int getObjects();
-  public int getCompactions();
+  public int getDefragmentations();
   public long getFragments();
   public int getLargestFragment();
   public int getFragmentation();
-  public long getCompactionTime();
+  public long getDefragmentationTime();
   
   public Statistics getStats();
   public void close();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
index 2bdcfba..0976259 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
@@ -56,10 +56,10 @@ public class OffHeapStorage implements OffHeapMemoryStats {
   private static final int usedMemoryId;
   private static final int objectsId;
   private static final int readsId;
-  private static final int compactionsId;
+  private static final int defragmentationId;
   private static final int fragmentsId;
   private static final int largestFragmentId;
-  private static final int compactionTimeId;
+  private static final int defragmentationTimeId;
   private static final int fragmentationId;
   // NOTE!!!! When adding new stats make sure and update the initialize method on this class
   
@@ -68,19 +68,19 @@ public class OffHeapStorage implements OffHeapMemoryStats {
     final StatisticsTypeFactory f = StatisticsTypeFactoryImpl.singleton();
     
     final String usedMemoryDesc = "The amount of off-heap memory, in bytes, that is being used to store data.";
-    final String compactionsDesc = "The total number of times off-heap memory has been compacted.";
-    final String compactionTimeDesc = "The total time spent compacting off-heap memory.";
-    final String fragmentationDesc = "The percentage of off-heap free memory that is fragmented.  Updated every time a compaction is performed.";
-    final String fragmentsDesc = "The number of fragments of free off-heap memory. Updated every time a compaction is done.";
+    final String defragmentationDesc = "The total number of times off-heap memory has been defragmented.";
+    final String defragmentationTimeDesc = "The total time spent defragmenting off-heap memory.";
+    final String fragmentationDesc = "The percentage of off-heap free memory that is fragmented.  Updated every time a defragmentation is performed.";
+    final String fragmentsDesc = "The number of fragments of free off-heap memory. Updated every time a defragmentation is done.";
     final String freeMemoryDesc = "The amount of off-heap memory, in bytes, that is not being used.";
-    final String largestFragmentDesc = "The largest fragment of memory found by the last compaction of off heap memory. Updated every time a compaction is done.";
+    final String largestFragmentDesc = "The largest fragment of memory found by the last defragmentation of off heap memory. Updated every time a defragmentation is done.";
     final String objectsDesc = "The number of objects stored in off-heap memory.";
     final String readsDesc = "The total number of reads of off-heap memory. Only reads of a full object increment this statistic. If only a part of the object is read this statistic is not incremented.";
     final String maxMemoryDesc = "The maximum amount of off-heap memory, in bytes. This is the amount of memory allocated at startup and does not change.";
 
     final String usedMemory = "usedMemory";
-    final String compactions = "compactions";
-    final String compactionTime = "compactionTime";
+    final String defragmentations = "defragmentations";
+    final String defragmentationTime = "defragmentationTime";
     final String fragmentation = "fragmentation";
     final String fragments = "fragments";
     final String freeMemory = "freeMemory";
@@ -94,8 +94,8 @@ public class OffHeapStorage implements OffHeapMemoryStats {
         statsTypeDescription,
         new StatisticDescriptor[] {
             f.createLongGauge(usedMemory, usedMemoryDesc, "bytes"),
-            f.createIntCounter(compactions, compactionsDesc, "compactions"),
-            f.createLongCounter(compactionTime, compactionTimeDesc, "nanoseconds", false),
+            f.createIntCounter(defragmentations, defragmentationDesc, "defragmentations"),
+            f.createLongCounter(defragmentationTime, defragmentationTimeDesc, "nanoseconds", false),
             f.createIntGauge(fragmentation, fragmentationDesc, "percentage"),
             f.createLongGauge(fragments, fragmentsDesc, "fragments"),
             f.createLongGauge(freeMemory, freeMemoryDesc, "bytes"),
@@ -107,8 +107,8 @@ public class OffHeapStorage implements OffHeapMemoryStats {
     );
     
     usedMemoryId = statsType.nameToId(usedMemory);
-    compactionsId = statsType.nameToId(compactions);
-    compactionTimeId = statsType.nameToId(compactionTime);
+    defragmentationId = statsType.nameToId(defragmentations);
+    defragmentationTimeId = statsType.nameToId(defragmentationTime);
     fragmentationId = statsType.nameToId(fragmentation);
     fragmentsId = statsType.nameToId(fragments);
     freeMemoryId = statsType.nameToId(freeMemory);
@@ -281,13 +281,13 @@ public class OffHeapStorage implements OffHeapMemoryStats {
     return this.stats.getLong(readsId);
   }
 
-  private void incCompactions() {
-    this.stats.incInt(compactionsId, 1);
+  private void incDefragmentations() {
+    this.stats.incInt(defragmentationId, 1);
   }
 
   @Override
-  public int getCompactions() {
-    return this.stats.getInt(compactionsId);
+  public int getDefragmentations() {
+    return this.stats.getInt(defragmentationId);
   }
 
   @Override
@@ -311,21 +311,21 @@ public class OffHeapStorage implements OffHeapMemoryStats {
   }
   
   @Override
-  public long startCompaction() {
+  public long startDefragmentation() {
     return DistributionStats.getStatTime();
   }
   
   @Override
-  public void endCompaction(long start) {
-    incCompactions();
+  public void endDefragmentation(long start) {
+    incDefragmentations();
     if (DistributionStats.enableClockStats) {
-      stats.incLong(compactionTimeId, DistributionStats.getStatTime()-start);
+      stats.incLong(defragmentationTimeId, DistributionStats.getStatTime()-start);
     }
   }  
   
   @Override
-  public long getCompactionTime() {
-    return stats.getLong(compactionTimeId);
+  public long getDefragmentationTime() {
+    return stats.getLong(defragmentationTimeId);
   }
 
   @Override
@@ -354,21 +354,21 @@ public class OffHeapStorage implements OffHeapMemoryStats {
     setUsedMemory(oldStats.getUsedMemory());
     setObjects(oldStats.getObjects());
     setReads(oldStats.getReads());
-    setCompactions(oldStats.getCompactions());
+    setDefragmentations(oldStats.getDefragmentations());
     setFragments(oldStats.getFragments());
     setLargestFragment(oldStats.getLargestFragment());
-    setCompactionTime(oldStats.getCompactionTime());
+    setDefragmentationTime(oldStats.getDefragmentationTime());
     setFragmentation(oldStats.getFragmentation());
     
     oldStats.close();
   }
 
-  private void setCompactionTime(long value) {
-    stats.setLong(compactionTimeId, value);
+  private void setDefragmentationTime(long value) {
+    stats.setLong(defragmentationTimeId, value);
   }
 
-  private void setCompactions(int value) {
-    this.stats.setInt(compactionsId, value);
+  private void setDefragmentations(int value) {
+    this.stats.setInt(defragmentationId, value);
   }
 
   private void setReads(long value) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/MemberMBeanBridge.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/MemberMBeanBridge.java b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/MemberMBeanBridge.java
index 61e328d..6c7a44f 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/MemberMBeanBridge.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/MemberMBeanBridge.java
@@ -1919,7 +1919,7 @@ public class MemberMBeanBridge {
     OffHeapMemoryStats stats = getOffHeapStats();
     
     if(null != stats) {
-      compactionTime = stats.getCompactionTime();
+      compactionTime = stats.getDefragmentationTime();
     }
     
     return compactionTime;            

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
index 950d90b..28ff3ac 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
@@ -278,7 +278,7 @@ public class FreeListManagerTest {
   }
   
   @Test
-  public void compactWithLargeChunkSizeReturnsFalse() {
+  public void defragmentWithLargeChunkSizeReturnsFalse() {
     int SMALL_SLAB = 16;
     int MEDIUM_SLAB = 128;
     Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE);
@@ -295,12 +295,12 @@ public class FreeListManagerTest {
     for (OffHeapStoredObject c: chunks) {
       OffHeapStoredObject.release(c.getAddress(), this.freeListManager);
     }
-    this.freeListManager.firstCompact = false;
-    assertThat(this.freeListManager.compact(DEFAULT_SLAB_SIZE+1)).isFalse();
+    this.freeListManager.firstDefragmentation = false;
+    assertThat(this.freeListManager.defragment(DEFAULT_SLAB_SIZE+1)).isFalse();
   }
   
   @Test
-  public void compactWithChunkSizeOfMaxSlabReturnsTrue() {
+  public void defragmentWithChunkSizeOfMaxSlabReturnsTrue() {
     int SMALL_SLAB = 16;
     int MEDIUM_SLAB = 128;
     Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE);
@@ -318,12 +318,12 @@ public class FreeListManagerTest {
       OffHeapStoredObject.release(c.getAddress(), this.freeListManager);
     }
     
-    assertThat(this.freeListManager.compact(DEFAULT_SLAB_SIZE)).isTrue();
+    assertThat(this.freeListManager.defragment(DEFAULT_SLAB_SIZE)).isTrue();
     //assertThat(this.freeListManager.getFragmentList()).hasSize(4); // TODO intermittently fails because Fragments may be merged
   }
   
   @Test
-  public void compactWithLiveChunks() {
+  public void defragmentWithLiveChunks() {
     int SMALL_SLAB = 16;
     int MEDIUM_SLAB = 128;
     Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE);
@@ -341,22 +341,22 @@ public class FreeListManagerTest {
       OffHeapStoredObject.release(c.getAddress(), this.freeListManager);
     }
     
-    assertThat(this.freeListManager.compact(DEFAULT_SLAB_SIZE/2)).isTrue();
+    assertThat(this.freeListManager.defragment(DEFAULT_SLAB_SIZE/2)).isTrue();
   }
   
   @Test
-  public void compactAfterAllocatingAll() {
+  public void defragmentAfterAllocatingAll() {
     setUpSingleSlabManager();
     OffHeapStoredObject c = freeListManager.allocate(DEFAULT_SLAB_SIZE-8);
-    this.freeListManager.firstCompact = false;
-    assertThat(this.freeListManager.compact(1)).isFalse();
-    // call compact twice for extra code coverage
-    assertThat(this.freeListManager.compact(1)).isFalse();
+    this.freeListManager.firstDefragmentation = false;
+    assertThat(this.freeListManager.defragment(1)).isFalse();
+    // call defragmen twice for extra code coverage
+    assertThat(this.freeListManager.defragment(1)).isFalse();
     assertThat(this.freeListManager.getFragmentList()).isEmpty();
   }
   
   @Test
-  public void afterAllocatingAllOneSizeCompactToAllocateDifferentSize() {
+  public void afterAllocatingAllOneSizeDefragmentToAllocateDifferentSize() {
     setUpSingleSlabManager();
     ArrayList<OffHeapStoredObject> chunksToFree = new ArrayList<>();
     ArrayList<OffHeapStoredObject> chunksToFreeLater = new ArrayList<>();
@@ -394,42 +394,42 @@ public class FreeListManagerTest {
     OffHeapStoredObject.release(c4.getAddress(), freeListManager);
     OffHeapStoredObject.release(mediumChunk1.getAddress(), freeListManager);
     OffHeapStoredObject.release(mediumChunk2.getAddress(), freeListManager);
-    this.freeListManager.firstCompact = false;
-    assertThat(freeListManager.compact(DEFAULT_SLAB_SIZE-(ALLOCATE_COUNT*32))).isFalse();
+    this.freeListManager.firstDefragmentation = false;
+    assertThat(freeListManager.defragment(DEFAULT_SLAB_SIZE-(ALLOCATE_COUNT*32))).isFalse();
     for (int i=0; i < ((256*2)/96); i++) {
       OffHeapStoredObject.release(chunksToFreeLater.get(i).getAddress(), freeListManager);
     }
-    assertThat(freeListManager.compact(DEFAULT_SLAB_SIZE-(ALLOCATE_COUNT*32))).isTrue();
+    assertThat(freeListManager.defragment(DEFAULT_SLAB_SIZE-(ALLOCATE_COUNT*32))).isTrue();
   }
   
   @Test
-  public void afterAllocatingAndFreeingCompact() {
+  public void afterAllocatingAndFreeingDefragment() {
     int slabSize = 1024*3;
     setUpSingleSlabManager(slabSize);
     OffHeapStoredObject bigChunk1 = freeListManager.allocate(slabSize/3-8);
     OffHeapStoredObject bigChunk2 = freeListManager.allocate(slabSize/3-8);
     OffHeapStoredObject bigChunk3 = freeListManager.allocate(slabSize/3-8);
-    this.freeListManager.firstCompact = false;
-    assertThat(freeListManager.compact(1)).isFalse();
+    this.freeListManager.firstDefragmentation = false;
+    assertThat(freeListManager.defragment(1)).isFalse();
     OffHeapStoredObject.release(bigChunk3.getAddress(), freeListManager);
     OffHeapStoredObject.release(bigChunk2.getAddress(), freeListManager);
     OffHeapStoredObject.release(bigChunk1.getAddress(), freeListManager);
-    assertThat(freeListManager.compact(slabSize)).isTrue();
+    assertThat(freeListManager.defragment(slabSize)).isTrue();
   }
   
   @Test
-  public void compactWithEmptyTinyFreeList() {
+  public void defragmentWithEmptyTinyFreeList() {
     setUpSingleSlabManager();
     Fragment originalFragment = this.freeListManager.getFragmentList().get(0);
     OffHeapStoredObject c = freeListManager.allocate(16);
     OffHeapStoredObject.release(c.getAddress(), this.freeListManager);
     c = freeListManager.allocate(16);
-    this.freeListManager.firstCompact = false;
-    assertThat(this.freeListManager.compact(1)).isTrue();
+    this.freeListManager.firstDefragmentation = false;
+    assertThat(this.freeListManager.defragment(1)).isTrue();
     assertThat(this.freeListManager.getFragmentList()).hasSize(1);
-    Fragment compactedFragment = this.freeListManager.getFragmentList().get(0);
-    assertThat(compactedFragment.getSize()).isEqualTo(originalFragment.getSize()-(16+8));
-    assertThat(compactedFragment.getAddress()).isEqualTo(originalFragment.getAddress()+(16+8));
+    Fragment defragmentedFragment = this.freeListManager.getFragmentList().get(0);
+    assertThat(defragmentedFragment.getSize()).isEqualTo(originalFragment.getSize()-(16+8));
+    assertThat(defragmentedFragment.getAddress()).isEqualTo(originalFragment.getAddress()+(16+8));
   }
   
   @Test
@@ -445,7 +445,7 @@ public class FreeListManagerTest {
     this.freeListManager.allocate(DEFAULT_SLAB_SIZE-8-(OffHeapStoredObject.MIN_CHUNK_SIZE-1));
     this.freeListManager.allocate(MEDIUM_SLAB-8-(OffHeapStoredObject.MIN_CHUNK_SIZE-1));
     
-    assertThat(this.freeListManager.compact(SMALL_SLAB)).isTrue();
+    assertThat(this.freeListManager.defragment(SMALL_SLAB)).isTrue();
   }
  @Test
   public void maxAllocationUsesAllMemory() {
@@ -861,13 +861,13 @@ public class FreeListManagerTest {
       return super.createFreeListForEmptySlot(freeLists, idx);
     }
 
-    public boolean firstCompact = true;
+    public boolean firstDefragmentation = true;
     @Override
-    protected void afterCompactCountFetched() {
-      if (this.firstCompact) {
-        this.firstCompact = false;
-        // Force compact into thinking a concurrent compaction happened.
-        this.compactCount.incrementAndGet();
+    protected void afterDefragmentationCountFetched() {
+      if (this.firstDefragmentation) {
+        this.firstDefragmentation = false;
+        // Force defragmentation into thinking a concurrent defragmentation happened.
+        this.defragmentationCount.incrementAndGet();
       }
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternJUnitTest.java
index f1d223d..7036187 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternJUnitTest.java
@@ -44,14 +44,14 @@ public class MemoryAllocatorFillPatternJUnitTest {
   /** Chunk size for basic huge allocation test. */
   private static final int HUGE_CHUNK_SIZE = 1024 * 200;
   
-  /** The number of chunks to allocate in order to force compaction. */
-  private static final int COMPACTION_CHUNKS = 3;
+  /** The number of chunks to allocate in order to force defragmentation. */
+  private static final int DEFRAGMENTATION_CHUNKS = 3;
   
   /** Our slab size divided in three (with some padding for safety). */
-  private static final int COMPACTION_CHUNK_SIZE = (SLAB_SIZE / COMPACTION_CHUNKS) - 1024;
+  private static final int DEFRAGMENTATION_CHUNK_SIZE = (SLAB_SIZE / DEFRAGMENTATION_CHUNKS) - 1024;
   
-  /** This should force compaction when allocated. */
-  private static final int FORCE_COMPACTION_CHUNK_SIZE = COMPACTION_CHUNK_SIZE * 2;
+  /** This should force defragmentation when allocated. */
+  private static final int FORCE_DEFRAGMENTATION_CHUNK_SIZE = DEFRAGMENTATION_CHUNK_SIZE * 2;
 
   /** Our test victim. */
   private MemoryAllocatorImpl allocator = null;
@@ -141,22 +141,22 @@ public class MemoryAllocatorFillPatternJUnitTest {
 
   /**
    * This tests that fill validation is working properly on newly created fragments after
-   * a compaction.
+   * a defragmentation.
    * @throws Exception
    */
   @Test
-  public void testFillPatternAfterCompaction() throws Exception {
+  public void testFillPatternAfterDefragmentation() throws Exception {
     /*
      * Stores our allocated memory.
      */
-    OffHeapStoredObject[] allocatedChunks = new OffHeapStoredObject[COMPACTION_CHUNKS];
+    OffHeapStoredObject[] allocatedChunks = new OffHeapStoredObject[DEFRAGMENTATION_CHUNKS];
     
     /*
      * Use up most of our memory
      * Our memory looks like [      ][      ][      ]
      */
     for(int i =0;i < allocatedChunks.length;++i) {
-      allocatedChunks[i] = (OffHeapStoredObject) this.allocator.allocate(COMPACTION_CHUNK_SIZE);
+      allocatedChunks[i] = (OffHeapStoredObject) this.allocator.allocate(DEFRAGMENTATION_CHUNK_SIZE);
       allocatedChunks[i].validateFill();
     }
 
@@ -170,13 +170,13 @@ public class MemoryAllocatorFillPatternJUnitTest {
     
     /*
      * Now, allocate another chunk that is slightly larger than one of
-     * our initial chunks.  This should force a compaction causing our
+     * our initial chunks.  This should force a defragmentation causing our
      * memory to look like [            ][      ].
      */
-    OffHeapStoredObject slightlyLargerChunk = (OffHeapStoredObject) this.allocator.allocate(FORCE_COMPACTION_CHUNK_SIZE);
+    OffHeapStoredObject slightlyLargerChunk = (OffHeapStoredObject) this.allocator.allocate(FORCE_DEFRAGMENTATION_CHUNK_SIZE);
     
     /*
-     * Make sure the compacted memory has the fill validation.
+     * Make sure the defragmented memory has the fill validation.
      */
     slightlyLargerChunk.validateFill();
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorJUnitTest.java
index 7639f8d..582e8b9 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorJUnitTest.java
@@ -219,7 +219,7 @@ public class MemoryAllocatorJUnitTest {
       }
       hugemc.release();
       assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*BATCH_SIZE, ma.freeList.getFreeHugeMemory());
-      // now that we do compaction the following allocate works.
+      // now that we do defragmentation the following allocate works.
       hugemc = ma.allocate(minHuge + HUGE_MULTIPLE + HUGE_MULTIPLE-1);
     } finally {
       MemoryAllocatorImpl.freeOffHeapMemory();
@@ -389,7 +389,7 @@ public class MemoryAllocatorJUnitTest {
   }
   
   @Test
-  public void testCompaction() {
+  public void testDefragmentation() {
     final int perObjectOverhead = OffHeapStoredObject.HEADER_SIZE;
     final int BIG_ALLOC_SIZE = 150000;
     final int SMALL_ALLOC_SIZE = BIG_ALLOC_SIZE/2;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOffHeapMemoryStats.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOffHeapMemoryStats.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOffHeapMemoryStats.java
index 88bab77..d5ce58a 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOffHeapMemoryStats.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOffHeapMemoryStats.java
@@ -60,7 +60,7 @@ public class NullOffHeapMemoryStats implements OffHeapMemoryStats {
     return 0;
   }
   @Override
-  public int getCompactions() {
+  public int getDefragmentations() {
     return 0;
   }
   @Override
@@ -78,11 +78,11 @@ public class NullOffHeapMemoryStats implements OffHeapMemoryStats {
     return 0;
   }
   @Override
-  public long startCompaction() {
+  public long startDefragmentation() {
     return 0;
   }
   @Override
-  public void endCompaction(long start) {
+  public void endDefragmentation(long start) {
   }
   @Override
   public void setFragmentation(int value) {
@@ -96,7 +96,7 @@ public class NullOffHeapMemoryStats implements OffHeapMemoryStats {
     return null;
   }
   @Override
-  public long getCompactionTime() {
+  public long getDefragmentationTime() {
     return 0;
   }
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
index fb1aa41..02673a2 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
@@ -99,8 +99,8 @@ public abstract class OffHeapRegionBase {
       assertEquals(offHeapSize, ma.getFreeMemory());
       assertEquals(0, ma.getUsedMemory());
       // do an allocation larger than the slab size
-      // TODO: currently the compact will product slabs bigger than the max slab size
-      // (see the todo comment on compact() in FreeListManager).
+      // TODO: currently the defragment will produce slabs bigger than the max slab size
+      // (see the todo comment on defragment() in FreeListManager).
       // So we request 20m here since that it the total size.
       try {
         ma.allocate(1024*1024*20);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/155f87d5/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
index d30d4c4..77b1d8d 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
@@ -167,8 +167,8 @@ public class OffHeapStorageJUnitTest {
       assertEquals(1024*1024, stats.getFreeMemory());
       assertEquals(1024*1024, stats.getMaxMemory());
       assertEquals(0, stats.getUsedMemory());
-      assertEquals(0, stats.getCompactions());
-      assertEquals(0, stats.getCompactionTime());
+      assertEquals(0, stats.getDefragmentations());
+      assertEquals(0, stats.getDefragmentationTime());
       assertEquals(0, stats.getFragmentation());
       assertEquals(1, stats.getFragments());
       assertEquals(1024*1024, stats.getLargestFragment());
@@ -216,13 +216,13 @@ public class OffHeapStorageJUnitTest {
       boolean originalEnableClockStats = DistributionStats.enableClockStats;
       DistributionStats.enableClockStats = true;
       try {
-        long start = stats.startCompaction();
-        while (stats.startCompaction() == start) {
+        long start = stats.startDefragmentation();
+        while (stats.startDefragmentation() == start) {
           Thread.yield();
         }
-        stats.endCompaction(start);
-        assertEquals(1, stats.getCompactions());
-        assertTrue(stats.getCompactionTime() > 0);
+        stats.endDefragmentation(start);
+        assertEquals(1, stats.getDefragmentations());
+        assertTrue(stats.getDefragmentationTime() > 0);
       } finally {
         DistributionStats.enableClockStats = originalEnableClockStats;
       }
@@ -235,8 +235,8 @@ public class OffHeapStorageJUnitTest {
       assertEquals(0, stats.getFreeMemory());
       assertEquals(0, stats.getMaxMemory());
       assertEquals(0, stats.getUsedMemory());
-      assertEquals(0, stats.getCompactions());
-      assertEquals(0, stats.getCompactionTime());
+      assertEquals(0, stats.getDefragmentations());
+      assertEquals(0, stats.getDefragmentationTime());
       assertEquals(0, stats.getFragmentation());
       assertEquals(0, stats.getFragments());
       assertEquals(0, stats.getLargestFragment());



[19/26] incubator-geode git commit: GEODE-54: missing javadocs

Posted by kl...@apache.org.
GEODE-54: missing javadocs

Create docs landing page for Geode website
Add an href to javadocs

closes #113


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 91b70969ac8dc4067241870ab8a66c3c462d67c9
Parents: bec420b
Author: Dave Barnes <db...@pivotal.io>
Authored: Wed Feb 24 15:11:06 2016 -0800
Committer: Swapnil Bawaskar <sb...@pivotal.io>
Committed: Wed Mar 16 17:59:26 2016 -0700

----------------------------------------------------------------------
 geode-site/website/README.md                    |  2 +-
 geode-site/website/Rules                        |  3 --
 geode-site/website/content/community/index.html |  2 +-
 geode-site/website/content/docs/index.html      | 48 ++++++++++++++++++++
 geode-site/website/layouts/default.html         | 32 -------------
 geode-site/website/layouts/footer.html          |  2 +-
 geode-site/website/layouts/header.html          |  2 +-
 7 files changed, 52 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b70969/geode-site/website/README.md
----------------------------------------------------------------------
diff --git a/geode-site/website/README.md b/geode-site/website/README.md
index a43efb7..6e50821 100644
--- a/geode-site/website/README.md
+++ b/geode-site/website/README.md
@@ -6,7 +6,7 @@ Source files for the website are in ``${geode-project-dir}/geode-site/website/co
 
 Generated files for the website are in ``${geode-project-dir}/geode-site/content``
 
-The website is updated by a "sync" tool that monitors the __asf-site__ branch of our Git repo, so after to make changes you must push your updated source and generated files to that branch. The content will be published to the [Geode website](http://geode.incubator.apache.org), after a 5-20 minute delay.
+The website is updated by a "sync" tool that monitors the __asf-site__ branch of our Git repo, so after making changes you must push your updated source and generated files to that branch. The content will be published to the [Geode website](http://geode.incubator.apache.org), after a 5-20 minute delay.
 
 ## Prerequsites
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b70969/geode-site/website/Rules
----------------------------------------------------------------------
diff --git a/geode-site/website/Rules b/geode-site/website/Rules
index e1173df..5369385 100644
--- a/geode-site/website/Rules
+++ b/geode-site/website/Rules
@@ -35,9 +35,6 @@ passthrough /\/(bootstrap|css|font|img|js|static)\/.*/
 compile '/docs/*' do
   @docs = true
   filter :erb
-  filter :fenced_code_block
-  filter :pandoc
-  filter :colorize_syntax, :default_colorizer => :pygmentsrb, :pygmentsrb => { :options => { :startinline => 'True' } }
   layout 'docs'
 end
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b70969/geode-site/website/content/community/index.html
----------------------------------------------------------------------
diff --git a/geode-site/website/content/community/index.html b/geode-site/website/content/community/index.html
index 5c5f25f..5a695b2 100644
--- a/geode-site/website/content/community/index.html
+++ b/geode-site/website/content/community/index.html
@@ -128,7 +128,7 @@ under the License. -->
       </div>
       <div class="col-md-3">
         	<h3><a target="_blank" href="https://www.youtube.com/channel/UCaY2q0UlWjAgEGL7uhCLs6A">Geode ClubHouse</a></h3>
-        	<p>We meet every 15 days online for discussions around specific features, detailing internals and discuss on-going issues on JIRA at the Geode Clubhouse. All meetings are recorded and videos are availabe in our <a href="https://www.youtube.com/channel/UCaY2q0UlWjAgEGL7uhCLs6A">YouTube</a> channel.<p>
+        	<p>We meet every 15 days online for discussions around specific features, detailing internals and discuss on-going issues on JIRA at the Geode Clubhouse. All meetings are recorded and videos are available in our <a href="https://www.youtube.com/channel/UCaY2q0UlWjAgEGL7uhCLs6A">YouTube</a> channel.<p>
       </div>
 	  </div>
 </section>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b70969/geode-site/website/content/docs/index.html
----------------------------------------------------------------------
diff --git a/geode-site/website/content/docs/index.html b/geode-site/website/content/docs/index.html
new file mode 100644
index 0000000..f848dc1
--- /dev/null
+++ b/geode-site/website/content/docs/index.html
@@ -0,0 +1,48 @@
+<!-- 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. -->
+
+<!-- <div id="map-canvas" style="width: 100%;"></div> -->
+
+<section class="bf-tagline">
+    <div class="container">
+    	<div class="row">
+        <br/>
+    	    	<h2>Geode Documentation</h2>
+	</div>
+    </div>
+</section>
+
+
+<section class="bf-docs">
+    <div class="container">
+	<div class="row">
+	    <div class="col-md-4">
+	    		<h3><a href="http://geode.docs.pivotal.io/" style="color: #1275ff;">Apache Geode (incubating) User Documentation</a></h3>
+	    		<p>Installation Instructions, User Manual, other product docs</p>
+	    </div>
+	    <div class="col-md-4">
+	    		<h3><a href="http://geode.incubator.apache.org/releases/10M2SNAP/javadocs/index.html" style="color: #1275ff;">Javadocs</a></h3>
+	    		<p>API Reference in conventional Javadoc format<p>
+	    </div>
+	    <div class="col-md-4">
+	    		<h3><a href="https://cwiki.apache.org/confluence/display/GEODE/Index" style="color: #1275ff;">Apache Geode Wiki</a></h3>
+	    		<p>Community contributions on various topics<p>
+	    </div>
+	</div>
+    </div>
+</section>
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b70969/geode-site/website/layouts/default.html
----------------------------------------------------------------------
diff --git a/geode-site/website/layouts/default.html b/geode-site/website/layouts/default.html
index 5e5ba68..2e3e2cd 100644
--- a/geode-site/website/layouts/default.html
+++ b/geode-site/website/layouts/default.html
@@ -3,40 +3,8 @@
 
 <%= render 'header', {:docs => @docs, :community => @community} %>
 
-<% if @docs %>
-<div class="container bf-docs-container">
-    <div class="row">
-
-        <div class="col-md-9 main-article" role="main">
-            <div class="page-article">
-                <div class="page-header">
-                    <h1><%= @item[:title] %></h1>
-                    <!-- TODO: reenable this when we sync SVN to GitHub
-                  <small><a target="_blank" href="https://github.com/geode/website/blob/master/content<%= @item.path[0..-2] %>.md">contribute to this article on github</a></small>
-                    -->
-                </div>
-                <%= @content %>
-            </div>
-        </div>
-    </div>
-    <div class="row">
-        <div class="col-md-3"></div>
-        <div class="col-md-9">
-            <div class="github-callout">
-                <strong>Questions?</strong> Please do <a href="/community">ask on the mailing-lists</a>!<br/>
-                <!--
-                <strong>Found an error?</strong> We’d greatly appreciate a pull request about <a target="_blank" href="https://github.com/geode/website/blob/master/content<%= @item.path[0..-2] %>.md">this article on github</a>.</div>
-                -->
-            </div>
-        </div>
-    </div>
-</div>
-<% else %>
-
 <%= @content %>
 
-<% end %>
-
 <%= render 'footer' %>
 
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b70969/geode-site/website/layouts/footer.html
----------------------------------------------------------------------
diff --git a/geode-site/website/layouts/footer.html b/geode-site/website/layouts/footer.html
index ae38c13..3d31236 100644
--- a/geode-site/website/layouts/footer.html
+++ b/geode-site/website/layouts/footer.html
@@ -24,7 +24,7 @@
                 <ul class="nav nav-list">
                     <li class="nav-header">Resources</li>
                     <li><a href="http://github.com/apache/incubator-geode" target="_blank">GitHub Code</a></li>
-                    <li><a href="http://geode.docs.pivotal.io" target="_blank">Docs</a></li>
+                    <li><a href="/docs/">Docs</a></li>
                     <li><a href="https://issues.apache.org/jira/browse/GEODE" target="_blank">JIRA Bug Tracker</a></li>
                     <li><a href="http://stackoverflow.com/search?q=Apache%20Geode" target="_blank">StackOverflow</a></li>
                     <li><a href="/community/#live">Live Chat</a></li>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/91b70969/geode-site/website/layouts/header.html
----------------------------------------------------------------------
diff --git a/geode-site/website/layouts/header.html b/geode-site/website/layouts/header.html
index 4bffa61..e364fe4 100644
--- a/geode-site/website/layouts/header.html
+++ b/geode-site/website/layouts/header.html
@@ -231,7 +231,7 @@
         <nav class="collapse navbar-collapse bf-navbar-collapse" role="navigation">
             <ul class="nav navbar-nav navbar-right">
                 <li class="<%= 'active' if @community %>"><a href="/community/"><span class="icns icon-group"></span></a></li>
-                <li><a href="http://geode.docs.pivotal.io" target="_blank"><span class="icns icon-book"></span></a></li>
+                <li class="<%= 'active' if @docs %>"><a href="/docs/"><span class="icns icon-book"></span></a></li>
                 <li><a href="http://github.com/apache/incubator-geode" target="_blank"><span class="icns icon-github-sign"></span></a></li>
                 <!--<li><a href="https://trello.com/b/exQmJIOn/usergrid" target="_blank"><span class="icns icon-trello"></span></a></li>-->
                 <li><a href="https://issues.apache.org/jira/browse/GEODE/"


[23/26] incubator-geode git commit: GEODE-670: GatewaySenderEvents are now sized using Sizeable if appropriate

Posted by kl...@apache.org.
GEODE-670: GatewaySenderEvents are now sized using Sizeable if appropriate


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 5b6a2cdc08f521625e0987267201893735877323
Parents: 155f87d
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Wed Mar 16 11:50:44 2016 -0700
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Thu Mar 17 10:11:47 2016 -0700

----------------------------------------------------------------------
 .../java/com/gemstone/gemfire/internal/cache/BucketRegion.java | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5b6a2cdc/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 413fc87..2495464 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
@@ -2141,14 +2141,12 @@ implements Bucket
   }
 
   static int calcMemSize(Object value) {
-    if (value != null && (value instanceof GatewaySenderEventImpl)) {
-      return ((GatewaySenderEventImpl)value).getSerializedValueSize();
-    } 
     if (value == null || value instanceof Token) {
       return 0;
     }
     if (!(value instanceof byte[]) && !(value instanceof CachedDeserializable)
-        && !(value instanceof com.gemstone.gemfire.Delta) && !(value instanceof Delta)) {
+        && !(value instanceof com.gemstone.gemfire.Delta) && !(value instanceof Delta)
+        && !(value instanceof GatewaySenderEventImpl)) {
     // ezoerner:20090401 it's possible this value is a Delta
       throw new InternalGemFireError("DEBUG: calcMemSize: weird value (class " 
           + value.getClass() + "): " + value);


[07/26] incubator-geode git commit: GEODE-640 CI failure: CacheXml80DUnitTest.testCacheServerDisableTcpNoDelay

Posted by kl...@apache.org.
GEODE-640 CI failure: CacheXml80DUnitTest.testCacheServerDisableTcpNoDelay

Use TCP port 0, so that an available port will be automatically assigned.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: f7ca6346dc21aa2359ee5f5a2e2c97705e611e72
Parents: 44c388e
Author: Jianxia Chen <jc...@pivotal.io>
Authored: Tue Mar 15 16:09:11 2016 -0700
Committer: Jianxia Chen <jc...@pivotal.io>
Committed: Tue Mar 15 16:09:11 2016 -0700

----------------------------------------------------------------------
 .../test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f7ca6346/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java
index 155fb78..346c58a 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml80DUnitTest.java
@@ -183,6 +183,7 @@ public class CacheXml80DUnitTest extends CacheXml70DUnitTest {
     CacheCreation cache = new CacheCreation();
 
     CacheServer cs = cache.addCacheServer();
+    cs.setPort(0);
     cs.setTcpNoDelay(false);
     RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
     attrs.setDataPolicy(DataPolicy.NORMAL);


[12/26] incubator-geode git commit: GEODE-1101: rename SimpleMemoryAllocator to MemoryAllocator

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
index a009661..e10ca0a 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
@@ -54,7 +54,7 @@ public class LifecycleListenerJUnitTest {
     this.afterCreateCallbacks.clear();
     this.afterReuseCallbacks.clear();
     this.beforeCloseCallbacks.clear();
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    MemoryAllocatorImpl.freeOffHeapMemory();
   }
 
   @Test
@@ -63,7 +63,7 @@ public class LifecycleListenerJUnitTest {
     LifecycleListener.removeLifecycleListener(this.listener);
 
     SlabImpl slab = new SlabImpl(1024); // 1k
-    SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(),
+    MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(),
         new SlabImpl[] { slab });
 
     Assert.assertEquals(0, this.afterCreateCallbacks.size());
@@ -83,7 +83,7 @@ public class LifecycleListenerJUnitTest {
   public void testCallbacksAreCalledAfterCreate() {
     LifecycleListener.addLifecycleListener(this.listener);
     SlabImpl slab = new SlabImpl(1024); // 1k
-    SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(),
+    MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(),
         new SlabImpl[] { slab });
 
     Assert.assertEquals(1, this.afterCreateCallbacks.size());
@@ -104,10 +104,10 @@ public class LifecycleListenerJUnitTest {
 
     LifecycleListener.addLifecycleListener(this.listener);
 
-    System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "false");
+    System.setProperty(MemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "false");
 
     SlabImpl slab = new SlabImpl(1024); // 1k
-    SimpleMemoryAllocatorImpl ma = createAllocator(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[] { slab });
+    MemoryAllocatorImpl ma = createAllocator(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[] { slab });
 
     Assert.assertEquals(1, this.afterCreateCallbacks.size());
     Assert.assertEquals(0, this.afterReuseCallbacks.size());
@@ -125,7 +125,7 @@ public class LifecycleListenerJUnitTest {
     Assert.assertEquals(1, this.afterReuseCallbacks.size());
     Assert.assertEquals(1, this.beforeCloseCallbacks.size());
 
-    SimpleMemoryAllocatorImpl ma2 = createAllocator(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[] { slab });
+    MemoryAllocatorImpl ma2 = createAllocator(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[] { slab });
     assertEquals(null, ma2);
     
     Assert.assertEquals(1, this.afterCreateCallbacks.size());
@@ -139,20 +139,20 @@ public class LifecycleListenerJUnitTest {
     Assert.assertEquals(2, this.beforeCloseCallbacks.size());
   }
 
-  private SimpleMemoryAllocatorImpl createAllocator(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats ohms, SlabImpl[] slab) {
+  private MemoryAllocatorImpl createAllocator(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats ohms, SlabImpl[] slab) {
     try {
-       return SimpleMemoryAllocatorImpl.createForUnitTest(ooohml, ohms, slab);
+       return MemoryAllocatorImpl.createForUnitTest(ooohml, ohms, slab);
     } catch (IllegalStateException e) {
       return null;
     }
   }
   
-  private void closeAndFree(SimpleMemoryAllocatorImpl ma) {
-    System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "true");
+  private void closeAndFree(MemoryAllocatorImpl ma) {
+    System.setProperty(MemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "true");
     try {
       ma.close();
     } finally {
-      System.clearProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY);
+      System.clearProperty(MemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY);
     }
   }
   
@@ -162,7 +162,7 @@ public class LifecycleListenerJUnitTest {
     LifecycleListener.addLifecycleListener(this.listener);
 
     SlabImpl slab = new SlabImpl(1024); // 1k
-    SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[] { slab });
+    MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[] { slab });
 
     Assert.assertEquals(1, this.afterCreateCallbacks.size());
     Assert.assertEquals(0, this.afterReuseCallbacks.size());
@@ -175,7 +175,7 @@ public class LifecycleListenerJUnitTest {
     Assert.assertEquals(1, this.beforeCloseCallbacks.size());
 
     slab = new SlabImpl(1024); // 1k
-    SimpleMemoryAllocatorImpl ma2 = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[] { slab });
+    MemoryAllocatorImpl ma2 = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[] { slab });
 
     Assert.assertEquals(2, this.afterCreateCallbacks.size());
     Assert.assertEquals(0, this.afterReuseCallbacks.size());
@@ -189,11 +189,11 @@ public class LifecycleListenerJUnitTest {
   }
 
   static final class LifecycleListenerCallback {
-    private final SimpleMemoryAllocatorImpl allocator;
+    private final MemoryAllocatorImpl allocator;
     private final long timeStamp;
     private final Throwable creationTime;
 
-    LifecycleListenerCallback(SimpleMemoryAllocatorImpl allocator) {
+    LifecycleListenerCallback(MemoryAllocatorImpl allocator) {
       this.allocator = allocator;
       this.timeStamp = System.currentTimeMillis();
       this.creationTime = new Exception();
@@ -213,17 +213,17 @@ public class LifecycleListenerJUnitTest {
     }
 
     @Override
-    public void afterCreate(SimpleMemoryAllocatorImpl allocator) {
+    public void afterCreate(MemoryAllocatorImpl allocator) {
       this.afterCreateCallbacks.add(new LifecycleListenerCallback(allocator));
     }
 
     @Override
-    public void afterReuse(SimpleMemoryAllocatorImpl allocator) {
+    public void afterReuse(MemoryAllocatorImpl allocator) {
       this.afterReuseCallbacks.add(new LifecycleListenerCallback(allocator));
     }
 
     @Override
-    public void beforeClose(SimpleMemoryAllocatorImpl allocator) {
+    public void beforeClose(MemoryAllocatorImpl allocator) {
       this.beforeCloseCallbacks.add(new LifecycleListenerCallback(allocator));
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternIntegrationTest.java
new file mode 100644
index 0000000..2f202f8
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternIntegrationTest.java
@@ -0,0 +1,246 @@
+/*
+ * 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.offheap;
+
+import static org.junit.Assert.*;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Tests fill pattern validation for the {@link MemoryAllocatorImpl}.
+ */
+@Category(IntegrationTest.class)
+public class MemoryAllocatorFillPatternIntegrationTest {
+  private static Random random = ThreadLocalRandom.current();
+
+  /**
+   * Chunk operation types.
+   */
+  static enum Operation {
+    ALLOCATE,
+    FREE,
+    WRITE;
+    
+    // Holds all Operation values
+    private static Operation[] values = Operation.values(); 
+    
+    static Operation randomOperation() {
+      return values[random.nextInt(values.length)];
+    }
+  };
+  
+  /** Number of worker threads for advanced tests. */
+  private static final int WORKER_THREAD_COUNT = 5;
+  
+  /** Size of single test slab.*/
+  private static final int SLAB_SIZE = 1024 * 1024 * 50;
+  
+  /** Maximum number of bytes a worker thread can allocate during advanced tests.  */
+  private static final int MAX_WORKER_ALLOCATION_TOTAL_SIZE = SLAB_SIZE / WORKER_THREAD_COUNT / 2;
+  
+  /** Maximum allocation for a single Chunk.  */
+  private static final int MAX_WORKER_ALLOCATION_SIZE = 512;
+  
+  /** Canned data for write operations. */
+  private static final byte[] WRITE_BYTES = new String("Some string data.").getBytes();
+  
+  /** Minimum size for write operations. */
+  private static final int MIN_WORKER_ALLOCATION_SIZE = WRITE_BYTES.length;
+
+  /** Runtime for worker threads. */
+  private static final long RUN_TIME_IN_MILLIS = 1 * 1000 * 5;
+  
+  /** Chunk size for basic huge allocation test. */
+  private static final int HUGE_CHUNK_SIZE = 1024 * 200;
+  
+  /** Our test victim. */
+  private MemoryAllocatorImpl allocator = null;
+  
+  /** Our test victim's memory slab. */
+  private SlabImpl slab = null;
+
+  /**
+   * Enables fill validation and creates the test victim.
+   */
+  @Before
+  public void setUp() throws Exception {
+    System.setProperty("gemfire.validateOffHeapWithFill", "true");
+    this.slab = new SlabImpl(SLAB_SIZE);
+    this.allocator = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{this.slab});
+  }
+
+  /**
+   * Frees off heap memory.
+   */
+  @After
+  public void tearDown() throws Exception {
+    MemoryAllocatorImpl.freeOffHeapMemory();
+    System.clearProperty("gemfire.validateOffHeapWithFill");
+  }
+  
+  /**
+   * This test hammers a MemoryAllocatorImpl with multiple threads exercising
+   * the fill validation of tiny Chunks for one minute.  This, of course, exercises many aspects of
+   * the MemoryAllocatorImpl and its helper classes.
+   * @throws Exception
+   */
+  @Test
+  public void testFillPatternAdvancedForTinyAllocations() throws Exception { 
+    doFillPatternAdvancedTest(new ChunkSizer() {
+      @Override
+      public int allocationSize() {
+        int allocation = random.nextInt(MAX_WORKER_ALLOCATION_SIZE+1);
+        
+        while(allocation < MIN_WORKER_ALLOCATION_SIZE) {
+          allocation = random.nextInt(MAX_WORKER_ALLOCATION_SIZE+1);
+        }
+        return allocation;
+      }
+    });
+  }
+
+  /**
+   * This test hammers a MemoryAllocatorImpl with multiple threads exercising
+   * the fill validation of huge Chunks for one minute.  This, of course, exercises many aspects of
+   * the MemoryAllocatorImpl and its helper classes.
+   * @throws Exception
+   */
+  @Test
+  public void testFillPatternAdvancedForHugeAllocations() throws Exception {
+    doFillPatternAdvancedTest(new ChunkSizer() {
+      @Override
+      public int allocationSize() {
+        return HUGE_CHUNK_SIZE;
+      }
+    });
+  }
+  
+  private interface ChunkSizer {
+    int allocationSize();
+  }
+  
+  private void doFillPatternAdvancedTest(final ChunkSizer chunkSizer) throws InterruptedException {
+    // Used to manage worker thread completion
+    final CountDownLatch latch = new CountDownLatch(WORKER_THREAD_COUNT);
+    
+    // Use to track any errors the worker threads will encounter
+    final List<Throwable> threadErrorList = Collections.synchronizedList(new LinkedList<Throwable>());
+    
+    /*
+     * Start up a number of worker threads.  These threads will randomly allocate, free,
+     * and write to Chunks.
+     */
+    for(int i = 0;i < WORKER_THREAD_COUNT;++i) {
+      new Thread(new Runnable() {
+        // Total allocation in bytes for this thread
+        private int totalAllocation = 0;
+        
+        // List of Chunks allocated by this thread
+        private List<OffHeapStoredObject> chunks = new LinkedList<OffHeapStoredObject>();
+        
+        // Time to end thread execution
+        private long endTime = System.currentTimeMillis() + RUN_TIME_IN_MILLIS;
+        
+        /**
+         * Allocates a chunk and adds it to the thread's Chunk list.
+         */
+        private void allocate() {          
+          int allocation = chunkSizer.allocationSize();
+          OffHeapStoredObject chunk = (OffHeapStoredObject) allocator.allocate(allocation);
+          
+          // This should always work just after allocation
+          chunk.validateFill();
+          
+          chunks.add(chunk);
+          totalAllocation += chunk.getSize();
+        }
+        
+        /**
+         * Frees a random chunk from the Chunk list.
+         */
+        private void free() {
+          OffHeapStoredObject chunk = chunks.remove(random.nextInt(chunks.size()));
+          totalAllocation -= chunk.getSize();
+          
+          /*
+           * Chunk is filled here but another thread may have already grabbed it so we
+           * cannot validate the fill.
+           */
+          chunk.release(); 
+        }
+        
+        /**
+         * Writes canned data to a random Chunk from the Chunk list.
+         */
+        private void write() {
+          OffHeapStoredObject chunk = chunks.get(random.nextInt(chunks.size()));
+          chunk.writeDataBytes(0, WRITE_BYTES);
+        }
+        
+        /**
+         * Randomly selects Chunk operations and executes them
+         * for a period of time.  Collects any error thrown during execution.
+         */
+        @Override
+        public void run() {
+          try {
+            for(long currentTime = System.currentTimeMillis();currentTime < endTime;currentTime = System.currentTimeMillis()) {
+              Operation op = (totalAllocation == 0 ? Operation.ALLOCATE : (totalAllocation >= MAX_WORKER_ALLOCATION_TOTAL_SIZE ? Operation.FREE : Operation.randomOperation()));
+              switch(op) {
+              case ALLOCATE:
+                allocate();
+                break;
+              case FREE:
+                free();
+                break;
+              case WRITE:
+                write();
+                break;
+              }
+            }
+          } catch (Throwable t) {
+            threadErrorList.add(t);
+          } finally {
+            latch.countDown();
+          }
+       }        
+      }).start();
+    }
+    
+    // Make sure each thread ended cleanly
+    assertTrue(latch.await(2, TimeUnit.MINUTES));
+    
+    // Fail on the first error we find
+    if(!threadErrorList.isEmpty()) {
+      fail(threadErrorList.get(0).getMessage());
+    }
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternJUnitTest.java
new file mode 100644
index 0000000..f1d223d
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorFillPatternJUnitTest.java
@@ -0,0 +1,183 @@
+/*
+ * 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.offheap;
+
+import static org.junit.Assert.*;
+import static com.googlecode.catchexception.CatchException.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests fill pattern validation for the {@link MemoryAllocatorImpl}.
+ * @author rholmes
+ */
+@Category(UnitTest.class)
+public class MemoryAllocatorFillPatternJUnitTest {
+  
+  /** Size of single test slab.*/
+  private static final int SLAB_SIZE = 1024 * 1024 * 50;
+  
+  /** Canned data for write operations. */
+  private static final byte[] WRITE_BYTES = new String("Some string data.").getBytes();
+  
+  /** Chunk size for basic huge allocation test. */
+  private static final int HUGE_CHUNK_SIZE = 1024 * 200;
+  
+  /** The number of chunks to allocate in order to force compaction. */
+  private static final int COMPACTION_CHUNKS = 3;
+  
+  /** Our slab size divided in three (with some padding for safety). */
+  private static final int COMPACTION_CHUNK_SIZE = (SLAB_SIZE / COMPACTION_CHUNKS) - 1024;
+  
+  /** This should force compaction when allocated. */
+  private static final int FORCE_COMPACTION_CHUNK_SIZE = COMPACTION_CHUNK_SIZE * 2;
+
+  /** Our test victim. */
+  private MemoryAllocatorImpl allocator = null;
+  
+  /** Our test victim's memory slab. */
+  private SlabImpl slab = null;
+
+  /**
+   * Enables fill validation and creates the test victim.
+   */
+  @Before
+  public void setUp() throws Exception {
+    System.setProperty("gemfire.validateOffHeapWithFill", "true");
+    this.slab = new SlabImpl(SLAB_SIZE);
+    this.allocator = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{this.slab});
+  }
+
+  /**
+   * Frees off heap memory.
+   */
+  @After
+  public void tearDown() throws Exception {
+    MemoryAllocatorImpl.freeOffHeapMemory();
+    System.clearProperty("gemfire.validateOffHeapWithFill");
+  }
+
+  /**
+   * This tests the fill pattern for a single tiny Chunk allocation.
+   * @throws Exception
+   */
+  @Test
+  public void testFillPatternBasicForTinyAllocations() throws Exception {
+    doFillPatternBasic(1024);
+  }
+  
+  /**
+   * This tests the fill pattern for a single huge Chunk allocation.
+   * @throws Exception
+   */
+  @Test
+  public void testFillPatternBasicForHugeAllocations() throws Exception {
+    doFillPatternBasic(HUGE_CHUNK_SIZE);
+  }
+  
+  private void doFillPatternBasic(final int chunkSize) {
+    /*
+     * Pull a chunk off the fragment.  This will have no fill because
+     * it is a "fresh" chunk.
+     */
+    OffHeapStoredObject chunk = (OffHeapStoredObject) this.allocator.allocate(chunkSize);
+
+    /*
+     * Chunk should have valid fill from initial fragment allocation.
+     */
+    chunk.validateFill();
+         
+    // "Dirty" the chunk so the release has something to fill over
+    chunk.writeDataBytes(OffHeapStoredObject.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
+
+    // This should free the Chunk (ref count == 1)
+    chunk.release();
+
+    /*
+     * This chunk should have a fill because it was reused from the
+     * free list (assuming no fragmentation at this point...)
+     */
+    chunk = (OffHeapStoredObject) this.allocator.allocate(chunkSize);
+    
+    // Make sure we have a fill this time
+    chunk.validateFill();
+    
+    // Give the fill code something to write over during the release
+    chunk.writeDataBytes(OffHeapStoredObject.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
+    chunk.release();
+
+    // Again, make sure the release implemented the fill
+    chunk.validateFill();
+
+    // "Dirty up" the free chunk
+    chunk.writeDataBytes(OffHeapStoredObject.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
+    
+    catchException(chunk).validateFill();
+    assertTrue(caughtException() instanceof IllegalStateException);
+    assertEquals("Fill pattern violated for chunk " + chunk.getAddress() + " with size " + chunk.getSize(), caughtException().getMessage());
+    
+  }
+
+  /**
+   * This tests that fill validation is working properly on newly created fragments after
+   * a compaction.
+   * @throws Exception
+   */
+  @Test
+  public void testFillPatternAfterCompaction() throws Exception {
+    /*
+     * Stores our allocated memory.
+     */
+    OffHeapStoredObject[] allocatedChunks = new OffHeapStoredObject[COMPACTION_CHUNKS];
+    
+    /*
+     * Use up most of our memory
+     * Our memory looks like [      ][      ][      ]
+     */
+    for(int i =0;i < allocatedChunks.length;++i) {
+      allocatedChunks[i] = (OffHeapStoredObject) this.allocator.allocate(COMPACTION_CHUNK_SIZE);
+      allocatedChunks[i].validateFill();
+    }
+
+    /*
+     * Release some of our allocated chunks.
+     */
+    for(int i=0;i < 2;++i) {
+      allocatedChunks[i].release();
+      allocatedChunks[i].validateFill();      
+    }
+    
+    /*
+     * Now, allocate another chunk that is slightly larger than one of
+     * our initial chunks.  This should force a compaction causing our
+     * memory to look like [            ][      ].
+     */
+    OffHeapStoredObject slightlyLargerChunk = (OffHeapStoredObject) this.allocator.allocate(FORCE_COMPACTION_CHUNK_SIZE);
+    
+    /*
+     * Make sure the compacted memory has the fill validation.
+     */
+    slightlyLargerChunk.validateFill();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorJUnitTest.java
new file mode 100644
index 0000000..7639f8d
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorJUnitTest.java
@@ -0,0 +1,594 @@
+/*
+ * 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.offheap;
+
+import static org.junit.Assert.*;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.OutOfOffHeapMemoryException;
+import com.gemstone.gemfire.cache.CacheClosedException;
+import com.gemstone.gemfire.internal.logging.NullLogWriter;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class MemoryAllocatorJUnitTest {
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
+  private static int round(int multiple, int v) {
+    return ((v+multiple-1)/multiple)*multiple;
+  }
+  @Test
+  public void testNullGetAllocator() {
+    try {
+      MemoryAllocatorImpl.getAllocator();
+      fail("expected CacheClosedException");
+    } catch (CacheClosedException expected) {
+    }
+  }
+  @Test
+  public void testConstructor() {
+    try {
+      MemoryAllocatorImpl.createForUnitTest(null, null, null);
+      fail("expected IllegalArgumentException");
+    } catch (IllegalArgumentException expected) {
+    }
+  }
+  @Test
+  public void testCreate() {
+    System.setProperty(MemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "false");
+    {
+      NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
+      NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
+      try {
+        MemoryAllocatorImpl.createForUnitTest(listener, stats, 10, 950, 100, new SlabFactory() {
+     @Override
+     public Slab create(int size) {
+        throw new OutOfMemoryError("expected");
+     }
+    });
+      } catch (OutOfMemoryError expected) {
+      }
+      assertTrue(listener.isClosed());
+      assertTrue(stats.isClosed());
+     }
+    {
+      NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
+      NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
+      int MAX_SLAB_SIZE = 100;
+      try {
+        SlabFactory factory = new SlabFactory() {
+          private int createCount = 0;
+          @Override
+          public Slab create(int size) {
+            createCount++;
+            if (createCount == 1) {
+              return new SlabImpl(size);
+            } else {
+              throw new OutOfMemoryError("expected");
+            }
+          }
+        };
+        MemoryAllocatorImpl.createForUnitTest(listener, stats, 10, 950, MAX_SLAB_SIZE, factory);
+      } catch (OutOfMemoryError expected) {
+      }
+      assertTrue(listener.isClosed());
+      assertTrue(stats.isClosed());
+    }
+    {
+      NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
+      NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
+      SlabFactory factory = new SlabFactory() {
+        @Override
+        public Slab create(int size) {
+          return new SlabImpl(size);
+        }
+      };
+      MemoryAllocator ma = 
+        MemoryAllocatorImpl.createForUnitTest(listener, stats, 10, 950, 100, factory);
+      try {
+        assertFalse(listener.isClosed());
+        assertFalse(stats.isClosed());
+        ma.close();
+        assertTrue(listener.isClosed());
+        assertFalse(stats.isClosed());
+        listener = new NullOutOfOffHeapMemoryListener();
+        NullOffHeapMemoryStats stats2 = new NullOffHeapMemoryStats();
+        {
+          SlabImpl slab = new SlabImpl(1024);
+          try {
+            MemoryAllocatorImpl.createForUnitTest(listener, stats2, new SlabImpl[]{slab});
+          } catch (IllegalStateException expected) {
+            assertTrue("unexpected message: " + expected.getMessage(), 
+                expected.getMessage().equals("attempted to reuse existing off-heap memory even though new off-heap memory was allocated"));
+          } finally {
+            slab.free();
+          }
+          assertFalse(stats.isClosed());
+          assertTrue(listener.isClosed());
+          assertTrue(stats2.isClosed());
+        }
+        listener = new NullOutOfOffHeapMemoryListener();
+        stats2 = new NullOffHeapMemoryStats();
+        MemoryAllocator ma2 = MemoryAllocatorImpl.createForUnitTest(listener, stats2, 10, 950, 100, factory);
+        assertSame(ma, ma2);
+        assertTrue(stats.isClosed());
+        assertFalse(listener.isClosed());
+        assertFalse(stats2.isClosed());
+        stats = stats2;
+        ma.close();
+        assertTrue(listener.isClosed());
+        assertFalse(stats.isClosed());
+      } finally {
+        MemoryAllocatorImpl.freeOffHeapMemory();
+      }
+      assertTrue(stats.isClosed());
+    }
+  }
+  @Test
+  public void testBasics() {
+    int BATCH_SIZE = 1;
+    int TINY_MULTIPLE = FreeListManager.TINY_MULTIPLE;
+    int HUGE_MULTIPLE = FreeListManager.HUGE_MULTIPLE;
+    int perObjectOverhead = OffHeapStoredObject.HEADER_SIZE;
+    int maxTiny = FreeListManager.MAX_TINY-perObjectOverhead;
+    int minHuge = maxTiny+1;
+    int TOTAL_MEM = (maxTiny+perObjectOverhead)*BATCH_SIZE /*+ (maxBig+perObjectOverhead)*BATCH_SIZE*/ + round(TINY_MULTIPLE, minHuge+1+perObjectOverhead)*BATCH_SIZE + (TINY_MULTIPLE+perObjectOverhead)*BATCH_SIZE /*+ (MIN_BIG_SIZE+perObjectOverhead)*BATCH_SIZE*/ + round(TINY_MULTIPLE, minHuge+perObjectOverhead+1);
+    SlabImpl slab = new SlabImpl(TOTAL_MEM);
+    try {
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      assertEquals(TOTAL_MEM, ma.getFreeMemory());
+      assertEquals(TOTAL_MEM, ma.freeList.getFreeFragmentMemory());
+      assertEquals(0, ma.freeList.getFreeTinyMemory());
+      assertEquals(0, ma.freeList.getFreeHugeMemory());
+      StoredObject tinymc = ma.allocate(maxTiny);
+      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
+      assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead)*(BATCH_SIZE-1), ma.freeList.getFreeTinyMemory());
+      StoredObject hugemc = ma.allocate(minHuge);
+      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, minHuge+perObjectOverhead)/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
+      long freeSlab = ma.freeList.getFreeFragmentMemory();
+      long oldFreeHugeMemory = ma.freeList.getFreeHugeMemory();
+      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*(BATCH_SIZE-1), oldFreeHugeMemory);
+      hugemc.release();
+      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead), ma.freeList.getFreeHugeMemory()-oldFreeHugeMemory);
+      assertEquals(TOTAL_MEM/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
+      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
+      long oldFreeTinyMemory = ma.freeList.getFreeTinyMemory();
+      tinymc.release();
+      assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.freeList.getFreeTinyMemory()-oldFreeTinyMemory);
+      assertEquals(TOTAL_MEM, ma.getFreeMemory());
+      // now lets reallocate from the free lists
+      tinymc = ma.allocate(maxTiny);
+      assertEquals(oldFreeTinyMemory, ma.freeList.getFreeTinyMemory());
+      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
+      hugemc = ma.allocate(minHuge);
+      assertEquals(oldFreeHugeMemory, ma.freeList.getFreeHugeMemory());
+      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, minHuge+perObjectOverhead)/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
+      hugemc.release();
+      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead), ma.freeList.getFreeHugeMemory()-oldFreeHugeMemory);
+      assertEquals(TOTAL_MEM/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
+      assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
+      tinymc.release();
+      assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.freeList.getFreeTinyMemory()-oldFreeTinyMemory);
+      assertEquals(TOTAL_MEM, ma.getFreeMemory());
+      // None of the reallocates should have come from the slab.
+      assertEquals(freeSlab, ma.freeList.getFreeFragmentMemory());
+      tinymc = ma.allocate(1);
+      assertEquals(round(TINY_MULTIPLE, 1+perObjectOverhead), tinymc.getSize());
+      assertEquals(freeSlab-(round(TINY_MULTIPLE, 1+perObjectOverhead)*BATCH_SIZE), ma.freeList.getFreeFragmentMemory());
+      freeSlab = ma.freeList.getFreeFragmentMemory();
+      tinymc.release();
+      assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead)+(round(TINY_MULTIPLE, 1+perObjectOverhead)*BATCH_SIZE), ma.freeList.getFreeTinyMemory()-oldFreeTinyMemory);
+      
+      hugemc = ma.allocate(minHuge+1);
+      assertEquals(round(TINY_MULTIPLE, minHuge+1+perObjectOverhead), hugemc.getSize());
+      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*(BATCH_SIZE-1), ma.freeList.getFreeHugeMemory());
+      hugemc.release();
+      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*BATCH_SIZE, ma.freeList.getFreeHugeMemory());
+      hugemc = ma.allocate(minHuge);
+      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*(BATCH_SIZE-1), ma.freeList.getFreeHugeMemory());
+      if (BATCH_SIZE > 1) {
+        StoredObject hugemc2 = ma.allocate(minHuge);
+        assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*(BATCH_SIZE-2), ma.freeList.getFreeHugeMemory());
+        hugemc2.release();
+        assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*(BATCH_SIZE-1), ma.freeList.getFreeHugeMemory());
+      }
+      hugemc.release();
+      assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*BATCH_SIZE, ma.freeList.getFreeHugeMemory());
+      // now that we do compaction the following allocate works.
+      hugemc = ma.allocate(minHuge + HUGE_MULTIPLE + HUGE_MULTIPLE-1);
+    } finally {
+      MemoryAllocatorImpl.freeOffHeapMemory();
+    }
+  }
+  
+  @Test
+  public void testChunkCreateDirectByteBuffer() {
+    SlabImpl slab = new SlabImpl(1024*1024);
+    try {
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      ByteBuffer bb = ByteBuffer.allocate(1024);
+      for (int i=0; i < 1024; i++) {
+        bb.put((byte) i);
+      }
+      bb.position(0);
+      OffHeapStoredObject c = (OffHeapStoredObject) ma.allocateAndInitialize(bb.array(), false, false);
+      assertEquals(1024, c.getDataSize());
+      if (!Arrays.equals(bb.array(), c.getRawBytes())) {
+        fail("arrays are not equal. Expected " + Arrays.toString(bb.array()) + " but found: " + Arrays.toString(c.getRawBytes()));
+      }
+      ByteBuffer dbb = c.createDirectByteBuffer();
+      assertEquals(true, dbb.isDirect());
+      assertEquals(bb, dbb);
+    } finally {
+      MemoryAllocatorImpl.freeOffHeapMemory();
+    }
+  }
+  
+  @Test
+  public void testDebugLog() {
+    MemoryAllocatorImpl.debugLog("test debug log", false);
+    MemoryAllocatorImpl.debugLog("test debug log", true);
+  }
+  @Test
+  public void testGetLostChunks() {
+    SlabImpl slab = new SlabImpl(1024*1024);
+    try {
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      assertEquals(Collections.emptyList(), ma.getLostChunks());
+    } finally {
+      MemoryAllocatorImpl.freeOffHeapMemory();
+    }
+  }
+  @Test
+  public void testFindSlab() {
+    final int SLAB_SIZE = 1024*1024;
+    SlabImpl slab = new SlabImpl(SLAB_SIZE);
+    try {
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      assertEquals(0, ma.findSlab(slab.getMemoryAddress()));
+      assertEquals(0, ma.findSlab(slab.getMemoryAddress()+SLAB_SIZE-1));
+      try {
+        ma.findSlab(slab.getMemoryAddress()-1);
+        fail("expected IllegalStateException");
+      } catch (IllegalStateException expected) {
+      }
+      try {
+        ma.findSlab(slab.getMemoryAddress()+SLAB_SIZE);
+        fail("expected IllegalStateException");
+      } catch (IllegalStateException expected) {
+      }
+    } finally {
+      MemoryAllocatorImpl.freeOffHeapMemory();
+    }
+  }
+  @Test
+  public void testValidateAddressAndSize() {
+    final int SLAB_SIZE = 1024*1024;
+    SlabImpl slab = new SlabImpl(SLAB_SIZE);
+    try {
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      try {
+        MemoryAllocatorImpl.validateAddress(0L);
+        fail("expected IllegalStateException");
+      } catch (IllegalStateException expected) {
+        assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().contains("addr was smaller than expected"));
+      }
+      try {
+        MemoryAllocatorImpl.validateAddress(1L);
+        fail("expected IllegalStateException");
+      } catch (IllegalStateException expected) {
+        assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().contains("Valid addresses must be in one of the following ranges:"));
+      }
+      MemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), SLAB_SIZE, false);
+      MemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), SLAB_SIZE, true);
+      MemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), -1, true);
+      try {
+        MemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress()-1, SLAB_SIZE, true);
+        fail("expected IllegalStateException");
+      } catch (IllegalStateException expected) {
+        assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().equals(" address 0x" + Long.toString(slab.getMemoryAddress()-1, 16) + " does not address the original slab memory"));
+      }
+      try {
+        MemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), SLAB_SIZE+1, true);
+        fail("expected IllegalStateException");
+      } catch (IllegalStateException expected) {
+        assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().equals(" address 0x" + Long.toString(slab.getMemoryAddress()+SLAB_SIZE, 16) + " does not address the original slab memory"));
+      }
+    } finally {
+      MemoryAllocatorImpl.freeOffHeapMemory();
+    }
+  }
+  @Test
+  public void testMemoryInspection() {
+    final int SLAB_SIZE = 1024*1024;
+    SlabImpl slab = new SlabImpl(SLAB_SIZE);
+    try {
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      MemoryInspector inspector = ma.getMemoryInspector();
+      assertNotNull(inspector);
+      assertEquals(null, inspector.getFirstBlock());
+      assertEquals(Collections.emptyList(), inspector.getSnapshot());
+      assertEquals(Collections.emptyList(), inspector.getAllocatedBlocks());
+      assertEquals(null, inspector.getBlockAfter(null));
+      inspector.createSnapshot();
+      // call this twice for code coverage
+      inspector.createSnapshot();
+      try {
+        assertEquals(inspector.getAllBlocks(), inspector.getSnapshot());
+        MemoryBlock firstBlock = inspector.getFirstBlock();
+        assertNotNull(firstBlock);
+        assertEquals(1024*1024, firstBlock.getBlockSize());
+        assertEquals("N/A", firstBlock.getDataType());
+        assertEquals(-1, firstBlock.getFreeListId());
+        assertTrue(firstBlock.getAddress() > 0);
+        assertNull(firstBlock.getNextBlock());
+        assertEquals(0, firstBlock.getRefCount());
+        assertEquals(0, firstBlock.getSlabId());
+        assertEquals(MemoryBlock.State.UNUSED, firstBlock.getState());
+        assertFalse(firstBlock.isCompressed());
+        assertFalse(firstBlock.isSerialized());
+        assertEquals(null, inspector.getBlockAfter(firstBlock));
+      } finally {
+        inspector.clearSnapshot();
+      }
+    } finally {
+      MemoryAllocatorImpl.freeOffHeapMemory();
+    }
+  }
+
+  @Test
+  public void testClose() {
+    System.setProperty(MemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "false");
+    SlabImpl slab = new SlabImpl(1024*1024);
+    boolean freeSlab = true;
+    SlabImpl[] slabs = new SlabImpl[]{slab};
+    try {
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), slabs);
+      ma.close();
+      ma.close();
+      System.setProperty(MemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "true");
+      try {
+        ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), slabs);
+        ma.close();
+        freeSlab = false;
+        ma.close();
+      } finally {
+        System.clearProperty(MemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY);
+      }
+    } finally {
+      if (freeSlab) {
+        MemoryAllocatorImpl.freeOffHeapMemory();
+      }
+    }
+    
+  }
+  
+  @Test
+  public void testCompaction() {
+    final int perObjectOverhead = OffHeapStoredObject.HEADER_SIZE;
+    final int BIG_ALLOC_SIZE = 150000;
+    final int SMALL_ALLOC_SIZE = BIG_ALLOC_SIZE/2;
+    final int TOTAL_MEM = BIG_ALLOC_SIZE;
+    SlabImpl slab = new SlabImpl(TOTAL_MEM);
+    try {
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      StoredObject bmc = ma.allocate(BIG_ALLOC_SIZE-perObjectOverhead);
+      try {
+        StoredObject smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
+        fail("Expected out of memory");
+      } catch (OutOfOffHeapMemoryException expected) {
+      }
+      bmc.release();
+      assertEquals(TOTAL_MEM, ma.freeList.getFreeMemory());
+      StoredObject smc1 = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
+      StoredObject smc2 = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
+      smc2.release();
+      assertEquals(TOTAL_MEM-SMALL_ALLOC_SIZE, ma.freeList.getFreeMemory());
+      try {
+        bmc = ma.allocate(BIG_ALLOC_SIZE-perObjectOverhead);
+        fail("Expected out of memory");
+      } catch (OutOfOffHeapMemoryException expected) {
+      }
+      smc1.release();
+      assertEquals(TOTAL_MEM, ma.freeList.getFreeMemory());
+      bmc = ma.allocate(BIG_ALLOC_SIZE-perObjectOverhead);
+      bmc.release();
+      assertEquals(TOTAL_MEM, ma.freeList.getFreeMemory());
+      ArrayList<StoredObject> mcs = new ArrayList<StoredObject>();
+      for (int i=0; i < BIG_ALLOC_SIZE/(8+perObjectOverhead); i++) {
+        mcs.add(ma.allocate(8));
+      }
+      checkMcs(mcs);
+      assertEquals(0, ma.freeList.getFreeMemory());
+      try {
+        ma.allocate(8);
+        fail("expected out of memory");
+      } catch (OutOfOffHeapMemoryException expected) {
+      }
+      mcs.remove(0).release(); // frees 8+perObjectOverhead
+      assertEquals(8+perObjectOverhead, ma.freeList.getFreeMemory());
+      mcs.remove(0).release(); // frees 8+perObjectOverhead
+      assertEquals((8+perObjectOverhead)*2, ma.freeList.getFreeMemory());
+      ma.allocate(16).release(); // allocates and frees 16+perObjectOverhead; still have perObjectOverhead
+      assertEquals((8+perObjectOverhead)*2, ma.freeList.getFreeMemory());
+      mcs.remove(0).release(); // frees 8+perObjectOverhead
+      assertEquals((8+perObjectOverhead)*3, ma.freeList.getFreeMemory());
+      mcs.remove(0).release(); // frees 8+perObjectOverhead
+      assertEquals((8+perObjectOverhead)*4, ma.freeList.getFreeMemory());
+      // At this point I should have 8*4 + perObjectOverhead*4 of free memory
+      ma.allocate(8*4+perObjectOverhead*3).release();
+      assertEquals((8+perObjectOverhead)*4, ma.freeList.getFreeMemory());
+      mcs.remove(0).release(); // frees 8+perObjectOverhead
+      assertEquals((8+perObjectOverhead)*5, ma.freeList.getFreeMemory());
+      // At this point I should have 8*5 + perObjectOverhead*5 of free memory
+      try {
+        ma.allocate((8*5+perObjectOverhead*4)+1);
+        fail("expected out of memory");
+      } catch (OutOfOffHeapMemoryException expected) {
+      }
+      mcs.remove(0).release(); // frees 8+perObjectOverhead
+      assertEquals((8+perObjectOverhead)*6, ma.freeList.getFreeMemory());
+      checkMcs(mcs);
+      // At this point I should have 8*6 + perObjectOverhead*6 of free memory
+      StoredObject mc24 = ma.allocate(24);
+      checkMcs(mcs);
+      assertEquals((8+perObjectOverhead)*6 - (24+perObjectOverhead), ma.freeList.getFreeMemory());
+      // At this point I should have 8*3 + perObjectOverhead*5 of free memory
+      StoredObject mc16 = ma.allocate(16);
+      checkMcs(mcs);
+      assertEquals((8+perObjectOverhead)*6 - (24+perObjectOverhead) - (16+perObjectOverhead), ma.freeList.getFreeMemory());
+      // At this point I should have 8*1 + perObjectOverhead*4 of free memory
+      mcs.add(ma.allocate(8));
+      checkMcs(mcs);
+      assertEquals((8+perObjectOverhead)*6 - (24+perObjectOverhead) - (16+perObjectOverhead) - (8+perObjectOverhead), ma.freeList.getFreeMemory());
+      // At this point I should have 8*0 + perObjectOverhead*3 of free memory
+      StoredObject mcDO = ma.allocate(perObjectOverhead*2);
+      checkMcs(mcs);
+      // At this point I should have 8*0 + perObjectOverhead*0 of free memory
+      assertEquals(0, ma.freeList.getFreeMemory());
+      try {
+        ma.allocate(1);
+        fail("expected out of memory");
+      } catch (OutOfOffHeapMemoryException expected) {
+      }
+      checkMcs(mcs);
+      assertEquals(0, ma.freeList.getFreeMemory());
+      mcDO.release();
+      assertEquals((perObjectOverhead*3), ma.freeList.getFreeMemory());
+      mcs.remove(mcs.size()-1).release();
+      assertEquals((perObjectOverhead*3)+(8+perObjectOverhead), ma.freeList.getFreeMemory());
+      mc16.release();
+      assertEquals((perObjectOverhead*3)+(8+perObjectOverhead)+(16+perObjectOverhead), ma.freeList.getFreeMemory());
+      mc24.release();
+      assertEquals((perObjectOverhead*3)+(8+perObjectOverhead)+(16+perObjectOverhead)+(24+perObjectOverhead), ma.freeList.getFreeMemory());
+      
+      long freeMem = ma.freeList.getFreeMemory();
+      for (StoredObject mc: mcs) {
+        mc.release();
+        assertEquals(freeMem+(8+perObjectOverhead), ma.freeList.getFreeMemory());
+        freeMem += (8+perObjectOverhead);
+      }
+      mcs.clear();
+      assertEquals(TOTAL_MEM, ma.freeList.getFreeMemory());
+      bmc = ma.allocate(BIG_ALLOC_SIZE-perObjectOverhead);
+      bmc.release();
+    } finally {
+      MemoryAllocatorImpl.freeOffHeapMemory();
+    }
+  }
+  
+  long expectedMemoryUsage;
+  boolean memoryUsageEventReceived;
+  @Test
+  public void testUsageEventListener() {
+    final int perObjectOverhead = OffHeapStoredObject.HEADER_SIZE;
+    final int SMALL_ALLOC_SIZE = 1000;
+    SlabImpl slab = new SlabImpl(3000);
+    try {
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      MemoryUsageListener listener = new MemoryUsageListener() {
+        @Override
+        public void updateMemoryUsed(final long bytesUsed) {
+          MemoryAllocatorJUnitTest.this.memoryUsageEventReceived = true;
+          assertEquals(MemoryAllocatorJUnitTest.this.expectedMemoryUsage, bytesUsed);
+        }
+      };
+      ma.addMemoryUsageListener(listener);
+      
+      this.expectedMemoryUsage = SMALL_ALLOC_SIZE;
+      this.memoryUsageEventReceived = false;
+      StoredObject smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
+      assertEquals(true, this.memoryUsageEventReceived);
+      
+      this.expectedMemoryUsage = SMALL_ALLOC_SIZE * 2;
+      this.memoryUsageEventReceived = false;
+      smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
+      assertEquals(true, this.memoryUsageEventReceived);
+      
+      MemoryUsageListener unaddedListener = new MemoryUsageListener() {
+        @Override
+        public void updateMemoryUsed(final long bytesUsed) {
+          throw new IllegalStateException("Should never be called");
+        }
+      };
+      ma.removeMemoryUsageListener(unaddedListener);
+      
+      ma.removeMemoryUsageListener(listener);
+      
+      ma.removeMemoryUsageListener(unaddedListener);
+
+      this.expectedMemoryUsage = SMALL_ALLOC_SIZE * 2;
+      this.memoryUsageEventReceived = false;
+      smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
+      assertEquals(false, this.memoryUsageEventReceived);
+      
+    } finally {
+      MemoryAllocatorImpl.freeOffHeapMemory();
+    }
+  }
+  private void checkMcs(ArrayList<StoredObject> mcs) {
+    for (StoredObject mc: mcs) {
+      assertEquals(8+8, mc.getSize());
+    }
+  }
+  
+  @Test
+  public void testOutOfOffHeapMemory() {
+    final int perObjectOverhead = OffHeapStoredObject.HEADER_SIZE;
+    final int BIG_ALLOC_SIZE = 150000;
+    final int SMALL_ALLOC_SIZE = BIG_ALLOC_SIZE/2;
+    final int TOTAL_MEM = BIG_ALLOC_SIZE;
+    final SlabImpl slab = new SlabImpl(TOTAL_MEM);
+    final AtomicReference<OutOfOffHeapMemoryException> ooom = new AtomicReference<OutOfOffHeapMemoryException>();
+    final OutOfOffHeapMemoryListener oooml = new OutOfOffHeapMemoryListener() {
+      @Override
+      public void outOfOffHeapMemory(OutOfOffHeapMemoryException cause) {
+        ooom.set(cause);
+      }
+      @Override
+      public void close() {
+      }
+    };
+    try {
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(oooml, new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      // make a big allocation
+      StoredObject bmc = ma.allocate(BIG_ALLOC_SIZE-perObjectOverhead);
+      assertNull(ooom.get());
+      // drive the ma to ooom with small allocations
+      try {
+        StoredObject smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead);
+        fail("Expected out of memory");
+      } catch (OutOfOffHeapMemoryException expected) {
+      }
+      assertNotNull(ooom.get());
+      assertTrue(ooom.get().getMessage().contains("Out of off-heap memory. Could not allocate size of "));
+    } finally {
+      MemoryAllocatorImpl.freeOffHeapMemory();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNodeJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNodeJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNodeJUnitTest.java
index e1c3f4e..f0563ad 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNodeJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNodeJUnitTest.java
@@ -46,7 +46,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 @Category(UnitTest.class)
 public class MemoryBlockNodeJUnitTest {
 
-  private SimpleMemoryAllocatorImpl ma;
+  private MemoryAllocatorImpl ma;
   private OutOfOffHeapMemoryListener ooohml;
   private OffHeapMemoryStats stats;
   private Slab[] slabs = {
@@ -82,12 +82,12 @@ public class MemoryBlockNodeJUnitTest {
   public void setUp() {
     ooohml = mock(OutOfOffHeapMemoryListener.class);
     stats = mock(OffHeapMemoryStats.class);
-    ma = (SimpleMemoryAllocatorImpl) SimpleMemoryAllocatorImpl.createForUnitTest(ooohml, stats, slabs);
+    ma = (MemoryAllocatorImpl) MemoryAllocatorImpl.createForUnitTest(ooohml, stats, slabs);
   }
 
   @After
   public void tearDown() {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    MemoryAllocatorImpl.freeOffHeapMemory();
   }
   
   protected Object getValue() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
index fa4e776..95b6869 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
@@ -47,7 +47,7 @@ public class OffHeapHelperJUnitTest extends AbstractStoredObjectTestBase {
     OutOfOffHeapMemoryListener ooohml = mock(OutOfOffHeapMemoryListener.class);
     OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
 
-    ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, 3, OffHeapStorage.MIN_SLAB_SIZE * 3, OffHeapStorage.MIN_SLAB_SIZE);
+    ma = MemoryAllocatorImpl.create(ooohml, stats, 3, OffHeapStorage.MIN_SLAB_SIZE * 3, OffHeapStorage.MIN_SLAB_SIZE);
 
   }
 
@@ -71,7 +71,7 @@ public class OffHeapHelperJUnitTest extends AbstractStoredObjectTestBase {
 
   @After
   public void tearDown() {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    MemoryAllocatorImpl.freeOffHeapMemory();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapIndexJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapIndexJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapIndexJUnitTest.java
index ec494e8..571060b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapIndexJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapIndexJUnitTest.java
@@ -57,7 +57,7 @@ public class OffHeapIndexJUnitTest {
   @After
   public void tearDown() {
     this.gfc.close();
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    MemoryAllocatorImpl.freeOffHeapMemory();
     // TODO cleanup default disk store files
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
index ae1b35d..fb1aa41 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
@@ -75,7 +75,7 @@ public abstract class OffHeapRegionBase {
   private void closeCache(GemFireCacheImpl gfc, boolean keepOffHeapAllocated) {
     gfc.close();
     if (!keepOffHeapAllocated) {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+      MemoryAllocatorImpl.freeOffHeapMemory();
     }
     // TODO cleanup default disk store files
   }
@@ -100,7 +100,7 @@ public abstract class OffHeapRegionBase {
       assertEquals(0, ma.getUsedMemory());
       // do an allocation larger than the slab size
       // TODO: currently the compact will product slabs bigger than the max slab size
-      // (see the todo comment on compact() in SimpleMemoryAllocator).
+      // (see the todo comment on compact() in FreeListManager).
       // So we request 20m here since that it the total size.
       try {
         ma.allocate(1024*1024*20);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
index cf47a72..5cb6afb 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
@@ -65,12 +65,12 @@ public class OffHeapRegionEntryHelperJUnitTest {
     OutOfOffHeapMemoryListener ooohml = mock(OutOfOffHeapMemoryListener.class);
     OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
 
-    ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, 1, OffHeapStorage.MIN_SLAB_SIZE * 1, OffHeapStorage.MIN_SLAB_SIZE);
+    ma = MemoryAllocatorImpl.create(ooohml, stats, 1, OffHeapStorage.MIN_SLAB_SIZE * 1, OffHeapStorage.MIN_SLAB_SIZE);
   }
 
   @After
   public void tearDown() {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    MemoryAllocatorImpl.freeOffHeapMemory();
   }
 
   private OffHeapStoredObject createChunk(Object value) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
index d878358..d30d4c4 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
@@ -152,7 +152,7 @@ public class OffHeapStorageJUnitTest {
     StatisticsFactory localStatsFactory = new LocalStatisticsFactory(null);
     InternalDistributedSystem ids = mock(InternalDistributedSystem.class);
     MemoryAllocator ma = OffHeapStorage.createOffHeapStorage(localStatsFactory, OffHeapStorage.MIN_SLAB_SIZE, ids);
-    System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "true");
+    System.setProperty(MemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "true");
     ma.close();
   }
 
@@ -260,11 +260,11 @@ public class OffHeapStorageJUnitTest {
       verify(ooohml).outOfOffHeapMemory(ex);
 
     } finally {
-      System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "true");
+      System.setProperty(MemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "true");
       try {
         ma.close();
       } finally {
-        System.clearProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY);
+        System.clearProperty(MemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStackJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStackJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStackJUnitTest.java
index 884787f..1d19854 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStackJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStackJUnitTest.java
@@ -107,13 +107,13 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
   public void stackCreatedWithAddressIsNotEmpty() {
     SlabImpl slab = new SlabImpl(1024);
     try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
       OffHeapStoredObject chunk = (OffHeapStoredObject) ma.allocate(100);
 
       OffHeapStoredObjectAddressStack stack = new OffHeapStoredObjectAddressStack(chunk.getAddress());
       assertEquals(false, stack.isEmpty());
     } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+      MemoryAllocatorImpl.freeOffHeapMemory();
     }
   }
 
@@ -121,14 +121,14 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
   public void stackWithChunkIsNotEmpty() {
     SlabImpl slab = new SlabImpl(1024);
     try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
       OffHeapStoredObject chunk = (OffHeapStoredObject) ma.allocate(100);
 
       OffHeapStoredObjectAddressStack stack = new OffHeapStoredObjectAddressStack();
       stack.offer(chunk.getAddress());
       assertEquals(false, stack.isEmpty());
     } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+      MemoryAllocatorImpl.freeOffHeapMemory();
     }
   }
 
@@ -136,7 +136,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
   public void stackWithChunkTopEqualsAddress() {
     SlabImpl slab = new SlabImpl(1024);
     try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
       OffHeapStoredObject chunk = (OffHeapStoredObject) ma.allocate(100);
 
       long addr = chunk.getAddress();
@@ -144,7 +144,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
       stack.offer(addr);
       assertEquals(addr, stack.getTopAddress());
     } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+      MemoryAllocatorImpl.freeOffHeapMemory();
     }
   }
 
@@ -163,7 +163,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
   public void stackWithChunkClearReturnsAddressAndEmptiesStack() {
     SlabImpl slab = new SlabImpl(1024);
     try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
       OffHeapStoredObject chunk = (OffHeapStoredObject) ma.allocate(100);
 
       long addr = chunk.getAddress();
@@ -173,7 +173,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
       assertEquals(addr, clearAddr);
       assertEquals(true, stack.isEmpty());
     } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+      MemoryAllocatorImpl.freeOffHeapMemory();
     }
   }
 
@@ -181,7 +181,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
   public void stackWithChunkPollReturnsAddressAndEmptiesStack() {
     SlabImpl slab = new SlabImpl(1024);
     try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
       OffHeapStoredObject chunk = (OffHeapStoredObject) ma.allocate(100);
 
       long addr = chunk.getAddress();
@@ -191,7 +191,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
       assertEquals(addr, pollAddr);
       assertEquals(true, stack.isEmpty());
     } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+      MemoryAllocatorImpl.freeOffHeapMemory();
     }
   }
 
@@ -199,7 +199,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
   public void stackWithChunkTotalSizeIsChunkSize() {
     SlabImpl slab = new SlabImpl(1024);
     try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
       OffHeapStoredObject chunk = (OffHeapStoredObject) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
@@ -208,7 +208,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
       stack.offer(addr);
       assertEquals(chunkSize, stack.computeTotalSize());
     } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+      MemoryAllocatorImpl.freeOffHeapMemory();
     }
   }
 
@@ -217,7 +217,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
   public void stackWithChunkLogShowsMsgAndSize() {
     SlabImpl slab = new SlabImpl(1024);
     try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
       OffHeapStoredObject chunk = (OffHeapStoredObject) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
@@ -228,15 +228,15 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
       stack.logSizes(lw, "foo");
       verify(lw).info("foo"+chunkSize);
     } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+      MemoryAllocatorImpl.freeOffHeapMemory();
     }
   }
   
   private class TestableSyncChunkStack extends OffHeapStoredObjectAddressStack {
     public boolean doConcurrentMod = true;
     public int chunk2Size;
-    private SimpleMemoryAllocatorImpl ma;
-    TestableSyncChunkStack(SimpleMemoryAllocatorImpl ma) {
+    private MemoryAllocatorImpl ma;
+    TestableSyncChunkStack(MemoryAllocatorImpl ma) {
       this.ma = ma;
     }
     @Override
@@ -253,7 +253,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
   public void stackWithChunkTotalSizeIsChunkSizeWithConcurrentMod() {
     SlabImpl slab = new SlabImpl(1024);
     try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
       OffHeapStoredObject chunk = (OffHeapStoredObject) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
@@ -263,7 +263,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
       long totalSize = stack.computeTotalSize();
       assertEquals("chunkSize=" + chunkSize + " chunk2Size=" + stack.chunk2Size, chunkSize + stack.chunk2Size, totalSize);
     } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+      MemoryAllocatorImpl.freeOffHeapMemory();
     }
   }
 
@@ -272,7 +272,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
   public void stackWithChunkLogShowsMsgAndSizeWithConcurrentMod() {
     SlabImpl slab = new SlabImpl(1024);
     try {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{slab});
       OffHeapStoredObject chunk = (OffHeapStoredObject) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
@@ -284,7 +284,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
       verify(lw).info("foo"+chunkSize);
       verify(lw).info("foo"+stack.chunk2Size);
     } finally {
-      SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+      MemoryAllocatorImpl.freeOffHeapMemory();
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
index 956acb4..85c8d4c 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
@@ -63,12 +63,12 @@ public class OffHeapStoredObjectJUnitTest extends AbstractStoredObjectTestBase {
     OutOfOffHeapMemoryListener ooohml = mock(OutOfOffHeapMemoryListener.class);
     OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
 
-    ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, 3, OffHeapStorage.MIN_SLAB_SIZE * 3, OffHeapStorage.MIN_SLAB_SIZE);
+    ma = MemoryAllocatorImpl.create(ooohml, stats, 3, OffHeapStorage.MIN_SLAB_SIZE * 3, OffHeapStorage.MIN_SLAB_SIZE);
   }
 
   @After
   public void tearDown() {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    MemoryAllocatorImpl.freeOffHeapMemory();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
index f8a5c8e..aa09449 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
@@ -184,7 +184,7 @@ public class OffHeapValidationJUnitTest {
     MemoryBlock firstBlock = inspector.getFirstBlock();
     assertEquals(MemoryBlock.State.UNUSED, firstBlock.getState());
     
-    //System.out.println(((SimpleMemoryAllocatorImpl)inspector).getSnapshot());
+    //System.out.println(((MemoryAllocatorImpl)inspector).getSnapshot());
     
     // sort the ExpectedValues into the same order as the MemberBlocks from inspector
     Collections.sort(expected, 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
index 7157eaa..5d79192 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
@@ -33,7 +33,7 @@ import com.gemstone.gemfire.internal.HeapDataOutputStream;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
 import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.offheap.SlabImpl;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
@@ -43,16 +43,16 @@ public class OffHeapWriteObjectAsByteArrayJUnitTest {
 
   @Before
   public void setUp() throws Exception {
-    SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
+    MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
   }
 
   @After
   public void tearDown() throws Exception {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    MemoryAllocatorImpl.freeOffHeapMemory();
   }
   
   private StoredObject createStoredObject(byte[] bytes, boolean isSerialized, boolean isCompressed) {
-    return SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, isSerialized, isCompressed);
+    return MemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, isSerialized, isCompressed);
   }
   
   private DataInputStream createInput(HeapDataOutputStream hdos) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
index 25de4ea..9c2e5e8 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
@@ -91,7 +91,7 @@ public class OutOfOffHeapMemoryDUnitTest extends CacheTestCase {
   @SuppressWarnings("unused") // invoked by reflection from tearDown2()
   private static void cleanup() {
     disconnectFromDS();
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    MemoryAllocatorImpl.freeOffHeapMemory();
     cache.set(null);
     system.set(null);
     isSmallerVM.set(false);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java
deleted file mode 100644
index 51bc0a2..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.offheap;
-
-import static org.junit.Assert.*;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Tests fill pattern validation for the {@link SimpleMemoryAllocatorImpl}.
- */
-@Category(IntegrationTest.class)
-public class SimpleMemoryAllocatorFillPatternIntegrationTest {
-  private static Random random = ThreadLocalRandom.current();
-
-  /**
-   * Chunk operation types.
-   */
-  static enum Operation {
-    ALLOCATE,
-    FREE,
-    WRITE;
-    
-    // Holds all Operation values
-    private static Operation[] values = Operation.values(); 
-    
-    static Operation randomOperation() {
-      return values[random.nextInt(values.length)];
-    }
-  };
-  
-  /** Number of worker threads for advanced tests. */
-  private static final int WORKER_THREAD_COUNT = 5;
-  
-  /** Size of single test slab.*/
-  private static final int SLAB_SIZE = 1024 * 1024 * 50;
-  
-  /** Maximum number of bytes a worker thread can allocate during advanced tests.  */
-  private static final int MAX_WORKER_ALLOCATION_TOTAL_SIZE = SLAB_SIZE / WORKER_THREAD_COUNT / 2;
-  
-  /** Maximum allocation for a single Chunk.  */
-  private static final int MAX_WORKER_ALLOCATION_SIZE = 512;
-  
-  /** Canned data for write operations. */
-  private static final byte[] WRITE_BYTES = new String("Some string data.").getBytes();
-  
-  /** Minimum size for write operations. */
-  private static final int MIN_WORKER_ALLOCATION_SIZE = WRITE_BYTES.length;
-
-  /** Runtime for worker threads. */
-  private static final long RUN_TIME_IN_MILLIS = 1 * 1000 * 5;
-  
-  /** Chunk size for basic huge allocation test. */
-  private static final int HUGE_CHUNK_SIZE = 1024 * 200;
-  
-  /** Our test victim. */
-  private SimpleMemoryAllocatorImpl allocator = null;
-  
-  /** Our test victim's memory slab. */
-  private SlabImpl slab = null;
-
-  /**
-   * Enables fill validation and creates the test victim.
-   */
-  @Before
-  public void setUp() throws Exception {
-    System.setProperty("gemfire.validateOffHeapWithFill", "true");
-    this.slab = new SlabImpl(SLAB_SIZE);
-    this.allocator = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{this.slab});
-  }
-
-  /**
-   * Frees off heap memory.
-   */
-  @After
-  public void tearDown() throws Exception {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-    System.clearProperty("gemfire.validateOffHeapWithFill");
-  }
-  
-  /**
-   * This test hammers a SimpleMemoryAllocatorImpl with multiple threads exercising
-   * the fill validation of tiny Chunks for one minute.  This, of course, exercises many aspects of
-   * the SimpleMemoryAllocatorImpl and its helper classes.
-   * @throws Exception
-   */
-  @Test
-  public void testFillPatternAdvancedForTinyAllocations() throws Exception { 
-    doFillPatternAdvancedTest(new ChunkSizer() {
-      @Override
-      public int allocationSize() {
-        int allocation = random.nextInt(MAX_WORKER_ALLOCATION_SIZE+1);
-        
-        while(allocation < MIN_WORKER_ALLOCATION_SIZE) {
-          allocation = random.nextInt(MAX_WORKER_ALLOCATION_SIZE+1);
-        }
-        return allocation;
-      }
-    });
-  }
-
-  /**
-   * This test hammers a SimpleMemoryAllocatorImpl with multiple threads exercising
-   * the fill validation of huge Chunks for one minute.  This, of course, exercises many aspects of
-   * the SimpleMemoryAllocatorImpl and its helper classes.
-   * @throws Exception
-   */
-  @Test
-  public void testFillPatternAdvancedForHugeAllocations() throws Exception {
-    doFillPatternAdvancedTest(new ChunkSizer() {
-      @Override
-      public int allocationSize() {
-        return HUGE_CHUNK_SIZE;
-      }
-    });
-  }
-  
-  private interface ChunkSizer {
-    int allocationSize();
-  }
-  
-  private void doFillPatternAdvancedTest(final ChunkSizer chunkSizer) throws InterruptedException {
-    // Used to manage worker thread completion
-    final CountDownLatch latch = new CountDownLatch(WORKER_THREAD_COUNT);
-    
-    // Use to track any errors the worker threads will encounter
-    final List<Throwable> threadErrorList = Collections.synchronizedList(new LinkedList<Throwable>());
-    
-    /*
-     * Start up a number of worker threads.  These threads will randomly allocate, free,
-     * and write to Chunks.
-     */
-    for(int i = 0;i < WORKER_THREAD_COUNT;++i) {
-      new Thread(new Runnable() {
-        // Total allocation in bytes for this thread
-        private int totalAllocation = 0;
-        
-        // List of Chunks allocated by this thread
-        private List<OffHeapStoredObject> chunks = new LinkedList<OffHeapStoredObject>();
-        
-        // Time to end thread execution
-        private long endTime = System.currentTimeMillis() + RUN_TIME_IN_MILLIS;
-        
-        /**
-         * Allocates a chunk and adds it to the thread's Chunk list.
-         */
-        private void allocate() {          
-          int allocation = chunkSizer.allocationSize();
-          OffHeapStoredObject chunk = (OffHeapStoredObject) allocator.allocate(allocation);
-          
-          // This should always work just after allocation
-          chunk.validateFill();
-          
-          chunks.add(chunk);
-          totalAllocation += chunk.getSize();
-        }
-        
-        /**
-         * Frees a random chunk from the Chunk list.
-         */
-        private void free() {
-          OffHeapStoredObject chunk = chunks.remove(random.nextInt(chunks.size()));
-          totalAllocation -= chunk.getSize();
-          
-          /*
-           * Chunk is filled here but another thread may have already grabbed it so we
-           * cannot validate the fill.
-           */
-          chunk.release(); 
-        }
-        
-        /**
-         * Writes canned data to a random Chunk from the Chunk list.
-         */
-        private void write() {
-          OffHeapStoredObject chunk = chunks.get(random.nextInt(chunks.size()));
-          chunk.writeDataBytes(0, WRITE_BYTES);
-        }
-        
-        /**
-         * Randomly selects Chunk operations and executes them
-         * for a period of time.  Collects any error thrown during execution.
-         */
-        @Override
-        public void run() {
-          try {
-            for(long currentTime = System.currentTimeMillis();currentTime < endTime;currentTime = System.currentTimeMillis()) {
-              Operation op = (totalAllocation == 0 ? Operation.ALLOCATE : (totalAllocation >= MAX_WORKER_ALLOCATION_TOTAL_SIZE ? Operation.FREE : Operation.randomOperation()));
-              switch(op) {
-              case ALLOCATE:
-                allocate();
-                break;
-              case FREE:
-                free();
-                break;
-              case WRITE:
-                write();
-                break;
-              }
-            }
-          } catch (Throwable t) {
-            threadErrorList.add(t);
-          } finally {
-            latch.countDown();
-          }
-       }        
-      }).start();
-    }
-    
-    // Make sure each thread ended cleanly
-    assertTrue(latch.await(2, TimeUnit.MINUTES));
-    
-    // Fail on the first error we find
-    if(!threadErrorList.isEmpty()) {
-      fail(threadErrorList.get(0).getMessage());
-    }
-  }
-  
-}


[10/26] incubator-geode git commit: GEODE-992: Integrate with Travis CI

Posted by kl...@apache.org.
GEODE-992: Integrate with Travis CI

use absolute path while cat'ing the result of rat.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 4e84f1a890f244b164001cf381232b9fb06a1eb4
Parents: a904f14
Author: Swapnil Bawaskar <sb...@pivotal.io>
Authored: Wed Mar 16 10:17:36 2016 -0700
Committer: Swapnil Bawaskar <sb...@pivotal.io>
Committed: Wed Mar 16 10:18:46 2016 -0700

----------------------------------------------------------------------
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4e84f1a8/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 49197cd..c532f20 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,7 +27,7 @@ cache:
     - $HOME/.gradle/wrapper/
 
 after_failure:
-  - cat build/reports/rat/rat-report.txt
+  - cat /home/travis/build/apache/incubator-geode/build/reports/rat/rat-report.txt
 
 notifications:
   email:


[24/26] incubator-geode git commit: GEODE-1067: The dispatcher now handles IllegalStateException by retrying batch without the released event

Posted by kl...@apache.org.
GEODE-1067: The dispatcher now handles IllegalStateException by retrying batch without the released event


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

Branch: refs/heads/feature/GEODE-949-2
Commit: ff69aeae9615d7263075079e8e5f5180bc350dce
Parents: 5b6a2cd
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Wed Mar 16 12:27:39 2016 -0700
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Thu Mar 17 10:11:47 2016 -0700

----------------------------------------------------------------------
 .../wan/AbstractGatewaySenderEventProcessor.java     | 15 +++++++++++++++
 .../internal/cache/wan/GatewaySenderEventImpl.java   |  7 +++++++
 .../wan/GatewaySenderEventRemoteDispatcher.java      | 15 +++++++++++----
 3 files changed, 33 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ff69aeae/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 51b125a..5020cf2 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
@@ -520,6 +520,21 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread {
           filteredList = new ArrayList<GatewaySenderEventImpl>();
           
           filteredList.addAll(events);
+
+          // If the exception has been set and its cause is an IllegalStateExcetption,
+          // remove all events whose serialized value is no longer available
+          if (this.exception != null && this.exception.getCause() != null
+              && this.exception.getCause() instanceof IllegalStateException) {
+            for (Iterator<GatewaySenderEventImpl> i = filteredList.iterator(); i.hasNext();) {
+              GatewaySenderEventImpl event = i.next();
+              if (event.isSerializedValueNotAvailable()) {
+                i.remove();
+              }
+            }
+            this.exception = null;
+          }
+
+          // Filter the events
           for (GatewayEventFilter filter : sender.getGatewayEventFilters()) {
             Iterator<GatewaySenderEventImpl> itr = filteredList.iterator();
             while (itr.hasNext()) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ff69aeae/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
index d8922f8..6f284b5 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
@@ -131,6 +131,8 @@ public class GatewaySenderEventImpl implements
   protected transient Object valueObj;
   protected transient boolean valueObjReleased;
 
+  private transient boolean serializedValueNotAvailable;
+
   /**
    * Whether the value is a serialized object or just a byte[]
    */
@@ -662,6 +664,10 @@ public class GatewaySenderEventImpl implements
     }
   }
 
+  public boolean isSerializedValueNotAvailable() {
+    return this.serializedValueNotAvailable;
+  }
+
   /**
    * If the value owned of this event is just bytes return that byte array;
    * otherwise serialize the value object and return the serialized bytes.
@@ -698,6 +704,7 @@ public class GatewaySenderEventImpl implements
             this.value = result;
           } else if (result == null) {
             if (this.valueObjReleased) {
+              this.serializedValueNotAvailable = true;
               throw new IllegalStateException("Value is no longer available. getSerializedValue must be called before processEvents returns.");
             }
           }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ff69aeae/geode-wan/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java b/geode-wan/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
index 22dff3d..ad2be2b 100644
--- a/geode-wan/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
+++ b/geode-wan/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
@@ -163,7 +163,8 @@ public class GatewaySenderEventRemoteDispatcher implements
       } else if (t instanceof IOException
           || t instanceof ServerConnectivityException
           || t instanceof ConnectionDestroyedException
-          || t instanceof MessageTooLargeException) {
+          || t instanceof MessageTooLargeException
+          || t instanceof IllegalStateException) {
         this.processor.handleException();
         // If the cause is an IOException or a ServerException, sleep and retry.
         // Sleep for a bit and recheck.
@@ -268,6 +269,12 @@ public class GatewaySenderEventRemoteDispatcher implements
           LocalizedStrings.GatewayEventRemoteDispatcher_0_EXCEPTION_DURING_PROCESSING_BATCH_1_ON_CONNECTION_2.toLocalizedString(
               new Object[] {this, Integer.valueOf(currentBatchId), connection}), ex);
     }
+    catch (IllegalStateException e) {
+      this.processor.setException(new GatewaySenderException(e));
+      throw new GatewaySenderException(
+          LocalizedStrings.GatewayEventRemoteDispatcher_0_EXCEPTION_DURING_PROCESSING_BATCH_1_ON_CONNECTION_2.toLocalizedString(
+              new Object[] {this, Integer.valueOf(currentBatchId), connection}), e);
+    }
     catch (Exception e) {
       // An Exception has occurred. Get its cause.
       Throwable t = e.getCause();
@@ -321,7 +328,7 @@ public class GatewaySenderEventRemoteDispatcher implements
     if (cache != null && !cache.isClosed()) {
       if (this.sender.isPrimary() && (this.connection != null)) {
         if (this.ackReaderThread == null || !this.ackReaderThread.isRunning()) {
-          this.ackReaderThread = new AckReaderThread(this.sender);
+          this.ackReaderThread = new AckReaderThread(this.sender, this.processor);
           this.ackReaderThread.start();
           this.ackReaderThread.waitForRunningAckReaderThreadRunningState();
         }
@@ -541,8 +548,8 @@ public class GatewaySenderEventRemoteDispatcher implements
 
     private volatile boolean ackReaderThreadRunning = false;
 
-    public AckReaderThread(GatewaySender sender) {
-      super("AckReaderThread for : " + sender.getId());
+    public AckReaderThread(GatewaySender sender, AbstractGatewaySenderEventProcessor processor) {
+      super("AckReaderThread for : " + processor.getName());
       this.setDaemon(true);
       this.cache = (GemFireCacheImpl)((AbstractGatewaySender)sender).getCache();
     }


[18/26] incubator-geode git commit: GEODE-1103 intermittent suspect string in server cache during shutdown

Posted by kl...@apache.org.
GEODE-1103 intermittent suspect string in server cache during shutdown

Added an exception handler for InterruptedException that checks to see
if the AcceptorImpl is shutting down.  If so a warning message about the
interrupt is not logged.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: bec420bf54d7c78a8a81264f41b578f529453327
Parents: 442718f
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Wed Mar 16 16:02:30 2016 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Wed Mar 16 16:02:30 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/cache/tier/sockets/AcceptorImpl.java   | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bec420bf/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/AcceptorImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/AcceptorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/AcceptorImpl.java
index 89c073f..9f18f50 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/AcceptorImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/AcceptorImpl.java
@@ -1682,12 +1682,13 @@ public class AcceptorImpl extends Acceptor implements Runnable
         }
 
       } // synchronized
-    }
-    catch (Exception e) {/* ignore */
+    } catch (InterruptedException e) {
+      if (!this.shutdown) { // GEODE-1103: expect an interrupt during shutdown
+        logger.warn(LocalizedMessage.create(LocalizedStrings.AcceptorImpl_UNEXPECTED), e);
+      }
+    } catch (Exception e) {/* ignore */
       logger.warn(LocalizedMessage.create(LocalizedStrings.AcceptorImpl_UNEXPECTED), e);
     }
-    finally{
-    }
   }
   
   private void shutdownSCs() {


[09/26] incubator-geode git commit: GEODE-478: GatewaySender now handles MessageTooLargeExceptions

Posted by kl...@apache.org.
GEODE-478: GatewaySender now handles MessageTooLargeExceptions


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

Branch: refs/heads/feature/GEODE-949-2
Commit: a904f1474ec3153bc39f650d49731214f25c6230
Parents: 4d0dfc5
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Tue Mar 8 15:55:34 2016 -0800
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Wed Mar 16 09:56:41 2016 -0700

----------------------------------------------------------------------
 .../internal/cache/tier/sockets/Message.java    |  2 +-
 .../AbstractGatewaySenderEventProcessor.java    | 33 +++++++--
 .../parallel/ParallelGatewaySenderQueue.java    | 74 ++++++++++++++++----
 .../gemfire/internal/i18n/LocalizedStrings.java |  6 +-
 .../wan/GatewaySenderEventRemoteDispatcher.java | 31 +++++++-
 .../gemfire/internal/cache/wan/WANTestBase.java | 26 +++++--
 ...arallelGatewaySenderOperationsDUnitTest.java | 35 +++++++++
 7 files changed, 177 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a904f147/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Message.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Message.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Message.java
index a6495e2..44c88c1 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Message.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Message.java
@@ -564,7 +564,7 @@ public class Message  {
         msgLen = (int)(headerLen + totalPartLen);
         
         if (msgLen > MAX_MESSAGE_SIZE) {
-          throw new MessageTooLargeException("Message size(" + msgLen
+          throw new MessageTooLargeException("Message size (" + msgLen
               + ") exceeds gemfire.client.max-message-size setting (" + MAX_MESSAGE_SIZE + ")");
         }
         

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a904f147/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 86ecce1..51b125a 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
@@ -38,12 +38,9 @@ import com.gemstone.gemfire.cache.EntryEvent;
 import com.gemstone.gemfire.cache.Operation;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionDestroyedException;
-import com.gemstone.gemfire.cache.client.internal.Connection;
-import com.gemstone.gemfire.cache.client.internal.pooling.ConnectionDestroyedException;
 import com.gemstone.gemfire.cache.wan.GatewayEventFilter;
 import com.gemstone.gemfire.cache.wan.GatewayQueueEvent;
 import com.gemstone.gemfire.cache.wan.GatewaySender;
-import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.internal.cache.BucketRegion;
 import com.gemstone.gemfire.internal.cache.Conflatable;
 import com.gemstone.gemfire.internal.cache.DistributedRegion;
@@ -143,6 +140,13 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread {
   private volatile boolean resetLastPeekedEvents;
   
   private long numEventsDispatched;
+
+  /**
+   * The batchSize is the batch size being used by this processor. By default, it is the
+   * configured batch size of the GatewaySender. It may be automatically reduced if a
+   * MessageTooLargeException occurs.
+   */
+  private int batchSize;
   
   /**
    * @param createThreadGroup
@@ -152,6 +156,7 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread {
       String string, GatewaySender sender) {
     super(createThreadGroup, string);
     this.sender = (AbstractGatewaySender)sender;
+    this.batchSize = sender.getBatchSize();
   }
 
   abstract protected void initializeMessageQueue(String id);
@@ -214,6 +219,23 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread {
     this.resetLastPeekedEvents = true;
   }
 
+  protected int getBatchSize() {
+    return this.batchSize;
+  }
+
+  protected void setBatchSize(int batchSize) {
+    int currentBatchSize = this.batchSize;
+    if (batchSize <= 0) {
+      this.batchSize = 1;
+      logger.warn(LocalizedMessage.create(
+          LocalizedStrings.AbstractGatewaySenderEventProcessor_ATTEMPT_TO_SET_BATCH_SIZE_FAILED, new Object[] { currentBatchSize, batchSize }));
+    } else {
+      this.batchSize = batchSize;
+      logger.info(LocalizedMessage.create(
+          LocalizedStrings.AbstractGatewaySenderEventProcessor_SET_BATCH_SIZE, new Object[] { currentBatchSize, this.batchSize }));
+    }
+  }
+
   /**
    * Returns the current batch id to be used to identify the next batch.
    * 
@@ -387,7 +409,6 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread {
     final boolean isDebugEnabled = logger.isDebugEnabled();
     final boolean isTraceEnabled = logger.isTraceEnabled();
     
-    final int batchSize = sender.getBatchSize();
     final int batchTimeInterval = sender.getBatchTimeInterval();
     final GatewaySenderStats statistics = this.sender.getStatistics();
     
@@ -417,7 +438,7 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread {
 
         // Peek a batch
         if (isDebugEnabled) {
-          logger.debug("Attempting to peek a batch of {} events", batchSize);
+          logger.debug("Attempting to peek a batch of {} events", this.batchSize);
         }
         for (;;) {
           // check before sleeping
@@ -481,7 +502,7 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread {
               }
             }*/
             }
-            events = this.queue.peek(batchSize, batchTimeInterval);
+            events = this.queue.peek(this.batchSize, batchTimeInterval);
           } catch (InterruptedException e) {
             interrupted = true;
             this.sender.getCancelCriterion().checkCancelInProgress(e);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a904f147/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java
index c00903f..a9d0f3e 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java
@@ -54,7 +54,6 @@ import com.gemstone.gemfire.cache.EvictionAttributes;
 import com.gemstone.gemfire.cache.PartitionAttributesFactory;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionAttributes;
-import com.gemstone.gemfire.cache.RegionDestroyedException;
 import com.gemstone.gemfire.cache.asyncqueue.internal.AsyncEventQueueImpl;
 import com.gemstone.gemfire.distributed.internal.DM;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
@@ -143,7 +142,17 @@ public class ParallelGatewaySenderQueue implements RegionQueue {
   private static BatchRemovalThread removalThread = null;
 
   protected BlockingQueue<GatewaySenderEventImpl> peekedEvents = new LinkedBlockingQueue<GatewaySenderEventImpl>();
-  
+
+  /**
+   * The peekedEventsProcessing queue is used when the batch size is reduced due to a MessageTooLargeException
+   */
+  private BlockingQueue<GatewaySenderEventImpl> peekedEventsProcessing = new LinkedBlockingQueue<GatewaySenderEventImpl>();
+
+  /**
+   * The peekedEventsProcessingInProgress boolean denotes that processing existing peeked events is in progress
+   */
+  private boolean peekedEventsProcessingInProgress = false;
+
   public final AbstractGatewaySender sender ;
   
   public static final int WAIT_CYCLE_SHADOW_BUCKET_LOAD = 10;
@@ -1147,6 +1156,10 @@ public class ParallelGatewaySenderQueue implements RegionQueue {
 
   public void resetLastPeeked() {
     this.resetLastPeeked = true;
+
+    // Reset the in progress boolean and queue for peeked events in progress
+    this.peekedEventsProcessingInProgress = false;
+    this.peekedEventsProcessing.clear();
   }
   
   // Need to improve here.If first peek returns NULL then look in another bucket.
@@ -1283,19 +1296,9 @@ public class ParallelGatewaySenderQueue implements RegionQueue {
     long start = System.currentTimeMillis();
     long end = start + timeToWait;
 
-    if (this.resetLastPeeked) {
-      batch.addAll(peekedEvents);
-      this.resetLastPeeked = false;
-      if (isDebugEnabled) {
-        StringBuffer buffer = new StringBuffer();
-        for (GatewaySenderEventImpl ge : peekedEvents) {
-          buffer.append("event :");
-          buffer.append(ge);
-        }
-        logger.debug("Adding already peeked events to the batch {}", buffer);
-      }
-    }
-    
+    // Add peeked events
+    addPeekedEvents(batch, batchSize);
+
     int bId = -1;
     while (batch.size() < batchSize) {
       if (areLocalBucketQueueRegionsPresent()
@@ -1372,6 +1375,47 @@ public class ParallelGatewaySenderQueue implements RegionQueue {
     return batch;
   }
 
+  private void addPeekedEvents(List batch, int batchSize) {
+    if (this.resetLastPeeked) {
+      if (this.peekedEventsProcessingInProgress) {
+        // Peeked event processing is in progress. This means that the original peekedEvents
+        // contained > batch size events due to a reduction in the batch size. Create a batch
+        // from the peekedEventsProcessing queue.
+        addPreviouslyPeekedEvents(batch, batchSize);
+      } else if (peekedEvents.size() <= batchSize) {
+        // This is the normal case. The connection was lost while processing a batch.
+        // This recreates the batch from the current peekedEvents.
+        batch.addAll(peekedEvents);
+        this.resetLastPeeked = false;
+      } else {
+        // The peekedEvents queue is > batch size. This means that the previous batch size was
+        // reduced due to MessageTooLargeException. Create a batch from the peekedEventsProcessing queue.
+        this.peekedEventsProcessing.addAll(this.peekedEvents);
+        this.peekedEventsProcessingInProgress = true;
+        addPreviouslyPeekedEvents(batch, batchSize);
+      }
+      if (logger.isDebugEnabled()) {
+        StringBuffer buffer = new StringBuffer();
+        for (Object ge : batch) {
+          buffer.append("event :");
+          buffer.append(ge);
+        }
+        logger.debug("Adding already peeked events to the batch {}", buffer);
+      }
+    }
+  }
+
+  private void addPreviouslyPeekedEvents(List batch, int batchSize) {
+    for (int i=0; i<batchSize; i++) {
+      batch.add(this.peekedEventsProcessing.remove());
+      if (this.peekedEventsProcessing.isEmpty()) {
+        this.resetLastPeeked = false;
+        this.peekedEventsProcessingInProgress = false;
+        break;
+      }
+    }
+  }
+
   protected void blockProcesorThreadIfRequired() throws InterruptedException {
     queueEmptyLock.lock();
     try {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a904f147/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
index 8147718..3996692 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
@@ -2145,7 +2145,11 @@ public class LocalizedStrings extends ParentLocalizedStrings {
   public static final StringId AUTH_FAILED_TO_ACQUIRE_AUTHINITIALIZE_INSTANCE = new StringId(6611, "AuthInitialize instance could not be obtained");
   public static final StringId AUTH_FAILED_TO_OBTAIN_CREDENTIALS_IN_0_USING_AUTHINITIALIZE_1_2 = new StringId(6612, "Failed to obtain credentials using AuthInitialize [{1}]. {2}");
   public static final StringId DistributedSystem_BACKUP_ALREADY_IN_PROGRESS = new StringId(6613, "A backup is already in progress.");
-  
+
+  public static final StringId AbstractGatewaySenderEventProcessor_SET_BATCH_SIZE = new StringId(6614, "Set the batch size from {0} to {1} events");
+  public static final StringId AbstractGatewaySenderEventProcessor_ATTEMPT_TO_SET_BATCH_SIZE_FAILED = new StringId(6615, "Attempting to set the batch size from {0} to {1} events failed. Instead it was set to 1.");
+  public static final StringId GatewaySenderEventRemoteDispatcher_MESSAGE_TOO_LARGE_EXCEPTION = new StringId(6616, "The following exception occurred attempting to send a batch of {0} events. The batch will be tried again after reducing the batch size to {1} events.");
+
   /** Testing strings, messageId 90000-99999 **/
   
   /** These are simple messages for testing, translated with Babelfish. **/

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a904f147/geode-wan/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java b/geode-wan/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
index 9da6748..22dff3d 100644
--- a/geode-wan/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
+++ b/geode-wan/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
@@ -23,6 +23,8 @@ import java.util.List;
 import java.util.Set;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import com.gemstone.gemfire.GemFireIOException;
+import com.gemstone.gemfire.internal.cache.tier.sockets.MessageTooLargeException;
 import org.apache.logging.log4j.Logger;
 
 import com.gemstone.gemfire.CancelException;
@@ -31,7 +33,6 @@ import com.gemstone.gemfire.cache.RegionDestroyedException;
 import com.gemstone.gemfire.cache.client.ServerConnectivityException;
 import com.gemstone.gemfire.cache.client.ServerOperationException;
 import com.gemstone.gemfire.cache.client.internal.Connection;
-import com.gemstone.gemfire.cache.client.internal.ServerProxy;
 import com.gemstone.gemfire.cache.client.internal.pooling.ConnectionDestroyedException;
 import com.gemstone.gemfire.cache.wan.GatewaySender;
 import com.gemstone.gemfire.distributed.internal.ServerLocation;
@@ -151,7 +152,9 @@ public class GatewaySenderEventRemoteDispatcher implements
     try {
       long start = statistics.startTime();
       success =_dispatchBatch(events, isRetry);
-      statistics.endBatch(start, events.size());
+      if (success) {
+        statistics.endBatch(start, events.size());
+      }
     } catch (GatewaySenderException ge) {
 
       Throwable t = ge.getCause();
@@ -159,7 +162,8 @@ public class GatewaySenderEventRemoteDispatcher implements
         // if our pool is shutdown then just be silent
       } else if (t instanceof IOException
           || t instanceof ServerConnectivityException
-          || t instanceof ConnectionDestroyedException) {
+          || t instanceof ConnectionDestroyedException
+          || t instanceof MessageTooLargeException) {
         this.processor.handleException();
         // If the cause is an IOException or a ServerException, sleep and retry.
         // Sleep for a bit and recheck.
@@ -243,6 +247,27 @@ public class GatewaySenderEventRemoteDispatcher implements
           LocalizedStrings.GatewayEventRemoteDispatcher_0_EXCEPTION_DURING_PROCESSING_BATCH_1_ON_CONNECTION_2.toLocalizedString(
               new Object[] {this, Integer.valueOf(currentBatchId), connection}), ex);
     }
+    catch (GemFireIOException e) {
+      Throwable t = e.getCause();
+      if (t instanceof MessageTooLargeException) {
+        // A MessageTooLargeException has occurred.
+        // Do not process the connection as dead since it is not dead.
+        ex = (MessageTooLargeException)t;
+        // Reduce the batch size by half of the configured batch size or number of events in the current batch (whichever is less)
+        int newBatchSize = Math.min(events.size(), this.processor.getBatchSize())/2;
+        logger.warn(LocalizedMessage.create(
+            LocalizedStrings.GatewaySenderEventRemoteDispatcher_MESSAGE_TOO_LARGE_EXCEPTION, new Object[] { events.size(), newBatchSize }), e);
+        this.processor.setBatchSize(newBatchSize);
+      }
+      else {
+        ex = e;
+        // keep using the connection if we had a MessageTooLargeException. Else, destroy it
+        destroyConnection();
+      }
+      throw new GatewaySenderException(
+          LocalizedStrings.GatewayEventRemoteDispatcher_0_EXCEPTION_DURING_PROCESSING_BATCH_1_ON_CONNECTION_2.toLocalizedString(
+              new Object[] {this, Integer.valueOf(currentBatchId), connection}), ex);
+    }
     catch (Exception e) {
       // An Exception has occurred. Get its cause.
       Throwable t = e.getCause();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a904f147/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/WANTestBase.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/WANTestBase.java b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/WANTestBase.java
index 0a1a7ef..5da6b5c 100644
--- a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/WANTestBase.java
+++ b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/WANTestBase.java
@@ -2257,7 +2257,7 @@ public class WANTestBase extends DistributedTestCase{
   public static void createSender(String dsName, int remoteDsId,
       boolean isParallel, Integer maxMemory,
       Integer batchSize, boolean isConflation, boolean isPersistent,
-      GatewayEventFilter filter, boolean isManulaStart) {
+      GatewayEventFilter filter, boolean isManualStart) {
     final IgnoredException exln = IgnoredException.addIgnoredException("Could not connect");
     try {
       File persistentDirectory = new File(dsName + "_disk_"
@@ -2270,7 +2270,7 @@ public class WANTestBase extends DistributedTestCase{
         gateway.setParallel(true);
         gateway.setMaximumQueueMemory(maxMemory);
         gateway.setBatchSize(batchSize);
-        gateway.setManualStart(isManulaStart);
+        gateway.setManualStart(isManualStart);
         //set dispatcher threads
         gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
         ((InternalGatewaySenderFactory) gateway)
@@ -2294,7 +2294,7 @@ public class WANTestBase extends DistributedTestCase{
         GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
         gateway.setMaximumQueueMemory(maxMemory);
         gateway.setBatchSize(batchSize);
-        gateway.setManualStart(isManulaStart);
+        gateway.setManualStart(isManualStart);
         //set dispatcher threads
         gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
         ((InternalGatewaySenderFactory) gateway)
@@ -3056,7 +3056,25 @@ public class WANTestBase extends DistributedTestCase{
 //      r.destroy(i);
 //    }
   }
-  
+
+
+  public static void doPuts(String regionName, int numPuts, Object value) {
+    IgnoredException exp1 = IgnoredException.addIgnoredException(InterruptedException.class
+        .getName());
+    IgnoredException exp2 = IgnoredException.addIgnoredException(GatewaySenderException.class
+        .getName());
+    try {
+      Region r = cache.getRegion(Region.SEPARATOR + regionName);
+      assertNotNull(r);
+      for (long i = 0; i < numPuts; i++) {
+        r.put(i, value);
+      }
+    } finally {
+      exp1.remove();
+      exp2.remove();
+    }
+  }
+
   public static void doPuts(String regionName, int numPuts) {
     IgnoredException exp1 = IgnoredException.addIgnoredException(InterruptedException.class
         .getName());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a904f147/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderOperationsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderOperationsDUnitTest.java b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderOperationsDUnitTest.java
index 9e1b28c..f929d89 100644
--- a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderOperationsDUnitTest.java
+++ b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderOperationsDUnitTest.java
@@ -16,8 +16,10 @@
  */
 package com.gemstone.gemfire.internal.cache.wan.parallel;
 
+import com.gemstone.gemfire.GemFireIOException;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionDestroyedException;
+import com.gemstone.gemfire.internal.cache.tier.sockets.MessageTooLargeException;
 import com.gemstone.gemfire.internal.cache.wan.AbstractGatewaySender;
 import com.gemstone.gemfire.internal.cache.wan.GatewaySenderException;
 import com.gemstone.gemfire.internal.cache.wan.WANTestBase;
@@ -555,6 +557,39 @@ public class ParallelGatewaySenderOperationsDUnitTest extends WANTestBase {
     vm7.invoke(() -> WANTestBase.verifySenderDestroyed( "ln", true ));
   }
 
+  public void testParallelGatewaySenderMessageTooLargeException() {
+    Integer[] locatorPorts = createLNAndNYLocators();
+    Integer lnPort = locatorPorts[0];
+    Integer nyPort = locatorPorts[1];
+
+    // Create and start sender with reduced maximum message size and 1 dispatcher thread
+    String regionName = getTestMethodName() + "_PR";
+    vm4.invoke(() -> setMaximumMessageSize( 1024*1024 ));
+    vm4.invoke(() -> createCache( lnPort ));
+    vm4.invoke(() -> setNumDispatcherThreadsForTheRun( 1 ));
+    vm4.invoke(() -> createSender( "ln", 2, true, 100, 100, false, false, null, false ));
+    vm4.invoke(() -> createPartitionedRegion( regionName, "ln", 0, 100, isOffHeap() ));
+
+    // Do puts
+    int numPuts = 200;
+    vm4.invoke(() -> doPuts( regionName, numPuts, new byte[11000] ));
+    validateRegionSizes(regionName, numPuts, vm4);
+
+    // Start receiver
+    IgnoredException ignoredMTLE = IgnoredException.addIgnoredException(MessageTooLargeException.class.getName(), vm4);
+    IgnoredException ignoredGIOE = IgnoredException.addIgnoredException(GemFireIOException.class.getName(), vm4);
+    vm2.invoke(() -> createReceiver( nyPort ));
+    vm2.invoke(() -> createPartitionedRegion( regionName, null, 0, 100, isOffHeap() ));
+    validateRegionSizes( regionName, numPuts, vm2 );
+    ignoredMTLE.remove();
+    ignoredGIOE.remove();
+  }
+
+  private void setMaximumMessageSize(int maximumMessageSizeBytes) {
+    System.setProperty("gemfire.client.max-message-size", String.valueOf(maximumMessageSizeBytes));
+    LogWriterUtils.getLogWriter().info("Set gemfire.client.max-message-size: " + System.getProperty("gemfire.client.max-message-size"));
+  }
+
   private void createSendersReceiversAndPartitionedRegion(Integer lnPort, Integer nyPort, boolean createAccessors,
       boolean startSenders) {
     // Note: This is a test-specific method used by several test to create


[13/26] incubator-geode git commit: GEODE-1101: rename SimpleMemoryAllocator to MemoryAllocator

Posted by kl...@apache.org.
GEODE-1101: rename SimpleMemoryAllocator to MemoryAllocator


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 82faa8affc7517776418d84c21df9304ebf988de
Parents: 4e84f1a
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Tue Mar 15 11:39:30 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed Mar 16 11:05:37 2016 -0700

----------------------------------------------------------------------
 .../internal/cache/AbstractRegionEntry.java     |  22 +-
 .../gemfire/internal/cache/UpdateOperation.java |   2 +-
 .../tier/sockets/ClientUpdateMessageImpl.java   |   2 +-
 .../cache/wan/GatewaySenderEventImpl.java       |  10 -
 .../gemfire/internal/offheap/Fragment.java      |   2 +-
 .../internal/offheap/FreeListManager.java       |   8 +-
 .../internal/offheap/LifecycleListener.java     |  20 +-
 .../internal/offheap/MemoryAllocatorImpl.java   | 507 ++++++++++++++++
 .../internal/offheap/MemoryBlockNode.java       |   4 +-
 .../internal/offheap/OffHeapStorage.java        |   2 +-
 .../internal/offheap/OffHeapStoredObject.java   |  26 +-
 .../OffHeapStoredObjectAddressStack.java        |   4 +-
 .../internal/offheap/RefCountChangeInfo.java    |   2 +-
 .../internal/offheap/ReferenceCountHelper.java  |   4 +-
 .../offheap/SimpleMemoryAllocatorImpl.java      | 507 ----------------
 .../gemfire/cache30/MultiVMRegionTestCase.java  |  22 +-
 .../cache/ClientServerGetAllDUnitTest.java      |   4 +-
 .../gemfire/internal/cache/OffHeapTestUtil.java |   6 +-
 .../cache/OffHeapValueWrapperJUnitTest.java     |   8 +-
 .../cache/OldValueImporterTestBase.java         |  26 +-
 .../internal/offheap/FreeListManagerTest.java   |   6 +-
 .../offheap/LifecycleListenerJUnitTest.java     |  36 +-
 ...moryAllocatorFillPatternIntegrationTest.java | 246 ++++++++
 .../MemoryAllocatorFillPatternJUnitTest.java    | 183 ++++++
 .../offheap/MemoryAllocatorJUnitTest.java       | 594 +++++++++++++++++++
 .../offheap/MemoryBlockNodeJUnitTest.java       |   6 +-
 .../offheap/OffHeapHelperJUnitTest.java         |   4 +-
 .../internal/offheap/OffHeapIndexJUnitTest.java |   2 +-
 .../internal/offheap/OffHeapRegionBase.java     |   4 +-
 .../OffHeapRegionEntryHelperJUnitTest.java      |   4 +-
 .../offheap/OffHeapStorageJUnitTest.java        |   6 +-
 ...ffHeapStoredObjectAddressStackJUnitTest.java |  40 +-
 .../offheap/OffHeapStoredObjectJUnitTest.java   |   4 +-
 .../offheap/OffHeapValidationJUnitTest.java     |   2 +-
 .../OffHeapWriteObjectAsByteArrayJUnitTest.java |   8 +-
 .../offheap/OutOfOffHeapMemoryDUnitTest.java    |   2 +-
 ...moryAllocatorFillPatternIntegrationTest.java | 246 --------
 ...mpleMemoryAllocatorFillPatternJUnitTest.java | 183 ------
 .../offheap/SimpleMemoryAllocatorJUnitTest.java | 594 -------------------
 .../offheap/TinyMemoryBlockJUnitTest.java       |   8 +-
 .../TxReleasesOffHeapOnCloseJUnitTest.java      |   2 +-
 .../OffHeapByteBufferByteSourceJUnitTest.java   |   4 +-
 .../gemfire/pdx/OffHeapByteSourceJUnitTest.java |   8 +-
 43 files changed, 1676 insertions(+), 1704 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/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 a103e96..90d36d1 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
@@ -64,7 +64,7 @@ import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
 import com.gemstone.gemfire.internal.offheap.MemoryAllocator;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
@@ -1084,24 +1084,6 @@ public abstract class AbstractRegionEntry implements RegionEntry,
       }
       return basicEquals(deserializedObj, cd.getDeserializedForReading());
       }
-//      boolean result = Arrays.equals((byte[])cdVal, serializedObj);
-//      if (!result) {
-//        try {
-//          Object o1 = BlobHelper.deserializeBlob((byte[])cdVal);
-//          Object o2 = BlobHelper.deserializeBlob(serializedObj);
-//          SimpleMemoryAllocatorImpl.debugLog("checkCDEquals o1=<" + o1 + "> o2=<" + o2 + ">", false);
-//          if (o1.equals(o2)) {
-//            SimpleMemoryAllocatorImpl.debugLog("they are equal! a1=<" + Arrays.toString((byte[])cdVal) + "> a2=<" + Arrays.toString(serializedObj) + ">", false);
-//          }
-//        } catch (IOException e) {
-//          // TODO Auto-generated catch block
-//          e.printStackTrace();
-//        } catch (ClassNotFoundException e) {
-//          // TODO Auto-generated catch block
-//          e.printStackTrace();
-//        }
-//      }
-//      return result;
     } else {
       // prefer object form
       if (obj instanceof CachedDeserializable) {
@@ -1337,7 +1319,7 @@ public abstract class AbstractRegionEntry implements RegionEntry,
         byte[] compressedData = compressBytes(r, data);
         boolean isCompressed = compressedData != data;
         ReferenceCountHelper.setReferenceCountOwner(this);
-        MemoryAllocator ma = SimpleMemoryAllocatorImpl.getAllocator(); // fix for bug 47875
+        MemoryAllocator ma = MemoryAllocatorImpl.getAllocator(); // fix for bug 47875
         val = ma.allocateAndInitialize(compressedData, isSerialized, isCompressed, data);
         ReferenceCountHelper.setReferenceCountOwner(null);
       }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/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 d26f50c..acdec28 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
@@ -43,7 +43,7 @@ import com.gemstone.gemfire.internal.cache.EntryEventImpl.SerializedCacheValueIm
 import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.internal.util.BlobHelper;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientUpdateMessageImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientUpdateMessageImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientUpdateMessageImpl.java
index 97d9a3d..6d1508f 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientUpdateMessageImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ClientUpdateMessageImpl.java
@@ -56,7 +56,7 @@ import com.gemstone.gemfire.internal.cache.lru.Sizeable;
 import com.gemstone.gemfire.internal.cache.tier.MessageType;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 
 /**
  * Class <code>ClientUpdateMessageImpl</code> is a message representing a cache

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
index b64a654..d8922f8 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
@@ -571,16 +571,6 @@ public class GatewaySenderEventImpl implements
   }
 
   /**
-   * This method is meant for internal use by the SimpleMemoryAllocatorImpl.
-   * Others should use getRawValue instead.
-   * @return if the result is an off-heap reference then callers must use it before this event is released.
-   */
-  @Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE)
-  public Object getValueObject() {
-    return this.valueObj;
-  }
-
-  /**
    * Return this event's deserialized value
    * 
    * @return this event's deserialized value

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
index d36a71c..0ea6cf8 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
@@ -38,7 +38,7 @@ public class Fragment implements MemoryBlock {
   private static AtomicIntegerFieldUpdater<Fragment> freeIdxUpdater = AtomicIntegerFieldUpdater.newUpdater(Fragment.class, "freeIdx");
   
   public Fragment(long addr, int size) {
-    SimpleMemoryAllocatorImpl.validateAddress(addr);
+    MemoryAllocatorImpl.validateAddress(addr);
     this.baseAddr = addr;
     this.size = size;
     freeIdxUpdater.set(this, 0);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
index 05010ab..c943a7e 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
@@ -35,7 +35,7 @@ import com.gemstone.gemfire.OutOfOffHeapMemoryException;
 import com.gemstone.gemfire.internal.logging.LogService;
 
 /**
- * Manages the free lists for a SimpleMemoryAllocatorImpl
+ * Manages the free lists and slabs for a MemoryAllocator
  */
 public class FreeListManager {
   static final Logger logger = LogService.getLogger();
@@ -127,9 +127,9 @@ public class FreeListManager {
    */
   private final AtomicInteger lastFragmentAllocation = new AtomicInteger(0);
   private final CopyOnWriteArrayList<Fragment> fragmentList;
-  private final SimpleMemoryAllocatorImpl ma;
+  private final MemoryAllocatorImpl ma;
 
-  public FreeListManager(SimpleMemoryAllocatorImpl ma, final Slab[] slabs) {
+  public FreeListManager(MemoryAllocatorImpl ma, final Slab[] slabs) {
     this.ma = ma;
     this.slabs = slabs;
     long total = 0;
@@ -762,7 +762,7 @@ public class FreeListManager {
   
   private List<MemoryBlock> getTinyFreeBlocks() {
     final List<MemoryBlock> value = new ArrayList<MemoryBlock>();
-    final SimpleMemoryAllocatorImpl sma = this.ma;
+    final MemoryAllocatorImpl sma = this.ma;
     for (int i = 0; i < this.tinyFreeLists.length(); i++) {
       if (this.tinyFreeLists.get(i) == null) continue;
       long addr = this.tinyFreeLists.get(i).getTopAddress();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/LifecycleListener.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/LifecycleListener.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/LifecycleListener.java
index 613b12a..4a80057 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/LifecycleListener.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/LifecycleListener.java
@@ -22,23 +22,23 @@ import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * Used by tests to get notifications about the lifecycle of a 
- * SimpleMemoryAllocatorImpl.
+ * MemoryAllocatorImpl.
  * 
  * @author Kirk Lund
  */
 public interface LifecycleListener {
 
   /**
-   * Callback is invoked after creating a new SimpleMemoryAllocatorImpl. 
+   * Callback is invoked after creating a new MemoryAllocatorImpl. 
    * 
    * Create occurs during the first initialization of an 
    * InternalDistributedSystem within the JVM.
    * 
    * @param allocator the instance that has just been created
    */
-  public void afterCreate(SimpleMemoryAllocatorImpl allocator);
+  public void afterCreate(MemoryAllocatorImpl allocator);
   /**
-   * Callback is invoked after reopening an existing SimpleMemoryAllocatorImpl 
+   * Callback is invoked after reopening an existing MemoryAllocatorImpl 
    * for reuse. 
    * 
    * Reuse occurs during any intialization of an 
@@ -47,30 +47,30 @@ public interface LifecycleListener {
    * 
    * @param allocator the instance that has just been reopened for reuse
    */
-  public void afterReuse(SimpleMemoryAllocatorImpl allocator);
+  public void afterReuse(MemoryAllocatorImpl allocator);
   /**
-   * Callback is invoked before closing the SimpleMemoryAllocatorImpl
+   * Callback is invoked before closing the MemoryAllocatorImpl
    * 
    * Close occurs after the InternalDistributedSystem and DistributionManager 
    * have completely disconnected. 
    * 
    * @param allocator the instance that is about to be closed
    */
-  public void beforeClose(SimpleMemoryAllocatorImpl allocator);
+  public void beforeClose(MemoryAllocatorImpl allocator);
   
-  static  void invokeBeforeClose(SimpleMemoryAllocatorImpl allocator) {
+  static  void invokeBeforeClose(MemoryAllocatorImpl allocator) {
     for (Iterator<LifecycleListener> iter = lifecycleListeners.iterator(); iter.hasNext();) {
       LifecycleListener listener = iter.next();
       listener.beforeClose(allocator);
     }
   }
-  static void invokeAfterReuse(SimpleMemoryAllocatorImpl allocator) {
+  static void invokeAfterReuse(MemoryAllocatorImpl allocator) {
     for (Iterator<LifecycleListener> iter = lifecycleListeners.iterator(); iter.hasNext();) {
       LifecycleListener listener = iter.next();
       listener.afterReuse(allocator);
     }
   }
-  static void invokeAfterCreate(SimpleMemoryAllocatorImpl allocator) {
+  static void invokeAfterCreate(MemoryAllocatorImpl allocator) {
     for (Iterator<LifecycleListener> iter = lifecycleListeners.iterator(); iter.hasNext();) {
       LifecycleListener listener = iter.next();
       listener.afterCreate(allocator);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorImpl.java
new file mode 100644
index 0000000..2050dd4
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocatorImpl.java
@@ -0,0 +1,507 @@
+/*
+ * 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.offheap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.logging.log4j.Logger;
+
+import com.gemstone.gemfire.cache.CacheClosedException;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionService;
+import com.gemstone.gemfire.internal.cache.BucketRegion;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.LocalRegion;
+import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.internal.cache.PartitionedRegionDataStore;
+import com.gemstone.gemfire.internal.cache.RegionEntry;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.offheap.annotations.OffHeapIdentifier;
+import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
+
+/**
+ * This allocator is somewhat like an Arena allocator.
+ * We start out with an array of multiple large chunks of memory.
+ * We also keep lists of any chunk that have been allocated and freed.
+ * An allocation will always try to find a chunk in a free list that is a close fit to the requested size.
+ * If no close fits exist then it allocates the next slice from the front of one the original large chunks.
+ * If we can not find enough free memory then all the existing free memory is compacted.
+ * If we still do not have enough to make the allocation an exception is thrown.
+ * 
+ * @author darrel
+ * @author Kirk Lund
+ * @since 9.0
+ */
+public class MemoryAllocatorImpl implements MemoryAllocator {
+
+  static final Logger logger = LogService.getLogger();
+  
+  public static final String FREE_OFF_HEAP_MEMORY_PROPERTY = "gemfire.free-off-heap-memory";
+  
+  private volatile OffHeapMemoryStats stats;
+  
+  private volatile OutOfOffHeapMemoryListener ooohml;
+  
+  OutOfOffHeapMemoryListener getOutOfOffHeapMemoryListener() {
+    return this.ooohml;
+  }
+
+  public final FreeListManager freeList;
+
+  private MemoryInspector memoryInspector;
+
+  private volatile MemoryUsageListener[] memoryUsageListeners = new MemoryUsageListener[0];
+  
+  private static MemoryAllocatorImpl singleton = null;
+  
+  public static MemoryAllocatorImpl getAllocator() {
+    MemoryAllocatorImpl result = singleton;
+    if (result == null) {
+      throw new CacheClosedException("Off Heap memory allocator does not exist.");
+    }
+    return result;
+  }
+
+  private static final boolean DO_EXPENSIVE_VALIDATION = Boolean.getBoolean("gemfire.OFF_HEAP_DO_EXPENSIVE_VALIDATION");
+  
+  public static MemoryAllocator create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, int slabCount, 
+      long offHeapMemorySize, long maxSlabSize) {
+    return create(ooohml, stats, slabCount, offHeapMemorySize, maxSlabSize, null,
+        new SlabFactory() {
+      @Override
+      public Slab create(int size) {
+        return new SlabImpl(size);
+      }
+    });
+  }
+
+  private static MemoryAllocatorImpl create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, int slabCount, 
+      long offHeapMemorySize, long maxSlabSize, Slab[] slabs, 
+      SlabFactory slabFactory) {
+    MemoryAllocatorImpl result = singleton;
+    boolean created = false;
+    try {
+    if (result != null) {
+      result.reuse(ooohml, stats, offHeapMemorySize, slabs);
+      logger.info("Reusing {}  bytes of off-heap memory. The maximum size of a single off-heap object is {}  bytes.", result.getTotalMemory(), result.freeList.getLargestSlabSize());
+      created = true;
+      LifecycleListener.invokeAfterReuse(result);
+    } else {
+      if (slabs == null) {
+        // allocate memory chunks
+        logger.info("Allocating {} bytes of off-heap memory. The maximum size of a single off-heap object is {} bytes.", offHeapMemorySize, maxSlabSize);
+        slabs = new SlabImpl[slabCount];
+        long uncreatedMemory = offHeapMemorySize;
+        for (int i=0; i < slabCount; i++) {
+          try {
+            if (uncreatedMemory >= maxSlabSize) {
+              slabs[i] = slabFactory.create((int) maxSlabSize);
+              uncreatedMemory -= maxSlabSize;
+            } else {
+              // the last slab can be smaller then maxSlabSize
+              slabs[i] = slabFactory.create((int) uncreatedMemory);
+            }
+          } catch (OutOfMemoryError err) {
+            if (i > 0) {
+              logger.error("Off-heap memory creation failed after successfully allocating {} bytes of off-heap memory.", (i*maxSlabSize));
+            }
+            for (int j=0; j < i; j++) {
+              if (slabs[j] != null) {
+                slabs[j].free();
+              }
+            }
+            throw err;
+          }
+        }
+      }
+
+      result = new MemoryAllocatorImpl(ooohml, stats, slabs);
+      singleton = result;
+      LifecycleListener.invokeAfterCreate(result);
+      created = true;
+    }
+    } finally {
+      if (!created) {
+        if (stats != null) {
+          stats.close();
+        }
+        if (ooohml != null) {
+          ooohml.close();
+        }
+      }
+    }
+    return result;
+  }
+  static MemoryAllocatorImpl createForUnitTest(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, int slabCount, 
+      long offHeapMemorySize, long maxSlabSize, SlabFactory memChunkFactory) {
+    return create(ooohml, stats, slabCount, offHeapMemorySize, maxSlabSize, null, 
+        memChunkFactory);
+  }
+  public static MemoryAllocatorImpl createForUnitTest(OutOfOffHeapMemoryListener oooml, OffHeapMemoryStats stats, Slab[] slabs) {
+    int slabCount = 0;
+    long offHeapMemorySize = 0;
+    long maxSlabSize = 0;
+    if (slabs != null) {
+      slabCount = slabs.length;
+      for (int i=0; i < slabCount; i++) {
+        int slabSize = slabs[i].getSize();
+        offHeapMemorySize += slabSize;
+        if (slabSize > maxSlabSize) {
+          maxSlabSize = slabSize;
+        }
+      }
+    }
+    return create(oooml, stats, slabCount, offHeapMemorySize, maxSlabSize, slabs, null);
+  }
+  
+  
+  private void reuse(OutOfOffHeapMemoryListener oooml, OffHeapMemoryStats newStats, long offHeapMemorySize, Slab[] slabs) {
+    if (isClosed()) {
+      throw new IllegalStateException("Can not reuse a closed off-heap memory manager.");
+    }
+    if (oooml == null) {
+      throw new IllegalArgumentException("OutOfOffHeapMemoryListener is null");
+    }
+    if (getTotalMemory() != offHeapMemorySize) {
+      logger.warn("Using {} bytes of existing off-heap memory instead of the requested {}.", getTotalMemory(), offHeapMemorySize);
+    }
+    if (!this.freeList.okToReuse(slabs)) {
+      throw new IllegalStateException("attempted to reuse existing off-heap memory even though new off-heap memory was allocated");
+    }
+    this.ooohml = oooml;
+    newStats.initialize(this.stats);
+    this.stats = newStats;
+  }
+
+  private MemoryAllocatorImpl(final OutOfOffHeapMemoryListener oooml, final OffHeapMemoryStats stats, final Slab[] slabs) {
+    if (oooml == null) {
+      throw new IllegalArgumentException("OutOfOffHeapMemoryListener is null");
+    }
+    
+    this.ooohml = oooml;
+    this.stats = stats;
+
+    this.stats.setFragments(slabs.length);
+    this.stats.setLargestFragment(slabs[0].getSize());
+    
+    this.freeList = new FreeListManager(this, slabs);
+    this.memoryInspector = new MemoryInspectorImpl(this.freeList);
+
+    this.stats.incMaxMemory(this.freeList.getTotalMemory());
+    this.stats.incFreeMemory(this.freeList.getTotalMemory());
+  }
+  
+  public List<OffHeapStoredObject> getLostChunks() {
+    List<OffHeapStoredObject> liveChunks = this.freeList.getLiveChunks();
+    List<OffHeapStoredObject> regionChunks = getRegionLiveChunks();
+    Set<OffHeapStoredObject> liveChunksSet = new HashSet<>(liveChunks);
+    Set<OffHeapStoredObject> regionChunksSet = new HashSet<>(regionChunks);
+    liveChunksSet.removeAll(regionChunksSet);
+    return new ArrayList<OffHeapStoredObject>(liveChunksSet);
+  }
+  
+  /**
+   * Returns a possibly empty list that contains all the Chunks used by regions.
+   */
+  private List<OffHeapStoredObject> getRegionLiveChunks() {
+    ArrayList<OffHeapStoredObject> result = new ArrayList<OffHeapStoredObject>();
+    RegionService gfc = GemFireCacheImpl.getInstance();
+    if (gfc != null) {
+      Iterator<Region<?,?>> rootIt = gfc.rootRegions().iterator();
+      while (rootIt.hasNext()) {
+        Region<?,?> rr = rootIt.next();
+        getRegionLiveChunks(rr, result);
+        Iterator<Region<?,?>> srIt = rr.subregions(true).iterator();
+        while (srIt.hasNext()) {
+          getRegionLiveChunks(srIt.next(), result);
+        }
+      }
+    }
+    return result;
+  }
+
+  private void getRegionLiveChunks(Region<?,?> r, List<OffHeapStoredObject> result) {
+    if (r.getAttributes().getOffHeap()) {
+
+      if (r instanceof PartitionedRegion) {
+        PartitionedRegionDataStore prs = ((PartitionedRegion) r).getDataStore();
+        if (prs != null) {
+          Set<BucketRegion> brs = prs.getAllLocalBucketRegions();
+          if (brs != null) {
+            for (BucketRegion br : brs) {
+              if (br != null && !br.isDestroyed()) {
+                this.basicGetRegionLiveChunks(br, result);
+              }
+
+            }
+          }
+        }
+      } else {
+        this.basicGetRegionLiveChunks((LocalRegion) r, result);
+      }
+
+    }
+
+  }
+  
+  private void basicGetRegionLiveChunks(LocalRegion r, List<OffHeapStoredObject> result) {
+    for (Object key : r.keySet()) {
+      RegionEntry re = ((LocalRegion) r).getRegionEntry(key);
+      if (re != null) {
+        /**
+         * value could be GATEWAY_SENDER_EVENT_IMPL_VALUE or region entry value.
+         */
+        @Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE)
+        Object value = re._getValue();
+        if (value instanceof OffHeapStoredObject) {
+          result.add((OffHeapStoredObject) value);
+        }
+      }
+    }
+  }
+
+  private OffHeapStoredObject allocateOffHeapStoredObject(int size) {
+    OffHeapStoredObject result = this.freeList.allocate(size);
+    int resultSize = result.getSize();
+    stats.incObjects(1);
+    stats.incUsedMemory(resultSize);
+    stats.incFreeMemory(-resultSize);
+    notifyListeners();
+    if (ReferenceCountHelper.trackReferenceCounts()) {
+      ReferenceCountHelper.refCountChanged(result.getAddress(), false, 1);
+    }
+    return result;
+  }
+  
+  @Override
+  public StoredObject allocate(int size) {
+    //System.out.println("allocating " + size);
+    OffHeapStoredObject result = allocateOffHeapStoredObject(size);
+    //("allocated off heap object of size " + size + " @" + Long.toHexString(result.getMemoryAddress()), true);
+    return result;
+  }
+  
+  public static void debugLog(String msg, boolean logStack) {
+    if (logStack) {
+      logger.info(msg, new RuntimeException(msg));
+    } else {
+      logger.info(msg);
+    }
+  }
+  
+  @Override
+  public StoredObject allocateAndInitialize(byte[] v, boolean isSerialized, boolean isCompressed) {
+    return allocateAndInitialize(v, isSerialized, isCompressed, null);
+  }
+  @Override
+  public StoredObject allocateAndInitialize(byte[] v, boolean isSerialized, boolean isCompressed, byte[] originalHeapData) {
+    long addr = OffHeapRegionEntryHelper.encodeDataAsAddress(v, isSerialized, isCompressed);
+    if (addr != 0L) {
+      return new TinyStoredObject(addr);
+    }
+    OffHeapStoredObject result = allocateOffHeapStoredObject(v.length);
+    //debugLog("allocated off heap object of size " + v.length + " @" + Long.toHexString(result.getMemoryAddress()), true);
+    //debugLog("allocated off heap object of size " + v.length + " @" + Long.toHexString(result.getMemoryAddress()) +  "chunkSize=" + result.getSize() + " isSerialized=" + isSerialized + " v=" + Arrays.toString(v), true);
+    result.setSerializedValue(v);
+    result.setSerialized(isSerialized);
+    result.setCompressed(isCompressed);
+    if (originalHeapData != null) {
+      result = new OffHeapStoredObjectWithHeapForm(result, originalHeapData);
+    }
+    return result;
+  }
+  
+  @Override
+  public long getFreeMemory() {
+    return this.freeList.getFreeMemory();
+  }
+
+  @Override
+  public long getUsedMemory() {
+    return this.freeList.getUsedMemory();
+  }
+
+  @Override
+  public long getTotalMemory() {
+    return this.freeList.getTotalMemory();
+  }
+  
+  @Override
+  public void close() {
+    try {
+      LifecycleListener.invokeBeforeClose(this);
+    } finally {
+      this.ooohml.close();
+      if (Boolean.getBoolean(FREE_OFF_HEAP_MEMORY_PROPERTY)) {
+        realClose();
+      }
+    }
+  }
+  
+  public static void freeOffHeapMemory() {
+    MemoryAllocatorImpl ma = singleton;
+    if (ma != null) {
+      ma.realClose();
+    }
+  }
+  
+  private void realClose() {
+    // Removing this memory immediately can lead to a SEGV. See 47885.
+    if (setClosed()) {
+      this.freeList.freeSlabs();
+      this.stats.close();
+      singleton = null;
+    }
+  }
+  
+  private final AtomicBoolean closed = new AtomicBoolean();
+  private boolean isClosed() {
+    return this.closed.get();
+  }
+  /**
+   * Returns true if caller is the one who should close; false if some other thread
+   * is already closing.
+   */
+  private boolean setClosed() {
+    return this.closed.compareAndSet(false, true);
+  }
+  
+
+  FreeListManager getFreeListManager() {
+    return this.freeList;
+  }
+  
+  /**
+   * Return the slabId of the slab that contains the given addr.
+   */
+  int findSlab(long addr) {
+    return this.freeList.findSlab(addr);
+  }
+  
+  public OffHeapMemoryStats getStats() {
+    return this.stats;
+  }
+  
+  @Override
+  public void addMemoryUsageListener(final MemoryUsageListener listener) {
+    synchronized (this.memoryUsageListeners) {
+      final MemoryUsageListener[] newMemoryUsageListeners = Arrays.copyOf(this.memoryUsageListeners, this.memoryUsageListeners.length + 1);
+      newMemoryUsageListeners[this.memoryUsageListeners.length] = listener;
+      this.memoryUsageListeners = newMemoryUsageListeners;
+    }
+  }
+  
+  @Override
+  public void removeMemoryUsageListener(final MemoryUsageListener listener) {
+    synchronized (this.memoryUsageListeners) {
+      int listenerIndex = -1;
+      for (int i = 0; i < this.memoryUsageListeners.length; i++) {
+        if (this.memoryUsageListeners[i] == listener) {
+          listenerIndex = i;
+          break;
+        }
+      }
+
+      if (listenerIndex != -1) {
+        final MemoryUsageListener[] newMemoryUsageListeners = new MemoryUsageListener[this.memoryUsageListeners.length - 1];
+        System.arraycopy(this.memoryUsageListeners, 0, newMemoryUsageListeners, 0, listenerIndex);
+        System.arraycopy(this.memoryUsageListeners, listenerIndex + 1, newMemoryUsageListeners, listenerIndex,
+            this.memoryUsageListeners.length - listenerIndex - 1);
+        this.memoryUsageListeners = newMemoryUsageListeners;
+      }
+    }
+  }
+  
+  void notifyListeners() {
+    final MemoryUsageListener[] savedListeners = this.memoryUsageListeners;
+    
+    if (savedListeners.length == 0) {
+      return;
+    }
+
+    final long bytesUsed = getUsedMemory();
+    for (int i = 0; i < savedListeners.length; i++) {
+      savedListeners[i].updateMemoryUsed(bytesUsed);
+    }
+  }
+  
+  static void validateAddress(long addr) {
+    validateAddressAndSize(addr, -1);
+  }
+  
+  static void validateAddressAndSize(long addr, int size) {
+    // if the caller does not have a "size" to provide then use -1
+    if ((addr & 7) != 0) {
+      StringBuilder sb = new StringBuilder();
+      sb.append("address was not 8 byte aligned: 0x").append(Long.toString(addr, 16));
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.singleton;
+      if (ma != null) {
+        sb.append(". Valid addresses must be in one of the following ranges: ");
+        ma.freeList.getSlabDescriptions(sb);
+     }
+      throw new IllegalStateException(sb.toString());
+    }
+    if (addr >= 0 && addr < 1024) {
+      throw new IllegalStateException("addr was smaller than expected 0x" + addr);
+    }
+    validateAddressAndSizeWithinSlab(addr, size, DO_EXPENSIVE_VALIDATION);
+  }
+
+  static void validateAddressAndSizeWithinSlab(long addr, int size, boolean doExpensiveValidation) {
+    if (doExpensiveValidation) {
+      MemoryAllocatorImpl ma = MemoryAllocatorImpl.singleton;
+      if (ma != null) {
+        if (!ma.freeList.validateAddressAndSizeWithinSlab(addr, size)) {
+          throw new IllegalStateException(" address 0x" + Long.toString(addr, 16) + " does not address the original slab memory");
+        }
+      }
+    }
+  }
+
+  public synchronized List<MemoryBlock> getOrphans() {
+    List<OffHeapStoredObject> liveChunks = this.freeList.getLiveChunks();
+    List<OffHeapStoredObject> regionChunks = getRegionLiveChunks();
+    liveChunks.removeAll(regionChunks);
+    List<MemoryBlock> orphans = new ArrayList<MemoryBlock>();
+    for (OffHeapStoredObject chunk: liveChunks) {
+      orphans.add(new MemoryBlockNode(this, chunk));
+    }
+    Collections.sort(orphans,
+        new Comparator<MemoryBlock>() {
+          @Override
+          public int compare(MemoryBlock o1, MemoryBlock o2) {
+            return Long.valueOf(o1.getAddress()).compareTo(o2.getAddress());
+          }
+        });
+    //this.memoryBlocks = new WeakReference<List<MemoryBlock>>(orphans);
+    return orphans;
+  }
+
+  @Override
+  public MemoryInspector getMemoryInspector() {
+    return this.memoryInspector;
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
index 6e2414f..a72d618 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
@@ -26,9 +26,9 @@ import com.gemstone.gemfire.cache.CacheClosedException;
  * Basic implementation of MemoryBlock for test validation only.
  */
 public class MemoryBlockNode implements MemoryBlock {
-  private final SimpleMemoryAllocatorImpl ma;
+  private final MemoryAllocatorImpl ma;
   private final MemoryBlock block;
-  MemoryBlockNode(SimpleMemoryAllocatorImpl ma, MemoryBlock block) {
+  MemoryBlockNode(MemoryAllocatorImpl ma, MemoryBlock block) {
     this.ma = ma;
     this.block = block;
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
index 9c6c75a..2bdcfba 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
@@ -199,7 +199,7 @@ public class OffHeapStorage implements OffHeapMemoryStats {
 
     final int slabCount = calcSlabCount(maxSlabSize, offHeapMemorySize);
 
-    return SimpleMemoryAllocatorImpl.create(ooohml, stats, slabCount, offHeapMemorySize, maxSlabSize);
+    return MemoryAllocatorImpl.create(ooohml, stats, slabCount, offHeapMemorySize, maxSlabSize);
   }
   
   private static final long MAX_SLAB_SIZE = Integer.MAX_VALUE;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObject.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObject.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObject.java
index 68c9bdd..9861a54 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObject.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObject.java
@@ -96,7 +96,7 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
     final static byte FILL_BYTE = 0x3c;
     
     protected OffHeapStoredObject(long memoryAddress, int chunkSize) {
-      SimpleMemoryAllocatorImpl.validateAddressAndSize(memoryAddress, chunkSize);
+      MemoryAllocatorImpl.validateAddressAndSize(memoryAddress, chunkSize);
       this.memoryAddress = memoryAddress;
       setSize(chunkSize);
       AddressableMemoryManager.writeIntVolatile(getAddress()+REF_COUNT_OFFSET, MAGIC_NUMBER);
@@ -121,7 +121,7 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
      * memoryAddress. The off heap header has already been initialized.
      */
     protected OffHeapStoredObject(long memoryAddress) {
-      SimpleMemoryAllocatorImpl.validateAddress(memoryAddress);
+      MemoryAllocatorImpl.validateAddress(memoryAddress);
       this.memoryAddress = memoryAddress;
     }
     
@@ -168,8 +168,8 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
       // TODO OFFHEAP: no need to copy to heap. Just get the address of each and compare each byte. No need to call incReads when reading from address.
       int i;
       // inc it twice since we are reading two different objects
-      SimpleMemoryAllocatorImpl.getAllocator().getStats().incReads();
-      SimpleMemoryAllocatorImpl.getAllocator().getStats().incReads();
+      MemoryAllocatorImpl.getAllocator().getStats().incReads();
+      MemoryAllocatorImpl.getAllocator().getStats().incReads();
       for (i=0; i < mySize-(dataCache1.length-1); i+=dataCache1.length) {
         this.readDataBytes(i, dataCache1);
         other.readDataBytes(i, dataCache2);
@@ -206,7 +206,7 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
       final byte[] dataCache = new byte[1024];
       int idx=0;
       int i;
-      SimpleMemoryAllocatorImpl.getAllocator().getStats().incReads();
+      MemoryAllocatorImpl.getAllocator().getStats().incReads();
       for (i=0; i < mySize-(dataCache.length-1); i+=dataCache.length) {
         this.readDataBytes(i, dataCache);
         for (int j=0; j < dataCache.length; j++) {
@@ -416,7 +416,7 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
       byte[] result = new byte[getDataSize()];
       readDataBytes(0, result);
       //debugLog("reading", true);
-      SimpleMemoryAllocatorImpl.getAllocator().getStats().incReads();
+      MemoryAllocatorImpl.getAllocator().getStats().incReads();
       return result;
     }
     protected byte[] getRawBytes() {
@@ -487,19 +487,19 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
     }
 
     public static int getSize(long memAddr) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      MemoryAllocatorImpl.validateAddress(memAddr);
       return AddressableMemoryManager.readInt(memAddr+CHUNK_SIZE_OFFSET);
     }
     public static void setSize(long memAddr, int size) {
-      SimpleMemoryAllocatorImpl.validateAddressAndSize(memAddr, size);
+      MemoryAllocatorImpl.validateAddressAndSize(memAddr, size);
       AddressableMemoryManager.writeInt(memAddr+CHUNK_SIZE_OFFSET, size);
     }
     public static long getNext(long memAddr) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      MemoryAllocatorImpl.validateAddress(memAddr);
       return AddressableMemoryManager.readLong(memAddr+HEADER_SIZE);
     }
     public static void setNext(long memAddr, long next) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      MemoryAllocatorImpl.validateAddress(memAddr);
       AddressableMemoryManager.writeLong(memAddr+HEADER_SIZE, next);
     }
     
@@ -595,7 +595,7 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
     }
 
     public static boolean retain(long memAddr) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      MemoryAllocatorImpl.validateAddress(memAddr);
       int uc;
       int rawBits;
       int retryCount = 0;
@@ -628,7 +628,7 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
       release(memAddr, null);
     }
     static void release(final long memAddr, FreeListManager freeListManager) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      MemoryAllocatorImpl.validateAddress(memAddr);
       int newCount;
       int rawBits;
       boolean returnToAllocator;
@@ -661,7 +661,7 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
           ReferenceCountHelper.freeRefCountInfo(memAddr);
         }
         if (freeListManager == null) {
-          freeListManager = SimpleMemoryAllocatorImpl.getAllocator().getFreeListManager();
+          freeListManager = MemoryAllocatorImpl.getAllocator().getFreeListManager();
         }
         freeListManager.free(memAddr);
       } else {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStack.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStack.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStack.java
index 40d0143..b69d3a6 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStack.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStack.java
@@ -29,7 +29,7 @@ public class OffHeapStoredObjectAddressStack {
   private volatile long topAddr;
   
   public OffHeapStoredObjectAddressStack(long addr) {
-    if (addr != 0L) SimpleMemoryAllocatorImpl.validateAddress(addr);
+    if (addr != 0L) MemoryAllocatorImpl.validateAddress(addr);
     this.topAddr = addr;
   }
   public OffHeapStoredObjectAddressStack() {
@@ -40,7 +40,7 @@ public class OffHeapStoredObjectAddressStack {
   }
   public void offer(long e) {
     assert e != 0;
-    SimpleMemoryAllocatorImpl.validateAddress(e);
+    MemoryAllocatorImpl.validateAddress(e);
     synchronized (this) {
       OffHeapStoredObject.setNext(e, this.topAddr);
       this.topAddr = e;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/RefCountChangeInfo.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/RefCountChangeInfo.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/RefCountChangeInfo.java
index e3b4b1f..cc67a58 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/RefCountChangeInfo.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/RefCountChangeInfo.java
@@ -23,7 +23,7 @@ import com.gemstone.gemfire.internal.shared.StringPrintWriter;
 
 @SuppressWarnings("serial")
 /**
- * Used by SimpleMemoryAllocatorImpl to debug off-heap memory leaks.
+ * Used by MemoryAllocatorImpl to debug off-heap memory leaks.
  */
 public class RefCountChangeInfo extends Throwable {
   private final String threadName;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/ReferenceCountHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/ReferenceCountHelper.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/ReferenceCountHelper.java
index 778b329..f6696b0 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/ReferenceCountHelper.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/ReferenceCountHelper.java
@@ -214,7 +214,7 @@ public class ReferenceCountHelper {
       }
     }
     if (list == LOCKED) {
-      SimpleMemoryAllocatorImpl.debugLog("refCount " + (decRefCount ? "deced" : "inced") + " after orphan detected for @" + Long.toHexString(address), true);
+      MemoryAllocatorImpl.debugLog("refCount " + (decRefCount ? "deced" : "inced") + " after orphan detected for @" + Long.toHexString(address), true);
       return;
     }
     RefCountChangeInfo info = new RefCountChangeInfo(decRefCount, rc, owner);
@@ -242,7 +242,7 @@ public class ReferenceCountHelper {
     if (!trackReferenceCounts()) return;
     List<RefCountChangeInfo> freedInfo = stacktraces.remove(address);
     if (freedInfo == LOCKED) {
-      SimpleMemoryAllocatorImpl.debugLog("freed after orphan detected for @" + Long.toHexString(address), true);
+      MemoryAllocatorImpl.debugLog("freed after orphan detected for @" + Long.toHexString(address), true);
     } else if (trackFreedReferenceCounts()) {
       if (freedInfo != null) {
         freedStacktraces.put(address, freedInfo);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
deleted file mode 100644
index f7fa888..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.offheap;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.logging.log4j.Logger;
-
-import com.gemstone.gemfire.cache.CacheClosedException;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.RegionService;
-import com.gemstone.gemfire.internal.cache.BucketRegion;
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.internal.cache.LocalRegion;
-import com.gemstone.gemfire.internal.cache.PartitionedRegion;
-import com.gemstone.gemfire.internal.cache.PartitionedRegionDataStore;
-import com.gemstone.gemfire.internal.cache.RegionEntry;
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.offheap.annotations.OffHeapIdentifier;
-import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
-
-/**
- * This allocator is somewhat like an Arena allocator.
- * We start out with an array of multiple large chunks of memory.
- * We also keep lists of any chunk that have been allocated and freed.
- * An allocation will always try to find a chunk in a free list that is a close fit to the requested size.
- * If no close fits exist then it allocates the next slice from the front of one the original large chunks.
- * If we can not find enough free memory then all the existing free memory is compacted.
- * If we still do not have enough to make the allocation an exception is thrown.
- * 
- * @author darrel
- * @author Kirk Lund
- * @since 9.0
- */
-public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
-
-  static final Logger logger = LogService.getLogger();
-  
-  public static final String FREE_OFF_HEAP_MEMORY_PROPERTY = "gemfire.free-off-heap-memory";
-  
-  private volatile OffHeapMemoryStats stats;
-  
-  private volatile OutOfOffHeapMemoryListener ooohml;
-  
-  OutOfOffHeapMemoryListener getOutOfOffHeapMemoryListener() {
-    return this.ooohml;
-  }
-
-  public final FreeListManager freeList;
-
-  private MemoryInspector memoryInspector;
-
-  private volatile MemoryUsageListener[] memoryUsageListeners = new MemoryUsageListener[0];
-  
-  private static SimpleMemoryAllocatorImpl singleton = null;
-  
-  public static SimpleMemoryAllocatorImpl getAllocator() {
-    SimpleMemoryAllocatorImpl result = singleton;
-    if (result == null) {
-      throw new CacheClosedException("Off Heap memory allocator does not exist.");
-    }
-    return result;
-  }
-
-  private static final boolean DO_EXPENSIVE_VALIDATION = Boolean.getBoolean("gemfire.OFF_HEAP_DO_EXPENSIVE_VALIDATION");
-  
-  public static MemoryAllocator create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, int slabCount, 
-      long offHeapMemorySize, long maxSlabSize) {
-    return create(ooohml, stats, slabCount, offHeapMemorySize, maxSlabSize, null,
-        new SlabFactory() {
-      @Override
-      public Slab create(int size) {
-        return new SlabImpl(size);
-      }
-    });
-  }
-
-  private static SimpleMemoryAllocatorImpl create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, int slabCount, 
-      long offHeapMemorySize, long maxSlabSize, Slab[] slabs, 
-      SlabFactory slabFactory) {
-    SimpleMemoryAllocatorImpl result = singleton;
-    boolean created = false;
-    try {
-    if (result != null) {
-      result.reuse(ooohml, stats, offHeapMemorySize, slabs);
-      logger.info("Reusing {}  bytes of off-heap memory. The maximum size of a single off-heap object is {}  bytes.", result.getTotalMemory(), result.freeList.getLargestSlabSize());
-      created = true;
-      LifecycleListener.invokeAfterReuse(result);
-    } else {
-      if (slabs == null) {
-        // allocate memory chunks
-        logger.info("Allocating {} bytes of off-heap memory. The maximum size of a single off-heap object is {} bytes.", offHeapMemorySize, maxSlabSize);
-        slabs = new SlabImpl[slabCount];
-        long uncreatedMemory = offHeapMemorySize;
-        for (int i=0; i < slabCount; i++) {
-          try {
-            if (uncreatedMemory >= maxSlabSize) {
-              slabs[i] = slabFactory.create((int) maxSlabSize);
-              uncreatedMemory -= maxSlabSize;
-            } else {
-              // the last slab can be smaller then maxSlabSize
-              slabs[i] = slabFactory.create((int) uncreatedMemory);
-            }
-          } catch (OutOfMemoryError err) {
-            if (i > 0) {
-              logger.error("Off-heap memory creation failed after successfully allocating {} bytes of off-heap memory.", (i*maxSlabSize));
-            }
-            for (int j=0; j < i; j++) {
-              if (slabs[j] != null) {
-                slabs[j].free();
-              }
-            }
-            throw err;
-          }
-        }
-      }
-
-      result = new SimpleMemoryAllocatorImpl(ooohml, stats, slabs);
-      singleton = result;
-      LifecycleListener.invokeAfterCreate(result);
-      created = true;
-    }
-    } finally {
-      if (!created) {
-        if (stats != null) {
-          stats.close();
-        }
-        if (ooohml != null) {
-          ooohml.close();
-        }
-      }
-    }
-    return result;
-  }
-  static SimpleMemoryAllocatorImpl createForUnitTest(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, int slabCount, 
-      long offHeapMemorySize, long maxSlabSize, SlabFactory memChunkFactory) {
-    return create(ooohml, stats, slabCount, offHeapMemorySize, maxSlabSize, null, 
-        memChunkFactory);
-  }
-  public static SimpleMemoryAllocatorImpl createForUnitTest(OutOfOffHeapMemoryListener oooml, OffHeapMemoryStats stats, Slab[] slabs) {
-    int slabCount = 0;
-    long offHeapMemorySize = 0;
-    long maxSlabSize = 0;
-    if (slabs != null) {
-      slabCount = slabs.length;
-      for (int i=0; i < slabCount; i++) {
-        int slabSize = slabs[i].getSize();
-        offHeapMemorySize += slabSize;
-        if (slabSize > maxSlabSize) {
-          maxSlabSize = slabSize;
-        }
-      }
-    }
-    return create(oooml, stats, slabCount, offHeapMemorySize, maxSlabSize, slabs, null);
-  }
-  
-  
-  private void reuse(OutOfOffHeapMemoryListener oooml, OffHeapMemoryStats newStats, long offHeapMemorySize, Slab[] slabs) {
-    if (isClosed()) {
-      throw new IllegalStateException("Can not reuse a closed off-heap memory manager.");
-    }
-    if (oooml == null) {
-      throw new IllegalArgumentException("OutOfOffHeapMemoryListener is null");
-    }
-    if (getTotalMemory() != offHeapMemorySize) {
-      logger.warn("Using {} bytes of existing off-heap memory instead of the requested {}.", getTotalMemory(), offHeapMemorySize);
-    }
-    if (!this.freeList.okToReuse(slabs)) {
-      throw new IllegalStateException("attempted to reuse existing off-heap memory even though new off-heap memory was allocated");
-    }
-    this.ooohml = oooml;
-    newStats.initialize(this.stats);
-    this.stats = newStats;
-  }
-
-  private SimpleMemoryAllocatorImpl(final OutOfOffHeapMemoryListener oooml, final OffHeapMemoryStats stats, final Slab[] slabs) {
-    if (oooml == null) {
-      throw new IllegalArgumentException("OutOfOffHeapMemoryListener is null");
-    }
-    
-    this.ooohml = oooml;
-    this.stats = stats;
-
-    this.stats.setFragments(slabs.length);
-    this.stats.setLargestFragment(slabs[0].getSize());
-    
-    this.freeList = new FreeListManager(this, slabs);
-    this.memoryInspector = new MemoryInspectorImpl(this.freeList);
-
-    this.stats.incMaxMemory(this.freeList.getTotalMemory());
-    this.stats.incFreeMemory(this.freeList.getTotalMemory());
-  }
-  
-  public List<OffHeapStoredObject> getLostChunks() {
-    List<OffHeapStoredObject> liveChunks = this.freeList.getLiveChunks();
-    List<OffHeapStoredObject> regionChunks = getRegionLiveChunks();
-    Set<OffHeapStoredObject> liveChunksSet = new HashSet<>(liveChunks);
-    Set<OffHeapStoredObject> regionChunksSet = new HashSet<>(regionChunks);
-    liveChunksSet.removeAll(regionChunksSet);
-    return new ArrayList<OffHeapStoredObject>(liveChunksSet);
-  }
-  
-  /**
-   * Returns a possibly empty list that contains all the Chunks used by regions.
-   */
-  private List<OffHeapStoredObject> getRegionLiveChunks() {
-    ArrayList<OffHeapStoredObject> result = new ArrayList<OffHeapStoredObject>();
-    RegionService gfc = GemFireCacheImpl.getInstance();
-    if (gfc != null) {
-      Iterator<Region<?,?>> rootIt = gfc.rootRegions().iterator();
-      while (rootIt.hasNext()) {
-        Region<?,?> rr = rootIt.next();
-        getRegionLiveChunks(rr, result);
-        Iterator<Region<?,?>> srIt = rr.subregions(true).iterator();
-        while (srIt.hasNext()) {
-          getRegionLiveChunks(srIt.next(), result);
-        }
-      }
-    }
-    return result;
-  }
-
-  private void getRegionLiveChunks(Region<?,?> r, List<OffHeapStoredObject> result) {
-    if (r.getAttributes().getOffHeap()) {
-
-      if (r instanceof PartitionedRegion) {
-        PartitionedRegionDataStore prs = ((PartitionedRegion) r).getDataStore();
-        if (prs != null) {
-          Set<BucketRegion> brs = prs.getAllLocalBucketRegions();
-          if (brs != null) {
-            for (BucketRegion br : brs) {
-              if (br != null && !br.isDestroyed()) {
-                this.basicGetRegionLiveChunks(br, result);
-              }
-
-            }
-          }
-        }
-      } else {
-        this.basicGetRegionLiveChunks((LocalRegion) r, result);
-      }
-
-    }
-
-  }
-  
-  private void basicGetRegionLiveChunks(LocalRegion r, List<OffHeapStoredObject> result) {
-    for (Object key : r.keySet()) {
-      RegionEntry re = ((LocalRegion) r).getRegionEntry(key);
-      if (re != null) {
-        /**
-         * value could be GATEWAY_SENDER_EVENT_IMPL_VALUE or region entry value.
-         */
-        @Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE)
-        Object value = re._getValue();
-        if (value instanceof OffHeapStoredObject) {
-          result.add((OffHeapStoredObject) value);
-        }
-      }
-    }
-  }
-
-  private OffHeapStoredObject allocateOffHeapStoredObject(int size) {
-    OffHeapStoredObject result = this.freeList.allocate(size);
-    int resultSize = result.getSize();
-    stats.incObjects(1);
-    stats.incUsedMemory(resultSize);
-    stats.incFreeMemory(-resultSize);
-    notifyListeners();
-    if (ReferenceCountHelper.trackReferenceCounts()) {
-      ReferenceCountHelper.refCountChanged(result.getAddress(), false, 1);
-    }
-    return result;
-  }
-  
-  @Override
-  public StoredObject allocate(int size) {
-    //System.out.println("allocating " + size);
-    OffHeapStoredObject result = allocateOffHeapStoredObject(size);
-    //("allocated off heap object of size " + size + " @" + Long.toHexString(result.getMemoryAddress()), true);
-    return result;
-  }
-  
-  public static void debugLog(String msg, boolean logStack) {
-    if (logStack) {
-      logger.info(msg, new RuntimeException(msg));
-    } else {
-      logger.info(msg);
-    }
-  }
-  
-  @Override
-  public StoredObject allocateAndInitialize(byte[] v, boolean isSerialized, boolean isCompressed) {
-    return allocateAndInitialize(v, isSerialized, isCompressed, null);
-  }
-  @Override
-  public StoredObject allocateAndInitialize(byte[] v, boolean isSerialized, boolean isCompressed, byte[] originalHeapData) {
-    long addr = OffHeapRegionEntryHelper.encodeDataAsAddress(v, isSerialized, isCompressed);
-    if (addr != 0L) {
-      return new TinyStoredObject(addr);
-    }
-    OffHeapStoredObject result = allocateOffHeapStoredObject(v.length);
-    //debugLog("allocated off heap object of size " + v.length + " @" + Long.toHexString(result.getMemoryAddress()), true);
-    //debugLog("allocated off heap object of size " + v.length + " @" + Long.toHexString(result.getMemoryAddress()) +  "chunkSize=" + result.getSize() + " isSerialized=" + isSerialized + " v=" + Arrays.toString(v), true);
-    result.setSerializedValue(v);
-    result.setSerialized(isSerialized);
-    result.setCompressed(isCompressed);
-    if (originalHeapData != null) {
-      result = new OffHeapStoredObjectWithHeapForm(result, originalHeapData);
-    }
-    return result;
-  }
-  
-  @Override
-  public long getFreeMemory() {
-    return this.freeList.getFreeMemory();
-  }
-
-  @Override
-  public long getUsedMemory() {
-    return this.freeList.getUsedMemory();
-  }
-
-  @Override
-  public long getTotalMemory() {
-    return this.freeList.getTotalMemory();
-  }
-  
-  @Override
-  public void close() {
-    try {
-      LifecycleListener.invokeBeforeClose(this);
-    } finally {
-      this.ooohml.close();
-      if (Boolean.getBoolean(FREE_OFF_HEAP_MEMORY_PROPERTY)) {
-        realClose();
-      }
-    }
-  }
-  
-  public static void freeOffHeapMemory() {
-    SimpleMemoryAllocatorImpl ma = singleton;
-    if (ma != null) {
-      ma.realClose();
-    }
-  }
-  
-  private void realClose() {
-    // Removing this memory immediately can lead to a SEGV. See 47885.
-    if (setClosed()) {
-      this.freeList.freeSlabs();
-      this.stats.close();
-      singleton = null;
-    }
-  }
-  
-  private final AtomicBoolean closed = new AtomicBoolean();
-  private boolean isClosed() {
-    return this.closed.get();
-  }
-  /**
-   * Returns true if caller is the one who should close; false if some other thread
-   * is already closing.
-   */
-  private boolean setClosed() {
-    return this.closed.compareAndSet(false, true);
-  }
-  
-
-  FreeListManager getFreeListManager() {
-    return this.freeList;
-  }
-  
-  /**
-   * Return the slabId of the slab that contains the given addr.
-   */
-  int findSlab(long addr) {
-    return this.freeList.findSlab(addr);
-  }
-  
-  public OffHeapMemoryStats getStats() {
-    return this.stats;
-  }
-  
-  @Override
-  public void addMemoryUsageListener(final MemoryUsageListener listener) {
-    synchronized (this.memoryUsageListeners) {
-      final MemoryUsageListener[] newMemoryUsageListeners = Arrays.copyOf(this.memoryUsageListeners, this.memoryUsageListeners.length + 1);
-      newMemoryUsageListeners[this.memoryUsageListeners.length] = listener;
-      this.memoryUsageListeners = newMemoryUsageListeners;
-    }
-  }
-  
-  @Override
-  public void removeMemoryUsageListener(final MemoryUsageListener listener) {
-    synchronized (this.memoryUsageListeners) {
-      int listenerIndex = -1;
-      for (int i = 0; i < this.memoryUsageListeners.length; i++) {
-        if (this.memoryUsageListeners[i] == listener) {
-          listenerIndex = i;
-          break;
-        }
-      }
-
-      if (listenerIndex != -1) {
-        final MemoryUsageListener[] newMemoryUsageListeners = new MemoryUsageListener[this.memoryUsageListeners.length - 1];
-        System.arraycopy(this.memoryUsageListeners, 0, newMemoryUsageListeners, 0, listenerIndex);
-        System.arraycopy(this.memoryUsageListeners, listenerIndex + 1, newMemoryUsageListeners, listenerIndex,
-            this.memoryUsageListeners.length - listenerIndex - 1);
-        this.memoryUsageListeners = newMemoryUsageListeners;
-      }
-    }
-  }
-  
-  void notifyListeners() {
-    final MemoryUsageListener[] savedListeners = this.memoryUsageListeners;
-    
-    if (savedListeners.length == 0) {
-      return;
-    }
-
-    final long bytesUsed = getUsedMemory();
-    for (int i = 0; i < savedListeners.length; i++) {
-      savedListeners[i].updateMemoryUsed(bytesUsed);
-    }
-  }
-  
-  static void validateAddress(long addr) {
-    validateAddressAndSize(addr, -1);
-  }
-  
-  static void validateAddressAndSize(long addr, int size) {
-    // if the caller does not have a "size" to provide then use -1
-    if ((addr & 7) != 0) {
-      StringBuilder sb = new StringBuilder();
-      sb.append("address was not 8 byte aligned: 0x").append(Long.toString(addr, 16));
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.singleton;
-      if (ma != null) {
-        sb.append(". Valid addresses must be in one of the following ranges: ");
-        ma.freeList.getSlabDescriptions(sb);
-     }
-      throw new IllegalStateException(sb.toString());
-    }
-    if (addr >= 0 && addr < 1024) {
-      throw new IllegalStateException("addr was smaller than expected 0x" + addr);
-    }
-    validateAddressAndSizeWithinSlab(addr, size, DO_EXPENSIVE_VALIDATION);
-  }
-
-  static void validateAddressAndSizeWithinSlab(long addr, int size, boolean doExpensiveValidation) {
-    if (doExpensiveValidation) {
-      SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.singleton;
-      if (ma != null) {
-        if (!ma.freeList.validateAddressAndSizeWithinSlab(addr, size)) {
-          throw new IllegalStateException(" address 0x" + Long.toString(addr, 16) + " does not address the original slab memory");
-        }
-      }
-    }
-  }
-
-  public synchronized List<MemoryBlock> getOrphans() {
-    List<OffHeapStoredObject> liveChunks = this.freeList.getLiveChunks();
-    List<OffHeapStoredObject> regionChunks = getRegionLiveChunks();
-    liveChunks.removeAll(regionChunks);
-    List<MemoryBlock> orphans = new ArrayList<MemoryBlock>();
-    for (OffHeapStoredObject chunk: liveChunks) {
-      orphans.add(new MemoryBlockNode(this, chunk));
-    }
-    Collections.sort(orphans,
-        new Comparator<MemoryBlock>() {
-          @Override
-          public int compare(MemoryBlock o1, MemoryBlock o2) {
-            return Long.valueOf(o1.getAddress()).compareTo(o2.getAddress());
-          }
-        });
-    //this.memoryBlocks = new WeakReference<List<MemoryBlock>>(orphans);
-    return orphans;
-  }
-
-  @Override
-  public MemoryInspector getMemoryInspector() {
-    return this.memoryInspector;
-  }
-  
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
index dce68cf..8127eea 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
@@ -110,7 +110,7 @@ import com.gemstone.gemfire.internal.cache.versions.RegionVersionVector;
 import com.gemstone.gemfire.internal.cache.versions.VMRegionVersionVector;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.test.dunit.AsyncInvocation;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
@@ -2000,7 +2000,7 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
             assertEquals(1, region.size());
             if (region.getAttributes().getOffHeap() && !(region instanceof PartitionedRegion)) {
               GemFireCacheImpl gfc = (GemFireCacheImpl) getCache();
-              SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore();
+              MemoryAllocatorImpl ma = (MemoryAllocatorImpl) gfc.getOffHeapStore();
               LocalRegion reRegion;
               reRegion = (LocalRegion) region;
               RegionEntry re = reRegion.getRegionEntry(key2);
@@ -2066,7 +2066,7 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
             assertEquals(1, region.size());
             if (region.getAttributes().getOffHeap() && !(region instanceof PartitionedRegion)) {
               GemFireCacheImpl gfc = (GemFireCacheImpl) getCache();
-              SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore();
+              MemoryAllocatorImpl ma = (MemoryAllocatorImpl) gfc.getOffHeapStore();
               assertEquals(1, ma.getStats().getObjects());
             }
           }
@@ -2087,7 +2087,7 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
           assertEquals(2, region.size());
           if (region.getAttributes().getOffHeap() && !(region instanceof PartitionedRegion)) {
             GemFireCacheImpl gfc = (GemFireCacheImpl) getCache();
-            SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore();
+            MemoryAllocatorImpl ma = (MemoryAllocatorImpl) gfc.getOffHeapStore();
             assertEquals(2, ma.getStats().getObjects());
             LocalRegion reRegion;
             reRegion = (LocalRegion) region;
@@ -2153,7 +2153,7 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
             assertEquals(2, region.size());
             if (region.getAttributes().getOffHeap() && !(region instanceof PartitionedRegion)) {
               GemFireCacheImpl gfc = (GemFireCacheImpl) getCache();
-              SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore();
+              MemoryAllocatorImpl ma = (MemoryAllocatorImpl) gfc.getOffHeapStore();
               assertEquals(2, ma.getStats().getObjects());
               LocalRegion reRegion;
               reRegion = (LocalRegion) region;
@@ -2177,7 +2177,7 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
           assertEquals(2, region.size());
           if (region.getAttributes().getOffHeap() && !(region instanceof PartitionedRegion)) {
             GemFireCacheImpl gfc = (GemFireCacheImpl) getCache();
-            SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore();
+            MemoryAllocatorImpl ma = (MemoryAllocatorImpl) gfc.getOffHeapStore();
             assertEquals(2, ma.getStats().getObjects());
           }
         }
@@ -2237,7 +2237,7 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
             assertEquals(2, region.size());
             if (region.getAttributes().getOffHeap() && !(region instanceof PartitionedRegion)) {
               GemFireCacheImpl gfc = (GemFireCacheImpl) getCache();
-              SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore();
+              MemoryAllocatorImpl ma = (MemoryAllocatorImpl) gfc.getOffHeapStore();
               assertEquals(2, ma.getStats().getObjects());
             }
           }
@@ -2257,7 +2257,7 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
           assertEquals(1, region.size());
           if (region.getAttributes().getOffHeap() && !(region instanceof PartitionedRegion)) {
             GemFireCacheImpl gfc = (GemFireCacheImpl) getCache();
-            SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore();
+            MemoryAllocatorImpl ma = (MemoryAllocatorImpl) gfc.getOffHeapStore();
             assertEquals(1, ma.getStats().getObjects());
           }
        }
@@ -2312,7 +2312,7 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
             assertEquals(1, region.size());
             if (region.getAttributes().getOffHeap() && !(region instanceof PartitionedRegion)) {
               GemFireCacheImpl gfc = (GemFireCacheImpl) getCache();
-              SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore();
+              MemoryAllocatorImpl ma = (MemoryAllocatorImpl) gfc.getOffHeapStore();
               assertEquals(1, ma.getStats().getObjects());
             }
           }
@@ -2331,13 +2331,13 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
           assertEquals(1, region.size());
           if (region.getAttributes().getOffHeap() && !(region instanceof PartitionedRegion)) {
             GemFireCacheImpl gfc = (GemFireCacheImpl) getCache();
-            SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore();
+            MemoryAllocatorImpl ma = (MemoryAllocatorImpl) gfc.getOffHeapStore();
             assertEquals(1, ma.getStats().getObjects());
           }
           region.destroyRegion(arg);
           if (region.getAttributes().getOffHeap() && !(region instanceof PartitionedRegion)) {
             GemFireCacheImpl gfc = (GemFireCacheImpl) getCache();
-            final SimpleMemoryAllocatorImpl ma = (SimpleMemoryAllocatorImpl) gfc.getOffHeapStore();
+            final MemoryAllocatorImpl ma = (MemoryAllocatorImpl) gfc.getOffHeapStore();
             WaitCriterion waitForStatChange = new WaitCriterion() {
               public boolean done() {
                 return ma.getStats().getObjects() == 0;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerGetAllDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerGetAllDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerGetAllDUnitTest.java
index f7f633c..803593e 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerGetAllDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerGetAllDUnitTest.java
@@ -39,7 +39,7 @@ import com.gemstone.gemfire.cache30.ClientServerTestCase;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 import com.gemstone.gemfire.test.dunit.Assert;
 import com.gemstone.gemfire.test.dunit.AsyncInvocation;
 import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
@@ -270,7 +270,7 @@ import com.gemstone.gemfire.test.dunit.VM;
     server.invoke(new CacheSerializableRunnable("Dump OffHeap Stats") {
       @Override
       public void run2() throws CacheException {
-        SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.getAllocator();
+        MemoryAllocatorImpl ma = MemoryAllocatorImpl.getAllocator();
         System.out.println("STATS: objects=" + ma.getStats().getObjects() + " usedMemory=" + ma.getStats().getUsedMemory() + " reads=" + ma.getStats().getReads());
       }
     });

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapTestUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapTestUtil.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapTestUtil.java
index 8fd6895..f9d2c2a 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapTestUtil.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapTestUtil.java
@@ -25,15 +25,15 @@ import com.gemstone.gemfire.cache.CacheClosedException;
 import com.gemstone.gemfire.internal.offheap.MemoryBlock;
 import com.gemstone.gemfire.internal.offheap.RefCountChangeInfo;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 
 @SuppressWarnings("deprecation")
 public class OffHeapTestUtil {
 
   public static void checkOrphans() { // TODO:KIRK: need to do something special to guarantee proper tearDown
-    SimpleMemoryAllocatorImpl allocator = null;
+    MemoryAllocatorImpl allocator = null;
     try {
-      allocator = SimpleMemoryAllocatorImpl.getAllocator();
+      allocator = MemoryAllocatorImpl.getAllocator();
     } catch (CacheClosedException ignore) {
       // no off-heap memory so no orphans
       return;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
index 0829009..550d133 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
@@ -31,7 +31,7 @@ import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.OffHeapValueWrapper;
 import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.Flushable;
 import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
 import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 import com.gemstone.gemfire.internal.offheap.SlabImpl;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
@@ -40,18 +40,18 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 public class OffHeapValueWrapperJUnitTest {
 
   private static OffHeapValueWrapper createChunkValueWrapper(byte[] bytes, boolean isSerialized) {
-    StoredObject c = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, isSerialized, false);
+    StoredObject c = MemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, isSerialized, false);
     return new OffHeapValueWrapper(c);
   }
 
   @Before
   public void setUp() throws Exception {
-    SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
+    MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
   }
 
   @After
   public void tearDown() throws Exception {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    MemoryAllocatorImpl.freeOffHeapMemory();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
index 84d7fc7..6dbe100 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
@@ -30,7 +30,7 @@ import com.gemstone.gemfire.internal.offheap.OffHeapStoredObject;
 import com.gemstone.gemfire.internal.offheap.TinyStoredObject;
 import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
 import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
 import com.gemstone.gemfire.internal.offheap.SlabImpl;
 import com.gemstone.gemfire.internal.util.BlobHelper;
 
@@ -109,8 +109,8 @@ public abstract class OldValueImporterTestBase {
     
     // off-heap DataAsAddress byte array
     {
-      SimpleMemoryAllocatorImpl sma =
-          SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
+      MemoryAllocatorImpl sma =
+          MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
       try {
         byte[] baValue = new byte[] {1,2};
         TinyStoredObject baValueSO = (TinyStoredObject) sma.allocateAndInitialize(baValue, false, false);
@@ -121,13 +121,13 @@ public abstract class OldValueImporterTestBase {
         fromData(imsg, bytes);
         assertArrayEquals(baValue, (byte[])getOldValueFromImporter(imsg));
       } finally {
-        SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+        MemoryAllocatorImpl.freeOffHeapMemory();
       }
     }
     // off-heap Chunk byte array
     {
-      SimpleMemoryAllocatorImpl sma =
-          SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
+      MemoryAllocatorImpl sma =
+          MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
       try {
         byte[] baValue = new byte[] {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
         OffHeapStoredObject baValueSO = (OffHeapStoredObject) sma.allocateAndInitialize(baValue, false, false);
@@ -138,13 +138,13 @@ public abstract class OldValueImporterTestBase {
         fromData(imsg, bytes);
         assertArrayEquals(baValue, (byte[])getOldValueFromImporter(imsg));
       } finally {
-        SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+        MemoryAllocatorImpl.freeOffHeapMemory();
       }
     }
     // off-heap DataAsAddress String
     {
-      SimpleMemoryAllocatorImpl sma =
-          SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
+      MemoryAllocatorImpl sma =
+          MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
       try {
         String baValue = "12";
         byte[] baValueBlob = BlobHelper.serializeToBlob(baValue);
@@ -156,13 +156,13 @@ public abstract class OldValueImporterTestBase {
         fromData(imsg, bytes);
         assertArrayEquals(baValueBlob, ((VMCachedDeserializable)getOldValueFromImporter(imsg)).getSerializedValue());
       } finally {
-        SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+        MemoryAllocatorImpl.freeOffHeapMemory();
       }
     }
     // off-heap Chunk String
     {
-      SimpleMemoryAllocatorImpl sma =
-          SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
+      MemoryAllocatorImpl sma =
+          MemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
       try {
         String baValue = "12345678";
         byte[] baValueBlob = BlobHelper.serializeToBlob(baValue);
@@ -174,7 +174,7 @@ public abstract class OldValueImporterTestBase {
         fromData(imsg, bytes);
         assertArrayEquals(baValueBlob, ((VMCachedDeserializable)getOldValueFromImporter(imsg)).getSerializedValue());
       } finally {
-        SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+        MemoryAllocatorImpl.freeOffHeapMemory();
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/82faa8af/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
index 382bd98..950d90b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
@@ -43,7 +43,7 @@ public class FreeListManagerTest {
   }
 
   private final int DEFAULT_SLAB_SIZE = 1024*1024*5;
-  private final SimpleMemoryAllocatorImpl ma = mock(SimpleMemoryAllocatorImpl.class);
+  private final MemoryAllocatorImpl ma = mock(MemoryAllocatorImpl.class);
   private final OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
   private TestableFreeListManager freeListManager;
   
@@ -68,7 +68,7 @@ public class FreeListManagerTest {
     }
   }
   
-  private static TestableFreeListManager createFreeListManager(SimpleMemoryAllocatorImpl ma, Slab[] slabs) {
+  private static TestableFreeListManager createFreeListManager(MemoryAllocatorImpl ma, Slab[] slabs) {
     return new TestableFreeListManager(ma, slabs);
   }
   
@@ -871,7 +871,7 @@ public class FreeListManagerTest {
       }
     }
     
-    public TestableFreeListManager(SimpleMemoryAllocatorImpl ma, Slab[] slabs) {
+    public TestableFreeListManager(MemoryAllocatorImpl ma, Slab[] slabs) {
       super(ma, slabs);
     }
     


[26/26] incubator-geode git commit: Merge remote-tracking branch 'origin/develop' into feature/GEODE-949-2

Posted by kl...@apache.org.
Merge remote-tracking branch 'origin/develop' into feature/GEODE-949-2


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 2184de4dc872264b3adc2f0975488d06b13e143d
Parents: 5dcd681 d72986b
Author: Kirk Lund <kl...@apache.org>
Authored: Thu Mar 17 14:13:49 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Thu Mar 17 14:13:49 2016 -0700

----------------------------------------------------------------------
 .travis.yml                                     |   7 +-
 .../rest/internal/web/RestFunctionTemplate.java |  23 +
 ...stAPIOnRegionFunctionExecutionDUnitTest.java | 479 ++++-----------
 .../web/controllers/RestAPITestBase.java        | 209 +++++--
 ...tAPIsOnGroupsFunctionExecutionDUnitTest.java | 310 +++-------
 ...APIsOnMembersFunctionExecutionDUnitTest.java | 299 ++--------
 .../gemfire/internal/SocketCreator.java         |   2 +-
 .../internal/cache/AbstractRegionEntry.java     |  22 +-
 .../gemfire/internal/cache/BucketRegion.java    |   6 +-
 .../gemfire/internal/cache/TXManagerImpl.java   |   3 +-
 .../gemfire/internal/cache/UpdateOperation.java |   2 +-
 .../cache/control/HeapMemoryMonitor.java        |  14 +-
 .../cache/tier/sockets/AcceptorImpl.java        |   9 +-
 .../tier/sockets/ClientUpdateMessageImpl.java   |   2 +-
 .../internal/cache/tier/sockets/Message.java    |   2 +-
 .../AbstractGatewaySenderEventProcessor.java    |  48 +-
 .../cache/wan/GatewaySenderEventImpl.java       |  33 +-
 .../parallel/ParallelGatewaySenderQueue.java    |  74 ++-
 .../gemfire/internal/i18n/LocalizedStrings.java |   6 +-
 .../gemfire/internal/offheap/Fragment.java      |   4 +-
 .../internal/offheap/FreeListManager.java       |  44 +-
 .../internal/offheap/LifecycleListener.java     |  20 +-
 .../internal/offheap/MemoryAllocatorImpl.java   | 507 ++++++++++++++++
 .../internal/offheap/MemoryBlockNode.java       |   4 +-
 .../internal/offheap/OffHeapMemoryStats.java    |   8 +-
 .../internal/offheap/OffHeapStorage.java        |  60 +-
 .../internal/offheap/OffHeapStoredObject.java   |  26 +-
 .../OffHeapStoredObjectAddressStack.java        |   4 +-
 .../internal/offheap/RefCountChangeInfo.java    |   2 +-
 .../internal/offheap/ReferenceCountHelper.java  |   4 +-
 .../offheap/SimpleMemoryAllocatorImpl.java      | 507 ----------------
 .../internal/beans/MemberMBeanBridge.java       |   2 +-
 .../gemfire/cache30/CacheXml80DUnitTest.java    |   2 +
 .../gemfire/cache30/MultiVMRegionTestCase.java  |  22 +-
 .../disttx/DistTXManagerImplJUnitTest.java      |   6 +
 .../cache/ClientServerGetAllDUnitTest.java      |   4 +-
 .../gemfire/internal/cache/OffHeapTestUtil.java |   6 +-
 .../cache/OffHeapValueWrapperJUnitTest.java     |   8 +-
 .../cache/OldValueImporterTestBase.java         |  26 +-
 .../internal/cache/TXManagerImplJUnitTest.java  |  11 +
 .../internal/offheap/FreeListManagerTest.java   |  72 +--
 .../offheap/LifecycleListenerJUnitTest.java     |  36 +-
 ...moryAllocatorFillPatternIntegrationTest.java | 246 ++++++++
 .../MemoryAllocatorFillPatternJUnitTest.java    | 183 ++++++
 .../offheap/MemoryAllocatorJUnitTest.java       | 594 +++++++++++++++++++
 .../offheap/MemoryBlockNodeJUnitTest.java       |   6 +-
 .../offheap/NullOffHeapMemoryStats.java         |   8 +-
 .../offheap/OffHeapHelperJUnitTest.java         |   4 +-
 .../internal/offheap/OffHeapIndexJUnitTest.java |   2 +-
 .../internal/offheap/OffHeapRegionBase.java     |   6 +-
 .../OffHeapRegionEntryHelperJUnitTest.java      |   4 +-
 .../offheap/OffHeapStorageJUnitTest.java        |  24 +-
 ...ffHeapStoredObjectAddressStackJUnitTest.java |  40 +-
 .../offheap/OffHeapStoredObjectJUnitTest.java   |   4 +-
 .../offheap/OffHeapValidationJUnitTest.java     |   2 +-
 .../OffHeapWriteObjectAsByteArrayJUnitTest.java |   8 +-
 .../offheap/OutOfOffHeapMemoryDUnitTest.java    |   2 +-
 ...moryAllocatorFillPatternIntegrationTest.java | 246 --------
 ...mpleMemoryAllocatorFillPatternJUnitTest.java | 183 ------
 .../offheap/SimpleMemoryAllocatorJUnitTest.java | 594 -------------------
 .../offheap/TinyMemoryBlockJUnitTest.java       |   8 +-
 .../TxReleasesOffHeapOnCloseJUnitTest.java      |   2 +-
 .../OffHeapByteBufferByteSourceJUnitTest.java   |   4 +-
 .../gemfire/pdx/OffHeapByteSourceJUnitTest.java |   8 +-
 .../security/ClientAuthorizationTestBase.java   |  49 +-
 .../generator/SSLCredentialGenerator.java       |   2 +-
 .../com/gemstone/gemfire/test/dunit/VM.java     |   2 +-
 .../test/dunit/tests/BasicDUnitTest.java        |  42 ++
 geode-site/website/README.md                    |   2 +-
 geode-site/website/Rules                        |   3 -
 geode-site/website/content/community/index.html |   2 +-
 geode-site/website/content/docs/index.html      |  48 ++
 geode-site/website/layouts/default.html         |  32 -
 geode-site/website/layouts/footer.html          |   2 +-
 geode-site/website/layouts/header.html          |   2 +-
 .../wan/GatewaySenderEventRemoteDispatcher.java |  44 +-
 .../gemfire/internal/cache/wan/WANTestBase.java |  26 +-
 .../cache/wan/misc/WANSSLDUnitTest.java         |   2 +
 ...arallelGatewaySenderOperationsDUnitTest.java |  35 ++
 .../controllers/FunctionAccessController.java   | 195 +++---
 .../rest/internal/web/util/ArrayUtils.java      |  12 +-
 gradle/dependency-versions.properties           |   4 +-
 82 files changed, 2686 insertions(+), 2931 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2184de4d/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
index d49c423,8476ae2..c7eed57
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
@@@ -1,6 -1,6 +1,3 @@@
--
--package com.gemstone.gemfire.security;
--
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
@@@ -9,9 -9,9 +6,9 @@@
   * 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
@@@ -19,7 -19,7 +16,7 @@@
   * specific language governing permissions and limitations
   * under the License.
   */
--
++package com.gemstone.gemfire.security;
  
  import java.util.ArrayList;
  import java.util.HashMap;
@@@ -58,12 -55,8 +52,13 @@@ import com.gemstone.gemfire.internal.Av
  import com.gemstone.gemfire.internal.cache.AbstractRegionEntry;
  import com.gemstone.gemfire.internal.cache.LocalRegion;
  import com.gemstone.gemfire.internal.util.Callable;
++import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
++import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator.ClassCode;
 +import com.gemstone.gemfire.security.generator.CredentialGenerator;
 +import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
 +import com.gemstone.gemfire.security.generator.XmlAuthzCredentialGenerator;
  import com.gemstone.gemfire.test.dunit.Assert;
  import com.gemstone.gemfire.test.dunit.DistributedTestCase;
- import com.gemstone.gemfire.test.dunit.LogWriterUtils;
  import com.gemstone.gemfire.test.dunit.VM;
  import com.gemstone.gemfire.test.dunit.Wait;
  import com.gemstone.gemfire.test.dunit.WaitCriterion;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2184de4d/geode-core/src/test/java/com/gemstone/gemfire/security/generator/SSLCredentialGenerator.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/security/generator/SSLCredentialGenerator.java
index 10e2e18,0000000..ff23f78
mode 100755,000000..100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/generator/SSLCredentialGenerator.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/generator/SSLCredentialGenerator.java
@@@ -1,121 -1,0 +1,121 @@@
 +/*
 + * 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.security.generator;
 +
 +import com.gemstone.gemfire.internal.logging.LogService;
 +import com.gemstone.gemfire.security.AuthenticationFailedException;
 +import org.apache.logging.log4j.Logger;
 +
 +import java.io.File;
 +import java.io.IOException;
 +import java.security.Principal;
 +import java.util.Properties;
 +
 +public class SSLCredentialGenerator extends CredentialGenerator {
 +
 +  private static final Logger logger = LogService.getLogger();
 +
 +  @Override
 +  protected Properties initialize() throws IllegalArgumentException {
 +    this.javaProperties = getValidJavaSSLProperties();
 +    return getSSLProperties();
 +  }
 +
 +  @Override
 +  public ClassCode classCode() {
 +    return ClassCode.SSL;
 +  }
 +
 +  @Override
 +  public String getAuthInit() {
 +    return null;
 +  }
 +
 +  @Override
 +  public String getAuthenticator() {
 +    return null;
 +  }
 +
 +  @Override
 +  public Properties getValidCredentials(int index) {
 +    this.javaProperties = getValidJavaSSLProperties();
 +    return getSSLProperties();
 +  }
 +
 +  @Override
 +  public Properties getValidCredentials(final Principal principal) {
 +    this.javaProperties = getValidJavaSSLProperties();
 +    return getSSLProperties();
 +  }
 +
 +  @Override
 +  public Properties getInvalidCredentials(final int index) {
 +    this.javaProperties = getInvalidJavaSSLProperties();
 +    return getSSLProperties();
 +  }
 +
 +  private File findTrustedJKS() {
 +    final File ssldir = new File(System.getProperty("JTESTS") + "/ssl");
 +    return new File(ssldir, "trusted.keystore");
 +  }
 +
 +  private File findUntrustedJKS() {
 +    final File ssldir = new File(System.getProperty("JTESTS") + "/ssl");
 +    return new File(ssldir, "untrusted.keystore");
 +  }
 +
 +  private Properties getValidJavaSSLProperties() {
 +    final File jks = findTrustedJKS();
 +
 +    try {
 +      final Properties props = new Properties();
 +      props.setProperty("javax.net.ssl.trustStore", jks.getCanonicalPath());
 +      props.setProperty("javax.net.ssl.trustStorePassword", "password");
 +      props.setProperty("javax.net.ssl.keyStore", jks.getCanonicalPath());
 +      props.setProperty("javax.net.ssl.keyStorePassword", "password");
 +      return props;
 +
 +    } catch (IOException ex) {
 +      throw new AuthenticationFailedException("SSL: Exception while opening the key store: " + ex.getMessage(), ex);
 +    }
 +  }
 +
 +  private Properties getInvalidJavaSSLProperties() {
 +    final File jks = findUntrustedJKS();
 +
 +    try {
 +      final Properties props = new Properties();
 +      props.setProperty("javax.net.ssl.trustStore", jks.getCanonicalPath());
 +      props.setProperty("javax.net.ssl.trustStorePassword", "password");
 +      props.setProperty("javax.net.ssl.keyStore", jks.getCanonicalPath());
 +      props.setProperty("javax.net.ssl.keyStorePassword", "password");
 +      return props;
 +
 +    } catch (IOException ex) {
 +      throw new AuthenticationFailedException("SSL: Exception while opening the key store: " + ex.getMessage(), ex);
 +    }
 +  }
 +
 +  private Properties getSSLProperties() {
 +    Properties props = new Properties();
 +    props.setProperty("ssl-enabled", "true");
 +    props.setProperty("ssl-require-authentication", "true");
-     props.setProperty("ssl-ciphers", "SSL_RSA_WITH_RC4_128_MD5");
++    props.setProperty("ssl-ciphers", "SSL_RSA_WITH_3DES_EDE_CBC_SHA");
 +    props.setProperty("ssl-protocols", "TLSv1");
 +    return props;
 +  }
 +}


[04/26] incubator-geode git commit: GEODE-1097 allow Lambda invocations to be named so that they show up in test logs

Posted by kl...@apache.org.
GEODE-1097 allow Lambda invocations to be named so that they show up in test logs

addressing issues found by Jianxia.  One of the VM methods was not invoking
the correct runnable.  Unit tests were needed for the NamedRunnable
invocation methods.  Since Runnable doesn't return a result the test
ensures that the target method has been invoked by having it throw an
exception.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: c5a88171733532e76f9f6880d0a8f5ea6fe0bede
Parents: 5503de0
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Tue Mar 15 14:02:34 2016 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Tue Mar 15 14:04:47 2016 -0700

----------------------------------------------------------------------
 .../com/gemstone/gemfire/test/dunit/VM.java     |  2 +-
 .../test/dunit/tests/BasicDUnitTest.java        | 42 ++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5a88171/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java
index 8e408dc..1c6ba6e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java
@@ -259,7 +259,7 @@ public class VM implements Serializable {
    */
   public AsyncInvocation invokeAsync(String name, SerializableRunnableIF r) {
     NamedRunnable nr = new NamedRunnable(name, r);
-    return invokeAsync(r, "run", new Object[0]);
+    return invokeAsync(nr, "run", new Object[0]);
   }
   
   /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5a88171/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
index 195d5f4..3a98188 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
@@ -106,6 +106,48 @@ public class BasicDUnitTest extends DistributedTestCase {
     assertEquals(0, vm0num);
     
   }
+  
+  static class BasicDUnitException extends RuntimeException {
+    public BasicDUnitException() {
+    }
+  }
+  
+  public static void throwException() throws BasicDUnitException {
+    throw new BasicDUnitException();
+  }
+
+  public void testInvokeNamedRunnableLambdaAsync() throws Throwable {
+    Host host = Host.getHost(0);
+    VM vm0 = host.getVM(0);
+    
+    AsyncInvocation<Integer> async0 = vm0.invokeAsync("throwSomething", () -> BasicDUnitTest.throwException());
+    try {
+      async0.getResult();
+      throw new Error("expected an exception to be thrown");
+    } catch (Exception e) {
+      Throwable cause = e.getCause();
+      if (cause == null) {
+        throw new Error("expected an exception with a cause to be thrown", e);
+      }
+      if ( !(cause.getCause() instanceof BasicDUnitException) ) {
+        throw new Error("expected a BasicDUnitException to be thrown", e.getCause());
+      }
+    }
+  }
+
+  public void testInvokeNamedRunnableLambda() throws Throwable {
+    Host host = Host.getHost(0);
+    VM vm0 = host.getVM(0);
+    
+    try {
+      vm0.invoke("throwSomething", () -> BasicDUnitTest.throwException());
+      throw new Error("expected an exception to be thrown");
+    } catch (Exception e) {
+      if ( !(e.getCause() instanceof BasicDUnitException) ) {
+        throw new Error("expected a BasicDUnitException to be thrown", e.getCause());
+      }
+    }
+  }
 
   static class BasicTestException extends RuntimeException {
     BasicTestException() {


[02/26] incubator-geode git commit: GEODE-1053: Adding "filter" on Function Rest Invoction Refactoring of RestAPIOnRegionFunctionExecutionDUnitTest.java RestAPIsOnGroupsFunctionExecutionDUnitTest.java RestAPIsOnMembersFunctionExecutionDUnitTest.java. Upd

Posted by kl...@apache.org.
GEODE-1053: Adding "filter" on Function Rest Invoction
Refactoring of RestAPIOnRegionFunctionExecutionDUnitTest.java RestAPIsOnGroupsFunctionExecutionDUnitTest.java RestAPIsOnMembersFunctionExecutionDUnitTest.java.
Updating dependency-versions.properties http-core and http-client


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

Branch: refs/heads/feature/GEODE-949-2
Commit: f2175524491fcab3206b718d6de0164d4fed8906
Parents: 22ab270
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Wed Mar 9 19:58:06 2016 +1100
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Wed Mar 16 05:53:57 2016 +1100

----------------------------------------------------------------------
 .../rest/internal/web/RestFunctionTemplate.java |  23 +
 ...stAPIOnRegionFunctionExecutionDUnitTest.java | 488 +++++--------------
 .../web/controllers/RestAPITestBase.java        | 182 +++++--
 ...tAPIsOnGroupsFunctionExecutionDUnitTest.java | 334 ++++---------
 ...APIsOnMembersFunctionExecutionDUnitTest.java | 314 +++---------
 .../controllers/FunctionAccessController.java   | 195 ++++----
 .../rest/internal/web/util/ArrayUtils.java      |  12 +-
 gradle/dependency-versions.properties           |   4 +-
 8 files changed, 554 insertions(+), 998 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2175524/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestFunctionTemplate.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestFunctionTemplate.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestFunctionTemplate.java
new file mode 100644
index 0000000..8cd0638
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestFunctionTemplate.java
@@ -0,0 +1,23 @@
+/*
+ * 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.rest.internal.web;
+
+import com.gemstone.gemfire.cache.execute.FunctionAdapter;
+
+public abstract class RestFunctionTemplate extends FunctionAdapter {
+  public int invocationCount = 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2175524/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
index 4a958ce..63bd9fa 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
@@ -16,28 +16,8 @@
  */
 package com.gemstone.gemfire.rest.internal.web.controllers;
 
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-
 import com.gemstone.gemfire.LogWriter;
-import com.gemstone.gemfire.cache.AttributesFactory;
-import com.gemstone.gemfire.cache.DataPolicy;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.RegionAttributes;
-import com.gemstone.gemfire.cache.Scope;
-import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.*;
 import com.gemstone.gemfire.cache.execute.FunctionContext;
 import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.cache.execute.RegionFunctionContext;
@@ -47,44 +27,24 @@ import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.internal.cache.PartitionAttributesImpl;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.PartitionedRegionTestHelper;
-import com.gemstone.gemfire.internal.cache.functions.DistributedRegionFunction;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.IgnoredException;
-import com.gemstone.gemfire.test.dunit.SerializableCallable;
-import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.rest.internal.web.RestFunctionTemplate;
+import org.apache.http.client.methods.CloseableHttpResponse;
+
+import java.io.Serializable;
+import java.util.*;
 
 /**
  * Dunit Test to validate OnRegion function execution with REST APIs
- * 
+ *
  * @author Nilkanth Patel
  * @since 8.0
  */
 
 public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
 
-  private static final long serialVersionUID = 1L;
-
-  public static final String REGION_NAME = "DistributedRegionFunctionExecutionDUnitTest";
-
-  public static final String PR_REGION_NAME = "samplePRRegion";
-
-  public static Region region = null;
-
-  public static List<String> restURLs = new ArrayList<String>();
-
-  public static String restEndPoint = null;
-
-  public static String getRestEndPoint() {
-    return restEndPoint;
-  }
-
-  public static void setRestEndPoint(String restEndPoint) {
-    RestAPIOnRegionFunctionExecutionDUnitTest.restEndPoint = restEndPoint;
-  }
-
-  public static final Function function = new DistributedRegionFunction();
+  private final String REPLICATE_REGION_NAME = "sampleRRegion";
 
-  public static final Function functionWithNoResultThrowsException = new MyFunctionException();
+  private final String PR_REGION_NAME = "samplePRRegion";
 
   public RestAPIOnRegionFunctionExecutionDUnitTest(String name) {
     super(name);
@@ -92,52 +52,10 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
 
   public void setUp() throws Exception {
     super.setUp();
-    final Host host = Host.getHost(0);
-  }
-
-  static class FunctionWithNoLastResult implements Function {
-    private static final long serialVersionUID = -1032915440862585532L;
-    public static final String Id = "FunctionWithNoLastResult";
-    public static int invocationCount;
-
-    @Override
-    public void execute(FunctionContext context) {
-      invocationCount++;
-      InternalDistributedSystem
-          .getConnectedInstance()
-          .getLogWriter()
-          .info(
-              "<ExpectedException action=add>did not send last result"
-                  + "</ExpectedException>");
-      context.getResultSender().sendResult(
-          (Serializable) context.getArguments());
-    }
-
-    @Override
-    public String getId() {
-      return Id;
-    }
-
-    @Override
-    public boolean hasResult() {
-      return true;
-    }
-
-    @Override
-    public boolean optimizeForWrite() {
-      return false;
-    }
-
-    @Override
-    public boolean isHA() {
-      return false;
-    }
   }
 
-  static class SampleFunction implements Function {
-    private static final long serialVersionUID = -1032915440862585534L;
+  private class SampleFunction extends RestFunctionTemplate {
     public static final String Id = "SampleFunction";
-    public static int invocationCount;
 
     @Override
     public void execute(FunctionContext context) {
@@ -145,7 +63,7 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
       if (context instanceof RegionFunctionContext) {
         RegionFunctionContext rfContext = (RegionFunctionContext) context;
         rfContext.getDataSet().getCache().getLogger()
-            .info("Executing function :  TestFunction2.execute " + rfContext);
+            .info("Executing function :  SampleFunction.execute(hasResult=true) with filter: " + rfContext.getFilter() + "  " + rfContext);
         if (rfContext.getArguments() instanceof Boolean) {
           /* return rfContext.getArguments(); */
           if (hasResult()) {
@@ -157,7 +75,7 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
                 .getCache()
                 .getLogger()
                 .info(
-                    "Executing function :  TestFunction2.execute " + rfContext);
+                    "Executing function :  SampleFunction.execute(hasResult=false) " + rfContext);
             while (true && !rfContext.getDataSet().isDestroyed()) {
               rfContext.getDataSet().getCache().getLogger()
                   .info("For Bug43513 ");
@@ -172,7 +90,7 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
         } else if (rfContext.getArguments() instanceof String) {
           String key = (String) rfContext.getArguments();
           if (key.equals("TestingTimeOut")) { // for test
-                                              // PRFunctionExecutionDUnitTest#testRemoteMultiKeyExecution_timeout
+            // PRFunctionExecutionDUnitTest#testRemoteMultiKeyExecution_timeout
             try {
               Thread.sleep(2000);
             } catch (InterruptedException e) {
@@ -208,7 +126,7 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
           /* return vals; */
         } else if (rfContext.getArguments() instanceof HashMap) {
           HashMap putData = (HashMap) rfContext.getArguments();
-          for (Iterator i = putData.entrySet().iterator(); i.hasNext();) {
+          for (Iterator i = putData.entrySet().iterator(); i.hasNext(); ) {
             Map.Entry me = (Map.Entry) i.next();
             rfContext.getDataSet().put(me.getKey(), me.getValue());
           }
@@ -222,7 +140,7 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
         } else {
           DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
           LogWriter logger = ds.getLogWriter();
-          logger.info("Executing in TestFunction on Server : "
+          logger.info("Executing in SampleFunction on Server : "
               + ds.getDistributedMember() + "with Context : " + context);
           while (ds.isConnected()) {
             logger
@@ -249,7 +167,7 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
 
     @Override
     public boolean optimizeForWrite() {
-      return false;
+      return true;
     }
 
     @Override
@@ -258,54 +176,22 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
     }
   }
 
-  private int getInvocationCount(VM vm) {
-    return (Integer) vm.invoke(new SerializableCallable() {
-      /**
-       * 
-       */
-      private static final long serialVersionUID = 1L;
-
-      @Override
-      public Object call() throws Exception {
-        SampleFunction f = (SampleFunction) FunctionService
-            .getFunction(SampleFunction.Id);
-        int count = f.invocationCount;
-        f.invocationCount = 0;
-        return count;
-      }
-    });
-  }
-
-  private void verifyAndResetInvocationCount(VM vm, final int count) {
-    vm.invoke(new SerializableCallable() {
-      /**
-       * 
-       */
-      private static final long serialVersionUID = 1L;
-
-      @Override
-      public Object call() throws Exception {
-        SampleFunction f = (SampleFunction) FunctionService
-            .getFunction(SampleFunction.Id);
-        assertEquals(count, f.invocationCount);
-        // assert succeeded, reset count
-        f.invocationCount = 0;
-        return null;
-      }
-    });
+  private void verifyAndResetInvocationCount(final int count) {
+    SampleFunction f = (SampleFunction) FunctionService
+        .getFunction(SampleFunction.Id);
+    assertEquals(count, f.invocationCount);
   }
 
-  public static void createPeer(DataPolicy policy) {
+  private void createPeer(DataPolicy policy) {
     AttributesFactory factory = new AttributesFactory();
     factory.setScope(Scope.DISTRIBUTED_ACK);
     factory.setDataPolicy(policy);
-    assertNotNull(cache);
-    region = cache.createRegion(REGION_NAME, factory.create());
+    Region region = CacheFactory.getAnyInstance().createRegion(REPLICATE_REGION_NAME, factory.create());
     com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Region Created :" + region);
     assertNotNull(region);
   }
 
-  public static boolean createPeerWithPR() {
+  private boolean createPeerWithPR() {
     RegionAttributes ra = PartitionedRegionTestHelper.createRegionAttrsForPR(0,
         10);
     AttributesFactory raf = new AttributesFactory(ra);
@@ -314,41 +200,19 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
     pa.setTotalNumBuckets(17);
     raf.setPartitionAttributes(pa);
 
-    if (cache == null || cache.isClosed()) {
-      // Cache not available
-    }
-    assertNotNull(cache);
-
-    region = cache.createRegion(PR_REGION_NAME, raf.create());
+    Region region = CacheFactory.getAnyInstance().createRegion(PR_REGION_NAME, raf.create());
     com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Region Created :" + region);
     assertNotNull(region);
     return Boolean.TRUE;
   }
 
-  public static void populateRegion() {
-    assertNotNull(cache);
-    region = cache.getRegion(REGION_NAME);
-    assertNotNull(region);
-    for (int i = 1; i <= 200; i++) {
-      region.put("execKey-" + i, new Integer(i));
-    }
-  }
-
-  public static void populatePRRegion() {
-    assertNotNull(cache);
-    region = cache.getRegion(REGION_NAME);
-
-    PartitionedRegion pr = (PartitionedRegion) cache.getRegion(PR_REGION_NAME);
+  private void populatePRRegion() {
+    PartitionedRegion pr = (PartitionedRegion) CacheFactory.getAnyInstance().getRegion(PR_REGION_NAME);
     DistributedSystem.setThreadsSocketPolicy(false);
-    final HashSet testKeys = new HashSet();
 
     for (int i = (pr.getTotalNumberOfBuckets() * 3); i > 0; i--) {
-      testKeys.add("execKey-" + i);
-    }
-    int j = 0;
-    for (Iterator i = testKeys.iterator(); i.hasNext();) {
-      Integer val = new Integer(j++);
-      pr.put(i.next(), val);
+      Integer val = new Integer(i + 1);
+      pr.put("execKey-" + i, val);
     }
     // Assert there is data in each bucket
     for (int bid = 0; bid < pr.getTotalNumberOfBuckets(); bid++) {
@@ -356,9 +220,8 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
     }
   }
 
-  public static void populateRRRegion() {
-    assertNotNull(cache);
-    region = cache.getRegion(REGION_NAME);
+  private void populateRRRegion() {
+    Region region = CacheFactory.getAnyInstance().getRegion(REPLICATE_REGION_NAME);
     assertNotNull(region);
 
     final HashSet testKeys = new HashSet();
@@ -366,163 +229,48 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
       testKeys.add("execKey-" + i);
     }
     int j = 0;
-    for (Iterator i = testKeys.iterator(); i.hasNext();) {
+    for (Iterator i = testKeys.iterator(); i.hasNext(); ) {
       Integer val = new Integer(j++);
       region.put(i.next(), val);
     }
 
   }
 
-  public static void executeFunction_NoLastResult(String regionName) {
-
-    try {
-      CloseableHttpClient httpclient = HttpClients.createDefault();
-      CloseableHttpResponse response = null;
-      Random randomGenerator = new Random();
-      int index = randomGenerator.nextInt(restURLs.size());
-      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/"
-          + "FunctionWithNoLastResult" + "?onRegion=" + regionName);
-      post.addHeader("Content-Type", "application/json");
-      post.addHeader("Accept", "application/json");
-      response = httpclient.execute(post);
-    } catch (Exception e) {
-      throw new RuntimeException("unexpected exception", e);
-    }
-
-  }
-
-  public static void executeFunctionThroughRestCall(String regionName) {
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Entering executeFunctionThroughRestCall");
-    try {
-      CloseableHttpClient httpclient = HttpClients.createDefault();
-      CloseableHttpResponse response = null;
-      Random randomGenerator = new Random();
-      int index = randomGenerator.nextInt(restURLs.size());
-      
-      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/"
-          + "SampleFunction" + "?onRegion=" + regionName);
-      post.addHeader("Content-Type", "application/json");
-      post.addHeader("Accept", "application/json");
-      
-      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Request: POST " + post.toString());
-      response = httpclient.execute(post);
-      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Response: POST " + response.toString());
-      
-      assertEquals(response.getStatusLine().getStatusCode(), 200);
-      assertNotNull(response.getEntity());
-    } catch (Exception e) {
-      throw new RuntimeException("unexpected exception", e);
-    }
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Exiting executeFunctionThroughRestCall");
-
-  }
-
-  private void registerFunction(VM vm) {
-    vm.invoke(new SerializableCallable() {
-      private static final long serialVersionUID = 1L;
-      @Override
-      public Object call() throws Exception {
-        FunctionService.registerFunction(new FunctionWithNoLastResult());
-        return null;
-      }
-    });
-  }
-
-  private void registerSampleFunction(VM vm) {
-    vm.invoke(new SerializableCallable() {
-      private static final long serialVersionUID = 1L;
-
-      @Override
-      public Object call() throws Exception {
-        FunctionService.registerFunction(new SampleFunction());
-        return null;
-      }
-    });
+  @Override
+  protected String getFunctionID() {
+    return SampleFunction.Id;
   }
 
-  public void __testOnRegionExecutionOnDataPolicyEmpty_NoLastResult() {
-    // Step-1 : create cache on each VM, this will start HTTP service in
-    // embedded mode and deploy REST APIs web app on it.
-
-    fail("This test is trying to invoke non existent methods");
-//    String url1 = (String) vm3.invoke(() -> createCacheInVm( vm3 ));
-//    restURLs.add(url1);
-//
-//    String url2 = (String) vm0.invoke(() -> createCacheInVm( vm0 ));
-//    restURLs.add(url2);
-//
-//    String url3 = (String) vm1.invoke(() -> createCacheInVm( vm1 ));
-//    restURLs.add(url3);
-//
-//    String url4 = (String) vm2.invoke(() -> createCacheInVm( vm2 ));
-//    restURLs.add(url4);
-
-    // Step-2: Register function in all VMs
-    registerFunction(vm3);
-    registerFunction(vm0);
-    registerFunction(vm1);
-    registerFunction(vm2);
-
-    // Step-3: Create and configure Region on all VMs
-    vm3.invoke(() -> createPeer( DataPolicy.EMPTY ));
-    vm0.invoke(() -> createPeer( DataPolicy.REPLICATE ));
-    vm1.invoke(() -> createPeer( DataPolicy.REPLICATE ));
-    vm2.invoke(() -> createPeer( DataPolicy.REPLICATE ));
-
-    // Step-4 : Do some puts on region created earlier
-    vm3.invoke(() -> populateRegion());
-
-    // add expected exception to avoid suspect strings
-    final IgnoredException ex = IgnoredException.addIgnoredException("did not send last result");
-
-    // Step-5 : Execute function randomly (in iteration) on all available (per
-    // VM) REST end-points and verify its result
-    for (int i = 0; i < 10; i++) {
-      executeFunction_NoLastResult(REGION_NAME);
-    }
-    ex.remove();
+  private void createCacheAndRegisterFunction() {
+    restURLs.add(vm0.invoke(() -> createCacheWithGroups(vm0, null)));
+    restURLs.add(vm1.invoke(() -> createCacheWithGroups(vm1, null)));
+    restURLs.add(vm2.invoke(() -> createCacheWithGroups(vm2, null)));
+    restURLs.add(vm3.invoke(() -> createCacheWithGroups(vm3, null)));
 
-    restURLs.clear();
+    vm0.invoke(() -> FunctionService.registerFunction(new SampleFunction()));
+    vm1.invoke(() -> FunctionService.registerFunction(new SampleFunction()));
+    vm2.invoke(() -> FunctionService.registerFunction(new SampleFunction()));
+    vm3.invoke(() -> FunctionService.registerFunction(new SampleFunction()));
   }
 
-  public void testOnRegionExecutionWithRR() {
-    // Step-1 : create cache on each VM, this will start HTTP service in
-    // embedded mode and deploy REST APIs web app on it.
-    //
-    String url1 = (String) vm3.invoke(() -> RestAPITestBase.createCache( vm3 ));
-    restURLs.add(url1);
+  public void testOnRegionExecutionWithReplicateRegion() {
+    createCacheAndRegisterFunction();
 
-    String url2 = (String) vm0.invoke(() -> RestAPITestBase.createCache( vm0 ));
-    restURLs.add(url2);
+    vm3.invoke(() -> createPeer(DataPolicy.EMPTY));
+    vm0.invoke(() -> createPeer(DataPolicy.REPLICATE));
+    vm1.invoke(() -> createPeer(DataPolicy.REPLICATE));
+    vm2.invoke(() -> createPeer(DataPolicy.REPLICATE));
 
-    String url3 = (String) vm1.invoke(() -> RestAPITestBase.createCache( vm1 ));
-    restURLs.add(url3);
-
-    String url4 = (String) vm2.invoke(() -> RestAPITestBase.createCache( vm2 ));
-    restURLs.add(url4);
-
-    // Step-2: Register function in all VMs
-    registerSampleFunction(vm3);
-    registerSampleFunction(vm0);
-    registerSampleFunction(vm1);
-    registerSampleFunction(vm2);
-
-    // Step-3: Create and configure PR on all VMs
-    vm3.invoke(() -> createPeer( DataPolicy.EMPTY ));
-    vm0.invoke(() -> createPeer( DataPolicy.REPLICATE ));
-    vm1.invoke(() -> createPeer( DataPolicy.REPLICATE ));
-    vm2.invoke(() -> createPeer( DataPolicy.REPLICATE ));
-
-    // Step-4 : Do some puts in Replicated region on vm3
     vm3.invoke(() -> populateRRRegion());
 
-    // Step-5 : Execute function randomly (in iteration) on all available (per
-    // VM) REST end-points and verify its result
-    executeFunctionThroughRestCall(REGION_NAME);
-    int c0 = getInvocationCount(vm0);
-    int c1 = getInvocationCount(vm1);
-    int c2 = getInvocationCount(vm2);
-    int c3 = getInvocationCount(vm3);
+    CloseableHttpResponse response = executeFunctionThroughRestCall("SampleFunction", REPLICATE_REGION_NAME, null, null, null, null);
+    assertEquals(200, response.getStatusLine().getStatusCode());
+    assertNotNull(response.getEntity());
+
+    int c0 = vm0.invoke(() -> getInvocationCount());
+    int c1 = vm1.invoke(() -> getInvocationCount());
+    int c2 = vm2.invoke(() -> getInvocationCount());
+    int c3 = vm3.invoke(() -> getInvocationCount());
 
     assertEquals(1, c0 + c1 + c2 + c3);
 
@@ -530,88 +278,84 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
     restURLs.clear();
   }
 
-  public void testOnRegionExecutionWithPR() throws Exception {
-    final String rName = getUniqueName();
-
-    // Step-1 : create cache on each VM, this will start HTTP service in
-    // embedded mode and deploy REST APIs web app on it.
-    String url1 = (String) vm3.invoke(() -> RestAPITestBase.createCache( vm3 ));
-    restURLs.add(url1);
-
-    String url2 = (String) vm0.invoke(() -> RestAPITestBase.createCache( vm0 ));
-    restURLs.add(url2);
+  public void testOnRegionExecutionWithPartitionRegion() throws Exception {
+    createCacheAndRegisterFunction();
 
-    String url3 = (String) vm1.invoke(() -> RestAPITestBase.createCache( vm1 ));
-    restURLs.add(url3);
-
-    String url4 = (String) vm2.invoke(() -> RestAPITestBase.createCache( vm2 ));
-    restURLs.add(url4);
-
-    // Step-2: Register function in all VMs
-    registerSampleFunction(vm3);
-    registerSampleFunction(vm0);
-    registerSampleFunction(vm1);
-    registerSampleFunction(vm2);
-
-    // Step-3: Create and configure PR on all VMs
-    vm3.invoke(() -> createPeerWithPR());
     vm0.invoke(() -> createPeerWithPR());
     vm1.invoke(() -> createPeerWithPR());
     vm2.invoke(() -> createPeerWithPR());
+    vm3.invoke(() -> createPeerWithPR());
 
-    // Step-4: Do some puts such that data exist in each bucket
     vm3.invoke(() -> populatePRRegion());
 
-    // Step-5 : Execute function randomly (in iteration) on all available (per
-    // VM) REST end-points and verify its result
-    executeFunctionThroughRestCall(PR_REGION_NAME);
-
-    // Assert that each node has executed the function once.
-    verifyAndResetInvocationCount(vm0, 1);
-    verifyAndResetInvocationCount(vm1, 1);
-    verifyAndResetInvocationCount(vm2, 1);
-    verifyAndResetInvocationCount(vm3, 1);
+    CloseableHttpResponse response = executeFunctionThroughRestCall("SampleFunction", PR_REGION_NAME, null, null, null, null);
+    assertEquals(200, response.getStatusLine().getStatusCode());
+    assertNotNull(response.getEntity());
 
-    int c0 = getInvocationCount(vm0);
-    int c1 = getInvocationCount(vm1);
-    int c2 = getInvocationCount(vm2);
-    int c3 = getInvocationCount(vm3);
+    vm0.invoke(() -> verifyAndResetInvocationCount(1));
+    vm1.invoke(() -> verifyAndResetInvocationCount(1));
+    vm2.invoke(() -> verifyAndResetInvocationCount(1));
+    vm3.invoke(() -> verifyAndResetInvocationCount(1));
 
     restURLs.clear();
   }
 
-}
+  public void testOnRegionWithFilterExecutionWithPartitionRegion() throws Exception {
+    createCacheAndRegisterFunction();
 
-class MyFunctionException implements Function {
+    vm0.invoke(() -> createPeerWithPR());
+    vm1.invoke(() -> createPeerWithPR());
+    vm2.invoke(() -> createPeerWithPR());
+    vm3.invoke(() -> createPeerWithPR());
 
-  /**
-   * 
-   */
-  private static final long serialVersionUID = 1L;
+    vm3.invoke(() -> populatePRRegion());
 
-  @Override
-  public void execute(FunctionContext context) {
-    throw new RuntimeException("failure");
-  }
+    CloseableHttpResponse response = executeFunctionThroughRestCall("SampleFunction", PR_REGION_NAME, "key2", null, null, null);
+    assertEquals(200, response.getStatusLine().getStatusCode());
+    assertNotNull(response.getEntity());
 
-  @Override
-  public String getId() {
-    return this.getClass().getName();
-  }
+    int c0 = vm0.invoke(() -> getInvocationCount());
+    int c1 = vm1.invoke(() -> getInvocationCount());
+    int c2 = vm2.invoke(() -> getInvocationCount());
+    int c3 = vm3.invoke(() -> getInvocationCount());
 
-  @Override
-  public boolean hasResult() {
-    return true;
-  }
+    assertEquals(1, (c0 + c1 + c2 + c3));
 
-  @Override
-  public boolean isHA() {
-    return false;
+    restURLs.clear();
   }
 
-  @Override
-  public boolean optimizeForWrite() {
-    return false;
-  }
+//  public void testOnRegionWithFilterExecutionWithPartitionRegionJsonArgs() throws Exception {
+//    createCacheAndRegisterFunction();
+//
+//    vm0.invoke(() -> createPeerWithPR());
+//    vm1.invoke(() -> createPeerWithPR());
+//    vm2.invoke(() -> createPeerWithPR());
+//    vm3.invoke(() -> createPeerWithPR());
+//
+//    vm3.invoke(() -> populatePRRegion());
+//
+//    String jsonBody = "["
+//        + "{\"@type\": \"double\",\"@value\": 210}"
+//        + ",{\"@type\":\"com.gemstone.gemfire.web.rest.domain.Item\","
+//        + "\"itemNo\":\"599\",\"description\":\"Part X Free on Bumper Offer\","
+//        + "\"quantity\":\"2\","
+//        + "\"unitprice\":\"5\","
+//        + "\"totalprice\":\"10.00\"}"
+//        + "]";
+//
+//    CloseableHttpResponse response = executeFunctionThroughRestCall("SampleFunction", PR_REGION_NAME, null, jsonBody, null, null);
+//    assertEquals(200, response.getStatusLine().getStatusCode());
+//    assertNotNull(response.getEntity());
+//
+//    // Assert that only 1 node has executed the function.
+//    int c0 = vm0.invoke(() -> getInvocationCount());
+//    int c1 = vm1.invoke(() -> getInvocationCount());
+//    int c2 = vm2.invoke(() -> getInvocationCount());
+//    int c3 = vm3.invoke(() -> getInvocationCount());
+//
+//    assertEquals(1, (c0 + c1 + c2 + c3));
+//
+//    restURLs.clear();
+//  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2175524/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
index 3709475..0d1fee8 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
@@ -16,36 +16,48 @@
  */
 package com.gemstone.gemfire.rest.internal.web.controllers;
 
-import java.util.Properties;
-
 import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheClosedException;
 import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.GemFireVersion;
+import com.gemstone.gemfire.internal.lang.StringUtils;
 import com.gemstone.gemfire.management.internal.AgentUtil;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.Invoke;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.rest.internal.web.RestFunctionTemplate;
+import com.gemstone.gemfire.test.dunit.*;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.json.JSONArray;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Random;
 
 public class RestAPITestBase extends DistributedTestCase {
-  private static final long serialVersionUID = 1L;
-  public static Cache cache = null;
+  protected Cache cache = null;
+  protected List<String> restURLs = new ArrayList();
   VM vm0 = null;
   VM vm1 = null;
   VM vm2 = null;
   VM vm3 = null;
-  
+
   public RestAPITestBase(String name) {
     super(name);
   }
-  
-  
+
   @Override
   public void setUp() throws Exception {
     super.setUp();
@@ -54,7 +66,7 @@ public class RestAPITestBase extends DistributedTestCase {
     if (agentUtil.findWarLocation("geode-web-api") == null) {
       fail("unable to locate geode-web-api WAR file");
     }
-    Wait.pause(5000);
+    Wait.pause(1000);
     final Host host = Host.getHost(0);
     vm0 = host.getVM(0);
     vm1 = host.getVM(1);
@@ -62,9 +74,9 @@ public class RestAPITestBase extends DistributedTestCase {
     vm3 = host.getVM(3);
     // gradle sets a property telling us where the build is located
     final String buildDir = System.getProperty("geode.build.dir", System.getProperty("user.dir"));
-    Invoke.invokeInEveryVM(()-> System.setProperty("geode.build.dir", buildDir));
-  }  
-  
+    Invoke.invokeInEveryVM(() -> System.setProperty("geode.build.dir", buildDir));
+  }
+
   /**
    * close the clients and teh servers
    */
@@ -78,56 +90,122 @@ public class RestAPITestBase extends DistributedTestCase {
 
   /**
    * close the cache
-   * 
    */
-  public static void closeCache() {
+  private void closeCache() {
     if (cache != null && !cache.isClosed()) {
       cache.close();
       cache.getDistributedSystem().disconnect();
     }
   }
-  
-  protected static String createCache(VM currentVM) {
-    
-    RestAPITestBase test = new RestAPITestBase(getTestMethodName());
-    
-    final String hostName = currentVM.getHost().getHostName();
-    final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
-    
-    Properties props = new Properties();
-    
-    props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
-    props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, hostName);
-    props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME,String.valueOf(serverPort));
-    
 
-    InternalDistributedSystem ds = test.getSystem(props);
-    cache = CacheFactory.create(ds);
-    return "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
-    
-  }
-  
-  public static String createCacheWithGroups (VM vm, final String groups, final String regionName ) {
+  public String createCacheWithGroups(VM vm, final String groups) {
     RestAPITestBase test = new RestAPITestBase(getTestMethodName());
-    
-    final String hostName = vm.getHost().getHostName(); 
+
+    final String hostName = vm.getHost().getHostName();
     final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
-    
+
     Properties props = new Properties();
-    
-    if(groups != null) {
+
+    if (groups != null) {
       props.put("groups", groups);
     }
-    
+
     props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
     props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, hostName);
     props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(serverPort));
-    
+
     InternalDistributedSystem ds = test.getSystem(props);
     cache = CacheFactory.create(ds);
-    
-    String restEndPoint =  "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
-    return restEndPoint; 
+
+    String restEndPoint = "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
+    return restEndPoint;
+  }
+
+  protected int getInvocationCount() {
+    RestFunctionTemplate function = (RestFunctionTemplate) FunctionService.getFunction(getFunctionID());
+    return function.invocationCount;
+  }
+
+  protected CloseableHttpResponse executeFunctionThroughRestCall(String function, String regionName, String filter, String jsonBody, String groups,
+      String members) {
+    LogWriterUtils.getLogWriter().info("Entering executeFunctionThroughRestCall");
+    try {
+      CloseableHttpClient httpclient = HttpClients.createDefault();
+      Random randomGenerator = new Random();
+      int restURLIndex = randomGenerator.nextInt(restURLs.size());
+
+      HttpPost post = createHTTPPost(function, regionName, filter, restURLIndex, groups, members, jsonBody);
+
+      LogWriterUtils.getLogWriter().info("Request: POST " + post.toString());
+      return httpclient.execute(post);
+    } catch (Exception e) {
+      throw new RuntimeException("unexpected exception", e);
+    }
   }
-  
+
+  private HttpPost createHTTPPost(String function, String regionName, String filter, int restUrlIndex, String groups, String members, String jsonBody) {
+    StringBuilder restURLBuilder = new StringBuilder();
+    restURLBuilder.append(restURLs.get(restUrlIndex) + "/functions/" + function+"?");
+    if (regionName != null && !regionName.isEmpty()) {
+      restURLBuilder.append("onRegion=" + regionName);
+    }
+    else if (groups != null && !groups.isEmpty()) {
+      restURLBuilder.append("onGroups=" + groups);
+    }
+    else if (members != null && !members.isEmpty()) {
+      restURLBuilder.append("onMembers=" + members);
+    }
+    if (filter != null && !filter.isEmpty()) {
+      restURLBuilder.append("&filter=" + filter);
+    }
+    String restString = restURLBuilder.toString();
+    HttpPost post = new HttpPost(restString);
+    post.addHeader("Content-Type", "application/json");
+    post.addHeader("Accept", "application/json");
+    if (jsonBody != null && !StringUtils.isEmpty(jsonBody)) {
+      StringEntity jsonStringEntity = new StringEntity(jsonBody, ContentType.DEFAULT_TEXT);
+      post.setEntity(jsonStringEntity);
+    }
+    return post;
+  }
+
+  protected String getFunctionID() {
+    throw new RuntimeException("This method should be overridden");
+  }
+
+  protected void assertHttpResponse(CloseableHttpResponse response, int httpCode, int expectedServerResponses) {
+    assertEquals(httpCode, response.getStatusLine().getStatusCode());
+
+    //verify response has body flag, expected is true.
+    assertNotNull(response.getEntity());
+    try {
+      String httpResponseString = processHttpResponse(response);
+      response.close();
+      LogWriterUtils.getLogWriter().info("Response : " + httpResponseString);
+      //verify function execution result
+      JSONArray resultArray = new JSONArray(httpResponseString);
+      assertEquals(resultArray.length(), expectedServerResponses);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  private String processHttpResponse(HttpResponse response) {
+    try {
+      HttpEntity entity = response.getEntity();
+      InputStream content = entity.getContent();
+      BufferedReader reader = new BufferedReader(new InputStreamReader(
+          content));
+      String line;
+      StringBuffer sb = new StringBuffer();
+      while ((line = reader.readLine()) != null) {
+        sb.append(line);
+      }
+      return sb.toString();
+    } catch (IOException e) {
+      LogWriterUtils.getLogWriter().error("Error in processing Http Response", e);
+    }
+    return "";
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2175524/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
index 1ae3810..5acaccb 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
@@ -16,62 +16,119 @@
  */
 package com.gemstone.gemfire.rest.internal.web.controllers;
 
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.json.JSONArray;
-
-import com.gemstone.gemfire.cache.execute.Function;
 import com.gemstone.gemfire.cache.execute.FunctionContext;
 import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.IgnoredException;
+import com.gemstone.gemfire.rest.internal.web.RestFunctionTemplate;
 import com.gemstone.gemfire.test.dunit.LogWriterUtils;
-import com.gemstone.gemfire.test.dunit.SerializableCallable;
-import com.gemstone.gemfire.test.dunit.VM;
+import org.apache.http.client.methods.CloseableHttpResponse;
+
+import java.util.ArrayList;
+import java.util.Collections;
 
 public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase {
 
   public RestAPIsOnGroupsFunctionExecutionDUnitTest(String name) {
     super(name);
   }
-  
+
   public void setUp() throws Exception {
     super.setUp();
-    final Host host = Host.getHost(0);
   }
-  
-  private void registerFunction(VM vm) {
-    vm.invoke(new SerializableCallable() {
-      private static final long serialVersionUID = 1L;
-      
-      @Override
-      public Object call() throws Exception {
-        FunctionService.registerFunction(new OnGroupsFunction());
-        return null;
-      }
-    });
+
+  @Override
+  protected String getFunctionID() {
+    return OnGroupsFunction.Id;
+  }
+
+  private void resetInvocationCount() {
+    OnGroupsFunction f = (OnGroupsFunction) FunctionService.getFunction(OnGroupsFunction.Id);
+    f.invocationCount = 0;
+  }
+
+  public void testonGroupsExecutionOnAllMembers() {
+    setupCacheWithGroupsAndFunction();
+
+    for (int i = 0; i < 10; i++) {
+      CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "g0,g1", null);
+      assertHttpResponse(response, 200, 3);
+    }
+
+    int c0 = vm0.invoke(() -> getInvocationCount());
+    int c1 = vm1.invoke(() -> getInvocationCount());
+    int c2 = vm2.invoke(() -> getInvocationCount());
+
+    assertEquals(30, (c0 + c1 + c2));
+
+    restURLs.clear();
+  }
+
+  private void setupCacheWithGroupsAndFunction() {
+    restURLs.add(vm0.invoke(() -> createCacheWithGroups(vm0, "g0,gm")));
+    restURLs.add(vm1.invoke(() -> createCacheWithGroups(vm1, "g1")));
+    restURLs.add(vm2.invoke(() -> createCacheWithGroups(vm2, "g0,g1")));
+
+    vm0.invoke(() -> FunctionService.registerFunction(new OnGroupsFunction()));
+    vm1.invoke(() -> FunctionService.registerFunction(new OnGroupsFunction()));
+    vm2.invoke(() -> FunctionService.registerFunction(new OnGroupsFunction()));
   }
-  
-  static class OnGroupsFunction implements Function {
-    private static final long serialVersionUID = -1032915440862585532L;
+
+  public void testonGroupsExecutionOnAllMembersWithFilter() {
+    setupCacheWithGroupsAndFunction();
+
+    //Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
+    for (int i = 0; i < 10; i++) {
+      CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, "someKey", null, "g1", null);
+      assertHttpResponse(response, 500, 0);
+    }
+
+    int c0 = vm0.invoke(() -> getInvocationCount());
+    int c1 = vm1.invoke(() -> getInvocationCount());
+    int c2 = vm2.invoke(() -> getInvocationCount());
+
+    assertEquals(0, (c0 + c1 + c2));
+    restURLs.clear();
+  }
+
+  public void testBasicP2PFunctionSelectedGroup() {
+    setupCacheWithGroupsAndFunction();
+
+    //Step-3 : Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
+    for (int i = 0; i < 5; i++) {
+      CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "no%20such%20group", null);
+      assertHttpResponse(response, 500, 0);
+    }
+    int c0 = vm0.invoke(() -> getInvocationCount());
+    int c1 = vm1.invoke(() -> getInvocationCount());
+    int c2 = vm2.invoke(() -> getInvocationCount());
+
+    assertEquals(0, (c0 + c1 + c2));
+
+    for (int i = 0; i < 5; i++) {
+
+      CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "gm", null);
+      assertHttpResponse(response, 200, 1);
+    }
+
+    c0 = vm0.invoke(() -> getInvocationCount());
+    c1 = vm1.invoke(() -> getInvocationCount());
+    c2 = vm2.invoke(() -> getInvocationCount());
+
+    assertEquals(5, (c0 + c1 + c2));
+
+    vm0.invoke(() -> resetInvocationCount());
+    vm1.invoke(() -> resetInvocationCount());
+    vm2.invoke(() -> resetInvocationCount());
+
+    restURLs.clear();
+  }
+
+  private class OnGroupsFunction extends RestFunctionTemplate {
     public static final String Id = "OnGroupsFunction";
-    public static int invocationCount;
 
     @Override
     public void execute(FunctionContext context) {
-      LogWriterUtils.getLogWriter().fine("SWAP:1:executing OnGroupsFunction:"+invocationCount);
+      LogWriterUtils.getLogWriter().fine("SWAP:1:executing OnGroupsFunction:" + invocationCount);
       InternalDistributedSystem ds = InternalDistributedSystem.getConnectedInstance();
       invocationCount++;
       ArrayList<String> l = (ArrayList<String>) context.getArguments();
@@ -101,206 +158,5 @@ public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase
       return false;
     }
   }
-  
-  
-  public static void executeFunctionThroughRestCall(List<String> restURLs) {
-    Random randomGenerator = new Random();
-    int index = randomGenerator.nextInt(restURLs.size());
-    
-    try {
-      
-      CloseableHttpClient httpclient = HttpClients.createDefault();
-      CloseableHttpResponse response = null;
-      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/OnGroupsFunction?onGroups=g0,g1");
-      post.addHeader("Content-Type", "application/json");
-      post.addHeader("Accept", "application/json");
-      LogWriterUtils.getLogWriter().info("Request POST : " + post.toString());
-      response = httpclient.execute(post);
-      
-      HttpEntity entity = response.getEntity();
-      InputStream content = entity.getContent();
-      BufferedReader reader = new BufferedReader(new InputStreamReader(
-          content));
-      String line;
-      StringBuffer sb = new StringBuffer();
-      while ((line = reader.readLine()) != null) {
-        sb.append(line);
-      }      
-      LogWriterUtils.getLogWriter().info("Response : " + sb.toString());
-    
-      //verify response status code. expected status code is 200 OK.
-      assertEquals(response.getStatusLine().getStatusCode(), 200);
-      
-      
-      //verify response hasbody flag, expected is true.
-      assertNotNull(response.getEntity());
-      
-      
-      response.close();
-      
-      //verify function execution result
-      JSONArray resultArray = new JSONArray(sb.toString());
-      assertEquals(resultArray.length(), 3);
-      
-    } catch (Exception e) {
-      throw new RuntimeException("unexpected exception", e);
-    }
-    
-  }
-  
-  public static void executeFunctionOnMemberThroughRestCall(List<String> restURLs) {
-    Random randomGenerator = new Random();
-    int index = randomGenerator.nextInt(restURLs.size());
-    
-    //Testcase-1: Executing function on non-existing group. 
-    final IgnoredException ex = IgnoredException.addIgnoredException("com.gemstone.gemfire.cache.execute.FunctionException");
-    try {
-      
-      CloseableHttpClient httpclient = HttpClients.createDefault();
-      CloseableHttpResponse response = null;
-      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/OnGroupsFunction?onGroups=no%20such%20group");
-      post.addHeader("Content-Type", "application/json");
-      post.addHeader("Accept", "application/json");
-      response = httpclient.execute(post);
-      
-      if ( response.getStatusLine().getStatusCode() == 200 ) {
-        fail("FunctionException expected : no member(s) are found belonging to the provided group(s)");
-      }
-    } catch (Exception e) {
-      throw new RuntimeException("unexpected exception", e);
-      
-    } finally {
-      ex.remove();
-    }
-    
-    //Testcase-2: Executing function on group with args.
-    
-    final String FUNCTION_ARGS1 =  "{"
-        +        "\"@type\": \"string\","
-        +        "\"@value\": \"gm\""
-        +    "}";
-    
-    try {
-     
-      CloseableHttpClient httpclient = HttpClients.createDefault();
-      CloseableHttpResponse response = null;
-      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/OnGroupsFunction?onGroups=gm");
-      post.addHeader("Content-Type", "application/json");
-      post.addHeader("Accept", "application/json");
-      response = httpclient.execute(post);
-      
-      //verify response status code
-      assertEquals(response.getStatusLine().getStatusCode(), 200);
-      
-      //verify response hasbody flag
-      assertNotNull(response.getEntity());
-      
-      HttpEntity entity = response.getEntity();
-      InputStream content = entity.getContent();
-      BufferedReader reader = new BufferedReader(new InputStreamReader(
-          content));
-      String line;
-      StringBuffer sb = new StringBuffer();
-      while ((line = reader.readLine()) != null) {
-        sb.append(line);
-      }
-      response.close();
-      
-      //verify function execution result
-      JSONArray resultArray = new JSONArray(sb.toString());
-      assertEquals(resultArray.length(), 1);
-      
-    } catch (Exception e) {
-      throw new RuntimeException("unexpected exception", e);
-    }   
-  }
-  
-  private void verifyAndResetInvocationCount(VM vm, final int count) {
-    vm.invoke(new SerializableCallable() {
-      @Override
-      public Object call() throws Exception {
-        OnGroupsFunction f = (OnGroupsFunction) FunctionService.getFunction(OnGroupsFunction.Id);
-        assertEquals(count, f.invocationCount);
-        // assert succeeded, reset count
-        f.invocationCount = 0;
-        return null;
-      }
-    });
-  }
-  
-  private void resetInvocationCount(VM vm) {
-    vm.invoke(new SerializableCallable() {
-      @Override
-      public Object call() throws Exception {
-        OnGroupsFunction f = (OnGroupsFunction) FunctionService.getFunction(OnGroupsFunction.Id);
-        f.invocationCount = 0;
-        return null;
-      }
-    });
-  }
-  
-  public void testonGroupsExecutionOnAllMembers() {
-  
-    List<String> restURLs = new ArrayList<String>(); 
-    //Step-1 : create cache on each VM, this will start HTTP service in embedded mode and deploy REST APIs web app on it.
-    //         Create and configure Region on all VMs. Add Rest end-point into the restURLs list.
-    
-    String url1 = (String)vm0.invoke(() -> RestAPITestBase.createCacheWithGroups(vm0, "g0,gm", "TEST_REGION"));
-    restURLs.add(url1);
-    
-    String url2 = (String)vm1.invoke(() -> RestAPITestBase.createCacheWithGroups(vm1, "g1", "TEST_REGION" ));
-    restURLs.add(url2);
-    
-    String url3 = (String)vm2.invoke(() -> RestAPITestBase.createCacheWithGroups(vm2, "g0,g1", "TEST_REGION"));
-    restURLs.add(url3);
-    
-    //Step-2: Register function in all VMs
-    registerFunction(vm0);
-    registerFunction(vm1);
-    registerFunction(vm2);
-    
-    //Step-3 : Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
-    for (int i=0; i< 10; i++)
-      executeFunctionThroughRestCall(restURLs);
-    
-    //Verify that each node belonging to specified group has run the function
-    verifyAndResetInvocationCount(vm0, 10);
-    verifyAndResetInvocationCount(vm1, 10);
-    verifyAndResetInvocationCount(vm2, 10);
-   
-    restURLs.clear();
-  }
-  
-  
-  public void testBasicP2PFunctionSelectedGroup() {
-  
-    List<String> restURLs = new ArrayList<String>(); 
-    
-    //Step-1 : create cache on each VM, this will start HTTP service in embedded mode and deploy REST APIs web app on it.
-    //         Create and configure Region on all VMs. Add Rest end-point into the restURLs list.
-    String url1 = (String)vm0.invoke(() -> RestAPITestBase.createCacheWithGroups(vm0, "g0,gm", "null" ));
-    restURLs.add(url1);
-    
-    String url2 = (String)vm1.invoke(() -> RestAPITestBase.createCacheWithGroups(vm1, "g1", "null"  ));
-    restURLs.add(url2);
-    
-    String url3 = (String)vm2.invoke(() -> RestAPITestBase.createCacheWithGroups(vm2, "g0,g1", "null" ));
-    restURLs.add(url3);
-    
-    //Step-2: Register function in all VMs
-    registerFunction(vm0);
-    registerFunction(vm1);
-    registerFunction(vm2);
-    
-    //Step-3 : Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
-    for (int i=0; i< 5; i++)
-      executeFunctionOnMemberThroughRestCall(restURLs);
-    
-    resetInvocationCount(vm0);
-    resetInvocationCount(vm1);
-    resetInvocationCount(vm2);
-    
-    restURLs.clear();
-  }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2175524/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
index adb2b55..ac922ad 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
@@ -16,82 +16,49 @@
  */
 package com.gemstone.gemfire.rest.internal.web.controllers;
 
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.Random;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.json.JSONArray;
-
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.CacheClosedException;
 import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.execute.Function;
 import com.gemstone.gemfire.cache.execute.FunctionContext;
 import com.gemstone.gemfire.cache.execute.FunctionService;
-import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.test.dunit.Assert;
-import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.rest.internal.web.RestFunctionTemplate;
 import com.gemstone.gemfire.test.dunit.LogWriterUtils;
-import com.gemstone.gemfire.test.dunit.SerializableCallable;
 import com.gemstone.gemfire.test.dunit.VM;
+import org.apache.http.client.methods.CloseableHttpResponse;
+
+import java.util.Properties;
 
 /**
- * 
  * @author Nilkanth Patel
  */
 
-public class RestAPIsOnMembersFunctionExecutionDUnitTest extends CacheTestCase { 
-  
+public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase {
+
   private static final long serialVersionUID = 1L;
-  
-  VM member1 = null;
-  VM member2 = null;
-  VM member3 = null;
-  VM member4 = null;
-  
-  static InternalDistributedSystem ds = null;
 
   public RestAPIsOnMembersFunctionExecutionDUnitTest(String name) {
     super(name);
   }
-  
+
   @Override
   public void setUp() throws Exception {
     super.setUp();
-    Host host = Host.getHost(0);
-    member1 = host.getVM(0);
-    member2 = host.getVM(1);
-    member3 = host.getVM(2);
-    member4 = host.getVM(3);
   }
-  
-  static class OnMembersFunction implements Function {
-    private static final long serialVersionUID = -1032915440862585532L;
+
+  private class OnMembersFunction extends RestFunctionTemplate {
     public static final String Id = "OnMembersFunction";
-    public static int invocationCount;
 
     @Override
     public void execute(FunctionContext context) {
-      
-      LogWriterUtils.getLogWriter().fine("SWAP:1:executing OnMembersFunction:"+invocationCount);
-      InternalDistributedSystem ds = InternalDistributedSystem.getConnectedInstance();
+
+      LogWriterUtils.getLogWriter().fine("SWAP:1:executing OnMembersFunction:" + invocationCount);
       invocationCount++;
-      
+
       context.getResultSender().lastResult(Boolean.TRUE);
     }
-    
+
     @Override
     public String getId() {
       return Id;
@@ -112,217 +79,98 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends CacheTestCase {
       return false;
     }
   }
-  
-  private void verifyAndResetInvocationCount(VM vm, final int count) {
-    vm.invoke(new SerializableCallable() {
-      @Override
-      public Object call() throws Exception {
-        OnMembersFunction f = (OnMembersFunction) FunctionService.getFunction(OnMembersFunction.Id);
-        assertEquals(count, f.invocationCount);
-        // assert succeeded, reset count
-        f.invocationCount = 0;
-        return null;
-      }
-    });
-  }
-  
-  private InternalDistributedSystem createSystem(Properties props){
-    try {
-      ds = getSystem(props);
-      assertNotNull(ds);
-      FunctionService.registerFunction(new OnMembersFunction());
-      
-    }
-    catch (Exception e) {
-      Assert.fail("Failed while creating the Distribued System", e);
-    }
-    return ds;
-  }
-  
-  public static String createCacheAndRegisterFunction(VM vm, String memberName) {
-    final String hostName = vm.getHost().getHostName(); 
+
+  private String createCacheAndRegisterFunction(VM vm, String memberName) {
+    final String hostName = vm.getHost().getHostName();
     final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
-    
+
     Properties props = new Properties();
     props.setProperty(DistributionConfig.NAME_NAME, memberName);
     props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
     props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, hostName);
     props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(serverPort));
-    
+
     Cache c = null;
     try {
-      c = CacheFactory.getInstance( new RestAPIsOnMembersFunctionExecutionDUnitTest("temp").getSystem(props));
+      c = CacheFactory.getInstance(new RestAPIsOnMembersFunctionExecutionDUnitTest("temp").getSystem(props));
       c.close();
     } catch (CacheClosedException cce) {
     }
-    
+
     c = CacheFactory.create(new RestAPIsOnMembersFunctionExecutionDUnitTest("temp").getSystem(props));
     FunctionService.registerFunction(new OnMembersFunction());
-    
-    String restEndPoint =  "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
+
+    String restEndPoint = "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
     return restEndPoint;
-   
+
   }
-  
-  public static void executeFunctionOnAllMembersThroughRestCall(List<String> restURLs) {
-    Random randomGenerator = new Random();
-    int index = randomGenerator.nextInt(restURLs.size());
-    
-    //Testcase: onMembers Function execution with No groups specified
-    try {
-      
-      CloseableHttpClient httpclient = HttpClients.createDefault();
-      CloseableHttpResponse response = null;
-      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/OnMembersFunction");
-      post.addHeader("Content-Type", "application/json");
-      post.addHeader("Accept", "application/json");
-      
-      LogWriterUtils.getLogWriter().info("Request POST : " + post.toString());
-      
-      response = httpclient.execute(post);
-      
-      HttpEntity entity = response.getEntity();
-      InputStream content = entity.getContent();
-      BufferedReader reader = new BufferedReader(new InputStreamReader(
-          content));
-      String line;
-      StringBuffer sb = new StringBuffer();
-      while ((line = reader.readLine()) != null) {
-        sb.append(line);
-      }
-      LogWriterUtils.getLogWriter().info("Response : " + sb.toString());
-            
-      
-      //verify response status code
-      assertEquals(200, response.getStatusLine().getStatusCode());
-      
-      //verify response hasbody flag
-      assertNotNull(response.getEntity());
-      
-      
-      response.close();      
-     
-      JSONArray resultArray = new JSONArray(sb.toString());
-      assertEquals(resultArray.length(), 4);
-      
-      //fail("Expected exception while executing function onMembers without any members ");
-      
-    } catch (Exception e) {
-      throw new RuntimeException("unexpected exception", e);
-    }
+
+  @Override
+  protected String getFunctionID() {
+    return OnMembersFunction.Id;
   }
- 
-  public static void executeFunctionOnGivenMembersThroughRestCall(List<String> restURLs) {
-    Random randomGenerator = new Random();
-    int index = randomGenerator.nextInt(restURLs.size());
-    
-    //Testcase: onMembers Function execution with valid groups
-    try {
-      
-      CloseableHttpClient httpclient = HttpClients.createDefault();
-      CloseableHttpResponse response = null;
-      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/OnMembersFunction?onMembers=m1,m2,m3");
-      post.addHeader("Content-Type", "application/json");
-      post.addHeader("Accept", "application/json");
-      response = httpclient.execute(post);
-    
-      //verify response status code. expected status code is 200 OK.
-      assertEquals(response.getStatusLine().getStatusCode(), 200);
-      
-      //verify response hasbody flag, expected is true.
-      assertNotNull(response.getEntity());
-      
-      
-      HttpEntity entity = response.getEntity();
-      InputStream content = entity.getContent();
-      BufferedReader reader = new BufferedReader(new InputStreamReader(
-          content));
-      String line;
-      StringBuffer sb = new StringBuffer();
-      while ((line = reader.readLine()) != null) {
-        sb.append(line);
-      }
-      response.close();
-      
-      //verify function execution result
-      JSONArray resultArray = new JSONArray(sb.toString());
-      assertEquals(resultArray.length(), 3);
-      
-    } catch (Exception e) {
-      throw new RuntimeException("unexpected exception", e);
+
+  public void testFunctionExecutionOnAllMembers() {
+    restURLs.add(vm0.invoke(() -> createCacheAndRegisterFunction(vm0, "m1")));
+    restURLs.add(vm1.invoke(() -> createCacheAndRegisterFunction(vm1, "m2")));
+    restURLs.add(vm2.invoke(() -> createCacheAndRegisterFunction(vm2, "m3")));
+    restURLs.add(vm3.invoke(() -> createCacheAndRegisterFunction(vm3, "m4")));
+
+    for (int i = 0; i < 10; i++) {
+      CloseableHttpResponse response = executeFunctionThroughRestCall("OnMembersFunction",null,null,null,null,null);
+      assertHttpResponse(response, 200, 4);
     }
+
+    int c0 = vm0.invoke(() -> getInvocationCount());
+    int c1 = vm1.invoke(() -> getInvocationCount());
+    int c2 = vm2.invoke(() -> getInvocationCount());
+    int c3 = vm3.invoke(() -> getInvocationCount());
+
+    assertEquals(40, (c0 + c1 + c2 + c3));
+
+    restURLs.clear();
   }
-  
-  public void testFunctionExecutionOnAllMembers()  {
-    
-    List<String> restURLs = new ArrayList<String>(); 
-    
-    //Step-1 : create cache on each VM, this will start HTTP service in embedded mode and deploy REST APIs web app on it.
-    //         Connect to DS and Register function. Add Rest end-point into the restURLs list.
-    
-    String url1 = (String)member1.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member1, "m1"));
-    restURLs.add(url1);
-    
-    String url2 = (String)member2.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member2, "m2"));
-    restURLs.add(url2);
-    
-    String url3 = (String)member3.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member3, "m3"));
-    restURLs.add(url3);
-    
-    String url4 = (String)member4.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member4, "m4"));
-    restURLs.add(url4);
-    
-    //default case, execute function on all members, register the function in controller VM
-    //FunctionService.registerFunction(new OnMembersFunction());
-    
-    //Step-2 : Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
-    for (int i=0; i< 10; i++) {
-      executeFunctionOnAllMembersThroughRestCall(restURLs);
+
+  public void testFunctionExecutionEOnSelectedMembers() {
+    restURLs.add((String) vm0.invoke(() -> createCacheAndRegisterFunction(vm0, "m1")));
+    restURLs.add((String) vm1.invoke(() -> createCacheAndRegisterFunction(vm1, "m2")));
+    restURLs.add((String) vm2.invoke(() -> createCacheAndRegisterFunction(vm2, "m3")));
+    restURLs.add((String) vm3.invoke(() -> createCacheAndRegisterFunction(vm3, "m4")));
+
+    for (int i = 0; i < 10; i++) {
+      CloseableHttpResponse response = executeFunctionThroughRestCall("OnMembersFunction",null,null,null,null,"m1,m2,m3");
+      assertHttpResponse(response, 200, 3);
     }
-    
-    //Verify that each node (m1, m2, m3) has run the function
-    verifyAndResetInvocationCount(member1, 10);
-    verifyAndResetInvocationCount(member2, 10);
-    verifyAndResetInvocationCount(member3, 10);
-    verifyAndResetInvocationCount(member4, 10);
+
+    int c0 = vm0.invoke(() -> getInvocationCount());
+    int c1 = vm1.invoke(() -> getInvocationCount());
+    int c2 = vm2.invoke(() -> getInvocationCount());
+    int c3 = vm3.invoke(() -> getInvocationCount());
+
+    assertEquals(30, (c0 + c1 + c2 + c3));
 
     restURLs.clear();
   }
-  
-  public void testFunctionExecutionEOnSelectedMembers()  {
-    
-    List<String> restURLs = new ArrayList<String>(); 
-    
-    //Step-1 : create cache on each VM, this will start HTTP service in embedded mode and deploy REST APIs web app on it.
-    //         Connect to DS and Register function. Add Rest end-point into the restURLs list.
-    
-    String url1 = (String)member1.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member1, "m1"));
-    restURLs.add(url1);
-    
-    String url2 = (String)member2.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member2, "m2"));
-    restURLs.add(url2);
-    
-    String url3 = (String)member3.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member3, "m3"));
-    restURLs.add(url3);
-    
-    String url4 = (String)member4.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member4, "m4"));
-    restURLs.add(url4);
-    
-    //default case, execute function on all members, register the function in controller VM
-    //FunctionService.registerFunction(new OnMembersFunction());
-    
-    //Step-2 : Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
-    for (int i=0; i< 10; i++) {
-      executeFunctionOnGivenMembersThroughRestCall(restURLs);
+
+  public void testFunctionExecutionOnMembersWithFilter() {
+    restURLs.add((String) vm0.invoke(() -> createCacheAndRegisterFunction(vm0, "m1")));
+    restURLs.add((String) vm1.invoke(() -> createCacheAndRegisterFunction(vm1, "m2")));
+    restURLs.add((String) vm2.invoke(() -> createCacheAndRegisterFunction(vm2, "m3")));
+    restURLs.add((String) vm3.invoke(() -> createCacheAndRegisterFunction(vm3, "m4")));
+
+    for (int i = 0; i < 10; i++) {
+      CloseableHttpResponse response = executeFunctionThroughRestCall("OnMembersFunction",null,"key2",null,null,"m1,m2,m3");
+      assertHttpResponse(response, 500, 0);
     }
-    
-    //Verify that each node (m1, m2, m3) has run the function
-    verifyAndResetInvocationCount(member1, 10);
-    verifyAndResetInvocationCount(member2, 10);
-    verifyAndResetInvocationCount(member3, 10);
-    
+
+    int c0 = vm0.invoke(() -> getInvocationCount());
+    int c1 = vm1.invoke(() -> getInvocationCount());
+    int c2 = vm2.invoke(() -> getInvocationCount());
+    int c3 = vm3.invoke(() -> getInvocationCount());
+
+    assertEquals(0, (c0 + c1 + c2 + c3));
 
     restURLs.clear();
   }
-  
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2175524/geode-web-api/src/main/java/com/gemstone/gemfire/rest/internal/web/controllers/FunctionAccessController.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/com/gemstone/gemfire/rest/internal/web/controllers/FunctionAccessController.java b/geode-web-api/src/main/java/com/gemstone/gemfire/rest/internal/web/controllers/FunctionAccessController.java
index 2c37c7f..929b70a 100644
--- a/geode-web-api/src/main/java/com/gemstone/gemfire/rest/internal/web/controllers/FunctionAccessController.java
+++ b/geode-web-api/src/main/java/com/gemstone/gemfire/rest/internal/web/controllers/FunctionAccessController.java
@@ -17,44 +17,32 @@
 
 package com.gemstone.gemfire.rest.internal.web.controllers;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.logging.log4j.Logger;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Controller;
-import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
 import com.gemstone.gemfire.cache.LowMemoryException;
-import com.gemstone.gemfire.cache.execute.Execution;
-import com.gemstone.gemfire.cache.execute.Function;
-import com.gemstone.gemfire.cache.execute.FunctionException;
-import com.gemstone.gemfire.cache.execute.FunctionService;
-import com.gemstone.gemfire.cache.execute.ResultCollector;
+import com.gemstone.gemfire.cache.execute.*;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.rest.internal.web.exception.GemfireRestException;
 import com.gemstone.gemfire.rest.internal.web.util.ArrayUtils;
 import com.gemstone.gemfire.rest.internal.web.util.JSONUtils;
-import org.json.JSONException;
 import com.wordnik.swagger.annotations.Api;
 import com.wordnik.swagger.annotations.ApiOperation;
 import com.wordnik.swagger.annotations.ApiResponse;
 import com.wordnik.swagger.annotations.ApiResponses;
+import org.apache.logging.log4j.Logger;
+import org.json.JSONException;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
 
 /**
  * The FunctionsController class serving REST Requests related to the function execution
- * <p/>
+ * <p>
+ *
  * @author Nilkanth Patel, john blum
  * @see org.springframework.stereotype.Controller
  * @since 8.0
@@ -72,172 +60,181 @@ public class FunctionAccessController extends AbstractBaseController {
 
   /**
    * Gets the version of the REST API implemented by this @Controller.
-   * <p/>
+   * <p>
+   *
    * @return a String indicating the REST API version.
    */
   @Override
   protected String getRestApiVersion() {
     return REST_API_VERSION;
   }
-  
+
   /**
    * list all registered functions in Gemfire data node
+   *
    * @return result as a JSON document.
    */
-  @RequestMapping(method = RequestMethod.GET,  produces = { MediaType.APPLICATION_JSON_VALUE })
+  @RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
   @ApiOperation(
-    value = "list all functions",
-    notes = "list all functions available in the GemFire cluster",
-    response  = void.class
+      value = "list all functions",
+      notes = "list all functions available in the GemFire cluster",
+      response = void.class
   )
-  @ApiResponses( {
-    @ApiResponse( code = 200, message = "OK." ),
-    @ApiResponse( code = 500, message = "GemFire throws an error or exception." )   
-  } )
+  @ApiResponses({
+      @ApiResponse(code = 200, message = "OK."),
+      @ApiResponse(code = 500, message = "GemFire throws an error or exception.")
+  })
   @ResponseBody
   @ResponseStatus(HttpStatus.OK)
   public ResponseEntity<?> list() {
-    
-    if(logger.isDebugEnabled()){
+
+    if (logger.isDebugEnabled()) {
       logger.debug("Listing all registered Functions in GemFire...");
     }
-    
+
     final Map<String, Function> registeredFunctions = FunctionService.getRegisteredFunctions();
-    String listFunctionsAsJson =  JSONUtils.formulateJsonForListFunctionsCall(registeredFunctions.keySet());
-    final HttpHeaders headers = new HttpHeaders();  
+    String listFunctionsAsJson = JSONUtils.formulateJsonForListFunctionsCall(registeredFunctions.keySet());
+    final HttpHeaders headers = new HttpHeaders();
     headers.setLocation(toUri("functions"));
     return new ResponseEntity<String>(listFunctionsAsJson, headers, HttpStatus.OK);
-  } 
-  
+  }
+
   /**
    * Execute a function on Gemfire data node using REST API call.
-   * Arguments to the function are passed as JSON string in the request body. 
+   * Arguments to the function are passed as JSON string in the request body.
+   *
    * @param functionId represents function to be executed
-   * @param region list of regions on which function to be executed.
-   * @param members list of nodes on which function to be executed.
-   * @param groups list of groups on which function to be executed. 
+   * @param region     list of regions on which function to be executed.
+   * @param members    list of nodes on which function to be executed.
+   * @param groups     list of groups on which function to be executed.
+   * @param filter     list of keys which the function will use to determine on which node to execute the function.
    * @param argsInBody function argument as a JSON document
    * @return result as a JSON document
    */
   @RequestMapping(method = RequestMethod.POST, value = "/{functionId}", produces = { MediaType.APPLICATION_JSON_VALUE })
   @ApiOperation(
-    value = "execute function",
-    notes = "Execute function with arguments on regions, members, or group(s). By default function will be executed on all nodes if none of (onRegion, onMembers, onGroups) specified",
-    response  = void.class
+      value = "execute function",
+      notes = "Execute function with arguments on regions, members, or group(s). By default function will be executed on all nodes if none of (onRegion, onMembers, onGroups) specified",
+      response = void.class
   )
-  @ApiResponses( {
-    @ApiResponse( code = 200, message = "OK." ),
-    @ApiResponse( code = 500, message = "if GemFire throws an error or exception" ),
-    @ApiResponse( code = 400, message = "if Function arguments specified as JSON document in the request body is invalid" )
-  } )
+  @ApiResponses({
+      @ApiResponse(code = 200, message = "OK."),
+      @ApiResponse(code = 500, message = "if GemFire throws an error or exception"),
+      @ApiResponse(code = 400, message = "if Function arguments specified as JSON document in the request body is invalid")
+  })
   @ResponseBody
   @ResponseStatus(HttpStatus.OK)
   public ResponseEntity<String> execute(@PathVariable("functionId") String functionId,
-                          @RequestParam(value = "onRegion", required = false ) String region,
-                          @RequestParam(value = "onMembers", required = false ) final String[] members,
-                          @RequestParam(value = "onGroups", required = false) final String[] groups,
-                          @RequestBody(required = false) final String argsInBody
-                          )
-  {
+      @RequestParam(value = "onRegion", required = false) String region,
+      @RequestParam(value = "onMembers", required = false) final String[] members,
+      @RequestParam(value = "onGroups", required = false) final String[] groups,
+      @RequestParam(value = "filter", required = false) final String[] filter,
+      @RequestBody(required = false) final String argsInBody
+  ) {
     Execution function = null;
     functionId = decode(functionId);
-    
+
     if (StringUtils.hasText(region)) {
-      if(logger.isDebugEnabled()){
+      if (logger.isDebugEnabled()) {
         logger.debug("Executing Function ({}) with arguments ({}) on Region ({})...", functionId,
             ArrayUtils.toString(argsInBody), region);
       }
-      
+
       region = decode(region);
       try {
         function = FunctionService.onRegion(getRegion(region));
-      } catch(FunctionException fe){
+      } catch (FunctionException fe) {
         throw new GemfireRestException(String.format("The Region identified by name (%1$s) could not found!", region), fe);
       }
-    }
-    else if (ArrayUtils.isNotEmpty(members)) {
-      if(logger.isDebugEnabled()){
+    } else if (ArrayUtils.isNotEmpty(members)) {
+      if (logger.isDebugEnabled()) {
         logger.debug("Executing Function ({}) with arguments ({}) on Member ({})...", functionId,
             ArrayUtils.toString(argsInBody), ArrayUtils.toString(members));
       }
-      try {            
+      try {
         function = FunctionService.onMembers(getMembers(members));
-      } catch(FunctionException fe){
-        throw new GemfireRestException("Could not found the specified members in disributed system!", fe);
+      } catch (FunctionException fe) {
+        throw new GemfireRestException("Could not found the specified members in distributed system!", fe);
       }
-    }
-    else if (ArrayUtils.isNotEmpty(groups)) {
-      if(logger.isDebugEnabled()){
+    } else if (ArrayUtils.isNotEmpty(groups)) {
+      if (logger.isDebugEnabled()) {
         logger.debug("Executing Function ({}) with arguments ({}) on Groups ({})...", functionId,
             ArrayUtils.toString(argsInBody), ArrayUtils.toString(groups));
       }
       try {
         function = FunctionService.onMembers(groups);
-      } catch(FunctionException fe){
+      } catch (FunctionException fe) {
         throw new GemfireRestException("no member(s) are found belonging to the provided group(s)!", fe);
       }
-    }
-    else {
+    } else {
       //Default case is to execute function on all existing data node in DS, document this.
-      if(logger.isDebugEnabled()){
+      if (logger.isDebugEnabled()) {
         logger.debug("Executing Function ({}) with arguments ({}) on all Members...", functionId,
             ArrayUtils.toString(argsInBody));
       }
-        
+
       try {
         function = FunctionService.onMembers(getAllMembersInDS());
-      } catch(FunctionException fe) {
-        throw new GemfireRestException("Disributed system does not contain any valid data node to run the specified  function!", fe);
+      } catch (FunctionException fe) {
+        throw new GemfireRestException("Distributed system does not contain any valid data node to run the specified  function!", fe);
+      }
+    }
+
+    if (!ArrayUtils.isEmpty(filter)) {
+      if (logger.isDebugEnabled()) {
+        logger.debug("Executing Function ({}) with filter ({})", functionId,
+            ArrayUtils.toString(filter));
       }
+      Set filter1 = ArrayUtils.asSet(filter);
+      function = function.withFilter(filter1);
     }
 
     final ResultCollector<?, ?> results;
-    
+
     try {
-      if(argsInBody != null) 
-      {
+      if (argsInBody != null) {
         Object[] args = jsonToObjectArray(argsInBody);
-        
+
         //execute function with specified arguments
-        if(args.length == 1){
+        if (args.length == 1) {
           results = function.withArgs(args[0]).execute(functionId);
         } else {
           results = function.withArgs(args).execute(functionId);
         }
-      }else { 
+      } else {
         //execute function with no args
         results = function.execute(functionId);
       }
-    } catch(ClassCastException cce){
+    } catch (ClassCastException cce) {
       throw new GemfireRestException("Key is of an inappropriate type for this region!", cce);
-    } catch(NullPointerException npe){
+    } catch (NullPointerException npe) {
       throw new GemfireRestException("Specified key is null and this region does not permit null keys!", npe);
-    } catch(LowMemoryException lme){
+    } catch (LowMemoryException lme) {
       throw new GemfireRestException("Server has encountered low memory condition!", lme);
     } catch (IllegalArgumentException ie) {
       throw new GemfireRestException("Input parameter is null! ", ie);
-    }catch (FunctionException fe){
+    } catch (FunctionException fe) {
       throw new GemfireRestException("Server has encountered error while executing the function!", fe);
     }
-    
+
     try {
       Object functionResult = results.getResult();
-    
-      if(functionResult instanceof List<?>) {
+
+      if (functionResult instanceof List<?>) {
         final HttpHeaders headers = new HttpHeaders();
         headers.setLocation(toUri("functions", functionId));
-      
+
         try {
           @SuppressWarnings("unchecked")
-          String functionResultAsJson = JSONUtils.convertCollectionToJson((ArrayList<Object>)functionResult);
-          return new ResponseEntity<String>(functionResultAsJson, headers, HttpStatus.OK);  
+          String functionResultAsJson = JSONUtils.convertCollectionToJson((ArrayList<Object>) functionResult);
+          return new ResponseEntity<String>(functionResultAsJson, headers, HttpStatus.OK);
         } catch (JSONException e) {
           throw new GemfireRestException("Could not convert function results into Restful (JSON) format!", e);
         }
-      }else {
+      } else {
         throw new GemfireRestException("Function has returned results that could not be converted into Restful (JSON) format!");
       }
-    }catch (FunctionException fe) {
+    } catch (FunctionException fe) {
       fe.printStackTrace();
       throw new GemfireRestException("Server has encountered an error while processing function execution!", fe);
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2175524/geode-web-api/src/main/java/com/gemstone/gemfire/rest/internal/web/util/ArrayUtils.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/com/gemstone/gemfire/rest/internal/web/util/ArrayUtils.java b/geode-web-api/src/main/java/com/gemstone/gemfire/rest/internal/web/util/ArrayUtils.java
index 261f9ad..d2d4f2f 100644
--- a/geode-web-api/src/main/java/com/gemstone/gemfire/rest/internal/web/util/ArrayUtils.java
+++ b/geode-web-api/src/main/java/com/gemstone/gemfire/rest/internal/web/util/ArrayUtils.java
@@ -17,6 +17,9 @@
 
 package com.gemstone.gemfire.rest.internal.web.util;
 
+import java.util.LinkedHashSet;
+import java.util.Set;
+
 /**
  * The ArrayUtils class is an abstract utility class for working with Object arrays.
  * <p/>
@@ -56,5 +59,12 @@ public abstract class ArrayUtils {
   public static String toString(final String... array) {
     return toString((Object[])array); 
   }
-  
+
+  public static Set asSet(String[] filter) {
+    LinkedHashSet linkedHashSet = new LinkedHashSet(filter.length);
+    for (int i = 0; i < filter.length; i++) {
+      linkedHashSet.add(filter[i]);
+    }
+    return linkedHashSet;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2175524/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index 8a533f6..f0738d7 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -45,8 +45,8 @@ hamcrest-all.version = 1.3
 hbase.version = 0.94.27
 hibernate.version = 3.5.5-Final
 hibernate-commons-annotations.version = 3.2.0.Final
-httpclient.version = 4.3.3
-httpcore.version = 4.3.3
+httpclient.version = 4.5.1
+httpcore.version = 4.4.4
 httpunit.version = 1.7.2
 hsqldb.version = 2.0.0
 jackson.version = 2.2.0


[17/26] incubator-geode git commit: GEODE-620 Geode SSL configuration is out of date

Posted by kl...@apache.org.
GEODE-620 Geode SSL configuration is out of date

In reviewing uses of SSL I found that SocketCreator did not have support for
TLSv1.2 and that one of the test classes had a reference to an RC4-based
cipher suite.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 442718f45f49add3c4b1e4d47049174f038663b3
Parents: d8f28d2
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Wed Mar 16 15:57:55 2016 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Wed Mar 16 16:01:17 2016 -0700

----------------------------------------------------------------------
 .../src/main/java/com/gemstone/gemfire/internal/SocketCreator.java | 2 +-
 geode-core/src/test/java/security/SSLCredentialGenerator.java      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/442718f4/geode-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
index 5bfa7bd..458f41a 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
@@ -571,7 +571,7 @@ public class SocketCreator {
       return c;
     }
     // lookup known algorithms
-    String[] knownAlgorithms = {"SSL", "SSLv2", "SSLv3", "TLS", "TLSv1", "TLSv1.1"};
+    String[] knownAlgorithms = {"SSL", "SSLv2", "SSLv3", "TLS", "TLSv1", "TLSv1.1", "TLSv1.2"};
     for (String algo : knownAlgorithms) {
       try {
         c = SSLContext.getInstance(algo);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/442718f4/geode-core/src/test/java/security/SSLCredentialGenerator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/security/SSLCredentialGenerator.java b/geode-core/src/test/java/security/SSLCredentialGenerator.java
index e547630..d05e963 100755
--- a/geode-core/src/test/java/security/SSLCredentialGenerator.java
+++ b/geode-core/src/test/java/security/SSLCredentialGenerator.java
@@ -76,7 +76,7 @@ public class SSLCredentialGenerator extends CredentialGenerator {
     Properties props = new Properties();
     props.setProperty("ssl-enabled", "true");
     props.setProperty("ssl-require-authentication", "true");
-    props.setProperty("ssl-ciphers", "SSL_RSA_WITH_RC4_128_MD5");
+    props.setProperty("ssl-ciphers", "SSL_RSA_WITH_3DES_EDE_CBC_SHA");
     props.setProperty("ssl-protocols", "TLSv1");
     return props;
   }


[15/26] incubator-geode git commit: GEODE-1007 CI failure: ClientAuthroizationTwoDUnitTest.testAllOpsWithFailover2

Posted by kl...@apache.org.
GEODE-1007 CI failure: ClientAuthroizationTwoDUnitTest.testAllOpsWithFailover2

The previous fix caused ClientAuthorizationDUnitTest.testAllOpsWithFailover
to have problems.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: f4b203793e0cb1b16a09cc3ae6eed570ecfd1ef4
Parents: 79d2990
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Wed Mar 16 11:00:41 2016 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Wed Mar 16 12:41:20 2016 -0700

----------------------------------------------------------------------
 .../security/ClientAuthorizationTestBase.java   | 25 +++++++++++++-------
 1 file changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f4b20379/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
index cc468e1..8476ae2 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
@@ -855,12 +855,17 @@ public class ClientAuthorizationTestBase extends DistributedTestCase {
       Properties serverProps = buildProperties(authenticator, accessor, false,
           extraAuthProps, extraAuthzProps);
       // Get ports for the servers
-      int port1 = 0;
+      Keeper locator1PortKeeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
+      Keeper locator2PortKeeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
+      Keeper port1Keeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
       Keeper port2Keeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
+      int locator1Port = locator1PortKeeper.getPort();
+      int locator2Port = locator2PortKeeper.getPort();
+      int port1 = port1Keeper.getPort();
       int port2 = port2Keeper.getPort();
 
       // Perform all the ops on the clients
-      List<OperationWithAction> opBlock = new ArrayList<>();
+      List opBlock = new ArrayList();
       Random rnd = new Random();
       for (int opNum = 0; opNum < opCodes.length; ++opNum) {
         // Start client with valid credentials as specified in
@@ -871,20 +876,22 @@ public class ClientAuthorizationTestBase extends DistributedTestCase {
           // End of current operation block; execute all the operations
           // on the servers with/without failover
           if (opBlock.size() > 0) {
+            locator1PortKeeper.release();
+            port1Keeper.release();
             // Start the first server and execute the operation block
-            final int locatorPort = 0;
-            port1 = server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                    locatorPort, 0, serverProps,
+            server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
+                    locator1Port, port1, serverProps,
                     javaProps ));
             server2.invoke(() -> SecurityTestUtil.closeCache());
             executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
                 extraAuthzProps, tgen, rnd);
             if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
               // Failover to the second server and run the block again
-              final String locatorString = null;
-              port2 = server2.invoke(() -> SecurityTestUtil.createCacheServer(
-                      serverProps, javaProps, null, locatorString, 0, Boolean.TRUE,
-                          SecurityTestUtil.NO_EXCEPTION ));
+              locator2PortKeeper.release();
+              port2Keeper.release();
+              server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
+                      locator2Port, port2, serverProps,
+                      javaProps ));
               server1.invoke(() -> SecurityTestUtil.closeCache());
               executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
                   extraAuthzProps, tgen, rnd);


[16/26] incubator-geode git commit: GEODE-1096: HeapMemoryMonitor to consider testBytesUsedForThresholdSet

Posted by kl...@apache.org.
GEODE-1096: HeapMemoryMonitor to consider testBytesUsedForThresholdSet

   HeapMemoryMonitor facilitates to instrument used bytes for testing,
   but updateStateAndSendEvent ignores the instrudmented value.
   Fix is to consider testBytesUsedForThresholdSet (if it is set)
   while sending a new memory event.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: d8f28d23ebcae788a9390fc428310c37a9ef7744
Parents: f4b2037
Author: Sai Boorlagadda <sb...@pivotal.io>
Authored: Mon Mar 14 14:42:27 2016 -0700
Committer: Sai Boorlagadda <sb...@pivotal.io>
Committed: Wed Mar 16 14:24:05 2016 -0700

----------------------------------------------------------------------
 .../internal/cache/control/HeapMemoryMonitor.java     | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d8f28d23/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java
index 27a6dff..ffd940e 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java
@@ -385,11 +385,7 @@ public void stopMonitoring() {
       this.thresholds = new MemoryThresholds(this.thresholds.getMaxMemoryBytes(), criticalThreshold, this.thresholds
           .getEvictionThreshold());
 
-      if (testBytesUsedForThresholdSet != -1) {
-        updateStateAndSendEvent(testBytesUsedForThresholdSet);
-      } else {
-        updateStateAndSendEvent(getBytesUsed());
-      }
+      updateStateAndSendEvent();
       
       // Start or stop monitoring based upon whether a threshold has been set
       if (this.thresholds.isEvictionThresholdEnabled() || this.thresholds.isCriticalThresholdEnabled()) {
@@ -437,11 +433,7 @@ public void stopMonitoring() {
       this.thresholds = new MemoryThresholds(this.thresholds.getMaxMemoryBytes(), this.thresholds.getCriticalThreshold(),
           evictionThreshold);
 
-      if (testBytesUsedForThresholdSet != -1) {
-        updateStateAndSendEvent(testBytesUsedForThresholdSet);
-      } else {
-        updateStateAndSendEvent(getBytesUsed());
-      }
+      updateStateAndSendEvent();
 
       // Start or stop monitoring based upon whether a threshold has been set
       if (this.thresholds.isEvictionThresholdEnabled() || this.thresholds.isCriticalThresholdEnabled()) {
@@ -463,7 +455,7 @@ public void stopMonitoring() {
    * If necessary, change the state and send an event for the state change.
    */
   public void updateStateAndSendEvent() {
-    updateStateAndSendEvent(getBytesUsed());
+    updateStateAndSendEvent(testBytesUsedForThresholdSet != -1 ? testBytesUsedForThresholdSet : getBytesUsed());
   }
   
   /**


[08/26] incubator-geode git commit: GEODE-1053: Refactoring some test code. Updating Apache header for NamedCallable.java and NamedRunnable.java Updated httpcore.version in dependency-versions.properties

Posted by kl...@apache.org.
GEODE-1053: Refactoring some test code.
Updating Apache header for NamedCallable.java and NamedRunnable.java
Updated httpcore.version in dependency-versions.properties


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 4d0dfc569bf8dcdf1c3d98de0a7c8beceb2187f0
Parents: f7ca634
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Wed Mar 16 20:10:10 2016 +1100
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Wed Mar 16 20:10:10 2016 +1100

----------------------------------------------------------------------
 ...stAPIOnRegionFunctionExecutionDUnitTest.java | 150 +++++++++----------
 .../web/controllers/RestAPITestBase.java        |  27 +++-
 ...tAPIsOnGroupsFunctionExecutionDUnitTest.java |  50 ++-----
 ...APIsOnMembersFunctionExecutionDUnitTest.java |  21 +--
 .../gemfire/test/dunit/NamedCallable.java       |  16 ++
 .../gemfire/test/dunit/NamedRunnable.java       |  16 ++
 gradle/dependency-versions.properties           |   2 +-
 7 files changed, 144 insertions(+), 138 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d0dfc56/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
index de7c97c..ed622e8 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
@@ -28,6 +28,7 @@ import com.gemstone.gemfire.internal.cache.PartitionAttributesImpl;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.PartitionedRegionTestHelper;
 import com.gemstone.gemfire.rest.internal.web.RestFunctionTemplate;
+import com.gemstone.gemfire.test.dunit.VM;
 import org.apache.http.client.methods.CloseableHttpResponse;
 
 import java.io.Serializable;
@@ -175,12 +176,6 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
     }
   }
 
-  private void verifyAndResetInvocationCount(final int count) {
-    SampleFunction f = (SampleFunction) FunctionService
-        .getFunction(SampleFunction.Id);
-    assertEquals(count, f.invocationCount);
-  }
-
   private void createPeer(DataPolicy policy) {
     AttributesFactory factory = new AttributesFactory();
     factory.setScope(Scope.DISTRIBUTED_ACK);
@@ -241,37 +236,32 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
   }
 
   private void createCacheAndRegisterFunction() {
-    restURLs.add(vm0.invoke(() -> createCacheWithGroups(vm0, null)));
-    restURLs.add(vm1.invoke(() -> createCacheWithGroups(vm1, null)));
-    restURLs.add(vm2.invoke(() -> createCacheWithGroups(vm2, null)));
-    restURLs.add(vm3.invoke(() -> createCacheWithGroups(vm3, null)));
-
-    vm0.invoke(() -> FunctionService.registerFunction(new SampleFunction()));
-    vm1.invoke(() -> FunctionService.registerFunction(new SampleFunction()));
-    vm2.invoke(() -> FunctionService.registerFunction(new SampleFunction()));
-    vm3.invoke(() -> FunctionService.registerFunction(new SampleFunction()));
+    restURLs.add(vm0.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm0, null)));
+    restURLs.add(vm1.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm1, null)));
+    restURLs.add(vm2.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm2, null)));
+    restURLs.add(vm3.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm3, null)));
+
+    vm0.invoke("registerFunction(new SampleFunction())", () -> FunctionService.registerFunction(new SampleFunction()));
+    vm1.invoke("registerFunction(new SampleFunction())", () -> FunctionService.registerFunction(new SampleFunction()));
+    vm2.invoke("registerFunction(new SampleFunction())", () -> FunctionService.registerFunction(new SampleFunction()));
+    vm3.invoke("registerFunction(new SampleFunction())", () -> FunctionService.registerFunction(new SampleFunction()));
   }
 
   public void testOnRegionExecutionWithReplicateRegion() {
     createCacheAndRegisterFunction();
 
-    vm3.invoke(() -> createPeer(DataPolicy.EMPTY));
-    vm0.invoke(() -> createPeer(DataPolicy.REPLICATE));
-    vm1.invoke(() -> createPeer(DataPolicy.REPLICATE));
-    vm2.invoke(() -> createPeer(DataPolicy.REPLICATE));
+    vm3.invoke("createPeer", () -> createPeer(DataPolicy.EMPTY));
+    vm0.invoke("createPeer", () -> createPeer(DataPolicy.REPLICATE));
+    vm1.invoke("createPeer", () -> createPeer(DataPolicy.REPLICATE));
+    vm2.invoke("createPeer", () -> createPeer(DataPolicy.REPLICATE));
 
-    vm3.invoke(() -> populateRRRegion());
+    vm3.invoke("populateRRRegion", () -> populateRRRegion());
 
     CloseableHttpResponse response = executeFunctionThroughRestCall("SampleFunction", REPLICATE_REGION_NAME, null, null, null, null);
     assertEquals(200, response.getStatusLine().getStatusCode());
     assertNotNull(response.getEntity());
 
-    int c0 = vm0.invoke(() -> getInvocationCount());
-    int c1 = vm1.invoke(() -> getInvocationCount());
-    int c2 = vm2.invoke(() -> getInvocationCount());
-    int c3 = vm3.invoke(() -> getInvocationCount());
-
-    assertEquals(1, c0 + c1 + c2 + c3);
+    assertCorrectInvocationCount(1, vm0, vm1, vm2, vm3);
 
     // remove the expected exception
     restURLs.clear();
@@ -280,21 +270,15 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
   public void testOnRegionExecutionWithPartitionRegion() throws Exception {
     createCacheAndRegisterFunction();
 
-    vm0.invoke(() -> createPeerWithPR());
-    vm1.invoke(() -> createPeerWithPR());
-    vm2.invoke(() -> createPeerWithPR());
-    vm3.invoke(() -> createPeerWithPR());
+    createPeersWithPR(vm0, vm1, vm2, vm3);
 
-    vm3.invoke(() -> populatePRRegion());
+    vm3.invoke("populatePRRegion", () -> populatePRRegion());
 
     CloseableHttpResponse response = executeFunctionThroughRestCall("SampleFunction", PR_REGION_NAME, null, null, null, null);
     assertEquals(200, response.getStatusLine().getStatusCode());
     assertNotNull(response.getEntity());
 
-    vm0.invoke(() -> verifyAndResetInvocationCount(1));
-    vm1.invoke(() -> verifyAndResetInvocationCount(1));
-    vm2.invoke(() -> verifyAndResetInvocationCount(1));
-    vm3.invoke(() -> verifyAndResetInvocationCount(1));
+    assertCorrectInvocationCount(4, vm0, vm1, vm2, vm3);
 
     restURLs.clear();
   }
@@ -302,59 +286,67 @@ public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
   public void testOnRegionWithFilterExecutionWithPartitionRegion() throws Exception {
     createCacheAndRegisterFunction();
 
-    vm0.invoke(() -> createPeerWithPR());
-    vm1.invoke(() -> createPeerWithPR());
-    vm2.invoke(() -> createPeerWithPR());
-    vm3.invoke(() -> createPeerWithPR());
+    createPeersWithPR(vm0, vm1, vm2, vm3);
 
-    vm3.invoke(() -> populatePRRegion());
+    vm3.invoke("populatePRRegion",() -> populatePRRegion());
 
     CloseableHttpResponse response = executeFunctionThroughRestCall("SampleFunction", PR_REGION_NAME, "key2", null, null, null);
     assertEquals(200, response.getStatusLine().getStatusCode());
     assertNotNull(response.getEntity());
 
-    int c0 = vm0.invoke(() -> getInvocationCount());
-    int c1 = vm1.invoke(() -> getInvocationCount());
-    int c2 = vm2.invoke(() -> getInvocationCount());
-    int c3 = vm3.invoke(() -> getInvocationCount());
-
-    assertEquals(1, (c0 + c1 + c2 + c3));
+    assertCorrectInvocationCount(1, vm0, vm1, vm2, vm3);
 
     restURLs.clear();
   }
 
-//  public void testOnRegionWithFilterExecutionWithPartitionRegionJsonArgs() throws Exception {
-//    createCacheAndRegisterFunction();
-//
-//    vm0.invoke(() -> createPeerWithPR());
-//    vm1.invoke(() -> createPeerWithPR());
-//    vm2.invoke(() -> createPeerWithPR());
-//    vm3.invoke(() -> createPeerWithPR());
-//
-//    vm3.invoke(() -> populatePRRegion());
-//
-//    String jsonBody = "["
-//        + "{\"@type\": \"double\",\"@value\": 210}"
-//        + ",{\"@type\":\"com.gemstone.gemfire.web.rest.domain.Item\","
-//        + "\"itemNo\":\"599\",\"description\":\"Part X Free on Bumper Offer\","
-//        + "\"quantity\":\"2\","
-//        + "\"unitprice\":\"5\","
-//        + "\"totalprice\":\"10.00\"}"
-//        + "]";
-//
-//    CloseableHttpResponse response = executeFunctionThroughRestCall("SampleFunction", PR_REGION_NAME, null, jsonBody, null, null);
-//    assertEquals(200, response.getStatusLine().getStatusCode());
-//    assertNotNull(response.getEntity());
-//
-//    // Assert that only 1 node has executed the function.
-//    int c0 = vm0.invoke(() -> getInvocationCount());
-//    int c1 = vm1.invoke(() -> getInvocationCount());
-//    int c2 = vm2.invoke(() -> getInvocationCount());
-//    int c3 = vm3.invoke(() -> getInvocationCount());
-//
-//    assertEquals(1, (c0 + c1 + c2 + c3));
-//
-//    restURLs.clear();
-//  }
+  private void createPeersWithPR(VM... vms) {
+    for (int i = 0; i < vms.length; i++) {
+      vms[i].invoke("createPeerWithPR", () -> createPeerWithPR());
+    }
+  }
+
+  public void testOnRegionWithFilterExecutionWithPartitionRegionJsonArgs() throws Exception {
+    createCacheAndRegisterFunction();
+
+    createPeersWithPR(vm0, vm1, vm2, vm3);
+
+    vm3.invoke("populatePRRegion",() -> populatePRRegion());
+
+    String jsonBody = "["
+        + "{\"@type\": \"double\",\"@value\": 210}"
+        + ",{\"@type\":\"com.gemstone.gemfire.rest.internal.web.controllers.Item\","
+        + "\"itemNo\":\"599\",\"description\":\"Part X Free on Bumper Offer\","
+        + "\"quantity\":\"2\","
+        + "\"unitprice\":\"5\","
+        + "\"totalprice\":\"10.00\"}"
+        + "]";
+
+    CloseableHttpResponse response = executeFunctionThroughRestCall("SampleFunction", PR_REGION_NAME, null, jsonBody, null, null);
+    assertEquals(200, response.getStatusLine().getStatusCode());
+    assertNotNull(response.getEntity());
+
+    // Assert that only 1 node has executed the function.
+    assertCorrectInvocationCount(4, vm0, vm1, vm2, vm3);
+
+    jsonBody = "["
+        + "{\"@type\": \"double\",\"@value\": 220}"
+        + ",{\"@type\":\"com.gemstone.gemfire.rest.internal.web.controllers.Item\","
+        + "\"itemNo\":\"609\",\"description\":\"Part X Free on Bumper Offer\","
+        + "\"quantity\":\"3\","
+        + "\"unitprice\":\"9\","
+        + "\"totalprice\":\"12.00\"}"
+        + "]";
+
+    resetInvocationCounts(vm0,vm1,vm2,vm3);
+
+    response = executeFunctionThroughRestCall("SampleFunction", PR_REGION_NAME, "key2", jsonBody, null, null);
+    assertEquals(200, response.getStatusLine().getStatusCode());
+    assertNotNull(response.getEntity());
+
+    // Assert that only 1 node has executed the function.
+    assertCorrectInvocationCount(1, vm0, vm1, vm2, vm3);
+
+    restURLs.clear();
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d0dfc56/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
index 0d1fee8..ba709b7 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
@@ -18,6 +18,7 @@ package com.gemstone.gemfire.rest.internal.web.controllers;
 
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.execute.Function;
 import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
@@ -49,10 +50,10 @@ import java.util.Random;
 public class RestAPITestBase extends DistributedTestCase {
   protected Cache cache = null;
   protected List<String> restURLs = new ArrayList();
-  VM vm0 = null;
-  VM vm1 = null;
-  VM vm2 = null;
-  VM vm3 = null;
+  protected VM vm0 = null;
+  protected VM vm1 = null;
+  protected VM vm2 = null;
+  protected VM vm3 = null;
 
   public RestAPITestBase(String name) {
     super(name);
@@ -208,4 +209,22 @@ public class RestAPITestBase extends DistributedTestCase {
     return "";
   }
 
+  protected void assertCorrectInvocationCount(int expectedInvocationCount, VM... vms) {
+    int count = 0;
+    for (int i = 0; i < vms.length; i++) {
+      count += vms[i].invoke("getInvocationCount",() -> getInvocationCount());
+    }
+    assertEquals(expectedInvocationCount,count);
+  }
+
+  protected void resetInvocationCount() {
+    RestFunctionTemplate f = (RestFunctionTemplate) FunctionService.getFunction(getFunctionID());
+    f.invocationCount = 0;
+  }
+
+  protected void resetInvocationCounts(VM... vms) {
+    for (int i = 0; i < vms.length; i++) {
+      vms[i].invoke("resetInvocationCount", () -> resetInvocationCount());
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d0dfc56/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
index 5acaccb..0419c78 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
@@ -21,6 +21,7 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.rest.internal.web.RestFunctionTemplate;
 import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.VM;
 import org.apache.http.client.methods.CloseableHttpResponse;
 
 import java.util.ArrayList;
@@ -41,9 +42,14 @@ public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase
     return OnGroupsFunction.Id;
   }
 
-  private void resetInvocationCount() {
-    OnGroupsFunction f = (OnGroupsFunction) FunctionService.getFunction(OnGroupsFunction.Id);
-    f.invocationCount = 0;
+  private void setupCacheWithGroupsAndFunction() {
+    restURLs.add(vm0.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm0, "g0,gm")));
+    restURLs.add(vm1.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm1, "g1")));
+    restURLs.add(vm2.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm2, "g0,g1")));
+
+    vm0.invoke("registerFunction(new OnGroupsFunction())", () -> FunctionService.registerFunction(new OnGroupsFunction()));
+    vm1.invoke("registerFunction(new OnGroupsFunction())", () -> FunctionService.registerFunction(new OnGroupsFunction()));
+    vm2.invoke("registerFunction(new OnGroupsFunction())", () -> FunctionService.registerFunction(new OnGroupsFunction()));
   }
 
   public void testonGroupsExecutionOnAllMembers() {
@@ -54,25 +60,11 @@ public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase
       assertHttpResponse(response, 200, 3);
     }
 
-    int c0 = vm0.invoke(() -> getInvocationCount());
-    int c1 = vm1.invoke(() -> getInvocationCount());
-    int c2 = vm2.invoke(() -> getInvocationCount());
-
-    assertEquals(30, (c0 + c1 + c2));
+    assertCorrectInvocationCount(30, vm0, vm1, vm2);
 
     restURLs.clear();
   }
 
-  private void setupCacheWithGroupsAndFunction() {
-    restURLs.add(vm0.invoke(() -> createCacheWithGroups(vm0, "g0,gm")));
-    restURLs.add(vm1.invoke(() -> createCacheWithGroups(vm1, "g1")));
-    restURLs.add(vm2.invoke(() -> createCacheWithGroups(vm2, "g0,g1")));
-
-    vm0.invoke(() -> FunctionService.registerFunction(new OnGroupsFunction()));
-    vm1.invoke(() -> FunctionService.registerFunction(new OnGroupsFunction()));
-    vm2.invoke(() -> FunctionService.registerFunction(new OnGroupsFunction()));
-  }
-
   public void testonGroupsExecutionOnAllMembersWithFilter() {
     setupCacheWithGroupsAndFunction();
 
@@ -82,11 +74,7 @@ public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase
       assertHttpResponse(response, 500, 0);
     }
 
-    int c0 = vm0.invoke(() -> getInvocationCount());
-    int c1 = vm1.invoke(() -> getInvocationCount());
-    int c2 = vm2.invoke(() -> getInvocationCount());
-
-    assertEquals(0, (c0 + c1 + c2));
+    assertCorrectInvocationCount(0, vm0, vm1, vm2);
     restURLs.clear();
   }
 
@@ -98,11 +86,7 @@ public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase
       CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "no%20such%20group", null);
       assertHttpResponse(response, 500, 0);
     }
-    int c0 = vm0.invoke(() -> getInvocationCount());
-    int c1 = vm1.invoke(() -> getInvocationCount());
-    int c2 = vm2.invoke(() -> getInvocationCount());
-
-    assertEquals(0, (c0 + c1 + c2));
+    assertCorrectInvocationCount(0, vm0, vm1, vm2);
 
     for (int i = 0; i < 5; i++) {
 
@@ -110,15 +94,9 @@ public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase
       assertHttpResponse(response, 200, 1);
     }
 
-    c0 = vm0.invoke(() -> getInvocationCount());
-    c1 = vm1.invoke(() -> getInvocationCount());
-    c2 = vm2.invoke(() -> getInvocationCount());
-
-    assertEquals(5, (c0 + c1 + c2));
+    assertCorrectInvocationCount(5, vm0, vm1, vm2);
 
-    vm0.invoke(() -> resetInvocationCount());
-    vm1.invoke(() -> resetInvocationCount());
-    vm2.invoke(() -> resetInvocationCount());
+    resetInvocationCounts(vm0,vm1,vm2);
 
     restURLs.clear();
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d0dfc56/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
index 7a994d6..f8bf20e 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
@@ -114,12 +114,7 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase
       assertHttpResponse(response, 200, 4);
     }
 
-    int c0 = vm0.invoke(() -> getInvocationCount());
-    int c1 = vm1.invoke(() -> getInvocationCount());
-    int c2 = vm2.invoke(() -> getInvocationCount());
-    int c3 = vm3.invoke(() -> getInvocationCount());
-
-    assertEquals(40, (c0 + c1 + c2 + c3));
+    assertCorrectInvocationCount(40,vm0,vm1,vm2,vm3);
 
     restURLs.clear();
   }
@@ -139,12 +134,7 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase
       assertHttpResponse(response, 200, 3);
     }
 
-    int c0 = vm0.invoke(() -> getInvocationCount());
-    int c1 = vm1.invoke(() -> getInvocationCount());
-    int c2 = vm2.invoke(() -> getInvocationCount());
-    int c3 = vm3.invoke(() -> getInvocationCount());
-
-    assertEquals(30, (c0 + c1 + c2 + c3));
+    assertCorrectInvocationCount(30,vm0,vm1,vm2,vm3);
 
     restURLs.clear();
   }
@@ -157,12 +147,7 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase
       assertHttpResponse(response, 500, 0);
     }
 
-    int c0 = vm0.invoke(() -> getInvocationCount());
-    int c1 = vm1.invoke(() -> getInvocationCount());
-    int c2 = vm2.invoke(() -> getInvocationCount());
-    int c3 = vm3.invoke(() -> getInvocationCount());
-
-    assertEquals(0, (c0 + c1 + c2 + c3));
+    assertCorrectInvocationCount(0,vm0,vm1,vm2,vm3);
 
     restURLs.clear();
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d0dfc56/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/NamedCallable.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/NamedCallable.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/NamedCallable.java
index 66a3f38..67357d9 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/NamedCallable.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/NamedCallable.java
@@ -1,3 +1,19 @@
+/*
+ * 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.test.dunit;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d0dfc56/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/NamedRunnable.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/NamedRunnable.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/NamedRunnable.java
index 8a7fe28..9c127b0 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/NamedRunnable.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/NamedRunnable.java
@@ -1,3 +1,19 @@
+/*
+ * 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.test.dunit;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4d0dfc56/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index f0738d7..7a5054b 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -46,7 +46,7 @@ hbase.version = 0.94.27
 hibernate.version = 3.5.5-Final
 hibernate-commons-annotations.version = 3.2.0.Final
 httpclient.version = 4.5.1
-httpcore.version = 4.4.4
+httpcore.version = 4.4.3
 httpunit.version = 1.7.2
 hsqldb.version = 2.0.0
 jackson.version = 2.2.0


[20/26] incubator-geode git commit: GEODE-992: Integrate with Travis CI

Posted by kl...@apache.org.
GEODE-992: Integrate with Travis CI

disable CI on feature branches and asf-site branch.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 67f0e2ca8dd384100a111e56aba052bc825ba103
Parents: 91b7096
Author: Swapnil Bawaskar <sb...@pivotal.io>
Authored: Wed Mar 16 18:06:53 2016 -0700
Committer: Swapnil Bawaskar <sb...@pivotal.io>
Committed: Wed Mar 16 18:06:53 2016 -0700

----------------------------------------------------------------------
 .travis.yml | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/67f0e2ca/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index c532f20..fdbea8d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -35,3 +35,8 @@ notifications:
       - dev@geode.incubator.apache.org
     on_success: change
     on_failure: change
+
+branches:
+  except:
+    - /^feature.*$/
+    - asf-site


[03/26] incubator-geode git commit: GEODE-1099: NPE thrown from TXManagerImpl.isDistributed()

Posted by kl...@apache.org.
GEODE-1099: NPE thrown from TXManagerImpl.isDistributed()

Use the existing reference to InternalDistributedSystem so as to prevent a NPE.
If the member is indeed being disconnected, a CacheClosed exception is thrown
while trying to send the message.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 5503de078aa0d45961dc143569651276948ff587
Parents: e22cd95
Author: Swapnil Bawaskar <sb...@pivotal.io>
Authored: Mon Mar 14 17:38:57 2016 -0700
Committer: Swapnil Bawaskar <sb...@pivotal.io>
Committed: Tue Mar 15 12:39:56 2016 -0700

----------------------------------------------------------------------
 .../com/gemstone/gemfire/internal/cache/TXManagerImpl.java    | 3 ++-
 .../gemfire/internal/cache/TXManagerImplJUnitTest.java        | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5503de07/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java
index de49fea..7c270fe 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java
@@ -1502,7 +1502,8 @@ public final class TXManagerImpl implements CacheTransactionManager,
      Boolean value = isTXDistributed.get();
     // This can be null if not set in setDistributed().
     if (value == null) {
-      return InternalDistributedSystem.getAnyInstance().getOriginalConfig().getDistributedTransactions();
+      InternalDistributedSystem ids = (InternalDistributedSystem) cache.getDistributedSystem();
+      return ids.getOriginalConfig().getDistributedTransactions();
     } else {
       return value.booleanValue();
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5503de07/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
index a92d4dc..0467f4f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
@@ -331,4 +331,11 @@ public class TXManagerImplJUnitTest {
     assertNull(region.get("key"));
     System.setProperty("gemfire.suspendedTxTimeout", "");
   }
+
+  @Test
+  public void testIsDistributedDoesNotThrowNPE() {
+    TXManagerImpl txMgr = (TXManagerImpl) cache.getCacheTransactionManager();
+    cache.getDistributedSystem().disconnect();
+    assertFalse(txMgr.isDistributed());
+  }
 }


[25/26] incubator-geode git commit: GEODE-620 Geode SSL configuration is out of date

Posted by kl...@apache.org.
GEODE-620 Geode SSL configuration is out of date

the change in cipher suite caused suspect strings to be found in
one of the WANSSLDUnitTest test cases.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: d72986be565457c31270326e491c2be98a5e8102
Parents: 05cd144
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Thu Mar 17 10:54:03 2016 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Thu Mar 17 10:54:28 2016 -0700

----------------------------------------------------------------------
 .../gemstone/gemfire/internal/cache/wan/misc/WANSSLDUnitTest.java  | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d72986be/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANSSLDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANSSLDUnitTest.java b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANSSLDUnitTest.java
index 36f1226..3df01ef 100644
--- a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANSSLDUnitTest.java
+++ b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANSSLDUnitTest.java
@@ -96,6 +96,8 @@ public class WANSSLDUnitTest extends WANTestBase{
   public void testSenderSSLReceiverNoSSL(){
     IgnoredException.addIgnoredException("Acceptor received unknown");
     IgnoredException.addIgnoredException("failed accepting client");
+    IgnoredException.addIgnoredException("Error in connecting to peer");
+    IgnoredException.addIgnoredException("Remote host closed connection during handshake");
       Integer lnPort = (Integer)vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId( 1 ));
       Integer nyPort = (Integer)vm1.invoke(() -> WANTestBase.createFirstRemoteLocator( 2, lnPort ));
 


[14/26] incubator-geode git commit: GEODE-1099: NPE thrown from TXManagerImpl.isDistributed()

Posted by kl...@apache.org.
GEODE-1099: NPE thrown from TXManagerImpl.isDistributed()

fixing the DistTXManagerImplJUnitTest that was overriding the test added
in the last commit for this issue.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: 79d2990eb2be920e93a5bb413830db0c8458fb91
Parents: 82faa8a
Author: Swapnil Bawaskar <sb...@pivotal.io>
Authored: Wed Mar 16 10:28:11 2016 -0700
Committer: Swapnil Bawaskar <sb...@pivotal.io>
Committed: Wed Mar 16 12:40:31 2016 -0700

----------------------------------------------------------------------
 .../gemstone/gemfire/disttx/DistTXManagerImplJUnitTest.java    | 6 ++++++
 .../gemfire/internal/cache/TXManagerImplJUnitTest.java         | 4 ++++
 2 files changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/79d2990e/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXManagerImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXManagerImplJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXManagerImplJUnitTest.java
index 1df2c45..e4db285 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXManagerImplJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXManagerImplJUnitTest.java
@@ -18,6 +18,7 @@ package com.gemstone.gemfire.disttx;
 
 import java.util.Properties;
 
+import com.gemstone.gemfire.internal.cache.TXManagerImpl;
 import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.cache.CacheFactory;
@@ -27,6 +28,7 @@ import com.gemstone.gemfire.internal.cache.TXManagerImplJUnitTest;
 import com.gemstone.gemfire.test.junit.categories.DistributedTransactionsTest;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 
+import static junit.framework.TestCase.assertTrue;
 
 /**
  * Same tests as that of {@link TXManagerImplJUnitTest} after setting
@@ -51,4 +53,8 @@ public class DistTXManagerImplJUnitTest extends TXManagerImplJUnitTest {
     assert(txmgr.isDistributed());
   }
 
+  @Override
+  protected void callIsDistributed(TXManagerImpl txMgr) {
+    assertTrue(txMgr.isDistributed());
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/79d2990e/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
index 0467f4f..fa4c640 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
@@ -336,6 +336,10 @@ public class TXManagerImplJUnitTest {
   public void testIsDistributedDoesNotThrowNPE() {
     TXManagerImpl txMgr = (TXManagerImpl) cache.getCacheTransactionManager();
     cache.getDistributedSystem().disconnect();
+    callIsDistributed(txMgr);
+  }
+
+  protected void callIsDistributed(TXManagerImpl txMgr) {
     assertFalse(txMgr.isDistributed());
   }
 }