Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 116824 Details for
Bug 166692
[Tech Preview] Add per thread exection time, cycles and instructions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch for 166692
patch20081024.txt (text/plain), 110.03 KB, created by
Richard Y.S. HUANG
on 2008-11-03 11:03:35 EST
(
hide
)
Description:
patch for 166692
Filename:
MIME Type:
Creator:
Richard Y.S. HUANG
Created:
2008-11-03 11:03:35 EST
Size:
110.03 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.trace.arm >Index: src-probes/GenericArm_probe.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-probes/GenericArm_probe.java,v >retrieving revision 1.11 >diff -u -r1.11 GenericArm_probe.java >--- src-probes/GenericArm_probe.java 30 Aug 2007 21:35:32 -0000 1.11 >+++ src-probes/GenericArm_probe.java 24 Oct 2008 09:25:03 -0000 >@@ -16,7 +16,7 @@ > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html >- * $Id: GenericArm_probe.java,v 1.11 2007/08/30 21:35:32 apatel Exp $ >+ * $Id: GenericArm.probe,v 1.10 2007/08/30 21:35:32 apatel Exp $ > * > * Contributors: > * IBM - Initial API and implementation >Index: src-probes/Servlet_probe.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-probes/Servlet_probe.java,v >retrieving revision 1.10 >diff -u -r1.10 Servlet_probe.java >--- src-probes/Servlet_probe.java 31 Aug 2007 19:26:27 -0000 1.10 >+++ src-probes/Servlet_probe.java 24 Oct 2008 09:25:03 -0000 >@@ -16,7 +16,7 @@ > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html >- * $Id: Servlet_probe.java,v 1.10 2007/08/31 19:26:27 apatel Exp $ >+ * $Id: Servlet.probe,v 1.8 2007/08/10 22:40:55 apatel Exp $ > * > * Contributors: > * IBM - Initial API and implementation >Index: src-probes/EJB_probe.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-probes/EJB_probe.java,v >retrieving revision 1.8 >diff -u -r1.8 EJB_probe.java >--- src-probes/EJB_probe.java 10 Aug 2007 22:41:50 -0000 1.8 >+++ src-probes/EJB_probe.java 24 Oct 2008 09:25:03 -0000 >@@ -16,7 +16,7 @@ > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html >- * $Id: EJB_probe.java,v 1.8 2007/08/10 22:41:50 apatel Exp $ >+ * $Id: EJB.probe,v 1.7 2007/08/10 22:40:54 apatel Exp $ > * > * Contributors: > * IBM - Initial API and implementation >Index: src-probes/JDBC_probe.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-probes/JDBC_probe.java,v >retrieving revision 1.7 >diff -u -r1.7 JDBC_probe.java >--- src-probes/JDBC_probe.java 10 Aug 2007 22:41:50 -0000 1.7 >+++ src-probes/JDBC_probe.java 24 Oct 2008 09:25:03 -0000 >@@ -14,7 +14,7 @@ > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html >- * $Id: JDBC_probe.java,v 1.7 2007/08/10 22:41:50 apatel Exp $ >+ * $Id: JDBC.probe,v 1.5 2007/08/10 22:40:54 apatel Exp $ > * > * Contributors: > * IBM - Initial API and implementation >Index: src-model/org/eclipse/tptp/trace/arm/internal/model/ArmInstrument.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-model/org/eclipse/tptp/trace/arm/internal/model/ArmInstrument.java,v >retrieving revision 1.8 >diff -u -r1.8 ArmInstrument.java >--- src-model/org/eclipse/tptp/trace/arm/internal/model/ArmInstrument.java 26 Sep 2006 22:40:21 -0000 1.8 >+++ src-model/org/eclipse/tptp/trace/arm/internal/model/ArmInstrument.java 24 Oct 2008 09:25:03 -0000 >@@ -11,11 +11,38 @@ > ***********************************************************************/ > package org.eclipse.tptp.trace.arm.internal.model; > >+import java.util.ArrayList; > import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; > import java.util.Properties; > > import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger; >+import org.opengroup.arm40.metric.ArmMetric; >+import org.opengroup.arm40.metric.ArmMetricCounter32; >+import org.opengroup.arm40.metric.ArmMetricCounter32Definition; >+import org.opengroup.arm40.metric.ArmMetricCounter64; >+import org.opengroup.arm40.metric.ArmMetricCounter64Definition; >+import org.opengroup.arm40.metric.ArmMetricCounterFloat32; >+import org.opengroup.arm40.metric.ArmMetricCounterFloat32Definition; >+import org.opengroup.arm40.metric.ArmMetricDefinition; > import org.opengroup.arm40.metric.ArmMetricFactory; >+import org.opengroup.arm40.metric.ArmMetricGauge32; >+import org.opengroup.arm40.metric.ArmMetricGauge32Definition; >+import org.opengroup.arm40.metric.ArmMetricGauge64; >+import org.opengroup.arm40.metric.ArmMetricGauge64Definition; >+import org.opengroup.arm40.metric.ArmMetricGaugeFloat32; >+import org.opengroup.arm40.metric.ArmMetricGaugeFloat32Definition; >+import org.opengroup.arm40.metric.ArmMetricGroup; >+import org.opengroup.arm40.metric.ArmMetricGroupDefinition; >+import org.opengroup.arm40.metric.ArmMetricNumericId32; >+import org.opengroup.arm40.metric.ArmMetricNumericId32Definition; >+import org.opengroup.arm40.metric.ArmMetricNumericId64; >+import org.opengroup.arm40.metric.ArmMetricNumericId64Definition; >+import org.opengroup.arm40.metric.ArmMetricString32; >+import org.opengroup.arm40.metric.ArmMetricString32Definition; >+import org.opengroup.arm40.metric.ArmTransactionWithMetrics; >+import org.opengroup.arm40.metric.ArmTransactionWithMetricsDefinition; > import org.opengroup.arm40.tranreport.ArmTranReport; > import org.opengroup.arm40.tranreport.ArmTranReportFactory; > import org.opengroup.arm40.transaction.ArmApplication; >@@ -53,9 +80,12 @@ > > /* The ARM 4.0 Application Instance for the TT product. */ > private ArmApplication applicationInstance; >- >- /* Internal cache of the ARM 4.0 identity properties */ >+ >+ /* Internal cache of the ARM 4.0 identity properties : ArmTransactionDefinition*/ > private HashMap armTranDefCache = new HashMap(30); >+ >+ /* Internal cache of the ARM 4.0 identity properties : ArmTransactionWithMetricsDefinition*/ >+ private HashMap armTranWithMetricDefCache = new HashMap(30); > > /* The ARM 4.0 Error handler */ > private ArmErrorCallback armErrorCallBack; >@@ -102,6 +132,7 @@ > .newInstance(); > tranFactory.setErrorCallback(armErrorCallBack); > } catch (Exception ex) { >+ ex.printStackTrace(); > /* If error, then null */ > tranFactory = null; > /* ArmTransFactoryInit_ERROR = IWAT0766E */ >@@ -109,6 +140,10 @@ > ArmInstrumentMessages.getString("ArmTransFactoryInit_ERROR"), > ARMLogger.LOG, ex); > } >+ catch(Throwable t) >+ { >+ t.printStackTrace(); >+ } > } > > return tranFactory; >@@ -152,7 +187,7 @@ > * @return the ArmMetricFactory. > */ > private ArmMetricFactory getArmMetricFactory() { >- if (metricFactory != null) { >+ if (metricFactory == null) { > /* Check for the metric factory */ > try { > Properties p = System.getProperties(); >@@ -262,13 +297,23 @@ > */ > public ArmTransaction transactionStart(InstrumentDataProvider data, > ArmCorrelator parentCorrelator) { >- > ArmTransaction armTransaction = null; > > if (tranFactory != null) { >- ArmTransactionDefinition armTranDef = getArmTransactionDefinition(data); >- armTransaction = tranFactory.newArmTransaction(getArmApplication(), >- armTranDef); >+ // create ArmTransaction/ArmTransactionWithMetric instance if there >+ // is/isn't ARM metric. >+ if (ArmMetricManager.getInstance().hasMetric()) { >+ try { >+ armTransaction = getArmTransactionWithMetric(data); >+ } catch (Throwable e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ } else { >+ ArmTransactionDefinition armTranDef = getArmTransactionDefinition(data); >+ armTransaction = tranFactory.newArmTransaction( >+ getArmApplication(), armTranDef); >+ } > > String[] contextValues = data.getContextValues(); > for (int i = 0; i < contextValues.length; i++) { >@@ -283,6 +328,7 @@ > armTransaction.setUser(tranFactory.newArmUser( > data.getUserName() == null ? "*" : data.getUserName(), null)); > >+ > if (parentCorrelator == null) { > armTransaction.start(); > } else { >@@ -294,6 +340,285 @@ > } // end of transactionStart() > > /** >+ * Create an ArmTransactionWithMetrics instance. >+ * >+ * @param data >+ * @return >+ */ >+ private ArmTransactionWithMetrics getArmTransactionWithMetric( >+ InstrumentDataProvider data) { >+ if (metricFactory == null) { >+ getArmMetricFactory(); >+ } >+ >+ String transName = data.getTransactionName(); >+ ArmTransactionWithMetrics transactionWithMetrics = null; >+ if (metricFactory != null) { >+ synchronized (armTranWithMetricDefCache) { >+ if (metricFactory != null) { >+ List metrics = ArmMetricManager.getInstance().getMetrics(); >+ ArmTransactionWithMetricsDefinition transactionWithMetricsDef = getArmTransactionWithMetricDefinition( >+ transName, metrics); >+ transactionWithMetrics = getArmTransactionWithMetric( >+ transName, metrics, transactionWithMetricsDef); >+ } >+ } >+ } >+ >+ return transactionWithMetrics; >+ } >+ >+ /** >+ * Create an ArmTransactionWithMetricsDefinition instance. Maybe should use >+ * cache here. >+ * >+ * @param transName >+ * @param metrics >+ * @return >+ */ >+ private ArmTransactionWithMetricsDefinition getArmTransactionWithMetricDefinition( >+ String transName, List metrics) { >+ ArmTransactionWithMetricsDefinition transactionWithMetricsDef; >+ List metricsDef = getArmMetricDefs(metrics); >+ >+ ArmMetricDefinition[] metricDefArray = (ArmMetricDefinition[]) metricsDef >+ .toArray(new ArmMetricDefinition[metricsDef.size()]); >+ >+ ArmMetricGroupDefinition metGroupDef = metricFactory >+ .newArmMetricGroupDefinition(metricDefArray); >+ >+ transactionWithMetricsDef = (ArmTransactionWithMetricsDefinition) armTranWithMetricDefCache >+ .get(transName); >+ >+ if (transactionWithMetricsDef == null) { >+ transactionWithMetricsDef = metricFactory >+ .newArmTransactionWithMetricsDefinition( >+ getArmApplicationDefinition(), transName, null, >+ metGroupDef, null); >+ >+ armTranWithMetricDefCache.put(transName, transactionWithMetricsDef); >+ } >+ return transactionWithMetricsDef; >+ } >+ >+ /** >+ * Get the ArmMetricDefinition instances. The elements of parameter metrics >+ * will be updated to match the metric and it's definition.<br> >+ * TODO Move switch-case here to some other place. For example, another >+ * classes. switch-case is not good coding style. >+ * >+ * @param metrics >+ * List of ArmMetricManager.Metric. >+ * @return List of ArmMetricDefinition. >+ */ >+ private List getArmMetricDefs(List metrics) { >+ List metricDefs = new ArrayList(); >+ for (Iterator iterator = metrics.iterator(); iterator.hasNext();) { >+ ArmMetricManager.Metric metric = (ArmMetricManager.Metric) iterator >+ .next(); >+ ArmMetricDefinition metricDefinition = metric.getDefinition(); >+ if (metricDefinition == null) { >+ // Big switch-case to create ArmMetricDefinition instance. >+ switch (metric.getMetricType()) { >+ case ArmMetricConstants.ArmMetricCounter32: >+ metricDefinition = metricFactory >+ .newArmMetricCounter32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricCounter64: >+ metricDefinition = metricFactory >+ .newArmMetricCounter64Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricCounterFloat32: >+ metricDefinition = metricFactory >+ .newArmMetricCounterFloat32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricGauge32: >+ metricDefinition = metricFactory >+ .newArmMetricGauge32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricGauge64: >+ metricDefinition = metricFactory >+ .newArmMetricGauge64Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricGaugeFloat32: >+ metricDefinition = metricFactory >+ .newArmMetricGaugeFloat32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricNumericId32: >+ metricDefinition = metricFactory >+ .newArmMetricNumericId32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricNumericId64: >+ metricDefinition = metricFactory >+ .newArmMetricNumericId64Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ case ArmMetricConstants.ArmMetricString32: >+ metricDefinition = metricFactory >+ .newArmMetricString32Definition( >+ getArmApplicationDefinition(), metric >+ .getMetricName(), null, >+ ArmMetricDefinition.METRIC_USE_GENERAL, >+ null); >+ break; >+ default: >+ metricDefinition = null; >+ break; >+ } >+ } >+ if (metricDefinition != null) { >+ metricDefs.add(metricDefinition); >+ metric.setDefinition(metricDefinition); >+ } >+ } >+ return metricDefs; >+ } >+ >+ /** >+ * Create an ArmTransactionWithMetrics instance. >+ * >+ * @param transName >+ * @param metrics >+ * @param transactionWithMetricsDef >+ * @return >+ */ >+ private ArmTransactionWithMetrics getArmTransactionWithMetric( >+ String transName, List metrics, >+ ArmTransactionWithMetricsDefinition transactionWithMetricsDef) { >+ ArmTransactionWithMetrics transactionWithMetrics; >+ List armMetrics = getArmMetric(metrics); >+ >+ ArmMetric[] metricDefArray = (ArmMetric[]) armMetrics >+ .toArray(new ArmMetric[armMetrics.size()]); >+ >+ ArmMetricGroup metGroup = metricFactory.newArmMetricGroup( >+ transactionWithMetricsDef.getMetricGroupDefinition(), >+ metricDefArray); >+ >+ transactionWithMetrics = metricFactory.newArmTransactionWithMetrics( >+ getArmApplication(), transactionWithMetricsDef, metGroup); >+ >+ return transactionWithMetrics; >+ } >+ >+ /** >+ * Get the ArmMetricDefinition instances.<br> >+ * TODO Move switch-case here to some other place. For example, another >+ * classes. switch-case is not good coding style. >+ * >+ * @param metrics >+ * List of ArmMetricManager.Metric. >+ * @return List of ArmMetric. >+ */ >+ private List getArmMetric(List metrics) { >+ List armMetrics = new ArrayList(); >+ for (Iterator iterator = metrics.iterator(); iterator.hasNext();) { >+ ArmMetricManager.Metric metric = (ArmMetricManager.Metric) iterator >+ .next(); >+ ArmMetric armMetric = null; >+ ArmMetricDefinition metricDefinition = metric.getDefinition(); >+ if (metricDefinition != null) { >+ String metricValue = metric.getMetricValue(); >+ // Big switch-case to create ArmMetric instance. >+ switch (metric.getMetricType()) { >+ case ArmMetricConstants.ArmMetricCounter32: >+ ArmMetricCounter32 armMetricCounter32 = metricFactory >+ .newArmMetricCounter32((ArmMetricCounter32Definition) metricDefinition); >+ armMetricCounter32.set(Integer.parseInt(metricValue)); >+ armMetric = armMetricCounter32; >+ break; >+ case ArmMetricConstants.ArmMetricCounter64: >+ ArmMetricCounter64 armMetricCounter64 = metricFactory >+ .newArmMetricCounter64((ArmMetricCounter64Definition) metricDefinition); >+ armMetricCounter64.set(Long.parseLong(metricValue)); >+ armMetric = armMetricCounter64; >+ break; >+ case ArmMetricConstants.ArmMetricCounterFloat32: >+ ArmMetricCounterFloat32 armMetricCounterFloat32 = metricFactory >+ .newArmMetricCounterFloat32((ArmMetricCounterFloat32Definition) metricDefinition); >+ armMetricCounterFloat32.set(Float.parseFloat(metricValue)); >+ armMetric = armMetricCounterFloat32; >+ break; >+ case ArmMetricConstants.ArmMetricGauge32: >+ ArmMetricGauge32 armMetricGauge32 = metricFactory >+ .newArmMetricGauge32((ArmMetricGauge32Definition) metricDefinition); >+ armMetricGauge32.set(Integer.parseInt(metricValue)); >+ armMetric = armMetricGauge32; >+ break; >+ case ArmMetricConstants.ArmMetricGauge64: >+ ArmMetricGauge64 armMetricGauge64 = metricFactory >+ .newArmMetricGauge64((ArmMetricGauge64Definition) metricDefinition); >+ armMetricGauge64.set(Long.parseLong(metricValue)); >+ armMetric = armMetricGauge64; >+ break; >+ case ArmMetricConstants.ArmMetricGaugeFloat32: >+ ArmMetricGaugeFloat32 armMetricGaugeFloat32 = metricFactory >+ .newArmMetricGaugeFloat32((ArmMetricGaugeFloat32Definition) metricDefinition); >+ armMetricGaugeFloat32.set(Float.parseFloat(metricValue)); >+ armMetric = armMetricGaugeFloat32; >+ break; >+ case ArmMetricConstants.ArmMetricNumericId32: >+ ArmMetricNumericId32 armMetricNumericId32 = metricFactory >+ .newArmMetricNumericId32((ArmMetricNumericId32Definition) metricDefinition); >+ armMetricNumericId32.set(Integer.parseInt(metricValue)); >+ armMetric = armMetricNumericId32; >+ break; >+ case ArmMetricConstants.ArmMetricNumericId64: >+ ArmMetricNumericId64 armMetricNumericId64 = metricFactory >+ .newArmMetricNumericId64((ArmMetricNumericId64Definition) metricDefinition); >+ armMetricNumericId64.set(Long.parseLong(metricValue)); >+ armMetric = armMetricNumericId64; >+ break; >+ case ArmMetricConstants.ArmMetricString32: >+ ArmMetricString32 armMetricString32 = metricFactory >+ .newArmMetricString32((ArmMetricString32Definition) metricDefinition); >+ armMetricString32.set(metricValue); >+ armMetric = armMetricString32; >+ break; >+ default: >+ armMetric = null; >+ break; >+ } >+ } >+ if (armMetric != null) { >+ armMetrics.add(armMetric); >+ } >+ } >+ return armMetrics; >+ } >+ >+ /** > * The wrapper method for the arm stop() call. > * > * @param transaction the transaction data >Index: .classpath >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/.classpath,v >retrieving revision 1.6 >diff -u -r1.6 .classpath >--- .classpath 10 Aug 2007 22:41:50 -0000 1.6 >+++ .classpath 24 Oct 2008 09:24:53 -0000 >@@ -9,7 +9,9 @@ > <classpathentry kind="src" path="src-model"/> > <classpathentry kind="src" path="src-logging"/> > <classpathentry kind="src" path="src-loader"/> >- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> >+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/IBM Java50"/> > <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> >+ <classpathentry kind="lib" path="external-jars/j2ee-arm.jar"/> >+ <classpathentry kind="lib" path="JPerf.jar"/> > <classpathentry kind="output" path="bin"/> > </classpath> >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/plugin.xml,v >retrieving revision 1.6 >diff -u -r1.6 plugin.xml >--- plugin.xml 28 Feb 2008 23:18:41 -0000 1.6 >+++ plugin.xml 24 Oct 2008 09:24:55 -0000 >@@ -23,7 +23,12 @@ > instrumentTypeId="org.eclipse.tptp.trace.arm.ui.armInstrumentType" > name="Generic Probe" > script="GenericArm.probescript" >- type="probe"/> >+ type="probe"> >+ <metricProviders> >+ <metricProvider >+ metricProviderIdRef="org.eclipse.tptp.trace.arm.PttMetricProvider"></metricProvider> >+ </metricProviders> >+ </instrumentPoint> > <instrumentPoint > description="Collects ARM data for Java Servlets." > id="org.eclipse.tptp.trace.arm.probes.j2ee.servlet" >@@ -56,5 +61,12 @@ > name="Generic Aspect" > type="aspect"/> > </extension> >+ <extension >+ point="org.eclipse.tptp.platform.instrumentation.ui.metricProvider"> >+ <metricProvider >+ id="org.eclipse.tptp.trace.arm.PttMetricProvider" >+ providerClass="org.eclipse.tptp.trace.arm.internal.model.impl.PttMetricNameProvider"> >+ </metricProvider> >+ </extension> > > </plugin> >Index: build.properties >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/build.properties,v >retrieving revision 1.23 >diff -u -r1.23 build.properties >--- build.properties 18 Jan 2008 20:36:19 -0000 1.23 >+++ build.properties 24 Oct 2008 09:24:53 -0000 >@@ -29,7 +29,8 @@ > src-probes/GenericArm.probescript,\ > src-probes/Servlet.probescript,\ > src-probes/JDBC.probescript,\ >- armAspects.jar >+ armAspects.jar,\ >+ JPerf.jar > jars.extra.classpath = ../../external-jars/j2ee-arm.jar > source.config.jar = src-config/ > output.config.jar = bin/ >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/META-INF/MANIFEST.MF,v >retrieving revision 1.18 >diff -u -r1.18 MANIFEST.MF >--- META-INF/MANIFEST.MF 23 Apr 2008 16:53:52 -0000 1.18 >+++ META-INF/MANIFEST.MF 24 Oct 2008 09:24:55 -0000 >@@ -24,5 +24,6 @@ > cbeLogging.jar, > armLibrary.jar, > armModel.jar, >- armProbes.jar >+ armProbes.jar, >+ JPerf.jar > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >Index: src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmEventFactory.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmEventFactory.java,v >retrieving revision 1.6 >diff -u -r1.6 TPTPArmEventFactory.java >--- src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmEventFactory.java 28 Feb 2008 16:41:56 -0000 1.6 >+++ src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmEventFactory.java 24 Oct 2008 09:25:01 -0000 >@@ -20,6 +20,8 @@ > import org.eclipse.tptp.trace.arm.internal.transaction.ArmIdentityPropertiesImpl; > import org.eclipse.tptp.trace.arm.internal.transaction.ArmTransactionImpl; > import org.eclipse.tptp.trace.arm.internal.util.ArmIdentityProperty; >+import org.opengroup.arm40.metric.ArmMetricGroup; >+import org.opengroup.arm40.metric.ArmTransactionWithMetrics; > import org.opengroup.arm40.transaction.ArmApplication; > import org.opengroup.arm40.transaction.ArmApplicationDefinition; > import org.opengroup.arm40.transaction.ArmCorrelator; >@@ -37,15 +39,30 @@ > public class TPTPArmEventFactory { > > /** >- * > * @param transaction > * @return > */ > public static TPTPStartArmEvent newStartEvent(ArmTransaction transaction) { >- return new TPTPStartArmEventImpl(transaction); >+ if (transaction instanceof ArmTransactionWithMetrics) { >+ ArmTransactionWithMetrics transactionWithMetrics = (ArmTransactionWithMetrics) transaction; >+ return newStartMetricEvent(transactionWithMetrics); >+ } else { >+ return new TPTPStartArmEventImpl(transaction); >+ } > } > > /** >+ * Create TPTPStartArmEvent instance. This instance will be the >+ * implementation with metric. >+ * >+ * @param transaction >+ * @return >+ */ >+ public static TPTPStartArmEvent newStartMetricEvent(ArmTransactionWithMetrics transaction) { >+ return new TPTPStartArmMetricEventImpl(transaction); >+ } >+ >+ /** > * > * @param transaction > * @return >@@ -70,7 +87,28 @@ > super(transaction, ((ArmTransactionImpl) transaction) > .getArrivalTime()); > } >+ } >+ >+ /** >+ * Just extend to support metric. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+ private static class TPTPStartArmMetricEventImpl extends TPTPStartArmEventImpl >+ implements TPTPArmMetricEvent { >+ >+ public TPTPStartArmMetricEventImpl(ArmTransactionWithMetrics transaction) { >+ super(transaction); >+ this.metricGroup = transaction.getMetricGroup(); >+ } >+ >+ public ArmMetricGroup getArmMetricGroup() { >+ return metricGroup; >+ } > >+ private ArmMetricGroup metricGroup; > } > > /** >@@ -92,6 +130,8 @@ > > } > >+ >+ > /** > * > * @author rdanek >Index: src-agent/org/eclipse/tptp/trace/arm/internal/agent/Agent.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-agent/org/eclipse/tptp/trace/arm/internal/agent/Agent.java,v >retrieving revision 1.16 >diff -u -r1.16 Agent.java >--- src-agent/org/eclipse/tptp/trace/arm/internal/agent/Agent.java 9 Aug 2007 21:13:11 -0000 1.16 >+++ src-agent/org/eclipse/tptp/trace/arm/internal/agent/Agent.java 24 Oct 2008 09:24:57 -0000 >@@ -265,10 +265,10 @@ > * @see org.eclipse.tptp.trace.arm.internal.agent.trace.IXmlTraceWriter#write(org.eclipse.tptp.trace.arm.internal.agent.trace.events.IBaseRecord) > */ > public void write(IBaseRecord message) { >- _agent.logMessageUTF8(message.toString()); >+ _agent.logMessageUTF8(message.toString()); > > /* Log Debug Message */ >- _logger.logDebug(ARMLogger.SEV_DEBUG_MIN, "write(IBaseRecord): " //$NON-NLS-1$ >+ _logger.logDebug(ARMLogger.SEV_FATAL, "write(IBaseRecord): " //$NON-NLS-1$ > + message.toString()); > > >Index: src-agent/org/eclipse/tptp/trace/arm/internal/agent/processor/ARMEventProcessor.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-agent/org/eclipse/tptp/trace/arm/internal/agent/processor/ARMEventProcessor.java,v >retrieving revision 1.5 >diff -u -r1.5 ARMEventProcessor.java >--- src-agent/org/eclipse/tptp/trace/arm/internal/agent/processor/ARMEventProcessor.java 20 Jul 2006 01:38:35 -0000 1.5 >+++ src-agent/org/eclipse/tptp/trace/arm/internal/agent/processor/ARMEventProcessor.java 24 Oct 2008 09:24:59 -0000 >@@ -20,12 +20,14 @@ > import org.eclipse.tptp.trace.arm.internal.agent.model.IRuntimeModel; > import org.eclipse.tptp.trace.arm.internal.agent.trace.events.InvocationContextRecord; > import org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodEventRecord; >+import org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodMetricEventRecord; > import org.eclipse.tptp.trace.arm.internal.agent.trace.events.RemoteMethodEventRecord; > import org.eclipse.tptp.trace.arm.internal.agent.trace.exceptions.MethodEntryException; > import org.eclipse.tptp.trace.arm.internal.agent.util.IEventProcessor; > import org.eclipse.tptp.trace.arm.internal.agent.util.Timestamp; > import org.eclipse.tptp.trace.arm.internal.correlator.TPTPArmCorrelator; > import org.eclipse.tptp.trace.arm.internal.event.TPTPArmEvent; >+import org.eclipse.tptp.trace.arm.internal.event.TPTPArmMetricEvent; > import org.eclipse.tptp.trace.arm.internal.event.TPTPStartArmEvent; > import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger; > >@@ -107,11 +109,20 @@ > > boolean isEntry = event instanceof TPTPStartArmEvent; > MethodEventRecord mr; >- >+ > if (isLocalInvocation && isSameThread) { >- mr = new MethodEventRecord(methodName, methodSignature, methodKey, >- ticket, seqCtr, className, threadid, timestamp, isEntry, >- appName, component); >+ // Create method event record with metric or without metric. >+ if (event instanceof TPTPArmMetricEvent) { >+ TPTPArmMetricEvent metricEvent = (TPTPArmMetricEvent) event; >+ mr = new MethodMetricEventRecord(methodName, methodSignature, >+ methodKey, ticket, seqCtr, className, threadid, >+ timestamp, isEntry, appName, component, metricEvent >+ .getArmMetricGroup()); >+ } else { >+ mr = new MethodEventRecord(methodName, methodSignature, >+ methodKey, ticket, seqCtr, className, threadid, >+ timestamp, isEntry, appName, component); >+ } > > } else { > mr = createRemoteMethodEvent(methodName, methodSignature, >Index: src-config/org/eclipse/tptp/trace/arm/SetConfig.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-config/org/eclipse/tptp/trace/arm/SetConfig.java,v >retrieving revision 1.7 >diff -u -r1.7 SetConfig.java >--- src-config/org/eclipse/tptp/trace/arm/SetConfig.java 10 Aug 2007 22:40:55 -0000 1.7 >+++ src-config/org/eclipse/tptp/trace/arm/SetConfig.java 24 Oct 2008 09:25:01 -0000 >@@ -84,6 +84,12 @@ > Variable.setPosition(var, "append"); > Variable.setValue(var, "%PLUGINS_HOME%" + sr + getPluginName() + sr + "armLoader.jar"); > app.appendChild(var); >+ >+ var = doc.createElement(Variable.TAG); >+ Variable.setName(var, "CLASSPATH"); >+ Variable.setPosition(var, "append"); >+ Variable.setValue(var, "%PLUGINS_HOME%" + sr + getPluginName() + sr + "JPerf.jar"); >+ app.appendChild(var); > > var = doc.createElement(Variable.TAG); > Variable.setName(var, "CLASSPATH"); >Index: src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodEventRecord.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm/src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodEventRecord.java,v >retrieving revision 1.3 >diff -u -r1.3 MethodEventRecord.java >--- src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodEventRecord.java 7 Jul 2006 16:39:28 -0000 1.3 >+++ src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodEventRecord.java 24 Oct 2008 09:24:59 -0000 >@@ -133,7 +133,7 @@ > String methodEvent = super.getXmlPrinter().MethodEntry( > _methodIdRef, _ticket, _sequenceCounter, _stackDepth, > _classIdRef, _threadIdRef, _time); >- methodEvent += "\r\n"+super.getXmlPrinter().ParameterRecord(super.getTransactionDetailIdRef())+"\r\n"; //$NON-NLS-1$ //$NON-NLS-2$ >+ methodEvent += "\r\n"+getEntryParameterPart()+"\r\n"; //$NON-NLS-1$ //$NON-NLS-2$ > methodEvent += super.getXmlPrinter().MethodEntryEnd(); > return methodEvent; > >@@ -143,4 +143,14 @@ > _classIdRef, _threadIdRef, _time); > } > >+ /** >+ * Parameter part of the record for method entry. The succlass can override >+ * it to add additional part. >+ * >+ * @return >+ */ >+ protected String getEntryParameterPart() { >+ return super.getXmlPrinter().ParameterRecord( >+ super.getTransactionDetailIdRef()); >+ } > } >\ No newline at end of file >Index: src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricConstants.java >=================================================================== >RCS file: src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricConstants.java >diff -N src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: ArmMetricConstants.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.model; >+ >+/** >+ * Classes to define the metric types. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+public class ArmMetricConstants { >+ >+ // Metric types >+ public static final int UNKOWN = -1; >+ public static final int ArmMetricCounter32 = 1; >+ public static final int ArmMetricCounter64 = 2; >+ public static final int ArmMetricCounterFloat32 = 3; >+ public static final int ArmMetricGauge32 = 4; >+ public static final int ArmMetricGauge64 = 5; >+ public static final int ArmMetricGaugeFloat32 = 6; >+ public static final int ArmMetricNumericId32 = 7; >+ public static final int ArmMetricNumericId64 = 8; >+ public static final int ArmMetricString32 = 9; >+} >Index: src-model/org/eclipse/tptp/trace/arm/internal/model/impl/PttMetricValueProvider.java >=================================================================== >RCS file: src-model/org/eclipse/tptp/trace/arm/internal/model/impl/PttMetricValueProvider.java >diff -N src-model/org/eclipse/tptp/trace/arm/internal/model/impl/PttMetricValueProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-model/org/eclipse/tptp/trace/arm/internal/model/impl/PttMetricValueProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,125 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: PttMetricValueProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.model.impl; >+ >+import java.util.Arrays; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.Map; >+ >+import jperf.JPerf; >+import jperf.PerThreadTime; >+ >+import org.eclipse.tptp.trace.arm.internal.model.ArmMetricConstants; >+import org.eclipse.tptp.trace.arm.internal.model.IMetricValueProvider; >+ >+/** >+ * The metric value provider. It provides value via PTT. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+public class PttMetricValueProvider implements IMetricValueProvider, >+ IPttMetricProvider { >+ >+ /** >+ * Metric names which will be used to init ptt. It should have the same >+ * order with METRIC_NAMES. >+ */ >+ private static final String[] METRIC_NAMES_FOR_PTT = { "CYCLES", >+ "NONHALTED_CYCLES", "INSTR", "UOPS", "ALL_UOPS", "BRANCH", >+ "MISPRED_BRANCH", "CALLS", "ITLB_MISS", "TC_FLUSH", >+ "TC_DELIVER_LP0", "TC_DELIVER_LP1", "TC_MISS", "L2_READ_MISS", >+ "L2_READ_REFS", "L3_READ_MISS", "L3_READ_REFS", "MACHINE_CLEAR", >+ "MACHINE_CLEAR_MO", "MACHINE_CLEAR_SM", "BRANCH_TAKEN", >+ "PROC_BUS_ACCESS", "PROC_NONPREFETCH_BUS_ACCESS", "PROC_READS", >+ "PROC_WRITES", "PROC_READS_NONPREFETCH", "PROC_BUS_ACCESS_UW", >+ "PROC_BUS_READS_UW", "PROC_BUS_WRITES_UW", >+ "PROC_READS_NONPREFETCH_UW" }; >+ >+ /** >+ * Mapping between the metric names in eclipse Workbench and ptt init. >+ */ >+ private static final Map METRICS_MAPPING; >+ static { >+ Map tempMap = new HashMap(METRIC_NAMES.length); >+ for (int i = 0; i < METRIC_NAMES.length; i++) { >+ tempMap.put(METRIC_NAMES[i], METRIC_NAMES_FOR_PTT[i]); >+ } >+ METRICS_MAPPING = Collections.unmodifiableMap(tempMap); >+ } >+ >+ public String[] getNames() { >+ return METRIC_NAMES; >+ } >+ >+ public int getType(String name) { >+ // TODO : always return ArmMetricString32 now. >+ return ArmMetricConstants.ArmMetricString32; >+ } >+ >+ public String getVaule(String name) { >+ return getVaules(new String[] { name })[0]; >+ } >+ >+ public int[] getType(String[] names) { >+ int[] result = new int[names.length]; >+ Arrays.fill(result, ArmMetricConstants.ArmMetricString32); >+ return result; >+ } >+ >+ public String[] getVaules(String[] names) { >+ PerThreadTime ptt = new PerThreadTime(); >+ >+ // reset >+ ptt.Terminate(); >+ >+ String[] pttMetricNames = getMetricNamesForPtt(names); >+ ptt.Init(pttMetricNames.length, pttMetricNames, >+ JPerf.PTT_USER_LEVEL); >+ ptt.GetCurrentThreadData(); >+ >+ String[] result = new String[pttMetricNames.length]; >+ for (int i = 0; i < result.length; i++) { >+ result[i] = Long.toString(ptt.mv[i]); >+ } >+ >+ return result; >+ } >+ >+ private String[] getMetricNamesForPtt(String[] names) { >+ String[] pttMetricNames = new String[names.length]; >+ for (int i = 0; i < pttMetricNames.length; i++) { >+ pttMetricNames[i] = (String) METRICS_MAPPING.get(names[i]); >+ } >+ return pttMetricNames; >+ } >+ >+ /** >+ * @return the id >+ */ >+ public String getId() { >+ return id; >+ } >+ >+ /** >+ * @param id >+ * the id to set >+ */ >+ public void setId(String id) { >+ this.id = id; >+ } >+ >+ private String id; >+ >+} >Index: src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmMetricEvent.java >=================================================================== >RCS file: src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmMetricEvent.java >diff -N src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmMetricEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmMetricEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: TPTPArmMetricEvent.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.event; >+ >+import org.opengroup.arm40.metric.ArmMetricGroup; >+ >+/** >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+public interface TPTPArmMetricEvent extends TPTPArmEvent { >+ >+ /** >+ * Get the metric group. >+ * >+ * @return >+ */ >+ ArmMetricGroup getArmMetricGroup(); >+ >+} >Index: src-model/org/eclipse/tptp/trace/arm/internal/model/impl/IPttMetricProvider.java >=================================================================== >RCS file: src-model/org/eclipse/tptp/trace/arm/internal/model/impl/IPttMetricProvider.java >diff -N src-model/org/eclipse/tptp/trace/arm/internal/model/impl/IPttMetricProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-model/org/eclipse/tptp/trace/arm/internal/model/impl/IPttMetricProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: IPttMetricProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.model.impl; >+ >+/** >+ * >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+public interface IPttMetricProvider { >+ >+ /** >+ * Metric names which will display in eclipse Workbench. It should have the >+ * same order with METRIC_NAMES_FOR_PTT.<br> >+ * TODO : use the meaning name. >+ */ >+ public static final String[] METRIC_NAMES = { "CYCLES", "NONHALTED_CYCLES", >+ "INSTR", "UOPS", "ALL_UOPS", "BRANCH", "MISPRED_BRANCH", "CALLS", >+ "ITLB_MISS", "TC_FLUSH", "TC_DELIVER_LP0", "TC_DELIVER_LP1", >+ "TC_MISS", "L2_READ_MISS", "L2_READ_REFS", "L3_READ_MISS", >+ "L3_READ_REFS", "MACHINE_CLEAR", "MACHINE_CLEAR_MO", >+ "MACHINE_CLEAR_SM", "BRANCH_TAKEN", "PROC_BUS_ACCESS", >+ "PROC_NONPREFETCH_BUS_ACCESS", "PROC_READS", "PROC_WRITES", >+ "PROC_READS_NONPREFETCH", "PROC_BUS_ACCESS_UW", >+ "PROC_BUS_READS_UW", "PROC_BUS_WRITES_UW", >+ "PROC_READS_NONPREFETCH_UW" }; >+} >Index: src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodMetricEventRecord.java >=================================================================== >RCS file: src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodMetricEventRecord.java >diff -N src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodMetricEventRecord.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodMetricEventRecord.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: MethodMetricEventRecord.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.agent.trace.events; >+ >+import org.eclipse.tptp.trace.arm.internal.agent.util.Timestamp; >+import org.eclipse.tptp.trace.arm.internal.metric.ArmMetricGroupImpl; >+import org.opengroup.arm40.metric.ArmMetric; >+import org.opengroup.arm40.metric.ArmMetricGroup; >+ >+/** >+ * This class extends MethodEventRecord to provide the feature about metric. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+public class MethodMetricEventRecord extends MethodEventRecord { >+ >+ /** >+ * @param name >+ * @param signature >+ * @param key >+ * @param _ticket >+ * @param counter >+ * @param name2 >+ * @param idRef >+ * @param _timestamp >+ * @param entry >+ * @param applicationName >+ * @param transactionDetail >+ */ >+ public MethodMetricEventRecord(String name, String signature, Object key, >+ long _ticket, long counter, String name2, long idRef, >+ Timestamp _timestamp, boolean entry, String applicationName, >+ String transactionDetail, ArmMetricGroup metricGroup) { >+ super(name, signature, key, _ticket, counter, name2, idRef, _timestamp, >+ entry, applicationName, transactionDetail); >+ this.metricGroup = metricGroup; >+ } >+ >+ /** >+ * @return the metricGroup >+ */ >+ public ArmMetricGroup getMetricGroup() { >+ return metricGroup; >+ } >+ >+ private ArmMetricGroup metricGroup; >+ >+ /** >+ * Add the information about metric. >+ * >+ * @see org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodEventRecord#getEntryParameterPart() >+ */ >+ protected String getEntryParameterPart() { >+ String parameter = super.getEntryParameterPart(); >+ // Add the information about metric. >+ ArmMetric[] metrics = ((ArmMetricGroupImpl) metricGroup).getMetrics(); >+ for (int i = 0; i < metrics.length; i++) { >+ parameter += "\r\n" + metrics[i].toString(); >+ } >+ return parameter; >+ } >+ >+} >Index: src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricManager.java >=================================================================== >RCS file: src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricManager.java >diff -N src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,235 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: ArmMetricManager.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.model; >+ >+import java.io.BufferedReader; >+import java.io.File; >+import java.io.FileReader; >+import java.io.IOException; >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.opengroup.arm40.metric.ArmMetricDefinition; >+ >+/** >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+public class ArmMetricManager { >+ >+ /** >+ * Prefix of the temp file for metric. >+ */ >+ private static final String ARM_PREFIX_FOR_METRIC = "ARM"; >+ >+ /** >+ * Singleton. >+ */ >+ private static final ArmMetricManager instance = new ArmMetricManager(); >+ >+ public static ArmMetricManager getInstance() { >+ return instance; >+ } >+ >+ private ArmMetricManager() { >+ try { >+ loadMetricProvider(); >+ } catch (Throwable e) { >+ // Do nothing. Just skip load. >+ } >+ } >+ >+ private void loadMetricProvider() throws IOException { >+ String tmpDir = System.getProperty("java.io.tmpdir"); >+ File metricFile = new File(tmpDir, ARM_PREFIX_FOR_METRIC >+ + "instrument-runtime.properties"); >+ >+ BufferedReader reader = new BufferedReader(new FileReader(metricFile)); >+ String line = reader.readLine(); >+ while (line != null) { >+ String[] metricInfo = line.split(IMetricValueProvider.SEPARATOR); >+ if (metricInfo.length >= 2) { >+ IMetricValueProvider provider = getMetricProvider(metricInfo[0]); >+ saveMetricInfo(provider, metricInfo[1]); >+ } >+ line = reader.readLine(); >+ } >+ } >+ >+ private void saveMetricInfo(IMetricValueProvider provider, String metricName) { >+ List metricNames = (List) metricInformation.get(provider); >+ if (metricNames == null) { >+ metricNames = new ArrayList(); >+ metricInformation.put(provider, metricNames); >+ } >+ metricNames.add(metricName); >+ } >+ >+ /** >+ * Get the instance of the {@link IMetricValueProvider}. A new instance will >+ * be created if there is no such instance. >+ * >+ * @param className The class name of the {@link IMetricValueProvider} >+ * @return >+ */ >+ private IMetricValueProvider getMetricProvider(String className) { >+ IMetricValueProvider provider = (IMetricValueProvider) metricProviders >+ .get(className); >+ if (provider == null) { >+ try { >+ Class clazz = Class.forName(className); >+ provider = (IMetricValueProvider) clazz.newInstance(); >+ metricProviders.put(className, provider); >+ } catch (ClassNotFoundException e) { >+ e.printStackTrace(); >+ } catch (NoClassDefFoundError e) { >+ e.printStackTrace(); >+ } catch (IllegalAccessException e) { >+ e.printStackTrace(); >+ } catch (InstantiationException e) { >+ e.printStackTrace(); >+ } >+ } >+ return provider; >+ } >+ >+ /** >+ * Check whether there is metric. >+ * >+ * @return >+ */ >+ public boolean hasMetric() { >+ return (metricProviders != null) && (metricProviders.size() != 0); >+ } >+ >+ /** >+ * Get the metrics. >+ * >+ * @return The list of the {@link ArmMetricManager.Metric}. >+ */ >+ public List getMetrics() { >+ List metrics = new ArrayList(); >+ for (Iterator iterator = metricInformation.entrySet().iterator(); iterator >+ .hasNext();) { >+ Map.Entry entry = (Map.Entry) iterator.next(); >+ IMetricValueProvider provider = (IMetricValueProvider) entry >+ .getKey(); >+ List metricNames = (List) entry.getValue(); >+ for (Iterator iterator2 = metricNames.iterator(); iterator2 >+ .hasNext();) { >+ String metricName = (String) iterator2.next(); >+ String metricValue = provider.getVaule(metricName); >+ int metricType = provider.getType(metricName); >+ metrics.add(new Metric(metricName, metricValue, metricType, >+ provider)); >+ } >+ } >+ return metrics; >+ } >+ >+ /** >+ * Support this method to support {@link IMetricValueProvider} instance >+ * initialization. >+ * >+ * @return >+ */ >+ public Collection getmMetricProviders() { >+ return metricProviders.values(); >+ } >+ >+ /** >+ * Store the instances of the {@link IMetricValueProvider}. The key is the >+ * class name, and the value is the instance. >+ */ >+ private Map metricProviders = new HashMap(); >+ >+ /** >+ * Store the instances of the {@link IMetricValueProvider} and the metrics >+ * they should provide. The key is the instance , and the value is the list >+ * of the metric name. >+ */ >+ private Map metricInformation = new HashMap(); >+ >+ /** >+ * Value object to store the metric information. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+ public class Metric { >+ >+ public Metric(String metricName, String metricValue, int metricType, >+ IMetricValueProvider metricProvider) { >+ super(); >+ this.metricName = metricName; >+ this.metricValue = metricValue; >+ this.metricType = metricType; >+ this.metricProvider = metricProvider; >+ } >+ >+ /** >+ * @return the metricName >+ */ >+ public String getMetricName() { >+ return metricName; >+ } >+ >+ /** >+ * @return the metricValue >+ */ >+ public String getMetricValue() { >+ return metricValue; >+ } >+ >+ /** >+ * @return the metricType >+ */ >+ public int getMetricType() { >+ return metricType; >+ } >+ >+ /** >+ * @return the metricProvider >+ */ >+ public IMetricValueProvider getMetricProvider() { >+ return metricProvider; >+ } >+ >+ /** >+ * @return the definition >+ */ >+ public ArmMetricDefinition getDefinition() { >+ return definition; >+ } >+ >+ /** >+ * @param definition >+ * the definition to set >+ */ >+ public void setDefinition(ArmMetricDefinition definition) { >+ this.definition = definition; >+ } >+ >+ private String metricName; >+ private String metricValue; >+ private int metricType; >+ private IMetricValueProvider metricProvider; >+ private ArmMetricDefinition definition; >+ >+ } >+} >Index: src-model/org/eclipse/tptp/trace/arm/internal/model/impl/PttMetricNameProvider.java >=================================================================== >RCS file: src-model/org/eclipse/tptp/trace/arm/internal/model/impl/PttMetricNameProvider.java >diff -N src-model/org/eclipse/tptp/trace/arm/internal/model/impl/PttMetricNameProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-model/org/eclipse/tptp/trace/arm/internal/model/impl/PttMetricNameProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: PttMetricNameProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.model.impl; >+ >+import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider; >+ >+/** >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+public class PttMetricNameProvider implements IMetricNameProvider, IPttMetricProvider { >+ >+ public String[] getNames() { >+ return METRIC_NAMES; >+ } >+ >+ public String getMetricValueProviderName() { >+ return PttMetricValueProvider.class.getName(); >+ } >+ >+ /** >+ * @return the id >+ */ >+ public String getId() { >+ return id; >+ } >+ >+ /** >+ * @param id >+ * the id to set >+ */ >+ public void setId(String id) { >+ this.id = id; >+ } >+ >+ private String id; >+} >Index: src-model/org/eclipse/tptp/trace/arm/internal/model/IMetricValueProvider.java >=================================================================== >RCS file: src-model/org/eclipse/tptp/trace/arm/internal/model/IMetricValueProvider.java >diff -N src-model/org/eclipse/tptp/trace/arm/internal/model/IMetricValueProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-model/org/eclipse/tptp/trace/arm/internal/model/IMetricValueProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: IMetricValueProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.internal.model; >+ >+/** >+ * Interface for metric value provider. It's only used in agent. >+ * >+ * @since TPTP 4.5.1 >+ * @author Gao Peng >+ * >+ */ >+public interface IMetricValueProvider { >+ >+ /** >+ * The separator between the metric information. >+ */ >+ String METRIC_SEPERATOR = "\t"; >+ >+ /** >+ * The separator between the parts of the metric information. >+ */ >+ String SEPARATOR = ","; >+ >+ /** >+ * >+ */ >+ String METRIC_PREFIX = "METRIC_PREFIX"; >+ >+ /** >+ * Return the metric value. >+ * >+ * @param name >+ * the metric name. >+ * @return the metric value. >+ */ >+ String getVaule(String name); >+ >+ /** >+ * Return the type of the metric value. >+ * >+ * @param name >+ * the metric name. >+ * @return the type of the metric value. >+ */ >+ int getType(String name); >+ >+ /** >+ * Return the metric values. >+ * >+ * @param name >+ * the metric names. >+ * @return the metric values. >+ */ >+ String[] getVaules(String[] names); >+ >+ /** >+ * Return the type of the metric values. >+ * >+ * @param name >+ * the metric names. >+ * @return the type of the metric values. >+ */ >+ int[] getType(String[] names); >+ >+} >#P org.eclipse.tptp.platform.instrumentation.ui >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPointManager.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPointManager.java,v >retrieving revision 1.5 >diff -u -r1.5 InstrumentPointManager.java >--- src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPointManager.java 27 Oct 2006 21:23:44 -0000 1.5 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPointManager.java 24 Oct 2008 09:25:31 -0000 >@@ -82,6 +82,8 @@ > String descr = element[j].getAttribute("description"); > String script = element[j].getAttribute("script"); > String instrumentTypeId = element[j].getAttribute("instrumentTypeId"); >+ >+ IMetricNameProvider[] metricProviders = getMetricProviders(element[j]); > > String cint = element[j].getContributor().getName(); > >@@ -135,6 +137,9 @@ > instrumentPoint.setProbeScriptContent(probeScriptContents); > instrumentPoint.setType(type); > instrumentPoint.setProbeScript(script); >+ instrumentPoint >+ .setMetricProviders(new CombinedMetricProvider( >+ metricProviders)); > > instrumentPoints.put(id, instrumentPoint); > } catch (Exception ex) { >@@ -144,6 +149,35 @@ > } > } > } // end of initialize() >+ >+ /** >+ * Get the metricProviders. >+ * >+ * @param element >+ * @return the class names of metric providers. >+ */ >+ private IMetricNameProvider[] getMetricProviders( >+ IConfigurationElement element) { >+ IMetricNameProvider[] metricProviders = null; >+ IConfigurationElement[] metricProviderGroup = element >+ .getChildren("metricProviders"); >+ if (metricProviderGroup.length != 0) { >+ IConfigurationElement[] metricProviderElements = metricProviderGroup[0] >+ .getChildren("metricProvider"); >+ metricProviders = new IMetricNameProvider[metricProviderElements.length]; >+ for (int i = 0; i < metricProviderElements.length; i++) { >+ IConfigurationElement metricProvider = metricProviderElements[i]; >+ // get the id of the metricProvider. >+ String metricProviderId = metricProvider >+ .getAttribute("metricProviderIdRef"); >+ // get the IMetricProvider instance from MetricProviderManager >+ // via the id of the metricProvider. >+ metricProviders[i] = MetricProviderManager.getInstance() >+ .getMetricProvider(metricProviderId); >+ } >+ } >+ return metricProviders; >+ } > > private ByteArrayOutputStream findClass(String className, String bundleId) throws IOException { > if (!className.startsWith("/")) { >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPoint.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPoint.java,v >retrieving revision 1.1 >diff -u -r1.1 InstrumentPoint.java >--- src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPoint.java 16 Aug 2006 14:42:52 -0000 1.1 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPoint.java 24 Oct 2008 09:25:28 -0000 >@@ -48,6 +48,11 @@ > /* The contents of the probe script */ > private String probeScriptContent; > >+ /** >+ * The metric provider. This value can be null for no metric provider. >+ */ >+ private IMetricNameProvider metricProvider; >+ > > /** > * Default constructor >@@ -204,4 +209,18 @@ > this.type = type; > } > >+ /** >+ * @return the metricProviders >+ */ >+ public IMetricNameProvider getMetricProvider() { >+ return metricProvider; >+ } >+ >+ /** >+ * @param metricProviders >+ * the metricProviders to set >+ */ >+ public void setMetricProviders(IMetricNameProvider metricProvider) { >+ this.metricProvider = metricProvider; >+ } > } >Index: schema/instrumentPointDeclaration.exsd >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/schema/instrumentPointDeclaration.exsd,v >retrieving revision 1.3 >diff -u -r1.3 instrumentPointDeclaration.exsd >--- schema/instrumentPointDeclaration.exsd 20 Sep 2006 19:14:52 -0000 1.3 >+++ schema/instrumentPointDeclaration.exsd 24 Oct 2008 09:25:28 -0000 >@@ -1,16 +1,21 @@ > <?xml version='1.0' encoding='UTF-8'?> > <!-- Schema file written by PDE --> >-<schema targetNamespace="org.eclipse.tptp.platform.instrumentation.ui"> >+<schema targetNamespace="org.eclipse.tptp.platform.instrumentation.ui" xmlns="http://www.w3.org/2001/XMLSchema"> > <annotation> >- <appInfo> >+ <appinfo> > <meta.schema plugin="org.eclipse.tptp.platform.instrumentation.ui" id="instrumentPointDeclaration" name="instrumentPointDeclaration"/> >- </appInfo> >+ </appinfo> > <documentation> > This extension point is used to register instrument points. The instrument point supports two types probes or aspects. > </documentation> > </annotation> > > <element name="extension"> >+ <annotation> >+ <appinfo> >+ <meta.element /> >+ </appinfo> >+ </annotation> > <complexType> > <sequence> > <element ref="instrumentPoint" minOccurs="1" maxOccurs="unbounded"/> >@@ -34,9 +39,9 @@ > <documentation> > > </documentation> >- <appInfo> >+ <appinfo> > <meta.attribute translatable="true"/> >- </appInfo> >+ </appinfo> > </annotation> > </attribute> > </complexType> >@@ -44,6 +49,9 @@ > > <element name="instrumentPoint"> > <complexType> >+ <sequence> >+ <element ref="metricProviders" minOccurs="0" maxOccurs="1"/> >+ </sequence> > <attribute name="name" type="string" use="required"> > <annotation> > <documentation> >@@ -63,9 +71,9 @@ > <documentation> > > </documentation> >- <appInfo> >+ <appinfo> > <meta.attribute kind="java"/> >- </appInfo> >+ </appinfo> > </annotation> > </attribute> > <attribute name="type" use="required"> >@@ -107,19 +115,39 @@ > </complexType> > </element> > >+ <element name="metricProviders"> >+ <complexType> >+ <sequence minOccurs="1" maxOccurs="unbounded"> >+ <element ref="metricProvider"/> >+ </sequence> >+ </complexType> >+ </element> >+ >+ <element name="metricProvider"> >+ <complexType> >+ <attribute name="metricProviderIdRef" type="string"> >+ <annotation> >+ <documentation> >+ The reference ID of metricProvider. >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ > <annotation> >- <appInfo> >+ <appinfo> > <meta.section type="since"/> >- </appInfo> >+ </appinfo> > <documentation> > Since TPTP 4.3 > </documentation> > </annotation> > > <annotation> >- <appInfo> >+ <appinfo> > <meta.section type="examples"/> >- </appInfo> >+ </appinfo> > <documentation> > <extension > point="org.eclipse.tptp.platform.instrumentation.ui.instrumentPointDeclaration"> >@@ -130,33 +158,39 @@ > instrumentTypeId="org.eclipse.tptp.trace.arm.ui.armInstrumentType" > name="Generic Probe" > script="Generic.probescript" >- type="probes"/> >+ type="probes"> >+ <metricProviders> >+ <metricProvider >+ metricProviderIdRef="org.eclipse.tptp.trace.arm.PttMetricProvider"> >+ </metricProvider> >+ </metricProviders> >+ </instrumentPoint> > </extension> > </documentation> > </annotation> > > <annotation> >- <appInfo> >+ <appinfo> > <meta.section type="apiInfo"/> >- </appInfo> >+ </appinfo> > <documentation> > [Enter API information here.] > </documentation> > </annotation> > > <annotation> >- <appInfo> >+ <appinfo> > <meta.section type="implementation"/> >- </appInfo> >+ </appinfo> > <documentation> > [Enter information about supplied implementation of this extension point.] > </documentation> > </annotation> > > <annotation> >- <appInfo> >+ <appinfo> > <meta.section type="copyright"/> >- </appInfo> >+ </appinfo> > <documentation> > Copyright (c) 2006 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> > </documentation> >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/InstrumentDelegateHelper.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/InstrumentDelegateHelper.java,v >retrieving revision 1.32 >diff -u -r1.32 InstrumentDelegateHelper.java >--- src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/InstrumentDelegateHelper.java 7 Mar 2008 15:57:03 -0000 1.32 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/InstrumentDelegateHelper.java 24 Oct 2008 09:25:33 -0000 >@@ -15,11 +15,13 @@ > import java.io.ByteArrayOutputStream; > import java.io.File; > import java.io.FileOutputStream; >+import java.io.FileWriter; >+import java.io.FilenameFilter; > import java.io.IOException; >+import java.io.PrintWriter; > import java.net.URL; > import java.util.ArrayList; > import java.util.HashMap; >-import java.util.Hashtable; > import java.util.Iterator; > import java.util.List; > import java.util.Map; >@@ -35,7 +37,6 @@ > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; > import org.eclipse.hyades.internal.execution.local.control.Agent; >-import org.eclipse.hyades.internal.execution.local.control.InactiveProcessException; > import org.eclipse.hyades.internal.execution.local.control.Process; > import org.eclipse.hyades.internal.execution.local.control.ProcessListener; > import org.eclipse.hyades.models.hierarchy.TRCProcessProxy; >@@ -53,16 +54,17 @@ > import org.eclipse.tptp.platform.instrumentation.ui.internal.LogHelper; > import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorLoader; > import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorManager; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider; > import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPoint; > import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPointManager; > import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentSelectManager; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.core.MetricProviderManager; > import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.FileTransfer; > import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.InstrumentLookupService; > import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.listener.InstrumentProcessListener; > import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentMessages; > import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentUtil; > import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisType; >-import org.eclipse.tptp.trace.ui.internal.launcher.core.DataCollector; > import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherMessages; > import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility; > import org.eclipse.tptp.trace.ui.provisional.launcher.ProcessParameters; >@@ -92,6 +94,9 @@ > * @return The save copy of ILaunchConfiguration > */ > public static ILaunchConfiguration preLaunch(ILaunchConfiguration configuration) throws CoreException { >+ >+ // Save metric information >+ saveMetricInfo(configuration); > > //first identified that it is JVMPI instrument Collector > InstrumentUtil.initiazeInstrumentCollector(configuration, InstrumentConstants.PI_INSTRUMENT_COLLECTOR); >@@ -102,10 +107,146 @@ > /* Create Project and Model */ > createModelEntities(configuration); > >+ > return handleInstrumentGenerator(configuration); > > } // end of preLaunch(...) >- >+ >+ /** >+ * Store the metric information in file in temp dir. This file will be read >+ * by the agent. >+ * >+ * @param configuration >+ * @throws CoreException >+ */ >+ private static void saveMetricInfo(ILaunchConfiguration configuration) >+ throws CoreException { >+ Map attributes = configuration.getAttributes(); >+ boolean saved = false; >+ for (Iterator iterator = attributes.keySet().iterator(); iterator >+ .hasNext();) { >+ String key = (String) iterator.next(); >+ if (key.startsWith(IMetricNameProvider.METRIC_PREFIX)) { >+ saved = saveMetricInfo(key, configuration.getAttribute(key, >+ (String) null)); >+ } >+ } >+ if (!saved) { >+ // remove the temp file for metric if ther is no metric file. >+ removeTempMetricFile(); >+ } >+ } >+ >+ >+ /** >+ * Store the metric information in file in temp dir. This file will be read >+ * by the agent. >+ * >+ * @param metricId the metric ID. >+ * @param metricInfo the metric information. >+ * @return >+ */ >+ private static boolean saveMetricInfo(String metricId, String metricInfo) { >+ if (metricInfo == null) { >+ // return false if nothing is saved. >+ return false; >+ } >+ >+ File metricFile = getTempMetricFile(metricId); >+ if (metricFile == null) >+ { >+ // return false if nothing is saved. >+ return false; >+ } >+ >+ String[][] metrics = getMetrics(metricInfo); >+ PrintWriter writer = null; >+ try { >+ writer = new PrintWriter(new FileWriter(metricFile)); >+ for (int i = 0; i < metrics.length; i++) { >+ writer.print(metrics[i][0]); >+ writer.print(IMetricNameProvider.SEPARATOR); >+ writer.println(metrics[i][1]); >+ } >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } finally { >+ if (writer != null) { >+ writer.flush(); >+ writer.close(); >+ } >+ } >+ >+ return true; >+ } >+ >+ /** >+ * Get the temp file name for metric. >+ * >+ * @param metricId >+ * @return >+ */ >+ private static File getTempMetricFile(String metricId) { >+ String[] metricMetadata = metricId.split(IMetricNameProvider.SEPARATOR); >+ if (metricMetadata.length != 3) { >+ return null; >+ } >+ String metricType = metricMetadata[1]; >+ >+ String tmpDir = System.getProperty("java.io.tmpdir"); >+ File metricFile = new File(tmpDir, metricType >+ + "instrument-runtime.properties"); >+ return metricFile; >+ } >+ >+ /** >+ * Remove all of the temp file for metric. >+ */ >+ private static void removeTempMetricFile() { >+ String tmpDir = System.getProperty("java.io.tmpdir"); >+ File[] metricFiles = new File(tmpDir).listFiles(new FilenameFilter(){ >+ >+ public boolean accept(File dir, String name) { >+ return name.endsWith("instrument-runtime.properties"); >+ }}); >+ for (int i = 0; i < metricFiles.length; i++) { >+ metricFiles[i].delete(); >+ } >+ } >+ >+ /** >+ * Parser the metric information to get the class names of the metric value >+ * providers and metric names. >+ * >+ * @param metricInfo >+ * @return The second dim is 2. The first element of the second dim is the >+ * class name of the metric value provider, and the second element >+ * of the second dim is metric name. >+ */ >+ private static String[][] getMetrics(String metricInfo) { >+ String[] metrics = metricInfo >+ .split(IMetricNameProvider.METRIC_SEPERATOR); >+ String[][] result = new String[metrics.length][2]; >+ for (int i = 0; i < metrics.length; i++) { >+ String[] metricInfos = metrics[i] >+ .split(IMetricNameProvider.SEPARATOR); >+ if (metricInfos.length != 2) { >+ result[i][0] = ""; >+ result[i][1] = ""; >+ } else { >+ String metricID = metricInfos[0]; >+ String metricName = metricInfos[1]; >+ String metricClassName = MetricProviderManager.getInstance() >+ .getMetricProvider(metricID) >+ .getMetricValueProviderName(); >+ result[i][0] = metricClassName; >+ result[i][1] = metricName; >+ } >+ } >+ >+ return result; >+ } >+ > /** > * It is used to handle instrument generator stuff for user selected analysis types. > * >@@ -488,12 +629,12 @@ > ByteArrayInputStream inputStream = new ByteArrayInputStream(stream.toByteArray()); > byte[] buf = new byte[4096]; > int len; >- while((len=inputStream.read(buf))>0){ >- jarOut.write(buf,0,len); >- } >- stream.close(); >- inputStream.close(); >- jarOut.closeEntry(); >+ while((len=inputStream.read(buf))>0){ >+ jarOut.write(buf,0,len); >+ } >+ stream.close(); >+ inputStream.close(); >+ jarOut.closeEntry(); > } > } > jarOut.finish(); >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/TIInstrumentDelegateHelper.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/TIInstrumentDelegateHelper.java,v >retrieving revision 1.1 >diff -u -r1.1 TIInstrumentDelegateHelper.java >--- src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/TIInstrumentDelegateHelper.java 7 Mar 2008 15:57:00 -0000 1.1 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/TIInstrumentDelegateHelper.java 24 Oct 2008 09:25:39 -0000 >@@ -12,6 +12,7 @@ > **********************************************************************/ > package org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.deleg.application; > >+import java.io.InputStream; > import java.net.InetAddress; > import java.net.UnknownHostException; > import java.util.ArrayList; >@@ -1080,13 +1081,39 @@ > } > > public void incomingData(char[] buffer, int length, InetAddress peer) >- { >+ { > if (!enabled) > return; > preIncomingData(); > super.incommingData(buffer, length, peer); > } > >+ >+ >+ public void incommingData(byte[] buffer, int offset, int length, >+ InetAddress peer) { >+ super.incommingData(buffer, offset, length, peer); >+ } >+ >+ public void incommingData(char[] buffer, int offset, int length, >+ InetAddress peer) { >+ super.incommingData(buffer, offset, length, peer); >+ } >+ >+ public void incommingData(byte[] data, int length, InetAddress peer) { >+ super.incommingData(data, length, peer); >+ } >+ >+ public void incommingData(char[] data, int length, InetAddress peer) { >+ super.incommingData(data, length, peer); >+ } >+ >+ public void incommingStream(InputStream inputStream, InetAddress peer) { >+ super.incommingStream(inputStream, peer); >+ } >+ >+ >+ > private void preIncomingData() > { > if (!processAlive) >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/plugin.xml,v >retrieving revision 1.30 >diff -u -r1.30 plugin.xml >--- plugin.xml 7 Mar 2008 15:56:58 -0000 1.30 >+++ plugin.xml 24 Oct 2008 09:25:26 -0000 >@@ -18,6 +18,7 @@ > <extension-point id="generatorMechanism" name="generatorMechanism" schema="schema/generatorMechanism.exsd"/> > <extension-point id="instrumentPointDeclaration" name="instrumentPointDeclaration" schema="schema/instrumentPointDeclaration.exsd"/> > <extension-point id="runtimeJarsDependency" name="runtimeJarsDependency" schema="schema/runtimeJarsDependency.exsd"/> >+ <extension-point id="metricProvider" name="metricProvider" schema="schema/metricProvider.exsd"/> > > <!-- The Instrument collector --> > <extension >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/listener/InstrumentProcessListener.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.instrumentation.ui/src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/listener/InstrumentProcessListener.java,v >retrieving revision 1.13 >diff -u -r1.13 InstrumentProcessListener.java >--- src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/listener/InstrumentProcessListener.java 24 Aug 2007 13:55:49 -0000 1.13 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/listener/InstrumentProcessListener.java 24 Oct 2008 09:25:43 -0000 >@@ -16,6 +16,8 @@ > import java.io.FileInputStream; > import java.io.FileNotFoundException; > import java.io.IOException; >+import java.io.InputStream; >+import java.net.InetAddress; > import java.nio.ByteBuffer; > import java.util.ArrayList; > import java.util.HashMap; >@@ -645,7 +647,7 @@ > fdataProcessor = (StatGeneratorDataProcessor) LoadersUtils.locateDataProcessor(agentProxy); > if (fdataProcessor == null) > { >- fdataProcessor = new StatGeneratorDataProcessor(agentProxy); >+ fdataProcessor = new FilterDataProcessor(agentProxy); > LoadersUtils.registerDataProcessor(agentProxy, fdataProcessor); > } > >@@ -737,7 +739,7 @@ > fdataProcessor = (StatGeneratorDataProcessor) LoadersUtils.locateDataProcessor(agentProxy); > if (fdataProcessor == null) > { >- fdataProcessor = new StatGeneratorDataProcessor(agentProxy); >+ fdataProcessor = new FilterDataProcessor(agentProxy); > LoadersUtils.registerDataProcessor(agentProxy, fdataProcessor); > } > >@@ -978,5 +980,34 @@ > return agentActive; > } > } >+ >+ >+ class FilterDataProcessor extends StatGeneratorDataProcessor >+ { >+ >+ public FilterDataProcessor(TRCAgentProxy agentProxy) { >+ super(agentProxy); >+ } >+ >+ public void incommingStream(InputStream inputStream, InetAddress peer) { >+ super.incommingStream(new FilterInputStream(inputStream), peer); >+ } >+ >+ } > >+ class FilterInputStream extends InputStream{ >+ >+ public FilterInputStream(InputStream inputStream) { >+ super(); >+ this.inputStream = inputStream; >+ } >+ >+ public int read() throws IOException { >+ int i = inputStream.read(); >+ System.out.print((char)i); >+ return i; >+ } >+ >+ private InputStream inputStream; >+ } > } >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/CombinedMetricProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/CombinedMetricProvider.java >diff -N src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/CombinedMetricProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/CombinedMetricProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,114 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: CombinedMetricProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.platform.instrumentation.ui.internal.core; >+ >+import java.util.List; >+ >+/** >+ * Combine implementation of {@link IMetricNameProvider}. >+ * >+ * @since TPTP 4.5.1 >+ * @author Gao Peng >+ * >+ */ >+public class CombinedMetricProvider implements IMetricNameProvider { >+ >+ /** >+ * Default ID because this implementation of {@link IMetricNameProvider} is >+ * not defined in plugin.xml. >+ */ >+ private static final String COMBINED_ID = "CombinedMetricProvider"; >+ >+ /** >+ * @param metricProviders >+ * Implemenations of {@link IMetricNameProvider} which will be >+ * combined. >+ */ >+ public CombinedMetricProvider(IMetricNameProvider[] metricProviders) { >+ this.metricProviders = metricProviders; >+ } >+ >+ /** >+ * @param metricProviderList >+ * Implemenations of {@link IMetricNameProvider} which will be >+ * combined. >+ */ >+ public CombinedMetricProvider(List metricProviderList) { >+ this.metricProviders = (IMetricNameProvider[]) metricProviderList >+ .toArray(new IMetricNameProvider[metricProviderList.size()]); >+ } >+ >+ public String getId() { >+ return id; >+ } >+ >+ public void setId(String id) { >+ this.id = id; >+ } >+ >+ /** >+ * It will return the name of all of the combined >+ * {@link IMetricNameProvider} implementations with the format : >+ * id,metricName >+ * >+ * @see org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider#getNames() >+ */ >+ public String[] getNames() { >+ if ((metricProviders == null) || (metricProviders.length == 0)) { >+ return null; >+ } >+ >+ String[] names = getFullName(metricProviders[0]); >+ for (int i = 1; i < metricProviders.length; i++) { >+ IMetricNameProvider metricProvider = metricProviders[i]; >+ String[] newNames = getFullName(metricProvider); >+ String[] combinedNames = new String[names.length + newNames.length]; >+ System.arraycopy(names, 0, combinedNames, 0, names.length); >+ System.arraycopy(newNames, names.length, combinedNames, >+ names.length, newNames.length); >+ names = combinedNames; >+ } >+ >+ return names; >+ } >+ >+ /** >+ * Get names with the ID of the metric provider. >+ * >+ * @param metricProvider >+ * @return >+ */ >+ private String[] getFullName(IMetricNameProvider metricProvider) { >+ String[] names = metricProvider.getNames(); >+ String[] fullNames = new String[names.length]; >+ String metricProviderId = metricProvider.getId(); >+ for (int i = 0; i < fullNames.length; i++) { >+ fullNames[i] = metricProviderId + IMetricNameProvider.SEPARATOR >+ + names[i]; >+ } >+ return fullNames; >+ } >+ >+ /** >+ * No metric value provider for this {@link IMetricNameProvider} >+ * implementation. >+ * >+ * @see org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider#getMetricValueProviderName() >+ */ >+ public String getMetricValueProviderName() { >+ return null; >+ } >+ >+ private IMetricNameProvider[] metricProviders; >+ private String id = COMBINED_ID; >+ >+} >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/IMetricNameProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/IMetricNameProvider.java >diff -N src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/IMetricNameProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/IMetricNameProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: IMetricNameProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.platform.instrumentation.ui.internal.core; >+ >+/** >+ * Interface for metricProvider extension point. >+ * >+ * @since TPTP 4.5.1 >+ * @author Gao Peng >+ * >+ */ >+public interface IMetricNameProvider { >+ >+ /** >+ * The separator between the metric information. >+ */ >+ String METRIC_SEPERATOR = "\t"; >+ >+ /** >+ * The separator between the parts of the metric information. >+ */ >+ String SEPARATOR = ","; >+ >+ /** >+ * The prefix of the key which used in ILaunchConfiguration. >+ */ >+ String METRIC_PREFIX = "METRIC_PREFIX"; >+ >+ /** >+ * @return the ID of the metric provider. >+ */ >+ String getId(); >+ >+ /** >+ * Set the ID of the metric provider. >+ */ >+ void setId(String id); >+ >+ /** >+ * @return the name list of the metric provider. The name should start with >+ * the id and SEPARATOR. >+ */ >+ String[] getNames(); >+ >+ /** >+ * Get the name of the metric value provider. It should be a quality class >+ * name and be used when profiling. <br> >+ * >+ * I have to split the name provider and the value provider because this >+ * plugin are not used in agent controller. >+ * >+ * @return >+ */ >+ String getMetricValueProviderName(); >+} >Index: schema/metricProvider.exsd >=================================================================== >RCS file: schema/metricProvider.exsd >diff -N schema/metricProvider.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/metricProvider.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,130 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.tptp.platform.instrumentation.ui" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appinfo> >+ <meta.schema plugin="org.eclipse.tptp.platform.instrumentation.ui" id="metricProvider" name="metricProvider"/> >+ </appinfo> >+ <documentation> >+ This extension point is used to register metric provider. The metric provider supports metric data. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appinfo> >+ <meta.element /> >+ </appinfo> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="metricProvider" minOccurs="1" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appinfo> >+ <meta.attribute translatable="true"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="metricProvider"> >+ <complexType> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="providerClass" type="string"> >+ <annotation> >+ <documentation> >+ Define the metric names provided by this implementation carefully. If there are duplicated names in multiply metricProvider, there is no guaratee that which metric names will be used in runmtime. >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="java" basedOn=":org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="since"/> >+ </appinfo> >+ <documentation> >+ Since TPTP 4.5.1 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="examples"/> >+ </appinfo> >+ <documentation> >+ <extension >+ point="org.eclipse.tptp.platform.instrumentation.ui.metricProvider"> >+ <metricProvider >+ id="org.eclipse.tptp.trace.arm.PttMetricProvider" >+ providerClass="org.eclipse.tptp.trace.arm.internal.model.impl.PttMetricNameProvider"> >+ </metricProvider> >+ </extension> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="apiinfo"/> >+ </appinfo> >+ <documentation> >+ [Enter API information here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="implementation"/> >+ </appinfo> >+ <documentation> >+ [Enter information about supplied implementation of this extension point.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="copyright"/> >+ </appinfo> >+ <documentation> >+ Copyright (c) 2008 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/MetricProviderManager.java >=================================================================== >RCS file: src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/MetricProviderManager.java >diff -N src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/MetricProviderManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/MetricProviderManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,120 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: MetricProviderManager.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.platform.instrumentation.ui.internal.core; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.LogHelper; >+ >+/** >+ * Manager of the metric provider. It scans for the metricProvider extensions >+ * and will register them with this manager. >+ * >+ * @since TPTP 4.5.1 >+ * @author Gao Peng >+ * >+ */ >+public class MetricProviderManager { >+ >+ /** The metric provider point extension */ >+ private static final String METRIC_PROVIDER_POINT_EXTENSION = "org.eclipse.tptp.platform.instrumentation.ui.metricProvider"; >+ >+ /** This instance of this singleton class */ >+ private static MetricProviderManager instance; >+ >+ /** >+ * Stores the {@link IMetricNameProvider} instances. <br> >+ * KEY = metric provider id. <br> >+ * VALUE = An instance of metric provider >+ */ >+ private Map metricProviders = new HashMap(); >+ >+ /** >+ * Hide the default constructor. This ensures against outside instantiation. >+ */ >+ private MetricProviderManager() { >+ initialize(); >+ } >+ >+ /** >+ * Scan the registered instrument points and loads them in the >+ * instrumentPoints table. >+ */ >+ public void initialize() { >+ metricProviders.clear(); >+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry() >+ .getExtensionPoint(METRIC_PROVIDER_POINT_EXTENSION); >+ >+ if (extensionPoint == null) { >+ return; >+ } >+ >+ IExtension extension[] = extensionPoint.getExtensions(); >+ >+ // Iterate through each instrument point element to construct the >+ // instrument object and to associate it with the right entity. >+ for (int i = 0; i < extension.length; i++) { >+ IConfigurationElement element[] = extension[i] >+ .getConfigurationElements(); >+ for (int j = 0; j < element.length; j++) { >+ try { >+ String id = element[j].getAttribute("id"); >+ IMetricNameProvider provider = (IMetricNameProvider) element[j] >+ .createExecutableExtension("providerClass"); >+ provider.setId(id); >+ metricProviders.put(id, provider); >+ } catch (Exception ex) { >+ // report the problem. >+ LogHelper.error(ex); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Returns the instance of this singleton class. >+ * >+ * @return The instance of this singleton class >+ */ >+ public static MetricProviderManager getInstance() { >+ if (instance == null) >+ instance = new MetricProviderManager(); >+ return instance; >+ } >+ >+ /** >+ * Returns all the registered InstrumentPoint >+ * >+ * @return an array of all the registered InstrumentPoint >+ */ >+ public IMetricNameProvider[] getMetricProviders() { >+ return (IMetricNameProvider[]) metricProviders.values().toArray( >+ new IMetricNameProvider[metricProviders.size()]); >+ } >+ >+ /** >+ * Returns an InstrumentPoint with a given id. >+ * >+ * @param id >+ * the id >+ * @return an InstrumentPoint >+ */ >+ public IMetricNameProvider getMetricProvider(String id) { >+ return (IMetricNameProvider) metricProviders.get(id); >+ } >+ >+} >#P org.eclipse.tptp.trace.arm.ui >Index: src/org/eclipse/tptp/trace/arm/ui/internal/util/messages.properties >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm.ui/src/org/eclipse/tptp/trace/arm/ui/internal/util/messages.properties,v >retrieving revision 1.15 >diff -u -r1.15 messages.properties >--- src/org/eclipse/tptp/trace/arm/ui/internal/util/messages.properties 11 Mar 2008 20:14:27 -0000 1.15 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/util/messages.properties 24 Oct 2008 09:25:57 -0000 >@@ -23,6 +23,7 @@ > NAME_COLUMN = Name > DESCP_COLUMN = Description > FILTER_LABEL = Filter >+METRIC_LABEL = Metric > NO_DESCP_LABEL = No description given > INTERNAL_ERROR = Internal error in ARM analysis type > >@@ -30,6 +31,7 @@ > ERROR_INSTRUMENT_EXIST_DETAIL = Occured in method: {0}()\n > > INSTRUMENT_POINT_FILTER_TITLE = Instrument Point Filter >+ARM_METRIC_TITLE = Available metric properties > > DEFAULT_SERVLET_FILTER = Default Servlet Filter Set > DEFAULT_JDBC_FILTER = Default JDBC Filter Set >Index: src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmMessages.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm.ui/src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmMessages.java,v >retrieving revision 1.12 >diff -u -r1.12 ArmMessages.java >--- src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmMessages.java 11 Mar 2008 20:14:27 -0000 1.12 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmMessages.java 24 Oct 2008 09:25:57 -0000 >@@ -34,11 +34,13 @@ > public static String NAME_COLUMN; > public static String DESCP_COLUMN; > public static String FILTER_LABEL; >+ public static String METRIC_LABEL; > public static String NO_DESCP_LABEL; > public static String INTERNAL_ERROR; > public static String ERROR_INTRUMENT_EXIST; > public static String ERROR_INSTRUMENT_EXIST_DETAIL; > public static String INSTRUMENT_POINT_FILTER_TITLE; >+ public static String ARM_METRIC_TITLE; > public static String DEFAULT_SERVLET_FILTER; > public static String DEFAULT_JDBC_FILTER; > public static String DEFAULT_J2EE_FILTER; >Index: src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmConstants.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm.ui/src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmConstants.java,v >retrieving revision 1.8 >diff -u -r1.8 ArmConstants.java >--- src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmConstants.java 16 Apr 2007 21:45:40 -0000 1.8 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmConstants.java 24 Oct 2008 09:25:57 -0000 >@@ -32,6 +32,8 @@ > public static final String TRANSACTION_GOOD_STATEMENT = "armStatus = " + ARM_TRANSACTION_GOOD_EXPRESSION + ";"; > public static final String TRANSACTION_FAILED_STATEMENT = "armStatus = " + ARM_TRANSACTION_FAILED_EXPRESSION + ";"; > >+ public static final String ARM_PREFIX_FOR_METRIC = "ARM"; >+ > public static final String ACTIVE_FILTER_PREFIX = "ACTIVE_FILTER_FOR_"; > public static final String ENABLE_FILTER_PREFIX = "ENABLE_FILTER_FOR_"; > public static final String FILTER_SET_PREFIX = "FILTER_SET_FOR_"; >Index: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/InstrumentPointSelectionUI.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.arm.ui/src/org/eclipse/tptp/trace/arm/ui/internal/configuration/InstrumentPointSelectionUI.java,v >retrieving revision 1.11 >diff -u -r1.11 InstrumentPointSelectionUI.java >--- src/org/eclipse/tptp/trace/arm/ui/internal/configuration/InstrumentPointSelectionUI.java 28 Feb 2008 16:41:50 -0000 1.11 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/configuration/InstrumentPointSelectionUI.java 24 Oct 2008 09:25:56 -0000 >@@ -12,6 +12,7 @@ > package org.eclipse.tptp.trace.arm.ui.internal.configuration; > > import java.util.ArrayList; >+import java.util.Arrays; > import java.util.List; > > import org.eclipse.debug.core.ILaunchConfiguration; >@@ -64,7 +65,8 @@ > /* The indexs for the points table */ > private final static int NAME_INDEX = 0; > private final static int FILTER_INDEX = 1; >- private final static int DESCRIPTION_INDEX = 2; >+ private final static int METRIC_INDEX = 2; >+ private final static int DESCRIPTION_INDEX = 3; > > private final static String ARM_INSTRUM_TYPE = > "org.eclipse.tptp.trace.arm.ui.armInstrumentType"; >@@ -101,7 +103,7 @@ > public void setSelectItems(List list) { > TableItem[] items = pointsTable.getItems(); > >- if (list != null || list.size() > 0) { >+ if (list != null && list.size() > 0) { > for (int i = 0; i < items.length; i++) { > InstrumentPoint entry = (InstrumentPoint) items[i].getData(); > if (list.contains(entry.getId())) { >@@ -149,6 +151,7 @@ > TableLayout tableLayout = new TableLayout(); > tableLayout.addColumnData(new ColumnWeightData(150, true)); > tableLayout.addColumnData(new ColumnWeightData(50, true)); >+ tableLayout.addColumnData(new ColumnWeightData(50, true)); > tableLayout.addColumnData(new ColumnWeightData(200, true)); > > pointsTable.setHeaderVisible(true); >@@ -170,10 +173,14 @@ > TableColumn tc2 = new TableColumn(pointsTable, SWT.NONE); > tc2.setText(ArmMessages.FILTER_LABEL); > tc2.setWidth(45); >- >+ > TableColumn tc3 = new TableColumn(pointsTable, SWT.NONE); >- tc3.setText(ArmMessages.DESCP_COLUMN); >- tc3.setWidth(200); >+ tc3.setText(ArmMessages.METRIC_LABEL); >+ tc3.setWidth(45); >+ >+ TableColumn tc4 = new TableColumn(pointsTable, SWT.NONE); >+ tc4.setText(ArmMessages.DESCP_COLUMN); >+ tc4.setWidth(200); > > InstrumentPoint loaders[] = > InstrumentPointManager.getInstance().getInstrumentPointsByType( >@@ -233,9 +240,17 @@ > protected void columnClicked(int columnToEdit) { > IStructuredSelection selection = (IStructuredSelection) pointsList.getSelection(); > InstrumentPoint vmd = (InstrumentPoint) selection.getFirstElement(); >- if (vmd != null && (columnToEdit == FILTER_INDEX)) { >- InstrumentPointFiltersDialog intrumentPointDlg = new InstrumentPointFiltersDialog(null, launchConfiguration, vmd.getId()); >- intrumentPointDlg.open(); >+ if (vmd != null) { >+ if (columnToEdit == FILTER_INDEX) { >+ InstrumentPointFiltersDialog intrumentPointDlg = new InstrumentPointFiltersDialog( >+ null, launchConfiguration, vmd.getId()); >+ intrumentPointDlg.open(); >+ } else if (columnToEdit == METRIC_INDEX) { >+ if (vmd.getMetricProvider() != null) { >+ ArmMetricsDialog armMetricsDialog = new ArmMetricsDialog(null, launchConfiguration, vmd); >+ armMetricsDialog.open(); >+ } >+ } > } > } > >@@ -245,7 +260,7 @@ > public class InstrumentPointLabelProvider extends LabelProvider implements ITableLabelProvider { > > public Image getColumnImage(Object element, int columnIndex) { >- if (columnIndex == FILTER_INDEX) { >+ if ((columnIndex == FILTER_INDEX)|| (columnIndex == METRIC_INDEX)) { > return ArmUIPlugin.getDefault().getImage("settings"); > } > return null; >Index: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricContentProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricContentProvider.java >diff -N src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: ArmMetricContentProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.ui.internal.configuration; >+ >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider; >+ >+/** >+ * Content provider of ArmMetricsDialog. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+public class ArmMetricContentProvider implements IStructuredContentProvider { >+ >+ public Object[] getElements(Object inputElement) { >+ return ((IMetricNameProvider) inputElement).getNames(); >+ } >+ >+ public void dispose() { >+ // Do nothing. >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ // Do nothing. >+ } >+} >Index: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricsDialog.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricsDialog.java >diff -N src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricsDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricsDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,174 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: ArmMetricsDialog.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.ui.internal.configuration; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.hyades.ui.util.GridUtil; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.viewers.CheckboxTableViewer; >+import org.eclipse.jface.viewers.ColumnLayoutData; >+import org.eclipse.jface.viewers.ColumnPixelData; >+import org.eclipse.jface.viewers.TableLayout; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.TableColumn; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider; >+import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPoint; >+import org.eclipse.tptp.trace.arm.ui.internal.util.ArmConstants; >+import org.eclipse.tptp.trace.arm.ui.internal.util.ArmMessages; >+ >+/** >+ * Dialog to get the configuration of metric. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ */ >+public class ArmMetricsDialog extends Dialog { >+ >+ public ArmMetricsDialog(Shell parentShell, >+ ILaunchConfiguration launchConfiguration, >+ InstrumentPoint instrumentPoint) { >+ super(parentShell); >+ setShellStyle(getShellStyle() | SWT.RESIZE); >+ >+ this.instrumentPoint = instrumentPoint; >+ this.launchConfiguration = launchConfiguration; >+ } >+ >+ protected Control createDialogArea(Composite parent) { >+ Composite result = (Composite) super.createDialogArea(parent); >+ >+ Composite tableGroup = new Composite(result, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 1; >+ tableGroup.setLayout(layout); >+ GridData data = GridUtil.createFill(); >+ data.heightHint = 100; >+ >+ tableGroup.setLayoutData(data); >+ Table filterSetTable = new Table(tableGroup, SWT.V_SCROLL | SWT.BORDER >+ | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK); >+ filterSetTable.setLinesVisible(false); >+ filterSetTable.setLayoutData(GridUtil.createFill()); >+ >+ armTableViewer = new CheckboxTableViewer(filterSetTable); >+ armTableViewer.setContentProvider(new ArmMetricContentProvider()); >+ armTableViewer.setLabelProvider(new ArmMetricLabelProvider()); >+ armTableViewer.setInput(instrumentPoint.getMetricProvider()); >+ >+ TableLayout layoutt = new TableLayout(); >+ filterSetTable.setLayout(layoutt); >+ >+ ColumnLayoutData l = new ColumnPixelData(420, true); >+ layoutt.addColumnData(l); >+ >+ TableColumn tc = new TableColumn(filterSetTable, SWT.NONE, 0); >+ tc.setResizable(l.resizable); >+ >+ configUI(); >+ >+ return result; >+ } >+ >+ /** >+ * Load configuration of metric from ILaunchConfiguration and setup Table in >+ * dialog. >+ */ >+ private void configUI() { >+ try { >+ String checkedMetrics = launchConfiguration.getAttribute( >+ getArmKey(), ""); >+ if (!checkedMetrics.equals("")) { >+ armTableViewer.setCheckedElements(checkedMetrics >+ .split(IMetricNameProvider.METRIC_SEPERATOR)); >+ } >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ } >+ } >+ >+ /** >+ * Override to double the dialog size. >+ * >+ * @see org.eclipse.jface.dialogs.Dialog#getInitialSize() >+ */ >+ protected Point getInitialSize() { >+ Point size = super.getInitialSize(); >+ // Double the size of the dialog. >+ Point doubleSize = new Point(size.x * 2, size.y * 2); >+ return doubleSize; >+ } >+ >+ /** >+ * Get the configuration of the metric, and save it in ILaunchConfiguration. >+ */ >+ protected void okPressed() { >+ if (launchConfiguration instanceof ILaunchConfigurationWorkingCopy) { >+ ILaunchConfigurationWorkingCopy workingCopy = (ILaunchConfigurationWorkingCopy) launchConfiguration; >+ >+ StringBuffer buffer = new StringBuffer(); >+ for (int i = 0; i < armTableViewer.getCheckedElements().length; i++) { >+ String element = (String) armTableViewer.getCheckedElements()[i]; >+ buffer.append(element).append( >+ IMetricNameProvider.METRIC_SEPERATOR); >+ } >+ >+ if (buffer.length() == 0) { >+ workingCopy.removeAttribute(getArmKey()); >+ } else { >+ workingCopy.setAttribute(getArmKey(), buffer.toString()); >+ } >+ } >+ >+ super.okPressed(); >+ } >+ >+ /** >+ * Get the key to store metric information in ILaunchConfiguration. >+ * >+ * @return >+ */ >+ private String getArmKey() { >+ return IMetricNameProvider.METRIC_PREFIX >+ + IMetricNameProvider.SEPARATOR >+ + ArmConstants.ARM_PREFIX_FOR_METRIC >+ + IMetricNameProvider.SEPARATOR + instrumentPoint.getId(); >+ } >+ >+ protected void configureShell(Shell newShell) { >+ super.configureShell(newShell); >+ newShell.setText(ArmMessages.ARM_METRIC_TITLE); >+ } >+ >+ /** >+ * ILaunchConfiguration of the workbench. >+ */ >+ private ILaunchConfiguration launchConfiguration; >+ >+ /** >+ * InstrumentPoint about the metric. >+ */ >+ private InstrumentPoint instrumentPoint; >+ >+ /** >+ * CheckboxTableViewer of the Table in dialog. >+ */ >+ private CheckboxTableViewer armTableViewer; >+} >Index: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricLabelProvider.java >diff -N src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: ArmMetricLabelProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.trace.arm.ui.internal.configuration; >+ >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.swt.graphics.Image; >+ >+/** >+ * Label provider of ArmMetricsDialog. >+ * >+ * @author Gao Peng >+ * @since TPTP 4.5.1 >+ * >+ */ >+public class ArmMetricLabelProvider extends LabelProvider implements >+ ITableLabelProvider { >+ >+ public Image getColumnImage(Object element, int columnIndex) { >+ // No image. >+ return null; >+ } >+ >+ public String getColumnText(Object element, int columnIndex) { >+ return (String) element; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 166692
:
116824
|
118588
|
118589