def get_consumers(self, consumer, channel): return [ consumer(queues=[execution.get_queue(routing_key=publishers.ANY_RK, exclusive=True)], accept=['pickle'], callbacks=[self.processor(ActionExecutionAPI)]), consumer(queues=[Queue(None, liveaction.LIVEACTION_XCHG, routing_key=publishers.ANY_RK, exclusive=True)], accept=['pickle'], callbacks=[self.processor(LiveActionAPI)]) ]
from st2common.persistence.execution import ActionExecution from st2common.persistence.marker import DumperMarker from st2common.transport import consumers, execution, publishers from st2common.transport import utils as transport_utils from st2common.util import isotime from st2exporter.exporter.dumper import Dumper __all__ = [ 'ExecutionsExporter' ] COMPLETION_STATUSES = [LIVEACTION_STATUS_SUCCEEDED, LIVEACTION_STATUS_FAILED, LIVEACTION_STATUS_CANCELED] LOG = logging.getLogger(__name__) EXPORTER_WORK_Q = execution.get_queue( 'st2.exporter.work', routing_key=publishers.UPDATE_RK) class ExecutionsExporter(consumers.MessageHandler): message_type = ActionExecutionDB def __init__(self, connection, queues): super(ExecutionsExporter, self).__init__(connection, queues) self.pending_executions = Queue.Queue() self._dumper = Dumper(queue=self.pending_executions, export_dir=cfg.CONF.exporter.dump_dir) self._consumer_thread = None def start(self, wait=False): LOG.info('Bootstrapping executions from db...') try:
routing_key=action_constants.LIVEACTION_STATUS_SCHEDULED) ACTIONRUNNER_CANCEL_QUEUE = liveaction.get_status_management_queue( 'st2.actionrunner.cancel', routing_key=action_constants.LIVEACTION_STATUS_CANCELING) ACTIONRUNNER_PAUSE_QUEUE = liveaction.get_status_management_queue( 'st2.actionrunner.pause', routing_key=action_constants.LIVEACTION_STATUS_PAUSING) ACTIONRUNNER_RESUME_QUEUE = liveaction.get_status_management_queue( 'st2.actionrunner.resume', routing_key=action_constants.LIVEACTION_STATUS_RESUMING) # Used by the exporter service EXPORTER_WORK_QUEUE = execution.get_queue('st2.exporter.work', routing_key=publishers.UPDATE_RK) # Used by the notifier service NOTIFIER_ACTIONUPDATE_WORK_QUEUE = execution.get_queue( 'st2.notifiers.execution.work', routing_key=publishers.UPDATE_RK) # Used by the results tracker service RESULTSTRACKER_ACTIONSTATE_WORK_QUEUE = actionexecutionstate.get_queue( 'st2.resultstracker.work', routing_key=publishers.CREATE_RK) # Used by the rules engine service RULESENGINE_WORK_QUEUE = reactor.get_trigger_instances_queue( name='st2.trigger_instances_dispatch.rules_engine', routing_key='#') # Used by the stream service STREAM_ANNOUNCEMENT_WORK_QUEUE = announcement.get_queue(
# Used by the action scheduler service ACTIONSCHEDULER_REQUEST_QUEUE = liveaction.get_status_management_queue( 'st2.actionrunner.req', routing_key=action_constants.LIVEACTION_STATUS_REQUESTED) # Used by the action runner service ACTIONRUNNER_WORK_QUEUE = liveaction.get_status_management_queue( 'st2.actionrunner.work', routing_key=action_constants.LIVEACTION_STATUS_SCHEDULED) ACTIONRUNNER_CANCEL_QUEUE = liveaction.get_status_management_queue( 'st2.actionrunner.canel', routing_key=action_constants.LIVEACTION_STATUS_CANCELING) # Used by the exporter service EXPORTER_WORK_QUEUE = execution.get_queue('st2.exporter.work', routing_key=publishers.UPDATE_RK) # Used by the notifier service NOTIFIER_ACTIONUPDATE_WORK_QUEUE = execution.get_queue( 'st2.notifiers.execution.work', routing_key=publishers.UPDATE_RK) # Used by the results tracker service RESULTSTRACKER_ACTIONSTATE_WORK_QUEUE = actionexecutionstate.get_queue( 'st2.resultstracker.work', routing_key=publishers.CREATE_RK) # Used by the rules engine service RULESENGINE_WORK_QUEUE = reactor.get_trigger_instances_queue( name='st2.trigger_instances_dispatch.rules_engine', routing_key='#') # Used by the stream service STREAM_ANNOUNCEMENT_WORK_QUEUE = announcement.get_queue(
from st2common.transport import consumers, execution, publishers from st2common.transport import utils as transport_utils from st2common.transport.reactor import TriggerDispatcher from st2common.util import isotime from st2common.util import jinja as jinja_utils from st2common.constants.action import ACTION_CONTEXT_KV_PREFIX from st2common.constants.action import ACTION_PARAMETERS_KV_PREFIX from st2common.constants.action import ACTION_RESULTS_KV_PREFIX from st2common.constants.keyvalue import FULL_SYSTEM_SCOPE, SYSTEM_SCOPE, DATASTORE_PARENT_SCOPE from st2common.services.keyvalues import KeyValueLookup __all__ = ['Notifier', 'get_notifier'] LOG = logging.getLogger(__name__) ACTIONUPDATE_WORK_Q = execution.get_queue('st2.notifiers.execution.work', routing_key=publishers.UPDATE_RK) ACTION_SENSOR_ENABLED = cfg.CONF.action_sensor.enable # XXX: Fix this nasty positional dependency. ACTION_TRIGGER_TYPE = INTERNAL_TRIGGER_TYPES['action'][0] NOTIFY_TRIGGER_TYPE = INTERNAL_TRIGGER_TYPES['action'][1] class Notifier(consumers.MessageHandler): message_type = ActionExecutionDB def __init__(self, connection, queues, trigger_dispatcher=None): super(Notifier, self).__init__(connection, queues) if not trigger_dispatcher: trigger_dispatcher = TriggerDispatcher(LOG) self._trigger_dispatcher = trigger_dispatcher
ACTIONRUNNER_CANCEL_QUEUE = liveaction.get_status_management_queue( 'st2.actionrunner.cancel', routing_key=action_constants.LIVEACTION_STATUS_CANCELING) ACTIONRUNNER_PAUSE_QUEUE = liveaction.get_status_management_queue( 'st2.actionrunner.pause', routing_key=action_constants.LIVEACTION_STATUS_PAUSING) ACTIONRUNNER_RESUME_QUEUE = liveaction.get_status_management_queue( 'st2.actionrunner.resume', routing_key=action_constants.LIVEACTION_STATUS_RESUMING) # Used by the exporter service EXPORTER_WORK_QUEUE = execution.get_queue( 'st2.exporter.work', routing_key=publishers.UPDATE_RK) # Used by the notifier service NOTIFIER_ACTIONUPDATE_WORK_QUEUE = execution.get_queue( 'st2.notifiers.execution.work', routing_key=publishers.UPDATE_RK) # Used by the results tracker service RESULTSTRACKER_ACTIONSTATE_WORK_QUEUE = actionexecutionstate.get_queue( 'st2.resultstracker.work', routing_key=publishers.CREATE_RK)