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
29 * Constructor with parameters.
32 * @param timestamp The timestamp of this event
33 * @param source The source of this event
34 * @param type The type of this event
35 * @param content The content of this event
36 * @param reference The reference of this event
37 * @param lttEvent A reference to a valid JniEvent object
39 * @see org.eclipse.linuxtools.tmf.event.TmfTimestamp
40 * @see org.eclipse.linuxtools.tmf.event.TmfEventSource
41 * @see org.eclipse.linuxtools.lttng.event.LttngEventType
42 * @see org.eclipse.linuxtools.lttng.event.LttngEventContent
43 * @see org.eclipse.linuxtools.lttng.event.LttngEventReference
44 * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
46 public LttngEvent(TmfTrace
<LttngEvent
> parent
, LttngTimestamp timestamp
, TmfEventSource source
, LttngEventType type
, LttngEventContent content
,
47 LttngEventReference reference
, JniEvent lttEvent
) {
48 super(timestamp
, source
, type
, reference
);
51 jniEventReference
= lttEvent
;
52 setParentTrace(parent
);
59 * @param oldEvent Event we want to copy from.
61 @SuppressWarnings("unchecked")
62 public LttngEvent(LttngEvent oldEvent
) {
64 (TmfTrace
<LttngEvent
>) oldEvent
.getParentTrace(),
65 (LttngTimestamp
)oldEvent
.getTimestamp(),
66 (TmfEventSource
)oldEvent
.getSource(),
67 (LttngEventType
)oldEvent
.getType(),
68 (LttngEventContent
)oldEvent
.getContent(),
69 (LttngEventReference
)oldEvent
.getReference(),
70 oldEvent
.jniEventReference
74 * Set a new parent trace for this event
76 * @param parentTrace The new parent
78 public void setParentTrace(TmfTrace
<LttngEvent
> parentTrace
) {
79 fParentTrace
= parentTrace
;
84 * Return the channel name of this event.<p>
86 * @return Channel (tracefile) for this event
88 public String
getChannelName() {
89 return this.getType().getTracefileName();
93 * Cpu id number of this event.
98 public long getCpuId() {
99 return this.getType().getCpuId();
103 * Marker name of this event.
106 * @return Marker name
108 public String
getMarkerName() {
109 return this.getType().getMarkerName();
113 * Marker id of this event.
118 public int getMarkerId() {
119 return this.getType().getMarkerId();
123 public LttngEventContent
getContent() {
124 return (LttngEventContent
) fContent
;
127 public void setContent(LttngEventContent newContent
) {
128 fContent
= newContent
;
132 public LttngEventType
getType() {
133 return (LttngEventType
) fType
;
136 public void setType(LttngEventType newType
) {
141 * Set a new JniReference for this event.
144 * Note : Reference is used to get back to the Jni during event parsing and
145 * need to be consistent.
147 * @param newJniEventReference New reference
149 * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
151 public synchronized void updateJniEventReference(JniEvent newJniEventReference
) {
152 this.jniEventReference
= newJniEventReference
;
156 * Convert this event into a Jni JniEvent.
159 * Note : Some verifications are done to make sure the event is still valid
160 * on the Jni side before conversion.<br>
161 * If it is not the case, null will be returned.
163 * @return The converted JniEvent
165 * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
167 public synchronized JniEvent
convertEventTmfToJni() {
168 JniEvent tmpEvent
= null;
171 // Should we remove the check to save some time??
173 // We don't want to send away events that are outdated as their
174 // informations could be invalid
175 // If the timestamp between the event and the trace are not coherent we
176 // will not perform the conversion
177 if (jniEventReference
.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime() == getTimestamp().getValue()) {
178 tmpEvent
= jniEventReference
;
181 .println("convertEventTmfToJni() failed: Unsynced Timestamp > TMF:" + getTimestamp().getValue() + " <--> JNI:" + jniEventReference
.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime()); //$NON-NLS-1$//$NON-NLS-2$
187 @SuppressWarnings("nls")
188 public String
toString() {
189 StringBuffer result
= new StringBuffer("[LttngEvent(");
190 result
.append("Timestamp:" + getTimestamp().getValue());
191 result
.append(",Channel:" + getChannelName());
192 result
.append(",CPU:" + getCpuId());
193 result
.append(",Marker:" + getMarkerName());
194 result
.append(",Content:" + getContent() + ")]");
196 return result
.toString();
200 public LttngEvent
clone() {
201 LttngEvent clone
= (LttngEvent
) super.clone();
202 clone
.getContent().setEvent(clone
);
203 clone
.jniEventReference
= jniEventReference
;