tmf/lttng: Fix newly-introduced Javadoc warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / trace / TmfTrace.java
CommitLineData
8c8bf09f 1/*******************************************************************************
09e86496 2 * Copyright (c) 2009, 2010, 2012 Ericsson
0bfb7d06 3 *
8c8bf09f
ASL
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
0bfb7d06 8 *
8c8bf09f 9 * Contributors:
20658947
FC
10 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Trace Model 1.0
8c8bf09f
ASL
12 *******************************************************************************/
13
6c13869b 14package org.eclipse.linuxtools.tmf.core.trace;
8c8bf09f 15
6f4a1d2b 16import java.io.File;
8c8bf09f 17
828e5592 18import org.eclipse.core.resources.IResource;
9b749023 19import org.eclipse.core.runtime.IPath;
6c13869b 20import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
72f1e62a 21import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
4df4581d 22import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
6c13869b
FC
23import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
24import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
b4f71e4a 25import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
6c13869b
FC
26import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
27import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
7898bb21 28import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
200789b3 29import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
1c0de632 30import org.eclipse.linuxtools.tmf.core.statistics.TmfStateStatistics;
8c8bf09f
ASL
31
32/**
09e86496
FC
33 * Abstract implementation of ITmfTrace.
34 * <p>
13cb5f43
FC
35 * Since the concept of 'location' is trace specific, the concrete classes have
36 * to provide the related methods, namely:
37 * <ul>
38 * <li> public ITmfLocation<?> getCurrentLocation()
39 * <li> public double getLocationRatio(ITmfLocation<?> location)
40 * <li> public ITmfContext seekEvent(ITmfLocation<?> location)
41 * <li> public ITmfContext seekEvent(double ratio)
2848c377 42 * <li> public boolean validate(IProject project, String path)
13cb5f43
FC
43 * </ul>
44 * A concrete trace must provide its corresponding parser. A common way to
45 * accomplish this is by making the concrete class extend TmfTrace and
46 * implement ITmfEventParser.
47 * <p>
48 * The concrete class can either specify its own indexer or use the provided
49 * TmfCheckpointIndexer (default). In this case, the trace cache size will be
50 * used as checkpoint interval.
0bfb7d06 51 *
f7703ed6
FC
52 * @version 1.0
53 * @author Francois Chouinard
54 *
f7703ed6
FC
55 * @see ITmfEvent
56 * @see ITmfTraceIndexer
57 * @see ITmfEventParser
8c8bf09f 58 */
6256d8ad 59public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
62d1696a 60
e31e01e8 61 // ------------------------------------------------------------------------
8c8bf09f 62 // Attributes
e31e01e8 63 // ------------------------------------------------------------------------
8c8bf09f 64
09e86496
FC
65 // The resource used for persistent properties for this trace
66 private IResource fResource;
67
b0a282fb 68 // The trace path
12c155f5 69 private String fPath;
b0a282fb 70
0316808c
FC
71 // The trace cache page size
72 private int fCacheSize = ITmfTrace.DEFAULT_TRACE_CACHE_SIZE;
62d1696a 73
0316808c
FC
74 // The number of events collected (so far)
75 private long fNbEvents = 0;
62d1696a
FC
76
77 // The time span of the event stream
a4115405
FC
78 private ITmfTimestamp fStartTime = TmfTimestamp.BIG_CRUNCH;
79 private ITmfTimestamp fEndTime = TmfTimestamp.BIG_BANG;
62d1696a 80
0316808c
FC
81 // The trace streaming interval (0 = no streaming)
82 private long fStreamingInterval = 0;
085d898f 83
0316808c 84 // The trace indexer
6256d8ad 85 private ITmfTraceIndexer fIndexer;
20658947 86
0316808c 87 // The trace parser
6256d8ad 88 private ITmfEventParser fParser;
7e6347b0 89
200789b3
AM
90 // The trace's statistics
91 private ITmfStatistics fStatistics;
92
e31e01e8 93 // ------------------------------------------------------------------------
3791b5df 94 // Construction
e31e01e8 95 // ------------------------------------------------------------------------
8c8bf09f 96
62d1696a 97 /**
3791b5df 98 * The default, parameterless, constructor
62d1696a 99 */
3791b5df
FC
100 public TmfTrace() {
101 super();
05bd3318
FC
102 }
103
104 /**
13cb5f43 105 * The standard constructor (non-live trace). Applicable when the trace
0bfb7d06
MK
106 * implements its own parser and if at checkpoint-based index is OK.
107 *
20658947
FC
108 * @param resource the resource associated to the trace
109 * @param type the trace event type
110 * @param path the trace path
111 * @param cacheSize the trace cache size
6f4e8ec0 112 * @throws TmfTraceException If something failed during the opening
20658947 113 */
6256d8ad 114 protected TmfTrace(final IResource resource, final Class<? extends ITmfEvent> type, final String path, final int cacheSize) throws TmfTraceException {
9e0640dc 115 this(resource, type, path, cacheSize, 0);
20658947
FC
116 }
117
118 /**
13cb5f43
FC
119 * The standard constructor (live trace). Applicable when the trace
120 * implements its own parser and if at checkpoint-based index is OK.
0bfb7d06 121 *
20658947 122 * @param resource the resource associated to the trace
3791b5df
FC
123 * @param type the trace event type
124 * @param path the trace path
20658947
FC
125 * @param cacheSize the trace cache size
126 * @param interval the trace streaming interval
6f4e8ec0 127 * @throws TmfTraceException If something failed during the opening
05bd3318 128 */
6256d8ad 129 protected TmfTrace(final IResource resource, final Class<? extends ITmfEvent> type, final String path, final int cacheSize, final long interval) throws TmfTraceException {
20658947 130 this(resource, type, path, cacheSize, interval, null);
05bd3318
FC
131 }
132
133 /**
13cb5f43
FC
134 * The 'non-default indexer' constructor. Allows to provide a trace
135 * specific indexer.
0bfb7d06 136 *
20658947 137 * @param resource the resource associated to the trace
3791b5df
FC
138 * @param type the trace event type
139 * @param path the trace path
20658947 140 * @param cacheSize the trace cache size
6f4e8ec0 141 * @param interval the trace streaming interval
20658947 142 * @param indexer the trace indexer
6f4e8ec0 143 * @throws TmfTraceException If something failed during the opening
05bd3318 144 */
6256d8ad
AM
145 protected TmfTrace(final IResource resource, final Class<? extends ITmfEvent> type, final String path, final int cacheSize,
146 final long interval, final ITmfTraceIndexer indexer) throws TmfTraceException {
0316808c 147 this(resource, type, path, cacheSize, interval, indexer, null);
13cb5f43
FC
148 }
149
150 /**
0bfb7d06
MK
151 * The full constructor where trace specific indexer/parser are provided.
152 *
13cb5f43
FC
153 * @param resource the resource associated to the trace
154 * @param type the trace event type
155 * @param path the trace path
156 * @param cacheSize the trace cache size
6f4e8ec0 157 * @param interval the trace streaming interval
13cb5f43
FC
158 * @param indexer the trace indexer
159 * @param parser the trace event parser
6f4e8ec0 160 * @throws TmfTraceException If something failed during the opening
13cb5f43 161 */
6256d8ad
AM
162 protected TmfTrace(final IResource resource, final Class<? extends ITmfEvent> type, final String path, final int cacheSize,
163 final long interval, final ITmfTraceIndexer indexer, final ITmfEventParser parser) throws TmfTraceException {
00641a97 164 super();
0316808c 165 fCacheSize = (cacheSize > 0) ? cacheSize : ITmfTrace.DEFAULT_TRACE_CACHE_SIZE;
3791b5df 166 fStreamingInterval = interval;
7e6347b0 167 fIndexer = (indexer != null) ? indexer : new TmfCheckpointIndexer(this, fCacheSize);
13cb5f43 168 fParser = parser;
09e86496 169 initialize(resource, path, type);
8c8bf09f
ASL
170 }
171
3791b5df
FC
172 /**
173 * Copy constructor
0bfb7d06 174 *
3791b5df 175 * @param trace the original trace
063f0d27 176 * @throws TmfTraceException Should not happen usually
3791b5df 177 */
6256d8ad 178 public TmfTrace(final TmfTrace trace) throws TmfTraceException {
3791b5df 179 super();
0316808c 180 if (trace == null) {
3791b5df 181 throw new IllegalArgumentException();
0316808c 182 }
20658947
FC
183 fCacheSize = trace.getCacheSize();
184 fStreamingInterval = trace.getStreamingInterval();
7e6347b0 185 fIndexer = new TmfCheckpointIndexer(this);
13cb5f43
FC
186 fParser = trace.fParser;
187 initialize(trace.getResource(), trace.getPath(), trace.getEventType());
3791b5df
FC
188 }
189
7e6347b0
FC
190 // ------------------------------------------------------------------------
191 // ITmfTrace - Initializers
192 // ------------------------------------------------------------------------
193
194 /* (non-Javadoc)
195 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class)
196 */
197 @Override
6256d8ad 198 public void initTrace(final IResource resource, final String path, final Class<? extends ITmfEvent> type) throws TmfTraceException {
9dc3dee2 199 fIndexer = new TmfCheckpointIndexer(this, fCacheSize);
7e6347b0 200 initialize(resource, path, type);
7e6347b0
FC
201 }
202
09e86496 203 /**
1703b536 204 * Initialize the trace common attributes and the base component.
0bfb7d06
MK
205 *
206 * @param resource the Eclipse resource (trace)
1703b536
FC
207 * @param path the trace path
208 * @param type the trace event type
0bfb7d06 209 *
6f4e8ec0 210 * @throws TmfTraceException If something failed during the initialization
3791b5df 211 */
6256d8ad 212 protected void initialize(final IResource resource, final String path, final Class<? extends ITmfEvent> type) throws TmfTraceException {
0316808c 213 if (path == null) {
b4f71e4a 214 throw new TmfTraceException("Invalid trace path"); //$NON-NLS-1$
0316808c 215 }
3791b5df 216 fPath = path;
1703b536 217 fResource = resource;
25e48683 218 String traceName = (resource != null) ? resource.getName() : null;
1703b536
FC
219 // If no resource was provided, extract the display name the trace path
220 if (traceName == null) {
9b749023 221 final int sep = path.lastIndexOf(IPath.SEPARATOR);
1703b536
FC
222 traceName = (sep >= 0) ? path.substring(sep + 1) : path;
223 }
2352aed9
FC
224 if (fParser == null) {
225 if (this instanceof ITmfEventParser) {
6256d8ad 226 fParser = (ITmfEventParser) this;
2352aed9
FC
227 } else {
228 throw new TmfTraceException("Invalid trace parser"); //$NON-NLS-1$
229 }
230 }
3791b5df 231 super.init(traceName, type);
200789b3
AM
232
233 buildStatistics();
3791b5df
FC
234 }
235
2352aed9
FC
236 /**
237 * Indicates if the path points to an existing file/directory
0bfb7d06 238 *
2352aed9
FC
239 * @param path the path to test
240 * @return true if the file/directory exists
3791b5df 241 */
2352aed9 242 protected boolean fileExists(final String path) {
085d898f 243 final File file = new File(path);
3791b5df
FC
244 return file.exists();
245 }
246
c7e1020d
FC
247 /**
248 * Index the trace
0bfb7d06 249 *
c7e1020d
FC
250 * @param waitForCompletion index synchronously (true) or not (false)
251 */
252 protected void indexTrace(boolean waitForCompletion) {
9e0640dc 253 getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, waitForCompletion);
c7e1020d
FC
254 }
255
200789b3 256 /**
6f4e8ec0 257 * The default implementation of TmfTrace uses a TmfStatistics back-end.
200789b3
AM
258 * Override this if you want to specify another type (or none at all).
259 *
6f4e8ec0
AM
260 * @throws TmfTraceException
261 * If there was a problem setting up the statistics
200789b3
AM
262 * @since 2.0
263 */
264 protected void buildStatistics() throws TmfTraceException {
265 /*
266 * Initialize the statistics provider, but only if a Resource has been
267 * set (so we don't build it for experiments, for unit tests, etc.)
268 */
1c0de632 269 fStatistics = (fResource == null ? null : new TmfStateStatistics(this) );
200789b3
AM
270 }
271
b5ee6881
FC
272 /**
273 * Clears the trace
274 */
275 @Override
276 public synchronized void dispose() {
1a4205d9 277 /* Clean up the index if applicable */
77551cc2
FC
278 if (getIndexer() != null) {
279 getIndexer().dispose();
280 }
1a4205d9
AM
281
282 /* Clean up the statistics */
283 if (fStatistics != null) {
284 fStatistics.dispose();
285 }
b5ee6881
FC
286 super.dispose();
287 }
288
3791b5df 289 // ------------------------------------------------------------------------
09e86496 290 // ITmfTrace - Basic getters
e31e01e8 291 // ------------------------------------------------------------------------
8c8bf09f 292
09e86496 293 /* (non-Javadoc)
13cb5f43 294 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getEventType()
25e48683
FC
295 */
296 @Override
6256d8ad
AM
297 public Class<ITmfEvent> getEventType() {
298 return (Class<ITmfEvent>) super.getType();
25e48683
FC
299 }
300
09e86496
FC
301 /* (non-Javadoc)
302 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getResource()
62d1696a 303 */
d4011df2 304 @Override
09e86496
FC
305 public IResource getResource() {
306 return fResource;
8c8bf09f
ASL
307 }
308
09e86496
FC
309 /* (non-Javadoc)
310 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getPath()
62d1696a 311 */
d4011df2 312 @Override
09e86496
FC
313 public String getPath() {
314 return fPath;
8c8bf09f
ASL
315 }
316
20658947
FC
317 /* (non-Javadoc)
318 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getIndexPageSize()
319 */
320 @Override
321 public int getCacheSize() {
322 return fCacheSize;
323 }
324
325 /* (non-Javadoc)
326 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getStreamingInterval()
327 */
328 @Override
329 public long getStreamingInterval() {
330 return fStreamingInterval;
331 }
332
0316808c
FC
333 /**
334 * @return the trace indexer
335 */
6256d8ad 336 protected ITmfTraceIndexer getIndexer() {
0316808c
FC
337 return fIndexer;
338 }
339
340 /**
341 * @return the trace parser
342 */
6256d8ad 343 protected ITmfEventParser getParser() {
0316808c
FC
344 return fParser;
345 }
346
200789b3
AM
347 /**
348 * @since 2.0
349 */
350 @Override
351 public ITmfStatistics getStatistics() {
352 return fStatistics;
353 }
354
7898bb21
AM
355 /**
356 * @since 2.0
357 */
358 @Override
359 public ITmfStateSystem getStateSystem() {
360 /*
361 * By default, no state system is used. Sub-classes can specify their
362 * own behaviour.
363 */
364 return null;
365 }
366
09e86496
FC
367 // ------------------------------------------------------------------------
368 // ITmfTrace - Trace characteristics getters
369 // ------------------------------------------------------------------------
370
371 /* (non-Javadoc)
372 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getNbEvents()
b0a282fb 373 */
d4011df2 374 @Override
afc86f78 375 public synchronized long getNbEvents() {
3791b5df 376 return fNbEvents;
b0a282fb
FC
377 }
378
09e86496
FC
379 /* (non-Javadoc)
380 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getTimeRange()
62d1696a 381 */
d4011df2 382 @Override
12c155f5 383 public TmfTimeRange getTimeRange() {
cb866e08 384 return new TmfTimeRange(fStartTime, fEndTime);
8c8bf09f
ASL
385 }
386
09e86496
FC
387 /* (non-Javadoc)
388 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getStartTime()
e31e01e8 389 */
d4011df2 390 @Override
4df4581d 391 public ITmfTimestamp getStartTime() {
4593bd5b 392 return fStartTime;
146a887c
FC
393 }
394
09e86496
FC
395 /* (non-Javadoc)
396 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getEndTime()
e31e01e8 397 */
d4011df2 398 @Override
4df4581d 399 public ITmfTimestamp getEndTime() {
4593bd5b 400 return fEndTime;
20658947
FC
401 }
402
403 // ------------------------------------------------------------------------
0316808c 404 // Convenience setters/getters
20658947
FC
405 // ------------------------------------------------------------------------
406
0316808c
FC
407 /**
408 * Set the trace cache size. Must be done at initialization time.
0bfb7d06 409 *
0316808c
FC
410 * @param cacheSize The trace cache size
411 */
412 protected void setCacheSize(final int cacheSize) {
413 fCacheSize = cacheSize;
414 }
415
416 /**
417 * Set the trace known number of events. This can be quite dynamic
418 * during indexing or for live traces.
0bfb7d06 419 *
0316808c
FC
420 * @param nbEvents The number of events
421 */
422 protected synchronized void setNbEvents(final long nbEvents) {
423 fNbEvents = (nbEvents > 0) ? nbEvents : 0;
424 }
425
20658947
FC
426 /**
427 * Update the trace events time range
0bfb7d06 428 *
20658947
FC
429 * @param range the new time range
430 */
431 protected void setTimeRange(final TmfTimeRange range) {
4593bd5b
AM
432 fStartTime = range.getStartTime();
433 fEndTime = range.getEndTime();
20658947
FC
434 }
435
436 /**
437 * Update the trace chronologically first event timestamp
0bfb7d06 438 *
20658947
FC
439 * @param startTime the new first event timestamp
440 */
441 protected void setStartTime(final ITmfTimestamp startTime) {
4593bd5b 442 fStartTime = startTime;
20658947
FC
443 }
444
445 /**
446 * Update the trace chronologically last event timestamp
0bfb7d06 447 *
20658947
FC
448 * @param endTime the new last event timestamp
449 */
450 protected void setEndTime(final ITmfTimestamp endTime) {
4593bd5b 451 fEndTime = endTime;
20658947
FC
452 }
453
454 /**
0316808c 455 * Set the polling interval for live traces (default = 0 = no streaming).
0bfb7d06 456 *
20658947
FC
457 * @param interval the new trace streaming interval
458 */
459 protected void setStreamingInterval(final long interval) {
1703b536 460 fStreamingInterval = (interval > 0) ? interval : 0;
146a887c
FC
461 }
462
0316808c
FC
463 /**
464 * Set the trace indexer. Must be done at initialization time.
0bfb7d06 465 *
0316808c
FC
466 * @param indexer the trace indexer
467 */
6256d8ad 468 protected void setIndexer(final ITmfTraceIndexer indexer) {
0316808c
FC
469 fIndexer = indexer;
470 }
471
472 /**
473 * Set the trace parser. Must be done at initialization time.
0bfb7d06 474 *
0316808c
FC
475 * @param parser the new trace parser
476 */
6256d8ad 477 protected void setParser(final ITmfEventParser parser) {
0316808c
FC
478 fParser = parser;
479 }
480
09e86496 481 // ------------------------------------------------------------------------
7e6347b0 482 // ITmfTrace - SeekEvent operations (returning a trace context)
09e86496
FC
483 // ------------------------------------------------------------------------
484
485 /* (non-Javadoc)
7e6347b0 486 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(long)
1b70b6dc
PT
487 */
488 @Override
7e6347b0 489 public synchronized ITmfContext seekEvent(final long rank) {
09e86496 490
7e6347b0 491 // A rank <= 0 indicates to seek the first event
2352aed9 492 if (rank <= 0) {
1e1bef82 493 ITmfContext context = seekEvent((ITmfLocation) null);
2352aed9
FC
494 context.setRank(0);
495 return context;
496 }
09e86496 497
09e86496 498 // Position the trace at the checkpoint
7e6347b0 499 final ITmfContext context = fIndexer.seekIndex(rank);
09e86496
FC
500
501 // And locate the requested event context
7e6347b0
FC
502 long pos = context.getRank();
503 if (pos < rank) {
c32744d6 504 ITmfEvent event = getNext(context);
0bfb7d06 505 while ((event != null) && (++pos < rank)) {
c32744d6 506 event = getNext(context);
7e6347b0 507 }
09e86496
FC
508 }
509 return context;
1b70b6dc
PT
510 }
511
09e86496 512 /* (non-Javadoc)
7e6347b0 513 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
09e86496
FC
514 */
515 @Override
7e6347b0 516 public synchronized ITmfContext seekEvent(final ITmfTimestamp timestamp) {
09e86496 517
7e6347b0 518 // A null timestamp indicates to seek the first event
2352aed9 519 if (timestamp == null) {
1e1bef82 520 ITmfContext context = seekEvent((ITmfLocation) null);
2352aed9
FC
521 context.setRank(0);
522 return context;
523 }
09e86496 524
1703b536 525 // Position the trace at the checkpoint
408e65d2 526 ITmfContext context = fIndexer.seekIndex(timestamp);
09e86496
FC
527
528 // And locate the requested event context
7e6347b0 529 final ITmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype...
c32744d6 530 ITmfEvent event = getNext(nextEventContext);
7e6347b0 531 while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) {
4c9f2944 532 context.dispose();
3cec7398 533 context = nextEventContext.clone();
c32744d6 534 event = getNext(nextEventContext);
09e86496 535 }
4c9f2944 536 nextEventContext.dispose();
0316808c
FC
537 if (event == null) {
538 context.setLocation(null);
539 context.setRank(ITmfContext.UNKNOWN_RANK);
540 }
09e86496
FC
541 return context;
542 }
0283f7ff 543
09e86496
FC
544 // ------------------------------------------------------------------------
545 // ITmfTrace - Read operations (returning an actual event)
546 // ------------------------------------------------------------------------
547
d337369a 548 /* (non-Javadoc)
b4f71e4a 549 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
abfad0aa 550 */
d4011df2 551 @Override
6256d8ad 552 public synchronized ITmfEvent getNext(final ITmfContext context) {
09e86496 553 // parseEvent() does not update the context
6256d8ad 554 final ITmfEvent event = fParser.parseEvent(context);
09e86496 555 if (event != null) {
d337369a 556 updateAttributes(context, event.getTimestamp());
09e86496
FC
557 context.setLocation(getCurrentLocation());
558 context.increaseRank();
559 processEvent(event);
560 }
561 return event;
562 }
563
564 /**
d337369a 565 * Hook for special event processing by the concrete class
7e6347b0 566 * (called by TmfTrace.getEvent())
0bfb7d06 567 *
d337369a 568 * @param event the event
09e86496
FC
569 */
570 protected void processEvent(final ITmfEvent event) {
d337369a 571 // Do nothing
09e86496
FC
572 }
573
d337369a
FC
574 /**
575 * Update the trace attributes
0bfb7d06 576 *
d337369a 577 * @param context the current trace context
2848c377 578 * @param timestamp the corresponding timestamp
d337369a
FC
579 */
580 protected synchronized void updateAttributes(final ITmfContext context, final ITmfTimestamp timestamp) {
0bfb7d06 581 if (fStartTime.equals(TmfTimestamp.BIG_BANG) || (fStartTime.compareTo(timestamp, false) > 0)) {
4593bd5b 582 fStartTime = timestamp;
09e86496 583 }
0bfb7d06 584 if (fEndTime.equals(TmfTimestamp.BIG_CRUNCH) || (fEndTime.compareTo(timestamp, false) < 0)) {
4593bd5b 585 fEndTime = timestamp;
09e86496
FC
586 }
587 if (context.hasValidRank()) {
d337369a 588 long rank = context.getRank();
09e86496
FC
589 if (fNbEvents <= rank) {
590 fNbEvents = rank + 1;
591 }
200789b3
AM
592 if (fIndexer != null) {
593 fIndexer.updateIndex(context, timestamp);
594 }
09e86496 595 }
abfad0aa
FC
596 }
597
3791b5df 598 // ------------------------------------------------------------------------
d337369a 599 // TmfDataProvider
3791b5df
FC
600 // ------------------------------------------------------------------------
601
d337369a
FC
602 /* (non-Javadoc)
603 * @see org.eclipse.linuxtools.tmf.core.component.TmfDataProvider#armRequest(org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest)
604 */
3791b5df 605 @Override
6256d8ad
AM
606 protected ITmfContext armRequest(final ITmfDataRequest request) {
607 if ((request instanceof ITmfEventRequest)
608 && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest) request).getRange().getStartTime())
0bfb7d06 609 && (request.getIndex() == 0))
0316808c 610 {
6256d8ad
AM
611 final ITmfContext context = seekEvent(((ITmfEventRequest) request).getRange().getStartTime());
612 ((ITmfEventRequest) request).setStartIndex((int) context.getRank());
3791b5df
FC
613 return context;
614
615 }
616 return seekEvent(request.getIndex());
617 }
618
3791b5df 619 // ------------------------------------------------------------------------
09e86496 620 // toString
3791b5df
FC
621 // ------------------------------------------------------------------------
622
d337369a
FC
623 /* (non-Javadoc)
624 * @see java.lang.Object#toString()
625 */
12c155f5 626 @Override
09e86496 627 @SuppressWarnings("nls")
afc86f78 628 public synchronized String toString() {
20658947
FC
629 return "TmfTrace [fPath=" + fPath + ", fCacheSize=" + fCacheSize
630 + ", fNbEvents=" + fNbEvents + ", fStartTime=" + fStartTime
631 + ", fEndTime=" + fEndTime + ", fStreamingInterval=" + fStreamingInterval + "]";
12c155f5
FC
632 }
633
8c8bf09f 634}
This page took 0.088838 seconds and 5 git commands to generate.