Search in sources :

Example 1 with TCPNIOTransport

use of org.glassfish.grizzly.nio.transport.TCPNIOTransport in project jersey by jersey.

the class JerseyGrizzlyRunner method main.

public static void main(String[] args) throws Exception {
    System.out.println("Jersey performance test web service application");
    final String jaxRsApp = args.length > 0 ? args[0] : null;
    //noinspection unchecked
    final ResourceConfig resourceConfig = ResourceConfig.forApplicationClass((Class<? extends Application>) Class.forName(jaxRsApp));
    URI baseUri = args.length > 1 ? URI.create(args[1]) : BASE_URI;
    int selectors = args.length > 2 ? Integer.parseInt(args[2]) : DEFAULT_SELECTORS;
    int workers = args.length > 3 ? Integer.parseInt(args[3]) : DEFAULT_WORKERS;
    final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig, false);
    final TCPNIOTransport transport = server.getListener("grizzly").getTransport();
    transport.setSelectorRunnersCount(selectors);
    transport.setWorkerThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(workers).setMaxPoolSize(workers));
    server.start();
    System.out.println(String.format("Application started.\nTry out %s\nHit Ctrl-C to stop it...", baseUri));
    while (server.isStarted()) {
        Thread.sleep(600000);
    }
}
Also used : TCPNIOTransport(org.glassfish.grizzly.nio.transport.TCPNIOTransport) HttpServer(org.glassfish.grizzly.http.server.HttpServer) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) URI(java.net.URI)

Example 2 with TCPNIOTransport

use of org.glassfish.grizzly.nio.transport.TCPNIOTransport in project Payara by payara.

the class GenericGrizzlyListener method configureTCPTransport.

protected NIOTransport configureTCPTransport(final Transport transportConfig) {
    final TCPNIOTransport tcpTransport = configureDefaultThreadPoolConfigs(TCPNIOTransportBuilder.newInstance().build());
    tcpTransport.setTcpNoDelay(Boolean.parseBoolean(transportConfig.getTcpNoDelay()));
    tcpTransport.setLinger(Integer.parseInt(transportConfig.getLinger()));
    tcpTransport.setWriteTimeout(Long.parseLong(transportConfig.getWriteTimeoutMillis()), TimeUnit.MILLISECONDS);
    tcpTransport.setReadTimeout(Long.parseLong(transportConfig.getReadTimeoutMillis()), TimeUnit.MILLISECONDS);
    tcpTransport.setServerConnectionBackLog(Integer.parseInt(transportConfig.getMaxConnectionsCount()));
    return tcpTransport;
}
Also used : TCPNIOTransport(org.glassfish.grizzly.nio.transport.TCPNIOTransport)

Aggregations

TCPNIOTransport (org.glassfish.grizzly.nio.transport.TCPNIOTransport)2 URI (java.net.URI)1 HttpServer (org.glassfish.grizzly.http.server.HttpServer)1 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)1