Пример #1
0
    def register(self, agent_id, agent_domain, pth, config_txt):
        #: indicates whether another instance of the same agent is already
        #: running with the same configuration
        agent_name = agent_id.split('-', 1)[0]
        self.agentnames[agent_id] = agent_name
        output_altering_options = get_output_altering_options(str(config_txt))

        name_config = (agent_name, output_altering_options)
        already_running = len(self.uniq_conf_clients[name_config]) > 1
        self.uniq_conf_clients[name_config].append(agent_id)

        self.clients[agent_id] = pth
        self.agents_output_altering_options[agent_id] = output_altering_options
        self.agents_full_config_txts[agent_id] = str(config_txt)
        log.info("New client %s (%s) in domain %s with config %s", pth,
                 agent_id, agent_domain, config_txt)
        # Send not-yet processed descriptors to the agent...
        if not already_running:
            # ...unless another instance of the same agent has already been
            # started, and should be processing those descriptors
            unprocessed = \
                self.store.list_unprocessed_by_agent(agent_name,
                                                     output_altering_options)
            self.descriptor_handled_count[name_config] = \
                self.descriptor_count - len(unprocessed)
            for dom, uuid, sel in unprocessed:
                self.targeted_descriptor("storage", dom, uuid, sel,
                                         [agent_name], False)
Пример #2
0
 def join(self, agent, agent_domain=DEFAULT_DOMAIN):
     agid = "%s-%i" % (agent.name, self.agent_count)
     self.agent_count += 1
     self.agents_full_config_txts[agid] = agent.config_txt
     self.agents_output_altering_options[agid] = \
         get_output_altering_options(agent.config_txt)
     self.agent_descs[agid] = agent_desc(agid, agent_domain)
     self.agents[agid] = agent
     return agid
Пример #3
0
 def unlock(self, desc_domain, selector, slots, processing_failed, retries,
            wait_time, request_id):
     lockid = self.name + get_output_altering_options(self.config_txt)
     lockid += '-reqid-%d-' % request_id
     if self._process_slots_:
         selectorsstr = "!".join(slots.get(s, "?") for s in
                                 self._process_slots_)
     else:
         selectorsstr = selector
     self.bus.unlock(self.id, lockid, desc_domain, selectorsstr,
                     processing_failed, retries, wait_time)
Пример #4
0
    def lock(self, desc_domain, selector, slots, request_id):
        """
        :param selectorstr: describes the selectors being processed
        """
        #: describes the agent & its configuration
        lockid = self.name + get_output_altering_options(self.config_txt)
        lockid += '-reqid-%d-' % request_id

        # In case of slots, lock on all the selectors at once, so that if one
        # optional selector is missing at the time of the lock, another lock
        # will be taken when this selector is received and processing the
        # complete set of slots will not be blocked.
        if self._process_slots_:
            #: describes selectors that are considered for this lock
            selectorsstr = "!".join(slots.get(s, "?") for s in
                                    self._process_slots_)
        else:
            selectorsstr = selector

        self.held_locks.append((desc_domain, selector, slots, False, 0, 0,
                                request_id))
        return self.bus.lock(self.id, lockid, desc_domain, selectorsstr)