df0f01c1d9115a22ae38b06d7a77d44f938dc5b0
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / trace / TmfTrace.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 Ericsson
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 *******************************************************************************/
14
15 package org.eclipse.linuxtools.tmf.core.trace;
16
17 import java.io.File;
18 import java.util.Collections;
19 import java.util.LinkedHashMap;
20 import java.util.Map;
21
22 import org.eclipse.core.resources.IResource;
23 import org.eclipse.core.runtime.CoreException;
24 import org.eclipse.core.runtime.IPath;
25 import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
26 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
27 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
28 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
29 import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
30 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
31 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
32 import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
33 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
34 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceRangeUpdatedSignal;
35 import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
36 import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
37 import org.eclipse.linuxtools.tmf.core.statistics.TmfStateStatistics;
38 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
39 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
40 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
41
42 /**
43 * Abstract implementation of ITmfTrace.
44 * <p>
45 * Since the concept of 'location' is trace specific, the concrete classes have
46 * to provide the related methods, namely:
47 * <ul>
48 * <li> public ITmfLocation<?> getCurrentLocation()
49 * <li> public double getLocationRatio(ITmfLocation<?> location)
50 * <li> public ITmfContext seekEvent(ITmfLocation<?> location)
51 * <li> public ITmfContext seekEvent(double ratio)
52 * <li> public boolean validate(IProject project, String path)
53 * </ul>
54 * A concrete trace must provide its corresponding parser. A common way to
55 * accomplish this is by making the concrete class extend TmfTrace and
56 * implement ITmfEventParser.
57 * <p>
58 * The concrete class can either specify its own indexer or use the provided
59 * TmfCheckpointIndexer (default). In this case, the trace cache size will be
60 * used as checkpoint interval.
61 *
62 * @version 1.0
63 * @author Francois Chouinard
64 *
65 * @see ITmfEvent
66 * @see ITmfTraceIndexer
67 * @see ITmfEventParser
68 */
69 public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
70
71 // ------------------------------------------------------------------------
72 // Attributes
73 // ------------------------------------------------------------------------
74
75 // The resource used for persistent properties for this trace
76 private IResource fResource;
77
78 // The trace path
79 private String fPath;
80
81 // The trace cache page size
82 private int fCacheSize = ITmfTrace.DEFAULT_TRACE_CACHE_SIZE;
83
84 // The number of events collected (so far)
85 private long fNbEvents = 0;
86
87 // The time span of the event stream
88 private ITmfTimestamp fStartTime = TmfTimestamp.BIG_BANG;
89 private ITmfTimestamp fEndTime = TmfTimestamp.BIG_BANG;
90
91 // The trace streaming interval (0 = no streaming)
92 private long fStreamingInterval = 0;
93
94 // The trace indexer
95 private ITmfTraceIndexer fIndexer;
96
97 // The trace parser
98 private ITmfEventParser fParser;
99
100 // The trace's statistics
101 private ITmfStatistics fStatistics;
102
103 // The current selected time
104 private ITmfTimestamp fCurrentTime = TmfTimestamp.ZERO;
105
106 // The current selected range
107 private TmfTimeRange fCurrentRange = TmfTimeRange.NULL_RANGE;
108
109 /**
110 * The collection of state systems that are registered with this trace. Each
111 * sub-class can decide to add its (one or many) state system to this map
112 * during their {@link #buildStateSystem()}.
113 *
114 * @since 2.0
115 */
116 protected final Map<String, ITmfStateSystem> fStateSystems =
117 new LinkedHashMap<String, ITmfStateSystem>();
118
119 // ------------------------------------------------------------------------
120 // Construction
121 // ------------------------------------------------------------------------
122
123 /**
124 * The default, parameterless, constructor
125 */
126 public TmfTrace() {
127 super();
128 }
129
130 /**
131 * Full constructor.
132 *
133 * @param resource
134 * The resource associated to the trace
135 * @param type
136 * The type of events that will be read from this trace
137 * @param path
138 * The path to the trace on the filesystem
139 * @param cacheSize
140 * The trace cache size. Pass '-1' to use the default specified
141 * in {@link ITmfTrace#DEFAULT_TRACE_CACHE_SIZE}
142 * @param interval
143 * The trace streaming interval. You can use '0' for post-mortem
144 * traces.
145 * @param indexer
146 * The trace indexer. You can pass 'null' to use a default
147 * checkpoint indexer.
148 * @param parser
149 * The trace event parser. Use 'null' if (and only if) the trace
150 * object itself is also the ITmfEventParser to be used.
151 * @throws TmfTraceException
152 * If something failed during the opening
153 */
154 protected TmfTrace(final IResource resource,
155 final Class<? extends ITmfEvent> type,
156 final String path,
157 final int cacheSize,
158 final long interval,
159 final ITmfTraceIndexer indexer,
160 final ITmfEventParser parser)
161 throws TmfTraceException {
162 super();
163 fCacheSize = (cacheSize > 0) ? cacheSize : ITmfTrace.DEFAULT_TRACE_CACHE_SIZE;
164 fStreamingInterval = interval;
165 fIndexer = (indexer != null) ? indexer : new TmfCheckpointIndexer(this, fCacheSize);
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 fIndexer = new TmfCheckpointIndexer(this);
184 fParser = trace.fParser;
185 initialize(trace.getResource(), trace.getPath(), trace.getEventType());
186 }
187
188 // ------------------------------------------------------------------------
189 // ITmfTrace - Initializers
190 // ------------------------------------------------------------------------
191
192 /* (non-Javadoc)
193 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class)
194 */
195 @Override
196 public void initTrace(final IResource resource, final String path, final Class<? extends ITmfEvent> type) throws TmfTraceException {
197 fIndexer = new TmfCheckpointIndexer(this, fCacheSize);
198 initialize(resource, path, type);
199 }
200
201 /**
202 * Initialize the trace common attributes and the base component.
203 *
204 * @param resource the Eclipse resource (trace)
205 * @param path the trace path
206 * @param type the trace event type
207 *
208 * @throws TmfTraceException If something failed during the initialization
209 */
210 protected void initialize(final IResource resource, final String path, final Class<? extends ITmfEvent> type) throws TmfTraceException {
211 if (path == null) {
212 throw new TmfTraceException("Invalid trace path"); //$NON-NLS-1$
213 }
214 fPath = path;
215 fResource = resource;
216 String traceName = (resource != null) ? resource.getName() : null;
217 // If no resource was provided, extract the display name the trace path
218 if (traceName == null) {
219 final int sep = path.lastIndexOf(IPath.SEPARATOR);
220 traceName = (sep >= 0) ? path.substring(sep + 1) : path;
221 }
222 if (fParser == null) {
223 if (this instanceof ITmfEventParser) {
224 fParser = (ITmfEventParser) this;
225 } else {
226 throw new TmfTraceException("Invalid trace parser"); //$NON-NLS-1$
227 }
228 }
229 super.init(traceName, type);
230 }
231
232 /**
233 * Indicates if the path points to an existing file/directory
234 *
235 * @param path the path to test
236 * @return true if the file/directory exists
237 */
238 protected boolean fileExists(final String path) {
239 final File file = new File(path);
240 return file.exists();
241 }
242
243 /**
244 * Index the trace
245 *
246 * @param waitForCompletion index synchronously (true) or not (false)
247 */
248 protected void indexTrace(boolean waitForCompletion) {
249 getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, waitForCompletion);
250 }
251
252 /**
253 * The default implementation of TmfTrace uses a TmfStatistics back-end.
254 * Override this if you want to specify another type (or none at all).
255 *
256 * @throws TmfTraceException
257 * If there was a problem setting up the statistics
258 * @since 2.0
259 */
260 protected void buildStatistics() throws TmfTraceException {
261 /*
262 * Initialize the statistics provider, but only if a Resource has been
263 * set (so we don't build it for experiments, for unit tests, etc.)
264 */
265 fStatistics = (fResource == null ? null : new TmfStateStatistics(this) );
266 }
267
268 /**
269 * Build the state system(s) associated with this trace type.
270 *
271 * Suppressing the warning, because the 'throws' will usually happen in
272 * sub-classes.
273 *
274 * @throws TmfTraceException
275 * If there is a problem during the build
276 * @since 2.0
277 */
278 @SuppressWarnings("unused")
279 protected void buildStateSystem() throws TmfTraceException {
280 /*
281 * Nothing is done in the base implementation, please specify
282 * how/if to register a new state system in derived classes.
283 */
284 return;
285 }
286
287 /**
288 * Clears the trace
289 */
290 @Override
291 public synchronized void dispose() {
292 /* Clean up the index if applicable */
293 if (getIndexer() != null) {
294 getIndexer().dispose();
295 }
296
297 /* Clean up the statistics */
298 if (fStatistics != null) {
299 fStatistics.dispose();
300 }
301
302 /* Clean up the state systems */
303 for (ITmfStateSystem ss : fStateSystems.values()) {
304 ss.dispose();
305 }
306
307 super.dispose();
308 }
309
310 // ------------------------------------------------------------------------
311 // ITmfTrace - Basic getters
312 // ------------------------------------------------------------------------
313
314 /**
315 * @since 2.0
316 */
317 @Override
318 public ITmfTrace[] getTraces() {
319 return new ITmfTrace[] { this };
320 }
321
322 /* (non-Javadoc)
323 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getEventType()
324 */
325 @Override
326 public Class<ITmfEvent> getEventType() {
327 return (Class<ITmfEvent>) super.getType();
328 }
329
330 /* (non-Javadoc)
331 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getResource()
332 */
333 @Override
334 public IResource getResource() {
335 return fResource;
336 }
337
338 /* (non-Javadoc)
339 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getPath()
340 */
341 @Override
342 public String getPath() {
343 return fPath;
344 }
345
346 /* (non-Javadoc)
347 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getIndexPageSize()
348 */
349 @Override
350 public int getCacheSize() {
351 return fCacheSize;
352 }
353
354 /* (non-Javadoc)
355 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getStreamingInterval()
356 */
357 @Override
358 public long getStreamingInterval() {
359 return fStreamingInterval;
360 }
361
362 /**
363 * @return the trace indexer
364 */
365 protected ITmfTraceIndexer getIndexer() {
366 return fIndexer;
367 }
368
369 /**
370 * @return the trace parser
371 */
372 protected ITmfEventParser getParser() {
373 return fParser;
374 }
375
376 /**
377 * @since 2.0
378 */
379 @Override
380 public ITmfStatistics getStatistics() {
381 return fStatistics;
382 }
383
384 /**
385 * @since 2.0
386 */
387 @Override
388 public final Map<String, ITmfStateSystem> getStateSystems() {
389 return Collections.unmodifiableMap(fStateSystems);
390 }
391
392 /**
393 * @since 2.0
394 */
395 @Override
396 public final void registerStateSystem(String id, ITmfStateSystem ss) {
397 fStateSystems.put(id, ss);
398 }
399
400 // ------------------------------------------------------------------------
401 // ITmfTrace - Trace characteristics getters
402 // ------------------------------------------------------------------------
403
404 @Override
405 public synchronized long getNbEvents() {
406 return fNbEvents;
407 }
408
409 /**
410 * @since 2.0
411 */
412 @Override
413 public TmfTimeRange getTimeRange() {
414 return new TmfTimeRange(fStartTime, fEndTime);
415 }
416
417 /**
418 * @since 2.0
419 */
420 @Override
421 public ITmfTimestamp getStartTime() {
422 return fStartTime;
423 }
424
425 /**
426 * @since 2.0
427 */
428 @Override
429 public ITmfTimestamp getEndTime() {
430 return fEndTime;
431 }
432
433 /**
434 * @since 2.0
435 */
436 @Override
437 public ITmfTimestamp getCurrentTime() {
438 return fCurrentTime;
439 }
440
441 /**
442 * @since 2.0
443 */
444 @Override
445 public TmfTimeRange getCurrentRange() {
446 return fCurrentRange;
447 }
448
449 /**
450 * @since 2.0
451 */
452 @Override
453 public ITmfTimestamp getInitialRangeOffset() {
454 final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
455 return new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
456 }
457
458 // ------------------------------------------------------------------------
459 // Convenience setters
460 // ------------------------------------------------------------------------
461
462 /**
463 * Set the trace cache size. Must be done at initialization time.
464 *
465 * @param cacheSize The trace cache size
466 */
467 protected void setCacheSize(final int cacheSize) {
468 fCacheSize = cacheSize;
469 }
470
471 /**
472 * Set the trace known number of events. This can be quite dynamic
473 * during indexing or for live traces.
474 *
475 * @param nbEvents The number of events
476 */
477 protected synchronized void setNbEvents(final long nbEvents) {
478 fNbEvents = (nbEvents > 0) ? nbEvents : 0;
479 }
480
481 /**
482 * Update the trace events time range
483 *
484 * @param range the new time range
485 * @since 2.0
486 */
487 protected void setTimeRange(final TmfTimeRange range) {
488 fStartTime = range.getStartTime();
489 fEndTime = range.getEndTime();
490 }
491
492 /**
493 * Update the trace chronologically first event timestamp
494 *
495 * @param startTime the new first event timestamp
496 * @since 2.0
497 */
498 protected void setStartTime(final ITmfTimestamp startTime) {
499 fStartTime = startTime;
500 }
501
502 /**
503 * Update the trace chronologically last event timestamp
504 *
505 * @param endTime the new last event timestamp
506 * @since 2.0
507 */
508 protected void setEndTime(final ITmfTimestamp endTime) {
509 fEndTime = endTime;
510 }
511
512 /**
513 * Set the polling interval for live traces (default = 0 = no streaming).
514 *
515 * @param interval the new trace streaming interval
516 */
517 protected void setStreamingInterval(final long interval) {
518 fStreamingInterval = (interval > 0) ? interval : 0;
519 }
520
521 /**
522 * Set the trace indexer. Must be done at initialization time.
523 *
524 * @param indexer the trace indexer
525 */
526 protected void setIndexer(final ITmfTraceIndexer indexer) {
527 fIndexer = indexer;
528 }
529
530 /**
531 * Set the trace parser. Must be done at initialization time.
532 *
533 * @param parser the new trace parser
534 */
535 protected void setParser(final ITmfEventParser parser) {
536 fParser = parser;
537 }
538
539 // ------------------------------------------------------------------------
540 // ITmfTrace - SeekEvent operations (returning a trace context)
541 // ------------------------------------------------------------------------
542
543 @Override
544 public synchronized ITmfContext seekEvent(final long rank) {
545
546 // A rank <= 0 indicates to seek the first event
547 if (rank <= 0) {
548 ITmfContext context = seekEvent((ITmfLocation) null);
549 context.setRank(0);
550 return context;
551 }
552
553 // Position the trace at the checkpoint
554 final ITmfContext context = fIndexer.seekIndex(rank);
555
556 // And locate the requested event context
557 long pos = context.getRank();
558 if (pos < rank) {
559 ITmfEvent event = getNext(context);
560 while ((event != null) && (++pos < rank)) {
561 event = getNext(context);
562 }
563 }
564 return context;
565 }
566
567 /**
568 * @since 2.0
569 */
570 @Override
571 public synchronized ITmfContext seekEvent(final ITmfTimestamp timestamp) {
572
573 // A null timestamp indicates to seek the first event
574 if (timestamp == null) {
575 ITmfContext context = seekEvent((ITmfLocation) null);
576 context.setRank(0);
577 return context;
578 }
579
580 // Position the trace at the checkpoint
581 ITmfContext context = fIndexer.seekIndex(timestamp);
582
583 // And locate the requested event context
584 ITmfLocation previousLocation = context.getLocation();
585 long previousRank = context.getRank();
586 ITmfEvent event = getNext(context);
587 while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) {
588 previousLocation = context.getLocation();
589 previousRank = context.getRank();
590 event = getNext(context);
591 }
592 if (event == null) {
593 context.setLocation(null);
594 context.setRank(ITmfContext.UNKNOWN_RANK);
595 } else {
596 context.dispose();
597 context = seekEvent(previousLocation);
598 context.setRank(previousRank);
599 }
600 return context;
601 }
602
603 // ------------------------------------------------------------------------
604 // ITmfTrace - Read operations (returning an actual event)
605 // ------------------------------------------------------------------------
606
607 @Override
608 public synchronized ITmfEvent getNext(final ITmfContext context) {
609 // parseEvent() does not update the context
610 final ITmfEvent event = fParser.parseEvent(context);
611 if (event != null) {
612 updateAttributes(context, event.getTimestamp());
613 context.setLocation(getCurrentLocation());
614 context.increaseRank();
615 processEvent(event);
616 }
617 return event;
618 }
619
620 /**
621 * Hook for special event processing by the concrete class
622 * (called by TmfTrace.getEvent())
623 *
624 * @param event the event
625 */
626 protected void processEvent(final ITmfEvent event) {
627 // Do nothing
628 }
629
630 /**
631 * Update the trace attributes
632 *
633 * @param context the current trace context
634 * @param timestamp the corresponding timestamp
635 * @since 2.0
636 */
637 protected synchronized void updateAttributes(final ITmfContext context, final ITmfTimestamp timestamp) {
638 if (fStartTime.equals(TmfTimestamp.BIG_BANG) || (fStartTime.compareTo(timestamp, false) > 0)) {
639 fStartTime = timestamp;
640 }
641 if (fEndTime.equals(TmfTimestamp.BIG_CRUNCH) || (fEndTime.compareTo(timestamp, false) < 0)) {
642 fEndTime = timestamp;
643 }
644 if (fCurrentRange == TmfTimeRange.NULL_RANGE) {
645 fCurrentTime = timestamp;
646 ITmfTimestamp initialOffset = getInitialRangeOffset();
647 long endValue = timestamp.getValue() + initialOffset.normalize(0, timestamp.getScale()).getValue();
648 ITmfTimestamp endTimestamp = new TmfTimestamp(endValue, timestamp.getScale());
649 fCurrentRange = new TmfTimeRange(timestamp, endTimestamp);
650 }
651 if (context.hasValidRank()) {
652 long rank = context.getRank();
653 if (fNbEvents <= rank) {
654 fNbEvents = rank + 1;
655 }
656 if (fIndexer != null) {
657 fIndexer.updateIndex(context, timestamp);
658 }
659 }
660 }
661
662 // ------------------------------------------------------------------------
663 // TmfDataProvider
664 // ------------------------------------------------------------------------
665
666 /**
667 * @since 2.0
668 */
669 @Override
670 public synchronized ITmfContext armRequest(final ITmfDataRequest request) {
671 if (executorIsShutdown()) {
672 return null;
673 }
674 if ((request instanceof ITmfEventRequest)
675 && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest) request).getRange().getStartTime())
676 && (request.getIndex() == 0))
677 {
678 final ITmfContext context = seekEvent(((ITmfEventRequest) request).getRange().getStartTime());
679 ((ITmfEventRequest) request).setStartIndex((int) context.getRank());
680 return context;
681
682 }
683 return seekEvent(request.getIndex());
684 }
685
686 // ------------------------------------------------------------------------
687 // Signal handlers
688 // ------------------------------------------------------------------------
689
690 /**
691 * Handler for the Trace Opened signal
692 *
693 * @param signal
694 * The incoming signal
695 * @since 2.0
696 */
697 @TmfSignalHandler
698 public void traceOpened(TmfTraceOpenedSignal signal) {
699 ITmfTrace trace = null;
700 for (ITmfTrace expTrace : signal.getTrace().getTraces()) {
701 if (expTrace == this) {
702 trace = expTrace;
703 break;
704 }
705 }
706
707 if (trace == null) {
708 /* This signal is not for us */
709 return;
710 }
711
712 /*
713 * The signal is for this trace, or for an experiment containing
714 * this trace.
715 */
716 try {
717 buildStatistics();
718 buildStateSystem();
719 } catch (TmfTraceException e) {
720 e.printStackTrace();
721 }
722
723 /* Refresh the project, so it can pick up new files that got created. */
724 try {
725 if (fResource != null) {
726 fResource.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
727 }
728 } catch (CoreException e) {
729 e.printStackTrace();
730 }
731
732 if (signal.getTrace() == this) {
733 /* Additionally, the signal is directly for this trace or experiment. */
734 if (getNbEvents() == 0) {
735 return;
736 }
737
738 final TmfTimeRange timeRange = new TmfTimeRange(getStartTime(), TmfTimestamp.BIG_CRUNCH);
739 final TmfTraceRangeUpdatedSignal rangeUpdatedsignal = new TmfTraceRangeUpdatedSignal(this, this, timeRange);
740
741 // Broadcast in separate thread to prevent deadlock
742 new Thread() {
743 @Override
744 public void run() {
745 broadcast(rangeUpdatedsignal);
746 }
747 }.start();
748 return;
749 }
750 }
751
752 /**
753 * Signal handler for the TmfTraceRangeUpdatedSignal signal
754 *
755 * @param signal The incoming signal
756 * @since 2.0
757 */
758 @TmfSignalHandler
759 public void traceRangeUpdated(final TmfTraceRangeUpdatedSignal signal) {
760 if (signal.getTrace() == this) {
761 getIndexer().buildIndex(getNbEvents(), signal.getRange(), false);
762 }
763 }
764
765 /**
766 * Signal handler for the TmfTimeSynchSignal signal
767 *
768 * @param signal The incoming signal
769 * @since 2.0
770 */
771 @TmfSignalHandler
772 public void synchToTime(final TmfTimeSynchSignal signal) {
773 if (signal.getCurrentTime().compareTo(fStartTime) >= 0 && signal.getCurrentTime().compareTo(fEndTime) <= 0) {
774 fCurrentTime = signal.getCurrentTime();
775 }
776 }
777
778 /**
779 * Signal handler for the TmfRangeSynchSignal signal
780 *
781 * @param signal The incoming signal
782 * @since 2.0
783 */
784 @TmfSignalHandler
785 public void synchToRange(final TmfRangeSynchSignal signal) {
786 if (signal.getCurrentTime().compareTo(fStartTime) >= 0 && signal.getCurrentTime().compareTo(fEndTime) <= 0) {
787 fCurrentTime = signal.getCurrentTime();
788 }
789 if (signal.getCurrentRange().getIntersection(getTimeRange()) != null) {
790 fCurrentRange = signal.getCurrentRange().getIntersection(getTimeRange());
791 }
792 }
793
794 // ------------------------------------------------------------------------
795 // toString
796 // ------------------------------------------------------------------------
797
798 @Override
799 @SuppressWarnings("nls")
800 public synchronized String toString() {
801 return "TmfTrace [fPath=" + fPath + ", fCacheSize=" + fCacheSize
802 + ", fNbEvents=" + fNbEvents + ", fStartTime=" + fStartTime
803 + ", fEndTime=" + fEndTime + ", fStreamingInterval=" + fStreamingInterval + "]";
804 }
805
806 }
This page took 0.048406 seconds and 5 git commands to generate.