dev@grizzly.java.net

Re: About Grizzly's RCM

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Fri, 17 Jul 2009 10:29:42 -0400

Salut,

Bongjae Chang wrote:
> Hi,
>
> Today, I tried to review and test the ResourceAllocationFilter.

Great!

>
> But, I have some questions about ResourceAllocationFilter.
>
>
> 1. ResourceAllocationFilter#getContextRoot()'s return value
>
> If a client sends "GET /examples/index.html HTTP/1.1" request to the
> grizzly server, getContextRoot() returns "examples/index.html".
>
> But, I think that ResourceAllocationFilter#getContextRoot() should
> return "/examples/index.html" because a user's policyMetric is like
> "/myApplication|0.9".

Agree


>
> Is it right?
>
> If my thoughts are correct, here is the proposed patch.
>
> Index: com/sun/grizzly/rcm/ResourceAllocationFilter.java
> ===================================================================
> --- com/sun/grizzly/rcm/ResourceAllocationFilter.java (revision 3411)
> +++ com/sun/grizzly/rcm/ResourceAllocationFilter.java (working copy)
> @@ -466,7 +466,7 @@
> case 0: // Search for first ' '
> if (c == 0x20){
> state = 1;
> - start = byteBuffer.position() + 1;
> + start = byteBuffer.position();
> }
> break;
> case 1: // Search for next ' '
>

This is strange as it looks for ' ', which is why start needs to be
bumped by 1 so we start at /. Not sure we should remove the +1 unless
I'm missing something.

>
>
> 2. ResourceAllocationFilter#invokeProtocolParser()'s strange code?
>
> Here is ResourceAllocationFilter#invokeProtocolParser()
>
> ---
> public boolean invokeProtocolParser(...) {
> ...
> try{
> NIOContext copyContext = (NIOContext) Cloner.clone(ctx);
> copyContext.execute(copyContext.getProtocolChainContextTask());
> *copyContext.setThreadPool(threadPool);*
> } catch(...){
> ...
> }
> ...
> }
> ---
>
> I couldn't understand the above code because the decided thread
> pool(threadPool) was set after NIOContext.execute().
>
> Then, NIOContext.execute() doesn't use the decided thread pool but
> original thread pool.
>
> Is it right?

Wow this is seriously broken. You are right.


>
>
> 3. Implications of the policyMetric
>
> When I read the JavaDoc and
> http://weblogs.java.net/blog/jfarcand/archive/2006/04/resource_consum.html,
> it seems that an user can set the policyMetric like the following.
>
> ---
> -Dcom.sun.grizzly.rcm.policyMetric="/examples|0.9"
> ---
>
> Then, does it mean that the policy is applied to all sub requests of
> "examples" context? Or does it mean that the policy is applied to only
> "/examples" request?
>
> I think that it is better that the policy should be applied to
> "/examples", "/examples/index.html", "/examples/something" and etc...
>
> What do you think?

Agree. But if we go that route we will need to improve the mapping of
the request. So I think we will need to inject the Mapper or (I can see
Hubert and Alexey smiling) write a new one to replace the over
complicated Mapper.

>
>
> If I am missing some points, please advice me.

No you are totally right. I'm just curious about (1). For 3, do you want
to go ahead and write/use the Mapper?

A+

- Jeanfrancois


>
> Thanks.
>
> --
> Bongjae Chang