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 118588 Details for
Bug 166692
[Tech Preview] Add per thread exection time, cycles and instructions
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]
patch for 166692
166692-patch.txt (text/plain), 96.14 KB, created by
Richard Y.S. HUANG
on 2008-11-24 09:00:11 EST
(
hide
)
Description:
patch for 166692
Filename:
MIME Type:
Creator:
Richard Y.S. HUANG
Created:
2008-11-24 09:00:11 EST
Size:
96.14 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.trace.arm.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.13 >diff -u -r1.13 MANIFEST.MF >--- META-INF/MANIFEST.MF 10 Apr 2008 17:22:01 -0000 1.13 >+++ META-INF/MANIFEST.MF 24 Nov 2008 13:52:32 -0000 >@@ -16,7 +16,8 @@ > org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)", > org.eclipse.hyades.trace.views;bundle-version="[4.1.0,5.0.0)", > org.eclipse.text, >- org.eclipse.jdt.ui;bundle-version="[3.2.0,4.0.0)" >+ org.eclipse.jdt.ui;bundle-version="[3.2.0,4.0.0)", >+ org.eclipse.tptp.platform.models > Eclipse-LazyStart: true > Bundle-ActivationPolicy: lazy > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >Index: src/org/eclipse/tptp/trace/arm/ui/internal/util/messages.properties >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm.ui/src/org/eclipse/tptp/trace/arm/ui/internal/util/messages.properties,v >retrieving revision 1.15 >diff -u -r1.15 messages.properties >--- src/org/eclipse/tptp/trace/arm/ui/internal/util/messages.properties 11 Mar 2008 20:14:27 -0000 1.15 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/util/messages.properties 24 Nov 2008 13:52:32 -0000 >@@ -23,6 +23,7 @@ > NAME_COLUMN = Name > DESCP_COLUMN = Description > FILTER_LABEL = Filter >+METRIC_LABEL = Metric > NO_DESCP_LABEL = No description given > INTERNAL_ERROR = Internal error in ARM analysis type > >@@ -30,6 +31,7 @@ > ERROR_INSTRUMENT_EXIST_DETAIL = Occured in method: {0}()\n > > INSTRUMENT_POINT_FILTER_TITLE = Instrument Point Filter >+ARM_METRIC_TITLE = Available metric properties > > DEFAULT_SERVLET_FILTER = Default Servlet Filter Set > DEFAULT_JDBC_FILTER = Default JDBC Filter Set >Index: src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmMessages.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm.ui/src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmMessages.java,v >retrieving revision 1.12 >diff -u -r1.12 ArmMessages.java >--- src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmMessages.java 11 Mar 2008 20:14:27 -0000 1.12 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmMessages.java 24 Nov 2008 13:52:32 -0000 >@@ -34,11 +34,13 @@ > public static String NAME_COLUMN; > public static String DESCP_COLUMN; > public static String FILTER_LABEL; >+ public static String METRIC_LABEL; > public static String NO_DESCP_LABEL; > public static String INTERNAL_ERROR; > public static String ERROR_INTRUMENT_EXIST; > public static String ERROR_INSTRUMENT_EXIST_DETAIL; > public static String INSTRUMENT_POINT_FILTER_TITLE; >+ public static String ARM_METRIC_TITLE; > public static String DEFAULT_SERVLET_FILTER; > public static String DEFAULT_JDBC_FILTER; > public static String DEFAULT_J2EE_FILTER; >Index: src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmConstants.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm.ui/src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmConstants.java,v >retrieving revision 1.8 >diff -u -r1.8 ArmConstants.java >--- src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmConstants.java 16 Apr 2007 21:45:40 -0000 1.8 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmConstants.java 24 Nov 2008 13:52:32 -0000 >@@ -32,6 +32,8 @@ > public static final String TRANSACTION_GOOD_STATEMENT = "armStatus = " + ARM_TRANSACTION_GOOD_EXPRESSION + ";"; > public static final String TRANSACTION_FAILED_STATEMENT = "armStatus = " + ARM_TRANSACTION_FAILED_EXPRESSION + ";"; > >+ public static final String ARM_PREFIX_FOR_METRIC = "ARM"; >+ > public static final String ACTIVE_FILTER_PREFIX = "ACTIVE_FILTER_FOR_"; > public static final String ENABLE_FILTER_PREFIX = "ENABLE_FILTER_FOR_"; > public static final String FILTER_SET_PREFIX = "FILTER_SET_FOR_"; >Index: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/InstrumentPointSelectionUI.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm.ui/src/org/eclipse/tptp/trace/arm/ui/internal/configuration/InstrumentPointSelectionUI.java,v >retrieving revision 1.11 >diff -u -r1.11 InstrumentPointSelectionUI.java >--- src/org/eclipse/tptp/trace/arm/ui/internal/configuration/InstrumentPointSelectionUI.java 28 Feb 2008 16:41:50 -0000 1.11 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/configuration/InstrumentPointSelectionUI.java 24 Nov 2008 13:52:32 -0000 >@@ -64,7 +64,8 @@ > /* The indexs for the points table */ > private final static int NAME_INDEX = 0; > private final static int FILTER_INDEX = 1; >- private final static int DESCRIPTION_INDEX = 2; >+ private final static int METRIC_INDEX = 2; >+ private final static int DESCRIPTION_INDEX = 3; > > private final static String ARM_INSTRUM_TYPE = > "org.eclipse.tptp.trace.arm.ui.armInstrumentType"; >@@ -101,7 +102,7 @@ > public void setSelectItems(List list) { > TableItem[] items = pointsTable.getItems(); > >- if (list != null || list.size() > 0) { >+ if (list != null && list.size() > 0) { > for (int i = 0; i < items.length; i++) { > InstrumentPoint entry = (InstrumentPoint) items[i].getData(); > if (list.contains(entry.getId())) { >@@ -149,6 +150,7 @@ > TableLayout tableLayout = new TableLayout(); > tableLayout.addColumnData(new ColumnWeightData(150, true)); > tableLayout.addColumnData(new ColumnWeightData(50, true)); >+ tableLayout.addColumnData(new ColumnWeightData(50, true)); > tableLayout.addColumnData(new ColumnWeightData(200, true)); > > pointsTable.setHeaderVisible(true); >@@ -170,10 +172,14 @@ > TableColumn tc2 = new TableColumn(pointsTable, SWT.NONE); > tc2.setText(ArmMessages.FILTER_LABEL); > tc2.setWidth(45); >- >+ > TableColumn tc3 = new TableColumn(pointsTable, SWT.NONE); >- tc3.setText(ArmMessages.DESCP_COLUMN); >- tc3.setWidth(200); >+ tc3.setText(ArmMessages.METRIC_LABEL); >+ tc3.setWidth(45); >+ >+ TableColumn tc4 = new TableColumn(pointsTable, SWT.NONE); >+ tc4.setText(ArmMessages.DESCP_COLUMN); >+ tc4.setWidth(200); > > InstrumentPoint loaders[] = > InstrumentPointManager.getInstance().getInstrumentPointsByType( >@@ -233,9 +239,17 @@ > protected void columnClicked(int columnToEdit) { > IStructuredSelection selection = (IStructuredSelection) pointsList.getSelection(); > InstrumentPoint vmd = (InstrumentPoint) selection.getFirstElement(); >- if (vmd != null && (columnToEdit == FILTER_INDEX)) { >- InstrumentPointFiltersDialog intrumentPointDlg = new InstrumentPointFiltersDialog(null, launchConfiguration, vmd.getId()); >- intrumentPointDlg.open(); >+ if (vmd != null) { >+ if (columnToEdit == FILTER_INDEX) { >+ InstrumentPointFiltersDialog intrumentPointDlg = new InstrumentPointFiltersDialog( >+ null, launchConfiguration, vmd.getId()); >+ intrumentPointDlg.open(); >+ } else if (columnToEdit == METRIC_INDEX) { >+ if (vmd.getMetricProvider() != null) { >+ ArmMetricsDialog armMetricsDialog = new ArmMetricsDialog(null, launchConfiguration, vmd); >+ armMetricsDialog.open(); >+ } >+ } > } > } > >@@ -245,7 +259,7 @@ > public class InstrumentPointLabelProvider extends LabelProvider implements ITableLabelProvider { > > public Image getColumnImage(Object element, int columnIndex) { >- if (columnIndex == FILTER_INDEX) { >+ if ((columnIndex == FILTER_INDEX)|| (columnIndex == METRIC_INDEX)) { > return ArmUIPlugin.getDefault().getImage("settings"); > } > return null; >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm.ui/plugin.xml,v >retrieving revision 1.21 >diff -u -r1.21 plugin.xml >--- plugin.xml 11 Jun 2008 21:31:09 -0000 1.21 >+++ plugin.xml 24 Nov 2008 13:52:32 -0000 >@@ -199,4 +199,20 @@ > > </extension> > >+ <extension >+ point="org.eclipse.hyades.trace.views.columnExtension"> >+ <columnExtension >+ align="right" >+ class="org.eclipse.tptp.trace.arm.ui.internal.configuration.ArmMetricColumnExtension" >+ id="org.eclipse.tptp.trace.arm.ui.internal.configuration.ArmMetricColumnExtension" >+ name="Arm Metric Information" >+ pos="0" >+ style="1" >+ width="90"> >+ <applyTo >+ viewId="org.eclipse.hyades.trace.views.internal.MethodInvocationStatistic"> >+ </applyTo> >+ </columnExtension> >+ </extension> >+ > </plugin> >Index: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricContentProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricContentProvider.java >diff -N src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: ArmMetricContentProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.ui.internal.configuration; >+ >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider; >+ >+/** >+ * Content provider of ArmMetricsDialog. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.2 >+ * >+ */ >+public class ArmMetricContentProvider implements IStructuredContentProvider { >+ >+ public Object[] getElements(Object inputElement) { >+ return ((IMetricNameProvider) inputElement).getNames(); >+ } >+ >+ public void dispose() { >+ // Do nothing. >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ // Do nothing. >+ } >+} >Index: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricsDialog.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricsDialog.java >diff -N src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricsDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricsDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,174 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: ArmMetricsDialog.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.ui.internal.configuration; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.hyades.ui.util.GridUtil; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.viewers.CheckboxTableViewer; >+import org.eclipse.jface.viewers.ColumnLayoutData; >+import org.eclipse.jface.viewers.ColumnPixelData; >+import org.eclipse.jface.viewers.TableLayout; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.TableColumn; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPoint; >+import org.eclipse.tptp.trace.arm.ui.internal.util.ArmConstants; >+import org.eclipse.tptp.trace.arm.ui.internal.util.ArmMessages; >+ >+/** >+ * Dialog to get the configuration of metric. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ */ >+public class ArmMetricsDialog extends Dialog { >+ >+ public ArmMetricsDialog(Shell parentShell, >+ ILaunchConfiguration launchConfiguration, >+ InstrumentPoint instrumentPoint) { >+ super(parentShell); >+ setShellStyle(getShellStyle() | SWT.RESIZE); >+ >+ this.instrumentPoint = instrumentPoint; >+ this.launchConfiguration = launchConfiguration; >+ } >+ >+ protected Control createDialogArea(Composite parent) { >+ Composite result = (Composite) super.createDialogArea(parent); >+ >+ Composite tableGroup = new Composite(result, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 1; >+ tableGroup.setLayout(layout); >+ GridData data = GridUtil.createFill(); >+ data.heightHint = 100; >+ >+ tableGroup.setLayoutData(data); >+ Table filterSetTable = new Table(tableGroup, SWT.V_SCROLL | SWT.BORDER >+ | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK); >+ filterSetTable.setLinesVisible(false); >+ filterSetTable.setLayoutData(GridUtil.createFill()); >+ >+ armTableViewer = new CheckboxTableViewer(filterSetTable); >+ armTableViewer.setContentProvider(new ArmMetricContentProvider()); >+ armTableViewer.setLabelProvider(new ArmMetricLabelProvider()); >+ armTableViewer.setInput(instrumentPoint.getMetricProvider()); >+ >+ TableLayout layoutt = new TableLayout(); >+ filterSetTable.setLayout(layoutt); >+ >+ ColumnLayoutData l = new ColumnPixelData(420, true); >+ layoutt.addColumnData(l); >+ >+ TableColumn tc = new TableColumn(filterSetTable, SWT.NONE, 0); >+ tc.setResizable(l.resizable); >+ >+ configUI(); >+ >+ return result; >+ } >+ >+ /** >+ * Load configuration of metric from ILaunchConfiguration and setup Table in >+ * dialog. >+ */ >+ private void configUI() { >+ try { >+ String checkedMetrics = launchConfiguration.getAttribute( >+ getArmKey(), ""); >+ if (!checkedMetrics.equals("")) { >+ armTableViewer.setCheckedElements(checkedMetrics >+ .split(IMetricNameProvider.METRIC_SEPERATOR)); >+ } >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ } >+ } >+ >+ /** >+ * Override to double the dialog size. >+ * >+ * @see org.eclipse.jface.dialogs.Dialog#getInitialSize() >+ */ >+ protected Point getInitialSize() { >+ Point size = super.getInitialSize(); >+ // Double the size of the dialog. >+ Point doubleSize = new Point(size.x * 2, size.y * 2); >+ return doubleSize; >+ } >+ >+ /** >+ * Get the configuration of the metric, and save it in ILaunchConfiguration. >+ */ >+ protected void okPressed() { >+ if (launchConfiguration instanceof ILaunchConfigurationWorkingCopy) { >+ ILaunchConfigurationWorkingCopy workingCopy = (ILaunchConfigurationWorkingCopy) launchConfiguration; >+ >+ StringBuffer buffer = new StringBuffer(); >+ for (int i = 0; i < armTableViewer.getCheckedElements().length; i++) { >+ String element = (String) armTableViewer.getCheckedElements()[i]; >+ buffer.append(element).append( >+ IMetricNameProvider.METRIC_SEPERATOR); >+ } >+ >+ if (buffer.length() == 0) { >+ workingCopy.removeAttribute(getArmKey()); >+ } else { >+ workingCopy.setAttribute(getArmKey(), buffer.toString()); >+ } >+ } >+ >+ super.okPressed(); >+ } >+ >+ /** >+ * Get the key to store metric information in ILaunchConfiguration. >+ * >+ * @return >+ */ >+ private String getArmKey() { >+ return IMetricNameProvider.METRIC_PREFIX >+ + IMetricNameProvider.SEPARATOR >+ + ArmConstants.ARM_PREFIX_FOR_METRIC >+ + IMetricNameProvider.SEPARATOR + instrumentPoint.getId(); >+ } >+ >+ protected void configureShell(Shell newShell) { >+ super.configureShell(newShell); >+ newShell.setText(ArmMessages.ARM_METRIC_TITLE); >+ } >+ >+ /** >+ * ILaunchConfiguration of the workbench. >+ */ >+ private ILaunchConfiguration launchConfiguration; >+ >+ /** >+ * InstrumentPoint about the metric. >+ */ >+ private InstrumentPoint instrumentPoint; >+ >+ /** >+ * CheckboxTableViewer of the Table in dialog. >+ */ >+ private CheckboxTableViewer armTableViewer; >+} >Index: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricColumnExtension.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricColumnExtension.java >diff -N src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricColumnExtension.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricColumnExtension.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,88 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: ArmMetricContentProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.ui.internal.configuration; >+ >+import java.util.Iterator; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.hyades.models.hierarchy.TRCAnnotation; >+import org.eclipse.hyades.models.trace.impl.TRCFullMethodInvocationImpl; >+import org.eclipse.hyades.trace.views.util.internal.IColumnExtension; >+import org.eclipse.jface.viewers.ILabelProviderListener; >+import org.eclipse.swt.graphics.Image; >+ >+/** >+ * Column extension for Arm Metric. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.2 >+ * >+ */ >+public class ArmMetricColumnExtension implements IColumnExtension { >+ >+ private static final String METRIC_SEPERATOR = ","; >+ >+ public int compare(int pos, Object e1, Object e2) { >+ return 0; >+ } >+ >+ public Image getColumnImage(Object element, int columnIndex) { >+ return null; >+ } >+ >+ public String getColumnText(Object element, int columnIndex) { >+ TRCFullMethodInvocationImpl method = (TRCFullMethodInvocationImpl) element; >+ >+ String ticket = Long.toString(method.getTicket()); >+ StringBuffer metricBuffer = new StringBuffer(); >+ for (Iterator annotationIterator = method.getMethod().getAnnotations() >+ .iterator(); annotationIterator.hasNext();) { >+ TRCAnnotation annotation = (TRCAnnotation) annotationIterator >+ .next(); >+ if (ticket.equals(annotation.getName())) { >+ for (Iterator metricIterator = annotation.getValues() >+ .iterator(); metricIterator.hasNext();) { >+ metricBuffer.append(metricIterator.next()); >+ if (metricIterator.hasNext()) { >+ metricBuffer.append(METRIC_SEPERATOR); >+ } >+ } >+ } >+ } >+ >+ return metricBuffer.toString(); >+ } >+ >+ public void addListener(ILabelProviderListener listener) { >+ // Do nothing. >+ } >+ >+ public void dispose() { >+ // Do nothing. >+ } >+ >+ public boolean isLabelProperty(Object element, String property) { >+ // Do nothing. >+ return false; >+ } >+ >+ public void removeListener(ILabelProviderListener listener) { >+ // Do nothing. >+ } >+ >+ public void setInitializationData(IConfigurationElement config, >+ String propertyName, Object data) throws CoreException { >+ // Do nothing. >+ } >+ >+} >Index: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricLabelProvider.java >diff -N src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: ArmMetricLabelProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.ui.internal.configuration; >+ >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.swt.graphics.Image; >+ >+/** >+ * Label provider of ArmMetricsDialog. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.2 >+ * >+ */ >+public class ArmMetricLabelProvider extends LabelProvider implements >+ ITableLabelProvider { >+ >+ public Image getColumnImage(Object element, int columnIndex) { >+ // No image. >+ return null; >+ } >+ >+ public String getColumnText(Object element, int columnIndex) { >+ return (String) element; >+ } >+ >+} >#P org.eclipse.tptp.platform.models >Index: src-trace/org/eclipse/hyades/loaders/trace/XMLmethodEntryLoader.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.models/src-trace/org/eclipse/hyades/loaders/trace/XMLmethodEntryLoader.java,v >retrieving revision 1.16 >diff -u -r1.16 XMLmethodEntryLoader.java >--- src-trace/org/eclipse/hyades/loaders/trace/XMLmethodEntryLoader.java 12 Mar 2008 20:37:17 -0000 1.16 >+++ src-trace/org/eclipse/hyades/loaders/trace/XMLmethodEntryLoader.java 24 Nov 2008 13:52:35 -0000 >@@ -11,10 +11,15 @@ > * $Id: XMLmethodEntryLoader.java,v 1.16 2008/03/12 20:37:17 jkubasta Exp $ > **********************************************************************/ > package org.eclipse.hyades.loaders.trace; >+import java.util.ArrayList; >+import java.util.List; >+ > import org.eclipse.hyades.loaders.trace.TraceUtils.InvocationInfo; > import org.eclipse.hyades.loaders.util.HierarchyContext; > import org.eclipse.hyades.loaders.util.LoadersUtils; > import org.eclipse.hyades.loaders.util.LookupServiceExtensions; >+import org.eclipse.hyades.models.hierarchy.HierarchyFactory; >+import org.eclipse.hyades.models.hierarchy.TRCAnnotation; > import org.eclipse.hyades.models.trace.TRCClass; > import org.eclipse.hyades.models.trace.TRCFullMethodInvocation; > import org.eclipse.hyades.models.trace.TRCFullTraceObject; >@@ -29,6 +34,10 @@ > * > */ > public class XMLmethodEntryLoader extends TraceMethodBaseLoader { >+ >+ private static final String METRIC_PRE = "ArmMetric"; >+ private static final String METRIC_SEPERATOR = ":"; >+ > //~ Static fields/initializers > // ----------------------------------------------------------------- > // private static final String THREAD_ID_REF = "threadIdRef"; >@@ -38,7 +47,18 @@ > if (!loadToModel) { > return; > } >- super.addAttribute(name, value); >+ if (inMetric) { >+ // There are many name and value attribute in the metric elements. >+ // The first pair is the name and value of metric. The key and value >+ // will be clean when element end. >+ if (name.equals("name")) { >+ metricName = (metricName == null) ? value : metricName; >+ } else if (name.equals("value")) { >+ metricValue = (metricValue == null) ? value : metricValue; >+ } >+ } else { >+ super.addAttribute(name, value); >+ } > } > public void addYourselfInContext() { > if (!loadToModel) { >@@ -71,6 +91,13 @@ > super.cleanUp(); > } > public void endChild(String name) { >+ // Store the metric information and clean the fields for metric information. >+ if (name.startsWith(METRIC_PRE) && inMetric) { >+ metrics.add(metricName + METRIC_SEPERATOR + metricValue); >+ metricName = null; >+ metricValue = null; >+ inMetric = false; >+ } > } > public void initialize(HierarchyContext context, String name) { > loadToModel = context.isLoadToModel(); >@@ -87,8 +114,15 @@ > if (name.equals(INVOCATION_CONTEXT)) { > setNullInvocationContext(); > activeInvocationContext = true; >- } else >+ } else if (name.startsWith(METRIC_PRE)) { >+ if (metrics == null) >+ { >+ metrics = new ArrayList(); >+ } >+ inMetric = true; >+ } else { > super.startChild(name); >+ } > } > > protected void processENI(int step) { >@@ -104,6 +138,8 @@ > fullInvocation.setMethod(theMethod); > fullInvocation.setThread(theThread); > fullInvocation.setProcess(theProcess); >+ >+ addMetricAnnotation(); > > addInputOutputValues(); > >@@ -152,6 +188,8 @@ > fullInvocation.setThread(theThread); > fullInvocation.setProcess(theProcess); > fullInvocation.setOwningObject((TRCFullTraceObject) theObject); >+ >+ addMetricAnnotation(); > > addInputOutputValues(); > >@@ -172,6 +210,20 @@ > // LookupServiceExtensions.getInstance().register(context, > // fullInvocation); > } >+ >+ /** >+ * Add annotation with metric information to fullInvocation. >+ */ >+ private void addMetricAnnotation() { >+ if (metrics != null) >+ { >+ TRCAnnotation annotation = HierarchyFactory.eINSTANCE.createTRCAnnotation(); >+ annotation.setName(Long.toString(ticket)); >+ annotation.getValues().addAll(metrics); >+ fullInvocation.getMethod().getAnnotations().add(annotation); >+ metrics.clear(); >+ } >+ } > /** > * > */ >@@ -331,4 +383,21 @@ > ModelDebugger.log(e); > } > } >+ >+ /** >+ * True when the current element is the Arm Metric element. >+ */ >+ private boolean inMetric; >+ /** >+ * The name of the metric. >+ */ >+ private String metricName; >+ /** >+ * The value of the metric. >+ */ >+ private String metricValue; >+ /** >+ * The list to store the metric information. >+ */ >+ private List metrics; > } >\ No newline at end of file >#P org.eclipse.tptp.trace.arm >Index: src-model/org/eclipse/tptp/trace/arm/internal/model/ArmInstrument.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-model/org/eclipse/tptp/trace/arm/internal/model/ArmInstrument.java,v >retrieving revision 1.8 >diff -u -r1.8 ArmInstrument.java >--- src-model/org/eclipse/tptp/trace/arm/internal/model/ArmInstrument.java 26 Sep 2006 22:40:21 -0000 1.8 >+++ src-model/org/eclipse/tptp/trace/arm/internal/model/ArmInstrument.java 24 Nov 2008 13:52:39 -0000 >@@ -11,11 +11,38 @@ > ***********************************************************************/ > package org.eclipse.tptp.trace.arm.internal.model; > >+import java.util.ArrayList; > import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; > import java.util.Properties; > > import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger; >+import org.opengroup.arm40.metric.ArmMetric; >+import org.opengroup.arm40.metric.ArmMetricCounter32; >+import org.opengroup.arm40.metric.ArmMetricCounter32Definition; >+import org.opengroup.arm40.metric.ArmMetricCounter64; >+import org.opengroup.arm40.metric.ArmMetricCounter64Definition; >+import org.opengroup.arm40.metric.ArmMetricCounterFloat32; >+import org.opengroup.arm40.metric.ArmMetricCounterFloat32Definition; >+import org.opengroup.arm40.metric.ArmMetricDefinition; > import org.opengroup.arm40.metric.ArmMetricFactory; >+import org.opengroup.arm40.metric.ArmMetricGauge32; >+import org.opengroup.arm40.metric.ArmMetricGauge32Definition; >+import org.opengroup.arm40.metric.ArmMetricGauge64; >+import org.opengroup.arm40.metric.ArmMetricGauge64Definition; >+import org.opengroup.arm40.metric.ArmMetricGaugeFloat32; >+import org.opengroup.arm40.metric.ArmMetricGaugeFloat32Definition; >+import org.opengroup.arm40.metric.ArmMetricGroup; >+import org.opengroup.arm40.metric.ArmMetricGroupDefinition; >+import org.opengroup.arm40.metric.ArmMetricNumericId32; >+import org.opengroup.arm40.metric.ArmMetricNumericId32Definition; >+import org.opengroup.arm40.metric.ArmMetricNumericId64; >+import org.opengroup.arm40.metric.ArmMetricNumericId64Definition; >+import org.opengroup.arm40.metric.ArmMetricString32; >+import org.opengroup.arm40.metric.ArmMetricString32Definition; >+import org.opengroup.arm40.metric.ArmTransactionWithMetrics; >+import org.opengroup.arm40.metric.ArmTransactionWithMetricsDefinition; > import org.opengroup.arm40.tranreport.ArmTranReport; > import org.opengroup.arm40.tranreport.ArmTranReportFactory; > import org.opengroup.arm40.transaction.ArmApplication; >@@ -53,9 +80,12 @@ > > /* The ARM 4.0 Application Instance for the TT product. */ > private ArmApplication applicationInstance; >- >- /* Internal cache of the ARM 4.0 identity properties */ >+ >+ /* Internal cache of the ARM 4.0 identity properties : ArmTransactionDefinition*/ > private HashMap armTranDefCache = new HashMap(30); >+ >+ /* Internal cache of the ARM 4.0 identity properties : ArmTransactionWithMetricsDefinition*/ >+ private HashMap armTranWithMetricDefCache = new HashMap(30); > > /* The ARM 4.0 Error handler */ > private ArmErrorCallback armErrorCallBack; >@@ -102,6 +132,7 @@ > .newInstance(); > tranFactory.setErrorCallback(armErrorCallBack); > } catch (Exception ex) { >+ ex.printStackTrace(); > /* If error, then null */ > tranFactory = null; > /* ArmTransFactoryInit_ERROR = IWAT0766E */ >@@ -109,6 +140,10 @@ > ArmInstrumentMessages.getString("ArmTransFactoryInit_ERROR"), > ARMLogger.LOG, ex); > } >+ catch(Throwable t) >+ { >+ t.printStackTrace(); >+ } > } > > return tranFactory; >@@ -152,7 +187,7 @@ > * @return the ArmMetricFactory. > */ > private ArmMetricFactory getArmMetricFactory() { >- if (metricFactory != null) { >+ if (metricFactory == null) { > /* Check for the metric factory */ > try { > Properties p = System.getProperties(); >@@ -262,13 +297,23 @@ > */ > public ArmTransaction transactionStart(InstrumentDataProvider data, > ArmCorrelator parentCorrelator) { >- > ArmTransaction armTransaction = null; > > if (tranFactory != null) { >- ArmTransactionDefinition armTranDef = getArmTransactionDefinition(data); >- armTransaction = tranFactory.newArmTransaction(getArmApplication(), >- armTranDef); >+ // create ArmTransaction/ArmTransactionWithMetric instance if there >+ // is/isn't ARM metric. >+ if (ArmMetricManager.getInstance().hasMetric()) { >+ try { >+ armTransaction = getArmTransactionWithMetric(data); >+ } catch (Throwable e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ } else { >+ ArmTransactionDefinition armTranDef = getArmTransactionDefinition(data); >+ armTransaction = tranFactory.newArmTransaction( >+ getArmApplication(), armTranDef); >+ } > > String[] contextValues = data.getContextValues(); > for (int i = 0; i < contextValues.length; i++) { >@@ -283,6 +328,7 @@ > armTransaction.setUser(tranFactory.newArmUser( > data.getUserName() == null ? "*" : data.getUserName(), null)); > >+ > if (parentCorrelator == null) { > armTransaction.start(); > } else { >@@ -294,6 +340,285 @@ > } // end of transactionStart() > > /** >+ * Create an ArmTransactionWithMetrics instance. >+ * >+ * @param data >+ * @return >+ */ >+ private ArmTransactionWithMetrics getArmTransactionWithMetric( >+ InstrumentDataProvider data) { >+ if (metricFactory == null) { >+ getArmMetricFactory(); >+ } >+ >+ String transName = data.getTransactionName(); >+ ArmTransactionWithMetrics transactionWithMetrics = null; >+ if (metricFactory != null) { >+ synchronized (armTranWithMetricDefCache) { >+ if (metricFactory != null) { >+ List metrics = ArmMetricManager.getInstance().getMetrics(); >+ ArmTransactionWithMetricsDefinition transactionWithMetricsDef = getArmTransactionWithMetricDefinition( >+ transName, metrics); >+ transactionWithMetrics = getArmTransactionWithMetric( >+ transName, metrics, transactionWithMetricsDef); >+ } >+ } >+ } >+ >+ return transactionWithMetrics; >+ } >+ >+ /** >+ * Create an ArmTransactionWithMetricsDefinition instance. Maybe should use >+ * cache here. >+ * >+ * @param transName >+ * @param metrics >+ * @return >+ */ >+ private ArmTransactionWithMetricsDefinition getArmTransactionWithMetricDefinition( >+ String transName, List metrics) { >+ ArmTransactionWithMetricsDefinition transactionWithMetricsDef; >+ List metricsDef = getArmMetricDefs(metrics); >+ >+ ArmMetricDefinition[] metricDefArray = (ArmMetricDefinition[]) metricsDef >+ .toArray(new ArmMetricDefinition[metricsDef.size()]); >+ >+ ArmMetricGroupDefinition metGroupDef = metricFactory >+ .newArmMetricGroupDefinition(metricDefArray); >+ >+ transactionWithMetricsDef = (ArmTransactionWithMetricsDefinition) armTranWithMetricDefCache >+ .get(transName); >+ >+ if (transactionWithMetricsDef == null) { >+ transactionWithMetricsDef = metricFactory >+ .newArmTransactionWithMetricsDefinition( >+ getArmApplicationDefinition(), transName, null, >+ metGroupDef, null); >+ >+ armTranWithMetricDefCache.put(transName, transactionWithMetricsDef); >+ } >+ return transactionWithMetricsDef; >+ } >+ >+ /** >+ * Get the ArmMetricDefinition instances. The elements of parameter metrics >+ * will be updated to match the metric and it's definition.<br> >+ * TODO Move switch-case here to some other place. For example, another >+ * classes. switch-case is not good coding style. >+ * >+ * @param metrics >+ * List of ArmMetricManager.Metric. >+ * @return List of ArmMetricDefinition. >+ */ >+ private List getArmMetricDefs(List metrics) { >+ List metricDefs = new ArrayList(); >+ for (Iterator iterator = metrics.iterator(); iterator.hasNext();) { >+ ArmMetricManager.Metric metric = (ArmMetricManager.Metric) iterator >+ .next(); >+ ArmMetricDefinition metricDefinition = metric.getDefinition(); >+ if (metricDefinition == null) { >+ // Big switch-case to create ArmMetricDefinition instance. >+ switch (metric.getMetricType()) { >+ case ArmMetricConstants.ArmMetricCounter32: >+ metricDefinition = metricFactory >+ .newArmMetricCounter32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricCounter64: >+ metricDefinition = metricFactory >+ .newArmMetricCounter64Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricCounterFloat32: >+ metricDefinition = metricFactory >+ .newArmMetricCounterFloat32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricGauge32: >+ metricDefinition = metricFactory >+ .newArmMetricGauge32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricGauge64: >+ metricDefinition = metricFactory >+ .newArmMetricGauge64Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricGaugeFloat32: >+ metricDefinition = metricFactory >+ .newArmMetricGaugeFloat32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricNumericId32: >+ metricDefinition = metricFactory >+ .newArmMetricNumericId32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricNumericId64: >+ metricDefinition = metricFactory >+ .newArmMetricNumericId64Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricString32: >+ metricDefinition = metricFactory >+ .newArmMetricString32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ default: >+ metricDefinition = null; >+ break; >+ } >+ } >+ if (metricDefinition != null) { >+ metricDefs.add(metricDefinition); >+ metric.setDefinition(metricDefinition); >+ } >+ } >+ return metricDefs; >+ } >+ >+ /** >+ * Create an ArmTransactionWithMetrics instance. >+ * >+ * @param transName >+ * @param metrics >+ * @param transactionWithMetricsDef >+ * @return >+ */ >+ private ArmTransactionWithMetrics getArmTransactionWithMetric( >+ String transName, List metrics, >+ ArmTransactionWithMetricsDefinition transactionWithMetricsDef) { >+ ArmTransactionWithMetrics transactionWithMetrics; >+ List armMetrics = getArmMetric(metrics); >+ >+ ArmMetric[] metricDefArray = (ArmMetric[]) armMetrics >+ .toArray(new ArmMetric[armMetrics.size()]); >+ >+ ArmMetricGroup metGroup = metricFactory.newArmMetricGroup( >+ transactionWithMetricsDef.getMetricGroupDefinition(), >+ metricDefArray); >+ >+ transactionWithMetrics = metricFactory.newArmTransactionWithMetrics( >+ getArmApplication(), transactionWithMetricsDef, metGroup); >+ >+ return transactionWithMetrics; >+ } >+ >+ /** >+ * Get the ArmMetricDefinition instances.<br> >+ * TODO Move switch-case here to some other place. For example, another >+ * classes. switch-case is not good coding style. >+ * >+ * @param metrics >+ * List of ArmMetricManager.Metric. >+ * @return List of ArmMetric. >+ */ >+ private List getArmMetric(List metrics) { >+ List armMetrics = new ArrayList(); >+ for (Iterator iterator = metrics.iterator(); iterator.hasNext();) { >+ ArmMetricManager.Metric metric = (ArmMetricManager.Metric) iterator >+ .next(); >+ ArmMetric armMetric = null; >+ ArmMetricDefinition metricDefinition = metric.getDefinition(); >+ if (metricDefinition != null) { >+ String metricValue = metric.getMetricValue(); >+ // Big switch-case to create ArmMetric instance. >+ switch (metric.getMetricType()) { >+ case ArmMetricConstants.ArmMetricCounter32: >+ ArmMetricCounter32 armMetricCounter32 = metricFactory >+ .newArmMetricCounter32((ArmMetricCounter32Definition) metricDefinition); >+ armMetricCounter32.set(Integer.parseInt(metricValue)); >+ armMetric = armMetricCounter32; >+ break; >+ case ArmMetricConstants.ArmMetricCounter64: >+ ArmMetricCounter64 armMetricCounter64 = metricFactory >+ .newArmMetricCounter64((ArmMetricCounter64Definition) metricDefinition); >+ armMetricCounter64.set(Long.parseLong(metricValue)); >+ armMetric = armMetricCounter64; >+ break; >+ case ArmMetricConstants.ArmMetricCounterFloat32: >+ ArmMetricCounterFloat32 armMetricCounterFloat32 = metricFactory >+ .newArmMetricCounterFloat32((ArmMetricCounterFloat32Definition) metricDefinition); >+ armMetricCounterFloat32.set(Float.parseFloat(metricValue)); >+ armMetric = armMetricCounterFloat32; >+ break; >+ case ArmMetricConstants.ArmMetricGauge32: >+ ArmMetricGauge32 armMetricGauge32 = metricFactory >+ .newArmMetricGauge32((ArmMetricGauge32Definition) metricDefinition); >+ armMetricGauge32.set(Integer.parseInt(metricValue)); >+ armMetric = armMetricGauge32; >+ break; >+ case ArmMetricConstants.ArmMetricGauge64: >+ ArmMetricGauge64 armMetricGauge64 = metricFactory >+ .newArmMetricGauge64((ArmMetricGauge64Definition) metricDefinition); >+ armMetricGauge64.set(Long.parseLong(metricValue)); >+ armMetric = armMetricGauge64; >+ break; >+ case ArmMetricConstants.ArmMetricGaugeFloat32: >+ ArmMetricGaugeFloat32 armMetricGaugeFloat32 = metricFactory >+ .newArmMetricGaugeFloat32((ArmMetricGaugeFloat32Definition) metricDefinition); >+ armMetricGaugeFloat32.set(Float.parseFloat(metricValue)); >+ armMetric = armMetricGaugeFloat32; >+ break; >+ case ArmMetricConstants.ArmMetricNumericId32: >+ ArmMetricNumericId32 armMetricNumericId32 = metricFactory >+ .newArmMetricNumericId32((ArmMetricNumericId32Definition) metricDefinition); >+ armMetricNumericId32.set(Integer.parseInt(metricValue)); >+ armMetric = armMetricNumericId32; >+ break; >+ case ArmMetricConstants.ArmMetricNumericId64: >+ ArmMetricNumericId64 armMetricNumericId64 = metricFactory >+ .newArmMetricNumericId64((ArmMetricNumericId64Definition) metricDefinition); >+ armMetricNumericId64.set(Long.parseLong(metricValue)); >+ armMetric = armMetricNumericId64; >+ break; >+ case ArmMetricConstants.ArmMetricString32: >+ ArmMetricString32 armMetricString32 = metricFactory >+ .newArmMetricString32((ArmMetricString32Definition) metricDefinition); >+ armMetricString32.set(metricValue); >+ armMetric = armMetricString32; >+ break; >+ default: >+ armMetric = null; >+ break; >+ } >+ } >+ if (armMetric != null) { >+ armMetrics.add(armMetric); >+ } >+ } >+ return armMetrics; >+ } >+ >+ /** > * The wrapper method for the arm stop() call. > * > * @param transaction the transaction data >Index: src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmEventFactory.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmEventFactory.java,v >retrieving revision 1.6 >diff -u -r1.6 TPTPArmEventFactory.java >--- src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmEventFactory.java 28 Feb 2008 16:41:56 -0000 1.6 >+++ src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmEventFactory.java 24 Nov 2008 13:52:39 -0000 >@@ -20,6 +20,8 @@ > import org.eclipse.tptp.trace.arm.internal.transaction.ArmIdentityPropertiesImpl; > import org.eclipse.tptp.trace.arm.internal.transaction.ArmTransactionImpl; > import org.eclipse.tptp.trace.arm.internal.util.ArmIdentityProperty; >+import org.opengroup.arm40.metric.ArmMetricGroup; >+import org.opengroup.arm40.metric.ArmTransactionWithMetrics; > import org.opengroup.arm40.transaction.ArmApplication; > import org.opengroup.arm40.transaction.ArmApplicationDefinition; > import org.opengroup.arm40.transaction.ArmCorrelator; >@@ -37,15 +39,30 @@ > public class TPTPArmEventFactory { > > /** >- * > * @param transaction > * @return > */ > public static TPTPStartArmEvent newStartEvent(ArmTransaction transaction) { >- return new TPTPStartArmEventImpl(transaction); >+ if (transaction instanceof ArmTransactionWithMetrics) { >+ ArmTransactionWithMetrics transactionWithMetrics = (ArmTransactionWithMetrics) transaction; >+ return newStartMetricEvent(transactionWithMetrics); >+ } else { >+ return new TPTPStartArmEventImpl(transaction); >+ } > } > > /** >+ * Create TPTPStartArmEvent instance. This instance will be the >+ * implementation with metric. >+ * >+ * @param transaction >+ * @return >+ */ >+ public static TPTPStartArmEvent newStartMetricEvent(ArmTransactionWithMetrics transaction) { >+ return new TPTPStartArmMetricEventImpl(transaction); >+ } >+ >+ /** > * > * @param transaction > * @return >@@ -70,7 +87,28 @@ > super(transaction, ((ArmTransactionImpl) transaction) > .getArrivalTime()); > } >+ } >+ >+ /** >+ * Just extend to support metric. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+ private static class TPTPStartArmMetricEventImpl extends TPTPStartArmEventImpl >+ implements TPTPArmMetricEvent { >+ >+ public TPTPStartArmMetricEventImpl(ArmTransactionWithMetrics transaction) { >+ super(transaction); >+ this.metricGroup = transaction.getMetricGroup(); >+ } >+ >+ public ArmMetricGroup getArmMetricGroup() { >+ return metricGroup; >+ } > >+ private ArmMetricGroup metricGroup; > } > > /** >@@ -92,6 +130,8 @@ > > } > >+ >+ > /** > * > * @author rdanek >Index: src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodEventRecord.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodEventRecord.java,v >retrieving revision 1.3 >diff -u -r1.3 MethodEventRecord.java >--- src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodEventRecord.java 7 Jul 2006 16:39:28 -0000 1.3 >+++ src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodEventRecord.java 24 Nov 2008 13:52:39 -0000 >@@ -133,7 +133,7 @@ > String methodEvent = super.getXmlPrinter().MethodEntry( > _methodIdRef, _ticket, _sequenceCounter, _stackDepth, > _classIdRef, _threadIdRef, _time); >- methodEvent += "\r\n"+super.getXmlPrinter().ParameterRecord(super.getTransactionDetailIdRef())+"\r\n"; //$NON-NLS-1$ //$NON-NLS-2$ >+ methodEvent += "\r\n"+getEntryParameterPart()+"\r\n"; //$NON-NLS-1$ //$NON-NLS-2$ > methodEvent += super.getXmlPrinter().MethodEntryEnd(); > return methodEvent; > >@@ -143,4 +143,14 @@ > _classIdRef, _threadIdRef, _time); > } > >+ /** >+ * Parameter part of the record for method entry. The succlass can override >+ * it to add additional part. >+ * >+ * @return >+ */ >+ protected String getEntryParameterPart() { >+ return super.getXmlPrinter().ParameterRecord( >+ super.getTransactionDetailIdRef()); >+ } > } >\ No newline at end of file >Index: src-agent/org/eclipse/tptp/trace/arm/internal/agent/processor/ARMEventProcessor.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-agent/org/eclipse/tptp/trace/arm/internal/agent/processor/ARMEventProcessor.java,v >retrieving revision 1.5 >diff -u -r1.5 ARMEventProcessor.java >--- src-agent/org/eclipse/tptp/trace/arm/internal/agent/processor/ARMEventProcessor.java 20 Jul 2006 01:38:35 -0000 1.5 >+++ src-agent/org/eclipse/tptp/trace/arm/internal/agent/processor/ARMEventProcessor.java 24 Nov 2008 13:52:39 -0000 >@@ -20,12 +20,14 @@ > import org.eclipse.tptp.trace.arm.internal.agent.model.IRuntimeModel; > import org.eclipse.tptp.trace.arm.internal.agent.trace.events.InvocationContextRecord; > import org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodEventRecord; >+import org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodMetricEventRecord; > import org.eclipse.tptp.trace.arm.internal.agent.trace.events.RemoteMethodEventRecord; > import org.eclipse.tptp.trace.arm.internal.agent.trace.exceptions.MethodEntryException; > import org.eclipse.tptp.trace.arm.internal.agent.util.IEventProcessor; > import org.eclipse.tptp.trace.arm.internal.agent.util.Timestamp; > import org.eclipse.tptp.trace.arm.internal.correlator.TPTPArmCorrelator; > import org.eclipse.tptp.trace.arm.internal.event.TPTPArmEvent; >+import org.eclipse.tptp.trace.arm.internal.event.TPTPArmMetricEvent; > import org.eclipse.tptp.trace.arm.internal.event.TPTPStartArmEvent; > import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger; > >@@ -107,11 +109,20 @@ > > boolean isEntry = event instanceof TPTPStartArmEvent; > MethodEventRecord mr; >- >+ > if (isLocalInvocation && isSameThread) { >- mr = new MethodEventRecord(methodName, methodSignature, methodKey, >- ticket, seqCtr, className, threadid, timestamp, isEntry, >- appName, component); >+ // Create method event record with metric or without metric. >+ if (event instanceof TPTPArmMetricEvent) { >+ TPTPArmMetricEvent metricEvent = (TPTPArmMetricEvent) event; >+ mr = new MethodMetricEventRecord(methodName, methodSignature, >+ methodKey, ticket, seqCtr, className, threadid, >+ timestamp, isEntry, appName, component, metricEvent >+ .getArmMetricGroup()); >+ } else { >+ mr = new MethodEventRecord(methodName, methodSignature, >+ methodKey, ticket, seqCtr, className, threadid, >+ timestamp, isEntry, appName, component); >+ } > > } else { > mr = createRemoteMethodEvent(methodName, methodSignature, >Index: src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricConstants.java >=================================================================== >RCS file: src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricConstants.java >diff -N src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: ArmMetricConstants.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.model; >+ >+/** >+ * Classes to define the metric types. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.2 >+ * >+ */ >+public class ArmMetricConstants { >+ >+ // Metric types >+ public static final int UNKOWN = -1; >+ public static final int ArmMetricCounter32 = 1; >+ public static final int ArmMetricCounter64 = 2; >+ public static final int ArmMetricCounterFloat32 = 3; >+ public static final int ArmMetricGauge32 = 4; >+ public static final int ArmMetricGauge64 = 5; >+ public static final int ArmMetricGaugeFloat32 = 6; >+ public static final int ArmMetricNumericId32 = 7; >+ public static final int ArmMetricNumericId64 = 8; >+ public static final int ArmMetricString32 = 9; >+} >Index: src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmMetricEvent.java >=================================================================== >RCS file: src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmMetricEvent.java >diff -N src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmMetricEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmMetricEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: TPTPArmMetricEvent.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.event; >+ >+import org.opengroup.arm40.metric.ArmMetricGroup; >+ >+/** >+ * @author Gao Peng >+ * @since TPTP 4.5.2 >+ * >+ */ >+public interface TPTPArmMetricEvent extends TPTPArmEvent { >+ >+ /** >+ * Get the metric group. >+ * >+ * @return >+ */ >+ ArmMetricGroup getArmMetricGroup(); >+ >+} >Index: src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodMetricEventRecord.java >=================================================================== >RCS file: src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodMetricEventRecord.java >diff -N src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodMetricEventRecord.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodMetricEventRecord.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: MethodMetricEventRecord.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.agent.trace.events; >+ >+import org.eclipse.tptp.trace.arm.internal.agent.util.Timestamp; >+import org.eclipse.tptp.trace.arm.internal.metric.ArmMetricGroupImpl; >+import org.opengroup.arm40.metric.ArmMetric; >+import org.opengroup.arm40.metric.ArmMetricGroup; >+ >+/** >+ * This class extends MethodEventRecord to provide the feature about metric. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.2 >+ * >+ */ >+public class MethodMetricEventRecord extends MethodEventRecord { >+ >+ /** >+ * @param name >+ * @param signature >+ * @param key >+ * @param _ticket >+ * @param counter >+ * @param name2 >+ * @param idRef >+ * @param _timestamp >+ * @param entry >+ * @param applicationName >+ * @param transactionDetail >+ */ >+ public MethodMetricEventRecord(String name, String signature, Object key, >+ long _ticket, long counter, String name2, long idRef, >+ Timestamp _timestamp, boolean entry, String applicationName, >+ String transactionDetail, ArmMetricGroup metricGroup) { >+ super(name, signature, key, _ticket, counter, name2, idRef, _timestamp, >+ entry, applicationName, transactionDetail); >+ this.metricGroup = metricGroup; >+ } >+ >+ /** >+ * @return the metricGroup >+ */ >+ public ArmMetricGroup getMetricGroup() { >+ return metricGroup; >+ } >+ >+ private ArmMetricGroup metricGroup; >+ >+ /** >+ * Add the information about metric. >+ * >+ * @see org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodEventRecord#getEntryParameterPart() >+ */ >+ protected String getEntryParameterPart() { >+ String parameter = super.getEntryParameterPart(); >+ // Add the information about metric. >+ ArmMetric[] metrics = ((ArmMetricGroupImpl) metricGroup).getMetrics(); >+ for (int i = 0; i < metrics.length; i++) { >+ parameter += "\r\n" + metrics[i].toString(); >+ } >+ return parameter; >+ } >+ >+} >Index: src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricManager.java >=================================================================== >RCS file: src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricManager.java >diff -N src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,237 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: ArmMetricManager.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.model; >+ >+import java.io.BufferedReader; >+import java.io.File; >+import java.io.FileReader; >+import java.io.IOException; >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.opengroup.arm40.metric.ArmMetricDefinition; >+ >+/** >+ * Manager of Arm Metric. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.2 >+ * >+ */ >+public class ArmMetricManager { >+ >+ /** >+ * Prefix of the temp file for metric. >+ */ >+ private static final String ARM_PREFIX_FOR_METRIC = "ARM"; >+ >+ /** >+ * Singleton. >+ */ >+ private static final ArmMetricManager instance = new ArmMetricManager(); >+ >+ public static ArmMetricManager getInstance() { >+ return instance; >+ } >+ >+ private ArmMetricManager() { >+ try { >+ loadMetricProvider(); >+ } catch (Throwable e) { >+ // Do nothing. Just skip load. >+ } >+ } >+ >+ private void loadMetricProvider() throws IOException { >+ String tmpDir = System.getProperty("java.io.tmpdir"); >+ File metricFile = new File(tmpDir, ARM_PREFIX_FOR_METRIC >+ + "instrument-runtime.properties"); >+ >+ BufferedReader reader = new BufferedReader(new FileReader(metricFile)); >+ String line = reader.readLine(); >+ while (line != null) { >+ String[] metricInfo = line.split(IMetricValueProvider.SEPARATOR); >+ if (metricInfo.length >= 2) { >+ IMetricValueProvider provider = getMetricProvider(metricInfo[0]); >+ saveMetricInfo(provider, metricInfo[1]); >+ } >+ line = reader.readLine(); >+ } >+ } >+ >+ private void saveMetricInfo(IMetricValueProvider provider, String metricName) { >+ List metricNames = (List) metricInformation.get(provider); >+ if (metricNames == null) { >+ metricNames = new ArrayList(); >+ metricInformation.put(provider, metricNames); >+ } >+ metricNames.add(metricName); >+ } >+ >+ /** >+ * Get the instance of the {@link IMetricValueProvider}. A new instance will >+ * be created if there is no such instance. >+ * >+ * @param className The class name of the {@link IMetricValueProvider} >+ * @return >+ */ >+ private IMetricValueProvider getMetricProvider(String className) { >+ IMetricValueProvider provider = (IMetricValueProvider) metricProviders >+ .get(className); >+ if (provider == null) { >+ try { >+ Class clazz = Class.forName(className); >+ provider = (IMetricValueProvider) clazz.newInstance(); >+ metricProviders.put(className, provider); >+ } catch (ClassNotFoundException e) { >+ e.printStackTrace(); >+ } catch (NoClassDefFoundError e) { >+ e.printStackTrace(); >+ } catch (IllegalAccessException e) { >+ e.printStackTrace(); >+ } catch (InstantiationException e) { >+ e.printStackTrace(); >+ } >+ } >+ return provider; >+ } >+ >+ /** >+ * Check whether there is metric. >+ * >+ * @return >+ */ >+ public boolean hasMetric() { >+ return (metricProviders != null) && (metricProviders.size() != 0); >+ } >+ >+ /** >+ * Get the metrics. >+ * >+ * @return The list of the {@link ArmMetricManager.Metric}. >+ */ >+ public List getMetrics() { >+ List metrics = new ArrayList(); >+ for (Iterator iterator = metricInformation.entrySet().iterator(); iterator >+ .hasNext();) { >+ Map.Entry entry = (Map.Entry) iterator.next(); >+ IMetricValueProvider provider = (IMetricValueProvider) entry >+ .getKey(); >+ List metricNames = (List) entry.getValue(); >+ for (Iterator iterator2 = metricNames.iterator(); iterator2 >+ .hasNext();) { >+ String metricName = (String) iterator2.next(); >+ String metricValue = provider.getVaule(metricName); >+ int metricType = provider.getType(metricName); >+ metrics.add(new Metric(metricName, metricValue, metricType, >+ provider)); >+ } >+ } >+ return metrics; >+ } >+ >+ /** >+ * Support this method to support {@link IMetricValueProvider} instance >+ * initialization. >+ * >+ * @return >+ */ >+ public Collection getmMetricProviders() { >+ return metricProviders.values(); >+ } >+ >+ /** >+ * Store the instances of the {@link IMetricValueProvider}. The key is the >+ * class name, and the value is the instance. >+ */ >+ private Map metricProviders = new HashMap(); >+ >+ /** >+ * Store the instances of the {@link IMetricValueProvider} and the metrics >+ * they should provide. The key is the instance , and the value is the list >+ * of the metric name. >+ */ >+ private Map metricInformation = new HashMap(); >+ >+ /** >+ * Value object to store the metric information. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+ public class Metric { >+ >+ public Metric(String metricName, String metricValue, int metricType, >+ IMetricValueProvider metricProvider) { >+ super(); >+ this.metricName = metricName; >+ this.metricValue = metricValue; >+ this.metricType = metricType; >+ this.metricProvider = metricProvider; >+ } >+ >+ /** >+ * @return the metricName >+ */ >+ public String getMetricName() { >+ return metricName; >+ } >+ >+ /** >+ * @return the metricValue >+ */ >+ public String getMetricValue() { >+ return metricValue; >+ } >+ >+ /** >+ * @return the metricType >+ */ >+ public int getMetricType() { >+ return metricType; >+ } >+ >+ /** >+ * @return the metricProvider >+ */ >+ public IMetricValueProvider getMetricProvider() { >+ return metricProvider; >+ } >+ >+ /** >+ * @return the definition >+ */ >+ public ArmMetricDefinition getDefinition() { >+ return definition; >+ } >+ >+ /** >+ * @param definition >+ * the definition to set >+ */ >+ public void setDefinition(ArmMetricDefinition definition) { >+ this.definition = definition; >+ } >+ >+ private String metricName; >+ private String metricValue; >+ private int metricType; >+ private IMetricValueProvider metricProvider; >+ private ArmMetricDefinition definition; >+ >+ } >+} >Index: src-model/org/eclipse/tptp/trace/arm/internal/model/IMetricValueProvider.java >=================================================================== >RCS file: src-model/org/eclipse/tptp/trace/arm/internal/model/IMetricValueProvider.java >diff -N src-model/org/eclipse/tptp/trace/arm/internal/model/IMetricValueProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-model/org/eclipse/tptp/trace/arm/internal/model/IMetricValueProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: IMetricValueProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.model; >+ >+/** >+ * Interface for metric value provider. It's only used in agent. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.2 >+ * >+ */ >+public interface IMetricValueProvider { >+ >+ /** >+ * The separator between the metric information. >+ */ >+ String METRIC_SEPERATOR = "\t"; >+ >+ /** >+ * The separator between the parts of the metric information. >+ */ >+ String SEPARATOR = ","; >+ >+ /** >+ * >+ */ >+ String METRIC_PREFIX = "METRIC_PREFIX"; >+ >+ /** >+ * Return the metric value. >+ * >+ * @param name >+ * the metric name. >+ * @return the metric value. >+ */ >+ String getVaule(String name); >+ >+ /** >+ * Return the type of the metric value. >+ * >+ * @param name >+ * the metric name. >+ * @return the type of the metric value. >+ */ >+ int getType(String name); >+ >+ /** >+ * Return the metric values. >+ * >+ * @param name >+ * the metric names. >+ * @return the metric values. >+ */ >+ String[] getVaules(String[] names); >+ >+ /** >+ * Return the type of the metric values. >+ * >+ * @param name >+ * the metric names. >+ * @return the type of the metric values. >+ */ >+ int[] getType(String[] names); >+ >+} >#P org.eclipse.tptp.platform.instrumentation.ui >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPointManager.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPointManager.java,v >retrieving revision 1.5 >diff -u -r1.5 InstrumentPointManager.java >--- src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPointManager.java 27 Oct 2006 21:23:44 -0000 1.5 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPointManager.java 24 Nov 2008 13:52:44 -0000 >@@ -82,6 +82,9 @@ > String descr = element[j].getAttribute("description"); > String script = element[j].getAttribute("script"); > String instrumentTypeId = element[j].getAttribute("instrumentTypeId"); >+ >+ IMetricNameProvider[] metricProviders = MetricProviderManager >+ .getInstance().getMetricProviders(id); > > String cint = element[j].getContributor().getName(); > >@@ -135,6 +138,11 @@ > instrumentPoint.setProbeScriptContent(probeScriptContents); > instrumentPoint.setType(type); > instrumentPoint.setProbeScript(script); >+ if (metricProviders.length != 0) { >+ instrumentPoint >+ .setMetricProviders(new CombinedMetricProvider( >+ metricProviders)); >+ } > > instrumentPoints.put(id, instrumentPoint); > } catch (Exception ex) { >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPoint.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPoint.java,v >retrieving revision 1.1 >diff -u -r1.1 InstrumentPoint.java >--- src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPoint.java 16 Aug 2006 14:42:52 -0000 1.1 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPoint.java 24 Nov 2008 13:52:44 -0000 >@@ -48,6 +48,11 @@ > /* The contents of the probe script */ > private String probeScriptContent; > >+ /** >+ * The metric provider. This value can be null for no metric provider. >+ */ >+ private IMetricNameProvider metricProvider; >+ > > /** > * Default constructor >@@ -204,4 +209,18 @@ > this.type = type; > } > >+ /** >+ * @return the metricProviders >+ */ >+ public IMetricNameProvider getMetricProvider() { >+ return metricProvider; >+ } >+ >+ /** >+ * @param metricProviders >+ * the metricProviders to set >+ */ >+ public void setMetricProviders(IMetricNameProvider metricProvider) { >+ this.metricProvider = metricProvider; >+ } > } >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/InstrumentDelegateHelper.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/InstrumentDelegateHelper.java,v >retrieving revision 1.32 >diff -u -r1.32 InstrumentDelegateHelper.java >--- src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/InstrumentDelegateHelper.java 7 Mar 2008 15:57:03 -0000 1.32 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/InstrumentDelegateHelper.java 24 Nov 2008 13:52:44 -0000 >@@ -15,11 +15,13 @@ > import java.io.ByteArrayOutputStream; > import java.io.File; > import java.io.FileOutputStream; >+import java.io.FileWriter; >+import java.io.FilenameFilter; > import java.io.IOException; >+import java.io.PrintWriter; > import java.net.URL; > import java.util.ArrayList; > import java.util.HashMap; >-import java.util.Hashtable; > import java.util.Iterator; > import java.util.List; > import java.util.Map; >@@ -35,7 +37,6 @@ > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; > import org.eclipse.hyades.internal.execution.local.control.Agent; >-import org.eclipse.hyades.internal.execution.local.control.InactiveProcessException; > import org.eclipse.hyades.internal.execution.local.control.Process; > import org.eclipse.hyades.internal.execution.local.control.ProcessListener; > import org.eclipse.hyades.models.hierarchy.TRCProcessProxy; >@@ -53,16 +54,17 @@ > import org.eclipse.tptp.platform.instrumentation.ui.internal.LogHelper; > import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorLoader; > import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorManager; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider; > import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPoint; > import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPointManager; > import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentSelectManager; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.core.MetricProviderManager; > import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.FileTransfer; > import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.InstrumentLookupService; > import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.listener.InstrumentProcessListener; > import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentMessages; > import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentUtil; > import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisType; >-import org.eclipse.tptp.trace.ui.internal.launcher.core.DataCollector; > import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherMessages; > import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility; > import org.eclipse.tptp.trace.ui.provisional.launcher.ProcessParameters; >@@ -92,6 +94,9 @@ > * @return The save copy of ILaunchConfiguration > */ > public static ILaunchConfiguration preLaunch(ILaunchConfiguration configuration) throws CoreException { >+ >+ // Save metric information >+ saveMetricInfo(configuration); > > //first identified that it is JVMPI instrument Collector > InstrumentUtil.initiazeInstrumentCollector(configuration, InstrumentConstants.PI_INSTRUMENT_COLLECTOR); >@@ -102,10 +107,146 @@ > /* Create Project and Model */ > createModelEntities(configuration); > >+ > return handleInstrumentGenerator(configuration); > > } // end of preLaunch(...) >- >+ >+ /** >+ * Store the metric information in file in temp dir. This file will be read >+ * by the agent. >+ * >+ * @param configuration >+ * @throws CoreException >+ */ >+ private static void saveMetricInfo(ILaunchConfiguration configuration) >+ throws CoreException { >+ Map attributes = configuration.getAttributes(); >+ boolean saved = false; >+ for (Iterator iterator = attributes.keySet().iterator(); iterator >+ .hasNext();) { >+ String key = (String) iterator.next(); >+ if (key.startsWith(IMetricNameProvider.METRIC_PREFIX)) { >+ saved = saveMetricInfo(key, configuration.getAttribute(key, >+ (String) null)); >+ } >+ } >+ if (!saved) { >+ // remove the temp file for metric if ther is no metric file. >+ removeTempMetricFile(); >+ } >+ } >+ >+ >+ /** >+ * Store the metric information in file in temp dir. This file will be read >+ * by the agent. >+ * >+ * @param metricId the metric ID. >+ * @param metricInfo the metric information. >+ * @return >+ */ >+ private static boolean saveMetricInfo(String metricId, String metricInfo) { >+ if (metricInfo == null) { >+ // return false if nothing is saved. >+ return false; >+ } >+ >+ File metricFile = getTempMetricFile(metricId); >+ if (metricFile == null) >+ { >+ // return false if nothing is saved. >+ return false; >+ } >+ >+ String[][] metrics = getMetrics(metricInfo); >+ PrintWriter writer = null; >+ try { >+ writer = new PrintWriter(new FileWriter(metricFile)); >+ for (int i = 0; i < metrics.length; i++) { >+ writer.print(metrics[i][0]); >+ writer.print(IMetricNameProvider.SEPARATOR); >+ writer.println(metrics[i][1]); >+ } >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } finally { >+ if (writer != null) { >+ writer.flush(); >+ writer.close(); >+ } >+ } >+ >+ return true; >+ } >+ >+ /** >+ * Get the temp file name for metric. >+ * >+ * @param metricId >+ * @return >+ */ >+ private static File getTempMetricFile(String metricId) { >+ String[] metricMetadata = metricId.split(IMetricNameProvider.SEPARATOR); >+ if (metricMetadata.length != 3) { >+ return null; >+ } >+ String metricType = metricMetadata[1]; >+ >+ String tmpDir = System.getProperty("java.io.tmpdir"); >+ File metricFile = new File(tmpDir, metricType >+ + "instrument-runtime.properties"); >+ return metricFile; >+ } >+ >+ /** >+ * Remove all of the temp file for metric. >+ */ >+ private static void removeTempMetricFile() { >+ String tmpDir = System.getProperty("java.io.tmpdir"); >+ File[] metricFiles = new File(tmpDir).listFiles(new FilenameFilter(){ >+ >+ public boolean accept(File dir, String name) { >+ return name.endsWith("instrument-runtime.properties"); >+ }}); >+ for (int i = 0; i < metricFiles.length; i++) { >+ metricFiles[i].delete(); >+ } >+ } >+ >+ /** >+ * Parser the metric information to get the class names of the metric value >+ * providers and metric names. >+ * >+ * @param metricInfo >+ * @return The second dim is 2. The first element of the second dim is the >+ * class name of the metric value provider, and the second element >+ * of the second dim is metric name. >+ */ >+ private static String[][] getMetrics(String metricInfo) { >+ String[] metrics = metricInfo >+ .split(IMetricNameProvider.METRIC_SEPERATOR); >+ String[][] result = new String[metrics.length][2]; >+ for (int i = 0; i < metrics.length; i++) { >+ String[] metricInfos = metrics[i] >+ .split(IMetricNameProvider.SEPARATOR); >+ if (metricInfos.length != 2) { >+ result[i][0] = ""; >+ result[i][1] = ""; >+ } else { >+ String metricID = metricInfos[0]; >+ String metricName = metricInfos[1]; >+ String metricClassName = MetricProviderManager.getInstance() >+ .getMetricProvider(metricID) >+ .getMetricValueProviderName(); >+ result[i][0] = metricClassName; >+ result[i][1] = metricName; >+ } >+ } >+ >+ return result; >+ } >+ > /** > * It is used to handle instrument generator stuff for user selected analysis types. > * >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/plugin.xml,v >retrieving revision 1.31 >diff -u -r1.31 plugin.xml >--- plugin.xml 21 Oct 2008 14:18:33 -0000 1.31 >+++ plugin.xml 24 Nov 2008 13:52:44 -0000 >@@ -18,6 +18,7 @@ > <extension-point id="generatorMechanism" name="generatorMechanism" schema="schema/generatorMechanism.exsd"/> > <extension-point id="instrumentPointDeclaration" name="instrumentPointDeclaration" schema="schema/instrumentPointDeclaration.exsd"/> > <extension-point id="runtimeJarsDependency" name="runtimeJarsDependency" schema="schema/runtimeJarsDependency.exsd"/> >+ <extension-point id="metricProvider" name="metricProvider" schema="schema/metricProvider.exsd"/> > > <!-- The Instrument collector --> > <extension >Index: build.properties >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/build.properties,v >retrieving revision 1.5 >diff -u -r1.5 build.properties >--- build.properties 18 Jan 2008 23:57:35 -0000 1.5 >+++ build.properties 24 Nov 2008 13:52:44 -0000 >@@ -1,6 +1,7 @@ > source.. = src/ > output.. = bin/ >-bin.includes = about.html, META-INF/,\ >+bin.includes = about.html,\ >+ META-INF/,\ > .,\ > plugin.xml,\ > icons/,\ >@@ -8,4 +9,6 @@ > about.ini,\ > about.mappings,\ > about.properties,\ >- tptp32.png >+ tptp32.png,\ >+ HelpContexts.xml,\ >+ schema/ >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/CombinedMetricProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/CombinedMetricProvider.java >diff -N src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/CombinedMetricProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/CombinedMetricProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,114 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: CombinedMetricProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.platform.instrumentation.ui.internal.core; >+ >+import java.util.List; >+ >+/** >+ * Combine implementation of {@link IMetricNameProvider}. >+ * >+ * @since TPTP 4.5.2 >+ * @author Gao Peng >+ * >+ */ >+public class CombinedMetricProvider implements IMetricNameProvider { >+ >+ /** >+ * Default ID because this implementation of {@link IMetricNameProvider} is >+ * not defined in plugin.xml. >+ */ >+ private static final String COMBINED_ID = "CombinedMetricProvider"; >+ >+ /** >+ * @param metricProviders >+ * Implemenations of {@link IMetricNameProvider} which will be >+ * combined. >+ */ >+ public CombinedMetricProvider(IMetricNameProvider[] metricProviders) { >+ this.metricProviders = metricProviders; >+ } >+ >+ /** >+ * @param metricProviderList >+ * Implemenations of {@link IMetricNameProvider} which will be >+ * combined. >+ */ >+ public CombinedMetricProvider(List metricProviderList) { >+ this.metricProviders = (IMetricNameProvider[]) metricProviderList >+ .toArray(new IMetricNameProvider[metricProviderList.size()]); >+ } >+ >+ public String getId() { >+ return id; >+ } >+ >+ public void setId(String id) { >+ this.id = id; >+ } >+ >+ /** >+ * It will return the name of all of the combined >+ * {@link IMetricNameProvider} implementations with the format : >+ * id,metricName >+ * >+ * @see org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider#getNames() >+ */ >+ public String[] getNames() { >+ if ((metricProviders == null) || (metricProviders.length == 0)) { >+ return null; >+ } >+ >+ String[] names = getFullName(metricProviders[0]); >+ for (int i = 1; i < metricProviders.length; i++) { >+ IMetricNameProvider metricProvider = metricProviders[i]; >+ String[] newNames = getFullName(metricProvider); >+ String[] combinedNames = new String[names.length + newNames.length]; >+ System.arraycopy(names, 0, combinedNames, 0, names.length); >+ System.arraycopy(newNames, names.length, combinedNames, >+ names.length, newNames.length); >+ names = combinedNames; >+ } >+ >+ return names; >+ } >+ >+ /** >+ * Get names with the ID of the metric provider. >+ * >+ * @param metricProvider >+ * @return >+ */ >+ private String[] getFullName(IMetricNameProvider metricProvider) { >+ String[] names = metricProvider.getNames(); >+ String[] fullNames = new String[names.length]; >+ String metricProviderId = metricProvider.getId(); >+ for (int i = 0; i < fullNames.length; i++) { >+ fullNames[i] = metricProviderId + IMetricNameProvider.SEPARATOR >+ + names[i]; >+ } >+ return fullNames; >+ } >+ >+ /** >+ * No metric value provider for this {@link IMetricNameProvider} >+ * implementation. >+ * >+ * @see org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider#getMetricValueProviderName() >+ */ >+ public String getMetricValueProviderName() { >+ return null; >+ } >+ >+ private IMetricNameProvider[] metricProviders; >+ private String id = COMBINED_ID; >+ >+} >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/IMetricNameProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/IMetricNameProvider.java >diff -N src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/IMetricNameProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/IMetricNameProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: IMetricNameProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.platform.instrumentation.ui.internal.core; >+ >+/** >+ * Interface for metricProvider extension point. >+ * >+ * @since TPTP 4.5.2 >+ * @author Gao Peng >+ * >+ */ >+public interface IMetricNameProvider { >+ >+ /** >+ * The separator between the metric information. >+ */ >+ String METRIC_SEPERATOR = "\t"; >+ >+ /** >+ * The separator between the parts of the metric information. >+ */ >+ String SEPARATOR = ","; >+ >+ /** >+ * The prefix of the key which used in ILaunchConfiguration. >+ */ >+ String METRIC_PREFIX = "METRIC_PREFIX"; >+ >+ /** >+ * @return the ID of the metric provider. >+ */ >+ String getId(); >+ >+ /** >+ * Set the ID of the metric provider. >+ */ >+ void setId(String id); >+ >+ /** >+ * @return the name list of the metric provider. The name should start with >+ * the id and SEPARATOR. >+ */ >+ String[] getNames(); >+ >+ /** >+ * Get the name of the metric value provider. It should be a quality class >+ * name and be used when profiling. <br> >+ * >+ * I have to split the name provider and the value provider because this >+ * plugin are not used in agent controller. >+ * >+ * @return >+ */ >+ String getMetricValueProviderName(); >+} >Index: schema/metricProvider.exsd >=================================================================== >RCS file: schema/metricProvider.exsd >diff -N schema/metricProvider.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/metricProvider.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,148 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.tptp.platform.instrumentation.ui" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appinfo> >+ <meta.schema plugin="org.eclipse.tptp.platform.instrumentation.ui" id="metricProvider" name="metricProvider"/> >+ </appinfo> >+ <documentation> >+ This extension point is used to register metric provider. The metric provider supports metric data. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appinfo> >+ <meta.element /> >+ </appinfo> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="metricProvider" minOccurs="1" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appinfo> >+ <meta.attribute translatable="true"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="metricProvider"> >+ <complexType> >+ <sequence minOccurs="1" maxOccurs="unbounded"> >+ <element ref="instrumentPointIdRef"/> >+ </sequence> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="providerClass" type="string"> >+ <annotation> >+ <documentation> >+ Define the metric names provided by this implementation carefully. If there are duplicated names in multiply metricProvider, there is no guaratee that which metric names will be used in runmtime. >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="java" basedOn=":org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="instrumentPointIdRef"> >+ <complexType> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="since"/> >+ </appinfo> >+ <documentation> >+ Since TPTP 4.5.1 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="examples"/> >+ </appinfo> >+ <documentation> >+ <extension >+ point="org.eclipse.tptp.platform.instrumentation.ui.metricProvider"> >+ <metricProvider >+ id="org.eclipse.tptp.trace.arm.ptt.metricProvider" >+ providerClass="org.eclipse.tptp.trace.arm.ptt.PttMetricNameProvider"> >+ <instrumentPointIdRef >+ id="org.eclipse.tptp.trace.arm.probes.generic"> >+ </instrumentPointIdRef> >+ </metricProvider> >+ </extension> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="apiinfo"/> >+ </appinfo> >+ <documentation> >+ [Enter API information here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="implementation"/> >+ </appinfo> >+ <documentation> >+ [Enter information about supplied implementation of this extension point.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="copyright"/> >+ </appinfo> >+ <documentation> >+ Copyright (c) 2008 IBM Corporation and others. 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 <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/MetricProviderManager.java >=================================================================== >RCS file: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/MetricProviderManager.java >diff -N src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/MetricProviderManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/MetricProviderManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,159 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: MetricProviderManager.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.platform.instrumentation.ui.internal.core; >+ >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.LogHelper; >+ >+/** >+ * Manager of the metric provider. It scans for the metricProvider extensions >+ * and will register them with this manager. >+ * >+ * @since TPTP 4.5.2 >+ * @author Gao Peng >+ * >+ */ >+public class MetricProviderManager { >+ >+ /** The metric provider point extension */ >+ private static final String METRIC_PROVIDER_POINT_EXTENSION = "org.eclipse.tptp.platform.instrumentation.ui.metricProvider"; >+ >+ /** This instance of this singleton class */ >+ private static MetricProviderManager instance; >+ >+ /** >+ * Hide the default constructor. This ensures against outside instantiation. >+ */ >+ private MetricProviderManager() { >+ initialize(); >+ } >+ >+ /** >+ * Scan the registered instrument points and loads them in the >+ * instrumentPoints table. >+ */ >+ public void initialize() { >+ metricProviders.clear(); >+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry() >+ .getExtensionPoint(METRIC_PROVIDER_POINT_EXTENSION); >+ >+ if (extensionPoint == null) { >+ return; >+ } >+ >+ IExtension extension[] = extensionPoint.getExtensions(); >+ >+ // Iterate through each instrument point element to construct the >+ // instrument object and to associate it with the right entity. >+ for (int i = 0; i < extension.length; i++) { >+ IConfigurationElement[] metricNameProviders = extension[i] >+ .getConfigurationElements(); >+ for (int j = 0; j < metricNameProviders.length; j++) { >+ try { >+ String id = metricNameProviders[j].getAttribute("id"); >+ IMetricNameProvider provider = (IMetricNameProvider) metricNameProviders[j] >+ .createExecutableExtension("providerClass"); >+ provider.setId(id); >+ metricProviders.put(id, provider); >+ IConfigurationElement[] instrumentPointElements = metricNameProviders[j] >+ .getChildren(); >+ List instrumentPoints = new ArrayList(); >+ for (int k = 0; k < instrumentPointElements.length; k++) { >+ instrumentPoints.add(instrumentPointElements[k] >+ .getAttribute("id")); >+ } >+ instrumentPointRefs.put(provider, instrumentPoints); >+ } catch (Exception ex) { >+ // report the problem. >+ LogHelper.error(ex); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Returns the instance of this singleton class. >+ * >+ * @return The instance of this singleton class >+ */ >+ public static MetricProviderManager getInstance() { >+ if (instance == null) >+ instance = new MetricProviderManager(); >+ return instance; >+ } >+ >+ /** >+ * Returns all the registered InstrumentPoint >+ * >+ * @return an array of all the registered InstrumentPoint >+ */ >+ public IMetricNameProvider[] getMetricProviders() { >+ return (IMetricNameProvider[]) metricProviders.values().toArray( >+ new IMetricNameProvider[metricProviders.size()]); >+ } >+ >+ /** >+ * Returns an InstrumentPoint with a given id. >+ * >+ * @param id >+ * the id >+ * @return an InstrumentPoint >+ */ >+ public IMetricNameProvider getMetricProvider(String id) { >+ return (IMetricNameProvider) metricProviders.get(id); >+ } >+ >+ /** >+ * Get the metric providers for the instrument point. >+ * >+ * @param instrumentPointRefId >+ * @return >+ */ >+ public IMetricNameProvider[] getMetricProviders(String instrumentPointRefId) { >+ List metricProviderList = new ArrayList(); >+ for (Iterator iterator = instrumentPointRefs.entrySet().iterator(); iterator >+ .hasNext();) { >+ Map.Entry entry = (Map.Entry) iterator.next(); >+ List instrumentPointRefIds = (List) entry.getValue(); >+ if (instrumentPointRefIds.contains(instrumentPointRefId)) { >+ metricProviderList.add(entry.getKey()); >+ } >+ } >+ return (IMetricNameProvider[]) metricProviderList >+ .toArray(new IMetricNameProvider[metricProviderList.size()]); >+ } >+ >+ /** >+ * Stores the {@link IMetricNameProvider} instances. <br> >+ * KEY = metric provider id. <br> >+ * VALUE = An instance of metric provider >+ */ >+ private Map metricProviders = new HashMap(); >+ >+ /** >+ * Stores the reference between the metric provider and the instrument >+ * points. <br> >+ * KEY = metric provider. <br> >+ * VALUE = The instrument points >+ */ >+ private Map instrumentPointRefs = new HashMap(); >+ >+} >#P org.eclipse.hyades.trace.views >Index: src/org/eclipse/hyades/trace/views/internal/MethodInvocationStatistic.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.hyades.trace.views/src/org/eclipse/hyades/trace/views/internal/MethodInvocationStatistic.java,v >retrieving revision 1.37 >diff -u -r1.37 MethodInvocationStatistic.java >--- src/org/eclipse/hyades/trace/views/internal/MethodInvocationStatistic.java 27 May 2008 15:25:35 -0000 1.37 >+++ src/org/eclipse/hyades/trace/views/internal/MethodInvocationStatistic.java 24 Nov 2008 13:52:47 -0000 >@@ -34,6 +34,8 @@ > import org.eclipse.hyades.trace.views.internal.view.columnlabels.MethodInvocationColumnLabel; > import org.eclipse.hyades.trace.views.internal.view.columnlabels.MethodInvocationEntryTimeColumnLabel; > import org.eclipse.hyades.trace.views.util.internal.ColumnData; >+import org.eclipse.hyades.trace.views.util.internal.ColumnExtensionValue; >+import org.eclipse.hyades.trace.views.util.internal.IColumnExtension; > import org.eclipse.hyades.trace.views.util.internal.ITimeChangedListener; > import org.eclipse.hyades.trace.views.util.internal.StatisticTableColumnInfo; > import org.eclipse.hyades.ui.provisional.context.ContextManager; >@@ -269,7 +271,12 @@ > case 4://cpu time > return getElementColumnText(obj, _CPUTimeCol, false); > } >- >+ >+ // if column extended >+ if (_listOfColumExtension.size() != 0) { >+ ColumnExtensionValue elt = (ColumnExtensionValue) _listOfColumExtension.get(pos - 5); >+ return ((IColumnExtension)(elt.getClassOfColumnExtension())).getColumnText(obj,elt.getInitialColumnPos()); >+ } > > return ""; > } >@@ -356,6 +363,7 @@ > + IContextAttributes.METHOD_AVG_BASE_TIME + ":4:" > + String.valueOf(ColumnData.IS_VISIBLE) + ":right:100"; > >+ executionColumn += getColumnsTemplateExtensions(5, "org.eclipse.hyades.trace.views.internal.MethodInvocationStatistic", false); > return executionColumn; > } >
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 166692
:
116824
| 118588 |
118589