Example #1
0
    def __init__(self, *args, **kwargs):
        self.call = None

        self.node_updater = NodeCacheUpdater()
        self.cluster_updater = ClusterCacheUpdater()
        self.vm_updater = VirtualMachineCacheUpdater()
        self.job_updater = JobCacheUpdater()
Example #2
0
class CacheService(Service):
    def __init__(self, *args, **kwargs):
        self.call = None

        self.node_updater = NodeCacheUpdater()
        self.cluster_updater = ClusterCacheUpdater()
        self.vm_updater = VirtualMachineCacheUpdater()
        self.job_updater = JobCacheUpdater()

    def update_cache(self):
        """ a single run of all update classes """
        return DeferredList(
            [
                self.vm_updater.update(),
                self.job_updater.update(),
                self.node_updater.update(),
                self.cluster_updater.update(),
            ]
        )

    def startService(self):
        self.call = LoopingCall(self.update_cache)
        self.call.start(settings.PERIODIC_CACHE_REFRESH)

    def stopService(self):
        if self.call is not None:
            self.call.stop()