Search in sources :

Example 1 with StatsCollector

use of net.opentsdb.stats.StatsCollector in project opentsdb by OpenTSDB.

the class TextImporter method main.

public static void main(String[] args) throws Exception {
    ArgP argp = new ArgP();
    CliOptions.addCommon(argp);
    CliOptions.addAutoMetricFlag(argp);
    argp.addOption("--skip-errors", "Whether or not to skip exceptions " + "during processing");
    args = CliOptions.parse(argp, args);
    if (args == null) {
        usage(argp, 1);
    } else if (args.length < 1) {
        usage(argp, 2);
    }
    // get a config object
    Config config = CliOptions.getConfig(argp);
    final TSDB tsdb = new TSDB(config);
    final boolean skip_errors = argp.has("--skip-errors");
    tsdb.checkNecessaryTablesExist().joinUninterruptibly();
    argp = null;
    try {
        int points = 0;
        final long start_time = System.nanoTime();
        for (final String path : args) {
            points += importFile(tsdb.getClient(), tsdb, path, skip_errors);
        }
        final double time_delta = (System.nanoTime() - start_time) / 1000000000.0;
        LOG.info(String.format("Total: imported %d data points in %.3fs" + " (%.1f points/s)", points, time_delta, (points / time_delta)));
        // TODO(tsuna): Figure out something better than just writing to stderr.
        tsdb.collectStats(new StatsCollector("tsd") {

            @Override
            public final void emit(final String line) {
                System.err.print(line);
            }
        });
    } finally {
        try {
            tsdb.shutdown().joinUninterruptibly();
        } catch (Exception e) {
            LOG.error("Unexpected exception", e);
            System.exit(1);
        }
    }
}
Also used : StatsCollector(net.opentsdb.stats.StatsCollector) Config(net.opentsdb.utils.Config) TSDB(net.opentsdb.core.TSDB) PleaseThrottleException(org.hbase.async.PleaseThrottleException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 TSDB (net.opentsdb.core.TSDB)1 StatsCollector (net.opentsdb.stats.StatsCollector)1 Config (net.opentsdb.utils.Config)1 PleaseThrottleException (org.hbase.async.PleaseThrottleException)1