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

Method updateFromQueryString

src/tsd/client/MetricForm.java:222–292  ·  view source on GitHub ↗
(final String m, final String o)

Source from the content-addressed store, hash-verified

220 }
221
222 public void updateFromQueryString(final String m, final String o) {
223 // TODO: Try to reduce code duplication with GraphHandler.parseQuery().
224 // m is of the following forms:
225 // agg:[interval-agg:][rate[{counter[,max[,reset]]}:]metric[{tag=value,...}]
226 // Where the parts in square brackets `[' .. `]' are optional.
227 final String[] parts = m.split(":");
228 int i = parts.length;
229 if (i < 2 || i > 4) {
230 return; // Malformed.
231 }
232
233 setSelectedItem(aggregators, parts[0]);
234
235 i--; // Move to the last part (the metric name).
236 metric.setText(parseWithMetric(parts[i]));
237 metric_change_handler.onMetricChange(this);
238
239 final boolean rate = parts[--i].startsWith("rate");
240 this.rate.setValue(rate, false);
241 LocalRateOptions rate_options = parseRateOptions(rate, parts[i]);
242 this.rate_counter.setValue(rate_options.is_counter, false);
243 final long rate_counter_max = rate_options.counter_max;
244 this.counter_max.setValue(
245 rate_counter_max == Long.MAX_VALUE ? "" : Long.toString(rate_counter_max),
246 false);
247 this.counter_reset_value
248 .setValue(Long.toString(rate_options.reset_value), false);
249 if (rate) {
250 i--;
251 }
252
253 // downsampling function & interval.
254 if (i > 0) {
255 // First dash should have been given.
256 final int first_dash = parts[1].indexOf('-', 1); // 1st char can't be `-'.
257 if (first_dash < 0) {
258 disableDownsample();
259 return; // Invalid downsampling specifier.
260 }
261
262 // Second dash (and subsequent fill policy) are optional.
263 final int second_dash = parts[1].indexOf('-', first_dash + 1);
264
265 downsample.setValue(true, false);
266
267 downsampler.setEnabled(true);
268 fill_policy.setEnabled(true);
269 if (-1 == second_dash) {
270 // No fill policy given.
271 setSelectedItem(downsampler, parts[1].substring(first_dash + 1));
272
273 // So use a default.
274 // TODO: don't assume this exists.
275 setSelectedItem(fill_policy, "lerp");
276 } else {
277 // User specified fill policy.
278 setSelectedItem(downsampler, parts[1].substring(first_dash + 1,
279 second_dash));

Callers 1

Calls 10

setSelectedItemMethod · 0.95
parseWithMetricMethod · 0.95
parseRateOptionsMethod · 0.95
disableDownsampleMethod · 0.95
setEnabledMethod · 0.80
containsMethod · 0.80
onMetricChangeMethod · 0.65
splitMethod · 0.45
setValueMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected