1 package org
.eclipse
.linuxtools
.lttng
.core
.tests
.headless
;
2 /*******************************************************************************
3 * Copyright (c) 2009 Ericsson
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
11 * William Bourque (wbourque@gmail.com) - Initial API and implementation
12 *******************************************************************************/
14 import org
.eclipse
.linuxtools
.lttng
.core
.event
.LttngEvent
;
15 import org
.eclipse
.linuxtools
.lttng
.core
.event
.LttngTimestamp
;
16 import org
.eclipse
.linuxtools
.lttng
.core
.trace
.LTTngTrace
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEvent
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimeRange
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.experiment
.TmfExperiment
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.request
.TmfEventRequest
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
23 @SuppressWarnings("nls")
24 public class TmfTraceTest
extends TmfEventRequest
<LttngEvent
> {
26 @SuppressWarnings("unchecked")
27 public TmfTraceTest(Class
<?
extends TmfEvent
> dataType
, TmfTimeRange range
, int nbRequested
) {
28 super((Class
<LttngEvent
>)dataType
, range
, nbRequested
, 1);
33 public static final String TRACE_PATH
= "/home/william/trace-614601events-nolost-newformat";
35 // *** Change this to run several time over the same trace
36 public static final int NB_OF_PASS
= 1;
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;
44 public static int nbEvent
= 0;
45 public static int nbPassDone
= 0;
46 public static TmfExperiment
<LttngEvent
> fExperiment
= null;
49 public static void main(String
[] args
) {
52 // OUr experiment will contains ONE trace
53 @SuppressWarnings("unchecked")
54 ITmfTrace
<LttngEvent
>[] traces
= new ITmfTrace
[1];
55 traces
[0] = new LTTngTrace(TRACE_PATH
);
56 // Create our new experiment
57 fExperiment
= new TmfExperiment
<LttngEvent
>(LttngEvent
.class, "Headless", traces
);
60 // Create a new time range from -infinity to +infinity
61 // That way, we will get "everything" in the trace
62 LttngTimestamp ts1
= new LttngTimestamp(Long
.MIN_VALUE
);
63 LttngTimestamp ts2
= new LttngTimestamp(Long
.MAX_VALUE
);
64 TmfTimeRange tmpRange
= new TmfTimeRange(ts1
, ts2
);
67 // We will issue a request for each "pass".
68 // TMF will then process them synchonously
69 TmfTraceTest request
= null;
70 for ( int x
=0; x
<NB_OF_PASS
; x
++ ) {
71 request
= new TmfTraceTest(LttngEvent
.class, tmpRange
, Integer
.MAX_VALUE
);
72 fExperiment
.sendRequest(request
);
76 catch (NullPointerException e
) {
77 // Silently dismiss Null pointer exception
78 // The only way to "finish" the threads in TMF is by crashing them with null
87 public void handleData(LttngEvent event
) {
88 super.handleData(event
);
89 if ( (event
!= null) && (PARSE_EVENTS
) ) {
90 ((LttngEvent
) event
).getContent().getFields();
92 // *** Uncomment the following to print the parsed content
93 // Warning : this is VERY intensive
95 //System.out.println((LttngEvent)evt[0]);
96 //System.out.println(((LttngEvent)evt[0]).getContent());
103 public void handleCompleted() {
104 if ( nbPassDone
>= NB_OF_PASS
) {
106 System
.out
.println("Nb events : " + nbEvent
);
108 fExperiment
.sendRequest(null);
110 catch (Exception e
) {}
115 public void handleSuccess() {
119 public void handleFailure() {
123 public void handleCancel() {
This page took 0.034028 seconds and 5 git commands to generate.