summaryrefslogtreecommitdiffstats
path: root/vespaclient-java/src/main/java/com/yahoo/vespastat/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'vespaclient-java/src/main/java/com/yahoo/vespastat/Main.java')
-rw-r--r--vespaclient-java/src/main/java/com/yahoo/vespastat/Main.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/vespaclient-java/src/main/java/com/yahoo/vespastat/Main.java b/vespaclient-java/src/main/java/com/yahoo/vespastat/Main.java
new file mode 100644
index 00000000000..9d87a6f68f4
--- /dev/null
+++ b/vespaclient-java/src/main/java/com/yahoo/vespastat/Main.java
@@ -0,0 +1,38 @@
+// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespastat;
+
+/**
+ * Main application class
+ *
+ * @author bjorncs
+ */
+public class Main {
+
+ private Main() {
+ }
+
+ public static void main(String[] args) {
+ CommandLineOptions options = new CommandLineOptions();
+ try {
+ ClientParameters params = options.parseCommandLineArguments(args);
+ if (params.help) {
+ options.printHelp();
+ return;
+ }
+ BucketStatsRetriever retriever = new BucketStatsRetriever(
+ new DocumentAccessFactory(),
+ params.route,
+ createShutdownHookRegistrar());
+ BucketStatsPrinter printer = new BucketStatsPrinter(retriever, System.out);
+ printer.retrieveAndPrintBucketStats(params.selectionType, params.id, params.dumpData);
+ } catch (IllegalArgumentException e) {
+ System.err.printf("Failed to parse command line arguments: %s.\n", e.getMessage());
+ } catch (BucketStatsException e) {
+ System.err.println(e.getMessage());
+ }
+ }
+
+ private static BucketStatsRetriever.ShutdownHookRegistrar createShutdownHookRegistrar() {
+ return runnable -> Runtime.getRuntime().addShutdownHook(new Thread(runnable));
+ }
+}