cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christoph Gaffga" <cgaf...@triplemind.com>
Subject Re: ContentAggregator and multithreating (migrating C2 -> C2.1M2), is it thread-safe?
Date Fri, 23 May 2003 14:04:55 GMT
Just to see if I got it right, you wrote:
> Have a look at the DefaultIncludeCacheManager - it can include in
parallel.

my Aggregator does:

    // Part extends Thread
    Part.run() {
      SourceUtil.toSAX(part.source, buffer);
    }

    // Aggregator.generate()
    for(iterate all parts) {
      part.start();
    }
    for(iterate all parts) {
      part.join();
      part.buffer.toSAX(contentHandler);
    }

so I need to do something like:

    // Aggregator.generate()
    for(iterate all parts) {
      part.includeCacheManager = new DefaultIncludeCacheManager();
      part.includeCacheManager.compose(this.manager);
      part.session = includeCacheManager.getSession(this.par);
      part.includeCacheManager.load(part.uri, part.session);
    }
    for(iterate all parts) {
      part.includeCacheManager.stream(part.uri, part.session,
contentHandler);
    }

Is this right? Please give me a hint because I am not so familar whith these
IncludeCacheManager(and Session)-stuff.

Christoph

P.S.:
is there a special reason you are using
    // wait
    while (!loader.finished) {
      try {
        Thread.sleep(10);
      } catch (InterruptedException e) { }
    }
in DefaultIncludeCacheManger (line 259). Isn't it better to have the thread
as a class variable (see line 212) and then use thread.join()?



"Carsten Ziegeler" <cziegeler@s-und-n.de> schrieb im Newsbeitrag
news:LKENJPKDAIKAPKHEOCMMGEBMDLAA.cziegeler@s-und-n.de...
> Have a look at the DefaultIncludeCacheManager - it can include in
parallel.
>
> Carsten
>
> > -----Original Message-----
> > From: news [mailto:news@main.gmane.org]On Behalf Of Christoph Gaffga
> > Sent: Friday, May 23, 2003 12:14 PM
> > To: cocoon-dev@xml.apache.org
> > Subject: ContentAggregator and multithreating (migrating C2 -> C2.1M2),
> > is it thread-safe?
> >
> >
> > Hi,
> >
> > I posted this to cocoon-users before, but I think it's perheaps more a
> > development issue.
> >
> > Also I got some response saying the threaded ContentAggregator
> > would be nice
> > to be included in cocoon:
> > From: "Torsten Knodt" <torstenknodt@datas-world.de>
> > > > P.S.: Wouldn't it be nice to have a multi-threaded Aggreagator with
> > cocoon?
> > > Nice? It would be fantastic. I think this issue is on the top two of
the
> > > performance killers in cocoon.
> >
> > Carsten Ziegeler gave me a hint that there should be already an
> > multi-threaded content aggregator in 2.1,the cinclude
> > transformer. I checked
> > this and found no multi-threating code in this transformer (am I
blind?),
> > only code about caching.
> >
> > So, is there somebody how had the same Problems about Threads and
coocon,
> > any help would be appriciated.
> >
> > Christoph Gaffga
> > cgaffga@triplemind.com
> >
> > P.S.: I would also contribute this Aggregator to the cocoon project if
it
> > works and there is any interest.
> >
> > ----- Original Message -----
> > From: "Christoph Gaffga" <cgaffga@triplemind.com>
> > Newsgroups: gmane.text.xml.cocoon.user
> > Cc: cziegeler@apache.org, giacomo@apache.org
> > Sent: Friday, May 23, 2003 12:59 AM
> > Subject: ContentAggregator and multithreating (migrating C2 -> C2.1M2),
is
> > it thread-safe?
> > > Hi,
> > >
> > > we are mirgating form cocoon2.0.4 to cocoon2.1-M2 and found
> > some Problems
> > > with the new APIs. We rewrote the ContentAggregator to use Threads an
> > > simulaniosly generate the parts, buffer them, and then write
> > the output in
> > > the right order.
> > > With cocoon2.1-M2 there seems to be some syncronization issue, we
always
> > get
> > > the following exception:
> > >
> > > java.lang.IndexOutOfBoundsException: Index: 55, Size: 31
> > >         at java.util.ArrayList.RangeCheck(ArrayList.java:508)
> > >         at java.util.ArrayList.remove(ArrayList.java:388)
> > >         at
> > >
> > org.apache.cocoon.components.EnvironmentDescription.removeFromAuto
> > Release(Co
> > > coonComponentManager.java:569)
> > >         at
> > >
> > org.apache.cocoon.components.CocoonComponentManager.removeFromAuto
> > maticRelea
> > > se(CocoonComponentManager.java:410)
> > >         at
> > >
> > org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.r
> > elease(Abs
> > > tractProcessingPipeline.java:203)
> > >         at
> > >
> > org.apache.cocoon.components.source.impl.SitemapSource.reset(Sitem
> > apSource.j
> > > ava:436)
> > >         at
> > >
> > org.apache.cocoon.components.source.impl.SitemapSource.toSAX(Sitem
> > apSource.j
> > > ava:428)
> > >         at
> > >
> >
org.apache.cocoon.components.source.SourceUtil.toSAX(SourceUtil.java:159)
> > >         at
> > >
> >
org.apache.cocoon.components.source.SourceUtil.toSAX(SourceUtil.java:126)
> > >         at
> > >
> > com.triplemind.asp.generator.AbstractAggregator$Part.run(AbstractA
> > ggregator.
> > > java:96)
> > >
> > > The Aggregators generate() method looks like that:
> > >
> > >   public void generate() throws IOException, SAXException,
> > > ProcessingException {
> > >     ...
> > >       // Start generation...
> > >       for(int i = 0; i < this.parts.size(); i++) {
> > >         final Part part = (Part)this.parts.get(i);
> > >         part.start();
> > >       }
> > >       // Start aggregation...
> > >       for(int i = 0; i < this.parts.size(); i++) {
> > >         ...
> > >           part.join();
> > >           part.toSAX(this);
> > >         ...
> > >       }
> > >     ...
> > >   }
> > >
> > > as said before, the part caches the result of the source. When
> > we have the
> > > same in one for-loop, than ist runs fine, so it't not a problem with
our
> > > class, I guess. In cocoon2.0.4 it runs as well.
> > >
> > > So, is there a known Problem with thread-safty? How to solve this?
> > >
> > > Regards
> > > Christoph Gaffga
> > > cgaffga@triplemind.com
> > >
> > >
> > > P.S.: Wouldn't it be nice to have a multi-threaded Aggreagator with
> > cocoon?
> >
> >
> >
>
>




Mime
View raw message