Merge "Fix Cassandra cluster restart"
This commit is contained in:
commit
012da9a334
@ -766,8 +766,8 @@ class CassandraAppStatus(service.BaseDbStatus):
|
|||||||
|
|
||||||
def _get_actual_db_status(self):
|
def _get_actual_db_status(self):
|
||||||
try:
|
try:
|
||||||
self.client.execute('SELECT now() FROM system.local;')
|
if self.client.local_node_is_up():
|
||||||
return rd_instance.ServiceStatuses.RUNNING
|
return rd_instance.ServiceStatuses.RUNNING
|
||||||
except NoHostAvailable:
|
except NoHostAvailable:
|
||||||
return rd_instance.ServiceStatuses.SHUTDOWN
|
return rd_instance.ServiceStatuses.SHUTDOWN
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -1238,6 +1238,20 @@ class CassandraConnection(object):
|
|||||||
return query.format(*identifiers)
|
return query.format(*identifiers)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
def node_is_up(self, host_ip):
|
||||||
|
"""Test whether the Cassandra node located at the given IP is up.
|
||||||
|
"""
|
||||||
|
for host in self._cluster.metadata.all_hosts():
|
||||||
|
if host.address == host_ip:
|
||||||
|
return host.is_up
|
||||||
|
return False
|
||||||
|
|
||||||
|
def local_node_is_up(self):
|
||||||
|
"""Test whether Cassandra is up on the localhost.
|
||||||
|
"""
|
||||||
|
return (self.node_is_up('127.0.0.1') or
|
||||||
|
self.node_is_up(netutils.get_my_ipv4()))
|
||||||
|
|
||||||
def _connect(self):
|
def _connect(self):
|
||||||
if not self._cluster.is_shutdown:
|
if not self._cluster.is_shutdown:
|
||||||
LOG.debug("Connecting to a Cassandra cluster as '%s'."
|
LOG.debug("Connecting to a Cassandra cluster as '%s'."
|
||||||
|
Loading…
Reference in New Issue
Block a user