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

Method main

src/tools/CliQuery.java:59–103  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

57 }
58
59 public static void main(String[] args) throws Exception {
60 ArgP argp = new ArgP();
61 CliOptions.addCommon(argp);
62 CliOptions.addVerbose(argp);
63 argp.addOption("--graph", "BASEPATH",
64 "Output data points to a set of files for gnuplot."
65 + " The path of the output files will start with"
66 + " BASEPATH.");
67 args = CliOptions.parse(argp, args);
68 if (args == null) {
69 usage(argp, "Invalid usage.", 1);
70 } else if (args.length < 3) {
71 usage(argp, "Not enough arguments.", 2);
72 }
73
74 // get a config object
75 Config config = CliOptions.getConfig(argp);
76
77 final TSDB tsdb = new TSDB(config);
78 tsdb.checkNecessaryTablesExist().joinUninterruptibly();
79 final String basepath = argp.get("--graph");
80 argp = null;
81
82 Plot plot = null;
83 try {
84 plot = doQuery(tsdb, args, basepath != null);
85 } finally {
86 try {
87 tsdb.shutdown().joinUninterruptibly();
88 } catch (Exception e) {
89 LOG.error("Unexpected exception", e);
90 System.exit(1);
91 }
92 }
93
94 if (plot != null) {
95 try {
96 final int npoints = plot.dumpToFiles(basepath);
97 LOG.info("Wrote " + npoints + " for Gnuplot");
98 } catch (IOException e) {
99 LOG.error("Failed to write the Gnuplot file under " + basepath, e);
100 System.exit(1);
101 }
102 }
103 }
104
105 private static Plot doQuery(final TSDB tsdb,
106 final String args[],

Callers

nothing calls this directly

Calls 12

addCommonMethod · 0.95
addVerboseMethod · 0.95
addOptionMethod · 0.95
parseMethod · 0.95
usageMethod · 0.95
getConfigMethod · 0.95
getMethod · 0.95
doQueryMethod · 0.95
shutdownMethod · 0.95
dumpToFilesMethod · 0.95
errorMethod · 0.80

Tested by

no test coverage detected