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

Collapse All | Expand All

(-)src-probes/GenericArm_probe.java (-1 / +1 lines)
Lines 16-22 Link Here
16
 * are made available under the terms of the Eclipse Public License v1.0
16
 * are made available under the terms of the Eclipse Public License v1.0
17
 * which accompanies this distribution, and is available at
17
 * which accompanies this distribution, and is available at
18
 * http://www.eclipse.org/legal/epl-v10.html
18
 * http://www.eclipse.org/legal/epl-v10.html
19
 * $Id: GenericArm_probe.java,v 1.11 2007/08/30 21:35:32 apatel Exp $
19
 * $Id: GenericArm.probe,v 1.10 2007/08/30 21:35:32 apatel Exp $
20
 * 
20
 * 
21
 * Contributors: 
21
 * Contributors: 
22
 * IBM - Initial API and implementation
22
 * IBM - Initial API and implementation
(-)src-probes/Servlet_probe.java (-1 / +1 lines)
Lines 16-22 Link Here
16
 * are made available under the terms of the Eclipse Public License v1.0
16
 * are made available under the terms of the Eclipse Public License v1.0
17
 * which accompanies this distribution, and is available at
17
 * which accompanies this distribution, and is available at
18
 * http://www.eclipse.org/legal/epl-v10.html
18
 * http://www.eclipse.org/legal/epl-v10.html
19
 * $Id: Servlet_probe.java,v 1.10 2007/08/31 19:26:27 apatel Exp $
19
 * $Id: Servlet.probe,v 1.8 2007/08/10 22:40:55 apatel Exp $
20
 * 
20
 * 
21
 * Contributors: 
21
 * Contributors: 
22
 * IBM - Initial API and implementation
22
 * IBM - Initial API and implementation
(-)src-probes/EJB_probe.java (-1 / +1 lines)
Lines 16-22 Link Here
16
 * are made available under the terms of the Eclipse Public License v1.0
16
 * are made available under the terms of the Eclipse Public License v1.0
17
 * which accompanies this distribution, and is available at
17
 * which accompanies this distribution, and is available at
18
 * http://www.eclipse.org/legal/epl-v10.html
18
 * http://www.eclipse.org/legal/epl-v10.html
19
 * $Id: EJB_probe.java,v 1.8 2007/08/10 22:41:50 apatel Exp $
19
 * $Id: EJB.probe,v 1.7 2007/08/10 22:40:54 apatel Exp $
20
 * 
20
 * 
21
 * Contributors: 
21
 * Contributors: 
22
 * IBM - Initial API and implementation
22
 * IBM - Initial API and implementation
(-)src-probes/JDBC_probe.java (-1 / +1 lines)
Lines 14-20 Link Here
14
 * are made available under the terms of the Eclipse Public License v1.0
14
 * are made available under the terms of the Eclipse Public License v1.0
15
 * which accompanies this distribution, and is available at
15
 * which accompanies this distribution, and is available at
16
 * http://www.eclipse.org/legal/epl-v10.html
16
 * http://www.eclipse.org/legal/epl-v10.html
17
 * $Id: JDBC_probe.java,v 1.7 2007/08/10 22:41:50 apatel Exp $
17
 * $Id: JDBC.probe,v 1.5 2007/08/10 22:40:54 apatel Exp $
18
 * 
18
 * 
19
 * Contributors: 
19
 * Contributors: 
20
 * IBM - Initial API and implementation
20
 * IBM - Initial API and implementation
(-)src-model/org/eclipse/tptp/trace/arm/internal/model/ArmInstrument.java (-7 / +332 lines)
Lines 11-21 Link Here
11
 ***********************************************************************/
11
 ***********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.model;
12
package org.eclipse.tptp.trace.arm.internal.model;
13
13
14
import java.util.ArrayList;
14
import java.util.HashMap;
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.List;
15
import java.util.Properties;
18
import java.util.Properties;
16
19
17
import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger;
20
import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger;
21
import org.opengroup.arm40.metric.ArmMetric;
22
import org.opengroup.arm40.metric.ArmMetricCounter32;
23
import org.opengroup.arm40.metric.ArmMetricCounter32Definition;
24
import org.opengroup.arm40.metric.ArmMetricCounter64;
25
import org.opengroup.arm40.metric.ArmMetricCounter64Definition;
26
import org.opengroup.arm40.metric.ArmMetricCounterFloat32;
27
import org.opengroup.arm40.metric.ArmMetricCounterFloat32Definition;
28
import org.opengroup.arm40.metric.ArmMetricDefinition;
18
import org.opengroup.arm40.metric.ArmMetricFactory;
29
import org.opengroup.arm40.metric.ArmMetricFactory;
30
import org.opengroup.arm40.metric.ArmMetricGauge32;
31
import org.opengroup.arm40.metric.ArmMetricGauge32Definition;
32
import org.opengroup.arm40.metric.ArmMetricGauge64;
33
import org.opengroup.arm40.metric.ArmMetricGauge64Definition;
34
import org.opengroup.arm40.metric.ArmMetricGaugeFloat32;
35
import org.opengroup.arm40.metric.ArmMetricGaugeFloat32Definition;
36
import org.opengroup.arm40.metric.ArmMetricGroup;
37
import org.opengroup.arm40.metric.ArmMetricGroupDefinition;
38
import org.opengroup.arm40.metric.ArmMetricNumericId32;
39
import org.opengroup.arm40.metric.ArmMetricNumericId32Definition;
40
import org.opengroup.arm40.metric.ArmMetricNumericId64;
41
import org.opengroup.arm40.metric.ArmMetricNumericId64Definition;
42
import org.opengroup.arm40.metric.ArmMetricString32;
43
import org.opengroup.arm40.metric.ArmMetricString32Definition;
44
import org.opengroup.arm40.metric.ArmTransactionWithMetrics;
45
import org.opengroup.arm40.metric.ArmTransactionWithMetricsDefinition;
19
import org.opengroup.arm40.tranreport.ArmTranReport;
46
import org.opengroup.arm40.tranreport.ArmTranReport;
20
import org.opengroup.arm40.tranreport.ArmTranReportFactory;
47
import org.opengroup.arm40.tranreport.ArmTranReportFactory;
21
import org.opengroup.arm40.transaction.ArmApplication;
48
import org.opengroup.arm40.transaction.ArmApplication;
Lines 53-61 Link Here
53
80
54
	/* The ARM 4.0 Application Instance for the TT product. */
81
	/* The ARM 4.0 Application Instance for the TT product. */
55
	private ArmApplication applicationInstance;
82
	private ArmApplication applicationInstance;
56
	
83
57
	/* Internal cache of the ARM 4.0 identity properties */
84
	/* Internal cache of the ARM 4.0 identity properties : ArmTransactionDefinition*/
58
	private HashMap armTranDefCache = new HashMap(30); 
85
	private HashMap armTranDefCache = new HashMap(30); 
86
87
	/* Internal cache of the ARM 4.0 identity properties : ArmTransactionWithMetricsDefinition*/
88
	private HashMap armTranWithMetricDefCache = new HashMap(30); 
59
	
89
	
60
	/* The ARM 4.0 Error handler */
90
	/* The ARM 4.0 Error handler */
61
	private ArmErrorCallback armErrorCallBack;
91
	private ArmErrorCallback armErrorCallBack;
Lines 102-107 Link Here
102
						.newInstance();
132
						.newInstance();
103
				tranFactory.setErrorCallback(armErrorCallBack);
133
				tranFactory.setErrorCallback(armErrorCallBack);
104
			} catch (Exception ex) {
134
			} catch (Exception ex) {
135
				ex.printStackTrace();
105
				/* If error, then null */
136
				/* If error, then null */
106
				tranFactory = null;
137
				tranFactory = null;
107
				/* ArmTransFactoryInit_ERROR = IWAT0766E */
138
				/* ArmTransFactoryInit_ERROR = IWAT0766E */
Lines 109-114 Link Here
109
						ArmInstrumentMessages.getString("ArmTransFactoryInit_ERROR"),
140
						ArmInstrumentMessages.getString("ArmTransFactoryInit_ERROR"),
110
						ARMLogger.LOG, ex);
141
						ARMLogger.LOG, ex);
111
			}
142
			}
143
			catch(Throwable t)
144
			{
145
				t.printStackTrace();
146
			}
112
		}
147
		}
113
		
148
		
114
		return tranFactory;
149
		return tranFactory;
Lines 152-158 Link Here
152
	 * @return the ArmMetricFactory.
187
	 * @return the ArmMetricFactory.
153
	 */
188
	 */
154
	private ArmMetricFactory getArmMetricFactory() {
189
	private ArmMetricFactory getArmMetricFactory() {
155
		if (metricFactory != null) {
190
		if (metricFactory == null) {
156
			/* Check for the metric factory */
191
			/* Check for the metric factory */
157
			try {
192
			try {
158
				Properties p = System.getProperties();
193
				Properties p = System.getProperties();
Lines 262-274 Link Here
262
	 */
297
	 */
263
	public ArmTransaction transactionStart(InstrumentDataProvider data, 
298
	public ArmTransaction transactionStart(InstrumentDataProvider data, 
264
			ArmCorrelator parentCorrelator) {
299
			ArmCorrelator parentCorrelator) {
265
		
266
		ArmTransaction armTransaction = null;
300
		ArmTransaction armTransaction = null;
267
		
301
		
268
		if (tranFactory != null) {
302
		if (tranFactory != null) {
269
			ArmTransactionDefinition armTranDef = getArmTransactionDefinition(data);
303
			// create ArmTransaction/ArmTransactionWithMetric instance if there
270
			armTransaction = tranFactory.newArmTransaction(getArmApplication(),
304
			// is/isn't ARM metric.
271
					armTranDef);
305
			if (ArmMetricManager.getInstance().hasMetric()) {		
306
				try {
307
					armTransaction = getArmTransactionWithMetric(data);
308
				} catch (Throwable e) {
309
					// TODO Auto-generated catch block
310
					e.printStackTrace();
311
				}
312
			} else {
313
				ArmTransactionDefinition armTranDef = getArmTransactionDefinition(data);
314
				armTransaction = tranFactory.newArmTransaction(
315
						getArmApplication(), armTranDef);
316
			}
272
			
317
			
273
			String[] contextValues = data.getContextValues();
318
			String[] contextValues = data.getContextValues();
274
			for (int i = 0; i < contextValues.length; i++) {
319
			for (int i = 0; i < contextValues.length; i++) {
Lines 283-288 Link Here
283
			armTransaction.setUser(tranFactory.newArmUser(
328
			armTransaction.setUser(tranFactory.newArmUser(
284
					data.getUserName() == null ? "*" : data.getUserName(), null));
329
					data.getUserName() == null ? "*" : data.getUserName(), null));
285
			
330
			
331
			
286
			if (parentCorrelator == null) {
332
			if (parentCorrelator == null) {
287
				armTransaction.start();
333
				armTransaction.start();
288
			} else {
334
			} else {
Lines 294-299 Link Here
294
	} // end of transactionStart()
340
	} // end of transactionStart()
295
341
296
	/**
342
	/**
343
	 * Create an ArmTransactionWithMetrics instance.
344
	 * 
345
	 * @param data
346
	 * @return
347
	 */
348
	private ArmTransactionWithMetrics getArmTransactionWithMetric(
349
			InstrumentDataProvider data) {
350
		if (metricFactory == null) {
351
			getArmMetricFactory();
352
		}
353
354
		String transName = data.getTransactionName();
355
		ArmTransactionWithMetrics transactionWithMetrics = null;
356
		if (metricFactory != null) {
357
			synchronized (armTranWithMetricDefCache) {
358
				if (metricFactory != null) {
359
					List metrics = ArmMetricManager.getInstance().getMetrics();
360
					ArmTransactionWithMetricsDefinition transactionWithMetricsDef = getArmTransactionWithMetricDefinition(
361
							transName, metrics);
362
					transactionWithMetrics = getArmTransactionWithMetric(
363
							transName, metrics, transactionWithMetricsDef);
364
				}
365
			}
366
		}
367
368
		return transactionWithMetrics;
369
	}
370
371
	/**
372
	 * Create an ArmTransactionWithMetricsDefinition instance. Maybe should use
373
	 * cache here.
374
	 * 
375
	 * @param transName
376
	 * @param metrics
377
	 * @return
378
	 */
379
	private ArmTransactionWithMetricsDefinition getArmTransactionWithMetricDefinition(
380
			String transName, List metrics) {
381
		ArmTransactionWithMetricsDefinition transactionWithMetricsDef;
382
		List metricsDef = getArmMetricDefs(metrics);
383
384
		ArmMetricDefinition[] metricDefArray = (ArmMetricDefinition[]) metricsDef
385
				.toArray(new ArmMetricDefinition[metricsDef.size()]);
386
387
		ArmMetricGroupDefinition metGroupDef = metricFactory
388
				.newArmMetricGroupDefinition(metricDefArray);
389
390
		transactionWithMetricsDef = (ArmTransactionWithMetricsDefinition) armTranWithMetricDefCache
391
				.get(transName);
392
393
		if (transactionWithMetricsDef == null) {
394
			transactionWithMetricsDef = metricFactory
395
					.newArmTransactionWithMetricsDefinition(
396
							getArmApplicationDefinition(), transName, null,
397
							metGroupDef, null);
398
399
			armTranWithMetricDefCache.put(transName, transactionWithMetricsDef);
400
		}
401
		return transactionWithMetricsDef;
402
	}
403
404
	/**
405
	 * Get the ArmMetricDefinition instances. The elements of parameter metrics
406
	 * will be updated to match the metric and it's definition.<br>
407
	 * TODO Move switch-case here to some other place. For example, another
408
	 * classes. switch-case is not good coding style.
409
	 * 
410
	 * @param metrics
411
	 *            List of ArmMetricManager.Metric.
412
	 * @return List of ArmMetricDefinition.
413
	 */
414
	private List getArmMetricDefs(List metrics) {
415
		List metricDefs = new ArrayList();
416
		for (Iterator iterator = metrics.iterator(); iterator.hasNext();) {
417
			ArmMetricManager.Metric metric = (ArmMetricManager.Metric) iterator
418
					.next();
419
			ArmMetricDefinition metricDefinition = metric.getDefinition();
420
			if (metricDefinition == null) {
421
				// Big switch-case to create ArmMetricDefinition instance.
422
				switch (metric.getMetricType()) {
423
				case ArmMetricConstants.ArmMetricCounter32:
424
					metricDefinition = metricFactory
425
							.newArmMetricCounter32Definition(
426
									getArmApplicationDefinition(), metric
427
											.getMetricName(), null,
428
									ArmMetricDefinition.METRIC_USE_GENERAL,
429
									null);
430
					break;
431
				case ArmMetricConstants.ArmMetricCounter64:
432
					metricDefinition = metricFactory
433
							.newArmMetricCounter64Definition(
434
									getArmApplicationDefinition(), metric
435
											.getMetricName(), null,
436
									ArmMetricDefinition.METRIC_USE_GENERAL,
437
									null);
438
					break;
439
				case ArmMetricConstants.ArmMetricCounterFloat32:
440
					metricDefinition = metricFactory
441
							.newArmMetricCounterFloat32Definition(
442
									getArmApplicationDefinition(), metric
443
											.getMetricName(), null,
444
									ArmMetricDefinition.METRIC_USE_GENERAL,
445
									null);
446
					break;
447
				case ArmMetricConstants.ArmMetricGauge32:
448
					metricDefinition = metricFactory
449
							.newArmMetricGauge32Definition(
450
									getArmApplicationDefinition(), metric
451
											.getMetricName(), null,
452
									ArmMetricDefinition.METRIC_USE_GENERAL,
453
									null);
454
					break;
455
				case ArmMetricConstants.ArmMetricGauge64:
456
					metricDefinition = metricFactory
457
							.newArmMetricGauge64Definition(
458
									getArmApplicationDefinition(), metric
459
											.getMetricName(), null,
460
									ArmMetricDefinition.METRIC_USE_GENERAL,
461
									null);
462
					break;
463
				case ArmMetricConstants.ArmMetricGaugeFloat32:
464
					metricDefinition = metricFactory
465
							.newArmMetricGaugeFloat32Definition(
466
									getArmApplicationDefinition(), metric
467
											.getMetricName(), null,
468
									ArmMetricDefinition.METRIC_USE_GENERAL,
469
									null);
470
					break;
471
				case ArmMetricConstants.ArmMetricNumericId32:
472
					metricDefinition = metricFactory
473
							.newArmMetricNumericId32Definition(
474
									getArmApplicationDefinition(), metric
475
											.getMetricName(), null,
476
									ArmMetricDefinition.METRIC_USE_GENERAL,
477
									null);
478
					break;
479
				case ArmMetricConstants.ArmMetricNumericId64:
480
					metricDefinition = metricFactory
481
							.newArmMetricNumericId64Definition(
482
									getArmApplicationDefinition(), metric
483
											.getMetricName(), null,
484
									ArmMetricDefinition.METRIC_USE_GENERAL,
485
									null);
486
					break;
487
				case ArmMetricConstants.ArmMetricString32:
488
					metricDefinition = metricFactory
489
							.newArmMetricString32Definition(
490
									getArmApplicationDefinition(), metric
491
											.getMetricName(), null,
492
									ArmMetricDefinition.METRIC_USE_GENERAL,
493
									null);
494
					break;
495
				default:
496
					metricDefinition = null;
497
					break;
498
				}
499
			}
500
			if (metricDefinition != null) {
501
				metricDefs.add(metricDefinition);
502
				metric.setDefinition(metricDefinition);
503
			}
504
		}
505
		return metricDefs;
506
	}
507
508
	/**
509
	 * Create an ArmTransactionWithMetrics instance.
510
	 * 
511
	 * @param transName
512
	 * @param metrics
513
	 * @param transactionWithMetricsDef
514
	 * @return
515
	 */
516
	private ArmTransactionWithMetrics getArmTransactionWithMetric(
517
			String transName, List metrics,
518
			ArmTransactionWithMetricsDefinition transactionWithMetricsDef) {
519
		ArmTransactionWithMetrics transactionWithMetrics;
520
		List armMetrics = getArmMetric(metrics);
521
522
		ArmMetric[] metricDefArray = (ArmMetric[]) armMetrics
523
				.toArray(new ArmMetric[armMetrics.size()]);
524
525
		ArmMetricGroup metGroup = metricFactory.newArmMetricGroup(
526
				transactionWithMetricsDef.getMetricGroupDefinition(),
527
				metricDefArray);
528
529
		transactionWithMetrics = metricFactory.newArmTransactionWithMetrics(
530
				getArmApplication(), transactionWithMetricsDef, metGroup);
531
532
		return transactionWithMetrics;
533
	}
534
535
	/**
536
	 * Get the ArmMetricDefinition instances.<br>
537
	 * TODO Move switch-case here to some other place. For example, another
538
	 * classes. switch-case is not good coding style.
539
	 * 
540
	 * @param metrics
541
	 *            List of ArmMetricManager.Metric.
542
	 * @return List of ArmMetric.
543
	 */
544
	private List getArmMetric(List metrics) {
545
		List armMetrics = new ArrayList();
546
		for (Iterator iterator = metrics.iterator(); iterator.hasNext();) {
547
			ArmMetricManager.Metric metric = (ArmMetricManager.Metric) iterator
548
					.next();
549
			ArmMetric armMetric = null;
550
			ArmMetricDefinition metricDefinition = metric.getDefinition();
551
			if (metricDefinition != null) {
552
				String metricValue = metric.getMetricValue();
553
				// Big switch-case to create ArmMetric instance.
554
				switch (metric.getMetricType()) {
555
				case ArmMetricConstants.ArmMetricCounter32:
556
					ArmMetricCounter32 armMetricCounter32 = metricFactory
557
							.newArmMetricCounter32((ArmMetricCounter32Definition) metricDefinition);
558
					armMetricCounter32.set(Integer.parseInt(metricValue));
559
					armMetric = armMetricCounter32;
560
					break;
561
				case ArmMetricConstants.ArmMetricCounter64:
562
					ArmMetricCounter64 armMetricCounter64 = metricFactory
563
							.newArmMetricCounter64((ArmMetricCounter64Definition) metricDefinition);
564
					armMetricCounter64.set(Long.parseLong(metricValue));
565
					armMetric = armMetricCounter64;
566
					break;
567
				case ArmMetricConstants.ArmMetricCounterFloat32:
568
					ArmMetricCounterFloat32 armMetricCounterFloat32 = metricFactory
569
							.newArmMetricCounterFloat32((ArmMetricCounterFloat32Definition) metricDefinition);
570
					armMetricCounterFloat32.set(Float.parseFloat(metricValue));
571
					armMetric = armMetricCounterFloat32;
572
					break;
573
				case ArmMetricConstants.ArmMetricGauge32:
574
					ArmMetricGauge32 armMetricGauge32 = metricFactory
575
							.newArmMetricGauge32((ArmMetricGauge32Definition) metricDefinition);
576
					armMetricGauge32.set(Integer.parseInt(metricValue));
577
					armMetric = armMetricGauge32;
578
					break;
579
				case ArmMetricConstants.ArmMetricGauge64:
580
					ArmMetricGauge64 armMetricGauge64 = metricFactory
581
							.newArmMetricGauge64((ArmMetricGauge64Definition) metricDefinition);
582
					armMetricGauge64.set(Long.parseLong(metricValue));
583
					armMetric = armMetricGauge64;
584
					break;
585
				case ArmMetricConstants.ArmMetricGaugeFloat32:
586
					ArmMetricGaugeFloat32 armMetricGaugeFloat32 = metricFactory
587
							.newArmMetricGaugeFloat32((ArmMetricGaugeFloat32Definition) metricDefinition);
588
					armMetricGaugeFloat32.set(Float.parseFloat(metricValue));
589
					armMetric = armMetricGaugeFloat32;
590
					break;
591
				case ArmMetricConstants.ArmMetricNumericId32:
592
					ArmMetricNumericId32 armMetricNumericId32 = metricFactory
593
							.newArmMetricNumericId32((ArmMetricNumericId32Definition) metricDefinition);
594
					armMetricNumericId32.set(Integer.parseInt(metricValue));
595
					armMetric = armMetricNumericId32;
596
					break;
597
				case ArmMetricConstants.ArmMetricNumericId64:
598
					ArmMetricNumericId64 armMetricNumericId64 = metricFactory
599
							.newArmMetricNumericId64((ArmMetricNumericId64Definition) metricDefinition);
600
					armMetricNumericId64.set(Long.parseLong(metricValue));
601
					armMetric = armMetricNumericId64;
602
					break;
603
				case ArmMetricConstants.ArmMetricString32:
604
					ArmMetricString32 armMetricString32 = metricFactory
605
							.newArmMetricString32((ArmMetricString32Definition) metricDefinition);
606
					armMetricString32.set(metricValue);
607
					armMetric = armMetricString32;
608
					break;
609
				default:
610
					armMetric = null;
611
					break;
612
				}
613
			}
614
			if (armMetric != null) {
615
				armMetrics.add(armMetric);
616
			}
617
		}
618
		return armMetrics;
619
	}
620
621
	/**
297
	 * The wrapper method for the arm stop() call.
622
	 * The wrapper method for the arm stop() call.
298
	 * 
623
	 * 
299
	 * @param transaction the transaction data
624
	 * @param transaction the transaction data
(-).classpath (-1 / +3 lines)
Lines 9-15 Link Here
9
	<classpathentry kind="src" path="src-model"/>
9
	<classpathentry kind="src" path="src-model"/>
10
	<classpathentry kind="src" path="src-logging"/>
10
	<classpathentry kind="src" path="src-logging"/>
11
	<classpathentry kind="src" path="src-loader"/>
11
	<classpathentry kind="src" path="src-loader"/>
12
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
12
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/IBM Java50"/>
13
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
13
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
14
	<classpathentry kind="lib" path="external-jars/j2ee-arm.jar"/>
15
	<classpathentry kind="lib" path="JPerf.jar"/>
14
	<classpathentry kind="output" path="bin"/>
16
	<classpathentry kind="output" path="bin"/>
15
</classpath>
17
</classpath>
(-)plugin.xml (-1 / +13 lines)
Lines 23-29 Link Here
23
            instrumentTypeId="org.eclipse.tptp.trace.arm.ui.armInstrumentType"
23
            instrumentTypeId="org.eclipse.tptp.trace.arm.ui.armInstrumentType"
24
            name="Generic Probe"
24
            name="Generic Probe"
25
            script="GenericArm.probescript"
25
            script="GenericArm.probescript"
26
            type="probe"/>
26
            type="probe">
27
         <metricProviders>
28
            <metricProvider
29
                  metricProviderIdRef="org.eclipse.tptp.trace.arm.PttMetricProvider"></metricProvider>
30
         </metricProviders>
31
      </instrumentPoint>
27
      <instrumentPoint
32
      <instrumentPoint
28
            description="Collects ARM data for Java Servlets."
33
            description="Collects ARM data for Java Servlets."
29
            id="org.eclipse.tptp.trace.arm.probes.j2ee.servlet"
34
            id="org.eclipse.tptp.trace.arm.probes.j2ee.servlet"
Lines 56-60 Link Here
56
            name="Generic Aspect"
61
            name="Generic Aspect"
57
            type="aspect"/>
62
            type="aspect"/>
58
   </extension>
63
   </extension>
64
   <extension
65
         point="org.eclipse.tptp.platform.instrumentation.ui.metricProvider">
66
      <metricProvider
67
            id="org.eclipse.tptp.trace.arm.PttMetricProvider"
68
            providerClass="org.eclipse.tptp.trace.arm.internal.model.impl.PttMetricNameProvider">
69
      </metricProvider>
70
   </extension>
59
71
60
</plugin>
72
</plugin>
(-)build.properties (-1 / +2 lines)
Lines 29-35 Link Here
29
               src-probes/GenericArm.probescript,\
29
               src-probes/GenericArm.probescript,\
30
               src-probes/Servlet.probescript,\
30
               src-probes/Servlet.probescript,\
31
               src-probes/JDBC.probescript,\
31
               src-probes/JDBC.probescript,\
32
               armAspects.jar
32
               armAspects.jar,\
33
               JPerf.jar
33
jars.extra.classpath = ../../external-jars/j2ee-arm.jar
34
jars.extra.classpath = ../../external-jars/j2ee-arm.jar
34
source.config.jar = src-config/
35
source.config.jar = src-config/
35
output.config.jar = bin/
36
output.config.jar = bin/
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 24-28 Link Here
24
 cbeLogging.jar,
24
 cbeLogging.jar,
25
 armLibrary.jar,
25
 armLibrary.jar,
26
 armModel.jar,
26
 armModel.jar,
27
 armProbes.jar
27
 armProbes.jar,
28
 JPerf.jar
28
Bundle-RequiredExecutionEnvironment: J2SE-1.4
29
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmEventFactory.java (-2 / +42 lines)
Lines 20-25 Link Here
20
import org.eclipse.tptp.trace.arm.internal.transaction.ArmIdentityPropertiesImpl;
20
import org.eclipse.tptp.trace.arm.internal.transaction.ArmIdentityPropertiesImpl;
21
import org.eclipse.tptp.trace.arm.internal.transaction.ArmTransactionImpl;
21
import org.eclipse.tptp.trace.arm.internal.transaction.ArmTransactionImpl;
22
import org.eclipse.tptp.trace.arm.internal.util.ArmIdentityProperty;
22
import org.eclipse.tptp.trace.arm.internal.util.ArmIdentityProperty;
23
import org.opengroup.arm40.metric.ArmMetricGroup;
24
import org.opengroup.arm40.metric.ArmTransactionWithMetrics;
23
import org.opengroup.arm40.transaction.ArmApplication;
25
import org.opengroup.arm40.transaction.ArmApplication;
24
import org.opengroup.arm40.transaction.ArmApplicationDefinition;
26
import org.opengroup.arm40.transaction.ArmApplicationDefinition;
25
import org.opengroup.arm40.transaction.ArmCorrelator;
27
import org.opengroup.arm40.transaction.ArmCorrelator;
Lines 37-51 Link Here
37
public class TPTPArmEventFactory {
39
public class TPTPArmEventFactory {
38
40
39
	/**
41
	/**
40
	 * 
41
	 * @param transaction
42
	 * @param transaction
42
	 * @return
43
	 * @return
43
	 */
44
	 */
44
	public static TPTPStartArmEvent newStartEvent(ArmTransaction transaction) {
45
	public static TPTPStartArmEvent newStartEvent(ArmTransaction transaction) {
45
		return new TPTPStartArmEventImpl(transaction);
46
		if (transaction instanceof ArmTransactionWithMetrics) {
47
			ArmTransactionWithMetrics transactionWithMetrics = (ArmTransactionWithMetrics) transaction;
48
			return newStartMetricEvent(transactionWithMetrics);
49
		} else {
50
			return new TPTPStartArmEventImpl(transaction);
51
		}
46
	}
52
	}
47
53
48
	/**
54
	/**
55
	 * Create TPTPStartArmEvent instance. This instance will be the
56
	 * implementation with metric.
57
	 * 
58
	 * @param transaction
59
	 * @return
60
	 */
61
	public static TPTPStartArmEvent newStartMetricEvent(ArmTransactionWithMetrics transaction) {
62
		return new TPTPStartArmMetricEventImpl(transaction);
63
	}
64
	
65
	/**
49
	 * 
66
	 * 
50
	 * @param transaction
67
	 * @param transaction
51
	 * @return
68
	 * @return
Lines 70-76 Link Here
70
			super(transaction, ((ArmTransactionImpl) transaction)
87
			super(transaction, ((ArmTransactionImpl) transaction)
71
					.getArrivalTime());
88
					.getArrivalTime());
72
		}
89
		}
90
	}
91
92
	/**
93
	 * Just extend to support metric.
94
	 * 
95
	 * @author Gao Peng
96
	 * @since TPTP 4.5.1
97
	 *
98
	 */
99
	private static class TPTPStartArmMetricEventImpl extends TPTPStartArmEventImpl
100
			implements TPTPArmMetricEvent {
101
102
		public TPTPStartArmMetricEventImpl(ArmTransactionWithMetrics transaction) {
103
			super(transaction);
104
			this.metricGroup = transaction.getMetricGroup();
105
		}
106
107
		public ArmMetricGroup getArmMetricGroup() {
108
			return metricGroup;
109
		}
73
110
111
		private ArmMetricGroup metricGroup;
74
	}
112
	}
75
113
76
	/**
114
	/**
Lines 92-97 Link Here
92
130
93
	}
131
	}
94
132
133
	
134
	
95
	/**
135
	/**
96
	 * 
136
	 * 
97
	 * @author rdanek
137
	 * @author rdanek
(-)src-agent/org/eclipse/tptp/trace/arm/internal/agent/Agent.java (-2 / +2 lines)
Lines 265-274 Link Here
265
	 * @see org.eclipse.tptp.trace.arm.internal.agent.trace.IXmlTraceWriter#write(org.eclipse.tptp.trace.arm.internal.agent.trace.events.IBaseRecord)
265
	 * @see org.eclipse.tptp.trace.arm.internal.agent.trace.IXmlTraceWriter#write(org.eclipse.tptp.trace.arm.internal.agent.trace.events.IBaseRecord)
266
	 */
266
	 */
267
	public void write(IBaseRecord message) {
267
	public void write(IBaseRecord message) {
268
        _agent.logMessageUTF8(message.toString());
268
		_agent.logMessageUTF8(message.toString());
269
269
270
        /* Log Debug Message */
270
        /* Log Debug Message */
271
        _logger.logDebug(ARMLogger.SEV_DEBUG_MIN, "write(IBaseRecord): " //$NON-NLS-1$
271
        _logger.logDebug(ARMLogger.SEV_FATAL, "write(IBaseRecord): " //$NON-NLS-1$
272
                + message.toString());
272
                + message.toString());
273
273
274
274
(-)src-agent/org/eclipse/tptp/trace/arm/internal/agent/processor/ARMEventProcessor.java (-4 / +15 lines)
Lines 20-31 Link Here
20
import org.eclipse.tptp.trace.arm.internal.agent.model.IRuntimeModel;
20
import org.eclipse.tptp.trace.arm.internal.agent.model.IRuntimeModel;
21
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.InvocationContextRecord;
21
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.InvocationContextRecord;
22
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodEventRecord;
22
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodEventRecord;
23
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodMetricEventRecord;
23
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.RemoteMethodEventRecord;
24
import org.eclipse.tptp.trace.arm.internal.agent.trace.events.RemoteMethodEventRecord;
24
import org.eclipse.tptp.trace.arm.internal.agent.trace.exceptions.MethodEntryException;
25
import org.eclipse.tptp.trace.arm.internal.agent.trace.exceptions.MethodEntryException;
25
import org.eclipse.tptp.trace.arm.internal.agent.util.IEventProcessor;
26
import org.eclipse.tptp.trace.arm.internal.agent.util.IEventProcessor;
26
import org.eclipse.tptp.trace.arm.internal.agent.util.Timestamp;
27
import org.eclipse.tptp.trace.arm.internal.agent.util.Timestamp;
27
import org.eclipse.tptp.trace.arm.internal.correlator.TPTPArmCorrelator;
28
import org.eclipse.tptp.trace.arm.internal.correlator.TPTPArmCorrelator;
28
import org.eclipse.tptp.trace.arm.internal.event.TPTPArmEvent;
29
import org.eclipse.tptp.trace.arm.internal.event.TPTPArmEvent;
30
import org.eclipse.tptp.trace.arm.internal.event.TPTPArmMetricEvent;
29
import org.eclipse.tptp.trace.arm.internal.event.TPTPStartArmEvent;
31
import org.eclipse.tptp.trace.arm.internal.event.TPTPStartArmEvent;
30
import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger;
32
import org.eclipse.tptp.trace.arm.internal.logging.ARMLogger;
31
33
Lines 107-117 Link Here
107
109
108
		boolean isEntry = event instanceof TPTPStartArmEvent;
110
		boolean isEntry = event instanceof TPTPStartArmEvent;
109
		MethodEventRecord mr;
111
		MethodEventRecord mr;
110
112
		
111
		if (isLocalInvocation && isSameThread) {
113
		if (isLocalInvocation && isSameThread) {
112
			mr = new MethodEventRecord(methodName, methodSignature, methodKey,
114
			// Create method event record with metric or without metric.
113
					ticket, seqCtr, className, threadid, timestamp, isEntry,
115
			if (event instanceof TPTPArmMetricEvent) {
114
					appName, component);
116
				TPTPArmMetricEvent metricEvent = (TPTPArmMetricEvent) event;
117
				mr = new MethodMetricEventRecord(methodName, methodSignature,
118
						methodKey, ticket, seqCtr, className, threadid,
119
						timestamp, isEntry, appName, component, metricEvent
120
								.getArmMetricGroup());
121
			} else {
122
				mr = new MethodEventRecord(methodName, methodSignature,
123
						methodKey, ticket, seqCtr, className, threadid,
124
						timestamp, isEntry, appName, component);
125
			}
115
126
116
		} else {
127
		} else {
117
			mr = createRemoteMethodEvent(methodName, methodSignature,
128
			mr = createRemoteMethodEvent(methodName, methodSignature,
(-)src-config/org/eclipse/tptp/trace/arm/SetConfig.java (+6 lines)
Lines 84-89 Link Here
84
		Variable.setPosition(var, "append");
84
		Variable.setPosition(var, "append");
85
		Variable.setValue(var, "%PLUGINS_HOME%" + sr + getPluginName() + sr + "armLoader.jar");
85
		Variable.setValue(var, "%PLUGINS_HOME%" + sr + getPluginName() + sr + "armLoader.jar");
86
		app.appendChild(var);
86
		app.appendChild(var);
87
		
88
		var = doc.createElement(Variable.TAG);
89
		Variable.setName(var, "CLASSPATH");
90
		Variable.setPosition(var, "append");
91
		Variable.setValue(var, "%PLUGINS_HOME%" + sr + getPluginName() + sr + "JPerf.jar");
92
		app.appendChild(var);
87
93
88
		var = doc.createElement(Variable.TAG);
94
		var = doc.createElement(Variable.TAG);
89
		Variable.setName(var, "CLASSPATH");
95
		Variable.setName(var, "CLASSPATH");
(-)src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodEventRecord.java (-1 / +11 lines)
Lines 133-139 Link Here
133
            String methodEvent = super.getXmlPrinter().MethodEntry(
133
            String methodEvent = super.getXmlPrinter().MethodEntry(
134
                    _methodIdRef, _ticket, _sequenceCounter, _stackDepth,
134
                    _methodIdRef, _ticket, _sequenceCounter, _stackDepth,
135
                    _classIdRef, _threadIdRef, _time);
135
                    _classIdRef, _threadIdRef, _time);
136
            methodEvent += "\r\n"+super.getXmlPrinter().ParameterRecord(super.getTransactionDetailIdRef())+"\r\n";   //$NON-NLS-1$ //$NON-NLS-2$
136
            methodEvent += "\r\n"+getEntryParameterPart()+"\r\n";   //$NON-NLS-1$ //$NON-NLS-2$
137
            methodEvent += super.getXmlPrinter().MethodEntryEnd(); 
137
            methodEvent += super.getXmlPrinter().MethodEntryEnd(); 
138
            return methodEvent; 
138
            return methodEvent; 
139
        			
139
        			
Lines 143-146 Link Here
143
                    _classIdRef, _threadIdRef, _time);
143
                    _classIdRef, _threadIdRef, _time);
144
    }
144
    }
145
145
146
	/**
147
	 * Parameter part of the record for method entry. The succlass can override
148
	 * it to add additional part.
149
	 * 
150
	 * @return
151
	 */
152
	protected String getEntryParameterPart() {
153
		return super.getXmlPrinter().ParameterRecord(
154
				super.getTransactionDetailIdRef());
155
	}
146
}
156
}
(-)src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricConstants.java (+34 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: ArmMetricConstants.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.model;
13
14
/**
15
 * Classes to define the metric types.
16
 * 
17
 * @author Gao Peng
18
 * @since TPTP 4.5.1
19
 * 
20
 */
21
public class ArmMetricConstants {
22
23
	// Metric types
24
	public static final int UNKOWN = -1;
25
	public static final int ArmMetricCounter32 = 1;
26
	public static final int ArmMetricCounter64 = 2;
27
	public static final int ArmMetricCounterFloat32 = 3;
28
	public static final int ArmMetricGauge32 = 4;
29
	public static final int ArmMetricGauge64 = 5;
30
	public static final int ArmMetricGaugeFloat32 = 6;
31
	public static final int ArmMetricNumericId32 = 7;
32
	public static final int ArmMetricNumericId64 = 8;
33
	public static final int ArmMetricString32 = 9;
34
}
(-)src-model/org/eclipse/tptp/trace/arm/internal/model/impl/PttMetricValueProvider.java (+125 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: PttMetricValueProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.model.impl;
13
14
import java.util.Arrays;
15
import java.util.Collections;
16
import java.util.HashMap;
17
import java.util.Map;
18
19
import jperf.JPerf;
20
import jperf.PerThreadTime;
21
22
import org.eclipse.tptp.trace.arm.internal.model.ArmMetricConstants;
23
import org.eclipse.tptp.trace.arm.internal.model.IMetricValueProvider;
24
25
/**
26
 * The metric value provider. It provides value via PTT.
27
 * 
28
 * @author Gao Peng
29
 * @since TPTP 4.5.1
30
 * 
31
 */
32
public class PttMetricValueProvider implements IMetricValueProvider,
33
		IPttMetricProvider {
34
35
	/**
36
	 * Metric names which will be used to init ptt. It should have the same
37
	 * order with METRIC_NAMES.
38
	 */
39
	private static final String[] METRIC_NAMES_FOR_PTT = { "CYCLES",
40
			"NONHALTED_CYCLES", "INSTR", "UOPS", "ALL_UOPS", "BRANCH",
41
			"MISPRED_BRANCH", "CALLS", "ITLB_MISS", "TC_FLUSH",
42
			"TC_DELIVER_LP0", "TC_DELIVER_LP1", "TC_MISS", "L2_READ_MISS",
43
			"L2_READ_REFS", "L3_READ_MISS", "L3_READ_REFS", "MACHINE_CLEAR",
44
			"MACHINE_CLEAR_MO", "MACHINE_CLEAR_SM", "BRANCH_TAKEN",
45
			"PROC_BUS_ACCESS", "PROC_NONPREFETCH_BUS_ACCESS", "PROC_READS",
46
			"PROC_WRITES", "PROC_READS_NONPREFETCH", "PROC_BUS_ACCESS_UW",
47
			"PROC_BUS_READS_UW", "PROC_BUS_WRITES_UW",
48
			"PROC_READS_NONPREFETCH_UW" };
49
50
	/**
51
	 * Mapping between the metric names in eclipse Workbench and ptt init.
52
	 */
53
	private static final Map METRICS_MAPPING;
54
	static {
55
		Map tempMap = new HashMap(METRIC_NAMES.length);
56
		for (int i = 0; i < METRIC_NAMES.length; i++) {
57
			tempMap.put(METRIC_NAMES[i], METRIC_NAMES_FOR_PTT[i]);
58
		}
59
		METRICS_MAPPING = Collections.unmodifiableMap(tempMap);
60
	}
61
62
	public String[] getNames() {
63
		return METRIC_NAMES;
64
	}
65
66
	public int getType(String name) {
67
		// TODO : always return ArmMetricString32 now.
68
		return ArmMetricConstants.ArmMetricString32;
69
	}
70
71
	public String getVaule(String name) {
72
		return getVaules(new String[] { name })[0];
73
	}
74
75
	public int[] getType(String[] names) {
76
		int[] result = new int[names.length];
77
		Arrays.fill(result, ArmMetricConstants.ArmMetricString32);
78
		return result;
79
	}
80
81
	public String[] getVaules(String[] names) {
82
		PerThreadTime ptt = new PerThreadTime();
83
84
		// reset
85
		ptt.Terminate();
86
87
		String[] pttMetricNames = getMetricNamesForPtt(names);
88
		ptt.Init(pttMetricNames.length, pttMetricNames,
89
				JPerf.PTT_USER_LEVEL);
90
		ptt.GetCurrentThreadData();
91
92
		String[] result = new String[pttMetricNames.length];
93
		for (int i = 0; i < result.length; i++) {
94
			result[i] = Long.toString(ptt.mv[i]);
95
		}
96
97
		return result;
98
	}
99
100
	private String[] getMetricNamesForPtt(String[] names) {
101
		String[] pttMetricNames = new String[names.length];
102
		for (int i = 0; i < pttMetricNames.length; i++) {
103
			pttMetricNames[i] = (String) METRICS_MAPPING.get(names[i]);
104
		}
105
		return pttMetricNames;
106
	}
107
108
	/**
109
	 * @return the id
110
	 */
111
	public String getId() {
112
		return id;
113
	}
114
115
	/**
116
	 * @param id
117
	 *            the id to set
118
	 */
119
	public void setId(String id) {
120
		this.id = id;
121
	}
122
123
	private String id;
124
125
}
(-)src-arm-core/org/eclipse/tptp/trace/arm/internal/event/TPTPArmMetricEvent.java (+30 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: TPTPArmMetricEvent.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.event;
13
14
import org.opengroup.arm40.metric.ArmMetricGroup;
15
16
/**
17
 * @author Gao Peng
18
 * @since TPTP 4.5.1
19
 * 
20
 */
21
public interface TPTPArmMetricEvent extends TPTPArmEvent {
22
23
	/**
24
	 * Get the metric group.
25
	 * 
26
	 * @return
27
	 */
28
	ArmMetricGroup getArmMetricGroup();
29
30
}
(-)src-model/org/eclipse/tptp/trace/arm/internal/model/impl/IPttMetricProvider.java (+38 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: IPttMetricProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.model.impl;
13
14
/**
15
 * 
16
 * 
17
 * @author Gao Peng
18
 * @since TPTP 4.5.1
19
 * 
20
 */
21
public interface IPttMetricProvider {
22
23
	/**
24
	 * Metric names which will display in eclipse Workbench. It should have the
25
	 * same order with METRIC_NAMES_FOR_PTT.<br>
26
	 * TODO : use the meaning name.
27
	 */
28
	public static final String[] METRIC_NAMES = { "CYCLES", "NONHALTED_CYCLES",
29
			"INSTR", "UOPS", "ALL_UOPS", "BRANCH", "MISPRED_BRANCH", "CALLS",
30
			"ITLB_MISS", "TC_FLUSH", "TC_DELIVER_LP0", "TC_DELIVER_LP1",
31
			"TC_MISS", "L2_READ_MISS", "L2_READ_REFS", "L3_READ_MISS",
32
			"L3_READ_REFS", "MACHINE_CLEAR", "MACHINE_CLEAR_MO",
33
			"MACHINE_CLEAR_SM", "BRANCH_TAKEN", "PROC_BUS_ACCESS",
34
			"PROC_NONPREFETCH_BUS_ACCESS", "PROC_READS", "PROC_WRITES",
35
			"PROC_READS_NONPREFETCH", "PROC_BUS_ACCESS_UW",
36
			"PROC_BUS_READS_UW", "PROC_BUS_WRITES_UW",
37
			"PROC_READS_NONPREFETCH_UW" };
38
}
(-)src-agent/org/eclipse/tptp/trace/arm/internal/agent/trace/events/MethodMetricEventRecord.java (+74 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: MethodMetricEventRecord.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.agent.trace.events;
13
14
import org.eclipse.tptp.trace.arm.internal.agent.util.Timestamp;
15
import org.eclipse.tptp.trace.arm.internal.metric.ArmMetricGroupImpl;
16
import org.opengroup.arm40.metric.ArmMetric;
17
import org.opengroup.arm40.metric.ArmMetricGroup;
18
19
/**
20
 * This class extends MethodEventRecord to provide the feature about metric.
21
 * 
22
 * @author Gao Peng
23
 * @since TPTP 4.5.1
24
 * 
25
 */
26
public class MethodMetricEventRecord extends MethodEventRecord {
27
28
	/**
29
	 * @param name
30
	 * @param signature
31
	 * @param key
32
	 * @param _ticket
33
	 * @param counter
34
	 * @param name2
35
	 * @param idRef
36
	 * @param _timestamp
37
	 * @param entry
38
	 * @param applicationName
39
	 * @param transactionDetail
40
	 */
41
	public MethodMetricEventRecord(String name, String signature, Object key,
42
			long _ticket, long counter, String name2, long idRef,
43
			Timestamp _timestamp, boolean entry, String applicationName,
44
			String transactionDetail, ArmMetricGroup metricGroup) {
45
		super(name, signature, key, _ticket, counter, name2, idRef, _timestamp,
46
				entry, applicationName, transactionDetail);
47
		this.metricGroup = metricGroup;
48
	}
49
50
	/**
51
	 * @return the metricGroup
52
	 */
53
	public ArmMetricGroup getMetricGroup() {
54
		return metricGroup;
55
	}
56
57
	private ArmMetricGroup metricGroup;
58
59
	/**
60
	 * Add the information about metric.
61
	 * 
62
	 * @see org.eclipse.tptp.trace.arm.internal.agent.trace.events.MethodEventRecord#getEntryParameterPart()
63
	 */
64
	protected String getEntryParameterPart() {
65
		String parameter = super.getEntryParameterPart();
66
		// Add the information about metric.
67
		ArmMetric[] metrics = ((ArmMetricGroupImpl) metricGroup).getMetrics();
68
		for (int i = 0; i < metrics.length; i++) {
69
			parameter += "\r\n" + metrics[i].toString();
70
		}
71
		return parameter;
72
	}
73
74
}
(-)src-model/org/eclipse/tptp/trace/arm/internal/model/ArmMetricManager.java (+235 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: ArmMetricManager.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.model;
13
14
import java.io.BufferedReader;
15
import java.io.File;
16
import java.io.FileReader;
17
import java.io.IOException;
18
import java.util.ArrayList;
19
import java.util.Collection;
20
import java.util.HashMap;
21
import java.util.Iterator;
22
import java.util.List;
23
import java.util.Map;
24
25
import org.opengroup.arm40.metric.ArmMetricDefinition;
26
27
/**
28
 * @author Gao Peng
29
 * @since TPTP 4.5.1
30
 * 
31
 */
32
public class ArmMetricManager {
33
	
34
	/**
35
	 * Prefix of the temp file for metric.
36
	 */
37
	private static final String ARM_PREFIX_FOR_METRIC = "ARM";
38
39
	/**
40
	 * Singleton.
41
	 */
42
	private static final ArmMetricManager instance = new ArmMetricManager();
43
44
	public static ArmMetricManager getInstance() {
45
		return instance;
46
	}
47
48
	private ArmMetricManager() {
49
		try {
50
			loadMetricProvider();
51
		} catch (Throwable e) {
52
			// Do nothing. Just skip load.
53
		}
54
	}
55
56
	private void loadMetricProvider() throws IOException {
57
		String tmpDir = System.getProperty("java.io.tmpdir");
58
		File metricFile = new File(tmpDir, ARM_PREFIX_FOR_METRIC
59
				+ "instrument-runtime.properties");
60
61
		BufferedReader reader = new BufferedReader(new FileReader(metricFile));
62
		String line = reader.readLine();
63
		while (line != null) {
64
			String[] metricInfo = line.split(IMetricValueProvider.SEPARATOR);
65
			if (metricInfo.length >= 2) {
66
				IMetricValueProvider provider = getMetricProvider(metricInfo[0]);
67
				saveMetricInfo(provider, metricInfo[1]);
68
			}
69
			line = reader.readLine();
70
		}
71
	}
72
73
	private void saveMetricInfo(IMetricValueProvider provider, String metricName) {
74
		List metricNames = (List) metricInformation.get(provider);
75
		if (metricNames == null) {
76
			metricNames = new ArrayList();
77
			metricInformation.put(provider, metricNames);
78
		}
79
		metricNames.add(metricName);
80
	}
81
82
	/**
83
	 * Get the instance of the {@link IMetricValueProvider}. A new instance will
84
	 * be created if there is no such instance.
85
	 * 
86
	 * @param className The class name of the {@link IMetricValueProvider}
87
	 * @return
88
	 */
89
	private IMetricValueProvider getMetricProvider(String className) {
90
		IMetricValueProvider provider = (IMetricValueProvider) metricProviders
91
				.get(className);
92
		if (provider == null) {
93
			try {
94
				Class clazz = Class.forName(className);
95
				provider = (IMetricValueProvider) clazz.newInstance();
96
				metricProviders.put(className, provider);
97
			} catch (ClassNotFoundException e) {
98
				e.printStackTrace();
99
			} catch (NoClassDefFoundError e) {
100
				e.printStackTrace();
101
			} catch (IllegalAccessException e) {
102
				e.printStackTrace();
103
			} catch (InstantiationException e) {
104
				e.printStackTrace();
105
			}
106
		}
107
		return provider;
108
	}
109
110
	/**
111
	 * Check whether there is metric.
112
	 * 
113
	 * @return
114
	 */
115
	public boolean hasMetric() {
116
		return (metricProviders != null) && (metricProviders.size() != 0);
117
	}
118
119
	/**
120
	 * Get the metrics.
121
	 * 
122
	 * @return The list of the {@link ArmMetricManager.Metric}.
123
	 */
124
	public List getMetrics() {
125
		List metrics = new ArrayList();
126
		for (Iterator iterator = metricInformation.entrySet().iterator(); iterator
127
				.hasNext();) {
128
			Map.Entry entry = (Map.Entry) iterator.next();
129
			IMetricValueProvider provider = (IMetricValueProvider) entry
130
					.getKey();
131
			List metricNames = (List) entry.getValue();
132
			for (Iterator iterator2 = metricNames.iterator(); iterator2
133
					.hasNext();) {
134
				String metricName = (String) iterator2.next();
135
				String metricValue = provider.getVaule(metricName);
136
				int metricType = provider.getType(metricName);
137
				metrics.add(new Metric(metricName, metricValue, metricType,
138
						provider));
139
			}
140
		}
141
		return metrics;
142
	}
143
144
	/**
145
	 * Support this method to support {@link IMetricValueProvider} instance
146
	 * initialization.
147
	 * 
148
	 * @return
149
	 */
150
	public Collection getmMetricProviders() {
151
		return metricProviders.values();
152
	}
153
154
	/**
155
	 * Store the instances of the {@link IMetricValueProvider}. The key is the
156
	 * class name, and the value is the instance.
157
	 */
158
	private Map metricProviders = new HashMap();
159
160
	/**
161
	 * Store the instances of the {@link IMetricValueProvider} and the metrics
162
	 * they should provide. The key is the instance , and the value is the list
163
	 * of the metric name.
164
	 */
165
	private Map metricInformation = new HashMap();
166
167
	/**
168
	 * Value object to store the metric information.
169
	 * 
170
	 * @author Gao Peng
171
	 * @since TPTP 4.5.1
172
	 * 
173
	 */
174
	public class Metric {
175
176
		public Metric(String metricName, String metricValue, int metricType,
177
				IMetricValueProvider metricProvider) {
178
			super();
179
			this.metricName = metricName;
180
			this.metricValue = metricValue;
181
			this.metricType = metricType;
182
			this.metricProvider = metricProvider;
183
		}
184
185
		/**
186
		 * @return the metricName
187
		 */
188
		public String getMetricName() {
189
			return metricName;
190
		}
191
192
		/**
193
		 * @return the metricValue
194
		 */
195
		public String getMetricValue() {
196
			return metricValue;
197
		}
198
199
		/**
200
		 * @return the metricType
201
		 */
202
		public int getMetricType() {
203
			return metricType;
204
		}
205
206
		/**
207
		 * @return the metricProvider
208
		 */
209
		public IMetricValueProvider getMetricProvider() {
210
			return metricProvider;
211
		}
212
213
		/**
214
		 * @return the definition
215
		 */
216
		public ArmMetricDefinition getDefinition() {
217
			return definition;
218
		}
219
220
		/**
221
		 * @param definition
222
		 *            the definition to set
223
		 */
224
		public void setDefinition(ArmMetricDefinition definition) {
225
			this.definition = definition;
226
		}
227
228
		private String metricName;
229
		private String metricValue;
230
		private int metricType;
231
		private IMetricValueProvider metricProvider;
232
		private ArmMetricDefinition definition;
233
234
	}
235
}
(-)src-model/org/eclipse/tptp/trace/arm/internal/model/impl/PttMetricNameProvider.java (+47 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: PttMetricNameProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.model.impl;
13
14
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider;
15
16
/**
17
 * @author Gao Peng
18
 * @since TPTP 4.5.1
19
 * 
20
 */
21
public class PttMetricNameProvider implements IMetricNameProvider, IPttMetricProvider {
22
	
23
	public String[] getNames() {
24
		return METRIC_NAMES;
25
	}
26
27
	public String getMetricValueProviderName() {
28
		return PttMetricValueProvider.class.getName();
29
	}
30
	
31
	/**
32
	 * @return the id
33
	 */
34
	public String getId() {
35
		return id;
36
	}
37
38
	/**
39
	 * @param id
40
	 *            the id to set
41
	 */
42
	public void setId(String id) {
43
		this.id = id;
44
	}
45
46
	private String id;
47
}
(-)src-model/org/eclipse/tptp/trace/arm/internal/model/IMetricValueProvider.java (+74 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: IMetricValueProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.internal.model;
13
14
/**
15
 * Interface for metric value provider. It's only used in agent.
16
 * 
17
 * @since TPTP 4.5.1
18
 * @author Gao Peng
19
 * 
20
 */
21
public interface IMetricValueProvider {
22
23
	/**
24
	 * The separator between the metric information.
25
	 */
26
	String METRIC_SEPERATOR = "\t";
27
28
	/**
29
	 * The separator between the parts of the metric information.
30
	 */
31
	String SEPARATOR = ",";
32
33
	/**
34
	 * 
35
	 */
36
	String METRIC_PREFIX = "METRIC_PREFIX";
37
38
	/**
39
	 * Return the metric value.
40
	 * 
41
	 * @param name
42
	 *            the metric name.
43
	 * @return the metric value.
44
	 */
45
	String getVaule(String name);
46
47
	/**
48
	 * Return the type of the metric value.
49
	 * 
50
	 * @param name
51
	 *            the metric name.
52
	 * @return the type of the metric value.
53
	 */
54
	int getType(String name);
55
56
	/**
57
	 * Return the metric values.
58
	 * 
59
	 * @param name
60
	 *            the metric names.
61
	 * @return the metric values.
62
	 */
63
	String[] getVaules(String[] names);
64
65
	/**
66
	 * Return the type of the metric values.
67
	 * 
68
	 * @param name
69
	 *            the metric names.
70
	 * @return the type of the metric values.
71
	 */
72
	int[] getType(String[] names);
73
74
}
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPointManager.java (+34 lines)
Lines 82-87 Link Here
82
					String descr = element[j].getAttribute("description");
82
					String descr = element[j].getAttribute("description");
83
					String script = element[j].getAttribute("script");
83
					String script = element[j].getAttribute("script");
84
					String instrumentTypeId = element[j].getAttribute("instrumentTypeId");
84
					String instrumentTypeId = element[j].getAttribute("instrumentTypeId");
85
86
					IMetricNameProvider[] metricProviders = getMetricProviders(element[j]);
85
					
87
					
86
					String cint = element[j].getContributor().getName();
88
					String cint = element[j].getContributor().getName();
87
					
89
					
Lines 135-140 Link Here
135
					instrumentPoint.setProbeScriptContent(probeScriptContents);
137
					instrumentPoint.setProbeScriptContent(probeScriptContents);
136
					instrumentPoint.setType(type);
138
					instrumentPoint.setType(type);
137
					instrumentPoint.setProbeScript(script);
139
					instrumentPoint.setProbeScript(script);
140
					instrumentPoint
141
							.setMetricProviders(new CombinedMetricProvider(
142
									metricProviders));
138
					
143
					
139
					instrumentPoints.put(id, instrumentPoint);
144
					instrumentPoints.put(id, instrumentPoint);
140
				} catch (Exception ex) { 
145
				} catch (Exception ex) { 
Lines 144-149 Link Here
144
			}
149
			}
145
		}
150
		}
146
	} // end of initialize()
151
	} // end of initialize()
152
153
	/**
154
	 * Get the metricProviders.
155
	 * 
156
	 * @param element
157
	 * @return the class names of metric providers.
158
	 */
159
	private IMetricNameProvider[] getMetricProviders(
160
			IConfigurationElement element) {
161
		IMetricNameProvider[] metricProviders = null;
162
		IConfigurationElement[] metricProviderGroup = element
163
				.getChildren("metricProviders");
164
		if (metricProviderGroup.length != 0) {
165
			IConfigurationElement[] metricProviderElements = metricProviderGroup[0]
166
					.getChildren("metricProvider");
167
			metricProviders = new IMetricNameProvider[metricProviderElements.length];
168
			for (int i = 0; i < metricProviderElements.length; i++) {
169
				IConfigurationElement metricProvider = metricProviderElements[i];
170
				// get the id of the metricProvider.
171
				String metricProviderId = metricProvider
172
						.getAttribute("metricProviderIdRef");
173
				// get the IMetricProvider instance from MetricProviderManager
174
				// via the id of the metricProvider.
175
				metricProviders[i] = MetricProviderManager.getInstance()
176
						.getMetricProvider(metricProviderId);
177
			}
178
		}
179
		return metricProviders;
180
	}
147
	
181
	
148
	private ByteArrayOutputStream findClass(String className, String bundleId) throws IOException {
182
	private ByteArrayOutputStream findClass(String className, String bundleId) throws IOException {
149
		if (!className.startsWith("/")) {
183
		if (!className.startsWith("/")) {
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/InstrumentPoint.java (+19 lines)
Lines 48-53 Link Here
48
	/* The contents of the probe script */
48
	/* The contents of the probe script */
49
	private String probeScriptContent;
49
	private String probeScriptContent;
50
	
50
	
51
	/**
52
	 * The metric provider. This value can be null for no metric provider.
53
	 */
54
	private IMetricNameProvider metricProvider;
55
	
51
	
56
	
52
	/**
57
	/**
53
	 * Default constructor
58
	 * Default constructor
Lines 204-207 Link Here
204
		this.type = type;
209
		this.type = type;
205
	}
210
	}
206
211
212
	/**
213
	 * @return the metricProviders
214
	 */
215
	public IMetricNameProvider getMetricProvider() {
216
		return metricProvider;
217
	}
218
219
	/**
220
	 * @param metricProviders
221
	 *            the metricProviders to set
222
	 */
223
	public void setMetricProviders(IMetricNameProvider metricProvider) {
224
		this.metricProvider = metricProvider;
225
	}
207
}
226
}
(-)schema/instrumentPointDeclaration.exsd (-18 / +52 lines)
Lines 1-16 Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.tptp.platform.instrumentation.ui">
3
<schema targetNamespace="org.eclipse.tptp.platform.instrumentation.ui" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
4
<annotation>
5
      <appInfo>
5
      <appinfo>
6
         <meta.schema plugin="org.eclipse.tptp.platform.instrumentation.ui" id="instrumentPointDeclaration" name="instrumentPointDeclaration"/>
6
         <meta.schema plugin="org.eclipse.tptp.platform.instrumentation.ui" id="instrumentPointDeclaration" name="instrumentPointDeclaration"/>
7
      </appInfo>
7
      </appinfo>
8
      <documentation>
8
      <documentation>
9
         This extension point is used to register instrument points.  The instrument point supports two types probes or aspects.
9
         This extension point is used to register instrument points.  The instrument point supports two types probes or aspects.
10
      </documentation>
10
      </documentation>
11
   </annotation>
11
   </annotation>
12
12
13
   <element name="extension">
13
   <element name="extension">
14
      <annotation>
15
         <appinfo>
16
            <meta.element />
17
         </appinfo>
18
      </annotation>
14
      <complexType>
19
      <complexType>
15
         <sequence>
20
         <sequence>
16
            <element ref="instrumentPoint" minOccurs="1" maxOccurs="unbounded"/>
21
            <element ref="instrumentPoint" minOccurs="1" maxOccurs="unbounded"/>
Lines 34-42 Link Here
34
               <documentation>
39
               <documentation>
35
                  
40
                  
36
               </documentation>
41
               </documentation>
37
               <appInfo>
42
               <appinfo>
38
                  <meta.attribute translatable="true"/>
43
                  <meta.attribute translatable="true"/>
39
               </appInfo>
44
               </appinfo>
40
            </annotation>
45
            </annotation>
41
         </attribute>
46
         </attribute>
42
      </complexType>
47
      </complexType>
Lines 44-49 Link Here
44
49
45
   <element name="instrumentPoint">
50
   <element name="instrumentPoint">
46
      <complexType>
51
      <complexType>
52
         <sequence>
53
            <element ref="metricProviders" minOccurs="0" maxOccurs="1"/>
54
         </sequence>
47
         <attribute name="name" type="string" use="required">
55
         <attribute name="name" type="string" use="required">
48
            <annotation>
56
            <annotation>
49
               <documentation>
57
               <documentation>
Lines 63-71 Link Here
63
               <documentation>
71
               <documentation>
64
                  
72
                  
65
               </documentation>
73
               </documentation>
66
               <appInfo>
74
               <appinfo>
67
                  <meta.attribute kind="java"/>
75
                  <meta.attribute kind="java"/>
68
               </appInfo>
76
               </appinfo>
69
            </annotation>
77
            </annotation>
70
         </attribute>
78
         </attribute>
71
         <attribute name="type" use="required">
79
         <attribute name="type" use="required">
Lines 107-125 Link Here
107
      </complexType>
115
      </complexType>
108
   </element>
116
   </element>
109
117
118
   <element name="metricProviders">
119
      <complexType>
120
         <sequence minOccurs="1" maxOccurs="unbounded">
121
            <element ref="metricProvider"/>
122
         </sequence>
123
      </complexType>
124
   </element>
125
126
   <element name="metricProvider">
127
      <complexType>
128
         <attribute name="metricProviderIdRef" type="string">
129
            <annotation>
130
               <documentation>
131
                  The reference ID of metricProvider.
132
               </documentation>
133
            </annotation>
134
         </attribute>
135
      </complexType>
136
   </element>
137
110
   <annotation>
138
   <annotation>
111
      <appInfo>
139
      <appinfo>
112
         <meta.section type="since"/>
140
         <meta.section type="since"/>
113
      </appInfo>
141
      </appinfo>
114
      <documentation>
142
      <documentation>
115
         Since TPTP 4.3
143
         Since TPTP 4.3
116
      </documentation>
144
      </documentation>
117
   </annotation>
145
   </annotation>
118
146
119
   <annotation>
147
   <annotation>
120
      <appInfo>
148
      <appinfo>
121
         <meta.section type="examples"/>
149
         <meta.section type="examples"/>
122
      </appInfo>
150
      </appinfo>
123
      <documentation>
151
      <documentation>
124
         &lt;extension
152
         &lt;extension
125
         point=&quot;org.eclipse.tptp.platform.instrumentation.ui.instrumentPointDeclaration&quot;&gt;
153
         point=&quot;org.eclipse.tptp.platform.instrumentation.ui.instrumentPointDeclaration&quot;&gt;
Lines 130-162 Link Here
130
            instrumentTypeId=&quot;org.eclipse.tptp.trace.arm.ui.armInstrumentType&quot;
158
            instrumentTypeId=&quot;org.eclipse.tptp.trace.arm.ui.armInstrumentType&quot;
131
            name=&quot;Generic Probe&quot;
159
            name=&quot;Generic Probe&quot;
132
            script=&quot;Generic.probescript&quot;
160
            script=&quot;Generic.probescript&quot;
133
            type=&quot;probes&quot;/&gt;
161
            type=&quot;probes&quot;&gt;
162
         &lt;metricProviders&gt;
163
            &lt;metricProvider
164
               metricProviderIdRef=&quot;org.eclipse.tptp.trace.arm.PttMetricProvider&quot;&gt;
165
            &lt;/metricProvider&gt;
166
         &lt;/metricProviders&gt;
167
      &lt;/instrumentPoint&gt;
134
   &lt;/extension&gt;
168
   &lt;/extension&gt;
135
      </documentation>
169
      </documentation>
136
   </annotation>
170
   </annotation>
137
171
138
   <annotation>
172
   <annotation>
139
      <appInfo>
173
      <appinfo>
140
         <meta.section type="apiInfo"/>
174
         <meta.section type="apiInfo"/>
141
      </appInfo>
175
      </appinfo>
142
      <documentation>
176
      <documentation>
143
         [Enter API information here.]
177
         [Enter API information here.]
144
      </documentation>
178
      </documentation>
145
   </annotation>
179
   </annotation>
146
180
147
   <annotation>
181
   <annotation>
148
      <appInfo>
182
      <appinfo>
149
         <meta.section type="implementation"/>
183
         <meta.section type="implementation"/>
150
      </appInfo>
184
      </appinfo>
151
      <documentation>
185
      <documentation>
152
         [Enter information about supplied implementation of this extension point.]
186
         [Enter information about supplied implementation of this extension point.]
153
      </documentation>
187
      </documentation>
154
   </annotation>
188
   </annotation>
155
189
156
   <annotation>
190
   <annotation>
157
      <appInfo>
191
      <appinfo>
158
         <meta.section type="copyright"/>
192
         <meta.section type="copyright"/>
159
      </appInfo>
193
      </appinfo>
160
      <documentation>
194
      <documentation>
161
         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 &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
195
         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 &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
162
      </documentation>
196
      </documentation>
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/InstrumentDelegateHelper.java (-10 / +151 lines)
Lines 15-25 Link Here
15
import java.io.ByteArrayOutputStream;
15
import java.io.ByteArrayOutputStream;
16
import java.io.File;
16
import java.io.File;
17
import java.io.FileOutputStream;
17
import java.io.FileOutputStream;
18
import java.io.FileWriter;
19
import java.io.FilenameFilter;
18
import java.io.IOException;
20
import java.io.IOException;
21
import java.io.PrintWriter;
19
import java.net.URL;
22
import java.net.URL;
20
import java.util.ArrayList;
23
import java.util.ArrayList;
21
import java.util.HashMap;
24
import java.util.HashMap;
22
import java.util.Hashtable;
23
import java.util.Iterator;
25
import java.util.Iterator;
24
import java.util.List;
26
import java.util.List;
25
import java.util.Map;
27
import java.util.Map;
Lines 35-41 Link Here
35
import org.eclipse.debug.core.ILaunchConfiguration;
37
import org.eclipse.debug.core.ILaunchConfiguration;
36
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
38
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
37
import org.eclipse.hyades.internal.execution.local.control.Agent;
39
import org.eclipse.hyades.internal.execution.local.control.Agent;
38
import org.eclipse.hyades.internal.execution.local.control.InactiveProcessException;
39
import org.eclipse.hyades.internal.execution.local.control.Process;
40
import org.eclipse.hyades.internal.execution.local.control.Process;
40
import org.eclipse.hyades.internal.execution.local.control.ProcessListener;
41
import org.eclipse.hyades.internal.execution.local.control.ProcessListener;
41
import org.eclipse.hyades.models.hierarchy.TRCProcessProxy;
42
import org.eclipse.hyades.models.hierarchy.TRCProcessProxy;
Lines 53-68 Link Here
53
import org.eclipse.tptp.platform.instrumentation.ui.internal.LogHelper;
54
import org.eclipse.tptp.platform.instrumentation.ui.internal.LogHelper;
54
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorLoader;
55
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorLoader;
55
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorManager;
56
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.GeneratorManager;
57
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider;
56
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPoint;
58
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPoint;
57
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPointManager;
59
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPointManager;
58
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentSelectManager;
60
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentSelectManager;
61
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.MetricProviderManager;
59
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.FileTransfer;
62
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.FileTransfer;
60
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.InstrumentLookupService;
63
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.InstrumentLookupService;
61
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.listener.InstrumentProcessListener;
64
import org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.listener.InstrumentProcessListener;
62
import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentMessages;
65
import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentMessages;
63
import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentUtil;
66
import org.eclipse.tptp.platform.instrumentation.ui.internal.util.InstrumentUtil;
64
import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisType;
67
import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisType;
65
import org.eclipse.tptp.trace.ui.internal.launcher.core.DataCollector;
66
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherMessages;
68
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherMessages;
67
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
69
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
68
import org.eclipse.tptp.trace.ui.provisional.launcher.ProcessParameters;
70
import org.eclipse.tptp.trace.ui.provisional.launcher.ProcessParameters;
Lines 92-97 Link Here
92
	 * @return The save copy of ILaunchConfiguration
94
	 * @return The save copy of ILaunchConfiguration
93
	 */
95
	 */
94
	public static ILaunchConfiguration preLaunch(ILaunchConfiguration configuration) throws CoreException {
96
	public static ILaunchConfiguration preLaunch(ILaunchConfiguration configuration) throws CoreException {
97
98
		// Save metric information
99
		saveMetricInfo(configuration);
95
		
100
		
96
		//first identified that it is JVMPI instrument Collector
101
		//first identified that it is JVMPI instrument Collector
97
		InstrumentUtil.initiazeInstrumentCollector(configuration, InstrumentConstants.PI_INSTRUMENT_COLLECTOR);
102
		InstrumentUtil.initiazeInstrumentCollector(configuration, InstrumentConstants.PI_INSTRUMENT_COLLECTOR);
Lines 102-111 Link Here
102
		/* Create Project and Model */
107
		/* Create Project and Model */
103
		createModelEntities(configuration);
108
		createModelEntities(configuration);
104
		
109
		
110
		
105
		return handleInstrumentGenerator(configuration);
111
		return handleInstrumentGenerator(configuration);
106
		
112
		
107
	} // end of preLaunch(...)
113
	} // end of preLaunch(...)
108
	
114
115
	/**
116
	 * Store the metric information in file in temp dir. This file will be read
117
	 * by the agent.
118
	 * 
119
	 * @param configuration
120
	 * @throws CoreException
121
	 */
122
	private static void saveMetricInfo(ILaunchConfiguration configuration)
123
			throws CoreException {
124
		Map attributes = configuration.getAttributes();
125
		boolean saved = false;
126
		for (Iterator iterator = attributes.keySet().iterator(); iterator
127
				.hasNext();) {
128
			String key = (String) iterator.next();
129
			if (key.startsWith(IMetricNameProvider.METRIC_PREFIX)) {
130
				saved = saveMetricInfo(key, configuration.getAttribute(key,
131
						(String) null));
132
			}
133
		}
134
		if (!saved) {
135
			// remove the temp file for metric if ther is no metric file.
136
			removeTempMetricFile();
137
		}
138
	}
139
140
141
	/**
142
	 * Store the metric information in file in temp dir. This file will be read
143
	 * by the agent.
144
	 * 
145
	 * @param metricId the metric ID.
146
	 * @param metricInfo the metric information.
147
	 * @return
148
	 */
149
	private static boolean saveMetricInfo(String metricId, String metricInfo) {
150
		if (metricInfo == null) {
151
			// return false if nothing is saved.
152
			return false;
153
		}
154
155
		File metricFile = getTempMetricFile(metricId);
156
		if (metricFile == null)
157
		{
158
			// return false if nothing is saved.
159
			return false;
160
		}
161
		
162
		String[][] metrics = getMetrics(metricInfo);
163
		PrintWriter writer = null;
164
		try {
165
			writer = new PrintWriter(new FileWriter(metricFile));
166
			for (int i = 0; i < metrics.length; i++) {
167
				writer.print(metrics[i][0]);
168
				writer.print(IMetricNameProvider.SEPARATOR);
169
				writer.println(metrics[i][1]);
170
			}
171
		} catch (IOException e) {
172
			e.printStackTrace();
173
		} finally {
174
			if (writer != null) {
175
				writer.flush();
176
				writer.close();
177
			}
178
		}
179
		
180
		return true;
181
	}
182
183
	/**
184
	 * Get the temp file name for metric.
185
	 * 
186
	 * @param metricId
187
	 * @return
188
	 */
189
	private static File getTempMetricFile(String metricId) {
190
		String[] metricMetadata = metricId.split(IMetricNameProvider.SEPARATOR);
191
		if (metricMetadata.length != 3) {
192
			return null;
193
		}
194
		String metricType = metricMetadata[1];
195
196
		String tmpDir = System.getProperty("java.io.tmpdir");
197
		File metricFile = new File(tmpDir, metricType
198
				+ "instrument-runtime.properties");
199
		return metricFile;
200
	}
201
202
	/**
203
	 * Remove all of the temp file for metric.
204
	 */
205
	private static void removeTempMetricFile() {
206
		String tmpDir = System.getProperty("java.io.tmpdir");
207
		File[] metricFiles = new File(tmpDir).listFiles(new FilenameFilter(){
208
209
			public boolean accept(File dir, String name) {
210
				return name.endsWith("instrument-runtime.properties");
211
			}});
212
		for (int i = 0; i < metricFiles.length; i++) {
213
			metricFiles[i].delete();
214
		}
215
	}
216
217
	/**
218
	 * Parser the metric information to get the class names of the metric value
219
	 * providers and metric names.
220
	 * 
221
	 * @param metricInfo
222
	 * @return The second dim is 2. The first element of the second dim is the
223
	 *         class name of the metric value provider, and the second element
224
	 *         of the second dim is metric name.
225
	 */
226
	private static String[][] getMetrics(String metricInfo) {
227
		String[] metrics = metricInfo
228
				.split(IMetricNameProvider.METRIC_SEPERATOR);
229
		String[][] result = new String[metrics.length][2];
230
		for (int i = 0; i < metrics.length; i++) {
231
			String[] metricInfos = metrics[i]
232
					.split(IMetricNameProvider.SEPARATOR);
233
			if (metricInfos.length != 2) {
234
				result[i][0] = "";
235
				result[i][1] = "";
236
			} else {
237
				String metricID = metricInfos[0];
238
				String metricName = metricInfos[1];
239
				String metricClassName = MetricProviderManager.getInstance()
240
						.getMetricProvider(metricID)
241
						.getMetricValueProviderName();
242
				result[i][0] = metricClassName;
243
				result[i][1] = metricName;
244
			}
245
		}
246
247
		return result;
248
	}
249
109
	/**
250
	/**
110
	 * It is used to handle instrument generator stuff for user selected analysis types.
251
	 * It is used to handle instrument generator stuff for user selected analysis types.
111
	 * 
252
	 * 
Lines 488-499 Link Here
488
					ByteArrayInputStream inputStream = new ByteArrayInputStream(stream.toByteArray());
629
					ByteArrayInputStream inputStream = new ByteArrayInputStream(stream.toByteArray());
489
					byte[] buf = new byte[4096];
630
					byte[] buf = new byte[4096];
490
					int len;
631
					int len;
491
				    while((len=inputStream.read(buf))>0){
632
					while((len=inputStream.read(buf))>0){
492
				    	jarOut.write(buf,0,len);
633
						jarOut.write(buf,0,len);
493
				    }
634
					}
494
				    stream.close();
635
					stream.close();
495
				    inputStream.close();
636
					inputStream.close();
496
				    jarOut.closeEntry();
637
					jarOut.closeEntry();
497
				}
638
				}
498
			}
639
			}
499
			jarOut.finish();
640
			jarOut.finish();
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/deleg/application/TIInstrumentDelegateHelper.java (-1 / +28 lines)
Lines 12-17 Link Here
12
 **********************************************************************/
12
 **********************************************************************/
13
package org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.deleg.application;
13
package org.eclipse.tptp.platform.instrumentation.ui.internal.launcher.deleg.application;
14
14
15
import java.io.InputStream;
15
import java.net.InetAddress;
16
import java.net.InetAddress;
16
import java.net.UnknownHostException;
17
import java.net.UnknownHostException;
17
import java.util.ArrayList;
18
import java.util.ArrayList;
Lines 1080-1092 Link Here
1080
		}
1081
		}
1081
1082
1082
		public void incomingData(char[] buffer, int length, InetAddress peer)
1083
		public void incomingData(char[] buffer, int length, InetAddress peer)
1083
		{		
1084
		{
1084
			if (!enabled)
1085
			if (!enabled)
1085
				return;
1086
				return;
1086
			preIncomingData();
1087
			preIncomingData();
1087
			super.incommingData(buffer, length, peer);
1088
			super.incommingData(buffer, length, peer);
1088
		}
1089
		}
1089
		
1090
		
1091
		
1092
		
1093
		public void incommingData(byte[] buffer, int offset, int length,
1094
				InetAddress peer) {
1095
			super.incommingData(buffer, offset, length, peer);
1096
		}
1097
1098
		public void incommingData(char[] buffer, int offset, int length,
1099
				InetAddress peer) {
1100
			super.incommingData(buffer, offset, length, peer);
1101
		}
1102
1103
		public void incommingData(byte[] data, int length, InetAddress peer) {
1104
			super.incommingData(data, length, peer);
1105
		}
1106
1107
		public void incommingData(char[] data, int length, InetAddress peer) {
1108
			super.incommingData(data, length, peer);
1109
		}
1110
1111
		public void incommingStream(InputStream inputStream, InetAddress peer) {
1112
			super.incommingStream(inputStream, peer);
1113
		}
1114
1115
		
1116
		
1090
		private void preIncomingData() 
1117
		private void preIncomingData() 
1091
		{
1118
		{
1092
			if (!processAlive)
1119
			if (!processAlive)
(-)plugin.xml (+1 lines)
Lines 18-23 Link Here
18
   <extension-point id="generatorMechanism" name="generatorMechanism" schema="schema/generatorMechanism.exsd"/>
18
   <extension-point id="generatorMechanism" name="generatorMechanism" schema="schema/generatorMechanism.exsd"/>
19
   <extension-point id="instrumentPointDeclaration" name="instrumentPointDeclaration" schema="schema/instrumentPointDeclaration.exsd"/>
19
   <extension-point id="instrumentPointDeclaration" name="instrumentPointDeclaration" schema="schema/instrumentPointDeclaration.exsd"/>
20
   <extension-point id="runtimeJarsDependency" name="runtimeJarsDependency" schema="schema/runtimeJarsDependency.exsd"/>
20
   <extension-point id="runtimeJarsDependency" name="runtimeJarsDependency" schema="schema/runtimeJarsDependency.exsd"/>
21
   <extension-point id="metricProvider" name="metricProvider" schema="schema/metricProvider.exsd"/>
21
   
22
   
22
   <!-- The Instrument collector -->
23
   <!-- The Instrument collector -->
23
   <extension
24
   <extension
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/launcher/listener/InstrumentProcessListener.java (-2 / +33 lines)
Lines 16-21 Link Here
16
import java.io.FileInputStream;
16
import java.io.FileInputStream;
17
import java.io.FileNotFoundException;
17
import java.io.FileNotFoundException;
18
import java.io.IOException;
18
import java.io.IOException;
19
import java.io.InputStream;
20
import java.net.InetAddress;
19
import java.nio.ByteBuffer;
21
import java.nio.ByteBuffer;
20
import java.util.ArrayList;
22
import java.util.ArrayList;
21
import java.util.HashMap;
23
import java.util.HashMap;
Lines 645-651 Link Here
645
        	fdataProcessor = (StatGeneratorDataProcessor) LoadersUtils.locateDataProcessor(agentProxy);
647
        	fdataProcessor = (StatGeneratorDataProcessor) LoadersUtils.locateDataProcessor(agentProxy);
646
          	if (fdataProcessor == null) 
648
          	if (fdataProcessor == null) 
647
            {
649
            {
648
          		fdataProcessor = new StatGeneratorDataProcessor(agentProxy);
650
          		fdataProcessor = new FilterDataProcessor(agentProxy);
649
               LoadersUtils.registerDataProcessor(agentProxy, fdataProcessor);                        
651
               LoadersUtils.registerDataProcessor(agentProxy, fdataProcessor);                        
650
            }
652
            }
651
           
653
           
Lines 737-743 Link Here
737
        	fdataProcessor = (StatGeneratorDataProcessor) LoadersUtils.locateDataProcessor(agentProxy);
739
        	fdataProcessor = (StatGeneratorDataProcessor) LoadersUtils.locateDataProcessor(agentProxy);
738
          	if (fdataProcessor == null) 
740
          	if (fdataProcessor == null) 
739
            {
741
            {
740
          		fdataProcessor = new StatGeneratorDataProcessor(agentProxy);
742
          		fdataProcessor = new FilterDataProcessor(agentProxy);
741
               LoadersUtils.registerDataProcessor(agentProxy, fdataProcessor);                        
743
               LoadersUtils.registerDataProcessor(agentProxy, fdataProcessor);                        
742
            }
744
            }
743
           
745
           
Lines 978-982 Link Here
978
			return agentActive;
980
			return agentActive;
979
		}
981
		}
980
	}
982
	}
983
984
985
	class FilterDataProcessor extends StatGeneratorDataProcessor
986
	{
987
988
		public FilterDataProcessor(TRCAgentProxy agentProxy) {
989
			super(agentProxy);
990
		}
991
992
		public void incommingStream(InputStream inputStream, InetAddress peer) {
993
			super.incommingStream(new FilterInputStream(inputStream), peer);
994
		}
995
		
996
	}
981
	
997
	
998
	class FilterInputStream extends InputStream{
999
		
1000
		public FilterInputStream(InputStream inputStream) {
1001
			super();
1002
			this.inputStream = inputStream;
1003
		}
1004
1005
		public int read() throws IOException {
1006
			int i = inputStream.read();
1007
			System.out.print((char)i);
1008
			return i;
1009
		}
1010
	
1011
		private InputStream inputStream;
1012
	}
982
}
1013
}
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/CombinedMetricProvider.java (+114 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: CombinedMetricProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.platform.instrumentation.ui.internal.core;
13
14
import java.util.List;
15
16
/**
17
 * Combine implementation of {@link IMetricNameProvider}.
18
 * 
19
 * @since TPTP 4.5.1
20
 * @author Gao Peng
21
 * 
22
 */
23
public class CombinedMetricProvider implements IMetricNameProvider {
24
25
	/**
26
	 * Default ID because this implementation of {@link IMetricNameProvider} is
27
	 * not defined in plugin.xml.
28
	 */
29
	private static final String COMBINED_ID = "CombinedMetricProvider";
30
31
	/**
32
	 * @param metricProviders
33
	 *            Implemenations of {@link IMetricNameProvider} which will be
34
	 *            combined.
35
	 */
36
	public CombinedMetricProvider(IMetricNameProvider[] metricProviders) {
37
		this.metricProviders = metricProviders;
38
	}
39
40
	/**
41
	 * @param metricProviderList
42
	 *            Implemenations of {@link IMetricNameProvider} which will be
43
	 *            combined.
44
	 */
45
	public CombinedMetricProvider(List metricProviderList) {
46
		this.metricProviders = (IMetricNameProvider[]) metricProviderList
47
				.toArray(new IMetricNameProvider[metricProviderList.size()]);
48
	}
49
50
	public String getId() {
51
		return id;
52
	}
53
54
	public void setId(String id) {
55
		this.id = id;
56
	}
57
58
	/**
59
	 * It will return the name of all of the combined
60
	 * {@link IMetricNameProvider} implementations with the format :
61
	 * id,metricName
62
	 * 
63
	 * @see org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider#getNames()
64
	 */
65
	public String[] getNames() {
66
		if ((metricProviders == null) || (metricProviders.length == 0)) {
67
			return null;
68
		}
69
70
		String[] names = getFullName(metricProviders[0]);
71
		for (int i = 1; i < metricProviders.length; i++) {
72
			IMetricNameProvider metricProvider = metricProviders[i];
73
			String[] newNames = getFullName(metricProvider);
74
			String[] combinedNames = new String[names.length + newNames.length];
75
			System.arraycopy(names, 0, combinedNames, 0, names.length);
76
			System.arraycopy(newNames, names.length, combinedNames,
77
					names.length, newNames.length);
78
			names = combinedNames;
79
		}
80
81
		return names;
82
	}
83
84
	/**
85
	 * Get names with the ID of the metric provider.
86
	 * 
87
	 * @param metricProvider
88
	 * @return
89
	 */
90
	private String[] getFullName(IMetricNameProvider metricProvider) {
91
		String[] names = metricProvider.getNames();
92
		String[] fullNames = new String[names.length];
93
		String metricProviderId = metricProvider.getId();
94
		for (int i = 0; i < fullNames.length; i++) {
95
			fullNames[i] = metricProviderId + IMetricNameProvider.SEPARATOR
96
					+ names[i];
97
		}
98
		return fullNames;
99
	}
100
101
	/**
102
	 * No metric value provider for this {@link IMetricNameProvider}
103
	 * implementation.
104
	 * 
105
	 * @see org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider#getMetricValueProviderName()
106
	 */
107
	public String getMetricValueProviderName() {
108
		return null;
109
	}
110
111
	private IMetricNameProvider[] metricProviders;
112
	private String id = COMBINED_ID;
113
114
}
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/IMetricNameProvider.java (+64 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: IMetricNameProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.platform.instrumentation.ui.internal.core;
13
14
/**
15
 * Interface for metricProvider extension point.
16
 * 
17
 * @since TPTP 4.5.1
18
 * @author Gao Peng
19
 * 
20
 */
21
public interface IMetricNameProvider {
22
23
	/**
24
	 * The separator between the metric information.
25
	 */
26
	String METRIC_SEPERATOR = "\t";
27
28
	/**
29
	 * The separator between the parts of the metric information.
30
	 */
31
	String SEPARATOR = ",";
32
33
	/**
34
	 * The prefix of the key which used in ILaunchConfiguration.
35
	 */
36
	String METRIC_PREFIX = "METRIC_PREFIX";
37
38
	/**
39
	 * @return the ID of the metric provider.
40
	 */
41
	String getId();
42
43
	/**
44
	 * Set the ID of the metric provider.
45
	 */
46
	void setId(String id);
47
48
	/**
49
	 * @return the name list of the metric provider. The name should start with
50
	 *         the id and SEPARATOR.
51
	 */
52
	String[] getNames();
53
54
	/**
55
	 * Get the name of the metric value provider. It should be a quality class
56
	 * name and be used when profiling. <br>
57
	 * 
58
	 * I have to split the name provider and the value provider because this
59
	 * plugin are not used in agent controller.
60
	 * 
61
	 * @return
62
	 */
63
	String getMetricValueProviderName();
64
}
(-)schema/metricProvider.exsd (+130 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.tptp.platform.instrumentation.ui" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appinfo>
6
         <meta.schema plugin="org.eclipse.tptp.platform.instrumentation.ui" id="metricProvider" name="metricProvider"/>
7
      </appinfo>
8
      <documentation>
9
         This extension point is used to register metric provider. The metric provider supports metric data.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appinfo>
16
            <meta.element />
17
         </appinfo>
18
      </annotation>
19
      <complexType>
20
         <sequence>
21
            <element ref="metricProvider" minOccurs="1" maxOccurs="unbounded"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appinfo>
43
                  <meta.attribute translatable="true"/>
44
               </appinfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49
50
   <element name="metricProvider">
51
      <complexType>
52
         <attribute name="name" type="string">
53
            <annotation>
54
               <documentation>
55
                  
56
               </documentation>
57
            </annotation>
58
         </attribute>
59
         <attribute name="id" type="string" use="required">
60
            <annotation>
61
               <documentation>
62
                  
63
               </documentation>
64
            </annotation>
65
         </attribute>
66
         <attribute name="providerClass" type="string">
67
            <annotation>
68
               <documentation>
69
                  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.
70
               </documentation>
71
               <appinfo>
72
                  <meta.attribute kind="java" basedOn=":org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider"/>
73
               </appinfo>
74
            </annotation>
75
         </attribute>
76
      </complexType>
77
   </element>
78
79
   <annotation>
80
      <appinfo>
81
         <meta.section type="since"/>
82
      </appinfo>
83
      <documentation>
84
         Since TPTP 4.5.1
85
      </documentation>
86
   </annotation>
87
88
   <annotation>
89
      <appinfo>
90
         <meta.section type="examples"/>
91
      </appinfo>
92
      <documentation>
93
            &lt;extension
94
         point=&quot;org.eclipse.tptp.platform.instrumentation.ui.metricProvider&quot;&gt;
95
      &lt;metricProvider
96
            id=&quot;org.eclipse.tptp.trace.arm.PttMetricProvider&quot;
97
            providerClass=&quot;org.eclipse.tptp.trace.arm.internal.model.impl.PttMetricNameProvider&quot;&gt;
98
      &lt;/metricProvider&gt;
99
   &lt;/extension&gt;
100
      </documentation>
101
   </annotation>
102
103
   <annotation>
104
      <appinfo>
105
         <meta.section type="apiinfo"/>
106
      </appinfo>
107
      <documentation>
108
         [Enter API information here.]
109
      </documentation>
110
   </annotation>
111
112
   <annotation>
113
      <appinfo>
114
         <meta.section type="implementation"/>
115
      </appinfo>
116
      <documentation>
117
         [Enter information about supplied implementation of this extension point.]
118
      </documentation>
119
   </annotation>
120
121
   <annotation>
122
      <appinfo>
123
         <meta.section type="copyright"/>
124
      </appinfo>
125
      <documentation>
126
         Copyright (c) 2008 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
127
      </documentation>
128
   </annotation>
129
130
</schema>
(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/core/MetricProviderManager.java (+120 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: MetricProviderManager.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.platform.instrumentation.ui.internal.core;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.core.runtime.IConfigurationElement;
18
import org.eclipse.core.runtime.IExtension;
19
import org.eclipse.core.runtime.IExtensionPoint;
20
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.tptp.platform.instrumentation.ui.internal.LogHelper;
22
23
/**
24
 * Manager of the metric provider. It scans for the metricProvider extensions
25
 * and will register them with this manager.
26
 * 
27
 * @since TPTP 4.5.1
28
 * @author Gao Peng
29
 * 
30
 */
31
public class MetricProviderManager {
32
33
	/** The metric provider point extension */
34
	private static final String METRIC_PROVIDER_POINT_EXTENSION = "org.eclipse.tptp.platform.instrumentation.ui.metricProvider";
35
36
	/** This instance of this singleton class */
37
	private static MetricProviderManager instance;
38
39
	/**
40
	 * Stores the {@link IMetricNameProvider} instances. <br>
41
	 * KEY = metric provider id. <br>
42
	 * VALUE = An instance of metric provider
43
	 */
44
	private Map metricProviders = new HashMap();
45
46
	/**
47
	 * Hide the default constructor. This ensures against outside instantiation.
48
	 */
49
	private MetricProviderManager() {
50
		initialize();
51
	}
52
53
	/**
54
	 * Scan the registered instrument points and loads them in the
55
	 * instrumentPoints table.
56
	 */
57
	public void initialize() {
58
		metricProviders.clear();
59
		IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
60
				.getExtensionPoint(METRIC_PROVIDER_POINT_EXTENSION);
61
62
		if (extensionPoint == null) {
63
			return;
64
		}
65
66
		IExtension extension[] = extensionPoint.getExtensions();
67
68
		// Iterate through each instrument point element to construct the
69
		// instrument object and to associate it with the right entity.
70
		for (int i = 0; i < extension.length; i++) {
71
			IConfigurationElement element[] = extension[i]
72
					.getConfigurationElements();
73
			for (int j = 0; j < element.length; j++) {
74
				try {
75
					String id = element[j].getAttribute("id");
76
					IMetricNameProvider provider = (IMetricNameProvider) element[j]
77
							.createExecutableExtension("providerClass");
78
					provider.setId(id);
79
					metricProviders.put(id, provider);
80
				} catch (Exception ex) {
81
					// report the problem.
82
					LogHelper.error(ex);
83
				}
84
			}
85
		}
86
	}
87
88
	/**
89
	 * Returns the instance of this singleton class.
90
	 * 
91
	 * @return The instance of this singleton class
92
	 */
93
	public static MetricProviderManager getInstance() {
94
		if (instance == null)
95
			instance = new MetricProviderManager();
96
		return instance;
97
	}
98
99
	/**
100
	 * Returns all the registered InstrumentPoint
101
	 * 
102
	 * @return an array of all the registered InstrumentPoint
103
	 */
104
	public IMetricNameProvider[] getMetricProviders() {
105
		return (IMetricNameProvider[]) metricProviders.values().toArray(
106
				new IMetricNameProvider[metricProviders.size()]);
107
	}
108
109
	/**
110
	 * Returns an InstrumentPoint with a given id.
111
	 * 
112
	 * @param id
113
	 *            the id
114
	 * @return an InstrumentPoint
115
	 */
116
	public IMetricNameProvider getMetricProvider(String id) {
117
		return (IMetricNameProvider) metricProviders.get(id);
118
	}
119
120
}
(-)src/org/eclipse/tptp/trace/arm/ui/internal/util/messages.properties (+2 lines)
Lines 23-28 Link Here
23
NAME_COLUMN = Name
23
NAME_COLUMN = Name
24
DESCP_COLUMN = Description
24
DESCP_COLUMN = Description
25
FILTER_LABEL = Filter
25
FILTER_LABEL = Filter
26
METRIC_LABEL = Metric
26
NO_DESCP_LABEL = No description given
27
NO_DESCP_LABEL = No description given
27
INTERNAL_ERROR = Internal error in ARM analysis type
28
INTERNAL_ERROR = Internal error in ARM analysis type
28
29
Lines 30-35 Link Here
30
ERROR_INSTRUMENT_EXIST_DETAIL = Occured in method: {0}()\n
31
ERROR_INSTRUMENT_EXIST_DETAIL = Occured in method: {0}()\n
31
32
32
INSTRUMENT_POINT_FILTER_TITLE = Instrument Point Filter
33
INSTRUMENT_POINT_FILTER_TITLE = Instrument Point Filter
34
ARM_METRIC_TITLE = Available metric properties
33
35
34
DEFAULT_SERVLET_FILTER = Default Servlet Filter Set
36
DEFAULT_SERVLET_FILTER = Default Servlet Filter Set
35
DEFAULT_JDBC_FILTER = Default JDBC Filter Set
37
DEFAULT_JDBC_FILTER = Default JDBC Filter Set
(-)src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmMessages.java (+2 lines)
Lines 34-44 Link Here
34
	public static String NAME_COLUMN;
34
	public static String NAME_COLUMN;
35
	public static String DESCP_COLUMN;
35
	public static String DESCP_COLUMN;
36
	public static String FILTER_LABEL;
36
	public static String FILTER_LABEL;
37
	public static String METRIC_LABEL;
37
	public static String NO_DESCP_LABEL;
38
	public static String NO_DESCP_LABEL;
38
	public static String INTERNAL_ERROR;
39
	public static String INTERNAL_ERROR;
39
	public static String ERROR_INTRUMENT_EXIST;
40
	public static String ERROR_INTRUMENT_EXIST;
40
	public static String ERROR_INSTRUMENT_EXIST_DETAIL;
41
	public static String ERROR_INSTRUMENT_EXIST_DETAIL;
41
	public static String INSTRUMENT_POINT_FILTER_TITLE;
42
	public static String INSTRUMENT_POINT_FILTER_TITLE;
43
	public static String ARM_METRIC_TITLE;
42
	public static String DEFAULT_SERVLET_FILTER;
44
	public static String DEFAULT_SERVLET_FILTER;
43
	public static String DEFAULT_JDBC_FILTER;
45
	public static String DEFAULT_JDBC_FILTER;
44
	public static String DEFAULT_J2EE_FILTER;
46
	public static String DEFAULT_J2EE_FILTER;
(-)src/org/eclipse/tptp/trace/arm/ui/internal/util/ArmConstants.java (+2 lines)
Lines 32-37 Link Here
32
	public static final String TRANSACTION_GOOD_STATEMENT = "armStatus = " + ARM_TRANSACTION_GOOD_EXPRESSION + ";";
32
	public static final String TRANSACTION_GOOD_STATEMENT = "armStatus = " + ARM_TRANSACTION_GOOD_EXPRESSION + ";";
33
	public static final String TRANSACTION_FAILED_STATEMENT = "armStatus = " + ARM_TRANSACTION_FAILED_EXPRESSION + ";";
33
	public static final String TRANSACTION_FAILED_STATEMENT = "armStatus = " + ARM_TRANSACTION_FAILED_EXPRESSION + ";";
34
	
34
	
35
	public static final String ARM_PREFIX_FOR_METRIC = "ARM";
36
	
35
	public static final String ACTIVE_FILTER_PREFIX = "ACTIVE_FILTER_FOR_";
37
	public static final String ACTIVE_FILTER_PREFIX = "ACTIVE_FILTER_FOR_";
36
	public static final String ENABLE_FILTER_PREFIX = "ENABLE_FILTER_FOR_";
38
	public static final String ENABLE_FILTER_PREFIX = "ENABLE_FILTER_FOR_";
37
	public static final String FILTER_SET_PREFIX = "FILTER_SET_FOR_";
39
	public static final String FILTER_SET_PREFIX = "FILTER_SET_FOR_";
(-)src/org/eclipse/tptp/trace/arm/ui/internal/configuration/InstrumentPointSelectionUI.java (-9 / +24 lines)
Lines 12-17 Link Here
12
package org.eclipse.tptp.trace.arm.ui.internal.configuration;
12
package org.eclipse.tptp.trace.arm.ui.internal.configuration;
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Arrays;
15
import java.util.List;
16
import java.util.List;
16
17
17
import org.eclipse.debug.core.ILaunchConfiguration;
18
import org.eclipse.debug.core.ILaunchConfiguration;
Lines 64-70 Link Here
64
	/* The indexs for the points table */
65
	/* The indexs for the points table */
65
	private final static int NAME_INDEX = 0;
66
	private final static int NAME_INDEX = 0;
66
	private final static int FILTER_INDEX = 1;
67
	private final static int FILTER_INDEX = 1;
67
	private final static int DESCRIPTION_INDEX = 2;
68
	private final static int METRIC_INDEX = 2;
69
	private final static int DESCRIPTION_INDEX = 3;
68
	
70
	
69
	private final static String ARM_INSTRUM_TYPE = 
71
	private final static String ARM_INSTRUM_TYPE = 
70
		"org.eclipse.tptp.trace.arm.ui.armInstrumentType";
72
		"org.eclipse.tptp.trace.arm.ui.armInstrumentType";
Lines 101-107 Link Here
101
	public void setSelectItems(List list) {
103
	public void setSelectItems(List list) {
102
		TableItem[] items = pointsTable.getItems();
104
		TableItem[] items = pointsTable.getItems();
103
		
105
		
104
		if (list != null || list.size() > 0) {
106
		if (list != null && list.size() > 0) {
105
			for (int i = 0; i < items.length; i++) {
107
			for (int i = 0; i < items.length; i++) {
106
				InstrumentPoint entry = (InstrumentPoint) items[i].getData();
108
				InstrumentPoint entry = (InstrumentPoint) items[i].getData();
107
				if (list.contains(entry.getId())) {
109
				if (list.contains(entry.getId())) {
Lines 149-154 Link Here
149
		TableLayout tableLayout = new TableLayout();
151
		TableLayout tableLayout = new TableLayout();
150
		tableLayout.addColumnData(new ColumnWeightData(150, true));
152
		tableLayout.addColumnData(new ColumnWeightData(150, true));
151
        tableLayout.addColumnData(new ColumnWeightData(50, true));
153
        tableLayout.addColumnData(new ColumnWeightData(50, true));
154
        tableLayout.addColumnData(new ColumnWeightData(50, true));
152
        tableLayout.addColumnData(new ColumnWeightData(200, true));
155
        tableLayout.addColumnData(new ColumnWeightData(200, true));
153
        
156
        
154
        pointsTable.setHeaderVisible(true);
157
        pointsTable.setHeaderVisible(true);
Lines 170-179 Link Here
170
		TableColumn tc2 = new TableColumn(pointsTable, SWT.NONE);
173
		TableColumn tc2 = new TableColumn(pointsTable, SWT.NONE);
171
		tc2.setText(ArmMessages.FILTER_LABEL);
174
		tc2.setText(ArmMessages.FILTER_LABEL);
172
		tc2.setWidth(45);
175
		tc2.setWidth(45);
173
		
176
174
		TableColumn tc3 = new TableColumn(pointsTable, SWT.NONE);
177
		TableColumn tc3 = new TableColumn(pointsTable, SWT.NONE);
175
		tc3.setText(ArmMessages.DESCP_COLUMN);
178
		tc3.setText(ArmMessages.METRIC_LABEL);
176
		tc3.setWidth(200);
179
		tc3.setWidth(45);
180
181
		TableColumn tc4 = new TableColumn(pointsTable, SWT.NONE);
182
		tc4.setText(ArmMessages.DESCP_COLUMN);
183
		tc4.setWidth(200);
177
		
184
		
178
		InstrumentPoint loaders[] = 
185
		InstrumentPoint loaders[] = 
179
			InstrumentPointManager.getInstance().getInstrumentPointsByType(
186
			InstrumentPointManager.getInstance().getInstrumentPointsByType(
Lines 233-241 Link Here
233
	protected void columnClicked(int columnToEdit) {
240
	protected void columnClicked(int columnToEdit) {
234
		IStructuredSelection selection = (IStructuredSelection) pointsList.getSelection();
241
		IStructuredSelection selection = (IStructuredSelection) pointsList.getSelection();
235
		InstrumentPoint vmd = (InstrumentPoint) selection.getFirstElement();
242
		InstrumentPoint vmd = (InstrumentPoint) selection.getFirstElement();
236
		if (vmd != null && (columnToEdit == FILTER_INDEX)) {
243
		if (vmd != null) {
237
			InstrumentPointFiltersDialog intrumentPointDlg = new InstrumentPointFiltersDialog(null, launchConfiguration, vmd.getId());
244
			if (columnToEdit == FILTER_INDEX) {
238
			intrumentPointDlg.open();
245
				InstrumentPointFiltersDialog intrumentPointDlg = new InstrumentPointFiltersDialog(
246
						null, launchConfiguration, vmd.getId());
247
				intrumentPointDlg.open();
248
			} else if (columnToEdit == METRIC_INDEX) {
249
				if (vmd.getMetricProvider() != null) {
250
					ArmMetricsDialog armMetricsDialog = new ArmMetricsDialog(null, launchConfiguration, vmd);
251
					armMetricsDialog.open();
252
				}
253
			}
239
		}
254
		}
240
	}
255
	}
241
	
256
	
Lines 245-251 Link Here
245
	public class InstrumentPointLabelProvider extends LabelProvider implements ITableLabelProvider {
260
	public class InstrumentPointLabelProvider extends LabelProvider implements ITableLabelProvider {
246
		
261
		
247
		public Image getColumnImage(Object element, int columnIndex) {
262
		public Image getColumnImage(Object element, int columnIndex) {
248
			if (columnIndex == FILTER_INDEX) {
263
			if ((columnIndex == FILTER_INDEX)|| (columnIndex == METRIC_INDEX)) {
249
				return ArmUIPlugin.getDefault().getImage("settings");
264
				return ArmUIPlugin.getDefault().getImage("settings");
250
			}
265
			}
251
			return null;
266
			return null;
(-)src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricContentProvider.java (+38 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: ArmMetricContentProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.ui.internal.configuration;
13
14
import org.eclipse.jface.viewers.IStructuredContentProvider;
15
import org.eclipse.jface.viewers.Viewer;
16
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider;
17
18
/**
19
 * Content provider of ArmMetricsDialog.
20
 * 
21
 * @author Gao Peng
22
 * @since TPTP 4.5.1
23
 * 
24
 */
25
public class ArmMetricContentProvider implements IStructuredContentProvider {
26
27
	public Object[] getElements(Object inputElement) {
28
		return ((IMetricNameProvider) inputElement).getNames();
29
	}
30
31
	public void dispose() {
32
		// Do nothing.
33
	}
34
35
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
36
		// Do nothing.
37
	}
38
}
(-)src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricsDialog.java (+174 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: ArmMetricsDialog.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.ui.internal.configuration;
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17
import org.eclipse.hyades.ui.util.GridUtil;
18
import org.eclipse.jface.dialogs.Dialog;
19
import org.eclipse.jface.viewers.CheckboxTableViewer;
20
import org.eclipse.jface.viewers.ColumnLayoutData;
21
import org.eclipse.jface.viewers.ColumnPixelData;
22
import org.eclipse.jface.viewers.TableLayout;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.graphics.Point;
25
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.layout.GridLayout;
27
import org.eclipse.swt.widgets.Composite;
28
import org.eclipse.swt.widgets.Control;
29
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.swt.widgets.Table;
31
import org.eclipse.swt.widgets.TableColumn;
32
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.IMetricNameProvider;
33
import org.eclipse.tptp.platform.instrumentation.ui.internal.core.InstrumentPoint;
34
import org.eclipse.tptp.trace.arm.ui.internal.util.ArmConstants;
35
import org.eclipse.tptp.trace.arm.ui.internal.util.ArmMessages;
36
37
/**
38
 * Dialog to get the configuration of metric.
39
 * 
40
 * @author Gao Peng
41
 * @since TPTP 4.5.1
42
 */
43
public class ArmMetricsDialog extends Dialog {
44
45
	public ArmMetricsDialog(Shell parentShell,
46
			ILaunchConfiguration launchConfiguration,
47
			InstrumentPoint instrumentPoint) {
48
		super(parentShell);
49
		setShellStyle(getShellStyle() | SWT.RESIZE);
50
51
		this.instrumentPoint = instrumentPoint;
52
		this.launchConfiguration = launchConfiguration;
53
	}
54
55
	protected Control createDialogArea(Composite parent) {
56
		Composite result = (Composite) super.createDialogArea(parent);
57
58
		Composite tableGroup = new Composite(result, SWT.NONE);
59
		GridLayout layout = new GridLayout();
60
		layout.numColumns = 1;
61
		tableGroup.setLayout(layout);
62
		GridData data = GridUtil.createFill();
63
		data.heightHint = 100;
64
65
		tableGroup.setLayoutData(data);
66
		Table filterSetTable = new Table(tableGroup, SWT.V_SCROLL | SWT.BORDER
67
				| SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK);
68
		filterSetTable.setLinesVisible(false);
69
		filterSetTable.setLayoutData(GridUtil.createFill());
70
71
		armTableViewer = new CheckboxTableViewer(filterSetTable);
72
		armTableViewer.setContentProvider(new ArmMetricContentProvider());
73
		armTableViewer.setLabelProvider(new ArmMetricLabelProvider());
74
		armTableViewer.setInput(instrumentPoint.getMetricProvider());
75
76
		TableLayout layoutt = new TableLayout();
77
		filterSetTable.setLayout(layoutt);
78
79
		ColumnLayoutData l = new ColumnPixelData(420, true);
80
		layoutt.addColumnData(l);
81
82
		TableColumn tc = new TableColumn(filterSetTable, SWT.NONE, 0);
83
		tc.setResizable(l.resizable);
84
85
		configUI();
86
87
		return result;
88
	}
89
90
	/**
91
	 * Load configuration of metric from ILaunchConfiguration and setup Table in
92
	 * dialog.
93
	 */
94
	private void configUI() {
95
		try {
96
			String checkedMetrics = launchConfiguration.getAttribute(
97
					getArmKey(), "");
98
			if (!checkedMetrics.equals("")) {
99
				armTableViewer.setCheckedElements(checkedMetrics
100
						.split(IMetricNameProvider.METRIC_SEPERATOR));
101
			}
102
		} catch (CoreException e) {
103
			e.printStackTrace();
104
		}
105
	}
106
107
	/**
108
	 * Override to double the dialog size.
109
	 * 
110
	 * @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
111
	 */
112
	protected Point getInitialSize() {
113
		Point size = super.getInitialSize();
114
		// Double the size of the dialog.
115
		Point doubleSize = new Point(size.x * 2, size.y * 2);
116
		return doubleSize;
117
	}
118
119
	/**
120
	 * Get the configuration of the metric, and save it in ILaunchConfiguration.
121
	 */
122
	protected void okPressed() {
123
		if (launchConfiguration instanceof ILaunchConfigurationWorkingCopy) {
124
			ILaunchConfigurationWorkingCopy workingCopy = (ILaunchConfigurationWorkingCopy) launchConfiguration;
125
126
			StringBuffer buffer = new StringBuffer();
127
			for (int i = 0; i < armTableViewer.getCheckedElements().length; i++) {
128
				String element = (String) armTableViewer.getCheckedElements()[i];
129
				buffer.append(element).append(
130
						IMetricNameProvider.METRIC_SEPERATOR);
131
			}
132
133
			if (buffer.length() == 0) {
134
				workingCopy.removeAttribute(getArmKey());
135
			} else {
136
				workingCopy.setAttribute(getArmKey(), buffer.toString());
137
			}
138
		}
139
140
		super.okPressed();
141
	}
142
143
	/**
144
	 * Get the key to store metric information in ILaunchConfiguration.
145
	 * 
146
	 * @return
147
	 */
148
	private String getArmKey() {
149
		return IMetricNameProvider.METRIC_PREFIX
150
				+ IMetricNameProvider.SEPARATOR
151
				+ ArmConstants.ARM_PREFIX_FOR_METRIC
152
				+ IMetricNameProvider.SEPARATOR + instrumentPoint.getId();
153
	}
154
155
	protected void configureShell(Shell newShell) {
156
		super.configureShell(newShell);
157
		newShell.setText(ArmMessages.ARM_METRIC_TITLE);
158
	}
159
160
	/**
161
	 * ILaunchConfiguration of the workbench.
162
	 */
163
	private ILaunchConfiguration launchConfiguration;
164
	
165
	/**
166
	 * InstrumentPoint about the metric.
167
	 */
168
	private InstrumentPoint instrumentPoint;
169
	
170
	/**
171
	 * CheckboxTableViewer of the Table in dialog.
172
	 */
173
	private CheckboxTableViewer armTableViewer;
174
}
(-)src/org/eclipse/tptp/trace/arm/ui/internal/configuration/ArmMetricLabelProvider.java (+37 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: ArmMetricLabelProvider.java,v 1.1 2008/08/08 20:08:08 gpeng Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.arm.ui.internal.configuration;
13
14
import org.eclipse.jface.viewers.ITableLabelProvider;
15
import org.eclipse.jface.viewers.LabelProvider;
16
import org.eclipse.swt.graphics.Image;
17
18
/**
19
 * Label provider of ArmMetricsDialog.
20
 * 
21
 * @author Gao Peng
22
 * @since TPTP 4.5.1
23
 * 
24
 */
25
public class ArmMetricLabelProvider extends LabelProvider implements
26
		ITableLabelProvider {
27
28
	public Image getColumnImage(Object element, int columnIndex) {
29
		// No image.
30
		return null;
31
	}
32
33
	public String getColumnText(Object element, int columnIndex) {
34
		return (String) element;
35
	}
36
37
}

Return to bug 166692