dev@glassfish.java.net

Re: [REVIEW] thread-pool move

From: Jerome Dochez <Jerome.Dochez_at_Sun.COM>
Date: Mon, 27 Apr 2009 22:50:32 -0700

looks good to me.
just one question, why does the max threadpool size goes from 20 to 2 ?

jerome

On Apr 27, 2009, at 5:33 PM, Justin Lee wrote:

> Attached is the diff for moving thread-pool back under config/thread-
> pools.
> Index: ../packager/nucleus-base/domains/domain1/config/domain.xml
> ===================================================================
> --- ../packager/nucleus-base/domains/domain1/config/domain.xml
> (revision 26651)
> +++ ../packager/nucleus-base/domains/domain1/config/domain.xml Mon
> Apr 27 20:04:01 EDT 2009
> @@ -168,7 +168,7 @@
> </protocol>
> </protocols>
> <network-listeners>
> - <thread-pool max-thread-pool-size="20" min-thread-pool-
> size="2" thread-pool-id="http-thread-pool" max-queue-size="4096"></
> thread-pool>
> + <thread-pool min-thread-pool-size="2" thread-pool-
> id="http-thread-pool" max-queue-size="4096"></thread-pool>
> <thread-pool thread-pool-id="thread-pool-1"></thread-pool>
> <network-listener port="8080" protocol="http-listener-1"
> transport="tcp" name="http-listener-1" thread-pool="http-thread-
> pool"></network-listener>
> <network-listener port="8181" enabled="false"
> protocol="http-listener-2" transport="tcp" name="http-listener-2"
> thread-pool="http-thread-pool"></network-listener>
> @@ -178,6 +178,10 @@
> <transport name="tcp"></transport>
> </transports>
> </network-config>
> + <thread-pools>
> + <thread-pool min-thread-pool-size="2" thread-pool-
> id="http-thread-pool" max-queue-size="4096"></thread-pool>
> + <thread-pool thread-pool-id="thread-pool-1"/>
> + </thread-pools>
> </config>
> </configs>
> <property name="administrative.domain.name" value="domain1"></
> property>
> Index: ../web/admin/src/main/java/org/glassfish/web/admin/cli/
> CreateHttpListener.java
> ===================================================================
> --- ../web/admin/src/main/java/org/glassfish/web/admin/cli/
> CreateHttpListener.java (revision 26651)
> +++ ../web/admin/src/main/java/org/glassfish/web/admin/cli/
> CreateHttpListener.java Thu Apr 23 23:10:22 EDT 2009
> @@ -236,7 +236,7 @@
> }
>
> private void setThreadPool(NetworkConfig config, NetworkListener
> newListener) {
> - final List<ThreadPool> pools =
> config.getNetworkListeners().getThreadPool();
> + final List<ThreadPool> pools =
> config.getParent(Config.class).getThreadPools().getThreadPool();
> for (ThreadPool pool : pools) {
> if ("http-thread-pool".equals(pool.getThreadPoolId())) {
> newListener.setThreadPool(pool.getThreadPoolId());
> Index: ../admin/config-api/src/main/java/org/glassfish/config/
> support/GrizzlyConfigSchemaMigrator.java
> ===================================================================
> --- ../admin/config-api/src/main/java/org/glassfish/config/support/
> GrizzlyConfigSchemaMigrator.java (revision 26651)
> +++ ../admin/config-api/src/main/java/org/glassfish/config/support/
> GrizzlyConfigSchemaMigrator.java Fri Apr 24 00:06:03 EDT 2009
> @@ -50,7 +50,8 @@
>
> public void postConstruct() {
> try {
> - if (!
> domain
> .getConfigs
> ().getConfig().get(0).getHttpService().getHttpListener().isEmpty()) {
> + final Config config =
> domain.getConfigs().getConfig().get(0);
> + if (!
> config.getHttpService().getHttpListener().isEmpty()) {
> ConfigSupport.apply(new SingleConfigCode<Domain>() {
> public Object run(Domain param) throws
> TransactionFailure {
> migrateSettings(param);
> @@ -58,35 +59,49 @@
> }
> }, domain);
> }
> - if
> (domain.getConfigs().getConfig().get(0).getThreadPools() != null) {
> + if
> (config.getNetworkConfig().getNetworkListeners().getThreadPool() !=
> null) {
> + ThreadPools threadPools = config.getThreadPools();
> + if (threadPools == null) {
> + threadPools = createThreadPools();
> + }
> ConfigSupport.apply(new
> SingleConfigCode<ThreadPools>() {
> public Object run(ThreadPools param) throws
> TransactionFailure {
> migrateThreadPools(param);
> return null;
> }
> - },
> domain.getConfigs().getConfig().get(0).getThreadPools());
> + }, threadPools);
> }
> } catch (TransactionFailure tf) {
> Logger.getAnonymousLogger().log(Level.SEVERE, "Failure
> while upgrading application grizzly related items."
> + " Please redeploy", tf);
> throw new RuntimeException(tf);
> + } catch (PropertyVetoException e) {
> + Logger.getAnonymousLogger().log(Level.SEVERE, "Failure
> while upgrading application grizzly related items."
> + + " Please redeploy", e);
> + throw new RuntimeException(e);
> }
> }
>
> private void migrateThreadPools(final ThreadPools threadPools)
> throws TransactionFailure {
> + final Config config = threadPools.getParent(Config.class);
> + final NetworkListeners networkListeners =
> config.getNetworkConfig().getNetworkListeners();
> +
> threadPools.getThreadPool().addAll(networkListeners.getThreadPool());
> +
> ConfigSupport.apply(new SingleConfigCode<NetworkListeners>() {
> - @Override
> - public Object run(NetworkListeners param) {
> -
> param.getThreadPool().addAll(threadPools.getThreadPool());
> + public Object run(NetworkListeners param) throws
> PropertyVetoException {
> + param.getThreadPool().clear();
> return null;
> }
> - },
> threadPools
> .getParent(Config.class).getNetworkConfig().getNetworkListeners());
> - threadPools.getThreadPool().clear();
> - ConfigSupport.apply(new SingleConfigCode<Config>() {
> - public Object run(Config param) throws
> PropertyVetoException {
> - param.setThreadPools(null);
> - return null;
> + }, networkListeners);
> - }
> + }
> +
> + private ThreadPools createThreadPools() throws
> TransactionFailure, PropertyVetoException {
> + return (ThreadPools) ConfigSupport.apply(new
> SingleConfigCode<Config>() {
> + public Object run(Config param) throws
> PropertyVetoException, TransactionFailure {
> + final ThreadPools threadPools =
> param.createChild(ThreadPools.class);
> + param.setThreadPools(threadPools);
> + return threadPools;
> + }
> }, domain.getConfigs().getConfig().get(0));
> }
>
> Index: ../packager/nucleus-base/lib/templates/domain.xml
> ===================================================================
> --- ../packager/nucleus-base/lib/templates/domain.xml (revision 26651)
> +++ ../packager/nucleus-base/lib/templates/domain.xml Mon Apr 27
> 20:04:01 EDT 2009
> @@ -170,8 +170,6 @@
> </protocol>
> </protocols>
> <network-listeners>
> - <thread-pool max-thread-pool-size="20" min-thread-pool-
> size="2" thread-pool-id="http-thread-pool" max-queue-size="4096"></
> thread-pool>
> - <thread-pool thread-pool-id="thread-pool-1"/>
> <network-listener port="%%%HTTP_PORT%%%" protocol="http-
> listener-1" transport="tcp" name="http-listener-1" thread-pool="http-
> thread-pool"></network-listener>
> <network-listener port="%%%HTTP_SSL_PORT%%%"
> enabled="false" protocol="http-listener-2" transport="tcp"
> name="http-listener-2" thread-pool="http-thread-pool"></network-
> listener>
> <network-listener port="%%%ADMIN_PORT%%%" protocol="admin-
> listener" transport="tcp" name="admin-listener" thread-pool="http-
> thread-pool"></network-listener>
> @@ -180,6 +178,10 @@
> <transport name="tcp"></transport>
> </transports>
> </network-config>
> + <thread-pools>
> + <thread-pool min-thread-pool-size="2" thread-pool-
> id="http-thread-pool" max-queue-size="4096"></thread-pool>
> + <thread-pool thread-pool-id="thread-pool-1"/>
> + </thread-pools>
> </config>
> </configs>
> <property name="administrative.domain.name" value="%%%DOMAIN_NAME%%
> %"/>
> Index: ../admin/config-api/src/main/java/com/sun/enterprise/config/
> serverbeans/ThreadPools.java
> ===================================================================
> --- ../admin/config-api/src/main/java/com/sun/enterprise/config/
> serverbeans/ThreadPools.java (revision 26651)
> +++ ../admin/config-api/src/main/java/com/sun/enterprise/config/
> serverbeans/ThreadPools.java Thu Apr 23 23:08:04 EDT 2009
> @@ -50,7 +50,6 @@
> // general solution needed; this is intermediate solution
> @AMXCreatorInfo(creatables = {ThreadPool.class})
> @Configured
> -_at_Deprecated
> public interface ThreadPools extends ConfigBeanProxy, Injectable {
> /**
> * Gets the value of the threadPool property. <p/> <p/> This
> accessor method returns a reference to the live list,
> Index: ../orb/orb-iiop/src/main/java/org/glassfish/enterprise/iiop/
> impl/IIOPUtils.java
> ===================================================================
> --- ../orb/orb-iiop/src/main/java/org/glassfish/enterprise/iiop/impl/
> IIOPUtils.java (revision 26651)
> +++ ../orb/orb-iiop/src/main/java/org/glassfish/enterprise/iiop/impl/
> IIOPUtils.java Mon Apr 27 18:16:11 EDT 2009
> @@ -10,6 +10,7 @@
> import com.sun.enterprise.config.serverbeans.IiopListener;
> import com.sun.enterprise.config.serverbeans.IiopService;
> import com.sun.enterprise.config.serverbeans.ServerRef;
> +import com.sun.enterprise.config.serverbeans.ThreadPools;
> import com.sun.grizzly.config.dom.NetworkListener;
> import com.sun.grizzly.config.dom.NetworkListeners;
> import com.sun.grizzly.config.dom.ThreadPool;
> @@ -64,7 +65,7 @@
> if( processEnv.getProcessType() == ProcessType.Server) {
>
> iiopService = habitat.getComponent(IiopService.class);
> - final List<ThreadPool> threadPool =
> habitat.getComponent(NetworkListeners.class).getThreadPool();
> + final Collection<ThreadPool> threadPool =
> habitat.getAllByType(ThreadPool.class);
> final Collection<NetworkListener> listeners =
> habitat.getAllByType(NetworkListener.class);
> final Set<String> names = new TreeSet<String>();
> threadPools = new ArrayList<ThreadPool>();
> Index: ../pom.xml
> ===================================================================
> --- ../pom.xml (revision 26651)
> +++ ../pom.xml Mon Apr 27 17:23:35 EDT 2009
> @@ -110,7 +110,7 @@
> <deployment-api.version>1.2-rev-1</deployment-api.version>
> <jaxrpc-api.version>1.1</jaxrpc-api.version>
> <grizzly.version>1.9.14</grizzly.version>
> - <grizzly-config.version>1.0.1</grizzly-config.version>
> + <grizzly-config.version>1.0.2</grizzly-config.version>
> <jaxb-api.version>2.1</jaxb-api.version>
> <jaxws-api.version>2.1</jaxws-api.version>
> <jsr250-api.version>1.0</jsr250-api.version>
> Index: ../admin/config-api/src/main/java/com/sun/enterprise/config/
> serverbeans/Config.java
> ===================================================================
> --- ../admin/config-api/src/main/java/com/sun/enterprise/config/
> serverbeans/Config.java (revision 26651)
> +++ ../admin/config-api/src/main/java/com/sun/enterprise/config/
> serverbeans/Config.java Thu Apr 23 23:10:22 EDT 2009
> @@ -403,7 +403,6 @@
> * {_at_link ThreadPools }
> */
> @Element(required=true)
> - @Deprecated
> ThreadPools getThreadPools();
>
> /**
> @@ -412,7 +411,6 @@
> * @param value allowed object is
> * {_at_link ThreadPools }
> */
> - @Deprecated
> void setThreadPools(ThreadPools value) throws
> PropertyVetoException;
>
> /**
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net