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): ...@@ -41,14 +41,10 @@ class Partition(object):
tid = '\x00' * 8 tid = '\x00' * 8
self.tid = tid self.tid = tid
def safe(self, pending_tid_list): def safe(self, min_pending_tid):
if self.tid is None: tid = self.tid
return False return tid is not None and (
for tid in pending_tid_list: min_pending_tid is None or tid < min_pending_tid)
if self.tid >= tid:
return False
return True
class Replicator(object): class Replicator(object):
"""This class handles replications of objects and transactions. """This class handles replications of objects and transactions.
...@@ -222,15 +218,18 @@ class Replicator(object): ...@@ -222,15 +218,18 @@ class Replicator(object):
return return
# Try to select something. # 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(): 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.current_partition = partition
self.unfinished_tid_list = None
break break
else: else:
# Not yet. # Not yet.
logging.debug('not ready yet') logging.debug('not ready yet')
self.unfinished_tid_list = None
return return
self._startReplication() 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