Search in sources :

Example 1 with FilterChainBuilder

use of org.glassfish.grizzly.filterchain.FilterChainBuilder in project dubbo by alibaba.

the class GrizzlyClient method doOpen.

@Override
protected void doOpen() throws Throwable {
    FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
    filterChainBuilder.add(new TransportFilter());
    filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
    filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
    TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
    ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
    config.setPoolName(CLIENT_THREAD_POOL_NAME).setQueueLimit(-1).setCorePoolSize(0).setMaxPoolSize(Integer.MAX_VALUE).setKeepAliveTime(60L, TimeUnit.SECONDS);
    builder.setTcpNoDelay(true).setKeepAlive(true).setConnectionTimeout(getTimeout()).setIOStrategy(SameThreadIOStrategy.getInstance());
    transport = builder.build();
    transport.setProcessor(filterChainBuilder.build());
    transport.start();
}
Also used : TCPNIOTransportBuilder(org.glassfish.grizzly.nio.transport.TCPNIOTransportBuilder) ThreadPoolConfig(org.glassfish.grizzly.threadpool.ThreadPoolConfig) FilterChainBuilder(org.glassfish.grizzly.filterchain.FilterChainBuilder) TransportFilter(org.glassfish.grizzly.filterchain.TransportFilter)

Example 2 with FilterChainBuilder

use of org.glassfish.grizzly.filterchain.FilterChainBuilder in project dubbo by alibaba.

the class GrizzlyServer method doOpen.

@Override
protected void doOpen() throws Throwable {
    FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
    filterChainBuilder.add(new TransportFilter());
    filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
    filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
    TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
    ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
    config.setPoolName(SERVER_THREAD_POOL_NAME).setQueueLimit(-1);
    String threadpool = getUrl().getParameter(Constants.THREADPOOL_KEY, Constants.DEFAULT_THREADPOOL);
    if (Constants.DEFAULT_THREADPOOL.equals(threadpool)) {
        int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
        config.setCorePoolSize(threads).setMaxPoolSize(threads).setKeepAliveTime(0L, TimeUnit.SECONDS);
    } else if ("cached".equals(threadpool)) {
        int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Integer.MAX_VALUE);
        config.setCorePoolSize(0).setMaxPoolSize(threads).setKeepAliveTime(60L, TimeUnit.SECONDS);
    } else {
        throw new IllegalArgumentException("Unsupported threadpool type " + threadpool);
    }
    builder.setKeepAlive(true).setReuseAddress(false).setIOStrategy(SameThreadIOStrategy.getInstance());
    transport = builder.build();
    transport.setProcessor(filterChainBuilder.build());
    transport.bind(getBindAddress());
    transport.start();
}
Also used : TCPNIOTransportBuilder(org.glassfish.grizzly.nio.transport.TCPNIOTransportBuilder) ThreadPoolConfig(org.glassfish.grizzly.threadpool.ThreadPoolConfig) FilterChainBuilder(org.glassfish.grizzly.filterchain.FilterChainBuilder) TransportFilter(org.glassfish.grizzly.filterchain.TransportFilter)

Example 3 with FilterChainBuilder

use of org.glassfish.grizzly.filterchain.FilterChainBuilder in project dubbo by alibaba.

the class GrizzlyClient method doOpen.

@Override
protected void doOpen() throws Throwable {
    FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
    filterChainBuilder.add(new TransportFilter());
    filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
    filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
    TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
    ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
    config.setPoolName(CLIENT_THREAD_POOL_NAME).setQueueLimit(-1).setCorePoolSize(0).setMaxPoolSize(Integer.MAX_VALUE).setKeepAliveTime(60L, TimeUnit.SECONDS);
    builder.setTcpNoDelay(true).setKeepAlive(true).setConnectionTimeout(getConnectTimeout()).setIOStrategy(SameThreadIOStrategy.getInstance());
    transport = builder.build();
    transport.setProcessor(filterChainBuilder.build());
    transport.start();
}
Also used : TCPNIOTransportBuilder(org.glassfish.grizzly.nio.transport.TCPNIOTransportBuilder) ThreadPoolConfig(org.glassfish.grizzly.threadpool.ThreadPoolConfig) FilterChainBuilder(org.glassfish.grizzly.filterchain.FilterChainBuilder) TransportFilter(org.glassfish.grizzly.filterchain.TransportFilter)

Example 4 with FilterChainBuilder

use of org.glassfish.grizzly.filterchain.FilterChainBuilder in project dubbo by alibaba.

the class GrizzlyServer method doOpen.

