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
.event
.LttngSyntheticEvent
.SequenceInd
;
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)
38 public abstract ILttngEventProcessor
getBeforeProcessor(String eventType
);
41 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventToHandlerResolver#getAfterProcessor(java.lang.String)
43 public abstract ILttngEventProcessor
getAfterProcessor(String eventType
);
46 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventToHandlerResolver#getfinishProcessor()
48 public abstract ILttngEventProcessor
getfinishProcessor();
51 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventToHandlerResolver#getStateUpdaterProcessor(java.lang.String)
53 public abstract ILttngEventProcessor
getStateUpdaterProcessor(
57 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor#process(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
59 public boolean process(LttngEvent trcEvent
, LttngTraceState traceSt
) {
60 if (trcEvent
instanceof LttngSyntheticEvent
) {
62 // prepare to dispatch synthetic events to its corresponding handler
63 LttngSyntheticEvent synEvent
= (LttngSyntheticEvent
) trcEvent
;
64 ILttngEventProcessor processor
= null;
66 // Status indicators do not contain a valid marker name
67 if (synEvent
.getSynType() == SequenceInd
.STARTREQ
) {
72 if (synEvent
.getSynType() == SequenceInd
.ENDREQ
) {
73 processor
= getfinishProcessor();
74 TraceDebug
.debug("EndRequest satus received:");
76 // valid marker name expected
77 String eventType
= synEvent
.getMarkerName();
79 if (synEvent
.getSynType() == SequenceInd
.BEFORE
) {
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();
86 else if (synEvent
.getSynType() == SequenceInd
.UPDATE
) {
87 processor
= getStateUpdaterProcessor(eventType
);
88 incrementStateUpdateCount();
90 else if (synEvent
.getSynType() == SequenceInd
.AFTER
) {
91 processor
= getAfterProcessor(eventType
);
94 // TODO: Implement filter of events not associated to this trace
95 // Make sure the event received is associated to this trace
96 // handling context, Implementing a trace compare for each event
97 // is not acceptable due to performance, and a reference check
98 // may not be feasible since there are trace clones used either
99 // to build the state system check points or UI requests.
101 // if (traceSt != null && trcEvent.getParentTrace() !=
102 // traceSt.getContext().getTraceIdRef()) {
103 // // increment the number of events filtered out
104 // filteredOutEventsCount++;
109 if (processor
!= null) {
110 processor
.process(trcEvent
, traceSt
);
121 * org.eclipse.linuxtools.lttng.state.evProcessor.IBaseEventProcessor#process
122 * (org.eclipse.linuxtools.tmf.event.TmfEvent,
123 * org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
125 public void process(TmfEvent tmfEvent
, LttngTraceState traceSt
) {
126 if (tmfEvent
== null) {
130 if (!(tmfEvent
instanceof LttngSyntheticEvent
)) {
132 .debug("The event received is not an instance of LttngSyntheticEvent and can not be processed");
136 LttngSyntheticEvent trcEvent
= (LttngSyntheticEvent
) tmfEvent
;
138 process(trcEvent
, traceSt
);
144 * @see org.eclipse.linuxtools.lttng.state.evProcessor.IBaseEventProcessor#
145 * getEventsNotHandled()
147 public Set
<String
> getEventsNotHandled() {
154 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor#
157 public Long
getBeforeEventCount() {
158 return fbeforeEventCount
;
164 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor#
165 * getStateUpdateCount()
167 public Long
getStateUpdateCount() {
168 return fstateUpdateCount
;
174 * @see org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor#
175 * getFilteredOutEventCount()
177 public Long
getFilteredOutEventCount() {
178 return filteredOutEventsCount
;
183 * Initialise counter values, e.g before new requests
186 protected void reset() {
187 fbeforeEventCount
= 0L;
188 fstateUpdateCount
= 0L;
189 filteredOutEventsCount
= 0L;
193 * Multi-threading not expected
195 protected void incrementBeforeEventCount() {
200 * Multi-threading not expected
202 protected void incrementStateUpdateCount() {