Search in sources :

Example 1 with MemoryManager

use of org.glassfish.grizzly.memory.MemoryManager in project Payara by payara.

the class GrizzlyConfigTest method testDirectBufferConfiguration.

@Test
public void testDirectBufferConfiguration() throws Exception {
    GrizzlyConfig grizzlyConfig = null;
    try {
        configure();
        grizzlyConfig = new GrizzlyConfig("grizzly-direct-buffer.xml");
        grizzlyConfig.setupNetwork();
        final String bufferType = grizzlyConfig.getConfig().getNetworkListeners().getNetworkListener().get(0).findTransport().getByteBufferType();
        Assert.assertEquals("direct", bufferType);
        GenericGrizzlyListener genericGrizzlyListener = (GenericGrizzlyListener) getListener(grizzlyConfig, "http-listener-1");
        MemoryManager mm = genericGrizzlyListener.getTransport().getMemoryManager();
        assertEquals(ByteBufferManager.class.getName(), mm.getClass().getName());
        assertTrue(((ByteBufferManager) mm).isDirect());
    } finally {
        if (grizzlyConfig != null) {
            grizzlyConfig.shutdownNetwork();
            grizzlyConfig.shutdown();
        }
    }
}
Also used : MemoryManager(org.glassfish.grizzly.memory.MemoryManager) HeapMemoryManager(org.glassfish.grizzly.memory.HeapMemoryManager) ByteBufferManager(org.glassfish.grizzly.memory.ByteBufferManager) Test(org.junit.Test)

Example 2 with MemoryManager

use of org.glassfish.grizzly.memory.MemoryManager in project Payara by payara.

the class XProtocolFilter method handleRead.

@Override
public NextAction handleRead(final FilterChainContext ctx) throws IOException {
    final Connection connection = ctx.getConnection();
    final MemoryManager memoryManager = connection.getTransport().getMemoryManager();
    ctx.write(Buffers.wrap(memoryManager, "X-Protocol-Response", CHARSET));
    ctx.flush(new EmptyCompletionHandler() {

        @Override
        public void completed(Object result) {
            connection.closeSilently();
        }
    });
    return ctx.getStopAction();
}
Also used : Connection(org.glassfish.grizzly.Connection) EmptyCompletionHandler(org.glassfish.grizzly.EmptyCompletionHandler) MemoryManager(org.glassfish.grizzly.memory.MemoryManager)

Example 3 with MemoryManager

use of org.glassfish.grizzly.memory.MemoryManager in project Payara by payara.

the class GrizzlyConfigTest method testDefaultBufferConfiguration.

@Test
public void testDefaultBufferConfiguration() throws Exception {
    GrizzlyConfig grizzlyConfig = null;
    try {
        configure();
        grizzlyConfig = new GrizzlyConfig("grizzly-config.xml");
        grizzlyConfig.setupNetwork();
        final String bufferType = grizzlyConfig.getConfig().getNetworkListeners().getNetworkListener().get(0).findTransport().getByteBufferType();
        Assert.assertEquals("heap", bufferType);
        GenericGrizzlyListener genericGrizzlyListener = (GenericGrizzlyListener) getListener(grizzlyConfig, "http-listener-1");
        MemoryManager mm = genericGrizzlyListener.getTransport().getMemoryManager();
        assertEquals(HeapMemoryManager.class.getName(), mm.getClass().getName());
    } finally {
        if (grizzlyConfig != null) {
            grizzlyConfig.shutdownNetwork();
            grizzlyConfig.shutdown();
        }
    }
}
Also used : MemoryManager(org.glassfish.grizzly.memory.MemoryManager) HeapMemoryManager(org.glassfish.grizzly.memory.HeapMemoryManager) HeapMemoryManager(org.glassfish.grizzly.memory.HeapMemoryManager) Test(org.junit.Test)

Aggregations

MemoryManager (org.glassfish.grizzly.memory.MemoryManager)3 HeapMemoryManager (org.glassfish.grizzly.memory.HeapMemoryManager)2 Test (org.junit.Test)2 Connection (org.glassfish.grizzly.Connection)1 EmptyCompletionHandler (org.glassfish.grizzly.EmptyCompletionHandler)1 ByteBufferManager (org.glassfish.grizzly.memory.ByteBufferManager)1