tmf: Fix orignal trace import wizard (bug 409721)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.help / doc / User-Guide.mediawiki
CommitLineData
067490ab
AM
1
2= Introduction =
3
4The purpose of the '''Tracing Monitoring Framework (TMF)''' is to facilitate the integration of tracing and monitoring tools into Eclipse, to provide out-of-the-box generic functionalities/views and provide extension mechanisms of the base functionalities for application specific purposes.
5
6= TMF UML2 Sequence Diagram Framework =
7
8The purpose of the UML2 Sequence Diagram Framework of TMF is to provide a framework for generation of UML2 sequence diagrams. It provides
9*UML2 Sequence diagram drawing capabilities (i.e. lifelines, messages, activations, object creation and deletion)
10*a generic, re-usable Sequence Diagram View
11*Eclipse Extension Point for the creation of sequence diagrams
12*callback hooks for searching and filtering within the Sequence Diagram View
13*scalability<br>
14The following chapters describe the Sequence Diagram Framework as well as a reference implementation and its usage.
15
16== TMF UML2 Sequence Diagram Extensions ==
17
18In the UML2 Sequence Diagram Framework an Eclipse extension point is defined so that other plug-ins can contribute code to create sequence diagram.
19
20'''Identifier''': org.eclipse.linuxtools.tmf.ui.uml2SDLoader<br>
21'''Since''': Since 0.3.2 (based on UML2SD of org.eclipse.tptp.common.ui)<br>
22'''Description''': This extension point aims to list and connect any UML2 Sequence Diagram loader.<br>
23'''Configuration Markup''':<br>
24
25<pre>
26<!ELEMENT extension (uml2SDLoader)+>
27<!ATTLIST extension
28point CDATA #REQUIRED
29id CDATA #IMPLIED
30name CDATA #IMPLIED
31>
32</pre>
33
34*point - A fully qualified identifier of the target extension point.
35*id - An optional identifier of the extension instance.
36*name - An optional name of the extension instance.
37
38<pre>
39<!ELEMENT uml2SDLoader EMPTY>
40<!ATTLIST uml2SDLoader
41id CDATA #REQUIRED
42name CDATA #REQUIRED
43class CDATA #REQUIRED
44view CDATA #REQUIRED
45default (true | false)
46</pre>
47
fac4e45b 48*id - A unique identifier for this uml2SDLoader. This is not mandatory as long as the id attribute cannot be retrieved by the provider plug-in. The class attribute is the one on which the underlying algorithm relies.
067490ab
AM
49*name - An name of the extension instance.
50*class - The implementation of this UML2 SD viewer loader. The class must implement org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader.
51*view - The view ID of the view that this loader aims to populate. Either org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView itself or a extension of org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView.
52*default - Set to true to make this loader the default one for the view; in case of several default loaders, first one coming from extensions list is taken.
53
54
55== Management of the Extension Point ==
56
57The TMF UI plug-in is responsible for evaluating each contribution to the extension point.
58<br>
59<br>
60With this extension point, a loader class is associated with a Sequence Diagram View. Multiple loaders can be associated to a single Sequence Diagram View. However, additional means have to be implemented to specify which loader should be used when opening the view. For example, an eclipse action or command could be used for that. This additional code is not necessary if there is only one loader for a given Sequence Diagram View associated and this loader has the attribute "default" set to "true". (see also [[#Using one Sequence Diagram View with Multiple Loaders | Using one Sequence Diagram View with Multiple Loaders]])
61
62== Sequence Diagram View ==
63
64For this extension point a Sequence Diagram View has to be defined as well. The Sequence Diagram View class implementation is provided by the plug-in ''org.eclipse.linuxtools.tmf.ui'' (''org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView'') and can be used as is or can also be sub-classed. For that, a view extension has to be added to the ''plugin.xml''.
65
66=== Supported Widgets ===
67
68The loader class provides a frame containing all the UML2 widgets to be displayed. The following widgets exist:
69
70*Lifeline
71*Activation
72*Synchronous Message
73*Asynchronous Message
74*Synchronous Message Return
75*Asynchronous Message Return
76*Stop
77
78For a lifeline, a category can be defined. The lifeline category defines icons, which are displayed in the lifeline header.
79
80=== Zooming ===
81
82The Sequence Diagram View allows the user to zoom in, zoom out and reset the zoom factor.
83
84=== Printing ===
85
86It is possible to print the whole sequence diagram as well as part of it.
87
88=== Key Bindings ===
89
90*SHIFT+ALT+ARROW-DOWN - to scroll down within sequence diagram one view page at a time
91*SHIFT+ALT+ARROW-UP - to scroll up within sequence diagram one view page at a time
92*SHIFT+ALT+ARROW-RIGHT - to scroll right within sequence diagram one view page at a time
93*SHIFT+ALT+ARROW-LEFT - to scroll left within sequence diagram one view page at a time
94*SHIFT+ALT+ARROW-HOME - to jump to the beginning of the selected message if not already visible in page
95*SHIFT+ALT+ARROW-END - to jump to the end of the selected message if not already visible in page
96*CTRL+F - to open find dialog if either the basic or extended find provider is defined (see [[#Using the Find Provider Interface | Using the Find Provider Interface]])
97*CTRL+P - to open print dialog
98
99=== Preferences ===
100
101The UML2 Sequence Diagram Framework provides preferences to customize the appearance of the Sequence Diagram View. The color of all widgets and text as well as the fonts of the text of all widget can be adjust. Amongst others the default lifeline width can be alternated. To change preferences select '''Windows->Preferences->Tracing->UML2 Sequence Diagrams'''. The following preference page will show:<br>
102[[Image:images/SeqDiagramPref.png]] <br>
103After changing the preferences select '''OK'''.
104
105=== Callback hooks ===
106
107The Sequence Diagram View provides several callback hooks so that extension can provide application specific functionality. The following interfaces can be provided:
108* Basic find provider or extended find Provider<br> For finding within the sequence diagram
109* Basic filter provider and extended Filter Provider<br> For filtering within the sequnce diagram.
110* Basic paging provider or advanced paging provider<br> For scalability reasons, used to limit number of displayed messages
111* Properies provider<br> To provide properties of selected elements
112* Collapse provider <br> To collapse areas of the sequence diagram
113
114== Tutorial ==
115
116This tutorial describes how to create a UML2 Sequence Diagram Loader extension and use this loader in the in Eclipse.
117
118=== Prerequisites ===
119
120The tutorial is based on Eclipse 3.7 (Eclipse Indigo) and TMF 0.3.2.
121
122=== Creating an Eclipse UI Plug-in ===
123
124To create a new project with name org.eclipse.linuxtools.tmf.sample.ui select '''File -> New -> Project -> Plug-in Development -> Plug-in Project'''. <br>
125[[Image:images/Screenshot-NewPlug-inProject1.png]]<br>
126
127[[Image:images/Screenshot-NewPlug-inProject2.png]]<br>
128
129[[Image:Screenshot-NewPlug-inProject3.png]]<br>
130
131=== Creating a Sequence Diagram View ===
132
133To open the plug-in manifest, double-click on the MANIFEST.MF file. <br>
134[[Image:images/SelectManifest.png]]<br>
135
136Change to the Dependencies tab and select '''Add...''' of the ''Required Plug-ins'' section. A new dialog box will open. Next find plug-in ''org.eclipse.linuxtools.tmf.ui'' and press '''OK'''<br>
137[[Image:images/AddDependencyTmfUi.png]]<br>
138
139Change to the Extensions tab and select '''Add...''' of the ''All Extension'' section. A new dialog box will open. Find the view extension ''org.eclipse.ui.views'' and press '''Finish'''.<br>
140[[Image:images/AddViewExtension1.png]]<br>
141
142To create a Sequence Diagram View, click the right mouse button. Then select '''New -> view'''<br>
143[[Image:images/AddViewExtension2.png]]<br>
144
145A new view entry has been created. Fill in the fields ''id'', ''name'' and ''class''. Note that for ''class'' the SD view implementation (''org.eclipse.linuxtools.tmf.ui.views.SDView'') of the TMF UI plug-in is used.<br>
146[[Image:images/FillSampleSeqDiagram.png]]<br>
147
148The view is prepared. Run the Example. To launch the an Eclipse Application select the ''Overview'' tab and click on '''Launch an Eclipse Application'''<br>
149[[Image:images/RunEclipseApplication.png]]<br>
150
151A new Eclipse application window will show. In the new window go to '''Windows -> Show View -> Other... -> Other -> Sample Sequence Diagram'''.<br>
152[[Image:images/ShowViewOther.png]]<br>
153
154The Sequence Diagram View will open with an blank page.<br>
155[[Image:images/BlankSampleSeqDiagram.png]]<br>
156
157Close the Example Application.
158
159=== Defining the uml2SDLoader Extension ===
160
161After defining the Sequence Diagram View it's time to create the ''uml2SDLoader'' Extension. <br>
162
163Before doing that add a dependency to TMF. For that select '''Add...''' of the ''Required Plug-ins'' section. A new dialog box will open. Next find plug-in ''org.eclipse.linuxtools.tmf'' and press '''OK'''<br>
164[[Image:images/AddDependencyTmf.png]]<br>
165
166To create the loader extension, change to the Extensions tab and select '''Add...''' of the ''All Extension'' section. A new dialog box will open. Find the extension ''org.eclipse.linuxtools.tmf.ui.uml2SDLoader'' and press '''Finish'''.<br>
167[[Image:images/AddTmfUml2SDLoader.png]]<br>
168
169A new 'uml2SDLoader'' extension has been created. Fill in fields ''id'', ''name'', ''class'', ''view'' and ''default''. Use ''default'' equal true for this example. For the view add the id of the Sequence Diagram View of chapter [[#Creating a Sequence Diagram View | Creating a Sequence Diagram View]]. <br>
170[[Image:images/FillSampleLoader.png]]<br>
171
172Then click on ''class'' (see above) to open the new class dialog box. Fill in the relevant fields and select '''Finish'''. <br>
173[[Image:images/NewSampleLoaderClass.png]]<br>
174
175A new Java class will be created which implements the interface ''org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader''.<br>
176
177<pre>
178package org.eclipse.linuxtools.tmf.sample.ui;
179
180import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
181import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader;
182
183public class SampleLoader implements IUml2SDLoader {
184
185 public SampleLoader() {
186 // TODO Auto-generated constructor stub
187 }
188
189 @Override
190 public void dispose() {
191 // TODO Auto-generated method stub
192
193 }
194
195 @Override
196 public String getTitleString() {
197 // TODO Auto-generated method stub
198 return null;
199 }
200
201 @Override
202 public void setViewer(SDView arg0) {
203 // TODO Auto-generated method stub
204
205 }
206</pre>
207
208=== Implementing the Loader Class ===
209
210Next is to implement the methods of the IUml2SDLoader interface method. The following code snippet shows how to create the major sequence diagram elements. Please note that no time information is stored.<br>
211
212<pre>
213package org.eclipse.linuxtools.tmf.sample.ui;
214
215import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
216import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage;
217import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessageReturn;
218import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ExecutionOccurrence;
219import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Frame;
220import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline;
221import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Stop;
222import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage;
223import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessageReturn;
224import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader;
225
226public class SampleLoader implements IUml2SDLoader {
227
228 private SDView fSdView;
229
230 public SampleLoader() {
231 }
232
233 @Override
234 public void dispose() {
235 }
236
237 @Override
238 public String getTitleString() {
239 return "Sample Diagram";
240 }
241
242 @Override
243 public void setViewer(SDView arg0) {
244 fSdView = arg0;
245 createFrame();
246 }
247
248 private void createFrame() {
249
250 Frame testFrame = new Frame();
251 testFrame.setName("Sample Frame");
252
253 /*
254 * Create lifelines
255 */
256
257 Lifeline lifeLine1 = new Lifeline();
258 lifeLine1.setName("Object1");
259 testFrame.addLifeLine(lifeLine1);
260
261 Lifeline lifeLine2 = new Lifeline();
262 lifeLine2.setName("Object2");
263 testFrame.addLifeLine(lifeLine2);
264
265
266 /*
267 * Create Sync Message
268 */
269 // Get new occurrence on lifelines
270 lifeLine1.getNewEventOccurrence();
271
272 // Get Sync message instances
273 SyncMessage start = new SyncMessage();
274 start.setName("Start");
275 start.setEndLifeline(lifeLine1);
276 testFrame.addMessage(start);
277
278 /*
279 * Create Sync Message
280 */
281 // Get new occurrence on lifelines
282 lifeLine1.getNewEventOccurrence();
283 lifeLine2.getNewEventOccurrence();
284
285 // Get Sync message instances
286 SyncMessage syn1 = new SyncMessage();
287 syn1.setName("Sync Message 1");
288 syn1.setStartLifeline(lifeLine1);
289 syn1.setEndLifeline(lifeLine2);
290 testFrame.addMessage(syn1);
291
292 /*
293 * Create corresponding Sync Message Return
294 */
295
296 // Get new occurrence on lifelines
297 lifeLine1.getNewEventOccurrence();
298 lifeLine2.getNewEventOccurrence();
299
300 SyncMessageReturn synReturn1 = new SyncMessageReturn();
301 synReturn1.setName("Sync Message Return 1");
302 synReturn1.setStartLifeline(lifeLine2);
303 synReturn1.setEndLifeline(lifeLine1);
304 synReturn1.setMessage(syn1);
305 testFrame.addMessage(synReturn1);
306
307 /*
308 * Create Activations (Execution Occurrence)
309 */
310 ExecutionOccurrence occ1 = new ExecutionOccurrence();
311 occ1.setStartOccurrence(start.getEventOccurrence());
312 occ1.setEndOccurrence(synReturn1.getEventOccurrence());
313 lifeLine1.addExecution(occ1);
314 occ1.setName("Activation 1");
315
316 ExecutionOccurrence occ2 = new ExecutionOccurrence();
317 occ2.setStartOccurrence(syn1.getEventOccurrence());
318 occ2.setEndOccurrence(synReturn1.getEventOccurrence());
319 lifeLine2.addExecution(occ2);
320 occ2.setName("Activation 2");
321
322 /*
323 * Create Sync Message
324 */
325 // Get new occurrence on lifelines
326 lifeLine1.getNewEventOccurrence();
327 lifeLine2.getNewEventOccurrence();
328
329 // Get Sync message instances
330 AsyncMessage asyn1 = new AsyncMessage();
331 asyn1.setName("Async Message 1");
332 asyn1.setStartLifeline(lifeLine1);
333 asyn1.setEndLifeline(lifeLine2);
334 testFrame.addMessage(asyn1);
335
336 /*
337 * Create corresponding Sync Message Return
338 */
339
340 // Get new occurrence on lifelines
341 lifeLine1.getNewEventOccurrence();
342 lifeLine2.getNewEventOccurrence();
343
344 AsyncMessageReturn asynReturn1 = new AsyncMessageReturn();
345 asynReturn1.setName("Async Message Return 1");
346 asynReturn1.setStartLifeline(lifeLine2);
347 asynReturn1.setEndLifeline(lifeLine1);
348 asynReturn1.setMessage(asyn1);
349 testFrame.addMessage(asynReturn1);
350
351 /*
352 * Create a note
353 */
354
355 // Get new occurrence on lifelines
356 lifeLine1.getNewEventOccurrence();
357
358 EllipsisisMessage info = new EllipsisisMessage();
359 info.setName("Object deletion");
360 info.setStartLifeline(lifeLine2);
361 testFrame.addNode(info);
362
363 /*
364 * Create a Stop
365 */
366 Stop stop = new Stop();
367 stop.setLifeline(lifeLine2);
368 stop.setEventOccurrence(lifeLine2.getNewEventOccurrence());
369 lifeLine2.addNode(stop);
370
371 fSdView.setFrame(testFrame);
372 }
373}
374</pre>
375
376Now it's time to run the example application. To launch the Example Application select the ''Overview'' tab and click on '''Launch an Eclipse Application'''<br>
377[[Image:images/SampleDiagram1.png]] <br>
378
379=== Adding time information ===
380
381To add time information in sequence diagram the timestamp has to be set for each message. The sequence diagram framework uses the ''TmfTimestamp'' class of plug-in ''org.eclipse.linuxtools.tmf''. Use ''setTime()'' on each message ''SyncMessage'' since start and end time are the same. For each ''AsyncMessage'' set start and end time separately by using methods ''setStartTime'' and ''setEndTime''. For example: <br>
382
383<pre>
384 private void createFrame() {
385 //...
fac4e45b
BH
386 start.setTime(new TmfTimestamp(1000, -3));
387 syn1.setTime(new TmfTimestamp(1005, -3));
388 synReturn1.setTime(new TmfTimestamp(1050, -3));
389 asyn1.setStartTime(new TmfTimestamp(1060, -3));
390 asyn1.setEndTime(new TmfTimestamp(1070, -3));
391 asynReturn1.setStartTime(new TmfTimestamp(1060, -3));
392 asynReturn1.setEndTime(new TmfTimestamp(1070, -3));
067490ab
AM
393 //...
394 }
395</pre>
396
397When running the example application, a time compression bar on the left appears which indicates the time elapsed between consecutive events. The time compression scale shows where the time falls between the minimum and maximum delta times. The intensity of the color is used to indicate the length of time, namely, the deeper the intensity, the higher the delta time. The minimum and maximum delta times are configurable through the collbar menu ''Configure Min Max''. The time compression bar and scale may provide an indication about which events consumes the most time. By hovering over the time compression bar a tooltip appears containing more information. <br>
398
399[[Image:images/SampleDiagramTimeComp.png]] <br>
400
401By hovering over a message it will show the time information in the appearing tooltip. For each ''SyncMessage'' it shows its time occurrence and for each ''AsyncMessage'' it shows the start and end time.
402
403[[Image:images/SampleDiagramSyncMessage.png]] <br>
404[[Image:images/SampleDiagramAsyncMessage.png]] <br>
405
406To see the time elapsed between 2 messages, select one message and hover over a second message. A tooltip will show with the delta in time. Note if the second message is before the first then a negative delta is displayed. Note that for ''AsynMessage'' the end time is used for the delta calculation.<br>
407[[Image:images/SampleDiagramMessageDelta.png]] <br>
408
409=== Default Coolbar and Menu Items ===
410
411The Sequence Diagram View comes with default coolbar and menu items. By default, each sequence diagram shows the following actions:
412* Zoom in
413* Zoom out
414* Reset Zoom Factor
415* Selection
416* Configure Min Max (drop-down menu only)
417* Navigation -> Show the node end (drop-down menu only)
418* Navigation -> Show the node start (drop-down menu only)
419
420[[Image:images/DefaultCoolbarMenu.png]]<br>
421
422=== Implementing Optional Callbacks ===
423
424The following chapters describe how to use all supported provider interfaces.
425
426==== Using the Paging Provider Interface ====
427
428For scalability reasons, the paging provider interfaces exists to limit the number of messages displayed in the Sequence Diagram View at a time. For that, two interfaces exist, the basic paging provider and the advanced paging provider. When using the basic paging interface, actions for traversing page by page through the sequence diagram of a trace will be provided.
429<br>
430To use the basic paging provider, first the interface methods of the ''ISDPagingProvider'' have to be implemented by a class. (i.e. ''hasNextPage()'', ''hasPrevPage()'', ''nextPage()'', ''prevPage()'', ''firstPage()'' and ''endPage()''. Typically, this is implemented in the loader class. Secondly, the provider has to be set in the Sequence Diagram View. This will be done in the ''setViewer()'' method of the loader class. Lastly, the paging provider has to be removed from the view, when the ''dispose()'' method of the loader class is called.
431
432<pre>
433public class SampleLoader implements IUml2SDLoader, ISDPagingProvider {
434 //...
435 private page = 0;
436
437 @Override
438 public void dispose() {
439 if (fSdView != null) {
440 fSdView.resetProviders();
441 }
442 }
443
444 @Override
445 public void setViewer(SDView arg0) {
446 fSdView = arg0;
447 fSdView.setSDPagingProvider(this);
448 createFrame();
449 }
450
451 private void createSecondFrame() {
452 Frame testFrame = new Frame();
453 testFrame.setName("SecondFrame");
454 Lifeline lifeline = new Lifeline();
455 lifeline.setName("LifeLine 0");
456 testFrame.addLifeLine(lifeline);
457 lifeline = new Lifeline();
458 lifeline.setName("LifeLine 1");
459 testFrame.addLifeLine(lifeline);
460 for (int i = 1; i < 5; i++) {
461 SyncMessage message = new SyncMessage();
462 message.autoSetStartLifeline(testFrame.getLifeline(0));
463 message.autoSetEndLifeline(testFrame.getLifeline(0));
464 message.setName((new StringBuilder("Message ")).append(i).toString());
465 testFrame.addMessage(message);
466
467 SyncMessageReturn messageReturn = new SyncMessageReturn();
468 messageReturn.autoSetStartLifeline(testFrame.getLifeline(0));
469 messageReturn.autoSetEndLifeline(testFrame.getLifeline(0));
470
471 testFrame.addMessage(messageReturn);
472 messageReturn.setName((new StringBuilder("Message return ")).append(i).toString());
473 ExecutionOccurrence occ = new ExecutionOccurrence();
474 occ.setStartOccurrence(testFrame.getSyncMessage(i - 1).getEventOccurrence());
475 occ.setEndOccurrence(testFrame.getSyncMessageReturn(i - 1).getEventOccurrence());
476 testFrame.getLifeline(0).addExecution(occ);
477 }
478 fSdView.setFrame(testFrame);
479 }
480
067490ab
AM
481 @Override
482 public boolean hasNextPage() {
483 return page == 0;
484 }
485
067490ab
AM
486 @Override
487 public boolean hasPrevPage() {
488 return page == 1;
489 }
490
067490ab
AM
491 @Override
492 public void nextPage() {
493 page = 1;
494 createSecondFrame();
495 }
496
067490ab
AM
497 @Override
498 public void prevPage() {
499 page = 0;
500 createFrame();
501 }
502
067490ab
AM
503 @Override
504 public void firstPage() {
505 page = 0;
506 createFrame();
507 }
508
067490ab
AM
509 @Override
510 public void lastPage() {
511 page = 1;
512 createSecondFrame();
513 }
514 //...
515}
516
517</pre>
518
519When running the example application, new actions will be shown in the coolbar and the coolbar menu. <br>
520
521[[Image:images/PageProviderAdded.png]]
522
523<br><br>
524To use the advanced paging provider, the interface ''ISDAdvancePagingProvider'' has to be implemented. It extends the basic paging provider. The methods ''currentPage()'', ''pagesCount()'' and ''pageNumberChanged()'' have to be added.
525<br>
526
527==== Using the Find Provider Interface ====
528
fac4e45b 529For finding nodes in a sequence diagram two interfaces exists. One for basic finding and one for extended finding. The basic find comes with a dialog box for entering find criteria as regular expressions. This find criteria can be used to execute the find. Find criteria a persisted in the Eclipse workspace.
067490ab
AM
530<br>
531For the extended find provider interface a ''org.eclipse.jface.action.Action'' class has to be provided. The actual find handling has to be implemented and triggered by the action.
532<br>
533Only on at a time can be active. If the extended find provder is defined it obsoletes the basic find provider.
534<br>
535To use the basic find provider, first the interface methods of the ''ISDFindProvider'' have to be implemented by a class. Typically, this is implemented in the loader class. Add the ISDFindProvider to the list of implemented interfaces, implement the methods ''find()'' and ''cancel()'' and set the provider in the ''setViewer()'' method as well as remove the provider in the ''dispose()'' method of the loader class. Please note that the ''ISDFindProvider'' extends the interface ''ISDGraphNodeSupporter'' which methods (''isNodeSupported()'' and ''getNodeName()'') have to be implemented, too. The following shows an example implementation. Please note that only search for lifelines and SynchMessage are supported. The find itself will always find only the first occurrence the pattern to match.
536
537<pre>
538public class SampleLoader implements IUml2SDLoader, ISDPagingProvider, ISDFindProvider {
539
540 //...
541 @Override
542 public void dispose() {
543 if (fSdView != null) {
544 fSdView.resetProviders();
545 }
546 }
547
548 @Override
549 public void setViewer(SDView arg0) {
550 fSdView = arg0;
551 fSdView.setSDPagingProvider(this);
552 fSdView.setSDFindProvider(this);
553 createFrame();
554 }
11252342 555
067490ab
AM
556 @Override
557 public boolean isNodeSupported(int nodeType) {
558 switch (nodeType) {
559 case ISDGraphNodeSupporter.LIFELINE:
560 case ISDGraphNodeSupporter.SYNCMESSAGE:
561 return true;
562
563 default:
564 break;
565 }
566 return false;
567 }
568
067490ab
AM
569 @Override
570 public String getNodeName(int nodeType, String loaderClassName) {
571 switch (nodeType) {
572 case ISDGraphNodeSupporter.LIFELINE:
573 return "Lifeline";
574 case ISDGraphNodeSupporter.SYNCMESSAGE:
575 return "Sync Message";
576 }
577 return "";
578 }
579
067490ab
AM
580 @Override
581 public boolean find(Criteria criteria) {
582 Frame frame = fSdView.getFrame();
583 if (criteria.isLifeLineSelected()) {
584 for (int i = 0; i < frame.lifeLinesCount(); i++) {
585 if (criteria.matches(frame.getLifeline(i).getName())) {
586 fSdView.getSDWidget().moveTo(frame.getLifeline(i));
587 return true;
588 }
589 }
590 }
591 if (criteria.isSyncMessageSelected()) {
592 for (int i = 0; i < frame.syncMessageCount(); i++) {
593 if (criteria.matches(frame.getSyncMessage(i).getName())) {
594 fSdView.getSDWidget().moveTo(frame.getSyncMessage(i));
595 return true;
596 }
597 }
598 }
599 return false;
600 }
601
067490ab
AM
602 @Override
603 public void cancel() {
604 // reset find parameters
605 }
606 //...
607}
608</pre>
609
610When running the example application, the find action will be shown in the coolbar and the coolbar menu. <br>
611[[Image:images/FindProviderAdded.png]]
612
613To find a sequence diagram node press on the find button of the coolbar (see above). A new dialog box will open. Enter a regular expression in the ''Matching String'' text box, select the node types (e.g. Sync Message) and press '''Find'''. If found the corresponding node will be selected. If not found the dialog box will indicate not found. <br>
614[[Image:images/FindDialog.png]]<br>
615
616Note that the find dialog will be opened by typing the key shortcut CRTL+F.
617
618==== Using the Filter Provider Interface ====
619
fac4e45b 620For filtering of sequence diagram elements two interfaces exists. One basic for filtering and one for extended filtering. The basic filtering comes with two dialog for entering filter criteria as regular expressions and one for selecting the filter to be used. Multiple filters can be active at a time. Filter criteria are persisted in the Eclipse workspace.
067490ab
AM
621<br>
622To use the basic filter provider, first the interface method of the ''ISDFilterProvider'' has to be implemented by a class. Typically, this is implemented in the loader class. Add the ''ISDFilterProvider'' to the list of implemented interfaces, implement the method ''filter()''and set the provider in the ''setViewer()'' method as well as remove the provider in the ''dispose()'' method of the loader class. Please note that the ''ISDFindProvider'' extends the interface ''ISDGraphNodeSupporter'' which methods (''isNodeSupported()'' and ''getNodeName()'') have to be implemented, too. <br>
623Note that no example implementation of ''filter()'' is provided.
624<br>
625
626<pre>
627public class SampleLoader implements IUml2SDLoader, ISDPagingProvider, ISDFindProvider, ISDFilterProvider {
628
629 //...
630 @Override
631 public void dispose() {
632 if (fSdView != null) {
633 fSdView.resetProviders();
634 }
635 }
636
637 @Override
638 public void setViewer(SDView arg0) {
639 fSdView = arg0;
640 fSdView.setSDPagingProvider(this);
641 fSdView.setSDFindProvider(this);
642 fSdView.setSDFilterProvider(this);
643 createFrame();
644 }
645
067490ab
AM
646 @Override
647 public boolean filter(List<?> list) {
648 return false;
649 }
650 //...
651}
652</pre>
653
654When running the example application, the filter action will be shown in the coolbar menu. <br>
655[[Image:images/HidePatternsMenuItem.png]]
656
657To filter select the '''Hide Patterns...''' of the coolbar menu. A new dialog box will open. <br>
658[[Image:images/DialogHidePatterns.png]]
659
660To Add a new filter press '''Add...'''. A new dialog box will open. Enter a regular expression in the ''Matching String'' text box, select the node types (e.g. Sync Message) and press '''Create''''. <br>
661[[Image:images/DialogHidePatterns.png]] <br>
662
663Now back at the Hide Pattern dialog. Select one or more filter and select '''OK'''.
664
665To use the extended filter provider, the interface ''ISDExtendedFilterProvider'' has to be implemented. It will provide a ''org.eclipse.jface.action.Action'' class containing the actual filter handling and filter algorithm.
666
667==== Using the Extended Action Bar Provider Interface ====
668
669The extended action bar provider can be used to add customized actions to the Sequence Diagram View.
670To use the extended action bar provider, first the interface method of the interface ''ISDExtendedActionBarProvider'' has to be implemented by a class. Typically, this is implemented in the loader class. Add the ''ISDExtendedActionBarProvider'' to the list of implemented interfaces, implement the method ''supplementCoolbarContent()'' and set the provider in the ''setViewer()'' method as well as remove the provider in the ''dispose()'' method of the loader class. <br>
671
672<pre>
673public class SampleLoader implements IUml2SDLoader, ISDPagingProvider, ISDFindProvider, ISDFilterProvider, ISDExtendedActionBarProvider {
674 //...
675
676 @Override
677 public void dispose() {
678 if (fSdView != null) {
679 fSdView.resetProviders();
680 }
681 }
682
683 @Override
684 public void setViewer(SDView arg0) {
685 fSdView = arg0;
686 fSdView.setSDPagingProvider(this);
687 fSdView.setSDFindProvider(this);
688 fSdView.setSDFilterProvider(this);
689 fSdView.setSDExtendedActionBarProvider(this);
690 createFrame();
691 }
692
067490ab
AM
693 @Override
694 public void supplementCoolbarContent(IActionBars iactionbars) {
695 Action action = new Action("Refresh") {
696 @Override
697 public void run() {
698 System.out.println("Refreshing...");
699 }
700 };
701 iactionbars.getMenuManager().add(action);
702 iactionbars.getToolBarManager().add(action);
703 }
704 //...
705}
706</pre>
707
708When running the example application, all new actions will be added to the coolbar and coolbar menu according to the implementation of ''supplementCoolbarContent()''<br>.
709For the example above the coolbar and coolbar menu will look as follows.
710
711[[Image:images/SupplCoolbar.png]]
712
713==== Using the Properties Provider Interface====
714
715This interface can be used to provide property information. A property provider which returns an ''IPropertyPageSheet'' (see ''org.eclipse.ui.views'') has to be implemented and set in the Sequence Diagram View. <br>
716
717To use the property provider, first the interface method of the ''ISDPropertiesProvider'' has to be implemented by a class. Typically, this is implemented in the loader class. Add the ''ISDPropertiesProvider'' to the list of implemented interfaces, implement the method ''getPropertySheetEntry()'' and set the provider in the ''setViewer()'' method as well as remove the provider in the ''dispose()'' method of the loader class. Please note that no example is provided here.
718
719Please refer to the following Eclipse articles for more information about properties and tabed properties.
720*[http://www.eclipse.org/articles/Article-Properties-View/properties-view.html | Take control of your properties]
721*[http://www.eclipse.org/articles/Article-Tabbed-Properties/tabbed_properties_view.html | The Eclipse Tabbed Properties View]
722
723==== Using the Collapse Provider Interface ====
724
725This interface can be used to define a provider which responsibility is to collapse two selected lifelines. This can be used to hide a pair of lifelines.
726
727To use the collapse provider, first the interface method of the ''ISDCollapseProvider'' has to be implemented by a class. Typically, this is implemented in the loader class. Add the ISDCollapseProvider to the list of implemented interfaces, implement the method ''collapseTwoLifelines()'' and set the provider in the ''setViewer()'' method as well as remove the provider in the ''dispose()'' method of the loader class. Please note that no example is provided here.
728
729==== Using the Selection Provider Service ====
730
731The Sequence Diagram View comes with a build in selection provider service. To this service listeners can be added. To use the selection provider service, the interface ''ISelectionListener'' of plug-in ''org.eclipse.ui'' has to implemented. Typically this is implemented in loader class. Firstly, add the ''ISelectionListener'' interface to the list of implemented interfaces, implement the method ''selectionChanged()'' and set the listener in method ''setViewer()'' as well as remove the listener in the ''dispose()'' method of the loader class.
732
733<pre>
734public class SampleLoader implements IUml2SDLoader, ISDPagingProvider, ISDFindProvider, ISDFilterProvider, ISDExtendedActionBarProvider, ISelectionListener {
735
736 //...
737 @Override
738 public void dispose() {
739 if (fSdView != null) {
740 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removePostSelectionListener(this);
741 fSdView.resetProviders();
742 }
743 }
744
745 @Override
746 public String getTitleString() {
747 return "Sample Diagram";
748 }
749
750 @Override
751 public void setViewer(SDView arg0) {
752 fSdView = arg0;
753 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addPostSelectionListener(this);
754 fSdView.setSDPagingProvider(this);
755 fSdView.setSDFindProvider(this);
756 fSdView.setSDFilterProvider(this);
757 fSdView.setSDExtendedActionBarProvider(this);
758
759 createFrame();
760 }
761
067490ab
AM
762 @Override
763 public void selectionChanged(IWorkbenchPart part, ISelection selection) {
764 ISelection sel = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
765 if (sel != null && (sel instanceof StructuredSelection)) {
766 StructuredSelection stSel = (StructuredSelection) sel;
767 if (stSel.getFirstElement() instanceof BaseMessage) {
768 BaseMessage syncMsg = ((BaseMessage) stSel.getFirstElement());
769 System.out.println("Message '" + syncMsg.getName() + "' selected.");
770 }
771 }
772 }
773
774 //...
775}
776</pre>
777
778=== Printing a Sequence Diagram ===
779
780To print a the whole sequence diagram or only parts of it, select the Sequence Diagram View and select '''File -> Print...''' or type the key combination ''CTRL+P''. A new print dialog will open. <br>
781
782[[Image:images/PrintDialog.png]] <br>
783
784Fill in all the relevant information, select '''Printer...''' to choose the printer and the press '''OK'''.
785
786=== Using one Sequence Diagram View with Multiple Loaders ===
787
788A Sequence Diagram View definition can be used with multiple sequence diagram loaders. However, the active loader to be used when opening the view has to be set. For this define an Eclipse action or command and assign the current loader to the view. Here is a code snippet for that:
789
790<pre>
791public class OpenSDView extends AbstractHandler {
792 @Override
793 public Object execute(ExecutionEvent event) throws ExecutionException {
794 try {
795 IWorkbenchPage persp = TmfUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
796 SDView view = (SDView) persp.showView("org.eclipse.linuxtools.ust.examples.ui.componentinteraction");
797 LoadersManager.getLoadersManager().createLoader("org.eclipse.linuxtools.tmf.ui.views.uml2sd.impl.TmfUml2SDSyncLoader", view);
798 } catch (PartInitException e) {
799 throw new ExecutionException("PartInitException caught: ", e);
800 }
801 return null;
802 }
803}
804</pre>
805
806=== Downloading the Tutorial ===
807
fac4e45b 808Use the following link to download the source code of the tutorial [http://wiki.eclipse.org/images/e/e6/SamplePlugin.zip Plug-in of Tutorial].
067490ab
AM
809
810== Integration of Tracing and Monitoring Framework with Sequence Diagram Framework ==
811
812In the previous sections the Sequence Diagram Framework has been described and a tutorial was provided. In the following sections the integration of the Sequence Diagram Framework with other features of TMF will be described. Together it is a powerful framework to analyze and visualize content of traces. The integration is explained using the reference implementation of a UML2 sequence diagram loader which part of the TMF UI delivery. The reference implementation can be used as is, can be sub-classed or simply be an example for other sequence diagram loaders to be implemented.
813
814=== Reference Implementation ===
815
816A Sequence Diagram View Extension is defined in the plug-in TMF UI as well as a uml2SDLoader Extension with the reference loader.
817
818[[Image:images/ReferenceExtensions.png]]
819
820=== Used Sequence Diagram Features ===
821
822Besides the default features of the Sequence Diagram Framework, the reference implementation uses the following additional features:
823*Advanced paging
824*Basic finding
825*Basic filtering
826*Selection Service
827
828==== Advanced paging ====
829
830The reference loader implements the interface ''ISDAdvancedPagingProvider'' interface. Please refer to section [[#Using the Paging Provider Interface | Using the Paging Provider Interface]] for more details about the advanced paging feature.
831
832==== Basic finding ====
833
834The reference loader implements the interface ''ISDFindProvider'' interface. The user can search for ''Lifelines'' and ''Interactions''. The find is done across pages. If the expression to match is not on the current page a new thread is started to search on other pages. If expression is found the corresponding page is shown as well as the searched item is displayed. If not found then a message is displayed in the ''Progress View'' of Eclipse. Please refer to section [[#Using the Find Provider Interface | Using the Find Provider Interface]] for more details about the basic find feature.
835
836==== Basic filtering ====
837
838The reference loader implements the interface ''ISDFilterProvider'' interface. The user can filter on ''Lifelines'' and ''Interactions''. Please refer to section [[#Using the Filter Provider Interface | Using the Filter Provider Interface]] for more details about the basic filter feature.
839
840==== Selection Service ====
841
842The reference loader implements the interface ''ISelectionListener'' interface. When an interaction is selected a ''TmfTimeSynchSignal'' is broadcast (see [[#TMF Signal Framework | TMF Signal Framework]]). Please also refer to section [[#Using the Selection Provider Service | Using the Selection Provider Service]] for more details about the selection service and .
843
844=== Used TMF Features ===
845
846The reference implementation uses the following features of TMF:
847*TMF Experiment and Trace for accessing traces
848*Event Request Framework to request TMF events from the experiment and respective traces
849*Signal Framework for broadcasting and receiving TMF signals for synchronization purposes
850
851==== TMF Experiment and Trace for accessing traces ====
852
853The reference loader uses TMF Experiments to access traces and to request data from the traces.
854
855==== TMF Event Request Framework ====
856
857The reference loader use the TMF Event Request Framework to request events from the experiment and its traces.
858
859When opening a traces (which is triggered by signal ''TmfExperimentSelected'') or when opening the Sequence Diagram View after a trace had been opened previously, a TMF background request is initiated to index the trace and to fill in the first page of the sequence diagram. The purpose of the indexing is to store time ranges for pages with 10000 messages per page. This allows quickly to move to certain pages in a trace without having to re-parse from the beginning. The request is called indexing request.
860
861When switching pages, the a TMF foreground event request is initiated to retrieve the corresponding events from the experiment. It uses the time range stored in the index for the respective page.
862
863A third type of event request is issued for finding specific data across pages.
864
865==== TMF Signal Framework ====
866
867The reference loader extends the class ''TmfComponent''. By doing that the loader is register as TMF signal handler for sending and receiving TMF signals. The loader implements signal handlers for the following TMF signals:
fac4e45b
BH
868*''TmfTraceSelectedSignal''
869This signal indicates that a trace or experiment was selected. When receiving this signal the indexing request is initiated and the first page is displayed after receiving the relevant information.
870*''traceClosed''
871This signal indicates that a trace or experiment was closed. When receiving this signal the loader resets its data and a blank page is loaded in the Sequence Diagram View.
067490ab 872*''TmfTimeSynchSignal''
fac4e45b 873This signal indicates that a event with a certain timestamp is selected. When receiving this signal the corresponding message is selected in the Sequence Diagram View. If necessary, the page is changed.
067490ab
AM
874*''TmfRangeSynchSignal''
875This signal indicates that a new time range is in focus. When receiving this signal the loader loads the page which corresponds to the start time of the time range signal. The message with the start time will be in focus.
876
fac4e45b 877Besides acting on receiving signals, the reference loader is also sending signals. A ''TmfTimeSynchSignal'' is broadcasted with the timestamp of the message which was selected in the Sequence Diagram View. ''TmfRangeSynchSignal'' is sent when a page is changed in the Sequence Diagram View. The start timestamp of the time range sent is the timestamp of the first message. The end timestamp sent is the timestamp of the first message plus the current time range window. The current time range window is the time window that was indicated in the last received ''TmfRangeSynchSignal''.
067490ab
AM
878
879=== Supported Traces ===
880
fac4e45b 881The reference implementation is able to analyze traces from a single component that traces the interaction with other components. For example, a server node could have trace information about its interaction with client nodes. The server node could be traced and then analyzed using TMF and the Sequence Diagram Framework of TMF could used to visualize the interactions with the client nodes.<br>
067490ab
AM
882
883Note that combined traces of multiple components, that contain the trace information about the same interactions are not supported in the reference implementation!
884
885=== Trace Format ===
886
887The reference implementation in class ''TmfUml2SDSyncLoader'' in package ''org.eclipse.linuxtools.tmf.ui.views.uml2sd.impl'' analyzes events from type ''ITmfEvent'' and creates events type ''ITmfSyncSequenceDiagramEvent'' if the ''ITmfEvent'' contains all relevant information information. The parsing algorithm looks like as follows:
888
889<pre>
890 /**
891 * @param tmfEvent Event to parse for sequence diagram event details
892 * @return sequence diagram event if details are available else null
893 */
fac4e45b 894 protected ITmfSyncSequenceDiagramEvent getSequenceDiagramEvent(ITmfEvent tmfEvent){
067490ab
AM
895 //type = .*RECEIVE.* or .*SEND.*
896 //content = sender:<sender name>:receiver:<receiver name>,signal:<signal name>
897 String eventType = tmfEvent.getType().toString();
fac4e45b
BH
898 if (eventType.contains(Messages.TmfUml2SDSyncLoader_EventTypeSend) || eventType.contains(Messages.TmfUml2SDSyncLoader_EventTypeReceive)) {
899 Object sender = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncLoader_FieldSender);
900 Object receiver = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncLoader_FieldReceiver);
901 Object name = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncLoader_FieldSignal);
067490ab
AM
902 if ((sender instanceof ITmfEventField) && (receiver instanceof ITmfEventField) && (name instanceof ITmfEventField)) {
903 ITmfSyncSequenceDiagramEvent sdEvent = new TmfSyncSequenceDiagramEvent(tmfEvent,
904 ((ITmfEventField) sender).getValue().toString(),
905 ((ITmfEventField) receiver).getValue().toString(),
906 ((ITmfEventField) name).getValue().toString());
907
908 return sdEvent;
909 }
910 }
911 return null;
fac4e45b 912 }
067490ab
AM
913</pre>
914
915The analysis looks for event type Strings containing ''SEND'' and ''RECEIVE''. If event type matches these key words, the analyzer will look for strings ''sender'', ''receiver'' and ''signal'' in the event fields of type ''ITmfEventField''. If all the data is found a sequence diagram event from can be created. Note that Sync Messages are assumed, which means start and end time are the same.
916
917=== How to use the Reference Implementation ===
918
919An example trace visualizer is provided that uses a trace in binary format. It contains trace events with sequence diagram information. To parse the data using TMF a class is provided that implements ''ITmfTrace''. Additionally, a parser is provided that reads from the file and converts a trace event to ''TmfEvent''. This parser implements the interface ''ITmfEventParser''. To get the source code see [[#Downloading the Reference Plug-in | Download the Reference Plug-in]]
920<br>
921The plug-in structure will look like this:<br>
922[[Image:images/ReferencePlugin.png]]<br>
923
924To open the plug-in manifest, double-click on the MANIFEST.MF file. <br>
925[[Image:images/SelectManifestRef.png]]<br>
926
927Run the Reference Application. To launch the Eclipse Application select the ''Overview'' tab and click on '''Launch an Eclipse Application'''<br>
928[[Image:images/RunApplicationRef.png]]<br>
929
930To open the Reference Sequence Diagram View, select '''Windows -> Show View -> Other... -> TMF -> Sequence Diagram''' <br>
931[[Image:images/ShowTmfSDView.png]]<br>
932
fac4e45b 933An blank Sequence Diagram View will open.
067490ab 934
fac4e45b 935Select the '''Select Experiment''' button of the toolbar to load the sequence diagram from the data provided in the trace file. What this does is open the file ''tracesets/sdEvents'', parse this file through TMF and analyze all events of type ''TmfEvent'' and generates the Sequence Diagram out of it. <br>
067490ab
AM
936[[Image:images/ReferenceSeqDiagram.png]]<br>
937
938Now the reference application can be explored. To demonstrate the view features try the following things:
939*Select a message in the Sequence diagram. As result the corresponding event will be selected in the Events View.
940*Select an event in the Events View. As result the corresponding message in the Sequence Diagram View will be selected. If necessary, the page will be changed.
941*In the Events View, press key ''End''. As result, the Sequence Diagram view will jump to the last page.
942*In the Events View, press key ''Home''. As result, the Sequence Diagram view will jump to the first page.
943*In the Sequence Diagram View select the find button. Enter the expression '''REGISTER.*''', select '''Search for Interaction''' and press '''Find'''. As result the corresponding message will be selected in the Sequence Diagram and the corresponding event in the Events View will be selected. Select again '''Find''' the next occurrence of will be selected. Since the second occurrence is on a different page than the first, the corresponding page will be loaded.
944* In the Sequence Diagram View, select menu item '''Hide Patterns...'''. Add the filter '''BALL.*''' for '''Interaction''' only and select '''OK'''. As result all messages with name ''BALL_REQUEST'' and ''BALL_REPLY'' will be hidden. To remove the filter, select menu item '''Hide Patterns...''', deselect the corresponding filter and press '''OK'''. All the messages will be shown again.<br>
945
946To dispose the diagram, select the '''Dispose Experiment''' button of the toolbar. The current sequence diagram will be disposed and an empty diagram will be loaded.
947
948=== Extending the Reference Loader ===
949
950In some case it might be necessary to change the implementation of the analysis of each ''TmfEvent'' for the generation of ''Sequence Diagram Events''. For that just extend the class ''TmfUml2SDSyncLoader'' and overwrite the method ''protected ITmfSyncSequenceDiagramEvent getSequnceDiagramEvent(TmfEvent tmfEvent)'' with your own implementation.
951
952=== Downloading the Reference Plug-in ===
fac4e45b 953To download the reference plug-in that demonstrates the reference loader, use the following link: [http://wiki.eclipse.org/images/d/d3/ReferencePlugin.zip Reference Plug-in]. Just extract the zip file and import the extracted Eclipse plug-in (plug-in name: ''org.eclipse.linuxtools.tmf.reference.ui'') to your Eclipse workspace. <br>
067490ab
AM
954
955=CTF Parser=
956
5f7ef209 957== CTF Format ==
067490ab
AM
958CTF is a format used to store traces. It is self defining, binary and made to be easy to write to.
959Before going further, the full specification of the CTF file format can be found at http://www.efficios.com/ .
960
5f7ef209 961For the purpose of the reader some basic description will be given. A CTF trace typically is made of several files all in the same folder.
067490ab 962
5f7ef209 963These files can be split into two types :
067490ab
AM
964* Metadata
965* Event streams
5f7ef209 966
067490ab 967=== Metadata ===
5f7ef209 968The metadata is either raw text or packetized text. It is tsdl encoded. it contains a description of the type of data in the event streams. It can grow over time if new events are added to a trace but it will never overwrite what is already there.
067490ab
AM
969
970=== Event Streams ===
5f7ef209 971The event streams are a file per stream per cpu. These streams are binary and packet based. The streams store events and event information (ie lost events) The event data is stored in headers and field payloads.
067490ab
AM
972
973So if you have two streams (channels) "channel1" and "channel2" and 4 cores, you will have the following files in your trace directory: "channel1_0" , "channel1_1" , "channel1_2" , "channel1_3" , "channel2_0" , "channel2_1" , "channel2_2" & "channel2_3"
974
975== Reading a trace ==
976In order to read a CTF trace, two steps must be done.
977* The metadata must be read to know how to read the events.
978* the events must be read.
979
5f7ef209 980The metadata is a written in a subset of the C language called TSDL. To read it, first it is depacketized (if it is not in plain text) then the raw text is parsed by an antlr grammer. The parsing is done in two phases. There is a lexer (CTFLexer.g) which separated the metatdata text into tokens. The tokens are then pattern matched using the parser (CTFParser.g) to form an AST. This AST is walked through using "IOStructGen.java" to populate streams and traces in trace parent object.
067490ab 981
5f7ef209
MK
982When the metadata is loaded and read, the trace object will be populated with 3 items:
983* the event definitions available per stream: a definition is a description of the datatype.
984* the event declarations available per stream: this will save declaration creation on a per event basis. They will all be created in advance, just not populated.
985* the beginning of a packet index.
067490ab 986
5f7ef209 987Now all the trace readers for the event streams have everything they need to read a trace. They will each point to one file, and read the file from packet to packet. Everytime the trace reader changes packet, the index is updated with the new packet's information. The readers are in a priority queue and sorted by timestamp. This ensures that the events are read in a sequential order. They are also sorted by file name so that in the eventuality that two events occur at the same time, they stay in the same order.
067490ab
AM
988
989== Seeking in a trace ==
5f7ef209 990The reason for maintaining an index is to speed up seeks. In the case that a user wishes to seek to a certain timestamp, they just have to find the index entry that contains the timestamp, and go there to iterate in that packet until the proper event is found. this will reduce the searches time by an order of 8000 for a 256k paket size (kernel default).
067490ab
AM
991
992== Interfacing to TMF ==
5f7ef209 993The trace can be read easily now but the data is still awkward to extract.
067490ab
AM
994
995=== CtfLocation ===
5f7ef209 996A location in a given trace, it is currently the timestamp of a trace and the index of the event. The index shows for a given timestamp if it is the first second or nth element.
067490ab
AM
997
998=== CtfTmfTrace ===
999The CtfTmfTrace is a wrapper for the standard CTF trace that allows it to perform the following actions:
5f7ef209
MK
1000* '''initTrace()''' create a trace
1001* '''validateTrace()''' is the trace a CTF trace?
1002* '''getLocationRatio()''' how far in the trace is my location?
1003* '''seekEvent()''' sets the cursor to a certain point in a trace.
1004* '''readNextEvent()''' reads the next event and then advances the cursor
1005* '''getTraceProperties()''' gets the 'env' structures of the metadata
067490ab
AM
1006
1007=== CtfIterator ===
1008The CtfIterator is a wrapper to the CTF file reader. It behaves like an iterator on a trace. However, it contains a file pointer and thus cannot be duplicated too often or the system will run out of file handles. To alleviate the situation, a pool of iterators is created at the very beginning and stored in the CtfTmfTrace. They can be retried by calling the GetIterator() method.
1009
5f7ef209
MK
1010=== CtfIteratorManager ===
1011Since each CtfIterator will have a file reader, the OS will run out of handles if too many iterators are spawned. The solution is to use the iterator manager. This will allow the user to get an iterator. If there is a context at the requested position, the manager will return that one, if not, a context will be selected at random and set to the correct location. Using random replacement minimizes contention as it will settle quickly at a new balance point.
1012
1013=== CtfTmfContext ===
1014The CtfTmfContext implements the ITmfContext type. It is the CTF equivalent of TmfContext. It has a CtfLocation and points to an iterator in the CtfTmfTrace iterator pool as well as the parent trace. it is made to be cloned easily and not affect system resources much. Contexts behave much like C file pointers (FILE*) but they can be copied until one runs out of RAM.
067490ab
AM
1015
1016=== CtfTmfTimestamp ===
1017The CtfTmfTimestamp take a CTF time (normally a long int) and outputs the time formats it as a TmfTimestamp, allowing it to be compared to other timestamps. The time is stored with the UTC offset already applied. It also features a simple toString() function that allows it to output the time in more Human readable ways: "yyyy/mm/dd/hh:mm:ss.nnnnnnnnn ns" for example. An additional feature is the getDelta() function that allows two timestamps to be substracted, showing the time difference between A and B.
1018
1019=== CtfTmfEvent ===
5f7ef209 1020The CtfTmfEvent is an ITmfEvent that is used to wrap event declarations and event definitions from the CTF side into easier to read and parse chunks of information. It is a final class with final fields made to be newed very often without incurring performance costs. Most of the information is already available. It should be noted that one type of event can appear called "lost event" these are synthetic events that do not exist in the trace. They will not appear in other trace readers such as babeltrace.
067490ab
AM
1021
1022=== Other ===
5f7ef209 1023There are other helper files that format given events for views, they are simpler and the architecture does not depend on them.
067490ab
AM
1024
1025=== Limitations ===
1026For the moment live trace reading is not supported, there are no sources of traces to test on.
1027
This page took 0.12986 seconds and 5 git commands to generate.