Commit | Line | Data |
---|---|---|
6e512b93 ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 Ericsson | |
3 | * | |
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 | |
8 | * | |
9 | * Contributors: Alvaro Sanchez-Leon - Initial implementation | |
10 | *******************************************************************************/ | |
11 | package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor; | |
12 | ||
13 | import java.util.Vector; | |
14 | ||
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; | |
24 | ||
25 | /** | |
26 | * Creates specific finish state data request | |
27 | * | |
28 | * @author alvaro | |
29 | * | |
30 | */ | |
31 | public class FlowFinishUpdateHandler extends AbsFlowTRangeUpdate | |
32 | implements ILttngEventProcessor { | |
33 | ||
34 | public Events getEventHandleType() { | |
35 | // No specific event | |
36 | return null; | |
37 | } | |
38 | ||
d4011df2 | 39 | @Override |
6e512b93 | 40 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
a72a38d9 ASL |
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; | |
45 | ||
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; | |
50 | } | |
51 | ||
6e512b93 ASL |
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()); | |
62 | ||
63 | // Drawing the last state for processes related to the current trace | |
64 | // id. | |
65 | if (!localProcess.getTraceID().equals(traceId)) { | |
66 | continue; | |
67 | } | |
68 | ||
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 | |
71 | // process | |
72 | if (stateProcess == null) { | |
73 | // Get Start time from the end time of previous event | |
74 | Vector<TimeRangeComponent> childrenEvents = localProcess | |
75 | .getTraceEvents(); | |
76 | long nextGoodTime; | |
77 | String stateMode; | |
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(); | |
87 | ||
88 | // Draw with the Local information since the current | |
89 | // request did | |
90 | // not contain events related to this process | |
a72a38d9 | 91 | makeDraw(traceSt, nextGoodTime, endOfEvent, localProcess, params, stateMode); |
6e512b93 | 92 | } else { |
a72a38d9 ASL |
93 | TraceDebug.debug("previous event not instance of TimeRangeEvent?: " |
94 | + prevEvent.getClass().getSimpleName()); | |
6e512b93 ASL |
95 | } |
96 | } else { | |
97 | numWithNoChildren++; | |
98 | } | |
99 | ||
100 | numLocalNotFound++; | |
101 | continue; | |
102 | } | |
a72a38d9 | 103 | |
6e512b93 ASL |
104 | numLocalFound++; |
105 | // Draw the last state for this process | |
a72a38d9 | 106 | makeDraw(traceSt, endOfEvent, stateProcess, localProcess, params); |
6e512b93 ASL |
107 | } |
108 | ||
109 | TraceDebug.debug("Print Last Event: NumLocalFound " + numLocalFound | |
110 | + "; NumLocalNotFound: " + numLocalNotFound | |
111 | + "; NumWithNoChildren: " + numWithNoChildren); | |
112 | ||
113 | return false; | |
114 | } | |
115 | ||
116 | } |