示例#1
0
    def __init__(self, config, system, settings):
        """
        :type config: xml.etree.ElementTree.Element
        :type system: zoom.common.types.PlatformType
        :type settings: dict
        """
        self._log = logging.getLogger('sent.child')
        self._action_queue = UniqueQueue()
        self._cancel_flag = ThreadSafeObject(False)

        self.name = verify_attribute(config, 'id')
        self._application_type = verify_attribute(config, 'type')
        self._config = config
        self._system = system  # Linux or Windows
        self._settings = settings
        self._process = self._create_process()
示例#2
0
    def add_task(self, task, is_cancel=False):
        """
        Add Task to UniqueQueue. Submit task node to ZooKeeper.
        If `is_cancel` clear the queue, and submit only cancel.
        :type task: zoom.agent.task.task.Task
        :type is_cancel: bool
        """
        if task.host not in self._task_queue:
            self._task_queue[task.host] = UniqueQueue()

        host_q = self._task_queue.get(task.host)

        if is_cancel:
            host_q.clear()
            task_path = zk_path_join(self._configuration.task_path, task.host)

            try:
                self._zoo_keeper.delete(task_path)
            except NoNodeError:
                pass

        host_q.append_unique(task, sender=task.host)
        self._submit_task(task)