5b9e5d8e7a
This makes the polling agents not use pipelines. Instead it simply sends notifications for the notification agent to pick up and transform if the pipeline.yaml says it should. Inside the AgentManager and the PollingTask the data representation is adjusted somewhat. Rather than making a single task for any given interval, we make a single task for any name in the "sources" list. This ought to mean (given that the interval is the same across various sources in the default config) that we will get some I/Ox interleaving. At the moment all samples gathered by one pollng task are sent as an individual notification. This is being done to minimize the apparent surface area of this change. The expected long term change is for single samples to be sent so as to increase granularity and I/O interleaving. The unit tests have been updated to reflect the new data representation. The agent tests are fairly strongly oriented towards testing that discovery and resource handling behave correctly. Some additions have been made to make sure that samples traverse a fake messaging bus as expected. Coverage of the ceilometer/agent/base has increased from 98 to 99%. Additional functional testing should be implemented when we have established the infrastructure for such things. Implements blueprint pollsters-no-transform DocImpact Change-Id: I25c22077e80509799713571dfd79c87fe21c8677
76 lines
2.7 KiB
Python
76 lines
2.7 KiB
Python
#
|
|
# Copyright 2015 Hewlett Packard
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import abc
|
|
|
|
from oslo_config import cfg
|
|
from oslo_log import log
|
|
from oslo_service import service as os_service
|
|
import six
|
|
|
|
from ceilometer.i18n import _, _LE, _LI
|
|
from ceilometer import pipeline
|
|
|
|
LOG = log.getLogger(__name__)
|
|
|
|
|
|
@six.add_metaclass(abc.ABCMeta)
|
|
class BaseService(os_service.Service):
|
|
|
|
def init_pipeline_refresh(self):
|
|
if cfg.CONF.refresh_pipeline_cfg:
|
|
|
|
self.pipeline_mtime = pipeline.get_pipeline_mtime()
|
|
self.pipeline_hash = pipeline.get_pipeline_hash()
|
|
|
|
self.tg.add_timer(cfg.CONF.pipeline_polling_interval,
|
|
self.refresh_pipeline)
|
|
|
|
@abc.abstractmethod
|
|
def reload_pipeline(self):
|
|
"""Reload pipeline in the agents."""
|
|
|
|
def refresh_pipeline(self):
|
|
mtime = pipeline.get_pipeline_mtime()
|
|
if mtime > self.pipeline_mtime:
|
|
LOG.info(_LI('Pipeline configuration file has been updated.'))
|
|
|
|
self.pipeline_mtime = mtime
|
|
_hash = pipeline.get_pipeline_hash()
|
|
|
|
if _hash != self.pipeline_hash:
|
|
LOG.info(_LI("Detected change in pipeline configuration."))
|
|
|
|
try:
|
|
# Pipeline in the notification agent.
|
|
if hasattr(self, 'pipeline_manager'):
|
|
self.pipeline_manager = pipeline.setup_pipeline()
|
|
# Polling in the polling agent.
|
|
elif hasattr(self, 'polling_manager'):
|
|
self.polling_manager = pipeline.setup_polling()
|
|
LOG.debug(_("Pipeline has been refreshed. "
|
|
"old hash: %(old)s, new hash: %(new)s") %
|
|
({'old': self.pipeline_hash,
|
|
'new': _hash}))
|
|
except Exception as err:
|
|
LOG.debug(_("Active pipeline config's hash is %s") %
|
|
self.pipeline_hash)
|
|
LOG.exception(_LE('Unable to load changed pipeline: %s')
|
|
% err)
|
|
return
|
|
|
|
self.pipeline_hash = _hash
|
|
self.reload_pipeline()
|