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);
/**
* 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);
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());
}
}
/**
- * 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.
*
*/
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.