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

Method parseCommandLineQuery

src/tools/CliQuery.java:162–247  ·  view source on GitHub ↗

Parses the query from the command lines. @param args The command line arguments. @param tsdb The TSDB to use. @param queries The list in which Querys will be appended. @param plotparams The list in which global plot parameters will be appended. Ignored if null. @param plotoptions Th

(final String[] args,
                                    final TSDB tsdb,
                                    final ArrayList<Query> queries,
                                    final ArrayList<String> plotparams,
                                    final ArrayList<String> plotoptions)

Source from the content-addressed store, hash-verified

160 * appended. Ignored if {@code null}.
161 */
162 static void parseCommandLineQuery(final String[] args,
163 final TSDB tsdb,
164 final ArrayList<Query> queries,
165 final ArrayList<String> plotparams,
166 final ArrayList<String> plotoptions) {
167 long start_ts = DateTime.parseDateTimeString(args[0], null);
168 if (start_ts >= 0)
169 start_ts /= 1000;
170 long end_ts = -1;
171 if (args.length > 3){
172 // see if we can detect an end time
173 try{
174 if (args[1].charAt(0) != '+'
175 && (args[1].indexOf(':') >= 0
176 || args[1].indexOf('/') >= 0
177 || args[1].indexOf('-') >= 0
178 || Long.parseLong(args[1]) > 0)){
179 end_ts = DateTime.parseDateTimeString(args[1], null);
180 }
181 }catch (NumberFormatException nfe) {
182 // ignore it as it means the third parameter is likely the aggregator
183 }
184 }
185 // temp fixup to seconds from ms until the rest of TSDB supports ms
186 // Note you can't append this to the DateTime.parseDateTimeString() call as
187 // it clobbers -1 results
188 if (end_ts >= 0)
189 end_ts /= 1000;
190
191 int i = end_ts < 0 ? 1 : 2;
192 while (i < args.length && args[i].charAt(0) == '+') {
193 if (plotparams != null) {
194 plotparams.add(args[i]);
195 }
196 i++;
197 }
198
199 while (i < args.length) {
200 final Aggregator agg = Aggregators.get(args[i++]);
201 final boolean rate = args[i].equals("rate");
202 RateOptions rate_options = new RateOptions(false, Long.MAX_VALUE,
203 RateOptions.DEFAULT_RESET_VALUE);
204 if (rate) {
205 i++;
206
207 long counterMax = Long.MAX_VALUE;
208 long resetValue = RateOptions.DEFAULT_RESET_VALUE;
209 if (args[i].startsWith("counter")) {
210 String[] parts = Tags.splitString(args[i], ',');
211 if (parts.length >= 2 && parts[1].length() > 0) {
212 counterMax = Long.parseLong(parts[1]);
213 }
214 if (parts.length >= 3 && parts[2].length() > 0) {
215 resetValue = Long.parseLong(parts[2]);
216 }
217 rate_options = new RateOptions(true, counterMax, resetValue);
218 i++;
219 }

Callers 4

runQueryMethod · 0.95
mainMethod · 0.95
doDumpMethod · 0.95
doQueryMethod · 0.95

Calls 12

parseDateTimeStringMethod · 0.95
getMethod · 0.95
splitStringMethod · 0.95
parseMethod · 0.95
setStartTimeMethod · 0.95
setEndTimeMethod · 0.95
setTimeSeriesMethod · 0.95
downsampleMethod · 0.95
parseLongMethod · 0.80
newQueryMethod · 0.80
addMethod · 0.45
equalsMethod · 0.45

Tested by 1

runQueryMethod · 0.76