tmf: Use tabs in statistics view for each traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.core.tests / src / org / eclipse / linuxtools / lttng / core / tests / headless / TmfTraceTest.java
1 package org.eclipse.linuxtools.lttng.core.tests.headless;
2 /*******************************************************************************
3 * Copyright (c) 2009 Ericsson
4 *
5 * All rights reserved. This program and the accompanying materials are
6 * made available under the terms of the Eclipse Public License v1.0 which
7 * accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
9 *
10 * Contributors:
11 * William Bourque (wbourque@gmail.com) - Initial API and implementation
12 *******************************************************************************/
13
14 import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
15 import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp;
16 import org.eclipse.linuxtools.internal.lttng.core.trace.LTTngTrace;
17 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
18 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
19 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
20 import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
21 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
22 import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
23
24 @SuppressWarnings("nls")
25 public class TmfTraceTest extends TmfEventRequest {
26
27 public TmfTraceTest(final Class<? extends TmfEvent> dataType, final TmfTimeRange range, final int nbRequested) {
28 super(dataType, range, nbRequested, 1);
29 }
30
31
32 // Path of the trace
33 public static final String TRACE_PATH = "/home/william/trace-614601events-nolost-newformat";
34
35 // *** Change this to run several time over the same trace
36 public static final int NB_OF_PASS = 1;
37
38 // *** Change this to true to parse all the events in the trace
39 // Otherwise, events are just read
40 public final boolean PARSE_EVENTS = true;
41
42
43 // Work variables
44 public static int nbEvent = 0;
45 public static int nbPassDone = 0;
46 public static TmfExperiment fExperiment = null;
47
48
49 public static void main(final String[] args) {
50
51 try {
52 // OUr experiment will contains ONE trace
53 final ITmfTrace[] traces = new ITmfTrace[1];
54 traces[0] = new LTTngTrace(null, TRACE_PATH);
55 // Create our new experiment
56 fExperiment = new TmfExperiment(LttngEvent.class, "Headless", traces);
57
58
59 // Create a new time range from -infinity to +infinity
60 // That way, we will get "everything" in the trace
61 final LttngTimestamp ts1 = new LttngTimestamp(Long.MIN_VALUE);
62 final LttngTimestamp ts2 = new LttngTimestamp(Long.MAX_VALUE);
63 final TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
64
65
66 // We will issue a request for each "pass".
67 // TMF will then process them synchonously
68 TmfTraceTest request = null;
69 for ( int x=0; x<NB_OF_PASS; x++ ) {
70 request = new TmfTraceTest(LttngEvent.class, tmpRange, Integer.MAX_VALUE );
71 fExperiment.sendRequest(request);
72 nbPassDone++;
73 }
74 }
75 catch (final NullPointerException e) {
76 // Silently dismiss Null pointer exception
77 // The only way to "finish" the threads in TMF is by crashing them with null
78 }
79 catch (final Exception e) {
80 e.printStackTrace();
81 }
82
83 }
84
85 @Override
86 public void handleData(final ITmfEvent event) {
87 super.handleData(event);
88 if ( (event != null) && (PARSE_EVENTS) ) {
89 event.getContent().getFields();
90
91 // *** Uncomment the following to print the parsed content
92 // Warning : this is VERY intensive
93 //
94 //System.out.println((LttngEvent)evt[0]);
95 //System.out.println(((LttngEvent)evt[0]).getContent());
96
97 nbEvent++;
98 }
99 }
100
101 @Override
102 public void handleCompleted() {
103 if ( nbPassDone >= NB_OF_PASS ) {
104 try {
105 System.out.println("Nb events : " + nbEvent);
106
107 fExperiment.sendRequest(null);
108 }
109 catch (final Exception e) {}
110 }
111 }
112
113 @Override
114 public void handleSuccess() {
115 }
116
117 @Override
118 public void handleFailure() {
119 }
120
121 @Override
122 public void handleCancel() {
123 }
124
125 }
This page took 0.035727 seconds and 5 git commands to generate.