glassfish_at_javadesktop.org wrote:
> Well, thanks for your answer they are pretty near to what I need and very well described.
>
> I guess the solution lies somewhere between your two hints.
>
> I absolutely need to get hold of the threads that are used to process the web service request. So the pipeline solution would allow me to create the threads myself which would help but I can't see how to associate these threads with the web service they are used for. On the other hand in the enableRCM way I can identify the service via a part of their URL.
>
> So I need both. Any idea?
Agreed. enableRCM is probably the solution + your own Thread pool. What
you can do is to write your own Grizzly rules used by RCM. I suspect
extending the following classes:
https://glassfish.dev.java.net/source/browse/glassfish/appserv-http-engine/src/java/com/sun/enterprise/web/ara/rules/PathRule.java?rev=1.2.6.2&view=markup
which extends
https://glassfish.dev.java.net/source/browse/glassfish/appserv-http-engine/src/java/com/sun/enterprise/web/ara/rules/ThreadRatioRule.java?rev=1.4&view=markup
(this is where the thread pool allocation happens):
> public Integer call() throws Exception{
> boolean noCache = false;
> if ( leftRatio == 0 ) {
> if ( allocationPolicy.equals(RESERVE) )
> return IsolationRulesExecutor.RULE_BLOCKED;
> else if ( allocationPolicy.equals(CEILING) ) {
>
> // If true, then we need to wait for free space. If false, then
> // we can go ahead and let the task execute with its default
> // pipeline
> if ( isPipelineInUse() )
> return IsolationRulesExecutor.RULE_DELAY;
> else
> noCache = true;
> }
> }
>
> String token = getContextRoot();
>
> // Lazy instanciation
> Pipeline pipeline = pipelines.get(token);
> if ( pipeline == null ){
> pipeline = applyRule(token);
> pipelines.put(token,pipeline);
> }
>
> readTask.setPipeline(pipeline);
> if (!noCache)
> return IsolationRulesExecutor.RULE_OK;
> else
> return IsolationRulesExecutor.RULE_OK_NOCACHE;
> }
So for you case, you just need to extend the call() method to implement
your thread pool allocation strategy. Your extension (lets call it
com.foo.BarRule) can sniff the context-root, get your own customized
Pipeline, and execute it. Something like:
public Integer call() throws Exception{
....
String token = getContextRoot();
// Decide which thread pool to assign to the web-service request.
if (applyWSThreadPool(token)) {
readTask.setPipeline(yourWebServicePipelineImpl);
} else {
// Use the Grizzly default Thread pool
....
}
return IsolationRulesExecutor.RULE_OK;
}
when applyWSThreadPool(..) is where you place your allocation strategy.
Once done, adding your own Rule to Grizzly is simple (kind of). Just jar
it, drop it under ${glassfish.home}/lib/BarRule.jar
and add it domain.xml:
<http-listener.....
<property name="enableRCM" value="true"/>
</http-listener>
...
<jvm-options>-Dcom.sun.enterprise.web.ara.rules=com.foo.BarRule"/>
The later options will tell the Grizzly Rules Engine to execute your
rule on every request, which is what you want.
>
> I'm a bit confused: what is the sense of being able to create thread pools in the admin-gui if I'm not able to control what they are used for???
Those thread pool are for Corba/EJB, not for the WebContainer. Switching
the WebContainer thread pool is not something we officially supported
because you need to implement the Pipeline interface, which is a private
interface.
Anyway several product injects their own thread pool using the Pipeline
API and it works well :-) For GlassFish v3, I will make sure the hidden
properties [1] of Grizzly are exposed in the admin-gui :-) :-)
Hope that help!
-- Jeanfrancois
[1]
http://weblogs.java.net/blog/jfarcand/archive/2007/10/22_unpublished.html
>
> anyway thanks for your help more ideas are welcome
> [Message sent by forum member 'wierob' (wierob)]
>
> http://forums.java.net/jive/thread.jspa?messageID=247997
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>