Esempio n. 1
0
 def push():
     try:
         pack_tid = None  # TODO
         for serial, oid in object_list:
             oid_set = object_dict.get(serial)
             if oid_set:
                 if type(oid_set) is list:
                     object_dict[serial] = oid_set = set(oid_set)
                 if oid in oid_set:
                     oid_set.remove(oid)
                     if not oid_set:
                         del object_dict[serial]
                     continue
             object = dm.getObject(oid, serial)
             if not object:
                 conn.send(
                     Errors.ReplicationError(
                         "partition %u dropped or truncated" %
                         partition), msg_id)
                 return
             conn.send(Packets.AddObject(oid, serial, *object[2:]),
                       msg_id)
             yield
         conn.send(
             Packets.AnswerFetchObjects(pack_tid, next_tid, next_oid,
                                        object_dict), msg_id)
         yield
     except (weakref.ReferenceError, ConnectionClosed):
         pass
Esempio n. 2
0
 def push():
     try:
         pack_tid = None  # TODO
         for serial, oid in object_list:
             oid_set = object_dict.get(serial)
             if oid_set:
                 if type(oid_set) is tuple:
                     object_dict[serial] = oid_set = set(oid_set)
                 if oid in oid_set:
                     oid_set.remove(oid)
                     if not oid_set:
                         del object_dict[serial]
                     continue
             object = dm.fetchObject(oid, serial)
             if not object:
                 conn.send(
                     Errors.ReplicationError(
                         "partition %u dropped or truncated" %
                         partition), msg_id)
                 return
             if not object[2]:  # creation undone
                 object = object[0], 0, ZERO_HASH, '', object[4]
             # Same as in askFetchTransactions.
             conn.send(Packets.AddObject(oid, *object), msg_id)
             yield conn.buffering
         conn.send(
             Packets.AnswerFetchObjects(pack_tid, next_tid, next_oid,
                                        object_dict), msg_id)
         yield
     except (weakref.ReferenceError, ConnectionClosed):
         pass
Esempio n. 3
0
 def push():
     try:
         pack_tid = None  # TODO
         for tid in tid_list:
             if tid in peer_tid_set:
                 peer_tid_set.remove(tid)
             else:
                 t = dm.getTransaction(tid)
                 if t is None:
                     conn.send(
                         Errors.ReplicationError(
                             "partition %u dropped" % partition),
                         msg_id)
                     return
                 oid_list, user, desc, ext, packed, ttid = t
                 conn.send(
                     Packets.AddTransaction(tid, user, desc, ext,
                                            packed, ttid, oid_list),
                     msg_id)
                 yield
         conn.send(
             Packets.AnswerFetchTransactions(pack_tid, next_tid,
                                             peer_tid_set), msg_id)
         yield
     except (weakref.ReferenceError, ConnectionClosed):
         pass
Esempio n. 4
0
 def push():
     try:
         pack_tid = None  # TODO
         for tid in tid_list:
             if tid in peer_tid_set:
                 peer_tid_set.remove(tid)
             else:
                 t = dm.getTransaction(tid)
                 if t is None:
                     conn.send(
                         Errors.ReplicationError(
                             "partition %u dropped" % partition),
                         msg_id)
                     return
                 oid_list, user, desc, ext, packed, ttid = t
                 # Sending such packet does not mark the connection
                 # for writing if there's too little data in the buffer.
                 conn.send(
                     Packets.AddTransaction(tid, user, desc, ext,
                                            bool(packed), ttid,
                                            oid_list), msg_id)
                 # To avoid delaying several connections simultaneously,
                 # and also prevent the backend from scanning different
                 # parts of the DB at the same time, we ask the
                 # scheduler not to switch to another background task.
                 # Ideally, we are filling a buffer while the kernel
                 # is flushing another one for a concurrent connection.
                 yield conn.buffering
         conn.send(
             Packets.AnswerFetchTransactions(pack_tid, next_tid,
                                             peer_tid_set), msg_id)
         yield
     except (weakref.ReferenceError, ConnectionClosed):
         pass