1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * William Bourque (wbourque@gmail.com) - Initial API and implementation
11 *******************************************************************************/
13 import org
.eclipse
.linuxtools
.lttng
.event
.LttngEvent
;
14 import org
.eclipse
.linuxtools
.lttng
.event
.LttngTimestamp
;
15 import org
.eclipse
.linuxtools
.lttng
.trace
.LTTngTrace
;
16 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
17 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
18 import org
.eclipse
.linuxtools
.tmf
.experiment
.TmfExperiment
;
19 import org
.eclipse
.linuxtools
.tmf
.request
.TmfEventRequest
;
20 import org
.eclipse
.linuxtools
.tmf
.trace
.ITmfTrace
;
22 public class TmfTraceTest
extends TmfEventRequest
<LttngEvent
> {
24 @SuppressWarnings("unchecked")
25 public TmfTraceTest(Class
<?
extends TmfEvent
> dataType
, TmfTimeRange range
, int nbRequested
) {
26 super((Class
<LttngEvent
>)dataType
, range
, nbRequested
, 1);
31 public static final String TRACE_PATH
= "/home/william/trace-614601events-nolost-newformat";
33 // *** Change this to run several time over the same trace
34 public static final int NB_OF_PASS
= 1;
36 // *** Change this to true to parse all the events in the trace
37 // Otherwise, events are just read
38 public final boolean PARSE_EVENTS
= true;
42 public static int nbEvent
= 0;
43 public static int nbPassDone
= 0;
44 public static TmfExperiment
<LttngEvent
> fExperiment
= null;
47 public static void main(String
[] args
) {
50 // OUr experiment will contains ONE trace
51 ITmfTrace
[] traces
= new ITmfTrace
[1];
52 traces
[0] = new LTTngTrace(TRACE_PATH
);
53 // Create our new experiment
54 fExperiment
= new TmfExperiment
<LttngEvent
>(LttngEvent
.class, "Headless", traces
);
57 // Create a new time range from -infinity to +infinity
58 // That way, we will get "everything" in the trace
59 LttngTimestamp ts1
= new LttngTimestamp(Long
.MIN_VALUE
);
60 LttngTimestamp ts2
= new LttngTimestamp(Long
.MAX_VALUE
);
61 TmfTimeRange tmpRange
= new TmfTimeRange(ts1
, ts2
);
64 // We will issue a request for each "pass".
65 // TMF will then process them synchonously
66 TmfTraceTest request
= null;
67 for ( int x
=0; x
<NB_OF_PASS
; x
++ ) {
68 request
= new TmfTraceTest(LttngEvent
.class, tmpRange
, Integer
.MAX_VALUE
);
69 fExperiment
.sendRequest(request
);
73 catch (NullPointerException e
) {
74 // Silently dismiss Null pointer exception
75 // The only way to "finish" the threads in TMF is by crashing them with null
85 public void handleData() {
86 LttngEvent
[] result
= getData();
88 LttngEvent evt
= (result
.length
> 0) ? result
[0] : null;
90 if ( (evt
!= null) && (PARSE_EVENTS
) ) {
91 ((LttngEvent
) evt
).getContent().getFields();
93 // *** Uncomment the following to print the parsed content
94 // Warning : this is VERY intensive
96 //System.out.println((LttngEvent)evt[0]);
97 //System.out.println(((LttngEvent)evt[0]).getContent());
104 public void handleCompleted() {
105 if ( nbPassDone
>= NB_OF_PASS
) {
107 System
.out
.println("Nb events : " + nbEvent
);
109 fExperiment
.sendRequest(null);
111 catch (Exception e
) {}
116 public void handleSuccess() {
120 public void handleFailure() {
124 public void handleCancel() {
This page took 0.036881 seconds and 5 git commands to generate.