Example #1
0
 def process_incoming(self, link, connection):
   key = (connection.container_id, link.name)
   target = self.targets[key]
   xfr = link.get()
   if not isinstance(target, TxnTarget):
     if xfr.state:
       txn = self.coordinator.get_transaction(xfr.state)
     else:
       txn = None
   else:
     txn = None
   disp = target.put(xfr.delivery_tag, xfr, owner=txn)
   if txn:
     xdisp = TransactionalState(txn.txn_id, disp)
     def doit(t=xfr.delivery_tag, d=disp, xd=xdisp):
       target.settle(t, d)
       link.settle(t, xd)
     def undo(t=xfr.delivery_tag):
       target.settle(t, None)
       link.settle(t, None)
     txn.add_work(doit, undo)
     disp=xdisp
   link.disposition(xfr.delivery_tag, disp)
   if not txn:
     # XXX: enums
     if link.rcv_settle_mode == 0:
       link.settle(xfr.delivery_tag)
Example #2
0
  def process_sender(self, link, connection):
    if link.source is None: return
    key = (connection.container_id, link.name)
    source = self.sources[key]
    while link.capacity() > 0:
      tag, xfr = source.get()
      if xfr is None:
        link.drained()
        break
      else:
        link.send(delivery_tag = tag, message_format = xfr.message_format,
                  settled = link.snd_settle_mode == 1, # XXX: enums
                  payload = xfr.payload)

    for t, l, r in link.get_remote(modified=True):
      if l.resumed:
        link.settle(t, None)
      elif r.settled or r.state is not None:
        def doit(t=t, s=r.state):
          state = source.settle(t, r.state)
          link.settle(t, state)
        def undo(t=t):
          pass
        if r.state:
          txn = self.coordinator.get_transaction(r.state)
        else:
          txn = None
        if txn:
          txn.add_work(doit, undo)
        else:
          doit()
      r.modified = False
Example #3
0
  def process_receiver(self, link, connection):
    if link.target is None: return
    key = (connection.container_id, link.name)
    target = self.targets[key]

    for t, l, r in link.get_remote():
      if l.resumed:
        link.settle(t, None)
      elif r.settled and not isinstance(l.state, TransactionalState):
        state = target.settle(t, l.state)
        link.settle(t, state)

    if target.capacity() and link.credit() < 10: link.flow(10)
Example #4
0
 def undo(t=xfr.delivery_tag):
   target.settle(t, None)
   link.settle(t, None)
Example #5
0
 def doit(t=xfr.delivery_tag, d=disp, xd=xdisp):
   target.settle(t, d)
   link.settle(t, xd)
Example #6
0
 def doit(t=t, s=r.state):
   state = source.settle(t, r.state)
   link.settle(t, state)