4ba16bf7379d75e5bcc94738937aff56b64414b8
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / 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.tracecompass.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.tracecompass.internal.tmf.core.Activator;
33 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
34 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper;
35 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisManager;
36 import org.eclipse.tracecompass.tmf.core.component.TmfEventProvider;
37 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
38 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
39 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
40 import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
41 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
42 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
43 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
44 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal;
45 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceUpdatedSignal;
46 import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform;
47 import org.eclipse.tracecompass.tmf.core.synchronization.TimestampTransformFactory;
48 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
49 import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
50 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
51 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
52 import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer;
53 import org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
54 import org.eclipse.tracecompass.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 if (name == null) {
207 throw new IllegalArgumentException();
208 }
209 setName(name);
210 initTrace(resource, path, type);
211 }
212
213 @Override
214 public void initTrace(final IResource resource, final String path, final Class<? extends ITmfEvent> type) throws TmfTraceException {
215 initialize(resource, path, type);
216 }
217
218 /**
219 * Initialize the trace common attributes and the base component.
220 *
221 * @param resource the Eclipse resource (trace)
222 * @param path the trace path
223 * @param type the trace event type
224 *
225 * @throws TmfTraceException If something failed during the initialization
226 */
227 protected void initialize(final IResource resource,
228 final String path,
229 final Class<? extends ITmfEvent> type)
230 throws TmfTraceException {
231 if (path == null) {
232 throw new TmfTraceException("Invalid trace path"); //$NON-NLS-1$
233 }
234 fPath = path;
235 fResource = resource;
236 String traceName = getName();
237 if (traceName.isEmpty()) {
238 traceName = (resource != null) ? resource.getName() : new Path(path).lastSegment();
239 }
240 if (fParser == null) {
241 if (this instanceof ITmfEventParser) {
242 fParser = (ITmfEventParser) this;
243 } else {
244 throw new TmfTraceException("Invalid trace parser"); //$NON-NLS-1$
245 }
246 }
247 super.init(traceName, type);
248 // register as VIP after super.init() because TmfComponent registers to signal manager there
249 TmfSignalManager.registerVIP(this);
250 if (fIndexer != null) {
251 fIndexer.dispose();
252 }
253 fIndexer = createIndexer(fCacheSize);
254 }
255
256 /**
257 * Indicates if the path points to an existing file/directory
258 *
259 * @param path the path to test
260 * @return true if the file/directory exists
261 */
262 protected boolean fileExists(final String path) {
263 final File file = new File(path);
264 return file.exists();
265 }
266
267 /**
268 * @since 2.0
269 */
270 @Override
271 public void indexTrace(boolean waitForCompletion) {
272 getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, waitForCompletion);
273 }
274
275 /**
276 * Instantiate the applicable analysis modules and executes the analysis
277 * modules that are meant to be automatically executed
278 *
279 * @return An IStatus indicating whether the analysis could be run
280 * successfully or not
281 * @since 3.0
282 */
283 protected IStatus executeAnalysis() {
284 MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null);
285 Map<String, IAnalysisModuleHelper> modules = TmfAnalysisManager.getAnalysisModules(this.getClass());
286 for (IAnalysisModuleHelper helper : modules.values()) {
287 try {
288 IAnalysisModule module = helper.newModule(this);
289 fAnalysisModules.put(module.getId(), module);
290 if (module.isAutomatic()) {
291 status.add(module.schedule());
292 }
293 } catch (TmfAnalysisException e) {
294 status.add(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage()));
295 }
296 }
297 return status;
298 }
299
300 /**
301 * @since 3.0
302 */
303 @Override
304 public IAnalysisModule getAnalysisModule(String analysisId) {
305 return fAnalysisModules.get(analysisId);
306 }
307
308
309 /**
310 * @since 3.0
311 */
312 @Override
313 public Iterable<IAnalysisModule> getAnalysisModules() {
314 synchronized (fAnalysisModules) {
315 Set<IAnalysisModule> modules = new HashSet<>(fAnalysisModules.values());
316 return modules;
317 }
318 }
319
320 /**
321 * @since 3.0
322 */
323 @Override
324 public <T extends IAnalysisModule> T getAnalysisModuleOfClass(Class<T> moduleClass, String id) {
325 Iterable<T> modules = getAnalysisModulesOfClass(moduleClass);
326 for (T module : modules) {
327 if (id.equals(module.getId())) {
328 return module;
329 }
330 }
331 return null;
332 }
333
334 /**
335 * @since 3.0
336 */
337 @Override
338 public <T> Iterable<T> getAnalysisModulesOfClass(Class<T> moduleClass) {
339 Set<T> modules = new HashSet<>();
340 synchronized (fAnalysisModules) {
341 for (Entry<String, IAnalysisModule> entry : fAnalysisModules.entrySet()) {
342 if (moduleClass.isAssignableFrom(entry.getValue().getClass())) {
343 modules.add(moduleClass.cast(entry.getValue()));
344 }
345 }
346 }
347 return modules;
348 }
349
350 /**
351 * Clears the trace
352 */
353 @Override
354 public synchronized void dispose() {
355 /* Clean up the index if applicable */
356 if (getIndexer() != null) {
357 getIndexer().dispose();
358 }
359
360 /* Clean up the analysis modules */
361 synchronized (fAnalysisModules) {
362 for (IAnalysisModule module : fAnalysisModules.values()) {
363 module.dispose();
364 }
365 fAnalysisModules.clear();
366 }
367
368 super.dispose();
369 }
370
371 // ------------------------------------------------------------------------
372 // ITmfTrace - Basic getters
373 // ------------------------------------------------------------------------
374
375 @Override
376 public Class<? extends ITmfEvent> getEventType() {
377 return super.getType();
378 }
379
380 @Override
381 public IResource getResource() {
382 return fResource;
383 }
384
385 @Override
386 public String getPath() {
387 return fPath;
388 }
389
390 @Override
391 public int getCacheSize() {
392 return fCacheSize;
393 }
394
395 @Override
396 public long getStreamingInterval() {
397 return fStreamingInterval;
398 }
399
400 /**
401 * @return the trace indexer
402 * @since 3.0
403 */
404 protected ITmfTraceIndexer getIndexer() {
405 return fIndexer;
406 }
407
408 /**
409 * @return the trace parser
410 */
411 protected ITmfEventParser getParser() {
412 return fParser;
413 }
414
415 // ------------------------------------------------------------------------
416 // ITmfTrace - Trace characteristics getters
417 // ------------------------------------------------------------------------
418
419 @Override
420 public long getNbEvents() {
421 return fNbEvents;
422 }
423
424 /**
425 * @since 2.0
426 */
427 @Override
428 public TmfTimeRange getTimeRange() {
429 return new TmfTimeRange(fStartTime, fEndTime);
430 }
431
432 /**
433 * @since 2.0
434 */
435 @Override
436 public ITmfTimestamp getStartTime() {
437 return fStartTime;
438 }
439
440 /**
441 * @since 2.0
442 */
443 @Override
444 public ITmfTimestamp getEndTime() {
445 return fEndTime;
446 }
447
448 /**
449 * @since 2.0
450 */
451 @Override
452 public ITmfTimestamp getInitialRangeOffset() {
453 final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
454 return new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
455 }
456
457 /**
458 * @since 3.0
459 */
460 @Override
461 public String getHostId() {
462 return this.getName();
463 }
464
465 // ------------------------------------------------------------------------
466 // Convenience setters
467 // ------------------------------------------------------------------------
468
469 /**
470 * Set the trace cache size. Must be done at initialization time.
471 *
472 * @param cacheSize The trace cache size
473 */
474 protected void setCacheSize(final int cacheSize) {
475 fCacheSize = cacheSize;
476 }
477
478 /**
479 * Set the trace known number of events. This can be quite dynamic
480 * during indexing or for live traces.
481 *
482 * @param nbEvents The number of events
483 */
484 protected synchronized void setNbEvents(final long nbEvents) {
485 fNbEvents = (nbEvents > 0) ? nbEvents : 0;
486 }
487
488 /**
489 * Update the trace events time range
490 *
491 * @param range the new time range
492 * @since 2.0
493 */
494 protected void setTimeRange(final TmfTimeRange range) {
495 fStartTime = range.getStartTime();
496 fEndTime = range.getEndTime();
497 }
498
499 /**
500 * Update the trace chronologically first event timestamp
501 *
502 * @param startTime the new first event timestamp
503 * @since 2.0
504 */
505 protected void setStartTime(final ITmfTimestamp startTime) {
506 fStartTime = startTime;
507 }
508
509 /**
510 * Update the trace chronologically last event timestamp
511 *
512 * @param endTime the new last event timestamp
513 * @since 2.0
514 */
515 protected void setEndTime(final ITmfTimestamp endTime) {
516 fEndTime = endTime;
517 }
518
519 /**
520 * Set the polling interval for live traces (default = 0 = no streaming).
521 *
522 * @param interval the new trace streaming interval
523 */
524 protected void setStreamingInterval(final long interval) {
525 fStreamingInterval = (interval > 0) ? interval : 0;
526 }
527
528 /**
529 * Set the trace parser. Must be done at initialization time.
530 *
531 * @param parser the new trace parser
532 */
533 protected void setParser(final ITmfEventParser parser) {
534 fParser = parser;
535 }
536
537 // ------------------------------------------------------------------------
538 // ITmfTrace - SeekEvent operations (returning a trace context)
539 // ------------------------------------------------------------------------
540
541 @Override
542 public synchronized ITmfContext seekEvent(final long rank) {
543
544 // A rank <= 0 indicates to seek the first event
545 if (rank <= 0) {
546 ITmfContext context = seekEvent((ITmfLocation) null);
547 context.setRank(0);
548 return context;
549 }
550
551 // Position the trace at the checkpoint
552 final ITmfContext context = fIndexer.seekIndex(rank);
553
554 // And locate the requested event context
555 long pos = context.getRank();
556 if (pos < rank) {
557 ITmfEvent event = getNext(context);
558 while ((event != null) && (++pos < rank)) {
559 event = getNext(context);
560 }
561 }
562 return context;
563 }
564
565 /**
566 * @since 2.0
567 */
568 @Override
569 public synchronized ITmfContext seekEvent(final ITmfTimestamp timestamp) {
570
571 // A null timestamp indicates to seek the first event
572 if (timestamp == null) {
573 ITmfContext context = seekEvent((ITmfLocation) null);
574 context.setRank(0);
575 return context;
576 }
577
578 // Position the trace at the checkpoint
579 ITmfContext context = fIndexer.seekIndex(timestamp);
580
581 // And locate the requested event context
582 ITmfLocation previousLocation = context.getLocation();
583 long previousRank = context.getRank();
584 ITmfEvent event = getNext(context);
585 while (event != null && event.getTimestamp().compareTo(timestamp) < 0) {
586 previousLocation = context.getLocation();
587 previousRank = context.getRank();
588 event = getNext(context);
589 }
590 if (event == null) {
591 context.setLocation(null);
592 context.setRank(ITmfContext.UNKNOWN_RANK);
593 } else {
594 context.dispose();
595 context = seekEvent(previousLocation);
596 context.setRank(previousRank);
597 }
598 return context;
599 }
600
601 // ------------------------------------------------------------------------
602 // ITmfTrace - Read operations (returning an actual event)
603 // ------------------------------------------------------------------------
604
605 @Override
606 public synchronized ITmfEvent getNext(final ITmfContext context) {
607 // parseEvent() does not update the context
608 final ITmfEvent event = fParser.parseEvent(context);
609 if (event != null) {
610 updateAttributes(context, event.getTimestamp());
611 context.setLocation(getCurrentLocation());
612 context.increaseRank();
613 processEvent(event);
614 }
615 return event;
616 }
617
618 /**
619 * Hook for special event processing by the concrete class
620 * (called by TmfTrace.getEvent())
621 *
622 * @param event the event
623 */
624 protected void processEvent(final ITmfEvent event) {
625 // Do nothing
626 }
627
628 /**
629 * Update the trace attributes
630 *
631 * @param context the current trace context
632 * @param timestamp the corresponding timestamp
633 * @since 2.0
634 */
635 protected synchronized void updateAttributes(final ITmfContext context, final ITmfTimestamp timestamp) {
636 if (fStartTime.equals(TmfTimestamp.BIG_BANG) || (fStartTime.compareTo(timestamp) > 0)) {
637 fStartTime = timestamp;
638 }
639 if (fEndTime.equals(TmfTimestamp.BIG_CRUNCH) || (fEndTime.compareTo(timestamp) < 0)) {
640 fEndTime = timestamp;
641 }
642 if (context.hasValidRank()) {
643 long rank = context.getRank();
644 if (fNbEvents <= rank) {
645 fNbEvents = rank + 1;
646 }
647 if (fIndexer != null) {
648 fIndexer.updateIndex(context, timestamp);
649 }
650 }
651 }
652
653 // ------------------------------------------------------------------------
654 // TmfDataProvider
655 // ------------------------------------------------------------------------
656
657 /**
658 * @since 2.0
659 */
660 @Override
661 public synchronized ITmfContext armRequest(final ITmfEventRequest request) {
662 if (executorIsShutdown()) {
663 return null;
664 }
665 if (!TmfTimestamp.BIG_BANG.equals(request.getRange().getStartTime())
666 && (request.getIndex() == 0)) {
667 final ITmfContext context = seekEvent(request.getRange().getStartTime());
668 request.setStartIndex((int) context.getRank());
669 return context;
670
671 }
672 return seekEvent(request.getIndex());
673 }
674
675 // ------------------------------------------------------------------------
676 // Signal handlers
677 // ------------------------------------------------------------------------
678
679 /**
680 * Handler for the Trace Opened signal
681 *
682 * @param signal
683 * The incoming signal
684 * @since 2.0
685 */
686 @TmfSignalHandler
687 public void traceOpened(TmfTraceOpenedSignal signal) {
688 boolean signalIsForUs = false;
689 for (ITmfTrace trace : TmfTraceManager.getTraceSet(signal.getTrace())) {
690 if (trace == this) {
691 signalIsForUs = true;
692 break;
693 }
694 }
695
696 if (!signalIsForUs) {
697 return;
698 }
699
700 /*
701 * The signal is either for this trace, or for an experiment containing
702 * this trace.
703 */
704 IStatus status = executeAnalysis();
705 if (!status.isOK()) {
706 Activator.log(status);
707 }
708
709 TmfTraceManager.refreshSupplementaryFiles(this);
710
711 if (signal.getTrace() == this) {
712 /* Additionally, the signal is directly for this trace. */
713 if (getNbEvents() == 0) {
714 return;
715 }
716
717 /* For a streaming trace, the range updated signal should be sent
718 * by the subclass when a new safe time is determined.
719 */
720 if (getStreamingInterval() > 0) {
721 return;
722 }
723
724 if (isComplete()) {
725 final TmfTimeRange timeRange = new TmfTimeRange(getStartTime(), TmfTimestamp.BIG_CRUNCH);
726 final TmfTraceRangeUpdatedSignal rangeUpdatedsignal = new TmfTraceRangeUpdatedSignal(this, this, timeRange);
727
728 // Broadcast in separate thread to prevent deadlock
729 broadcastAsync(rangeUpdatedsignal);
730 }
731 return;
732 }
733 }
734
735 /**
736 * Signal handler for the TmfTraceRangeUpdatedSignal signal
737 *
738 * @param signal The incoming signal
739 * @since 2.0
740 */
741 @TmfSignalHandler
742 public void traceRangeUpdated(final TmfTraceRangeUpdatedSignal signal) {
743 if (signal.getTrace() == this) {
744 getIndexer().buildIndex(getNbEvents(), signal.getRange(), false);
745 }
746 }
747
748 /**
749 * Signal handler for the TmfTraceUpdatedSignal signal
750 *
751 * @param signal The incoming signal
752 * @since 3.0
753 */
754 @TmfSignalHandler
755 public void traceUpdated(final TmfTraceUpdatedSignal signal) {
756 if (signal.getSource() == getIndexer()) {
757 fNbEvents = signal.getNbEvents();
758 fStartTime = signal.getRange().getStartTime();
759 fEndTime = signal.getRange().getEndTime();
760 }
761 }
762
763 // ------------------------------------------------------------------------
764 // Timestamp transformation functions
765 // ------------------------------------------------------------------------
766
767 /**
768 * @since 3.0
769 */
770 @Override
771 public ITmfTimestampTransform getTimestampTransform() {
772 if (fTsTransform == null) {
773 fTsTransform = TimestampTransformFactory.getTimestampTransform(getResource());
774 }
775 return fTsTransform;
776 }
777
778 /**
779 * @since 3.0
780 */
781 @Override
782 public void setTimestampTransform(final ITmfTimestampTransform tt) {
783 fTsTransform = tt;
784 TimestampTransformFactory.setTimestampTransform(getResource(), tt);
785 }
786
787 /**
788 * @since 3.0
789 */
790 @Override
791 public ITmfTimestamp createTimestamp(long ts) {
792 return new TmfNanoTimestamp(getTimestampTransform().transform(ts));
793 }
794
795 // ------------------------------------------------------------------------
796 // toString
797 // ------------------------------------------------------------------------
798
799 @Override
800 @SuppressWarnings("nls")
801 public synchronized String toString() {
802 return "TmfTrace [fPath=" + fPath + ", fCacheSize=" + fCacheSize
803 + ", fNbEvents=" + fNbEvents + ", fStartTime=" + fStartTime
804 + ", fEndTime=" + fEndTime + ", fStreamingInterval=" + fStreamingInterval + "]";
805 }
806
807 /**
808 * @since 3.1
809 */
810 @Override
811 public boolean isComplete() {
812 /*
813 * Be default, all traces are "complete" which means no more data will
814 * be added later
815 */
816 return true;
817 }
818
819 /**
820 * @since 3.1
821 */
822 @Override
823 public void setComplete(boolean isComplete) {
824 /*
825 * This should be overridden by trace classes that can support live
826 * reading (traces in an incomplete state)
827 */
828 }
829 }
This page took 0.105878 seconds and 4 git commands to generate.