You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2016/02/19 02:05:44 UTC

[01/16] incubator-geode git commit: GEODE-934 Added info log while starting client queue dispatcher.

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-831 607d041de -> 610ebd50b


GEODE-934 Added info log while starting client queue dispatcher.


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

Branch: refs/heads/feature/GEODE-831
Commit: fd31ea5bb7561b5f300e4395788a4ea5e50cbead
Parents: 2aca64e
Author: Hitesh Khamesra <hk...@pivotal.io>
Authored: Wed Feb 17 14:54:51 2016 -0800
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Wed Feb 17 14:57:18 2016 -0800

----------------------------------------------------------------------
 .../gemfire/internal/cache/tier/sockets/CacheClientProxy.java      | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fd31ea5b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxy.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxy.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxy.java
index adaf400..69ae6d8 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxy.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxy.java
@@ -2583,6 +2583,8 @@ public class CacheClientProxy implements ClientSession {
               if (this._messageQueue.size() > 0) {
                 Thread.sleep(50);
               }
+              logger.info("available ids = " + this._messageQueue.size()+ " , isEmptyAckList =" + this._messageQueue.isEmptyAckList() 
+                            + ", peekInitialized = " + this._messageQueue.isPeekInitialized());
               while (!this._messageQueue.isEmptyAckList()&& this._messageQueue.isPeekInitialized()) {
                 this._messageQueue.remove();
               }


[07/16] incubator-geode git commit: FragmentJUnitTest now works with new code

Posted by ds...@apache.org.
FragmentJUnitTest now works with new 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/58c8fc84
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/58c8fc84
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/58c8fc84

Branch: refs/heads/feature/GEODE-831
Commit: 58c8fc84d25656cd328d242757c14946ffd51b35
Parents: f86ff84
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Wed Feb 17 17:03:54 2016 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed Feb 17 17:03:54 2016 -0800

----------------------------------------------------------------------
 .../internal/offheap/FragmentJUnitTest.java     | 45 ++------------------
 1 file changed, 4 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/58c8fc84/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
index ccc6b67..a10564f 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
@@ -33,19 +33,14 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.ExpectedException;
 
-import com.gemstone.gemfire.LogWriter;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
 public class FragmentJUnitTest {
 
-  private SimpleMemoryAllocatorImpl ma;
   private OutOfOffHeapMemoryListener ooohml;
   private OffHeapMemoryStats stats;
-  private LogWriter lw;
-  private UnsafeMemoryChunk.Factory umcFactory;
   private UnsafeMemoryChunk[] slabs;
-  private int numSlabs;
 
   static {
     ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
@@ -70,16 +65,11 @@ public class FragmentJUnitTest {
   public void setUp() throws Exception {
     ooohml = mock(OutOfOffHeapMemoryListener.class);
     stats = mock(OffHeapMemoryStats.class);
-    lw = mock(LogWriter.class);
     
-    numSlabs = 2;
-    umcFactory = new UnsafeMemoryChunk.Factory(){
-      @Override
-      public UnsafeMemoryChunk create(int size) {
-        return new UnsafeMemoryChunk(size);
-      }
-    };
-    slabs = allocateMemorySlabs();
+    UnsafeMemoryChunk slab1 = new UnsafeMemoryChunk((int)OffHeapStorage.MIN_SLAB_SIZE);
+    UnsafeMemoryChunk slab2 = new UnsafeMemoryChunk((int)OffHeapStorage.MIN_SLAB_SIZE);
+    slabs = new UnsafeMemoryChunk[]{slab1, slab2};
+    SimpleMemoryAllocatorImpl.createForUnitTest(ooohml, stats, slabs);
   }
 
   @After
@@ -87,11 +77,6 @@ public class FragmentJUnitTest {
     SimpleMemoryAllocatorImpl.freeOffHeapMemory();
   }
   
-  private UnsafeMemoryChunk[] allocateMemorySlabs() {
-    ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, lw, numSlabs, OffHeapStorage.MIN_SLAB_SIZE * numSlabs, OffHeapStorage.MIN_SLAB_SIZE, umcFactory);
-    return ma.getSlabs();
-  }
-
   
   @Test
   public void fragmentConstructorThrowsExceptionForNon8ByteAlignedAddress() {
@@ -147,7 +132,6 @@ public class FragmentJUnitTest {
   
   @Test
   public void getStateIsAlwaysStateUNUSED() {
-    slabs = allocateMemorySlabs();
     Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     softly.assertThat(fragment.getState()).isEqualTo(MemoryBlock.State.UNUSED);
     fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
@@ -156,7 +140,6 @@ public class FragmentJUnitTest {
 
   @Test
   public void getFreeListIdIsAlwaysMinus1() {
-    slabs = allocateMemorySlabs();
     Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     softly.assertThat(fragment.getFreeListId()).isEqualTo(-1);
     fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
@@ -165,7 +148,6 @@ public class FragmentJUnitTest {
 
   @Test
   public void getRefCountIsAlwaysZero() {
-    slabs = allocateMemorySlabs();
     Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     softly.assertThat(fragment.getRefCount()).isEqualTo(0);
     fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
@@ -174,7 +156,6 @@ public class FragmentJUnitTest {
 
   @Test
   public void getDataTypeIsAlwaysNA() {
-    slabs = allocateMemorySlabs();
     Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     softly.assertThat(fragment.getDataType()).isEqualTo("N/A");
     fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
@@ -183,7 +164,6 @@ public class FragmentJUnitTest {
 
   @Test
   public void isSerializedIsAlwaysFalse() {
-    slabs = allocateMemorySlabs();
     Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     softly.assertThat(fragment.isSerialized()).isEqualTo(false);
     fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
@@ -192,7 +172,6 @@ public class FragmentJUnitTest {
 
   @Test
   public void isCompressedIsAlwaysFalse() {
-    slabs = allocateMemorySlabs();
     Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     softly.assertThat(fragment.isCompressed()).isEqualTo(false);
     fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
@@ -201,7 +180,6 @@ public class FragmentJUnitTest {
 
   @Test
   public void getDataValueIsAlwaysNull() {
-    slabs = allocateMemorySlabs();
     Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     softly.assertThat(fragment.getDataValue()).isNull();
     fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
@@ -209,17 +187,7 @@ public class FragmentJUnitTest {
   }
 
   @Test
-  public void getChunkTypeIsAlwaysNull() {
-    slabs = allocateMemorySlabs();
-    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
-    softly.assertThat(fragment.getChunkType()).isNull();
-    fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
-    softly.assertThat(fragment.getChunkType()).isNull();
-  }
-
-  @Test
   public void fragmentEqualsComparesMemoryBlockAddresses() {
-    slabs = allocateMemorySlabs();
     Fragment fragment0 = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     Fragment sameFragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     Fragment fragment1 = new Fragment(slabs[1].getMemoryAddress(), slabs[1].getSize());
@@ -229,14 +197,12 @@ public class FragmentJUnitTest {
 
   @Test
   public void fragmentEqualsIsFalseForNonFragmentObjects() {
-    slabs = allocateMemorySlabs();
     Fragment fragment0 = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     assertThat(fragment0.equals(slabs[0]), is(false));
   }
 
   @Test
   public void fragmentHashCodeIsHashCodeOfItsMemoryAddress() {
-    slabs = allocateMemorySlabs();
     Fragment fragment0 = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     Fragment fragment1 = new Fragment(slabs[1].getMemoryAddress(), slabs[1].getSize());
     Long fragmentAddress = fragment0.getMemoryAddress();
@@ -246,7 +212,6 @@ public class FragmentJUnitTest {
 
   @Test
   public void fragmentFillSetsAllBytesToTheSameConstantValue() {
-    slabs = allocateMemorySlabs();
     Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     Long fragmentAddress = fragment.getMemoryAddress();
     byte[] bytes = new byte[(int)OffHeapStorage.MIN_SLAB_SIZE];
@@ -261,7 +226,6 @@ public class FragmentJUnitTest {
   public void getNextBlockThrowsExceptionForFragment() {
     expectedException.expect(UnsupportedOperationException.class);
 
-    slabs = allocateMemorySlabs();
     Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     fragment.getNextBlock();
     fail("getNextBlock failed to throw UnsupportedOperationException");
@@ -271,7 +235,6 @@ public class FragmentJUnitTest {
   public void getSlabIdThrowsExceptionForFragment() {
     expectedException.expect(UnsupportedOperationException.class);
 
-    slabs = allocateMemorySlabs();
     Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
     fragment.getSlabId();
     fail("getSlabId failed to throw UnsupportedOperationException");


[10/16] incubator-geode git commit: combined Chunk and GemFireChunk into GemFireChunk

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
index 2d86296..2379c2d 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
@@ -296,8 +296,8 @@ public class OffHeapValidationJUnitTest {
   
   private long getMemoryAddress(Region region, String key) {
     Object entry = ((LocalRegion) region).getRegionEntry(key)._getValue();
-    assertTrue(entry instanceof Chunk);
-    long memoryAddress = ((Chunk)entry).getMemoryAddress();
+    assertTrue(entry instanceof GemFireChunk);
+    long memoryAddress = ((GemFireChunk)entry).getMemoryAddress();
     assertTrue(memoryAddress > 0);
     return memoryAddress;
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
index d6ddf02..c0fc0b3 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
@@ -64,7 +64,7 @@ public class OffHeapWriteObjectAsByteArrayJUnitTest {
   public void testByteArrayChunk() throws IOException, ClassNotFoundException {
     byte[] expected = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
     StoredObject so = createStoredObject(expected, false, false);
-    assertTrue(so instanceof Chunk);
+    assertTrue(so instanceof GemFireChunk);
     HeapDataOutputStream hdos = new HeapDataOutputStream(new byte[1024]);
     DataSerializer.writeObjectAsByteArray(so, hdos);
     DataInputStream in = createInput(hdos);
@@ -88,7 +88,7 @@ public class OffHeapWriteObjectAsByteArrayJUnitTest {
   public void testStringChunk() throws IOException, ClassNotFoundException {
     byte[] expected = EntryEventImpl.serialize("1234567890");
     StoredObject so = createStoredObject(expected, true, false);
-    assertTrue(so instanceof Chunk);
+    assertTrue(so instanceof GemFireChunk);
     HeapDataOutputStream hdos = new HeapDataOutputStream(new byte[1024]);
     DataSerializer.writeObjectAsByteArray(so, hdos);
     DataInputStream in = createInput(hdos);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OldFreeListOffHeapRegionJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OldFreeListOffHeapRegionJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OldFreeListOffHeapRegionJUnitTest.java
index 6e26b2f..104aba8 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OldFreeListOffHeapRegionJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OldFreeListOffHeapRegionJUnitTest.java
@@ -41,7 +41,7 @@ public class OldFreeListOffHeapRegionJUnitTest extends OffHeapRegionBase {
 
   @Override
   public int perObjectOverhead() {
-    return Chunk.OFF_HEAP_HEADER_SIZE;
+    return GemFireChunk.OFF_HEAP_HEADER_SIZE;
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java
index 34cb1c4..9f49da1 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java
@@ -163,7 +163,7 @@ public class SimpleMemoryAllocatorFillPatternIntegrationTest {
         private int totalAllocation = 0;
         
         // List of Chunks allocated by this thread
-        private List<Chunk> chunks = new LinkedList<Chunk>();
+        private List<GemFireChunk> chunks = new LinkedList<GemFireChunk>();
         
         // Time to end thread execution
         private long endTime = System.currentTimeMillis() + RUN_TIME_IN_MILLIS;
@@ -173,7 +173,7 @@ public class SimpleMemoryAllocatorFillPatternIntegrationTest {
          */
         private void allocate() {          
           int allocation = chunkSizer.allocationSize();
-          Chunk chunk = (Chunk) allocator.allocate(allocation);
+          GemFireChunk chunk = (GemFireChunk) allocator.allocate(allocation);
           
           // This should always work just after allocation
           chunk.validateFill();
@@ -186,7 +186,7 @@ public class SimpleMemoryAllocatorFillPatternIntegrationTest {
          * Frees a random chunk from the Chunk list.
          */
         private void free() {
-          Chunk chunk = chunks.remove(random.nextInt(chunks.size()));
+          GemFireChunk chunk = chunks.remove(random.nextInt(chunks.size()));
           totalAllocation -= chunk.getSize();
           
           /*
@@ -200,7 +200,7 @@ public class SimpleMemoryAllocatorFillPatternIntegrationTest {
          * Writes canned data to a random Chunk from the Chunk list.
          */
         private void write() {
-          Chunk chunk = chunks.get(random.nextInt(chunks.size()));
+          GemFireChunk chunk = chunks.get(random.nextInt(chunks.size()));
           chunk.writeBytes(0, WRITE_BYTES);
         }
         

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java
index 387c349..a03cf57 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java
@@ -101,7 +101,7 @@ public class SimpleMemoryAllocatorFillPatternJUnitTest {
      * Pull a chunk off the fragment.  This will have no fill because
      * it is a "fresh" chunk.
      */
-    Chunk chunk = (Chunk) this.allocator.allocate(chunkSize);
+    GemFireChunk chunk = (GemFireChunk) this.allocator.allocate(chunkSize);
 
     /*
      * Chunk should have valid fill from initial fragment allocation.
@@ -109,7 +109,7 @@ public class SimpleMemoryAllocatorFillPatternJUnitTest {
     chunk.validateFill();
          
     // "Dirty" the chunk so the release has something to fill over
-    chunk.writeBytes(Chunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
+    chunk.writeBytes(GemFireChunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
 
     // This should free the Chunk (ref count == 1)
     chunk.release();
@@ -118,20 +118,20 @@ public class SimpleMemoryAllocatorFillPatternJUnitTest {
      * This chunk should have a fill because it was reused from the
      * free list (assuming no fragmentation at this point...)
      */
-    chunk = (Chunk) this.allocator.allocate(chunkSize);
+    chunk = (GemFireChunk) 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.writeBytes(Chunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
+    chunk.writeBytes(GemFireChunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
     chunk.release();
 
     // Again, make sure the release implemented the fill
     chunk.validateFill();
 
     // "Dirty up" the free chunk
-    chunk.writeBytes(Chunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
+    chunk.writeBytes(GemFireChunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
     
     catchException(chunk).validateFill();
     assertTrue(caughtException() instanceof IllegalStateException);
@@ -149,14 +149,14 @@ public class SimpleMemoryAllocatorFillPatternJUnitTest {
     /*
      * Stores our allocated memory.
      */
-    Chunk[] allocatedChunks = new Chunk[COMPACTION_CHUNKS];
+    GemFireChunk[] allocatedChunks = new GemFireChunk[COMPACTION_CHUNKS];
     
     /*
      * Use up most of our memory
      * Our memory looks like [      ][      ][      ]
      */
     for(int i =0;i < allocatedChunks.length;++i) {
-      allocatedChunks[i] = (Chunk) this.allocator.allocate(COMPACTION_CHUNK_SIZE);
+      allocatedChunks[i] = (GemFireChunk) this.allocator.allocate(COMPACTION_CHUNK_SIZE);
       allocatedChunks[i].validateFill();
     }
 
@@ -173,7 +173,7 @@ public class SimpleMemoryAllocatorFillPatternJUnitTest {
      * our initial chunks.  This should force a compaction causing our
      * memory to look like [            ][      ].
      */
-    Chunk slightlyLargerChunk = (Chunk) this.allocator.allocate(FORCE_COMPACTION_CHUNK_SIZE);
+    GemFireChunk slightlyLargerChunk = (GemFireChunk) this.allocator.allocate(FORCE_COMPACTION_CHUNK_SIZE);
     
     /*
      * Make sure the compacted memory has the fill validation.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
index 2f47509..12c0e6d 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
@@ -191,7 +191,7 @@ public class SimpleMemoryAllocatorJUnitTest {
     int BATCH_SIZE = 1;
     int TINY_MULTIPLE = com.gemstone.gemfire.internal.offheap.FreeListManager.TINY_MULTIPLE;
     int HUGE_MULTIPLE = com.gemstone.gemfire.internal.offheap.FreeListManager.HUGE_MULTIPLE;
-    int perObjectOverhead = com.gemstone.gemfire.internal.offheap.Chunk.OFF_HEAP_HEADER_SIZE;
+    int perObjectOverhead = com.gemstone.gemfire.internal.offheap.GemFireChunk.OFF_HEAP_HEADER_SIZE;
     int maxTiny = com.gemstone.gemfire.internal.offheap.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);
@@ -273,7 +273,7 @@ public class SimpleMemoryAllocatorJUnitTest {
         bb.put((byte) i);
       }
       bb.position(0);
-      Chunk c = (Chunk) ma.allocateAndInitialize(bb.array(), false, false);
+      GemFireChunk c = (GemFireChunk) 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()));
@@ -427,7 +427,7 @@ public class SimpleMemoryAllocatorJUnitTest {
   
   @Test
   public void testCompaction() {
-    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.Chunk.OFF_HEAP_HEADER_SIZE;
+    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.GemFireChunk.OFF_HEAP_HEADER_SIZE;
     final int BIG_ALLOC_SIZE = 150000;
     final int SMALL_ALLOC_SIZE = BIG_ALLOC_SIZE/2;
     final int TOTAL_MEM = BIG_ALLOC_SIZE;
@@ -543,7 +543,7 @@ public class SimpleMemoryAllocatorJUnitTest {
   boolean memoryUsageEventReceived;
   @Test
   public void testUsageEventListener() {
-    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.Chunk.OFF_HEAP_HEADER_SIZE;
+    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.GemFireChunk.OFF_HEAP_HEADER_SIZE;
     final int SMALL_ALLOC_SIZE = 1000;
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(3000);
     try {
@@ -596,7 +596,7 @@ public class SimpleMemoryAllocatorJUnitTest {
   
   @Test
   public void testOutOfOffHeapMemory() {
-    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.Chunk.OFF_HEAP_HEADER_SIZE;
+    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.GemFireChunk.OFF_HEAP_HEADER_SIZE;
     final int BIG_ALLOC_SIZE = 150000;
     final int SMALL_ALLOC_SIZE = BIG_ALLOC_SIZE/2;
     final int TOTAL_MEM = BIG_ALLOC_SIZE;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
index 7a6343d..8d6eef0 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
@@ -107,7 +107,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      Chunk chunk = (Chunk) ma.allocate(100);
+      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
 
       SyncChunkStack stack = new SyncChunkStack(chunk.getMemoryAddress());
       assertEquals(false, stack.isEmpty());
@@ -121,7 +121,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      Chunk chunk = (Chunk) ma.allocate(100);
+      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
 
       SyncChunkStack stack = new SyncChunkStack();
       stack.offer(chunk.getMemoryAddress());
@@ -136,7 +136,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      Chunk chunk = (Chunk) ma.allocate(100);
+      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
 
       long addr = chunk.getMemoryAddress();
       SyncChunkStack stack = new SyncChunkStack();
@@ -163,7 +163,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      Chunk chunk = (Chunk) ma.allocate(100);
+      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
 
       long addr = chunk.getMemoryAddress();
       SyncChunkStack stack = new SyncChunkStack();
@@ -181,7 +181,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      Chunk chunk = (Chunk) ma.allocate(100);
+      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
 
       long addr = chunk.getMemoryAddress();
       SyncChunkStack stack = new SyncChunkStack();
@@ -199,7 +199,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      Chunk chunk = (Chunk) ma.allocate(100);
+      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
       long addr = chunk.getMemoryAddress();
@@ -217,7 +217,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      Chunk chunk = (Chunk) ma.allocate(100);
+      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
       long addr = chunk.getMemoryAddress();
@@ -242,7 +242,7 @@ public class SyncChunkStackJUnitTest {
     protected void testHookDoConcurrentModification() {
       if (doConcurrentMod) {
         doConcurrentMod = false;
-        Chunk chunk2 = (Chunk) ma.allocate(50);
+        GemFireChunk chunk2 = (GemFireChunk) ma.allocate(50);
         this.chunk2Size = chunk2.getSize();
         this.offer(chunk2.getMemoryAddress());
       }
@@ -253,7 +253,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      Chunk chunk = (Chunk) ma.allocate(100);
+      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
       long addr = chunk.getMemoryAddress();
@@ -272,7 +272,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      Chunk chunk = (Chunk) ma.allocate(100);
+      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
       long addr = chunk.getMemoryAddress();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
index 4f02f9d..4272bfd 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
@@ -22,7 +22,7 @@ import java.nio.ByteBuffer;
 
 import org.junit.experimental.categories.Category;
 
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.ByteSource;
@@ -35,8 +35,8 @@ public class OffHeapByteBufferByteSourceJUnitTest extends OffHeapByteSourceJUnit
   @Override
   protected ByteSource createByteSource(byte[] bytes) {
     StoredObject so = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false);
-    if (so instanceof Chunk) {
-      Chunk c = (Chunk) so;
+    if (so instanceof GemFireChunk) {
+      GemFireChunk c = (GemFireChunk) so;
       ByteBuffer bb = c.createDirectByteBuffer();
       if (bb == null) {
         fail("could not create a direct ByteBuffer for an off-heap Chunk");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
index df1af56..91b52e4 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
@@ -20,7 +20,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.experimental.categories.Category;
 
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
 import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
 import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
@@ -52,9 +52,9 @@ public class OffHeapByteSourceJUnitTest extends ByteSourceJUnitTest {
   @Override
   protected ByteSource createByteSource(byte[] bytes) {
     StoredObject so = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false);
-    if (so instanceof Chunk) {
+    if (so instanceof GemFireChunk) {
       // bypass the factory to make sure that OffHeapByteSource is tested
-      return new OffHeapByteSource((Chunk)so);
+      return new OffHeapByteSource((GemFireChunk)so);
     } else {
       // bytes are so small they can be encoded in a long (see DataAsAddress).
       // So for this test just wrap the original bytes.


[09/16] incubator-geode git commit: removed unused ChunkFactory

Posted by ds...@apache.org.
removed unused ChunkFactory


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

Branch: refs/heads/feature/GEODE-831
Commit: 34936a45c567c747a09755f65da599b14553a9ca
Parents: a1a7027
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Thu Feb 18 15:36:49 2016 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Thu Feb 18 15:36:49 2016 -0800

----------------------------------------------------------------------
 .../gemfire/internal/offheap/ChunkFactory.java  | 36 ---------
 .../internal/offheap/GemFireChunkFactory.java   | 33 ---------
 .../offheap/GemFireChunkFactoryJUnitTest.java   | 78 --------------------
 .../internal/offheap/StoredObjectTestSuite.java |  1 -
 4 files changed, 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/34936a45/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkFactory.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkFactory.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkFactory.java
deleted file mode 100644
index 3e38d22..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkFactory.java
+++ /dev/null
@@ -1,36 +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;
-
-
-/**
- * ChunkFactory can be used to create Chunk instances.
- * It can also be used to determine the ChunkType given a Chunk address
- * or the object header bits from an existing Chunk.
- */
-public interface ChunkFactory  {
-  /**
-   * Create a new chunk of the given size and type at the given address.
-   */
-  Chunk newChunk(long address, int chunkSize);
-  /**
-   * Create a new chunk for a block of memory (identified by address)
-   * that has already been allocated.
-   * The size and type are derived from the existing object header.
-   */
-  Chunk newChunk(long address);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/34936a45/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunkFactory.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunkFactory.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunkFactory.java
deleted file mode 100644
index 8da2180..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunkFactory.java
+++ /dev/null
@@ -1,33 +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;
-
-
-/**
- * A ChunkFactory that produces chunks of type GemFireChunk.
- */
-public class GemFireChunkFactory implements ChunkFactory {
-  @Override
-  public Chunk newChunk(long address, int chunkSize) {
-    return new GemFireChunk(address,chunkSize);
-  }
-
-  @Override
-  public Chunk newChunk(long address) {
-    return new GemFireChunk(address);
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/34936a45/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkFactoryJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkFactoryJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkFactoryJUnitTest.java
deleted file mode 100644
index 8442a39..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkFactoryJUnitTest.java
+++ /dev/null
@@ -1,78 +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.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.LogWriter;
-import com.gemstone.gemfire.internal.cache.EntryEventImpl;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class GemFireChunkFactoryJUnitTest {
-
-  private MemoryAllocator ma;
-
-  @Before
-  public void setUp() {
-    OutOfOffHeapMemoryListener ooohml = mock(OutOfOffHeapMemoryListener.class);
-    OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
-    LogWriter lw = mock(LogWriter.class);
-
-    ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, lw, 1, OffHeapStorage.MIN_SLAB_SIZE * 1, OffHeapStorage.MIN_SLAB_SIZE);
-  }
-
-  @After
-  public void tearDown() {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-  }
-
-  private GemFireChunk createChunk(Object value) {
-    byte[] v = EntryEventImpl.serialize(value);
-
-    boolean isSerialized = true;
-    boolean isCompressed = false;
-
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed);
-
-    return chunk;
-  }
-
-  @Test
-  public void factoryShouldCreateNewChunkWithGivenAddress() {
-    GemFireChunk chunk = createChunk(Long.MAX_VALUE);
-
-    ChunkFactory factory = new GemFireChunkFactory();
-    Chunk newChunk = factory.newChunk(chunk.getMemoryAddress());
-
-    assertNotNull(newChunk);
-    assertEquals(GemFireChunk.class, newChunk.getClass());
-
-    assertThat(newChunk.getMemoryAddress()).isEqualTo(chunk.getMemoryAddress());
-
-    chunk.release();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/34936a45/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
index d4f9e97..d24bc97 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
@@ -25,7 +25,6 @@ import org.junit.runners.Suite;
 	GemFireChunkJUnitTest.class,
 	ChunkWithHeapFormJUnitTest.class,
 	GemFireChunkSliceJUnitTest.class,
-	GemFireChunkFactoryJUnitTest.class
 })
 @RunWith(Suite.class)
 public class StoredObjectTestSuite {


[11/16] incubator-geode git commit: combined Chunk and GemFireChunk into GemFireChunk

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java
index c45dee3..c69fc57 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java
@@ -16,26 +16,722 @@
  */
 package com.gemstone.gemfire.internal.offheap;
 
+import java.io.DataOutput;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.internal.DSCODE;
+import com.gemstone.gemfire.internal.HeapDataOutputStream;
+import com.gemstone.gemfire.internal.InternalDataSerializer;
+import com.gemstone.gemfire.internal.cache.EntryEventImpl;
+import com.gemstone.gemfire.internal.cache.RegionEntry;
+import com.gemstone.gemfire.internal.cache.RegionEntryContext;
+import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 
 /**
- * A chunk that stores a GemFire object.
- * Currently the object stored in this chunk
- * is always an entry value of a Region.
- */
-public class GemFireChunk extends Chunk {
-  public GemFireChunk(long memoryAddress, int chunkSize) {
-    super(memoryAddress, chunkSize);
-  }
-
-  public GemFireChunk(long memoryAddress) {
-    super(memoryAddress);
-    // chunkType may be set by caller when it calls readyForAllocation
-  }
-  public GemFireChunk(GemFireChunk chunk) {
-    super(chunk);
-  }
-  @Override
-  public Chunk slice(int position, int limit) {
-    return new GemFireChunkSlice(this, position, limit);
-  }
-}
\ No newline at end of file
+   * A chunk that stores a Java object.
+   * Currently the object stored in this chunk
+   * is always an entry value of a Region.
+   * Note: this class has a natural ordering that is inconsistent with equals.
+   * Instances of this class should have a short lifetime. We do not store references
+   * to it in the cache. Instead the memoryAddress is stored in a primitive field in
+   * the cache and if used it will then, if needed, create an instance of this class.
+   */
+  public class GemFireChunk extends OffHeapCachedDeserializable implements Comparable<GemFireChunk>, MemoryBlock {
+    /**
+     * The unsafe memory address of the first byte of this chunk
+     */
+    private final long memoryAddress;
+    
+    /**
+     * The useCount, chunkSize, dataSizeDelta, isSerialized, and isCompressed
+     * are all stored in off heap memory in a HEADER. This saves heap memory
+     * by using off heap.
+     */
+    public final static int OFF_HEAP_HEADER_SIZE = 4 + 4;
+    /**
+     * We need to smallest chunk to at least have enough room for a hdr
+     * and for an off heap ref (which is a long).
+     */
+    public final static int MIN_CHUNK_SIZE = OFF_HEAP_HEADER_SIZE + 8;
+    /**
+     * int field.
+     * The number of bytes in this chunk.
+     */
+    private final static int CHUNK_SIZE_OFFSET = 0;
+    /**
+     * Volatile int field
+     * The upper two bits are used for the isSerialized
+     * and isCompressed flags.
+     * The next three bits are unused.
+     * The lower 3 bits of the most significant byte contains a magic number to help us detect
+     * if we are changing the ref count of an object that has been released.
+     * The next byte contains the dataSizeDelta.
+     * The number of bytes of logical data in this chunk.
+     * Since the number of bytes of logical data is always <= chunkSize
+     * and since chunkSize never changes, we have dataSize be
+     * a delta whose max value would be HUGE_MULTIPLE-1.
+     * The lower two bytes contains the use count.
+     */
+    final static int REF_COUNT_OFFSET = 4;
+    /**
+     * The upper two bits are used for the isSerialized
+     * and isCompressed flags.
+     */
+    final static int IS_SERIALIZED_BIT =    0x80000000;
+    final static int IS_COMPRESSED_BIT =    0x40000000;
+    // UNUSED 0x38000000
+    final static int MAGIC_MASK = 0x07000000;
+    final static int MAGIC_NUMBER = 0x05000000;
+    final static int DATA_SIZE_DELTA_MASK = 0x00ff0000;
+    final static int DATA_SIZE_SHIFT = 16;
+    final static int REF_COUNT_MASK =       0x0000ffff;
+    final static int MAX_REF_COUNT = 0xFFFF;
+    final static long FILL_PATTERN = 0x3c3c3c3c3c3c3c3cL;
+    final static byte FILL_BYTE = 0x3c;
+    
+    protected GemFireChunk(long memoryAddress, int chunkSize) {
+      SimpleMemoryAllocatorImpl.validateAddressAndSize(memoryAddress, chunkSize);
+      this.memoryAddress = memoryAddress;
+      setSize(chunkSize);
+      UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, MAGIC_NUMBER);
+    }
+    public void readyForFree() {
+      UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, 0);
+    }
+    public void readyForAllocation() {
+      if (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, 0, MAGIC_NUMBER)) {
+        throw new IllegalStateException("Expected 0 but found " + Integer.toHexString(UnsafeMemoryChunk.readAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET)));
+      }
+    }
+    /**
+     * Should only be used by FakeChunk subclass
+     */
+    protected GemFireChunk() {
+      this.memoryAddress = 0L;
+    }
+    
+    /**
+     * Used to create a Chunk given an existing, already allocated,
+     * memoryAddress. The off heap header has already been initialized.
+     */
+    protected GemFireChunk(long memoryAddress) {
+      SimpleMemoryAllocatorImpl.validateAddress(memoryAddress);
+      this.memoryAddress = memoryAddress;
+    }
+    
+    protected GemFireChunk(GemFireChunk chunk) {
+      this.memoryAddress = chunk.memoryAddress;
+    }
+    
+    /**
+     * Throw an exception if this chunk is not allocated
+     */
+    public void checkIsAllocated() {
+      int originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
+      if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
+        throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
+      }
+    }
+    
+    public void incSize(int inc) {
+      setSize(getSize()+inc);
+    }
+    
+    protected void beforeReturningToAllocator() {
+      
+    }
+
+    @Override
+    public int getSize() {
+      return getSize(this.memoryAddress);
+    }
+
+    public void setSize(int size) {
+      setSize(this.memoryAddress, size);
+    }
+
+    public long getMemoryAddress() {
+      return this.memoryAddress;
+    }
+    
+    public int getDataSize() {
+      /*int dataSizeDelta = UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET);
+      dataSizeDelta &= DATA_SIZE_DELTA_MASK;
+      dataSizeDelta >>= DATA_SIZE_SHIFT;
+      return getSize() - dataSizeDelta;*/
+      return getDataSize(this.memoryAddress);
+    }
+    
+    protected static int getDataSize(long memoryAdress) {
+      int dataSizeDelta = UnsafeMemoryChunk.readAbsoluteInt(memoryAdress+REF_COUNT_OFFSET);
+      dataSizeDelta &= DATA_SIZE_DELTA_MASK;
+      dataSizeDelta >>= DATA_SIZE_SHIFT;
+      return getSize(memoryAdress) - dataSizeDelta;
+    }
+    
+    protected long getBaseDataAddress() {
+      return this.memoryAddress+OFF_HEAP_HEADER_SIZE;
+    }
+    protected int getBaseDataOffset() {
+      return 0;
+    }
+    
+    /**
+     * Creates and returns a direct ByteBuffer that contains the contents of this Chunk.
+     * Note that the returned ByteBuffer has a reference to this chunk's
+     * off-heap address so it can only be used while this Chunk is retained.
+     * @return the created direct byte buffer or null if it could not be created.
+     */
+    @Unretained
+    public ByteBuffer createDirectByteBuffer() {
+      return basicCreateDirectByteBuffer(getBaseDataAddress(), getDataSize());
+    }
+    @Override
+    public void sendTo(DataOutput out) throws IOException {
+      if (!this.isCompressed() && out instanceof HeapDataOutputStream) {
+        ByteBuffer bb = createDirectByteBuffer();
+        if (bb != null) {
+          HeapDataOutputStream hdos = (HeapDataOutputStream) out;
+          if (this.isSerialized()) {
+            hdos.write(bb);
+          } else {
+            hdos.writeByte(DSCODE.BYTE_ARRAY);
+            InternalDataSerializer.writeArrayLength(bb.remaining(), hdos);
+            hdos.write(bb);
+          }
+          return;
+        }
+      }
+      super.sendTo(out);
+    }
+    
+    @Override
+    public void sendAsByteArray(DataOutput out) throws IOException {
+      if (!isCompressed() && out instanceof HeapDataOutputStream) {
+        ByteBuffer bb = createDirectByteBuffer();
+        if (bb != null) {
+          HeapDataOutputStream hdos = (HeapDataOutputStream) out;
+          InternalDataSerializer.writeArrayLength(bb.remaining(), hdos);
+          hdos.write(bb);
+          return;
+        }
+      }
+      super.sendAsByteArray(out);
+    }
+       
+    private static volatile Class dbbClass = null;
+    private static volatile Constructor dbbCtor = null;
+    private static volatile boolean dbbCreateFailed = false;
+    
+    /**
+     * @return the created direct byte buffer or null if it could not be created.
+     */
+    private static ByteBuffer basicCreateDirectByteBuffer(long baseDataAddress, int dataSize) {
+      if (dbbCreateFailed) {
+        return null;
+      }
+      Constructor ctor = dbbCtor;
+      if (ctor == null) {
+        Class c = dbbClass;
+        if (c == null) {
+          try {
+            c = Class.forName("java.nio.DirectByteBuffer");
+          } catch (ClassNotFoundException e) {
+            //throw new IllegalStateException("Could not find java.nio.DirectByteBuffer", e);
+            dbbCreateFailed = true;
+            dbbAddressFailed = true;
+            return null;
+          }
+          dbbClass = c;
+        }
+        try {
+          ctor = c.getDeclaredConstructor(long.class, int.class);
+        } catch (NoSuchMethodException | SecurityException e) {
+          //throw new IllegalStateException("Could not get constructor DirectByteBuffer(long, int)", e);
+          dbbClass = null;
+          dbbCreateFailed = true;
+          return null;
+        }
+        ctor.setAccessible(true);
+        dbbCtor = ctor;
+      }
+      try {
+        return (ByteBuffer)ctor.newInstance(baseDataAddress, dataSize);
+      } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+        //throw new IllegalStateException("Could not create an instance using DirectByteBuffer(long, int)", e);
+        dbbClass = null;
+        dbbCtor = null;
+        dbbCreateFailed = true;
+        return null;
+      }
+    }
+    private static volatile Method dbbAddressMethod = null;
+    private static volatile boolean dbbAddressFailed = false;
+    
+    /**
+     * Returns the address of the Unsafe memory for the first byte of a direct ByteBuffer.
+     * If the buffer is not direct or the address can not be obtained return 0.
+     */
+    public static long getDirectByteBufferAddress(ByteBuffer bb) {
+      if (!bb.isDirect()) {
+        return 0L;
+      }
+      if (dbbAddressFailed) {
+        return 0L;
+      }
+      Method m = dbbAddressMethod;
+      if (m == null) {
+        Class c = dbbClass;
+        if (c == null) {
+          try {
+            c = Class.forName("java.nio.DirectByteBuffer");
+          } catch (ClassNotFoundException e) {
+            //throw new IllegalStateException("Could not find java.nio.DirectByteBuffer", e);
+            dbbCreateFailed = true;
+            dbbAddressFailed = true;
+            return 0L;
+          }
+          dbbClass = c;
+        }
+        try {
+          m = c.getDeclaredMethod("address");
+        } catch (NoSuchMethodException | SecurityException e) {
+          //throw new IllegalStateException("Could not get method DirectByteBuffer.address()", e);
+          dbbClass = null;
+          dbbAddressFailed = true;
+          return 0L;
+        }
+        m.setAccessible(true);
+        dbbAddressMethod = m;
+      }
+      try {
+        return (Long)m.invoke(bb);
+      } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+        //throw new IllegalStateException("Could not create an invoke DirectByteBuffer.address()", e);
+        dbbClass = null;
+        dbbAddressMethod = null;
+        dbbAddressFailed = true;
+        return 0L;
+      }
+    }
+    /**
+     * Returns an address that can be used with unsafe apis to access this chunks memory.
+     * @param offset the offset from this chunk's first byte of the byte the returned address should point to. Must be >= 0.
+     * @param size the number of bytes that will be read using the returned address. Assertion will use this to verify that all the memory accessed belongs to this chunk. Must be > 0.
+     * @return a memory address that can be used with unsafe apis
+     */
+    public long getUnsafeAddress(int offset, int size) {
+      assert offset >= 0 && offset + size <= getDataSize(): "Offset=" + offset + ",size=" + size + ",dataSize=" + getDataSize() + ", chunkSize=" + getSize() + ", but offset + size must be <= " + getDataSize();
+      assert size > 0;
+      long result = getBaseDataAddress() + offset;
+      // validateAddressAndSizeWithinSlab(result, size);
+      return result;
+    }
+    
+    @Override
+    public byte readByte(int offset) {
+      assert offset < getDataSize();
+      return UnsafeMemoryChunk.readAbsoluteByte(getBaseDataAddress() + offset);
+    }
+
+    @Override
+    public void writeByte(int offset, byte value) {
+      assert offset < getDataSize();
+      UnsafeMemoryChunk.writeAbsoluteByte(getBaseDataAddress() + offset, value);
+    }
+
+    @Override
+    public void readBytes(int offset, byte[] bytes) {
+      readBytes(offset, bytes, 0, bytes.length);
+    }
+
+    @Override
+    public void writeBytes(int offset, byte[] bytes) {
+      writeBytes(offset, bytes, 0, bytes.length);
+    }
+
+    public long getAddressForReading(int offset, int size) {
+      //delegate to getUnsafeAddress - as both the methods does return the memory address from given offset
+      return getUnsafeAddress(offset, size);
+    }
+    
+    @Override
+    public void readBytes(int offset, byte[] bytes, int bytesOffset, int size) {
+      assert offset+size <= getDataSize();
+      UnsafeMemoryChunk.readAbsoluteBytes(getBaseDataAddress() + offset, bytes, bytesOffset, size);
+    }
+
+    @Override
+    public void writeBytes(int offset, byte[] bytes, int bytesOffset, int size) {
+      assert offset+size <= getDataSize();
+      UnsafeMemoryChunk.writeAbsoluteBytes(getBaseDataAddress() + offset, bytes, bytesOffset, size);
+    }
+    
+    @Override
+    public void release() {
+      release(this.memoryAddress);
+     }
+
+    @Override
+    public int compareTo(GemFireChunk o) {
+      int result = Integer.signum(getSize() - o.getSize());
+      if (result == 0) {
+        // For the same sized chunks we really don't care about their order
+        // but we need compareTo to only return 0 if the two chunks are identical
+        result = Long.signum(getMemoryAddress() - o.getMemoryAddress());
+      }
+      return result;
+    }
+    
+    @Override
+    public boolean equals(Object o) {
+      if (o instanceof GemFireChunk) {
+        return getMemoryAddress() == ((GemFireChunk) o).getMemoryAddress();
+      }
+      return false;
+    }
+    
+    @Override
+    public int hashCode() {
+      long value = this.getMemoryAddress();
+      return (int)(value ^ (value >>> 32));
+    }
+
+    // OffHeapCachedDeserializable methods 
+    
+    @Override
+    public void setSerializedValue(byte[] value) {
+      writeBytes(0, value);
+    }
+    
+    public byte[] getDecompressedBytes(RegionEntryContext context) {
+      byte[] result = getCompressedBytes();
+      long time = context.getCachePerfStats().startDecompression();
+      result = context.getCompressor().decompress(result);
+      context.getCachePerfStats().endDecompression(time);      
+      return result;
+    }
+    
+    /**
+     * Returns the raw possibly compressed bytes of this chunk
+     */
+    public byte[] getCompressedBytes() {
+      byte[] result = new byte[getDataSize()];
+      readBytes(0, result);
+      //debugLog("reading", true);
+      SimpleMemoryAllocatorImpl.getAllocator().getStats().incReads();
+      return result;
+    }
+    protected byte[] getRawBytes() {
+      byte[] result = getCompressedBytes();
+      // TODO OFFHEAP: change the following to assert !isCompressed();
+      if (isCompressed()) {
+        throw new UnsupportedOperationException();
+      }
+      return result;
+    }
+
+    @Override
+    public byte[] getSerializedValue() {
+      byte [] result = getRawBytes();
+      if (!isSerialized()) {
+        // The object is a byte[]. So we need to make it look like a serialized byte[] in our result
+        result = EntryEventImpl.serialize(result);
+      }
+      return result;
+    }
+    
+    @Override
+    public Object getDeserializedValue(Region r, RegionEntry re) {
+      if (isSerialized()) {
+        // TODO OFFHEAP: debug deserializeChunk
+        return EntryEventImpl.deserialize(getRawBytes());
+        //assert !isCompressed();
+        //return EntryEventImpl.deserializeChunk(this);
+      } else {
+        return getRawBytes();
+      }
+    }
+    
+    /**
+     * We want this to include memory overhead so use getSize() instead of getDataSize().
+     */
+    @Override
+    public int getSizeInBytes() {
+      // Calling getSize includes the off heap header size.
+      // We do not add anything to this since the size of the reference belongs to the region entry size
+      // not the size of this object.
+      return getSize();
+    }
+
+    @Override
+    public int getValueSizeInBytes() {
+      return getDataSize();
+    }
+
+    @Override
+    public void copyBytes(int src, int dst, int size) {
+      throw new UnsupportedOperationException("Implement if used");
+//      assert src+size <= getDataSize();
+//      assert dst+size < getDataSize();
+//      getSlabs()[this.getSlabIdx()].copyBytes(getBaseDataAddress()+src, getBaseDataAddress()+dst, size);
+    }
+
+    @Override
+    public boolean isSerialized() {
+      return (UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET) & IS_SERIALIZED_BIT) != 0;
+    }
+
+    @Override
+    public boolean isCompressed() {
+      return (UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET) & IS_COMPRESSED_BIT) != 0;
+    }
+
+    @Override
+    public boolean retain() {
+      return retain(this.memoryAddress);
+    }
+
+    @Override
+    public int getRefCount() {
+      return getRefCount(this.memoryAddress);
+    }
+
+    public static int getSize(long memAddr) {
+      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      return UnsafeMemoryChunk.readAbsoluteInt(memAddr+CHUNK_SIZE_OFFSET);
+    }
+    public static void setSize(long memAddr, int size) {
+      SimpleMemoryAllocatorImpl.validateAddressAndSize(memAddr, size);
+      UnsafeMemoryChunk.writeAbsoluteInt(memAddr+CHUNK_SIZE_OFFSET, size);
+    }
+    public static long getNext(long memAddr) {
+      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      return UnsafeMemoryChunk.readAbsoluteLong(memAddr+OFF_HEAP_HEADER_SIZE);
+    }
+    public static void setNext(long memAddr, long next) {
+      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      UnsafeMemoryChunk.writeAbsoluteLong(memAddr+OFF_HEAP_HEADER_SIZE, next);
+    }
+    
+    /**
+     * Fills the chunk with a repeated byte fill pattern.
+     * @param baseAddress the starting address for a {@link GemFireChunk}.
+     */
+    public static void fill(long baseAddress) {
+      long startAddress = baseAddress + MIN_CHUNK_SIZE;
+      int size = getSize(baseAddress) - MIN_CHUNK_SIZE;
+      
+      UnsafeMemoryChunk.fill(startAddress, size, FILL_BYTE);
+    }
+    
+    /**
+     * Validates that the fill pattern for this chunk has not been disturbed.  This method
+     * assumes the TINY_MULTIPLE is 8 bytes.
+     * @throws IllegalStateException when the pattern has been violated.
+     */
+    public void validateFill() {
+      assert FreeListManager.TINY_MULTIPLE == 8;
+      
+      long startAddress = getMemoryAddress() + MIN_CHUNK_SIZE;
+      int size = getSize() - MIN_CHUNK_SIZE;
+      
+      for(int i = 0;i < size;i += FreeListManager.TINY_MULTIPLE) {
+        if(UnsafeMemoryChunk.readAbsoluteLong(startAddress + i) != FILL_PATTERN) {
+          throw new IllegalStateException("Fill pattern violated for chunk " + getMemoryAddress() + " with size " + getSize());
+        }        
+      }
+    }
+
+    public void setSerialized(boolean isSerialized) {
+      if (isSerialized) {
+        int bits;
+        int originalBits;
+        do {
+          originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
+          if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
+            throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
+          }
+          bits = originalBits | IS_SERIALIZED_BIT;
+        } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
+      }
+    }
+    public void setCompressed(boolean isCompressed) {
+      if (isCompressed) {
+        int bits;
+        int originalBits;
+        do {
+          originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
+          if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
+            throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
+          }
+          bits = originalBits | IS_COMPRESSED_BIT;
+        } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
+      }
+    }
+    public void setDataSize(int dataSize) { // KIRK
+      assert dataSize <= getSize();
+      int delta = getSize() - dataSize;
+      assert delta <= (DATA_SIZE_DELTA_MASK >> DATA_SIZE_SHIFT);
+      delta <<= DATA_SIZE_SHIFT;
+      int bits;
+      int originalBits;
+      do {
+        originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
+        if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
+          throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
+        }
+        bits = originalBits;
+        bits &= ~DATA_SIZE_DELTA_MASK; // clear the old dataSizeDelta bits
+        bits |= delta; // set the dataSizeDelta bits to the new delta value
+      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
+    }
+    
+    public void initializeUseCount() {
+      int rawBits;
+      do {
+        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
+        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
+          throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(rawBits));
+        }
+        int uc = rawBits & REF_COUNT_MASK;
+        if (uc != 0) {
+          throw new IllegalStateException("Expected use count to be zero but it was: " + uc + " rawBits=0x" + Integer.toHexString(rawBits));
+        }
+      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, rawBits, rawBits+1));
+    }
+
+    public static int getRefCount(long memAddr) {
+      return UnsafeMemoryChunk.readAbsoluteInt(memAddr+REF_COUNT_OFFSET) & REF_COUNT_MASK;
+    }
+
+    public static boolean retain(long memAddr) {
+      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      int uc;
+      int rawBits;
+      int retryCount = 0;
+      do {
+        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET);
+        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
+          // same as uc == 0
+          // TODO MAGIC_NUMBER rethink its use and interaction with compactor fragments
+          return false;
+        }
+        uc = rawBits & REF_COUNT_MASK;
+        if (uc == MAX_REF_COUNT) {
+          throw new IllegalStateException("Maximum use count exceeded. rawBits=" + Integer.toHexString(rawBits));
+        } else if (uc == 0) {
+          return false;
+        }
+        retryCount++;
+        if (retryCount > 1000) {
+          throw new IllegalStateException("tried to write " + (rawBits+1) + " to @" + Long.toHexString(memAddr) + " 1,000 times.");
+        }
+      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET, rawBits, rawBits+1));
+      //debugLog("use inced ref count " + (uc+1) + " @" + Long.toHexString(memAddr), true);
+      if (ReferenceCountHelper.trackReferenceCounts()) {
+        ReferenceCountHelper.refCountChanged(memAddr, false, uc+1);
+      }
+
+      return true;
+    }
+    public static void release(final long memAddr) {
+      release(memAddr, null);
+    }
+    static void release(final long memAddr, FreeListManager freeListManager) {
+      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      int newCount;
+      int rawBits;
+      boolean returnToAllocator;
+      do {
+        returnToAllocator = false;
+        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET);
+        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
+          String msg = "It looks like off heap memory @" + Long.toHexString(memAddr) + " was already freed. rawBits=" + Integer.toHexString(rawBits) + " history=" + ReferenceCountHelper.getFreeRefCountInfo(memAddr);
+          //debugLog(msg, true);
+          throw new IllegalStateException(msg);
+        }
+        int curCount = rawBits&REF_COUNT_MASK;
+        if ((curCount) == 0) {
+          //debugLog("too many frees @" + Long.toHexString(memAddr), true);
+          throw new IllegalStateException("Memory has already been freed." + " history=" + ReferenceCountHelper.getFreeRefCountInfo(memAddr) /*+ System.identityHashCode(this)*/);
+        }
+        if (curCount == 1) {
+          newCount = 0; // clear the use count, bits, and the delta size since it will be freed.
+          returnToAllocator = true;
+        } else {
+          newCount = rawBits-1;
+        }
+      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET, rawBits, newCount));
+      //debugLog("free deced ref count " + (newCount&USE_COUNT_MASK) + " @" + Long.toHexString(memAddr), true);
+      if (returnToAllocator ) {
+       if (ReferenceCountHelper.trackReferenceCounts()) {
+          if (ReferenceCountHelper.trackFreedReferenceCounts()) {
+            ReferenceCountHelper.refCountChanged(memAddr, true, newCount&REF_COUNT_MASK);
+          }
+          ReferenceCountHelper.freeRefCountInfo(memAddr);
+        }
+        if (freeListManager == null) {
+          freeListManager = SimpleMemoryAllocatorImpl.getAllocator().getFreeListManager();
+        }
+        freeListManager.free(memAddr);
+      } else {
+        if (ReferenceCountHelper.trackReferenceCounts()) {
+          ReferenceCountHelper.refCountChanged(memAddr, true, newCount&REF_COUNT_MASK);
+        }
+      }
+    }
+    
+    @Override
+    public String toString() {
+      return toStringForOffHeapByteSource();
+      // This old impl is not safe because it calls getDeserializedForReading and we have code that call toString that does not inc the refcount.
+      // Also if this Chunk is compressed we don't know how to decompress it.
+      //return super.toString() + ":<dataSize=" + getDataSize() + " refCount=" + getRefCount() + " addr=" + getMemoryAddress() + " storedObject=" + getDeserializedForReading() + ">";
+    }
+    
+    protected String toStringForOffHeapByteSource() {
+      return super.toString() + ":<dataSize=" + getDataSize() + " refCount=" + getRefCount() + " addr=" + Long.toHexString(getMemoryAddress()) + ">";
+    }
+    
+    @Override
+    public State getState() {
+      if (getRefCount() > 0) {
+        return State.ALLOCATED;
+      } else {
+        return State.DEALLOCATED;
+      }
+    }
+    @Override
+    public MemoryBlock getNextBlock() {
+      throw new UnsupportedOperationException();
+    }
+    @Override
+    public int getBlockSize() {
+      return getSize();
+    }
+    @Override
+    public int getSlabId() {
+      throw new UnsupportedOperationException();
+    }
+    @Override
+    public int getFreeListId() {
+      return -1;
+    }
+    @Override
+    public String getDataType() {
+      return null;
+    }
+    @Override
+    public Object getDataValue() {
+      return null;
+    }
+    public GemFireChunk slice(int position, int limit) {
+      return new GemFireChunkSlice(this, position, limit);
+    }
+  }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
index a57bd74..820a56c 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
@@ -65,15 +65,15 @@ public class MemoryBlockNode implements MemoryBlock {
     if (!isSerialized()) {
       // byte array
       if (isCompressed()) {
-        return "compressed byte[" + ((Chunk)this.block).getDataSize() + "]";
+        return "compressed byte[" + ((GemFireChunk)this.block).getDataSize() + "]";
       } else {
-        return "byte[" + ((Chunk)this.block).getDataSize() + "]";
+        return "byte[" + ((GemFireChunk)this.block).getDataSize() + "]";
       }
     } else if (isCompressed()) {
-      return "compressed object of size " + ((Chunk)this.block).getDataSize();
+      return "compressed object of size " + ((GemFireChunk)this.block).getDataSize();
     }
     //Object obj = EntryEventImpl.deserialize(((Chunk)this.block).getRawBytes());
-    byte[] bytes = ((Chunk)this.block).getRawBytes();
+    byte[] bytes = ((GemFireChunk)this.block).getRawBytes();
     return DataType.getDataType(bytes);
   }
   public boolean isSerialized() {
@@ -88,14 +88,14 @@ public class MemoryBlockNode implements MemoryBlock {
     if (dataType == null || dataType.equals("N/A")) {
       return null;
     } else if (isCompressed()) {
-      return ((Chunk)this.block).getCompressedBytes();
+      return ((GemFireChunk)this.block).getCompressedBytes();
     } else if (!isSerialized()) {
       // byte array
       //return "byte[" + ((Chunk)this.block).getDataSize() + "]";
-      return ((Chunk)this.block).getRawBytes();
+      return ((GemFireChunk)this.block).getRawBytes();
     } else {
       try {
-        byte[] bytes = ((Chunk)this.block).getRawBytes();
+        byte[] bytes = ((GemFireChunk)this.block).getRawBytes();
         return DataSerializer.readObject(DataType.getDataInput(bytes));
       } catch (IOException e) {
         e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
index 1ec722d..35f5fc2 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
@@ -46,7 +46,7 @@ public abstract class OffHeapCachedDeserializable extends AbstractStoredObject i
     if (isSerialized()) {
       userBits = EntryBits.setSerialized(userBits, true);
     }
-    wrapper.setChunkData((Chunk) this, userBits);
+    wrapper.setChunkData((GemFireChunk) this, userBits);
   }
   
   String getShortClassName() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
index c8bb131..e662cfc 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
@@ -63,7 +63,7 @@ public class OffHeapRegionEntryHelper {
   };
   
   private static long objectToAddress(@Unretained Object v) {
-    if (v instanceof Chunk) return ((Chunk) v).getMemoryAddress();
+    if (v instanceof GemFireChunk) return ((GemFireChunk) v).getMemoryAddress();
     if (v instanceof DataAsAddress) return ((DataAsAddress) v).getEncodedAddress();
     if (v == null) return NULL_ADDRESS;
     if (v == Token.TOMBSTONE) return TOMBSTONE_ADDRESS;
@@ -90,7 +90,7 @@ public class OffHeapRegionEntryHelper {
   @Unretained @Retained
   public static Object addressToObject(@Released @Retained long ohAddress, boolean decompress, RegionEntryContext context) {
     if (isOffHeap(ohAddress)) {
-      @Unretained Chunk chunk =  new GemFireChunk(ohAddress);
+      @Unretained GemFireChunk chunk =  new GemFireChunk(ohAddress);
       @Unretained Object result = chunk;
       if (decompress && chunk.isCompressed()) {
         try {
@@ -160,7 +160,7 @@ public class OffHeapRegionEntryHelper {
 
   private static void releaseAddress(@Released long ohAddress) {
     if (isOffHeap(ohAddress)) {
-      Chunk.release(ohAddress);
+      GemFireChunk.release(ohAddress);
     }
   }
   
@@ -354,11 +354,11 @@ public class OffHeapRegionEntryHelper {
     int retryCount = 0;
     @Retained long addr = re.getAddress();
     while (isOffHeap(addr)) {
-      if (Chunk.retain(addr)) {
+      if (GemFireChunk.retain(addr)) {
         @Unretained long addr2 = re.getAddress();
         if (addr != addr2) {
           retryCount = 0;
-          Chunk.release(addr);
+          GemFireChunk.release(addr);
           // spin around and try again.
           addr = addr2;
         } else {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
index 6b3a730..209005c 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
@@ -224,20 +224,20 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
     this.stats.incFreeMemory(this.freeList.getTotalMemory());
   }
   
-  public List<Chunk> getLostChunks() {
-    List<Chunk> liveChunks = this.freeList.getLiveChunks();
-    List<Chunk> regionChunks = getRegionLiveChunks();
-    Set<Chunk> liveChunksSet = new HashSet<>(liveChunks);
-    Set<Chunk> regionChunksSet = new HashSet<>(regionChunks);
+  public List<GemFireChunk> getLostChunks() {
+    List<GemFireChunk> liveChunks = this.freeList.getLiveChunks();
+    List<GemFireChunk> regionChunks = getRegionLiveChunks();
+    Set<GemFireChunk> liveChunksSet = new HashSet<>(liveChunks);
+    Set<GemFireChunk> regionChunksSet = new HashSet<>(regionChunks);
     liveChunksSet.removeAll(regionChunksSet);
-    return new ArrayList<Chunk>(liveChunksSet);
+    return new ArrayList<GemFireChunk>(liveChunksSet);
   }
   
   /**
    * Returns a possibly empty list that contains all the Chunks used by regions.
    */
-  private List<Chunk> getRegionLiveChunks() {
-    ArrayList<Chunk> result = new ArrayList<Chunk>();
+  private List<GemFireChunk> getRegionLiveChunks() {
+    ArrayList<GemFireChunk> result = new ArrayList<GemFireChunk>();
     RegionService gfc = GemFireCacheImpl.getInstance();
     if (gfc != null) {
       Iterator<Region<?,?>> rootIt = gfc.rootRegions().iterator();
@@ -253,7 +253,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
     return result;
   }
 
-  private void getRegionLiveChunks(Region<?,?> r, List<Chunk> result) {
+  private void getRegionLiveChunks(Region<?,?> r, List<GemFireChunk> result) {
     if (r.getAttributes().getOffHeap()) {
 
       if (r instanceof PartitionedRegion) {
@@ -277,7 +277,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
 
   }
   
-  private void basicGetRegionLiveChunks(LocalRegion r, List<Chunk> result) {
+  private void basicGetRegionLiveChunks(LocalRegion r, List<GemFireChunk> result) {
     for (Object key : r.keySet()) {
       RegionEntry re = ((LocalRegion) r).getRegionEntry(key);
       if (re != null) {
@@ -286,15 +286,15 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
          */
         @Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE)
         Object value = re._getValue();
-        if (value instanceof Chunk) {
-          result.add((Chunk) value);
+        if (value instanceof GemFireChunk) {
+          result.add((GemFireChunk) value);
         }
       }
     }
   }
 
-  private Chunk allocateChunk(int size) {
-    Chunk result = this.freeList.allocate(size);
+  private GemFireChunk allocateChunk(int size) {
+    GemFireChunk result = this.freeList.allocate(size);
     int resultSize = result.getSize();
     stats.incObjects(1);
     stats.incUsedMemory(resultSize);
@@ -309,7 +309,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
   @Override
   public MemoryChunk allocate(int size) {
     //System.out.println("allocating " + size);
-    Chunk result = allocateChunk(size);
+    GemFireChunk result = allocateChunk(size);
     //("allocated off heap object of size " + size + " @" + Long.toHexString(result.getMemoryAddress()), true);
     return result;
   }
@@ -328,7 +328,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
     if (addr != 0L) {
       return new DataAsAddress(addr);
     }
-    Chunk result = allocateChunk(v.length);
+    GemFireChunk result = allocateChunk(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);
@@ -485,11 +485,11 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
   }
 
   public synchronized List<MemoryBlock> getOrphans() {
-    List<Chunk> liveChunks = this.freeList.getLiveChunks();
-    List<Chunk> regionChunks = getRegionLiveChunks();
+    List<GemFireChunk> liveChunks = this.freeList.getLiveChunks();
+    List<GemFireChunk> regionChunks = getRegionLiveChunks();
     liveChunks.removeAll(regionChunks);
     List<MemoryBlock> orphans = new ArrayList<MemoryBlock>();
-    for (Chunk chunk: liveChunks) {
+    for (GemFireChunk chunk: liveChunks) {
       orphans.add(new MemoryBlockNode(this, chunk));
     }
     Collections.sort(orphans,

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SyncChunkStack.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SyncChunkStack.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SyncChunkStack.java
index 7ba28a2..a532ccf 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SyncChunkStack.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SyncChunkStack.java
@@ -42,7 +42,7 @@ public class SyncChunkStack {
     assert e != 0;
     SimpleMemoryAllocatorImpl.validateAddress(e);
     synchronized (this) {
-      Chunk.setNext(e, this.topAddr);
+      GemFireChunk.setNext(e, this.topAddr);
       this.topAddr = e;
     }
   }
@@ -51,7 +51,7 @@ public class SyncChunkStack {
     synchronized (this) {
       result = this.topAddr;
       if (result != 0L) {
-        this.topAddr = Chunk.getNext(result);
+        this.topAddr = GemFireChunk.getNext(result);
       }
     }
     return result;
@@ -85,8 +85,8 @@ public class SyncChunkStack {
       concurrentModDetected = false;
       addr = headAddr;
       while (addr != 0L) {
-        int curSize = Chunk.getSize(addr);
-        addr = Chunk.getNext(addr);
+        int curSize = GemFireChunk.getSize(addr);
+        addr = GemFireChunk.getNext(addr);
         testHookDoConcurrentModification();
         long curHead = this.topAddr;
         if (curHead != headAddr) {
@@ -113,8 +113,8 @@ public class SyncChunkStack {
       result = 0;
       addr = headAddr;
       while (addr != 0L) {
-        result += Chunk.getSize(addr);
-        addr = Chunk.getNext(addr);
+        result += GemFireChunk.getSize(addr);
+        addr = GemFireChunk.getNext(addr);
         testHookDoConcurrentModification();
         long curHead = this.topAddr;
         if (curHead != headAddr) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ByteBufferInputStream.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ByteBufferInputStream.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ByteBufferInputStream.java
index 8a7d351..0097a34 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ByteBufferInputStream.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ByteBufferInputStream.java
@@ -31,7 +31,7 @@ import java.nio.ByteOrder;
 
 import com.gemstone.gemfire.internal.ByteBufferWriter;
 import com.gemstone.gemfire.internal.HeapDataOutputStream;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.UnsafeMemoryChunk;
 
 /**
@@ -109,7 +109,7 @@ public class ByteBufferInputStream extends InputStream implements DataInput, jav
     public static ByteSource create(ByteBuffer bb) {
       return new ByteBufferByteSource(bb);
     }
-    public static ByteSource create(Chunk chunk) {
+    public static ByteSource create(GemFireChunk chunk) {
       // Since I found a way to create a DirectByteBuffer (using reflection) from a Chunk
       // we might not even need the ByteSource abstraction any more.
       // But it is possible that createByteBuffer will not work on a different jdk so keep it for now.
@@ -323,9 +323,9 @@ public class ByteBufferInputStream extends InputStream implements DataInput, jav
   public static class OffHeapByteSource implements ByteSource {
     private int position;
     private int limit;
-    private final Chunk chunk;
+    private final GemFireChunk chunk;
 
-    public OffHeapByteSource(Chunk c) {
+    public OffHeapByteSource(GemFireChunk c) {
       this.chunk = c;
       this.position = 0;
       this.limit = capacity();
@@ -724,7 +724,7 @@ public class ByteBufferInputStream extends InputStream implements DataInput, jav
     this.buffer = copy.buffer.duplicate();
   }
 
-  public ByteBufferInputStream(Chunk blob) {
+  public ByteBufferInputStream(GemFireChunk blob) {
     this.buffer = ByteSourceFactory.create(blob);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ImmutableByteBufferInputStream.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ImmutableByteBufferInputStream.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ImmutableByteBufferInputStream.java
index 52f332f..a765c3d 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ImmutableByteBufferInputStream.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ImmutableByteBufferInputStream.java
@@ -18,7 +18,7 @@ package com.gemstone.gemfire.internal.tcp;
 
 import java.nio.ByteBuffer;
 
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 
 /**
  * You should only create an instance of this class if the bytes this buffer reads
@@ -67,7 +67,7 @@ public class ImmutableByteBufferInputStream extends ByteBufferInputStream {
     // for serialization
   }
   
-  public ImmutableByteBufferInputStream(Chunk blob) {
+  public ImmutableByteBufferInputStream(GemFireChunk blob) {
     super(blob);
   }
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
index 7a4840e..d4dae92 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
@@ -27,7 +27,7 @@ import com.gemstone.gemfire.internal.DSCODE;
 import com.gemstone.gemfire.internal.HeapDataOutputStream;
 import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.pdx.internal.PdxInputStream;
 
@@ -140,7 +140,7 @@ public class BlobHelper {
    * If a PdxInstance is returned then it will refer to Chunk's off-heap memory
    * with an unretained reference.
    */
-  public static @Unretained Object deserializeOffHeapBlob(Chunk blob) throws IOException, ClassNotFoundException {
+  public static @Unretained Object deserializeOffHeapBlob(GemFireChunk blob) throws IOException, ClassNotFoundException {
     Object result;
     final long start = startDeserialization();
     // For both top level and nested pdxs we just want a reference to this off-heap blob.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInputStream.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInputStream.java b/gemfire-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInputStream.java
index 85e078d..74277f4 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInputStream.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInputStream.java
@@ -26,7 +26,7 @@ import java.util.Date;
 import com.gemstone.gemfire.DataSerializer;
 import com.gemstone.gemfire.InternalGemFireException;
 import com.gemstone.gemfire.pdx.PdxSerializationException;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream;
 import com.gemstone.gemfire.internal.tcp.ImmutableByteBufferInputStream;
 
@@ -76,7 +76,7 @@ public class PdxInputStream extends ImmutableByteBufferInputStream {
     // for serialization
   }
 
-  public PdxInputStream(Chunk blob) {
+  public PdxInputStream(GemFireChunk blob) {
     super(blob);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
index 35e6f71..5d2f8d0 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
@@ -29,7 +29,7 @@ import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.ChunkValueWrapper;
 import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.Flushable;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
 import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
 import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
@@ -40,7 +40,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 public class ChunkValueWrapperJUnitTest {
 
   private static ChunkValueWrapper createChunkValueWrapper(byte[] bytes, boolean isSerialized) {
-    Chunk c = (Chunk)SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, isSerialized, false);
+    GemFireChunk c = (GemFireChunk)SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, isSerialized, false);
     return new ChunkValueWrapper(c);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
index 647a58b..0b1d130 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
@@ -26,7 +26,7 @@ import org.junit.Test;
 
 import com.gemstone.gemfire.internal.HeapDataOutputStream;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl.OldValueImporter;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.DataAsAddress;
 import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
 import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
@@ -130,7 +130,7 @@ public abstract class OldValueImporterTestBase {
           SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{new UnsafeMemoryChunk(1024*1024)});
       try {
         byte[] baValue = new byte[] {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
-        Chunk baValueSO = (Chunk) sma.allocateAndInitialize(baValue, false, false);
+        GemFireChunk baValueSO = (GemFireChunk) sma.allocateAndInitialize(baValue, false, false);
         OldValueImporter omsg = createImporter();
         omsg.importOldObject(baValueSO, false);
         hdos = new HeapDataOutputStream(bytes);
@@ -166,7 +166,7 @@ public abstract class OldValueImporterTestBase {
       try {
         String baValue = "12345678";
         byte[] baValueBlob = BlobHelper.serializeToBlob(baValue);
-        Chunk baValueSO = (Chunk) sma.allocateAndInitialize(baValueBlob, true, false);
+        GemFireChunk baValueSO = (GemFireChunk) sma.allocateAndInitialize(baValueBlob, true, false);
         OldValueImporter omsg = createImporter();
         omsg.importOldObject(baValueSO, true);
         hdos = new HeapDataOutputStream(bytes);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapFormJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapFormJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapFormJUnitTest.java
index bc32367..8f9473f 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapFormJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapFormJUnitTest.java
@@ -50,7 +50,7 @@ public class ChunkWithHeapFormJUnitTest extends GemFireChunkJUnitTest {
     byte[] valueInBytes = getValueAsByteArray();
     ChunkWithHeapForm heapForm = new ChunkWithHeapForm(chunk, valueInBytes);
 
-    Chunk chunkWithOutHeapForm = heapForm.getChunkWithoutHeapForm();
+    GemFireChunk chunkWithOutHeapForm = heapForm.getChunkWithoutHeapForm();
 
     assertNotNull(chunkWithOutHeapForm);
     assertEquals(GemFireChunk.class, chunkWithOutHeapForm.getClass());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
index acecf97..1b37f23 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
@@ -211,7 +211,7 @@ public class FragmentJUnitTest {
     Long fragmentAddress = fragment.getMemoryAddress();
     byte[] bytes = new byte[(int)OffHeapStorage.MIN_SLAB_SIZE];
     byte[] expectedBytes = new byte[(int)OffHeapStorage.MIN_SLAB_SIZE];
-    Arrays.fill(expectedBytes, Chunk.FILL_BYTE);;
+    Arrays.fill(expectedBytes, GemFireChunk.FILL_BYTE);;
     fragment.fill();
     UnsafeMemoryChunk.readAbsoluteBytes(fragmentAddress, bytes, 0, (int)OffHeapStorage.MIN_SLAB_SIZE);
     assertThat(bytes, is(equalTo(expectedBytes)));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
index 0de4ea7..ce98510 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
@@ -104,12 +104,12 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int tinySize = 10;
 
-    Chunk c = this.freeListManager.allocate(tinySize);
+    GemFireChunk c = this.freeListManager.allocate(tinySize);
     
     validateChunkSizes(c, tinySize);
   }
   
-  private void validateChunkSizes(Chunk c, int dataSize) {
+  private void validateChunkSizes(GemFireChunk c, int dataSize) {
     assertThat(c).isNotNull();
     assertThat(c.getDataSize()).isEqualTo(dataSize);
     assertThat(c.getSize()).isEqualTo(computeExpectedSize(dataSize));
@@ -120,8 +120,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int tinySize = 10;
     
-    Chunk c = this.freeListManager.allocate(tinySize);
-    Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c = this.freeListManager.allocate(tinySize);
+    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     c = this.freeListManager.allocate(tinySize);
 
     validateChunkSizes(c, tinySize);
@@ -132,8 +132,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = 10;
     
-    Chunk c = this.freeListManager.allocate(dataSize);
-    Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c = this.freeListManager.allocate(dataSize);
+    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     this.freeListManager.allocate(dataSize);
     // free list will now be empty
     c = this.freeListManager.allocate(dataSize);
@@ -146,7 +146,7 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int hugeSize = FreeListManager.MAX_TINY+1;
 
-    Chunk c = this.freeListManager.allocate(hugeSize);
+    GemFireChunk c = this.freeListManager.allocate(hugeSize);
 
     validateChunkSizes(c, hugeSize);
   }
@@ -156,8 +156,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = FreeListManager.MAX_TINY+1;
     
-    Chunk c = this.freeListManager.allocate(dataSize);
-    Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c = this.freeListManager.allocate(dataSize);
+    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     this.freeListManager.allocate(dataSize);
     // free list will now be empty
     c = this.freeListManager.allocate(dataSize);
@@ -170,8 +170,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = FreeListManager.MAX_TINY+1+1024;
     
-    Chunk c = this.freeListManager.allocate(dataSize);
-    Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c = this.freeListManager.allocate(dataSize);
+    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     dataSize = FreeListManager.MAX_TINY+1;
     c = this.freeListManager.allocate(dataSize);
     
@@ -188,8 +188,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = 10;
     
-    Chunk c = this.freeListManager.allocate(dataSize);
-    Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c = this.freeListManager.allocate(dataSize);
+    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     
     assertThat(this.freeListManager.getFreeTinyMemory()).isEqualTo(computeExpectedSize(dataSize));
   }
@@ -199,13 +199,13 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = 10;
     
-    Chunk c = this.freeListManager.allocate(dataSize);
-    Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c = this.freeListManager.allocate(dataSize);
+    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     
     int dataSize2 = 100;
     
-    Chunk c2 = this.freeListManager.allocate(dataSize2);
-    Chunk.release(c2.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c2 = this.freeListManager.allocate(dataSize2);
+    GemFireChunk.release(c2.getMemoryAddress(), this.freeListManager);
     
     assertThat(this.freeListManager.getFreeTinyMemory()).isEqualTo(computeExpectedSize(dataSize)+computeExpectedSize(dataSize2));
   }
@@ -221,8 +221,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = FreeListManager.MAX_TINY+1+1024;
     
-    Chunk c = this.freeListManager.allocate(dataSize);
-    Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c = this.freeListManager.allocate(dataSize);
+    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     
     assertThat(this.freeListManager.getFreeHugeMemory()).isEqualTo(computeExpectedSize(dataSize));
   }
@@ -237,7 +237,7 @@ public class FreeListManagerTest {
   @Test
   public void freeFragmentMemorySomeOfFragmentAllocated() {
     setUpSingleSlabManager();
-    Chunk c = this.freeListManager.allocate(DEFAULT_SLAB_SIZE/4-8);
+    GemFireChunk c = this.freeListManager.allocate(DEFAULT_SLAB_SIZE/4-8);
     
     assertThat(this.freeListManager.getFreeFragmentMemory()).isEqualTo((DEFAULT_SLAB_SIZE/4)*3);
   }
@@ -245,13 +245,13 @@ public class FreeListManagerTest {
   @Test
   public void freeFragmentMemoryMostOfFragmentAllocated() {
     setUpSingleSlabManager();
-    Chunk c = this.freeListManager.allocate(DEFAULT_SLAB_SIZE-8-8);
+    GemFireChunk c = this.freeListManager.allocate(DEFAULT_SLAB_SIZE-8-8);
     
     assertThat(this.freeListManager.getFreeFragmentMemory()).isZero();
   }
   
   private int computeExpectedSize(int dataSize) {
-    return ((dataSize + Chunk.OFF_HEAP_HEADER_SIZE + 7) / 8) * 8;
+    return ((dataSize + GemFireChunk.OFF_HEAP_HEADER_SIZE + 7) / 8) * 8;
   }
 
   @Test(expected = AssertionError.class)
@@ -288,13 +288,13 @@ public class FreeListManagerTest {
         new UnsafeMemoryChunk(SMALL_SLAB), 
         new UnsafeMemoryChunk(MEDIUM_SLAB), 
         slab});
-    ArrayList<Chunk> chunks = new ArrayList<>();
+    ArrayList<GemFireChunk> chunks = new ArrayList<>();
     chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
     chunks.add(this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8));
     chunks.add(this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8));
     chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
-    for (Chunk c: chunks) {
-      Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    for (GemFireChunk c: chunks) {
+      GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     }
     this.freeListManager.firstCompact = false;
     assertThat(this.freeListManager.compact(DEFAULT_SLAB_SIZE+1)).isFalse();
@@ -310,13 +310,13 @@ public class FreeListManagerTest {
         new UnsafeMemoryChunk(SMALL_SLAB), 
         new UnsafeMemoryChunk(MEDIUM_SLAB), 
         slab});
-    ArrayList<Chunk> chunks = new ArrayList<>();
+    ArrayList<GemFireChunk> chunks = new ArrayList<>();
     chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
     chunks.add(this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8));
     chunks.add(this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8));
     chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
-    for (Chunk c: chunks) {
-      Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    for (GemFireChunk c: chunks) {
+      GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     }
     
     assertThat(this.freeListManager.compact(DEFAULT_SLAB_SIZE)).isTrue();
@@ -333,13 +333,13 @@ public class FreeListManagerTest {
         new UnsafeMemoryChunk(SMALL_SLAB), 
         new UnsafeMemoryChunk(MEDIUM_SLAB), 
         slab});
-    ArrayList<Chunk> chunks = new ArrayList<>();
+    ArrayList<GemFireChunk> chunks = new ArrayList<>();
     chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
     this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8);
     chunks.add(this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8));
     this.freeListManager.allocate(SMALL_SLAB-8+1);
-    for (Chunk c: chunks) {
-      Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    for (GemFireChunk c: chunks) {
+      GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     }
     
     assertThat(this.freeListManager.compact(DEFAULT_SLAB_SIZE/2)).isTrue();
@@ -348,7 +348,7 @@ public class FreeListManagerTest {
   @Test
   public void compactAfterAllocatingAll() {
     setUpSingleSlabManager();
-    Chunk c = freeListManager.allocate(DEFAULT_SLAB_SIZE-8);
+    GemFireChunk c = freeListManager.allocate(DEFAULT_SLAB_SIZE-8);
     this.freeListManager.firstCompact = false;
     assertThat(this.freeListManager.compact(1)).isFalse();
     // call compact twice for extra code coverage
@@ -359,46 +359,46 @@ public class FreeListManagerTest {
   @Test
   public void afterAllocatingAllOneSizeCompactToAllocateDifferentSize() {
     setUpSingleSlabManager();
-    ArrayList<Chunk> chunksToFree = new ArrayList<>();
-    ArrayList<Chunk> chunksToFreeLater = new ArrayList<>();
+    ArrayList<GemFireChunk> chunksToFree = new ArrayList<>();
+    ArrayList<GemFireChunk> chunksToFreeLater = new ArrayList<>();
     int ALLOCATE_COUNT = 1000;
-    Chunk bigChunk = freeListManager.allocate(DEFAULT_SLAB_SIZE-8-(ALLOCATE_COUNT*32)-256-256);
+    GemFireChunk bigChunk = freeListManager.allocate(DEFAULT_SLAB_SIZE-8-(ALLOCATE_COUNT*32)-256-256);
     for (int i=0; i < ALLOCATE_COUNT; i++) {
-      Chunk c = freeListManager.allocate(24);
+      GemFireChunk c = freeListManager.allocate(24);
       if (i%3 != 2) {
         chunksToFree.add(c);
       } else {
         chunksToFreeLater.add(c);
       }
     }
-    Chunk c1 = freeListManager.allocate(64-8);
-    Chunk c2 = freeListManager.allocate(64-8);
-    Chunk c3 = freeListManager.allocate(64-8);
-    Chunk c4 = freeListManager.allocate(64-8);
+    GemFireChunk c1 = freeListManager.allocate(64-8);
+    GemFireChunk c2 = freeListManager.allocate(64-8);
+    GemFireChunk c3 = freeListManager.allocate(64-8);
+    GemFireChunk c4 = freeListManager.allocate(64-8);
 
-    Chunk mediumChunk1 = freeListManager.allocate(128-8);
-    Chunk mediumChunk2 = freeListManager.allocate(128-8);
+    GemFireChunk mediumChunk1 = freeListManager.allocate(128-8);
+    GemFireChunk mediumChunk2 = freeListManager.allocate(128-8);
 
-    Chunk.release(bigChunk.getMemoryAddress(), freeListManager);
+    GemFireChunk.release(bigChunk.getMemoryAddress(), freeListManager);
     int s = chunksToFree.size();
     for (int i=s/2; i >=0; i--) {
-      Chunk c = chunksToFree.get(i);
-      Chunk.release(c.getMemoryAddress(), freeListManager);
+      GemFireChunk c = chunksToFree.get(i);
+      GemFireChunk.release(c.getMemoryAddress(), freeListManager);
     }
     for (int i=(s/2)+1; i < s; i++) {
-      Chunk c = chunksToFree.get(i);
-      Chunk.release(c.getMemoryAddress(), freeListManager);
+      GemFireChunk c = chunksToFree.get(i);
+      GemFireChunk.release(c.getMemoryAddress(), freeListManager);
     }
-    Chunk.release(c3.getMemoryAddress(), freeListManager);
-    Chunk.release(c1.getMemoryAddress(), freeListManager);
-    Chunk.release(c2.getMemoryAddress(), freeListManager);
-    Chunk.release(c4.getMemoryAddress(), freeListManager);
-    Chunk.release(mediumChunk1.getMemoryAddress(), freeListManager);
-    Chunk.release(mediumChunk2.getMemoryAddress(), freeListManager);
+    GemFireChunk.release(c3.getMemoryAddress(), freeListManager);
+    GemFireChunk.release(c1.getMemoryAddress(), freeListManager);
+    GemFireChunk.release(c2.getMemoryAddress(), freeListManager);
+    GemFireChunk.release(c4.getMemoryAddress(), freeListManager);
+    GemFireChunk.release(mediumChunk1.getMemoryAddress(), freeListManager);
+    GemFireChunk.release(mediumChunk2.getMemoryAddress(), freeListManager);
     this.freeListManager.firstCompact = false;
     assertThat(freeListManager.compact(DEFAULT_SLAB_SIZE-(ALLOCATE_COUNT*32))).isFalse();
     for (int i=0; i < ((256*2)/96); i++) {
-      Chunk.release(chunksToFreeLater.get(i).getMemoryAddress(), freeListManager);
+      GemFireChunk.release(chunksToFreeLater.get(i).getMemoryAddress(), freeListManager);
     }
     assertThat(freeListManager.compact(DEFAULT_SLAB_SIZE-(ALLOCATE_COUNT*32))).isTrue();
   }
@@ -407,14 +407,14 @@ public class FreeListManagerTest {
   public void afterAllocatingAndFreeingCompact() {
     int slabSize = 1024*3;
     setUpSingleSlabManager(slabSize);
-    Chunk bigChunk1 = freeListManager.allocate(slabSize/3-8);
-    Chunk bigChunk2 = freeListManager.allocate(slabSize/3-8);
-    Chunk bigChunk3 = freeListManager.allocate(slabSize/3-8);
+    GemFireChunk bigChunk1 = freeListManager.allocate(slabSize/3-8);
+    GemFireChunk bigChunk2 = freeListManager.allocate(slabSize/3-8);
+    GemFireChunk bigChunk3 = freeListManager.allocate(slabSize/3-8);
     this.freeListManager.firstCompact = false;
     assertThat(freeListManager.compact(1)).isFalse();
-    Chunk.release(bigChunk3.getMemoryAddress(), freeListManager);
-    Chunk.release(bigChunk2.getMemoryAddress(), freeListManager);
-    Chunk.release(bigChunk1.getMemoryAddress(), freeListManager);
+    GemFireChunk.release(bigChunk3.getMemoryAddress(), freeListManager);
+    GemFireChunk.release(bigChunk2.getMemoryAddress(), freeListManager);
+    GemFireChunk.release(bigChunk1.getMemoryAddress(), freeListManager);
     assertThat(freeListManager.compact(slabSize)).isTrue();
   }
   
@@ -422,8 +422,8 @@ public class FreeListManagerTest {
   public void compactWithEmptyTinyFreeList() {
     setUpSingleSlabManager();
     Fragment originalFragment = this.freeListManager.getFragmentList().get(0);
-    Chunk c = freeListManager.allocate(16);
-    Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c = freeListManager.allocate(16);
+    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     c = freeListManager.allocate(16);
     this.freeListManager.firstCompact = false;
     assertThat(this.freeListManager.compact(1)).isTrue();
@@ -443,8 +443,8 @@ public class FreeListManagerTest {
         new UnsafeMemoryChunk(SMALL_SLAB), 
         new UnsafeMemoryChunk(MEDIUM_SLAB), 
         slab});
-    this.freeListManager.allocate(DEFAULT_SLAB_SIZE-8-(Chunk.MIN_CHUNK_SIZE-1));
-    this.freeListManager.allocate(MEDIUM_SLAB-8-(Chunk.MIN_CHUNK_SIZE-1));
+    this.freeListManager.allocate(DEFAULT_SLAB_SIZE-8-(GemFireChunk.MIN_CHUNK_SIZE-1));
+    this.freeListManager.allocate(MEDIUM_SLAB-8-(GemFireChunk.MIN_CHUNK_SIZE-1));
     
     assertThat(this.freeListManager.compact(SMALL_SLAB)).isTrue();
   }
@@ -672,9 +672,9 @@ public class FreeListManagerTest {
     UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
     long address = chunk.getMemoryAddress();
     this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
-    Chunk c = this.freeListManager.allocate(24);
-    Chunk c2 = this.freeListManager.allocate(24);
-    Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c = this.freeListManager.allocate(24);
+    GemFireChunk c2 = this.freeListManager.allocate(24);
+    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
 
     List<MemoryBlock> ob = this.freeListManager.getOrderedBlocks();
     assertThat(ob).hasSize(3);
@@ -692,8 +692,8 @@ public class FreeListManagerTest {
   public void allocatedBlocksEmptyAfterFree() {
     UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
     this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
-    Chunk c = this.freeListManager.allocate(24);
-    Chunk.release(c.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c = this.freeListManager.allocate(24);
+    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
     List<MemoryBlock> ob = this.freeListManager.getAllocatedBlocks();
     assertThat(ob).hasSize(0);
   }
@@ -702,7 +702,7 @@ public class FreeListManagerTest {
   public void allocatedBlocksHasAllocatedChunk() {
     UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
     this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
-    Chunk c = this.freeListManager.allocate(24);
+    GemFireChunk c = this.freeListManager.allocate(24);
     List<MemoryBlock> ob = this.freeListManager.getAllocatedBlocks();
     assertThat(ob).hasSize(1);
     assertThat(ob.get(0).getMemoryAddress()).isEqualTo(c.getMemoryAddress());
@@ -712,8 +712,8 @@ public class FreeListManagerTest {
   public void allocatedBlocksHasBothAllocatedChunks() {
     UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
     this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
-    Chunk c = this.freeListManager.allocate(24);
-    Chunk c2 = this.freeListManager.allocate(33);
+    GemFireChunk c = this.freeListManager.allocate(24);
+    GemFireChunk c2 = this.freeListManager.allocate(33);
     List<MemoryBlock> ob = this.freeListManager.getAllocatedBlocks();
     assertThat(ob).hasSize(2);
   }
@@ -731,10 +731,10 @@ public class FreeListManagerTest {
     UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(32);
     UnsafeMemoryChunk chunk2 = new UnsafeMemoryChunk(1024*1024*5);
     this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk, chunk2});
-    Chunk c = this.freeListManager.allocate(24);
-    Chunk c2 = this.freeListManager.allocate(1024*1024);
-    Chunk.release(c.getMemoryAddress(), this.freeListManager);
-    Chunk.release(c2.getMemoryAddress(), this.freeListManager);
+    GemFireChunk c = this.freeListManager.allocate(24);
+    GemFireChunk c2 = this.freeListManager.allocate(1024*1024);
+    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    GemFireChunk.release(c2.getMemoryAddress(), this.freeListManager);
     
     LogWriter lw = mock(LogWriter.class);
     this.freeListManager.logOffHeapState(lw, 1024);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListOffHeapRegionJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListOffHeapRegionJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListOffHeapRegionJUnitTest.java
index 93f2039..edbe235 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListOffHeapRegionJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListOffHeapRegionJUnitTest.java
@@ -40,7 +40,7 @@ public class FreeListOffHeapRegionJUnitTest extends OffHeapRegionBase {
 
   @Override
   public int perObjectOverhead() {
-    return Chunk.OFF_HEAP_HEADER_SIZE;
+    return GemFireChunk.OFF_HEAP_HEADER_SIZE;
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java
index 3b2f865..23445cf 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java
@@ -255,7 +255,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
     GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
 
-    int headerBeforeSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + Chunk.REF_COUNT_OFFSET);
+    int headerBeforeSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + GemFireChunk.REF_COUNT_OFFSET);
 
     assertThat(chunk.isSerialized()).isFalse();
 
@@ -263,9 +263,9 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
     assertThat(chunk.isSerialized()).isTrue();
 
-    int headerAfterSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + Chunk.REF_COUNT_OFFSET);
+    int headerAfterSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + GemFireChunk.REF_COUNT_OFFSET);
 
-    assertThat(headerAfterSerializedBitSet).isEqualTo(headerBeforeSerializedBitSet | Chunk.IS_SERIALIZED_BIT);
+    assertThat(headerAfterSerializedBitSet).isEqualTo(headerBeforeSerializedBitSet | GemFireChunk.IS_SERIALIZED_BIT);
 
     chunk.release();
   }
@@ -289,7 +289,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
     GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
 
-    int headerBeforeCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + Chunk.REF_COUNT_OFFSET);
+    int headerBeforeCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + GemFireChunk.REF_COUNT_OFFSET);
 
     assertThat(chunk.isCompressed()).isFalse();
 
@@ -297,9 +297,9 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
     assertThat(chunk.isCompressed()).isTrue();
 
-    int headerAfterCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + Chunk.REF_COUNT_OFFSET);
+    int headerAfterCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + GemFireChunk.REF_COUNT_OFFSET);
 
-    assertThat(headerAfterCompressedBitSet).isEqualTo(headerBeforeCompressedBitSet | Chunk.IS_COMPRESSED_BIT);
+    assertThat(headerAfterCompressedBitSet).isEqualTo(headerBeforeCompressedBitSet | GemFireChunk.IS_COMPRESSED_BIT);
 
     chunk.release();
   }
@@ -484,7 +484,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void readyForFreeShouldResetTheRefCount() {
-    Chunk chunk = createValueAsSerializedStoredObject(getValue());
+    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     int refCountBeforeFreeing = chunk.getRefCount();
     assertThat(refCountBeforeFreeing).isEqualTo(1);
@@ -497,7 +497,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = IllegalStateException.class)
   public void readyForAllocationShouldThrowExceptionIfAlreadyAllocated() {
-    Chunk chunk = createValueAsSerializedStoredObject(getValue());
+    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     // chunk is already allocated when we created it, so calling readyForAllocation should throw exception.
     chunk.readyForAllocation();
@@ -507,7 +507,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void checkIsAllocatedShouldReturnIfAllocated() {
-    Chunk chunk = createValueAsSerializedStoredObject(getValue());
+    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
     chunk.checkIsAllocated();
 
     chunk.release();
@@ -515,7 +515,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = IllegalStateException.class)
   public void checkIsAllocatedShouldThrowExceptionIfNotAllocated() {
-    Chunk chunk = createValueAsSerializedStoredObject(getValue());
+    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
     chunk.release();
     chunk.checkIsAllocated();
 
@@ -524,8 +524,8 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void sendToShouldWriteSerializedValueToDataOutputIfValueIsSerialized() throws IOException {
-    Chunk chunk = createValueAsSerializedStoredObject(getValue());
-    Chunk spyChunk = spy(chunk);
+    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    GemFireChunk spyChunk = spy(chunk);
 
     HeapDataOutputStream dataOutput = mock(HeapDataOutputStream.class);
     ByteBuffer directByteBuffer = ByteBuffer.allocate(1024);
@@ -607,10 +607,10 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
     GemFireChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
 
     ByteBuffer buffer = chunk.createDirectByteBuffer();
-    long bufferAddress = Chunk.getDirectByteBufferAddress(buffer);
+    long bufferAddress = GemFireChunk.getDirectByteBufferAddress(buffer);
 
     // returned address should be starting of the value (after skipping HEADER_SIZE bytes)
-    assertEquals(chunk.getMemoryAddress() + Chunk.OFF_HEAP_HEADER_SIZE, bufferAddress);
+    assertEquals(chunk.getMemoryAddress() + GemFireChunk.OFF_HEAP_HEADER_SIZE, bufferAddress);
 
     chunk.release();
   }
@@ -731,7 +731,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
     GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
 
     // loop though and invoke retain for MAX_REF_COUNT-1 times, as create chunk above counted as one reference
-    for (int i = 0; i < Chunk.MAX_REF_COUNT - 1; i++)
+    for (int i = 0; i < GemFireChunk.MAX_REF_COUNT - 1; i++)
       chunk.retain();
 
     // invoke for the one more time should throw exception
@@ -776,7 +776,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
     assertThat(chunk.toStringForOffHeapByteSource()).endsWith(expected);
 
     // test toString
-    Chunk spy = spy(chunk);
+    GemFireChunk spy = spy(chunk);
     spy.toString();
     verify(spy, times(1)).toStringForOffHeapByteSource();
 
@@ -892,7 +892,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
     GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(new byte[100], isSerialized, isCompressed);
 
     // first fill the unused part with FILL_PATTERN
-    Chunk.fill(chunk.getMemoryAddress());
+    GemFireChunk.fill(chunk.getMemoryAddress());
 
     // Validate that it is filled
     chunk.validateFill();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
index 8a648b5..78143d5 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
@@ -540,11 +540,11 @@ public abstract class OffHeapRegionBase {
     @Released(OffHeapIdentifier.TEST_OFF_HEAP_REGION_BASE_LISTENER)
     @Override
     public void close() {
-      if (this.ohOldValue instanceof Chunk) {
-        ((Chunk)this.ohOldValue).release();
+      if (this.ohOldValue instanceof GemFireChunk) {
+        ((GemFireChunk)this.ohOldValue).release();
       }
-      if (this.ohNewValue instanceof Chunk) {
-        ((Chunk)this.ohNewValue).release();
+      if (this.ohNewValue instanceof GemFireChunk) {
+        ((GemFireChunk)this.ohNewValue).release();
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
index eae2b7a..a611aa5 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
@@ -54,7 +54,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 @Category(UnitTest.class)
 @RunWith(PowerMockRunner.class)
 @PowerMockIgnore("*.UnitTest")
-@PrepareForTest({ Chunk.class, OffHeapRegionEntryHelper.class })
+@PrepareForTest({ GemFireChunk.class, OffHeapRegionEntryHelper.class })
 public class OffHeapRegionEntryHelperJUnitTest {
 
   private static final Long VALUE_IS_NOT_ENCODABLE = 0L;
@@ -294,7 +294,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
   @Test
   public void isOffHeapShouldReturnTrueIfAddressIsOnOffHeap() {
-    Chunk value = createChunk(Long.MAX_VALUE);
+    GemFireChunk value = createChunk(Long.MAX_VALUE);
     assertThat(OffHeapRegionEntryHelper.isOffHeap(value.getMemoryAddress())).isTrue();
   }
 
@@ -327,7 +327,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
     long oldAddress = 1L;
 
     // testing when the newValue is a chunk
-    Chunk newValue = createChunk(Long.MAX_VALUE);
+    GemFireChunk newValue = createChunk(Long.MAX_VALUE);
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldAddress);
     when(re.setAddress(oldAddress, newValue.getMemoryAddress())).thenReturn(Boolean.TRUE);
@@ -440,13 +440,13 @@ public class OffHeapRegionEntryHelperJUnitTest {
     // mock region entry
     OffHeapRegionEntry re = mock(OffHeapRegionEntry.class);
 
-    Chunk oldValue = createChunk(Long.MAX_VALUE);
-    Chunk newValue = createChunk(Long.MAX_VALUE - 1);
+    GemFireChunk oldValue = createChunk(Long.MAX_VALUE);
+    GemFireChunk newValue = createChunk(Long.MAX_VALUE - 1);
 
     // mock Chunk static methods - in-order to verify that release is called
-    PowerMockito.spy(Chunk.class);
-    PowerMockito.doNothing().when(Chunk.class);
-    Chunk.release(oldValue.getMemoryAddress());
+    PowerMockito.spy(GemFireChunk.class);
+    PowerMockito.doNothing().when(GemFireChunk.class);
+    GemFireChunk.release(oldValue.getMemoryAddress());
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldValue.getMemoryAddress());
@@ -460,7 +460,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
     // verify oldAddress is released
     PowerMockito.verifyStatic();
-    Chunk.release(oldValue.getMemoryAddress());
+    GemFireChunk.release(oldValue.getMemoryAddress());
   }
 
   @Test
@@ -475,9 +475,9 @@ public class OffHeapRegionEntryHelperJUnitTest {
     DataAsAddress newAddress = new DataAsAddress(OffHeapRegionEntryHelper.encodeDataAsAddress(newData, false, false));
 
     // mock Chunk static methods - in-order to verify that release is never called
-    PowerMockito.spy(Chunk.class);
-    PowerMockito.doNothing().when(Chunk.class);
-    Chunk.release(oldAddress);
+    PowerMockito.spy(GemFireChunk.class);
+    PowerMockito.doNothing().when(GemFireChunk.class);
+    GemFireChunk.release(oldAddress);
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldAddress);
@@ -491,7 +491,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
     // verify that release is never called as the old address is not on offheap
     PowerMockito.verifyStatic(never());
-    Chunk.release(oldAddress);
+    GemFireChunk.release(oldAddress);
   }
 
   @Test
@@ -505,9 +505,9 @@ public class OffHeapRegionEntryHelperJUnitTest {
     long newAddress = OffHeapRegionEntryHelper.REMOVED_PHASE2_ADDRESS;
 
     // mock Chunk static methods - in-order to verify that release is never called
-    PowerMockito.spy(Chunk.class);
-    PowerMockito.doNothing().when(Chunk.class);
-    Chunk.release(oldAddress);
+    PowerMockito.spy(GemFireChunk.class);
+    PowerMockito.doNothing().when(GemFireChunk.class);
+    GemFireChunk.release(oldAddress);
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldAddress);
@@ -521,7 +521,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
     // verify that release is never called as the old address is not on offheap
     PowerMockito.verifyStatic(never());
-    Chunk.release(oldAddress);
+    GemFireChunk.release(oldAddress);
   }
 
   @Test(expected = IllegalStateException.class)
@@ -541,7 +541,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
     // mock region entry
     OffHeapRegionEntry re = mock(OffHeapRegionEntry.class);
 
-    Chunk chunk = createChunk(Long.MAX_VALUE);
+    GemFireChunk chunk = createChunk(Long.MAX_VALUE);
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(chunk.getMemoryAddress());
@@ -627,10 +627,10 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
   @Test
   public void addressToObjectShouldReturnValueFromChunk() {
-    Chunk expected = createChunk(Long.MAX_VALUE);
+    GemFireChunk expected = createChunk(Long.MAX_VALUE);
     Object actual = OffHeapRegionEntryHelper.addressToObject(expected.getMemoryAddress(), false, null);
 
-    assertThat(actual).isInstanceOf(Chunk.class);
+    assertThat(actual).isInstanceOf(GemFireChunk.class);
     assertThat(actual).isEqualTo(expected);
   }
 



[05/16] incubator-geode git commit: GEODE-481: CI failure: QueryUsingFunctionContextDUnitTest.testQueriesWithFilterKeysOnPRWithBucketDestroy

Posted by ds...@apache.org.
GEODE-481: CI failure: QueryUsingFunctionContextDUnitTest.testQueriesWithFilterKeysOnPRWithBucketDestroy

The error handling for functions is different depending on if it failed locally or remotely.
In this case, the function was failing on the remote node and the try/catch block would have it send
the exception, however there are two types of send exception calls.
We needed it to use the result sender's way to send the exception (possibly less header data)


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

Branch: refs/heads/feature/GEODE-831
Commit: 92be457c6ca230e588cbd053b34c796d8f924e0a
Parents: 4569387
Author: Jason Huynh <hu...@gmail.com>
Authored: Thu Feb 11 10:01:48 2016 -0800
Committer: Jason Huynh <hu...@gmail.com>
Committed: Wed Feb 17 16:38:11 2016 -0800

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


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92be457c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/ExecuteRegionFunction66.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/ExecuteRegionFunction66.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/ExecuteRegionFunction66.java
index 6d9ca49..018d05b 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/ExecuteRegionFunction66.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/ExecuteRegionFunction66.java
@@ -23,13 +23,12 @@ import java.util.Set;
 
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.client.internal.ExecuteFunctionHelper;
-import com.gemstone.gemfire.cache.client.internal.Op;
 import com.gemstone.gemfire.cache.execute.Function;
 import com.gemstone.gemfire.cache.execute.FunctionException;
 import com.gemstone.gemfire.cache.execute.FunctionInvocationTargetException;
 import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.cache.operations.ExecuteFunctionOperationContext;
-import com.gemstone.gemfire.i18n.LogWriterI18n;
+import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
 import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.internal.cache.DistributedRegion;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
@@ -299,9 +298,9 @@ public class ExecuteRegionFunction66 extends BaseCommand {
       }
       catch (FunctionException fe) {
         String message = fe.getMessage();
-
-        if (fe.getCause() instanceof FunctionInvocationTargetException) {
-          if (fe.getCause() instanceof InternalFunctionInvocationTargetException) {
+        Object cause = fe.getCause();
+        if (cause instanceof FunctionInvocationTargetException || cause instanceof QueryInvocationTargetException) {
+          if (cause instanceof InternalFunctionInvocationTargetException) {
             // Fix for #44709: User should not be aware of
             // InternalFunctionInvocationTargetException. No instance of
             // InternalFunctionInvocationTargetException is giving useful


[08/16] incubator-geode git commit: more cleanup of FragmentJUnitTest

Posted by ds...@apache.org.
more cleanup of FragmentJUnitTest


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

Branch: refs/heads/feature/GEODE-831
Commit: a1a7027efb93fa35a1b50ba88986b47661e84d7b
Parents: 58c8fc8
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Wed Feb 17 17:07:02 2016 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed Feb 17 17:07:02 2016 -0800

----------------------------------------------------------------------
 .../gemfire/internal/offheap/FragmentJUnitTest.java      | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a1a7027e/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
index a10564f..acecf97 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
@@ -18,7 +18,6 @@
 package com.gemstone.gemfire.internal.offheap;
 
 import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
 import static org.hamcrest.CoreMatchers.*;
 
 import java.util.Arrays;
@@ -38,8 +37,6 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 @Category(UnitTest.class)
 public class FragmentJUnitTest {
 
-  private OutOfOffHeapMemoryListener ooohml;
-  private OffHeapMemoryStats stats;
   private UnsafeMemoryChunk[] slabs;
 
   static {
@@ -63,18 +60,16 @@ public class FragmentJUnitTest {
 
   @Before
   public void setUp() throws Exception {
-    ooohml = mock(OutOfOffHeapMemoryListener.class);
-    stats = mock(OffHeapMemoryStats.class);
-    
     UnsafeMemoryChunk slab1 = new UnsafeMemoryChunk((int)OffHeapStorage.MIN_SLAB_SIZE);
     UnsafeMemoryChunk slab2 = new UnsafeMemoryChunk((int)OffHeapStorage.MIN_SLAB_SIZE);
     slabs = new UnsafeMemoryChunk[]{slab1, slab2};
-    SimpleMemoryAllocatorImpl.createForUnitTest(ooohml, stats, slabs);
   }
 
   @After
   public void tearDown() throws Exception {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+    for (int i=0; i < slabs.length; i++) {
+      slabs[i].release();
+    }
   }
   
   


[04/16] incubator-geode git commit: GEODE-855: create unit test for Fragment class

Posted by ds...@apache.org.
GEODE-855: create unit test for Fragment class


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

Branch: refs/heads/feature/GEODE-831
Commit: 45693879573b3380f298550b8e1624ee1189f9d4
Parents: b9fe091
Author: Ken Howe <kh...@pivotal.io>
Authored: Tue Jan 26 14:11:16 2016 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed Feb 17 16:17:49 2016 -0800

----------------------------------------------------------------------
 .../internal/offheap/FragmentJUnitTest.java     | 280 +++++++++++++++++++
 1 file changed, 280 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/45693879/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
new file mode 100644
index 0000000..ccc6b67
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
@@ -0,0 +1,280 @@
+/*
+ * 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 org.mockito.Mockito.mock;
+import static org.hamcrest.CoreMatchers.*;
+
+import java.util.Arrays;
+
+import org.assertj.core.api.JUnitSoftAssertions;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.ExpectedException;
+
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class FragmentJUnitTest {
+
+  private SimpleMemoryAllocatorImpl ma;
+  private OutOfOffHeapMemoryListener ooohml;
+  private OffHeapMemoryStats stats;
+  private LogWriter lw;
+  private UnsafeMemoryChunk.Factory umcFactory;
+  private UnsafeMemoryChunk[] slabs;
+  private int numSlabs;
+
+  static {
+    ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
+  }
+  
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+  
+  @Rule
+  public JUnitSoftAssertions softly = new JUnitSoftAssertions();
+
+
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+  }
+
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    ooohml = mock(OutOfOffHeapMemoryListener.class);
+    stats = mock(OffHeapMemoryStats.class);
+    lw = mock(LogWriter.class);
+    
+    numSlabs = 2;
+    umcFactory = new UnsafeMemoryChunk.Factory(){
+      @Override
+      public UnsafeMemoryChunk create(int size) {
+        return new UnsafeMemoryChunk(size);
+      }
+    };
+    slabs = allocateMemorySlabs();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+  }
+  
+  private UnsafeMemoryChunk[] allocateMemorySlabs() {
+    ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, lw, numSlabs, OffHeapStorage.MIN_SLAB_SIZE * numSlabs, OffHeapStorage.MIN_SLAB_SIZE, umcFactory);
+    return ma.getSlabs();
+  }
+
+  
+  @Test
+  public void fragmentConstructorThrowsExceptionForNon8ByteAlignedAddress() {
+      expectedException.expect(IllegalStateException.class);
+      expectedException.expectMessage("address was not 8 byte aligned");
+
+      new Fragment(slabs[0].getMemoryAddress() + 2, 0);
+      fail("Constructor failed to throw exception for non-8-byte alignment");
+  }
+
+  @Test
+  public void zeroSizeFragmentHasNoFreeSpace() {
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), 0);
+    assertThat(fragment.freeSpace(), is(0));
+  }
+
+  @Test
+  public void unallocatedFragmentHasFreeSpaceEqualToFragmentSize() {
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.getSize()).isEqualTo((int)OffHeapStorage.MIN_SLAB_SIZE);
+    softly.assertThat(fragment.freeSpace()).isEqualTo((int)OffHeapStorage.MIN_SLAB_SIZE);
+  }
+
+  @Test
+  public void allocatingFromFragmentReducesFreeSpace() {
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256)).isEqualTo(true);
+    softly.assertThat(fragment.freeSpace()).isEqualTo(768);
+    softly.assertThat(fragment.getFreeIndex()).isEqualTo(256);
+  }
+
+  @Test
+  public void fragementAllocationIsUnsafeWithRespectToAllocationSize() {
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + (int)OffHeapStorage.MIN_SLAB_SIZE + 8)).isEqualTo(true);
+    softly.assertThat(fragment.freeSpace()).isEqualTo(-8);
+  }
+
+  @Test
+  public void getBlockSizeReturnsFreeSpace() {
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256)).isEqualTo(true);
+    softly.assertThat(fragment.getBlockSize()).isEqualTo(fragment.freeSpace());
+  }
+
+  @Test
+  public void getMemoryAdressIsAlwaysFragmentBaseAddress() {
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.getMemoryAddress()).isEqualTo(slabs[0].getMemoryAddress());
+    fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
+    softly.assertThat(fragment.getMemoryAddress()).isEqualTo(slabs[0].getMemoryAddress());
+  }
+  
+  @Test
+  public void getStateIsAlwaysStateUNUSED() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.getState()).isEqualTo(MemoryBlock.State.UNUSED);
+    fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
+    softly.assertThat(fragment.getState()).isEqualTo(MemoryBlock.State.UNUSED);
+  }
+
+  @Test
+  public void getFreeListIdIsAlwaysMinus1() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.getFreeListId()).isEqualTo(-1);
+    fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
+    softly.assertThat(fragment.getFreeListId()).isEqualTo(-1);
+  }
+
+  @Test
+  public void getRefCountIsAlwaysZero() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.getRefCount()).isEqualTo(0);
+    fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
+    softly.assertThat(fragment.getRefCount()).isEqualTo(0);
+  }
+
+  @Test
+  public void getDataTypeIsAlwaysNA() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.getDataType()).isEqualTo("N/A");
+    fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
+    softly.assertThat(fragment.getDataType()).isEqualTo("N/A");
+  }
+
+  @Test
+  public void isSerializedIsAlwaysFalse() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.isSerialized()).isEqualTo(false);
+    fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
+    softly.assertThat(fragment.isSerialized()).isEqualTo(false);
+  }
+
+  @Test
+  public void isCompressedIsAlwaysFalse() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.isCompressed()).isEqualTo(false);
+    fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
+    softly.assertThat(fragment.isCompressed()).isEqualTo(false);
+  }
+
+  @Test
+  public void getDataValueIsAlwaysNull() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.getDataValue()).isNull();
+    fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
+    softly.assertThat(fragment.getDataValue()).isNull();
+  }
+
+  @Test
+  public void getChunkTypeIsAlwaysNull() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    softly.assertThat(fragment.getChunkType()).isNull();
+    fragment.allocate(fragment.getFreeIndex(), fragment.getFreeIndex() + 256);
+    softly.assertThat(fragment.getChunkType()).isNull();
+  }
+
+  @Test
+  public void fragmentEqualsComparesMemoryBlockAddresses() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment0 = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    Fragment sameFragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    Fragment fragment1 = new Fragment(slabs[1].getMemoryAddress(), slabs[1].getSize());
+    softly.assertThat(fragment0.equals(sameFragment)).isEqualTo(true);
+    softly.assertThat(fragment0.equals(fragment1)).isEqualTo(false);
+  }
+
+  @Test
+  public void fragmentEqualsIsFalseForNonFragmentObjects() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment0 = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    assertThat(fragment0.equals(slabs[0]), is(false));
+  }
+
+  @Test
+  public void fragmentHashCodeIsHashCodeOfItsMemoryAddress() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment0 = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    Fragment fragment1 = new Fragment(slabs[1].getMemoryAddress(), slabs[1].getSize());
+    Long fragmentAddress = fragment0.getMemoryAddress();
+    softly.assertThat(fragment0.hashCode()).isEqualTo(fragmentAddress.hashCode())
+                                           .isNotEqualTo(fragment1.hashCode());
+  }
+
+  @Test
+  public void fragmentFillSetsAllBytesToTheSameConstantValue() {
+    slabs = allocateMemorySlabs();
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    Long fragmentAddress = fragment.getMemoryAddress();
+    byte[] bytes = new byte[(int)OffHeapStorage.MIN_SLAB_SIZE];
+    byte[] expectedBytes = new byte[(int)OffHeapStorage.MIN_SLAB_SIZE];
+    Arrays.fill(expectedBytes, Chunk.FILL_BYTE);;
+    fragment.fill();
+    UnsafeMemoryChunk.readAbsoluteBytes(fragmentAddress, bytes, 0, (int)OffHeapStorage.MIN_SLAB_SIZE);
+    assertThat(bytes, is(equalTo(expectedBytes)));
+  }
+
+  @Test
+  public void getNextBlockThrowsExceptionForFragment() {
+    expectedException.expect(UnsupportedOperationException.class);
+
+    slabs = allocateMemorySlabs();
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    fragment.getNextBlock();
+    fail("getNextBlock failed to throw UnsupportedOperationException");
+  }
+
+  @Test
+  public void getSlabIdThrowsExceptionForFragment() {
+    expectedException.expect(UnsupportedOperationException.class);
+
+    slabs = allocateMemorySlabs();
+    Fragment fragment = new Fragment(slabs[0].getMemoryAddress(), slabs[0].getSize());
+    fragment.getSlabId();
+    fail("getSlabId failed to throw UnsupportedOperationException");
+  }
+  
+}


[14/16] incubator-geode git commit: renamed off-heap classes with GemFire in their name

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java
deleted file mode 100644
index c69fc57..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java
+++ /dev/null
@@ -1,737 +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.io.DataOutput;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.ByteBuffer;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.DSCODE;
-import com.gemstone.gemfire.internal.HeapDataOutputStream;
-import com.gemstone.gemfire.internal.InternalDataSerializer;
-import com.gemstone.gemfire.internal.cache.EntryEventImpl;
-import com.gemstone.gemfire.internal.cache.RegionEntry;
-import com.gemstone.gemfire.internal.cache.RegionEntryContext;
-import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
-
-/**
-   * A chunk that stores a Java object.
-   * Currently the object stored in this chunk
-   * is always an entry value of a Region.
-   * Note: this class has a natural ordering that is inconsistent with equals.
-   * Instances of this class should have a short lifetime. We do not store references
-   * to it in the cache. Instead the memoryAddress is stored in a primitive field in
-   * the cache and if used it will then, if needed, create an instance of this class.
-   */
-  public class GemFireChunk extends OffHeapCachedDeserializable implements Comparable<GemFireChunk>, MemoryBlock {
-    /**
-     * The unsafe memory address of the first byte of this chunk
-     */
-    private final long memoryAddress;
-    
-    /**
-     * The useCount, chunkSize, dataSizeDelta, isSerialized, and isCompressed
-     * are all stored in off heap memory in a HEADER. This saves heap memory
-     * by using off heap.
-     */
-    public final static int OFF_HEAP_HEADER_SIZE = 4 + 4;
-    /**
-     * We need to smallest chunk to at least have enough room for a hdr
-     * and for an off heap ref (which is a long).
-     */
-    public final static int MIN_CHUNK_SIZE = OFF_HEAP_HEADER_SIZE + 8;
-    /**
-     * int field.
-     * The number of bytes in this chunk.
-     */
-    private final static int CHUNK_SIZE_OFFSET = 0;
-    /**
-     * Volatile int field
-     * The upper two bits are used for the isSerialized
-     * and isCompressed flags.
-     * The next three bits are unused.
-     * The lower 3 bits of the most significant byte contains a magic number to help us detect
-     * if we are changing the ref count of an object that has been released.
-     * The next byte contains the dataSizeDelta.
-     * The number of bytes of logical data in this chunk.
-     * Since the number of bytes of logical data is always <= chunkSize
-     * and since chunkSize never changes, we have dataSize be
-     * a delta whose max value would be HUGE_MULTIPLE-1.
-     * The lower two bytes contains the use count.
-     */
-    final static int REF_COUNT_OFFSET = 4;
-    /**
-     * The upper two bits are used for the isSerialized
-     * and isCompressed flags.
-     */
-    final static int IS_SERIALIZED_BIT =    0x80000000;
-    final static int IS_COMPRESSED_BIT =    0x40000000;
-    // UNUSED 0x38000000
-    final static int MAGIC_MASK = 0x07000000;
-    final static int MAGIC_NUMBER = 0x05000000;
-    final static int DATA_SIZE_DELTA_MASK = 0x00ff0000;
-    final static int DATA_SIZE_SHIFT = 16;
-    final static int REF_COUNT_MASK =       0x0000ffff;
-    final static int MAX_REF_COUNT = 0xFFFF;
-    final static long FILL_PATTERN = 0x3c3c3c3c3c3c3c3cL;
-    final static byte FILL_BYTE = 0x3c;
-    
-    protected GemFireChunk(long memoryAddress, int chunkSize) {
-      SimpleMemoryAllocatorImpl.validateAddressAndSize(memoryAddress, chunkSize);
-      this.memoryAddress = memoryAddress;
-      setSize(chunkSize);
-      UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, MAGIC_NUMBER);
-    }
-    public void readyForFree() {
-      UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, 0);
-    }
-    public void readyForAllocation() {
-      if (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, 0, MAGIC_NUMBER)) {
-        throw new IllegalStateException("Expected 0 but found " + Integer.toHexString(UnsafeMemoryChunk.readAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET)));
-      }
-    }
-    /**
-     * Should only be used by FakeChunk subclass
-     */
-    protected GemFireChunk() {
-      this.memoryAddress = 0L;
-    }
-    
-    /**
-     * Used to create a Chunk given an existing, already allocated,
-     * memoryAddress. The off heap header has already been initialized.
-     */
-    protected GemFireChunk(long memoryAddress) {
-      SimpleMemoryAllocatorImpl.validateAddress(memoryAddress);
-      this.memoryAddress = memoryAddress;
-    }
-    
-    protected GemFireChunk(GemFireChunk chunk) {
-      this.memoryAddress = chunk.memoryAddress;
-    }
-    
-    /**
-     * Throw an exception if this chunk is not allocated
-     */
-    public void checkIsAllocated() {
-      int originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
-      if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
-        throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
-      }
-    }
-    
-    public void incSize(int inc) {
-      setSize(getSize()+inc);
-    }
-    
-    protected void beforeReturningToAllocator() {
-      
-    }
-
-    @Override
-    public int getSize() {
-      return getSize(this.memoryAddress);
-    }
-
-    public void setSize(int size) {
-      setSize(this.memoryAddress, size);
-    }
-
-    public long getMemoryAddress() {
-      return this.memoryAddress;
-    }
-    
-    public int getDataSize() {
-      /*int dataSizeDelta = UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET);
-      dataSizeDelta &= DATA_SIZE_DELTA_MASK;
-      dataSizeDelta >>= DATA_SIZE_SHIFT;
-      return getSize() - dataSizeDelta;*/
-      return getDataSize(this.memoryAddress);
-    }
-    
-    protected static int getDataSize(long memoryAdress) {
-      int dataSizeDelta = UnsafeMemoryChunk.readAbsoluteInt(memoryAdress+REF_COUNT_OFFSET);
-      dataSizeDelta &= DATA_SIZE_DELTA_MASK;
-      dataSizeDelta >>= DATA_SIZE_SHIFT;
-      return getSize(memoryAdress) - dataSizeDelta;
-    }
-    
-    protected long getBaseDataAddress() {
-      return this.memoryAddress+OFF_HEAP_HEADER_SIZE;
-    }
-    protected int getBaseDataOffset() {
-      return 0;
-    }
-    
-    /**
-     * Creates and returns a direct ByteBuffer that contains the contents of this Chunk.
-     * Note that the returned ByteBuffer has a reference to this chunk's
-     * off-heap address so it can only be used while this Chunk is retained.
-     * @return the created direct byte buffer or null if it could not be created.
-     */
-    @Unretained
-    public ByteBuffer createDirectByteBuffer() {
-      return basicCreateDirectByteBuffer(getBaseDataAddress(), getDataSize());
-    }
-    @Override
-    public void sendTo(DataOutput out) throws IOException {
-      if (!this.isCompressed() && out instanceof HeapDataOutputStream) {
-        ByteBuffer bb = createDirectByteBuffer();
-        if (bb != null) {
-          HeapDataOutputStream hdos = (HeapDataOutputStream) out;
-          if (this.isSerialized()) {
-            hdos.write(bb);
-          } else {
-            hdos.writeByte(DSCODE.BYTE_ARRAY);
-            InternalDataSerializer.writeArrayLength(bb.remaining(), hdos);
-            hdos.write(bb);
-          }
-          return;
-        }
-      }
-      super.sendTo(out);
-    }
-    
-    @Override
-    public void sendAsByteArray(DataOutput out) throws IOException {
-      if (!isCompressed() && out instanceof HeapDataOutputStream) {
-        ByteBuffer bb = createDirectByteBuffer();
-        if (bb != null) {
-          HeapDataOutputStream hdos = (HeapDataOutputStream) out;
-          InternalDataSerializer.writeArrayLength(bb.remaining(), hdos);
-          hdos.write(bb);
-          return;
-        }
-      }
-      super.sendAsByteArray(out);
-    }
-       
-    private static volatile Class dbbClass = null;
-    private static volatile Constructor dbbCtor = null;
-    private static volatile boolean dbbCreateFailed = false;
-    
-    /**
-     * @return the created direct byte buffer or null if it could not be created.
-     */
-    private static ByteBuffer basicCreateDirectByteBuffer(long baseDataAddress, int dataSize) {
-      if (dbbCreateFailed) {
-        return null;
-      }
-      Constructor ctor = dbbCtor;
-      if (ctor == null) {
-        Class c = dbbClass;
-        if (c == null) {
-          try {
-            c = Class.forName("java.nio.DirectByteBuffer");
-          } catch (ClassNotFoundException e) {
-            //throw new IllegalStateException("Could not find java.nio.DirectByteBuffer", e);
-            dbbCreateFailed = true;
-            dbbAddressFailed = true;
-            return null;
-          }
-          dbbClass = c;
-        }
-        try {
-          ctor = c.getDeclaredConstructor(long.class, int.class);
-        } catch (NoSuchMethodException | SecurityException e) {
-          //throw new IllegalStateException("Could not get constructor DirectByteBuffer(long, int)", e);
-          dbbClass = null;
-          dbbCreateFailed = true;
-          return null;
-        }
-        ctor.setAccessible(true);
-        dbbCtor = ctor;
-      }
-      try {
-        return (ByteBuffer)ctor.newInstance(baseDataAddress, dataSize);
-      } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-        //throw new IllegalStateException("Could not create an instance using DirectByteBuffer(long, int)", e);
-        dbbClass = null;
-        dbbCtor = null;
-        dbbCreateFailed = true;
-        return null;
-      }
-    }
-    private static volatile Method dbbAddressMethod = null;
-    private static volatile boolean dbbAddressFailed = false;
-    
-    /**
-     * Returns the address of the Unsafe memory for the first byte of a direct ByteBuffer.
-     * If the buffer is not direct or the address can not be obtained return 0.
-     */
-    public static long getDirectByteBufferAddress(ByteBuffer bb) {
-      if (!bb.isDirect()) {
-        return 0L;
-      }
-      if (dbbAddressFailed) {
-        return 0L;
-      }
-      Method m = dbbAddressMethod;
-      if (m == null) {
-        Class c = dbbClass;
-        if (c == null) {
-          try {
-            c = Class.forName("java.nio.DirectByteBuffer");
-          } catch (ClassNotFoundException e) {
-            //throw new IllegalStateException("Could not find java.nio.DirectByteBuffer", e);
-            dbbCreateFailed = true;
-            dbbAddressFailed = true;
-            return 0L;
-          }
-          dbbClass = c;
-        }
-        try {
-          m = c.getDeclaredMethod("address");
-        } catch (NoSuchMethodException | SecurityException e) {
-          //throw new IllegalStateException("Could not get method DirectByteBuffer.address()", e);
-          dbbClass = null;
-          dbbAddressFailed = true;
-          return 0L;
-        }
-        m.setAccessible(true);
-        dbbAddressMethod = m;
-      }
-      try {
-        return (Long)m.invoke(bb);
-      } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-        //throw new IllegalStateException("Could not create an invoke DirectByteBuffer.address()", e);
-        dbbClass = null;
-        dbbAddressMethod = null;
-        dbbAddressFailed = true;
-        return 0L;
-      }
-    }
-    /**
-     * Returns an address that can be used with unsafe apis to access this chunks memory.
-     * @param offset the offset from this chunk's first byte of the byte the returned address should point to. Must be >= 0.
-     * @param size the number of bytes that will be read using the returned address. Assertion will use this to verify that all the memory accessed belongs to this chunk. Must be > 0.
-     * @return a memory address that can be used with unsafe apis
-     */
-    public long getUnsafeAddress(int offset, int size) {
-      assert offset >= 0 && offset + size <= getDataSize(): "Offset=" + offset + ",size=" + size + ",dataSize=" + getDataSize() + ", chunkSize=" + getSize() + ", but offset + size must be <= " + getDataSize();
-      assert size > 0;
-      long result = getBaseDataAddress() + offset;
-      // validateAddressAndSizeWithinSlab(result, size);
-      return result;
-    }
-    
-    @Override
-    public byte readByte(int offset) {
-      assert offset < getDataSize();
-      return UnsafeMemoryChunk.readAbsoluteByte(getBaseDataAddress() + offset);
-    }
-
-    @Override
-    public void writeByte(int offset, byte value) {
-      assert offset < getDataSize();
-      UnsafeMemoryChunk.writeAbsoluteByte(getBaseDataAddress() + offset, value);
-    }
-
-    @Override
-    public void readBytes(int offset, byte[] bytes) {
-      readBytes(offset, bytes, 0, bytes.length);
-    }
-
-    @Override
-    public void writeBytes(int offset, byte[] bytes) {
-      writeBytes(offset, bytes, 0, bytes.length);
-    }
-
-    public long getAddressForReading(int offset, int size) {
-      //delegate to getUnsafeAddress - as both the methods does return the memory address from given offset
-      return getUnsafeAddress(offset, size);
-    }
-    
-    @Override
-    public void readBytes(int offset, byte[] bytes, int bytesOffset, int size) {
-      assert offset+size <= getDataSize();
-      UnsafeMemoryChunk.readAbsoluteBytes(getBaseDataAddress() + offset, bytes, bytesOffset, size);
-    }
-
-    @Override
-    public void writeBytes(int offset, byte[] bytes, int bytesOffset, int size) {
-      assert offset+size <= getDataSize();
-      UnsafeMemoryChunk.writeAbsoluteBytes(getBaseDataAddress() + offset, bytes, bytesOffset, size);
-    }
-    
-    @Override
-    public void release() {
-      release(this.memoryAddress);
-     }
-
-    @Override
-    public int compareTo(GemFireChunk o) {
-      int result = Integer.signum(getSize() - o.getSize());
-      if (result == 0) {
-        // For the same sized chunks we really don't care about their order
-        // but we need compareTo to only return 0 if the two chunks are identical
-        result = Long.signum(getMemoryAddress() - o.getMemoryAddress());
-      }
-      return result;
-    }
-    
-    @Override
-    public boolean equals(Object o) {
-      if (o instanceof GemFireChunk) {
-        return getMemoryAddress() == ((GemFireChunk) o).getMemoryAddress();
-      }
-      return false;
-    }
-    
-    @Override
-    public int hashCode() {
-      long value = this.getMemoryAddress();
-      return (int)(value ^ (value >>> 32));
-    }
-
-    // OffHeapCachedDeserializable methods 
-    
-    @Override
-    public void setSerializedValue(byte[] value) {
-      writeBytes(0, value);
-    }
-    
-    public byte[] getDecompressedBytes(RegionEntryContext context) {
-      byte[] result = getCompressedBytes();
-      long time = context.getCachePerfStats().startDecompression();
-      result = context.getCompressor().decompress(result);
-      context.getCachePerfStats().endDecompression(time);      
-      return result;
-    }
-    
-    /**
-     * Returns the raw possibly compressed bytes of this chunk
-     */
-    public byte[] getCompressedBytes() {
-      byte[] result = new byte[getDataSize()];
-      readBytes(0, result);
-      //debugLog("reading", true);
-      SimpleMemoryAllocatorImpl.getAllocator().getStats().incReads();
-      return result;
-    }
-    protected byte[] getRawBytes() {
-      byte[] result = getCompressedBytes();
-      // TODO OFFHEAP: change the following to assert !isCompressed();
-      if (isCompressed()) {
-        throw new UnsupportedOperationException();
-      }
-      return result;
-    }
-
-    @Override
-    public byte[] getSerializedValue() {
-      byte [] result = getRawBytes();
-      if (!isSerialized()) {
-        // The object is a byte[]. So we need to make it look like a serialized byte[] in our result
-        result = EntryEventImpl.serialize(result);
-      }
-      return result;
-    }
-    
-    @Override
-    public Object getDeserializedValue(Region r, RegionEntry re) {
-      if (isSerialized()) {
-        // TODO OFFHEAP: debug deserializeChunk
-        return EntryEventImpl.deserialize(getRawBytes());
-        //assert !isCompressed();
-        //return EntryEventImpl.deserializeChunk(this);
-      } else {
-        return getRawBytes();
-      }
-    }
-    
-    /**
-     * We want this to include memory overhead so use getSize() instead of getDataSize().
-     */
-    @Override
-    public int getSizeInBytes() {
-      // Calling getSize includes the off heap header size.
-      // We do not add anything to this since the size of the reference belongs to the region entry size
-      // not the size of this object.
-      return getSize();
-    }
-
-    @Override
-    public int getValueSizeInBytes() {
-      return getDataSize();
-    }
-
-    @Override
-    public void copyBytes(int src, int dst, int size) {
-      throw new UnsupportedOperationException("Implement if used");
-//      assert src+size <= getDataSize();
-//      assert dst+size < getDataSize();
-//      getSlabs()[this.getSlabIdx()].copyBytes(getBaseDataAddress()+src, getBaseDataAddress()+dst, size);
-    }
-
-    @Override
-    public boolean isSerialized() {
-      return (UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET) & IS_SERIALIZED_BIT) != 0;
-    }
-
-    @Override
-    public boolean isCompressed() {
-      return (UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET) & IS_COMPRESSED_BIT) != 0;
-    }
-
-    @Override
-    public boolean retain() {
-      return retain(this.memoryAddress);
-    }
-
-    @Override
-    public int getRefCount() {
-      return getRefCount(this.memoryAddress);
-    }
-
-    public static int getSize(long memAddr) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
-      return UnsafeMemoryChunk.readAbsoluteInt(memAddr+CHUNK_SIZE_OFFSET);
-    }
-    public static void setSize(long memAddr, int size) {
-      SimpleMemoryAllocatorImpl.validateAddressAndSize(memAddr, size);
-      UnsafeMemoryChunk.writeAbsoluteInt(memAddr+CHUNK_SIZE_OFFSET, size);
-    }
-    public static long getNext(long memAddr) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
-      return UnsafeMemoryChunk.readAbsoluteLong(memAddr+OFF_HEAP_HEADER_SIZE);
-    }
-    public static void setNext(long memAddr, long next) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
-      UnsafeMemoryChunk.writeAbsoluteLong(memAddr+OFF_HEAP_HEADER_SIZE, next);
-    }
-    
-    /**
-     * Fills the chunk with a repeated byte fill pattern.
-     * @param baseAddress the starting address for a {@link GemFireChunk}.
-     */
-    public static void fill(long baseAddress) {
-      long startAddress = baseAddress + MIN_CHUNK_SIZE;
-      int size = getSize(baseAddress) - MIN_CHUNK_SIZE;
-      
-      UnsafeMemoryChunk.fill(startAddress, size, FILL_BYTE);
-    }
-    
-    /**
-     * Validates that the fill pattern for this chunk has not been disturbed.  This method
-     * assumes the TINY_MULTIPLE is 8 bytes.
-     * @throws IllegalStateException when the pattern has been violated.
-     */
-    public void validateFill() {
-      assert FreeListManager.TINY_MULTIPLE == 8;
-      
-      long startAddress = getMemoryAddress() + MIN_CHUNK_SIZE;
-      int size = getSize() - MIN_CHUNK_SIZE;
-      
-      for(int i = 0;i < size;i += FreeListManager.TINY_MULTIPLE) {
-        if(UnsafeMemoryChunk.readAbsoluteLong(startAddress + i) != FILL_PATTERN) {
-          throw new IllegalStateException("Fill pattern violated for chunk " + getMemoryAddress() + " with size " + getSize());
-        }        
-      }
-    }
-
-    public void setSerialized(boolean isSerialized) {
-      if (isSerialized) {
-        int bits;
-        int originalBits;
-        do {
-          originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
-          if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
-            throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
-          }
-          bits = originalBits | IS_SERIALIZED_BIT;
-        } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
-      }
-    }
-    public void setCompressed(boolean isCompressed) {
-      if (isCompressed) {
-        int bits;
-        int originalBits;
-        do {
-          originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
-          if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
-            throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
-          }
-          bits = originalBits | IS_COMPRESSED_BIT;
-        } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
-      }
-    }
-    public void setDataSize(int dataSize) { // KIRK
-      assert dataSize <= getSize();
-      int delta = getSize() - dataSize;
-      assert delta <= (DATA_SIZE_DELTA_MASK >> DATA_SIZE_SHIFT);
-      delta <<= DATA_SIZE_SHIFT;
-      int bits;
-      int originalBits;
-      do {
-        originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
-        if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
-          throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
-        }
-        bits = originalBits;
-        bits &= ~DATA_SIZE_DELTA_MASK; // clear the old dataSizeDelta bits
-        bits |= delta; // set the dataSizeDelta bits to the new delta value
-      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
-    }
-    
-    public void initializeUseCount() {
-      int rawBits;
-      do {
-        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
-        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
-          throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(rawBits));
-        }
-        int uc = rawBits & REF_COUNT_MASK;
-        if (uc != 0) {
-          throw new IllegalStateException("Expected use count to be zero but it was: " + uc + " rawBits=0x" + Integer.toHexString(rawBits));
-        }
-      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, rawBits, rawBits+1));
-    }
-
-    public static int getRefCount(long memAddr) {
-      return UnsafeMemoryChunk.readAbsoluteInt(memAddr+REF_COUNT_OFFSET) & REF_COUNT_MASK;
-    }
-
-    public static boolean retain(long memAddr) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
-      int uc;
-      int rawBits;
-      int retryCount = 0;
-      do {
-        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET);
-        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
-          // same as uc == 0
-          // TODO MAGIC_NUMBER rethink its use and interaction with compactor fragments
-          return false;
-        }
-        uc = rawBits & REF_COUNT_MASK;
-        if (uc == MAX_REF_COUNT) {
-          throw new IllegalStateException("Maximum use count exceeded. rawBits=" + Integer.toHexString(rawBits));
-        } else if (uc == 0) {
-          return false;
-        }
-        retryCount++;
-        if (retryCount > 1000) {
-          throw new IllegalStateException("tried to write " + (rawBits+1) + " to @" + Long.toHexString(memAddr) + " 1,000 times.");
-        }
-      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET, rawBits, rawBits+1));
-      //debugLog("use inced ref count " + (uc+1) + " @" + Long.toHexString(memAddr), true);
-      if (ReferenceCountHelper.trackReferenceCounts()) {
-        ReferenceCountHelper.refCountChanged(memAddr, false, uc+1);
-      }
-
-      return true;
-    }
-    public static void release(final long memAddr) {
-      release(memAddr, null);
-    }
-    static void release(final long memAddr, FreeListManager freeListManager) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
-      int newCount;
-      int rawBits;
-      boolean returnToAllocator;
-      do {
-        returnToAllocator = false;
-        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET);
-        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
-          String msg = "It looks like off heap memory @" + Long.toHexString(memAddr) + " was already freed. rawBits=" + Integer.toHexString(rawBits) + " history=" + ReferenceCountHelper.getFreeRefCountInfo(memAddr);
-          //debugLog(msg, true);
-          throw new IllegalStateException(msg);
-        }
-        int curCount = rawBits&REF_COUNT_MASK;
-        if ((curCount) == 0) {
-          //debugLog("too many frees @" + Long.toHexString(memAddr), true);
-          throw new IllegalStateException("Memory has already been freed." + " history=" + ReferenceCountHelper.getFreeRefCountInfo(memAddr) /*+ System.identityHashCode(this)*/);
-        }
-        if (curCount == 1) {
-          newCount = 0; // clear the use count, bits, and the delta size since it will be freed.
-          returnToAllocator = true;
-        } else {
-          newCount = rawBits-1;
-        }
-      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET, rawBits, newCount));
-      //debugLog("free deced ref count " + (newCount&USE_COUNT_MASK) + " @" + Long.toHexString(memAddr), true);
-      if (returnToAllocator ) {
-       if (ReferenceCountHelper.trackReferenceCounts()) {
-          if (ReferenceCountHelper.trackFreedReferenceCounts()) {
-            ReferenceCountHelper.refCountChanged(memAddr, true, newCount&REF_COUNT_MASK);
-          }
-          ReferenceCountHelper.freeRefCountInfo(memAddr);
-        }
-        if (freeListManager == null) {
-          freeListManager = SimpleMemoryAllocatorImpl.getAllocator().getFreeListManager();
-        }
-        freeListManager.free(memAddr);
-      } else {
-        if (ReferenceCountHelper.trackReferenceCounts()) {
-          ReferenceCountHelper.refCountChanged(memAddr, true, newCount&REF_COUNT_MASK);
-        }
-      }
-    }
-    
-    @Override
-    public String toString() {
-      return toStringForOffHeapByteSource();
-      // This old impl is not safe because it calls getDeserializedForReading and we have code that call toString that does not inc the refcount.
-      // Also if this Chunk is compressed we don't know how to decompress it.
-      //return super.toString() + ":<dataSize=" + getDataSize() + " refCount=" + getRefCount() + " addr=" + getMemoryAddress() + " storedObject=" + getDeserializedForReading() + ">";
-    }
-    
-    protected String toStringForOffHeapByteSource() {
-      return super.toString() + ":<dataSize=" + getDataSize() + " refCount=" + getRefCount() + " addr=" + Long.toHexString(getMemoryAddress()) + ">";
-    }
-    
-    @Override
-    public State getState() {
-      if (getRefCount() > 0) {
-        return State.ALLOCATED;
-      } else {
-        return State.DEALLOCATED;
-      }
-    }
-    @Override
-    public MemoryBlock getNextBlock() {
-      throw new UnsupportedOperationException();
-    }
-    @Override
-    public int getBlockSize() {
-      return getSize();
-    }
-    @Override
-    public int getSlabId() {
-      throw new UnsupportedOperationException();
-    }
-    @Override
-    public int getFreeListId() {
-      return -1;
-    }
-    @Override
-    public String getDataType() {
-      return null;
-    }
-    @Override
-    public Object getDataValue() {
-      return null;
-    }
-    public GemFireChunk slice(int position, int limit) {
-      return new GemFireChunkSlice(this, position, limit);
-    }
-  }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSlice.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSlice.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSlice.java
deleted file mode 100644
index 0c27aa3..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSlice.java
+++ /dev/null
@@ -1,44 +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;
-
-/**
- * Represents a slice of a GemFireChunk.
- * A slice is a subsequence of the bytes stored in a GemFireChunk.
- */
-public class GemFireChunkSlice extends GemFireChunk {
-  private final int offset;
-  private final int capacity;
-  public GemFireChunkSlice(GemFireChunk gemFireChunk, int position, int limit) {
-    super(gemFireChunk);
-    this.offset = gemFireChunk.getBaseDataOffset() + position;
-    this.capacity = limit - position;
-  }
-  @Override
-  public int getDataSize() {
-    return this.capacity;
-  }
-  
-  @Override
-  protected long getBaseDataAddress() {
-    return super.getBaseDataAddress() + this.offset;
-  }
-  @Override
-  protected int getBaseDataOffset() {
-    return this.offset;
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
index 820a56c..b41d429 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
@@ -65,15 +65,15 @@ public class MemoryBlockNode implements MemoryBlock {
     if (!isSerialized()) {
       // byte array
       if (isCompressed()) {
-        return "compressed byte[" + ((GemFireChunk)this.block).getDataSize() + "]";
+        return "compressed byte[" + ((ObjectChunk)this.block).getDataSize() + "]";
       } else {
-        return "byte[" + ((GemFireChunk)this.block).getDataSize() + "]";
+        return "byte[" + ((ObjectChunk)this.block).getDataSize() + "]";
       }
     } else if (isCompressed()) {
-      return "compressed object of size " + ((GemFireChunk)this.block).getDataSize();
+      return "compressed object of size " + ((ObjectChunk)this.block).getDataSize();
     }
     //Object obj = EntryEventImpl.deserialize(((Chunk)this.block).getRawBytes());
-    byte[] bytes = ((GemFireChunk)this.block).getRawBytes();
+    byte[] bytes = ((ObjectChunk)this.block).getRawBytes();
     return DataType.getDataType(bytes);
   }
   public boolean isSerialized() {
@@ -88,14 +88,14 @@ public class MemoryBlockNode implements MemoryBlock {
     if (dataType == null || dataType.equals("N/A")) {
       return null;
     } else if (isCompressed()) {
-      return ((GemFireChunk)this.block).getCompressedBytes();
+      return ((ObjectChunk)this.block).getCompressedBytes();
     } else if (!isSerialized()) {
       // byte array
       //return "byte[" + ((Chunk)this.block).getDataSize() + "]";
-      return ((GemFireChunk)this.block).getRawBytes();
+      return ((ObjectChunk)this.block).getRawBytes();
     } else {
       try {
-        byte[] bytes = ((GemFireChunk)this.block).getRawBytes();
+        byte[] bytes = ((ObjectChunk)this.block).getRawBytes();
         return DataSerializer.readObject(DataType.getDataInput(bytes));
       } catch (IOException e) {
         e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunk.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunk.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunk.java
new file mode 100644
index 0000000..29e6956
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunk.java
@@ -0,0 +1,737 @@
+/*
+ * 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.io.DataOutput;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.internal.DSCODE;
+import com.gemstone.gemfire.internal.HeapDataOutputStream;
+import com.gemstone.gemfire.internal.InternalDataSerializer;
+import com.gemstone.gemfire.internal.cache.EntryEventImpl;
+import com.gemstone.gemfire.internal.cache.RegionEntry;
+import com.gemstone.gemfire.internal.cache.RegionEntryContext;
+import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
+
+/**
+   * A chunk that stores a Java object.
+   * Currently the object stored in this chunk
+   * is always an entry value of a Region.
+   * Note: this class has a natural ordering that is inconsistent with equals.
+   * Instances of this class should have a short lifetime. We do not store references
+   * to it in the cache. Instead the memoryAddress is stored in a primitive field in
+   * the cache and if used it will then, if needed, create an instance of this class.
+   */
+  public class ObjectChunk extends OffHeapCachedDeserializable implements Comparable<ObjectChunk>, MemoryBlock {
+    /**
+     * The unsafe memory address of the first byte of this chunk
+     */
+    private final long memoryAddress;
+    
+    /**
+     * The useCount, chunkSize, dataSizeDelta, isSerialized, and isCompressed
+     * are all stored in off heap memory in a HEADER. This saves heap memory
+     * by using off heap.
+     */
+    public final static int OFF_HEAP_HEADER_SIZE = 4 + 4;
+    /**
+     * We need to smallest chunk to at least have enough room for a hdr
+     * and for an off heap ref (which is a long).
+     */
+    public final static int MIN_CHUNK_SIZE = OFF_HEAP_HEADER_SIZE + 8;
+    /**
+     * int field.
+     * The number of bytes in this chunk.
+     */
+    private final static int CHUNK_SIZE_OFFSET = 0;
+    /**
+     * Volatile int field
+     * The upper two bits are used for the isSerialized
+     * and isCompressed flags.
+     * The next three bits are unused.
+     * The lower 3 bits of the most significant byte contains a magic number to help us detect
+     * if we are changing the ref count of an object that has been released.
+     * The next byte contains the dataSizeDelta.
+     * The number of bytes of logical data in this chunk.
+     * Since the number of bytes of logical data is always <= chunkSize
+     * and since chunkSize never changes, we have dataSize be
+     * a delta whose max value would be HUGE_MULTIPLE-1.
+     * The lower two bytes contains the use count.
+     */
+    final static int REF_COUNT_OFFSET = 4;
+    /**
+     * The upper two bits are used for the isSerialized
+     * and isCompressed flags.
+     */
+    final static int IS_SERIALIZED_BIT =    0x80000000;
+    final static int IS_COMPRESSED_BIT =    0x40000000;
+    // UNUSED 0x38000000
+    final static int MAGIC_MASK = 0x07000000;
+    final static int MAGIC_NUMBER = 0x05000000;
+    final static int DATA_SIZE_DELTA_MASK = 0x00ff0000;
+    final static int DATA_SIZE_SHIFT = 16;
+    final static int REF_COUNT_MASK =       0x0000ffff;
+    final static int MAX_REF_COUNT = 0xFFFF;
+    final static long FILL_PATTERN = 0x3c3c3c3c3c3c3c3cL;
+    final static byte FILL_BYTE = 0x3c;
+    
+    protected ObjectChunk(long memoryAddress, int chunkSize) {
+      SimpleMemoryAllocatorImpl.validateAddressAndSize(memoryAddress, chunkSize);
+      this.memoryAddress = memoryAddress;
+      setSize(chunkSize);
+      UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, MAGIC_NUMBER);
+    }
+    public void readyForFree() {
+      UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, 0);
+    }
+    public void readyForAllocation() {
+      if (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, 0, MAGIC_NUMBER)) {
+        throw new IllegalStateException("Expected 0 but found " + Integer.toHexString(UnsafeMemoryChunk.readAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET)));
+      }
+    }
+    /**
+     * Should only be used by FakeChunk subclass
+     */
+    protected ObjectChunk() {
+      this.memoryAddress = 0L;
+    }
+    
+    /**
+     * Used to create a Chunk given an existing, already allocated,
+     * memoryAddress. The off heap header has already been initialized.
+     */
+    protected ObjectChunk(long memoryAddress) {
+      SimpleMemoryAllocatorImpl.validateAddress(memoryAddress);
+      this.memoryAddress = memoryAddress;
+    }
+    
+    protected ObjectChunk(ObjectChunk chunk) {
+      this.memoryAddress = chunk.memoryAddress;
+    }
+    
+    /**
+     * Throw an exception if this chunk is not allocated
+     */
+    public void checkIsAllocated() {
+      int originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
+      if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
+        throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
+      }
+    }
+    
+    public void incSize(int inc) {
+      setSize(getSize()+inc);
+    }
+    
+    protected void beforeReturningToAllocator() {
+      
+    }
+
+    @Override
+    public int getSize() {
+      return getSize(this.memoryAddress);
+    }
+
+    public void setSize(int size) {
+      setSize(this.memoryAddress, size);
+    }
+
+    public long getMemoryAddress() {
+      return this.memoryAddress;
+    }
+    
+    public int getDataSize() {
+      /*int dataSizeDelta = UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET);
+      dataSizeDelta &= DATA_SIZE_DELTA_MASK;
+      dataSizeDelta >>= DATA_SIZE_SHIFT;
+      return getSize() - dataSizeDelta;*/
+      return getDataSize(this.memoryAddress);
+    }
+    
+    protected static int getDataSize(long memoryAdress) {
+      int dataSizeDelta = UnsafeMemoryChunk.readAbsoluteInt(memoryAdress+REF_COUNT_OFFSET);
+      dataSizeDelta &= DATA_SIZE_DELTA_MASK;
+      dataSizeDelta >>= DATA_SIZE_SHIFT;
+      return getSize(memoryAdress) - dataSizeDelta;
+    }
+    
+    protected long getBaseDataAddress() {
+      return this.memoryAddress+OFF_HEAP_HEADER_SIZE;
+    }
+    protected int getBaseDataOffset() {
+      return 0;
+    }
+    
+    /**
+     * Creates and returns a direct ByteBuffer that contains the contents of this Chunk.
+     * Note that the returned ByteBuffer has a reference to this chunk's
+     * off-heap address so it can only be used while this Chunk is retained.
+     * @return the created direct byte buffer or null if it could not be created.
+     */
+    @Unretained
+    public ByteBuffer createDirectByteBuffer() {
+      return basicCreateDirectByteBuffer(getBaseDataAddress(), getDataSize());
+    }
+    @Override
+    public void sendTo(DataOutput out) throws IOException {
+      if (!this.isCompressed() && out instanceof HeapDataOutputStream) {
+        ByteBuffer bb = createDirectByteBuffer();
+        if (bb != null) {
+          HeapDataOutputStream hdos = (HeapDataOutputStream) out;
+          if (this.isSerialized()) {
+            hdos.write(bb);
+          } else {
+            hdos.writeByte(DSCODE.BYTE_ARRAY);
+            InternalDataSerializer.writeArrayLength(bb.remaining(), hdos);
+            hdos.write(bb);
+          }
+          return;
+        }
+      }
+      super.sendTo(out);
+    }
+    
+    @Override
+    public void sendAsByteArray(DataOutput out) throws IOException {
+      if (!isCompressed() && out instanceof HeapDataOutputStream) {
+        ByteBuffer bb = createDirectByteBuffer();
+        if (bb != null) {
+          HeapDataOutputStream hdos = (HeapDataOutputStream) out;
+          InternalDataSerializer.writeArrayLength(bb.remaining(), hdos);
+          hdos.write(bb);
+          return;
+        }
+      }
+      super.sendAsByteArray(out);
+    }
+       
+    private static volatile Class dbbClass = null;
+    private static volatile Constructor dbbCtor = null;
+    private static volatile boolean dbbCreateFailed = false;
+    
+    /**
+     * @return the created direct byte buffer or null if it could not be created.
+     */
+    private static ByteBuffer basicCreateDirectByteBuffer(long baseDataAddress, int dataSize) {
+      if (dbbCreateFailed) {
+        return null;
+      }
+      Constructor ctor = dbbCtor;
+      if (ctor == null) {
+        Class c = dbbClass;
+        if (c == null) {
+          try {
+            c = Class.forName("java.nio.DirectByteBuffer");
+          } catch (ClassNotFoundException e) {
+            //throw new IllegalStateException("Could not find java.nio.DirectByteBuffer", e);
+            dbbCreateFailed = true;
+            dbbAddressFailed = true;
+            return null;
+          }
+          dbbClass = c;
+        }
+        try {
+          ctor = c.getDeclaredConstructor(long.class, int.class);
+        } catch (NoSuchMethodException | SecurityException e) {
+          //throw new IllegalStateException("Could not get constructor DirectByteBuffer(long, int)", e);
+          dbbClass = null;
+          dbbCreateFailed = true;
+          return null;
+        }
+        ctor.setAccessible(true);
+        dbbCtor = ctor;
+      }
+      try {
+        return (ByteBuffer)ctor.newInstance(baseDataAddress, dataSize);
+      } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+        //throw new IllegalStateException("Could not create an instance using DirectByteBuffer(long, int)", e);
+        dbbClass = null;
+        dbbCtor = null;
+        dbbCreateFailed = true;
+        return null;
+      }
+    }
+    private static volatile Method dbbAddressMethod = null;
+    private static volatile boolean dbbAddressFailed = false;
+    
+    /**
+     * Returns the address of the Unsafe memory for the first byte of a direct ByteBuffer.
+     * If the buffer is not direct or the address can not be obtained return 0.
+     */
+    public static long getDirectByteBufferAddress(ByteBuffer bb) {
+      if (!bb.isDirect()) {
+        return 0L;
+      }
+      if (dbbAddressFailed) {
+        return 0L;
+      }
+      Method m = dbbAddressMethod;
+      if (m == null) {
+        Class c = dbbClass;
+        if (c == null) {
+          try {
+            c = Class.forName("java.nio.DirectByteBuffer");
+          } catch (ClassNotFoundException e) {
+            //throw new IllegalStateException("Could not find java.nio.DirectByteBuffer", e);
+            dbbCreateFailed = true;
+            dbbAddressFailed = true;
+            return 0L;
+          }
+          dbbClass = c;
+        }
+        try {
+          m = c.getDeclaredMethod("address");
+        } catch (NoSuchMethodException | SecurityException e) {
+          //throw new IllegalStateException("Could not get method DirectByteBuffer.address()", e);
+          dbbClass = null;
+          dbbAddressFailed = true;
+          return 0L;
+        }
+        m.setAccessible(true);
+        dbbAddressMethod = m;
+      }
+      try {
+        return (Long)m.invoke(bb);
+      } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+        //throw new IllegalStateException("Could not create an invoke DirectByteBuffer.address()", e);
+        dbbClass = null;
+        dbbAddressMethod = null;
+        dbbAddressFailed = true;
+        return 0L;
+      }
+    }
+    /**
+     * Returns an address that can be used with unsafe apis to access this chunks memory.
+     * @param offset the offset from this chunk's first byte of the byte the returned address should point to. Must be >= 0.
+     * @param size the number of bytes that will be read using the returned address. Assertion will use this to verify that all the memory accessed belongs to this chunk. Must be > 0.
+     * @return a memory address that can be used with unsafe apis
+     */
+    public long getUnsafeAddress(int offset, int size) {
+      assert offset >= 0 && offset + size <= getDataSize(): "Offset=" + offset + ",size=" + size + ",dataSize=" + getDataSize() + ", chunkSize=" + getSize() + ", but offset + size must be <= " + getDataSize();
+      assert size > 0;
+      long result = getBaseDataAddress() + offset;
+      // validateAddressAndSizeWithinSlab(result, size);
+      return result;
+    }
+    
+    @Override
+    public byte readByte(int offset) {
+      assert offset < getDataSize();
+      return UnsafeMemoryChunk.readAbsoluteByte(getBaseDataAddress() + offset);
+    }
+
+    @Override
+    public void writeByte(int offset, byte value) {
+      assert offset < getDataSize();
+      UnsafeMemoryChunk.writeAbsoluteByte(getBaseDataAddress() + offset, value);
+    }
+
+    @Override
+    public void readBytes(int offset, byte[] bytes) {
+      readBytes(offset, bytes, 0, bytes.length);
+    }
+
+    @Override
+    public void writeBytes(int offset, byte[] bytes) {
+      writeBytes(offset, bytes, 0, bytes.length);
+    }
+
+    public long getAddressForReading(int offset, int size) {
+      //delegate to getUnsafeAddress - as both the methods does return the memory address from given offset
+      return getUnsafeAddress(offset, size);
+    }
+    
+    @Override
+    public void readBytes(int offset, byte[] bytes, int bytesOffset, int size) {
+      assert offset+size <= getDataSize();
+      UnsafeMemoryChunk.readAbsoluteBytes(getBaseDataAddress() + offset, bytes, bytesOffset, size);
+    }
+
+    @Override
+    public void writeBytes(int offset, byte[] bytes, int bytesOffset, int size) {
+      assert offset+size <= getDataSize();
+      UnsafeMemoryChunk.writeAbsoluteBytes(getBaseDataAddress() + offset, bytes, bytesOffset, size);
+    }
+    
+    @Override
+    public void release() {
+      release(this.memoryAddress);
+     }
+
+    @Override
+    public int compareTo(ObjectChunk o) {
+      int result = Integer.signum(getSize() - o.getSize());
+      if (result == 0) {
+        // For the same sized chunks we really don't care about their order
+        // but we need compareTo to only return 0 if the two chunks are identical
+        result = Long.signum(getMemoryAddress() - o.getMemoryAddress());
+      }
+      return result;
+    }
+    
+    @Override
+    public boolean equals(Object o) {
+      if (o instanceof ObjectChunk) {
+        return getMemoryAddress() == ((ObjectChunk) o).getMemoryAddress();
+      }
+      return false;
+    }
+    
+    @Override
+    public int hashCode() {
+      long value = this.getMemoryAddress();
+      return (int)(value ^ (value >>> 32));
+    }
+
+    // OffHeapCachedDeserializable methods 
+    
+    @Override
+    public void setSerializedValue(byte[] value) {
+      writeBytes(0, value);
+    }
+    
+    public byte[] getDecompressedBytes(RegionEntryContext context) {
+      byte[] result = getCompressedBytes();
+      long time = context.getCachePerfStats().startDecompression();
+      result = context.getCompressor().decompress(result);
+      context.getCachePerfStats().endDecompression(time);      
+      return result;
+    }
+    
+    /**
+     * Returns the raw possibly compressed bytes of this chunk
+     */
+    public byte[] getCompressedBytes() {
+      byte[] result = new byte[getDataSize()];
+      readBytes(0, result);
+      //debugLog("reading", true);
+      SimpleMemoryAllocatorImpl.getAllocator().getStats().incReads();
+      return result;
+    }
+    protected byte[] getRawBytes() {
+      byte[] result = getCompressedBytes();
+      // TODO OFFHEAP: change the following to assert !isCompressed();
+      if (isCompressed()) {
+        throw new UnsupportedOperationException();
+      }
+      return result;
+    }
+
+    @Override
+    public byte[] getSerializedValue() {
+      byte [] result = getRawBytes();
+      if (!isSerialized()) {
+        // The object is a byte[]. So we need to make it look like a serialized byte[] in our result
+        result = EntryEventImpl.serialize(result);
+      }
+      return result;
+    }
+    
+    @Override
+    public Object getDeserializedValue(Region r, RegionEntry re) {
+      if (isSerialized()) {
+        // TODO OFFHEAP: debug deserializeChunk
+        return EntryEventImpl.deserialize(getRawBytes());
+        //assert !isCompressed();
+        //return EntryEventImpl.deserializeChunk(this);
+      } else {
+        return getRawBytes();
+      }
+    }
+    
+    /**
+     * We want this to include memory overhead so use getSize() instead of getDataSize().
+     */
+    @Override
+    public int getSizeInBytes() {
+      // Calling getSize includes the off heap header size.
+      // We do not add anything to this since the size of the reference belongs to the region entry size
+      // not the size of this object.
+      return getSize();
+    }
+
+    @Override
+    public int getValueSizeInBytes() {
+      return getDataSize();
+    }
+
+    @Override
+    public void copyBytes(int src, int dst, int size) {
+      throw new UnsupportedOperationException("Implement if used");
+//      assert src+size <= getDataSize();
+//      assert dst+size < getDataSize();
+//      getSlabs()[this.getSlabIdx()].copyBytes(getBaseDataAddress()+src, getBaseDataAddress()+dst, size);
+    }
+
+    @Override
+    public boolean isSerialized() {
+      return (UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET) & IS_SERIALIZED_BIT) != 0;
+    }
+
+    @Override
+    public boolean isCompressed() {
+      return (UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET) & IS_COMPRESSED_BIT) != 0;
+    }
+
+    @Override
+    public boolean retain() {
+      return retain(this.memoryAddress);
+    }
+
+    @Override
+    public int getRefCount() {
+      return getRefCount(this.memoryAddress);
+    }
+
+    public static int getSize(long memAddr) {
+      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      return UnsafeMemoryChunk.readAbsoluteInt(memAddr+CHUNK_SIZE_OFFSET);
+    }
+    public static void setSize(long memAddr, int size) {
+      SimpleMemoryAllocatorImpl.validateAddressAndSize(memAddr, size);
+      UnsafeMemoryChunk.writeAbsoluteInt(memAddr+CHUNK_SIZE_OFFSET, size);
+    }
+    public static long getNext(long memAddr) {
+      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      return UnsafeMemoryChunk.readAbsoluteLong(memAddr+OFF_HEAP_HEADER_SIZE);
+    }
+    public static void setNext(long memAddr, long next) {
+      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      UnsafeMemoryChunk.writeAbsoluteLong(memAddr+OFF_HEAP_HEADER_SIZE, next);
+    }
+    
+    /**
+     * Fills the chunk with a repeated byte fill pattern.
+     * @param baseAddress the starting address for a {@link ObjectChunk}.
+     */
+    public static void fill(long baseAddress) {
+      long startAddress = baseAddress + MIN_CHUNK_SIZE;
+      int size = getSize(baseAddress) - MIN_CHUNK_SIZE;
+      
+      UnsafeMemoryChunk.fill(startAddress, size, FILL_BYTE);
+    }
+    
+    /**
+     * Validates that the fill pattern for this chunk has not been disturbed.  This method
+     * assumes the TINY_MULTIPLE is 8 bytes.
+     * @throws IllegalStateException when the pattern has been violated.
+     */
+    public void validateFill() {
+      assert FreeListManager.TINY_MULTIPLE == 8;
+      
+      long startAddress = getMemoryAddress() + MIN_CHUNK_SIZE;
+      int size = getSize() - MIN_CHUNK_SIZE;
+      
+      for(int i = 0;i < size;i += FreeListManager.TINY_MULTIPLE) {
+        if(UnsafeMemoryChunk.readAbsoluteLong(startAddress + i) != FILL_PATTERN) {
+          throw new IllegalStateException("Fill pattern violated for chunk " + getMemoryAddress() + " with size " + getSize());
+        }        
+      }
+    }
+
+    public void setSerialized(boolean isSerialized) {
+      if (isSerialized) {
+        int bits;
+        int originalBits;
+        do {
+          originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
+          if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
+            throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
+          }
+          bits = originalBits | IS_SERIALIZED_BIT;
+        } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
+      }
+    }
+    public void setCompressed(boolean isCompressed) {
+      if (isCompressed) {
+        int bits;
+        int originalBits;
+        do {
+          originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
+          if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
+            throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
+          }
+          bits = originalBits | IS_COMPRESSED_BIT;
+        } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
+      }
+    }
+    public void setDataSize(int dataSize) { // KIRK
+      assert dataSize <= getSize();
+      int delta = getSize() - dataSize;
+      assert delta <= (DATA_SIZE_DELTA_MASK >> DATA_SIZE_SHIFT);
+      delta <<= DATA_SIZE_SHIFT;
+      int bits;
+      int originalBits;
+      do {
+        originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
+        if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
+          throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
+        }
+        bits = originalBits;
+        bits &= ~DATA_SIZE_DELTA_MASK; // clear the old dataSizeDelta bits
+        bits |= delta; // set the dataSizeDelta bits to the new delta value
+      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
+    }
+    
+    public void initializeUseCount() {
+      int rawBits;
+      do {
+        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
+        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
+          throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(rawBits));
+        }
+        int uc = rawBits & REF_COUNT_MASK;
+        if (uc != 0) {
+          throw new IllegalStateException("Expected use count to be zero but it was: " + uc + " rawBits=0x" + Integer.toHexString(rawBits));
+        }
+      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, rawBits, rawBits+1));
+    }
+
+    public static int getRefCount(long memAddr) {
+      return UnsafeMemoryChunk.readAbsoluteInt(memAddr+REF_COUNT_OFFSET) & REF_COUNT_MASK;
+    }
+
+    public static boolean retain(long memAddr) {
+      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      int uc;
+      int rawBits;
+      int retryCount = 0;
+      do {
+        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET);
+        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
+          // same as uc == 0
+          // TODO MAGIC_NUMBER rethink its use and interaction with compactor fragments
+          return false;
+        }
+        uc = rawBits & REF_COUNT_MASK;
+        if (uc == MAX_REF_COUNT) {
+          throw new IllegalStateException("Maximum use count exceeded. rawBits=" + Integer.toHexString(rawBits));
+        } else if (uc == 0) {
+          return false;
+        }
+        retryCount++;
+        if (retryCount > 1000) {
+          throw new IllegalStateException("tried to write " + (rawBits+1) + " to @" + Long.toHexString(memAddr) + " 1,000 times.");
+        }
+      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET, rawBits, rawBits+1));
+      //debugLog("use inced ref count " + (uc+1) + " @" + Long.toHexString(memAddr), true);
+      if (ReferenceCountHelper.trackReferenceCounts()) {
+        ReferenceCountHelper.refCountChanged(memAddr, false, uc+1);
+      }
+
+      return true;
+    }
+    public static void release(final long memAddr) {
+      release(memAddr, null);
+    }
+    static void release(final long memAddr, FreeListManager freeListManager) {
+      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
+      int newCount;
+      int rawBits;
+      boolean returnToAllocator;
+      do {
+        returnToAllocator = false;
+        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET);
+        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
+          String msg = "It looks like off heap memory @" + Long.toHexString(memAddr) + " was already freed. rawBits=" + Integer.toHexString(rawBits) + " history=" + ReferenceCountHelper.getFreeRefCountInfo(memAddr);
+          //debugLog(msg, true);
+          throw new IllegalStateException(msg);
+        }
+        int curCount = rawBits&REF_COUNT_MASK;
+        if ((curCount) == 0) {
+          //debugLog("too many frees @" + Long.toHexString(memAddr), true);
+          throw new IllegalStateException("Memory has already been freed." + " history=" + ReferenceCountHelper.getFreeRefCountInfo(memAddr) /*+ System.identityHashCode(this)*/);
+        }
+        if (curCount == 1) {
+          newCount = 0; // clear the use count, bits, and the delta size since it will be freed.
+          returnToAllocator = true;
+        } else {
+          newCount = rawBits-1;
+        }
+      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET, rawBits, newCount));
+      //debugLog("free deced ref count " + (newCount&USE_COUNT_MASK) + " @" + Long.toHexString(memAddr), true);
+      if (returnToAllocator ) {
+       if (ReferenceCountHelper.trackReferenceCounts()) {
+          if (ReferenceCountHelper.trackFreedReferenceCounts()) {
+            ReferenceCountHelper.refCountChanged(memAddr, true, newCount&REF_COUNT_MASK);
+          }
+          ReferenceCountHelper.freeRefCountInfo(memAddr);
+        }
+        if (freeListManager == null) {
+          freeListManager = SimpleMemoryAllocatorImpl.getAllocator().getFreeListManager();
+        }
+        freeListManager.free(memAddr);
+      } else {
+        if (ReferenceCountHelper.trackReferenceCounts()) {
+          ReferenceCountHelper.refCountChanged(memAddr, true, newCount&REF_COUNT_MASK);
+        }
+      }
+    }
+    
+    @Override
+    public String toString() {
+      return toStringForOffHeapByteSource();
+      // This old impl is not safe because it calls getDeserializedForReading and we have code that call toString that does not inc the refcount.
+      // Also if this Chunk is compressed we don't know how to decompress it.
+      //return super.toString() + ":<dataSize=" + getDataSize() + " refCount=" + getRefCount() + " addr=" + getMemoryAddress() + " storedObject=" + getDeserializedForReading() + ">";
+    }
+    
+    protected String toStringForOffHeapByteSource() {
+      return super.toString() + ":<dataSize=" + getDataSize() + " refCount=" + getRefCount() + " addr=" + Long.toHexString(getMemoryAddress()) + ">";
+    }
+    
+    @Override
+    public State getState() {
+      if (getRefCount() > 0) {
+        return State.ALLOCATED;
+      } else {
+        return State.DEALLOCATED;
+      }
+    }
+    @Override
+    public MemoryBlock getNextBlock() {
+      throw new UnsupportedOperationException();
+    }
+    @Override
+    public int getBlockSize() {
+      return getSize();
+    }
+    @Override
+    public int getSlabId() {
+      throw new UnsupportedOperationException();
+    }
+    @Override
+    public int getFreeListId() {
+      return -1;
+    }
+    @Override
+    public String getDataType() {
+      return null;
+    }
+    @Override
+    public Object getDataValue() {
+      return null;
+    }
+    public ObjectChunk slice(int position, int limit) {
+      return new ObjectChunkSlice(this, position, limit);
+    }
+  }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSlice.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSlice.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSlice.java
new file mode 100644
index 0000000..0a1ca15
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSlice.java
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+/**
+ * Represents a slice of a GemFireChunk.
+ * A slice is a subsequence of the bytes stored in a GemFireChunk.
+ */
+public class ObjectChunkSlice extends ObjectChunk {
+  private final int offset;
+  private final int capacity;
+  public ObjectChunkSlice(ObjectChunk gemFireChunk, int position, int limit) {
+    super(gemFireChunk);
+    this.offset = gemFireChunk.getBaseDataOffset() + position;
+    this.capacity = limit - position;
+  }
+  @Override
+  public int getDataSize() {
+    return this.capacity;
+  }
+  
+  @Override
+  protected long getBaseDataAddress() {
+    return super.getBaseDataAddress() + this.offset;
+  }
+  @Override
+  protected int getBaseDataOffset() {
+    return this.offset;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
index 35f5fc2..bd380e2 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
@@ -46,7 +46,7 @@ public abstract class OffHeapCachedDeserializable extends AbstractStoredObject i
     if (isSerialized()) {
       userBits = EntryBits.setSerialized(userBits, true);
     }
-    wrapper.setChunkData((GemFireChunk) this, userBits);
+    wrapper.setChunkData((ObjectChunk) this, userBits);
   }
   
   String getShortClassName() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
index e662cfc..b62d97a 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelper.java
@@ -63,7 +63,7 @@ public class OffHeapRegionEntryHelper {
   };
   
   private static long objectToAddress(@Unretained Object v) {
-    if (v instanceof GemFireChunk) return ((GemFireChunk) v).getMemoryAddress();
+    if (v instanceof ObjectChunk) return ((ObjectChunk) v).getMemoryAddress();
     if (v instanceof DataAsAddress) return ((DataAsAddress) v).getEncodedAddress();
     if (v == null) return NULL_ADDRESS;
     if (v == Token.TOMBSTONE) return TOMBSTONE_ADDRESS;
@@ -90,7 +90,7 @@ public class OffHeapRegionEntryHelper {
   @Unretained @Retained
   public static Object addressToObject(@Released @Retained long ohAddress, boolean decompress, RegionEntryContext context) {
     if (isOffHeap(ohAddress)) {
-      @Unretained GemFireChunk chunk =  new GemFireChunk(ohAddress);
+      @Unretained ObjectChunk chunk =  new ObjectChunk(ohAddress);
       @Unretained Object result = chunk;
       if (decompress && chunk.isCompressed()) {
         try {
@@ -160,7 +160,7 @@ public class OffHeapRegionEntryHelper {
 
   private static void releaseAddress(@Released long ohAddress) {
     if (isOffHeap(ohAddress)) {
-      GemFireChunk.release(ohAddress);
+      ObjectChunk.release(ohAddress);
     }
   }
   
@@ -354,11 +354,11 @@ public class OffHeapRegionEntryHelper {
     int retryCount = 0;
     @Retained long addr = re.getAddress();
     while (isOffHeap(addr)) {
-      if (GemFireChunk.retain(addr)) {
+      if (ObjectChunk.retain(addr)) {
         @Unretained long addr2 = re.getAddress();
         if (addr != addr2) {
           retryCount = 0;
-          GemFireChunk.release(addr);
+          ObjectChunk.release(addr);
           // spin around and try again.
           addr = addr2;
         } else {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
index 209005c..14bde59 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
@@ -224,20 +224,20 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
     this.stats.incFreeMemory(this.freeList.getTotalMemory());
   }
   
-  public List<GemFireChunk> getLostChunks() {
-    List<GemFireChunk> liveChunks = this.freeList.getLiveChunks();
-    List<GemFireChunk> regionChunks = getRegionLiveChunks();
-    Set<GemFireChunk> liveChunksSet = new HashSet<>(liveChunks);
-    Set<GemFireChunk> regionChunksSet = new HashSet<>(regionChunks);
+  public List<ObjectChunk> getLostChunks() {
+    List<ObjectChunk> liveChunks = this.freeList.getLiveChunks();
+    List<ObjectChunk> regionChunks = getRegionLiveChunks();
+    Set<ObjectChunk> liveChunksSet = new HashSet<>(liveChunks);
+    Set<ObjectChunk> regionChunksSet = new HashSet<>(regionChunks);
     liveChunksSet.removeAll(regionChunksSet);
-    return new ArrayList<GemFireChunk>(liveChunksSet);
+    return new ArrayList<ObjectChunk>(liveChunksSet);
   }
   
   /**
    * Returns a possibly empty list that contains all the Chunks used by regions.
    */
-  private List<GemFireChunk> getRegionLiveChunks() {
-    ArrayList<GemFireChunk> result = new ArrayList<GemFireChunk>();
+  private List<ObjectChunk> getRegionLiveChunks() {
+    ArrayList<ObjectChunk> result = new ArrayList<ObjectChunk>();
     RegionService gfc = GemFireCacheImpl.getInstance();
     if (gfc != null) {
       Iterator<Region<?,?>> rootIt = gfc.rootRegions().iterator();
@@ -253,7 +253,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
     return result;
   }
 
-  private void getRegionLiveChunks(Region<?,?> r, List<GemFireChunk> result) {
+  private void getRegionLiveChunks(Region<?,?> r, List<ObjectChunk> result) {
     if (r.getAttributes().getOffHeap()) {
 
       if (r instanceof PartitionedRegion) {
@@ -277,7 +277,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
 
   }
   
-  private void basicGetRegionLiveChunks(LocalRegion r, List<GemFireChunk> result) {
+  private void basicGetRegionLiveChunks(LocalRegion r, List<ObjectChunk> result) {
     for (Object key : r.keySet()) {
       RegionEntry re = ((LocalRegion) r).getRegionEntry(key);
       if (re != null) {
@@ -286,15 +286,15 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
          */
         @Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE)
         Object value = re._getValue();
-        if (value instanceof GemFireChunk) {
-          result.add((GemFireChunk) value);
+        if (value instanceof ObjectChunk) {
+          result.add((ObjectChunk) value);
         }
       }
     }
   }
 
-  private GemFireChunk allocateChunk(int size) {
-    GemFireChunk result = this.freeList.allocate(size);
+  private ObjectChunk allocateChunk(int size) {
+    ObjectChunk result = this.freeList.allocate(size);
     int resultSize = result.getSize();
     stats.incObjects(1);
     stats.incUsedMemory(resultSize);
@@ -309,7 +309,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
   @Override
   public MemoryChunk allocate(int size) {
     //System.out.println("allocating " + size);
-    GemFireChunk result = allocateChunk(size);
+    ObjectChunk result = allocateChunk(size);
     //("allocated off heap object of size " + size + " @" + Long.toHexString(result.getMemoryAddress()), true);
     return result;
   }
@@ -328,7 +328,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
     if (addr != 0L) {
       return new DataAsAddress(addr);
     }
-    GemFireChunk result = allocateChunk(v.length);
+    ObjectChunk result = allocateChunk(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);
@@ -485,11 +485,11 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
   }
 
   public synchronized List<MemoryBlock> getOrphans() {
-    List<GemFireChunk> liveChunks = this.freeList.getLiveChunks();
-    List<GemFireChunk> regionChunks = getRegionLiveChunks();
+    List<ObjectChunk> liveChunks = this.freeList.getLiveChunks();
+    List<ObjectChunk> regionChunks = getRegionLiveChunks();
     liveChunks.removeAll(regionChunks);
     List<MemoryBlock> orphans = new ArrayList<MemoryBlock>();
-    for (GemFireChunk chunk: liveChunks) {
+    for (ObjectChunk chunk: liveChunks) {
       orphans.add(new MemoryBlockNode(this, chunk));
     }
     Collections.sort(orphans,

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SyncChunkStack.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SyncChunkStack.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SyncChunkStack.java
index a532ccf..99fd96f 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SyncChunkStack.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SyncChunkStack.java
@@ -42,7 +42,7 @@ public class SyncChunkStack {
     assert e != 0;
     SimpleMemoryAllocatorImpl.validateAddress(e);
     synchronized (this) {
-      GemFireChunk.setNext(e, this.topAddr);
+      ObjectChunk.setNext(e, this.topAddr);
       this.topAddr = e;
     }
   }
@@ -51,7 +51,7 @@ public class SyncChunkStack {
     synchronized (this) {
       result = this.topAddr;
       if (result != 0L) {
-        this.topAddr = GemFireChunk.getNext(result);
+        this.topAddr = ObjectChunk.getNext(result);
       }
     }
     return result;
@@ -85,8 +85,8 @@ public class SyncChunkStack {
       concurrentModDetected = false;
       addr = headAddr;
       while (addr != 0L) {
-        int curSize = GemFireChunk.getSize(addr);
-        addr = GemFireChunk.getNext(addr);
+        int curSize = ObjectChunk.getSize(addr);
+        addr = ObjectChunk.getNext(addr);
         testHookDoConcurrentModification();
         long curHead = this.topAddr;
         if (curHead != headAddr) {
@@ -113,8 +113,8 @@ public class SyncChunkStack {
       result = 0;
       addr = headAddr;
       while (addr != 0L) {
-        result += GemFireChunk.getSize(addr);
-        addr = GemFireChunk.getNext(addr);
+        result += ObjectChunk.getSize(addr);
+        addr = ObjectChunk.getNext(addr);
         testHookDoConcurrentModification();
         long curHead = this.topAddr;
         if (curHead != headAddr) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ByteBufferInputStream.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ByteBufferInputStream.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ByteBufferInputStream.java
index 0097a34..cfc05f2 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ByteBufferInputStream.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ByteBufferInputStream.java
@@ -31,7 +31,7 @@ import java.nio.ByteOrder;
 
 import com.gemstone.gemfire.internal.ByteBufferWriter;
 import com.gemstone.gemfire.internal.HeapDataOutputStream;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.UnsafeMemoryChunk;
 
 /**
@@ -109,7 +109,7 @@ public class ByteBufferInputStream extends InputStream implements DataInput, jav
     public static ByteSource create(ByteBuffer bb) {
       return new ByteBufferByteSource(bb);
     }
-    public static ByteSource create(GemFireChunk chunk) {
+    public static ByteSource create(ObjectChunk chunk) {
       // Since I found a way to create a DirectByteBuffer (using reflection) from a Chunk
       // we might not even need the ByteSource abstraction any more.
       // But it is possible that createByteBuffer will not work on a different jdk so keep it for now.
@@ -323,9 +323,9 @@ public class ByteBufferInputStream extends InputStream implements DataInput, jav
   public static class OffHeapByteSource implements ByteSource {
     private int position;
     private int limit;
-    private final GemFireChunk chunk;
+    private final ObjectChunk chunk;
 
-    public OffHeapByteSource(GemFireChunk c) {
+    public OffHeapByteSource(ObjectChunk c) {
       this.chunk = c;
       this.position = 0;
       this.limit = capacity();
@@ -724,7 +724,7 @@ public class ByteBufferInputStream extends InputStream implements DataInput, jav
     this.buffer = copy.buffer.duplicate();
   }
 
-  public ByteBufferInputStream(GemFireChunk blob) {
+  public ByteBufferInputStream(ObjectChunk blob) {
     this.buffer = ByteSourceFactory.create(blob);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ImmutableByteBufferInputStream.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ImmutableByteBufferInputStream.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ImmutableByteBufferInputStream.java
index a765c3d..d632158 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ImmutableByteBufferInputStream.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/ImmutableByteBufferInputStream.java
@@ -18,7 +18,7 @@ package com.gemstone.gemfire.internal.tcp;
 
 import java.nio.ByteBuffer;
 
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 
 /**
  * You should only create an instance of this class if the bytes this buffer reads
@@ -67,7 +67,7 @@ public class ImmutableByteBufferInputStream extends ByteBufferInputStream {
     // for serialization
   }
   
-  public ImmutableByteBufferInputStream(GemFireChunk blob) {
+  public ImmutableByteBufferInputStream(ObjectChunk blob) {
     super(blob);
   }
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
index d4dae92..40015a4 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
@@ -27,7 +27,7 @@ import com.gemstone.gemfire.internal.DSCODE;
 import com.gemstone.gemfire.internal.HeapDataOutputStream;
 import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.pdx.internal.PdxInputStream;
 
@@ -140,7 +140,7 @@ public class BlobHelper {
    * If a PdxInstance is returned then it will refer to Chunk's off-heap memory
    * with an unretained reference.
    */
-  public static @Unretained Object deserializeOffHeapBlob(GemFireChunk blob) throws IOException, ClassNotFoundException {
+  public static @Unretained Object deserializeOffHeapBlob(ObjectChunk blob) throws IOException, ClassNotFoundException {
     Object result;
     final long start = startDeserialization();
     // For both top level and nested pdxs we just want a reference to this off-heap blob.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInputStream.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInputStream.java b/gemfire-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInputStream.java
index 74277f4..4a5a9df 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInputStream.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInputStream.java
@@ -26,7 +26,7 @@ import java.util.Date;
 import com.gemstone.gemfire.DataSerializer;
 import com.gemstone.gemfire.InternalGemFireException;
 import com.gemstone.gemfire.pdx.PdxSerializationException;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream;
 import com.gemstone.gemfire.internal.tcp.ImmutableByteBufferInputStream;
 
@@ -76,7 +76,7 @@ public class PdxInputStream extends ImmutableByteBufferInputStream {
     // for serialization
   }
 
-  public PdxInputStream(GemFireChunk blob) {
+  public PdxInputStream(ObjectChunk blob) {
     super(blob);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
index 5d2f8d0..b69f82e 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
@@ -29,7 +29,7 @@ import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.ChunkValueWrapper;
 import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.Flushable;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
 import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
 import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
@@ -40,7 +40,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 public class ChunkValueWrapperJUnitTest {
 
   private static ChunkValueWrapper createChunkValueWrapper(byte[] bytes, boolean isSerialized) {
-    GemFireChunk c = (GemFireChunk)SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, isSerialized, false);
+    ObjectChunk c = (ObjectChunk)SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, isSerialized, false);
     return new ChunkValueWrapper(c);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
index 0b1d130..690b55a 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
@@ -26,7 +26,7 @@ import org.junit.Test;
 
 import com.gemstone.gemfire.internal.HeapDataOutputStream;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl.OldValueImporter;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.DataAsAddress;
 import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
 import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
@@ -130,7 +130,7 @@ public abstract class OldValueImporterTestBase {
           SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{new UnsafeMemoryChunk(1024*1024)});
       try {
         byte[] baValue = new byte[] {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
-        GemFireChunk baValueSO = (GemFireChunk) sma.allocateAndInitialize(baValue, false, false);
+        ObjectChunk baValueSO = (ObjectChunk) sma.allocateAndInitialize(baValue, false, false);
         OldValueImporter omsg = createImporter();
         omsg.importOldObject(baValueSO, false);
         hdos = new HeapDataOutputStream(bytes);
@@ -166,7 +166,7 @@ public abstract class OldValueImporterTestBase {
       try {
         String baValue = "12345678";
         byte[] baValueBlob = BlobHelper.serializeToBlob(baValue);
-        GemFireChunk baValueSO = (GemFireChunk) sma.allocateAndInitialize(baValueBlob, true, false);
+        ObjectChunk baValueSO = (ObjectChunk) sma.allocateAndInitialize(baValueBlob, true, false);
         OldValueImporter omsg = createImporter();
         omsg.importOldObject(baValueSO, true);
         hdos = new HeapDataOutputStream(bytes);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapFormJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapFormJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapFormJUnitTest.java
index 8f9473f..b4a3084 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapFormJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapFormJUnitTest.java
@@ -33,7 +33,7 @@ public class ChunkWithHeapFormJUnitTest extends GemFireChunkJUnitTest {
 
   @Test
   public void getRawBytesShouldReturnCachedHeapForm() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
 
     byte[] valueInBytes = getValueAsByteArray();
     ChunkWithHeapForm heapForm = new ChunkWithHeapForm(chunk, valueInBytes);
@@ -45,15 +45,15 @@ public class ChunkWithHeapFormJUnitTest extends GemFireChunkJUnitTest {
 
   @Test
   public void getChunkWithoutHeapFormShouldReturnGemFireChunk() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     byte[] valueInBytes = getValueAsByteArray();
     ChunkWithHeapForm heapForm = new ChunkWithHeapForm(chunk, valueInBytes);
 
-    GemFireChunk chunkWithOutHeapForm = heapForm.getChunkWithoutHeapForm();
+    ObjectChunk chunkWithOutHeapForm = heapForm.getChunkWithoutHeapForm();
 
     assertNotNull(chunkWithOutHeapForm);
-    assertEquals(GemFireChunk.class, chunkWithOutHeapForm.getClass());
+    assertEquals(ObjectChunk.class, chunkWithOutHeapForm.getClass());
 
     assertEquals(chunk, heapForm.getChunkWithoutHeapForm());
 



[16/16] incubator-geode git commit: fixed some names in comments and params

Posted by ds...@apache.org.
fixed some names in comments and params


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

Branch: refs/heads/feature/GEODE-831
Commit: 610ebd50b3bbd2604f5af3aea84f03483f62572f
Parents: 1a82c80
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Thu Feb 18 17:05:10 2016 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Thu Feb 18 17:05:10 2016 -0800

----------------------------------------------------------------------
 .../gemfire/internal/offheap/ObjectChunkSlice.java        | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/610ebd50/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSlice.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSlice.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSlice.java
index 0a1ca15..3d6bf57 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSlice.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSlice.java
@@ -17,15 +17,15 @@
 package com.gemstone.gemfire.internal.offheap;
 
 /**
- * Represents a slice of a GemFireChunk.
- * A slice is a subsequence of the bytes stored in a GemFireChunk.
+ * Represents a slice of an ObjectChunk.
+ * A slice is a subsequence of the bytes stored in an ObjectChunk.
  */
 public class ObjectChunkSlice extends ObjectChunk {
   private final int offset;
   private final int capacity;
-  public ObjectChunkSlice(ObjectChunk gemFireChunk, int position, int limit) {
-    super(gemFireChunk);
-    this.offset = gemFireChunk.getBaseDataOffset() + position;
+  public ObjectChunkSlice(ObjectChunk objectChunk, int position, int limit) {
+    super(objectChunk);
+    this.offset = objectChunk.getBaseDataOffset() + position;
     this.capacity = limit - position;
   }
   @Override


[13/16] incubator-geode git commit: renamed off-heap classes with GemFire in their name

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
index 1b37f23..54eac9e 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
@@ -211,7 +211,7 @@ public class FragmentJUnitTest {
     Long fragmentAddress = fragment.getMemoryAddress();
     byte[] bytes = new byte[(int)OffHeapStorage.MIN_SLAB_SIZE];
     byte[] expectedBytes = new byte[(int)OffHeapStorage.MIN_SLAB_SIZE];
-    Arrays.fill(expectedBytes, GemFireChunk.FILL_BYTE);;
+    Arrays.fill(expectedBytes, ObjectChunk.FILL_BYTE);;
     fragment.fill();
     UnsafeMemoryChunk.readAbsoluteBytes(fragmentAddress, bytes, 0, (int)OffHeapStorage.MIN_SLAB_SIZE);
     assertThat(bytes, is(equalTo(expectedBytes)));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
index ce98510..64032cc 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
@@ -104,12 +104,12 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int tinySize = 10;
 
-    GemFireChunk c = this.freeListManager.allocate(tinySize);
+    ObjectChunk c = this.freeListManager.allocate(tinySize);
     
     validateChunkSizes(c, tinySize);
   }
   
-  private void validateChunkSizes(GemFireChunk c, int dataSize) {
+  private void validateChunkSizes(ObjectChunk c, int dataSize) {
     assertThat(c).isNotNull();
     assertThat(c.getDataSize()).isEqualTo(dataSize);
     assertThat(c.getSize()).isEqualTo(computeExpectedSize(dataSize));
@@ -120,8 +120,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int tinySize = 10;
     
-    GemFireChunk c = this.freeListManager.allocate(tinySize);
-    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c = this.freeListManager.allocate(tinySize);
+    ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     c = this.freeListManager.allocate(tinySize);
 
     validateChunkSizes(c, tinySize);
@@ -132,8 +132,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = 10;
     
-    GemFireChunk c = this.freeListManager.allocate(dataSize);
-    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c = this.freeListManager.allocate(dataSize);
+    ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     this.freeListManager.allocate(dataSize);
     // free list will now be empty
     c = this.freeListManager.allocate(dataSize);
@@ -146,7 +146,7 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int hugeSize = FreeListManager.MAX_TINY+1;
 
-    GemFireChunk c = this.freeListManager.allocate(hugeSize);
+    ObjectChunk c = this.freeListManager.allocate(hugeSize);
 
     validateChunkSizes(c, hugeSize);
   }
@@ -156,8 +156,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = FreeListManager.MAX_TINY+1;
     
-    GemFireChunk c = this.freeListManager.allocate(dataSize);
-    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c = this.freeListManager.allocate(dataSize);
+    ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     this.freeListManager.allocate(dataSize);
     // free list will now be empty
     c = this.freeListManager.allocate(dataSize);
@@ -170,8 +170,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = FreeListManager.MAX_TINY+1+1024;
     
-    GemFireChunk c = this.freeListManager.allocate(dataSize);
-    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c = this.freeListManager.allocate(dataSize);
+    ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     dataSize = FreeListManager.MAX_TINY+1;
     c = this.freeListManager.allocate(dataSize);
     
@@ -188,8 +188,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = 10;
     
-    GemFireChunk c = this.freeListManager.allocate(dataSize);
-    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c = this.freeListManager.allocate(dataSize);
+    ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     
     assertThat(this.freeListManager.getFreeTinyMemory()).isEqualTo(computeExpectedSize(dataSize));
   }
@@ -199,13 +199,13 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = 10;
     
-    GemFireChunk c = this.freeListManager.allocate(dataSize);
-    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c = this.freeListManager.allocate(dataSize);
+    ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     
     int dataSize2 = 100;
     
-    GemFireChunk c2 = this.freeListManager.allocate(dataSize2);
-    GemFireChunk.release(c2.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c2 = this.freeListManager.allocate(dataSize2);
+    ObjectChunk.release(c2.getMemoryAddress(), this.freeListManager);
     
     assertThat(this.freeListManager.getFreeTinyMemory()).isEqualTo(computeExpectedSize(dataSize)+computeExpectedSize(dataSize2));
   }
@@ -221,8 +221,8 @@ public class FreeListManagerTest {
     setUpSingleSlabManager();
     int dataSize = FreeListManager.MAX_TINY+1+1024;
     
-    GemFireChunk c = this.freeListManager.allocate(dataSize);
-    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c = this.freeListManager.allocate(dataSize);
+    ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     
     assertThat(this.freeListManager.getFreeHugeMemory()).isEqualTo(computeExpectedSize(dataSize));
   }
@@ -237,7 +237,7 @@ public class FreeListManagerTest {
   @Test
   public void freeFragmentMemorySomeOfFragmentAllocated() {
     setUpSingleSlabManager();
-    GemFireChunk c = this.freeListManager.allocate(DEFAULT_SLAB_SIZE/4-8);
+    ObjectChunk c = this.freeListManager.allocate(DEFAULT_SLAB_SIZE/4-8);
     
     assertThat(this.freeListManager.getFreeFragmentMemory()).isEqualTo((DEFAULT_SLAB_SIZE/4)*3);
   }
@@ -245,13 +245,13 @@ public class FreeListManagerTest {
   @Test
   public void freeFragmentMemoryMostOfFragmentAllocated() {
     setUpSingleSlabManager();
-    GemFireChunk c = this.freeListManager.allocate(DEFAULT_SLAB_SIZE-8-8);
+    ObjectChunk c = this.freeListManager.allocate(DEFAULT_SLAB_SIZE-8-8);
     
     assertThat(this.freeListManager.getFreeFragmentMemory()).isZero();
   }
   
   private int computeExpectedSize(int dataSize) {
-    return ((dataSize + GemFireChunk.OFF_HEAP_HEADER_SIZE + 7) / 8) * 8;
+    return ((dataSize + ObjectChunk.OFF_HEAP_HEADER_SIZE + 7) / 8) * 8;
   }
 
   @Test(expected = AssertionError.class)
@@ -288,13 +288,13 @@ public class FreeListManagerTest {
         new UnsafeMemoryChunk(SMALL_SLAB), 
         new UnsafeMemoryChunk(MEDIUM_SLAB), 
         slab});
-    ArrayList<GemFireChunk> chunks = new ArrayList<>();
+    ArrayList<ObjectChunk> chunks = new ArrayList<>();
     chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
     chunks.add(this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8));
     chunks.add(this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8));
     chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
-    for (GemFireChunk c: chunks) {
-      GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    for (ObjectChunk c: chunks) {
+      ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     }
     this.freeListManager.firstCompact = false;
     assertThat(this.freeListManager.compact(DEFAULT_SLAB_SIZE+1)).isFalse();
@@ -310,13 +310,13 @@ public class FreeListManagerTest {
         new UnsafeMemoryChunk(SMALL_SLAB), 
         new UnsafeMemoryChunk(MEDIUM_SLAB), 
         slab});
-    ArrayList<GemFireChunk> chunks = new ArrayList<>();
+    ArrayList<ObjectChunk> chunks = new ArrayList<>();
     chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
     chunks.add(this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8));
     chunks.add(this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8));
     chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
-    for (GemFireChunk c: chunks) {
-      GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    for (ObjectChunk c: chunks) {
+      ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     }
     
     assertThat(this.freeListManager.compact(DEFAULT_SLAB_SIZE)).isTrue();
@@ -333,13 +333,13 @@ public class FreeListManagerTest {
         new UnsafeMemoryChunk(SMALL_SLAB), 
         new UnsafeMemoryChunk(MEDIUM_SLAB), 
         slab});
-    ArrayList<GemFireChunk> chunks = new ArrayList<>();
+    ArrayList<ObjectChunk> chunks = new ArrayList<>();
     chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
     this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8);
     chunks.add(this.freeListManager.allocate(DEFAULT_SLAB_SIZE/2-8));
     this.freeListManager.allocate(SMALL_SLAB-8+1);
-    for (GemFireChunk c: chunks) {
-      GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    for (ObjectChunk c: chunks) {
+      ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     }
     
     assertThat(this.freeListManager.compact(DEFAULT_SLAB_SIZE/2)).isTrue();
@@ -348,7 +348,7 @@ public class FreeListManagerTest {
   @Test
   public void compactAfterAllocatingAll() {
     setUpSingleSlabManager();
-    GemFireChunk c = freeListManager.allocate(DEFAULT_SLAB_SIZE-8);
+    ObjectChunk c = freeListManager.allocate(DEFAULT_SLAB_SIZE-8);
     this.freeListManager.firstCompact = false;
     assertThat(this.freeListManager.compact(1)).isFalse();
     // call compact twice for extra code coverage
@@ -359,46 +359,46 @@ public class FreeListManagerTest {
   @Test
   public void afterAllocatingAllOneSizeCompactToAllocateDifferentSize() {
     setUpSingleSlabManager();
-    ArrayList<GemFireChunk> chunksToFree = new ArrayList<>();
-    ArrayList<GemFireChunk> chunksToFreeLater = new ArrayList<>();
+    ArrayList<ObjectChunk> chunksToFree = new ArrayList<>();
+    ArrayList<ObjectChunk> chunksToFreeLater = new ArrayList<>();
     int ALLOCATE_COUNT = 1000;
-    GemFireChunk bigChunk = freeListManager.allocate(DEFAULT_SLAB_SIZE-8-(ALLOCATE_COUNT*32)-256-256);
+    ObjectChunk bigChunk = freeListManager.allocate(DEFAULT_SLAB_SIZE-8-(ALLOCATE_COUNT*32)-256-256);
     for (int i=0; i < ALLOCATE_COUNT; i++) {
-      GemFireChunk c = freeListManager.allocate(24);
+      ObjectChunk c = freeListManager.allocate(24);
       if (i%3 != 2) {
         chunksToFree.add(c);
       } else {
         chunksToFreeLater.add(c);
       }
     }
-    GemFireChunk c1 = freeListManager.allocate(64-8);
-    GemFireChunk c2 = freeListManager.allocate(64-8);
-    GemFireChunk c3 = freeListManager.allocate(64-8);
-    GemFireChunk c4 = freeListManager.allocate(64-8);
+    ObjectChunk c1 = freeListManager.allocate(64-8);
+    ObjectChunk c2 = freeListManager.allocate(64-8);
+    ObjectChunk c3 = freeListManager.allocate(64-8);
+    ObjectChunk c4 = freeListManager.allocate(64-8);
 
-    GemFireChunk mediumChunk1 = freeListManager.allocate(128-8);
-    GemFireChunk mediumChunk2 = freeListManager.allocate(128-8);
+    ObjectChunk mediumChunk1 = freeListManager.allocate(128-8);
+    ObjectChunk mediumChunk2 = freeListManager.allocate(128-8);
 
-    GemFireChunk.release(bigChunk.getMemoryAddress(), freeListManager);
+    ObjectChunk.release(bigChunk.getMemoryAddress(), freeListManager);
     int s = chunksToFree.size();
     for (int i=s/2; i >=0; i--) {
-      GemFireChunk c = chunksToFree.get(i);
-      GemFireChunk.release(c.getMemoryAddress(), freeListManager);
+      ObjectChunk c = chunksToFree.get(i);
+      ObjectChunk.release(c.getMemoryAddress(), freeListManager);
     }
     for (int i=(s/2)+1; i < s; i++) {
-      GemFireChunk c = chunksToFree.get(i);
-      GemFireChunk.release(c.getMemoryAddress(), freeListManager);
+      ObjectChunk c = chunksToFree.get(i);
+      ObjectChunk.release(c.getMemoryAddress(), freeListManager);
     }
-    GemFireChunk.release(c3.getMemoryAddress(), freeListManager);
-    GemFireChunk.release(c1.getMemoryAddress(), freeListManager);
-    GemFireChunk.release(c2.getMemoryAddress(), freeListManager);
-    GemFireChunk.release(c4.getMemoryAddress(), freeListManager);
-    GemFireChunk.release(mediumChunk1.getMemoryAddress(), freeListManager);
-    GemFireChunk.release(mediumChunk2.getMemoryAddress(), freeListManager);
+    ObjectChunk.release(c3.getMemoryAddress(), freeListManager);
+    ObjectChunk.release(c1.getMemoryAddress(), freeListManager);
+    ObjectChunk.release(c2.getMemoryAddress(), freeListManager);
+    ObjectChunk.release(c4.getMemoryAddress(), freeListManager);
+    ObjectChunk.release(mediumChunk1.getMemoryAddress(), freeListManager);
+    ObjectChunk.release(mediumChunk2.getMemoryAddress(), freeListManager);
     this.freeListManager.firstCompact = false;
     assertThat(freeListManager.compact(DEFAULT_SLAB_SIZE-(ALLOCATE_COUNT*32))).isFalse();
     for (int i=0; i < ((256*2)/96); i++) {
-      GemFireChunk.release(chunksToFreeLater.get(i).getMemoryAddress(), freeListManager);
+      ObjectChunk.release(chunksToFreeLater.get(i).getMemoryAddress(), freeListManager);
     }
     assertThat(freeListManager.compact(DEFAULT_SLAB_SIZE-(ALLOCATE_COUNT*32))).isTrue();
   }
@@ -407,14 +407,14 @@ public class FreeListManagerTest {
   public void afterAllocatingAndFreeingCompact() {
     int slabSize = 1024*3;
     setUpSingleSlabManager(slabSize);
-    GemFireChunk bigChunk1 = freeListManager.allocate(slabSize/3-8);
-    GemFireChunk bigChunk2 = freeListManager.allocate(slabSize/3-8);
-    GemFireChunk bigChunk3 = freeListManager.allocate(slabSize/3-8);
+    ObjectChunk bigChunk1 = freeListManager.allocate(slabSize/3-8);
+    ObjectChunk bigChunk2 = freeListManager.allocate(slabSize/3-8);
+    ObjectChunk bigChunk3 = freeListManager.allocate(slabSize/3-8);
     this.freeListManager.firstCompact = false;
     assertThat(freeListManager.compact(1)).isFalse();
-    GemFireChunk.release(bigChunk3.getMemoryAddress(), freeListManager);
-    GemFireChunk.release(bigChunk2.getMemoryAddress(), freeListManager);
-    GemFireChunk.release(bigChunk1.getMemoryAddress(), freeListManager);
+    ObjectChunk.release(bigChunk3.getMemoryAddress(), freeListManager);
+    ObjectChunk.release(bigChunk2.getMemoryAddress(), freeListManager);
+    ObjectChunk.release(bigChunk1.getMemoryAddress(), freeListManager);
     assertThat(freeListManager.compact(slabSize)).isTrue();
   }
   
@@ -422,8 +422,8 @@ public class FreeListManagerTest {
   public void compactWithEmptyTinyFreeList() {
     setUpSingleSlabManager();
     Fragment originalFragment = this.freeListManager.getFragmentList().get(0);
-    GemFireChunk c = freeListManager.allocate(16);
-    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c = freeListManager.allocate(16);
+    ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     c = freeListManager.allocate(16);
     this.freeListManager.firstCompact = false;
     assertThat(this.freeListManager.compact(1)).isTrue();
@@ -443,8 +443,8 @@ public class FreeListManagerTest {
         new UnsafeMemoryChunk(SMALL_SLAB), 
         new UnsafeMemoryChunk(MEDIUM_SLAB), 
         slab});
-    this.freeListManager.allocate(DEFAULT_SLAB_SIZE-8-(GemFireChunk.MIN_CHUNK_SIZE-1));
-    this.freeListManager.allocate(MEDIUM_SLAB-8-(GemFireChunk.MIN_CHUNK_SIZE-1));
+    this.freeListManager.allocate(DEFAULT_SLAB_SIZE-8-(ObjectChunk.MIN_CHUNK_SIZE-1));
+    this.freeListManager.allocate(MEDIUM_SLAB-8-(ObjectChunk.MIN_CHUNK_SIZE-1));
     
     assertThat(this.freeListManager.compact(SMALL_SLAB)).isTrue();
   }
@@ -672,9 +672,9 @@ public class FreeListManagerTest {
     UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
     long address = chunk.getMemoryAddress();
     this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
-    GemFireChunk c = this.freeListManager.allocate(24);
-    GemFireChunk c2 = this.freeListManager.allocate(24);
-    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c = this.freeListManager.allocate(24);
+    ObjectChunk c2 = this.freeListManager.allocate(24);
+    ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
 
     List<MemoryBlock> ob = this.freeListManager.getOrderedBlocks();
     assertThat(ob).hasSize(3);
@@ -692,8 +692,8 @@ public class FreeListManagerTest {
   public void allocatedBlocksEmptyAfterFree() {
     UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
     this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
-    GemFireChunk c = this.freeListManager.allocate(24);
-    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c = this.freeListManager.allocate(24);
+    ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
     List<MemoryBlock> ob = this.freeListManager.getAllocatedBlocks();
     assertThat(ob).hasSize(0);
   }
@@ -702,7 +702,7 @@ public class FreeListManagerTest {
   public void allocatedBlocksHasAllocatedChunk() {
     UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
     this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
-    GemFireChunk c = this.freeListManager.allocate(24);
+    ObjectChunk c = this.freeListManager.allocate(24);
     List<MemoryBlock> ob = this.freeListManager.getAllocatedBlocks();
     assertThat(ob).hasSize(1);
     assertThat(ob.get(0).getMemoryAddress()).isEqualTo(c.getMemoryAddress());
@@ -712,8 +712,8 @@ public class FreeListManagerTest {
   public void allocatedBlocksHasBothAllocatedChunks() {
     UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
     this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
-    GemFireChunk c = this.freeListManager.allocate(24);
-    GemFireChunk c2 = this.freeListManager.allocate(33);
+    ObjectChunk c = this.freeListManager.allocate(24);
+    ObjectChunk c2 = this.freeListManager.allocate(33);
     List<MemoryBlock> ob = this.freeListManager.getAllocatedBlocks();
     assertThat(ob).hasSize(2);
   }
@@ -731,10 +731,10 @@ public class FreeListManagerTest {
     UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(32);
     UnsafeMemoryChunk chunk2 = new UnsafeMemoryChunk(1024*1024*5);
     this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk, chunk2});
-    GemFireChunk c = this.freeListManager.allocate(24);
-    GemFireChunk c2 = this.freeListManager.allocate(1024*1024);
-    GemFireChunk.release(c.getMemoryAddress(), this.freeListManager);
-    GemFireChunk.release(c2.getMemoryAddress(), this.freeListManager);
+    ObjectChunk c = this.freeListManager.allocate(24);
+    ObjectChunk c2 = this.freeListManager.allocate(1024*1024);
+    ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
+    ObjectChunk.release(c2.getMemoryAddress(), this.freeListManager);
     
     LogWriter lw = mock(LogWriter.class);
     this.freeListManager.logOffHeapState(lw, 1024);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListOffHeapRegionJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListOffHeapRegionJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListOffHeapRegionJUnitTest.java
index edbe235..6790f6a 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListOffHeapRegionJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListOffHeapRegionJUnitTest.java
@@ -40,7 +40,7 @@ public class FreeListOffHeapRegionJUnitTest extends OffHeapRegionBase {
 
   @Override
   public int perObjectOverhead() {
-    return GemFireChunk.OFF_HEAP_HEADER_SIZE;
+    return ObjectChunk.OFF_HEAP_HEADER_SIZE;
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java
index 23445cf..7f4b27f 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java
@@ -98,7 +98,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
   }
 
   @Override
-  public GemFireChunk createValueAsUnserializedStoredObject(Object value) {
+  public ObjectChunk createValueAsUnserializedStoredObject(Object value) {
     byte[] valueInByteArray;
     if (value instanceof Long) {
       valueInByteArray = convertValueToByteArray(value);
@@ -113,7 +113,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
   }
 
   @Override
-  public GemFireChunk createValueAsSerializedStoredObject(Object value) {
+  public ObjectChunk createValueAsSerializedStoredObject(Object value) {
     byte[] valueInSerializedByteArray = EntryEventImpl.serialize(value);
 
     boolean isSerialized = true;
@@ -122,16 +122,16 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
     return createChunk(valueInSerializedByteArray, isSerialized, isCompressed);
   }
 
-  private GemFireChunk createChunk(byte[] v, boolean isSerialized, boolean isCompressed) {
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed);
+  private ObjectChunk createChunk(byte[] v, boolean isSerialized, boolean isCompressed) {
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed);
     return chunk;
   }
 
   @Test
   public void chunkCanBeCreatedFromAnotherChunk() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
 
-    GemFireChunk newChunk = new GemFireChunk(chunk);
+    ObjectChunk newChunk = new ObjectChunk(chunk);
 
     assertNotNull(newChunk);
     assertThat(newChunk.getMemoryAddress()).isEqualTo(chunk.getMemoryAddress());
@@ -141,9 +141,9 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void chunkCanBeCreatedWithOnlyMemoryAddress() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
 
-    GemFireChunk newChunk = new GemFireChunk(chunk.getMemoryAddress());
+    ObjectChunk newChunk = new ObjectChunk(chunk.getMemoryAddress());
 
     assertNotNull(newChunk);
     assertThat(newChunk.getMemoryAddress()).isEqualTo(chunk.getMemoryAddress());
@@ -153,15 +153,15 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void chunkSliceCanBeCreatedFromAnotherChunk() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
 
     int position = 1;
     int end = 2;
 
-    GemFireChunk newChunk = (GemFireChunk) chunk.slice(position, end);
+    ObjectChunk newChunk = (ObjectChunk) chunk.slice(position, end);
 
     assertNotNull(newChunk);
-    assertThat(newChunk.getClass()).isEqualTo(GemFireChunkSlice.class);
+    assertThat(newChunk.getClass()).isEqualTo(ObjectChunkSlice.class);
     assertThat(newChunk.getMemoryAddress()).isEqualTo(chunk.getMemoryAddress());
 
     chunk.release();
@@ -169,7 +169,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void fillSerializedValueShouldFillWrapperWithSerializedValueIfValueIsSerialized() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     // mock the things
     BytesAndBitsForCompactor wrapper = mock(BytesAndBitsForCompactor.class);
@@ -185,7 +185,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void fillSerializedValueShouldFillWrapperWithDeserializedValueIfValueIsNotSerialized() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
 
     // mock the things
     BytesAndBitsForCompactor wrapper = mock(BytesAndBitsForCompactor.class);
@@ -200,7 +200,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void getShortClassNameShouldReturnShortClassName() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     assertThat(chunk.getShortClassName()).isEqualTo("GemFireChunk");
 
     chunk.release();
@@ -208,12 +208,12 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void chunksAreEqualsOnlyByAddress() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
 
-    GemFireChunk newChunk = new GemFireChunk(chunk.getMemoryAddress());
+    ObjectChunk newChunk = new ObjectChunk(chunk.getMemoryAddress());
     assertThat(chunk.equals(newChunk)).isTrue();
 
-    GemFireChunk chunkWithSameValue = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunkWithSameValue = createValueAsUnserializedStoredObject(getValue());
     assertThat(chunk.equals(chunkWithSameValue)).isFalse();
 
     Object someObject = getValue();
@@ -225,16 +225,16 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void chunksShouldBeComparedBySize() {
-    GemFireChunk chunk1 = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk1 = createValueAsSerializedStoredObject(getValue());
 
-    GemFireChunk chunk2 = chunk1;
+    ObjectChunk chunk2 = chunk1;
     assertThat(chunk1.compareTo(chunk2)).isEqualTo(0);
 
-    GemFireChunk chunkWithSameValue = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunkWithSameValue = createValueAsSerializedStoredObject(getValue());
     assertThat(chunk1.compareTo(chunkWithSameValue)).isEqualTo(Long.signum(chunk1.getMemoryAddress() - chunkWithSameValue.getMemoryAddress()));
 
-    GemFireChunk chunk3 = createValueAsSerializedStoredObject(Long.MAX_VALUE);
-    GemFireChunk chunk4 = createValueAsSerializedStoredObject(Long.MAX_VALUE);
+    ObjectChunk chunk3 = createValueAsSerializedStoredObject(Long.MAX_VALUE);
+    ObjectChunk chunk4 = createValueAsSerializedStoredObject(Long.MAX_VALUE);
 
     int newSizeForChunk3 = 2;
     int newSizeForChunk4 = 3;
@@ -253,9 +253,9 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
     boolean isSerialized = false;
     boolean isCompressed = false;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
 
-    int headerBeforeSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + GemFireChunk.REF_COUNT_OFFSET);
+    int headerBeforeSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + ObjectChunk.REF_COUNT_OFFSET);
 
     assertThat(chunk.isSerialized()).isFalse();
 
@@ -263,16 +263,16 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
     assertThat(chunk.isSerialized()).isTrue();
 
-    int headerAfterSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + GemFireChunk.REF_COUNT_OFFSET);
+    int headerAfterSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + ObjectChunk.REF_COUNT_OFFSET);
 
-    assertThat(headerAfterSerializedBitSet).isEqualTo(headerBeforeSerializedBitSet | GemFireChunk.IS_SERIALIZED_BIT);
+    assertThat(headerAfterSerializedBitSet).isEqualTo(headerBeforeSerializedBitSet | ObjectChunk.IS_SERIALIZED_BIT);
 
     chunk.release();
   }
 
   @Test(expected = IllegalStateException.class)
   public void setSerialziedShouldThrowExceptionIfChunkIsAlreadyReleased() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     chunk.release();
     chunk.setSerialized(true);
 
@@ -287,9 +287,9 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
     boolean isSerialized = false;
     boolean isCompressed = false;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
 
-    int headerBeforeCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + GemFireChunk.REF_COUNT_OFFSET);
+    int headerBeforeCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + ObjectChunk.REF_COUNT_OFFSET);
 
     assertThat(chunk.isCompressed()).isFalse();
 
@@ -297,16 +297,16 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
     assertThat(chunk.isCompressed()).isTrue();
 
-    int headerAfterCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + GemFireChunk.REF_COUNT_OFFSET);
+    int headerAfterCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + ObjectChunk.REF_COUNT_OFFSET);
 
-    assertThat(headerAfterCompressedBitSet).isEqualTo(headerBeforeCompressedBitSet | GemFireChunk.IS_COMPRESSED_BIT);
+    assertThat(headerAfterCompressedBitSet).isEqualTo(headerBeforeCompressedBitSet | ObjectChunk.IS_COMPRESSED_BIT);
 
     chunk.release();
   }
 
   @Test(expected = IllegalStateException.class)
   public void setCompressedShouldThrowExceptionIfChunkIsAlreadyReleased() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     chunk.release();
     chunk.setCompressed(true);
 
@@ -315,7 +315,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void setDataSizeShouldSetTheDataSizeBits() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
 
     int beforeSize = chunk.getDataSize();
 
@@ -331,7 +331,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = IllegalStateException.class)
   public void setDataSizeShouldThrowExceptionIfChunkIsAlreadyReleased() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     chunk.release();
     chunk.setDataSize(1);
 
@@ -340,7 +340,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = IllegalStateException.class)
   public void initializeUseCountShouldThrowIllegalStateExceptionIfChunkIsAlreadyRetained() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     chunk.retain();
     chunk.initializeUseCount();
 
@@ -349,7 +349,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = IllegalStateException.class)
   public void initializeUseCountShouldThrowIllegalStateExceptionIfChunkIsAlreadyReleased() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     chunk.release();
     chunk.initializeUseCount();
 
@@ -358,7 +358,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void isSerializedPdxInstanceShouldReturnTrueIfItsPDXInstance() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     byte[] serailizedValue = chunk.getSerializedValue();
     serailizedValue[0] = DSCODE.PDX;
@@ -383,7 +383,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void isSerializedPdxInstanceShouldReturnFalseIfItsNotPDXInstance() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
     assertThat(chunk.isSerializedPdxInstance()).isFalse();
 
     chunk.release();
@@ -391,22 +391,22 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void checkDataEqualsByChunk() {
-    GemFireChunk chunk1 = createValueAsSerializedStoredObject(getValue());
-    GemFireChunk sameAsChunk1 = chunk1;
+    ObjectChunk chunk1 = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk sameAsChunk1 = chunk1;
 
     assertThat(chunk1.checkDataEquals(sameAsChunk1)).isTrue();
 
-    GemFireChunk unserializedChunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk unserializedChunk = createValueAsUnserializedStoredObject(getValue());
     assertThat(chunk1.checkDataEquals(unserializedChunk)).isFalse();
 
-    GemFireChunk chunkDifferBySize = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunkDifferBySize = createValueAsSerializedStoredObject(getValue());
     chunkDifferBySize.setSize(0);
     assertThat(chunk1.checkDataEquals(chunkDifferBySize)).isFalse();
 
-    GemFireChunk chunkDifferByValue = createValueAsSerializedStoredObject(Long.MAX_VALUE - 1);
+    ObjectChunk chunkDifferByValue = createValueAsSerializedStoredObject(Long.MAX_VALUE - 1);
     assertThat(chunk1.checkDataEquals(chunkDifferByValue)).isFalse();
 
-    GemFireChunk newChunk1 = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk newChunk1 = createValueAsSerializedStoredObject(getValue());
     assertThat(chunk1.checkDataEquals(newChunk1)).isTrue();
 
     chunk1.release();
@@ -418,13 +418,13 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void checkDataEqualsBySerializedValue() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
     assertThat(chunk.checkDataEquals(new byte[1])).isFalse();
 
-    GemFireChunk chunkDifferByValue = createValueAsSerializedStoredObject(Long.MAX_VALUE - 1);
+    ObjectChunk chunkDifferByValue = createValueAsSerializedStoredObject(Long.MAX_VALUE - 1);
     assertThat(chunk.checkDataEquals(chunkDifferByValue.getSerializedValue())).isFalse();
 
-    GemFireChunk newChunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk newChunk = createValueAsSerializedStoredObject(getValue());
     assertThat(chunk.checkDataEquals(newChunk.getSerializedValue())).isTrue();
 
     chunk.release();
@@ -440,7 +440,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
     boolean isSerialized = true;
     boolean isCompressed = true;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
 
     RegionEntryContext regionContext = mock(RegionEntryContext.class);
     CachePerfStats cacheStats = mock(CachePerfStats.class);
@@ -469,7 +469,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void incSizeShouldIncrementSize() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     int beforeSize = chunk.getSize();
 
@@ -484,7 +484,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void readyForFreeShouldResetTheRefCount() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     int refCountBeforeFreeing = chunk.getRefCount();
     assertThat(refCountBeforeFreeing).isEqualTo(1);
@@ -497,7 +497,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = IllegalStateException.class)
   public void readyForAllocationShouldThrowExceptionIfAlreadyAllocated() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     // chunk is already allocated when we created it, so calling readyForAllocation should throw exception.
     chunk.readyForAllocation();
@@ -507,7 +507,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void checkIsAllocatedShouldReturnIfAllocated() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
     chunk.checkIsAllocated();
 
     chunk.release();
@@ -515,7 +515,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = IllegalStateException.class)
   public void checkIsAllocatedShouldThrowExceptionIfNotAllocated() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
     chunk.release();
     chunk.checkIsAllocated();
 
@@ -524,8 +524,8 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void sendToShouldWriteSerializedValueToDataOutputIfValueIsSerialized() throws IOException {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-    GemFireChunk spyChunk = spy(chunk);
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk spyChunk = spy(chunk);
 
     HeapDataOutputStream dataOutput = mock(HeapDataOutputStream.class);
     ByteBuffer directByteBuffer = ByteBuffer.allocate(1024);
@@ -543,7 +543,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
   @Test
   public void sendToShouldWriteUnserializedValueToDataOutputIfValueIsUnserialized() throws IOException {
     byte[] regionEntryValue = getValueAsByteArray();
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
 
     // writeByte is a final method and cannot be mocked, so creating a real one
     HeapDataOutputStream dataOutput = new HeapDataOutputStream(Version.CURRENT);
@@ -566,7 +566,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
   @Test
   public void sendAsByteArrayShouldWriteValueToDataOutput() throws IOException {
     byte[] regionEntryValue = getValueAsByteArray();
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
 
     // writeByte is a final method and cannot be mocked, so creating a real one
     HeapDataOutputStream dataOutput = new HeapDataOutputStream(Version.CURRENT);
@@ -589,7 +589,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
   public void createDirectByteBufferShouldCreateAByteBuffer() {
     byte[] regionEntryValue = getValueAsByteArray();
 
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
 
     ByteBuffer buffer = chunk.createDirectByteBuffer();
 
@@ -604,20 +604,20 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
   @Test
   public void getDirectByteBufferShouldCreateAByteBuffer() {
     byte[] regionEntryValue = getValueAsByteArray();
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
 
     ByteBuffer buffer = chunk.createDirectByteBuffer();
-    long bufferAddress = GemFireChunk.getDirectByteBufferAddress(buffer);
+    long bufferAddress = ObjectChunk.getDirectByteBufferAddress(buffer);
 
     // returned address should be starting of the value (after skipping HEADER_SIZE bytes)
-    assertEquals(chunk.getMemoryAddress() + GemFireChunk.OFF_HEAP_HEADER_SIZE, bufferAddress);
+    assertEquals(chunk.getMemoryAddress() + ObjectChunk.OFF_HEAP_HEADER_SIZE, bufferAddress);
 
     chunk.release();
   }
 
   @Test(expected = AssertionError.class)
   public void getAddressForReadingShouldFailIfItsOutsideOfChunk() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
     chunk.getAddressForReading(0, chunk.getDataSize() + 1);
 
     chunk.release();
@@ -625,7 +625,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void getAddressForReadingShouldReturnDataAddressFromGivenOffset() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     int offset = 1;
     long requestedAddress = chunk.getAddressForReading(offset, 1);
@@ -637,7 +637,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void getSizeInBytesShouldReturnSize() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
     assertThat(chunk.getSizeInBytes()).isEqualTo(chunk.getSize());
 
     chunk.release();
@@ -645,7 +645,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = AssertionError.class)
   public void getUnsafeAddressShouldFailIfOffsetIsNegative() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
     chunk.getUnsafeAddress(-1, 1);
 
     chunk.release();
@@ -653,7 +653,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = AssertionError.class)
   public void getUnsafeAddressShouldFailIfSizeIsNegative() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
     chunk.getUnsafeAddress(1, -1);
 
     chunk.release();
@@ -661,7 +661,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = AssertionError.class)
   public void getUnsafeAddressShouldFailIfItsOutsideOfChunk() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
     chunk.getUnsafeAddress(0, chunk.getDataSize() + 1);
 
     chunk.release();
@@ -669,7 +669,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void getUnsafeAddressShouldReturnUnsafeAddress() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     int offset = 1;
     long unsafeAddress = chunk.getUnsafeAddress(offset, 1);
@@ -681,7 +681,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = AssertionError.class)
   public void readByteAndWriteByteShouldFailIfOffsetIsOutside() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     chunk.readByte(chunk.getDataSize() + 1);
 
@@ -692,7 +692,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void writeByteShouldWriteAtCorrectLocation() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
 
     byte valueBeforeWrite = chunk.readByte(2);
 
@@ -709,7 +709,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void retainShouldIncrementRefCount() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     assertThat(chunk.getRefCount()).isEqualTo(1);
 
     chunk.retain();
@@ -728,10 +728,10 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = IllegalStateException.class)
   public void retainShouldThrowExceptionAfterMaxNumberOfTimesRetained() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
 
     // loop though and invoke retain for MAX_REF_COUNT-1 times, as create chunk above counted as one reference
-    for (int i = 0; i < GemFireChunk.MAX_REF_COUNT - 1; i++)
+    for (int i = 0; i < ObjectChunk.MAX_REF_COUNT - 1; i++)
       chunk.retain();
 
     // invoke for the one more time should throw exception
@@ -740,7 +740,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void releaseShouldDecrementRefCount() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     assertThat(chunk.getRefCount()).isEqualTo(1);
 
     chunk.retain();
@@ -763,20 +763,20 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = IllegalStateException.class)
   public void releaseShouldThrowExceptionIfChunkIsAlreadyReleased() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     chunk.release();
     chunk.release();
   }
 
   @Test
   public void testToStringForOffHeapByteSource() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
 
     String expected = ":<dataSize=" + chunk.getDataSize() + " refCount=" + chunk.getRefCount() + " addr=" + Long.toHexString(chunk.getMemoryAddress()) + ">";
     assertThat(chunk.toStringForOffHeapByteSource()).endsWith(expected);
 
     // test toString
-    GemFireChunk spy = spy(chunk);
+    ObjectChunk spy = spy(chunk);
     spy.toString();
     verify(spy, times(1)).toStringForOffHeapByteSource();
 
@@ -785,7 +785,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void getStateShouldReturnAllocatedIfRefCountIsGreaterThanZero() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     assertEquals(State.ALLOCATED, chunk.getState());
 
     chunk.release();
@@ -793,14 +793,14 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void getStateShouldReturnDeallocatedIfRefCountIsZero() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     chunk.release();
     assertEquals(State.DEALLOCATED, chunk.getState());
   }
 
   @Test(expected = UnsupportedOperationException.class)
   public void getNextBlockShouldThrowUnSupportedOperationException() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     chunk.getNextBlock();
 
     chunk.release();
@@ -808,7 +808,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void getBlockSizeShouldBeSameSameGetSize() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     assertEquals(chunk.getSize(), chunk.getBlockSize());
 
     chunk.release();
@@ -816,7 +816,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = UnsupportedOperationException.class)
   public void copyBytesShouldThrowUnSupportedOperationException() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     chunk.copyBytes(1, 2, 1);
 
     chunk.release();
@@ -824,7 +824,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test(expected = UnsupportedOperationException.class)
   public void getSlabIdShouldThrowUnSupportedOperationException() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     chunk.getSlabId();
 
     chunk.release();
@@ -832,7 +832,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void getFreeListIdShouldReturnMinusOne() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     assertThat(chunk.getFreeListId()).isEqualTo(-1);
 
     chunk.release();
@@ -840,7 +840,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void getDataTypeShouldReturnNull() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     assertThat(chunk.getDataType()).isNull();
 
     chunk.release();
@@ -848,7 +848,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
 
   @Test
   public void getDataDataShouldReturnNull() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
     assertThat(chunk.getDataValue()).isNull();
   }
 
@@ -860,7 +860,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
     boolean isSerialized = true;
     boolean isCompressed = true;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
 
     chunk.getRawBytes();
 
@@ -875,7 +875,7 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
     boolean isSerialized = false;
     boolean isCompressed = false;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
 
     byte[] serializedValue = chunk.getSerializedValue();
 
@@ -889,10 +889,10 @@ public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
     boolean isSerialized = false;
     boolean isCompressed = false;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(new byte[100], isSerialized, isCompressed);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(new byte[100], isSerialized, isCompressed);
 
     // first fill the unused part with FILL_PATTERN
-    GemFireChunk.fill(chunk.getMemoryAddress());
+    ObjectChunk.fill(chunk.getMemoryAddress());
 
     // Validate that it is filled
     chunk.validateFill();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSliceJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSliceJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSliceJUnitTest.java
index 39ee620..60a7f9e 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSliceJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSliceJUnitTest.java
@@ -33,11 +33,11 @@ public class GemFireChunkSliceJUnitTest extends GemFireChunkJUnitTest {
     int position = 1;
     int end = 2;
 
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    GemFireChunkSlice slice = (GemFireChunkSlice) chunk.slice(position, end);
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunkSlice slice = (ObjectChunkSlice) chunk.slice(position, end);
 
     assertNotNull(slice);
-    assertEquals(GemFireChunkSlice.class, slice.getClass());
+    assertEquals(ObjectChunkSlice.class, slice.getClass());
 
     assertEquals(end - position, slice.getDataSize());
   }
@@ -47,11 +47,11 @@ public class GemFireChunkSliceJUnitTest extends GemFireChunkJUnitTest {
     int position = 1;
     int end = 2;
 
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    GemFireChunkSlice slice = (GemFireChunkSlice) chunk.slice(position, end);
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunkSlice slice = (ObjectChunkSlice) chunk.slice(position, end);
 
     assertNotNull(slice);
-    assertEquals(GemFireChunkSlice.class, slice.getClass());
+    assertEquals(ObjectChunkSlice.class, slice.getClass());
 
     assertEquals(chunk.getBaseDataAddress() + position, slice.getBaseDataAddress());
   }
@@ -61,11 +61,11 @@ public class GemFireChunkSliceJUnitTest extends GemFireChunkJUnitTest {
     int position = 1;
     int end = 2;
 
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    GemFireChunkSlice slice = (GemFireChunkSlice) chunk.slice(position, end);
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunkSlice slice = (ObjectChunkSlice) chunk.slice(position, end);
 
     assertNotNull(slice);
-    assertEquals(GemFireChunkSlice.class, slice.getClass());
+    assertEquals(ObjectChunkSlice.class, slice.getClass());
 
     assertEquals(chunk.getBaseDataOffset() + position, slice.getBaseDataOffset());
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
index 6c037e1..b1e3af0 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
@@ -128,8 +128,8 @@ public class OffHeapHelperJUnitTest extends AbstractStoredObjectTestBase {
     return createdObject;
   }
 
-  private GemFireChunk createChunk(byte[] v, boolean isSerialized, boolean isCompressed) {
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed);
+  private ObjectChunk createChunk(byte[] v, boolean isSerialized, boolean isCompressed) {
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed);
     return chunk;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
index 78143d5..8de0406 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
@@ -540,11 +540,11 @@ public abstract class OffHeapRegionBase {
     @Released(OffHeapIdentifier.TEST_OFF_HEAP_REGION_BASE_LISTENER)
     @Override
     public void close() {
-      if (this.ohOldValue instanceof GemFireChunk) {
-        ((GemFireChunk)this.ohOldValue).release();
+      if (this.ohOldValue instanceof ObjectChunk) {
+        ((ObjectChunk)this.ohOldValue).release();
       }
-      if (this.ohNewValue instanceof GemFireChunk) {
-        ((GemFireChunk)this.ohNewValue).release();
+      if (this.ohNewValue instanceof ObjectChunk) {
+        ((ObjectChunk)this.ohNewValue).release();
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
index a611aa5..5d53109 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
@@ -54,7 +54,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 @Category(UnitTest.class)
 @RunWith(PowerMockRunner.class)
 @PowerMockIgnore("*.UnitTest")
-@PrepareForTest({ GemFireChunk.class, OffHeapRegionEntryHelper.class })
+@PrepareForTest({ ObjectChunk.class, OffHeapRegionEntryHelper.class })
 public class OffHeapRegionEntryHelperJUnitTest {
 
   private static final Long VALUE_IS_NOT_ENCODABLE = 0L;
@@ -75,13 +75,13 @@ public class OffHeapRegionEntryHelperJUnitTest {
     SimpleMemoryAllocatorImpl.freeOffHeapMemory();
   }
 
-  private GemFireChunk createChunk(Object value) {
+  private ObjectChunk createChunk(Object value) {
     byte[] v = EntryEventImpl.serialize(value);
 
     boolean isSerialized = true;
     boolean isCompressed = false;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed);
 
     return chunk;
   }
@@ -294,7 +294,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
   @Test
   public void isOffHeapShouldReturnTrueIfAddressIsOnOffHeap() {
-    GemFireChunk value = createChunk(Long.MAX_VALUE);
+    ObjectChunk value = createChunk(Long.MAX_VALUE);
     assertThat(OffHeapRegionEntryHelper.isOffHeap(value.getMemoryAddress())).isTrue();
   }
 
@@ -327,7 +327,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
     long oldAddress = 1L;
 
     // testing when the newValue is a chunk
-    GemFireChunk newValue = createChunk(Long.MAX_VALUE);
+    ObjectChunk newValue = createChunk(Long.MAX_VALUE);
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldAddress);
     when(re.setAddress(oldAddress, newValue.getMemoryAddress())).thenReturn(Boolean.TRUE);
@@ -440,13 +440,13 @@ public class OffHeapRegionEntryHelperJUnitTest {
     // mock region entry
     OffHeapRegionEntry re = mock(OffHeapRegionEntry.class);
 
-    GemFireChunk oldValue = createChunk(Long.MAX_VALUE);
-    GemFireChunk newValue = createChunk(Long.MAX_VALUE - 1);
+    ObjectChunk oldValue = createChunk(Long.MAX_VALUE);
+    ObjectChunk newValue = createChunk(Long.MAX_VALUE - 1);
 
     // mock Chunk static methods - in-order to verify that release is called
-    PowerMockito.spy(GemFireChunk.class);
-    PowerMockito.doNothing().when(GemFireChunk.class);
-    GemFireChunk.release(oldValue.getMemoryAddress());
+    PowerMockito.spy(ObjectChunk.class);
+    PowerMockito.doNothing().when(ObjectChunk.class);
+    ObjectChunk.release(oldValue.getMemoryAddress());
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldValue.getMemoryAddress());
@@ -460,7 +460,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
     // verify oldAddress is released
     PowerMockito.verifyStatic();
-    GemFireChunk.release(oldValue.getMemoryAddress());
+    ObjectChunk.release(oldValue.getMemoryAddress());
   }
 
   @Test
@@ -475,9 +475,9 @@ public class OffHeapRegionEntryHelperJUnitTest {
     DataAsAddress newAddress = new DataAsAddress(OffHeapRegionEntryHelper.encodeDataAsAddress(newData, false, false));
 
     // mock Chunk static methods - in-order to verify that release is never called
-    PowerMockito.spy(GemFireChunk.class);
-    PowerMockito.doNothing().when(GemFireChunk.class);
-    GemFireChunk.release(oldAddress);
+    PowerMockito.spy(ObjectChunk.class);
+    PowerMockito.doNothing().when(ObjectChunk.class);
+    ObjectChunk.release(oldAddress);
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldAddress);
@@ -491,7 +491,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
     // verify that release is never called as the old address is not on offheap
     PowerMockito.verifyStatic(never());
-    GemFireChunk.release(oldAddress);
+    ObjectChunk.release(oldAddress);
   }
 
   @Test
@@ -505,9 +505,9 @@ public class OffHeapRegionEntryHelperJUnitTest {
     long newAddress = OffHeapRegionEntryHelper.REMOVED_PHASE2_ADDRESS;
 
     // mock Chunk static methods - in-order to verify that release is never called
-    PowerMockito.spy(GemFireChunk.class);
-    PowerMockito.doNothing().when(GemFireChunk.class);
-    GemFireChunk.release(oldAddress);
+    PowerMockito.spy(ObjectChunk.class);
+    PowerMockito.doNothing().when(ObjectChunk.class);
+    ObjectChunk.release(oldAddress);
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldAddress);
@@ -521,7 +521,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
     // verify that release is never called as the old address is not on offheap
     PowerMockito.verifyStatic(never());
-    GemFireChunk.release(oldAddress);
+    ObjectChunk.release(oldAddress);
   }
 
   @Test(expected = IllegalStateException.class)
@@ -541,7 +541,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
     // mock region entry
     OffHeapRegionEntry re = mock(OffHeapRegionEntry.class);
 
-    GemFireChunk chunk = createChunk(Long.MAX_VALUE);
+    ObjectChunk chunk = createChunk(Long.MAX_VALUE);
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(chunk.getMemoryAddress());
@@ -627,10 +627,10 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
   @Test
   public void addressToObjectShouldReturnValueFromChunk() {
-    GemFireChunk expected = createChunk(Long.MAX_VALUE);
+    ObjectChunk expected = createChunk(Long.MAX_VALUE);
     Object actual = OffHeapRegionEntryHelper.addressToObject(expected.getMemoryAddress(), false, null);
 
-    assertThat(actual).isInstanceOf(GemFireChunk.class);
+    assertThat(actual).isInstanceOf(ObjectChunk.class);
     assertThat(actual).isEqualTo(expected);
   }
 
@@ -640,7 +640,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
     boolean isSerialized = true;
     boolean isCompressed = true;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(data, isSerialized, isCompressed);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(data, isSerialized, isCompressed);
 
     // create the mock context
     RegionEntryContext regionContext = mock(RegionEntryContext.class);
@@ -669,7 +669,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
     boolean isSerialized = false;
     boolean isCompressed = true;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(data, isSerialized, isCompressed);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(data, isSerialized, isCompressed);
 
     // create the mock context
     RegionEntryContext regionContext = mock(RegionEntryContext.class);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
index 2379c2d..630ae22 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
@@ -296,8 +296,8 @@ public class OffHeapValidationJUnitTest {
   
   private long getMemoryAddress(Region region, String key) {
     Object entry = ((LocalRegion) region).getRegionEntry(key)._getValue();
-    assertTrue(entry instanceof GemFireChunk);
-    long memoryAddress = ((GemFireChunk)entry).getMemoryAddress();
+    assertTrue(entry instanceof ObjectChunk);
+    long memoryAddress = ((ObjectChunk)entry).getMemoryAddress();
     assertTrue(memoryAddress > 0);
     return memoryAddress;
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
index c0fc0b3..9c83f5b 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapWriteObjectAsByteArrayJUnitTest.java
@@ -64,7 +64,7 @@ public class OffHeapWriteObjectAsByteArrayJUnitTest {
   public void testByteArrayChunk() throws IOException, ClassNotFoundException {
     byte[] expected = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
     StoredObject so = createStoredObject(expected, false, false);
-    assertTrue(so instanceof GemFireChunk);
+    assertTrue(so instanceof ObjectChunk);
     HeapDataOutputStream hdos = new HeapDataOutputStream(new byte[1024]);
     DataSerializer.writeObjectAsByteArray(so, hdos);
     DataInputStream in = createInput(hdos);
@@ -88,7 +88,7 @@ public class OffHeapWriteObjectAsByteArrayJUnitTest {
   public void testStringChunk() throws IOException, ClassNotFoundException {
     byte[] expected = EntryEventImpl.serialize("1234567890");
     StoredObject so = createStoredObject(expected, true, false);
-    assertTrue(so instanceof GemFireChunk);
+    assertTrue(so instanceof ObjectChunk);
     HeapDataOutputStream hdos = new HeapDataOutputStream(new byte[1024]);
     DataSerializer.writeObjectAsByteArray(so, hdos);
     DataInputStream in = createInput(hdos);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OldFreeListOffHeapRegionJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OldFreeListOffHeapRegionJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OldFreeListOffHeapRegionJUnitTest.java
index 104aba8..d8c35b8 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OldFreeListOffHeapRegionJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OldFreeListOffHeapRegionJUnitTest.java
@@ -41,7 +41,7 @@ public class OldFreeListOffHeapRegionJUnitTest extends OffHeapRegionBase {
 
   @Override
   public int perObjectOverhead() {
-    return GemFireChunk.OFF_HEAP_HEADER_SIZE;
+    return ObjectChunk.OFF_HEAP_HEADER_SIZE;
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java
index 9f49da1..51f46a1 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternIntegrationTest.java
@@ -163,7 +163,7 @@ public class SimpleMemoryAllocatorFillPatternIntegrationTest {
         private int totalAllocation = 0;
         
         // List of Chunks allocated by this thread
-        private List<GemFireChunk> chunks = new LinkedList<GemFireChunk>();
+        private List<ObjectChunk> chunks = new LinkedList<ObjectChunk>();
         
         // Time to end thread execution
         private long endTime = System.currentTimeMillis() + RUN_TIME_IN_MILLIS;
@@ -173,7 +173,7 @@ public class SimpleMemoryAllocatorFillPatternIntegrationTest {
          */
         private void allocate() {          
           int allocation = chunkSizer.allocationSize();
-          GemFireChunk chunk = (GemFireChunk) allocator.allocate(allocation);
+          ObjectChunk chunk = (ObjectChunk) allocator.allocate(allocation);
           
           // This should always work just after allocation
           chunk.validateFill();
@@ -186,7 +186,7 @@ public class SimpleMemoryAllocatorFillPatternIntegrationTest {
          * Frees a random chunk from the Chunk list.
          */
         private void free() {
-          GemFireChunk chunk = chunks.remove(random.nextInt(chunks.size()));
+          ObjectChunk chunk = chunks.remove(random.nextInt(chunks.size()));
           totalAllocation -= chunk.getSize();
           
           /*
@@ -200,7 +200,7 @@ public class SimpleMemoryAllocatorFillPatternIntegrationTest {
          * Writes canned data to a random Chunk from the Chunk list.
          */
         private void write() {
-          GemFireChunk chunk = chunks.get(random.nextInt(chunks.size()));
+          ObjectChunk chunk = chunks.get(random.nextInt(chunks.size()));
           chunk.writeBytes(0, WRITE_BYTES);
         }
         

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java
index a03cf57..7c26f86 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorFillPatternJUnitTest.java
@@ -101,7 +101,7 @@ public class SimpleMemoryAllocatorFillPatternJUnitTest {
      * Pull a chunk off the fragment.  This will have no fill because
      * it is a "fresh" chunk.
      */
-    GemFireChunk chunk = (GemFireChunk) this.allocator.allocate(chunkSize);
+    ObjectChunk chunk = (ObjectChunk) this.allocator.allocate(chunkSize);
 
     /*
      * Chunk should have valid fill from initial fragment allocation.
@@ -109,7 +109,7 @@ public class SimpleMemoryAllocatorFillPatternJUnitTest {
     chunk.validateFill();
          
     // "Dirty" the chunk so the release has something to fill over
-    chunk.writeBytes(GemFireChunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
+    chunk.writeBytes(ObjectChunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
 
     // This should free the Chunk (ref count == 1)
     chunk.release();
@@ -118,20 +118,20 @@ public class SimpleMemoryAllocatorFillPatternJUnitTest {
      * This chunk should have a fill because it was reused from the
      * free list (assuming no fragmentation at this point...)
      */
-    chunk = (GemFireChunk) this.allocator.allocate(chunkSize);
+    chunk = (ObjectChunk) 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.writeBytes(GemFireChunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
+    chunk.writeBytes(ObjectChunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
     chunk.release();
 
     // Again, make sure the release implemented the fill
     chunk.validateFill();
 
     // "Dirty up" the free chunk
-    chunk.writeBytes(GemFireChunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
+    chunk.writeBytes(ObjectChunk.MIN_CHUNK_SIZE + 1, WRITE_BYTES);
     
     catchException(chunk).validateFill();
     assertTrue(caughtException() instanceof IllegalStateException);
@@ -149,14 +149,14 @@ public class SimpleMemoryAllocatorFillPatternJUnitTest {
     /*
      * Stores our allocated memory.
      */
-    GemFireChunk[] allocatedChunks = new GemFireChunk[COMPACTION_CHUNKS];
+    ObjectChunk[] allocatedChunks = new ObjectChunk[COMPACTION_CHUNKS];
     
     /*
      * Use up most of our memory
      * Our memory looks like [      ][      ][      ]
      */
     for(int i =0;i < allocatedChunks.length;++i) {
-      allocatedChunks[i] = (GemFireChunk) this.allocator.allocate(COMPACTION_CHUNK_SIZE);
+      allocatedChunks[i] = (ObjectChunk) this.allocator.allocate(COMPACTION_CHUNK_SIZE);
       allocatedChunks[i].validateFill();
     }
 
@@ -173,7 +173,7 @@ public class SimpleMemoryAllocatorFillPatternJUnitTest {
      * our initial chunks.  This should force a compaction causing our
      * memory to look like [            ][      ].
      */
-    GemFireChunk slightlyLargerChunk = (GemFireChunk) this.allocator.allocate(FORCE_COMPACTION_CHUNK_SIZE);
+    ObjectChunk slightlyLargerChunk = (ObjectChunk) this.allocator.allocate(FORCE_COMPACTION_CHUNK_SIZE);
     
     /*
      * Make sure the compacted memory has the fill validation.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
index 12c0e6d..1f17f9b 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
@@ -191,7 +191,7 @@ public class SimpleMemoryAllocatorJUnitTest {
     int BATCH_SIZE = 1;
     int TINY_MULTIPLE = com.gemstone.gemfire.internal.offheap.FreeListManager.TINY_MULTIPLE;
     int HUGE_MULTIPLE = com.gemstone.gemfire.internal.offheap.FreeListManager.HUGE_MULTIPLE;
-    int perObjectOverhead = com.gemstone.gemfire.internal.offheap.GemFireChunk.OFF_HEAP_HEADER_SIZE;
+    int perObjectOverhead = com.gemstone.gemfire.internal.offheap.ObjectChunk.OFF_HEAP_HEADER_SIZE;
     int maxTiny = com.gemstone.gemfire.internal.offheap.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);
@@ -273,7 +273,7 @@ public class SimpleMemoryAllocatorJUnitTest {
         bb.put((byte) i);
       }
       bb.position(0);
-      GemFireChunk c = (GemFireChunk) ma.allocateAndInitialize(bb.array(), false, false);
+      ObjectChunk c = (ObjectChunk) 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()));
@@ -427,7 +427,7 @@ public class SimpleMemoryAllocatorJUnitTest {
   
   @Test
   public void testCompaction() {
-    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.GemFireChunk.OFF_HEAP_HEADER_SIZE;
+    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.ObjectChunk.OFF_HEAP_HEADER_SIZE;
     final int BIG_ALLOC_SIZE = 150000;
     final int SMALL_ALLOC_SIZE = BIG_ALLOC_SIZE/2;
     final int TOTAL_MEM = BIG_ALLOC_SIZE;
@@ -543,7 +543,7 @@ public class SimpleMemoryAllocatorJUnitTest {
   boolean memoryUsageEventReceived;
   @Test
   public void testUsageEventListener() {
-    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.GemFireChunk.OFF_HEAP_HEADER_SIZE;
+    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.ObjectChunk.OFF_HEAP_HEADER_SIZE;
     final int SMALL_ALLOC_SIZE = 1000;
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(3000);
     try {
@@ -596,7 +596,7 @@ public class SimpleMemoryAllocatorJUnitTest {
   
   @Test
   public void testOutOfOffHeapMemory() {
-    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.GemFireChunk.OFF_HEAP_HEADER_SIZE;
+    final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.ObjectChunk.OFF_HEAP_HEADER_SIZE;
     final int BIG_ALLOC_SIZE = 150000;
     final int SMALL_ALLOC_SIZE = BIG_ALLOC_SIZE/2;
     final int TOTAL_MEM = BIG_ALLOC_SIZE;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
index 8d6eef0..3ae6159 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SyncChunkStackJUnitTest.java
@@ -107,7 +107,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
+      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
 
       SyncChunkStack stack = new SyncChunkStack(chunk.getMemoryAddress());
       assertEquals(false, stack.isEmpty());
@@ -121,7 +121,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
+      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
 
       SyncChunkStack stack = new SyncChunkStack();
       stack.offer(chunk.getMemoryAddress());
@@ -136,7 +136,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
+      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
 
       long addr = chunk.getMemoryAddress();
       SyncChunkStack stack = new SyncChunkStack();
@@ -163,7 +163,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
+      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
 
       long addr = chunk.getMemoryAddress();
       SyncChunkStack stack = new SyncChunkStack();
@@ -181,7 +181,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
+      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
 
       long addr = chunk.getMemoryAddress();
       SyncChunkStack stack = new SyncChunkStack();
@@ -199,7 +199,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
+      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
       long addr = chunk.getMemoryAddress();
@@ -217,7 +217,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
+      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
       long addr = chunk.getMemoryAddress();
@@ -242,7 +242,7 @@ public class SyncChunkStackJUnitTest {
     protected void testHookDoConcurrentModification() {
       if (doConcurrentMod) {
         doConcurrentMod = false;
-        GemFireChunk chunk2 = (GemFireChunk) ma.allocate(50);
+        ObjectChunk chunk2 = (ObjectChunk) ma.allocate(50);
         this.chunk2Size = chunk2.getSize();
         this.offer(chunk2.getMemoryAddress());
       }
@@ -253,7 +253,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
+      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
       long addr = chunk.getMemoryAddress();
@@ -272,7 +272,7 @@ public class SyncChunkStackJUnitTest {
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
     try {
       SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
-      GemFireChunk chunk = (GemFireChunk) ma.allocate(100);
+      ObjectChunk chunk = (ObjectChunk) ma.allocate(100);
       int chunkSize = chunk.getSize();
 
       long addr = chunk.getMemoryAddress();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
index 4272bfd..0f918cb 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteBufferByteSourceJUnitTest.java
@@ -22,7 +22,7 @@ import java.nio.ByteBuffer;
 
 import org.junit.experimental.categories.Category;
 
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.ByteSource;
@@ -35,8 +35,8 @@ public class OffHeapByteBufferByteSourceJUnitTest extends OffHeapByteSourceJUnit
   @Override
   protected ByteSource createByteSource(byte[] bytes) {
     StoredObject so = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false);
-    if (so instanceof GemFireChunk) {
-      GemFireChunk c = (GemFireChunk) so;
+    if (so instanceof ObjectChunk) {
+      ObjectChunk c = (ObjectChunk) so;
       ByteBuffer bb = c.createDirectByteBuffer();
       if (bb == null) {
         fail("could not create a direct ByteBuffer for an off-heap Chunk");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
index 91b52e4..6457425 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/pdx/OffHeapByteSourceJUnitTest.java
@@ -20,7 +20,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.experimental.categories.Category;
 
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
 import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
 import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
@@ -52,9 +52,9 @@ public class OffHeapByteSourceJUnitTest extends ByteSourceJUnitTest {
   @Override
   protected ByteSource createByteSource(byte[] bytes) {
     StoredObject so = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false);
-    if (so instanceof GemFireChunk) {
+    if (so instanceof ObjectChunk) {
       // bypass the factory to make sure that OffHeapByteSource is tested
-      return new OffHeapByteSource((GemFireChunk)so);
+      return new OffHeapByteSource((ObjectChunk)so);
     } else {
       // bytes are so small they can be encoded in a long (see DataAsAddress).
       // So for this test just wrap the original bytes.



[06/16] incubator-geode git commit: Merge remote-tracking branch 'origin/develop' into free list manager feature branch

Posted by ds...@apache.org.
Merge remote-tracking branch 'origin/develop' into free list manager feature 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/f86ff849
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/f86ff849
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/f86ff849

Branch: refs/heads/feature/GEODE-831
Commit: f86ff849503288fb6bd8838240abf67eb8264fa8
Parents: 607d041 92be457
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Wed Feb 17 16:45:48 2016 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed Feb 17 16:45:48 2016 -0800

----------------------------------------------------------------------
 gemfire-assembly/build.gradle                   |   1 -
 gemfire-assembly/src/src/dist/gradlew           | 221 +++++++++++++++
 .../gemfire/distributed/internal/DMStats.java   |   3 +-
 .../distributed/internal/DistributionStats.java |  16 +-
 .../internal/LonerDistributionManager.java      |   4 +-
 .../gms/messenger/JGroupsMessenger.java         |   2 +-
 .../cache/tier/sockets/CacheClientProxy.java    |   2 +
 .../command/ExecuteRegionFunction66.java        |   9 +-
 .../messenger/JGroupsMessengerJUnitTest.java    |  86 +++---
 .../internal/offheap/FragmentJUnitTest.java     | 280 +++++++++++++++++++
 10 files changed, 573 insertions(+), 51 deletions(-)
----------------------------------------------------------------------



[03/16] incubator-geode git commit: GEODE-968 Fixed typo in api name and added unit test.

Posted by ds...@apache.org.
GEODE-968 Fixed typo in api name and added unit test.


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

Branch: refs/heads/feature/GEODE-831
Commit: b9fe0919b2f117151845730e157bf38d50a2181c
Parents: fd31ea5
Author: Hitesh Khamesra <hk...@pivotal.io>
Authored: Wed Feb 17 16:00:24 2016 -0800
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Wed Feb 17 16:00:24 2016 -0800

----------------------------------------------------------------------
 .../gemfire/distributed/internal/DMStats.java   |  3 +-
 .../distributed/internal/DistributionStats.java | 16 ++--
 .../internal/LonerDistributionManager.java      |  4 +-
 .../gms/messenger/JGroupsMessenger.java         |  2 +-
 .../messenger/JGroupsMessengerJUnitTest.java    | 86 ++++++++++++--------
 5 files changed, 66 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b9fe0919/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
index c241bc7..6091b83 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DMStats.java
@@ -172,7 +172,8 @@ public interface DMStats {
 
   public void incMessageChannelTime(long val);
 
-  public void incUDPDispachRequestTime(long val);
+  public void incUDPDispatchRequestTime(long val);
+  public long getUDPDispatchRequestTime();
   
   public long getReplyMessageTime();
   public void incReplyMessageTime(long val);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b9fe0919/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
index 634929e..6750a54 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionStats.java
@@ -61,7 +61,7 @@ public class DistributionStats implements DMStats {
   private final static int processedMessagesTimeId;
   private final static int messageProcessingScheduleTimeId;
   private final static int messageChannelTimeId;
-  private final static int udpDispachRequestTimeId;
+  private final static int udpDispatchRequestTimeId;
   private final static int replyMessageTimeId;
   private final static int distributeMessageTimeId;
   private final static int nodesId;
@@ -273,7 +273,7 @@ public class DistributionStats implements DMStats {
     final String functionExecutionThreadsDesc = "The number of threads currently processing function execution messages.";
     final String waitingThreadsDesc = "The number of threads currently processing messages that had to wait for a resource.";
     final String messageChannelTimeDesc = "The total amount of time received messages spent in the distribution channel";
-    final String udpDispachRequestTimeDesc = "The total amount of time spent deserializing and dispatching UDP messages in the message-reader thread.";
+    final String udpDispatchRequestTimeDesc = "The total amount of time spent deserializing and dispatching UDP messages in the message-reader thread.";
     final String replyMessageTimeDesc = "The amount of time spent processing reply messages. This includes both processedMessagesTime and messageProcessingScheduleTime.";
     final String distributeMessageTimeDesc = "The amount of time it takes to prepare a message and send it on the network.  This includes sentMessagesTime.";
     final String nodesDesc = "The current number of nodes in this distributed system.";
@@ -411,7 +411,7 @@ public class DistributionStats implements DMStats {
         f.createIntGauge("functionExecutionThreads", functionExecutionThreadsDesc, "threads"),
         f.createIntGauge("waitingThreads", waitingThreadsDesc, "threads"),
         f.createLongCounter("messageChannelTime", messageChannelTimeDesc, "nanoseconds", false),
-        f.createLongCounter("udpDispachRequestTime", udpDispachRequestTimeDesc, "nanoseconds", false),
+        f.createLongCounter("udpDispatchRequestTime", udpDispatchRequestTimeDesc, "nanoseconds", false),
         f.createLongCounter("replyMessageTime", replyMessageTimeDesc, "nanoseconds", false),
         f.createLongCounter("distributeMessageTime", distributeMessageTimeDesc, "nanoseconds", false),
         f.createIntGauge("nodes", nodesDesc, "nodes"),
@@ -575,7 +575,7 @@ public class DistributionStats implements DMStats {
     messageProcessingScheduleTimeId =
       type.nameToId("messageProcessingScheduleTime");
     messageChannelTimeId = type.nameToId("messageChannelTime");
-    udpDispachRequestTimeId = type.nameToId("udpDispachRequestTime");
+    udpDispatchRequestTimeId = type.nameToId("udpDispatchRequestTime");
     replyMessageTimeId = type.nameToId("replyMessageTime");
     distributeMessageTimeId = type.nameToId("distributeMessageTime");
     nodesId = type.nameToId("nodes");
@@ -1083,12 +1083,16 @@ public class DistributionStats implements DMStats {
     }
   }
   
-  public void incUDPDispachRequestTime(long delta) {
+  public void incUDPDispatchRequestTime(long delta) {
     if (enableClockStats) {
-      this.stats.incLong(udpDispachRequestTimeId, delta);
+      this.stats.incLong(udpDispatchRequestTimeId, delta);
     }
   }
 
+  public long getUDPDispatchRequestTime() {
+    return this.stats.getLong(udpDispatchRequestTimeId);
+  }
+  
   public long getReplyMessageTime() {
     return this.stats.getLong(replyMessageTimeId);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b9fe0919/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
index 50c07de..c958028 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
@@ -363,7 +363,9 @@ public class LonerDistributionManager implements DM {
     @Override
     public void incMessageChannelTime(long val) {}
     @Override
-    public void incUDPDispachRequestTime(long val) {};
+    public void incUDPDispatchRequestTime(long val) {};
+    @Override
+    public long getUDPDispatchRequestTime() {return 0;};
     @Override
     public long getReplyMessageTime() {return 0;}
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b9fe0919/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
index b9fcc38..f3ba7a2 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
@@ -1082,7 +1082,7 @@ public class JGroupsMessenger implements Messenger {
         }
       }finally {
         long delta = DistributionStats.getStatTime() - startTime ;
-        JGroupsMessenger.this.services.getStatistics().incUDPDispachRequestTime(delta);
+        JGroupsMessenger.this.services.getStatistics().incUDPDispatchRequestTime(delta);
       }
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b9fe0919/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
index f30efc8..3dcf035 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
@@ -49,11 +49,14 @@ import org.junit.experimental.categories.Category;
 import com.gemstone.gemfire.ForcedDisconnectException;
 import com.gemstone.gemfire.GemFireIOException;
 import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException;
+import com.gemstone.gemfire.distributed.internal.DM;
 import com.gemstone.gemfire.distributed.internal.DMStats;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
 import com.gemstone.gemfire.distributed.internal.DistributionManager;
 import com.gemstone.gemfire.distributed.internal.DistributionMessage;
+import com.gemstone.gemfire.distributed.internal.DistributionStats;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.distributed.internal.SerialAckedMessage;
 import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.distributed.internal.membership.NetView;
@@ -78,6 +81,8 @@ import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
 import com.gemstone.gemfire.internal.cache.DistributedCacheOperation;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 
+import junit.framework.Assert;
+
 @Category(IntegrationTest.class)
 public class JGroupsMessengerJUnitTest {
   private Services services;
@@ -87,7 +92,7 @@ public class JGroupsMessengerJUnitTest {
   private Stopper stopper;
   private HealthMonitor healthMonitor;
   private InterceptUDP interceptor;
-
+  private long statsId = 123;
 
   /**
    * Create stub and mock objects
@@ -127,7 +132,9 @@ public class JGroupsMessengerJUnitTest {
     when(services.getHealthMonitor()).thenReturn(healthMonitor);
     when(services.getManager()).thenReturn(manager);
     when(services.getJoinLeave()).thenReturn(joinLeave);
-    when(services.getStatistics()).thenReturn(mock(DMStats.class));
+    DM dm = mock(DM.class);
+    InternalDistributedSystem system = InternalDistributedSystem.newInstanceForTesting(dm, nonDefault);
+    when(services.getStatistics()).thenReturn(new DistributionStats(system, statsId));
     
     messenger = new JGroupsMessenger();
     messenger.init(services);
@@ -747,40 +754,47 @@ public class JGroupsMessengerJUnitTest {
   
   @Test
   public void testReceiver() throws Exception {
-    initMocks(false);
-    JGroupsReceiver receiver = (JGroupsReceiver)messenger.myChannel.getReceiver();
-    
-    // a zero-length message is ignored
-    Message msg = new Message(new JGAddress(messenger.getMemberID()));
-    Object result = messenger.readJGMessage(msg);
-    assertNull(result);
-    
-    // for code coverage we need to pump this message through the receiver
-    receiver.receive(msg);
-    
-    // for more code coverage we need to actually set a buffer in the message
-    msg.setBuffer(new byte[0]);
-    result = messenger.readJGMessage(msg);
-    assertNull(result);
-    receiver.receive(msg);
-    
-    // now create a view and a real distribution-message
-    InternalDistributedMember myAddress = messenger.getMemberID();
-    InternalDistributedMember other = createAddress(8888);
-    NetView v = new NetView(myAddress);
-    v.add(other);
-    when(joinLeave.getView()).thenReturn(v);
-    messenger.installView(v);
-
-    List<InternalDistributedMember> recipients = v.getMembers();
-    SerialAckedMessage dmsg = new SerialAckedMessage();
-    dmsg.setRecipients(recipients);
-
-    // a message is ignored during manager shutdown
-    msg = messenger.createJGMessage(dmsg, new JGAddress(other), Version.CURRENT_ORDINAL);
-    when(manager.shutdownInProgress()).thenReturn(Boolean.TRUE);
-    receiver.receive(msg);
-    verify(manager, never()).processMessage(isA(DistributionMessage.class));
+    try {
+      DistributionStats.enableClockStats = true;
+      initMocks(false);
+      JGroupsReceiver receiver = (JGroupsReceiver)messenger.myChannel.getReceiver();
+      
+      // a zero-length message is ignored
+      Message msg = new Message(new JGAddress(messenger.getMemberID()));
+      Object result = messenger.readJGMessage(msg);
+      assertNull(result);
+      
+      // for code coverage we need to pump this message through the receiver
+      receiver.receive(msg);
+      
+      // for more code coverage we need to actually set a buffer in the message
+      msg.setBuffer(new byte[0]);
+      result = messenger.readJGMessage(msg);
+      assertNull(result);
+      receiver.receive(msg);
+      
+      // now create a view and a real distribution-message
+      InternalDistributedMember myAddress = messenger.getMemberID();
+      InternalDistributedMember other = createAddress(8888);
+      NetView v = new NetView(myAddress);
+      v.add(other);
+      when(joinLeave.getView()).thenReturn(v);
+      messenger.installView(v);
+  
+      List<InternalDistributedMember> recipients = v.getMembers();
+      SerialAckedMessage dmsg = new SerialAckedMessage();
+      dmsg.setRecipients(recipients);
+  
+      // a message is ignored during manager shutdown
+      msg = messenger.createJGMessage(dmsg, new JGAddress(other), Version.CURRENT_ORDINAL);
+      when(manager.shutdownInProgress()).thenReturn(Boolean.TRUE);
+      receiver.receive(msg);
+      verify(manager, never()).processMessage(isA(DistributionMessage.class));
+      
+      assertTrue("There should be UDPDispatchRequestTime stats", services.getStatistics().getUDPDispatchRequestTime() > 0);
+    }finally {
+      DistributionStats.enableClockStats = false;
+    }
   }
   
   @Test


[12/16] incubator-geode git commit: combined Chunk and GemFireChunk into GemFireChunk

Posted by ds...@apache.org.
combined Chunk and GemFireChunk into GemFireChunk


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

Branch: refs/heads/feature/GEODE-831
Commit: 436e143084cc2110655f424f1d46940792367ddb
Parents: 34936a4
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Thu Feb 18 16:58:10 2016 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Thu Feb 18 16:58:10 2016 -0800

----------------------------------------------------------------------
 .../internal/GetOperationContextImpl.java       |   6 +-
 .../query/internal/index/AbstractIndex.java     |   8 +-
 .../query/internal/index/DummyQRegion.java      |  14 +-
 .../cache/query/internal/index/HashIndex.java   |   6 +-
 .../internal/cache/AbstractRegionEntry.java     |   6 +-
 .../internal/cache/AbstractRegionMap.java       |   4 +-
 .../cache/BytesAndBitsForCompactor.java         |   8 +-
 .../gemfire/internal/cache/DiskEntry.java       |  20 +-
 .../internal/cache/DistributedRegion.java       |   6 +-
 .../gemfire/internal/cache/EntryEventImpl.java  |  52 +-
 .../gemfire/internal/cache/LocalRegion.java     |   6 +-
 .../internal/cache/PartitionedRegion.java       |   2 +-
 .../internal/cache/tier/sockets/Part.java       |  20 +-
 .../cache/wan/GatewaySenderEventImpl.java       |   8 +-
 .../gemfire/internal/offheap/Chunk.java         | 734 ------------------
 .../internal/offheap/ChunkWithHeapForm.java     |   2 +-
 .../gemfire/internal/offheap/Fragment.java      |   2 +-
 .../internal/offheap/FreeListManager.java       | 100 +--
 .../gemfire/internal/offheap/GemFireChunk.java  | 738 ++++++++++++++++++-
 .../internal/offheap/MemoryBlockNode.java       |  14 +-
 .../offheap/OffHeapCachedDeserializable.java    |   2 +-
 .../offheap/OffHeapRegionEntryHelper.java       |  10 +-
 .../offheap/SimpleMemoryAllocatorImpl.java      |  38 +-
 .../internal/offheap/SyncChunkStack.java        |  12 +-
 .../internal/tcp/ByteBufferInputStream.java     |  10 +-
 .../tcp/ImmutableByteBufferInputStream.java     |   4 +-
 .../gemfire/internal/util/BlobHelper.java       |   4 +-
 .../gemfire/pdx/internal/PdxInputStream.java    |   4 +-
 .../cache/ChunkValueWrapperJUnitTest.java       |   4 +-
 .../cache/OldValueImporterTestBase.java         |   6 +-
 .../offheap/ChunkWithHeapFormJUnitTest.java     |   2 +-
 .../internal/offheap/FragmentJUnitTest.java     |   2 +-
 .../internal/offheap/FreeListManagerTest.java   | 152 ++--
 .../offheap/FreeListOffHeapRegionJUnitTest.java |   2 +-
 .../internal/offheap/GemFireChunkJUnitTest.java |  34 +-
 .../internal/offheap/OffHeapRegionBase.java     |   8 +-
 .../OffHeapRegionEntryHelperJUnitTest.java      |  40 +-
 .../offheap/OffHeapValidationJUnitTest.java     |   4 +-
 .../OffHeapWriteObjectAsByteArrayJUnitTest.java |   4 +-
 .../OldFreeListOffHeapRegionJUnitTest.java      |   2 +-
 ...moryAllocatorFillPatternIntegrationTest.java |   8 +-
 ...mpleMemoryAllocatorFillPatternJUnitTest.java |  16 +-
 .../offheap/SimpleMemoryAllocatorJUnitTest.java |  10 +-
 .../offheap/SyncChunkStackJUnitTest.java        |  20 +-
 .../OffHeapByteBufferByteSourceJUnitTest.java   |   6 +-
 .../gemfire/pdx/OffHeapByteSourceJUnitTest.java |   6 +-
 46 files changed, 1064 insertions(+), 1102 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/cache/operations/internal/GetOperationContextImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/operations/internal/GetOperationContextImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/operations/internal/GetOperationContextImpl.java
index d973cd7..46aace1 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/operations/internal/GetOperationContextImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/operations/internal/GetOperationContextImpl.java
@@ -18,7 +18,7 @@ package com.gemstone.gemfire.cache.operations.internal;
 
 import com.gemstone.gemfire.SerializationException;
 import com.gemstone.gemfire.cache.operations.GetOperationContext;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.Releasable;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
@@ -70,7 +70,7 @@ public class GetOperationContextImpl extends GetOperationContext implements Rele
 
   private void checkForReleasedOffHeapValue(Object v) {
     // Note that we only care about Chunk (instead of all StoredObject) because it is the only one using a refcount
-    if (this.released && v instanceof Chunk) {
+    if (this.released && v instanceof GemFireChunk) {
       throw new IllegalStateException("Attempt to access off-heap value after the OperationContext callback returned.");
     }
   }
@@ -116,7 +116,7 @@ public class GetOperationContextImpl extends GetOperationContext implements Rele
     // our value (since this context did not retain it)
     // but we do make sure that any future attempt to access
     // the off-heap value fails.
-    if (super.getValue() instanceof Chunk) {
+    if (super.getValue() instanceof GemFireChunk) {
       this.released = true;
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
index 83a77fd..fe99079 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
@@ -75,7 +75,7 @@ import com.gemstone.gemfire.internal.cache.RegionEntry;
 import com.gemstone.gemfire.internal.cache.persistence.query.CloseableIterator;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 import com.gemstone.gemfire.pdx.PdxInstance;
@@ -1477,9 +1477,9 @@ public abstract class AbstractIndex implements IndexProtocol
         valueInIndex = verifyAndGetPdxDomainObject(value);
       } else{
         @Released Object val = re.getValueInVM(context.getPartitionedRegion());
-        Chunk valToFree = null;
-        if (val instanceof Chunk) {
-          valToFree = (Chunk)val;
+        GemFireChunk valToFree = null;
+        if (val instanceof GemFireChunk) {
+          valToFree = (GemFireChunk)val;
         }
         try {
         if (val instanceof CachedDeserializable) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/DummyQRegion.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/DummyQRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/DummyQRegion.java
index 3577e38..6887e9c 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/DummyQRegion.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/DummyQRegion.java
@@ -41,7 +41,7 @@ import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.RegionEntry;
 import com.gemstone.gemfire.internal.cache.RegionEntryContext;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
@@ -134,8 +134,8 @@ public class DummyQRegion extends QRegion {
     }
     valueInList.clear();
     Object val = this.entry.getValueOffHeapOrDiskWithoutFaultIn((LocalRegion) getRegion());
-    if (val instanceof Chunk) {
-      @Retained @Released Chunk ohval = (Chunk) val;
+    if (val instanceof GemFireChunk) {
+      @Retained @Released GemFireChunk ohval = (GemFireChunk) val;
       try {
         // TODO OFFHEAP: val may be off-heap PdxInstance
         val = ohval.getDeserializedValue(getRegion(), this.entry);
@@ -155,8 +155,8 @@ public class DummyQRegion extends QRegion {
       valueInArray = new  Object[1];      
     }   
     Object val = this.entry.getValueOffHeapOrDiskWithoutFaultIn((LocalRegion) getRegion());
-    if (val instanceof Chunk) {      
-      @Retained @Released Chunk ohval = (Chunk) val;
+    if (val instanceof GemFireChunk) {      
+      @Retained @Released GemFireChunk ohval = (GemFireChunk) val;
       try {
         // TODO OFFHEAP: val may be off-heap PdxInstance
         val = ohval.getDeserializedValue(getRegion(), this.entry);
@@ -178,8 +178,8 @@ public class DummyQRegion extends QRegion {
     }
     values.clear();
     Object val = this.entry.getValueOffHeapOrDiskWithoutFaultIn((LocalRegion) getRegion());
-    if (val instanceof Chunk) {
-      @Retained @Released Chunk ohval = (Chunk) val;
+    if (val instanceof GemFireChunk) {
+      @Retained @Released GemFireChunk ohval = (GemFireChunk) val;
       try {
         // TODO OFFHEAP: val may be off-heap PdxInstance
         val = ohval.getDeserializedValue(getRegion(), this.entry);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/HashIndex.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/HashIndex.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/HashIndex.java
index 465c038..1e0e8c4 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/HashIndex.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/HashIndex.java
@@ -79,7 +79,7 @@ import com.gemstone.gemfire.internal.cache.Token;
 import com.gemstone.gemfire.internal.cache.persistence.query.CloseableIterator;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 import com.gemstone.gemfire.pdx.internal.PdxString;
@@ -876,8 +876,8 @@ public class HashIndex extends AbstractIndex {
     if (this.indexOnValues) {
       Object o = entry.getValueOffHeapOrDiskWithoutFaultIn((LocalRegion) getRegion());
       try {
-        if (o instanceof Chunk) {
-          Chunk ohval = (Chunk) o;
+        if (o instanceof GemFireChunk) {
+          GemFireChunk ohval = (GemFireChunk) o;
           try {
             o = ohval.getDeserializedForReading();
           } finally {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
index 860d00f..1e65e2f 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
@@ -61,7 +61,7 @@ import com.gemstone.gemfire.internal.lang.StringUtils;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.ChunkWithHeapForm;
 import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.MemoryAllocator;
@@ -1311,9 +1311,9 @@ public abstract class AbstractRegionEntry implements RegionEntry,
           }
           return prepareValueForCache(r, heapValue, event, isEntryUpdate);
         }
-        if (val instanceof Chunk) {
+        if (val instanceof GemFireChunk) {
           // if the reused guy has a refcount then need to inc it
-          if (!((Chunk)val).retain()) {
+          if (!((GemFireChunk)val).retain()) {
             throw new IllegalStateException("Could not use an off heap value because it was freed");
           }
         }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
index 6fe60ce..bbd340e 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
@@ -75,7 +75,7 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.OffHeapRegionEntryHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
@@ -955,7 +955,7 @@ public abstract class AbstractRegionMap implements RegionMap {
                   ((ListOfDeltas)oldValue).apply(event);
                   Object preparedNewValue =oldRe.prepareValueForCache(owner,
                       event.getNewValueAsOffHeapDeserializedOrRaw(), true);
-                  if(preparedNewValue instanceof Chunk) {
+                  if(preparedNewValue instanceof GemFireChunk) {
                     event.setNewValue(preparedNewValue);
                   }
                   oldRe.setValue(owner, preparedNewValue, event);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BytesAndBitsForCompactor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BytesAndBitsForCompactor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BytesAndBitsForCompactor.java
index 3a3b5a1..ef93240 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BytesAndBitsForCompactor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BytesAndBitsForCompactor.java
@@ -16,7 +16,7 @@
  */
 package com.gemstone.gemfire.internal.cache;
 
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 
 /**
@@ -36,7 +36,7 @@ public class BytesAndBitsForCompactor {
    * The dataChunk field is unretained so it can only be used while the RegionEntry is still synced.
    * When done with the dataChunk, null it out if you want to reuse the byte[] later.
    */
-  private @Unretained Chunk dataChunk;
+  private @Unretained GemFireChunk dataChunk;
   private  byte[] data;
   private  byte userBits=0;
   // length of the data present in the byte array 
@@ -56,7 +56,7 @@ public class BytesAndBitsForCompactor {
   }
 
   
-  public final Chunk getDataChunk() {
+  public final GemFireChunk getDataChunk() {
     return this.dataChunk;
   }
   public final byte[] getBytes() {
@@ -87,7 +87,7 @@ public class BytesAndBitsForCompactor {
     this.validLength = validLength;    
     this.isReusable = isReusable;
   }
-  public void setChunkData(Chunk c, byte userBits) {
+  public void setChunkData(GemFireChunk c, byte userBits) {
     this.dataChunk = c;
     this.userBits = userBits;
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java
index c855cca..68ff77c 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java
@@ -40,7 +40,7 @@ import com.gemstone.gemfire.internal.cache.versions.VersionStamp;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
 import com.gemstone.gemfire.internal.offheap.Releasable;
@@ -208,8 +208,8 @@ public interface DiskEntry extends RegionEntry {
     static Object getValueOnDiskOrBuffer(DiskEntry entry, DiskRegion dr, RegionEntryContext context) {
       @Released Object v = getOffHeapValueOnDiskOrBuffer(entry, dr, context);
       if (v instanceof CachedDeserializable) {
-        if (v instanceof Chunk) {
-          @Released Chunk ohv = (Chunk) v;
+        if (v instanceof GemFireChunk) {
+          @Released GemFireChunk ohv = (GemFireChunk) v;
           try {
             v = ohv.getDeserializedValue(null, null);
             if (v == ohv) {
@@ -688,8 +688,8 @@ public interface DiskEntry extends RegionEntry {
      * Note that this class is only used with uncompressed chunks.
      */
     public static class ChunkValueWrapper implements ValueWrapper {
-      private final @Unretained Chunk chunk;
-      public ChunkValueWrapper(Chunk c) {
+      private final @Unretained GemFireChunk chunk;
+      public ChunkValueWrapper(GemFireChunk c) {
         assert !c.isCompressed();
         this.chunk = c;
       }
@@ -722,7 +722,7 @@ public interface DiskEntry extends RegionEntry {
             return;
           }
         }
-        final long bbAddress = Chunk.getDirectByteBufferAddress(bb);
+        final long bbAddress = GemFireChunk.getDirectByteBufferAddress(bb);
         if (bbAddress != 0L) {
           int bytesRemaining = maxOffset;
           int availableSpace = bb.remaining();
@@ -782,8 +782,8 @@ public interface DiskEntry extends RegionEntry {
         byte[] bytes;
         if (value instanceof CachedDeserializable) {
           CachedDeserializable proxy = (CachedDeserializable)value;
-          if (proxy instanceof Chunk) {
-            return new ChunkValueWrapper((Chunk) proxy);
+          if (proxy instanceof GemFireChunk) {
+            return new ChunkValueWrapper((GemFireChunk) proxy);
           }
           if (proxy instanceof StoredObject) {
             StoredObject ohproxy = (StoredObject) proxy;
@@ -833,8 +833,8 @@ public interface DiskEntry extends RegionEntry {
           // We don't do this for the delta case because getRawNewValue returns delta
           // and we want to write the entire new value to disk.
           rawValue = event.getRawNewValue();
-          if (rawValue instanceof Chunk) {
-            return new ChunkValueWrapper((Chunk) rawValue);
+          if (rawValue instanceof GemFireChunk) {
+            return new ChunkValueWrapper((GemFireChunk) rawValue);
           }
         }
         if (event.getCachedSerializedNewValue() != null) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
index 92b585a..d63dd90 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
@@ -121,7 +121,7 @@ import com.gemstone.gemfire.internal.cache.wan.parallel.ConcurrentParallelGatewa
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
@@ -2541,8 +2541,8 @@ public class DistributedRegion extends LocalRegion implements
     }
     //For SQLFire , we need to increment the use count so that returned
     //object has use count 2
-    if( incrementUseCountForSqlf && result instanceof Chunk) {
-      ((Chunk)result).retain();
+    if( incrementUseCountForSqlf && result instanceof GemFireChunk) {
+      ((GemFireChunk)result).retain();
     }
     return result;
     } finally {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
index 9cf2f13..8198349 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
@@ -73,7 +73,7 @@ import com.gemstone.gemfire.internal.lang.StringUtils;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.OffHeapRegionEntryHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
@@ -930,9 +930,9 @@ public class EntryEventImpl
     if (this.offHeapOk) {
       OffHeapHelper.releaseAndTrackOwner(this.newValue, this);
     }
-    if (v instanceof Chunk) {
+    if (v instanceof GemFireChunk) {
       ReferenceCountHelper.setReferenceCountOwner(this);
-      if (!((Chunk) v).retain()) {
+      if (!((GemFireChunk) v).retain()) {
         ReferenceCountHelper.setReferenceCountOwner(null);
         this.newValue = null;
         return;
@@ -946,13 +946,13 @@ public class EntryEventImpl
    * Returns true if this event has a reference to an off-heap new or old value.
    */
   public boolean hasOffHeapValue() {
-    return (this.newValue instanceof Chunk) || (this.oldValue instanceof Chunk);
+    return (this.newValue instanceof GemFireChunk) || (this.oldValue instanceof GemFireChunk);
   }
   
   @Unretained
   protected final Object basicGetNewValue() {
     Object result = this.newValue;
-    if (!this.offHeapOk && result instanceof Chunk) {
+    if (!this.offHeapOk && result instanceof GemFireChunk) {
       //this.region.getCache().getLogger().info("DEBUG new value already freed " + System.identityHashCode(result));
       throw new IllegalStateException("Attempt to access off heap value after the EntryEvent was released.");
     }
@@ -992,7 +992,7 @@ public class EntryEventImpl
     @Released final Object curOldValue = this.oldValue;
     if (v == curOldValue) return;
     if (this.offHeapOk) {
-      if (curOldValue instanceof Chunk) {
+      if (curOldValue instanceof GemFireChunk) {
         if (ReferenceCountHelper.trackReferenceCounts()) {
           OffHeapHelper.releaseAndTrackOwner(curOldValue, new OldValueOwner());
         } else {
@@ -1008,17 +1008,17 @@ public class EntryEventImpl
   private void retainAndSetOldValue(@Retained(ENTRY_EVENT_OLD_VALUE) Object v) {
     if (v == this.oldValue) return;
     
-    if (v instanceof Chunk) {
+    if (v instanceof GemFireChunk) {
       if (ReferenceCountHelper.trackReferenceCounts()) {
         ReferenceCountHelper.setReferenceCountOwner(new OldValueOwner());
-        boolean couldNotRetain = (!((Chunk) v).retain());
+        boolean couldNotRetain = (!((GemFireChunk) v).retain());
         ReferenceCountHelper.setReferenceCountOwner(null);
         if (couldNotRetain) {
           this.oldValue = null;
           return;
         }
       } else {
-        if (!((Chunk) v).retain()) {
+        if (!((GemFireChunk) v).retain()) {
           this.oldValue = null;
           return;
         }
@@ -1031,7 +1031,7 @@ public class EntryEventImpl
   private Object basicGetOldValue() {
     @Unretained(ENTRY_EVENT_OLD_VALUE)
     Object result = this.oldValue;
-    if (!this.offHeapOk && result instanceof Chunk) {
+    if (!this.offHeapOk && result instanceof GemFireChunk) {
       //this.region.getCache().getLogger().info("DEBUG old value already freed " + System.identityHashCode(result));
       throw new IllegalStateException("Attempt to access off heap value after the EntryEvent was released.");
     }
@@ -1360,7 +1360,7 @@ public class EntryEventImpl
       @Unretained(ENTRY_EVENT_NEW_VALUE)
       final StoredObject so = (StoredObject) nv;
       final boolean isSerialized = so.isSerialized();
-      if (nv instanceof Chunk) {
+      if (nv instanceof GemFireChunk) {
         if (importer.isUnretainedNewReferenceOk()) {
           importer.importNewObject(nv, isSerialized);
         } else {
@@ -1447,7 +1447,7 @@ public class EntryEventImpl
     if (ov instanceof StoredObject) {
       final StoredObject so = (StoredObject) ov;
       final boolean isSerialized = so.isSerialized();
-      if (ov instanceof Chunk) {
+      if (ov instanceof GemFireChunk) {
         if (importer.isUnretainedOldReferenceOk()) {
           importer.importOldObject(ov, isSerialized);
         } else {
@@ -1869,8 +1869,8 @@ public class EntryEventImpl
     Object preparedV = reentry.prepareValueForCache(this.region, v, this, this.hasDelta());
     if (preparedV != v) {
       v = preparedV;
-      if (v instanceof Chunk) {
-        if (!((Chunk) v).isCompressed()) { // fix bug 52109
+      if (v instanceof GemFireChunk) {
+        if (!((GemFireChunk) v).isCompressed()) { // fix bug 52109
           // If we put it off heap and it is not compressed then remember that value.
           // Otherwise we want to remember the decompressed value in the event.
           basicSetNewValue(v);
@@ -1931,8 +1931,8 @@ public class EntryEventImpl
       success = true;
     }
     } finally {
-      if (!success && reentry instanceof OffHeapRegionEntry && v instanceof Chunk) {
-        OffHeapRegionEntryHelper.releaseEntry((OffHeapRegionEntry)reentry, (Chunk)v);
+      if (!success && reentry instanceof OffHeapRegionEntry && v instanceof GemFireChunk) {
+        OffHeapRegionEntryHelper.releaseEntry((OffHeapRegionEntry)reentry, (GemFireChunk)v);
       }      
     }
     if (logger.isTraceEnabled()) {
@@ -2232,7 +2232,7 @@ public class EntryEventImpl
    * If a PdxInstance is returned then it will have an unretained reference
    * to Chunk's off-heap address.
    */
-  public static @Unretained Object deserializeChunk(Chunk bytes) {
+  public static @Unretained Object deserializeChunk(GemFireChunk bytes) {
     if (bytes == null)
       return null;
     try {
@@ -2874,7 +2874,7 @@ public class EntryEventImpl
     private final byte[] serializedValue;
     
     SerializedCacheValueImpl(EntryEventImpl event, Region r, RegionEntry re, @Unretained CachedDeserializable cd, byte[] serializedBytes) {
-      if (cd instanceof Chunk) {
+      if (cd instanceof GemFireChunk) {
         this.event = event;
       } else {
         this.event = null;
@@ -3053,14 +3053,14 @@ public class EntryEventImpl
     Object nv = basicGetNewValue();
     this.offHeapOk = false;
     
-    if (ov instanceof Chunk) {
+    if (ov instanceof GemFireChunk) {
       //this.region.getCache().getLogger().info("DEBUG freeing ref to old value on " + System.identityHashCode(ov));
       if (ReferenceCountHelper.trackReferenceCounts()) {
         ReferenceCountHelper.setReferenceCountOwner(new OldValueOwner());
-        ((Chunk) ov).release();
+        ((GemFireChunk) ov).release();
         ReferenceCountHelper.setReferenceCountOwner(null);
       } else {
-        ((Chunk) ov).release();
+        ((GemFireChunk) ov).release();
       }
     }
     OffHeapHelper.releaseAndTrackOwner(nv, this);
@@ -3071,7 +3071,7 @@ public class EntryEventImpl
    * Once this is called on an event it does not need to have release called.
    */
   public void disallowOffHeapValues() {
-    if (this.newValue instanceof Chunk || this.oldValue instanceof Chunk) {
+    if (this.newValue instanceof GemFireChunk || this.oldValue instanceof GemFireChunk) {
       throw new IllegalStateException("This event does not support off-heap values");
     }
     this.offHeapOk = false;
@@ -3085,7 +3085,7 @@ public class EntryEventImpl
   @Released({ENTRY_EVENT_NEW_VALUE, ENTRY_EVENT_OLD_VALUE})
   public void copyOffHeapToHeap() {
     Object ov = basicGetOldValue();
-    if (ov instanceof Chunk) {
+    if (ov instanceof GemFireChunk) {
       if (ReferenceCountHelper.trackReferenceCounts()) {
         ReferenceCountHelper.setReferenceCountOwner(new OldValueOwner());
         this.oldValue = OffHeapHelper.copyAndReleaseIfNeeded(ov);
@@ -3095,19 +3095,19 @@ public class EntryEventImpl
       }
     }
     Object nv = basicGetNewValue();
-    if (nv instanceof Chunk) {
+    if (nv instanceof GemFireChunk) {
       ReferenceCountHelper.setReferenceCountOwner(this);
       this.newValue = OffHeapHelper.copyAndReleaseIfNeeded(nv);
       ReferenceCountHelper.setReferenceCountOwner(null);
     }
-    if (this.newValue instanceof Chunk || this.oldValue instanceof Chunk) {
+    if (this.newValue instanceof GemFireChunk || this.oldValue instanceof GemFireChunk) {
       throw new IllegalStateException("event's old/new value still off-heap after calling copyOffHeapToHeap");
     }
     this.offHeapOk = false;
   }
 
   public boolean isOldValueOffHeap() {
-    return this.oldValue instanceof Chunk;
+    return this.oldValue instanceof GemFireChunk;
   }
   public final boolean isFetchFromHDFS() {
     return fetchFromHDFS;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
index 2092508..b367072 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
@@ -203,7 +203,7 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
@@ -1587,8 +1587,8 @@ public class LocalRegion extends AbstractRegion
           }
           //For sqlf since the deserialized value is nothing but chunk
           // before returning the found value increase its use count
-          if(GemFireCacheImpl.sqlfSystem() && result instanceof Chunk) {
-            if(!((Chunk)result).retain()) {
+          if(GemFireCacheImpl.sqlfSystem() && result instanceof GemFireChunk) {
+            if(!((GemFireChunk)result).retain()) {
               return null;
             }
           }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
index b145a91..1218f20 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
@@ -252,7 +252,7 @@ import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.LoggingThreadGroup;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.internal.sequencelog.RegionLogger;
 import com.gemstone.gemfire.internal.util.TransformUtils;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Part.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Part.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Part.java
index 5418c68..c401f3d 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Part.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Part.java
@@ -18,7 +18,7 @@ package com.gemstone.gemfire.internal.cache.tier.sockets;
 
 import com.gemstone.gemfire.internal.*;
 import com.gemstone.gemfire.internal.cache.CachedDeserializable;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.DataAsAddress;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.offheap.UnsafeMemoryChunk;
@@ -136,7 +136,7 @@ public class Part {
     if (so instanceof DataAsAddress) {
       this.part = ((DataAsAddress)so).getRawBytes();
     } else {
-      this.part = (Chunk)so;
+      this.part = (GemFireChunk)so;
     }
   }
   public byte getTypeCode() {
@@ -151,8 +151,8 @@ public class Part {
       return 0;
     } else if (this.part instanceof byte[]) {
       return ((byte[])this.part).length;
-    } else if (this.part instanceof Chunk) {
-      return ((Chunk) this.part).getValueSizeInBytes();
+    } else if (this.part instanceof GemFireChunk) {
+      return ((GemFireChunk) this.part).getValueSizeInBytes();
     } else {
       return ((HeapDataOutputStream)this.part).size();
     }
@@ -294,8 +294,8 @@ public class Part {
       if (this.part instanceof byte[]) {
         byte[] bytes = (byte[])this.part;
         out.write(bytes, 0, bytes.length);
-      } else if (this.part instanceof Chunk) {
-        Chunk c = (Chunk) this.part;
+      } else if (this.part instanceof GemFireChunk) {
+        GemFireChunk c = (GemFireChunk) this.part;
         ByteBuffer cbb = c.createDirectByteBuffer();
         if (cbb != null) {
           HeapDataOutputStream.writeByteBufferToStream(out,  buf, cbb);
@@ -327,8 +327,8 @@ public class Part {
     if (getLength() > 0) {
       if (this.part instanceof byte[]) {
         buf.put((byte[])this.part);
-      } else if (this.part instanceof Chunk) {
-        Chunk c = (Chunk) this.part;
+      } else if (this.part instanceof GemFireChunk) {
+        GemFireChunk c = (GemFireChunk) this.part;
         ByteBuffer bb = c.createDirectByteBuffer();
         if (bb != null) {
           buf.put(bb);
@@ -377,10 +377,10 @@ public class Part {
           }
           buf.clear();
         }
-      } else if (this.part instanceof Chunk) {
+      } else if (this.part instanceof GemFireChunk) {
         // instead of copying the Chunk to buf try to create a direct ByteBuffer and
         // just write it directly to the socket channel.
-        Chunk c = (Chunk) this.part;
+        GemFireChunk c = (GemFireChunk) this.part;
         ByteBuffer bb = c.createDirectByteBuffer();
         if (bb != null) {
           while (bb.remaining() > 0) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
index 4df8f35..cff3a6e 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
@@ -50,7 +50,7 @@ import com.gemstone.gemfire.internal.cache.WrappedCallbackArgument;
 import com.gemstone.gemfire.internal.cache.lru.Sizeable;
 import com.gemstone.gemfire.internal.cache.tier.sockets.CacheServerHelper;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.internal.offheap.Chunk;
+import com.gemstone.gemfire.internal.offheap.GemFireChunk;
 import com.gemstone.gemfire.internal.offheap.ChunkWithHeapForm;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
@@ -549,11 +549,11 @@ public class GatewaySenderEventImpl implements
     Object result = this.value;
     if (result == null) {
       result = this.valueObj;
-      if (result instanceof Chunk) {
+      if (result instanceof GemFireChunk) {
         if (this.valueObjReleased) {
           result = null;
         } else {
-          Chunk ohref = (Chunk) result;
+          GemFireChunk ohref = (GemFireChunk) result;
           if (!ohref.retain()) {
             result = null;
           } else if (this.valueObjReleased) {
@@ -1260,7 +1260,7 @@ public class GatewaySenderEventImpl implements
           return this;
         }
       }
-      if (v instanceof Chunk) {
+      if (v instanceof GemFireChunk) {
         try {
           return makeCopy();
         } catch (IllegalStateException ex) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Chunk.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Chunk.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Chunk.java
deleted file mode 100644
index 548464d..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Chunk.java
+++ /dev/null
@@ -1,734 +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.io.DataOutput;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.ByteBuffer;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.DSCODE;
-import com.gemstone.gemfire.internal.HeapDataOutputStream;
-import com.gemstone.gemfire.internal.InternalDataSerializer;
-import com.gemstone.gemfire.internal.cache.EntryEventImpl;
-import com.gemstone.gemfire.internal.cache.RegionEntry;
-import com.gemstone.gemfire.internal.cache.RegionEntryContext;
-import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
-
-/**
-   * Note: this class has a natural ordering that is inconsistent with equals.
-   * Instances of this class should have a short lifetime. We do not store references
-   * to it in the cache. Instead the memoryAddress is stored in a primitive field in
-   * the cache and if used it will then, if needed, create an instance of this class.
-   */
-  public abstract class Chunk extends OffHeapCachedDeserializable implements Comparable<Chunk>, MemoryBlock {
-    /**
-     * The unsafe memory address of the first byte of this chunk
-     */
-    private final long memoryAddress;
-    
-    /**
-     * The useCount, chunkSize, dataSizeDelta, isSerialized, and isCompressed
-     * are all stored in off heap memory in a HEADER. This saves heap memory
-     * by using off heap.
-     */
-    public final static int OFF_HEAP_HEADER_SIZE = 4 + 4;
-    /**
-     * We need to smallest chunk to at least have enough room for a hdr
-     * and for an off heap ref (which is a long).
-     */
-    public final static int MIN_CHUNK_SIZE = OFF_HEAP_HEADER_SIZE + 8;
-    /**
-     * int field.
-     * The number of bytes in this chunk.
-     */
-    private final static int CHUNK_SIZE_OFFSET = 0;
-    /**
-     * Volatile int field
-     * The upper two bits are used for the isSerialized
-     * and isCompressed flags.
-     * The next three bits are unused.
-     * The lower 3 bits of the most significant byte contains a magic number to help us detect
-     * if we are changing the ref count of an object that has been released.
-     * The next byte contains the dataSizeDelta.
-     * The number of bytes of logical data in this chunk.
-     * Since the number of bytes of logical data is always <= chunkSize
-     * and since chunkSize never changes, we have dataSize be
-     * a delta whose max value would be HUGE_MULTIPLE-1.
-     * The lower two bytes contains the use count.
-     */
-    final static int REF_COUNT_OFFSET = 4;
-    /**
-     * The upper two bits are used for the isSerialized
-     * and isCompressed flags.
-     */
-    final static int IS_SERIALIZED_BIT =    0x80000000;
-    final static int IS_COMPRESSED_BIT =    0x40000000;
-    // UNUSED 0x38000000
-    final static int MAGIC_MASK = 0x07000000;
-    final static int MAGIC_NUMBER = 0x05000000;
-    final static int DATA_SIZE_DELTA_MASK = 0x00ff0000;
-    final static int DATA_SIZE_SHIFT = 16;
-    final static int REF_COUNT_MASK =       0x0000ffff;
-    final static int MAX_REF_COUNT = 0xFFFF;
-    final static long FILL_PATTERN = 0x3c3c3c3c3c3c3c3cL;
-    final static byte FILL_BYTE = 0x3c;
-    
-    protected Chunk(long memoryAddress, int chunkSize) {
-      SimpleMemoryAllocatorImpl.validateAddressAndSize(memoryAddress, chunkSize);
-      this.memoryAddress = memoryAddress;
-      setSize(chunkSize);
-      UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, MAGIC_NUMBER);
-    }
-    public void readyForFree() {
-      UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, 0);
-    }
-    public void readyForAllocation() {
-      if (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET, 0, MAGIC_NUMBER)) {
-        throw new IllegalStateException("Expected 0 but found " + Integer.toHexString(UnsafeMemoryChunk.readAbsoluteIntVolatile(getMemoryAddress()+REF_COUNT_OFFSET)));
-      }
-    }
-    /**
-     * Should only be used by FakeChunk subclass
-     */
-    protected Chunk() {
-      this.memoryAddress = 0L;
-    }
-    
-    /**
-     * Used to create a Chunk given an existing, already allocated,
-     * memoryAddress. The off heap header has already been initialized.
-     */
-    protected Chunk(long memoryAddress) {
-      SimpleMemoryAllocatorImpl.validateAddress(memoryAddress);
-      this.memoryAddress = memoryAddress;
-    }
-    
-    protected Chunk(Chunk chunk) {
-      this.memoryAddress = chunk.memoryAddress;
-    }
-    
-    /**
-     * Throw an exception if this chunk is not allocated
-     */
-    public void checkIsAllocated() {
-      int originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
-      if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
-        throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
-      }
-    }
-    
-    public void incSize(int inc) {
-      setSize(getSize()+inc);
-    }
-    
-    protected void beforeReturningToAllocator() {
-      
-    }
-
-    @Override
-    public int getSize() {
-      return getSize(this.memoryAddress);
-    }
-
-    public void setSize(int size) {
-      setSize(this.memoryAddress, size);
-    }
-
-    public long getMemoryAddress() {
-      return this.memoryAddress;
-    }
-    
-    public int getDataSize() {
-      /*int dataSizeDelta = UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET);
-      dataSizeDelta &= DATA_SIZE_DELTA_MASK;
-      dataSizeDelta >>= DATA_SIZE_SHIFT;
-      return getSize() - dataSizeDelta;*/
-      return getDataSize(this.memoryAddress);
-    }
-    
-    protected static int getDataSize(long memoryAdress) {
-      int dataSizeDelta = UnsafeMemoryChunk.readAbsoluteInt(memoryAdress+REF_COUNT_OFFSET);
-      dataSizeDelta &= DATA_SIZE_DELTA_MASK;
-      dataSizeDelta >>= DATA_SIZE_SHIFT;
-      return getSize(memoryAdress) - dataSizeDelta;
-    }
-    
-    protected long getBaseDataAddress() {
-      return this.memoryAddress+OFF_HEAP_HEADER_SIZE;
-    }
-    protected int getBaseDataOffset() {
-      return 0;
-    }
-    
-    /**
-     * Creates and returns a direct ByteBuffer that contains the contents of this Chunk.
-     * Note that the returned ByteBuffer has a reference to this chunk's
-     * off-heap address so it can only be used while this Chunk is retained.
-     * @return the created direct byte buffer or null if it could not be created.
-     */
-    @Unretained
-    public ByteBuffer createDirectByteBuffer() {
-      return basicCreateDirectByteBuffer(getBaseDataAddress(), getDataSize());
-    }
-    @Override
-    public void sendTo(DataOutput out) throws IOException {
-      if (!this.isCompressed() && out instanceof HeapDataOutputStream) {
-        ByteBuffer bb = createDirectByteBuffer();
-        if (bb != null) {
-          HeapDataOutputStream hdos = (HeapDataOutputStream) out;
-          if (this.isSerialized()) {
-            hdos.write(bb);
-          } else {
-            hdos.writeByte(DSCODE.BYTE_ARRAY);
-            InternalDataSerializer.writeArrayLength(bb.remaining(), hdos);
-            hdos.write(bb);
-          }
-          return;
-        }
-      }
-      super.sendTo(out);
-    }
-    
-    @Override
-    public void sendAsByteArray(DataOutput out) throws IOException {
-      if (!isCompressed() && out instanceof HeapDataOutputStream) {
-        ByteBuffer bb = createDirectByteBuffer();
-        if (bb != null) {
-          HeapDataOutputStream hdos = (HeapDataOutputStream) out;
-          InternalDataSerializer.writeArrayLength(bb.remaining(), hdos);
-          hdos.write(bb);
-          return;
-        }
-      }
-      super.sendAsByteArray(out);
-    }
-       
-    private static volatile Class dbbClass = null;
-    private static volatile Constructor dbbCtor = null;
-    private static volatile boolean dbbCreateFailed = false;
-    
-    /**
-     * @return the created direct byte buffer or null if it could not be created.
-     */
-    private static ByteBuffer basicCreateDirectByteBuffer(long baseDataAddress, int dataSize) {
-      if (dbbCreateFailed) {
-        return null;
-      }
-      Constructor ctor = dbbCtor;
-      if (ctor == null) {
-        Class c = dbbClass;
-        if (c == null) {
-          try {
-            c = Class.forName("java.nio.DirectByteBuffer");
-          } catch (ClassNotFoundException e) {
-            //throw new IllegalStateException("Could not find java.nio.DirectByteBuffer", e);
-            dbbCreateFailed = true;
-            dbbAddressFailed = true;
-            return null;
-          }
-          dbbClass = c;
-        }
-        try {
-          ctor = c.getDeclaredConstructor(long.class, int.class);
-        } catch (NoSuchMethodException | SecurityException e) {
-          //throw new IllegalStateException("Could not get constructor DirectByteBuffer(long, int)", e);
-          dbbClass = null;
-          dbbCreateFailed = true;
-          return null;
-        }
-        ctor.setAccessible(true);
-        dbbCtor = ctor;
-      }
-      try {
-        return (ByteBuffer)ctor.newInstance(baseDataAddress, dataSize);
-      } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-        //throw new IllegalStateException("Could not create an instance using DirectByteBuffer(long, int)", e);
-        dbbClass = null;
-        dbbCtor = null;
-        dbbCreateFailed = true;
-        return null;
-      }
-    }
-    private static volatile Method dbbAddressMethod = null;
-    private static volatile boolean dbbAddressFailed = false;
-    
-    /**
-     * Returns the address of the Unsafe memory for the first byte of a direct ByteBuffer.
-     * If the buffer is not direct or the address can not be obtained return 0.
-     */
-    public static long getDirectByteBufferAddress(ByteBuffer bb) {
-      if (!bb.isDirect()) {
-        return 0L;
-      }
-      if (dbbAddressFailed) {
-        return 0L;
-      }
-      Method m = dbbAddressMethod;
-      if (m == null) {
-        Class c = dbbClass;
-        if (c == null) {
-          try {
-            c = Class.forName("java.nio.DirectByteBuffer");
-          } catch (ClassNotFoundException e) {
-            //throw new IllegalStateException("Could not find java.nio.DirectByteBuffer", e);
-            dbbCreateFailed = true;
-            dbbAddressFailed = true;
-            return 0L;
-          }
-          dbbClass = c;
-        }
-        try {
-          m = c.getDeclaredMethod("address");
-        } catch (NoSuchMethodException | SecurityException e) {
-          //throw new IllegalStateException("Could not get method DirectByteBuffer.address()", e);
-          dbbClass = null;
-          dbbAddressFailed = true;
-          return 0L;
-        }
-        m.setAccessible(true);
-        dbbAddressMethod = m;
-      }
-      try {
-        return (Long)m.invoke(bb);
-      } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-        //throw new IllegalStateException("Could not create an invoke DirectByteBuffer.address()", e);
-        dbbClass = null;
-        dbbAddressMethod = null;
-        dbbAddressFailed = true;
-        return 0L;
-      }
-    }
-    /**
-     * Returns an address that can be used with unsafe apis to access this chunks memory.
-     * @param offset the offset from this chunk's first byte of the byte the returned address should point to. Must be >= 0.
-     * @param size the number of bytes that will be read using the returned address. Assertion will use this to verify that all the memory accessed belongs to this chunk. Must be > 0.
-     * @return a memory address that can be used with unsafe apis
-     */
-    public long getUnsafeAddress(int offset, int size) {
-      assert offset >= 0 && offset + size <= getDataSize(): "Offset=" + offset + ",size=" + size + ",dataSize=" + getDataSize() + ", chunkSize=" + getSize() + ", but offset + size must be <= " + getDataSize();
-      assert size > 0;
-      long result = getBaseDataAddress() + offset;
-      // validateAddressAndSizeWithinSlab(result, size);
-      return result;
-    }
-    
-    @Override
-    public byte readByte(int offset) {
-      assert offset < getDataSize();
-      return UnsafeMemoryChunk.readAbsoluteByte(getBaseDataAddress() + offset);
-    }
-
-    @Override
-    public void writeByte(int offset, byte value) {
-      assert offset < getDataSize();
-      UnsafeMemoryChunk.writeAbsoluteByte(getBaseDataAddress() + offset, value);
-    }
-
-    @Override
-    public void readBytes(int offset, byte[] bytes) {
-      readBytes(offset, bytes, 0, bytes.length);
-    }
-
-    @Override
-    public void writeBytes(int offset, byte[] bytes) {
-      writeBytes(offset, bytes, 0, bytes.length);
-    }
-
-    public long getAddressForReading(int offset, int size) {
-      //delegate to getUnsafeAddress - as both the methods does return the memory address from given offset
-      return getUnsafeAddress(offset, size);
-    }
-    
-    @Override
-    public void readBytes(int offset, byte[] bytes, int bytesOffset, int size) {
-      assert offset+size <= getDataSize();
-      UnsafeMemoryChunk.readAbsoluteBytes(getBaseDataAddress() + offset, bytes, bytesOffset, size);
-    }
-
-    @Override
-    public void writeBytes(int offset, byte[] bytes, int bytesOffset, int size) {
-      assert offset+size <= getDataSize();
-      UnsafeMemoryChunk.writeAbsoluteBytes(getBaseDataAddress() + offset, bytes, bytesOffset, size);
-    }
-    
-    @Override
-    public void release() {
-      release(this.memoryAddress);
-     }
-
-    @Override
-    public int compareTo(Chunk o) {
-      int result = Integer.signum(getSize() - o.getSize());
-      if (result == 0) {
-        // For the same sized chunks we really don't care about their order
-        // but we need compareTo to only return 0 if the two chunks are identical
-        result = Long.signum(getMemoryAddress() - o.getMemoryAddress());
-      }
-      return result;
-    }
-    
-    @Override
-    public boolean equals(Object o) {
-      if (o instanceof Chunk) {
-        return getMemoryAddress() == ((Chunk) o).getMemoryAddress();
-      }
-      return false;
-    }
-    
-    @Override
-    public int hashCode() {
-      long value = this.getMemoryAddress();
-      return (int)(value ^ (value >>> 32));
-    }
-
-    // OffHeapCachedDeserializable methods 
-    
-    @Override
-    public void setSerializedValue(byte[] value) {
-      writeBytes(0, value);
-    }
-    
-    public byte[] getDecompressedBytes(RegionEntryContext context) {
-      byte[] result = getCompressedBytes();
-      long time = context.getCachePerfStats().startDecompression();
-      result = context.getCompressor().decompress(result);
-      context.getCachePerfStats().endDecompression(time);      
-      return result;
-    }
-    
-    /**
-     * Returns the raw possibly compressed bytes of this chunk
-     */
-    public byte[] getCompressedBytes() {
-      byte[] result = new byte[getDataSize()];
-      readBytes(0, result);
-      //debugLog("reading", true);
-      SimpleMemoryAllocatorImpl.getAllocator().getStats().incReads();
-      return result;
-    }
-    protected byte[] getRawBytes() {
-      byte[] result = getCompressedBytes();
-      // TODO OFFHEAP: change the following to assert !isCompressed();
-      if (isCompressed()) {
-        throw new UnsupportedOperationException();
-      }
-      return result;
-    }
-
-    @Override
-    public byte[] getSerializedValue() {
-      byte [] result = getRawBytes();
-      if (!isSerialized()) {
-        // The object is a byte[]. So we need to make it look like a serialized byte[] in our result
-        result = EntryEventImpl.serialize(result);
-      }
-      return result;
-    }
-    
-    @Override
-    public Object getDeserializedValue(Region r, RegionEntry re) {
-      if (isSerialized()) {
-        // TODO OFFHEAP: debug deserializeChunk
-        return EntryEventImpl.deserialize(getRawBytes());
-        //assert !isCompressed();
-        //return EntryEventImpl.deserializeChunk(this);
-      } else {
-        return getRawBytes();
-      }
-    }
-    
-    /**
-     * We want this to include memory overhead so use getSize() instead of getDataSize().
-     */
-    @Override
-    public int getSizeInBytes() {
-      // Calling getSize includes the off heap header size.
-      // We do not add anything to this since the size of the reference belongs to the region entry size
-      // not the size of this object.
-      return getSize();
-    }
-
-    @Override
-    public int getValueSizeInBytes() {
-      return getDataSize();
-    }
-
-    @Override
-    public void copyBytes(int src, int dst, int size) {
-      throw new UnsupportedOperationException("Implement if used");
-//      assert src+size <= getDataSize();
-//      assert dst+size < getDataSize();
-//      getSlabs()[this.getSlabIdx()].copyBytes(getBaseDataAddress()+src, getBaseDataAddress()+dst, size);
-    }
-
-    @Override
-    public boolean isSerialized() {
-      return (UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET) & IS_SERIALIZED_BIT) != 0;
-    }
-
-    @Override
-    public boolean isCompressed() {
-      return (UnsafeMemoryChunk.readAbsoluteInt(this.memoryAddress+REF_COUNT_OFFSET) & IS_COMPRESSED_BIT) != 0;
-    }
-
-    @Override
-    public boolean retain() {
-      return retain(this.memoryAddress);
-    }
-
-    @Override
-    public int getRefCount() {
-      return getRefCount(this.memoryAddress);
-    }
-
-    public static int getSize(long memAddr) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
-      return UnsafeMemoryChunk.readAbsoluteInt(memAddr+CHUNK_SIZE_OFFSET);
-    }
-    public static void setSize(long memAddr, int size) {
-      SimpleMemoryAllocatorImpl.validateAddressAndSize(memAddr, size);
-      UnsafeMemoryChunk.writeAbsoluteInt(memAddr+CHUNK_SIZE_OFFSET, size);
-    }
-    public static long getNext(long memAddr) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
-      return UnsafeMemoryChunk.readAbsoluteLong(memAddr+OFF_HEAP_HEADER_SIZE);
-    }
-    public static void setNext(long memAddr, long next) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
-      UnsafeMemoryChunk.writeAbsoluteLong(memAddr+OFF_HEAP_HEADER_SIZE, next);
-    }
-    
-    /**
-     * Fills the chunk with a repeated byte fill pattern.
-     * @param baseAddress the starting address for a {@link Chunk}.
-     */
-    public static void fill(long baseAddress) {
-      long startAddress = baseAddress + MIN_CHUNK_SIZE;
-      int size = getSize(baseAddress) - MIN_CHUNK_SIZE;
-      
-      UnsafeMemoryChunk.fill(startAddress, size, FILL_BYTE);
-    }
-    
-    /**
-     * Validates that the fill pattern for this chunk has not been disturbed.  This method
-     * assumes the TINY_MULTIPLE is 8 bytes.
-     * @throws IllegalStateException when the pattern has been violated.
-     */
-    public void validateFill() {
-      assert FreeListManager.TINY_MULTIPLE == 8;
-      
-      long startAddress = getMemoryAddress() + MIN_CHUNK_SIZE;
-      int size = getSize() - MIN_CHUNK_SIZE;
-      
-      for(int i = 0;i < size;i += FreeListManager.TINY_MULTIPLE) {
-        if(UnsafeMemoryChunk.readAbsoluteLong(startAddress + i) != FILL_PATTERN) {
-          throw new IllegalStateException("Fill pattern violated for chunk " + getMemoryAddress() + " with size " + getSize());
-        }        
-      }
-    }
-
-    public void setSerialized(boolean isSerialized) {
-      if (isSerialized) {
-        int bits;
-        int originalBits;
-        do {
-          originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
-          if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
-            throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
-          }
-          bits = originalBits | IS_SERIALIZED_BIT;
-        } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
-      }
-    }
-    public void setCompressed(boolean isCompressed) {
-      if (isCompressed) {
-        int bits;
-        int originalBits;
-        do {
-          originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
-          if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
-            throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
-          }
-          bits = originalBits | IS_COMPRESSED_BIT;
-        } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
-      }
-    }
-    public void setDataSize(int dataSize) { // KIRK
-      assert dataSize <= getSize();
-      int delta = getSize() - dataSize;
-      assert delta <= (DATA_SIZE_DELTA_MASK >> DATA_SIZE_SHIFT);
-      delta <<= DATA_SIZE_SHIFT;
-      int bits;
-      int originalBits;
-      do {
-        originalBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
-        if ((originalBits&MAGIC_MASK) != MAGIC_NUMBER) {
-          throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(originalBits));
-        }
-        bits = originalBits;
-        bits &= ~DATA_SIZE_DELTA_MASK; // clear the old dataSizeDelta bits
-        bits |= delta; // set the dataSizeDelta bits to the new delta value
-      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, originalBits, bits));
-    }
-    
-    public void initializeUseCount() {
-      int rawBits;
-      do {
-        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET);
-        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
-          throw new IllegalStateException("It looks like this off heap memory was already freed. rawBits=" + Integer.toHexString(rawBits));
-        }
-        int uc = rawBits & REF_COUNT_MASK;
-        if (uc != 0) {
-          throw new IllegalStateException("Expected use count to be zero but it was: " + uc + " rawBits=0x" + Integer.toHexString(rawBits));
-        }
-      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(this.memoryAddress+REF_COUNT_OFFSET, rawBits, rawBits+1));
-    }
-
-    public static int getRefCount(long memAddr) {
-      return UnsafeMemoryChunk.readAbsoluteInt(memAddr+REF_COUNT_OFFSET) & REF_COUNT_MASK;
-    }
-
-    public static boolean retain(long memAddr) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
-      int uc;
-      int rawBits;
-      int retryCount = 0;
-      do {
-        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET);
-        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
-          // same as uc == 0
-          // TODO MAGIC_NUMBER rethink its use and interaction with compactor fragments
-          return false;
-        }
-        uc = rawBits & REF_COUNT_MASK;
-        if (uc == MAX_REF_COUNT) {
-          throw new IllegalStateException("Maximum use count exceeded. rawBits=" + Integer.toHexString(rawBits));
-        } else if (uc == 0) {
-          return false;
-        }
-        retryCount++;
-        if (retryCount > 1000) {
-          throw new IllegalStateException("tried to write " + (rawBits+1) + " to @" + Long.toHexString(memAddr) + " 1,000 times.");
-        }
-      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET, rawBits, rawBits+1));
-      //debugLog("use inced ref count " + (uc+1) + " @" + Long.toHexString(memAddr), true);
-      if (ReferenceCountHelper.trackReferenceCounts()) {
-        ReferenceCountHelper.refCountChanged(memAddr, false, uc+1);
-      }
-
-      return true;
-    }
-    public static void release(final long memAddr) {
-      release(memAddr, null);
-    }
-    static void release(final long memAddr, FreeListManager freeListManager) {
-      SimpleMemoryAllocatorImpl.validateAddress(memAddr);
-      int newCount;
-      int rawBits;
-      boolean returnToAllocator;
-      do {
-        returnToAllocator = false;
-        rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET);
-        if ((rawBits&MAGIC_MASK) != MAGIC_NUMBER) {
-          String msg = "It looks like off heap memory @" + Long.toHexString(memAddr) + " was already freed. rawBits=" + Integer.toHexString(rawBits) + " history=" + ReferenceCountHelper.getFreeRefCountInfo(memAddr);
-          //debugLog(msg, true);
-          throw new IllegalStateException(msg);
-        }
-        int curCount = rawBits&REF_COUNT_MASK;
-        if ((curCount) == 0) {
-          //debugLog("too many frees @" + Long.toHexString(memAddr), true);
-          throw new IllegalStateException("Memory has already been freed." + " history=" + ReferenceCountHelper.getFreeRefCountInfo(memAddr) /*+ System.identityHashCode(this)*/);
-        }
-        if (curCount == 1) {
-          newCount = 0; // clear the use count, bits, and the delta size since it will be freed.
-          returnToAllocator = true;
-        } else {
-          newCount = rawBits-1;
-        }
-      } while (!UnsafeMemoryChunk.writeAbsoluteIntVolatile(memAddr+REF_COUNT_OFFSET, rawBits, newCount));
-      //debugLog("free deced ref count " + (newCount&USE_COUNT_MASK) + " @" + Long.toHexString(memAddr), true);
-      if (returnToAllocator ) {
-       if (ReferenceCountHelper.trackReferenceCounts()) {
-          if (ReferenceCountHelper.trackFreedReferenceCounts()) {
-            ReferenceCountHelper.refCountChanged(memAddr, true, newCount&REF_COUNT_MASK);
-          }
-          ReferenceCountHelper.freeRefCountInfo(memAddr);
-        }
-        if (freeListManager == null) {
-          freeListManager = SimpleMemoryAllocatorImpl.getAllocator().getFreeListManager();
-        }
-        freeListManager.free(memAddr);
-      } else {
-        if (ReferenceCountHelper.trackReferenceCounts()) {
-          ReferenceCountHelper.refCountChanged(memAddr, true, newCount&REF_COUNT_MASK);
-        }
-      }
-    }
-    
-    @Override
-    public String toString() {
-      return toStringForOffHeapByteSource();
-      // This old impl is not safe because it calls getDeserializedForReading and we have code that call toString that does not inc the refcount.
-      // Also if this Chunk is compressed we don't know how to decompress it.
-      //return super.toString() + ":<dataSize=" + getDataSize() + " refCount=" + getRefCount() + " addr=" + getMemoryAddress() + " storedObject=" + getDeserializedForReading() + ">";
-    }
-    
-    protected String toStringForOffHeapByteSource() {
-      return super.toString() + ":<dataSize=" + getDataSize() + " refCount=" + getRefCount() + " addr=" + Long.toHexString(getMemoryAddress()) + ">";
-    }
-    
-    @Override
-    public State getState() {
-      if (getRefCount() > 0) {
-        return State.ALLOCATED;
-      } else {
-        return State.DEALLOCATED;
-      }
-    }
-    @Override
-    public MemoryBlock getNextBlock() {
-      throw new UnsupportedOperationException();
-    }
-    @Override
-    public int getBlockSize() {
-      return getSize();
-    }
-    @Override
-    public int getSlabId() {
-      throw new UnsupportedOperationException();
-    }
-    @Override
-    public int getFreeListId() {
-      return -1;
-    }
-    @Override
-    public String getDataType() {
-      return null;
-    }
-    @Override
-    public Object getDataValue() {
-      return null;
-    }
-    public Chunk slice(int position, int limit) {
-      throw new UnsupportedOperationException();
-    }
-  }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapForm.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapForm.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapForm.java
index d7e65f7..d889610 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapForm.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapForm.java
@@ -34,7 +34,7 @@ public class ChunkWithHeapForm extends GemFireChunk {
     return this.heapForm;
   }
   
-  public Chunk getChunkWithoutHeapForm() {
+  public GemFireChunk getChunkWithoutHeapForm() {
     return new GemFireChunk(this);
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
index d178198..186a4e4 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
@@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
  *
  */
 public class Fragment implements MemoryBlock {
-  private static final byte FILL_BYTE = Chunk.FILL_BYTE;
+  private static final byte FILL_BYTE = GemFireChunk.FILL_BYTE;
   private final long baseAddr;
   private final int size;
   @SuppressWarnings("unused")

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/436e1430/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
index 8efefbd..3fbf526 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
@@ -45,28 +45,28 @@ public class FreeListManager {
   
   final private AtomicReferenceArray<SyncChunkStack> tinyFreeLists = new AtomicReferenceArray<SyncChunkStack>(TINY_FREE_LIST_COUNT);
   // hugeChunkSet is sorted by chunk size in ascending order. It will only contain chunks larger than MAX_TINY.
-  private final ConcurrentSkipListSet<Chunk> hugeChunkSet = new ConcurrentSkipListSet<Chunk>();
+  private final ConcurrentSkipListSet<GemFireChunk> hugeChunkSet = new ConcurrentSkipListSet<GemFireChunk>();
   private final AtomicLong allocatedSize = new AtomicLong(0L);
 
   private int getNearestTinyMultiple(int size) {
     return (size-1)/TINY_MULTIPLE;
   }
-  List<Chunk> getLiveChunks() {
-    ArrayList<Chunk> result = new ArrayList<Chunk>();
+  List<GemFireChunk> getLiveChunks() {
+    ArrayList<GemFireChunk> result = new ArrayList<GemFireChunk>();
     for (int i=0; i < slabs.length; i++) {
       getLiveChunks(slabs[i], result);
     }
     return result;
   }
-  private void getLiveChunks(AddressableMemoryChunk slab, List<Chunk> result) {
+  private void getLiveChunks(AddressableMemoryChunk slab, List<GemFireChunk> result) {
     long addr = slab.getMemoryAddress();
-    while (addr <= (slab.getMemoryAddress() + slab.getSize() - Chunk.MIN_CHUNK_SIZE)) {
+    while (addr <= (slab.getMemoryAddress() + slab.getSize() - GemFireChunk.MIN_CHUNK_SIZE)) {
       Fragment f = isAddrInFragmentFreeSpace(addr);
       if (f != null) {
         addr = f.getMemoryAddress() + f.getSize();
       } else {
-        int curChunkSize = Chunk.getSize(addr);
-        int refCount = Chunk.getRefCount(addr);
+        int curChunkSize = GemFireChunk.getSize(addr);
+        int refCount = GemFireChunk.getRefCount(addr);
         if (refCount > 0) {
           result.add(new GemFireChunk(addr));
         }
@@ -95,7 +95,7 @@ public class FreeListManager {
     long result = 0;
     for (Fragment f: this.fragmentList) {
       int freeSpace = f.freeSpace();
-      if (freeSpace >= Chunk.MIN_CHUNK_SIZE) {
+      if (freeSpace >= GemFireChunk.MIN_CHUNK_SIZE) {
         result += freeSpace;
       }
     }
@@ -113,7 +113,7 @@ public class FreeListManager {
   }
   long getFreeHugeMemory() {
     long hugeFree = 0;
-    for (Chunk c: this.hugeChunkSet) {
+    for (GemFireChunk c: this.hugeChunkSet) {
       hugeFree += c.getSize();
     }
     return hugeFree;
@@ -178,10 +178,10 @@ public class FreeListManager {
    * @throws IllegalStateException if a chunk can not be allocated.
    */
   @SuppressWarnings("synthetic-access")
-  public Chunk allocate(int size) {
+  public GemFireChunk allocate(int size) {
     assert size > 0;
     
-    Chunk result = basicAllocate(size, true);
+    GemFireChunk result = basicAllocate(size, true);
 
     result.setDataSize(size);
     this.allocatedSize.addAndGet(result.getSize());
@@ -190,13 +190,13 @@ public class FreeListManager {
     return result;
   }
 
-  private Chunk basicAllocate(int size, boolean useSlabs) {
+  private GemFireChunk basicAllocate(int size, boolean useSlabs) {
     if (useSlabs) {
       // Every object stored off heap has a header so we need
       // to adjust the size so that the header gets allocated.
       // If useSlabs is false then the incoming size has already
       // been adjusted.
-      size += Chunk.OFF_HEAP_HEADER_SIZE;
+      size += GemFireChunk.OFF_HEAP_HEADER_SIZE;
     }
     if (size <= MAX_TINY) {
       return allocateTiny(size, useSlabs);
@@ -205,17 +205,17 @@ public class FreeListManager {
     }
   }
 
-  private Chunk allocateFromFragments(int chunkSize) {
+  private GemFireChunk allocateFromFragments(int chunkSize) {
     do {
       final int lastAllocationId = this.lastFragmentAllocation.get();
       for (int i=lastAllocationId; i < this.fragmentList.size(); i++) {
-        Chunk result = allocateFromFragment(i, chunkSize);
+        GemFireChunk result = allocateFromFragment(i, chunkSize);
         if (result != null) {
           return result;
         }
       }
       for (int i=0; i < lastAllocationId; i++) {
-        Chunk result = allocateFromFragment(i, chunkSize);
+        GemFireChunk result = allocateFromFragment(i, chunkSize);
         if (result != null) {
           return result;
         }
@@ -247,7 +247,7 @@ public class FreeListManager {
   }
 
   private void logHugeState(LogWriter lw) {
-    for (Chunk c: this.hugeChunkSet) {
+    for (GemFireChunk c: this.hugeChunkSet) {
       lw.info("Free huge of size " + c.getSize());
     }
   }
@@ -345,10 +345,10 @@ public class FreeListManager {
               } else {
                 // see if we can conflate into sorted[idx]
                 long lowAddr = sorted[idx-1];
-                int lowSize = Chunk.getSize(lowAddr);
+                int lowSize = GemFireChunk.getSize(lowAddr);
                 if (lowAddr + lowSize == addr) {
                   // append the addr chunk to lowAddr
-                  Chunk.setSize(lowAddr, lowSize + Chunk.getSize(addr));
+                  GemFireChunk.setSize(lowAddr, lowSize + GemFireChunk.getSize(addr));
                 } else {
                   if (sortedSize >= sorted.length) {
                     long[] newSorted = new long[sorted.length+SORT_ARRAY_BLOCK_SIZE];
@@ -360,11 +360,11 @@ public class FreeListManager {
                 }
               }
             } else {
-              int addrSize = Chunk.getSize(addr);
+              int addrSize = GemFireChunk.getSize(addr);
               long highAddr = sorted[idx];
               if (addr + addrSize == highAddr) {
                 // append highAddr chunk to addr
-                Chunk.setSize(addr, addrSize + Chunk.getSize(highAddr));
+                GemFireChunk.setSize(addr, addrSize + GemFireChunk.getSize(highAddr));
                 sorted[idx] = addr;
               } else {
                 boolean insert = idx==0;
@@ -374,10 +374,10 @@ public class FreeListManager {
                   //                    long[] tmp = Arrays.copyOf(sorted, sortedSize);
                   //                    throw new IllegalStateException("addr was zero at idx=" + (idx-1) + " sorted="+ Arrays.toString(tmp));
                   //                  }
-                  int lowSize = Chunk.getSize(lowAddr);
+                  int lowSize = GemFireChunk.getSize(lowAddr);
                   if (lowAddr + lowSize == addr) {
                     // append the addr chunk to lowAddr
-                    Chunk.setSize(lowAddr, lowSize + addrSize);
+                    GemFireChunk.setSize(lowAddr, lowSize + addrSize);
                   } else {
                     insert = true;
                   }
@@ -403,10 +403,10 @@ public class FreeListManager {
         for (int i=sortedSize-1; i > 0; i--) {
           long addr = sorted[i];
           long lowAddr = sorted[i-1];
-          int lowSize = Chunk.getSize(lowAddr);
+          int lowSize = GemFireChunk.getSize(lowAddr);
           if (lowAddr + lowSize == addr) {
             // append addr chunk to lowAddr
-            Chunk.setSize(lowAddr, lowSize + Chunk.getSize(addr));
+            GemFireChunk.setSize(lowAddr, lowSize + GemFireChunk.getSize(addr));
             sorted[i] = 0L;
           }
         }
@@ -415,7 +415,7 @@ public class FreeListManager {
         for (int i=sortedSize-1; i >= 0; i--) {
           long addr = sorted[i];
           if (addr == 0L) continue;
-          int addrSize = Chunk.getSize(addr);
+          int addrSize = GemFireChunk.getSize(addr);
           Fragment f = createFragment(addr, addrSize);
           if (addrSize >= chunkSize) {
             result = true;
@@ -508,8 +508,8 @@ public class FreeListManager {
       do {
         offset = f.getFreeIndex();
         diff = f.getSize() - offset;
-      } while (diff >= Chunk.MIN_CHUNK_SIZE && !f.allocate(offset, offset+diff));
-      if (diff < Chunk.MIN_CHUNK_SIZE) {
+      } while (diff >= GemFireChunk.MIN_CHUNK_SIZE && !f.allocate(offset, offset+diff));
+      if (diff < GemFireChunk.MIN_CHUNK_SIZE) {
         // If diff > 0 then that memory will be lost during compaction.
         // This should never happen since we keep the sizes rounded
         // based on MIN_CHUNK_SIZE.
@@ -518,7 +518,7 @@ public class FreeListManager {
         continue;
       }
       long chunkAddr = f.getMemoryAddress()+offset;
-      Chunk.setSize(chunkAddr, diff);
+      GemFireChunk.setSize(chunkAddr, diff);
       result.offer(chunkAddr);
     }
     // All the fragments have been turned in to chunks so now clear them
@@ -540,7 +540,7 @@ public class FreeListManager {
     }
   }
   private void collectFreeHugeChunks(List<SyncChunkStack> l) {
-    Chunk c = this.hugeChunkSet.pollFirst();
+    GemFireChunk c = this.hugeChunkSet.pollFirst();
     SyncChunkStack result = null;
     while (c != null) {
       if (result == null) {
@@ -552,7 +552,7 @@ public class FreeListManager {
     }
   }
 
-  Chunk allocateFromFragment(final int fragIdx, final int chunkSize) {
+  GemFireChunk allocateFromFragment(final int fragIdx, final int chunkSize) {
     if (fragIdx >= this.fragmentList.size()) return null;
     final Fragment fragment;
     try {
@@ -571,7 +571,7 @@ public class FreeListManager {
         // this fragment has room
         int newOffset = oldOffset + chunkSize;
         int extraSize = fragmentSize - newOffset;
-        if (extraSize < Chunk.MIN_CHUNK_SIZE) {
+        if (extraSize < GemFireChunk.MIN_CHUNK_SIZE) {
           // include these last few bytes of the fragment in the allocation.
           // If we don't then they will be lost forever.
           // The extraSize bytes only apply to the first chunk we allocate (not the batch ones).
@@ -582,11 +582,11 @@ public class FreeListManager {
         if (fragment.allocate(oldOffset, newOffset)) {
           // We did the allocate!
           this.lastFragmentAllocation.set(fragIdx);
-          Chunk result = new GemFireChunk(fragment.getMemoryAddress()+oldOffset, chunkSize+extraSize);
+          GemFireChunk result = new GemFireChunk(fragment.getMemoryAddress()+oldOffset, chunkSize+extraSize);
           checkDataIntegrity(result);
           return result;
         } else {
-          Chunk result = basicAllocate(chunkSize, false);
+          GemFireChunk result = basicAllocate(chunkSize, false);
           if (result != null) {
             return result;
           }
@@ -600,15 +600,15 @@ public class FreeListManager {
   private int round(int multiple, int value) {
     return (int) ((((long)value + (multiple-1)) / multiple) * multiple);
   }
-  private Chunk allocateTiny(int size, boolean useFragments) {
+  private GemFireChunk allocateTiny(int size, boolean useFragments) {
     return basicAllocate(getNearestTinyMultiple(size), TINY_MULTIPLE, 0, this.tinyFreeLists, useFragments);
   }
-  private Chunk basicAllocate(int idx, int multiple, int offset, AtomicReferenceArray<SyncChunkStack> freeLists, boolean useFragments) {
+  private GemFireChunk basicAllocate(int idx, int multiple, int offset, AtomicReferenceArray<SyncChunkStack> freeLists, boolean useFragments) {
     SyncChunkStack clq = freeLists.get(idx);
     if (clq != null) {
       long memAddr = clq.poll();
       if (memAddr != 0) {
-        Chunk result = new GemFireChunk(memAddr);
+        GemFireChunk result = new GemFireChunk(memAddr);
         checkDataIntegrity(result);
         result.readyForAllocation();
         return result;
@@ -620,13 +620,13 @@ public class FreeListManager {
       return null;
     }
   }
-  private Chunk allocateHuge(int size, boolean useFragments) {
+  private GemFireChunk allocateHuge(int size, boolean useFragments) {
     // sizeHolder is a fake Chunk used to search our sorted hugeChunkSet.
-    Chunk sizeHolder = new FakeChunk(size);
-    NavigableSet<Chunk> ts = this.hugeChunkSet.tailSet(sizeHolder);
-    Chunk result = ts.pollFirst();
+    GemFireChunk sizeHolder = new FakeChunk(size);
+    NavigableSet<GemFireChunk> ts = this.hugeChunkSet.tailSet(sizeHolder);
+    GemFireChunk result = ts.pollFirst();
     if (result != null) {
-      if (result.getSize() - (HUGE_MULTIPLE - Chunk.OFF_HEAP_HEADER_SIZE) < size) {
+      if (result.getSize() - (HUGE_MULTIPLE - GemFireChunk.OFF_HEAP_HEADER_SIZE) < size) {
         // close enough to the requested size; just return it.
         checkDataIntegrity(result);
         result.readyForAllocation();
@@ -644,7 +644,7 @@ public class FreeListManager {
     }
   }
   
-  private void checkDataIntegrity(Chunk data) {
+  private void checkDataIntegrity(GemFireChunk data) {
     if (this.validateMemoryWithFill) {
       data.validateFill();
     }
@@ -654,7 +654,7 @@ public class FreeListManager {
    * ConcurrentSkipListSet. This is not a real chunk
    * but only used for searching.
    */
-  private static class FakeChunk extends Chunk {
+  private static class FakeChunk extends GemFireChunk {
     private final int size;
     public FakeChunk(int size) {
       super();
@@ -669,14 +669,14 @@ public class FreeListManager {
   @SuppressWarnings("synthetic-access")
   public void free(long addr) {
     if (this.validateMemoryWithFill) {
-      Chunk.fill(addr);
+      GemFireChunk.fill(addr);
     }
     
     free(addr, true);
   }
 
   private void free(long addr, boolean updateStats) {
-    int cSize = Chunk.getSize(addr);
+    int cSize = GemFireChunk.getSize(addr);
     if (updateStats) {
       OffHeapMemoryStats stats = this.ma.getStats();
       stats.incObjects(-1);
@@ -739,8 +739,8 @@ public class FreeListManager {
     }
   }
   
-  private void addBlocksFromChunks(Collection<Chunk> src, List<MemoryBlock> dest) {
-    for (Chunk chunk : src) {
+  private void addBlocksFromChunks(Collection<GemFireChunk> src, List<MemoryBlock> dest) {
+    for (GemFireChunk chunk : src) {
       dest.add(new MemoryBlockNode(this.ma, chunk));
     }
   }
@@ -759,7 +759,7 @@ public class FreeListManager {
       long addr = this.tinyFreeLists.get(i).getTopAddress();
       while (addr != 0L) {
         value.add(new MemoryBlockNode(sma, new TinyMemoryBlock(addr, i)));
-        addr = Chunk.getNext(addr);
+        addr = GemFireChunk.getNext(addr);
       }
     }
     return value;
@@ -800,7 +800,7 @@ public class FreeListManager {
 
     @Override
     public int getBlockSize() {
-      return Chunk.getSize(address);
+      return GemFireChunk.getSize(address);
     }
 
     @Override


[15/16] incubator-geode git commit: renamed off-heap classes with GemFire in their name

Posted by ds...@apache.org.
renamed off-heap classes with GemFire in their name


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

Branch: refs/heads/feature/GEODE-831
Commit: 1a82c80c702520df89ff01db851e38665f09890b
Parents: 436e143
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Thu Feb 18 17:02:51 2016 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Thu Feb 18 17:02:51 2016 -0800

----------------------------------------------------------------------
 .../internal/GetOperationContextImpl.java       |   6 +-
 .../query/internal/index/AbstractIndex.java     |   8 +-
 .../query/internal/index/DummyQRegion.java      |  14 +-
 .../cache/query/internal/index/HashIndex.java   |   6 +-
 .../internal/cache/AbstractRegionEntry.java     |  12 +-
 .../internal/cache/AbstractRegionMap.java       |   4 +-
 .../cache/BytesAndBitsForCompactor.java         |   8 +-
 .../gemfire/internal/cache/DiskEntry.java       |  20 +-
 .../internal/cache/DistributedRegion.java       |   6 +-
 .../gemfire/internal/cache/EntryEventImpl.java  |  52 +-
 .../gemfire/internal/cache/LocalRegion.java     |   6 +-
 .../internal/cache/PartitionedRegion.java       |   2 +-
 .../internal/cache/tier/sockets/Part.java       |  20 +-
 .../cache/wan/GatewaySenderEventImpl.java       |   8 +-
 .../internal/offheap/ChunkWithHeapForm.java     |   8 +-
 .../gemfire/internal/offheap/Fragment.java      |   2 +-
 .../internal/offheap/FreeListManager.java       | 104 +--
 .../gemfire/internal/offheap/GemFireChunk.java  | 737 -------------------
 .../internal/offheap/GemFireChunkSlice.java     |  44 --
 .../internal/offheap/MemoryBlockNode.java       |  14 +-
 .../gemfire/internal/offheap/ObjectChunk.java   | 737 +++++++++++++++++++
 .../internal/offheap/ObjectChunkSlice.java      |  44 ++
 .../offheap/OffHeapCachedDeserializable.java    |   2 +-
 .../offheap/OffHeapRegionEntryHelper.java       |  10 +-
 .../offheap/SimpleMemoryAllocatorImpl.java      |  38 +-
 .../internal/offheap/SyncChunkStack.java        |  12 +-
 .../internal/tcp/ByteBufferInputStream.java     |  10 +-
 .../tcp/ImmutableByteBufferInputStream.java     |   4 +-
 .../gemfire/internal/util/BlobHelper.java       |   4 +-
 .../gemfire/pdx/internal/PdxInputStream.java    |   4 +-
 .../cache/ChunkValueWrapperJUnitTest.java       |   4 +-
 .../cache/OldValueImporterTestBase.java         |   6 +-
 .../offheap/ChunkWithHeapFormJUnitTest.java     |   8 +-
 .../internal/offheap/FragmentJUnitTest.java     |   2 +-
 .../internal/offheap/FreeListManagerTest.java   | 152 ++--
 .../offheap/FreeListOffHeapRegionJUnitTest.java |   2 +-
 .../internal/offheap/GemFireChunkJUnitTest.java | 180 ++---
 .../offheap/GemFireChunkSliceJUnitTest.java     |  18 +-
 .../offheap/OffHeapHelperJUnitTest.java         |   4 +-
 .../internal/offheap/OffHeapRegionBase.java     |   8 +-
 .../OffHeapRegionEntryHelperJUnitTest.java      |  48 +-
 .../offheap/OffHeapValidationJUnitTest.java     |   4 +-
 .../OffHeapWriteObjectAsByteArrayJUnitTest.java |   4 +-
 .../OldFreeListOffHeapRegionJUnitTest.java      |   2 +-
 ...moryAllocatorFillPatternIntegrationTest.java |   8 +-
 ...mpleMemoryAllocatorFillPatternJUnitTest.java |  16 +-
 .../offheap/SimpleMemoryAllocatorJUnitTest.java |  10 +-
 .../offheap/SyncChunkStackJUnitTest.java        |  20 +-
 .../OffHeapByteBufferByteSourceJUnitTest.java   |   6 +-
 .../gemfire/pdx/OffHeapByteSourceJUnitTest.java |   6 +-
 50 files changed, 1227 insertions(+), 1227 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/cache/operations/internal/GetOperationContextImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/operations/internal/GetOperationContextImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/operations/internal/GetOperationContextImpl.java
index 46aace1..11d9248 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/operations/internal/GetOperationContextImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/operations/internal/GetOperationContextImpl.java
@@ -18,7 +18,7 @@ package com.gemstone.gemfire.cache.operations.internal;
 
 import com.gemstone.gemfire.SerializationException;
 import com.gemstone.gemfire.cache.operations.GetOperationContext;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.Releasable;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
@@ -70,7 +70,7 @@ public class GetOperationContextImpl extends GetOperationContext implements Rele
 
   private void checkForReleasedOffHeapValue(Object v) {
     // Note that we only care about Chunk (instead of all StoredObject) because it is the only one using a refcount
-    if (this.released && v instanceof GemFireChunk) {
+    if (this.released && v instanceof ObjectChunk) {
       throw new IllegalStateException("Attempt to access off-heap value after the OperationContext callback returned.");
     }
   }
@@ -116,7 +116,7 @@ public class GetOperationContextImpl extends GetOperationContext implements Rele
     // our value (since this context did not retain it)
     // but we do make sure that any future attempt to access
     // the off-heap value fails.
-    if (super.getValue() instanceof GemFireChunk) {
+    if (super.getValue() instanceof ObjectChunk) {
       this.released = true;
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
index fe99079..aab99cb 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
@@ -75,7 +75,7 @@ import com.gemstone.gemfire.internal.cache.RegionEntry;
 import com.gemstone.gemfire.internal.cache.persistence.query.CloseableIterator;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 import com.gemstone.gemfire.pdx.PdxInstance;
@@ -1477,9 +1477,9 @@ public abstract class AbstractIndex implements IndexProtocol
         valueInIndex = verifyAndGetPdxDomainObject(value);
       } else{
         @Released Object val = re.getValueInVM(context.getPartitionedRegion());
-        GemFireChunk valToFree = null;
-        if (val instanceof GemFireChunk) {
-          valToFree = (GemFireChunk)val;
+        ObjectChunk valToFree = null;
+        if (val instanceof ObjectChunk) {
+          valToFree = (ObjectChunk)val;
         }
         try {
         if (val instanceof CachedDeserializable) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/DummyQRegion.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/DummyQRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/DummyQRegion.java
index 6887e9c..bde948d 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/DummyQRegion.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/DummyQRegion.java
@@ -41,7 +41,7 @@ import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.RegionEntry;
 import com.gemstone.gemfire.internal.cache.RegionEntryContext;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
@@ -134,8 +134,8 @@ public class DummyQRegion extends QRegion {
     }
     valueInList.clear();
     Object val = this.entry.getValueOffHeapOrDiskWithoutFaultIn((LocalRegion) getRegion());
-    if (val instanceof GemFireChunk) {
-      @Retained @Released GemFireChunk ohval = (GemFireChunk) val;
+    if (val instanceof ObjectChunk) {
+      @Retained @Released ObjectChunk ohval = (ObjectChunk) val;
       try {
         // TODO OFFHEAP: val may be off-heap PdxInstance
         val = ohval.getDeserializedValue(getRegion(), this.entry);
@@ -155,8 +155,8 @@ public class DummyQRegion extends QRegion {
       valueInArray = new  Object[1];      
     }   
     Object val = this.entry.getValueOffHeapOrDiskWithoutFaultIn((LocalRegion) getRegion());
-    if (val instanceof GemFireChunk) {      
-      @Retained @Released GemFireChunk ohval = (GemFireChunk) val;
+    if (val instanceof ObjectChunk) {      
+      @Retained @Released ObjectChunk ohval = (ObjectChunk) val;
       try {
         // TODO OFFHEAP: val may be off-heap PdxInstance
         val = ohval.getDeserializedValue(getRegion(), this.entry);
@@ -178,8 +178,8 @@ public class DummyQRegion extends QRegion {
     }
     values.clear();
     Object val = this.entry.getValueOffHeapOrDiskWithoutFaultIn((LocalRegion) getRegion());
-    if (val instanceof GemFireChunk) {
-      @Retained @Released GemFireChunk ohval = (GemFireChunk) val;
+    if (val instanceof ObjectChunk) {
+      @Retained @Released ObjectChunk ohval = (ObjectChunk) val;
       try {
         // TODO OFFHEAP: val may be off-heap PdxInstance
         val = ohval.getDeserializedValue(getRegion(), this.entry);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/HashIndex.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/HashIndex.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/HashIndex.java
index 1e0e8c4..a30a264 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/HashIndex.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/HashIndex.java
@@ -79,7 +79,7 @@ import com.gemstone.gemfire.internal.cache.Token;
 import com.gemstone.gemfire.internal.cache.persistence.query.CloseableIterator;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 import com.gemstone.gemfire.pdx.internal.PdxString;
@@ -876,8 +876,8 @@ public class HashIndex extends AbstractIndex {
     if (this.indexOnValues) {
       Object o = entry.getValueOffHeapOrDiskWithoutFaultIn((LocalRegion) getRegion());
       try {
-        if (o instanceof GemFireChunk) {
-          GemFireChunk ohval = (GemFireChunk) o;
+        if (o instanceof ObjectChunk) {
+          ObjectChunk ohval = (ObjectChunk) o;
           try {
             o = ohval.getDeserializedForReading();
           } finally {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
index 1e65e2f..8910df3 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
@@ -61,9 +61,9 @@ import com.gemstone.gemfire.internal.lang.StringUtils;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.ChunkWithHeapForm;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.MemoryAllocator;
 import com.gemstone.gemfire.internal.offheap.OffHeapCachedDeserializable;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
@@ -1311,9 +1311,9 @@ public abstract class AbstractRegionEntry implements RegionEntry,
           }
           return prepareValueForCache(r, heapValue, event, isEntryUpdate);
         }
-        if (val instanceof GemFireChunk) {
+        if (val instanceof ObjectChunk) {
           // if the reused guy has a refcount then need to inc it
-          if (!((GemFireChunk)val).retain()) {
+          if (!((ObjectChunk)val).retain()) {
             throw new IllegalStateException("Could not use an off heap value because it was freed");
           }
         }
@@ -1348,8 +1348,8 @@ public abstract class AbstractRegionEntry implements RegionEntry,
         MemoryAllocator ma = SimpleMemoryAllocatorImpl.getAllocator(); // fix for bug 47875
         val = ma.allocateAndInitialize(compressedData, isSerialized, isCompressed); // TODO:KIRK:48068 race happens right after this line
         ReferenceCountHelper.setReferenceCountOwner(null);
-        if (val instanceof GemFireChunk) {
-          val = new com.gemstone.gemfire.internal.offheap.ChunkWithHeapForm((GemFireChunk)val, data);
+        if (val instanceof ObjectChunk) {
+          val = new com.gemstone.gemfire.internal.offheap.ChunkWithHeapForm((ObjectChunk)val, data);
         }
 //        if (val instanceof Chunk && r instanceof LocalRegion) {
 //          Chunk c = (Chunk) val;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
index bbd340e..699de2f 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
@@ -75,7 +75,7 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.OffHeapRegionEntryHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
@@ -955,7 +955,7 @@ public abstract class AbstractRegionMap implements RegionMap {
                   ((ListOfDeltas)oldValue).apply(event);
                   Object preparedNewValue =oldRe.prepareValueForCache(owner,
                       event.getNewValueAsOffHeapDeserializedOrRaw(), true);
-                  if(preparedNewValue instanceof GemFireChunk) {
+                  if(preparedNewValue instanceof ObjectChunk) {
                     event.setNewValue(preparedNewValue);
                   }
                   oldRe.setValue(owner, preparedNewValue, event);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BytesAndBitsForCompactor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BytesAndBitsForCompactor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BytesAndBitsForCompactor.java
index ef93240..cc358f5 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BytesAndBitsForCompactor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BytesAndBitsForCompactor.java
@@ -16,7 +16,7 @@
  */
 package com.gemstone.gemfire.internal.cache;
 
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 
 /**
@@ -36,7 +36,7 @@ public class BytesAndBitsForCompactor {
    * The dataChunk field is unretained so it can only be used while the RegionEntry is still synced.
    * When done with the dataChunk, null it out if you want to reuse the byte[] later.
    */
-  private @Unretained GemFireChunk dataChunk;
+  private @Unretained ObjectChunk dataChunk;
   private  byte[] data;
   private  byte userBits=0;
   // length of the data present in the byte array 
@@ -56,7 +56,7 @@ public class BytesAndBitsForCompactor {
   }
 
   
-  public final GemFireChunk getDataChunk() {
+  public final ObjectChunk getDataChunk() {
     return this.dataChunk;
   }
   public final byte[] getBytes() {
@@ -87,7 +87,7 @@ public class BytesAndBitsForCompactor {
     this.validLength = validLength;    
     this.isReusable = isReusable;
   }
-  public void setChunkData(GemFireChunk c, byte userBits) {
+  public void setChunkData(ObjectChunk c, byte userBits) {
     this.dataChunk = c;
     this.userBits = userBits;
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java
index 68ff77c..327279b 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java
@@ -40,7 +40,7 @@ import com.gemstone.gemfire.internal.cache.versions.VersionStamp;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
 import com.gemstone.gemfire.internal.offheap.Releasable;
@@ -208,8 +208,8 @@ public interface DiskEntry extends RegionEntry {
     static Object getValueOnDiskOrBuffer(DiskEntry entry, DiskRegion dr, RegionEntryContext context) {
       @Released Object v = getOffHeapValueOnDiskOrBuffer(entry, dr, context);
       if (v instanceof CachedDeserializable) {
-        if (v instanceof GemFireChunk) {
-          @Released GemFireChunk ohv = (GemFireChunk) v;
+        if (v instanceof ObjectChunk) {
+          @Released ObjectChunk ohv = (ObjectChunk) v;
           try {
             v = ohv.getDeserializedValue(null, null);
             if (v == ohv) {
@@ -688,8 +688,8 @@ public interface DiskEntry extends RegionEntry {
      * Note that this class is only used with uncompressed chunks.
      */
     public static class ChunkValueWrapper implements ValueWrapper {
-      private final @Unretained GemFireChunk chunk;
-      public ChunkValueWrapper(GemFireChunk c) {
+      private final @Unretained ObjectChunk chunk;
+      public ChunkValueWrapper(ObjectChunk c) {
         assert !c.isCompressed();
         this.chunk = c;
       }
@@ -722,7 +722,7 @@ public interface DiskEntry extends RegionEntry {
             return;
           }
         }
-        final long bbAddress = GemFireChunk.getDirectByteBufferAddress(bb);
+        final long bbAddress = ObjectChunk.getDirectByteBufferAddress(bb);
         if (bbAddress != 0L) {
           int bytesRemaining = maxOffset;
           int availableSpace = bb.remaining();
@@ -782,8 +782,8 @@ public interface DiskEntry extends RegionEntry {
         byte[] bytes;
         if (value instanceof CachedDeserializable) {
           CachedDeserializable proxy = (CachedDeserializable)value;
-          if (proxy instanceof GemFireChunk) {
-            return new ChunkValueWrapper((GemFireChunk) proxy);
+          if (proxy instanceof ObjectChunk) {
+            return new ChunkValueWrapper((ObjectChunk) proxy);
           }
           if (proxy instanceof StoredObject) {
             StoredObject ohproxy = (StoredObject) proxy;
@@ -833,8 +833,8 @@ public interface DiskEntry extends RegionEntry {
           // We don't do this for the delta case because getRawNewValue returns delta
           // and we want to write the entire new value to disk.
           rawValue = event.getRawNewValue();
-          if (rawValue instanceof GemFireChunk) {
-            return new ChunkValueWrapper((GemFireChunk) rawValue);
+          if (rawValue instanceof ObjectChunk) {
+            return new ChunkValueWrapper((ObjectChunk) rawValue);
           }
         }
         if (event.getCachedSerializedNewValue() != null) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
index d63dd90..0d20511 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java
@@ -121,7 +121,7 @@ import com.gemstone.gemfire.internal.cache.wan.parallel.ConcurrentParallelGatewa
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
@@ -2541,8 +2541,8 @@ public class DistributedRegion extends LocalRegion implements
     }
     //For SQLFire , we need to increment the use count so that returned
     //object has use count 2
-    if( incrementUseCountForSqlf && result instanceof GemFireChunk) {
-      ((GemFireChunk)result).retain();
+    if( incrementUseCountForSqlf && result instanceof ObjectChunk) {
+      ((ObjectChunk)result).retain();
     }
     return result;
     } finally {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
index 8198349..c8c05cf 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java
@@ -73,7 +73,7 @@ import com.gemstone.gemfire.internal.lang.StringUtils;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.OffHeapRegionEntryHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
@@ -930,9 +930,9 @@ public class EntryEventImpl
     if (this.offHeapOk) {
       OffHeapHelper.releaseAndTrackOwner(this.newValue, this);
     }
-    if (v instanceof GemFireChunk) {
+    if (v instanceof ObjectChunk) {
       ReferenceCountHelper.setReferenceCountOwner(this);
-      if (!((GemFireChunk) v).retain()) {
+      if (!((ObjectChunk) v).retain()) {
         ReferenceCountHelper.setReferenceCountOwner(null);
         this.newValue = null;
         return;
@@ -946,13 +946,13 @@ public class EntryEventImpl
    * Returns true if this event has a reference to an off-heap new or old value.
    */
   public boolean hasOffHeapValue() {
-    return (this.newValue instanceof GemFireChunk) || (this.oldValue instanceof GemFireChunk);
+    return (this.newValue instanceof ObjectChunk) || (this.oldValue instanceof ObjectChunk);
   }
   
   @Unretained
   protected final Object basicGetNewValue() {
     Object result = this.newValue;
-    if (!this.offHeapOk && result instanceof GemFireChunk) {
+    if (!this.offHeapOk && result instanceof ObjectChunk) {
       //this.region.getCache().getLogger().info("DEBUG new value already freed " + System.identityHashCode(result));
       throw new IllegalStateException("Attempt to access off heap value after the EntryEvent was released.");
     }
@@ -992,7 +992,7 @@ public class EntryEventImpl
     @Released final Object curOldValue = this.oldValue;
     if (v == curOldValue) return;
     if (this.offHeapOk) {
-      if (curOldValue instanceof GemFireChunk) {
+      if (curOldValue instanceof ObjectChunk) {
         if (ReferenceCountHelper.trackReferenceCounts()) {
           OffHeapHelper.releaseAndTrackOwner(curOldValue, new OldValueOwner());
         } else {
@@ -1008,17 +1008,17 @@ public class EntryEventImpl
   private void retainAndSetOldValue(@Retained(ENTRY_EVENT_OLD_VALUE) Object v) {
     if (v == this.oldValue) return;
     
-    if (v instanceof GemFireChunk) {
+    if (v instanceof ObjectChunk) {
       if (ReferenceCountHelper.trackReferenceCounts()) {
         ReferenceCountHelper.setReferenceCountOwner(new OldValueOwner());
-        boolean couldNotRetain = (!((GemFireChunk) v).retain());
+        boolean couldNotRetain = (!((ObjectChunk) v).retain());
         ReferenceCountHelper.setReferenceCountOwner(null);
         if (couldNotRetain) {
           this.oldValue = null;
           return;
         }
       } else {
-        if (!((GemFireChunk) v).retain()) {
+        if (!((ObjectChunk) v).retain()) {
           this.oldValue = null;
           return;
         }
@@ -1031,7 +1031,7 @@ public class EntryEventImpl
   private Object basicGetOldValue() {
     @Unretained(ENTRY_EVENT_OLD_VALUE)
     Object result = this.oldValue;
-    if (!this.offHeapOk && result instanceof GemFireChunk) {
+    if (!this.offHeapOk && result instanceof ObjectChunk) {
       //this.region.getCache().getLogger().info("DEBUG old value already freed " + System.identityHashCode(result));
       throw new IllegalStateException("Attempt to access off heap value after the EntryEvent was released.");
     }
@@ -1360,7 +1360,7 @@ public class EntryEventImpl
       @Unretained(ENTRY_EVENT_NEW_VALUE)
       final StoredObject so = (StoredObject) nv;
       final boolean isSerialized = so.isSerialized();
-      if (nv instanceof GemFireChunk) {
+      if (nv instanceof ObjectChunk) {
         if (importer.isUnretainedNewReferenceOk()) {
           importer.importNewObject(nv, isSerialized);
         } else {
@@ -1447,7 +1447,7 @@ public class EntryEventImpl
     if (ov instanceof StoredObject) {
       final StoredObject so = (StoredObject) ov;
       final boolean isSerialized = so.isSerialized();
-      if (ov instanceof GemFireChunk) {
+      if (ov instanceof ObjectChunk) {
         if (importer.isUnretainedOldReferenceOk()) {
           importer.importOldObject(ov, isSerialized);
         } else {
@@ -1869,8 +1869,8 @@ public class EntryEventImpl
     Object preparedV = reentry.prepareValueForCache(this.region, v, this, this.hasDelta());
     if (preparedV != v) {
       v = preparedV;
-      if (v instanceof GemFireChunk) {
-        if (!((GemFireChunk) v).isCompressed()) { // fix bug 52109
+      if (v instanceof ObjectChunk) {
+        if (!((ObjectChunk) v).isCompressed()) { // fix bug 52109
           // If we put it off heap and it is not compressed then remember that value.
           // Otherwise we want to remember the decompressed value in the event.
           basicSetNewValue(v);
@@ -1931,8 +1931,8 @@ public class EntryEventImpl
       success = true;
     }
     } finally {
-      if (!success && reentry instanceof OffHeapRegionEntry && v instanceof GemFireChunk) {
-        OffHeapRegionEntryHelper.releaseEntry((OffHeapRegionEntry)reentry, (GemFireChunk)v);
+      if (!success && reentry instanceof OffHeapRegionEntry && v instanceof ObjectChunk) {
+        OffHeapRegionEntryHelper.releaseEntry((OffHeapRegionEntry)reentry, (ObjectChunk)v);
       }      
     }
     if (logger.isTraceEnabled()) {
@@ -2232,7 +2232,7 @@ public class EntryEventImpl
    * If a PdxInstance is returned then it will have an unretained reference
    * to Chunk's off-heap address.
    */
-  public static @Unretained Object deserializeChunk(GemFireChunk bytes) {
+  public static @Unretained Object deserializeChunk(ObjectChunk bytes) {
     if (bytes == null)
       return null;
     try {
@@ -2874,7 +2874,7 @@ public class EntryEventImpl
     private final byte[] serializedValue;
     
     SerializedCacheValueImpl(EntryEventImpl event, Region r, RegionEntry re, @Unretained CachedDeserializable cd, byte[] serializedBytes) {
-      if (cd instanceof GemFireChunk) {
+      if (cd instanceof ObjectChunk) {
         this.event = event;
       } else {
         this.event = null;
@@ -3053,14 +3053,14 @@ public class EntryEventImpl
     Object nv = basicGetNewValue();
     this.offHeapOk = false;
     
-    if (ov instanceof GemFireChunk) {
+    if (ov instanceof ObjectChunk) {
       //this.region.getCache().getLogger().info("DEBUG freeing ref to old value on " + System.identityHashCode(ov));
       if (ReferenceCountHelper.trackReferenceCounts()) {
         ReferenceCountHelper.setReferenceCountOwner(new OldValueOwner());
-        ((GemFireChunk) ov).release();
+        ((ObjectChunk) ov).release();
         ReferenceCountHelper.setReferenceCountOwner(null);
       } else {
-        ((GemFireChunk) ov).release();
+        ((ObjectChunk) ov).release();
       }
     }
     OffHeapHelper.releaseAndTrackOwner(nv, this);
@@ -3071,7 +3071,7 @@ public class EntryEventImpl
    * Once this is called on an event it does not need to have release called.
    */
   public void disallowOffHeapValues() {
-    if (this.newValue instanceof GemFireChunk || this.oldValue instanceof GemFireChunk) {
+    if (this.newValue instanceof ObjectChunk || this.oldValue instanceof ObjectChunk) {
       throw new IllegalStateException("This event does not support off-heap values");
     }
     this.offHeapOk = false;
@@ -3085,7 +3085,7 @@ public class EntryEventImpl
   @Released({ENTRY_EVENT_NEW_VALUE, ENTRY_EVENT_OLD_VALUE})
   public void copyOffHeapToHeap() {
     Object ov = basicGetOldValue();
-    if (ov instanceof GemFireChunk) {
+    if (ov instanceof ObjectChunk) {
       if (ReferenceCountHelper.trackReferenceCounts()) {
         ReferenceCountHelper.setReferenceCountOwner(new OldValueOwner());
         this.oldValue = OffHeapHelper.copyAndReleaseIfNeeded(ov);
@@ -3095,19 +3095,19 @@ public class EntryEventImpl
       }
     }
     Object nv = basicGetNewValue();
-    if (nv instanceof GemFireChunk) {
+    if (nv instanceof ObjectChunk) {
       ReferenceCountHelper.setReferenceCountOwner(this);
       this.newValue = OffHeapHelper.copyAndReleaseIfNeeded(nv);
       ReferenceCountHelper.setReferenceCountOwner(null);
     }
-    if (this.newValue instanceof GemFireChunk || this.oldValue instanceof GemFireChunk) {
+    if (this.newValue instanceof ObjectChunk || this.oldValue instanceof ObjectChunk) {
       throw new IllegalStateException("event's old/new value still off-heap after calling copyOffHeapToHeap");
     }
     this.offHeapOk = false;
   }
 
   public boolean isOldValueOffHeap() {
-    return this.oldValue instanceof GemFireChunk;
+    return this.oldValue instanceof ObjectChunk;
   }
   public final boolean isFetchFromHDFS() {
     return fetchFromHDFS;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
index b367072..b6d8c49 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
@@ -203,7 +203,7 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
@@ -1587,8 +1587,8 @@ public class LocalRegion extends AbstractRegion
           }
           //For sqlf since the deserialized value is nothing but chunk
           // before returning the found value increase its use count
-          if(GemFireCacheImpl.sqlfSystem() && result instanceof GemFireChunk) {
-            if(!((GemFireChunk)result).retain()) {
+          if(GemFireCacheImpl.sqlfSystem() && result instanceof ObjectChunk) {
+            if(!((ObjectChunk)result).retain()) {
               return null;
             }
           }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
index 1218f20..541c453 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
@@ -252,7 +252,7 @@ import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.LoggingThreadGroup;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.internal.sequencelog.RegionLogger;
 import com.gemstone.gemfire.internal.util.TransformUtils;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Part.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Part.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Part.java
index c401f3d..4968610 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Part.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/Part.java
@@ -18,7 +18,7 @@ package com.gemstone.gemfire.internal.cache.tier.sockets;
 
 import com.gemstone.gemfire.internal.*;
 import com.gemstone.gemfire.internal.cache.CachedDeserializable;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.DataAsAddress;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.offheap.UnsafeMemoryChunk;
@@ -136,7 +136,7 @@ public class Part {
     if (so instanceof DataAsAddress) {
       this.part = ((DataAsAddress)so).getRawBytes();
     } else {
-      this.part = (GemFireChunk)so;
+      this.part = (ObjectChunk)so;
     }
   }
   public byte getTypeCode() {
@@ -151,8 +151,8 @@ public class Part {
       return 0;
     } else if (this.part instanceof byte[]) {
       return ((byte[])this.part).length;
-    } else if (this.part instanceof GemFireChunk) {
-      return ((GemFireChunk) this.part).getValueSizeInBytes();
+    } else if (this.part instanceof ObjectChunk) {
+      return ((ObjectChunk) this.part).getValueSizeInBytes();
     } else {
       return ((HeapDataOutputStream)this.part).size();
     }
@@ -294,8 +294,8 @@ public class Part {
       if (this.part instanceof byte[]) {
         byte[] bytes = (byte[])this.part;
         out.write(bytes, 0, bytes.length);
-      } else if (this.part instanceof GemFireChunk) {
-        GemFireChunk c = (GemFireChunk) this.part;
+      } else if (this.part instanceof ObjectChunk) {
+        ObjectChunk c = (ObjectChunk) this.part;
         ByteBuffer cbb = c.createDirectByteBuffer();
         if (cbb != null) {
           HeapDataOutputStream.writeByteBufferToStream(out,  buf, cbb);
@@ -327,8 +327,8 @@ public class Part {
     if (getLength() > 0) {
       if (this.part instanceof byte[]) {
         buf.put((byte[])this.part);
-      } else if (this.part instanceof GemFireChunk) {
-        GemFireChunk c = (GemFireChunk) this.part;
+      } else if (this.part instanceof ObjectChunk) {
+        ObjectChunk c = (ObjectChunk) this.part;
         ByteBuffer bb = c.createDirectByteBuffer();
         if (bb != null) {
           buf.put(bb);
@@ -377,10 +377,10 @@ public class Part {
           }
           buf.clear();
         }
-      } else if (this.part instanceof GemFireChunk) {
+      } else if (this.part instanceof ObjectChunk) {
         // instead of copying the Chunk to buf try to create a direct ByteBuffer and
         // just write it directly to the socket channel.
-        GemFireChunk c = (GemFireChunk) this.part;
+        ObjectChunk c = (ObjectChunk) this.part;
         ByteBuffer bb = c.createDirectByteBuffer();
         if (bb != null) {
           while (bb.remaining() > 0) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
index cff3a6e..1ec6b51 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
@@ -50,7 +50,7 @@ import com.gemstone.gemfire.internal.cache.WrappedCallbackArgument;
 import com.gemstone.gemfire.internal.cache.lru.Sizeable;
 import com.gemstone.gemfire.internal.cache.tier.sockets.CacheServerHelper;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.internal.offheap.GemFireChunk;
+import com.gemstone.gemfire.internal.offheap.ObjectChunk;
 import com.gemstone.gemfire.internal.offheap.ChunkWithHeapForm;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
@@ -549,11 +549,11 @@ public class GatewaySenderEventImpl implements
     Object result = this.value;
     if (result == null) {
       result = this.valueObj;
-      if (result instanceof GemFireChunk) {
+      if (result instanceof ObjectChunk) {
         if (this.valueObjReleased) {
           result = null;
         } else {
-          GemFireChunk ohref = (GemFireChunk) result;
+          ObjectChunk ohref = (ObjectChunk) result;
           if (!ohref.retain()) {
             result = null;
           } else if (this.valueObjReleased) {
@@ -1260,7 +1260,7 @@ public class GatewaySenderEventImpl implements
           return this;
         }
       }
-      if (v instanceof GemFireChunk) {
+      if (v instanceof ObjectChunk) {
         try {
           return makeCopy();
         } catch (IllegalStateException ex) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapForm.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapForm.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapForm.java
index d889610..1b2734f 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapForm.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkWithHeapForm.java
@@ -21,10 +21,10 @@ package com.gemstone.gemfire.internal.offheap;
  * This allows the operation to access the serialized heap form instead of copying
  * it from offheap. See bug 48135.
  */
-public class ChunkWithHeapForm extends GemFireChunk {
+public class ChunkWithHeapForm extends ObjectChunk {
   private final byte[] heapForm;
   
-  public ChunkWithHeapForm(GemFireChunk chunk, byte[] heapForm) {
+  public ChunkWithHeapForm(ObjectChunk chunk, byte[] heapForm) {
     super(chunk);
     this.heapForm = heapForm;
   }
@@ -34,7 +34,7 @@ public class ChunkWithHeapForm extends GemFireChunk {
     return this.heapForm;
   }
   
-  public GemFireChunk getChunkWithoutHeapForm() {
-    return new GemFireChunk(this);
+  public ObjectChunk getChunkWithoutHeapForm() {
+    return new ObjectChunk(this);
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
index 186a4e4..d337cfc 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
@@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
  *
  */
 public class Fragment implements MemoryBlock {
-  private static final byte FILL_BYTE = GemFireChunk.FILL_BYTE;
+  private static final byte FILL_BYTE = ObjectChunk.FILL_BYTE;
   private final long baseAddr;
   private final int size;
   @SuppressWarnings("unused")

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1a82c80c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
index 3fbf526..a716f14 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
@@ -45,30 +45,30 @@ public class FreeListManager {
   
   final private AtomicReferenceArray<SyncChunkStack> tinyFreeLists = new AtomicReferenceArray<SyncChunkStack>(TINY_FREE_LIST_COUNT);
   // hugeChunkSet is sorted by chunk size in ascending order. It will only contain chunks larger than MAX_TINY.
-  private final ConcurrentSkipListSet<GemFireChunk> hugeChunkSet = new ConcurrentSkipListSet<GemFireChunk>();
+  private final ConcurrentSkipListSet<ObjectChunk> hugeChunkSet = new ConcurrentSkipListSet<ObjectChunk>();
   private final AtomicLong allocatedSize = new AtomicLong(0L);
 
   private int getNearestTinyMultiple(int size) {
     return (size-1)/TINY_MULTIPLE;
   }
-  List<GemFireChunk> getLiveChunks() {
-    ArrayList<GemFireChunk> result = new ArrayList<GemFireChunk>();
+  List<ObjectChunk> getLiveChunks() {
+    ArrayList<ObjectChunk> result = new ArrayList<ObjectChunk>();
     for (int i=0; i < slabs.length; i++) {
       getLiveChunks(slabs[i], result);
     }
     return result;
   }
-  private void getLiveChunks(AddressableMemoryChunk slab, List<GemFireChunk> result) {
+  private void getLiveChunks(AddressableMemoryChunk slab, List<ObjectChunk> result) {
     long addr = slab.getMemoryAddress();
-    while (addr <= (slab.getMemoryAddress() + slab.getSize() - GemFireChunk.MIN_CHUNK_SIZE)) {
+    while (addr <= (slab.getMemoryAddress() + slab.getSize() - ObjectChunk.MIN_CHUNK_SIZE)) {
       Fragment f = isAddrInFragmentFreeSpace(addr);
       if (f != null) {
         addr = f.getMemoryAddress() + f.getSize();
       } else {
-        int curChunkSize = GemFireChunk.getSize(addr);
-        int refCount = GemFireChunk.getRefCount(addr);
+        int curChunkSize = ObjectChunk.getSize(addr);
+        int refCount = ObjectChunk.getRefCount(addr);
         if (refCount > 0) {
-          result.add(new GemFireChunk(addr));
+          result.add(new ObjectChunk(addr));
         }
         addr += curChunkSize;
       }
@@ -95,7 +95,7 @@ public class FreeListManager {
     long result = 0;
     for (Fragment f: this.fragmentList) {
       int freeSpace = f.freeSpace();
-      if (freeSpace >= GemFireChunk.MIN_CHUNK_SIZE) {
+      if (freeSpace >= ObjectChunk.MIN_CHUNK_SIZE) {
         result += freeSpace;
       }
     }
@@ -113,7 +113,7 @@ public class FreeListManager {
   }
   long getFreeHugeMemory() {
     long hugeFree = 0;
-    for (GemFireChunk c: this.hugeChunkSet) {
+    for (ObjectChunk c: this.hugeChunkSet) {
       hugeFree += c.getSize();
     }
     return hugeFree;
@@ -178,10 +178,10 @@ public class FreeListManager {
    * @throws IllegalStateException if a chunk can not be allocated.
    */
   @SuppressWarnings("synthetic-access")
-  public GemFireChunk allocate(int size) {
+  public ObjectChunk allocate(int size) {
     assert size > 0;
     
-    GemFireChunk result = basicAllocate(size, true);
+    ObjectChunk result = basicAllocate(size, true);
 
     result.setDataSize(size);
     this.allocatedSize.addAndGet(result.getSize());
@@ -190,13 +190,13 @@ public class FreeListManager {
     return result;
   }
 
-  private GemFireChunk basicAllocate(int size, boolean useSlabs) {
+  private ObjectChunk basicAllocate(int size, boolean useSlabs) {
     if (useSlabs) {
       // Every object stored off heap has a header so we need
       // to adjust the size so that the header gets allocated.
       // If useSlabs is false then the incoming size has already
       // been adjusted.
-      size += GemFireChunk.OFF_HEAP_HEADER_SIZE;
+      size += ObjectChunk.OFF_HEAP_HEADER_SIZE;
     }
     if (size <= MAX_TINY) {
       return allocateTiny(size, useSlabs);
@@ -205,17 +205,17 @@ public class FreeListManager {
     }
   }
 
-  private GemFireChunk allocateFromFragments(int chunkSize) {
+  private ObjectChunk allocateFromFragments(int chunkSize) {
     do {
       final int lastAllocationId = this.lastFragmentAllocation.get();
       for (int i=lastAllocationId; i < this.fragmentList.size(); i++) {
-        GemFireChunk result = allocateFromFragment(i, chunkSize);
+        ObjectChunk result = allocateFromFragment(i, chunkSize);
         if (result != null) {
           return result;
         }
       }
       for (int i=0; i < lastAllocationId; i++) {
-        GemFireChunk result = allocateFromFragment(i, chunkSize);
+        ObjectChunk result = allocateFromFragment(i, chunkSize);
         if (result != null) {
           return result;
         }
@@ -247,7 +247,7 @@ public class FreeListManager {
   }
 
   private void logHugeState(LogWriter lw) {
-    for (GemFireChunk c: this.hugeChunkSet) {
+    for (ObjectChunk c: this.hugeChunkSet) {
       lw.info("Free huge of size " + c.getSize());
     }
   }
@@ -345,10 +345,10 @@ public class FreeListManager {
               } else {
                 // see if we can conflate into sorted[idx]
                 long lowAddr = sorted[idx-1];
-                int lowSize = GemFireChunk.getSize(lowAddr);
+                int lowSize = ObjectChunk.getSize(lowAddr);
                 if (lowAddr + lowSize == addr) {
                   // append the addr chunk to lowAddr
-                  GemFireChunk.setSize(lowAddr, lowSize + GemFireChunk.getSize(addr));
+                  ObjectChunk.setSize(lowAddr, lowSize + ObjectChunk.getSize(addr));
                 } else {
                   if (sortedSize >= sorted.length) {
                     long[] newSorted = new long[sorted.length+SORT_ARRAY_BLOCK_SIZE];
@@ -360,11 +360,11 @@ public class FreeListManager {
                 }
               }
             } else {
-              int addrSize = GemFireChunk.getSize(addr);
+              int addrSize = ObjectChunk.getSize(addr);
               long highAddr = sorted[idx];
               if (addr + addrSize == highAddr) {
                 // append highAddr chunk to addr
-                GemFireChunk.setSize(addr, addrSize + GemFireChunk.getSize(highAddr));
+                ObjectChunk.setSize(addr, addrSize + ObjectChunk.getSize(highAddr));
                 sorted[idx] = addr;
               } else {
                 boolean insert = idx==0;
@@ -374,10 +374,10 @@ public class FreeListManager {
                   //                    long[] tmp = Arrays.copyOf(sorted, sortedSize);
                   //                    throw new IllegalStateException("addr was zero at idx=" + (idx-1) + " sorted="+ Arrays.toString(tmp));
                   //                  }
-                  int lowSize = GemFireChunk.getSize(lowAddr);
+                  int lowSize = ObjectChunk.getSize(lowAddr);
                   if (lowAddr + lowSize == addr) {
                     // append the addr chunk to lowAddr
-                    GemFireChunk.setSize(lowAddr, lowSize + addrSize);
+                    ObjectChunk.setSize(lowAddr, lowSize + addrSize);
                   } else {
                     insert = true;
                   }
@@ -403,10 +403,10 @@ public class FreeListManager {
         for (int i=sortedSize-1; i > 0; i--) {
           long addr = sorted[i];
           long lowAddr = sorted[i-1];
-          int lowSize = GemFireChunk.getSize(lowAddr);
+          int lowSize = ObjectChunk.getSize(lowAddr);
           if (lowAddr + lowSize == addr) {
             // append addr chunk to lowAddr
-            GemFireChunk.setSize(lowAddr, lowSize + GemFireChunk.getSize(addr));
+            ObjectChunk.setSize(lowAddr, lowSize + ObjectChunk.getSize(addr));
             sorted[i] = 0L;
           }
         }
@@ -415,7 +415,7 @@ public class FreeListManager {
         for (int i=sortedSize-1; i >= 0; i--) {
           long addr = sorted[i];
           if (addr == 0L) continue;
-          int addrSize = GemFireChunk.getSize(addr);
+          int addrSize = ObjectChunk.getSize(addr);
           Fragment f = createFragment(addr, addrSize);
           if (addrSize >= chunkSize) {
             result = true;
@@ -508,8 +508,8 @@ public class FreeListManager {
       do {
         offset = f.getFreeIndex();
         diff = f.getSize() - offset;
-      } while (diff >= GemFireChunk.MIN_CHUNK_SIZE && !f.allocate(offset, offset+diff));
-      if (diff < GemFireChunk.MIN_CHUNK_SIZE) {
+      } while (diff >= ObjectChunk.MIN_CHUNK_SIZE && !f.allocate(offset, offset+diff));
+      if (diff < ObjectChunk.MIN_CHUNK_SIZE) {
         // If diff > 0 then that memory will be lost during compaction.
         // This should never happen since we keep the sizes rounded
         // based on MIN_CHUNK_SIZE.
@@ -518,7 +518,7 @@ public class FreeListManager {
         continue;
       }
       long chunkAddr = f.getMemoryAddress()+offset;
-      GemFireChunk.setSize(chunkAddr, diff);
+      ObjectChunk.setSize(chunkAddr, diff);
       result.offer(chunkAddr);
     }
     // All the fragments have been turned in to chunks so now clear them
@@ -540,7 +540,7 @@ public class FreeListManager {
     }
   }
   private void collectFreeHugeChunks(List<SyncChunkStack> l) {
-    GemFireChunk c = this.hugeChunkSet.pollFirst();
+    ObjectChunk c = this.hugeChunkSet.pollFirst();
     SyncChunkStack result = null;
     while (c != null) {
       if (result == null) {
@@ -552,7 +552,7 @@ public class FreeListManager {
     }
   }
 
-  GemFireChunk allocateFromFragment(final int fragIdx, final int chunkSize) {
+  ObjectChunk allocateFromFragment(final int fragIdx, final int chunkSize) {
     if (fragIdx >= this.fragmentList.size()) return null;
     final Fragment fragment;
     try {
@@ -571,7 +571,7 @@ public class FreeListManager {
         // this fragment has room
         int newOffset = oldOffset + chunkSize;
         int extraSize = fragmentSize - newOffset;
-        if (extraSize < GemFireChunk.MIN_CHUNK_SIZE) {
+        if (extraSize < ObjectChunk.MIN_CHUNK_SIZE) {
           // include these last few bytes of the fragment in the allocation.
           // If we don't then they will be lost forever.
           // The extraSize bytes only apply to the first chunk we allocate (not the batch ones).
@@ -582,11 +582,11 @@ public class FreeListManager {
         if (fragment.allocate(oldOffset, newOffset)) {
           // We did the allocate!
           this.lastFragmentAllocation.set(fragIdx);
-          GemFireChunk result = new GemFireChunk(fragment.getMemoryAddress()+oldOffset, chunkSize+extraSize);
+          ObjectChunk result = new ObjectChunk(fragment.getMemoryAddress()+oldOffset, chunkSize+extraSize);
           checkDataIntegrity(result);
           return result;
         } else {
-          GemFireChunk result = basicAllocate(chunkSize, false);
+          ObjectChunk result = basicAllocate(chunkSize, false);
           if (result != null) {
             return result;
           }
@@ -600,15 +600,15 @@ public class FreeListManager {
   private int round(int multiple, int value) {
     return (int) ((((long)value + (multiple-1)) / multiple) * multiple);
   }
-  private GemFireChunk allocateTiny(int size, boolean useFragments) {
+  private ObjectChunk allocateTiny(int size, boolean useFragments) {
     return basicAllocate(getNearestTinyMultiple(size), TINY_MULTIPLE, 0, this.tinyFreeLists, useFragments);
   }
-  private GemFireChunk basicAllocate(int idx, int multiple, int offset, AtomicReferenceArray<SyncChunkStack> freeLists, boolean useFragments) {
+  private ObjectChunk basicAllocate(int idx, int multiple, int offset, AtomicReferenceArray<SyncChunkStack> freeLists, boolean useFragments) {
     SyncChunkStack clq = freeLists.get(idx);
     if (clq != null) {
       long memAddr = clq.poll();
       if (memAddr != 0) {
-        GemFireChunk result = new GemFireChunk(memAddr);
+        ObjectChunk result = new ObjectChunk(memAddr);
         checkDataIntegrity(result);
         result.readyForAllocation();
         return result;
@@ -620,13 +620,13 @@ public class FreeListManager {
       return null;
     }
   }
-  private GemFireChunk allocateHuge(int size, boolean useFragments) {
+  private ObjectChunk allocateHuge(int size, boolean useFragments) {
     // sizeHolder is a fake Chunk used to search our sorted hugeChunkSet.
-    GemFireChunk sizeHolder = new FakeChunk(size);
-    NavigableSet<GemFireChunk> ts = this.hugeChunkSet.tailSet(sizeHolder);
-    GemFireChunk result = ts.pollFirst();
+    ObjectChunk sizeHolder = new FakeChunk(size);
+    NavigableSet<ObjectChunk> ts = this.hugeChunkSet.tailSet(sizeHolder);
+    ObjectChunk result = ts.pollFirst();
     if (result != null) {
-      if (result.getSize() - (HUGE_MULTIPLE - GemFireChunk.OFF_HEAP_HEADER_SIZE) < size) {
+      if (result.getSize() - (HUGE_MULTIPLE - ObjectChunk.OFF_HEAP_HEADER_SIZE) < size) {
         // close enough to the requested size; just return it.
         checkDataIntegrity(result);
         result.readyForAllocation();
@@ -644,7 +644,7 @@ public class FreeListManager {
     }
   }
   
-  private void checkDataIntegrity(GemFireChunk data) {
+  private void checkDataIntegrity(ObjectChunk data) {
     if (this.validateMemoryWithFill) {
       data.validateFill();
     }
@@ -654,7 +654,7 @@ public class FreeListManager {
    * ConcurrentSkipListSet. This is not a real chunk
    * but only used for searching.
    */
-  private static class FakeChunk extends GemFireChunk {
+  private static class FakeChunk extends ObjectChunk {
     private final int size;
     public FakeChunk(int size) {
       super();
@@ -669,14 +669,14 @@ public class FreeListManager {
   @SuppressWarnings("synthetic-access")
   public void free(long addr) {
     if (this.validateMemoryWithFill) {
-      GemFireChunk.fill(addr);
+      ObjectChunk.fill(addr);
     }
     
     free(addr, true);
   }
 
   private void free(long addr, boolean updateStats) {
-    int cSize = GemFireChunk.getSize(addr);
+    int cSize = ObjectChunk.getSize(addr);
     if (updateStats) {
       OffHeapMemoryStats stats = this.ma.getStats();
       stats.incObjects(-1);
@@ -715,7 +715,7 @@ public class FreeListManager {
   }
   
   private void freeHuge(long addr, int cSize) {
-    this.hugeChunkSet.add(new GemFireChunk(addr)); // TODO make this a collection of longs
+    this.hugeChunkSet.add(new ObjectChunk(addr)); // TODO make this a collection of longs
   }
 
   List<MemoryBlock> getOrderedBlocks() {
@@ -739,8 +739,8 @@ public class FreeListManager {
     }
   }
   
-  private void addBlocksFromChunks(Collection<GemFireChunk> src, List<MemoryBlock> dest) {
-    for (GemFireChunk chunk : src) {
+  private void addBlocksFromChunks(Collection<ObjectChunk> src, List<MemoryBlock> dest) {
+    for (ObjectChunk chunk : src) {
       dest.add(new MemoryBlockNode(this.ma, chunk));
     }
   }
@@ -759,7 +759,7 @@ public class FreeListManager {
       long addr = this.tinyFreeLists.get(i).getTopAddress();
       while (addr != 0L) {
         value.add(new MemoryBlockNode(sma, new TinyMemoryBlock(addr, i)));
-        addr = GemFireChunk.getNext(addr);
+        addr = ObjectChunk.getNext(addr);
       }
     }
     return value;
@@ -800,7 +800,7 @@ public class FreeListManager {
 
     @Override
     public int getBlockSize() {
-      return GemFireChunk.getSize(address);
+      return ObjectChunk.getSize(address);
     }
 
     @Override


[02/16] incubator-geode git commit: GEODE-826 Added bigtop script in src/dist folder.

Posted by ds...@apache.org.
GEODE-826 Added bigtop script in src/dist folder.

Named that script to gradlew. tested on linux. Now gradle.properties
become part of src folder.


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

Branch: refs/heads/feature/GEODE-831
Commit: 2aca64e13b89880540c6199800ed708be291197a
Parents: 81417f9
Author: Hitesh Khamesra <hk...@pivotal.io>
Authored: Tue Feb 16 15:56:42 2016 -0800
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Wed Feb 17 14:57:18 2016 -0800

----------------------------------------------------------------------
 gemfire-assembly/build.gradle         |   1 -
 gemfire-assembly/src/src/dist/gradlew | 221 +++++++++++++++++++++++++++++
 2 files changed, 221 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2aca64e1/gemfire-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-assembly/build.gradle b/gemfire-assembly/build.gradle
index 72e97c5..96a03d4 100755
--- a/gemfire-assembly/build.gradle
+++ b/gemfire-assembly/build.gradle
@@ -225,7 +225,6 @@ distributions {
         exclude 'gradlew'
         exclude 'gradlew.bat'
         exclude 'gradle/wrapper/gradle-wrapper.jar'
-        exclude 'gradle/wrapper/gradle-wrapper.properties'
         exclude '.gradle'
         exclude '**/build/**'
         exclude '**/.project'

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2aca64e1/gemfire-assembly/src/src/dist/gradlew
----------------------------------------------------------------------
diff --git a/gemfire-assembly/src/src/dist/gradlew b/gemfire-assembly/src/src/dist/gradlew
new file mode 100755
index 0000000..de155c6
--- /dev/null
+++ b/gemfire-assembly/src/src/dist/gradlew
@@ -0,0 +1,221 @@
+#!/usr/bin/env bash
+
+# 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.
+
+##
+## Tries to recreate Gradle's gradlew command in pure bash.
+## This way you don't have to worry about binaries in your build.
+##
+## Depdencies
+## unzip
+##
+
+set -e
+set -o pipefail
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+    MAX_FD="maximum"
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+bin=`dirname "$0"`
+bin=`cd "$bin">/dev/null; pwd`
+
+if [ -e "$bin/gradle/wrapper/gradle-wrapper.properties" ]; then
+  . "$bin/gradle/wrapper/gradle-wrapper.properties"
+else
+  # the location that the wrapper is at doesn't have a properties
+  # check PWD, gradlew may be shared
+  if [ -e "$PWD/gradle/wrapper/gradle-wrapper.properties" ]; then
+    . "$PWD/gradle/wrapper/gradle-wrapper.properties"
+  else
+    echo "Unable to locate gradle-wrapper.properties.  Not at $PWD/gradle/wrapper/gradle-wrapper.properties or $bin/gradle/wrapper/gradle-wrapper.properties" 1>&2
+    exit 1
+  fi
+fi
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+darwin=false
+case "`uname`" in
+  Darwin* )
+    darwin=true
+    ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# does not match gradle's hash
+# waiting for http://stackoverflow.com/questions/26642077/java-biginteger-in-bash-rewrite-gradlew
+hash() {
+  local input="$1"
+  if $darwin; then
+    md5 -q -s "$1"
+  else
+    echo -n "$1" | md5sum  | cut -d" " -f1
+  fi
+}
+
+dist_path() {
+  local dir=$(basename $distributionUrl | sed 's;.zip;;g')
+  local id=$(hash "$distributionUrl")
+
+  echo "$HOME/.gradle/${distributionPath:-wrapper/dists}/$dir/$id"
+}
+
+zip_path() {
+  local dir=$(basename $distributionUrl | sed 's;.zip;;g')
+  local id=$(hash "$distributionUrl")
+
+  echo "$HOME/.gradle/${zipStorePath:-wrapper/dists}/$dir/$id"
+}
+
+download() {
+  local base_path=$(dist_path)
+  local file_name=$(basename $distributionUrl)
+  local dir_name=$(echo "$file_name" | sed 's;-bin.zip;;g' | sed 's;-src.zip;;g' |sed 's;-all.zip;;g')
+
+  if [ ! -d "$base_path" ]; then
+    mkdir -p "$base_path"
+  else
+    # if data already exists, it means we failed to do this before
+    # so cleanup last run and try again
+    rm -rf $base_path/*
+  fi
+
+  # download dist. curl on mac doesn't like the cert provided...
+  local zip_path=$(zip_path)
+  curl --insecure -L -o "$zip_path/$file_name" "$distributionUrl"
+
+  pushd "$base_path"
+    touch "$file_name.lck"
+    unzip "$zip_path/$file_name" 1> /dev/null
+    touch "$file_name.ok"
+  popd
+}
+
+is_cached() {
+  local file_name=$(basename $distributionUrl)
+
+  [ -e "$(dist_path)/$file_name.ok" ]
+}
+
+lib_path() {
+  local base_path=$(dist_path)
+  local file_name=$(basename $distributionUrl | sed 's;-bin.zip;;g' | sed 's;-src.zip;;g' |sed 's;-all.zip;;g')
+
+  echo "$base_path/$file_name/lib"
+}
+
+classpath() {
+  local dir=$(lib_path)
+  local cp=$(ls -1 $dir/*.jar | tr '\n' ':')
+  echo "$dir:$cp"
+}
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+
+main() {
+  if ! is_cached; then
+    download
+  fi
+
+  eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+  JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+  $JAVACMD "${JVM_OPTS[@]}" -cp $(classpath) org.gradle.launcher.GradleMain "$@"
+}
+
+main "$@"
+