Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 21736 invoked by uid 500); 3 Dec 2002 06:38:21 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 21725 invoked from network); 3 Dec 2002 06:38:20 -0000 Date: Mon, 2 Dec 2002 22:38:33 -0800 Subject: Re: Expire Continuations Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v548) From: Ovidiu Predescu To: cocoon-dev@xml.apache.org Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.548) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi Michael, OK, I'm back from a longer absence due to the Thanksgiving vacation. On Thursday, Nov 28, 2002, at 10:28 US/Pacific, Michael Melhem wrote: > Hi Ovidiu!! > > How are you mate, I guess you are not coming to the Frankfurt > Stammtisch???? :-P Wait a second, I want to come! ;) > I was thinking about how to Expire Continuations and have come up with > the following: > > We know from the "bus discussion" that placing every wk > (WebContinuation) > into the "expirations" Sorted TreeSet is a problematic solution. So how > about placing only the "leaf" nodes in this set for each tree? The bus discussion should be placed in the references section of the documentation and in the comments in the source code ;) > This can be done by: > for each new wk > (if wk.getparent().numChildren() < 2) > expirations.remove(wk.getparent()); > expirations.add(wk); > > This could be an expensive operation especially if the set of wk's is > very large .... although.. the treeSet guarantees log(n) time cost for > basic operations. What do you think ? > > Given that we have a sorted set of "leaf" nodes (from all continuation > trees) we need to excute the following algorithm to rid the > system of expired wk's > > For each leaf node in the set which is expired: > delete it, and > recursively delete its parent > only if its parent has also expired > *and* has no (other) children. > > We could make the ContinuationsManager an avlaon monitored Resource, > so that we can periodically trigger continuations clean ups. > > This implies the max life of an "wk" after lastAcceesTime > equals timeToLive + cleanUp_period. > > > What do you think?? I think the TreeSet is definitely the way to go, as it is a sorted collection and accesses and removals from it are very fast. One observation related to your algorithm, which is an idea I had when we got off The Bus, is that we don't need to handle children continuations of a given continuation. This is because each and every continuation will appear in the sorted tree, and we can expire individual continuations separate from their children. This is different than the ContinuationManagerImpl.invalidateWebContinuation() method which invalidates the whole subtree of continuations. We could add a similar method which removes only the continuation passed to it as argument, without recursively removing the whole continuation subtree. The expiration algorithm will then simply iterate over the tree set until a continuation whose access time + expiration time is greater than the current time. All the continuations encountered before that are simply removed from the global hash set. What do you think? Ovidiu --------------------------------------------------------------------- To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org For additional commands, email: cocoon-dev-help@xml.apache.org