Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 166692 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 16-22 Link Here
16
 org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)",
16
 org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)",
17
 org.eclipse.hyades.trace.views;bundle-version="[4.1.0,5.0.0)",
17
 org.eclipse.hyades.trace.views;bundle-version="[4.1.0,5.0.0)",
18
 org.eclipse.text,
18
 org.eclipse.text,
19
 org.eclipse.jdt.ui;bundle-version="[3.2.0,4.0.0)"
19
 org.eclipse.jdt.ui;bundle-version="[3.2.0,4.0.0)",
20
 org.eclipse.tptp.platform.models
20
Eclipse-LazyStart: true
21
Eclipse-LazyStart: true
21
Bundle-ActivationPolicy: lazy
22
Bundle-ActivationPolicy: lazy
22
Bundle-RequiredExecutionEnvironment: J2SE-1.4
23
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)src/org/eclipse/tptp/trace/arm/ui/internal/util/messages.properties (+2 lines)
Lines 23-28 Link Here
23
NAME_COLUMN = Name
23
NAME_COLUMN = Name
24
DESCP_COLUMN = Description
24
DESCP_COLUMN = Description
25
FILTER_LABEL = Filter
25
FILTER_LABEL = Filter
26
METRIC_LABEL = Metric
26
NO_DESCP_LABEL = No description given
27
NO_DESCP_LABEL = No description given
27
INTERNAL_ERROR = Internal error in ARM analysis type
28
INTERNAL_ERROR = Internal error in ARM analysis type
28
29
Lines 30-35 Link Here
30
ERROR_INSTRUMENT_EXIST_DETAIL = Occured in method: {0}()\n
31
ERROR_INSTRUMENT_EXIST_DETAIL = Occured in method: {0}()\n
31
32
32
INSTRUMENT_POINT_FILTER_TITLE = Instrument Point Filter
33
INSTRUMENT_POINT_FILTER_TITLE = Instrument Point Filter
34
ARM_METRIC_TITLE = Available metric properties
33
35
34
DEFAULT_SERVLET_FILTER = Default Servlet Filter Set
36
DEFAULT_SERVLET_FILTER = Default Servlet Filter Set
35
DEFAULT_JDBC_FILTER = Default JDBC Filter Set
37
DEFAULT_JDBC_FILTER = Default JDBC Filter Set
(-)src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmMessages.java (+2 lines)
Lines 34-44 Link Here
34
	public static String NAME_COLUMN;
34
	public static String NAME_COLUMN;
35
	public static String DESCP_COLUMN;
35
	public static String DESCP_COLUMN;
36
	public static String FILTER_LABEL;
36
	public static String FILTER_LABEL;
37
	public static String METRIC_LABEL;
37
	public static String NO_DESCP_LABEL;
38
	public static String NO_DESCP_LABEL;
38
	public static String INTERNAL_ERROR;
39
	public static String INTERNAL_ERROR;
39
	public static String ERROR_INTRUMENT_EXIST;
40
	public static String ERROR_INTRUMENT_EXIST;
40
	public static String ERROR_INSTRUMENT_EXIST_DETAIL;
41
	public static String ERROR_INSTRUMENT_EXIST_DETAIL;
41
	public static String INSTRUMENT_POINT_FILTER_TITLE;
42
	public static String INSTRUMENT_POINT_FILTER_TITLE;
43
	public static String ARM_METRIC_TITLE;
42
	public static String DEFAULT_SERVLET_FILTER;
44
	public static String DEFAULT_SERVLET_FILTER;
43
	public static String DEFAULT_JDBC_FILTER;
45
	public static String DEFAULT_JDBC_FILTER;
44
	public static String DEFAULT_J2EE_FILTER;
46
	public static String DEFAULT_J2EE_FILTER;
(-)src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmConstants.java (+2 lines)
Lines 32-37 Link Here
32
	public static final String TRANSACTION_GOOD_STATEMENT = "armStatus = " + ARM_TRANSACTION_GOOD_EXPRESSION + ";";
32
	public static final String TRANSACTION_GOOD_STATEMENT = "armStatus = " + ARM_TRANSACTION_GOOD_EXPRESSION + ";";
33
	public static final String TRANSACTION_FAILED_STATEMENT = "armStatus = " + ARM_TRANSACTION_FAILED_EXPRESSION + ";";
33
	public static final String TRANSACTION_FAILED_STATEMENT = "armStatus = " + ARM_TRANSACTION_FAILED_EXPRESSION + ";";
34
	
34
	
35
	public static final String ARM_PREFIX_FOR_METRIC = "ARM";
36
	
35
	public static final String ACTIVE_FILTER_PREFIX = "ACTIVE_FILTER_FOR_";
37
	public static final String ACTIVE_FILTER_PREFIX = "ACTIVE_FILTER_FOR_";
36
	public static final String ENABLE_FILTER_PREFIX = "ENABLE_FILTER_FOR_";
38
	public static final String ENABLE_FILTER_PREFIX = "ENABLE_FILTER_FOR_";
37
	public static final String FILTER_SET_PREFIX = "FILTER_SET_FOR_";
39
	public static final String FILTER_SET_PREFIX = "FILTER_SET_FOR_";
(-)src/org/eclipse/tptp/trace/arm/ui/internal/configuration/InstrumentPointSelectionUI.java (-9 / +23 lines)
Lines 64-70 Link Here
64
	/* The indexs for the points table */
64
	/* The indexs for the points table */
65
	private final static int NAME_INDEX = 0;
65
	private final static int NAME_INDEX = 0;
66
	private final static int FILTER_INDEX = 1;
66
	private final static int FILTER_INDEX = 1;
67
	private final static int DESCRIPTION_INDEX = 2;
67
	private final static int METRIC_INDEX = 2;
68
	private final static int DESCRIPTION_INDEX = 3;
68
	
69
	
69
	private final static String ARM_INSTRUM_TYPE = 
70
	private final static String ARM_INSTRUM_TYPE = 
70
		"org.eclipse.tptp.trace.arm.ui.armInstrumentType";
71
		"org.eclipse.tptp.trace.arm.ui.armInstrumentType";
