Commit 0f7566ad authored by Vincent Pelletier's avatar Vincent Pelletier

Simplify unfinished TID list handling.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2207 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent c340516c
......@@ -41,14 +41,10 @@ class Partition(object):
tid = '\x00' * 8
self.tid = tid
def safe(self, pending_tid_list):
if self.tid is None:
return False
for tid in pending_tid_list:
if self.tid >= tid:
return False
return True
def safe(self, min_pending_tid):
tid = self.tid
return tid is not None and (
min_pending_tid is None or tid < min_pending_tid)
class Replicator(object):
"""This class handles replications of objects and transactions.
......@@ -222,15 +218,18 @@ class Replicator(object):
return
# Try to select something.
if len(self.unfinished_tid_list):
min_unfinished_tid = min(self.unfinished_tid_list)
else:
min_unfinished_tid = None
self.unfinished_tid_list = None
for partition in self.partition_dict.values():
if partition.safe(self.unfinished_tid_list):
if partition.safe(min_unfinished_tid):
self.current_partition = partition
self.unfinished_tid_list = None
break
else:
# Not yet.
logging.debug('not ready yet')
self.unfinished_tid_list = None
return
self._startReplication()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment