tmf: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / linuxtools / tmf / core / trace / TmfTrace.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 Ericsson, École Polytechnique de Montréal
3 *
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
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Trace Model 1.0
12 * Patrick Tasse - Updated for removal of context clone
13 * Geneviève Bastien - Added timestamp transforms, its saving to file and
14 * timestamp creation functions
15 *******************************************************************************/
16
17 package org.eclipse.linuxtools.tmf.core.trace;
18
19 import java.io.File;
20 import java.util.Collections;
21 import java.util.HashSet;
22 import java.util.LinkedHashMap;
23 import java.util.Map;
24 import java.util.Map.Entry;
25 import java.util.Set;
26
27 import org.eclipse.core.resources.IResource;
28 import org.eclipse.core.runtime.IStatus;
29 import org.eclipse.core.runtime.MultiStatus;
30 import org.eclipse.core.runtime.Path;
31 import org.eclipse.core.runtime.Status;
32 import org.eclipse.linuxtools.internal.tmf.core.Activator;
33 import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
34 import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModuleHelper;
35 import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisManager;
36 import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
37 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
38 import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
39 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
40 import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
41 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
42 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
43 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
44 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceRangeUpdatedSignal;
45 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
46 import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
47 import org.eclipse.linuxtools.tmf.core.synchronization.TimestampTransformFactory;
48 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
49 import org.eclipse.linuxtools.tmf.core.timestamp.TmfNanoTimestamp;
50 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
51 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
52 import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
53 import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
54 import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
55
56 /**
57 * Abstract implementation of ITmfTrace.
58 * <p>
59 * Since the concept of 'location' is trace specific, the concrete classes have
60 * to provide the related methods, namely:
61 * <ul>
62 * <li> public ITmfLocation<?> getCurrentLocation()
63 * <li> public double getLocationRatio(ITmfLocation<?> location)
64 * <li> public ITmfContext seekEvent(ITmfLocation<?> location)
65 * <li> public ITmfContext seekEvent(double ratio)
66 * <li> public IStatus validate(IProject project, String path)
67 * </ul>
68 * A concrete trace must provide its corresponding parser. A common way to
69 * accomplish this is by making the concrete class extend TmfTrace and
70 * implement ITmfEventParser.
71 * <p>
72 * When constructing an event, the concrete trace should use the trace's
73 * timestamp transform to create the timestamp, by either transforming the
74 * parsed time value directly or by using the method createTimestamp().
75 * <p>
76 * The concrete class can either specify its own indexer or use the provided
77 * TmfCheckpointIndexer (default). In this case, the trace cache size will be
78 * used as checkpoint interval.
79 *
80 * @version 1.0
81 * @author Francois Chouinard
82 *
83 * @see ITmfEvent
84 * @see ITmfTraceIndexer
85 * @see ITmfEventParser
86 */
87 public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, ITmfTraceCompleteness {
88
89 // ------------------------------------------------------------------------
90 // Attributes
91 // ------------------------------------------------------------------------
92
93 // The resource used for persistent properties for this trace
94 private IResource fResource;
95
96 // The trace path
97 private String fPath;
98
99 // The trace cache page size
100 private int fCacheSize = ITmfTrace.DEFAULT_TRACE_CACHE_SIZE;
101
102 // The number of events collected (so far)
103 private volatile long fNbEvents = 0;
104
105 // The time span of the event stream
106 private ITmfTimestamp fStartTime = TmfTimestamp.BIG_BANG;
107 private ITmfTimestamp fEndTime = TmfTimestamp.BIG_BANG;
108
109 // The trace streaming interval (0 = no streaming)
110 private long fStreamingInterval = 0;
111
112 // The trace indexer
113 private ITmfTraceIndexer fIndexer;
114
115 // The trace parser
116 private ITmfEventParser fParser;
117
118 private ITmfTimestampTransform fTsTransform;
119
120 private final Map<String, IAnalysisModule> fAnalysisModules =
121 Collections.synchronizedMap(new LinkedHashMap<String, IAnalysisModule>());
122
123 // ------------------------------------------------------------------------
124 // Construction
125 // ------------------------------------------------------------------------
126
127 /**
128 * The default, parameterless, constructor
129 */
130 public TmfTrace() {
131 super();
132 fIndexer = createIndexer(DEFAULT_BLOCK_SIZE);
133 }
134
135 /**
136 * Full constructor.
137 *
138 * @param resource
139 * The resource associated to the trace
140 * @param type
141 * The type of events that will be read from this trace
142 * @param path
143 * The path to the trace on the filesystem
144 * @param cacheSize
145 * The trace cache size. Pass '-1' to use the default specified
146 * in {@link ITmfTrace#DEFAULT_TRACE_CACHE_SIZE}
147 * @param interval
148 * The trace streaming interval. You can use '0' for post-mortem
149 * traces.
150 * @param parser
151 * The trace event parser. Use 'null' if (and only if) the trace
152 * object itself is also the ITmfEventParser to be used.
153 * @throws TmfTraceException
154 * If something failed during the opening
155 */
156 protected TmfTrace(final IResource resource,
157 final Class<? extends ITmfEvent> type,
158 final String path,
159 final int cacheSize,
160 final long interval,
161 final ITmfEventParser parser)
162 throws TmfTraceException {
163 super();
164 fCacheSize = (cacheSize > 0) ? cacheSize : ITmfTrace.DEFAULT_TRACE_CACHE_SIZE;
165 fStreamingInterval = interval;
166 fParser = parser;
167 initialize(resource, path, type);
168 }
169
170 /**
171 * Copy constructor
172 *
173 * @param trace the original trace
174 * @throws TmfTraceException Should not happen usually
175 */
176 public TmfTrace(final TmfTrace trace) throws TmfTraceException {
177 super();
178 if (trace == null) {
179 throw new IllegalArgumentException();
180 }
181 fCacheSize = trace.getCacheSize();
182 fStreamingInterval = trace.getStreamingInterval();
183 fParser = trace.fParser;
184 initialize(trace.getResource(), trace.getPath(), trace.getEventType());
185 }
186
187 /**
188 * Creates the indexer instance. Classes extending this class can override
189 * this to provide a different indexer implementation.
190 *
191 * @param interval the checkpoints interval
192 *
193 * @return the indexer
194 * @since 3.0
195 */
196 protected ITmfTraceIndexer createIndexer(int interval) {
197 return new TmfCheckpointIndexer(this, interval);
198 }
199
200 // ------------------------------------------------------------------------
201 // ITmfTrace - Initializers
202 // ------------------------------------------------------------------------
203
204 @Override
205 public void initTrace(final IResource resource, final String path, final Class<? extends ITmfEvent> type, String name) throws TmfTraceException {
206 setName(name);
207 initTrace(resource, path, type);
208 }
209
210 @Override
211 public void initTrace(final IResource resource, final String path, final Class<? extends ITmfEvent> type) throws TmfTraceException {
212 initialize(resource, path, type);
213 }
214
215 /**
216 * Initialize the trace common attributes and the base component.
217 *
218 * @param resource the Eclipse resource (trace)
219 * @param path the trace path
220 * @param type the trace event type
221 *
222 * @throws TmfTraceException If something failed during the initialization
223 */
224 protected void initialize(final IResource resource,
225 final String path,
226 final Class<? extends ITmfEvent> type)
227 throws TmfTraceException {
228 if (path == null) {
229 throw new TmfTraceException("Invalid trace path"); //$NON-NLS-1$
230 }
231 fPath = path;
232 fResource = resource;
233 String traceName = getName();
234 if (traceName == null || traceName.isEmpty()) {
235 traceName = (resource != null) ? resource.getName() : new Path(path).lastSegment();
236 }
237 if (fParser == null) {
238 if (this instanceof ITmfEventParser) {
239 fParser = (ITmfEventParser) this;
240 } else {
241 throw new TmfTraceException("Invalid trace parser"); //$NON-NLS-1$
242 }
243 }
244 super.init(traceName, type);
245 // register as VIP after super.init() because TmfComponent registers to signal manager there
246 TmfSignalManager.registerVIP(this);
247 if (fIndexer != null) {
248 fIndexer.dispose();
249 }
250 fIndexer = createIndexer(fCacheSize);
251 }
252
253 /**
254 * Indicates if the path points to an existing file/directory
255 *
256 * @param path the path to test
257 * @return true if the file/directory exists
258 */
259 protected boolean fileExists(final String path) {
260 final File file = new File(path);
261 return file.exists();
262 }
263
264 /**
265 * @since 2.0
266 */
267 @Override
268 public void indexTrace(boolean waitForCompletion) {
269 getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, waitForCompletion);
270 }
271
272 /**
273 * Instantiate the applicable analysis modules and executes the analysis
274 * modules that are meant to be automatically executed
275 *
276 * @return An IStatus indicating whether the analysis could be run
277 * successfully or not
278 * @since 3.0
279 */
280 protected IStatus executeAnalysis() {
281 MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null);
282 Map<String, IAnalysisModuleHelper> modules = TmfAnalysisManager.getAnalysisModules(this.getClass());
283 for (IAnalysisModuleHelper helper : modules.values()) {
284 try {
285 IAnalysisModule module = helper.newModule(this);
286 fAnalysisModules.put(module.getId(), module);
287 if (module.isAutomatic()) {
288 status.add(module.schedule());
289 }
290 } catch (TmfAnalysisException e) {
291 status.add(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage()));
292 }
293 }
294 return status;
295 }
296
297 /**
298 * @since 3.0
299 */
300 @Override
301 public IAnalysisModule getAnalysisModule(String analysisId) {
302 return fAnalysisModules.get(analysisId);
303 }
304
305
306 /**
307 * @since 3.0
308 */
309 @Override
310 public Iterable<IAnalysisModule> getAnalysisModules() {
311 synchronized (fAnalysisModules) {
312 Set<IAnalysisModule> modules = new HashSet<>(fAnalysisModules.values());
313 return modules;
314 }
315 }
316
317 /**
318 * @since 3.0
319 */
320 @Override
321 public <T extends IAnalysisModule> T getAnalysisModuleOfClass(Class<T> moduleClass, String id) {
322 Iterable<T> modules = getAnalysisModulesOfClass(moduleClass);
323 for (T module : modules) {
324 if (id.equals(module.getId())) {
325 return module;
326 }
327 }
328 return null;
329 }
330
331 /**
332 * @since 3.0
333 */
334 @Override
335 public <T> Iterable<T> getAnalysisModulesOfClass(Class<T> moduleClass) {
336 Set<T> modules = new HashSet<>();
337 synchronized (fAnalysisModules) {
338 for (Entry<String, IAnalysisModule> entry : fAnalysisModules.entrySet()) {
339 if (moduleClass.isAssignableFrom(entry.getValue().getClass())) {
340 modules.add(moduleClass.cast(entry.getValue()));
341 }
342 }
343 }
344 return modules;
345 }
346
347 /**
348 * Clears the trace
349 */
350 @Override
351 public synchronized void dispose() {
352 /* Clean up the index if applicable */
353 if (getIndexer() != null) {
354 getIndexer().dispose();
355 }
356
357 /* Clean up the analysis modules */
358 synchronized (fAnalysisModules) {
359 for (IAnalysisModule module : fAnalysisModules.values()) {
360 module.dispose();
361 }
362 fAnalysisModules.clear();
363 }
364
365 super.dispose();
366 }
367
368 // ------------------------------------------------------------------------
369 // ITmfTrace - Basic getters
370 // ------------------------------------------------------------------------
371
372 @Override
373 public Class<? extends ITmfEvent> getEventType() {
374 return super.getType();
375 }
376
377 @Override
378 public IResource getResource() {
379 return fResource;
380 }
381
382 @Override
383 public String getPath() {
384 return fPath;
385 }
386
387 @Override
388 public int getCacheSize() {
389 return fCacheSize;
390 }
391
392 @Override
393 public long getStreamingInterval() {
394 return fStreamingInterval;
395 }
396
397 /**
398 * @return the trace indexer
399 * @since 3.0
400 */
401 protected ITmfTraceIndexer getIndexer() {
402 return fIndexer;
403 }
404
405 /**
406 * @return the trace parser
407 */
408 protected ITmfEventParser getParser() {
409 return fParser;
410 }
411
412 // ------------------------------------------------------------------------
413 // ITmfTrace - Trace characteristics getters
414 // ------------------------------------------------------------------------
415
416 @Override
417 public long getNbEvents() {
418 return fNbEvents;
419 }
420
421 /**
422 * @since 2.0
423 */
424 @Override
425 public TmfTimeRange getTimeRange() {
426 return new TmfTimeRange(fStartTime, fEndTime);
427 }
428
429 /**
430 * @since 2.0
431 */
432 @Override
433 public ITmfTimestamp getStartTime() {
434 return fStartTime;
435 }
436
437 /**
438 * @since 2.0
439 */
440 @Override
441 public ITmfTimestamp getEndTime() {
442 return fEndTime;
443 }
444
445 /**
446 * @since 2.0
447 */
448 @Override
449 public ITmfTimestamp getInitialRangeOffset() {
450 final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
451 return new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
452 }
453
454 /**
455 * @since 3.0
456 */
457 @Override
458 public String getHostId() {
459 return this.getName();
460 }
461
462 // ------------------------------------------------------------------------
463 // Convenience setters
464 // ------------------------------------------------------------------------
465
466 /**
467 * Set the trace cache size. Must be done at initialization time.
468 *
469 * @param cacheSize The trace cache size
470 */
471 protected void setCacheSize(final int cacheSize) {
472 fCacheSize = cacheSize;
473 }
474
475 /**
476 * Set the trace known number of events. This can be quite dynamic
477 * during indexing or for live traces.
478 *
479 * @param nbEvents The number of events
480 */
481 protected synchronized void setNbEvents(final long nbEvents) {
482 fNbEvents = (nbEvents > 0) ? nbEvents : 0;
483 }
484
485 /**
486 * Update the trace events time range
487 *
488 * @param range the new time range
489 * @since 2.0
490 */
491 protected void setTimeRange(final TmfTimeRange range) {
492 fStartTime = range.getStartTime();
493 fEndTime = range.getEndTime();
494 }
495
496 /**
497 * Update the trace chronologically first event timestamp
498 *
499 * @param startTime the new first event timestamp
500 * @since 2.0
501 */
502 protected void setStartTime(final ITmfTimestamp startTime) {
503 fStartTime = startTime;
504 }
505
506 /**
507 * Update the trace chronologically last event timestamp
508 *
509 * @param endTime the new last event timestamp
510 * @since 2.0
511 */
512 protected void setEndTime(final ITmfTimestamp endTime) {
513 fEndTime = endTime;
514 }
515
516 /**
517 * Set the polling interval for live traces (default = 0 = no streaming).
518 *
519 * @param interval the new trace streaming interval
520 */
521 protected void setStreamingInterval(final long interval) {
522 fStreamingInterval = (interval > 0) ? interval : 0;
523 }
524
525 /**
526 * Set the trace parser. Must be done at initialization time.
527 *
528 * @param parser the new trace parser
529 */
530 protected void setParser(final ITmfEventParser parser) {
531 fParser = parser;
532 }
533
534 // ------------------------------------------------------------------------
535 // ITmfTrace - SeekEvent operations (returning a trace context)
536 // ------------------------------------------------------------------------
537
538 @Override
539 public synchronized ITmfContext seekEvent(final long rank) {
540
541 // A rank <= 0 indicates to seek the first event
542 if (rank <= 0) {
543 ITmfContext context = seekEvent((ITmfLocation) null);
544 context.setRank(0);
545 return context;
546 }
547
548 // Position the trace at the checkpoint
549 final ITmfContext context = fIndexer.seekIndex(rank);
550
551 // And locate the requested event context
552 long pos = context.getRank();
553 if (pos < rank) {
554 ITmfEvent event = getNext(context);
555 while ((event != null) && (++pos < rank)) {
556 event = getNext(context);
557 }
558 }
559 return context;
560 }
561
562 /**
563 * @since 2.0
564 */
565 @Override
566 public synchronized ITmfContext seekEvent(final ITmfTimestamp timestamp) {
567
568 // A null timestamp indicates to seek the first event
569 if (timestamp == null) {
570 ITmfContext context = seekEvent((ITmfLocation) null);
571 context.setRank(0);
572 return context;
573 }
574
575 // Position the trace at the checkpoint
576 ITmfContext context = fIndexer.seekIndex(timestamp);
577
578 // And locate the requested event context
579 ITmfLocation previousLocation = context.getLocation();
580 long previousRank = context.getRank();
581 ITmfEvent event = getNext(context);
582 while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) {
583 previousLocation = context.getLocation();
584 previousRank = context.getRank();
585 event = getNext(context);
586 }
587 if (event == null) {
588 context.setLocation(null);
589 context.setRank(ITmfContext.UNKNOWN_RANK);
590 } else {
591 context.dispose();
592 context = seekEvent(previousLocation);
593 context.setRank(previousRank);
594 }
595 return context;
596 }
597
598 // ------------------------------------------------------------------------
599 // ITmfTrace - Read operations (returning an actual event)
600 // ------------------------------------------------------------------------
601
602 @Override
603 public synchronized ITmfEvent getNext(final ITmfContext context) {
604 // parseEvent() does not update the context
605 final ITmfEvent event = fParser.parseEvent(context);
606 if (event != null) {
607 updateAttributes(context, event.getTimestamp());
608 context.setLocation(getCurrentLocation());
609 context.increaseRank();
610 processEvent(event);
611 }
612 return event;
613 }
614
615 /**
616 * Hook for special event processing by the concrete class
617 * (called by TmfTrace.getEvent())
618 *
619 * @param event the event
620 */
621 protected void processEvent(final ITmfEvent event) {
622 // Do nothing
623 }
624
625 /**
626 * Update the trace attributes
627 *
628 * @param context the current trace context
629 * @param timestamp the corresponding timestamp
630 * @since 2.0
631 */
632 protected synchronized void updateAttributes(final ITmfContext context, final ITmfTimestamp timestamp) {
633 if (fStartTime.equals(TmfTimestamp.BIG_BANG) || (fStartTime.compareTo(timestamp, false) > 0)) {
634 fStartTime = timestamp;
635 }
636 if (fEndTime.equals(TmfTimestamp.BIG_CRUNCH) || (fEndTime.compareTo(timestamp, false) < 0)) {
637 fEndTime = timestamp;
638 }
639 if (context.hasValidRank()) {
640 long rank = context.getRank();
641 if (fNbEvents <= rank) {
642 fNbEvents = rank + 1;
643 }
644 if (fIndexer != null) {
645 fIndexer.updateIndex(context, timestamp);
646 }
647 }
648 }
649
650 // ------------------------------------------------------------------------
651 // TmfDataProvider
652 // ------------------------------------------------------------------------
653
654 /**
655 * @since 2.0
656 */
657 @Override
658 public synchronized ITmfContext armRequest(final ITmfEventRequest request) {
659 if (executorIsShutdown()) {
660 return null;
661 }
662 if (!TmfTimestamp.BIG_BANG.equals(request.getRange().getStartTime())
663 && (request.getIndex() == 0)) {
664 final ITmfContext context = seekEvent(request.getRange().getStartTime());
665 request.setStartIndex((int) context.getRank());
666 return context;
667
668 }
669 return seekEvent(request.getIndex());
670 }
671
672 // ------------------------------------------------------------------------
673 // Signal handlers
674 // ------------------------------------------------------------------------
675
676 /**
677 * Handler for the Trace Opened signal
678 *
679 * @param signal
680 * The incoming signal
681 * @since 2.0
682 */
683 @TmfSignalHandler
684 public void traceOpened(TmfTraceOpenedSignal signal) {
685 boolean signalIsForUs = false;
686 for (ITmfTrace trace : TmfTraceManager.getTraceSet(signal.getTrace())) {
687 if (trace == this) {
688 signalIsForUs = true;
689 break;
690 }
691 }
692
693 if (!signalIsForUs) {
694 return;
695 }
696
697 /*
698 * The signal is either for this trace, or for an experiment containing
699 * this trace.
700 */
701 IStatus status = executeAnalysis();
702 if (!status.isOK()) {
703 Activator.log(status);
704 }
705
706 TmfTraceManager.refreshSupplementaryFiles(this);
707
708 if (signal.getTrace() == this) {
709 /* Additionally, the signal is directly for this trace. */
710 if (getNbEvents() == 0) {
711 return;
712 }
713
714 /* For a streaming trace, the range updated signal should be sent
715 * by the subclass when a new safe time is determined.
716 */
717 if (getStreamingInterval() > 0) {
718 return;
719 }
720
721 if (isComplete()) {
722 final TmfTimeRange timeRange = new TmfTimeRange(getStartTime(), TmfTimestamp.BIG_CRUNCH);
723 final TmfTraceRangeUpdatedSignal rangeUpdatedsignal = new TmfTraceRangeUpdatedSignal(this, this, timeRange);
724
725 // Broadcast in separate thread to prevent deadlock
726 broadcastAsync(rangeUpdatedsignal);
727 }
728 return;
729 }
730 }
731
732 /**
733 * Signal handler for the TmfTraceRangeUpdatedSignal signal
734 *
735 * @param signal The incoming signal
736 * @since 2.0
737 */
738 @TmfSignalHandler
739 public void traceRangeUpdated(final TmfTraceRangeUpdatedSignal signal) {
740 if (signal.getTrace() == this) {
741 getIndexer().buildIndex(getNbEvents(), signal.getRange(), false);
742 }
743 }
744
745 /**
746 * Signal handler for the TmfTraceUpdatedSignal signal
747 *
748 * @param signal The incoming signal
749 * @since 3.0
750 */
751 @TmfSignalHandler
752 public void traceUpdated(final TmfTraceUpdatedSignal signal) {
753 if (signal.getSource() == getIndexer()) {
754 fNbEvents = signal.getNbEvents();
755 fStartTime = signal.getRange().getStartTime();
756 fEndTime = signal.getRange().getEndTime();
757 }
758 }
759
760 // ------------------------------------------------------------------------
761 // Timestamp transformation functions
762 // ------------------------------------------------------------------------
763
764 /**
765 * @since 3.0
766 */
767 @Override
768 public ITmfTimestampTransform getTimestampTransform() {
769 if (fTsTransform == null) {
770 fTsTransform = TimestampTransformFactory.getTimestampTransform(getResource());
771 }
772 return fTsTransform;
773 }
774
775 /**
776 * @since 3.0
777 */
778 @Override
779 public void setTimestampTransform(final ITmfTimestampTransform tt) {
780 fTsTransform = tt;
781 TimestampTransformFactory.setTimestampTransform(getResource(), tt);
782 }
783
784 /**
785 * @since 3.0
786 */
787 @Override
788 public ITmfTimestamp createTimestamp(long ts) {
789 return new TmfNanoTimestamp(getTimestampTransform().transform(ts));
790 }
791
792 // ------------------------------------------------------------------------
793 // toString
794 // ------------------------------------------------------------------------
795
796 @Override
797 @SuppressWarnings("nls")
798 public synchronized String toString() {
799 return "TmfTrace [fPath=" + fPath + ", fCacheSize=" + fCacheSize
800 + ", fNbEvents=" + fNbEvents + ", fStartTime=" + fStartTime
801 + ", fEndTime=" + fEndTime + ", fStreamingInterval=" + fStreamingInterval + "]";
802 }
803
804 /**
805 * @since 3.1
806 */
807 @Override
808 public boolean isComplete() {
809 /*
810 * Be default, all traces are "complete" which means no more data will
811 * be added later
812 */
813 return true;
814 }
815
816 /**
817 * @since 3.1
818 */
819 @Override
820 public void setComplete(boolean isComplete) {
821 /*
822 * This should be overridden by trace classes that can support live
823 * reading (traces in an incomplete state)
824 */
825 }
826 }
This page took 0.051129 seconds and 5 git commands to generate.