Skip to content

Commit

Permalink
Merge pull request #500 from tulumvinh/3.x
Browse files Browse the repository at this point in the history
Properly set recreated jxm connection
  • Loading branch information
tulumvinh authored Jul 5, 2016
2 parents dfcea1a + 557d0db commit 12a6a2e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions priam/src/main/java/com/netflix/priam/utils/JMXNodeTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,21 @@ private static boolean testConnection()

try
{
tool.isInitialized();
MBeanServerConnection serverConn = tool.mbeanServerConn;
if (serverConn == null) {
logger.info("Test connection to remove MBean server failed as there is no connection.");
return false;
}

if ( serverConn.getMBeanCount() < 1 ) { //If C* is up, it should have at multiple MBeans registered.
logger.info("Test connection to remove MBean server failed as there is no registered MBeans.");
return false;
}
}
catch (Throwable ex)
{
SystemUtils.closeQuietly(tool);
logger.error("Exception while checking JXM connection to C*, msg: " + ex.getLocalizedMessage());
return false;
}
return true;
Expand Down Expand Up @@ -154,7 +164,6 @@ public static synchronized JMXNodeTool connect(final IConfiguration config) thro
}

private static JMXNodeTool createConnection(final IConfiguration config) throws JMXConnectionException {
JMXNodeTool jmxNodeTool = null;
// If Cassandra is started then only start the monitoring
if (!CassandraMonitor.isCassadraStarted()) {
String exceptionMsg = "Cannot perform connection to remove jmx agent as Cassandra is not yet started, check back again later";
Expand All @@ -172,7 +181,7 @@ private static JMXNodeTool createConnection(final IConfiguration config) throws

try {

jmxNodeTool = new BoundedExponentialRetryCallable<JMXNodeTool>()
tool = new BoundedExponentialRetryCallable<JMXNodeTool>()
{
@Override
public JMXNodeTool retriableCall() throws Exception
Expand Down Expand Up @@ -200,10 +209,10 @@ public JMXNodeTool retriableCall() throws Exception
Iterator<INodeToolObserver> it = observers.iterator();
while (it.hasNext()) {
INodeToolObserver observer = it.next();
observer.nodeToolHasChanged(jmxNodeTool);
observer.nodeToolHasChanged(tool);
}

return jmxNodeTool;
return tool;
}

/**
Expand Down

0 comments on commit 12a6a2e

Please sign in to comment.