Nir Soffer has uploaded a new change for review. Change subject: monitor: Pass change event to monitor threads ......................................................................
monitor: Pass change event to monitor threads We used to pass the DomainMonitor object to MonitorThread, so the thread can emit state change events using the domain monitor's onStageChangeEvent instance variable. This couple together the objects and make them harder to test for no benefit. Now we pass the onStateChangeEvent object to the monitor threads so they can emit events. Change-Id: I48ddc78d0e0573ecaa5c29c621c0262f5e77d8c9 Signed-off-by: Nir Soffer <nsof...@redhat.com> --- M vdsm/storage/monitor.py 1 file changed, 5 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/06/57706/1 diff --git a/vdsm/storage/monitor.py b/vdsm/storage/monitor.py index bb044e2..0415675 100644 --- a/vdsm/storage/monitor.py +++ b/vdsm/storage/monitor.py @@ -21,7 +21,6 @@ import logging import threading import time -import weakref from vdsm import concurrent from vdsm import utils @@ -122,8 +121,8 @@ return log.info("Start monitoring %s", sdUUID) - monitor = MonitorThread(weakref.proxy(self), sdUUID, hostId, - self._interval) + monitor = MonitorThread(sdUUID, hostId, self._interval, + self.onDomainStateChange) monitor.poolDomain = poolDomain monitor.start() # The domain should be added only after it succesfully started @@ -192,14 +191,14 @@ class MonitorThread(object): - def __init__(self, domainMonitor, sdUUID, hostId, interval): + def __init__(self, sdUUID, hostId, interval, changeEvent): self.thread = concurrent.thread(self._run, logger=log.name) - self.domainMonitor = domainMonitor self.stopEvent = threading.Event() self.domain = None self.sdUUID = sdUUID self.hostId = hostId self.interval = interval + self.changeEvent = changeEvent self.nextStatus = Status(actual=False) self.status = FrozenStatus(self.nextStatus) self.isIsoDomain = None @@ -302,8 +301,7 @@ log.info("Domain %s became %s", self.sdUUID, "VALID" if self.nextStatus.valid else "INVALID") try: - self.domainMonitor.onDomainStateChange.emit( - self.sdUUID, self.nextStatus.valid) + self.changeEvent.emit(self.sdUUID, self.nextStatus.valid) except: log.exception("Error notifying state change for domain %s", self.sdUUID) -- To view, visit https://gerrit.ovirt.org/57706 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I48ddc78d0e0573ecaa5c29c621c0262f5e77d8c9 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <nsof...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches