1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made 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 (alvsan09@ail.com) - Initial API and implementation
11 * Michel Dagenais (michel.dagenais@polymtl.ca) - Reference C implementation, used with permission
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
;
18 import org
.eclipse
.linuxtools
.lttng
.TraceDebug
;
19 import org
.eclipse
.linuxtools
.lttng
.event
.LttngEvent
;
20 import org
.eclipse
.linuxtools
.lttng
.event
.LttngSyntheticEvent
;
21 import org
.eclipse
.linuxtools
.lttng
.state
.model
.LttngTraceState
;
22 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
28 public abstract class AbsEventToHandlerResolver
implements
29 IEventToHandlerResolver
, ITransEventProcessor
{
31 Long fbeforeEventCount
= 0L;
32 Long fstateUpdateCount
= 0L;
33 Long filteredOutEventsCount
= 0L;
36 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventToHandlerResolver#getBeforeProcessor(java.lang.String)
39 public abstract ILttngEventProcessor
getBeforeProcessor(String eventType
);
42 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventToHandlerResolver#getAfterProcessor(java.lang.String)
45 public abstract ILttngEventProcessor
getAfterProcessor(String eventType
);
48 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventToHandlerResolver#getfinishProcessor()
51 public abstract ILttngEventProcessor
getfinishProcessor();
54 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventToHandlerResolver#getStateUpdaterProcessor(java.lang.String)
57 public abstract ILttngEventProcessor
getStateUpdaterProcessor(
61 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor#process(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
64 public boolean process(LttngEvent trcEvent
, LttngTraceState traceSt
) {
65 if (trcEvent
instanceof LttngSyntheticEvent
) {
67 // prepare to dispatch synthetic events to its corresponding handler
68 LttngSyntheticEvent synEvent
= (LttngSyntheticEvent
) trcEvent
;
69 ILttngEventProcessor processor
= null;
70 String eventType
= synEvent
.getMarkerName();
72 switch (synEvent
.getSynType()) {
74 // Status indicators do not contain a valid marker name
80 processor
= getBeforeProcessor(eventType
);
81 // increment event count only for one sequence indicator,
82 // Note: BEFORE is selected to be used as an indicator to
83 // prevent duplicated updates in the state system
84 incrementBeforeEventCount();
89 processor
= getStateUpdaterProcessor(eventType
);
90 incrementStateUpdateCount();
95 processor
= getAfterProcessor(eventType
);
100 processor
= getfinishProcessor();
101 TraceDebug
.debug("EndRequest satus received:"); //$NON-NLS-1$
111 // For BEFORE/UPDATE/AFTER
112 // TODO: Implement filter of events not associated to this trace
113 // Make sure the event received is associated to this trace
114 // handling context, Implementing a trace compare for each event
115 // is not acceptable due to performance, and a reference check
116 // may not be feasible since there are trace clones used either
117 // to build the state system check points or UI requests.
119 // if (traceSt != null && trcEvent.getParentTrace() !=
120 // traceSt.getContext().getTraceIdRef()) {
121 // // increment the number of events filtered out
122 // filteredOutEventsCount++;
126 if (processor
!= null) {
127 processor
.process(trcEvent
, traceSt
);
138 * org.eclipse.linuxtools.lttng.state.evProcessor.IBaseEventProcessor#process
139 * (org.eclipse.linuxtools.tmf.event.TmfEvent,
140 * org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
143 public void process(TmfEvent tmfEvent
, LttngTraceState traceSt
) {
144 if (tmfEvent
== null) {
148 if (!(tmfEvent
instanceof LttngSyntheticEvent
)) {
150 .debug("The event received is not an instance of LttngSyntheticEvent and can not be processed"); //$NON-NLS-1$
154 LttngSyntheticEvent trcEvent
= (LttngSyntheticEvent
) tmfEvent
;
156 process(trcEvent
, traceSt
);
162 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IBaseEventProcessor#
163 * getEventsNotHandled()
165 public Set
<String
> getEventsNotHandled() {
172 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor#
176 public Long
getBeforeEventCount() {
177 return fbeforeEventCount
;
183 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor#
184 * getStateUpdateCount()
187 public Long
getStateUpdateCount() {
188 return fstateUpdateCount
;
194 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor#
195 * getFilteredOutEventCount()
198 public Long
getFilteredOutEventCount() {
199 return filteredOutEventsCount
;
204 * Initialise counter values, e.g before new requests
207 protected void reset() {
208 fbeforeEventCount
= 0L;
209 fstateUpdateCount
= 0L;
210 filteredOutEventsCount
= 0L;
214 * Multi-threading not expected
216 protected void incrementBeforeEventCount() {
221 * Multi-threading not expected
223 protected void incrementStateUpdateCount() {