geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [11/11] incubator-geode git commit: renamed ChunkValueWrapper to OffHeapValueWrapper
Date Tue, 08 Mar 2016 00:25:18 GMT
renamed ChunkValueWrapper to OffHeapValueWrapper


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

Branch: refs/heads/feature/GEODE-982
Commit: 875f8ace0c0cc7f72b1a586959d0bfe08e500319
Parents: 79ed00e
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Mon Mar 7 16:23:46 2016 -0800
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Mon Mar 7 16:23:46 2016 -0800

----------------------------------------------------------------------
 .../cache/ChunkValueWrapperJUnitTest.java       | 188 -------------------
 .../cache/OffHeapValueWrapperJUnitTest.java     | 188 +++++++++++++++++++
 2 files changed, 188 insertions(+), 188 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/875f8ace/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
deleted file mode 100644
index 19b1ac1..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ChunkValueWrapperJUnitTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.cache;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.OffHeapValueWrapper;
-import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.Flushable;
-import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
-import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
-import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
-import com.gemstone.gemfire.internal.offheap.SlabImpl;
-import com.gemstone.gemfire.internal.offheap.StoredObject;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class ChunkValueWrapperJUnitTest {
-
-  private static OffHeapValueWrapper createChunkValueWrapper(byte[] bytes, boolean isSerialized)
{
-    StoredObject c = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes,
isSerialized, false);
-    return new OffHeapValueWrapper(c);
-  }
-
-  @Before
-  public void setUp() throws Exception {
-    SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new
NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-  }
-
-  @Test
-  public void testIsSerialized() {
-    assertEquals(true, createChunkValueWrapper(new byte[16], true).isSerialized());
-    assertEquals(false, createChunkValueWrapper(new byte[16], false).isSerialized());
-  }
-  
-  @Test
-  public void testGetUserBits() {
-    assertEquals((byte)1, createChunkValueWrapper(new byte[16], true).getUserBits());
-    assertEquals((byte)0, createChunkValueWrapper(new byte[16], false).getUserBits());
-  }
-  
-  @Test
-  public void testGetLength() {
-    assertEquals(32, createChunkValueWrapper(new byte[32], true).getLength());
-    assertEquals(17, createChunkValueWrapper(new byte[17], false).getLength());
-  }
-  
-  @Test
-  public void testGetBytesAsString() {
-    assertEquals("byte[0, 0, 0, 0, 0, 0, 0, 0]", createChunkValueWrapper(new byte[8], false).getBytesAsString());
-  }
-  
-  @Test
-  public void testSendTo() throws IOException {
-    final ByteBuffer bb = ByteBuffer.allocateDirect(18);
-    bb.limit(8);
-    OffHeapValueWrapper vw = createChunkValueWrapper(new byte[]{1,2,3,4,5,6,7,8}, false);
-    vw.sendTo(bb, new Flushable() {
-      @Override
-      public void flush() throws IOException {
-        fail("should not have been called");
-      }
-
-      @Override
-      public void flush(ByteBuffer bb, ByteBuffer chunkbb) throws IOException {
-        fail("should not have been called");
-      }
-    });
-    assertEquals(8, bb.position());
-    bb.flip();
-    assertEquals(1, bb.get());
-    assertEquals(2, bb.get());
-    assertEquals(3, bb.get());
-    assertEquals(4, bb.get());
-    assertEquals(5, bb.get());
-    assertEquals(6, bb.get());
-    assertEquals(7, bb.get());
-    assertEquals(8, bb.get());
-    
-    bb.clear();
-    bb.limit(8);
-    vw = createChunkValueWrapper(new byte[]{1,2,3,4,5,6,7,8,9}, false);
-    final int[] flushCalls = new int[1];
-    vw.sendTo(bb, new Flushable() {
-      @Override
-      public void flush() throws IOException {
-        if (flushCalls[0] != 0) {
-          fail("expected flush to only be called once");
-        }
-        flushCalls[0]++;
-        assertEquals(8, bb.position());
-        for (int i=0; i < 8; i++) {
-          assertEquals(i+1, bb.get(i));
-        }
-        bb.clear();
-        bb.limit(8);
-      }
-
-      @Override
-      public void flush(ByteBuffer bb, ByteBuffer chunkbb) throws IOException {
-        fail("should not have been called");
-      }
-    });
-    assertEquals(1, bb.position());
-    bb.flip();
-    assertEquals(9, bb.get());
-    
-    bb.clear();
-    bb.limit(8);
-    flushCalls[0] = 0;
-    vw = createChunkValueWrapper(new byte[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}, false);
-    vw.sendTo(bb, new Flushable() {
-      @Override
-      public void flush() throws IOException {
-        if (flushCalls[0] > 1) {
-          fail("expected flush to only be called twice");
-        }
-        assertEquals(8, bb.position());
-        for (int i=0; i < 8; i++) {
-          assertEquals((flushCalls[0]*8)+i+1, bb.get(i));
-        }
-        flushCalls[0]++;
-        bb.clear();
-        bb.limit(8);
-      }
-
-      @Override
-      public void flush(ByteBuffer bb, ByteBuffer chunkbb) throws IOException {
-        fail("should not have been called");
-      }
-    });
-    assertEquals(1, bb.position());
-    bb.flip();
-    assertEquals(17, bb.get());
-    
-    // now test with a chunk that will not fit in bb.
-    bb.clear();
-    flushCalls[0] = 0;
-    bb.put((byte) 0);
-    vw = createChunkValueWrapper(new byte[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19},
false);
-    vw.sendTo(bb, new Flushable() {
-      @Override
-      public void flush() throws IOException {
-        fail("should not have been called");
-      }
-
-      @Override
-      public void flush(ByteBuffer bb, ByteBuffer chunkbb) throws IOException {
-        flushCalls[0]++;
-        assertEquals(1, bb.position());
-        bb.flip();
-        assertEquals(0, bb.get());
-        assertEquals(19, chunkbb.remaining());
-        for (int i=1; i <= 19; i++) {
-          assertEquals(i, chunkbb.get());
-        }
-      }
-    });
-    assertEquals(1, flushCalls[0]);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/875f8ace/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
new file mode 100644
index 0000000..0829009
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.internal.cache;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.OffHeapValueWrapper;
+import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.Flushable;
+import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
+import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
+import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.SlabImpl;
+import com.gemstone.gemfire.internal.offheap.StoredObject;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class OffHeapValueWrapperJUnitTest {
+
+  private static OffHeapValueWrapper createChunkValueWrapper(byte[] bytes, boolean isSerialized)
{
+    StoredObject c = SimpleMemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes,
isSerialized, false);
+    return new OffHeapValueWrapper(c);
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new
NullOffHeapMemoryStats(), new SlabImpl[]{new SlabImpl(1024*1024)});
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+  }
+
+  @Test
+  public void testIsSerialized() {
+    assertEquals(true, createChunkValueWrapper(new byte[16], true).isSerialized());
+    assertEquals(false, createChunkValueWrapper(new byte[16], false).isSerialized());
+  }
+  
+  @Test
+  public void testGetUserBits() {
+    assertEquals((byte)1, createChunkValueWrapper(new byte[16], true).getUserBits());
+    assertEquals((byte)0, createChunkValueWrapper(new byte[16], false).getUserBits());
+  }
+  
+  @Test
+  public void testGetLength() {
+    assertEquals(32, createChunkValueWrapper(new byte[32], true).getLength());
+    assertEquals(17, createChunkValueWrapper(new byte[17], false).getLength());
+  }
+  
+  @Test
+  public void testGetBytesAsString() {
+    assertEquals("byte[0, 0, 0, 0, 0, 0, 0, 0]", createChunkValueWrapper(new byte[8], false).getBytesAsString());
+  }
+  
+  @Test
+  public void testSendTo() throws IOException {
+    final ByteBuffer bb = ByteBuffer.allocateDirect(18);
+    bb.limit(8);
+    OffHeapValueWrapper vw = createChunkValueWrapper(new byte[]{1,2,3,4,5,6,7,8}, false);
+    vw.sendTo(bb, new Flushable() {
+      @Override
+      public void flush() throws IOException {
+        fail("should not have been called");
+      }
+
+      @Override
+      public void flush(ByteBuffer bb, ByteBuffer chunkbb) throws IOException {
+        fail("should not have been called");
+      }
+    });
+    assertEquals(8, bb.position());
+    bb.flip();
+    assertEquals(1, bb.get());
+    assertEquals(2, bb.get());
+    assertEquals(3, bb.get());
+    assertEquals(4, bb.get());
+    assertEquals(5, bb.get());
+    assertEquals(6, bb.get());
+    assertEquals(7, bb.get());
+    assertEquals(8, bb.get());
+    
+    bb.clear();
+    bb.limit(8);
+    vw = createChunkValueWrapper(new byte[]{1,2,3,4,5,6,7,8,9}, false);
+    final int[] flushCalls = new int[1];
+    vw.sendTo(bb, new Flushable() {
+      @Override
+      public void flush() throws IOException {
+        if (flushCalls[0] != 0) {
+          fail("expected flush to only be called once");
+        }
+        flushCalls[0]++;
+        assertEquals(8, bb.position());
+        for (int i=0; i < 8; i++) {
+          assertEquals(i+1, bb.get(i));
+        }
+        bb.clear();
+        bb.limit(8);
+      }
+
+      @Override
+      public void flush(ByteBuffer bb, ByteBuffer chunkbb) throws IOException {
+        fail("should not have been called");
+      }
+    });
+    assertEquals(1, bb.position());
+    bb.flip();
+    assertEquals(9, bb.get());
+    
+    bb.clear();
+    bb.limit(8);
+    flushCalls[0] = 0;
+    vw = createChunkValueWrapper(new byte[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}, false);
+    vw.sendTo(bb, new Flushable() {
+      @Override
+      public void flush() throws IOException {
+        if (flushCalls[0] > 1) {
+          fail("expected flush to only be called twice");
+        }
+        assertEquals(8, bb.position());
+        for (int i=0; i < 8; i++) {
+          assertEquals((flushCalls[0]*8)+i+1, bb.get(i));
+        }
+        flushCalls[0]++;
+        bb.clear();
+        bb.limit(8);
+      }
+
+      @Override
+      public void flush(ByteBuffer bb, ByteBuffer chunkbb) throws IOException {
+        fail("should not have been called");
+      }
+    });
+    assertEquals(1, bb.position());
+    bb.flip();
+    assertEquals(17, bb.get());
+    
+    // now test with a chunk that will not fit in bb.
+    bb.clear();
+    flushCalls[0] = 0;
+    bb.put((byte) 0);
+    vw = createChunkValueWrapper(new byte[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19},
false);
+    vw.sendTo(bb, new Flushable() {
+      @Override
+      public void flush() throws IOException {
+        fail("should not have been called");
+      }
+
+      @Override
+      public void flush(ByteBuffer bb, ByteBuffer chunkbb) throws IOException {
+        flushCalls[0]++;
+        assertEquals(1, bb.position());
+        bb.flip();
+        assertEquals(0, bb.get());
+        assertEquals(19, chunkbb.remaining());
+        for (int i=1; i <= 19; i++) {
+          assertEquals(i, chunkbb.get());
+        }
+      }
+    });
+    assertEquals(1, flushCalls[0]);
+  }
+}


Mime
View raw message