def _update_cache_groups(self): new_groups = {} for group in storage.groups: if (group.type != storage.Group.TYPE_CACHE or group.status != storage.Status.COUPLED): continue new_groups[group] = group new_cache_groups = {} for group in new_groups: cache_group = CacheGroup(group) new_cache_groups[cache_group] = cache_group new_groups_units = infrastructure.groups_units(new_groups.keys(), self.node_types) new_executing_tasks = cache_task_manager.list() for task in new_executing_tasks: group_id = task['group'] if group_id not in new_cache_groups: logger.warn('Task destination group {0} is not found among ' 'good cache groups'.format(group_id)) continue cache_group = new_cache_groups[group_id] cache_group.account_task(task) # DEBUG for cg in new_cache_groups.itervalues(): logger.debug( 'Cache group {0}: fes {1} ({2} - {3} - {4})'.format( cg, cg.effective_free_space, cg.group.node_backends[0].effective_space, cg.stat.used_space, cg.reserved_space)) # DEBUG END with self._cache_groups_lock: self.cache_groups = new_cache_groups self.groups_units = new_groups_units self.executing_tasks = new_executing_tasks
def group_units(self): return infrastructure.groups_units( [cg.group for cg in self.candidates] + [storage.groups[self.src_group_id]], self.node_types)