Commit 9141c717 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Fix some typos and add more debug prints.

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@208 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 67f21f13
...@@ -1092,7 +1092,7 @@ class Packet(object): ...@@ -1092,7 +1092,7 @@ class Packet(object):
oid_list.append(oid) oid_list.append(oid)
except: except:
raise ProtocolError(self, 'invalid answer transaction information') raise ProtocolError(self, 'invalid answer transaction information')
return tid, user, desc, ext_len, oid_list return tid, user, desc, ext, oid_list
decode_table[ANSWER_TRANSACTION_INFORMATION] = _decodeAnswerTransactionInformation decode_table[ANSWER_TRANSACTION_INFORMATION] = _decodeAnswerTransactionInformation
def _decodeAskObjectHistory(self): def _decodeAskObjectHistory(self):
......
...@@ -5,6 +5,7 @@ from neo.protocol import Packet, OUT_OF_DATE_STATE, STORAGE_NODE_TYPE, \ ...@@ -5,6 +5,7 @@ from neo.protocol import Packet, OUT_OF_DATE_STATE, STORAGE_NODE_TYPE, \
INVALID_OID, INVALID_TID, RUNNING_STATE INVALID_OID, INVALID_TID, RUNNING_STATE
from neo.connection import ClientConnection from neo.connection import ClientConnection
from neo.storage.handler import StorageEventHandler from neo.storage.handler import StorageEventHandler
from neo.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."""
...@@ -245,6 +246,10 @@ class Replicator(object): ...@@ -245,6 +246,10 @@ class Replicator(object):
"""This is a callback from OperationEventHandler.""" """This is a callback from OperationEventHandler."""
msg_id = packet.getId() msg_id = packet.getId()
try: try:
partition_list = self.critical_tid_dict[msg_id]
logging.debug('setting critical TID %s to %s',
dump(tid),
', '.join([str(p.getRID()) for p in partition_list]))
for partition in self.critical_tid_dict[msg_id]: for partition in self.critical_tid_dict[msg_id]:
partition.setCriticalTID(tid) partition.setCriticalTID(tid)
del self.critical_tid_dict[msg_id] del self.critical_tid_dict[msg_id]
...@@ -252,7 +257,6 @@ class Replicator(object): ...@@ -252,7 +257,6 @@ class Replicator(object):
pass pass
def _askCriticalTID(self): def _askCriticalTID(self):
logging.debug('self.new_partition_list = %r', self.new_partition_list)
conn = self.primary_master_connection conn = self.primary_master_connection
msg_id = conn.getNextId() msg_id = conn.getNextId()
conn.addPacket(Packet().askLastIDs(msg_id)) conn.addPacket(Packet().askLastIDs(msg_id))
...@@ -263,6 +267,8 @@ class Replicator(object): ...@@ -263,6 +267,8 @@ class Replicator(object):
def setUnfinishedTIDList(self, tid_list): def setUnfinishedTIDList(self, tid_list):
"""This is a callback from OperationEventHandler.""" """This is a callback from OperationEventHandler."""
logging.debug('setting unfinished TIDs %s',
','.join([dump(tid) for tid in tid_list]))
self.waiting_for_unfinished_tids = False self.waiting_for_unfinished_tids = False
self.unfinished_tid_list = tid_list self.unfinished_tid_list = tid_list
...@@ -277,12 +283,15 @@ class Replicator(object): ...@@ -277,12 +283,15 @@ class Replicator(object):
# Choose a storage node for the source. # Choose a storage node for the source.
app = self.app app = self.app
try: try:
cell_list = app.pt.getCellList(self.current_partition, True) cell_list = app.pt.getCellList(self.current_partition.getRID(),
True)
node_list = [cell.getNode() for cell in cell_list node_list = [cell.getNode() for cell in cell_list
if cell.getNodeState() == RUNNING_STATE] if cell.getNodeState() == RUNNING_STATE]
node = choice(node_list) node = choice(node_list)
except: except:
# Not operational. # Not operational.
logging.error('not operational', exc_info = 1)
self.current_partition = None
return return
addr = node.getServer() addr = node.getServer()
...@@ -324,6 +333,7 @@ class Replicator(object): ...@@ -324,6 +333,7 @@ class Replicator(object):
# I need to choose something. # I need to choose something.
if self.waiting_for_unfinished_tids: if self.waiting_for_unfinished_tids:
# Still waiting. # Still waiting.
logging.debug('waiting for unfinished tids')
return return
elif self.unfinished_tid_list is not None: elif self.unfinished_tid_list is not None:
# Try to select something. # Try to select something.
...@@ -334,15 +344,18 @@ class Replicator(object): ...@@ -334,15 +344,18 @@ class Replicator(object):
break break
else: else:
# Not yet. # Not yet.
logging.debug('not ready yet')
self.unfinished_tid_list = None self.unfinished_tid_list = None
return return
self._startReplication() self._startReplication()
else: else:
# Ask pending transactions. # Ask pending transactions.
logging.debug('asking unfinished tids')
self._askUnfinishedTIDs() self._askUnfinishedTIDs()
else: else:
if self.replication_done: if self.replication_done:
logging.info('replication is done')
try: try:
self.partition_list.remove(self.current_partition) self.partition_list.remove(self.current_partition)
except ValueError: except ValueError:
......
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