Optimize the flow of getting pollster resources

No need to call pollster's default discovery to get the resources if the
pipeline has already provided them.

Change-Id: Ib8959498b9dfd848087484d3348578733b790c29
Closes-Bug: #1437175
This commit is contained in:
Lianhao Lu 2015-03-27 15:07:02 +08:00
parent e14a4edc81
commit 9efa08d4a3

View File

@ -130,15 +130,12 @@ class PollingTask(object):
LOG.info(_("Polling pollster %(poll)s in the context of "
"%(src)s"),
dict(poll=pollster.name, src=source_name))
pollster_resources = []
if pollster.obj.default_discovery:
pollster_resources = self.manager.discover(
[pollster.obj.default_discovery], discovery_cache)
key = Resources.key(source_name, pollster)
source_resources = list(
candidate_res = list(
self.resources[key].get(discovery_cache))
candidate_res = (source_resources or
pollster_resources)
if not candidate_res and pollster.obj.default_discovery:
candidate_res = self.manager.discover(
[pollster.obj.default_discovery], discovery_cache)
# Remove duplicated resources and black resources. Using
# set() requires well defined __hash__ for each resource.