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><p>
11 * Lttng specific TmfEvent implementation.<p>
13 * The main difference from the basic Tmf implementation is that we keep an internal reference to the JniEvent<br>
14 * The conversion from this LttngEvent to the JniEvent is then possible.
16 public class LttngEvent
extends TmfEvent
{
18 // Reference to the JNI JniEvent. Should only be used INTERNALLY
19 private JniEvent jniEventReference
= null;
21 // Reference to the parent trace that own this event
22 private TmfTrace
<LttngEvent
> parentTrace
= null;
25 * Constructor with parameters.<p>
27 * @param timestamp The timestamp of this event
28 * @param source The source of this event
29 * @param type The type of this event
30 * @param content The content of this event
31 * @param reference The reference of this event
32 * @param lttEvent A reference to a valid JniEvent object
34 * @see org.eclipse.linuxtools.tmf.event.TmfTimestamp
35 * @see org.eclipse.linuxtools.tmf.event.TmfEventSource
36 * @see org.eclipse.linuxtools.lttng.event.LttngEventType
37 * @see org.eclipse.linuxtools.lttng.event.LttngEventContent
38 * @see org.eclipse.linuxtools.lttng.event.LttngEventReference
39 * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
41 public LttngEvent(TmfTrace
<LttngEvent
> parent
, LttngTimestamp timestamp
, TmfEventSource source
, LttngEventType type
, LttngEventContent content
, LttngEventReference reference
, JniEvent lttEvent
) {
42 super(timestamp
, source
, type
, reference
);
45 jniEventReference
= lttEvent
;
46 setParentTrace(parent
);
50 * Copy constructor.<p>
52 * @param oldEvent Event we want to copy from.
54 public LttngEvent(LttngEvent oldEvent
) {
56 oldEvent
.getParentTrace(),
57 (LttngTimestamp
)oldEvent
.getTimestamp(),
58 (TmfEventSource
)oldEvent
.getSource(),
59 (LttngEventType
)oldEvent
.getType(),
60 (LttngEventContent
)oldEvent
.getContent(),
61 (LttngEventReference
)oldEvent
.getReference(),
62 oldEvent
.jniEventReference
68 * Return the parent trace asoociated with this event
70 * @return Parent trace
72 public TmfTrace
<LttngEvent
> getParentTrace() {
77 * Set a new parent trace for this event
79 * @param parentTrace The new parent
81 public void setParentTrace(TmfTrace
<LttngEvent
> parentTrace
) {
82 this.parentTrace
= parentTrace
;
87 * Return the channel name of this event.<p>
89 * @return Channel (tracefile) for this event
91 public String
getChannelName() {
92 return ( (LttngEventType
)this.getType() ).getTracefileName();
96 * Cpu id number of this event.<p>
100 public long getCpuId() {
101 return ( (LttngEventType
)this.getType() ).getCpuId();
105 * Marker name of this event.<p>
107 * @return Marker name
109 public String
getMarkerName() {
110 return ( (LttngEventType
)this.getType() ).getMarkerName();
114 public LttngEventContent
getContent() {
115 return (LttngEventContent
)fContent
;
118 public void setContent(LttngEventContent newContent
) {
119 fContent
= newContent
;
123 public LttngEventType
getType() {
124 return (LttngEventType
)fType
;
127 public void setType(LttngEventType newType
) {
132 * Set a new JniReference for this event.<p>
134 * Note : Reference is used to get back to the Jni during event parsing and need to be consistent.
136 * @param newJniEventReference New reference
138 * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
140 public synchronized void updateJniEventReference(JniEvent newJniEventReference
) {
141 this.jniEventReference
= newJniEventReference
;
145 * Convert this event into a Jni JniEvent.<p>
147 * Note : Some verifications are done to make sure the event is still valid on
148 * the Jni side before conversion.<br> If it is not the case, null will be returned.
150 * @return The converted JniEvent
152 * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
154 public synchronized JniEvent
convertEventTmfToJni() {
155 JniEvent tmpEvent
= null;
158 // Should we remove the check to save some time??
160 // We don't want to send away events that are outdated as their informations could be invalid
161 // If the timestamp between the event and the trace are not coherent we will not perform the conversion
162 if ( jniEventReference
.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime() == getTimestamp().getValue() ) {
163 tmpEvent
= jniEventReference
;
166 System
.out
.println("convertEventTmfToJni() failed: Unsynced Timestamp > TMF:" + getTimestamp().getValue() + " <--> JNI:" + jniEventReference
.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime());
172 public String
toString() {
173 StringBuffer result
= new StringBuffer("[LttngEvent(");
174 result
.append("Timestamp:" + getTimestamp().getValue());
175 result
.append(",Channel:" + getChannelName());
176 result
.append(",CPU:" + getCpuId());
177 result
.append(",Marker:" + getMarkerName());
178 result
.append(",Content:" + getContent() + ")]");
180 return result
.toString();