GenericJMX plugin: Close and re-open the connection upon I/O-errors.
authorFlorian Forster <octo@noris.net>
Wed, 28 Oct 2009 12:31:06 +0000 (13:31 +0100)
committerFlorian Forster <octo@noris.net>
Wed, 28 Oct 2009 12:31:06 +0000 (13:31 +0100)
bindings/java/org/collectd/java/GenericJMXConfConnection.java
bindings/java/org/collectd/java/GenericJMXConfMBean.java

index 7214fd7..ffa9ded 100644 (file)
@@ -208,7 +208,16 @@ private void connect () /* {{{ */
     pd.setPlugin ("GenericJMX");
 
     for (int i = 0; i < this._mbeans.size (); i++)
-      this._mbeans.get (i).query (this._jmx_connection, pd);
+    {
+      int status;
+
+      status = this._mbeans.get (i).query (this._jmx_connection, pd);
+      if (status != 0)
+      {
+        this._jmx_connection = null;
+        return;
+      }
+    } /* for */
   } /* }}} void query */
 
   public String toString ()
index 27e9e32..1587bd5 100644 (file)
@@ -170,7 +170,7 @@ class GenericJMXConfMBean
     return (this._name);
   } /* }}} */
 
-  public void query (MBeanServerConnection conn, PluginData pd) /* {{{ */
+  public int query (MBeanServerConnection conn, PluginData pd) /* {{{ */
   {
     Set<ObjectName> names;
     Iterator<ObjectName> iter;
@@ -182,7 +182,7 @@ class GenericJMXConfMBean
     catch (Exception e)
     {
       Collectd.logError ("GenericJMXConfMBean: queryNames failed: " + e);
-      return;
+      return (-1);
     }
 
     if (names.size () == 0)
@@ -236,6 +236,8 @@ class GenericJMXConfMBean
       for (int i = 0; i < this._values.size (); i++)
         this._values.get (i).query (conn, objName, pd_tmp);
     }
+
+    return (0);
   } /* }}} void query */
 }