Fix some null warnings
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.statesystem.core / src / org / eclipse / tracecompass / internal / statesystem / core / StateSystem.java
CommitLineData
a52fde77 1/*******************************************************************************
e13bd4cd 2 * Copyright (c) 2012, 2015 Ericsson
a52fde77
AM
3 * Copyright (c) 2010, 2011 École Polytechnique de Montréal
4 * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
5df842b3 5 *
a52fde77
AM
6 * All rights reserved. This program and the accompanying materials are
7 * made available under the terms of the Eclipse Public License v1.0 which
8 * accompanies this distribution, and is available at
9 * http://www.eclipse.org/legal/epl-v10.html
5df842b3 10 *
e13bd4cd
PT
11 * Contributors:
12 * Alexandre Montplaisir - Initial API and implementation
13 * Patrick Tasse - Add message to exceptions
a52fde77
AM
14 *******************************************************************************/
15
e894a508 16package org.eclipse.tracecompass.internal.statesystem.core;
a52fde77 17
8d1346f0
AM
18import java.io.File;
19import java.io.IOException;
a52fde77 20import java.io.PrintWriter;
8d1346f0 21import java.util.ArrayList;
f94a0bac 22import java.util.LinkedList;
a52fde77 23import java.util.List;
16576a7e 24import java.util.concurrent.CountDownLatch;
9287b6a2 25import java.util.concurrent.TimeUnit;
a52fde77 26
2e21b6d8 27import org.eclipse.jdt.annotation.NonNull;
df2597e0 28import org.eclipse.jdt.annotation.Nullable;
e894a508
AM
29import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
30import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend;
31import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
32import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
33import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
34import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
35import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
e894a508 36import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
e894a508 37import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue.Type;
1dd75589 38import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
a52fde77
AM
39
40/**
8d1346f0
AM
41 * This is the core class of the Generic State System. It contains all the
42 * methods to build and query a state history. It's exposed externally through
43 * the IStateSystemQuerier and IStateSystemBuilder interfaces, depending if the
44 * user needs read-only access or read-write access.
5df842b3 45 *
8d1346f0
AM
46 * When building, DON'T FORGET to call .closeHistory() when you are done
47 * inserting intervals, or the storage backend will have no way of knowing it
48 * can close and write itself to disk, and its thread will keep running.
5df842b3 49 *
a52fde77 50 * @author alexmont
5df842b3 51 *
a52fde77 52 */
f1f86dfb 53public class StateSystem implements ITmfStateSystemBuilder {
a52fde77
AM
54
55 /* References to the inner structures */
8d1346f0
AM
56 private final AttributeTree attributeTree;
57 private final TransientState transState;
58 private final IStateHistoryBackend backend;
a52fde77 59
16576a7e
AM
60 /* Latch tracking if the state history is done building or not */
61 private final CountDownLatch finishedLatch = new CountDownLatch(1);
62
1a4205d9 63 private boolean buildCancelled = false;
96345c5a 64 private boolean isDisposed = false;
1a4205d9 65
f9a76cac
AM
66 /**
67 * New-file constructor. For when you build a state system with a new file,
68 * or if the back-end does not require a file on disk.
69 *
70 * @param backend
71 * Back-end plugin to use
72 */
b2f62cb5 73 public StateSystem(@NonNull IStateHistoryBackend backend) {
f9a76cac
AM
74 this.backend = backend;
75 this.transState = new TransientState(backend);
76 this.attributeTree = new AttributeTree(this);
77 }
78
a52fde77 79 /**
8d1346f0
AM
80 * General constructor
81 *
82 * @param backend
f9a76cac 83 * The "state history storage" back-end to use.
8d1346f0
AM
84 * @param newFile
85 * Put true if this is a new history started from scratch. It is
86 * used to tell the state system where to get its attribute tree.
87 * @throws IOException
88 * If there was a problem creating the new history file
a52fde77 89 */
b2f62cb5 90 public StateSystem(@NonNull IStateHistoryBackend backend, boolean newFile)
8d1346f0
AM
91 throws IOException {
92 this.backend = backend;
93 this.transState = new TransientState(backend);
a52fde77 94
8d1346f0
AM
95 if (newFile) {
96 attributeTree = new AttributeTree(this);
97 } else {
98 /* We're opening an existing file */
99 this.attributeTree = new AttributeTree(this, backend.supplyAttributeTreeReader());
100 transState.setInactive();
16576a7e
AM
101 finishedLatch.countDown(); /* The history is already built */
102 }
103 }
104
84a9548a
AM
105 @Override
106 public String getSSID() {
b2f62cb5 107 return backend.getSSID();
84a9548a
AM
108 }
109
16576a7e 110 @Override
2002c638
AM
111 public boolean isCancelled() {
112 return buildCancelled;
113 }
114
115 @Override
116 public void waitUntilBuilt() {
16576a7e
AM
117 try {
118 finishedLatch.await();
119 } catch (InterruptedException e) {
120 e.printStackTrace();
8d1346f0 121 }
1a4205d9
AM
122 }
123
9287b6a2
AM
124 @Override
125 public boolean waitUntilBuilt(long timeout) {
126 boolean ret = false;
127 try {
128 ret = finishedLatch.await(timeout, TimeUnit.MILLISECONDS);
129 } catch (InterruptedException e) {
130 e.printStackTrace();
131 }
132 return ret;
133 }
134
1a4205d9
AM
135 @Override
136 public synchronized void dispose() {
96345c5a 137 isDisposed = true;
1a4205d9
AM
138 if (transState.isActive()) {
139 transState.setInactive();
140 buildCancelled = true;
141 }
142 backend.dispose();
a52fde77
AM
143 }
144
8d1346f0
AM
145 //--------------------------------------------------------------------------
146 // General methods related to the attribute tree
147 //--------------------------------------------------------------------------
148
339d27b4
AM
149 /**
150 * Get the attribute tree associated with this state system. This should be
151 * the only way of accessing it (and if subclasses want to point to a
152 * different attribute tree than their own, they should only need to
153 * override this).
154 *
155 * @return The attribute tree
156 */
157 public AttributeTree getAttributeTree() {
158 return attributeTree;
159 }
160
8d1346f0
AM
161 /**
162 * Method used by the attribute tree when creating new attributes, to keep
163 * the attribute count in the transient state in sync.
164 */
bcec0116 165 public void addEmptyAttribute() {
8d1346f0
AM
166 transState.addEmptyEntry();
167 }
168
169 @Override
4623f57f 170 public int getNbAttributes() {
339d27b4 171 return getAttributeTree().getNbAttributes();
4623f57f
AM
172 }
173
8d1346f0
AM
174 @Override
175 public String getAttributeName(int attributeQuark) {
339d27b4 176 return getAttributeTree().getAttributeName(attributeQuark);
8d1346f0
AM
177 }
178
179 @Override
180 public String getFullAttributePath(int attributeQuark) {
339d27b4 181 return getAttributeTree().getFullAttributeName(attributeQuark);
8d1346f0
AM
182 }
183
34638411
AM
184 @Override
185 public String[] getFullAttributePathArray(int attributeQuark) {
186 return getAttributeTree().getFullAttributePathArray(attributeQuark);
187 }
188
8d1346f0
AM
189 //--------------------------------------------------------------------------
190 // Methods related to the storage backend
191 //--------------------------------------------------------------------------
a52fde77 192
8d1346f0
AM
193 @Override
194 public long getStartTime() {
195 return backend.getStartTime();
196 }
197
198 @Override
199 public long getCurrentEndTime() {
200 return backend.getEndTime();
201 }
202
203 @Override
204 public void closeHistory(long endTime) throws TimeRangeException {
205 File attributeTreeFile;
206 long attributeTreeFilePos;
207 long realEndTime = endTime;
208
209 if (realEndTime < backend.getEndTime()) {
210 /*
211 * This can happen (empty nodes pushing the border further, etc.)
212 * but shouldn't be too big of a deal.
213 */
214 realEndTime = backend.getEndTime();
215 }
216 transState.closeTransientState(realEndTime);
217 backend.finishedBuilding(realEndTime);
218
219 attributeTreeFile = backend.supplyAttributeTreeWriterFile();
220 attributeTreeFilePos = backend.supplyAttributeTreeWriterFilePosition();
221 if (attributeTreeFile != null) {
222 /*
223 * If null was returned, we simply won't save the attribute tree,
224 * too bad!
225 */
339d27b4 226 getAttributeTree().writeSelf(attributeTreeFile, attributeTreeFilePos);
8d1346f0 227 }
16576a7e 228 finishedLatch.countDown(); /* Mark the history as finished building */
8d1346f0
AM
229 }
230
231 //--------------------------------------------------------------------------
232 // Quark-retrieving methods
233 //--------------------------------------------------------------------------
234
235 @Override
a52fde77
AM
236 public int getQuarkAbsolute(String... attribute)
237 throws AttributeNotFoundException {
339d27b4 238 return getAttributeTree().getQuarkDontAdd(-1, attribute);
a52fde77
AM
239 }
240
8d1346f0 241 @Override
a52fde77 242 public int getQuarkAbsoluteAndAdd(String... attribute) {
339d27b4 243 return getAttributeTree().getQuarkAndAdd(-1, attribute);
a52fde77
AM
244 }
245
8d1346f0 246 @Override
a52fde77
AM
247 public int getQuarkRelative(int startingNodeQuark, String... subPath)
248 throws AttributeNotFoundException {
339d27b4 249 return getAttributeTree().getQuarkDontAdd(startingNodeQuark, subPath);
a52fde77
AM
250 }
251
8d1346f0 252 @Override
a52fde77 253 public int getQuarkRelativeAndAdd(int startingNodeQuark, String... subPath) {
339d27b4 254 return getAttributeTree().getQuarkAndAdd(startingNodeQuark, subPath);
a52fde77
AM
255 }
256
8d1346f0 257 @Override
c66426fd 258 public List<Integer> getSubAttributes(int quark, boolean recursive)
0a9de3d2 259 throws AttributeNotFoundException {
339d27b4 260 return getAttributeTree().getSubAttributes(quark, recursive);
0a9de3d2
AM
261 }
262
5206c858
AM
263 @Override
264 public List<Integer> getSubAttributes(int quark, boolean recursive, String pattern)
265 throws AttributeNotFoundException {
266 List<Integer> all = getSubAttributes(quark, recursive);
267 List<Integer> ret = new LinkedList<>();
268 for (Integer attQuark : all) {
269 String name = getAttributeName(attQuark.intValue());
270 if (name.matches(pattern)) {
271 ret.add(attQuark);
272 }
273 }
274 return ret;
275 }
276
0fdd2c45
FG
277 @Override
278 public int getParentAttributeQuark(int quark) {
279 return getAttributeTree().getParentAttributeQuark(quark);
280 }
281
8d1346f0 282 @Override
df2597e0
AM
283 public List<@NonNull Integer> getQuarks(String... pattern) {
284 List<@NonNull Integer> quarks = new LinkedList<>();
a4524c1b
AM
285 List<String> prefix = new LinkedList<>();
286 List<String> suffix = new LinkedList<>();
f94a0bac
AM
287 boolean split = false;
288 String[] prefixStr;
289 String[] suffixStr;
290 List<Integer> directChildren;
291 int startingAttribute;
292
293 /* Fill the "prefix" and "suffix" parts of the pattern around the '*' */
294 for (String entry : pattern) {
295 if (entry.equals("*")) { //$NON-NLS-1$
296 if (split) {
297 /*
298 * Split was already true? This means there was more than
299 * one wildcard. This is not supported, return an empty
300 * list.
301 */
302 return quarks;
303 }
304 split = true;
305 continue;
306 }
307
308 if (split) {
309 suffix.add(entry);
310 } else {
311 prefix.add(entry);
312 }
313 }
314 prefixStr = prefix.toArray(new String[prefix.size()]);
315 suffixStr = suffix.toArray(new String[suffix.size()]);
316
317 /*
318 * If there was no wildcard, we'll only return the one matching
319 * attribute, if there is one.
320 */
cb42195c 321 if (!split) {
f94a0bac
AM
322 int quark;
323 try {
324 quark = getQuarkAbsolute(prefixStr);
325 } catch (AttributeNotFoundException e) {
326 /* It's fine, we'll just return the empty List */
327 return quarks;
328 }
329 quarks.add(quark);
330 return quarks;
331 }
332
333 try {
334 if (prefix.size() == 0) {
335 /*
336 * If 'prefix' is empty, this means the wildcard was the first
337 * element. Look for the root node's sub-attributes.
338 */
339 startingAttribute = -1;
340 } else {
341 startingAttribute = getQuarkAbsolute(prefixStr);
342 }
339d27b4 343 directChildren = getSubAttributes(startingAttribute, false);
f94a0bac
AM
344 } catch (AttributeNotFoundException e) {
345 /* That attribute path did not exist, return the empty array */
346 return quarks;
347 }
348
349 /*
350 * Iterate of all the sub-attributes, and only keep those who match the
351 * 'suffix' part of the initial pattern.
352 */
353 for (int childQuark : directChildren) {
354 int matchingQuark;
355 try {
356 matchingQuark = getQuarkRelative(childQuark, suffixStr);
357 } catch (AttributeNotFoundException e) {
358 continue;
359 }
360 quarks.add(matchingQuark);
361 }
362
363 return quarks;
364 }
365
8d1346f0
AM
366 //--------------------------------------------------------------------------
367 // Methods related to insertions in the history
368 //--------------------------------------------------------------------------
a52fde77 369
8d1346f0 370 @Override
a52fde77 371 public void modifyAttribute(long t, ITmfStateValue value, int attributeQuark)
7e0b2b56
AM
372 throws TimeRangeException, AttributeNotFoundException,
373 StateValueTypeException {
feea3b3c
AM
374 if (value == null) {
375 /*
376 * TODO Replace with @NonNull parameter (will require fixing all the
377 * state providers!)
378 */
379 throw new IllegalArgumentException();
380 }
a52fde77
AM
381 transState.processStateChange(t, value, attributeQuark);
382 }
383
8d1346f0 384 @Override
a52fde77
AM
385 public void incrementAttribute(long t, int attributeQuark)
386 throws StateValueTypeException, TimeRangeException,
387 AttributeNotFoundException {
359eeba0
PT
388 ITmfStateValue stateValue = queryOngoingState(attributeQuark);
389 int prevValue = 0;
390 /* if the attribute was previously null, start counting at 0 */
391 if (!stateValue.isNull()) {
392 prevValue = stateValue.unboxInt();
280bbdbb 393 }
a52fde77
AM
394 modifyAttribute(t, TmfStateValue.newValueInt(prevValue + 1),
395 attributeQuark);
396 }
397
8d1346f0 398 @Override
a52fde77
AM
399 public void pushAttribute(long t, ITmfStateValue value, int attributeQuark)
400 throws TimeRangeException, AttributeNotFoundException,
401 StateValueTypeException {
0126a8ca 402 int stackDepth;
a52fde77
AM
403 int subAttributeQuark;
404 ITmfStateValue previousSV = transState.getOngoingStateValue(attributeQuark);
405
406 if (previousSV.isNull()) {
407 /*
408 * If the StateValue was null, this means this is the first time we
409 * use this attribute. Leave stackDepth at 0.
410 */
cb42195c 411 stackDepth = 0;
b67a2540 412 } else if (previousSV.getType() == Type.INTEGER) {
a52fde77
AM
413 /* Previous value was an integer, all is good, use it */
414 stackDepth = previousSV.unboxInt();
a52fde77
AM
415 } else {
416 /* Previous state of this attribute was another type? Not good! */
e13bd4cd 417 throw new StateValueTypeException(getSSID() + " Quark:" + attributeQuark + ", Type:" + previousSV.getType() + ", Expected:" + Type.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
90a25ebe
AM
418 }
419
e8251298 420 if (stackDepth >= 100000) {
90a25ebe 421 /*
a0f8fb9b
FW
422 * Limit stackDepth to 100000, to avoid having Attribute Trees grow
423 * out of control due to buggy insertions
90a25ebe 424 */
e13bd4cd
PT
425 String message = " Stack limit reached, not pushing"; //$NON-NLS-1$
426 throw new AttributeNotFoundException(getSSID() + " Quark:" + attributeQuark + message); //$NON-NLS-1$
a52fde77
AM
427 }
428
429 stackDepth++;
0126a8ca 430 subAttributeQuark = getQuarkRelativeAndAdd(attributeQuark, String.valueOf(stackDepth));
a52fde77 431
5896eb76 432 modifyAttribute(t, TmfStateValue.newValueInt(stackDepth), attributeQuark);
90a25ebe 433 modifyAttribute(t, value, subAttributeQuark);
a52fde77
AM
434 }
435
8d1346f0 436 @Override
5896eb76 437 public ITmfStateValue popAttribute(long t, int attributeQuark)
a52fde77
AM
438 throws AttributeNotFoundException, TimeRangeException,
439 StateValueTypeException {
e2eac108 440 /* These are the state values of the stack-attribute itself */
e13bd4cd 441 ITmfStateValue previousSV = transState.getOngoingStateValue(attributeQuark);
a52fde77
AM
442
443 if (previousSV.isNull()) {
e2eac108
AM
444 /*
445 * Trying to pop an empty stack. This often happens at the start of
446 * traces, for example when we see a syscall_exit, without having
447 * the corresponding syscall_entry in the trace. Just ignore
448 * silently.
449 */
5896eb76 450 return null;
90a25ebe 451 }
b67a2540 452 if (previousSV.getType() != Type.INTEGER) {
a52fde77 453 /*
b67a2540
AM
454 * The existing value was not an integer (which is expected for
455 * stack tops), this doesn't look like a valid stack attribute.
a52fde77 456 */
e13bd4cd 457 throw new StateValueTypeException(getSSID() + " Quark:" + attributeQuark + ", Type:" + previousSV.getType() + ", Expected:" + Type.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
a52fde77
AM
458 }
459
0126a8ca 460 int stackDepth = previousSV.unboxInt();
90a25ebe 461
e2eac108 462 if (stackDepth <= 0) {
a52fde77 463 /* This on the other hand should not happen... */
e13bd4cd 464 throw new StateValueTypeException(getSSID() + " Quark:" + attributeQuark + ", Stack depth:" + stackDepth); //$NON-NLS-1$//$NON-NLS-2$
a52fde77
AM
465 }
466
e2eac108 467 /* The attribute should already exist at this point */
0126a8ca 468 int subAttributeQuark = getQuarkRelative(attributeQuark, String.valueOf(stackDepth));
5896eb76 469 ITmfStateValue poppedValue = queryOngoingState(subAttributeQuark);
a52fde77 470
e2eac108
AM
471 /* Update the state value of the stack-attribute */
472 ITmfStateValue nextSV;
a0f8fb9b 473 if (--stackDepth == 0) {
359eeba0 474 /* Store a null state value */
e2eac108
AM
475 nextSV = TmfStateValue.nullValue();
476 } else {
477 nextSV = TmfStateValue.newValueInt(stackDepth);
478 }
479 modifyAttribute(t, nextSV, attributeQuark);
480
481 /* Delete the sub-attribute that contained the user's state value */
a52fde77 482 removeAttribute(t, subAttributeQuark);
e2eac108 483
5896eb76 484 return poppedValue;
a52fde77
AM
485 }
486
8d1346f0 487 @Override
a52fde77
AM
488 public void removeAttribute(long t, int attributeQuark)
489 throws TimeRangeException, AttributeNotFoundException {
feea3b3c
AM
490 if (attributeQuark < 0) {
491 throw new IllegalArgumentException();
492 }
c66426fd
AM
493
494 /*
feea3b3c 495 * Nullify our children first, recursively. We pass 'false' because we
c66426fd
AM
496 * handle the recursion ourselves.
497 */
feea3b3c 498 List<Integer> childAttributes = getSubAttributes(attributeQuark, false);
0126a8ca 499 for (int childNodeQuark : childAttributes) {
feea3b3c
AM
500 if (attributeQuark == childNodeQuark) {
501 /* Something went very wrong when building out attribute tree */
502 throw new IllegalStateException();
503 }
a52fde77
AM
504 removeAttribute(t, childNodeQuark);
505 }
506 /* Nullify ourselves */
7e0b2b56 507 try {
feea3b3c 508 transState.processStateChange(t, TmfStateValue.nullValue(), attributeQuark);
7e0b2b56 509 } catch (StateValueTypeException e) {
50678114
AM
510 /*
511 * Will not happen since we're inserting null values only, but poor
512 * compiler has no way of knowing this...
7e0b2b56 513 */
cb42195c 514 throw new IllegalStateException(e);
7e0b2b56 515 }
a52fde77
AM
516 }
517
8d1346f0
AM
518 //--------------------------------------------------------------------------
519 // "Current" query/update methods
520 //--------------------------------------------------------------------------
a52fde77 521
8d1346f0 522 @Override
a52fde77
AM
523 public ITmfStateValue queryOngoingState(int attributeQuark)
524 throws AttributeNotFoundException {
525 return transState.getOngoingStateValue(attributeQuark);
526 }
527
602c0697
AM
528 @Override
529 public long getOngoingStartTime(int attribute)
530 throws AttributeNotFoundException {
531 return transState.getOngoingStartTime(attribute);
532 }
533
8d1346f0 534 @Override
a52fde77
AM
535 public void updateOngoingState(ITmfStateValue newValue, int attributeQuark)
536 throws AttributeNotFoundException {
537 transState.changeOngoingStateValue(attributeQuark, newValue);
538 }
539
66866869
AM
540 /**
541 * Modify the whole "ongoing state" (state values + start times). This can
542 * be used when "seeking" a state system to a different point in the trace
543 * (and restoring the known stateInfo at this location). Use with care!
544 *
545 * @param newStateIntervals
546 * The new List of state values to use as ongoing state info
547 */
df2597e0 548 protected void replaceOngoingState(@NonNull List<@NonNull ITmfStateInterval> newStateIntervals) {
66866869 549 transState.replaceOngoingState(newStateIntervals);
a0f8fb9b 550 }
66866869 551
8d1346f0
AM
552 //--------------------------------------------------------------------------
553 // Regular query methods (sent to the back-end)
554 //--------------------------------------------------------------------------
555
556 @Override
557 public synchronized List<ITmfStateInterval> queryFullState(long t)
96345c5a
AM
558 throws TimeRangeException, StateSystemDisposedException {
559 if (isDisposed) {
560 throw new StateSystemDisposedException();
561 }
562
e62a23a9 563 final int nbAttr = getNbAttributes();
df2597e0 564 List<@Nullable ITmfStateInterval> stateInfo = new ArrayList<>(nbAttr);
8d1346f0
AM
565
566 /* Bring the size of the array to the current number of attributes */
e62a23a9 567 for (int i = 0; i < nbAttr; i++) {
8d1346f0
AM
568 stateInfo.add(null);
569 }
570
8d1346f0
AM
571 /*
572 * If we are currently building the history, also query the "ongoing"
573 * states for stuff that might not yet be written to the history.
574 */
575 if (transState.isActive()) {
576 transState.doQuery(stateInfo, t);
577 }
578
e62a23a9
AM
579 /* Query the storage backend */
580 backend.doQuery(stateInfo, t);
581
8d1346f0
AM
582 /*
583 * We should have previously inserted an interval for every attribute.
8d1346f0 584 */
e62a23a9
AM
585 for (ITmfStateInterval interval : stateInfo) {
586 if (interval == null) {
587 throw new IllegalStateException("Incoherent interval storage"); //$NON-NLS-1$
8d1346f0
AM
588 }
589 }
590 return stateInfo;
50678114
AM
591 }
592
8d1346f0
AM
593 @Override
594 public ITmfStateInterval querySingleState(long t, int attributeQuark)
96345c5a
AM
595 throws AttributeNotFoundException, TimeRangeException,
596 StateSystemDisposedException {
597 if (isDisposed) {
598 throw new StateSystemDisposedException();
599 }
8d1346f0 600
09e6fd9b
AM
601 ITmfStateInterval ret = transState.getIntervalAt(t, attributeQuark);
602 if (ret == null) {
603 /*
604 * The transient state did not have the information, let's look into
605 * the backend next.
606 */
8d1346f0
AM
607 ret = backend.doSingularQuery(t, attributeQuark);
608 }
609
8d1346f0 610 if (ret == null) {
e62a23a9
AM
611 /*
612 * If we did our job correctly, there should be intervals for every
613 * possible attribute, over all the valid time range.
614 */
615 throw new IllegalStateException("Incoherent interval storage"); //$NON-NLS-1$
8d1346f0
AM
616 }
617 return ret;
618 }
619
8d1346f0
AM
620 //--------------------------------------------------------------------------
621 // Debug methods
622 //--------------------------------------------------------------------------
623
624 static void logMissingInterval(int attribute, long timestamp) {
bcec0116 625 Activator.getDefault().logInfo("No data found in history for attribute " + //$NON-NLS-1$
8d1346f0
AM
626 attribute + " at time " + timestamp + //$NON-NLS-1$
627 ", returning dummy interval"); //$NON-NLS-1$
a52fde77
AM
628 }
629
630 /**
631 * Print out the contents of the inner structures.
5df842b3 632 *
a52fde77
AM
633 * @param writer
634 * The PrintWriter in which to print the output
635 */
feea3b3c 636 public void debugPrint(@NonNull PrintWriter writer) {
339d27b4 637 getAttributeTree().debugPrint(writer);
a52fde77 638 transState.debugPrint(writer);
8d1346f0 639 backend.debugPrint(writer);
a52fde77
AM
640 }
641
8d1346f0 642}
This page took 0.103664 seconds and 5 git commands to generate.