cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thorsten.scherler....@juntadeandalucia.es>
Subject Re: [2.1] AbstractCachingProcessingPipeline and cocoon CLI
Date Mon, 25 Aug 2008 10:40:16 GMT
On Fri, 2008-08-22 at 10:34 -0400, Vadim Gritsenko wrote:
> On Aug 22, 2008, at 8:57 AM, Thorsten Scherler wrote:
> 
> > On Fri, 2008-08-22 at 08:18 -0400, Vadim Gritsenko wrote:
> >> On Aug 22, 2008, at 3:35 AM, Thorsten Scherler wrote:
> >>
> >>> How about:
> >>>                } else {
> >>> -                    Object lock =
> >>> env.getObjectModel().get(HttpEnvironment.HTTP_REQUEST_OBJECT);
> >>> +                    Object lock =
> >>> env.getObjectModel().get(ObjectModelHelper.REQUEST_OBJECT);
> >>>                    try {
> >>>                        transientStore.store(lockKey, lock);
> >>>                    } catch (IOException e) {
> >>>
> >>> This way we always lock the same object.
> >>
> >> Exactly this thing I was trying to explain - it will not work because
> >> instead of using top level request you are suggesting to use current
> >> sub-request.
> >
> > Sorry I am not really following. As understand you we cannot use
> > ObjectModelHelper.REQUEST_OBJECT since we cannot be sure that is not a
> > sub-request (a request for the exact same resource in a concurrent
> > situation).
> 
> Exactly.
> 
> 
> > If the lock is null for a HttpEnvironment.HTTP_REQUEST_OBJECT then we
> > are in CLI mode.
> 
> (patch quoted above does not have lock == null comparison anymore,  
> that's why it is dangerous for HTTP env)
> 
> 
> > In CLI ASAIK there is no concurrent situation meaning
> > the problem cannot occur. However since the issue is talking about
> > includes that may occur.
> 
> Yes. You can still use IncludeTransformer in CLI. So deadlock can  
> happen.
> 
> 
> > Having a typical call from the cli gives for the env.getObjectModel():
> >
> > HashMap values:
> > [null,
> > response=org.apache.cocoon.environment.wrapper.ResponseWrapper@fd4662,
> > link-collection=[],
> > request=org.apache.cocoon.environment.wrapper.RequestWrapper@6dddcf,
> > null, null, null, null,
> > context 
> > = 
> > org 
> > .apache.cocoon.environment.commandline.CommandLineContext@14ba9a2,  
> > null, null, source- 
> > resolver 
> > = 
> > org 
> > .apache.cocoon.environment.commandline.FileSavingEnvironment@725967,  
> > org 
> > .apache 
> > .cocoon 
> > .components 
> > .CocoonComponentManager 
> > =org.apache.cocoon.components.EnvironmentDescription@d2efa1, null,  
> > null, null]
> >
> > So which object you would suggest to lock?
> >
> > You wrote "Suitable  alternative would be to lock against top most
> > command line request."
> >
> > To what you are referring with "top most command line request"?
> 
> That would be CommandLineRequest. 

Hmm, did you see the above objectModel? There is no such an object in
the map. There are exactly six objects in the model

1) response
2) link-collection
3) request
4) context
5) source-resolver
6) org.apache.cocoon.components.CocoonComponentManager

> Following HTTP environment analogy,  
> that would be CommandLineEnvironment.CLI_REQUEST_OBJECT.

Which does not exist, right?

I opened an issue COCOON-2241 around the issue.

The proposed solution is now taken the ObjectModelHelper.REQUEST_OBJECT
if the request is from CLI, if not it is using the
HttpEnvironment.HTTP_REQUEST_OBJECT.

IMO it should not be a problem with deadlocks since the
FileSavingEnvironment and LinkSamplingEnvironment (as only
implementations for the Cli) have in the constructor:

this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT,
new CommandLineRequest(this, null, uri, null, attributes, parameters,
headers));

which IMO makes it unique for each sub-request.

In comparison the HttpEnvironment has in the constructor:
this.objectModel.put(HTTP_REQUEST_OBJECT, req);
where HttpServletRequest req.

The uniqueness in both cases are, as I understand, the headers.

salu2

> 
> 
> Vadim
> 
> 
> > salu2
> >
> >>
> >> Take a look at EnvironmentWrapper (which is used e.g. in  
> >> SitemapSource):
> >>
> >>         // create new object model and replace the request object
> >>         Map oldObjectModel = env.getObjectModel();
> >>         if (oldObjectModel instanceof HashMap) {
> >>             this.objectModel = (Map) 
> >> ((HashMap)oldObjectModel).clone();
> >>         } else {
> >>             this.objectModel = new HashMap(oldObjectModel.size()*2);
> >>             Iterator entries = oldObjectModel.entrySet().iterator();
> >>             Map.Entry entry;
> >>             while (entries.hasNext()) {
> >>                 entry = (Map.Entry)entries.next();
> >>                 this.objectModel.put(entry.getKey(),  
> >> entry.getValue());
> >>             }
> >>         }
> >>         this.request = new
> >> RequestWrapper(ObjectModelHelper.getRequest(oldObjectModel),
> >>                                           requestURI,
> >>                                           queryString,
> >>                                           this,
> >>                                           rawMode);
> >>         this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT,
> >> this.request);
> >>
> >>
> >> Vadim
> > -- 
> > Thorsten Scherler                                  
> > thorsten.at.apache.org
> > Open Source Java                      consulting, training and  
> > solutions
> >
> 
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


Mime
View raw message