'Polling sample and notify.'

def poll_and_notify(self):

    cache = {}
    discovery_cache = {}
    poll_history = {}
    for source_name in self.pollster_matches:
        for pollster in self.pollster_matches[source_name]:
            key = Resources.key(source_name, pollster)
            candidate_res = list(self.resources[key].get(discovery_cache))
            if ((not candidate_res) and pollster.obj.default_discovery):
                candidate_res = self.manager.discover([pollster.obj.default_discovery], discovery_cache)
            polling_resources = []
            black_res = self.resources[key].blacklist
            history = poll_history.get(pollster.name, [])
            for x in candidate_res:
                if (x not in history):
                    history.append(x)
                    if (x not in black_res):
                        polling_resources.append(x)
            poll_history[pollster.name] = history
            if (not polling_resources):
                p_context = ('new    ' if history else '')
                LOG.info('Skip    pollster    %(name)s,    no    %(p_context)sresources    found    this    cycle', {'name': pollster.name, 'p_context': p_context})
                continue
            LOG.info('Polling    pollster    %(poll)s    in    the    context    of    %(src)s', dict(poll=pollster.name, src=source_name))
            try:
                polling_timestamp = timeutils.utcnow().isoformat()
                samples = pollster.obj.get_samples(manager=self.manager, cache=cache, resources=polling_resources)
                sample_batch = []
                for sample in samples:
                    sample.set_timestamp(polling_timestamp)
                    sample_dict = publisher_utils.meter_message_from_counter(sample, self._telemetry_secret)
                    if self._batch:
                        sample_batch.append(sample_dict)
                    else:
                        self._send_notification([sample_dict])
                if sample_batch:
                    self._send_notification(sample_batch)
            except plugin_base.PollsterPermanentError as err:
                LOG.error('Prevent    pollster    %(name)s    from    polling    %(res_list)s    on    source    %(source)s    anymore!', dict(name=pollster.name, res_list=str(err.fail_res_list), source=source_name))
                self.resources[key].blacklist.extend(err.fail_res_list)
            except Exception as err:
                LOG.error(('Continue    after    error    from    %(name)s:    %(error)s' % {'name': pollster.name, 'error': err}), exc_info=True)
