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@gmail.com) - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
;
17 import org
.eclipse
.linuxtools
.lttng
.TraceDebug
;
18 import org
.eclipse
.linuxtools
.lttng
.event
.LttngEvent
;
19 import org
.eclipse
.linuxtools
.lttng
.event
.LttngSyntheticEvent
;
20 import org
.eclipse
.linuxtools
.lttng
.state
.model
.LttngTraceState
;
21 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
27 public abstract class AbsEventToHandlerResolver
implements
28 IEventToHandlerResolver
, ITransEventProcessor
{
30 Long fbeforeEventCount
= 0L;
31 Long fstateUpdateCount
= 0L;
32 Long filteredOutEventsCount
= 0L;
35 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventToHandlerResolver#getBeforeProcessor(java.lang.String)
38 public abstract ILttngEventProcessor
getBeforeProcessor(String eventType
);
41 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventToHandlerResolver#getAfterProcessor(java.lang.String)
44 public abstract ILttngEventProcessor
getAfterProcessor(String eventType
);
47 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventToHandlerResolver#getfinishProcessor()
50 public abstract ILttngEventProcessor
getfinishProcessor();
53 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventToHandlerResolver#getStateUpdaterProcessor(java.lang.String)
56 public abstract ILttngEventProcessor
getStateUpdaterProcessor(
60 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor#process(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
63 public boolean process(LttngEvent trcEvent
, LttngTraceState traceSt
) {
64 if (trcEvent
instanceof LttngSyntheticEvent
) {
66 // prepare to dispatch synthetic events to its corresponding handler
67 LttngSyntheticEvent synEvent
= (LttngSyntheticEvent
) trcEvent
;
68 ILttngEventProcessor processor
= null;
69 String eventType
= synEvent
.getMarkerName();
71 switch (synEvent
.getSynType()) {
73 // Status indicators do not contain a valid marker name
79 processor
= getBeforeProcessor(eventType
);
80 // increment event count only for one sequence indicator,
81 // Note: BEFORE is selected to be used as an indicator to
82 // prevent duplicated updates in the state system
83 incrementBeforeEventCount();
88 processor
= getStateUpdaterProcessor(eventType
);
89 incrementStateUpdateCount();
94 processor
= getAfterProcessor(eventType
);
99 processor
= getfinishProcessor();
100 TraceDebug
.debug("EndRequest satus received:"); //$NON-NLS-1$
110 // For BEFORE/UPDATE/AFTER
111 // TODO: Implement filter of events not associated to this trace
112 // Make sure the event received is associated to this trace
113 // handling context, Implementing a trace compare for each event
114 // is not acceptable due to performance, and a reference check
115 // may not be feasible since there are trace clones used either
116 // to build the state system check points or UI requests.
118 // if (traceSt != null && trcEvent.getParentTrace() !=
119 // traceSt.getContext().getTraceIdRef()) {
120 // // increment the number of events filtered out
121 // filteredOutEventsCount++;
125 if (processor
!= null) {
126 processor
.process(trcEvent
, traceSt
);
137 * org.eclipse.linuxtools.lttng.state.evProcessor.IBaseEventProcessor#process
138 * (org.eclipse.linuxtools.tmf.event.TmfEvent,
139 * org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
142 public void process(TmfEvent tmfEvent
, LttngTraceState traceSt
) {
143 if (tmfEvent
== null) {
147 if (!(tmfEvent
instanceof LttngSyntheticEvent
)) {
149 .debug("The event received is not an instance of LttngSyntheticEvent and can not be processed"); //$NON-NLS-1$
153 LttngSyntheticEvent trcEvent
= (LttngSyntheticEvent
) tmfEvent
;
155 process(trcEvent
, traceSt
);
161 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IBaseEventProcessor#
162 * getEventsNotHandled()
164 public Set
<String
> getEventsNotHandled() {
171 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor#
175 public Long
getBeforeEventCount() {
176 return fbeforeEventCount
;
182 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor#
183 * getStateUpdateCount()
186 public Long
getStateUpdateCount() {
187 return fstateUpdateCount
;
193 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor#
194 * getFilteredOutEventCount()
197 public Long
getFilteredOutEventCount() {
198 return filteredOutEventsCount
;
203 * Initialise counter values, e.g before new requests
206 protected void reset() {
207 fbeforeEventCount
= 0L;
208 fstateUpdateCount
= 0L;
209 filteredOutEventsCount
= 0L;
213 * Multi-threading not expected
215 protected void incrementBeforeEventCount() {
220 * Multi-threading not expected
222 protected void incrementStateUpdateCount() {