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/03/05 01:51:09 UTC
[09/38] incubator-geode git commit: now compiles
now compiles
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/9afb5b8e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/9afb5b8e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/9afb5b8e
Branch: refs/heads/feature/GEODE-982
Commit: 9afb5b8e982a5c2b6e1fc4e6d5d0cbe82406ad2c
Parents: e14a568
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Fri Feb 26 17:07:05 2016 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Fri Feb 26 17:07:05 2016 -0800
----------------------------------------------------------------------
.../internal/offheap/MemoryAllocator.java | 2 +-
.../offheap/SimpleMemoryAllocatorImpl.java | 2 +-
.../internal/offheap/FreeListManagerTest.java | 130 +++++++++----------
.../offheap/MemoryBlockNodeJUnitTest.java | 10 +-
4 files changed, 70 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9afb5b8e/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocator.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocator.java
index cd710fa..f008a5e 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocator.java
@@ -29,7 +29,7 @@ public interface MemoryAllocator {
* @return the allocated chunk of memory.
* @throws IllegalStateException if the heap does not have enough memory to grant the request
*/
- public StoredObject allocate(int size);
+ public MemoryChunkWithRefCount allocate(int size);
/**
* Allocates off heap memory for the given data and returns a MemoryChunk
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9afb5b8e/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
index b264d89..e257ffa 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
@@ -307,7 +307,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
}
@Override
- public StoredObject allocate(int size) {
+ public MemoryChunkWithRefCount allocate(int size) {
//System.out.println("allocating " + size);
ObjectChunk result = allocateChunk(size);
//("allocated off heap object of size " + size + " @" + Long.toHexString(result.getMemoryAddress()), true);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9afb5b8e/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
index 64032cc..1f82cfe 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
@@ -69,7 +69,7 @@ public class FreeListManagerTest {
}
}
- private static TestableFreeListManager createFreeListManager(SimpleMemoryAllocatorImpl ma, AddressableMemoryChunk[] slabs) {
+ private static TestableFreeListManager createFreeListManager(SimpleMemoryAllocatorImpl ma, Slab[] slabs) {
return new TestableFreeListManager(ma, slabs);
}
@@ -77,8 +77,8 @@ public class FreeListManagerTest {
setUpSingleSlabManager(DEFAULT_SLAB_SIZE);
}
private void setUpSingleSlabManager(int slabSize) {
- UnsafeMemoryChunk slab = new UnsafeMemoryChunk(slabSize);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {slab});
+ Slab slab = new SlabImpl(slabSize);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {slab});
}
@Test
@@ -264,11 +264,11 @@ public class FreeListManagerTest {
public void allocateFromMultipleSlabs() {
int SMALL_SLAB = 16;
int MEDIUM_SLAB = 128;
- UnsafeMemoryChunk slab = new UnsafeMemoryChunk(DEFAULT_SLAB_SIZE);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {
- new UnsafeMemoryChunk(SMALL_SLAB),
- new UnsafeMemoryChunk(SMALL_SLAB),
- new UnsafeMemoryChunk(MEDIUM_SLAB),
+ Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {
+ new SlabImpl(SMALL_SLAB),
+ new SlabImpl(SMALL_SLAB),
+ new SlabImpl(MEDIUM_SLAB),
slab});
this.freeListManager.allocate(SMALL_SLAB-8+1);
this.freeListManager.allocate(DEFAULT_SLAB_SIZE-8);
@@ -282,11 +282,11 @@ public class FreeListManagerTest {
public void compactWithLargeChunkSizeReturnsFalse() {
int SMALL_SLAB = 16;
int MEDIUM_SLAB = 128;
- UnsafeMemoryChunk slab = new UnsafeMemoryChunk(DEFAULT_SLAB_SIZE);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {
- new UnsafeMemoryChunk(SMALL_SLAB),
- new UnsafeMemoryChunk(SMALL_SLAB),
- new UnsafeMemoryChunk(MEDIUM_SLAB),
+ Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {
+ new SlabImpl(SMALL_SLAB),
+ new SlabImpl(SMALL_SLAB),
+ new SlabImpl(MEDIUM_SLAB),
slab});
ArrayList<ObjectChunk> chunks = new ArrayList<>();
chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
@@ -304,11 +304,11 @@ public class FreeListManagerTest {
public void compactWithChunkSizeOfMaxSlabReturnsTrue() {
int SMALL_SLAB = 16;
int MEDIUM_SLAB = 128;
- UnsafeMemoryChunk slab = new UnsafeMemoryChunk(DEFAULT_SLAB_SIZE);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {
- new UnsafeMemoryChunk(SMALL_SLAB),
- new UnsafeMemoryChunk(SMALL_SLAB),
- new UnsafeMemoryChunk(MEDIUM_SLAB),
+ Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {
+ new SlabImpl(SMALL_SLAB),
+ new SlabImpl(SMALL_SLAB),
+ new SlabImpl(MEDIUM_SLAB),
slab});
ArrayList<ObjectChunk> chunks = new ArrayList<>();
chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
@@ -327,11 +327,11 @@ public class FreeListManagerTest {
public void compactWithLiveChunks() {
int SMALL_SLAB = 16;
int MEDIUM_SLAB = 128;
- UnsafeMemoryChunk slab = new UnsafeMemoryChunk(DEFAULT_SLAB_SIZE);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {
- new UnsafeMemoryChunk(SMALL_SLAB),
- new UnsafeMemoryChunk(SMALL_SLAB),
- new UnsafeMemoryChunk(MEDIUM_SLAB),
+ Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {
+ new SlabImpl(SMALL_SLAB),
+ new SlabImpl(SMALL_SLAB),
+ new SlabImpl(MEDIUM_SLAB),
slab});
ArrayList<ObjectChunk> chunks = new ArrayList<>();
chunks.add(this.freeListManager.allocate(SMALL_SLAB-8+1));
@@ -437,11 +437,11 @@ public class FreeListManagerTest {
public void allocationsThatLeaveLessThanMinChunkSizeFreeInAFragment() {
int SMALL_SLAB = 16;
int MEDIUM_SLAB = 128;
- UnsafeMemoryChunk slab = new UnsafeMemoryChunk(DEFAULT_SLAB_SIZE);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {
- new UnsafeMemoryChunk(SMALL_SLAB),
- new UnsafeMemoryChunk(SMALL_SLAB),
- new UnsafeMemoryChunk(MEDIUM_SLAB),
+ Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {
+ new SlabImpl(SMALL_SLAB),
+ new SlabImpl(SMALL_SLAB),
+ new SlabImpl(MEDIUM_SLAB),
slab});
this.freeListManager.allocate(DEFAULT_SLAB_SIZE-8-(ObjectChunk.MIN_CHUNK_SIZE-1));
this.freeListManager.allocate(MEDIUM_SLAB-8-(ObjectChunk.MIN_CHUNK_SIZE-1));
@@ -561,32 +561,32 @@ public class FreeListManagerTest {
@Test
public void okToReuseSameSlabs() {
- UnsafeMemoryChunk slab = new UnsafeMemoryChunk(DEFAULT_SLAB_SIZE);
- UnsafeMemoryChunk[] slabs = new UnsafeMemoryChunk[] {slab};
+ Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE);
+ Slab[] slabs = new Slab[] {slab};
this.freeListManager = createFreeListManager(ma, slabs);
assertThat(this.freeListManager.okToReuse(slabs)).isTrue();
}
@Test
public void notOkToReuseDifferentSlabs() {
- UnsafeMemoryChunk slab = new UnsafeMemoryChunk(DEFAULT_SLAB_SIZE);
- UnsafeMemoryChunk[] slabs = new UnsafeMemoryChunk[] {slab};
+ Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE);
+ Slab[] slabs = new Slab[] {slab};
this.freeListManager = createFreeListManager(ma, slabs);
- UnsafeMemoryChunk[] slabs2 = new UnsafeMemoryChunk[] {slab};
+ Slab[] slabs2 = new Slab[] {slab};
assertThat(this.freeListManager.okToReuse(slabs2)).isFalse();
}
@Test
public void firstSlabAlwaysLargest() {
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {
- new UnsafeMemoryChunk(10),
- new UnsafeMemoryChunk(100)});
+ this.freeListManager = createFreeListManager(ma, new Slab[] {
+ new SlabImpl(10),
+ new SlabImpl(100)});
assertThat(this.freeListManager.getLargestSlabSize()).isEqualTo(10);
}
@Test
public void findSlab() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(10);
+ Slab chunk = new SlabImpl(10);
long address = chunk.getMemoryAddress();
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk});
assertThat(this.freeListManager.findSlab(address)).isEqualTo(0);
assertThat(this.freeListManager.findSlab(address+9)).isEqualTo(0);
catchException(this.freeListManager).findSlab(address-1);
@@ -601,10 +601,10 @@ public class FreeListManagerTest {
@Test
public void findSecondSlab() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(10);
+ Slab chunk = new SlabImpl(10);
long address = chunk.getMemoryAddress();
- UnsafeMemoryChunk slab = new UnsafeMemoryChunk(DEFAULT_SLAB_SIZE);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {slab, chunk});
+ Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {slab, chunk});
assertThat(this.freeListManager.findSlab(address)).isEqualTo(1);
assertThat(this.freeListManager.findSlab(address+9)).isEqualTo(1);
catchException(this.freeListManager).findSlab(address-1);
@@ -619,9 +619,9 @@ public class FreeListManagerTest {
@Test
public void validateAddressWithinSlab() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(10);
+ Slab chunk = new SlabImpl(10);
long address = chunk.getMemoryAddress();
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk});
assertThat(this.freeListManager.validateAddressAndSizeWithinSlab(address, -1)).isTrue();
assertThat(this.freeListManager.validateAddressAndSizeWithinSlab(address+9, -1)).isTrue();
assertThat(this.freeListManager.validateAddressAndSizeWithinSlab(address-1, -1)).isFalse();
@@ -630,9 +630,9 @@ public class FreeListManagerTest {
@Test
public void validateAddressAndSizeWithinSlab() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(10);
+ Slab chunk = new SlabImpl(10);
long address = chunk.getMemoryAddress();
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk});
assertThat(this.freeListManager.validateAddressAndSizeWithinSlab(address, 1)).isTrue();
assertThat(this.freeListManager.validateAddressAndSizeWithinSlab(address, 10)).isTrue();
catchException(this.freeListManager).validateAddressAndSizeWithinSlab(address, 0);
@@ -647,10 +647,10 @@ public class FreeListManagerTest {
@Test
public void descriptionOfOneSlab() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(10);
+ Slab chunk = new SlabImpl(10);
long address = chunk.getMemoryAddress();
long endAddress = address+10;
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk});
StringBuilder sb = new StringBuilder();
this.freeListManager.getSlabDescriptions(sb);
assertThat(sb.toString()).isEqualTo("[" + Long.toString(address, 16) + ".." + Long.toString(endAddress, 16) + "] ");
@@ -658,9 +658,9 @@ public class FreeListManagerTest {
@Test
public void orderBlocksContainsFragment() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(10);
+ Slab chunk = new SlabImpl(10);
long address = chunk.getMemoryAddress();
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk});
List<MemoryBlock> ob = this.freeListManager.getOrderedBlocks();
assertThat(ob).hasSize(1);
assertThat(ob.get(0).getMemoryAddress()).isEqualTo(address);
@@ -669,9 +669,9 @@ public class FreeListManagerTest {
@Test
public void orderBlocksContainsTinyFree() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
+ Slab chunk = new SlabImpl(96);
long address = chunk.getMemoryAddress();
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk});
ObjectChunk c = this.freeListManager.allocate(24);
ObjectChunk c2 = this.freeListManager.allocate(24);
ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
@@ -682,16 +682,16 @@ public class FreeListManagerTest {
@Test
public void allocatedBlocksEmptyIfNoAllocations() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(10);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
+ Slab chunk = new SlabImpl(10);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk});
List<MemoryBlock> ob = this.freeListManager.getAllocatedBlocks();
assertThat(ob).hasSize(0);
}
@Test
public void allocatedBlocksEmptyAfterFree() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
+ Slab chunk = new SlabImpl(96);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk});
ObjectChunk c = this.freeListManager.allocate(24);
ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
List<MemoryBlock> ob = this.freeListManager.getAllocatedBlocks();
@@ -700,8 +700,8 @@ public class FreeListManagerTest {
@Test
public void allocatedBlocksHasAllocatedChunk() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
+ Slab chunk = new SlabImpl(96);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk});
ObjectChunk c = this.freeListManager.allocate(24);
List<MemoryBlock> ob = this.freeListManager.getAllocatedBlocks();
assertThat(ob).hasSize(1);
@@ -710,8 +710,8 @@ public class FreeListManagerTest {
@Test
public void allocatedBlocksHasBothAllocatedChunks() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
+ Slab chunk = new SlabImpl(96);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk});
ObjectChunk c = this.freeListManager.allocate(24);
ObjectChunk c2 = this.freeListManager.allocate(33);
List<MemoryBlock> ob = this.freeListManager.getAllocatedBlocks();
@@ -720,17 +720,17 @@ public class FreeListManagerTest {
@Test
public void allocateFromFragmentWithBadIndexesReturnsNull() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(96);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk});
+ Slab chunk = new SlabImpl(96);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk});
assertThat(this.freeListManager.allocateFromFragment(-1, 32)).isNull();
assertThat(this.freeListManager.allocateFromFragment(1, 32)).isNull();
}
@Test
public void testLogging() {
- UnsafeMemoryChunk chunk = new UnsafeMemoryChunk(32);
- UnsafeMemoryChunk chunk2 = new UnsafeMemoryChunk(1024*1024*5);
- this.freeListManager = createFreeListManager(ma, new UnsafeMemoryChunk[] {chunk, chunk2});
+ Slab chunk = new SlabImpl(32);
+ Slab chunk2 = new SlabImpl(1024*1024*5);
+ this.freeListManager = createFreeListManager(ma, new Slab[] {chunk, chunk2});
ObjectChunk c = this.freeListManager.allocate(24);
ObjectChunk c2 = this.freeListManager.allocate(1024*1024);
ObjectChunk.release(c.getMemoryAddress(), this.freeListManager);
@@ -789,7 +789,7 @@ public class FreeListManagerTest {
}
}
- public TestableFreeListManager(SimpleMemoryAllocatorImpl ma, AddressableMemoryChunk[] slabs) {
+ public TestableFreeListManager(SimpleMemoryAllocatorImpl ma, Slab[] slabs) {
super(ma, slabs);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9afb5b8e/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNodeJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNodeJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNodeJUnitTest.java
index 3d2dbc7..cad54c0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNodeJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNodeJUnitTest.java
@@ -49,11 +49,9 @@ public class MemoryBlockNodeJUnitTest {
private SimpleMemoryAllocatorImpl ma;
private OutOfOffHeapMemoryListener ooohml;
private OffHeapMemoryStats stats;
- private LogWriter lw;
- private int numSlabs;
- private AddressableMemoryChunk[] slabs = {
- new UnsafeMemoryChunk((int)OffHeapStorage.MIN_SLAB_SIZE),
- new UnsafeMemoryChunk((int)OffHeapStorage.MIN_SLAB_SIZE * 2)
+ private Slab[] slabs = {
+ new SlabImpl((int)OffHeapStorage.MIN_SLAB_SIZE),
+ new SlabImpl((int)OffHeapStorage.MIN_SLAB_SIZE * 2)
};
private MemoryChunkWithRefCount storedObject = null;
@@ -84,8 +82,6 @@ public class MemoryBlockNodeJUnitTest {
public void setUp() {
ooohml = mock(OutOfOffHeapMemoryListener.class);
stats = mock(OffHeapMemoryStats.class);
- lw = mock(LogWriter.class);
- numSlabs = 3;
ma = (SimpleMemoryAllocatorImpl) SimpleMemoryAllocatorImpl.createForUnitTest(ooohml, stats, slabs);
}