Beispiel #1
0
 def replicate(self):
     """ replicate log to targets """
     keys = OOSet(self._transactions.keys())
     for key in keys:
         transaction = self._transactions[key]
         try:
             transaction.replicate(self)
             del self._transactions[key]
         except:
             from sys import exc_info
             import traceback
             info = exc_info()
             zlog('Replication',
                  'Could not replicate transaction %s to %s'%(
                     oid2str(transaction.id), self.id)) 
             break
Beispiel #2
0
    def load(self, data=None, REQUEST=None):
        """ load replicated data """
        if data is None:
            data = REQUEST.get('data', None)
        if data is None:
            return
        payload = decompress(data)
        f = StringIO(payload)
        transaction = Unpickler(f).load()
        t_id = transaction['id']

        if t_id > self._last_transaction_id:
            self.REQUEST.set('replicating', '1')
            t = get_transaction()
            t.user = transaction['user'] + ' (replicated)'
            t.description = transaction['description']
            for entry_dict in transaction['entries'].values():
                self.realize_entry(entry_dict)
            zLOG.LOG('Replication', INFO, 'ReplicationLog.load> transaction id: %s' % oid2str(t_id)) #DBG 
        else:
            zlog('Replication', 
                 'Received old transaction: %s (last transaction: %s)'%(
                    t_id, self._last_transaction_id),
                 log_traceback=0)