if (tp != null) { try { maxThreadPoolSize = Integer.parseInt(tp.getMaxThreadPoolSize()); } catch (NumberFormatException ne) {
/** * Process the instance file if this is DAS and there are instances configured already in this domain */ @Override public void postConstruct() { // If this is not the DAS, no need for this pool if(serverEnv.isInstance()) { return; } int poolSize = 5; Config svrConfig = domain.getConfigNamed("server-config"); // I am doing this code instead of a simple svrConfig.getAdminListener() here because embedded tests are failing // during build; got to check the reason why later. if(svrConfig != null) { NetworkConfig nwc = svrConfig.getNetworkConfig(); if (nwc != null) { List<NetworkListener> lss = nwc.getNetworkListeners().getNetworkListener(); if ( (lss != null) && (!lss.isEmpty()) ) { for (NetworkListener ls : lss) { if (ServerTags.ADMIN_LISTENER_ID.equals(ls.getName())) { if(ls.findThreadPool() != null) { poolSize = Integer.parseInt(ls.findThreadPool().getMaxThreadPoolSize()); } } } } } } svc = Executors.newFixedThreadPool(poolSize, new InstanceStateThreadFactory()); }
protected ThreadPoolConfig configureThreadPoolConfig(final NetworkListener networkListener, final ThreadPool threadPool) { 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; }
protected ThreadPoolConfig configureThreadPoolConfig(final NetworkListener networkListener, final ThreadPool threadPool) { 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(obtainDelayedExecutor(), transactionTimeoutMillis, TimeUnit.MILLISECONDS); } return poolConfig; }