summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAlexandre Montplaisir2012-03-17 22:11:58 (EDT)
committer Francois Chouinard2012-03-19 17:44:06 (EDT)
commit9c24c5ec351978e1ff45213a13a1594c877aff31 (patch)
tree16c2f17fe296e4ab881689dbef56f51a930d54ad
parent563ee6fb6dc7e992a39f78d077edbf7ab4c0b555 (diff)
downloadorg.eclipse.linuxtools-9c24c5ec351978e1ff45213a13a1594c877aff31.zip
org.eclipse.linuxtools-9c24c5ec351978e1ff45213a13a1594c877aff31.tar.gz
org.eclipse.linuxtools-9c24c5ec351978e1ff45213a13a1594c877aff31.tar.bz2
GSS: Avoid doing time-range requests if one of the timestamps is invalid
Thanks to the unit-test benchmarking for letting me know of this problem... Also exposed checkValidTime() through the IHistoryBackend interface, this can be useful, as we see here.
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateHistorySystem.java11
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/backend/historytree/HistoryTreeBackend.java22
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/helpers/IStateHistoryBackend.java12
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 3f77430..25dd000 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 dab8018..2469b3c 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 26d3263..1d7a163 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.