Use try when watching health value in NodeInstance
This commit is contained in:
parent
0b583bfdaf
commit
2c3a3cdf52
|
@ -225,27 +225,32 @@ class NodeInstance(object):
|
||||||
)
|
)
|
||||||
self.flush_thread.start()
|
self.flush_thread.start()
|
||||||
|
|
||||||
@self.zkhandler.zk_conn.DataWatch(
|
try:
|
||||||
self.zkhandler.schema.path("node.monitoring.health", self.name)
|
|
||||||
)
|
|
||||||
def watch_node_health(data, stat, event=""):
|
|
||||||
if event and event.type == "DELETED":
|
|
||||||
# The key has been deleted after existing before; terminate this watcher
|
|
||||||
# because this class instance is about to be reaped in Daemon.py
|
|
||||||
return False
|
|
||||||
|
|
||||||
try:
|
@self.zkhandler.zk_conn.DataWatch(
|
||||||
data = data.decode("ascii")
|
self.zkhandler.schema.path("node.monitoring.health", self.name)
|
||||||
except AttributeError:
|
)
|
||||||
data = 100
|
def watch_node_health(data, stat, event=""):
|
||||||
|
if event and event.type == "DELETED":
|
||||||
|
# The key has been deleted after existing before; terminate this watcher
|
||||||
|
# because this class instance is about to be reaped in Daemon.py
|
||||||
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = int(data)
|
data = data.decode("ascii")
|
||||||
except ValueError:
|
except AttributeError:
|
||||||
pass
|
data = 100
|
||||||
|
|
||||||
if data != self.health:
|
try:
|
||||||
self.health = data
|
data = int(data)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if data != self.health:
|
||||||
|
self.health = data
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
@self.zkhandler.zk_conn.DataWatch(
|
@self.zkhandler.zk_conn.DataWatch(
|
||||||
self.zkhandler.schema.path("node.memory.free", self.name)
|
self.zkhandler.schema.path("node.memory.free", self.name)
|
||||||
|
|
Loading…
Reference in New Issue