}
}
}
private boolean isStorageServiceReachable() {
JMXConnector connector = null;
try {
Configuration pluginConfig = getResourceContext().getPluginConfiguration();
String url = pluginConfig.getSimpleValue("connectorAddress");
JMXServiceURL serviceURL = new JMXServiceURL(url);
connector = JMXConnectorFactory.connect(serviceURL, null);
MBeanServerConnection serverConnection = connector.getMBeanServerConnection();
ObjectName storageService = new ObjectName("org.apache.cassandra.db:type=StorageService");
// query an attribute to make sure it is in fact available
serverConnection.getAttribute(storageService, "NativeTransportRunning");
return true;
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Failed to make JMX connection to StorageService", e);
}
return false;
} finally {
if (connector != null) {
try {
connector.close();
} catch (IOException e) {
if (log.isDebugEnabled()) {
log.debug("An error occurred closing the JMX connector", e);
}
}