Lines 101-107 Link Here
101
	public void setSelectItems(List list) {
102
	public void setSelectItems(List list) {
102
		TableItem[] items = pointsTable.getItems();
103
		TableItem[] items = pointsTable.getItems();
103
		
104
		
104
		if (list != null || list.size() > 0) {
105
		if (list != null && list.size() > 0) {
105
			for (int i = 0; i < items.length; i++) {
106
			for (int i = 0; i < items.length; i++) {
106
				InstrumentPoint entry = (InstrumentPoint) items[i].getData();
107
				InstrumentPoint entry = (InstrumentPoint) items[i].getData();
107
				if (list.contains(entry.getId())) {
108
				if (list.contains(entry.getId())) {
Lines 149-154 Link Here
149
		TableLayout tableLayout = new TableLayout();
150
		TableLayout tableLayout = new TableLayout();
150
		tableLayout.addColumnData(new ColumnWeightData(150, true));
151
		tableLayout.addColumnData(new ColumnWeightData(150, true));
151
        tableLayout.addColumnData(new ColumnWeightData(50, true));
152
        tableLayout.addColumnData(new ColumnWeightData(50, true));
153
        tableLayout.addColumnData(new ColumnWeightData(50, true));
152
        tableLayout.addColumnData(new ColumnWeightData(200, true));
154
        tableLayout.addColumnData(new ColumnWeightData(200, true));
153
        
155
        
154
        pointsTable.setHeaderVisible(true);
156
        pointsTable.setHeaderVisible(true);
Lines 170-179 Link Here
170
		TableColumn tc2 = new TableColumn(pointsTable, SWT.NONE);
172
		TableColumn tc2 = new TableColumn(pointsTable, SWT.NONE);
171
		tc2.setText(ArmMessages.FILTER_LABEL);
173
		tc2.setText(ArmMessages.FILTER_LABEL);
172
		tc2.setWidth(45);
174
		tc2.setWidth(45);
173
		
175
174
		TableColumn tc3 = new TableColumn(pointsTable, SWT.NONE);
176
		TableColumn tc3 = new TableColumn(pointsTable, SWT.NONE);
175
		tc3.setText(ArmMessages.DESCP_COLUMN);
177
		tc3.setText(ArmMessages.METRIC_LABEL);
176
		tc3.setWidth(200);
178
		tc3.setWidth(45);
179
180
		TableColumn tc4 = new TableColumn(pointsTable, SWT.NONE);
181
		tc4.setText(ArmMessages.DESCP_COLUMN);
182
		tc4.setWidth(200);
177
		
183
		
178
		InstrumentPoint loaders[] = 
184
		InstrumentPoint loaders[] = 
179
			InstrumentPointManager.getInstance().getInstrumentPointsByType(
185
			InstrumentPointManager.getInstance().getInstrumentPointsByType(
Lines 233-241 Link Here
233
	protected void columnClicked(int columnToEdit) {
239
	protected void columnClicked(int columnToEdit) {
234
		IStructuredSelection selection = (IStructuredSelection) pointsList.getSelection();
240
		IStructuredSelection selection = (IStructuredSelection) pointsList.getSelection();
235
		InstrumentPoint vmd = (InstrumentPoint) selection.getFirstElement();
241
		InstrumentPoint vmd = (InstrumentPoint) selection.getFirstElement();
236
		if (vmd != null && (columnToEdit == FILTER_INDEX)) {
242
		if (vmd != null) {
237
			InstrumentPointFiltersDialog intrumentPointDlg = new InstrumentPointFiltersDialog(null, launchConfiguration, vmd.getId());
243
			if (columnToEdit == FILTER_INDEX) {
238
			intrumentPointDlg.open();
244
				InstrumentPointFiltersDialog intrumentPointDlg = new InstrumentPointFiltersDialog(
245
						null, launchConfiguration, vmd.getId());
246
				intrumentPointDlg.open();
247
			} else if (columnToEdit == METRIC_INDEX) {
248
				if (vmd.getMetricProvider() != null) {
249
					ArmMetricsDialog armMetricsDialog = new ArmMetricsDialog(null, launchConfiguration, vmd);
250
					armMetricsDialog.open();
251
				}
252
			}
239
		}
253
		}
240
	}
254
	}
241
	
255
	
Lines 245-251 Link Here
245
	public class InstrumentPointLabelProvider extends LabelProvider implements ITableLabelProvider {
259
	public class InstrumentPointLabelProvider extends LabelProvider implements ITableLabelProvider {
246
		
260
		
247
		public Image getColumnImage(Object element, int columnIndex) {
261
		public Image getColumnImage(Object element, int columnIndex) {
248
			if (columnIndex == FILTER_INDEX) {
262
			if ((columnIndex == FILTER_INDEX)|| (columnIndex == METRIC_INDEX)) {
249
				return ArmUIPlugin.getDefault().getImage("settings");
263
				return ArmUIPlugin.getDefault().getImage("settings");
250
			}
264
			}
251
			return null;
265
			return null;
(-)plugin.xml (+16 lines)
Lines 199-202 Link Here
199
                       
199
                       
200
   </extension>
200
   </extension>
201
   
201
   
202
   <extension
203
         point="org.eclipse.hyades.trace.views.columnExtension">
204
      <columnExtension
205
            align="right"
206
            class="org.eclipse.tptp.trace.arm.ui.internal.configuration.ArmMetricColumnExtension"
207
            id="org.eclipse.tptp.trace.arm.ui.internal.configuration.ArmMetricColumnExtension"
208
            name="Arm Metric Information"
209
            pos="0"
210
            style="1"
211
            width="90">
212
         <applyTo
213
               viewId="org.eclipse.hyades.trace.views.internal.MethodInvocationStatistic">
214
         </applyTo>
215
      </columnExtension>
216
   </extension>
217
   
202
</plugin>
218
</plugin>
(-)src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricContentProvider.java (+38 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: ArmMetricContentProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.ui.internal.configuration;
13
14
import org.eclipse.jface.viewers.IStructuredContentProvider;
15
import org.eclipse.jface.viewers.Viewer;
16
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider;
17
18
/**
19
 * Content provider of ArmMetricsDialog.
20
 * 
21
 * @author Gao Peng
22
 * @since TPTP 4.5.2
23
 * 
24
 */
25
public class ArmMetricContentProvider implements IStructuredContentProvider {
26
27
	public Object[] getElements(Object inputElement) {
28
		return ((IMetricNameProvider) inputElement).getNames();
29
	}
30
31
	public void dispose() {
32
		// Do nothing.
33
	}
34
35
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
36
		// Do nothing.
37
	}
38
}
(-)src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricsDialog.java (+174 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: ArmMetricsDialog.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.ui.internal.configuration;
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17
import org.eclipse.hyades.ui.util.GridUtil;
18
import org.eclipse.jface.dialogs.Dialog;
19
import org.eclipse.jface.viewers.CheckboxTableViewer;
20
import org.eclipse.jface.viewers.ColumnLayoutData;
21
import org.eclipse.jface.viewers.ColumnPixelData;
22
import org.eclipse.jface.viewers.TableLayout;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.graphics.Point;
25
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.layout.GridLayout;
27
import org.eclipse.swt.widgets.Composite;
28
import org.eclipse.swt.widgets.Control;
29
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.swt.widgets.Table;
31
import org.eclipse.swt.widgets.TableColumn;
32
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider;
33
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPoint;
34
import org.eclipse.tptp.trace.arm.ui.internal.util.ArmConstants;
35
import org.eclipse.tptp.trace.arm.ui.internal.util.ArmMessages;
36
37
/**
38
 * Dialog to get the configuration of metric.
39
 * 
40
 * @author Gao Peng
41
 * @since TPTP 4.5.1
42
 */
43
public class ArmMetricsDialog extends Dialog {
44
45
	public ArmMetricsDialog(Shell parentShell,
46
			ILaunchConfiguration launchConfiguration,
47
			InstrumentPoint instrumentPoint) {
48
		super(parentShell);
49
		setShellStyle(getShellStyle() | SWT.RESIZE);
50
51
		this.instrumentPoint = instrumentPoint;
52
		this.launchConfiguration = launchConfiguration;
53
	}
54
55
	protected Control createDialogArea(Composite parent) {
56
		Composite result = (Composite) super.createDialogArea(parent);
57
58
		Composite tableGroup = new Composite(result, SWT.NONE);
59
		GridLayout layout = new GridLayout();
60
		layout.numColumns = 1;
61
		tableGroup.setLayout(layout);
62
		GridData data = GridUtil.createFill();
63
		data.heightHint = 100;
64
65
		tableGroup.setLayoutData(data);
66
		Table filterSetTable = new Table(tableGroup, SWT.V_SCROLL | SWT.BORDER
67
				| SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK);
68
		filterSetTable.setLinesVisible(false);
69
		filterSetTable.setLayoutData(GridUtil.createFill());
70
71
		armTableViewer = new CheckboxTableViewer(filterSetTable);
72
		armTableViewer.setContentProvider(new ArmMetricContentProvider());
73
		armTableViewer.setLabelProvider(new ArmMetricLabelProvider());
74
		armTableViewer.setInput(instrumentPoint.getMetricProvider());
75
76
		TableLayout layoutt = new TableLayout();
77
		filterSetTable.setLayout(layoutt);
78
79
		ColumnLayoutData l = new ColumnPixelData(420, true);
80
		layoutt.addColumnData(l);
81
82
		TableColumn tc = new TableColumn(filterSetTable, SWT.NONE, 0);
83
		tc.setResizable(l.resizable);
84
85
		configUI();
86
87
		return result;
88
	}
89
90
	/**
91
	 * Load configuration of metric from ILaunchConfiguration and setup Table in
92
	 * dialog.
93
	 */
94
	private void configUI() {
95
		try {
96
			String checkedMetrics = launchConfiguration.getAttribute(
97
					getArmKey(), "");
98
			if (!checkedMetrics.equals("")) {
99
				armTableViewer.setCheckedElements(checkedMetrics
100
						.split(IMetricNameProvider.METRIC_SEPERATOR));
101
			}
102
		} catch (CoreException e) {
103
			e.printStackTrace();
104
		}
105
	}
106
107
	/**
108
	 * Override to double the dialog size.
109
	 * 
110
	 * @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
111
	 */
112
	protected Point getInitialSize() {
113
		Point size = super.getInitialSize();
114
		// Double the size of the dialog.
115
		Point doubleSize = new Point(size.x * 2, size.y * 2);
116
		return doubleSize;
117
	}
118
119
	/**
120
	 * Get the configuration of the metric, and save it in ILaunchConfiguration.
121
	 */
122
	protected void okPressed() {
123
		if (launchConfiguration instanceof ILaunchConfigurationWorkingCopy) {
124
			ILaunchConfigurationWorkingCopy workingCopy = (ILaunchConfigurationWorkingCopy) launchConfiguration;
125
126
			StringBuffer buffer = new StringBuffer();
127
			for (int i = 0; i < armTableViewer.getCheckedElements().length; i++) {
128
				String element = (String) armTableViewer.getCheckedElements()[i];
129
				buffer.append(element).append(
130
						IMetricNameProvider.METRIC_SEPERATOR);
131
			}
132
133
			if (buffer.length() == 0) {
134
				workingCopy.removeAttribute(getArmKey());
135
			} else {
136
				workingCopy.setAttribute(getArmKey(), buffer.toString());
137
			}
138
		}
139
140
		super.okPressed();
141
	}
142
143
	/**
144
	 * Get the key to store metric information in ILaunchConfiguration.
145
	 * 
146
	 * @return
147
	 */
148
	private String getArmKey() {
149
		return IMetricNameProvider.METRIC_PREFIX
150
				+ IMetricNameProvider.SEPARATOR
151
				+ ArmConstants.ARM_PREFIX_FOR_METRIC
152
				+ IMetricNameProvider.SEPARATOR + instrumentPoint.getId();
153
	}
154
155
	protected void configureShell(Shell newShell) {
156
		super.configureShell(newShell);
157
		newShell.setText(ArmMessages.ARM_METRIC_TITLE);
158
	}
159
160
	/**
161
	 * ILaunchConfiguration of the workbench.
162
	 */
163
	private ILaunchConfiguration launchConfiguration;
164
	
165
	/**
166
	 * InstrumentPoint about the metric.
167
	 */
168
	private InstrumentPoint instrumentPoint;
169
	
170
	/**
171
	 * CheckboxTableViewer of the Table in dialog.
172
	 */
173
	private CheckboxTableViewer armTableViewer;
174
}
(-)src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricColumnExtension.java (+88 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: ArmMetricContentProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.ui.internal.configuration;
13
14
import java.util.Iterator;
15
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IConfigurationElement;
18
import org.eclipse.hyades.models.hierarchy.TRCAnnotation;
19
import org.eclipse.hyades.models.trace.impl.TRCFullMethodInvocationImpl;
20
import org.eclipse.hyades.trace.views.util.internal.IColumnExtension;
21
import org.eclipse.jface.viewers.ILabelProviderListener;
22
import org.eclipse.swt.graphics.Image;
23
24
/**
25
 * Column extension for Arm Metric.
26
 * 
27
 * @author Gao Peng
28
 * @since TPTP 4.5.2
29
 * 
30
 */
31
public class ArmMetricColumnExtension implements IColumnExtension {
32
33
	private static final String METRIC_SEPERATOR = ",";
34
35
	public int compare(int pos, Object e1, Object e2) {
36
		return 0;
37
	}
38
39
	public Image getColumnImage(Object element, int columnIndex) {
40
		return null;
41
	}
42
43
	public String getColumnText(Object element, int columnIndex) {
44
		TRCFullMethodInvocationImpl method = (TRCFullMethodInvocationImpl) element;
45
46
		String ticket = Long.toString(method.getTicket());
47
		StringBuffer metricBuffer = new StringBuffer();
48
		for (Iterator annotationIterator = method.getMethod().getAnnotations()
49
				.iterator(); annotationIterator.hasNext();) {
50
			TRCAnnotation annotation = (TRCAnnotation) annotationIterator
51
					.next();
52
			if (ticket.equals(annotation.getName())) {
53
				for (Iterator metricIterator = annotation.getValues()
54
						.iterator(); metricIterator.hasNext();) {
55
					metricBuffer.append(metricIterator.next());
56
					if (metricIterator.hasNext()) {
57
						metricBuffer.append(METRIC_SEPERATOR);
58
					}
59
				}
60
			}
61
		}
62
63
		return metricBuffer.toString();
64
	}
65
66
	public void addListener(ILabelProviderListener listener) {
67
		// Do nothing.
68
	}
69
70
	public void dispose() {
71
		// Do nothing.
72
	}
73
74
	public boolean isLabelProperty(Object element, String property) {
75
		// Do nothing.
76
		return false;
77
	}
78
79
	public void removeListener(ILabelProviderListener listener) {
80
		// Do nothing.
81
	}
82
83
	public void setInitializationData(IConfigurationElement config,
84
			String propertyName, Object data) throws CoreException {
85
		// Do nothing.
86
	}
87
88
}
(-)src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricLabelProvider.java (+37 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: ArmMetricLabelProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.ui.internal.configuration;
13
14
import org.eclipse.jface.viewers.ITableLabelProvider;
15
import org.eclipse.jface.viewers.LabelProvider;
16
import org.eclipse.swt.graphics.Image;
17
18
/**
19
 * Label provider of ArmMetricsDialog.
20
 * 
21
 * @author Gao Peng
22
 * @since TPTP 4.5.2
23
 * 
24
 */
25
public class ArmMetricLabelProvider extends LabelProvider implements
26
		ITableLabelProvider {
27
28
	public Image getColumnImage(Object element, int columnIndex) {
29
		// No image.
30
		return null;
31
	}
32
33
	public String getColumnText(Object element, int columnIndex) {
34
		return (String) element;
35
	}
36
37
}
(-)src-trace/org/eclipse/hyades/loaders/trace/XMLmethodEntryLoader.java (-2 / +71 lines)
Lines 11-20 Link Here
11
 * $Id: XMLmethodEntryLoader.java,v 1.16 2008/03/12 20:37:17 jkubasta Exp $
11
 * $Id: XMLmethodEntryLoader.java,v 1.16 2008/03/12 20:37:17 jkubasta Exp $
12
 **********************************************************************/
12
 **********************************************************************/
13
package org.eclipse.hyades.loaders.trace;
13
package org.eclipse.hyades.loaders.trace;
14
import java.util.ArrayList;
15
import java.util.List;
16
14
import org.eclipse.hyades.loaders.trace.TraceUtils.InvocationInfo;
17
import org.eclipse.hyades.loaders.trace.TraceUtils.InvocationInfo;
15
import org.eclipse.hyades.loaders.util.HierarchyContext;
18
import org.eclipse.hyades.loaders.util.HierarchyContext;
16
import org.eclipse.hyades.loaders.util.LoadersUtils;
19
import org.eclipse.hyades.loaders.util.LoadersUtils;
17
import org.eclipse.hyades.loaders.util.LookupServiceExtensions;
20
import org.eclipse.hyades.loaders.util.LookupServiceExtensions;
21
import org.eclipse.hyades.models.hierarchy.HierarchyFactory;
22
import org.eclipse.hyades.models.hierarchy.TRCAnnotation;
18
import org.eclipse.hyades.models.trace.TRCClass;
23
import org.eclipse.hyades.models.trace.TRCClass;
19
import org.eclipse.hyades.models.trace.TRCFullMethodInvocation;
24
import org.eclipse.hyades.models.trace.TRCFullMethodInvocation;
20
import org.eclipse.hyades.models.trace.TRCFullTraceObject;
25
import org.eclipse.hyades.models.trace.TRCFullTraceObject;
Lines 29-34 Link Here
29
 *  
34
 *  
30
 */
35
 */
31
public class XMLmethodEntryLoader extends TraceMethodBaseLoader {
36
public class XMLmethodEntryLoader extends TraceMethodBaseLoader {
37
38
	private static final String METRIC_PRE = "ArmMetric";
39
	private static final String METRIC_SEPERATOR = ":";
40
	
32
	//~ Static fields/initializers
41
	//~ Static fields/initializers
33
	// -----------------------------------------------------------------
42
	// -----------------------------------------------------------------
34
	//    private static final String THREAD_ID_REF = "threadIdRef";
43
	//    private static final String THREAD_ID_REF = "threadIdRef";
Lines 38-44 Link Here
38
		if (!loadToModel) {
47
		if (!loadToModel) {
39
			return;
48
			return;
40
		}
49
		}
41
		super.addAttribute(name, value);
50
		if (inMetric) {
51
			// There are many name and value attribute in the metric elements.
52
			// The first pair is the name and value of metric. The key and value
53
			// will be clean when element end.
54
			if (name.equals("name")) {
55
				metricName = (metricName == null) ? value : metricName;
56
			} else if (name.equals("value")) {
57
				metricValue = (metricValue == null) ? value : metricValue;
58
			}
59
		} else {
60
			super.addAttribute(name, value);
61
		}
42
	}
62
	}
43
	public void addYourselfInContext() {
63
	public void addYourselfInContext() {
44
		if (!loadToModel) {
64
		if (!loadToModel) {
Lines 71-76 Link Here
71
		super.cleanUp();
91
		super.cleanUp();
72
	}
92
	}
73
	public void endChild(String name) {
93
	public void endChild(String name) {
94
		// Store the metric information and clean the fields for metric information.
95
		if (name.startsWith(METRIC_PRE) && inMetric) {
96
			metrics.add(metricName + METRIC_SEPERATOR + metricValue);
97
			metricName = null;
98
			metricValue = null;
99
			inMetric = false;
100
		}
74
	}
101
	}
75
	public void initialize(HierarchyContext context, String name) {
102
	public void initialize(HierarchyContext context, String name) {
76
		loadToModel = context.isLoadToModel();
103
		loadToModel = context.isLoadToModel();
Lines 87-94 Link Here
87
		if (name.equals(INVOCATION_CONTEXT)) {
114
		if (name.equals(INVOCATION_CONTEXT)) {
88
			setNullInvocationContext();
115
			setNullInvocationContext();
89
			activeInvocationContext = true;
116
			activeInvocationContext = true;
90
		} else
117
		} else if (name.startsWith(METRIC_PRE)) {
118
			if (metrics ==  null)
119
			{
120
				metrics = new ArrayList();
121
			}
122
			inMetric = true;
123
		} else {
91
			super.startChild(name);
124
			super.startChild(name);
125
		}
92
	}
126
	}
93
127
94
	protected void processENI(int step) {
128
	protected void processENI(int step) {
Lines 104-109 Link Here
104
		fullInvocation.setMethod(theMethod);
138
		fullInvocation.setMethod(theMethod);
105
		fullInvocation.setThread(theThread);
139
		fullInvocation.setThread(theThread);
106
		fullInvocation.setProcess(theProcess);
140
		fullInvocation.setProcess(theProcess);
141
		
142
		addMetricAnnotation();
107
        
143
        
108
		addInputOutputValues();
144
		addInputOutputValues();
109
        
145
        
Lines 152-157 Link Here
152
		fullInvocation.setThread(theThread);
188
		fullInvocation.setThread(theThread);
153
		fullInvocation.setProcess(theProcess);
189
		fullInvocation.setProcess(theProcess);
154
		fullInvocation.setOwningObject((TRCFullTraceObject) theObject);
190
		fullInvocation.setOwningObject((TRCFullTraceObject) theObject);
191
192
		addMetricAnnotation();
155
        
193
        
156
		addInputOutputValues();
194
		addInputOutputValues();
157
        
195
        
Lines 172-177 Link Here
172
		//        LookupServiceExtensions.getInstance().register(context,
210
		//        LookupServiceExtensions.getInstance().register(context,
173
		// fullInvocation);
211
		// fullInvocation);
174
	}
212
	}
213
	
214
	/**
215
	 * Add annotation with metric information to fullInvocation. 
216
	 */
217
	private void addMetricAnnotation() {
218
		if (metrics != null)
219
		{
220
			TRCAnnotation annotation = HierarchyFactory.eINSTANCE.createTRCAnnotation();
221
			annotation.setName(Long.toString(ticket));
222
			annotation.getValues().addAll(metrics);
223
			fullInvocation.getMethod().getAnnotations().add(annotation);
224
			metrics.clear();
225
		}
226
	}
175
	/**
227
	/**
176
	 *  
228
	 *  
177
	 */
229
	 */
Lines 331-334 Link Here
331
			ModelDebugger.log(e);
383
			ModelDebugger.log(e);
332
		}
384
		}
333
	}
385
	}
386
387
	/**
388
	 * True when the current element is the Arm Metric element.
389
	 */
390
	private boolean inMetric;
391
	/**
392
	 * The name of the metric.
393
	 */
394
	private String metricName;
395
	/**
396
	 * The value of the metric.
397
	 */
398
	private String metricValue;
399
	/**
400
	 * The list to store the metric information.
401
	 */
402
	private List metrics;
334
}
403
}
(-)src-model/org/eclipse/tptp/trace/arm/internal/model/ArmInstrument.java (-7 / +332 lines)
Lines 11-21 Link Here
11
 ***********************************************************************/
11
 ***********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.model;
12
package org.eclipse.tptp.trace.arm.internal.model;
13
13
14
import java.util.ArrayList;
14
import java.util.HashMap;
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.List;
15
import java.util.Properties;
18
import java.util.Properties;
16
19
17
import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger;
20
import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger;
21
import org.opengroup.arm40.metric.ArmMetric;
22
import org.opengroup.arm40.metric.ArmMetricCounter32;
23
import org.opengroup.arm40.metric.ArmMetricCounter32Definition;
24
import org.opengroup.arm40.metric.ArmMetricCounter64;
25
import org.opengroup.arm40.metric.ArmMetricCounter64Definition;
26
import org.opengroup.arm40.metric.ArmMetricCounterFloat32;
27
import org.opengroup.arm40.metric.ArmMetricCounterFloat32Definition;
28
import org.opengroup.arm40.metric.ArmMetricDefinition;
18
import org.opengroup.arm40.metric.ArmMetricFactory;
29
import org.opengroup.arm40.metric.ArmMetricFactory;
30
import org.opengroup.arm40.metric.ArmMetricGauge32;
31
import org.opengroup.arm40.metric.ArmMetricGauge32Definition;
32
import org.opengroup.arm40.metric.ArmMetricGauge64;
33
import org.opengroup.arm40.metric.ArmMetricGauge64Definition;
34
import org.opengroup.arm40.metric.ArmMetricGaugeFloat32;
35
import org.opengroup.arm40.metric.ArmMetricGaugeFloat32Definition;
36
import org.opengroup.arm40.metric.ArmMetricGroup;
37
import org.opengroup.arm40.metric.ArmMetricGroupDefinition;
38
import org.opengroup.arm40.metric.ArmMetricNumericId32;
39
import org.opengroup.arm40.metric.ArmMetricNumericId32Definition;
40
import org.opengroup.arm40.metric.ArmMetricNumericId64;
41
import org.opengroup.arm40.metric.ArmMetricNumericId64Definition;
42
import org.opengroup.arm40.metric.ArmMetricString32;
43
import org.opengroup.arm40.metric.ArmMetricString32Definition;
44
import org.opengroup.arm40.metric.ArmTransactionWithMetrics;
45
import org.opengroup.arm40.metric.ArmTransactionWithMetricsDefinition;
19
import org.opengroup.arm40.tranreport.ArmTranReport;
46
import org.opengroup.arm40.tranreport.ArmTranReport;
20
import org.opengroup.arm40.tranreport.ArmTranReportFactory;
47
import org.opengroup.arm40.tranreport.ArmTranReportFactory;
21
import org.opengroup.arm40.transaction.ArmApplication;
48
import org.opengroup.arm40.transaction.ArmApplication;
Lines 53-61 Link Here
53
80
54
	/* The ARM 4.0 Application Instance for the TT product. */
81
	/* The ARM 4.0 Application Instance for the TT product. */
55
	private ArmApplication applicationInstance;
82
	private ArmApplication applicationInstance;
56
	
83
57
	/* Internal cache of the ARM 4.0 identity properties */
84
	/* Internal cache of the ARM 4.0 identity properties : ArmTransactionDefinition*/
58
	private HashMap armTranDefCache = new HashMap(30); 
85
	private HashMap armTranDefCache = new HashMap(30); 
86
87
	/* Internal cache of the ARM 4.0 identity properties : ArmTransactionWithMetricsDefinition*/
88
	private HashMap armTranWithMetricDefCache = new HashMap(30); 
59
	
89
	
60
	/* The ARM 4.0 Error handler */
90
	/* The ARM 4.0 Error handler */
61
	private ArmErrorCallback armErrorCallBack;
91
	private ArmErrorCallback armErrorCallBack;
Lines 102-107 Link Here
102
						.newInstance();
132
						.newInstance();
103
				tranFactory.setErrorCallback(armErrorCallBack);
133
				tranFactory.setErrorCallback(armErrorCallBack);
104
			} catch (Exception ex) {
134
			} catch (Exception ex) {
135
				ex.printStackTrace();
105
				/* If error, then null */
136
				/* If error, then null */
106
				tranFactory = null;
137
				tranFactory = null;
107
				/* ArmTransFactoryInit_ERROR = IWAT0766E */
138
				/* ArmTransFactoryInit_ERROR = IWAT0766E */
Lines 109-114 Link Here
109
						ArmInstrumentMessages.getString("ArmTransFactoryInit_ERROR"),
140
						ArmInstrumentMessages.getString("ArmTransFactoryInit_ERROR"),
110
						ARMLogger.LOG, ex);
141
						ARMLogger.LOG, ex);
111
			}
142
			}
143
			catch(Throwable t)
144
			{
145
				t.printStackTrace();
146
			}
112
		}
147
		}
113
		
148
		
114
		return tranFactory;
149
		return tranFactory;
Lines 152-158 Link Here
152
	 * @return the ArmMetricFactory.
187
	 * @return the ArmMetricFactory.
153
	 */
188
	 */
154
	private ArmMetricFactory getArmMetricFactory() {
189
	private ArmMetricFactory getArmMetricFactory() {
155
		if (metricFactory != null) {
190
		if (metricFactory == null) {
156
			/* Check for the metric factory */
191
			/* Check for the metric factory */
157
			try {
192
			try {
158
				Properties p = System.getProperties();
193
				Properties p = System.getProperties();
Lines 262-274 Link Here
262
	 */
297
	 */
263
	public ArmTransaction transactionStart(InstrumentDataProvider data, 
298
	public ArmTransaction transactionStart(InstrumentDataProvider data, 
264
			ArmCorrelator parentCorrelator) {
299
			ArmCorrelator parentCorrelator) {
265
		
266
		ArmTransaction armTransaction = null;
300
		ArmTransaction armTransaction = null;
267
		
301
		
268
		if (tranFactory != null) {
302
		if (tranFactory != null) {
269
			ArmTransactionDefinition armTranDef = getArmTransactionDefinition(data);
303
			// create ArmTransaction/ArmTransactionWithMetric instance if there
270
			armTransaction = tranFactory.newArmTransaction(getArmApplication(),
304
			// is/isn't ARM metric.
271
					armTranDef);
305
			if (ArmMetricManager.getInstance().hasMetric()) {		
306
				try {
307
					armTransaction = getArmTransactionWithMetric(data);
308
				} catch (Throwable e) {
309
					// TODO Auto-generated catch block
310
					e.printStackTrace();
311
				}
312
			} else {
313
				ArmTransactionDefinition armTranDef = getArmTransactionDefinition(data);
314
				armTransaction = tranFactory.newArmTransaction(
315
						getArmApplication(), armTranDef);
316
			}
272
			
317
			
273
			String[] contextValues = data.getContextValues();
318
			String[] contextValues = data.getContextValues();
274
			for (int i = 0; i < contextValues.length; i++) {
319
			for (int i = 0; i < contextValues.length; i++) {
Lines 283-288 Link Here
283
			armTransaction.setUser(tranFactory.newArmUser(
328
			armTransaction.setUser(tranFactory.newArmUser(
284
					data.getUserName() == null ? "*" : data.getUserName(), null));
329
					data.getUserName() == null ? "*" : data.getUserName(), null));
285
			
330
			
331
			
286
			if (parentCorrelator == null) {
332
			if (parentCorrelator == null) {
287
				armTransaction.start();
333
				armTransaction.start();
288
			} else {
334
			} else {
Lines 294-299 Link Here
294
	} // end of transactionStart()
340
	} // end of transactionStart()
295
341
296
	/**
342
	/**
343
	 * Create an ArmTransactionWithMetrics instance.
344
	 * 
345
	 * @param data
346
	 * @return
347
	 */
348
	private ArmTransactionWithMetrics getArmTransactionWithMetric(
349
			InstrumentDataProvider data) {
350
		if (metricFactory == null) {
351
			getArmMetricFactory();
352
		}
353
354
		String transName = data.getTransactionName();
355
		ArmTransactionWithMetrics transactionWithMetrics = null;
356
		if (metricFactory != null) {
357
			synchronized (armTranWithMetricDefCache) {
358
				if (metricFactory != null) {
359
					List metrics = ArmMetricManager.getInstance().getMetrics();
360
					ArmTransactionWithMetricsDefinition transactionWithMetricsDef = getArmTransactionWithMetricDefinition(
361
							transName, metrics);
362
					transactionWithMetrics = getArmTransactionWithMetric(
363
							transName, metrics, transactionWithMetricsDef);
364
				}
365
			}
366
		}
367
368
		return transactionWithMetrics;
369
	}
370
371
	/**
372
	 * Create an ArmTransactionWithMetricsDefinition instance. Maybe should use
373
	 * cache here.
374
	 * 
375
	 * @param transName
376
	 * @param metrics
377
	 * @return
378
	 */
379
	private ArmTransactionWithMetricsDefinition getArmTransactionWithMetricDefinition(
380
			String transName, List metrics) {
381
		ArmTransactionWithMetricsDefinition transactionWithMetricsDef;
382
		List metricsDef = getArmMetricDefs(metrics);
383
384
		ArmMetricDefinition[] metricDefArray = (ArmMetricDefinition[]) metricsDef
385
				.toArray(new ArmMetricDefinition[metricsDef.size()]);
386
387
		ArmMetricGroupDefinition metGroupDef = metricFactory
388
				.newArmMetricGroupDefinition(metricDefArray);
389
390
		transactionWithMetricsDef = (ArmTransactionWithMetricsDefinition) armTranWithMetricDefCache
391
				.get(transName);
392
393
		if (transactionWithMetricsDef == null) {
394
			transactionWithMetricsDef = metricFactory
395
					.newArmTransactionWithMetricsDefinition(
396
							getArmApplicationDefinition(), transName, null,
397
							metGroupDef, null);
398
399
			armTranWithMetricDefCache.put(transName, transactionWithMetricsDef);
400
		}
401
		return transactionWithMetricsDef;
402
	}
403
404
	/**
405
	 * Get the ArmMetricDefinition instances. The elements of parameter metrics
406
	 * will be updated to match the metric and it's definition.<br>
407
	 * TODO Move switch-case here to some other place. For example, another
408
	 * classes. switch-case is not good coding style.
409
	 * 
410
	 * @param metrics
411
	 *            List of ArmMetricManager.Metric.
412
	 * @return List of ArmMetricDefinition.
413
	 */
414
	private List getArmMetricDefs(List metrics) {
415
		List metricDefs = new ArrayList();
416
		for (Iterator iterator = metrics.iterator(); iterator.hasNext();) {
417
			ArmMetricManager.Metric metric = (ArmMetricManager.Metric) iterator
418
					.next();
419
			ArmMetricDefinition metricDefinition = metric.getDefinition();
420
			if (metricDefinition == null) {
421
				// Big switch-case to create ArmMetricDefinition instance.
422
				switch (metric.getMetricType()) {
423
				case ArmMetricConstants.ArmMetricCounter32:
424
					metricDefinition = metricFactory
425
							.newArmMetricCounter32Definition(
426
									getArmApplicationDefinition(), metric
427
											.getMetricName(), null,
428
									ArmMetricDefinition.METRIC_USE_GENERAL,
429
									null);
430
					break;
431
				case ArmMetricConstants.ArmMetricCounter64:
432
					metricDefinition = metricFactory
433
							.newArmMetricCounter64Definition(
434
									getArmApplicationDefinition(), metric
435
											.getMetricName(), null,
436
									ArmMetricDefinition.METRIC_USE_GENERAL,
437
									null);
438
					break;
439
				case ArmMetricConstants.ArmMetricCounterFloat32:
440
					metricDefinition = metricFactory
441
							.newArmMetricCounterFloat32Definition(
442
									getArmApplicationDefinition(), metric
443
											.getMetricName(), null,
444
									ArmMetricDefinition.METRIC_USE_GENERAL,
445
									null);
446
					break;
447
				case ArmMetricConstants.ArmMetricGauge32:
448
					metricDefinition = metricFactory
449
							.newArmMetricGauge32Definition(
450
									getArmApplicationDefinition(), metric
451
											.getMetricName(), null,
452
									ArmMetricDefinition.METRIC_USE_GENERAL,
453
									null);
454
					break;
455
				case ArmMetricConstants.ArmMetricGauge64:
456
					metricDefinition = metricFactory
457
							.newArmMetricGauge64Definition(
458
									getArmApplicationDefinition(), metric
459
											.getMetricName(), null,
460
									ArmMetricDefinition.METRIC_USE_GENERAL,
461
									null);
462
					break;
463
				case ArmMetricConstants.ArmMetricGaugeFloat32:
464
					metricDefinition = metricFactory
465
							.newArmMetricGaugeFloat32Definition(
466
									getArmApplicationDefinition(), metric
467
											.getMetricName(), null,
468
									ArmMetricDefinition.METRIC_USE_GENERAL,
469
									null);
470
					break;
471
				case ArmMetricConstants.ArmMetricNumericId32:
472
					metricDefinition = metricFactory
473
							.newArmMetricNumericId32Definition(
474
									getArmApplicationDefinition(), metric
475
											.getMetricName(), null,
476
									ArmMetricDefinition.METRIC_USE_GENERAL,
477
									null);
478
					break;
479
				case ArmMetricConstants.ArmMetricNumericId64:
480
					metricDefinition = metricFactory
481
							.newArmMetricNumericId64Definition(
482
									getArmApplicationDefinition(), metric
483
											.getMetricName(), null,
484
									ArmMetricDefinition.METRIC_USE_GENERAL,
485
									null);
486
					break;
487
				case ArmMetricConstants.ArmMetricString32:
488
					metricDefinition = metricFactory
489
							.newArmMetricString32Definition(
490
									getArmApplicationDefinition(), metric
491
											.getMetricName(), null,
492
									ArmMetricDefinition.METRIC_USE_GENERAL,
493
									null);
494
					break;
495
				default:
496
					metricDefinition = null;
497
					break;
498
				}
499
			}
500
			if (metricDefinition != null) {
501
				metricDefs.add(metricDefinition);
502
				metric.setDefinition(metricDefinition);
503
			}
504
		}
505
		return metricDefs;
506
	}
507
508
	/**
509
	 * Create an ArmTransactionWithMetrics instance.
510
	 * 
511
	 * @param transName
512
	 * @param metrics
513
	 * @param transactionWithMetricsDef
514
	 * @return
515
	 */
516
	private ArmTransactionWithMetrics getArmTransactionWithMetric(
517
			String transName, List metrics,
518
			ArmTransactionWithMetricsDefinition transactionWithMetricsDef) {
519
		ArmTransactionWithMetrics transactionWithMetrics;
520
		List armMetrics = getArmMetric(metrics);
521
522
		ArmMetric[] metricDefArray = (ArmMetric[]) armMetrics
523
				.toArray(new ArmMetric[armMetrics.size()]);
524
525
		ArmMetricGroup metGroup = metricFactory.newArmMetricGroup(
526
				transactionWithMetricsDef.getMetricGroupDefinition(),
527
				metricDefArray);
528
529
		transactionWithMetrics = metricFactory.newArmTransactionWithMetrics(
530
				getArmApplication(), transactionWithMetricsDef, metGroup);
531
532
		return transactionWithMetrics;
533
	}
534
535
	/**
536
	 * Get the ArmMetricDefinition instances.<br>
537
	 * TODO Move switch-case here to some other place. For example, another
538
	 * classes. switch-case is not good coding style.
539
	 * 
540
	 * @param metrics
541
	 *            List of ArmMetricManager.Metric.
542
	 * @return List of ArmMetric.
543
	 */
544
	private List getArmMetric(List metrics) {
545
		List armMetrics = new ArrayList();
546
		for (Iterator iterator = metrics.iterator(); iterator.hasNext();) {
547
			ArmMetricManager.Metric metric = (ArmMetricManager.Metric) iterator
548
					.next();
549
			ArmMetric armMetric = null;
550
			ArmMetricDefinition metricDefinition = metric.getDefinition();
551
			if (metricDefinition != null) {
552
				String metricValue = metric.getMetricValue();
553
				// Big switch-case to create ArmMetric instance.
554
				switch (metric.getMetricType()) {
555
				case ArmMetricConstants.ArmMetricCounter32:
556
					ArmMetricCounter32 armMetricCounter32 = metricFactory
557
							.newArmMetricCounter32((ArmMetricCounter32Definition) metricDefinition);
558
					armMetricCounter32.set(Integer.parseInt(metricValue));
559
					armMetric = armMetricCounter32;
560
					break;
561
				case ArmMetricConstants.ArmMetricCounter64:
562
					ArmMetricCounter64 armMetricCounter64 = metricFactory
563
							.newArmMetricCounter64((ArmMetricCounter64Definition) metricDefinition);
564
					armMetricCounter64.set(Long.parseLong(metricValue));
565
					armMetric = armMetricCounter64;
566
					break;
567
				case ArmMetricConstants.ArmMetricCounterFloat32:
568
					ArmMetricCounterFloat32 armMetricCounterFloat32 = metricFactory
569
							.newArmMetricCounterFloat32((ArmMetricCounterFloat32Definition) metricDefinition);
570
					armMetricCounterFloat32.set(Float.parseFloat(metricValue));
571
					armMetric = armMetricCounterFloat32;
572
					break;
573
				case ArmMetricConstants.ArmMetricGauge32:
574
					ArmMetricGauge32 armMetricGauge32 = metricFactory
575
							.newArmMetricGauge32((ArmMetricGauge32Definition) metricDefinition);
576
					armMetricGauge32.set(Integer.parseInt(metricValue));
577
					armMetric = armMetricGauge32;
578
					break;
579
				case ArmMetricConstants.ArmMetricGauge64:
580
					ArmMetricGauge64 armMetricGauge64 = metricFactory
581
							.newArmMetricGauge64((ArmMetricGauge64Definition) metricDefinition);
582
					armMetricGauge64.set(Long.parseLong(metricValue));
583
					armMetric = armMetricGauge64;
584
					break;
585
				case ArmMetricConstants.ArmMetricGaugeFloat32:
586
					ArmMetricGaugeFloat32 armMetricGaugeFloat32 = metricFactory
587
							.newArmMetricGaugeFloat32((ArmMetricGaugeFloat32Definition) metricDefinition);
588
					armMetricGaugeFloat32.set(Float.parseFloat(metricValue));
589
					armMetric = armMetricGaugeFloat32;
590
					break;
591
				case ArmMetricConstants.ArmMetricNumericId32:
592
					ArmMetricNumericId32 armMetricNumericId32 = metricFactory
593
							.newArmMetricNumericId32((ArmMetricNumericId32Definition) metricDefinition);
594
					armMetricNumericId32.set(Integer.parseInt(metricValue));
595
					armMetric = armMetricNumericId32;
596
					break;
597
				case ArmMetricConstants.ArmMetricNumericId64:
598
					ArmMetricNumericId64 armMetricNumericId64 = metricFactory
599
							.newArmMetricNumericId64((ArmMetricNumericId64Definition) metricDefinition);
600
					armMetricNumericId64.set(Long.parseLong(metricValue));
601
					armMetric = armMetricNumericId64;
602
					break;
603
				case ArmMetricConstants.ArmMetricString32:
604
					ArmMetricString32 armMetricString32 = metricFactory
605
							.newArmMetricString32((ArmMetricString32Definition) metricDefinition);
606
					armMetricString32.set(metricValue);
607
					armMetric = armMetricString32;
608
					break;
609
				default:
610
					armMetric = null;
611
					break;
612
				}
613
			}
614
			if (armMetric != null) {
615
				armMetrics.add(armMetric);
616
			}
617
		}
618
		return armMetrics;
619
	}
620
621
	/**
297
	 * The wrapper method for the arm stop() call.
622
	 * The wrapper method for the arm stop() call.
298
	 * 
623
	 * 
299
	 * @param transaction the transaction data
624
	 * @param transaction the transaction data
(-)src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmEventFactory.java (-2 / +42 lines)
Lines 20-25 Link Here
20
import org.eclipse.tptp.trace.arm.internal.transaction.ArmIdentityPropertiesImpl;
20
import org.eclipse.tptp.trace.arm.internal.transaction.ArmIdentityPropertiesImpl;
21
import org.eclipse.tptp.trace.arm.internal.transaction.ArmTransactionImpl;
21
import org.eclipse.tptp.trace.arm.internal.transaction.ArmTransactionImpl;
22
import org.eclipse.tptp.trace.arm.internal.util.ArmIdentityProperty;
22
import org.eclipse.tptp.trace.arm.internal.util.ArmIdentityProperty;
23
import org.opengroup.arm40.metric.ArmMetricGroup;
24
import org.opengroup.arm40.metric.ArmTransactionWithMetrics;
23
import org.opengroup.arm40.transaction.ArmApplication;
25
import org.opengroup.arm40.transaction.ArmApplication;
24
import org.opengroup.arm40.transaction.ArmApplicationDefinition;
26
import org.opengroup.arm40.transaction.ArmApplicationDefinition;
25
import org.opengroup.arm40.transaction.ArmCorrelator;
27
import org.opengroup.arm40.transaction.ArmCorrelator;
Lines 37-51 Link Here
37
public class TPTPArmEventFactory {
39
public class TPTPArmEventFactory {
38
40
39
	/**
41
	/**
40
	 * 
41
	 * @param transaction
42
	 * @param transaction
42
	 * @return
43
	 * @return
43
	 */
44
	 */
44
	public static TPTPStartArmEvent newStartEvent(ArmTransaction transaction) {
45
	public static TPTPStartArmEvent newStartEvent(ArmTransaction transaction) {
45
		return new TPTPStartArmEventImpl(transaction);
46
		if (transaction instanceof ArmTransactionWithMetrics) {
47
			ArmTransactionWithMetrics transactionWithMetrics = (ArmTransactionWithMetrics) transaction;
48
			return newStartMetricEvent(transactionWithMetrics);
49
		} else {
50
			return new TPTPStartArmEventImpl(transaction);
51
		}
46
	}
52
	}
47
53
48
	/**
54
	/**
55
	 * Create TPTPStartArmEvent instance. This instance will be the
56
	 * implementation with metric.
57
	 * 
58
	 * @param transaction
59
	 * @return
60
	 */
61
	public static TPTPStartArmEvent newStartMetricEvent(ArmTransactionWithMetrics transaction) {
62
		return new TPTPStartArmMetricEventImpl(transaction);
63
	}
64
	
65
	/**
49
	 * 
66
	 * 
50
	 * @param transaction
67
	 * @param transaction
51
	 * @return
68
	 * @return
Lines 70-76 Link Here
70
			super(transaction, ((ArmTransactionImpl) transaction)
87
			super(transaction, ((ArmTransactionImpl) transaction)
71
					.getArrivalTime());
88
					.getArrivalTime());
72
		}
89
		}
90
	}
91
92
	/**
93
	 * Just extend to support metric.
94
	 * 
95
	 * @author Gao Peng
96
	 * @since TPTP 4.5.1
97
	 *
98
	 */
99
	private static class TPTPStartArmMetricEventImpl extends TPTPStartArmEventImpl
100
			implements TPTPArmMetricEvent {
101
102
		public TPTPStartArmMetricEventImpl(ArmTransactionWithMetrics transaction) {
103
			super(transaction);
104
			this.metricGroup = transaction.getMetricGroup();
105
		}
106
107
		public ArmMetricGroup getArmMetricGroup() {
108
			return metricGroup;
109
		}
73
110
111
		private ArmMetricGroup metricGroup;
74
	}
112
	}
75
113
76
	/**
114
	/**
Lines 92-97 Link Here
92
130
93
	}
131
	}
94
132
133
	
134
	
95
	/**
135
	/**
96
	 * 
136
	 * 
97
	 * @author rdanek
137
	 * @author rdanek
(-)src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodEventRecord.java (-1 / +11 lines)
Lines 133-139 Link Here
133
            String methodEvent = super.getXmlPrinter().MethodEntry(
133
            String methodEvent = super.getXmlPrinter().MethodEntry(
134
                    _methodIdRef, _ticket, _sequenceCounter, _stackDepth,
134
                    _methodIdRef, _ticket, _sequenceCounter, _stackDepth,
135
                    _classIdRef, _threadIdRef, _time);
135
                    _classIdRef, _threadIdRef, _time);
136
            methodEvent += "\r\n"+super.getXmlPrinter().ParameterRecord(super.getTransactionDetailIdRef())+"\r\n";   //$NON-NLS-1$ //$NON-NLS-2$
136
            methodEvent += "\r\n"+getEntryParameterPart()+"\r\n";   //$NON-NLS-1$ //$NON-NLS-2$
137
            methodEvent += super.getXmlPrinter().MethodEntryEnd(); 
137
            methodEvent += super.getXmlPrinter().MethodEntryEnd(); 
138
            return methodEvent; 
138
            return methodEvent; 
139
        			
139
        			
Lines 143-146 Link Here
143
                    _classIdRef, _threadIdRef, _time);
143
                    _classIdRef, _threadIdRef, _time);
144
    }
144
    }
145
145
146
	/**
147
	 * Parameter part of the record for method entry. The succlass can override
148
	 * it to add additional part.
149
	 * 
150
	 * @return
151
	 */
152
	protected String getEntryParameterPart() {
153
		return super.getXmlPrinter().ParameterRecord(
154
				super.getTransactionDetailIdRef());
155
	}
146
}
156
}
(-)src-agent/org/eclipse/tptp/trace/arm/internal/agent/processor/ARMEventProcessor.java (-4 / +15 lines)
Lines 20-31 Link Here
20
import org.eclipse.tptp.trace.arm.internal.agent.model.IRuntimeModel;
20
import org.eclipse.tptp.trace.arm.internal.agent.model.IRuntimeModel;
21
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.InvocationContextRecord;
21
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.InvocationContextRecord;
22
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodEventRecord;
22
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodEventRecord;
23
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodMetricEventRecord;
23
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.RemoteMethodEventRecord;
24
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.RemoteMethodEventRecord;
24
import org.eclipse.tptp.trace.arm.internal.agent.trace.exceptions.MethodEntryException;
25
import org.eclipse.tptp.trace.arm.internal.agent.trace.exceptions.MethodEntryException;
25
import org.eclipse.tptp.trace.arm.internal.agent.util.IEventProcessor;
26
import org.eclipse.tptp.trace.arm.internal.agent.util.IEventProcessor;
26
import org.eclipse.tptp.trace.arm.internal.agent.util.Timestamp;
27
import org.eclipse.tptp.trace.arm.internal.agent.util.Timestamp;
27
import org.eclipse.tptp.trace.arm.internal.correlator.TPTPArmCorrelator;
28
import org.eclipse.tptp.trace.arm.internal.correlator.TPTPArmCorrelator;
28
import org.eclipse.tptp.trace.arm.internal.event.TPTPArmEvent;
29
import org.eclipse.tptp.trace.arm.internal.event.TPTPArmEvent;
30
import org.eclipse.tptp.trace.arm.internal.event.TPTPArmMetricEvent;
29
import org.eclipse.tptp.trace.arm.internal.event.TPTPStartArmEvent;
31
import org.eclipse.tptp.trace.arm.internal.event.TPTPStartArmEvent;
30
import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger;
32
import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger;
31
33
Lines 107-117 Link Here
107
109
108
		boolean isEntry = event instanceof TPTPStartArmEvent;
110
		boolean isEntry = event instanceof TPTPStartArmEvent;
109
		MethodEventRecord mr;
111
		MethodEventRecord mr;
110
112
		
111
		if (isLocalInvocation && isSameThread) {
113
		if (isLocalInvocation && isSameThread) {
112
			mr = new MethodEventRecord(methodName, methodSignature, methodKey,
114
			// Create method event record with metric or without metric.
113
					ticket, seqCtr, className, threadid, timestamp, isEntry,
115
			if (event instanceof TPTPArmMetricEvent) {
114
					appName, component);
116
				TPTPArmMetricEvent metricEvent = (TPTPArmMetricEvent) event;
117
				mr = new MethodMetricEventRecord(methodName, methodSignature,
118
						methodKey, ticket, seqCtr, className, threadid,
119
						timestamp, isEntry, appName, component, metricEvent
120
								.getArmMetricGroup());
121
			} else {
122
				mr = new MethodEventRecord(methodName, methodSignature,
123
						methodKey, ticket, seqCtr, className, threadid,
124
						timestamp, isEntry, appName, component);
125
			}
115
126
116
		} else {
127
		} else {
117
			mr = createRemoteMethodEvent(methodName, methodSignature,
128
			mr = createRemoteMethodEvent(methodName, methodSignature,
(-)src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricConstants.java (+34 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: ArmMetricConstants.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.model;
13
14
/**
15
 * Classes to define the metric types.
16
 * 
17
 * @author Gao Peng
18
 * @since TPTP 4.5.2
19
 * 
20
 */
21
public class ArmMetricConstants {
22
23
	// Metric types
24
	public static final int UNKOWN = -1;
25
	public static final int ArmMetricCounter32 = 1;
26
	public static final int ArmMetricCounter64 = 2;
27
	public static final int ArmMetricCounterFloat32 = 3;
28
	public static final int ArmMetricGauge32 = 4;
29
	public static final int ArmMetricGauge64 = 5;
30
	public static final int ArmMetricGaugeFloat32 = 6;
31
	public static final int ArmMetricNumericId32 = 7;
32
	public static final int ArmMetricNumericId64 = 8;
33
	public static final int ArmMetricString32 = 9;
34
}
(-)src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmMetricEvent.java (+30 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: TPTPArmMetricEvent.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.event;
13
14
import org.opengroup.arm40.metric.ArmMetricGroup;
15
16
/**
17
 * @author Gao Peng
18
 * @since TPTP 4.5.2
19
 * 
20
 */
21
public interface TPTPArmMetricEvent extends TPTPArmEvent {
22
23
	/**
24
	 * Get the metric group.
25
	 * 
26
	 * @return
27
	 */
28
	ArmMetricGroup getArmMetricGroup();
29
30
}
(-)src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodMetricEventRecord.java (+74 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: MethodMetricEventRecord.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.agent.trace.events;
13
14
import org.eclipse.tptp.trace.arm.internal.agent.util.Timestamp;
15
import org.eclipse.tptp.trace.arm.internal.metric.ArmMetricGroupImpl;
16
import org.opengroup.arm40.metric.ArmMetric;
17
import org.opengroup.arm40.metric.ArmMetricGroup;
18
19
/**
20
 * This class extends MethodEventRecord to provide the feature about metric.
21
 * 
22
 * @author Gao Peng
23
 * @since TPTP 4.5.2
24
 * 
25
 */
26
public class MethodMetricEventRecord extends MethodEventRecord {
27
28
	/**
29
	 * @param name
30
	 * @param signature
31
	 * @param key
32
	 * @param _ticket
33
	 * @param counter
34
	 * @param name2
35
	 * @param idRef
36
	 * @param _timestamp
37
	 * @param entry
38
	 * @param applicationName
39
	 * @param transactionDetail
40
	 */
41
	public MethodMetricEventRecord(String name, String signature, Object key,
42
			long _ticket, long counter, String name2, long idRef,
43
			Timestamp _timestamp, boolean entry, String applicationName,
44
			String transactionDetail, ArmMetricGroup metricGroup) {
45
		super(name, signature, key, _ticket, counter, name2, idRef, _timestamp,
46
				entry, applicationName, transactionDetail);
47
		this.metricGroup = metricGroup;
48
	}
49
50
	/**
51
	 * @return the metricGroup
52
	 */
53
	public ArmMetricGroup getMetricGroup() {
54
		return metricGroup;
55
	}
56
57
	private ArmMetricGroup metricGroup;
58
59
	/**
60
	 * Add the information about metric.
61
	 * 
62
	 * @see org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodEventRecord#getEntryParameterPart()
63
	 */
64
	protected String getEntryParameterPart() {
65
		String parameter = super.getEntryParameterPart();
66
		// Add the information about metric.
67
		ArmMetric[] metrics = ((ArmMetricGroupImpl) metricGroup).getMetrics();
68
		for (int i = 0; i < metrics.length; i++) {
69
			parameter += "\r\n" + metrics[i].toString();
70
		}
71
		return parameter;
72
	}
73
74
}
(-)src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricManager.java (+237 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: ArmMetricManager.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.model;
13
14
import java.io.BufferedReader;
15
import java.io.File;
16
import java.io.FileReader;
17
import java.io.IOException;
18
import java.util.ArrayList;
19
import java.util.Collection;
20
import java.util.HashMap;
21
import java.util.Iterator;
22
import java.util.List;
23
import java.util.Map;
24
25
import org.opengroup.arm40.metric.ArmMetricDefinition;
26
27
/**
28
 * Manager of Arm Metric.
29
 * 
30
 * @author Gao Peng
31
 * @since TPTP 4.5.2
32
 * 
33
 */
34
public class ArmMetricManager {
35
	
36
	/**
37
	 * Prefix of the temp file for metric.
38
	 */
39
	private static final String ARM_PREFIX_FOR_METRIC = "ARM";
40
41
	/**
42
	 * Singleton.
43
	 */
44
	private static final ArmMetricManager instance = new ArmMetricManager();
45
46
	public static ArmMetricManager getInstance() {
47
		return instance;
48
	}
49
50
	private ArmMetricManager() {
51
		try {
52
			loadMetricProvider();
53
		} catch (Throwable e) {
54
			// Do nothing. Just skip load.
55
		}
56
	}
57
58
	private void loadMetricProvider() throws IOException {
59
		String tmpDir = System.getProperty("java.io.tmpdir");
60
		File metricFile = new File(tmpDir, ARM_PREFIX_FOR_METRIC
61
				+ "instrument-runtime.properties");
62
63
		BufferedReader reader = new BufferedReader(new FileReader(metricFile));
64
		String line = reader.readLine();
65
		while (line != null) {
66
			String[] metricInfo = line.split(IMetricValueProvider.SEPARATOR);
67
			if (metricInfo.length >= 2) {
68
				IMetricValueProvider provider = getMetricProvider(metricInfo[0]);
69
				saveMetricInfo(provider, metricInfo[1]);
70
			}
71
			line = reader.readLine();
72
		}
73
	}
74
75
	private void saveMetricInfo(IMetricValueProvider provider, String metricName) {
76
		List metricNames = (List) metricInformation.get(provider);
77
		if (metricNames == null) {
78
			metricNames = new ArrayList();
79
			metricInformation.put(provider, metricNames);
80
		}
81
		metricNames.add(metricName);
82
	}
83
84
	/**
85
	 * Get the instance of the {@link IMetricValueProvider}. A new instance will
86
	 * be created if there is no such instance.
87
	 * 
88
	 * @param className The class name of the {@link IMetricValueProvider}
89
	 * @return
90
	 */
91
	private IMetricValueProvider getMetricProvider(String className) {
92
		IMetricValueProvider provider = (IMetricValueProvider) metricProviders
93
				.get(className);
94
		if (provider == null) {
95
			try {
96
				Class clazz = Class.forName(className);
97
				provider = (IMetricValueProvider) clazz.newInstance();
98
				metricProviders.put(className, provider);
99
			} catch (ClassNotFoundException e) {
100
				e.printStackTrace();
101
			} catch (NoClassDefFoundError e) {
102
				e.printStackTrace();
103
			} catch (IllegalAccessException e) {
104
				e.printStackTrace();
105
			} catch (InstantiationException e) {
106
				e.printStackTrace();
107
			}
108
		}
109
		return provider;
110
	}
111
112
	/**
113
	 * Check whether there is metric.
114
	 * 
115
	 * @return
116
	 */
117
	public boolean hasMetric() {
118
		return (metricProviders != null) && (metricProviders.size() != 0);
119
	}
120
121
	/**
122
	 * Get the metrics.
123
	 * 
124
	 * @return The list of the {@link ArmMetricManager.Metric}.
125
	 */
126
	public List getMetrics() {
127
		List metrics = new ArrayList();
128
		for (Iterator iterator = metricInformation.entrySet().iterator(); iterator
129
				.hasNext();) {
130
			Map.Entry entry = (Map.Entry) iterator.next();
131
			IMetricValueProvider provider = (IMetricValueProvider) entry
132
					.getKey();
133
			List metricNames = (List) entry.getValue();
134
			for (Iterator iterator2 = metricNames.iterator(); iterator2
135
					.hasNext();) {
136
				String metricName = (String) iterator2.next();
137
				String metricValue = provider.getVaule(metricName);
138
				int metricType = provider.getType(metricName);
139
				metrics.add(new Metric(metricName, metricValue, metricType,
140
						provider));
141
			}
142
		}
143
		return metrics;
144
	}
145
146
	/**
147
	 * Support this method to support {@link IMetricValueProvider} instance
148
	 * initialization.
149
	 * 
150
	 * @return
151
	 */
152
	public Collection getmMetricProviders() {
153
		return metricProviders.values();
154
	}
155
156
	/**
157
	 * Store the instances of the {@link IMetricValueProvider}. The key is the
158
	 * class name, and the value is the instance.
159
	 */
160
	private Map metricProviders = new HashMap();
161
162
	/**
163
	 * Store the instances of the {@link IMetricValueProvider} and the metrics
164
	 * they should provide. The key is the instance , and the value is the list
165
	 * of the metric name.
166
	 */
167
	private Map metricInformation = new HashMap();
168
169
	/**
170
	 * Value object to store the metric information.
171
	 * 
172
	 * @author Gao Peng
173
	 * @since TPTP 4.5.1
174
	 * 
175
	 */
176
	public class Metric {
177
178
		public Metric(String metricName, String metricValue, int metricType,
179
				IMetricValueProvider metricProvider) {
180
			super();
181
			this.metricName = metricName;
182
			this.metricValue = metricValue;
183
			this.metricType = metricType;
184
			this.metricProvider = metricProvider;
185
		}
186
187
		/**
188
		 * @return the metricName
189
		 */
190
		public String getMetricName() {
191
			return metricName;
192
		}
193
194
		/**
195
		 * @return the metricValue
196
		 */
197
		public String getMetricValue() {
198
			return metricValue;
199
		}
200
201
		/**
202
		 * @return the metricType
203
		 */
204
		public int getMetricType() {
205
			return metricType;
206
		}
207
208
		/**
209
		 * @return the metricProvider
210
		 */
211
		public IMetricValueProvider getMetricProvider() {
212
			return metricProvider;
213
		}
214
215
		/**
216
		 * @return the definition
217
		 */
218
		public ArmMetricDefinition getDefinition() {
219
			return definition;
220
		}
221
222
		/**
223
		 * @param definition
224
		 *            the definition to set
225
		 */
226
		public void setDefinition(ArmMetricDefinition definition) {
227
			this.definition = definition;
228
		}
229
230
		private String metricName;
231
		private String metricValue;
232
		private int metricType;
233
		private IMetricValueProvider metricProvider;
234
		private ArmMetricDefinition definition;
235
236
	}
237
}
(-)src-model/org/eclipse/tptp/trace/arm/internal/model/IMetricValueProvider.java (+74 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: IMetricValueProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.model;
13
14
/**
15
 * Interface for metric value provider. It's only used in agent.
16
 * 
17
 * @author Gao Peng
18
 * @since TPTP 4.5.2
19
 * 
20
 */
21
public interface IMetricValueProvider {
22
23
	/**
24
	 * The separator between the metric information.
25
	 */
26
	String METRIC_SEPERATOR = "\t";
27
28
	/**
29
	 * The separator between the parts of the metric information.
30
	 */
31
	String SEPARATOR = ",";
32
33
	/**
34
	 * 
35
	 */
36
	String METRIC_PREFIX = "METRIC_PREFIX";
37
38
	/**
39
	 * Return the metric value.
40
	 * 
41
	 * @param name
42
	 *            the metric name.
43
	 * @return the metric value.
44
	 */
45
	String getVaule(String name);
46
47
	/**
48
	 * Return the type of the metric value.
49
	 * 
50
	 * @param name
51
	 *            the metric name.
52
	 * @return the type of the metric value.
53
	 */
54
	int getType(String name);
55
56
	/**
57
	 * Return the metric values.
58
	 * 
59
	 * @param name
60
	 *            the metric names.
61
	 * @return the metric values.
62
	 */
63
	String[] getVaules(String[] names);
64
65
	/**
66
	 * Return the type of the metric values.
67
	 * 
68
	 * @param name
69
	 *            the metric names.
70
	 * @return the type of the metric values.
71
	 */
72
	int[] getType(String[] names);
73
74
}
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPointManager.java (+8 lines)
Lines 82-87 Link Here
82
					String descr = element[j].getAttribute("description");
82
					String descr = element[j].getAttribute("description");
83
					String script = element[j].getAttribute("script");
83
					String script = element[j].getAttribute("script");
84
					String instrumentTypeId = element[j].getAttribute("instrumentTypeId");
84
					String instrumentTypeId = element[j].getAttribute("instrumentTypeId");
85
86
					IMetricNameProvider[] metricProviders = MetricProviderManager
87
							.getInstance().getMetricProviders(id);
85
					
88
					
86
					String cint = element[j].getContributor().getName();
89
					String cint = element[j].getContributor().getName();
87
					
90
					
Lines 135-140 Link Here
135
					instrumentPoint.setProbeScriptContent(probeScriptContents);
138
					instrumentPoint.setProbeScriptContent(probeScriptContents);
136
					instrumentPoint.setType(type);
139
					instrumentPoint.setType(type);
137
					instrumentPoint.setProbeScript(script);
140
					instrumentPoint.setProbeScript(script);
141
					if (metricProviders.length != 0) {
142
						instrumentPoint
143
								.setMetricProviders(new CombinedMetricProvider(
144
										metricProviders));
145
					}
138
					
146
					
139
					instrumentPoints.put(id, instrumentPoint);
147
					instrumentPoints.put(id, instrumentPoint);
140
				} catch (Exception ex) { 
148
				} catch (Exception ex) { 
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPoint.java (+19 lines)
Lines 48-53 Link Here
48
	/* The contents of the probe script */
48
	/* The contents of the probe script */
49
	private String probeScriptContent;
49
	private String probeScriptContent;
50
	
50
	
51
	/**
52
	 * The metric provider. This value can be null for no metric provider.
53
	 */
54
	private IMetricNameProvider metricProvider;
55
	
51
	
56
	
52
	/**
57
	/**
53
	 * Default constructor
58
	 * Default constructor
Lines 204-207 Link Here
204
		this.type = type;
209
		this.type = type;
205
	}
210
	}
206
211
212
	/**
213
	 * @return the metricProviders
214
	 */
215
	public IMetricNameProvider getMetricProvider() {
216
		return metricProvider;
217
	}
218
219
	/**
220
	 * @param metricProviders
221
	 *            the metricProviders to set
222
	 */
223
	public void setMetricProviders(IMetricNameProvider metricProvider) {
224
		this.metricProvider = metricProvider;
225
	}
207
}
226
}
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/InstrumentDelegateHelper.java (-4 / +145 lines)
Lines 15-25 Link Here
15
import java.io.ByteArrayOutputStream;
15
import java.io.ByteArrayOutputStream;
16
import java.io.File;
16
import java.io.File;
17
import java.io.FileOutputStream;
17
import java.io.FileOutputStream;
18
import java.io.FileWriter;
19
import java.io.FilenameFilter;
18
import java.io.IOException;
20
import java.io.IOException;
21
import java.io.PrintWriter;
19
import java.net.URL;
22
import java.net.URL;
20
import java.util.ArrayList;
23
import java.util.ArrayList;
21
import java.util.HashMap;
24
import java.util.HashMap;
22
import java.util.Hashtable;
23
import java.util.Iterator;
25
import java.util.Iterator;
24
import java.util.List;
26
import java.util.List;
25
import java.util.Map;
27
import java.util.Map;
Lines 35-41 Link Here
35
import org.eclipse.debug.core.ILaunchConfiguration;
37
import org.eclipse.debug.core.ILaunchConfiguration;
36
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
38
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
37
import org.eclipse.hyades.internal.execution.local.control.Agent;
39
import org.eclipse.hyades.internal.execution.local.control.Agent;
38
import org.eclipse.hyades.internal.execution.local.control.InactiveProcessException;
39
import org.eclipse.hyades.internal.execution.local.control.Process;
40
import org.eclipse.hyades.internal.execution.local.control.Process;
40
import org.eclipse.hyades.internal.execution.local.control.ProcessListener;
41
import org.eclipse.hyades.internal.execution.local.control.ProcessListener;
41
import org.eclipse.hyades.models.hierarchy.TRCProcessProxy;
42
import org.eclipse.hyades.models.hierarchy.TRCProcessProxy;
Lines 53-68 Link Here
53
import org.eclipse.tptp.platform.instrumentation.ui.internal.LogHelper;
54
import org.eclipse.tptp.platform.instrumentation.ui.internal.LogHelper;
54
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorLoader;
55
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorLoader;
55
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorManager;
56
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorManager;
57
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider;
56
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPoint;
58
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPoint;
57
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPointManager;
59
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPointManager;
58
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentSelectManager;
60
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentSelectManager;
61
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.MetricProviderManager;
59
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.FileTransfer;
62
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.FileTransfer;
60
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.InstrumentLookupService;
63
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.InstrumentLookupService;
61
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.listener.InstrumentProcessListener;
64
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.listener.InstrumentProcessListener;
62
import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentMessages;
65
import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentMessages;
63
import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentUtil;
66
import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentUtil;
64
import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisType;
67
import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisType;
65
import org.eclipse.tptp.trace.ui.internal.launcher.core.DataCollector;
66
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherMessages;
68
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherMessages;
67
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
69
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
68
import org.eclipse.tptp.trace.ui.provisional.launcher.ProcessParameters;
70
import org.eclipse.tptp.trace.ui.provisional.launcher.ProcessParameters;
Lines 92-97 Link Here
92
	 * @return The save copy of ILaunchConfiguration
94
	 * @return The save copy of ILaunchConfiguration
93
	 */
95
	 */
94
	public static ILaunchConfiguration preLaunch(ILaunchConfiguration configuration) throws CoreException {
96
	public static ILaunchConfiguration preLaunch(ILaunchConfiguration configuration) throws CoreException {
97
98
		// Save metric information
99
		saveMetricInfo(configuration);
95
		
100
		
96
		//first identified that it is JVMPI instrument Collector
101
		//first identified that it is JVMPI instrument Collector
97
		InstrumentUtil.initiazeInstrumentCollector(configuration, InstrumentConstants.PI_INSTRUMENT_COLLECTOR);
102
		InstrumentUtil.initiazeInstrumentCollector(configuration, InstrumentConstants.PI_INSTRUMENT_COLLECTOR);
Lines 102-111 Link Here
102
		/* Create Project and Model */
107
		/* Create Project and Model */
103
		createModelEntities(configuration);
108
		createModelEntities(configuration);
104
		
109
		
110
		
105
		return handleInstrumentGenerator(configuration);
111
		return handleInstrumentGenerator(configuration);
106
		
112
		
107
	} // end of preLaunch(...)
113
	} // end of preLaunch(...)
108
	
114
115
	/**
116
	 * Store the metric information in file in temp dir. This file will be read
117
	 * by the agent.
118
	 * 
119
	 * @param configuration
120
	 * @throws CoreException
121
	 */
122
	private static void saveMetricInfo(ILaunchConfiguration configuration)
123
			throws CoreException {
124
		Map attributes = configuration.getAttributes();
125
		boolean saved = false;
126
		for (Iterator iterator = attributes.keySet().iterator(); iterator
127
				.hasNext();) {
128
			String key = (String) iterator.next();
129
			if (key.startsWith(IMetricNameProvider.METRIC_PREFIX)) {
130
				saved = saveMetricInfo(key, configuration.getAttribute(key,
131
						(String) null));
132
			}
133
		}
134
		if (!saved) {
135
			// remove the temp file for metric if ther is no metric file.
136
			removeTempMetricFile();
137
		}
138
	}
139
140
141
	/**
142
	 * Store the metric information in file in temp dir. This file will be read
143
	 * by the agent.
144
	 * 
145
	 * @param metricId the metric ID.
146
	 * @param metricInfo the metric information.
147
	 * @return
148
	 */
149
	private static boolean saveMetricInfo(String metricId, String metricInfo) {
150
		if (metricInfo == null) {
151
			// return false if nothing is saved.
152
			return false;
153
		}
154
155
		File metricFile = getTempMetricFile(metricId);
156
		if (metricFile == null)
157
		{
158
			// return false if nothing is saved.
159
			return false;
160
		}
161
		
162
		String[][] metrics = getMetrics(metricInfo);
163
		PrintWriter writer = null;
164
		try {
165
			writer = new PrintWriter(new FileWriter(metricFile));
166
			for (int i = 0; i < metrics.length; i++) {
167
				writer.print(metrics[i][0]);
168
				writer.print(IMetricNameProvider.SEPARATOR);
169
				writer.println(metrics[i][1]);
170
			}
171
		} catch (IOException e) {
172
			e.printStackTrace();
173
		} finally {
174
			if (writer != null) {
175
				writer.flush();
176
				writer.close();
177
			}
178
		}
179
		
180
		return true;
181
	}
182
183
	/**
184
	 * Get the temp file name for metric.
185
	 * 
186
	 * @param metricId
187
	 * @return
188
	 */
189
	private static File getTempMetricFile(String metricId) {
190
		String[] metricMetadata = metricId.split(IMetricNameProvider.SEPARATOR);
191
		if (metricMetadata.length != 3) {
192
			return null;
193
		}
194
		String metricType = metricMetadata[1];
195
196
		String tmpDir = System.getProperty("java.io.tmpdir");
197
		File metricFile = new File(tmpDir, metricType
198
				+ "instrument-runtime.properties");
199
		return metricFile;
200
	}
201
202
	/**
203
	 * Remove all of the temp file for metric.
204
	 */
205
	private static void removeTempMetricFile() {
206
		String tmpDir = System.getProperty("java.io.tmpdir");
207
		File[] metricFiles = new File(tmpDir).listFiles(new FilenameFilter(){
208
209
			public boolean accept(File dir, String name) {
210
				return name.endsWith("instrument-runtime.properties");
211
			}});
212
		for (int i = 0; i < metricFiles.length; i++) {
213
			metricFiles[i].delete();
214
		}
215
	}
216
217
	/**
218
	 * Parser the metric information to get the class names of the metric value
219
	 * providers and metric names.
220
	 * 
221
	 * @param metricInfo
222
	 * @return The second dim is 2. The first element of the second dim is the
223
	 *         class name of the metric value provider, and the second element
224
	 *         of the second dim is metric name.
225
	 */
226
	private static String[][] getMetrics(String metricInfo) {
227
		String[] metrics = metricInfo
228
				.split(IMetricNameProvider.METRIC_SEPERATOR);
229
		String[][] result = new String[metrics.length][2];
230
		for (int i = 0; i < metrics.length; i++) {
231
			String[] metricInfos = metrics[i]
232
					.split(IMetricNameProvider.SEPARATOR);
233
			if (metricInfos.length != 2) {
234
				result[i][0] = "";
235
				result[i][1] = "";
236
			} else {
237
				String metricID = metricInfos[0];
238
				String metricName = metricInfos[1];
239
				String metricClassName = MetricProviderManager.getInstance()
240
						.getMetricProvider(metricID)
241
						.getMetricValueProviderName();
242
				result[i][0] = metricClassName;
243
				result[i][1] = metricName;
244
			}
245
		}
246
247
		return result;
248
	}
249
109
	/**
250
	/**
110
	 * It is used to handle instrument generator stuff for user selected analysis types.
251
	 * It is used to handle instrument generator stuff for user selected analysis types.
111
	 * 
252
	 * 
(-)plugin.xml (+1 lines)
Lines 18-23 Link Here
18
   <extension-point id="generatorMechanism" name="generatorMechanism" schema="schema/generatorMechanism.exsd"/>
18
   <extension-point id="generatorMechanism" name="generatorMechanism" schema="schema/generatorMechanism.exsd"/>
19
   <extension-point id="instrumentPointDeclaration" name="instrumentPointDeclaration" schema="schema/instrumentPointDeclaration.exsd"/>
19
   <extension-point id="instrumentPointDeclaration" name="instrumentPointDeclaration" schema="schema/instrumentPointDeclaration.exsd"/>
20
   <extension-point id="runtimeJarsDependency" name="runtimeJarsDependency" schema="schema/runtimeJarsDependency.exsd"/>
20
   <extension-point id="runtimeJarsDependency" name="runtimeJarsDependency" schema="schema/runtimeJarsDependency.exsd"/>
21
   <extension-point id="metricProvider" name="metricProvider" schema="schema/metricProvider.exsd"/>
21
   
22
   
22
   <!-- The Instrument collector -->
23
   <!-- The Instrument collector -->
23
   <extension
24
   <extension
(-)build.properties (-2 / +5 lines)
Lines 1-6 Link Here
1
source.. = src/
1
source.. = src/
2
output.. = bin/
2
output.. = bin/
3
bin.includes = about.html, META-INF/,\
3
bin.includes = about.html,\
4
               META-INF/,\
4
               .,\
5
               .,\
5
               plugin.xml,\
6
               plugin.xml,\
6
               icons/,\
7
               icons/,\
Lines 8-11 Link Here
8
               about.ini,\
9
               about.ini,\
9
               about.mappings,\
10
               about.mappings,\
10
               about.properties,\
11
               about.properties,\
11
               tptp32.png
12
               tptp32.png,\
13
               HelpContexts.xml,\
14
               schema/
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/CombinedMetricProvider.java (+114 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: CombinedMetricProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.platform.instrumentation.ui.internal.core;
13
14
import java.util.List;
15
16
/**
17
 * Combine implementation of {@link IMetricNameProvider}.
18
 * 
19
 * @since TPTP 4.5.2
20
 * @author Gao Peng
21
 * 
22
 */
23
public class CombinedMetricProvider implements IMetricNameProvider {
24
25
	/**
26
	 * Default ID because this implementation of {@link IMetricNameProvider} is
27
	 * not defined in plugin.xml.
28
	 */
29
	private static final String COMBINED_ID = "CombinedMetricProvider";
30
31
	/**
32
	 * @param metricProviders
33
	 *            Implemenations of {@link IMetricNameProvider} which will be
34
	 *            combined.
35
	 */
36
	public CombinedMetricProvider(IMetricNameProvider[] metricProviders) {
37
		this.metricProviders = metricProviders;
38
	}
39
40
	/**
41
	 * @param metricProviderList
42
	 *            Implemenations of {@link IMetricNameProvider} which will be
43
	 *            combined.
44
	 */
45
	public CombinedMetricProvider(List metricProviderList) {
46
		this.metricProviders = (IMetricNameProvider[]) metricProviderList
47
				.toArray(new IMetricNameProvider[metricProviderList.size()]);
48
	}
49
50
	public String getId() {
51
		return id;
52
	}
53
54
	public void setId(String id) {
55
		this.id = id;
56
	}
57
58
	/**
59
	 * It will return the name of all of the combined
60
	 * {@link IMetricNameProvider} implementations with the format :
61
	 * id,metricName
62
	 * 
63
	 * @see org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider#getNames()
64
	 */
65
	public String[] getNames() {
66
		if ((metricProviders == null) || (metricProviders.length == 0)) {
67
			return null;
68
		}
69
70
		String[] names = getFullName(metricProviders[0]);
71
		for (int i = 1; i < metricProviders.length; i++) {
72
			IMetricNameProvider metricProvider = metricProviders[i];
73
			String[] newNames = getFullName(metricProvider);
74
			String[] combinedNames = new String[names.length + newNames.length];
75
			System.arraycopy(names, 0, combinedNames, 0, names.length);
76
			System.arraycopy(newNames, names.length, combinedNames,
77
					names.length, newNames.length);
78
			names = combinedNames;
79
		}
80
81
		return names;
82
	}
83
84
	/**
85
	 * Get names with the ID of the metric provider.
86
	 * 
87
	 * @param metricProvider
88
	 * @return
89
	 */
90
	private String[] getFullName(IMetricNameProvider metricProvider) {
91
		String[] names = metricProvider.getNames();
92
		String[] fullNames = new String[names.length];
93
		String metricProviderId = metricProvider.getId();
94
		for (int i = 0; i < fullNames.length; i++) {
95
			fullNames[i] = metricProviderId + IMetricNameProvider.SEPARATOR
96
					+ names[i];
97
		}
98
		return fullNames;
99
	}
100
101
	/**
102
	 * No metric value provider for this {@link IMetricNameProvider}
103
	 * implementation.
104
	 * 
105
	 * @see org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider#getMetricValueProviderName()
106
	 */
107
	public String getMetricValueProviderName() {
108
		return null;
109
	}
110
111
	private IMetricNameProvider[] metricProviders;
112
	private String id = COMBINED_ID;
113
114
}
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/IMetricNameProvider.java (+64 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: IMetricNameProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.platform.instrumentation.ui.internal.core;
13
14
/**
15
 * Interface for metricProvider extension point.
16
 * 
17
 * @since TPTP 4.5.2
18
 * @author Gao Peng
19
 * 
20
 */
21
public interface IMetricNameProvider {
22
23
	/**
24
	 * The separator between the metric information.
25
	 */
26
	String METRIC_SEPERATOR = "\t";
27
28
	/**
29
	 * The separator between the parts of the metric information.
30
	 */
31
	String SEPARATOR = ",";
32
33
	/**
34
	 * The prefix of the key which used in ILaunchConfiguration.
35
	 */
36
	String METRIC_PREFIX = "METRIC_PREFIX";
37
38
	/**
39
	 * @return the ID of the metric provider.
40
	 */
41
	String getId();
42
43
	/**
44
	 * Set the ID of the metric provider.
45
	 */
46
	void setId(String id);
47
48
	/**
49
	 * @return the name list of the metric provider. The name should start with
50
	 *         the id and SEPARATOR.
51
	 */
52
	String[] getNames();
53
54
	/**
55
	 * Get the name of the metric value provider. It should be a quality class
56
	 * name and be used when profiling. <br>
57
	 * 
58
	 * I have to split the name provider and the value provider because this
59
	 * plugin are not used in agent controller.
60
	 * 
61
	 * @return
62
	 */
63
	String getMetricValueProviderName();
64
}
(-)schema/metricProvider.exsd (+148 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.tptp.platform.instrumentation.ui" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appinfo>
6
         <meta.schema plugin="org.eclipse.tptp.platform.instrumentation.ui" id="metricProvider" name="metricProvider"/>
7
      </appinfo>
8
      <documentation>
9
         This extension point is used to register metric provider. The metric provider supports metric data.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appinfo>
16
            <meta.element />
17
         </appinfo>
18
      </annotation>
19
      <complexType>
20
         <sequence>
21
            <element ref="metricProvider" minOccurs="1" maxOccurs="unbounded"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appinfo>
43
                  <meta.attribute translatable="true"/>
44
               </appinfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49
50
   <element name="metricProvider">
51
      <complexType>
52
         <sequence minOccurs="1" maxOccurs="unbounded">
53
            <element ref="instrumentPointIdRef"/>
54
         </sequence>
55
         <attribute name="name" type="string">
56
            <annotation>
57
               <documentation>
58
                  
59
               </documentation>
60
            </annotation>
61
         </attribute>
62
         <attribute name="id" type="string" use="required">
63
            <annotation>
64
               <documentation>
65
                  
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
         <attribute name="providerClass" type="string">
70
            <annotation>
71
               <documentation>
72
                  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.
73
               </documentation>
74
               <appinfo>
75
                  <meta.attribute kind="java" basedOn=":org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider"/>
76
               </appinfo>
77
            </annotation>
78
         </attribute>
79
      </complexType>
80
   </element>
81
82
   <element name="instrumentPointIdRef">
83
      <complexType>
84
         <attribute name="id" type="string" use="required">
85
            <annotation>
86
               <documentation>
87
                  
88
               </documentation>
89
            </annotation>
90
         </attribute>
91
      </complexType>
92
   </element>
93
94
   <annotation>
95
      <appinfo>
96
         <meta.section type="since"/>
97
      </appinfo>
98
      <documentation>
99
         Since TPTP 4.5.1
100
      </documentation>
101
   </annotation>
102
103
   <annotation>
104
      <appinfo>
105
         <meta.section type="examples"/>
106
      </appinfo>
107
      <documentation>
108
            &lt;extension
109
         point=&quot;org.eclipse.tptp.platform.instrumentation.ui.metricProvider&quot;&gt;
110
      &lt;metricProvider
111
            id=&quot;org.eclipse.tptp.trace.arm.ptt.metricProvider&quot;
112
            providerClass=&quot;org.eclipse.tptp.trace.arm.ptt.PttMetricNameProvider&quot;&gt;
113
            &lt;instrumentPointIdRef
114
                  id=&quot;org.eclipse.tptp.trace.arm.probes.generic&quot;&gt;
115
            &lt;/instrumentPointIdRef&gt;
116
      &lt;/metricProvider&gt;
117
   &lt;/extension&gt;
118
      </documentation>
119
   </annotation>
120
121
   <annotation>
122
      <appinfo>
123
         <meta.section type="apiinfo"/>
124
      </appinfo>
125
      <documentation>
126
         [Enter API information here.]
127
      </documentation>
128
   </annotation>
129
130
   <annotation>
131
      <appinfo>
132
         <meta.section type="implementation"/>
133
      </appinfo>
134
      <documentation>
135
         [Enter information about supplied implementation of this extension point.]
136
      </documentation>
137
   </annotation>
138
139
   <annotation>
140
      <appinfo>
141
         <meta.section type="copyright"/>
142
      </appinfo>
143
      <documentation>
144
         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 &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
145
      </documentation>
146
   </annotation>
147
148
</schema>
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/MetricProviderManager.java (+159 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: MetricProviderManager.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.platform.instrumentation.ui.internal.core;
13
14
import java.util.ArrayList;
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.List;
18
import java.util.Map;
19
20
import org.eclipse.core.runtime.IConfigurationElement;
21
import org.eclipse.core.runtime.IExtension;
22
import org.eclipse.core.runtime.IExtensionPoint;
23
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.tptp.platform.instrumentation.ui.internal.LogHelper;
25
26
/**
27
 * Manager of the metric provider. It scans for the metricProvider extensions
28
 * and will register them with this manager.
29
 * 
30
 * @since TPTP 4.5.2
31
 * @author Gao Peng
32
 * 
33
 */
34
public class MetricProviderManager {
35
36
	/** The metric provider point extension */
37
	private static final String METRIC_PROVIDER_POINT_EXTENSION = "org.eclipse.tptp.platform.instrumentation.ui.metricProvider";
38
39
	/** This instance of this singleton class */
40
	private static MetricProviderManager instance;
41
42
	/**
43
	 * Hide the default constructor. This ensures against outside instantiation.
44
	 */
45
	private MetricProviderManager() {
46
		initialize();
47
	}
48
49
	/**
50
	 * Scan the registered instrument points and loads them in the
51
	 * instrumentPoints table.
52
	 */
53
	public void initialize() {
54
		metricProviders.clear();
55
		IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
56
				.getExtensionPoint(METRIC_PROVIDER_POINT_EXTENSION);
57
58
		if (extensionPoint == null) {
59
			return;
60
		}
61
62
		IExtension extension[] = extensionPoint.getExtensions();
63
64
		// Iterate through each instrument point element to construct the
65
		// instrument object and to associate it with the right entity.
66
		for (int i = 0; i < extension.length; i++) {
67
			IConfigurationElement[] metricNameProviders = extension[i]
68
					.getConfigurationElements();
69
			for (int j = 0; j < metricNameProviders.length; j++) {
70
				try {
71
					String id = metricNameProviders[j].getAttribute("id");
72
					IMetricNameProvider provider = (IMetricNameProvider) metricNameProviders[j]
73
							.createExecutableExtension("providerClass");
74
					provider.setId(id);
75
					metricProviders.put(id, provider);
76
					IConfigurationElement[] instrumentPointElements = metricNameProviders[j]
77
							.getChildren();
78
					List instrumentPoints = new ArrayList();
79
					for (int k = 0; k < instrumentPointElements.length; k++) {
80
						instrumentPoints.add(instrumentPointElements[k]
81
								.getAttribute("id"));
82
					}
83
					instrumentPointRefs.put(provider, instrumentPoints);
84
				} catch (Exception ex) {
85
					// report the problem.
86
					LogHelper.error(ex);
87
				}
88
			}
89
		}
90
	}
91
92
	/**
93
	 * Returns the instance of this singleton class.
94
	 * 
95
	 * @return The instance of this singleton class
96
	 */
97
	public static MetricProviderManager getInstance() {
98
		if (instance == null)
99
			instance = new MetricProviderManager();
100
		return instance;
101
	}
102
103
	/**
104
	 * Returns all the registered InstrumentPoint
105
	 * 
106
	 * @return an array of all the registered InstrumentPoint
107
	 */
108
	public IMetricNameProvider[] getMetricProviders() {
109
		return (IMetricNameProvider[]) metricProviders.values().toArray(
110
				new IMetricNameProvider[metricProviders.size()]);
111
	}
112
113
	/**
114
	 * Returns an InstrumentPoint with a given id.
115
	 * 
116
	 * @param id
117
	 *            the id
118
	 * @return an InstrumentPoint
119
	 */
120
	public IMetricNameProvider getMetricProvider(String id) {
121
		return (IMetricNameProvider) metricProviders.get(id);
122
	}
123
124
	/**
125
	 * Get the metric providers for the instrument point.
126
	 * 
127
	 * @param instrumentPointRefId
128
	 * @return
129
	 */
130
	public IMetricNameProvider[] getMetricProviders(String instrumentPointRefId) {
131
		List metricProviderList = new ArrayList();
132
		for (Iterator iterator = instrumentPointRefs.entrySet().iterator(); iterator
133
				.hasNext();) {
134
			Map.Entry entry = (Map.Entry) iterator.next();
135
			List instrumentPointRefIds = (List) entry.getValue();
136
			if (instrumentPointRefIds.contains(instrumentPointRefId)) {
137
				metricProviderList.add(entry.getKey());
138
			}
139
		}
140
		return (IMetricNameProvider[]) metricProviderList
141
				.toArray(new IMetricNameProvider[metricProviderList.size()]);
142
	}
143
144
	/**
145
	 * Stores the {@link IMetricNameProvider} instances. <br>
146
	 * KEY = metric provider id. <br>
147
	 * VALUE = An instance of metric provider
148
	 */
149
	private Map metricProviders = new HashMap();
150
151
	/**
152
	 * Stores the reference between the metric provider and the instrument
153
	 * points. <br>
154
	 * KEY = metric provider. <br>
155
	 * VALUE = The instrument points
156
	 */
157
	private Map instrumentPointRefs = new HashMap();
158
159
}
(-)src/org/eclipse/hyades/trace/views/internal/MethodInvocationStatistic.java (-1 / +9 lines)
Lines 34-39 Link Here
34
import org.eclipse.hyades.trace.views.internal.view.columnlabels.MethodInvocationColumnLabel;
34
import org.eclipse.hyades.trace.views.internal.view.columnlabels.MethodInvocationColumnLabel;
35
import org.eclipse.hyades.trace.views.internal.view.columnlabels.MethodInvocationEntryTimeColumnLabel;
35
import org.eclipse.hyades.trace.views.internal.view.columnlabels.MethodInvocationEntryTimeColumnLabel;
36
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
36
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
37
import org.eclipse.hyades.trace.views.util.internal.ColumnExtensionValue;
38
import org.eclipse.hyades.trace.views.util.internal.IColumnExtension;
37
import org.eclipse.hyades.trace.views.util.internal.ITimeChangedListener;
39
import org.eclipse.hyades.trace.views.util.internal.ITimeChangedListener;
38
import org.eclipse.hyades.trace.views.util.internal.StatisticTableColumnInfo;
40
import org.eclipse.hyades.trace.views.util.internal.StatisticTableColumnInfo;
39
import org.eclipse.hyades.ui.provisional.context.ContextManager;
41
import org.eclipse.hyades.ui.provisional.context.ContextManager;
Lines 269-275 Link Here
269
					case 4://cpu time
271
					case 4://cpu time
270
						return getElementColumnText(obj, _CPUTimeCol, false);
272
						return getElementColumnText(obj, _CPUTimeCol, false);
271
				}
273
				}
272
				
274
275
				// if column extended
276
				if (_listOfColumExtension.size() != 0) {
277
					ColumnExtensionValue elt = (ColumnExtensionValue) _listOfColumExtension.get(pos - 5);
278
					return ((IColumnExtension)(elt.getClassOfColumnExtension())).getColumnText(obj,elt.getInitialColumnPos());
279
				}
273
            							
280
            							
274
			return "";
281
			return "";
275
		}
282
		}
Lines 356-361 Link Here
356
				+ IContextAttributes.METHOD_AVG_BASE_TIME	+ ":4:"
363
				+ IContextAttributes.METHOD_AVG_BASE_TIME	+ ":4:"
357
				+ String.valueOf(ColumnData.IS_VISIBLE) + ":right:100";
364
				+ String.valueOf(ColumnData.IS_VISIBLE) + ":right:100";
358
				
365
				
366
		executionColumn += getColumnsTemplateExtensions(5, "org.eclipse.hyades.trace.views.internal.MethodInvocationStatistic", false);
359
		return executionColumn;
367
		return executionColumn;
360
	}
368
	}
361
369

Return to bug 166692