Permalink
Browse files

added contents of static root to project and implemented &exact http

query parameter such that only data in between start and end is returned
  • Loading branch information...
1 parent b82c8d2 commit dc91c5fe3c102399e0fe0b75d7067351a81811c3 Mick Hittesdorf committed Jun 28, 2012
@@ -103,5 +103,13 @@ void setTimeSeries(String metric, Map<String, String> tags,
* perform the search.
*/
DataPoints[] run() throws HBaseException;
-
+
+ /**
+ * Sets flag that determines whether or not the time series interval should be expanded before
+ * after specified start and end times. Default is to extend the series to allow GnuPlot to
+ * render time series correctly at the edges.
+ * @param exact Whether to query the database and return just the points between start and end or not
+ *
+ */
+ public void setExact(boolean exact);
}
@@ -110,6 +110,9 @@
/** Minimum time interval (in seconds) wanted between each data point. */
private int sample_interval;
+
+ /** If true then don't extend range of time series beyond that specified in query **/
+ private boolean exact = false;
/** Constructor. */
public TsdbQuery(final TSDB tsdb) {
@@ -162,6 +165,10 @@ public void setTimeSeries(final String metric,
aggregator = function;
this.rate = rate;
}
+
+ public void setExact(boolean exact) {
+ this.exact = exact;
+ }
public void downsample(final int interval, final Aggregator downsampler) {
if (downsampler == null) {
@@ -372,10 +379,10 @@ Scanner getScanner() throws HBaseException {
// rely on having a few extra data points before & after the exact start
// & end dates in order to do proper rate calculation or downsampling near
// the "edges" of the graph.
- Bytes.setInt(start_row, (int) (getScanStartTime()/1000), metric_width);
+ Bytes.setInt(start_row, (int) (getScanStartTime()/1000 - Const.MAX_TIMESPAN/1000), metric_width);
Bytes.setInt(end_row, (end_time == UNSET
? -1 // Will scan until the end (0xFFF...).
- : (int) (getScanEndTime()/1000)),
+ : (int) (getScanEndTime()/1000 + (Const.MAX_TIMESPAN+1000)/1000)),
metric_width);
System.arraycopy(metric, 0, start_row, 0, metric_width);
System.arraycopy(metric, 0, end_row, 0, metric_width);
@@ -404,7 +411,7 @@ private long getScanStartTime() {
// but this doesn't really matter.
// Additionally, in case our sample_interval is large, we need to look
// even further before/after, so use that too.
- final long ts = getStartTime() - (Const.MAX_TIMESPAN * 2 - sample_interval*1000);
+ final long ts = (!exact ? (getStartTime() - (Const.MAX_TIMESPAN * 2 - sample_interval*1000)) : getStartTime());
return ts > 0 ? ts : 0;
}
@@ -418,7 +425,7 @@ private long getScanEndTime() {
// again that doesn't really matter.
// Additionally, in case our sample_interval is large, we need to look
// even further before/after, so use that too.
- return getEndTime() + (Const.MAX_TIMESPAN + 1000) + sample_interval*1000;
+ return (!exact ? (getEndTime() + (Const.MAX_TIMESPAN + 1000) + sample_interval*1000) : getEndTime()+1000);
}
/**
@@ -849,6 +849,12 @@ private static void respondAsciiQuery(final HttpQuery query,
final Query tsdbquery = tsdb.newQuery();
try {
tsdbquery.setTimeSeries(metric, parsedtags, agg, rate);
+ final List<String> exact = query.getQueryStringParams("exact");
+ if (exact != null) {
+ tsdbquery.setExact(true);
+ } else {
+ tsdbquery.setExact(false);
+ }
} catch (NoSuchUniqueName e) {
throw new BadRequestException(e.getMessage());
}
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Oops, something went wrong.

0 comments on commit dc91c5f

Please sign in to comment.