modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java | 17 ++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
New commits: commit 73a6f01b2d56f4e30e3423f42193b7fd9956bae3 Author: Stefan Negrea snegrea@redhat.com Date: Thu Aug 22 11:54:52 2013 -0500
Shutdown the cluster manager if the session connection fails; otherwise various mananger specific connections could remain open.
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java index d648ad8..09cc77e 100644 --- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java +++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java @@ -108,6 +108,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent }
+ Cluster cluster = null; try { Builder clusterBuilder = Cluster .builder() @@ -119,9 +120,21 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent clusterBuilder = clusterBuilder.withCredentials(username, password); }
- this.cassandraSession = clusterBuilder.build().connect(clusterName); + cluster = clusterBuilder.build(); + + this.cassandraSession = cluster.connect(clusterName); } catch (Exception e) { - LOG.error("Connect to Cassandra " + host + ":" + nativePort, e); + LOG.error("Connecting to Cassandra " + host + ":" + nativePort + + " failed. Attempting to shutdown the cluster manager and all the connections.", e); + + try { + if (cluster != null) { + cluster.shutdown(); + } + } catch (Exception shutdownException) { + LOG.error("Failed attempt to shutdown the cluster manager.", shutdownException); + } + throw e; } };
rhq-commits@lists.fedorahosted.org