Commit e4fce5a3 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Rename 'rid' to 'offset'.

Signed-off-by: default avatarGrégory <gregory@nexedi.com>

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2646 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 64824ad7
...@@ -182,27 +182,27 @@ class ReplicationHandler(EventHandler): ...@@ -182,27 +182,27 @@ class ReplicationHandler(EventHandler):
def _doAskCheckSerialRange(self, min_oid, min_tid, max_tid, def _doAskCheckSerialRange(self, min_oid, min_tid, max_tid,
length=RANGE_LENGTH): length=RANGE_LENGTH):
replicator = self.app.replicator replicator = self.app.replicator
partition = replicator.getCurrentRID() partition = replicator.getCurrentOffset()
check_args = (min_oid, min_tid, max_tid, length, partition) check_args = (min_oid, min_tid, max_tid, length, partition)
replicator.checkSerialRange(*check_args) replicator.checkSerialRange(*check_args)
return Packets.AskCheckSerialRange(*check_args) return Packets.AskCheckSerialRange(*check_args)
def _doAskCheckTIDRange(self, min_tid, max_tid, length=RANGE_LENGTH): def _doAskCheckTIDRange(self, min_tid, max_tid, length=RANGE_LENGTH):
replicator = self.app.replicator replicator = self.app.replicator
partition = replicator.getCurrentRID() partition = replicator.getCurrentOffset()
replicator.checkTIDRange(min_tid, max_tid, length, partition) replicator.checkTIDRange(min_tid, max_tid, length, partition)
return Packets.AskCheckTIDRange(min_tid, max_tid, length, partition) return Packets.AskCheckTIDRange(min_tid, max_tid, length, partition)
def _doAskTIDsFrom(self, min_tid, length): def _doAskTIDsFrom(self, min_tid, length):
replicator = self.app.replicator replicator = self.app.replicator
partition_id = replicator.getCurrentRID() partition_id = replicator.getCurrentOffset()
max_tid = replicator.getCurrentCriticalTID() max_tid = replicator.getCurrentCriticalTID()
replicator.getTIDsFrom(min_tid, max_tid, length, partition_id) replicator.getTIDsFrom(min_tid, max_tid, length, partition_id)
return Packets.AskTIDsFrom(min_tid, max_tid, length, [partition_id]) return Packets.AskTIDsFrom(min_tid, max_tid, length, [partition_id])
def _doAskObjectHistoryFrom(self, min_oid, min_serial, length): def _doAskObjectHistoryFrom(self, min_oid, min_serial, length):
replicator = self.app.replicator replicator = self.app.replicator
partition_id = replicator.getCurrentRID() partition_id = replicator.getCurrentOffset()
max_serial = replicator.getCurrentCriticalTID() max_serial = replicator.getCurrentCriticalTID()
replicator.getObjectHistoryFrom(min_oid, min_serial, max_serial, replicator.getObjectHistoryFrom(min_oid, min_serial, max_serial,
length, partition_id) length, partition_id)
...@@ -284,7 +284,7 @@ class ReplicationHandler(EventHandler): ...@@ -284,7 +284,7 @@ class ReplicationHandler(EventHandler):
# knows. # knows.
(last_tid, ) = params (last_tid, ) = params
app.dm.deleteTransactionsAbove(app.pt.getPartitions(), app.dm.deleteTransactionsAbove(app.pt.getPartitions(),
replicator.getCurrentRID(), last_tid) replicator.getCurrentOffset(), last_tid)
# If no more TID, a replication of transactions is finished. # If no more TID, a replication of transactions is finished.
# So start to replicate objects now. # So start to replicate objects now.
max_tid = replicator.getCurrentCriticalTID() max_tid = replicator.getCurrentCriticalTID()
...@@ -316,7 +316,7 @@ class ReplicationHandler(EventHandler): ...@@ -316,7 +316,7 @@ class ReplicationHandler(EventHandler):
# knows. # knows.
((last_oid, last_serial), ) = params ((last_oid, last_serial), ) = params
app.dm.deleteObjectsAbove(app.pt.getPartitions(), app.dm.deleteObjectsAbove(app.pt.getPartitions(),
replicator.getCurrentRID(), last_oid, last_serial) replicator.getCurrentOffset(), last_oid, last_serial)
# Nothing remains, so the replication for this partition is # Nothing remains, so the replication for this partition is
# finished. # finished.
replicator.setReplicationDone() replicator.setReplicationDone()
......
...@@ -26,12 +26,12 @@ from neo.lib.util import dump ...@@ -26,12 +26,12 @@ from neo.lib.util import dump
class Partition(object): class Partition(object):
"""This class abstracts the state of a partition.""" """This class abstracts the state of a partition."""
def __init__(self, rid): def __init__(self, offset):
self.rid = rid self.offset = offset
self.tid = None self.tid = None
def getRID(self): def getOffset(self):
return self.rid return self.offset
def getCriticalTID(self): def getCriticalTID(self):
return self.tid return self.tid
...@@ -193,9 +193,9 @@ class Replicator(object): ...@@ -193,9 +193,9 @@ class Replicator(object):
"""Return whether there is any pending partition.""" """Return whether there is any pending partition."""
return len(self.partition_dict) or len(self.new_partition_dict) return len(self.partition_dict) or len(self.new_partition_dict)
def getCurrentRID(self): def getCurrentOffset(self):
assert self.current_partition is not None assert self.current_partition is not None
return self.current_partition.getRID() return self.current_partition.getOffset()
def getCurrentCriticalTID(self): def getCurrentCriticalTID(self):
assert self.current_partition is not None assert self.current_partition is not None
...@@ -211,7 +211,7 @@ class Replicator(object): ...@@ -211,7 +211,7 @@ class Replicator(object):
def setCriticalTID(self, tid): def setCriticalTID(self, tid):
"""This is a callback from MasterOperationHandler.""" """This is a callback from MasterOperationHandler."""
neo.lib.logging.debug('setting critical TID %s to %s', dump(tid), neo.lib.logging.debug('setting critical TID %s to %s', dump(tid),
', '.join([str(p.getRID()) for p in self.critical_tid_list])) ', '.join([str(p.getOffset()) for p in self.critical_tid_list]))
for partition in self.critical_tid_list: for partition in self.critical_tid_list:
partition.setCriticalTID(tid) partition.setCriticalTID(tid)
self.critical_tid_list = [] self.critical_tid_list = []
...@@ -237,7 +237,7 @@ class Replicator(object): ...@@ -237,7 +237,7 @@ class Replicator(object):
def _startReplication(self): def _startReplication(self):
# Choose a storage node for the source. # Choose a storage node for the source.
app = self.app app = self.app
cell_list = app.pt.getCellList(self.current_partition.getRID(), cell_list = app.pt.getCellList(self.current_partition.getOffset(),
readable=True) readable=True)
node_list = [cell.getNode() for cell in cell_list node_list = [cell.getNode() for cell in cell_list
if cell.getNodeState() == NodeStates.RUNNING] if cell.getNodeState() == NodeStates.RUNNING]
...@@ -274,10 +274,10 @@ class Replicator(object): ...@@ -274,10 +274,10 @@ class Replicator(object):
def _finishReplication(self): def _finishReplication(self):
# TODO: remove try..except: pass # TODO: remove try..except: pass
try: try:
self.partition_dict.pop(self.current_partition.getRID()) self.partition_dict.pop(self.current_partition.getOffset())
# Notify to a primary master node that my cell is now up-to-date. # Notify to a primary master node that my cell is now up-to-date.
conn = self.app.master_conn conn = self.app.master_conn
offset = self.current_partition.getRID() offset = self.current_partition.getOffset()
conn.notify(Packets.NotifyReplicationDone(offset)) conn.notify(Packets.NotifyReplicationDone(offset))
except KeyError: except KeyError:
pass pass
...@@ -300,7 +300,7 @@ class Replicator(object): ...@@ -300,7 +300,7 @@ class Replicator(object):
not self.current_connection.isPending(): not self.current_connection.isPending():
# finish a replication # finish a replication
neo.lib.logging.info('replication is done for %s' % neo.lib.logging.info('replication is done for %s' %
(self.current_partition.getRID(), )) (self.current_partition.getOffset(), ))
self._finishReplication() self._finishReplication()
return return
...@@ -332,16 +332,16 @@ class Replicator(object): ...@@ -332,16 +332,16 @@ class Replicator(object):
self._startReplication() self._startReplication()
def removePartition(self, rid): def removePartition(self, offset):
"""This is a callback from MasterOperationHandler.""" """This is a callback from MasterOperationHandler."""
self.partition_dict.pop(rid, None) self.partition_dict.pop(offset, None)
self.new_partition_dict.pop(rid, None) self.new_partition_dict.pop(offset, None)
def addPartition(self, rid): def addPartition(self, offset):
"""This is a callback from MasterOperationHandler.""" """This is a callback from MasterOperationHandler."""
if not self.partition_dict.has_key(rid) \ if not self.partition_dict.has_key(offset) \
and not self.new_partition_dict.has_key(rid): and not self.new_partition_dict.has_key(offset):
self.new_partition_dict[rid] = Partition(rid) self.new_partition_dict[offset] = Partition(offset)
def _addTask(self, key, func, args=(), kw=None): def _addTask(self, key, func, args=(), kw=None):
task = Task(func, args, kw) task = Task(func, args, kw)
......
...@@ -76,7 +76,7 @@ class ReplicationTests(NeoUnitTestBase): ...@@ -76,7 +76,7 @@ class ReplicationTests(NeoUnitTestBase):
oapp.pt = pt oapp.pt = pt
oapp.master_conn = mconn oapp.master_conn = mconn
oapp.replicator = Replicator(oapp) oapp.replicator = Replicator(oapp)
oapp.replicator.getCurrentRID = lambda: 0 oapp.replicator.getCurrentOffset = lambda: 0
oapp.replicator.isCurrentConnection = lambda c: True oapp.replicator.isCurrentConnection = lambda c: True
oapp.replicator.getCurrentCriticalTID = lambda: MAX_TID oapp.replicator.getCurrentCriticalTID = lambda: MAX_TID
# handlers and connections # handlers and connections
......
...@@ -89,7 +89,7 @@ class StorageReplicationHandlerTests(NeoUnitTestBase): ...@@ -89,7 +89,7 @@ class StorageReplicationHandlerTests(NeoUnitTestBase):
'checkTIDRange': None, 'checkTIDRange': None,
'getTIDsFrom': None, 'getTIDsFrom': None,
'getObjectHistoryFrom': None, 'getObjectHistoryFrom': None,
'getCurrentRID': rid, 'getCurrentOffset': rid,
'getCurrentCriticalTID': critical_tid, 'getCurrentCriticalTID': critical_tid,
}) })
def isCurrentConnection(other_conn): def isCurrentConnection(other_conn):
...@@ -125,7 +125,7 @@ class StorageReplicationHandlerTests(NeoUnitTestBase): ...@@ -125,7 +125,7 @@ class StorageReplicationHandlerTests(NeoUnitTestBase):
pmin_tid, plength, ppartition = next_range.decode() pmin_tid, plength, ppartition = next_range.decode()
self.assertEqual(pmin_tid, add64(next_tid, 1)) self.assertEqual(pmin_tid, add64(next_tid, 1))
self.assertEqual(plength, RANGE_LENGTH) self.assertEqual(plength, RANGE_LENGTH)
self.assertEqual(ppartition, app.replicator.getCurrentRID()) self.assertEqual(ppartition, app.replicator.getCurrentOffset())
calls = app.replicator.mockGetNamedCalls('checkTIDRange') calls = app.replicator.mockGetNamedCalls('checkTIDRange')
self.assertEqual(len(calls), 1) self.assertEqual(len(calls), 1)
calls[0].checkArgs(pmin_tid, plength, ppartition) calls[0].checkArgs(pmin_tid, plength, ppartition)
...@@ -152,7 +152,7 @@ class StorageReplicationHandlerTests(NeoUnitTestBase): ...@@ -152,7 +152,7 @@ class StorageReplicationHandlerTests(NeoUnitTestBase):
self.assertEqual(pmin_oid, next_oid) self.assertEqual(pmin_oid, next_oid)
self.assertEqual(pmin_serial, add64(next_serial, 1)) self.assertEqual(pmin_serial, add64(next_serial, 1))
self.assertEqual(plength, RANGE_LENGTH) self.assertEqual(plength, RANGE_LENGTH)
self.assertEqual(ppartition, app.replicator.getCurrentRID()) self.assertEqual(ppartition, app.replicator.getCurrentOffset())
calls = app.replicator.mockGetNamedCalls('checkSerialRange') calls = app.replicator.mockGetNamedCalls('checkSerialRange')
self.assertEqual(len(calls), 1) self.assertEqual(len(calls), 1)
calls[0].checkArgs(pmin_oid, pmin_serial, plength, ppartition) calls[0].checkArgs(pmin_oid, pmin_serial, plength, ppartition)
......
...@@ -44,7 +44,7 @@ class StorageReplicatorTests(NeoUnitTestBase): ...@@ -44,7 +44,7 @@ class StorageReplicatorTests(NeoUnitTestBase):
replicator.populate() replicator.populate()
self.assertEqual(len(replicator.new_partition_dict), 1) self.assertEqual(len(replicator.new_partition_dict), 1)
partition = replicator.new_partition_dict[0] partition = replicator.new_partition_dict[0]
self.assertEqual(partition.getRID(), 0) self.assertEqual(partition.getOffset(), 0)
self.assertEqual(partition.getCriticalTID(), None) self.assertEqual(partition.getCriticalTID(), None)
self.assertTrue(replicator.replication_done) self.assertTrue(replicator.replication_done)
...@@ -216,7 +216,7 @@ class StorageReplicatorTests(NeoUnitTestBase): ...@@ -216,7 +216,7 @@ class StorageReplicatorTests(NeoUnitTestBase):
self.assertEqual(len(replicator.new_partition_dict), 2) self.assertEqual(len(replicator.new_partition_dict), 2)
self.assertEqual(replicator.new_partition_dict[1], None) self.assertEqual(replicator.new_partition_dict[1], None)
partition = replicator.new_partition_dict[2] partition = replicator.new_partition_dict[2]
self.assertEqual(partition.getRID(), 2) self.assertEqual(partition.getOffset(), 2)
self.assertEqual(partition.getCriticalTID(), None) self.assertEqual(partition.getCriticalTID(), None)
def test_processDelayedTasks(self): def test_processDelayedTasks(self):
......
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