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