MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / validateAndSetQuery

Method validateAndSetQuery

src/core/TSSubQuery.java:212–244  ·  view source on GitHub ↗

Runs through query parameters to make sure it's a valid request. This includes parsing the aggregator, downsampling info, metrics, tags or timeseries and setting the local parsed fields needed by the TSD for proper execution. If no exceptions are thrown, the query is considered valid. Note: Y

()

Source from the content-addressed store, hash-verified

210 * @throws IllegalArgumentException if something is wrong with the query
211 */
212 public void validateAndSetQuery() {
213 if (aggregator == null || aggregator.isEmpty()) {
214 throw new IllegalArgumentException("Missing the aggregation function");
215 }
216 try {
217 agg = Aggregators.get(aggregator);
218 } catch (NoSuchElementException nse) {
219 throw new IllegalArgumentException(
220 "No such aggregation function: " + aggregator);
221 }
222
223 // we must have at least one TSUID OR a metric
224 if ((tsuids == null || tsuids.isEmpty()) &&
225 (metric == null || metric.isEmpty())) {
226 throw new IllegalArgumentException(
227 "Missing the metric or tsuids, provide at least one");
228 }
229
230 // Make sure we have a filter list
231 if (filters == null) {
232 filters = new ArrayList<TagVFilter>();
233 }
234
235 // parse the downsampler if we have one
236 if (downsample != null && !downsample.isEmpty()) {
237 // downsampler given, so parse it
238 downsample_specifier = new DownsamplingSpecification(downsample);
239 } else {
240 // no downsampler
241 downsample_specifier = DownsamplingSpecification.NO_DOWNSAMPLER;
242 }
243 checkHistogramQuery();
244 }
245
246 /**
247 * Make sure the parameters for histogram query are valid.

Callers 15

validateMethod · 0.95
validateTSMethod · 0.95
validateNoDSMethod · 0.95
validateNullAggMethod · 0.95
validateEmptyAggMethod · 0.95
validateBadAggMethod · 0.95
validateBadDSMethod · 0.95
validateWithFilterMethod · 0.95

Calls 3

getMethod · 0.95
checkHistogramQueryMethod · 0.95
isEmptyMethod · 0.80

Tested by 15

validateMethod · 0.76
validateTSMethod · 0.76
validateNoDSMethod · 0.76
validateNullAggMethod · 0.76
validateEmptyAggMethod · 0.76
validateBadAggMethod · 0.76
validateBadDSMethod · 0.76
validateWithFilterMethod · 0.76