Commit 520c5f01 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Remove unused variable declarations. Fix typo on logging method.

Remove an assert in Connection class that check a sub-class attribute.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@822 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 5feef375
...@@ -291,7 +291,6 @@ class Connection(BaseConnection): ...@@ -291,7 +291,6 @@ class Connection(BaseConnection):
pass pass
except ConnectorConnectionRefusedException: except ConnectorConnectionRefusedException:
# should only occur while connecting # should only occur while connecting
assert self.connecting
self.handler.connectionFailed(self) self.handler.connectionFailed(self)
self.close() self.close()
except ConnectorConnectionClosedException: except ConnectorConnectionClosedException:
...@@ -432,7 +431,7 @@ class ClientConnection(Connection): ...@@ -432,7 +431,7 @@ class ClientConnection(Connection):
except ConnectorConnectionRefusedException: except ConnectorConnectionRefusedException:
handler.connectionFailed(self) handler.connectionFailed(self)
self.close() self.close()
except ConnectorException, msg: except ConnectorException:
# unhandled connector exception # unhandled connector exception
handler.connectionFailed(self) handler.connectionFailed(self)
self.close() self.close()
......
...@@ -377,7 +377,7 @@ class Application(object): ...@@ -377,7 +377,7 @@ class Application(object):
logging.info('begin the recovery of the status') logging.info('begin the recovery of the status')
self.changeClusterState(protocol.RECOVERING) self.changeClusterState(protocol.RECOVERING)
em, nm = self.em, self.nm em = self.em
self.loid = INVALID_OID self.loid = INVALID_OID
self.ltid = INVALID_TID self.ltid = INVALID_TID
......
...@@ -170,7 +170,6 @@ class PartitionTable(neo.pt.PartitionTable): ...@@ -170,7 +170,6 @@ class PartitionTable(neo.pt.PartitionTable):
for offset, row in enumerate(self.partition_list): for offset, row in enumerate(self.partition_list):
removed_cell_list = [] removed_cell_list = []
feeding_cell = None feeding_cell = None
out_of_date_cell_present = False
out_of_date_cell_list = [] out_of_date_cell_list = []
up_to_date_cell_list = [] up_to_date_cell_list = []
for cell in row: for cell in row:
......
...@@ -126,7 +126,6 @@ class RecoveryEventHandler(MasterEventHandler): ...@@ -126,7 +126,6 @@ class RecoveryEventHandler(MasterEventHandler):
def handleAnswerPartitionTable(self, conn, packet, ptid, row_list): def handleAnswerPartitionTable(self, conn, packet, ptid, row_list):
uuid = conn.getUUID() uuid = conn.getUUID()
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
if uuid != app.target_uuid: if uuid != app.target_uuid:
# If this is not from a target node, ignore it. # If this is not from a target node, ignore it.
logging.warn('got answer partition table from %s while waiting for %s', logging.warn('got answer partition table from %s while waiting for %s',
......
...@@ -171,8 +171,6 @@ class ClientServiceEventHandler(ServiceEventHandler): ...@@ -171,8 +171,6 @@ class ClientServiceEventHandler(ServiceEventHandler):
del app.finishing_transaction_dict[tid] del app.finishing_transaction_dict[tid]
def handleAbortTransaction(self, conn, packet, tid): def handleAbortTransaction(self, conn, packet, tid):
uuid = conn.getUUID()
node = self.app.nm.getNodeByUUID(uuid)
try: try:
del self.app.finishing_transaction_dict[tid] del self.app.finishing_transaction_dict[tid]
except KeyError: except KeyError:
...@@ -180,24 +178,18 @@ class ClientServiceEventHandler(ServiceEventHandler): ...@@ -180,24 +178,18 @@ class ClientServiceEventHandler(ServiceEventHandler):
pass pass
def handleAskNewTID(self, conn, packet): def handleAskNewTID(self, conn, packet):
uuid = conn.getUUID()
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
tid = app.getNextTID() tid = app.getNextTID()
app.finishing_transaction_dict[tid] = FinishingTransaction(conn) app.finishing_transaction_dict[tid] = FinishingTransaction(conn)
conn.answer(protocol.answerNewTID(tid), packet) conn.answer(protocol.answerNewTID(tid), packet)
def handleAskNewOIDs(self, conn, packet, num_oids): def handleAskNewOIDs(self, conn, packet, num_oids):
uuid = conn.getUUID()
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
oid_list = app.getNewOIDList(num_oids) oid_list = app.getNewOIDList(num_oids)
conn.answer(protocol.answerNewOIDs(oid_list), packet) conn.answer(protocol.answerNewOIDs(oid_list), packet)
def handleFinishTransaction(self, conn, packet, oid_list, tid): def handleFinishTransaction(self, conn, packet, oid_list, tid):
uuid = conn.getUUID()
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
# If the given transaction ID is later than the last TID, the peer # If the given transaction ID is later than the last TID, the peer
# is crazy. # is crazy.
if app.ltid < tid: if app.ltid < tid:
...@@ -303,9 +295,7 @@ class StorageServiceEventHandler(ServiceEventHandler): ...@@ -303,9 +295,7 @@ class StorageServiceEventHandler(ServiceEventHandler):
pass pass
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid): def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid):
uuid = conn.getUUID()
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
# If I get a bigger value here, it is dangerous. # If I get a bigger value here, it is dangerous.
if app.loid < loid or app.ltid < ltid or app.pt.getID() < lptid: if app.loid < loid or app.ltid < ltid or app.pt.getID() < lptid:
logging.critical('got later information in service') logging.critical('got later information in service')
......
...@@ -109,9 +109,7 @@ class VerificationEventHandler(MasterEventHandler): ...@@ -109,9 +109,7 @@ class VerificationEventHandler(MasterEventHandler):
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid): def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid):
uuid = conn.getUUID()
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
# If I get a bigger value here, it is dangerous. # If I get a bigger value here, it is dangerous.
if app.loid < loid or app.ltid < ltid or app.lptid < lptid: if app.loid < loid or app.ltid < ltid or app.lptid < lptid:
logging.critical('got later information in verification') logging.critical('got later information in verification')
...@@ -122,7 +120,6 @@ class VerificationEventHandler(MasterEventHandler): ...@@ -122,7 +120,6 @@ class VerificationEventHandler(MasterEventHandler):
logging.info('got unfinished transactions %s from %s:%d', logging.info('got unfinished transactions %s from %s:%d',
tid_list, *(conn.getAddress())) tid_list, *(conn.getAddress()))
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
if app.asking_uuid_dict.get(uuid, True): if app.asking_uuid_dict.get(uuid, True):
# No interest. # No interest.
return return
...@@ -135,7 +132,6 @@ class VerificationEventHandler(MasterEventHandler): ...@@ -135,7 +132,6 @@ class VerificationEventHandler(MasterEventHandler):
logging.info('got OIDs %s for %s from %s:%d', logging.info('got OIDs %s for %s from %s:%d',
oid_list, tid, *(conn.getAddress())) oid_list, tid, *(conn.getAddress()))
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
if app.asking_uuid_dict.get(uuid, True): if app.asking_uuid_dict.get(uuid, True):
# No interest. # No interest.
return return
...@@ -154,7 +150,6 @@ class VerificationEventHandler(MasterEventHandler): ...@@ -154,7 +150,6 @@ class VerificationEventHandler(MasterEventHandler):
uuid = conn.getUUID() uuid = conn.getUUID()
logging.info('TID not found: %s', message) logging.info('TID not found: %s', message)
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
if app.asking_uuid_dict.get(uuid, True): if app.asking_uuid_dict.get(uuid, True):
# No interest. # No interest.
return return
...@@ -165,7 +160,6 @@ class VerificationEventHandler(MasterEventHandler): ...@@ -165,7 +160,6 @@ class VerificationEventHandler(MasterEventHandler):
uuid = conn.getUUID() uuid = conn.getUUID()
logging.info('object %s:%s found', dump(oid), dump(tid)) logging.info('object %s:%s found', dump(oid), dump(tid))
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
if app.asking_uuid_dict.get(uuid, True): if app.asking_uuid_dict.get(uuid, True):
# No interest. # No interest.
return return
...@@ -175,7 +169,6 @@ class VerificationEventHandler(MasterEventHandler): ...@@ -175,7 +169,6 @@ class VerificationEventHandler(MasterEventHandler):
uuid = conn.getUUID() uuid = conn.getUUID()
logging.info('OID not found: %s', message) logging.info('OID not found: %s', message)
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
if app.asking_uuid_dict.get(uuid, True): if app.asking_uuid_dict.get(uuid, True):
# No interest. # No interest.
return return
......
...@@ -268,7 +268,6 @@ class Application(object): ...@@ -268,7 +268,6 @@ class Application(object):
logging.info('doing operation') logging.info('doing operation')
em = self.em em = self.em
nm = self.nm
handler = handlers.MasterOperationHandler(self) handler = handlers.MasterOperationHandler(self)
self.master_conn.setHandler(handler) self.master_conn.setHandler(handler)
...@@ -320,8 +319,8 @@ class Application(object): ...@@ -320,8 +319,8 @@ class Application(object):
l = len(self.event_queue) l = len(self.event_queue)
p = self.event_queue.popleft p = self.event_queue.popleft
for i in xrange(l): for i in xrange(l):
callable, args, kwargs = p() _callable, args, kwargs = p()
callable(*args, **kwargs) _callable(*args, **kwargs)
def getPartition(self, oid_or_tid): def getPartition(self, oid_or_tid):
return unpack('!Q', oid_or_tid)[0] % self.num_partitions return unpack('!Q', oid_or_tid)[0] % self.num_partitions
......
...@@ -28,7 +28,6 @@ class BootstrapHandler(BaseStorageHandler): ...@@ -28,7 +28,6 @@ class BootstrapHandler(BaseStorageHandler):
"""This class deals with events for a bootstrap phase.""" """This class deals with events for a bootstrap phase."""
def connectionCompleted(self, conn): def connectionCompleted(self, conn):
app = self.app
conn.ask(protocol.askPrimaryMaster()) conn.ask(protocol.askPrimaryMaster())
BaseStorageHandler.connectionCompleted(self, conn) BaseStorageHandler.connectionCompleted(self, conn)
......
...@@ -80,7 +80,6 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -80,7 +80,6 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
BaseClientAndStorageOperationHandler.connectionCompleted(self, conn) BaseClientAndStorageOperationHandler.connectionCompleted(self, conn)
def handleAbortTransaction(self, conn, packet, tid): def handleAbortTransaction(self, conn, packet, tid):
uuid = conn.getUUID()
app = self.app app = self.app
try: try:
t = app.transaction_dict[tid] t = app.transaction_dict[tid]
......
...@@ -100,7 +100,6 @@ class BaseMasterHandler(BaseStorageHandler): ...@@ -100,7 +100,6 @@ class BaseMasterHandler(BaseStorageHandler):
# XXX it might be better to implement this callback in each handler. # XXX it might be better to implement this callback in each handler.
uuid = conn.getUUID() uuid = conn.getUUID()
app = self.app app = self.app
node = app.nm.getNodeByUUID(uuid)
if app.primary_master_node is None \ if app.primary_master_node is None \
or app.primary_master_node.getUUID() != uuid: or app.primary_master_node.getUUID() != uuid:
return return
......
...@@ -52,8 +52,6 @@ class HiddenHandler(BaseStorageHandler): ...@@ -52,8 +52,6 @@ class HiddenHandler(BaseStorageHandler):
return return
for node_type, ip_address, port, uuid, state in node_list: for node_type, ip_address, port, uuid, state in node_list:
addr = (ip_address, port)
if node_type == STORAGE_NODE_TYPE: if node_type == STORAGE_NODE_TYPE:
if uuid == INVALID_UUID: if uuid == INVALID_UUID:
# No interest. # No interest.
......
...@@ -40,8 +40,7 @@ class IdentificationHandler(BaseStorageHandler): ...@@ -40,8 +40,7 @@ class IdentificationHandler(BaseStorageHandler):
# reject any incoming connections if not ready # reject any incoming connections if not ready
if not self.app.ready: if not self.app.ready:
raise protocol.NotReadyError raise protocol.NotReadyError
app, nm = self.app, self.app.nm app = self.app
server = (ip_address, port)
node = app.nm.getNodeByUUID(uuid) node = app.nm.getNodeByUUID(uuid)
if node is None: if node is None:
logging.error('reject an unknown node %s', dump(uuid)) logging.error('reject an unknown node %s', dump(uuid))
......
...@@ -132,8 +132,7 @@ class Replicator(object): ...@@ -132,8 +132,7 @@ class Replicator(object):
partition.setCriticalTID(tid) partition.setCriticalTID(tid)
del self.critical_tid_dict[msg_id] del self.critical_tid_dict[msg_id]
except KeyError: except KeyError:
logging.infor("setCriticalTID raised KeyError for msg_id %s" %(msg_id,)) logging.info("setCriticalTID raised KeyError for msg_id %s" %(msg_id,))
pass
def _askCriticalTID(self): def _askCriticalTID(self):
conn = self.primary_master_connection conn = self.primary_master_connection
......
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