geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [08/11] incubator-geode git commit: now uses GemFireChunk constructor instead of ChunkFactory
Date Wed, 27 Jan 2016 00:20:07 GMT
now uses GemFireChunk constructor instead of 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/b6fb3449
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/b6fb3449
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/b6fb3449

Branch: refs/heads/feature/GEODE-831
Commit: b6fb3449b075c2b1f45336f201048714d35957e9
Parents: f6ee9e2
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Mon Jan 25 15:48:40 2016 -0800
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Mon Jan 25 15:48:40 2016 -0800

----------------------------------------------------------------------
 .../gemfire/internal/offheap/FreeListManager.java     | 10 ++++------
 .../internal/offheap/OffHeapRegionEntryHelper.java    | 14 +-------------
 .../internal/offheap/SimpleMemoryAllocatorImpl.java   |  8 +-------
 .../gemfire/internal/offheap/FreeListManagerTest.java |  2 --
 4 files changed, 6 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6fb3449/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 cc2f38f..ed4b533 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
@@ -55,7 +55,6 @@ public class FreeListManager {
   }
   private void getLiveChunks(UnsafeMemoryChunk slab, List<Chunk> result) {
     long addr = slab.getMemoryAddress();
-    ChunkFactory cf = this.ma.getChunkFactory();
     while (addr <= (slab.getMemoryAddress() + slab.getSize() - Chunk.MIN_CHUNK_SIZE))
{
       Fragment f = isAddrInFragmentFreeSpace(addr);
       if (f != null) {
@@ -64,7 +63,7 @@ public class FreeListManager {
         int curChunkSize = Chunk.getSize(addr);
         int refCount = Chunk.getRefCount(addr);
         if (refCount > 0) {
-          result.add(cf.newChunk(addr));
+          result.add(new GemFireChunk(addr));
         }
         addr += curChunkSize;
       }
@@ -567,8 +566,7 @@ public class FreeListManager {
         if (fragment.allocate(oldOffset, newOffset)) {
           // We did the allocate!
           this.lastFragmentAllocation.set(fragIdx);
-          ChunkFactory cf = this.ma.getChunkFactory();
-          Chunk result = cf.newChunk(fragment.getMemoryAddress()+oldOffset, chunkSize+extraSize);
+          Chunk result = new GemFireChunk(fragment.getMemoryAddress()+oldOffset, chunkSize+extraSize);
 
           if(this.validateMemoryWithFill) {
             result.validateFill();
@@ -598,7 +596,7 @@ public class FreeListManager {
     if (clq != null) {
       long memAddr = clq.poll();
       if (memAddr != 0) {
-        Chunk result = this.ma.getChunkFactory().newChunk(memAddr);
+        Chunk result = new GemFireChunk(memAddr);
 
         // Data integrity check.
         if(this.validateMemoryWithFill) {          
@@ -703,7 +701,7 @@ public class FreeListManager {
 
   }
   private void freeHuge(long addr, int cSize) {
-    this.hugeChunkSet.add(this.ma.getChunkFactory().newChunk(addr)); // TODO make this a
collection of longs
+    this.hugeChunkSet.add(new GemFireChunk(addr)); // TODO make this a collection of longs
   }
 
   List<MemoryBlock> getOrderedBlocks() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6fb3449/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 b7887dd..c634f3d 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
@@ -49,17 +49,6 @@ public class OffHeapRegionEntryHelper {
   private static final long NOT_AVAILABLE_ADDRESS = 7L<<1;
   private static final long TOMBSTONE_ADDRESS = 8L<<1;
   public static final int MAX_LENGTH_FOR_DATA_AS_ADDRESS = 8;
- /* private static final ChunkFactory chunkFactory ;
-  static {
-    ChunkFactory factory;
-    try {
-       factory= SimpleMemoryAllocatorImpl.getAllocator().getChunkFactory();
-         
-    }catch(CacheClosedException ce) {
-      factory = null;
-    }
-    chunkFactory = factory;
-  }*/
   
   private static final Token[] addrToObj = new Token[]{
     null,
@@ -107,8 +96,7 @@ public class OffHeapRegionEntryHelper {
   @Unretained @Retained
   public static Object addressToObject(@Released @Retained long ohAddress, boolean decompress,
RegionEntryContext context) {
     if (isOffHeap(ohAddress)) {
-      //Chunk chunk = chunkFactory.newChunk(ohAddress);
-      @Unretained Chunk chunk =  SimpleMemoryAllocatorImpl.getAllocator().getChunkFactory().newChunk(ohAddress);
+      @Unretained Chunk chunk =  new GemFireChunk(ohAddress);
       @Unretained Object result = chunk;
       if (decompress && chunk.isCompressed()) {
         try {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6fb3449/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 3481e99..6d2391c 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
@@ -83,7 +83,6 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
   private volatile MemoryUsageListener[] memoryUsageListeners = new MemoryUsageListener[0];
   
   private static SimpleMemoryAllocatorImpl singleton = null;
-  private final ChunkFactory chunkFactory;
   
   public static SimpleMemoryAllocatorImpl getAllocator() {
     SimpleMemoryAllocatorImpl result = singleton;
@@ -230,8 +229,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
     this.ooohml = oooml;
     this.stats = stats;
     this.slabs = slabs;
-    this.chunkFactory = new GemFireChunkFactory();
-    
+
     //OSProcess.printStacks(0, InternalDistributedSystem.getAnyInstance().getLogWriter(),
false);
     this.stats.setFragments(slabs.length);
     largestSlab = slabs[0].getSize();
@@ -447,10 +445,6 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
     return this.stats;
   }
   
-  public ChunkFactory getChunkFactory() {
-    return this.chunkFactory;
-  }
-
   @Override
   public void addMemoryUsageListener(final MemoryUsageListener listener) {
     synchronized (this.memoryUsageListeners) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6fb3449/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 5596f9e..bab65dc 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
@@ -18,7 +18,6 @@ public class FreeListManagerTest {
   private final SimpleMemoryAllocatorImpl ma = mock(SimpleMemoryAllocatorImpl.class);
   private final UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024*1024*5);
   private final OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
-  private final ChunkFactory cf = new GemFireChunkFactory();
   private FreeListManager freeListManager;
   
 
@@ -35,7 +34,6 @@ public class FreeListManagerTest {
     when(ma.getSlabs()).thenReturn(new UnsafeMemoryChunk[] {slab});
     when(ma.getTotalMemory()).thenReturn((long) slab.getSize());
     when(ma.getStats()).thenReturn(stats);
-    when(ma.getChunkFactory()).thenReturn(cf);
     
     this.freeListManager = new FreeListManager(ma);
   }


Mime
View raw message