use of io.mycat.memory.unsafe.memory.mm.DataNodeMemoryManager in project Mycat-Server by MyCATApache.
the class TaskMemoryManagerSuite method cooperativeSpilling.
@Test
public void cooperativeSpilling() throws InterruptedException {
final TestMemoryManager memoryManager = new TestMemoryManager(new MycatPropertyConf());
memoryManager.limit(100);
final DataNodeMemoryManager manager = new DataNodeMemoryManager(memoryManager, 0);
TestMemoryConsumer c1 = new TestMemoryConsumer(manager);
TestMemoryConsumer c2 = new TestMemoryConsumer(manager);
c1.use(100);
Assert.assertEquals(100, c1.getUsed());
c2.use(100);
Assert.assertEquals(100, c2.getUsed());
// spilled
Assert.assertEquals(0, c1.getUsed());
c1.use(100);
Assert.assertEquals(100, c1.getUsed());
// spilled
Assert.assertEquals(0, c2.getUsed());
c1.use(50);
// spilled
Assert.assertEquals(50, c1.getUsed());
Assert.assertEquals(0, c2.getUsed());
c2.use(50);
Assert.assertEquals(50, c1.getUsed());
Assert.assertEquals(50, c2.getUsed());
c1.use(100);
Assert.assertEquals(100, c1.getUsed());
// spilled
Assert.assertEquals(0, c2.getUsed());
c1.free(20);
Assert.assertEquals(80, c1.getUsed());
c2.use(10);
Assert.assertEquals(80, c1.getUsed());
Assert.assertEquals(10, c2.getUsed());
c2.use(100);
Assert.assertEquals(100, c2.getUsed());
// spilled
Assert.assertEquals(0, c1.getUsed());
c1.free(0);
c2.free(100);
Assert.assertEquals(0, manager.cleanUpAllAllocatedMemory());
}
use of io.mycat.memory.unsafe.memory.mm.DataNodeMemoryManager in project Mycat-Server by MyCATApache.
the class UnsafeInMemorySorterSuite method testSortingEmptyInput.
@Test
public void testSortingEmptyInput() {
final DataNodeMemoryManager memoryManager = new DataNodeMemoryManager(new TestMemoryManager(new MycatPropertyConf().set("mycat.memory.offHeap.enabled", "false")), 0);
final TestMemoryConsumer consumer = new TestMemoryConsumer(memoryManager);
final UnsafeInMemorySorter sorter = new UnsafeInMemorySorter(consumer, memoryManager, mock(RecordComparator.class), mock(PrefixComparator.class), 100, shouldUseRadixSort(), true);
final UnsafeSorterIterator iter = sorter.getSortedIterator();
Assert.assertFalse(iter.hasNext());
}
Aggregations