From kato-spec-return-317-apmail-incubator-kato-spec-archive=incubator.apache.org@incubator.apache.org Tue Jan 05 15:34:37 2010 Return-Path: Delivered-To: apmail-incubator-kato-spec-archive@minotaur.apache.org Received: (qmail 76648 invoked from network); 5 Jan 2010 15:34:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Jan 2010 15:34:37 -0000 Received: (qmail 92300 invoked by uid 500); 5 Jan 2010 15:34:37 -0000 Delivered-To: apmail-incubator-kato-spec-archive@incubator.apache.org Received: (qmail 92264 invoked by uid 500); 5 Jan 2010 15:34:37 -0000 Mailing-List: contact kato-spec-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: kato-spec@incubator.apache.org Delivered-To: mailing list kato-spec@incubator.apache.org Received: (qmail 92254 invoked by uid 99); 5 Jan 2010 15:34:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jan 2010 15:34:37 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sonalgoyal4@gmail.com designates 209.85.160.41 as permitted sender) Received: from [209.85.160.41] (HELO mail-pw0-f41.google.com) (209.85.160.41) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jan 2010 15:34:27 +0000 Received: by pwj4 with SMTP id 4so2596438pwj.20 for ; Tue, 05 Jan 2010 07:34:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=8ooSlKza71KXuSt0JhJA56r011FA9gHlZW3lh1GXLIs=; b=j9JGSbtfa9S2CEVc9EGB+ggMOAJHrQmhwYszL0n0kzewcUEUr7TVRbLuVsk4xIV1DB iERQnziOmv53uG8Hd3ofiQKQqv6u7+L9bLQUYbKSfmMH/znNsLdnpWh3AQU5wov+3dSE 1QEKApVvrD8wXA3HlS7P6rW/LszMegfBU2xwQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=bhHpCJLwx2jLzahrS+KzEPowBkGOWRE9DgxESMZdVOO246OouQoDiHccVsb4qR8ODP tAmzGw/vZex9UUdaa6XJr+5Nndo4Le0WGQ+6ndWzofyisa2LmTPmOrZkapRhppbmox2c tBQlE5IuoPc8kVD83D/yYIkiMt+1yth8bmtCU= MIME-Version: 1.0 Received: by 10.142.247.40 with SMTP id u40mr4064310wfh.178.1262705644726; Tue, 05 Jan 2010 07:34:04 -0800 (PST) In-Reply-To: <4B4343D5.8060302@stoo.me.uk> References: <4B422913.30200@stoo.me.uk> <4B4343D5.8060302@stoo.me.uk> Date: Tue, 5 Jan 2010 21:04:04 +0530 Message-ID: <9f26e661001050734q42c7c983o1772c55456947f58@mail.gmail.com> Subject: Re: Snapshot Application development usecases From: Sonal Goyal To: kato-spec@incubator.apache.org Content-Type: multipart/alternative; boundary=00504502cc9f68ebdf047c6c9193 X-Virus-Checked: Checked by ClamAV on apache.org --00504502cc9f68ebdf047c6c9193 Content-Type: text/plain; charset=ISO-8859-1 Hi, A very happy new year to everyone. For the cases mentioned, we can slightly modify Stuart's approach and allow user defined filters: interface DumpFilter { boolean includeInDump(T t); } class ClassLoaderFilter implements DumpFilter... class ThreadFilter implements DumpFilter { private ArrayList threads; public ThreadFilter(ArrayList threads) { this.threads = threads; } boolean includeInDump(Thread t) { if (threads.contains(t)) return true; return false; } } class Dump{ void dump(); void dump(Object..roots); void setDepth(int depth); void addFilter(DumpFilter df); Set getFilters(); void setFilters(Set filters); } Thanks and Regards, Sonal On Tue, Jan 5, 2010 at 7:21 PM, Stuart Monteith wrote: > Given a method: > dump() > > to generate a dump, this could be expanded with: > > dump(Object obj) > > which would dump that object and what it refers too. > > Of course, doing the following: > > Object[] obj; > > dump(obj) > > I would expect that a Dump object would be created and used in multiple > places, configured for use by whatever. > The object passed to the dump method would be used as the context in which > the dump was to be taken. > > Commonly, we might expect: > > Object[] context = new Object[2]; > context[0] = Thread.getCurrentThread(); > context[1]= HTTPSession; > > dumpObj.dump(context); > > which the dumpObj has already been configured for. > > class Dump { > // Generate a dump. > void dump(); > > // Generate a dump, including the passed root object. > void dump(Object root); > > > // Get the roots already > Set getRoots(); > > // Sets the number of references > void setDepth(int depth); > > // Sets the objects to start scanning from > void setRoots(Set col) ; > > // Get the set of classloaders dumps are filtered against. > Set getClassLoadersFilter(); > > // Set the classloaders to filter against. > void setClassLoadersFilter(Set loaders); > > // Set the packages to filter against > Set getPackagesFilter(); > void setPackagesFilter(Set packages); > > // Filter by sets of Threads. > void setThreadsFilter(Set thread); > Set getThreadsFilter(); > > ... etc.. > } > > > Of course, filtering on annotations, classloader and packages are > essentially filtering by operations on classes. > Presuming the filtering is performed in Java, we could simply provide an > interface to determine this: > interface ClassFilter { > // Return true if class is to be included. > boolean filter(Class clazz); > } > > We could provide implementations of ClassFilters to perform the operations. > > I am a little concerned about how to implement this stuff. If it is Java, > we need a virtual machine, > and the one we are in may be failing in such a way we can't execute - an > OutOfMemoryError or > StackOverFlowError are both obvious examples. > > > Regards, > Stuart > > > > Steve Poole wrote: > >> Thanks Stuart - like the donkey. >> >> I would imagine, based on your examples, having methods like >> >> selectClassesLoadedBy(ClassLoader c) >> selectPackageName("com.silly.donkey.*") >> selectByAnnotation(Annotation a) >> selectReferencedObjects(Thread t); >> addFieldFilter(java.lang.reflect.Field f,Object value); >> selectReferencedObjectsWithin(Object root,int distance); >> >> >> I like to get down the the method definitions as quickly as possible as it >> makes it real :-) >> >> >> On Mon, Jan 4, 2010 at 5:44 PM, Stuart Monteith >> wrote: >> >> >> >>> Happy New Year everyone! >>> >>> The usecases are interesting, the problem is how to find and dump what >>> you >>> want and no more. >>> >>> >>> >> >> >>> Ways in which objects may be selected for dumping: >>> >>> o By classloader >>> This is can separate object instances at runtime by virtue of >>> their >>> classes having been >>> defined by the same classloader. >>> >>> o By class package >>> Simply filter dumped classes matching a given filter name. >>> >>> o By class annotation >>> Classes could be specially marked with an annotation that is >>> visible >>> at runtime. >>> >>> o By object instance. >>> A dump would have to be initiated /somewhere/. Realistically, we'd >>> have to start from a particular >>> object, class. An array could be passed to cater for multiple >>> roots. >>> >>> o By Thread. >>> Using a thread and all of its roots would be practicable if they >>> were accessible. >>> >>> o By field value: >>> Restrict dump to objects with a field containing a certain value, >>> determined at runtime. >>> >>> o By distance from the root object. >>> For example, given an object, only retrieve objects three >>> references >>> away. >>> >>> These could be used in various combinations. Dumping all objects of >>> classes >>> in package com.silly.donkey >>> is all very well, but this could be restricted to only those annotated >>> with >>> @DumpMe and further restricted >>> to only those reachable from a particular instance of >>> "com.silly.donkey.HeeHaw" . >>> >>> >>> Regards, >>> Stuart >>> >>> >>> Steve Poole wrote: >>> >>> >>> >>>> I want to present a few application development usecases for us to >>>> discuss >>>> to do with the Snapshot concept. >>>> >>>> First let's agree some basics >>>> >>>> An application snapshot is a deliberate subset of a running system. >>>> It's >>>> deliberate in that what is defined for inclusion / exclusion can be >>>> changed. >>>> >>>> To build an application snapshot three types of information are required >>>> >>>> 1 - root objects which determine where to start the snapshot from >>>> 2 - rules to restrict how "far" to search >>>> 3 - rules to describe what to include in the snapshot >>>> >>>> >>>> Example 1 >>>> >>>> A webserver session is behaving incorrectly. The application programmer >>>> wants to capture information >>>> to do with the session itself and some specific application details. >>>> >>>> The root object is an HTTPSession and the application code is all >>>> contained >>>> in packages that start org.acme.application >>>> The application programmer believes that the problem is in the >>>> application >>>> and so wants the minimum >>>> of system information included. >>>> >>>> >>>> Example 2 >>>> >>>> An error has occured and the application is about throw an exception. >>>> The >>>> application programmer wants to capture a series >>>> of objects related to the error and wants to see the Java stack >>>> including >>>> local variables. >>>> >>>> >>>> Example 3 >>>> >>>> A enterprise server is running slow and the application programmer would >>>> like to get a list of the instances of a specific interface >>>> that the server is managing, since the suspicion is that there are >>>> multiple >>>> instances of a nonthreadsafe instance of this interface when there >>>> should >>>> only be one. >>>> >>>> Example 4 >>>> >>>> A servlet server has run out of database connections and the suspicion >>>> is >>>> that managed objects have not been >>>> collected. Typically programmers use finalisers or depend on GC instead >>>> of >>>> using the Servlet.Destroy() method. >>>> the application programmer needs to get a list of objects in "Destroyed" >>>> state which obviously haven't been GC'd >>>> >>>> >>>> Cheers >>>> >>>> >>>> >>>> >>>> >>> -- >>> Stuart Monteith >>> http://blog.stoo.me.uk/ >>> >>> >>> >>> >> >> >> > > -- > Stuart Monteith > http://blog.stoo.me.uk/ > > --00504502cc9f68ebdf047c6c9193--