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 2015/12/02 01:06:17 UTC
[08/13] incubator-geode git commit: testFindSlab
testFindSlab
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/234c90ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/234c90ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/234c90ad
Branch: refs/heads/feature/GEODE-607
Commit: 234c90ad2c419d5ac982ba0d4744ae33f395ad57
Parents: 2b1d390
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Wed Nov 25 16:10:17 2015 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed Nov 25 16:10:17 2015 -0800
----------------------------------------------------------------------
.../internal/offheap/MemoryBlockNode.java | 1 -
.../offheap/SimpleMemoryAllocatorImpl.java | 2 +-
.../offheap/SimpleMemoryAllocatorJUnitTest.java | 22 ++++++++++++++++++++
3 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/234c90ad/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 3f5f4dc..b02d394 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
@@ -21,7 +21,6 @@ import java.util.Arrays;
import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.cache.CacheClosedException;
-import com.gemstone.gemfire.internal.offheap.MemoryBlock.State;
/**
* Basic implementation of MemoryBlock for test validation only.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/234c90ad/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 15e0177..84361c9 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
@@ -490,7 +490,7 @@ public final class SimpleMemoryAllocatorImpl implements MemoryAllocator, MemoryI
/**
* Return the slabId of the slab that contains the given addr.
*/
- protected int findSlab(long addr) {
+ int findSlab(long addr) {
for (int i=0; i < this.slabs.length; i++) {
UnsafeMemoryChunk slab = this.slabs[i];
long slabAddr = slab.getMemoryAddress();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/234c90ad/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 b1b77a9..b0bdeca 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
@@ -165,6 +165,28 @@ public class SimpleMemoryAllocatorJUnitTest {
}
}
@Test
+ public void testFindSlab() {
+ final int SLAB_SIZE = 1024*1024;
+ UnsafeMemoryChunk slab = new UnsafeMemoryChunk(SLAB_SIZE);
+ try {
+ SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
+ assertEquals(0, ma.findSlab(slab.getMemoryAddress()));
+ assertEquals(0, ma.findSlab(slab.getMemoryAddress()+SLAB_SIZE-1));
+ try {
+ ma.findSlab(slab.getMemoryAddress()-1);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ }
+ try {
+ ma.findSlab(slab.getMemoryAddress()+SLAB_SIZE);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ }
+ } finally {
+ SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+ }
+ }
+ @Test
public void testClose() {
UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024*1024);
boolean freeSlab = true;