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
9 * Contributors: Alvaro Sanchez-Leon - Initial implementation
10 *******************************************************************************/
11 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.evProcessor
;
13 import java
.util
.Vector
;
15 import org
.eclipse
.linuxtools
.lttng
.event
.LttngEvent
;
16 import org
.eclipse
.linuxtools
.lttng
.state
.StateStrings
.Events
;
17 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.ILttngEventProcessor
;
18 import org
.eclipse
.linuxtools
.lttng
.state
.model
.LttngProcessState
;
19 import org
.eclipse
.linuxtools
.lttng
.state
.model
.LttngTraceState
;
20 import org
.eclipse
.linuxtools
.lttng
.ui
.TraceDebug
;
21 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeComponent
;
22 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEvent
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEventProcess
;
26 * Creates specific finish state data request
31 public class FlowFinishUpdateHandler
extends AbsFlowTRangeUpdate
32 implements ILttngEventProcessor
{
34 public Events
getEventHandleType() {
40 public boolean process(LttngEvent trcEvent
, LttngTraceState traceSt
) {
41 // The end of the last state is unknown since it's beyond the requested time range window. Create this last
42 // event to half page after the visible window but not beyond the end of trace
43 long endOfTrace
= traceSt
.getContext().getTraceTimeWindow().getEndTime().getValue();
44 long halfWindow
= (params
.getEndTime() - params
.getStartTime()) / 2;
46 // End of event common to all processes within the trace for this specific request
47 long endOfEvent
= params
.getEndTime() + halfWindow
;
48 if (endOfEvent
> endOfTrace
) {
49 endOfEvent
= endOfTrace
;
52 TraceDebug
.debug("Number of localProcesses: "
53 + procContainer
.readItems().length
);
54 // to identify the process relevant to the traceState
55 String traceId
= traceSt
.getTraceId();
56 int numLocalFound
= 0;
57 int numLocalNotFound
= 0;
58 int numWithNoChildren
= 0;
59 for (TimeRangeEventProcess localProcess
: procContainer
.readItems()) {
60 LttngProcessState stateProcess
= lttv_state_find_process(traceSt
,
61 localProcess
.getCpu(), localProcess
.getPid());
63 // Drawing the last state for processes related to the current trace
65 if (!localProcess
.getTraceID().equals(traceId
)) {
69 // Check if the process is in the state provider, it is the case
70 // when the requested time frame did not include any events for a
72 if (stateProcess
== null) {
73 // Get Start time from the end time of previous event
74 Vector
<TimeRangeComponent
> childrenEvents
= localProcess
78 if (childrenEvents
.size() > 0) {
79 TimeRangeComponent prevEvent
= childrenEvents
80 .get(childrenEvents
.size() - 1);
81 if (prevEvent
instanceof TimeRangeEvent
) {
82 TimeRangeEvent prevTimeRange
= (TimeRangeEvent
) prevEvent
;
83 // calculate the next good time to draw the event
84 // nextGoodTime = prevTimeRange.getStopTime() + 1;
85 nextGoodTime
= localProcess
.getNext_good_time();
86 stateMode
= prevTimeRange
.getStateMode();
88 // Draw with the Local information since the current
90 // not contain events related to this process
91 makeDraw(traceSt
, nextGoodTime
, endOfEvent
, localProcess
, params
, stateMode
);
93 TraceDebug
.debug("previous event not instance of TimeRangeEvent?: "
94 + prevEvent
.getClass().getSimpleName());
105 // Draw the last state for this process
106 makeDraw(traceSt
, endOfEvent
, stateProcess
, localProcess
, params
);
109 TraceDebug
.debug("Print Last Event: NumLocalFound " + numLocalFound
110 + "; NumLocalNotFound: " + numLocalNotFound
111 + "; NumWithNoChildren: " + numWithNoChildren
);