1 package org
.eclipse
.linuxtools
.lttng
.event
;
3 import org
.eclipse
.linuxtools
.lttng
.jni
.JniEvent
;
4 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
5 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEventSource
;
6 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfTrace
;
9 * <b><u>LttngEvent</u></b>
11 * Lttng specific TmfEvent implementation.
13 * The main difference from the basic Tmf implementation is that we keep an
14 * internal reference to the JniEvent
16 * The conversion from this LttngEvent to the JniEvent is then possible.
18 public class LttngEvent
extends TmfEvent
{
20 // Reference to the JNI JniEvent. Should only be used INTERNALLY
21 private JniEvent jniEventReference
= null;
23 // Parameter-less constructor
26 fType
= LttngEventType
.DEFAULT_EVENT_TYPE
;
30 * Constructor with parameters.
33 * @param timestamp The timestamp of this event
34 * @param source The source of this event
35 * @param type The type of this event
36 * @param content The content of this event
37 * @param reference The reference of this event
38 * @param lttEvent A reference to a valid JniEvent object
40 * @see org.eclipse.linuxtools.tmf.event.TmfTimestamp
41 * @see org.eclipse.linuxtools.tmf.event.TmfEventSource
42 * @see org.eclipse.linuxtools.lttng.event.LttngEventType
43 * @see org.eclipse.linuxtools.lttng.event.LttngEventContent
44 * @see org.eclipse.linuxtools.lttng.event.LttngEventReference
45 * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
47 public LttngEvent(TmfTrace
<LttngEvent
> parent
, LttngTimestamp timestamp
, TmfEventSource source
, LttngEventType type
, LttngEventContent content
,
48 LttngEventReference reference
, JniEvent lttEvent
) {
49 super(timestamp
, source
, type
, reference
);
52 jniEventReference
= lttEvent
;
53 setParentTrace(parent
);
60 * @param oldEvent Event we want to copy from.
62 @SuppressWarnings("unchecked")
63 public LttngEvent(LttngEvent oldEvent
) {
65 (TmfTrace
<LttngEvent
>) oldEvent
.getParentTrace(),
66 (LttngTimestamp
)oldEvent
.getTimestamp(),
67 (TmfEventSource
)oldEvent
.getSource(),
68 (LttngEventType
)oldEvent
.getType(),
69 (LttngEventContent
)oldEvent
.getContent(),
70 (LttngEventReference
)oldEvent
.getReference(),
71 oldEvent
.jniEventReference
75 * Set a new parent trace for this event
77 * @param parentTrace The new parent
79 public void setParentTrace(TmfTrace
<LttngEvent
> parentTrace
) {
80 fParentTrace
= parentTrace
;
85 * Return the channel name of this event.<p>
87 * @return Channel (tracefile) for this event
89 public String
getChannelName() {
90 return this.getType().getTracefileName();
94 * Cpu id number of this event.
99 public long getCpuId() {
100 return this.getType().getCpuId();
104 * Marker name of this event.
107 * @return Marker name
109 public String
getMarkerName() {
110 return this.getType().getMarkerName();
114 * Marker id of this event.
119 public int getMarkerId() {
120 return this.getType().getMarkerId();
124 public LttngEventContent
getContent() {
125 return (LttngEventContent
) fContent
;
128 public void setContent(LttngEventContent newContent
) {
129 fContent
= newContent
;
133 public LttngEventType
getType() {
134 return (LttngEventType
) fType
;
137 public void setType(LttngEventType newType
) {
142 * Set a new JniReference for this event.
145 * Note : Reference is used to get back to the Jni during event parsing and
146 * need to be consistent.
148 * @param newJniEventReference New reference
150 * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
152 public synchronized void updateJniEventReference(JniEvent newJniEventReference
) {
153 this.jniEventReference
= newJniEventReference
;
157 * Convert this event into a Jni JniEvent.
160 * Note : Some verifications are done to make sure the event is still valid
161 * on the Jni side before conversion.<br>
162 * If it is not the case, null will be returned.
164 * @return The converted JniEvent
166 * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
168 public synchronized JniEvent
convertEventTmfToJni() {
169 JniEvent tmpEvent
= null;
172 // Should we remove the check to save some time??
174 // We don't want to send away events that are outdated as their
175 // informations could be invalid
176 // If the timestamp between the event and the trace are not coherent we
177 // will not perform the conversion
178 if (jniEventReference
.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime() == getTimestamp().getValue()) {
179 tmpEvent
= jniEventReference
;
182 .println("convertEventTmfToJni() failed: Unsynced Timestamp > TMF:" + getTimestamp().getValue() + " <--> JNI:" + jniEventReference
.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime()); //$NON-NLS-1$//$NON-NLS-2$
188 @SuppressWarnings("nls")
189 public String
toString() {
190 StringBuffer result
= new StringBuffer("[LttngEvent(");
191 result
.append("Timestamp:" + getTimestamp().getValue());
192 result
.append(",Channel:" + getChannelName());
193 result
.append(",CPU:" + getCpuId());
194 result
.append(",Marker:" + getMarkerName());
195 result
.append(",Content:" + getContent() + ")]");
197 return result
.toString();
201 public LttngEvent
clone() {
202 LttngEvent clone
= (LttngEvent
) super.clone();
203 clone
.getContent().setEvent(clone
);
204 clone
.jniEventReference
= jniEventReference
;