@Override public Object createManagementObject() { return createJmxManagementObject(); }
/** * Get the size of local thread memory pool. * * @return the size of local thread memory pool. */ public int getReadyThreadBufferSize() { ThreadLocalPool threadLocalPool = getThreadLocalPool(); if (threadLocalPool != null) { return threadLocalPool.remaining(); } return 0; }
@Override public void run() { final int allocSize = 16384; // Initialize memory manager mm.allocate(33); final int initialSize = mm.getReadyThreadBufferSize(); Buffer buffer = mm.allocate(allocSize); assertEquals( initialSize - allocSize, mm.getReadyThreadBufferSize()); buffer.dispose(); assertEquals(initialSize, mm.getReadyThreadBufferSize()); } };
@Override public void run() { final int allocSize = 16384; // Initialize memory manager mm.allocate(33); final int initialSize = mm.getReadyThreadBufferSize(); Buffer buffer = mm.allocate(allocSize); assertEquals( initialSize - allocSize, mm.getReadyThreadBufferSize()); buffer.position(allocSize / 2); buffer.trim(); assertEquals(initialSize - allocSize / 2, mm.getReadyThreadBufferSize()); buffer.dispose(); assertEquals(initialSize, mm.getReadyThreadBufferSize()); buffer = mm.allocate(allocSize / 2); assertEquals(initialSize - allocSize / 2, mm.getReadyThreadBufferSize()); buffer = mm.reallocate(buffer, allocSize); assertEquals(initialSize - allocSize, mm.getReadyThreadBufferSize()); buffer.dispose(); assertEquals(initialSize, mm.getReadyThreadBufferSize()); } };
@ManagedAttribute(id="max-buffer-size") @Description("The max buffer size, which could be associated with a thread") public int getMaxThreadBufferSize() { return ((org.glassfish.grizzly.memory.AbstractMemoryManager) memoryManager).getMaxBufferSize(); } }
public void setupNetwork() throws IOException { validateConfig(config); synchronized (listeners) { AbstractMemoryManager amm = null; for (final NetworkListener listener : config.getNetworkListeners().getNetworkListener()) { final GenericGrizzlyListener grizzlyListener = new GenericGrizzlyListener(); grizzlyListener.configure(habitat, listener); final MemoryManager mm = grizzlyListener.transport.getMemoryManager(); if (mm instanceof AbstractMemoryManager) { amm = (AbstractMemoryManager) mm; } listeners.add(grizzlyListener); final Thread thread = new DefaultWorkerThread(Grizzly.DEFAULT_ATTRIBUTE_BUILDER, grizzlyListener.getName(), amm != null ? amm.createThreadLocalPool() : null, new ListenerRunnable(grizzlyListener)); thread.setDaemon(true); thread.start(); } try { Thread.sleep(1000); // wait for the system to finish setting up the listener } catch (InterruptedException e) { logger.warning(e.getMessage()); throw new RuntimeException(e.getMessage()); } } }
@Test public void testByteOrderRestored() { Buffer b = mm.allocate(1024); if (b instanceof HeapBuffer) { b.order(ByteOrder.LITTLE_ENDIAN); assertEquals(ByteOrder.LITTLE_ENDIAN, b.order()); b.dispose(); assertEquals(ByteOrder.BIG_ENDIAN, b.order()); } }
/** * Get the size of local thread memory pool. * * @return the size of local thread memory pool. */ public int getReadyThreadBufferSize() { ThreadLocalPool threadLocalPool = getThreadLocalPool(); if (threadLocalPool != null) { return threadLocalPool.remaining(); } return 0; }
@Override public void run() { final int allocSize = 16384; // Initialize memory manager mm.allocate(33); final int initialSize = mm.getReadyThreadBufferSize(); Buffer buffer = mm.allocate(allocSize); assertEquals( initialSize - allocSize, mm.getReadyThreadBufferSize()); buffer.position(allocSize / 2); buffer.trim(); assertEquals(initialSize - allocSize / 2, mm.getReadyThreadBufferSize()); buffer.dispose(); assertEquals(initialSize, mm.getReadyThreadBufferSize()); } };
@ManagedAttribute(id="max-buffer-size") @Description("The max buffer size, which could be associated with a thread") public int getMaxThreadBufferSize() { return ((org.glassfish.grizzly.memory.AbstractMemoryManager) memoryManager).getMaxBufferSize(); } }
/** * Get the size of local thread memory pool. * * @return the size of local thread memory pool. */ public int getReadyThreadBufferSize() { ThreadLocalPool threadLocalPool = getThreadLocalPool(); if (threadLocalPool != null) { return threadLocalPool.remaining(); } return 0; }
@Override public Object createManagementObject() { return createJmxManagementObject(); }
mm.allocate(33); final int initialSize = mm.getReadyThreadBufferSize(); Buffer buffer1 = mm.allocate(chunkSize); assertEquals( initialSize - chunkSize, mm.getReadyThreadBufferSize()); Buffer buffer2 = mm.allocate(chunkSize); assertEquals( initialSize - chunkSize * 2, mm.getReadyThreadBufferSize()); Buffer buffer3 = mm.allocate(chunkSize); assertEquals( initialSize - chunkSize * 3, mm.getReadyThreadBufferSize()); Buffer buffer4 = mm.allocate(chunkSize); assertEquals( initialSize - chunkSize * 4, mm.getReadyThreadBufferSize()); mm.getReadyThreadBufferSize()); mm.getReadyThreadBufferSize()); mm.getReadyThreadBufferSize());
/** * Get the size of local thread memory pool. * * @return the size of local thread memory pool. */ public int getReadyThreadBufferSize() { ThreadLocalPool threadLocalPool = getThreadLocalPool(); if (threadLocalPool != null) { return threadLocalPool.remaining(); } return 0; }
@Override public Object createManagementObject() { return createJmxManagementObject(); }
@Override public void run() { // Initialize memory manager mm.allocate(33); final int initialSize = mm.getReadyThreadBufferSize(); CompositeBuffer compositeBuffer = CompositeBuffer.newBuffer(mm); for (int i = 0; i < 3; i++) { Buffer b = mm.allocate(100); b.allowBufferDispose(true); compositeBuffer.append(b); } compositeBuffer.toByteBuffer(0, 100); compositeBuffer.position(100); compositeBuffer.dispose(); assertEquals(initialSize, mm.getReadyThreadBufferSize()); } };
/** * Get the size of local thread memory pool. * * @return the size of local thread memory pool. */ public int getReadyThreadBufferSize() { ThreadLocalPool threadLocalPool = getThreadLocalPool(); if (threadLocalPool != null) { return threadLocalPool.remaining(); } return 0; }
@Override public Object createManagementObject() { return createJmxManagementObject(); }
mm.allocate(33); final int initialSize = mm.getReadyThreadBufferSize(); Buffer buffer1 = mm.allocate(chunkSize); assertEquals( initialSize - chunkSize, mm.getReadyThreadBufferSize()); assertEquals( initialSize - chunkSize / 2, mm.getReadyThreadBufferSize()); Buffer buffer2 = mm.allocate(chunkSize); assertEquals( initialSize - (chunkSize + chunkSize / 2), mm.getReadyThreadBufferSize()); assertEquals( initialSize - chunkSize, mm.getReadyThreadBufferSize()); mm.getReadyThreadBufferSize()); mm.getReadyThreadBufferSize());
/** * Get the size of local thread memory pool. * * @return the size of local thread memory pool. */ public int getReadyThreadBufferSize() { ThreadLocalPool threadLocalPool = getThreadLocalPool(); if (threadLocalPool != null) { return threadLocalPool.remaining(); } return 0; }