@Override
protected void doOpen() throws Throwable {
    FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
    filterChainBuilder.add(new TransportFilter());
    filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
    filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
    TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
    ThreadPoolConfig config = ThreadPoolConfig.defaultConfig();
    config.setPoolName(SERVER_THREAD_POOL_NAME).setQueueLimit(-1);
    String threadpool = getUrl().getParameter(THREADPOOL_KEY, DEFAULT_THREADPOOL);
    if (DEFAULT_THREADPOOL.equals(threadpool)) {
        int threads = getUrl().getPositiveParameter(THREADS_KEY, DEFAULT_THREADS);
        config.setCorePoolSize(threads).setMaxPoolSize(threads).setKeepAliveTime(0L, TimeUnit.SECONDS);
    } else if ("cached".equals(threadpool)) {
        int threads = getUrl().getPositiveParameter(THREADS_KEY, Integer.MAX_VALUE);
        config.setCorePoolSize(0).setMaxPoolSize(threads).setKeepAliveTime(60L, TimeUnit.SECONDS);
    } else {
        throw new IllegalArgumentException("Unsupported threadpool type " + threadpool);
    }
    builder.setWorkerThreadPoolConfig(config).setKeepAlive(true).setReuseAddress(false).setIOStrategy(SameThreadIOStrategy.getInstance());
    transport = builder.build();
    transport.setProcessor(filterChainBuilder.build());
    transport.bind(getBindAddress());
    transport.start();
}
Also used : TCPNIOTransportBuilder(org.glassfish.grizzly.nio.transport.TCPNIOTransportBuilder) ThreadPoolConfig(org.glassfish.grizzly.threadpool.ThreadPoolConfig) FilterChainBuilder(org.glassfish.grizzly.filterchain.FilterChainBuilder) TransportFilter(org.glassfish.grizzly.filterchain.TransportFilter)

Example 5 with FilterChainBuilder

use of org.glassfish.grizzly.filterchain.FilterChainBuilder in project Payara by payara.

the class GenericGrizzlyListener method configure.

/*
     * Configures the given grizzlyListener.
     *
     * @param networkListener The NetworkListener to configure
     */
// TODO: Must get the information from domain.xml Config objects.
// TODO: Pending Grizzly issue 54
@Override
public void configure(final ServiceLocator habitat, final NetworkListener networkListener) throws IOException {
    setName(networkListener.getName());
    setAddress(InetAddress.getByName(networkListener.getAddress()));
    setPort(Integer.parseInt(networkListener.getPort()));
    if (networkListener.getPortRange() != null) {
        setPortRange(PortRange.valueOf(networkListener.getPortRange()));
    }
    final FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
    configureTransport(networkListener, networkListener.findTransport(), filterChainBuilder);
    bindTransport();
    configureProtocol(habitat, networkListener, networkListener.findProtocol(), filterChainBuilder);
    configureThreadPool(habitat, networkListener, networkListener.findThreadPool());
    rootFilterChain = filterChainBuilder.build();
    transport.setProcessor(rootFilterChain);
}
Also used : FilterChainBuilder(org.glassfish.grizzly.filterchain.FilterChainBuilder)

Aggregations

FilterChainBuilder (org.glassfish.grizzly.filterchain.FilterChainBuilder)6 TransportFilter (org.glassfish.grizzly.filterchain.TransportFilter)5 TCPNIOTransportBuilder (org.glassfish.grizzly.nio.transport.TCPNIOTransportBuilder)4 ThreadPoolConfig (org.glassfish.grizzly.threadpool.ThreadPoolConfig)4 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Http (org.glassfish.grizzly.config.dom.Http)1 PortUnification (org.glassfish.grizzly.config.dom.PortUnification)1 Protocol (org.glassfish.grizzly.config.dom.Protocol)1 ProtocolChain (org.glassfish.grizzly.config.dom.ProtocolChain)1 ProtocolChainInstanceHandler (org.glassfish.grizzly.config.dom.ProtocolChainInstanceHandler)1 ProtocolFilter (org.glassfish.grizzly.config.dom.ProtocolFilter)1 HttpRedirectFilter (org.glassfish.grizzly.config.portunif.HttpRedirectFilter)1 Filter (org.glassfish.grizzly.filterchain.Filter)1 CompressionEncodingFilter (org.glassfish.grizzly.http.server.CompressionEncodingFilter)1 FileCacheFilter (org.glassfish.grizzly.http.server.FileCacheFilter)1 HttpServerFilter (org.glassfish.grizzly.http.server.HttpServerFilter)1 PUFilter (org.glassfish.grizzly.portunif.PUFilter)1 PUProtocol (org.glassfish.grizzly.portunif.PUProtocol)1