incubator-directmemory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raffaelegu...@apache.org
Subject svn commit: r1211877 - in /incubator/directmemory/trunk/directmemory-cache/src: main/java/org/apache/directmemory/memory/OffHeapMemoryBuffer.java test/java/org/apache/directmemory/memory/test/NIOTests.java
Date Thu, 08 Dec 2011 13:34:57 GMT
Author: raffaeleguidi
Date: Thu Dec  8 13:34:57 2011
New Revision: 1211877

URL: http://svn.apache.org/viewvc?rev=1211877&view=rev
Log:
fixed a nasty bug in new allocate() method

Modified:
    incubator/directmemory/trunk/directmemory-cache/src/main/java/org/apache/directmemory/memory/OffHeapMemoryBuffer.java
    incubator/directmemory/trunk/directmemory-cache/src/test/java/org/apache/directmemory/memory/test/NIOTests.java

Modified: incubator/directmemory/trunk/directmemory-cache/src/main/java/org/apache/directmemory/memory/OffHeapMemoryBuffer.java
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/directmemory-cache/src/main/java/org/apache/directmemory/memory/OffHeapMemoryBuffer.java?rev=1211877&r1=1211876&r2=1211877&view=diff
==============================================================================
--- incubator/directmemory/trunk/directmemory-cache/src/main/java/org/apache/directmemory/memory/OffHeapMemoryBuffer.java
(original)
+++ incubator/directmemory/trunk/directmemory-cache/src/main/java/org/apache/directmemory/memory/OffHeapMemoryBuffer.java
Thu Dec  8 13:34:57 2011
@@ -307,9 +307,9 @@ public class OffHeapMemoryBuffer {
 		used.addAndGet(size);
 		ByteBuffer buf = buffer.slice();
 		buf.position(fresh.start);
-		buf.limit(size);
 		
-		fresh.directBuffer = buf;
+		fresh.directBuffer = buf.slice();
+		fresh.directBuffer.limit(size);
 		pointers.add(fresh);
 		return fresh;	
 	}

Modified: incubator/directmemory/trunk/directmemory-cache/src/test/java/org/apache/directmemory/memory/test/NIOTests.java
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/directmemory-cache/src/test/java/org/apache/directmemory/memory/test/NIOTests.java?rev=1211877&r1=1211876&r2=1211877&view=diff
==============================================================================
--- incubator/directmemory/trunk/directmemory-cache/src/test/java/org/apache/directmemory/memory/test/NIOTests.java
(original)
+++ incubator/directmemory/trunk/directmemory-cache/src/test/java/org/apache/directmemory/memory/test/NIOTests.java
Thu Dec  8 13:34:57 2011
@@ -40,8 +40,22 @@ public class NIOTests {
 	
 	@BeforeClass
 	public static void init() {
+		byte[] payload = "012345678901234567890123456789012345678901234567890123456789".getBytes();
+
 		logger.info("init");
 		MemoryManager.init(1, Ram.Mb(100));
+
+		logger.info("payload size=" + Ram.inKb(payload.length));
+		long howMany = (MemoryManager.capacity() / payload.length);
+		howMany=(howMany*50)/100;
+		
+		
+		for (int i = 0; i < howMany ; i++) {
+			Pointer p = MemoryManager.store(payload);
+			assertNotNull(p);
+		}
+		
+		logger.info("" + howMany + " items stored");
 	}
 	
 	@Test
@@ -60,10 +74,8 @@ public class NIOTests {
 		assertEquals(size, b.limit());
 		
 		//assertEquals(size,p.end);
-    assertEquals(size,p.end-p.start); 
-		assertEquals(size, MemoryManager.getActiveBuffer().used());
-		MemoryManager.free(p);
-		assertEquals(0, MemoryManager.getActiveBuffer().used());
+		assertEquals(size,p.end-p.start); 
+//		assertEquals(size, MemoryManager.getActiveBuffer().used());
 		logger.info("end");
 	}
 



Mime
View raw message