From: Lukas P. <pe...@us...> - 2002-05-14 14:47:42
|
Update of /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime In directory usw-pr-cvs1:/tmp/cvs-serv3650 Modified Files: AllocTraceR.java CPUTraceR.java ImageR.java MethodR.java MonTraceR.java ThreadR.java Added Files: CPUThreadMethodR.java CPUThreadTraceR.java MonThreadMethodR.java MonThreadTraceR.java Log Message: added CPU + Mon --- NEW FILE: CPUThreadMethodR.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.realtime; import java.util.*; import net.sourceforge.javaprofiler.api.*; import net.sourceforge.javaprofiler.api.Class; import net.sourceforge.javaprofiler.api.Thread; import net.sourceforge.javaprofiler.api.ThreadGroup; import net.sourceforge.javaprofiler.jpiimpl.commun.IProf; import net.sourceforge.javaprofiler.jpiimpl.commun.IProfException; /** Implementation of API CPUThreadMethod * @author Lukas Petru */ public class CPUThreadMethodR extends MultiRootDataR implements CPUThreadMethod { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; /** VM Image that constructed this object. */ private ImageR image; /** Object identification. */ private Integer objId; // roots to which this object is linked private ThreadR thread; private MethodR location; // parents // CPU info private long hits; private long pureTime; // lists for children private final List cpuThreadTraces=new ArrayList(0); // unmodifiable variants of lists for children private final List roCPUThreadTraces=Collections.unmodifiableList( cpuThreadTraces); /** Constructs multi-rooted object * @param typeId Identification of <code>AllocTypeR</code> object. Should * be null if N/A. * @param threadId Identification of <code>ThreadR</code> object. Should * be null if N/A. * @param locationId Identification of <code>Location</code> object. * Should be null if N/A. * @param sid Object with data from communication layer. * @param RtImage <code>VirtualMachineImage</code> object to which this * object shall belong */ CPUThreadMethodR(Integer typeId, Integer threadId, Integer locationId, IProf.sID sid, ImageR RtImage) { image=RtImage; objId=new Integer(sid.objId); construct(typeId, threadId, locationId, sid); } /** Constructs object with only <code>ID</code>. * @param oId Object identification. * @param RtImage <code>VirtualMachineImage</code> object to which this * object shall belong */ CPUThreadMethodR(Integer oId, ImageR RtImage) { image=RtImage; objId=oId; } // ---------- return child Lists public void refreshCPUThreadTraces() { image.extractMultiRoot(this, IProf.CPU_THREAD_METHOD_TRACES, image.cpuThreadTraceFactory); } public List getCPUThreadTraces() { if ( image.getAlwaysRefresh() ) refreshCPUThreadTraces(); return roCPUThreadTraces; } // ---------- return parents public Thread getParentThread() { needConstructed(); return thread; } public Method getParentMethod() { needConstructed(); return location; } // ---------- return roots of this object /** Returns AllocType root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public AllocTypeR getAllocType() { return null; } /** Returns Thread root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public ThreadR getThread() { needConstructed(); return thread; } /** Returns Location root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public Location getLocation() { needConstructed(); return location; } // ---------- profiler statistic public long getNumOfHits() { conditionalRefresh(); return hits; } public long getPureTime() { conditionalRefresh(); return pureTime; } // ---------- refresh /** Refreshes statistics. */ public void refresh() { IProf.sData data; try { data = image.getIProf().getData(objId.intValue(), IProf.CPU_DATA); } catch (IProfException e) { throw new RuntimeException(e); } setData((IProf.sCpuStatData) data.statData); } // ---------- private / package void addCPUThreadTrace(CPUThreadTrace o) { cpuThreadTraces.add(o); } /** Finishes full object construction. */ void construct(Integer typeId, Integer threadId, Integer locationId, IProf.sID sid) { if (! isReady) { // resolve roots thread=image.resolveThread(threadId); location=image.resolveMethod(locationId); // resolve parents isReady=true; // add to parents' lists thread.addCPUThreadMethod(this); location.addCPUThreadMethod(this); } } /** Determines whether refresh should be done and does, if so. */ private void conditionalRefresh() { if (image.getAlwaysRefresh()) refresh(); } private void needConstructed() { if (!isReady) { IProf.sParents parents; try { parents=image.getIProf().getParents(objId.intValue()); } catch (IProfException e) { throw new RuntimeException(e); } // link to parents Integer threadId=new Integer(parents.parentUpObjId); thread=image.resolveThread(threadId); Integer locationId=new Integer(parents.parentLeftObjId); location=image.resolveMethod(locationId); // link to roots // (same as parents) isReady=true; // add to parents' lists thread.addCPUThreadMethod(this); location.addCPUThreadMethod(this); } } /** Finishes object construction with info gained from profiled VM. * @param sid Object info. */ void construct(IProf.sID sid) { // not yet determined, how to use this method } /** Fills object with data gained from profiled VM. * @param data Data. */ void setData(IProf.sCpuStatData cpuData) { hits=cpuData.hits; pureTime=cpuData.pureTime; } /** Fills object with data gained from profiled VM. * @param sid Object info and data. */ void setData(IProf.sID sid) { setData(sid.cpu); } /** Returns number that identifies object for profiler library. */ Integer getId() { return objId; } public String toString() { return getThread() + "-" + getLocation(); } } --- NEW FILE: CPUThreadTraceR.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.realtime; import java.util.*; import net.sourceforge.javaprofiler.api.*; import net.sourceforge.javaprofiler.api.Class; import net.sourceforge.javaprofiler.api.Thread; import net.sourceforge.javaprofiler.api.ThreadGroup; import net.sourceforge.javaprofiler.jpiimpl.commun.IProf; import net.sourceforge.javaprofiler.jpiimpl.commun.IProfException; /** Implementation of API CPUThreadTrace * @author Lukas Petru */ public class CPUThreadTraceR extends MultiRootDataR implements CPUThreadTrace { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; /** VM Image that constructed this object. */ private ImageR image; /** Object identification. */ private final Integer objId; // roots to which this object is linked private ThreadR thread; private CPUTraceR location; // parents private CPUThreadMethodR method; // CPU info private long hits; private long pureTime; /** Constructs multi-rooted object * @param typeId Identification of <code>AllocTypeR</code> object. Should * be null if N/A. * @param threadId Identification of <code>ThreadR</code> object. Should * be null if N/A. * @param locationId Identification of <code>Location</code> object. * Should be null if N/A. * @param sid Object with data from communication layer. * @param RtImage <code>VirtualMachineImage</code> object to which this * object shall belong */ CPUThreadTraceR(Integer typeId, Integer threadId, Integer locationId, IProf.sID sid, ImageR RtImage) { image=RtImage; objId=new Integer(sid.objId); construct(typeId, threadId, locationId, sid); } /** Constructs object with only <code>ID</code>. * @param oId Object identification. * @param RtImage <code>VirtualMachineImage</code> object to which this * object shall belong */ CPUThreadTraceR(Integer oId, ImageR RtImage) { image=RtImage; objId=oId; } // ---------- return child Lists // ---------- return parents public CPUThreadMethod getParentCPUThreadMethod() { needConstructed(); return method; } public Thread getParentThread() { needConstructed(); return thread; } public CPUTrace getParentCPUTrace() { needConstructed(); return location; } // ---------- return roots of this object /** Returns AllocType root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public AllocTypeR getAllocType() { return null; } /** Returns Thread root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public ThreadR getThread() { needConstructed(); return thread; } /** Returns Location root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public Location getLocation() { needConstructed(); return location; } // ---------- profiler statistic public long getNumOfHits() { conditionalRefresh(); return hits; } public long getPureTime() { conditionalRefresh(); return pureTime; } // ---------- refresh /** Refreshes statistics. */ public void refresh() { IProf.sData data; try { data = image.getIProf().getData(objId.intValue(), IProf.CPU_DATA); } catch (IProfException e) { throw new RuntimeException(e); } setData((IProf.sCpuStatData) data.statData); } // ---------- private / package /** Finishes full object construction. */ void construct(Integer typeId, Integer threadId, Integer locationId, IProf.sID sid) { if (! isReady) { // resolve roots thread=image.resolveThread(threadId); location=image.resolveCPUTrace(locationId); // resolve parents Integer methodId=new Integer(sid.parentUpObjId); if (image.containsId(methodId)) method=(CPUThreadMethodR) image.getObject(methodId); else { method=new CPUThreadMethodR(methodId, image); image.putObject(methodId, method); } isReady=true; // add to parents' lists method.addCPUThreadTrace(this); thread.addCPUThreadTrace(this); location.addCPUThreadTrace(this); } } /** Determines whether refresh should be done and does, if so. */ private void conditionalRefresh() { if (image.getAlwaysRefresh()) refresh(); } private void needConstructed() { if (!isReady) { IProf.sParents parents; try { parents=image.getIProf().getParents(objId.intValue()); } catch (IProfException e) { throw new RuntimeException(e); } // link to parents Integer methodId=new Integer(parents.parentUpObjId); if (image.containsId(methodId)) method=(CPUThreadMethodR) image.getObject(methodId); else { method=new CPUThreadMethodR(methodId, image); image.putObject(methodId, method); } // link to roots location=image.resolveCPUTrace(new Integer(parents. parentLeftObjId)); thread=method.getThread(); isReady=true; // add to parents' and root lists method.addCPUThreadTrace(this); thread.addCPUThreadTrace(this); location.addCPUThreadTrace(this); } } /** Finishes object construction with info gained from profiled VM. * @param sid Object info. */ void construct(IProf.sID sid) { // not yet determined, how to use this method } /** Fills object with data gained from profiled VM. * @param data Data. */ void setData(IProf.sCpuStatData cpuData) { hits=cpuData.hits; pureTime=cpuData.pureTime; } /** Fills object with data gained from profiled VM. * @param sid Object info and data. */ void setData(IProf.sID sid) { setData(sid.cpu); } /** Returns number that identifies object for profiler library. */ Integer getId() { return objId; } public String toString() { return getThread() + "-" + getLocation(); } } --- NEW FILE: MonThreadMethodR.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.realtime; import java.util.*; import net.sourceforge.javaprofiler.api.*; import net.sourceforge.javaprofiler.api.Class; import net.sourceforge.javaprofiler.api.Thread; import net.sourceforge.javaprofiler.api.ThreadGroup; import net.sourceforge.javaprofiler.jpiimpl.commun.IProf; import net.sourceforge.javaprofiler.jpiimpl.commun.IProfException; /** Implementation of API MonThreadMethod * @author Lukas Petru */ public class MonThreadMethodR extends MultiRootDataR implements MonThreadMethod { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; /** VM Image that constructed this object. */ private ImageR image; /** Object identification. */ private Integer objId; // roots to which this object is linked private ThreadR thread; private MethodR location; // parents // monitor info private long monitorHits; private long time; // lists for children private final List monThreadTraces=new ArrayList(0); // unmodifiable variants of lists for children private final List roMonThreadTraces=Collections.unmodifiableList( monThreadTraces); /** Constructs multi-rooted object * @param typeId Identification of <code>AllocTypeR</code> object. Should * be null if N/A. * @param threadId Identification of <code>ThreadR</code> object. Should * be null if N/A. * @param locationId Identification of <code>Location</code> object. * Should be null if N/A. * @param sid Object with data from communication layer. * @param RtImage <code>VirtualMachineImage</code> object to which this * object shall belong */ MonThreadMethodR(Integer typeId, Integer threadId, Integer locationId, IProf.sID sid, ImageR RtImage) { image=RtImage; objId=new Integer(sid.objId); construct(typeId, threadId, locationId, sid); } /** Constructs object with only <code>ID</code>. * @param oId Object identification. * @param RtImage <code>VirtualMachineImage</code> object to which this * object shall belong */ MonThreadMethodR(Integer oId, ImageR RtImage) { image=RtImage; objId=oId; } // ---------- return child Lists public void refreshMonThreadTraces() { image.extractMultiRoot(this, IProf.MON_THREAD_METHOD_TRACES, image.monThreadTraceFactory); } public List getMonThreadTraces() { if ( image.getAlwaysRefresh() ) refreshMonThreadTraces(); return roMonThreadTraces; } // ---------- return parents public Thread getParentThread() { needConstructed(); return thread; } public Method getParentMethod() { needConstructed(); return location; } // ---------- return roots of this object /** Returns AllocType root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public AllocTypeR getAllocType() { return null; } /** Returns Thread root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public ThreadR getThread() { needConstructed(); return thread; } /** Returns Location root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public Location getLocation() { needConstructed(); return location; } // ---------- profiler statistic public long getNumOfMonitorHits() { conditionalRefresh(); return monitorHits; } public long getTimeElapsedOnMonitor() { conditionalRefresh(); return time; } // ---------- refresh /** Refreshes statistics. */ public void refresh() { IProf.sData data; try { data = image.getIProf().getData(objId.intValue(), IProf.MON_DATA); } catch (IProfException e) { throw new RuntimeException(e); } setData((IProf.sMonStatData) data.statData); } // ---------- private / package void addMonThreadTrace(MonThreadTrace o) { monThreadTraces.add(o); } /** Finishes full object construction. */ void construct(Integer typeId, Integer threadId, Integer locationId, IProf.sID sid) { if (! isReady) { // resolve roots thread=image.resolveThread(threadId); location=image.resolveMethod(locationId); // resolve parents isReady=true; // add to parents' lists thread.addMonThreadMethod(this); location.addMonThreadMethod(this); } } /** Determines whether refresh should be done and does, if so. */ private void conditionalRefresh() { if (image.getAlwaysRefresh()) refresh(); } private void needConstructed() { if (!isReady) { IProf.sParents parents; try { parents=image.getIProf().getParents(objId.intValue()); } catch (IProfException e) { throw new RuntimeException(e); } // link to parents Integer threadId=new Integer(parents.parentUpObjId); thread=image.resolveThread(threadId); Integer locationId=new Integer(parents.parentLeftObjId); location=image.resolveMethod(locationId); // link to roots // (same as parents) isReady=true; // add to parents' lists thread.addMonThreadMethod(this); location.addMonThreadMethod(this); } } /** Finishes object construction with info gained from profiled VM. * @param sid Object info. */ void construct(IProf.sID sid) { // not yet determined, how to use this method } /** Fills object with data gained from profiled VM. * @param data Data. */ void setData(IProf.sMonStatData monData) { monitorHits=monData.hits; time=monData.time; } /** Fills object with data gained from profiled VM. * @param sid Object info and data. */ void setData(IProf.sID sid) { setData(sid.mon); } /** Returns number that identifies object for profiler library. */ Integer getId() { return objId; } public String toString() { return getThread() + "-" + getLocation(); } } --- NEW FILE: MonThreadTraceR.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.realtime; import java.util.*; import net.sourceforge.javaprofiler.api.*; import net.sourceforge.javaprofiler.api.Class; import net.sourceforge.javaprofiler.api.Thread; import net.sourceforge.javaprofiler.api.ThreadGroup; import net.sourceforge.javaprofiler.jpiimpl.commun.IProf; import net.sourceforge.javaprofiler.jpiimpl.commun.IProfException; /** Implementation of API MonThreadTrace * @author Lukas Petru */ public class MonThreadTraceR extends MultiRootDataR implements MonThreadTrace { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; /** VM Image that constructed this object. */ private ImageR image; /** Object identification. */ private final Integer objId; // roots to which this object is linked private ThreadR thread; private MonTraceR location; // parents private MonThreadMethodR method; // monitor info private long monitorHits; private long time; /** Constructs multi-rooted object * @param typeId Identification of <code>AllocTypeR</code> object. Should * be null if N/A. * @param threadId Identification of <code>ThreadR</code> object. Should * be null if N/A. * @param locationId Identification of <code>Location</code> object. * Should be null if N/A. * @param sid Object with data from communication layer. * @param RtImage <code>VirtualMachineImage</code> object to which this * object shall belong */ MonThreadTraceR(Integer typeId, Integer threadId, Integer locationId, IProf.sID sid, ImageR RtImage) { image=RtImage; objId=new Integer(sid.objId); construct(typeId, threadId, locationId, sid); } /** Constructs object with only <code>ID</code>. * @param oId Object identification. * @param RtImage <code>VirtualMachineImage</code> object to which this * object shall belong */ MonThreadTraceR(Integer oId, ImageR RtImage) { image=RtImage; objId=oId; } // ---------- return child Lists // ---------- return parents public MonThreadMethod getParentMonThreadMethod() { needConstructed(); return method; } public Thread getParentThread() { needConstructed(); return thread; } public MonTrace getParentMonTrace() { needConstructed(); return location; } // ---------- return roots of this object /** Returns AllocType root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public AllocTypeR getAllocType() { return null; } /** Returns Thread root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public ThreadR getThread() { needConstructed(); return thread; } /** Returns Location root of multi-rooted object. Returns <code>null * </code> if this root is N / A. */ public Location getLocation() { needConstructed(); return location; } // ---------- profiler statistic public long getNumOfMonitorHits() { conditionalRefresh(); return monitorHits; } public long getTimeElapsedOnMonitor() { conditionalRefresh(); return time; } // ---------- refresh /** Refreshes statistics. */ public void refresh() { IProf.sData data; try { data = image.getIProf().getData(objId.intValue(), IProf.MON_DATA); } catch (IProfException e) { throw new RuntimeException(e); } setData((IProf.sMonStatData) data.statData); } // ---------- private / package /** Finishes full object construction. */ void construct(Integer typeId, Integer threadId, Integer locationId, IProf.sID sid) { if (! isReady) { // resolve roots thread=image.resolveThread(threadId); location=image.resolveMonTrace(locationId); // resolve parents Integer methodId=new Integer(sid.parentUpObjId); if (image.containsId(methodId)) method=(MonThreadMethodR) image.getObject(methodId); else { method=new MonThreadMethodR(methodId, image); image.putObject(methodId, method); } isReady=true; // add to parents' lists method.addMonThreadTrace(this); thread.addMonThreadTrace(this); location.addMonThreadTrace(this); } } /** Determines whether refresh should be done and does, if so. */ private void conditionalRefresh() { if (image.getAlwaysRefresh()) refresh(); } private void needConstructed() { if (!isReady) { IProf.sParents parents; try { parents=image.getIProf().getParents(objId.intValue()); } catch (IProfException e) { throw new RuntimeException(e); } // link to parents Integer methodId=new Integer(parents.parentUpObjId); if (image.containsId(methodId)) method=(MonThreadMethodR) image.getObject(methodId); else { method=new MonThreadMethodR(methodId, image); image.putObject(methodId, method); } // link to roots location=image.resolveMonTrace(new Integer(parents. parentLeftObjId)); thread=method.getThread(); isReady=true; // add to parents' and root lists method.addMonThreadTrace(this); thread.addMonThreadTrace(this); location.addMonThreadTrace(this); } } /** Finishes object construction with info gained from profiled VM. * @param sid Object info. */ void construct(IProf.sID sid) { // not yet determined, how to use this method } /** Fills object with data gained from profiled VM. * @param data Data. */ void setData(IProf.sMonStatData monData) { monitorHits=monData.hits; time=monData.time; } /** Fills object with data gained from profiled VM. * @param sid Object info and data. */ void setData(IProf.sID sid) { setData(sid.mon); } /** Returns number that identifies object for profiler library. */ Integer getId() { return objId; } public String toString() { return getThread() + "-" + getLocation(); } } Index: AllocTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTraceR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** AllocTraceR.java 21 Apr 2002 19:43:48 -0000 1.2 --- AllocTraceR.java 14 May 2002 14:47:37 -0000 1.3 *************** *** 60,63 **** --- 60,66 ---- private final List roFrames=Collections.unmodifiableList(frames); + // parents + private MethodR method; + // memory info private long numLiveInstances; *************** *** 106,110 **** public Method getParentMethod() { needConstructed(); ! return ((Frame) frames.get(0)).getMethod(); } --- 109,113 ---- public Method getParentMethod() { needConstructed(); ! return method; } *************** *** 236,241 **** frames.add(caller); } isReady = true; ! ((MethodR) getParentMethod()).addAllocTrace(this); } --- 239,245 ---- frames.add(caller); } + method=(MethodR) ((FrameR) frames.get(frames.size()-1)).getMethod(); isReady = true; ! method.addAllocTrace(this); } Index: CPUTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/CPUTraceR.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** CPUTraceR.java 10 Apr 2002 16:01:15 -0000 1.1 --- CPUTraceR.java 14 May 2002 14:47:37 -0000 1.2 *************** *** 59,62 **** --- 59,65 ---- private final List roFrames=Collections.unmodifiableList(frames); + // parents + private MethodR method; + // CPU info private long hits; *************** *** 64,68 **** --- 67,75 ---- // lists for children + private final List cpuThreadTraces=new ArrayList(0); + // unmodifiable variants of lists for children + private final List roCPUThreadTraces=Collections.unmodifiableList( + cpuThreadTraces); /** Constructs new object with info. *************** *** 96,100 **** public Method getParentMethod() { needConstructed(); ! return ((Frame) frames.get(0)).getMethod(); } --- 103,107 ---- public Method getParentMethod() { needConstructed(); ! return method; } *************** *** 102,110 **** public void refreshCPUThreadTraces() { } public List getCPUThreadTraces() { ! //PENDING ! return Collections.EMPTY_LIST; } --- 109,120 ---- public void refreshCPUThreadTraces() { + image.extractMultiRoot(this, IProf.CPU_METHOD_TRACE_THREADS, + image.cpuThreadTraceFactory); } public List getCPUThreadTraces() { ! if ( image.getAlwaysRefresh() ) ! refreshCPUThreadTraces(); ! return roCPUThreadTraces; } *************** *** 171,174 **** --- 181,188 ---- // package / private + void addCPUThreadTrace(CPUThreadTrace o) { + cpuThreadTraces.add(o); + } + /** Finishes object construction with info gained from profiled VM. * @param sid Object info. *************** *** 191,196 **** frames.add(caller); } isReady = true; ! ((MethodR) getParentMethod()).addCPUTrace(this); } --- 205,211 ---- frames.add(caller); } + method=(MethodR) ((FrameR) frames.get(frames.size()-1)).getMethod(); isReady = true; ! method.addCPUTrace(this); } Index: ImageR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/ImageR.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** ImageR.java 23 Apr 2002 14:33:34 -0000 1.4 --- ImageR.java 14 May 2002 14:47:37 -0000 1.5 *************** *** 112,123 **** final Constructor allocThreadTraceFactory; final Constructor allocTypeThreadTraceFactory; // multi-root ID factories ! final Constructor allocTypeMethodIDFactory; ! final Constructor allocTypeTraceIDFactory; ! final Constructor allocTypeThreadIDFactory; ! final Constructor allocThreadMethodIDFactory; ! final Constructor allocTypeThreadMethodIDFactory; ! final Constructor allocThreadTraceIDFactory; ! final Constructor allocTypeThreadTraceIDFactory; Set getAllFlags=new HashSet(); --- 112,129 ---- final Constructor allocThreadTraceFactory; final Constructor allocTypeThreadTraceFactory; + final Constructor cpuThreadMethodFactory; + final Constructor cpuThreadTraceFactory; + final Constructor monThreadMethodFactory; + final Constructor monThreadTraceFactory; // multi-root ID factories ! // final Constructor allocTypeMethodIDFactory; ! // final Constructor allocTypeTraceIDFactory; ! // final Constructor allocTypeThreadIDFactory; ! // final Constructor allocThreadMethodIDFactory; ! // final Constructor allocTypeThreadMethodIDFactory; ! // final Constructor allocThreadTraceIDFactory; ! // final Constructor allocTypeThreadTraceIDFactory; ! // final Constructor cpuThreadMethodIDFactory; ! // final Constructor cpuThreadTraceIDFactory; Set getAllFlags=new HashSet(); *************** *** 225,252 **** "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeThreadTraceR" ).getDeclaredConstructor(mrParameterTypes); ! // init multi-root ID factories ! mrParameterTypes=new java.lang.Class[] { ! integerClass, this.getClass() }; ! allocTypeMethodIDFactory=java.lang.Class.forName( ! "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeMethodR" ! ).getDeclaredConstructor(mrParameterTypes); ! allocTypeTraceIDFactory=java.lang.Class.forName( ! "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeTraceR") ! .getDeclaredConstructor(mrParameterTypes); ! allocTypeThreadIDFactory=java.lang.Class.forName( ! "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeThreadR" ).getDeclaredConstructor(mrParameterTypes); ! allocThreadMethodIDFactory=java.lang.Class.forName( ! "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocThreadMethodR" ! ).getDeclaredConstructor(mrParameterTypes); ! allocTypeThreadMethodIDFactory=java.lang.Class.forName( ! "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeThreadMethodR" ).getDeclaredConstructor(mrParameterTypes); ! allocThreadTraceIDFactory=java.lang.Class.forName( ! "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocThreadTraceR" ).getDeclaredConstructor(mrParameterTypes); ! allocTypeThreadTraceIDFactory=java.lang.Class.forName( ! "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeThreadTraceR" ).getDeclaredConstructor(mrParameterTypes); } catch (ClassNotFoundException e) { throw new RuntimeException(e); --- 231,247 ---- "net.sourceforge.javaprofiler.jpiimpl.realtime.AllocTypeThreadTraceR" ).getDeclaredConstructor(mrParameterTypes); ! cpuThreadMethodFactory=java.lang.Class.forName( ! "net.sourceforge.javaprofiler.jpiimpl.realtime.CPUThreadMethodR" ).getDeclaredConstructor(mrParameterTypes); ! cpuThreadTraceFactory=java.lang.Class.forName( ! "net.sourceforge.javaprofiler.jpiimpl.realtime.CPUThreadTraceR" ).getDeclaredConstructor(mrParameterTypes); ! monThreadMethodFactory=java.lang.Class.forName( ! "net.sourceforge.javaprofiler.jpiimpl.realtime.MonThreadMethodR" ).getDeclaredConstructor(mrParameterTypes); ! monThreadTraceFactory=java.lang.Class.forName( ! "net.sourceforge.javaprofiler.jpiimpl.realtime.MonThreadTraceR" ).getDeclaredConstructor(mrParameterTypes); + // init multi-root ID factories } catch (ClassNotFoundException e) { throw new RuntimeException(e); *************** *** 392,395 **** --- 387,398 ---- case IProf.ALLOC_OBJECT_METHOD_TRACE_THREADS: return THREAD_KEY; case IProf.ALLOC_THREAD_METHOD_TRACE_OBJECTS: return TYPE_KEY; + case IProf.CPU_THREAD_METHOD_TRACES: return LOCATION_KEY; + case IProf.CPU_THREAD_METHODS: return LOCATION_KEY; + case IProf.CPU_METHOD_THREADS: return THREAD_KEY; + case IProf.CPU_METHOD_TRACE_THREADS: return THREAD_KEY; + case IProf.MON_THREAD_METHOD_TRACES: return LOCATION_KEY; + case IProf.MON_THREAD_METHODS: return LOCATION_KEY; + case IProf.MON_METHOD_THREADS: return THREAD_KEY; + case IProf.MON_METHOD_TRACE_THREADS: return THREAD_KEY; default: throw new RuntimeException("No branch in switch!"); } Index: MethodR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/MethodR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** MethodR.java 15 Apr 2002 19:46:06 -0000 1.2 --- MethodR.java 14 May 2002 14:47:37 -0000 1.3 *************** *** 81,84 **** --- 81,86 ---- private List allocTypeMethods=new ArrayList(0); private List allocThreadMethods=new ArrayList(0); + private List cpuThreadMethods=new ArrayList(0); + private List monThreadMethods=new ArrayList(0); // unmodifiable variants of lists for children *************** *** 93,96 **** --- 95,102 ---- private List roAllocThreadMethods=Collections.unmodifiableList( allocThreadMethods); + private List roCPUThreadMethods=Collections.unmodifiableList( + cpuThreadMethods); + private List roMonThreadMethods=Collections.unmodifiableList( + monThreadMethods); /** Constructs new object with info. *************** *** 177,183 **** } public List getCPUThreadMethods() { ! //PENDING ! return Collections.EMPTY_LIST; } --- 183,195 ---- } + public void refreshCPUThreadMethods() { + image.extractMultiRoot(this, IProf.CPU_METHOD_THREADS, + image.cpuThreadMethodFactory); + } + public List getCPUThreadMethods() { ! if ( image.getAlwaysRefresh() ) ! refreshCPUThreadMethods(); ! return roCPUThreadMethods; } *************** *** 193,199 **** } public List getMonThreadMethods() { ! //PENDING ! return Collections.EMPTY_LIST; } --- 205,217 ---- } + public void refreshMonThreadMethods() { + image.extractMultiRoot(this, IProf.MON_METHOD_THREADS, + image.monThreadMethodFactory); + } + public List getMonThreadMethods() { ! if ( image.getAlwaysRefresh() ) ! refreshMonThreadMethods(); ! return roMonThreadMethods; } *************** *** 314,317 **** --- 332,343 ---- void addAllocThreadMethod(AllocThreadMethod o) { allocThreadMethods.add(o); + } + + void addCPUThreadMethod(CPUThreadMethod o) { + cpuThreadMethods.add(o); + } + + void addMonThreadMethod(MonThreadMethod o) { + monThreadMethods.add(o); } Index: MonTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/MonTraceR.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** MonTraceR.java 10 Apr 2002 16:01:15 -0000 1.1 --- MonTraceR.java 14 May 2002 14:47:37 -0000 1.2 *************** *** 59,62 **** --- 59,65 ---- private final List roFrames=Collections.unmodifiableList(frames); + // parents + private MethodR method; + // monitor info private long monitorHits; *************** *** 64,68 **** --- 67,75 ---- // lists for children + private final List monThreadTraces=new ArrayList(0); + // unmodifiable variants of lists for children + private final List roMonThreadTraces=Collections.unmodifiableList( + monThreadTraces); /** Constructs new object with info. *************** *** 96,100 **** public Method getParentMethod() { needConstructed(); ! return ((Frame) frames.get(0)).getMethod(); } --- 103,107 ---- public Method getParentMethod() { needConstructed(); ! return method; } *************** *** 102,110 **** public void refreshMonThreadTraces() { } public List getMonThreadTraces() { ! //PENDING ! return Collections.EMPTY_LIST; } --- 109,120 ---- public void refreshMonThreadTraces() { + image.extractMultiRoot(this, IProf.MON_METHOD_TRACE_THREADS, + image.monThreadTraceFactory); } public List getMonThreadTraces() { ! if ( image.getAlwaysRefresh() ) ! refreshMonThreadTraces(); ! return roMonThreadTraces; } *************** *** 148,151 **** --- 158,165 ---- // package / private + void addMonThreadTrace(MonThreadTrace o) { + monThreadTraces.add(o); + } + public AllocTypeR getAllocType() { return null; *************** *** 180,185 **** frames.add(caller); } isReady = true; ! ((MethodR) getParentMethod()).addMonTrace(this); } --- 194,200 ---- frames.add(caller); } + method=(MethodR) ((FrameR) frames.get(frames.size()-1)).getMethod(); isReady = true; ! method.addMonTrace(this); } Index: ThreadR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/ThreadR.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ThreadR.java 21 Apr 2002 19:43:48 -0000 1.3 --- ThreadR.java 14 May 2002 14:47:37 -0000 1.4 *************** *** 80,83 **** --- 80,87 ---- private final List allocThreadMethods=new ArrayList(0); private final List allocThreadTraces=new ArrayList(0); + private final List cpuThreadMethods=new ArrayList(0); + private final List cpuThreadTraces=new ArrayList(0); + private final List monThreadMethods=new ArrayList(0); + private final List monThreadTraces=new ArrayList(0); // unmodifiable variants of lists for children *************** *** 88,91 **** --- 92,103 ---- private final List roAllocThreadTraces=Collections.unmodifiableList( allocThreadTraces); + private final List roCPUThreadMethods=Collections.unmodifiableList( + cpuThreadMethods); + private final List roCPUThreadTraces=Collections.unmodifiableList( + cpuThreadTraces); + private final List roMonThreadMethods=Collections.unmodifiableList( + monThreadMethods); + private final List roMonThreadTraces=Collections.unmodifiableList( + monThreadTraces); /** Constructs new object with info. *************** *** 129,140 **** // children lists getter methods public List getCPUThreadMethods() { ! //PENDING ! return Collections.EMPTY_LIST; } public List getCPUThreadTraces() { ! //PENDING ! return Collections.EMPTY_LIST; } --- 141,169 ---- // children lists getter methods + public void refreshCPUThreadMethods() { + image.extractMultiRoot(this, IProf.CPU_THREAD_METHODS, + image.cpuThreadMethodFactory); + } + public List getCPUThreadMethods() { ! if ( image.getAlwaysRefresh() ) ! refreshCPUThreadMethods(); ! return roCPUThreadMethods; } + public void refreshCPUThreadTraces() { + if (! image.getAlwaysRefresh()) + refreshCPUThreadMethods(); + Iterator it=getCPUThreadMethods().iterator(); + while (it.hasNext()) { + CPUThreadMethodR o=(CPUThreadMethodR) it.next(); + o.refreshCPUThreadTraces(); + } + } + public List getCPUThreadTraces() { ! if ( image.getAlwaysRefresh() ) ! refreshCPUThreadTraces(); ! return roCPUThreadTraces; } *************** *** 166,177 **** } public List getMonThreadMethods() { ! //PENDING ! return Collections.EMPTY_LIST; } public List getMonThreadTraces() { ! //PENDING ! return Collections.EMPTY_LIST; } --- 195,223 ---- } + public void refreshMonThreadMethods() { + image.extractMultiRoot(this, IProf.MON_THREAD_METHODS, + image.monThreadMethodFactory); + } + public List getMonThreadMethods() { ! if ( image.getAlwaysRefresh() ) ! refreshMonThreadMethods(); ! return roMonThreadMethods; } + public void refreshMonThreadTraces() { + if (! image.getAlwaysRefresh()) + refreshMonThreadMethods(); + Iterator it=getMonThreadMethods().iterator(); + while (it.hasNext()) { + MonThreadMethodR o=(MonThreadMethodR) it.next(); + o.refreshMonThreadTraces(); + } + } + public List getMonThreadTraces() { ! if ( image.getAlwaysRefresh() ) ! refreshMonThreadTraces(); ! return roMonThreadTraces; } *************** *** 283,286 **** --- 329,348 ---- void addAllocThreadTrace(AllocThreadTrace o) { allocThreadTraces.add(o); + } + + void addCPUThreadMethod(CPUThreadMethod o) { + cpuThreadMethods.add(o); + } + + void addCPUThreadTrace(CPUThreadTrace o) { + cpuThreadTraces.add(o); + } + + void addMonThreadMethod(MonThreadMethod o) { + monThreadMethods.add(o); + } + + void addMonThreadTrace(MonThreadTrace o) { + monThreadTraces.add(o); } |