(String[] args)
| 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[], |
nothing calls this directly
no test coverage detected