diff options
3 files changed, 31 insertions, 14 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateHistorySystem.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateHistorySystem.java index 3f77430564..25dd0007fb 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateHistorySystem.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateHistorySystem.java @@ -228,11 +228,20 @@ public class StateHistorySystem extends StateSystem { public List<ITmfStateInterval> queryHistoryRange(int attributeQuark, long t1, long t2) throws TimeRangeException, AttributeNotFoundException { - List<ITmfStateInterval> intervals = new ArrayList<ITmfStateInterval>(); + List<ITmfStateInterval> intervals; ITmfStateInterval currentInterval; long ts; + + if ( !(backend.checkValidTime(t1) && backend.checkValidTime(t2)) ) { + /* + * One of the two timestamps is out of range, don't bother + * with the requests + */ + throw new TimeRangeException(); + } /* Get the initial state at time T1 */ + intervals = new ArrayList<ITmfStateInterval>(); currentInterval = querySingleState(t1, attributeQuark); intervals.add(currentInterval); diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/backend/historytree/HistoryTreeBackend.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/backend/historytree/HistoryTreeBackend.java index dab8018dd1..2469b3c190 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/backend/historytree/HistoryTreeBackend.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/backend/historytree/HistoryTreeBackend.java @@ -80,8 +80,11 @@ public class HistoryTreeBackend implements IStateHistoryBackend { /** * Existing history constructor. Use this to open an existing state-file. * - * @param existingFileName Filename/location of the history we want to load - * @throws IOException If we can't read the file, if it doesn't exist or is not recognized + * @param existingFileName + * Filename/location of the history we want to load + * @throws IOException + * If we can't read the file, if it doesn't exist or is not + * recognized */ public HistoryTreeBackend(File existingStateFile) throws IOException { sht = new HistoryTree(existingStateFile); @@ -161,15 +164,8 @@ public class HistoryTreeBackend implements IStateHistoryBackend { return getRelevantInterval(t, attributeQuark); } - /** - * Simple check to make sure the requested timestamps are within the borders - * of this tree. - * - * @param t - * The queried timestamp - * @return True if it's within range, false if not. - */ - private boolean checkValidTime(long t) { + @Override + public boolean checkValidTime(long t) { return (t >= sht.getTreeStart() && t <= sht.getTreeEnd()); } @@ -249,8 +245,8 @@ public class HistoryTreeBackend implements IStateHistoryBackend { } /** - * The basic debugPrint method will print the tree structure, but not - * their contents. + * The basic debugPrint method will print the tree structure, but not their + * contents. * * This method here print the contents (the intervals) as well. * diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/helpers/IStateHistoryBackend.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/helpers/IStateHistoryBackend.java index 26d3263783..1d7a163ecf 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/helpers/IStateHistoryBackend.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/helpers/IStateHistoryBackend.java @@ -138,6 +138,18 @@ public interface IStateHistoryBackend { */ public ITmfStateInterval doSingularQuery(long t, int attributeQuark) throws TimeRangeException, AttributeNotFoundException; + + /** + * Simple check to make sure the requested timestamps are within the borders + * of this state history. This is used internally, but could also be used + * by the request sender (to check before sending in a lot of requests for + * example). + * + * @param t + * The queried timestamp + * @return True if the timestamp is within range, false if not. + */ + public boolean checkValidTime(long t); /** * Debug method to print the contents of the history backend. |