gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r14825 - gauger


From: gnunet
Subject: [GNUnet-SVN] r14825 - gauger
Date: Fri, 1 Apr 2011 17:56:44 +0200

Author: bartpolot
Date: 2011-04-01 17:56:44 +0200 (Fri, 01 Apr 2011)
New Revision: 14825

Added:
   gauger/Gauger.java
Log:
Added java binding for gauger


Added: gauger/Gauger.java
===================================================================
--- gauger/Gauger.java                          (rev 0)
+++ gauger/Gauger.java  2011-04-01 15:56:44 UTC (rev 14825)
@@ -0,0 +1,77 @@
+package org.gnunet.gauger;
+
+import java.io.IOException;
+
+/**
+ * Gauger binding for Java.
+ *
+ * @author Christian Grothoff
+ */
+public class Gauger {
+
+    /**
+    * Submit a value to the gauger server.
+    *
+    * @param component name of the subsystem
+    * @param name description for the value
+    * @param value numeric value
+    * @param unit unit for the value
+    */
+    public static void gauger (String component,
+                                String name,
+                                long value,
+                                String unit)
+    {
+        gauger (component, name, value, unit, -1);
+    }
+
+    /**
+    * Submit a value to the gauger server.
+    *
+    * @param component name of the subsystem
+    * @param name description for the value
+    * @param value numeric value
+    * @param unit unit for the value
+    * @param revision revision number to use
+    */
+    public static void gauger (String component,
+                               String name,
+                               long value,
+                               String unit,
+                               int revision)
+    {
+        Runtime rt = Runtime.getRuntime();
+        try
+        {
+            String[] cmds = (revision == -1) ?
+                new String[] {
+                "gauger-cli.py",
+                "-s",
+                "" + value,
+                "-u",
+                unit,
+                "-c",
+                component,
+                "-n",
+                name,
+            } :
+            new String[] {
+                "gauger-cli.py",
+                "-s",
+                "" + value,
+                "-u",
+                unit,
+                "-c",
+                component,
+                "-n",
+                name,
+                "-r",
+                "" + revision
+            };
+            rt.exec(cmds, null);
+        } catch (IOException io) {
+            // ignore errors
+        }
+    }
+
+}
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]