FreeListManager { static void verifyOffHeapAlignment(int tinyMultiple) { if (tinyMultiple <= 0 || (tinyMultiple & 3) != 0) { throw new IllegalStateException( GeodeGlossary.GEMFIRE_PREFIX + "OFF_HEAP_ALIGNMENT must be a multiple of 8."); } if (tinyMultiple > 256) { throw new IllegalStateException(GeodeGlossary.GEMFIRE_PREFIX + "OFF_HEAP_ALIGNMENT must be <= 256 and a multiple of 8."); } } FreeListManager(MemoryAllocatorImpl ma, final Slab[] slabs); long getUsedMemory(); long getFreeMemory(); @SuppressWarnings("synthetic-access") OffHeapStoredObject allocate(int size); @SuppressWarnings("synthetic-access") void free(long addr); static final int TINY_MULTIPLE; static final int TINY_FREE_LIST_COUNT; static final int HUGE_MULTIPLE; static final int MAX_TINY; }
@Test public void offHeapAlignmentLessThanZeroIsIllegal() { try { FreeListManager.verifyOffHeapAlignment(-1); fail("expected IllegalStateException"); } catch (IllegalStateException expected) { assertThat(expected.getMessage()).contains( GeodeGlossary.GEMFIRE_PREFIX + "OFF_HEAP_ALIGNMENT must be a multiple of 8"); } }
@Test public void offHeapAlignmentNotAMultipleOf8IsIllegal() { try { FreeListManager.verifyOffHeapAlignment(9); fail("expected IllegalStateException"); } catch (IllegalStateException expected) { assertThat(expected.getMessage()).contains( GeodeGlossary.GEMFIRE_PREFIX + "OFF_HEAP_ALIGNMENT must be a multiple of 8"); } }
@Test public void offHeapAlignmentGreaterThan256IsIllegal() { try { FreeListManager.verifyOffHeapAlignment(256 + 8); fail("expected IllegalStateException"); } catch (IllegalStateException expected) { assertThat(expected.getMessage()) .contains(GeodeGlossary.GEMFIRE_PREFIX + "OFF_HEAP_ALIGNMENT must be <= 256"); } }
@Test public void offHeapAlignmentOf256IsLegal() { FreeListManager.verifyOffHeapAlignment(256); }