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
.core
.event
.LttngEvent
;
18 import org
.eclipse
.linuxtools
.lttng
.core
.state
.StateStrings
.Events
;
19 import org
.eclipse
.linuxtools
.lttng
.core
.state
.evProcessor
.ILttngEventProcessor
;
20 import org
.eclipse
.linuxtools
.lttng
.core
.state
.model
.LttngProcessState
;
21 import org
.eclipse
.linuxtools
.lttng
.core
.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() {
41 @SuppressWarnings("deprecation")
43 public boolean process(LttngEvent trcEvent
, LttngTraceState traceSt
) {
44 // The end of the last state is unknown since it's beyond the requested time range window. Create this last
45 // event to half page after the visible window but not beyond the end of trace
46 long endOfTrace
= traceSt
.getContext().getTraceTimeWindow().getEndTime().getValue();
47 long halfWindow
= (params
.getEndTime() - params
.getStartTime()) / 2;
49 // End of event common to all processes within the trace for this specific request
50 long endOfEvent
= params
.getEndTime() + halfWindow
;
51 if (endOfEvent
> endOfTrace
) {
52 endOfEvent
= endOfTrace
;
55 TraceDebug
.debug("Number of localProcesses: " + procContainer
.readItems().length
); //$NON-NLS-1$
56 // to identify the process relevant to the traceState
57 String traceId
= traceSt
.getTraceId();
58 int numLocalFound
= 0;
59 int numLocalNotFound
= 0;
60 int numWithNoChildren
= 0;
61 for (TimeRangeEventProcess localProcess
: procContainer
.readItems()) {
62 LttngProcessState stateProcess
= lttv_state_find_process(traceSt
,
63 localProcess
.getCpu(), localProcess
.getPid());
65 // Drawing the last state for processes related to the current trace
67 if (!localProcess
.getTraceID().equals(traceId
)) {
71 // Check if the process is in the state provider, it is the case
72 // when the requested time frame did not include any events for a
74 if (stateProcess
== null) {
75 // Get Start time from the end time of previous event
76 Vector
<TimeRangeComponent
> childrenEvents
= localProcess
80 if (childrenEvents
.size() > 0) {
81 TimeRangeComponent prevEvent
= childrenEvents
82 .get(childrenEvents
.size() - 1);
83 if (prevEvent
instanceof TimeRangeEvent
) {
84 TimeRangeEvent prevTimeRange
= (TimeRangeEvent
) prevEvent
;
85 // calculate the next good time to draw the event
86 // nextGoodTime = prevTimeRange.getStopTime() + 1;
87 nextGoodTime
= localProcess
.getNext_good_time();
88 stateMode
= prevTimeRange
.getStateMode();
90 // Draw with the Local information since the current
92 // not contain events related to this process
93 makeDraw(traceSt
, nextGoodTime
, endOfEvent
, localProcess
, params
, stateMode
);
95 TraceDebug
.debug("previous event not instance of TimeRangeEvent?: " //$NON-NLS-1$
96 + prevEvent
.getClass().getSimpleName());
107 // Draw the last state for this process
108 makeDraw(traceSt
, endOfEvent
, stateProcess
, localProcess
, params
);
111 TraceDebug
.debug("Print Last Event: NumLocalFound " + numLocalFound
//$NON-NLS-1$
112 + "; NumLocalNotFound: " + numLocalNotFound
//$NON-NLS-1$
113 + "; NumWithNoChildren: " + numWithNoChildren
); //$NON-NLS-1$