From 91f44c9c9dbfa746fbe63b50c87fb8bf064d0daa Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 28 Oct 2009 13:31:06 +0100 Subject: [PATCH] GenericJMX plugin: Close and re-open the connection upon I/O-errors. --- .../org/collectd/java/GenericJMXConfConnection.java | 11 ++++++++++- .../java/org/collectd/java/GenericJMXConfMBean.java | 6 ++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bindings/java/org/collectd/java/GenericJMXConfConnection.java b/bindings/java/org/collectd/java/GenericJMXConfConnection.java index 7214fd76..ffa9ded4 100644 --- a/bindings/java/org/collectd/java/GenericJMXConfConnection.java +++ b/bindings/java/org/collectd/java/GenericJMXConfConnection.java @@ -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 () diff --git a/bindings/java/org/collectd/java/GenericJMXConfMBean.java b/bindings/java/org/collectd/java/GenericJMXConfMBean.java index 27e9e329..1587bd5f 100644 --- a/bindings/java/org/collectd/java/GenericJMXConfMBean.java +++ b/bindings/java/org/collectd/java/GenericJMXConfMBean.java @@ -170,7 +170,7 @@ class GenericJMXConfMBean return (this._name); } /* }}} */ - public void query (MBeanServerConnection conn, PluginData pd) /* {{{ */ + public int query (MBeanServerConnection conn, PluginData pd) /* {{{ */ { Set names; Iterator 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 */ } -- 2.30.2