Fix for bug 382438: null pointer exception when closing statistics view
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / trace / TmfExperiment.java
CommitLineData
8c8bf09f 1/*******************************************************************************
0316808c 2 * Copyright (c) 2009, 2010, 2012 Ericsson
ce2388e0 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
ce2388e0 8 *
8c8bf09f
ASL
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
0316808c 11 * Francois Chouinard - Updated as per TMF Trace Model 1.0
8c8bf09f
ASL
12 *******************************************************************************/
13
9e0640dc 14package org.eclipse.linuxtools.tmf.core.trace;
8c8bf09f 15
a1091415 16import org.eclipse.core.resources.IFile;
12c155f5 17import org.eclipse.core.resources.IProject;
828e5592 18import org.eclipse.core.resources.IResource;
9e0640dc
FC
19import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentContext;
20import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentLocation;
21import org.eclipse.linuxtools.internal.tmf.core.trace.TmfLocationArray;
72f1e62a 22import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
4df4581d 23import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
6c13869b
FC
24import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
25import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
0316808c 26import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
49e2f79a
FC
27import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
28import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
1b70b6dc 29import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
6c13869b
FC
30import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
31import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal;
32import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
33import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentUpdatedSignal;
34import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
c32744d6 35import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
8c8bf09f
ASL
36
37/**
9e0640dc 38 * TmfExperiment presents a time-ordered, unified view of a set of ITmfTrace:s
cbdacf03 39 * that are part of a tracing experiment.
4b7b3670
FC
40 *
41 * @version 1.0
42 * @author Francois Chouinard
8c8bf09f 43 */
0316808c 44public class TmfExperiment<T extends ITmfEvent> extends TmfTrace<T> implements ITmfEventParser<T> {
8c8bf09f 45
c32744d6
FC
46 // ------------------------------------------------------------------------
47 // Constants
48 // ------------------------------------------------------------------------
49
9e0640dc
FC
50 /**
51 * The default index page size
52 */
53 public static final int DEFAULT_INDEX_PAGE_SIZE = 5000;
c32744d6 54
8c8bf09f
ASL
55 // ------------------------------------------------------------------------
56 // Attributes
57 // ------------------------------------------------------------------------
58
9e0640dc
FC
59 /**
60 * The currently selected experiment (null if none)
61 */
c32744d6 62 protected static TmfExperiment<?> fCurrentExperiment = null;
e31e01e8 63
9e0640dc
FC
64 /**
65 * The set of traces that constitute the experiment
66 */
c32744d6 67 protected ITmfTrace<T>[] fTraces;
8c8bf09f 68
9e0640dc
FC
69 /**
70 * The set of traces that constitute the experiment
71 */
72 private boolean fInitialized = false;
a1091415 73
9e0640dc
FC
74 /**
75 * The experiment bookmarks file
76 */
77 private IFile fBookmarksFile;
828e5592 78
49e2f79a
FC
79
80 // Saved experiment context (optimization)
81 private TmfExperimentContext fExperimentContext;
82
8c8bf09f 83 // ------------------------------------------------------------------------
9e0640dc 84 // Construction
8c8bf09f
ASL
85 // ------------------------------------------------------------------------
86
9e0640dc
FC
87 /**
88 * @param type
89 * @param id
90 * @param traces
9b749023 91 * @throws TmfTraceException
9e0640dc
FC
92 */
93 public TmfExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces) {
94 this(type, id, traces, DEFAULT_INDEX_PAGE_SIZE);
96c6806f
PT
95 }
96
8c8bf09f
ASL
97 /**
98 * @param type
99 * @param id
100 * @param traces
8c8bf09f 101 * @param indexPageSize
9b749023 102 * @throws TmfTraceException
8c8bf09f 103 */
0316808c 104 @SuppressWarnings({ "unchecked", "rawtypes" })
9e0640dc 105 public TmfExperiment(final Class<T> type, final String path, final ITmfTrace<T>[] traces, final int indexPageSize) {
0316808c
FC
106 setCacheSize(indexPageSize);
107 setStreamingInterval(0);
07671572 108 setIndexer(new TmfCheckpointIndexer(this, indexPageSize));
0316808c
FC
109 setParser(this);
110 try {
111 super.initialize(null, path, type);
112 } catch (TmfTraceException e) {
113 e.printStackTrace();
114 }
8c8bf09f 115
a79913eb 116 fTraces = traces;
a87cc4ef 117 setTimeRange(TmfTimeRange.NULL_RANGE);
8c8bf09f 118 }
a79913eb 119
8c8bf09f 120 /**
ff4ed569 121 * Clears the experiment
8c8bf09f
ASL
122 */
123 @Override
12c155f5 124 @SuppressWarnings("rawtypes")
a79913eb
FC
125 public synchronized void dispose() {
126
cbdacf03 127 final TmfExperimentDisposedSignal<T> signal = new TmfExperimentDisposedSignal<T>(this, this);
a79913eb 128 broadcast(signal);
9e0640dc
FC
129
130 if (fCurrentExperiment == this) {
09d11238 131 fCurrentExperiment = null;
9e0640dc 132 }
a79913eb 133
77551cc2
FC
134 // Clean up the index if applicable
135 if (getIndexer() != null) {
136 getIndexer().dispose();
137 }
b5ee6881 138
a79913eb 139 if (fTraces != null) {
9b749023 140 for (final ITmfTrace trace : fTraces) {
a79913eb 141 trace.dispose();
9b749023 142 }
a79913eb
FC
143 fTraces = null;
144 }
2fb2eb37 145 super.dispose();
8c8bf09f
ASL
146 }
147
9e0640dc
FC
148 // ------------------------------------------------------------------------
149 // ITmfTrace - Initializers
150 // ------------------------------------------------------------------------
151
152 /* (non-Javadoc)
153 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String)
154 */
155 @Override
156 public boolean validate(final IProject project, final String path) {
157 return true;
158 }
159
160 /* (non-Javadoc)
161 * @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class)
162 */
163 @Override
164 public void initTrace(final IResource resource, final String path, final Class<T> type) {
165 }
166
8c8bf09f 167 // ------------------------------------------------------------------------
e31e01e8 168 // Accessors
8c8bf09f
ASL
169 // ------------------------------------------------------------------------
170
9e0640dc
FC
171 /**
172 * Selects the current, framework-wide, experiment
9b749023 173 *
9e0640dc
FC
174 * @param experiment das experiment
175 */
cbdacf03 176 public static void setCurrentExperiment(final TmfExperiment<?> experiment) {
9e0640dc 177 if (fCurrentExperiment != null && fCurrentExperiment != experiment) {
09d11238 178 fCurrentExperiment.dispose();
9e0640dc 179 }
a79913eb 180 fCurrentExperiment = experiment;
f6b14ce2
FC
181 }
182
9e0640dc
FC
183 /**
184 * @return das experiment
185 */
e31e01e8 186 public static TmfExperiment<?> getCurrentExperiment() {
a79913eb 187 return fCurrentExperiment;
8c8bf09f
ASL
188 }
189
9e0640dc
FC
190 /**
191 * Get the list of traces. Handle with care...
9b749023 192 *
9e0640dc
FC
193 * @return the experiment traces
194 */
12c155f5 195 public ITmfTrace<T>[] getTraces() {
a79913eb 196 return fTraces;
8c8bf09f
ASL
197 }
198
8c8bf09f 199 /**
cbdacf03
FC
200 * Returns the timestamp of the event at the requested index. If none,
201 * returns null.
9b749023 202 *
0d9a6d76
FC
203 * @param index the event index (rank)
204 * @return the corresponding event timestamp
8c8bf09f 205 */
cbdacf03 206 public ITmfTimestamp getTimestamp(final int index) {
0316808c 207 final ITmfContext context = seekEvent(index);
c32744d6 208 final ITmfEvent event = getNext(context);
a79913eb 209 return (event != null) ? event.getTimestamp() : null;
8c8bf09f
ASL
210 }
211
9e0640dc
FC
212 /**
213 * Set the file to be used for bookmarks on this experiment
9b749023 214 *
9e0640dc
FC
215 * @param file the bookmarks file
216 */
217 public void setBookmarksFile(final IFile file) {
218 fBookmarksFile = file;
219 }
07671572 220
9e0640dc
FC
221 /**
222 * Get the file used for bookmarks on this experiment
9b749023 223 *
9e0640dc
FC
224 * @return the bookmarks file or null if none is set
225 */
226 public IFile getBookmarksFile() {
227 return fBookmarksFile;
a79913eb
FC
228 }
229
49e2f79a
FC
230 // ------------------------------------------------------------------------
231 // Request management
232 // ------------------------------------------------------------------------
233
3bd44ac8
FC
234 /* (non-Javadoc)
235 * @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#armRequest(org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest)
236 */
49e2f79a 237 @Override
408e65d2 238 protected synchronized ITmfContext armRequest(final ITmfDataRequest<T> request) {
9b749023 239
6a953367
BH
240 // Make sure we have something to read from
241 if (fTraces == null) {
242 return null;
243 }
9b749023 244
49e2f79a
FC
245 if (request instanceof ITmfEventRequest<?>
246 && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest<T>) request).getRange().getStartTime())
247 && request.getIndex() == 0)
248 {
249 final ITmfContext context = seekEvent(((ITmfEventRequest<T>) request).getRange().getStartTime());
250 ((ITmfEventRequest<T>) request).setStartIndex((int) context.getRank());
251 return context;
252
253 }
254
255 // Check if we are already at the right index
256 if ((fExperimentContext != null) && fExperimentContext.getRank() == request.getIndex()) {
257 return fExperimentContext;
258 }
259
260 return seekEvent(request.getIndex());
261 }
262
a79913eb 263 // ------------------------------------------------------------------------
9f584e4c
FC
264 // ITmfTrace trace positioning
265 // ------------------------------------------------------------------------
266
f3fd42d1
FC
267 /* (non-Javadoc)
268 * @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#seekEvent(long)
9b749023 269 *
f3fd42d1
FC
270 * TmfTrace.seekEvent(rank) will return a context that will position the
271 * trace to read the event at rank 'rank' in the trace. In the case of an
272 * experiment context, that event has to be actually read in the fEvents
273 * buffer and the corresponding trace context has to point to the next
274 * event (rank + 1) in the trace (the sum of the traces contexts ranks
275 * should equal [exp context rank + #traces] (corner cases not considered).
9b749023 276 *
f3fd42d1
FC
277 * In the likely case that TmfTrace.seekEvent() computed the context
278 * by using a read loop (reading from the experiment), the 'lastTraceRead'
279 * field will be set to the actual trace that needs to be read to obtain
280 * event at rank 'rank'.
9b749023 281 *
f3fd42d1
FC
282 * Therefore, if 'lastTraceRead' is set, we need to read that particular
283 * trace *and* then decrease the context rank (which has to correspond to
284 * the rank of the event to be returned next by TmfExperiemnt.getNext().
285 */
286 @Override
287 public synchronized ITmfContext seekEvent(final long rank) {
288 TmfExperimentContext context = (TmfExperimentContext) super.seekEvent(rank);
289 int lastTrace = context.getLastTrace();
290 if (lastTrace != TmfExperimentContext.NO_TRACE) {
291 getNext(context);
292 context.setRank(rank);
293 context.setLastTrace(TmfExperimentContext.NO_TRACE);
294 }
295 return context;
296 }
297
9e0640dc
FC
298 /* (non-Javadoc)
299 *
9b749023 300 * Returns a brand new context based on the location provided and
9e0640dc 301 * initializes the event queues
9b749023 302 *
9e0640dc
FC
303 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfLocation)
304 */
a79913eb 305 @Override
9e0640dc 306 public synchronized ITmfContext seekEvent(final ITmfLocation<?> location) {
a79913eb 307 // Validate the location
9e0640dc 308 if (location != null && !(location instanceof TmfExperimentLocation)) {
a79913eb 309 return null; // Throw an exception?
9e0640dc
FC
310 }
311 // Make sure we have something to read from
312 if (fTraces == null) {
a79913eb 313 return null;
9e0640dc 314 }
8f50c396 315
a79913eb 316 // Instantiate the location
9e0640dc 317 final TmfExperimentLocation expLocation = (location == null)
9b749023 318 ? new TmfExperimentLocation(new TmfLocationArray(new ITmfLocation<?>[fTraces.length]))
9e0640dc 319 : (TmfExperimentLocation) location.clone();
8f50c396 320
a79913eb 321 // Create and populate the context's traces contexts
0316808c 322 final TmfExperimentContext context = new TmfExperimentContext(new ITmfContext[fTraces.length]);
9b635e61 323
a79913eb
FC
324 for (int i = 0; i < fTraces.length; i++) {
325 // Get the relevant trace attributes
5cc97265
FC
326 final ITmfLocation<?> trcLocation = expLocation.getLocation().getLocations()[i];
327 context.getContexts()[i] = fTraces[i].seekEvent(trcLocation);
328 expLocation.getLocation().getLocations()[i] = context.getContexts()[i].getLocation().clone();
c32744d6 329 context.getEvents()[i] = fTraces[i].getNext(context.getContexts()[i]);
a79913eb 330 }
8f50c396 331
a79913eb
FC
332 // Finalize context
333 context.setLocation(expLocation);
334 context.setLastTrace(TmfExperimentContext.NO_TRACE);
5cc97265 335 context.setRank(ITmfContext.UNKNOWN_RANK);
49e2f79a
FC
336
337 fExperimentContext = context;
9b749023 338 return context;
a79913eb 339 }
9f584e4c 340
3bd44ac8
FC
341 // ------------------------------------------------------------------------
342 // ITmfTrace - SeekEvent operations (returning a trace context)
343 // ------------------------------------------------------------------------
344
9e0640dc
FC
345 /* (non-Javadoc)
346 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(double)
347 */
c76c54bb 348 @Override
0316808c
FC
349 public ITmfContext seekEvent(final double ratio) {
350 final ITmfContext context = seekEvent((long) (ratio * getNbEvents()));
c76c54bb
FC
351 return context;
352 }
353
9e0640dc
FC
354 /* (non-Javadoc)
355 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getLocationRatio(org.eclipse.linuxtools.tmf.core.trace.ITmfLocation)
356 */
a79913eb 357 @Override
cbdacf03 358 public double getLocationRatio(final ITmfLocation<?> location) {
9e0640dc 359 if (location instanceof TmfExperimentLocation) {
5cc97265 360 return (double) seekEvent(location).getRank() / getNbEvents();
9e0640dc
FC
361 }
362 return 0.0;
c76c54bb
FC
363 }
364
9e0640dc
FC
365 /* (non-Javadoc)
366 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getCurrentLocation()
367 */
a79913eb
FC
368 @Override
369 public ITmfLocation<?> getCurrentLocation() {
5cc97265 370 ITmfLocation<?>[] locations = new ITmfLocation<?>[fTraces.length];
a87cc4ef 371 for (int i = 0; i < fTraces.length; i++) {
5cc97265 372 locations[i] = fTraces[i].getCurrentLocation();
a87cc4ef
FC
373 }
374 return new TmfExperimentLocation(new TmfLocationArray(locations));
a79913eb 375 }
c76c54bb 376
9e0640dc
FC
377 // ------------------------------------------------------------------------
378 // ITmfTrace trace positioning
379 // ------------------------------------------------------------------------
380
07671572 381 /* (non-Javadoc)
408e65d2 382 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser#parseEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
07671572
FC
383 */
384 @Override
408e65d2
FC
385 public synchronized T parseEvent(final ITmfContext context) {
386 final ITmfContext savedContext = context.clone();
387 final T event = getNext(savedContext);
07671572
FC
388 return event;
389 }
a79913eb 390
ce2388e0 391 /* (non-Javadoc)
408e65d2 392 * @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#getNext(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
a79913eb 393 */
0316808c 394 @Override
3bd44ac8 395 @SuppressWarnings("unchecked")
408e65d2 396 public synchronized T getNext(ITmfContext context) {
a79913eb
FC
397
398 // Validate the context
9e0640dc 399 if (!(context instanceof TmfExperimentContext)) {
a79913eb 400 return null; // Throw an exception?
9e0640dc 401 }
0e8c76f8
BH
402
403 // Make sure that we have something to read from
404 if (fTraces == null) {
405 return null;
406 }
407
a87cc4ef 408 TmfExperimentContext expContext = (TmfExperimentContext) context;
a79913eb 409
a87cc4ef 410 // If an event was consumed previously, first get the next one from that trace
cbdacf03 411 final int lastTrace = expContext.getLastTrace();
a79913eb 412 if (lastTrace != TmfExperimentContext.NO_TRACE) {
cbdacf03 413 final ITmfContext traceContext = expContext.getContexts()[lastTrace];
f3fd42d1
FC
414
415 TmfExperimentLocation location = (TmfExperimentLocation) expContext.getLocation();
416 if (location != null) {
417 location.getLocation().getLocations()[lastTrace] = traceContext.getLocation().clone();
418 }
419
c32744d6 420 expContext.getEvents()[lastTrace] = fTraces[lastTrace].getNext(traceContext);
a79913eb 421 expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
a79913eb
FC
422 }
423
424 // Scan the candidate events and identify the "next" trace to read from
425 int trace = TmfExperimentContext.NO_TRACE;
a4115405 426 ITmfTimestamp timestamp = TmfTimestamp.BIG_CRUNCH;
0316808c 427 for (int i = 0; i < fTraces.length; i++) {
cbdacf03 428 final ITmfEvent event = expContext.getEvents()[i];
a79913eb 429 if (event != null && event.getTimestamp() != null) {
cbdacf03 430 final ITmfTimestamp otherTS = event.getTimestamp();
a79913eb
FC
431 if (otherTS.compareTo(timestamp, true) < 0) {
432 trace = i;
433 timestamp = otherTS;
434 }
435 }
436 }
a87cc4ef
FC
437
438 T event = null;
07671572 439 if (trace != TmfExperimentContext.NO_TRACE) {
a87cc4ef 440 event = (T) expContext.getEvents()[trace];
408e65d2
FC
441 if (event != null) {
442 updateAttributes(expContext, event.getTimestamp());
408e65d2
FC
443 expContext.increaseRank();
444 expContext.setLastTrace(trace);
445 fExperimentContext = expContext;
446 processEvent(event);
447 }
07671572 448 }
a87cc4ef 449
a87cc4ef 450 return event;
a79913eb
FC
451 }
452
bcbea6a6 453 /* (non-Javadoc)
a79913eb
FC
454 * @see java.lang.Object#toString()
455 */
456 @Override
3b38ea61 457 @SuppressWarnings("nls")
9b749023 458 public synchronized String toString() {
a79913eb
FC
459 return "[TmfExperiment (" + getName() + ")]";
460 }
8c8bf09f
ASL
461
462 // ------------------------------------------------------------------------
9e0640dc 463 // Streaming support
8c8bf09f
ASL
464 // ------------------------------------------------------------------------
465
1b70b6dc 466 private synchronized void initializeStreamingMonitor() {
9e0640dc
FC
467
468 if (fInitialized) {
828e5592 469 return;
9e0640dc 470 }
828e5592
PT
471 fInitialized = true;
472
1b70b6dc 473 if (getStreamingInterval() == 0) {
0316808c 474 final ITmfContext context = seekEvent(0);
cbdacf03 475 final ITmfEvent event = getNext(context);
9b749023 476 if (event == null) {
1b70b6dc 477 return;
9b749023 478 }
cbdacf03 479 final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp().clone(), TmfTimestamp.BIG_CRUNCH);
828e5592
PT
480 final TmfExperimentRangeUpdatedSignal signal = new TmfExperimentRangeUpdatedSignal(this, this, timeRange);
481
482 // Broadcast in separate thread to prevent deadlock
483 new Thread() {
484 @Override
485 public void run() {
486 broadcast(signal);
487 }
488 }.start();
1b70b6dc
PT
489 return;
490 }
491
9e0640dc 492 final Thread thread = new Thread("Streaming Monitor for experiment " + getName()) { //$NON-NLS-1$
bcbea6a6
FC
493 private ITmfTimestamp safeTimestamp = null;
494 private TmfTimeRange timeRange = null;
1b70b6dc
PT
495
496 @Override
497 public void run() {
498 while (!fExecutor.isShutdown()) {
9e0640dc 499 if (!getIndexer().isIndexing()) {
a4115405
FC
500 ITmfTimestamp startTimestamp = TmfTimestamp.BIG_CRUNCH;
501 ITmfTimestamp endTimestamp = TmfTimestamp.BIG_BANG;
cbdacf03 502 for (final ITmfTrace<T> trace : fTraces) {
9b749023 503 if (trace.getStartTime().compareTo(startTimestamp) < 0) {
1b70b6dc 504 startTimestamp = trace.getStartTime();
9b749023
AM
505 }
506 if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0) {
1b70b6dc 507 endTimestamp = trace.getEndTime();
9b749023 508 }
1b70b6dc 509 }
9b749023 510 if (safeTimestamp != null && safeTimestamp.compareTo(getTimeRange().getEndTime(), false) > 0) {
1b70b6dc 511 timeRange = new TmfTimeRange(startTimestamp, safeTimestamp);
9b749023 512 } else {
1b70b6dc 513 timeRange = null;
9b749023 514 }
1b70b6dc
PT
515 safeTimestamp = endTimestamp;
516 if (timeRange != null) {
cbdacf03 517 final TmfExperimentRangeUpdatedSignal signal =
1b70b6dc
PT
518 new TmfExperimentRangeUpdatedSignal(TmfExperiment.this, TmfExperiment.this, timeRange);
519 broadcast(signal);
520 }
521 }
522 try {
523 Thread.sleep(getStreamingInterval());
cbdacf03 524 } catch (final InterruptedException e) {
1b70b6dc
PT
525 e.printStackTrace();
526 }
527 }
528 }
529 };
530 thread.start();
531 }
532
9e0640dc 533 /* (non-Javadoc)
1b70b6dc
PT
534 * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#getStreamingInterval()
535 */
536 @Override
537 public long getStreamingInterval() {
538 long interval = 0;
9b749023 539 for (final ITmfTrace<T> trace : fTraces) {
1b70b6dc 540 interval = Math.max(interval, trace.getStreamingInterval());
9b749023 541 }
1b70b6dc
PT
542 return interval;
543 }
544
8c8bf09f
ASL
545 // ------------------------------------------------------------------------
546 // Signal handlers
547 // ------------------------------------------------------------------------
548
9e0640dc 549 private Integer fEndSynchReference;
c32744d6 550
9e0640dc
FC
551 /**
552 * Signal handler for the TmfExperimentSelectedSignal signal
9b749023 553 *
9e0640dc
FC
554 * @param signal
555 */
8c8bf09f 556 @TmfSignalHandler
cbdacf03
FC
557 public void experimentSelected(final TmfExperimentSelectedSignal<T> signal) {
558 final TmfExperiment<?> experiment = signal.getExperiment();
a79913eb
FC
559 if (experiment == this) {
560 setCurrentExperiment(experiment);
6e85c58d 561 fEndSynchReference = Integer.valueOf(signal.getReference());
a79913eb 562 }
8c8bf09f
ASL
563 }
564
9e0640dc
FC
565 /**
566 * Signal handler for the TmfEndSynchSignal signal
9b749023 567 *
9e0640dc
FC
568 * @param signal
569 */
1b70b6dc 570 @TmfSignalHandler
cbdacf03 571 public void endSync(final TmfEndSynchSignal signal) {
1b70b6dc
PT
572 if (fEndSynchReference != null && fEndSynchReference.intValue() == signal.getReference()) {
573 fEndSynchReference = null;
574 initializeStreamingMonitor();
575 }
1b70b6dc
PT
576 }
577
828e5592 578 /**
9e0640dc 579 * Signal handler for the TmfTraceUpdatedSignal signal
9b749023 580 *
9e0640dc 581 * @param signal
828e5592 582 */
9e0640dc
FC
583 @TmfSignalHandler
584 public void traceUpdated(final TmfTraceUpdatedSignal signal) {
585 if (signal.getTrace() == this) {
586 broadcast(new TmfExperimentUpdatedSignal(this, this));
587 }
a1091415
PT
588 }
589
590 /**
9e0640dc 591 * Signal handler for the TmfExperimentRangeUpdatedSignal signal
9b749023 592 *
9e0640dc 593 * @param signal
a1091415 594 */
9e0640dc
FC
595 @TmfSignalHandler
596 public void experimentRangeUpdated(final TmfExperimentRangeUpdatedSignal signal) {
597 if (signal.getExperiment() == this) {
598 getIndexer().buildIndex(getNbEvents(), signal.getRange(), false);
599 }
a1091415
PT
600 }
601
4dc47e28 602}
This page took 0.103717 seconds and 5 git commands to generate.