Package org.glassfish.grizzly.threadpool

Examples of org.glassfish.grizzly.threadpool.ThreadPoolConfig


            filterChainBuilder.add(new RexProClientFilter());
            filterChainBuilder.add(handler);

            transport = TCPNIOTransportBuilder.newInstance().build();
            transport.setIOStrategy(LeaderFollowerNIOStrategy.getInstance());
            final ThreadPoolConfig workerThreadPoolConfig = ThreadPoolConfig.defaultConfig()
                    .setCorePoolSize(4)
                    .setMaxPoolSize(12);
            transport.setWorkerThreadPoolConfig(workerThreadPoolConfig);
            final ThreadPoolConfig kernalThreadPoolConfig = ThreadPoolConfig.defaultConfig()
                    .setCorePoolSize(4)
                    .setMaxPoolSize(12);
            transport.setKernelThreadPoolConfig(kernalThreadPoolConfig);
            transport.setProcessor(filterChainBuilder.build());
            transport.start();
View Full Code Here


        if (this.lastTransportReadBuffer != transportReadBuffer)
            this.tcpTransport.setReadBufferSize(this.transportReadBuffer);

        if (hasThreadPoolSizeChanged()) {
            final ThreadPoolConfig workerThreadPoolConfig = ThreadPoolConfig.defaultConfig()
                    .setCorePoolSize(coreWorkerThreadPoolSize)
                    .setMaxPoolSize(maxWorkerThreadPoolSize);
            tcpTransport.setWorkerThreadPoolConfig(workerThreadPoolConfig);
            final ThreadPoolConfig kernalThreadPoolConfig = ThreadPoolConfig.defaultConfig()
                    .setCorePoolSize(coreKernalThreadPoolSize)
                    .setMaxPoolSize(maxKernalThreadPoolSize);
            tcpTransport.setKernelThreadPoolConfig(kernalThreadPoolConfig);

            // if the threadpool is initialized then call reconfigure to reset the threadpool
View Full Code Here

            logger.info(String.format("RexPro Server bound to [%s:%s]", rexsterServerHost, rexsterServerPort));
        }

        if (hasThreadPoolSizeChanged()) {
            final ThreadPoolConfig workerThreadPoolConfig = ThreadPoolConfig.defaultConfig()
                    .setCorePoolSize(coreWorkerThreadPoolSize)
                    .setMaxPoolSize(maxWorkerThreadPoolSize);
            listener.getTransport().setWorkerThreadPoolConfig(workerThreadPoolConfig);
            final ThreadPoolConfig kernalThreadPoolConfig = ThreadPoolConfig.defaultConfig()
                    .setCorePoolSize(coreKernalThreadPoolSize)
                    .setMaxPoolSize(maxKernalThreadPoolSize);
            listener.getTransport().setKernelThreadPoolConfig(kernalThreadPoolConfig);

            if (listener.getTransport().getKernelThreadPool() != null) {
View Full Code Here

        final int maxQueueSize = threadPool.getMaxQueueSize() == null ? Integer.MAX_VALUE
            : Integer.parseInt(threadPool.getMaxQueueSize());
        final int minThreads = Integer.parseInt(threadPool.getMinThreadPoolSize());
        final int maxThreads = Integer.parseInt(threadPool.getMaxThreadPoolSize());
        final int timeout = Integer.parseInt(threadPool.getIdleThreadTimeoutSeconds());
        final ThreadPoolConfig poolConfig = ThreadPoolConfig.defaultConfig();
        poolConfig.setPoolName(networkListener.getName());
        poolConfig.setCorePoolSize(minThreads);
        poolConfig.setMaxPoolSize(maxThreads);
        poolConfig.setQueueLimit(maxQueueSize);

        // we specify the classloader that loaded this class to ensure
        // we present the same initial classloader no matter what mode
        // GlassFish is being run in.
        // See http://java.net/jira/browse/GLASSFISH-19639
        poolConfig.setInitialClassLoader(this.getClass().getClassLoader());

        poolConfig.setKeepAliveTime(timeout < 0 ? Long.MAX_VALUE : timeout, TimeUnit.SECONDS);
        if (transactionTimeoutMillis > 0 && !Utils.isDebugVM()) {
            poolConfig.setTransactionTimeout(delayedExecutor,
                    transactionTimeoutMillis, TimeUnit.MILLISECONDS);
        }
       
        return poolConfig;
    }
View Full Code Here

    @Override
    protected ThreadPoolConfig configureThreadPoolConfig(final NetworkListener networkListener,
                                                         final ThreadPool threadPool) {
       
        final ThreadPoolConfig config = super.configureThreadPoolConfig(
                networkListener, threadPool);
        config.getInitialMonitoringConfig().addProbes(new ThreadPoolMonitor(
                grizzlyService.getMonitoring(), name, config));
        return config;
    }
View Full Code Here

        SSLContextConfigurator sslConfig = new SSLContextConfigurator();
        sslConfig.setKeyStoreFile("/var/otp/keystore");
        sslConfig.setKeyStorePass("opentrip");

        /* OTP is CPU-bound, so we want only as many worker threads as we have cores. */
        ThreadPoolConfig threadPoolConfig = ThreadPoolConfig.defaultConfig()
            .setCorePoolSize(1)
            .setMaxPoolSize(Runtime.getRuntime().availableProcessors());

        /* HTTP (non-encrypted) listener */
        NetworkListener httpListener = new NetworkListener("otp_insecure", params.bindAddress, params.port);
View Full Code Here

    @Override
    protected ThreadPoolConfig configureThreadPoolConfig(final NetworkListener networkListener,
                                                         final ThreadPool threadPool) {
       
        final ThreadPoolConfig config = super.configureThreadPoolConfig(
                networkListener, threadPool);
        config.getInitialMonitoringConfig().addProbes(new ThreadPoolMonitor(
                grizzlyService.getMonitoring(), name, config));
        return config;
    }
View Full Code Here

        filterChainBuilder.add(new TransportFilter());
       
        filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getDownstreamCodec(), 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)
View Full Code Here

        NIOTransport transport = create();
        transport.setIOStrategy(ioStrategy);
        if (workerConfig != null) {
            transport.setWorkerThreadPoolConfig(workerConfig);
        }
        ThreadPoolConfig kernelLocal = kernelConfig;
        if (kernelLocal != null) {
            transport.setKernelThreadPoolConfig(kernelLocal);
        } else {
            kernelLocal = ThreadPoolConfig.defaultConfig();
            transport.setKernelThreadPoolConfig(kernelLocal);
View Full Code Here

            chain = builder.build();
            listener.setFilterChain(chain);

            final int transactionTimeout = listener.getTransactionTimeout();
            if (transactionTimeout >= 0) {
                ThreadPoolConfig threadPoolConfig = transport.getWorkerThreadPoolConfig();

                if (threadPoolConfig != null) {
                    threadPoolConfig.setTransactionTimeout(
                            delayedExecutor,
                            transactionTimeout,
                            TimeUnit.SECONDS);
                }
View Full Code Here

TOP

Related Classes of org.glassfish.grizzly.threadpool.ThreadPoolConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.