Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 92204 Details for
Bug 209727
[ThreadProf] Implement table view for monitors statistics
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
proposed implementation
patch_mon_stat_views.txt (text/plain), 78.78 KB, created by
Alexander N. Alexeev
on 2008-03-11 13:35:31 EDT
(
hide
)
Description:
proposed implementation
Filename:
MIME Type:
Creator:
Alexander N. Alexeev
Created:
2008-03-11 13:35:31 EDT
Size:
78.78 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.trace.jvmti.client >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/messages.properties >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.jvmti.client/src/org/eclipse/tptp/trace/jvmti/internal/client/views/messages.properties,v >retrieving revision 1.13 >diff -u -r1.13 messages.properties >--- src/org/eclipse/tptp/trace/jvmti/internal/client/views/messages.properties 5 Mar 2008 15:45:11 -0000 1.13 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/messages.properties 11 Mar 2008 17:30:35 -0000 >@@ -14,6 +14,7 @@ > # NLS_ENCODING=UTF-8 > > THREAD_STATISTIC_TITLE = Thread Statistics >+MONITOR_STATISTIC_TITLE = Monitor Statistics > THREAD_STATES_TITLE = Threads Visualizer > THREAD_ANALYSIS_TITLE = Threads Analysis > MEM_ANALYSIS_TITLE = Memory Analysis >@@ -106,4 +107,23 @@ > _OBJECT_WAITING_FOR = Object Waiting For > _UNDEFINED_GROUP = <undefined> > _THREAD_GROUP_LABEL = Thread Group [{0}] >-_EDIT_PROFILING_OPTIONS = Edit Profiling Options >\ No newline at end of file >+_EDIT_PROFILING_OPTIONS = Edit Profiling Options >+ >+ >+#Monitor statistics view messages >+_MONITOR_CLASS_NAME = Class Name: >+_MONITOR_CALLER = Caller >+_TOTAL_BLOCKED_TIME = Total Blocked Time >+_TOTAL_WAITING_TIME = Total Waiting Time >+_MAX_AVG_MIN_TIME = Max/Avg/Min Time >+_OBJECT_NUMBER = Object Number >+_THREAD_NUMBER = Thread Number >+_BLOCKED_COUNT = Blocked Count >+_WAITING_CONUT = Waited Count >+_THREAD_ID_TITLE = Thread Id >+_THREAD_NAME_TITLE = Thread Name >+ >+_MONITOR_THREADS_TAB = Threads Statistics >+_MONITOR_CLASSES_TAB = Monitor Classes Statistics >+_MONITOR_BLOCKED_TAB = Blocks Statistics >+_MONITOR_WAITING_TAB = Waits Statistics >\ No newline at end of file >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/UIMessages.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.jvmti.client/src/org/eclipse/tptp/trace/jvmti/internal/client/views/UIMessages.java,v >retrieving revision 1.13 >diff -u -r1.13 UIMessages.java >--- src/org/eclipse/tptp/trace/jvmti/internal/client/views/UIMessages.java 5 Mar 2008 15:45:12 -0000 1.13 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/UIMessages.java 11 Mar 2008 17:30:35 -0000 >@@ -18,6 +18,7 @@ > private static final String BUNDLE_NAME = "org.eclipse.tptp.trace.jvmti.internal.client.views.messages"; //$NON-NLS-1$ > > public static String THREAD_STATISTIC_TITLE; >+ public static String MONITOR_STATISTIC_TITLE; > public static String THREAD_STATES_TITLE; > public static String THREAD_ANALYSIS_TITLE; > public static String MEM_ANALYSIS_TITLE; >@@ -112,6 +113,23 @@ > public static String _THREAD_GROUP_LABEL; > public static String _EDIT_PROFILING_OPTIONS; > >+ //Monitor statistic view >+ public static String _MONITOR_CLASS_NAME; >+ public static String _MONITOR_CALLER; >+ public static String _TOTAL_BLOCKED_TIME; >+ public static String _TOTAL_WAITING_TIME; >+ public static String _MAX_AVG_MIN_TIME; >+ public static String _OBJECT_NUMBER; >+ public static String _THREAD_NUMBER; >+ public static String _BLOCKED_COUNT; >+ public static String _WAITING_CONUT; >+ public static String _THREAD_ID_TITLE; >+ public static String _THREAD_NAME_TITLE; >+ public static String _MONITOR_THREADS_TAB; >+ public static String _MONITOR_CLASSES_TAB; >+ public static String _MONITOR_BLOCKED_TAB; >+ public static String _MONITOR_WAITING_TAB; >+ > private UIMessages() { > // Do not instantiate > } >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesView.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.jvmti.client/src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesView.java,v >retrieving revision 1.3 >diff -u -r1.3 ThreadStatesView.java >--- src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesView.java 5 Mar 2008 15:45:10 -0000 1.3 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesView.java 11 Mar 2008 17:30:35 -0000 >@@ -8,6 +8,7 @@ > * Contributors: > * Intel Corporation - Initial API and implementation > * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * Alexander N. Alexeev, Intel - Add monitors statistics support > * > * $Id: ThreadStatesView.java,v 1.3 2008/03/05 15:45:10 ewchan Exp $ > *****************************************************************************/ >@@ -21,7 +22,6 @@ > import org.eclipse.hyades.trace.ui.internal.util.PerftraceUtil; > import org.eclipse.hyades.trace.views.util.internal.ThreadDetails; > import org.eclipse.hyades.ui.util.GridUtil; >-import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.ControlAdapter; >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadAnalysisPage.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.jvmti.client/src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadAnalysisPage.java,v >retrieving revision 1.1 >diff -u -r1.1 ThreadAnalysisPage.java >--- src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadAnalysisPage.java 20 Apr 2007 13:06:48 -0000 1.1 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadAnalysisPage.java 11 Mar 2008 17:30:35 -0000 >@@ -1,5 +1,5 @@ > /***************************************************************************** >- * Copyright (c) 2007 Intel Corporation. >+ * Copyright (c) 2008 Intel Corporation. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -8,6 +8,7 @@ > * Contributors: > * Intel Corporation - Initial API and implementation > * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * Alexander N. Alexeev, Intel - Add monitors statistics support > * > * $Id: ThreadAnalysisPage.java,v 1.1 2007/04/20 13:06:48 ewchan Exp $ > *****************************************************************************/ >@@ -31,8 +32,9 @@ > public class ThreadAnalysisPage extends TraceViewerPage { > > static public final int TAB_THREAD_STATISTIC = 0; >- static public final int TAB_THREAD_STATES = 1; >- static public final int TAB_NUM = 2; >+ static public final int TAB_MONITOR_STATISTIC = 1; >+ static public final int TAB_THREAD_STATES = 2; >+ static public final int TAB_NUM = 3; > > CTabFolder _tabFolder; > BaseProfilerView _views[]; >@@ -75,7 +77,7 @@ > } > }); > >- _views = new BaseProfilerView[2]; >+ _views = new BaseProfilerView[3]; > CTabItem tabItem; > > tabItem = new CTabItem(_tabFolder, SWT.NONE); >@@ -85,11 +87,17 @@ > tabItem.setControl(_views[0].getControl()); > > tabItem = new CTabItem(_tabFolder, SWT.NONE); >- tabItem.setText(UIMessages.THREAD_STATES_TITLE); >- ThreadStatesView view1 = new ThreadStatesView(_tabFolder, this); >+ tabItem.setText(UIMessages.MONITOR_STATISTIC_TITLE); >+ MonitorStatisticView view1 = new MonitorStatisticView(_tabFolder, this); > _views[1] = view1; >- tabItem.setControl(_views[1].getControl()); >+ tabItem.setControl(_views[1].getControl()); > >+ tabItem = new CTabItem(_tabFolder, SWT.NONE); >+ tabItem.setText(UIMessages.THREAD_STATES_TITLE); >+ ThreadStatesView view2 = new ThreadStatesView(_tabFolder, this); >+ _views[2] = view2; >+ tabItem.setControl(_views[2].getControl()); >+ > _tabFolder.setSelection(selectedTab); > setContextMenu(view0.getTree(), view0.getTreeViewer()); > } >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorThreadStatistics.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorThreadStatistics.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorThreadStatistics.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorThreadStatistics.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,317 @@ >+/********************************************************************** >+ * Copyright (c) 2008, Intel Corporation. >+ * All rights reserved. This content is made available under >+ * the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id$ >+ * >+ * Contributors: >+ * Intel Corporation - Initial API and implementation >+ * Alexander N. Alexeev, Intel - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import org.eclipse.hyades.ui.util.HyadesFormToolkit; >+import org.eclipse.jface.viewers.IBaseLabelProvider; >+import org.eclipse.jface.viewers.IContentProvider; >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.StructuredViewer; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerSorter; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.ViewForm; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Layout; >+import org.eclipse.swt.widgets.Tree; >+import org.eclipse.swt.widgets.TreeColumn; >+import org.eclipse.swt.widgets.TreeItem; >+import org.eclipse.tptp.trace.jvmti.internal.client.widgets.Utils; >+import org.eclipse.ui.forms.widgets.ColumnLayout; >+import org.eclipse.ui.forms.widgets.Section; >+ >+public class MonitorThreadStatistics extends LabelProvider implements ITableLabelProvider, SelectionListener{ >+ >+ // MONSTAT_THREADS_COL_THREAD_ID >+ private final static int MONSTAT_THREADS_COL_THREAD_ID_NUM = 0; >+ private final static int MONSTAT_THREADS_COL_THREAD_ID_DEFW = 60; >+ // MONSTAT_THREADS_COL_THREAD_NAME >+ private final static int MONSTAT_THREADS_COL_THREAD_NAME_NUM = 1; >+ private final static int MONSTAT_THREADS_COL_THREAD_NAME_DEFW = 200; >+ // MONSTAT_THREADS_COL_BLOCKED_COUNT >+ private final static int MONSTAT_THREADS_COL_BLOCKED_COUNT_NUM = 2; >+ private final static int MONSTAT_THREADS_COL_BLOCKED_COUNT_DEFW = 100; >+ // MONSTAT_THREADS_COL_BLOCKED_TIME >+ private final static int MONSTAT_THREADS_COL_BLOCKED_TIME_NUM = 3; >+ private final static int MONSTAT_THREADS_COL_BLOCKED_TIME_DEFW = 100; >+ // MONSTAT_THREADS_COL_WAITED_COUNT >+ private final static int MONSTAT_THREADS_COL_WAITING_COUNT_NUM = 4; >+ private final static int MONSTAT_THREADS_COL_WAITING_COUNT_DEFW = 100; >+ // MONSTAT_THREADS_COL_WAITED_TIME >+ private final static int MONSTAT_THREADS_COL_WAITING_TIME_NUM = 5; >+ private final static int MONSTAT_THREADS_COL_WAITING_TIME_DEFW = 100; >+ >+ //overall column number >+ private final static int MONSTAT_THREADS_COL_NUM = 6; >+ >+ >+ protected Composite _viewContainer; >+ protected ViewForm _dataPane; >+ protected StructuredViewer _viewer; >+ protected ThreadStatisticsSorter _sorter; >+ protected Layout _layout = null; >+ >+ protected HyadesFormToolkit _toolkit; >+ >+ MonitorStatisticController monViewCtrl; >+ >+ >+ >+ public MonitorThreadStatistics(Section section, MonitorStatisticController monViewCtrl) { >+ this.monViewCtrl = monViewCtrl; >+ _toolkit = new HyadesFormToolkit(section.getDisplay()); >+ _dataPane = _toolkit.createViewForm(section); >+ _viewContainer = _dataPane; >+ Control table = createTableViewer(_dataPane); >+ _dataPane.setContent(table); >+ } >+ >+ public Layout getLayout() { >+ if (_layout == null) >+ { >+ _layout = new ColumnLayout(); >+ ((ColumnLayout)_layout).maxNumColumns = 100; >+ } >+ return _layout; >+ } >+ >+ private Control createTableViewer(ViewForm parent) { >+ Tree tree = _toolkit.createTree(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.FLAT); >+ tree.setLinesVisible(true); >+ tree.setHeaderVisible(true); >+ tree.setLayout(getLayout()); >+ tree.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ tree.addSelectionListener(this); >+ >+ _viewer = new TreeViewer(tree); >+ _viewer.setContentProvider(getContentProvider()); >+ _viewer.setLabelProvider(getTableLabelProvider()); >+ >+ _sorter = new ThreadStatisticsSorter(); >+ >+ _viewer.setSorter(_sorter); >+ >+ createColumns(tree); >+ _sorter.changeColumnSelection(0); >+ >+ monViewCtrl.setThreadsViewer(_viewer); >+ return _viewer.getControl(); >+ } >+ >+ >+ private void createColumns(Tree tree) { >+ >+ int colWidth[] = new int[MONSTAT_THREADS_COL_NUM]; >+ String colTitle[] = new String[MONSTAT_THREADS_COL_NUM]; >+ TreeColumn columns[] = new TreeColumn[MONSTAT_THREADS_COL_NUM]; >+ >+ colTitle[MONSTAT_THREADS_COL_THREAD_ID_NUM] = UIMessages._THREAD_ID_TITLE; >+ colWidth[MONSTAT_THREADS_COL_THREAD_ID_NUM] = MONSTAT_THREADS_COL_THREAD_ID_DEFW; >+ colTitle[MONSTAT_THREADS_COL_THREAD_NAME_NUM] = UIMessages._THREAD_NAME_TITLE; >+ colWidth[MONSTAT_THREADS_COL_THREAD_NAME_NUM] = MONSTAT_THREADS_COL_THREAD_NAME_DEFW; >+ colTitle[MONSTAT_THREADS_COL_BLOCKED_COUNT_NUM] = UIMessages._BLOCKED_COUNT; >+ colWidth[MONSTAT_THREADS_COL_BLOCKED_COUNT_NUM] = MONSTAT_THREADS_COL_BLOCKED_COUNT_DEFW; >+ colTitle[MONSTAT_THREADS_COL_BLOCKED_TIME_NUM] = UIMessages._THREAD_BLOCKED_TIME; >+ colWidth[MONSTAT_THREADS_COL_BLOCKED_TIME_NUM] = MONSTAT_THREADS_COL_BLOCKED_TIME_DEFW; >+ colTitle[MONSTAT_THREADS_COL_WAITING_COUNT_NUM] = UIMessages._WAITING_CONUT; >+ colWidth[MONSTAT_THREADS_COL_WAITING_COUNT_NUM] = MONSTAT_THREADS_COL_WAITING_COUNT_DEFW; >+ colTitle[MONSTAT_THREADS_COL_WAITING_TIME_NUM] = UIMessages._THREAD_WAITING_TIME; >+ colWidth[MONSTAT_THREADS_COL_WAITING_TIME_NUM] = MONSTAT_THREADS_COL_WAITING_TIME_DEFW; >+ >+ >+ for (int i = 0; i < MONSTAT_THREADS_COL_NUM; i++) { >+ columns[i] = new TreeColumn(tree, SWT.NULL | SWT.NO_BACKGROUND | SWT.LEFT); >+ columns[i].setResizable(true); >+ columns[i].setText(colTitle[i]); >+ columns[i].setWidth(colWidth[i]); >+ columns[i].addSelectionListener(getColumnSelectionListener(i)); >+ } >+ >+ _sorter.setColumns(columns); >+ } >+ >+ SelectionListener getColumnSelectionListener(final int columnIndex) { >+ return new SelectionListener(){ >+ public void widgetSelected(SelectionEvent e) { >+ _sorter.changeColumnSelection(columnIndex); >+ _viewer.refresh(); >+ } >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ }; >+ } >+ >+ private IBaseLabelProvider getTableLabelProvider() { >+ return this; >+ } >+ >+ private IContentProvider getContentProvider() { >+ return new MonitorThreadStatisticContentProvider(); >+ } >+ >+ public Composite getViewContainer() { >+ return _viewContainer; >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ if (!(e.widget instanceof Tree)) { >+ // TODO add assert >+ return; >+ } >+ >+ Tree tree = (Tree)e.widget; >+ TreeItem[] selectedItems = tree.getSelection(); >+ MonitorThreadDetails[] threads = new MonitorThreadDetails[selectedItems.length]; >+ for (int i = 0; i < selectedItems.length; i++) { >+ threads[i] = (MonitorThreadDetails)selectedItems[i].getData(); >+ } >+ monViewCtrl.setSelectedThreads(threads); >+ } >+ >+ public Image getColumnImage(Object element, int columnIndex) { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public String getColumnText(Object element, int columnIndex) { >+ if (!(element instanceof MonitorThreadDetails)) { >+ // TODO add assert >+ return null; >+ } >+ >+ MonitorThreadDetails threadDetails = (MonitorThreadDetails)element; >+ switch (columnIndex) { >+ case MONSTAT_THREADS_COL_THREAD_ID_NUM: >+ return new Integer(threadDetails.getThread().getId()).toString(); >+ case MONSTAT_THREADS_COL_THREAD_NAME_NUM: >+ return (threadDetails.getThread().getName()); >+ case MONSTAT_THREADS_COL_BLOCKED_COUNT_NUM: >+ return new Integer(threadDetails.getBlockedCount()).toString(); >+ case MONSTAT_THREADS_COL_BLOCKED_TIME_NUM: >+ return Utils.formatTime(threadDetails.getBlockTime()).toString(); >+ case MONSTAT_THREADS_COL_WAITING_COUNT_NUM: >+ return new Integer(threadDetails.getWaitCount()).toString(); >+ case MONSTAT_THREADS_COL_WAITING_TIME_NUM: >+ return Utils.formatTime(threadDetails.getWaitingTime()).toString(); >+ default: >+ break; >+ } >+ return null; >+ } >+ >+ >+ class ThreadStatisticsSorter extends ViewerSorter { >+ >+ private int sortedIdx = -1; >+ private boolean ascOrder = true; >+ //private TreeColumn columns[] = null; >+ >+ void changeColumnSelection(int idx) { >+ if (sortedIdx == idx) { >+ ascOrder = !ascOrder; >+ } >+ else { >+ ascOrder = true; >+ } >+ sortedIdx = idx; >+ } >+ >+ void setColumns(TreeColumn columns[]) { >+ //this.columns = columns; >+ } >+ >+ public int compare(Viewer viewer, Object e1, Object e2) { >+ if (!(e1 instanceof MonitorThreadDetails) || >+ !(e2 instanceof MonitorThreadDetails)) { >+ return 0; >+ } >+ MonitorThreadDetails td1 = (MonitorThreadDetails)e1; >+ MonitorThreadDetails td2 = (MonitorThreadDetails)e2; >+ int result = 0; >+ >+ switch (sortedIdx) { >+ case MONSTAT_THREADS_COL_THREAD_ID_NUM: >+ result = td1.getThread().getId() - td2.getThread().getId(); >+ break; >+ case MONSTAT_THREADS_COL_THREAD_NAME_NUM: >+ result = td1.getThread().getName().compareTo(td2.getThread().getName()); >+ break; >+ case MONSTAT_THREADS_COL_BLOCKED_COUNT_NUM: >+ result = td1.getBlockedCount() - td2.getBlockedCount(); >+ break; >+ case MONSTAT_THREADS_COL_BLOCKED_TIME_NUM: >+ result = new Double(td1.getBlockTime()).compareTo(new Double (td2.getBlockTime())); >+ break; >+ case MONSTAT_THREADS_COL_WAITING_COUNT_NUM: >+ result = td1.getWaitCount() - td2.getWaitCount(); >+ break; >+ case MONSTAT_THREADS_COL_WAITING_TIME_NUM: >+ result = new Double(td1.getWaitingTime()).compareTo(new Double (td2.getWaitingTime())); >+ break; >+ default: >+ break; >+ } >+ return ascOrder ? result : -result; >+ } >+ >+ public boolean isSorterProperty(Object element, String property) { >+ return true; >+ } >+ } >+} >+ >+class MonitorThreadStatisticContentProvider implements ITreeContentProvider { >+ >+ Object[] threads; >+ >+ public Object[] getChildren(Object parentElement) { >+ return null; >+ } >+ >+ public Object getParent(Object element) { >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ return false; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ return threads; >+ } >+ >+ public void dispose() { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ if (newInput instanceof Object[]) { >+ threads = (Object[])newInput; >+ } >+ } >+ >+} >+ >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorThreadDetails.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorThreadDetails.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorThreadDetails.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorThreadDetails.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,135 @@ >+/********************************************************************** >+ * Copyright (c) 2008, Intel Corporation. >+ * All rights reserved. This content is made available under >+ * the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id$ >+ * >+ * Contributors: >+ * Intel Corporation - Initial API and implementation >+ * Alexander N. Alexeev, Intel - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.hyades.models.trace.TRCClass; >+import org.eclipse.hyades.models.trace.TRCObject; >+import org.eclipse.hyades.models.trace.TRCThread; >+import org.eclipse.hyades.models.trace.TRCThreadEvent; >+import org.eclipse.hyades.models.trace.TRCThreadSleepingEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForLockEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForObjectEvent; >+import org.eclipse.hyades.trace.ui.internal.util.PerftraceUtil; >+ >+ >+public class MonitorThreadDetails{ >+ >+ protected HashMap _classMap = new HashMap(); >+ >+ protected TRCThread _thread; >+ >+ protected double _lastUpdateTime = 0; >+ >+ protected double _sleepTime; >+ protected int _sleepCount; >+ >+ protected double _waitTime; >+ protected int _waitCount; >+ >+ protected double _blockTime; >+ protected int _blockCount; >+ >+ public MonitorThreadDetails(TRCThread thread) { >+ _thread = thread; >+ recalculate(); >+ } >+ >+ public void recalculate() { >+ EList events = _thread.getThreadEvents(); >+ int count = events.size(); >+ if (count > 0) { >+ TRCThreadEvent event = (TRCThreadEvent)events.get(0); >+ for (int i = 1; i < count; i++){ >+ TRCThreadEvent next = (TRCThreadEvent)events.get(i); >+ double timeSpan = Math.max(next.getTime() - event.getTime(), 0); >+ >+ updateMonitorsData(event, timeSpan); >+ MonitorClassDetails monObjectClass = getObjectClass(event); >+ if (null != monObjectClass) { >+ monObjectClass.updateMonitorsData(event, timeSpan); >+ } >+ >+ event = next; >+ } >+ _lastUpdateTime = ((TRCThreadEvent)events.get(count - 1)).getTime(); >+ } >+ } >+ >+ private void updateMonitorsData(TRCThreadEvent event, double timeSpan) { >+ if(event instanceof TRCThreadSleepingEvent) { >+ _sleepTime += timeSpan; >+ _sleepCount++; >+ } else if(event instanceof TRCThreadWaitingForObjectEvent) { >+ _waitTime += timeSpan; >+ _waitCount++; >+ } else if(event instanceof TRCThreadWaitingForLockEvent) { >+ _blockTime += timeSpan; >+ _blockCount++; >+ } >+ } >+ >+ private MonitorClassDetails getObjectClass(TRCThreadEvent event) { >+ TRCObject monObject = null; >+ if(event instanceof TRCThreadWaitingForObjectEvent) { >+ monObject = ((TRCThreadWaitingForObjectEvent)event).getObjectWaitingFor(); >+ } else if(event instanceof TRCThreadWaitingForLockEvent) { >+ monObject = ((TRCThreadWaitingForLockEvent)event).getLockedObject(); >+ } else { >+ return null; >+ } >+ TRCClass monObjClass = PerftraceUtil.getClass(monObject); >+ if (!_classMap.containsKey(monObjClass)) { >+ MonitorClassDetails classDetails = new MonitorClassDetails(monObjClass); >+ _classMap.put(monObjClass, classDetails); >+ return classDetails; >+ } >+ return (MonitorClassDetails)_classMap.get(monObjClass); >+ } >+ >+ public TRCThread getThread() { >+ return _thread; >+ } >+ >+ public int getBlockedCount() { >+ return _blockCount; >+ } >+ >+ public int getWaitCount() { >+ return _waitCount; >+ } >+ >+ public int getSleepCount() { >+ return _sleepCount; >+ } >+ >+ public double getBlockTime() { >+ return _blockTime; >+ } >+ >+ public double getSleepTime() { >+ return _sleepTime; >+ } >+ >+ public double getWaitingTime() { >+ return _waitTime; >+ } >+ >+ public Map getClassMap() { >+ return _classMap; >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassWaitingStatistics.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassWaitingStatistics.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassWaitingStatistics.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassWaitingStatistics.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,297 @@ >+/********************************************************************** >+ * Copyright (c) 2008, Intel Corporation. >+ * All rights reserved. This content is made available under >+ * the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id$ >+ * >+ * Contributors: >+ * Intel Corporation - Initial API and implementation >+ * Alexander N. Alexeev, Intel - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import org.eclipse.hyades.ui.util.HyadesFormToolkit; >+import org.eclipse.jface.viewers.IBaseLabelProvider; >+import org.eclipse.jface.viewers.IContentProvider; >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.StructuredViewer; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerSorter; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.ViewForm; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Layout; >+import org.eclipse.swt.widgets.Tree; >+import org.eclipse.swt.widgets.TreeColumn; >+import org.eclipse.tptp.trace.jvmti.internal.client.widgets.Utils; >+import org.eclipse.ui.forms.widgets.ColumnLayout; >+import org.eclipse.ui.forms.widgets.Section; >+ >+public class MonitorClassWaitingStatistics extends LabelProvider implements ITableLabelProvider, SelectionListener{ >+ >+ private final static int MONSTAT_WAITTIME_COL_CALLER_NUM = 0; >+ private final static int MONSTAT_WAITTIME_COL_CALLER_DEFW = 250; >+ private final static int MONSTAT_WAITTIME_COL_TOTAL_TIME_NUM = 1; >+ private final static int MONSTAT_WAITTIME_COL_TOTAL_TIME_DEFW = 100; >+ private final static int MONSTAT_WAITTIME_COL_COUNT_NUM = 2; >+ private final static int MONSTAT_WAITTIME_COL_COUNT_DEFW = 100; >+ private final static int MONSTAT_WAITTIME_COL_STAT_NUM = 3; >+ private final static int MONSTAT_WAITTIME_COL_STAT_DEFW = 200; >+ private final static int MONSTAT_WAITTIME_COL_OBJECT_NUM_NUM = 4; >+ private final static int MONSTAT_WAITTIME_COL_OBJECT_NUM_DEFW = 100; >+ private final static int MONSTAT_WAITTIME_COL_THREAD_NUM_NUM = 5; >+ private final static int MONSTAT_WAITTIME_COL_THREAD_NUM_DEFW = 100; >+ >+ //overall column number >+ private final static int MONSTAT_WAITTIME_COL_NUM = 6; >+ >+ >+ protected Composite _viewContainer; >+ protected ViewForm _dataPane; >+ protected StructuredViewer _viewer; >+ protected Layout _layout = null; >+ MonitorWaitingStatisticsSorter _sorter; >+ >+ protected HyadesFormToolkit _toolkit; >+ >+ MonitorStatisticController monViewCtrl; >+ >+ >+ public MonitorClassWaitingStatistics(Section section, MonitorStatisticController monViewCtrl) { >+ this.monViewCtrl = monViewCtrl; >+ _toolkit = new HyadesFormToolkit(section.getDisplay()); >+ _dataPane = _toolkit.createViewForm(section); >+ _viewContainer = _dataPane; >+ Control table = createTableViewer(_dataPane); >+ _dataPane.setContent(table); >+ } >+ >+ public Layout getLayout() { >+ if (_layout == null) >+ { >+ _layout = new ColumnLayout(); >+ ((ColumnLayout)_layout).maxNumColumns = 100; >+ } >+ return _layout; >+ } >+ >+ private Control createTableViewer(ViewForm parent) { >+ Tree tree = _toolkit.createTree(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.FLAT); >+ >+ tree.setLinesVisible(true); >+ tree.setHeaderVisible(true); >+ tree.setLayout(getLayout()); >+ tree.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ tree.addSelectionListener(this); >+ >+ _viewer = new TreeViewer(tree); >+ _viewer.setContentProvider(getContentProvider()); >+ _viewer.setLabelProvider(getTableLabelProvider()); >+ _sorter = new MonitorWaitingStatisticsSorter(); >+ _viewer.setSorter(_sorter); >+ >+ createColumns(tree); >+ _sorter.changeColumnSelection(0); >+ >+ monViewCtrl.setWaitTimeViewer(_viewer); >+ return _viewer.getControl(); >+ } >+ >+ private void createColumns(Tree tree) { >+ >+ int colWidth[] = new int[MONSTAT_WAITTIME_COL_NUM]; >+ String colTitle[] = new String[MONSTAT_WAITTIME_COL_NUM]; >+ TreeColumn columns[] = new TreeColumn[MONSTAT_WAITTIME_COL_NUM]; >+ >+ colTitle[MONSTAT_WAITTIME_COL_CALLER_NUM] = UIMessages._MONITOR_CALLER; >+ colWidth[MONSTAT_WAITTIME_COL_CALLER_NUM] = MONSTAT_WAITTIME_COL_CALLER_DEFW; >+ colTitle[MONSTAT_WAITTIME_COL_TOTAL_TIME_NUM] = UIMessages._TOTAL_WAITING_TIME; >+ colWidth[MONSTAT_WAITTIME_COL_TOTAL_TIME_NUM] = MONSTAT_WAITTIME_COL_TOTAL_TIME_DEFW; >+ colTitle[MONSTAT_WAITTIME_COL_COUNT_NUM] = UIMessages._WAITING_CONUT; >+ colWidth[MONSTAT_WAITTIME_COL_COUNT_NUM] = MONSTAT_WAITTIME_COL_COUNT_DEFW; >+ colTitle[MONSTAT_WAITTIME_COL_STAT_NUM] = UIMessages._MAX_AVG_MIN_TIME; >+ colWidth[MONSTAT_WAITTIME_COL_STAT_NUM] = MONSTAT_WAITTIME_COL_STAT_DEFW; >+ colTitle[MONSTAT_WAITTIME_COL_OBJECT_NUM_NUM] = UIMessages._OBJECT_NUMBER; >+ colWidth[MONSTAT_WAITTIME_COL_OBJECT_NUM_NUM] = MONSTAT_WAITTIME_COL_OBJECT_NUM_DEFW; >+ colTitle[MONSTAT_WAITTIME_COL_THREAD_NUM_NUM] = UIMessages._THREAD_NUMBER; >+ colWidth[MONSTAT_WAITTIME_COL_THREAD_NUM_NUM] = MONSTAT_WAITTIME_COL_THREAD_NUM_DEFW; >+ >+ for (int i = 0; i < MONSTAT_WAITTIME_COL_NUM; i++) { >+ columns[i] = new TreeColumn(tree, SWT.NULL | SWT.NO_BACKGROUND | SWT.LEFT); >+ columns[i].setResizable(true); >+ columns[i].setText(colTitle[i]); >+ columns[i].setWidth(colWidth[i]); >+ columns[i].addSelectionListener(getColumnSelectionListener(i)); >+ } >+ >+ _sorter.setColumns(columns); >+ } >+ >+ SelectionListener getColumnSelectionListener(final int columnIndex) { >+ return new SelectionListener(){ >+ public void widgetSelected(SelectionEvent e) { >+ _sorter.changeColumnSelection(columnIndex); >+ _viewer.refresh(); >+ } >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ }; >+ } >+ >+ private IBaseLabelProvider getTableLabelProvider() { >+ return this; >+ } >+ >+ private IContentProvider getContentProvider() { >+ return new MonitorWaitTimeStatisticContentProvider(); >+ } >+ >+ public Composite getViewContainer() { >+ return _viewContainer; >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ } >+ >+ public Image getColumnImage(Object element, int columnIndex) { >+ return null; >+ } >+ >+ public String getColumnText(Object element, int columnIndex) { >+ if (!(element instanceof MonitorCallDetails)) { >+ // TODO add assert >+ return null; >+ } >+ MonitorCallDetails monCallDetails = (MonitorCallDetails)element; >+ >+ switch (columnIndex) { >+ case MONSTAT_WAITTIME_COL_CALLER_NUM: >+ return monCallDetails.getCallTitle(); >+ case MONSTAT_WAITTIME_COL_TOTAL_TIME_NUM: >+ return Utils.formatTime(monCallDetails.getWaitingTime()); >+ case MONSTAT_WAITTIME_COL_COUNT_NUM: >+ return new Integer(monCallDetails.getWaitingCount()).toString(); >+ case MONSTAT_WAITTIME_COL_STAT_NUM: >+ return Utils.formatTime(monCallDetails.getMaxWaitingTime()) + " / " + >+ Utils.formatTime(monCallDetails.getAvgWaitingTime()) + " / " + >+ Utils.formatTime(monCallDetails.getMinWaitingTime()); >+ case MONSTAT_WAITTIME_COL_OBJECT_NUM_NUM: >+ return new Integer(monCallDetails.getWaitingObjectsCount()).toString(); >+ case MONSTAT_WAITTIME_COL_THREAD_NUM_NUM: >+ return new Integer(monCallDetails.getWaitingThreadsCount()).toString(); >+ default: >+ break; >+ } >+ return null; >+ >+ } >+ >+ class MonitorWaitingStatisticsSorter extends ViewerSorter { >+ >+ private int sortedIdx = -1; >+ private boolean ascOrder = true; >+ //private TreeColumn columns[] = null; >+ >+ void changeColumnSelection(int idx) { >+ // column isn't sortable >+ if (MONSTAT_WAITTIME_COL_STAT_NUM == idx) >+ return; >+ >+ if (sortedIdx == idx) { >+ ascOrder = !ascOrder; >+ } >+ else { >+ ascOrder = true; >+ } >+ sortedIdx = idx; >+ } >+ >+ void setColumns(TreeColumn columns[]) { >+ //this.columns = columns; >+ } >+ >+ public int compare(Viewer viewer, Object e1, Object e2) { >+ if (!(e1 instanceof MonitorCallDetails) || >+ !(e2 instanceof MonitorCallDetails)) { >+ return 0; >+ } >+ >+ MonitorCallDetails cd1 = (MonitorCallDetails)e1; >+ MonitorCallDetails cd2 = (MonitorCallDetails)e2; >+ int result = 0; >+ >+ switch (sortedIdx) { >+ case MONSTAT_WAITTIME_COL_CALLER_NUM: >+ result = cd1.getCallTitle().compareTo(cd2.getCallTitle()); >+ break; >+ case MONSTAT_WAITTIME_COL_COUNT_NUM: >+ result = cd1.getWaitingCount() - cd2.getWaitingCount(); >+ break; >+ case MONSTAT_WAITTIME_COL_TOTAL_TIME_NUM: >+ result = new Double(cd1.getWaitingTime()) >+ .compareTo(new Double (cd2.getWaitingTime())); >+ break; >+ case MONSTAT_WAITTIME_COL_OBJECT_NUM_NUM: >+ result = cd1.getWaitingObjectsCount() - cd2.getWaitingObjectsCount(); >+ break; >+ case MONSTAT_WAITTIME_COL_THREAD_NUM_NUM: >+ result = cd1.getWaitingThreadsCount() - cd2.getWaitingThreadsCount(); >+ break; >+ default: >+ break; >+ } >+ >+ return ascOrder ? result : -result; >+ } >+ >+ public boolean isSorterProperty(Object element, String property) { >+ return true; >+ } >+ >+ } >+} >+ >+class MonitorWaitTimeStatisticContentProvider implements ITreeContentProvider { >+ >+ Object[] calls; >+ >+ public Object[] getChildren(Object parentElement) { >+ return null; >+ } >+ >+ public Object getParent(Object element) { >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ return false; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ return calls; >+ } >+ >+ public void dispose() { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ if (newInput instanceof Object[]) { >+ calls = (Object[])newInput; >+ } >+ } >+ >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorStatisticController.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorStatisticController.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorStatisticController.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorStatisticController.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,177 @@ >+/********************************************************************** >+ * Copyright (c) 2008, Intel Corporation. >+ * All rights reserved. This content is made available under >+ * the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id$ >+ * >+ * Contributors: >+ * Intel Corporation - Initial API and implementation >+ * Alexander N. Alexeev, Intel - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import java.util.HashMap; >+ >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.hyades.models.trace.TRCClass; >+import org.eclipse.hyades.models.trace.TRCObject; >+import org.eclipse.hyades.models.trace.TRCThread; >+import org.eclipse.hyades.models.trace.TRCThreadEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForLockEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForObjectEvent; >+import org.eclipse.hyades.trace.ui.internal.util.PerftraceUtil; >+import org.eclipse.jface.viewers.StructuredViewer; >+import org.eclipse.ui.forms.widgets.Form; >+ >+public class MonitorStatisticController { >+ >+ private EObject modelRoot; >+ >+ StructuredViewer _threadsViewer; >+ StructuredViewer _classesViewer; >+ StructuredViewer _blockTimeViewer; >+ StructuredViewer _waitTimeViewer; >+ Form _classNameLable; >+ >+ HashMap _threads = new HashMap(); >+ >+ public void setMOFObject(EObject object) { >+ modelRoot = object; >+ initialize(); >+ } >+ >+ public void setThreadsViewer(StructuredViewer _viewer) { >+ _threadsViewer = _viewer; >+ } >+ >+ public void setClassesTimeViewer(StructuredViewer _viewer) { >+ _classesViewer = _viewer; >+ } >+ >+ public void setClassLabel(Form _form) { >+ _classNameLable = _form; >+ } >+ >+ public void setBlockTimeViewer(StructuredViewer _viewer) { >+ _blockTimeViewer = _viewer; >+ } >+ >+ public void setWaitTimeViewer(StructuredViewer _viewer) { >+ _waitTimeViewer = _viewer; >+ } >+ >+ public void update() { >+ //recalculate(); >+ _threadsViewer.setInput(_threads.values().toArray()); >+ } >+ >+ public void setSelectedThreads(MonitorThreadDetails[] threads) { >+ _classNameLable.setText(UIMessages._MONITOR_CLASS_NAME); >+ _classesViewer.setInput(getMonitorClasses(threads)); >+ _blockTimeViewer.setInput(null); >+ _waitTimeViewer.setInput(null); >+ } >+ >+ private Object[] getMonitorClasses(MonitorThreadDetails[] threads) { >+ return mergeClassDetails(threads); >+ } >+ >+ private Object[] mergeClassDetails(MonitorThreadDetails[] threads){ >+ if (threads.length == 1) { >+ return threads[0].getClassMap().values().toArray(); >+ } >+ >+ // TODO: VERY ineffective implementation, should be improved!!! >+ HashMap classMap = new HashMap(); >+ >+ for (int t = 0; t < threads.length; t++) { >+ TRCThread thread = threads[t].getThread(); >+ EList events = thread.getThreadEvents(); >+ int count = events.size(); >+ if (count > 0) { >+ TRCThreadEvent event = (TRCThreadEvent)events.get(0); >+ for (int i = 1; i < count; i++){ >+ TRCThreadEvent next = (TRCThreadEvent)events.get(i); >+ double timeSpan = Math.max(next.getTime() - event.getTime(), 0); >+ >+ >+ TRCObject monObject = null; >+ MonitorClassDetails classDetails = null; >+ >+ if(event instanceof TRCThreadWaitingForObjectEvent) { >+ monObject = ((TRCThreadWaitingForObjectEvent)event).getObjectWaitingFor(); >+ } else if(event instanceof TRCThreadWaitingForLockEvent) { >+ monObject = ((TRCThreadWaitingForLockEvent)event).getLockedObject(); >+ } >+ >+ if (monObject != null) { >+ TRCClass monObjClass = PerftraceUtil.getClass(monObject); >+ if (!classMap.containsKey(monObjClass)) { >+ classDetails = new MonitorClassDetails(monObjClass); >+ classMap.put(monObjClass, classDetails); >+ } >+ else { >+ classDetails = (MonitorClassDetails)classMap.get(monObjClass); >+ } >+ } >+ >+ if (null != classDetails) { >+ classDetails.updateMonitorsData(event, timeSpan); >+ } >+ >+ event = next; >+ } >+ } >+ } >+ >+ return classMap.values().toArray(); >+ } >+ >+ >+ public void setSelectedClass(Object classDesc) { >+ _classNameLable.setText(UIMessages._MONITOR_CLASS_NAME + " " >+ + ((MonitorClassDetails)classDesc).getClassObj().getName()); >+ _blockTimeViewer.setInput(getBlockObjects(classDesc)); >+ _waitTimeViewer.setInput(getWaitObjects(classDesc)); >+ } >+ >+ private Object[] getWaitObjects(Object classDesc) { >+ if (classDesc instanceof MonitorClassDetails) { >+ return ((MonitorClassDetails)classDesc).getWaitCalls(); >+ } >+ return null; >+ } >+ >+ private Object[] getBlockObjects(Object classDesc) { >+ if (classDesc instanceof MonitorClassDetails) { >+ return ((MonitorClassDetails)classDesc).getBlockCalls(); >+ } >+ return null; >+ } >+ >+ private void initialize() { >+ Object allThreads[] = PerftraceUtil.getAllThreads(modelRoot, false); >+ for (int i = 0; i < allThreads.length; i++) { >+ _threads.put(allThreads[i], new MonitorThreadDetails((TRCThread)allThreads[i])); >+ } >+ } >+ >+// private void recalculate() { >+// Object allThreads[] = PerftraceUtil.getAllThreads(modelRoot, false); >+// for (int i = 0; i < allThreads.length; i++) { >+// MonStatThreadDetails threadDetails = null; >+// if (!_threads.containsKey(allThreads[i])) { >+// threadDetails = new MonStatThreadDetails((TRCThread)allThreads[i]); >+// _threads.put(allThreads[i], threadDetails); >+// } else { >+// threadDetails = (MonStatThreadDetails)_threads.get(allThreads[i]); >+// } >+// threadDetails.recalculate(); >+// } >+// } >+ >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorStatisticView.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorStatisticView.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorStatisticView.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorStatisticView.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,116 @@ >+/********************************************************************** >+ * Copyright (c) 2008, Intel Corporation. >+ * All rights reserved. This content is made available under >+ * the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id$ >+ * >+ * Contributors: >+ * Intel Corporation - Initial API and implementation >+ * Alexander N. Alexeev, Intel - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import org.eclipse.hyades.trace.ui.TraceViewerPage; >+import org.eclipse.hyades.ui.util.HyadesFormToolkit; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.FillLayout; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.ui.forms.widgets.Form; >+import org.eclipse.ui.forms.widgets.Section; >+ >+public class MonitorStatisticView extends BaseProfilerView { >+ >+ private final static String TABLE_SECTION_THREAD_TITLE = UIMessages._MONITOR_THREADS_TAB; >+ private final static String TABLE_SECTION_MON_CLASSES_TITLE = UIMessages._MONITOR_CLASSES_TAB; >+ private final static String TABLE_SECTION_MON_BLOCKED_TITLE = UIMessages._MONITOR_BLOCKED_TAB; >+ private final static String TABLE_SECTION_MON_WAITING_TITLE = UIMessages._MONITOR_WAITING_TAB; >+ >+ private HyadesFormToolkit _toolkit; >+ private MonitorThreadStatistics _threadsStatistics; >+ private MonitorClassStatistics _monitorsStatistics; >+ private MonitorClassBlockedStatistics _classBlockTimeStatistics; >+ private MonitorClassWaitingStatistics _classWaitTimeStatistics; >+ private Form _form; >+ private MonitorStatisticController monViewCtrl; >+ >+ public MonitorStatisticView(Composite parent, TraceViewerPage page) { >+ super(parent, page); >+ } >+ >+ protected Control createDataViewer(Composite parent) { >+ _toolkit = new HyadesFormToolkit(parent.getDisplay()); >+ monViewCtrl = new MonitorStatisticController(); >+ monViewCtrl.setMOFObject(_page.getMOFObject()); >+ Composite monitorComposite = _toolkit.createComposite(parent); >+ monitorComposite.setLayout(new FillLayout(SWT.VERTICAL)); >+ >+ Composite sourceComposite = _toolkit.createComposite(monitorComposite); >+ sourceComposite.setLayout(new FillLayout(SWT.VERTICAL)); >+ createThreadsSection(sourceComposite); >+ createMonitorsSection(sourceComposite); >+ >+ _form = _toolkit.createForm(monitorComposite); >+ _form.setText(UIMessages._MONITOR_CLASS_NAME); >+ _form.getBody().setLayout(new FillLayout(SWT.VERTICAL)); >+ monViewCtrl.setClassLabel(_form); >+ >+ createClassBlockSection(_form.getBody()); >+ createClassWaitSection(_form.getBody()); >+ return monitorComposite; >+ } >+ >+ protected String getViewTypeStr() { >+ return "viewoption.monitors"; >+ } >+ >+ protected void update() { >+ monViewCtrl.update(); >+ } >+ >+ private void createThreadsSection(Composite parent) { >+ Section section = _toolkit.createSection(parent, Section.TITLE_BAR); >+ section.setText(TABLE_SECTION_THREAD_TITLE); >+ section.marginWidth = 3; >+ section.marginHeight = 3; >+ section.setLayout(new GridLayout()); >+ _threadsStatistics = new MonitorThreadStatistics (section, monViewCtrl); >+ section.setClient(_threadsStatistics.getViewContainer()); >+ } >+ >+ private void createMonitorsSection(Composite parent) { >+ Section section = _toolkit.createSection(parent, Section.TITLE_BAR); >+ section.setText(TABLE_SECTION_MON_CLASSES_TITLE); >+ section.marginWidth = 3; >+ section.marginHeight = 3; >+ section.setLayout(new GridLayout()); >+ _monitorsStatistics = new MonitorClassStatistics (section, monViewCtrl); >+ section.setClient(_monitorsStatistics.getViewContainer()); >+ } >+ >+ private void createClassBlockSection(Composite parent) { >+ Section section = _toolkit.createSection(parent, Section.TITLE_BAR); >+ section.setText(TABLE_SECTION_MON_BLOCKED_TITLE); >+ section.marginWidth = 3; >+ section.marginHeight = 3; >+ section.setLayout(new GridLayout()); >+ _classBlockTimeStatistics = new MonitorClassBlockedStatistics (section, monViewCtrl); >+ section.setClient(_classBlockTimeStatistics.getViewContainer()); >+ } >+ >+ private void createClassWaitSection(Composite parent) { >+ Section section = _toolkit.createSection(parent, Section.TITLE_BAR); >+ section.setText(TABLE_SECTION_MON_WAITING_TITLE); >+ section.marginWidth = 3; >+ section.marginHeight = 3; >+ section.setLayout(new GridLayout()); >+ _classWaitTimeStatistics = new MonitorClassWaitingStatistics (section, monViewCtrl); >+ section.setClient(_classWaitTimeStatistics.getViewContainer()); >+ } >+ >+ >+} >Index: .settings/org.eclipse.jdt.core.prefs >=================================================================== >RCS file: .settings/org.eclipse.jdt.core.prefs >diff -N .settings/org.eclipse.jdt.core.prefs >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .settings/org.eclipse.jdt.core.prefs 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,12 @@ >+#Mon Feb 18 18:56:17 MSK 2008 >+eclipse.preferences.version=1 >+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled >+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 >+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve >+org.eclipse.jdt.core.compiler.compliance=1.4 >+org.eclipse.jdt.core.compiler.debug.lineNumber=generate >+org.eclipse.jdt.core.compiler.debug.localVariable=generate >+org.eclipse.jdt.core.compiler.debug.sourceFile=generate >+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning >+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning >+org.eclipse.jdt.core.compiler.source=1.3 >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassDetails.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassDetails.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassDetails.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassDetails.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,91 @@ >+/********************************************************************** >+ * Copyright (c) 2008, Intel Corporation. >+ * All rights reserved. This content is made available under >+ * the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id$ >+ * >+ * Contributors: >+ * Intel Corporation - Initial API and implementation >+ * Alexander N. Alexeev, Intel - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import java.util.HashMap; >+ >+import org.eclipse.hyades.models.trace.TRCClass; >+import org.eclipse.hyades.models.trace.TRCThreadEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForLockEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForObjectEvent; >+ >+public class MonitorClassDetails { >+ >+ protected HashMap _monWaitCallSites = new HashMap(); >+ protected HashMap _monBlockCallSites = new HashMap(); >+ >+ protected TRCClass _monClass; >+ >+ protected double _blockTime; >+ protected int _blockCount; >+ protected double _waitTime; >+ protected int _waitCount; >+ >+ MonitorClassDetails(TRCClass monClass) { >+ this._monClass = monClass; >+ } >+ >+ public int getWaitingCount() { >+ return _waitCount; >+ } >+ >+ public int getBlockedCount() { >+ return _blockCount; >+ } >+ >+ public TRCClass getClassObj() { >+ return _monClass; >+ } >+ >+ public double getBlockedTime() { >+ return _blockTime; >+ } >+ >+ public double getWaitingTime () { >+ return _waitTime; >+ } >+ >+ public void updateMonitorsData(TRCThreadEvent event, double timeSpan) { >+ if(event instanceof TRCThreadWaitingForObjectEvent) { >+ _waitCount++; >+ _waitTime += timeSpan; >+ MonitorCallDetails callSite = new MonitorCallDetails(event); >+ if (!_monWaitCallSites.containsKey(callSite)) { >+ _monWaitCallSites.put(callSite, callSite); >+ } else { >+ callSite = (MonitorCallDetails)_monWaitCallSites.get(callSite); >+ } >+ callSite.updateCallData(event, timeSpan); >+ } else if(event instanceof TRCThreadWaitingForLockEvent) { >+ _blockCount++; >+ _blockTime += timeSpan; >+ MonitorCallDetails callSite = new MonitorCallDetails(event); >+ if (!_monBlockCallSites.containsKey(callSite)) { >+ _monBlockCallSites.put(callSite, callSite); >+ } else { >+ callSite = (MonitorCallDetails)_monBlockCallSites.get(callSite); >+ } >+ callSite.updateCallData(event, timeSpan); >+ } >+ } >+ >+ public Object[] getWaitCalls() { >+ return _monWaitCallSites.values().toArray(); >+ } >+ >+ public Object[] getBlockCalls() { >+ return _monBlockCallSites.values().toArray(); >+ } >+ >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorCallDetails.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorCallDetails.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorCallDetails.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorCallDetails.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,229 @@ >+/********************************************************************** >+ * Copyright (c) 2008, Intel Corporation. >+ * All rights reserved. This content is made available under >+ * the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id$ >+ * >+ * Contributors: >+ * Intel Corporation - Initial API and implementation >+ * Alexander N. Alexeev, Intel - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import java.util.ArrayList; >+import java.util.HashSet; >+import java.util.Iterator; >+ >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.hyades.models.hierarchy.TRCAnnotation; >+import org.eclipse.hyades.models.trace.TRCThreadEvent; >+import org.eclipse.hyades.models.trace.TRCThreadSleepingEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForLockEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForObjectEvent; >+ >+public class MonitorCallDetails { >+ final static String ANNATATION_NAME_LINES = "callStackDumpLineNumbers"; >+ final static String ANNATATION_NAME_METHODS = "callStackDumpMethods"; >+ final static String WAIT_METHOD_STR_CONST = "java.lang.Object.wait"; >+ >+ protected ArrayList _waitDeltas = new ArrayList(); >+ protected ArrayList _blockDeltas = new ArrayList(); >+ protected HashSet _waitThreadsSet = new HashSet(); >+ protected HashSet _waitObjectsSet = new HashSet(); >+ protected HashSet _blockThreadsSet = new HashSet(); >+ protected HashSet _blockObjectsSet = new HashSet(); >+ >+ //private ArrayList _methods = new ArrayList(); >+ //private ArrayList _lines = new ArrayList(); >+ >+ private String _idString = ""; >+ private String _callTitle = ""; >+ private boolean _isObjectWaiting; >+ >+ protected double _sleepingTime; >+ protected int _sleepingCount; >+ >+ protected double _waitingTime; >+ protected double _maxWaitingTime = 0; >+ protected double _minWaitingTime = Double.MAX_VALUE; >+ protected double _avgWaitingTime; >+ protected int _waitCount; >+ >+ protected double _blockedTime; >+ protected double _maxBlockedTime = 0; >+ protected double _minBlockedTime = Double.MAX_VALUE; >+ protected double _avgBlockedTime; >+ protected int _blockedCount; >+ >+ public int hashCode() { >+ final int prime = 31; >+ int result = 1; >+ result = prime * result >+ + ((_idString == null) ? 0 : _idString.hashCode()); >+ result = prime * result + (_isObjectWaiting ? 1231 : 1237); >+ return result; >+ } >+ >+ public boolean equals(Object obj) { >+ if (this == obj) >+ return true; >+ if (obj == null) >+ return false; >+ if (getClass() != obj.getClass()) >+ return false; >+ MonitorCallDetails other = (MonitorCallDetails) obj; >+ if (_idString == null) { >+ if (other._idString != null) >+ return false; >+ } else if (!_idString.equals(other._idString)) >+ return false; >+ if (_isObjectWaiting != other._isObjectWaiting) >+ return false; >+ return true; >+ } >+ >+ MonitorCallDetails(TRCThreadEvent event) { >+ _isObjectWaiting = false; >+ if (event instanceof TRCThreadWaitingForObjectEvent) { >+ _isObjectWaiting = true; >+ } >+ >+ TRCAnnotation methodsAnn = null; >+ TRCAnnotation linesAnn = null; >+ for (Iterator it=event.getAnnotations().iterator(); it.hasNext(); ) { >+ Object element = it.next(); >+ if (element instanceof TRCAnnotation) { >+ TRCAnnotation ann = (TRCAnnotation)element; >+ if (ann.getName().equals(ANNATATION_NAME_METHODS)) { >+ methodsAnn = ann; >+ } else if (ann.getName().equals(ANNATATION_NAME_LINES)) { >+ linesAnn = ann; >+ } >+ } >+ } >+ >+ if (null != methodsAnn) { >+ _idString = ""; >+ EList listMeth = methodsAnn.getValues(); >+ >+ if (!_isObjectWaiting && listMeth.size() > 0) { >+ _callTitle = listMeth.get(0).toString(); >+ } >+ >+ boolean titleFound = false; >+ for (int i = 0; i < listMeth.size(); i++) { >+ if (_isObjectWaiting) { >+ if (!titleFound && >+ _callTitle.startsWith(WAIT_METHOD_STR_CONST) && >+ !listMeth.get(i).toString().startsWith(WAIT_METHOD_STR_CONST)) { >+ _callTitle = listMeth.get(i).toString(); >+ titleFound = true; >+ } else if (!titleFound){ >+ _callTitle = listMeth.get(i).toString(); >+ } >+ } >+ _idString += listMeth.get(i).toString(); >+ } >+ if (null != linesAnn) { >+ EList listLines = linesAnn.getValues(); >+ for (int i = 0; i < listMeth.size() && i < listLines.size(); i++) { >+ _idString += listLines.get(i); >+ } >+ } >+ } >+ } >+ >+ public String getCallTitle() { >+ return _callTitle; >+ } >+ >+ public int getBlockedCount() { >+ return _blockedCount; >+ } >+ >+ public int getWaitingCount() { >+ return _waitCount; >+ } >+ >+ public int getSleepingCount() { >+ return _sleepingCount; >+ } >+ >+ public double getBlockedTime() { >+ return _blockedTime; >+ } >+ >+ public double getSleepingTime() { >+ return _sleepingTime; >+ } >+ >+ public double getWaitingTime() { >+ return _waitingTime; >+ } >+ >+ public double getMinBlockedTime() { >+ return _minBlockedTime; >+ } >+ >+ public double getAvgBlockedTime() { >+ return _avgBlockedTime; >+ } >+ >+ public double getMaxBlockedTime() { >+ return _maxBlockedTime; >+ } >+ >+ public double getMinWaitingTime() { >+ return _minWaitingTime; >+ } >+ >+ public double getAvgWaitingTime() { >+ return _avgWaitingTime; >+ } >+ >+ public double getMaxWaitingTime() { >+ return _maxWaitingTime; >+ } >+ >+ public int getWaitingObjectsCount() { >+ return _waitObjectsSet.size(); >+ } >+ >+ public int getBlockedObjectsCount() { >+ return _blockObjectsSet.size(); >+ } >+ >+ public int getWaitingThreadsCount() { >+ return _waitThreadsSet.size(); >+ } >+ >+ public int getBlockedThreadsCount() { >+ return _blockThreadsSet.size(); >+ } >+ >+ public void updateCallData(TRCThreadEvent event, double timeSpan) { >+ if(event instanceof TRCThreadSleepingEvent) { >+ _sleepingTime += timeSpan; >+ _sleepingCount++; >+ } else if(event instanceof TRCThreadWaitingForObjectEvent) { >+ _waitingTime += timeSpan; >+ _waitCount++; >+ _avgWaitingTime = _waitingTime/_waitCount; >+ if (timeSpan > _maxWaitingTime) _maxWaitingTime = timeSpan; >+ if (timeSpan < _minWaitingTime) _minWaitingTime = timeSpan; >+ _waitThreadsSet.add(event.getThread()); >+ _waitObjectsSet.add(((TRCThreadWaitingForObjectEvent)event).getObjectWaitingFor()); >+ } else if(event instanceof TRCThreadWaitingForLockEvent) { >+ _blockedTime += timeSpan; >+ _blockedCount++; >+ _avgBlockedTime = _blockedTime/_blockedCount; >+ if (timeSpan > _maxBlockedTime) _maxBlockedTime = timeSpan; >+ if (timeSpan < _minBlockedTime) _minBlockedTime = timeSpan; >+ _blockThreadsSet.add(event.getThread()); >+ _blockObjectsSet.add(((TRCThreadWaitingForLockEvent)event).getLockedObject()); >+ } >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassStatistics.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassStatistics.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassStatistics.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassStatistics.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,307 @@ >+/********************************************************************** >+ * Copyright (c) 2008, Intel Corporation. >+ * All rights reserved. This content is made available under >+ * the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id$ >+ * >+ * Contributors: >+ * Intel Corporation - Initial API and implementation >+ * Alexander N. Alexeev, Intel - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import org.eclipse.hyades.ui.util.HyadesFormToolkit; >+import org.eclipse.jface.viewers.IBaseLabelProvider; >+import org.eclipse.jface.viewers.IContentProvider; >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.StructuredViewer; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerSorter; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.ViewForm; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Layout; >+import org.eclipse.swt.widgets.Tree; >+import org.eclipse.swt.widgets.TreeColumn; >+import org.eclipse.swt.widgets.TreeItem; >+import org.eclipse.tptp.trace.jvmti.internal.client.widgets.Utils; >+import org.eclipse.ui.forms.widgets.ColumnLayout; >+import org.eclipse.ui.forms.widgets.Section; >+ >+public class MonitorClassStatistics extends LabelProvider implements ITableLabelProvider, SelectionListener{ >+ >+ // MONSTAT_CLASSES_COL_CLASS_NAME >+ private final static int MONSTAT_CLASSES_COL_CLASS_NAME_NUM = 0; >+ private final static int MONSTAT_CLASSES_COL_CLASS_NAME_DEFW = 260; >+ // MONSTAT_THREADS_COL_BLOCKED_COUNT >+ private final static int MONSTAT_CLASSES_COL_BLOCKED_COUNT_NUM = 1; >+ private final static int MONSTAT_CLASSES_COL_BLOCKED_COUNT_DEFW = 100; >+ // MONSTAT_CLASSES_COL_BLOCKED_TIME >+ private final static int MONSTAT_CLASSES_COL_BLOCKED_TIME_NUM = 2; >+ private final static int MONSTAT_CLASSES_COL_BLOCKED_TIME_DEFW = 100; >+ // MONSTAT_CLASSES_COL_WAITED_COUNT >+ private final static int MONSTAT_CLASSES_COL_WAITED_COUNT_NUM = 3; >+ private final static int MONSTAT_CLASSES_COL_WAITING_COUNT_DEFW = 100; >+ // MONSTAT_CLASSES_COL_WAITED_TIME >+ private final static int MONSTAT_CLASSES_COL_WAITED_TIME_NUM = 4; >+ private final static int MONSTAT_CLASSES_COL_WAITING_TIME_DEFW = 100; >+ >+ //overall column number >+ private final static int MONSTAT_CLASSES_COL_NUM = 5; >+ >+ >+ protected Composite _viewContainer; >+ protected ViewForm _dataPane; >+ protected StructuredViewer _viewer; >+ protected Layout _layout = null; >+ >+ protected HyadesFormToolkit _toolkit; >+ protected ClassStatisticsSorter _sorter; >+ >+ MonitorStatisticController monViewCtrl; >+ >+ public MonitorClassStatistics(Section section, MonitorStatisticController monViewCtrl) { >+ this.monViewCtrl = monViewCtrl; >+ _toolkit = new HyadesFormToolkit(section.getDisplay()); >+ _dataPane = _toolkit.createViewForm(section); >+ _viewContainer = _dataPane; >+ Control table = createTableViewer(_dataPane); >+ _dataPane.setContent(table); >+ } >+ >+ public Layout getLayout() { >+ if (_layout == null) >+ { >+ _layout = new ColumnLayout(); >+ ((ColumnLayout)_layout).maxNumColumns = 100; >+ } >+ return _layout; >+ } >+ >+ private Control createTableViewer(ViewForm parent) { >+ Tree tree = _toolkit.createTree(parent, SWT.FULL_SELECTION | SWT.FLAT); >+ >+ tree.setLinesVisible(true); >+ tree.setHeaderVisible(true); >+ tree.setLayout(getLayout()); >+ tree.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ tree.addSelectionListener(this); >+ >+ _viewer = new TreeViewer(tree); >+ >+ _viewer.setContentProvider(getContentProvider()); >+ _viewer.setLabelProvider(getTableLabelProvider()); >+ >+ _sorter = new ClassStatisticsSorter(); >+ >+ _viewer.setSorter(_sorter); >+ >+ createColumns(tree); >+ _sorter.changeColumnSelection(0); >+ >+ monViewCtrl.setClassesTimeViewer(_viewer); >+ return _viewer.getControl(); >+ } >+ >+ private void createColumns(Tree tree) { >+ >+ int colWidth[] = new int[MONSTAT_CLASSES_COL_NUM]; >+ String colTitle[] = new String[MONSTAT_CLASSES_COL_NUM]; >+ TreeColumn columns[] = new TreeColumn[MONSTAT_CLASSES_COL_NUM]; >+ >+ colTitle[MONSTAT_CLASSES_COL_CLASS_NAME_NUM] = UIMessages._THREAD_CLASS_NAME; >+ colWidth[MONSTAT_CLASSES_COL_CLASS_NAME_NUM] = MONSTAT_CLASSES_COL_CLASS_NAME_DEFW; >+ colTitle[MONSTAT_CLASSES_COL_BLOCKED_COUNT_NUM] = UIMessages._BLOCKED_COUNT; >+ colWidth[MONSTAT_CLASSES_COL_BLOCKED_COUNT_NUM] = MONSTAT_CLASSES_COL_BLOCKED_COUNT_DEFW; >+ colTitle[MONSTAT_CLASSES_COL_BLOCKED_TIME_NUM] = UIMessages._THREAD_BLOCKED_TIME; >+ colWidth[MONSTAT_CLASSES_COL_BLOCKED_TIME_NUM] = MONSTAT_CLASSES_COL_BLOCKED_TIME_DEFW; >+ colTitle[MONSTAT_CLASSES_COL_WAITED_COUNT_NUM] = UIMessages._WAITING_CONUT; >+ colWidth[MONSTAT_CLASSES_COL_WAITED_COUNT_NUM] = MONSTAT_CLASSES_COL_WAITING_COUNT_DEFW; >+ colTitle[MONSTAT_CLASSES_COL_WAITED_TIME_NUM] = UIMessages._THREAD_WAITING_TIME; >+ colWidth[MONSTAT_CLASSES_COL_WAITED_TIME_NUM] = MONSTAT_CLASSES_COL_WAITING_TIME_DEFW; >+ >+ for (int i = 0; i < MONSTAT_CLASSES_COL_NUM; i++) { >+ columns[i] = new TreeColumn(tree, SWT.NULL | SWT.NO_BACKGROUND | SWT.LEFT); >+ columns[i].setResizable(true); >+ columns[i].setText(colTitle[i]); >+ columns[i].setWidth(colWidth[i]); >+ columns[i].addSelectionListener(getColumnSelectionListener(i)); >+ } >+ >+ _sorter.setColumns(columns); >+ } >+ >+ SelectionListener getColumnSelectionListener(final int columnIndex) { >+ return new SelectionListener(){ >+ public void widgetSelected(SelectionEvent e) { >+ _sorter.changeColumnSelection(columnIndex); >+ _viewer.refresh(); >+ } >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ }; >+ } >+ >+ >+ >+ private IBaseLabelProvider getTableLabelProvider() { >+ return this; >+ } >+ >+ private IContentProvider getContentProvider() { >+ return new MonitorClassesStatisticContentProvider(); >+ } >+ >+ public Composite getViewContainer() { >+ return _viewContainer; >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ if (!(e.widget instanceof Tree)) { >+ // TODO add assert >+ return; >+ } >+ >+ Tree tree = (Tree)e.widget; >+ TreeItem[] selectedItems = tree.getSelection(); >+ MonitorClassDetails[] classes = new MonitorClassDetails[selectedItems.length]; >+ for (int i = 0; i < selectedItems.length; i++) { >+ classes[i] = (MonitorClassDetails)selectedItems[i].getData(); >+ } >+ monViewCtrl.setSelectedClass(classes[0]); >+ } >+ >+ public Image getColumnImage(Object element, int columnIndex) { >+ return null; >+ } >+ >+ public String getColumnText(Object element, int columnIndex) { >+ if (!(element instanceof MonitorClassDetails)) { >+ return null; >+ } >+ MonitorClassDetails monClassDetails = (MonitorClassDetails)element; >+ >+ switch (columnIndex) { >+ case MONSTAT_CLASSES_COL_CLASS_NAME_NUM: >+ return monClassDetails.getClassObj().getName(); >+ case MONSTAT_CLASSES_COL_BLOCKED_COUNT_NUM: >+ return new Integer(monClassDetails.getBlockedCount()).toString(); >+ case MONSTAT_CLASSES_COL_BLOCKED_TIME_NUM: >+ return Utils.formatTime(monClassDetails.getBlockedTime()); >+ case MONSTAT_CLASSES_COL_WAITED_COUNT_NUM: >+ return new Integer(monClassDetails.getWaitingCount()).toString(); >+ case MONSTAT_CLASSES_COL_WAITED_TIME_NUM: >+ return Utils.formatTime(monClassDetails.getWaitingTime()); >+ default: >+ break; >+ } >+ return null; >+ >+ } >+ >+ class ClassStatisticsSorter extends ViewerSorter { >+ >+ private int sortedIdx = -1; >+ private boolean ascOrder = true; >+ //private TreeColumn columns[] = null; >+ >+ void changeColumnSelection(int idx) { >+ if (sortedIdx == idx) { >+ ascOrder = !ascOrder; >+ } >+ else { >+ ascOrder = true; >+ } >+ sortedIdx = idx; >+ } >+ >+ void setColumns(TreeColumn columns[]) { >+ //this.columns = columns; >+ } >+ >+ public int compare(Viewer viewer, Object e1, Object e2) { >+ if (!(e1 instanceof MonitorClassDetails) || >+ !(e2 instanceof MonitorClassDetails)) { >+ return 0; >+ } >+ >+ MonitorClassDetails cd1 = (MonitorClassDetails)e1; >+ MonitorClassDetails cd2 = (MonitorClassDetails)e2; >+ int result = 0; >+ >+ switch (sortedIdx) { >+ case MONSTAT_CLASSES_COL_CLASS_NAME_NUM: >+ result = cd1.getClassObj().getName() >+ .compareTo(cd2.getClassObj().getName()); >+ break; >+ case MONSTAT_CLASSES_COL_BLOCKED_COUNT_NUM: >+ result = cd1.getBlockedCount() - cd2.getBlockedCount(); >+ break; >+ case MONSTAT_CLASSES_COL_BLOCKED_TIME_NUM: >+ result = new Double(cd1.getBlockedTime()) >+ .compareTo(new Double (cd2.getBlockedTime())); >+ break; >+ case MONSTAT_CLASSES_COL_WAITED_COUNT_NUM: >+ result = cd1.getWaitingCount() - cd2.getWaitingCount(); >+ break; >+ case MONSTAT_CLASSES_COL_WAITED_TIME_NUM: >+ result = new Double(cd1.getWaitingTime()) >+ .compareTo(new Double (cd2.getWaitingTime())); >+ break; >+ default: >+ break; >+ } >+ >+ return ascOrder ? result : -result; >+ } >+ >+ public boolean isSorterProperty(Object element, String property) { >+ return true; >+ } >+ >+ } >+} >+ >+class MonitorClassesStatisticContentProvider implements ITreeContentProvider { >+ Object[] classes = null; >+ >+ public Object[] getChildren(Object parentElement) { >+ return null; >+ } >+ >+ public Object getParent(Object element) { >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ return false; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ return classes; >+ } >+ >+ public void dispose() { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ if (newInput instanceof Object[]) { >+ classes = (Object[])newInput; >+ } >+ } >+ >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassBlockedStatistics.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassBlockedStatistics.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassBlockedStatistics.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/MonitorClassBlockedStatistics.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,296 @@ >+/********************************************************************** >+ * Copyright (c) 2008, Intel Corporation. >+ * All rights reserved. This content is made available under >+ * the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id$ >+ * >+ * Contributors: >+ * Intel Corporation - Initial API and implementation >+ * Alexander N. Alexeev, Intel - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import org.eclipse.hyades.ui.util.HyadesFormToolkit; >+import org.eclipse.jface.viewers.IBaseLabelProvider; >+import org.eclipse.jface.viewers.IContentProvider; >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.StructuredViewer; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerSorter; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.ViewForm; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Layout; >+import org.eclipse.swt.widgets.Tree; >+import org.eclipse.swt.widgets.TreeColumn; >+import org.eclipse.tptp.trace.jvmti.internal.client.widgets.Utils; >+import org.eclipse.ui.forms.widgets.ColumnLayout; >+import org.eclipse.ui.forms.widgets.Section; >+ >+public class MonitorClassBlockedStatistics extends LabelProvider implements ITableLabelProvider, SelectionListener{ >+ >+ private final static int MONSTAT_BLOCKTIME_COL_CALLER_NUM = 0; >+ private final static int MONSTAT_BLOCKTIME_COL_CALLER_DEFW = 250; >+ private final static int MONSTAT_BLOCKTIME_COL_TOTAL_TIME_NUM = 1; >+ private final static int MONSTAT_BLOCKTIME_COL_TOTAL_TIME_DEFW = 100; >+ private final static int MONSTAT_BLOCKTIME_COL_COUNT_NUM = 2; >+ private final static int MONSTAT_BLOCKTIME_COL_COUNT_DEFW = 100; >+ private final static int MONSTAT_BLOCKTIME_COL_STAT_NUM = 3; >+ private final static int MONSTAT_BLOCKTIME_COL_STAT_DEFW = 200; >+ private final static int MONSTAT_BLOCKTIME_COL_OBJECT_NUM_NUM = 4; >+ private final static int MONSTAT_BLOCKTIME_COL_OBJECT_NUM_DEFW = 100; >+ private final static int MONSTAT_BLOCKTIME_COL_THREAD_NUM_NUM = 5; >+ private final static int MONSTAT_BLOCKTIME_COL_THREAD_NUM_DEFW = 100; >+ >+ //overall column number >+ private final static int MONSTAT_BLOCKTIME_COL_NUM = 6; >+ >+ >+ protected Composite _viewContainer; >+ protected ViewForm _dataPane; >+ protected StructuredViewer _viewer; >+ protected Layout _layout = null; >+ >+ protected HyadesFormToolkit _toolkit; >+ >+ MonitorStatisticController monViewCtrl; >+ >+ MonitorBlockedStatisticsSorter _sorter; >+ >+ public MonitorClassBlockedStatistics(Section section, MonitorStatisticController monViewCtrl) { >+ this.monViewCtrl = monViewCtrl; >+ _toolkit = new HyadesFormToolkit(section.getDisplay()); >+ _dataPane = _toolkit.createViewForm(section); >+ _viewContainer = _dataPane; >+ Control table = createTableViewer(_dataPane); >+ _dataPane.setContent(table); >+ } >+ >+ public Layout getLayout() { >+ if (_layout == null) >+ { >+ _layout = new ColumnLayout(); >+ ((ColumnLayout)_layout).maxNumColumns = 100; >+ } >+ return _layout; >+ } >+ >+ private Control createTableViewer(ViewForm parent) { >+ Tree tree = _toolkit.createTree(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.FLAT); >+ >+ tree.setLinesVisible(true); >+ tree.setHeaderVisible(true); >+ tree.setLayout(getLayout()); >+ tree.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ tree.addSelectionListener(this); >+ >+ _viewer = new TreeViewer(tree); >+ >+ _viewer.setContentProvider(getContentProvider()); >+ _viewer.setLabelProvider(getTableLabelProvider()); >+ >+ _sorter = new MonitorBlockedStatisticsSorter(); >+ _viewer.setSorter(_sorter); >+ >+ createColumns(tree); >+ _sorter.changeColumnSelection(0); >+ >+ monViewCtrl.setBlockTimeViewer(_viewer); >+ return _viewer.getControl(); >+ } >+ >+ private void createColumns(Tree tree) { >+ >+ int colWidth[] = new int[MONSTAT_BLOCKTIME_COL_NUM]; >+ String colTitle[] = new String[MONSTAT_BLOCKTIME_COL_NUM]; >+ TreeColumn columns[] = new TreeColumn[MONSTAT_BLOCKTIME_COL_NUM]; >+ >+ colTitle[MONSTAT_BLOCKTIME_COL_CALLER_NUM] = UIMessages._MONITOR_CALLER; >+ colWidth[MONSTAT_BLOCKTIME_COL_CALLER_NUM] = MONSTAT_BLOCKTIME_COL_CALLER_DEFW; >+ colTitle[MONSTAT_BLOCKTIME_COL_TOTAL_TIME_NUM] = UIMessages._TOTAL_BLOCKED_TIME; >+ colWidth[MONSTAT_BLOCKTIME_COL_TOTAL_TIME_NUM] = MONSTAT_BLOCKTIME_COL_TOTAL_TIME_DEFW; >+ colTitle[MONSTAT_BLOCKTIME_COL_COUNT_NUM] = UIMessages._BLOCKED_COUNT; >+ colWidth[MONSTAT_BLOCKTIME_COL_COUNT_NUM] = MONSTAT_BLOCKTIME_COL_COUNT_DEFW; >+ colTitle[MONSTAT_BLOCKTIME_COL_STAT_NUM] = UIMessages._MAX_AVG_MIN_TIME; >+ colWidth[MONSTAT_BLOCKTIME_COL_STAT_NUM] = MONSTAT_BLOCKTIME_COL_STAT_DEFW; >+ colTitle[MONSTAT_BLOCKTIME_COL_OBJECT_NUM_NUM] = UIMessages._OBJECT_NUMBER; >+ colWidth[MONSTAT_BLOCKTIME_COL_OBJECT_NUM_NUM] = MONSTAT_BLOCKTIME_COL_OBJECT_NUM_DEFW; >+ colTitle[MONSTAT_BLOCKTIME_COL_THREAD_NUM_NUM] = UIMessages._THREAD_NUMBER; >+ colWidth[MONSTAT_BLOCKTIME_COL_THREAD_NUM_NUM] = MONSTAT_BLOCKTIME_COL_THREAD_NUM_DEFW; >+ >+ for (int i = 0; i < MONSTAT_BLOCKTIME_COL_NUM; i++) { >+ columns[i] = new TreeColumn(tree, SWT.NULL | SWT.NO_BACKGROUND | SWT.LEFT); >+ columns[i].setResizable(true); >+ columns[i].setText(colTitle[i]); >+ columns[i].setWidth(colWidth[i]); >+ columns[i].addSelectionListener(getColumnSelectionListener(i)); >+ } >+ >+ _sorter.setColumns(columns); >+ } >+ >+ SelectionListener getColumnSelectionListener(final int columnIndex) { >+ return new SelectionListener(){ >+ public void widgetSelected(SelectionEvent e) { >+ _sorter.changeColumnSelection(columnIndex); >+ _viewer.refresh(); >+ } >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ }; >+ } >+ >+ private IBaseLabelProvider getTableLabelProvider() { >+ return this; >+ } >+ >+ private IContentProvider getContentProvider() { >+ return new MonitorBlockTimeStatisticContentProvider(); >+ } >+ >+ public Composite getViewContainer() { >+ return _viewContainer; >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ } >+ >+ public Image getColumnImage(Object element, int columnIndex) { >+ return null; >+ } >+ >+ public String getColumnText(Object element, int columnIndex) { >+ if (!(element instanceof MonitorCallDetails)) { >+ return null; >+ } >+ MonitorCallDetails monCallDetails = (MonitorCallDetails)element; >+ >+ switch (columnIndex) { >+ case MONSTAT_BLOCKTIME_COL_CALLER_NUM: >+ return monCallDetails.getCallTitle(); >+ case MONSTAT_BLOCKTIME_COL_TOTAL_TIME_NUM: >+ return Utils.formatTime(monCallDetails.getBlockedTime()); >+ case MONSTAT_BLOCKTIME_COL_COUNT_NUM: >+ return new Integer(monCallDetails.getBlockedCount()).toString(); >+ case MONSTAT_BLOCKTIME_COL_STAT_NUM: >+ return Utils.formatTime(monCallDetails.getMaxBlockedTime()) + " / " + >+ Utils.formatTime(monCallDetails.getAvgBlockedTime()) + " / " + >+ Utils.formatTime(monCallDetails.getMinBlockedTime()); >+ case MONSTAT_BLOCKTIME_COL_OBJECT_NUM_NUM: >+ return new Integer(monCallDetails.getBlockedObjectsCount()).toString(); >+ case MONSTAT_BLOCKTIME_COL_THREAD_NUM_NUM: >+ return new Integer(monCallDetails.getBlockedThreadsCount()).toString(); >+ default: >+ break; >+ } >+ return null; >+ >+ } >+ >+ class MonitorBlockedStatisticsSorter extends ViewerSorter { >+ >+ private int sortedIdx = -1; >+ private boolean ascOrder = true; >+ //private TreeColumn columns[] = null; >+ >+ void changeColumnSelection(int idx) { >+ // column isn't sortable >+ if (MONSTAT_BLOCKTIME_COL_STAT_NUM == idx) >+ return; >+ >+ if (sortedIdx == idx) { >+ ascOrder = !ascOrder; >+ } >+ else { >+ ascOrder = true; >+ } >+ sortedIdx = idx; >+ } >+ >+ void setColumns(TreeColumn columns[]) { >+ //this.columns = columns; >+ } >+ >+ public int compare(Viewer viewer, Object e1, Object e2) { >+ if (!(e1 instanceof MonitorCallDetails) || >+ !(e2 instanceof MonitorCallDetails)) { >+ return 0; >+ } >+ >+ MonitorCallDetails cd1 = (MonitorCallDetails)e1; >+ MonitorCallDetails cd2 = (MonitorCallDetails)e2; >+ int result = 0; >+ >+ switch (sortedIdx) { >+ case MONSTAT_BLOCKTIME_COL_CALLER_NUM: >+ result = cd1.getCallTitle().compareTo(cd2.getCallTitle()); >+ break; >+ case MONSTAT_BLOCKTIME_COL_TOTAL_TIME_NUM: >+ result = new Double(cd1.getBlockedTime()) >+ .compareTo(new Double (cd2.getBlockedTime())); >+ break; >+ case MONSTAT_BLOCKTIME_COL_COUNT_NUM: >+ result = cd1.getBlockedCount() - cd2.getBlockedCount(); >+ break; >+ case MONSTAT_BLOCKTIME_COL_OBJECT_NUM_NUM: >+ result = cd1.getBlockedObjectsCount() - cd2.getBlockedObjectsCount(); >+ break; >+ case MONSTAT_BLOCKTIME_COL_THREAD_NUM_NUM: >+ result = cd1.getBlockedThreadsCount() - cd2.getBlockedThreadsCount(); >+ break; >+ default: >+ break; >+ } >+ >+ return ascOrder ? result : -result; >+ } >+ >+ public boolean isSorterProperty(Object element, String property) { >+ return true; >+ } >+ >+ } >+} >+ >+class MonitorBlockTimeStatisticContentProvider implements ITreeContentProvider { >+ Object[] calls; >+ >+ public Object[] getChildren(Object parentElement) { >+ return null; >+ } >+ >+ public Object getParent(Object element) { >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ return false; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ return calls; >+ } >+ >+ public void dispose() { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ if (newInput instanceof Object[]) { >+ calls = (Object[])newInput; >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 209727
: 92204