1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
4 * All rights reserved. This program and the accompanying materials are made
5 * 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 * Alvaro Sanchez-Leon - Initial implementation
11 * Michel Dagenais (michel.dagenais@polymtl.ca) - Reference C implementation, used with permission
12 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.evProcessor
;
15 import java
.util
.Vector
;
17 import org
.eclipse
.linuxtools
.lttng
.event
.LttngEvent
;
18 import org
.eclipse
.linuxtools
.lttng
.state
.StateStrings
.Events
;
19 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.ILttngEventProcessor
;
20 import org
.eclipse
.linuxtools
.lttng
.state
.model
.LttngProcessState
;
21 import org
.eclipse
.linuxtools
.lttng
.state
.model
.LttngTraceState
;
22 import org
.eclipse
.linuxtools
.lttng
.ui
.TraceDebug
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeComponent
;
24 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEvent
;
25 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEventProcess
;
28 * Creates specific finish state data request
33 public class FlowFinishUpdateHandler
extends AbsFlowTRangeUpdate
34 implements ILttngEventProcessor
{
36 public Events
getEventHandleType() {
42 public boolean process(LttngEvent trcEvent
, LttngTraceState traceSt
) {
43 // The end of the last state is unknown since it's beyond the requested time range window. Create this last
44 // event to half page after the visible window but not beyond the end of trace
45 long endOfTrace
= traceSt
.getContext().getTraceTimeWindow().getEndTime().getValue();
46 long halfWindow
= (params
.getEndTime() - params
.getStartTime()) / 2;
48 // End of event common to all processes within the trace for this specific request
49 long endOfEvent
= params
.getEndTime() + halfWindow
;
50 if (endOfEvent
> endOfTrace
) {
51 endOfEvent
= endOfTrace
;
54 TraceDebug
.debug("Number of localProcesses: " + procContainer
.readItems().length
); //$NON-NLS-1$
55 // to identify the process relevant to the traceState
56 String traceId
= traceSt
.getTraceId();
57 int numLocalFound
= 0;
58 int numLocalNotFound
= 0;
59 int numWithNoChildren
= 0;
60 for (TimeRangeEventProcess localProcess
: procContainer
.readItems()) {
61 LttngProcessState stateProcess
= lttv_state_find_process(traceSt
,
62 localProcess
.getCpu(), localProcess
.getPid());
64 // Drawing the last state for processes related to the current trace
66 if (!localProcess
.getTraceID().equals(traceId
)) {
70 // Check if the process is in the state provider, it is the case
71 // when the requested time frame did not include any events for a
73 if (stateProcess
== null) {
74 // Get Start time from the end time of previous event
75 Vector
<TimeRangeComponent
> childrenEvents
= localProcess
79 if (childrenEvents
.size() > 0) {
80 TimeRangeComponent prevEvent
= childrenEvents
81 .get(childrenEvents
.size() - 1);
82 if (prevEvent
instanceof TimeRangeEvent
) {
83 TimeRangeEvent prevTimeRange
= (TimeRangeEvent
) prevEvent
;
84 // calculate the next good time to draw the event
85 // nextGoodTime = prevTimeRange.getStopTime() + 1;
86 nextGoodTime
= localProcess
.getNext_good_time();
87 stateMode
= prevTimeRange
.getStateMode();
89 // Draw with the Local information since the current
91 // not contain events related to this process
92 makeDraw(traceSt
, nextGoodTime
, endOfEvent
, localProcess
, params
, stateMode
);
94 TraceDebug
.debug("previous event not instance of TimeRangeEvent?: " //$NON-NLS-1$
95 + prevEvent
.getClass().getSimpleName());
106 // Draw the last state for this process
107 makeDraw(traceSt
, endOfEvent
, stateProcess
, localProcess
, params
);
110 TraceDebug
.debug("Print Last Event: NumLocalFound " + numLocalFound
//$NON-NLS-1$
111 + "; NumLocalNotFound: " + numLocalNotFound
//$NON-NLS-1$
112 + "; NumWithNoChildren: " + numWithNoChildren
); //$NON-NLS-1$