Ejemplo n.º 1
0
    def dispatch_l3(self, d_context, args=(), kwargs={}):
        item = d_context.item
        event = d_context.event
        q_context = d_context.q_context
        chain = d_context.chain

        item_id = item["id"]
        # First round validation (Controller level)
        _validate_operation(event, item["status"], item_id)

        handlers = router_operations.handlers
        if event in handlers:
            for f in handlers[event]:
                first_run = False
                if item_id not in self.sync_items:
                    self.sync_items[item_id] = queue.Queue()
                    first_run = True
                self.sync_items[item_id].put(
                    ctx.OperationContext(event, q_context, item, chain, f,
                                         args, kwargs))
                if first_run:
                    t = greenthread.spawn(self._consume_l3, item_id,
                                          self.sync_items[item_id],
                                          self._plugin)
                if not self._async:
                    t.wait()
Ejemplo n.º 2
0
    def dispatch_l3(self, d_context, args=(), kwargs={}):
        item = d_context.item
        event = d_context.event
        n_context = d_context.n_context
        chain = d_context.chain

        item_id = item["id"]
        handlers = router_operations.handlers
        if event in handlers:
            for f in handlers[event]:
                first_run = False
                if item_id not in self.sync_items:
                    self.sync_items[item_id] = (queue.Queue(), )
                    first_run = True
                self.sync_items[item_id][0].put(
                    ctx.OperationContext(event, n_context, item, chain, f,
                                         args, kwargs))
                t = None
                if first_run:
                    t = greenthread.spawn(self._consume_l3, item_id,
                                          self.sync_items[item_id][0],
                                          self._plugin, self._async)
                    self.sync_items[item_id] += (t, )
                if not self._async:
                    t = self.sync_items[item_id][1]
                    t.wait()
Ejemplo n.º 3
0
    def dispatch_lb(self, d_context, *args, **kwargs):
        item = d_context.item
        event = d_context.event
        n_context = d_context.n_context
        chain = d_context.chain

        item_id = item["id"]
        if event in self.handlers:
            for f in self.handlers[event]:
                first_run = False
                if item_id not in self.sync_items:
                    self.sync_items[item_id] = [queue.Queue()]
                    first_run = True
                self.sync_items[item_id][0].put(
                    ctx.OperationContext(event, n_context, item, chain, f,
                                         args, kwargs))
                if first_run:
                    t = greenthread.spawn(self._consume_lb,
                                          item_id,
                                          self.sync_items[item_id][0],
                                          self._driver,
                                          self._async)
                    self.sync_items[item_id].append(t)
                if not self._async:
                    t = self.sync_items[item_id][1]
                    t.wait()