Пример #1
0
    def onTransactionCommitted(self, txn):
        # I have received all the lock answers now:
        # - send a Notify Transaction Finished to the initiated client node
        # - Invalidate Objects to the other client nodes
        ttid = txn.getTTID()
        tid = txn.getTID()
        transaction_node = txn.getNode()
        invalidate_objects = Packets.InvalidateObjects(tid, txn.getOIDList())
        for client_node in self.nm.getClientList(only_identified=True):
            c = client_node.getConnection()
            if client_node is transaction_node:
                c.answer(Packets.AnswerTransactionFinished(ttid, tid),
                         msg_id=txn.getMessageId())
            else:
                c.notify(invalidate_objects)

        # Unlock Information to relevant storage nodes.
        notify_unlock = Packets.NotifyUnlockInformation(ttid)
        getByUUID = self.nm.getByUUID
        for storage_uuid in txn.getUUIDList():
            getByUUID(storage_uuid).getConnection().notify(notify_unlock)

        # Notify storage that have replications blocked by this transaction,
        # and clients that try to recover from a failure during tpc_finish.
        notify_finished = Packets.NotifyTransactionFinished(ttid, tid)
        for uuid in txn.getNotificationUUIDList():
            node = getByUUID(uuid)
            if node.isClient():
                # There should be only 1 client interested.
                node.answer(Packets.AnswerFinalTID(tid))
            else:
                node.notify(notify_finished)

        assert self.last_transaction < tid, (self.last_transaction, tid)
        self.setLastTransaction(tid)
Пример #2
0
 def askFinalTID(self, conn, ttid):
     tm = self.app.tm
     if tm.getLastTID() < ttid:
         # Invalid ttid, or aborted transaction.
         tid = None
     elif ttid in tm:
         # Transaction is being finished.
         # We'll answer when it is unlocked.
         tm[ttid].registerForNotification(conn.getUUID())
         return
     else:
         # Transaction committed ? Tell client to ask storages.
         tid = MAX_TID
     conn.answer(Packets.AnswerFinalTID(tid))
Пример #3
0
 def askFinalTID(self, conn, ttid):
     conn.answer(Packets.AnswerFinalTID(self.app.tm.getFinalTID(ttid)))