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

Because the purpose of an handler is to *handle* (packets), remove the 'handle'

prefix from everywhere.


git-svn-id: https://svn.erp5.org/repos/neo/trunk@1350 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent a53b51dd
...@@ -25,7 +25,7 @@ from neo.util import dump ...@@ -25,7 +25,7 @@ from neo.util import dump
class AdminEventHandler(EventHandler): class AdminEventHandler(EventHandler):
"""This class deals with events for administrating cluster.""" """This class deals with events for administrating cluster."""
def handleAskPartitionList(self, conn, packet, min_offset, max_offset, uuid): def askPartitionList(self, conn, packet, min_offset, max_offset, uuid):
logging.info("ask partition list from %s to %s for %s" %(min_offset, max_offset, dump(uuid))) logging.info("ask partition list from %s to %s for %s" %(min_offset, max_offset, dump(uuid)))
app = self.app app = self.app
# check we have one pt otherwise ask it to PMN # check we have one pt otherwise ask it to PMN
...@@ -43,7 +43,7 @@ class AdminEventHandler(EventHandler): ...@@ -43,7 +43,7 @@ class AdminEventHandler(EventHandler):
app.sendPartitionTable(conn, min_offset, max_offset, uuid, packet.getId()) app.sendPartitionTable(conn, min_offset, max_offset, uuid, packet.getId())
def handleAskNodeList(self, conn, packet, node_type): def askNodeList(self, conn, packet, node_type):
logging.info("ask node list for %s" %(node_type)) logging.info("ask node list for %s" %(node_type))
def node_filter(n): def node_filter(n):
return n.getType() is node_type return n.getType() is node_type
...@@ -52,7 +52,7 @@ class AdminEventHandler(EventHandler): ...@@ -52,7 +52,7 @@ class AdminEventHandler(EventHandler):
p = protocol.answerNodeList(node_information_list) p = protocol.answerNodeList(node_information_list)
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
def handleSetNodeState(self, conn, packet, uuid, state, modify_partition_table): def setNodeState(self, conn, packet, uuid, state, modify_partition_table):
logging.info("set node state for %s-%s" %(dump(uuid), state)) logging.info("set node state for %s-%s" %(dump(uuid), state))
node = self.app.nm.getByUUID(uuid) node = self.app.nm.getByUUID(uuid)
if node is None: if node is None:
...@@ -69,7 +69,7 @@ class AdminEventHandler(EventHandler): ...@@ -69,7 +69,7 @@ class AdminEventHandler(EventHandler):
msg_id = self.app.master_conn.ask(p) msg_id = self.app.master_conn.ask(p)
self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()}) self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()})
def handleSetClusterState(self, conn, packet, state): def setClusterState(self, conn, packet, state):
# forward to primary # forward to primary
if self.app.master_conn is None: if self.app.master_conn is None:
raise protocol.NotReadyError('Not connected to a primary master.') raise protocol.NotReadyError('Not connected to a primary master.')
...@@ -77,7 +77,7 @@ class AdminEventHandler(EventHandler): ...@@ -77,7 +77,7 @@ class AdminEventHandler(EventHandler):
msg_id = self.app.master_conn.ask(p) msg_id = self.app.master_conn.ask(p)
self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()}) self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()})
def handleAddPendingNodes(self, conn, packet, uuid_list): def addPendingNodes(self, conn, packet, uuid_list):
if self.app.master_conn is None: if self.app.master_conn is None:
raise protocol.NotReadyError('Not connected to a primary master.') raise protocol.NotReadyError('Not connected to a primary master.')
logging.info('Add nodes %s' % [dump(uuid) for uuid in uuid_list]) logging.info('Add nodes %s' % [dump(uuid) for uuid in uuid_list])
...@@ -85,7 +85,7 @@ class AdminEventHandler(EventHandler): ...@@ -85,7 +85,7 @@ class AdminEventHandler(EventHandler):
msg_id = self.app.master_conn.ask(protocol.addPendingNodes(uuid_list)) msg_id = self.app.master_conn.ask(protocol.addPendingNodes(uuid_list))
self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()}) self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()})
def handleAskClusterState(self, conn, packet): def askClusterState(self, conn, packet):
if self.app.cluster_state is None: if self.app.cluster_state is None:
if self.app.master_conn is None: if self.app.master_conn is None:
raise protocol.NotReadyError('Not connected to a primary master.') raise protocol.NotReadyError('Not connected to a primary master.')
...@@ -96,7 +96,7 @@ class AdminEventHandler(EventHandler): ...@@ -96,7 +96,7 @@ class AdminEventHandler(EventHandler):
conn.answer(protocol.answerClusterState(self.app.cluster_state), conn.answer(protocol.answerClusterState(self.app.cluster_state),
packet.getId()) packet.getId())
def handleAskPrimaryMaster(self, conn, packet): def askPrimaryMaster(self, conn, packet):
if self.app.master_conn is None: if self.app.master_conn is None:
raise protocol.NotReadyError('Not connected to a primary master.') raise protocol.NotReadyError('Not connected to a primary master.')
master_node = self.app.master_node master_node = self.app.master_node
...@@ -135,17 +135,17 @@ class MasterEventHandler(EventHandler): ...@@ -135,17 +135,17 @@ class MasterEventHandler(EventHandler):
# unexpectexd answers and notifications # unexpectexd answers and notifications
super(MasterEventHandler, self).dispatch(conn, packet) super(MasterEventHandler, self).dispatch(conn, packet)
def handleAnswerNodeInformation(self, conn, packet, node_list): def answerNodeInformation(self, conn, packet, node_list):
# XXX: This will no more exists when the initialization module will be # XXX: This will no more exists when the initialization module will be
# implemented for factorize code (as done for bootstrap) # implemented for factorize code (as done for bootstrap)
logging.debug("handleAnswerNodeInformation") logging.debug("answerNodeInformation")
def handleAnswerPartitionTable(self, conn, packet, ptid, row_list): def answerPartitionTable(self, conn, packet, ptid, row_list):
# XXX: This will no more exists when the initialization module will be # XXX: This will no more exists when the initialization module will be
# implemented for factorize code (as done for bootstrap) # implemented for factorize code (as done for bootstrap)
logging.debug("handleAnswerPartitionTable") logging.debug("answerPartitionTable")
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list): def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
app = self.app app = self.app
if ptid < app.ptid: if ptid < app.ptid:
# Ignore this packet. # Ignore this packet.
...@@ -153,7 +153,7 @@ class MasterEventHandler(EventHandler): ...@@ -153,7 +153,7 @@ class MasterEventHandler(EventHandler):
app.ptid = ptid app.ptid = ptid
app.pt.update(ptid, cell_list, app.nm) app.pt.update(ptid, cell_list, app.nm)
def handleSendPartitionTable(self, conn, packet, ptid, row_list): def sendPartitionTable(self, conn, packet, ptid, row_list):
uuid = conn.getUUID() uuid = conn.getUUID()
app = self.app app = self.app
nm = app.nm nm = app.nm
...@@ -170,10 +170,10 @@ class MasterEventHandler(EventHandler): ...@@ -170,10 +170,10 @@ class MasterEventHandler(EventHandler):
pt.setCell(offset, node, state) pt.setCell(offset, node, state)
pt.log() pt.log()
def handleNotifyClusterInformation(self, conn, packet, cluster_state): def notifyClusterInformation(self, conn, packet, cluster_state):
self.app.cluster_state = cluster_state self.app.cluster_state = cluster_state
def handleNotifyNodeInformation(self, conn, packet, node_list): def notifyNodeInformation(self, conn, packet, node_list):
app = self.app app = self.app
app.nm.update(node_list) app.nm.update(node_list)
if not app.pt.filled(): if not app.pt.filled():
...@@ -189,30 +189,30 @@ class MasterRequestEventHandler(EventHandler): ...@@ -189,30 +189,30 @@ class MasterRequestEventHandler(EventHandler):
client_conn, kw = self.app.dispatcher.pop(msg_id) client_conn, kw = self.app.dispatcher.pop(msg_id)
client_conn.answer(packet, kw['msg_id']) client_conn.answer(packet, kw['msg_id'])
def handleAnswerClusterState(self, conn, packet, state): def answerClusterState(self, conn, packet, state):
logging.info("handleAnswerClusterState for a conn") logging.info("answerClusterState for a conn")
self.app.cluster_state = state self.app.cluster_state = state
self.__answerNeoCTL(packet.getId(), self.__answerNeoCTL(packet.getId(),
protocol.answerClusterState(state)) protocol.answerClusterState(state))
def handleAnswerNewNodes(self, conn, packet, uuid_list): def answerNewNodes(self, conn, packet, uuid_list):
logging.info("handleAnswerNewNodes for a conn") logging.info("answerNewNodes for a conn")
self.__answerNeoCTL(packet.getId(), self.__answerNeoCTL(packet.getId(),
protocol.answerNewNodes(uuid_list)) protocol.answerNewNodes(uuid_list))
def handleAnswerPartitionTable(self, conn, packet, ptid, row_list): def answerPartitionTable(self, conn, packet, ptid, row_list):
logging.info("handleAnswerPartitionTable for a conn") logging.info("answerPartitionTable for a conn")
client_conn, kw = self.app.dispatcher.pop(packet.getId()) client_conn, kw = self.app.dispatcher.pop(packet.getId())
# sent client the partition table # sent client the partition table
self.app.sendPartitionTable(client_conn, **kw) self.app.sendPartitionTable(client_conn, **kw)
def handleAnswerNodeState(self, conn, packet, uuid, state): def answerNodeState(self, conn, packet, uuid, state):
self.__answerNeoCTL(packet.getId(), self.__answerNeoCTL(packet.getId(),
protocol.answerNodeState(uuid, state)) protocol.answerNodeState(uuid, state))
def handleNoError(self, conn, packet, msg): def noError(self, conn, packet, msg):
self.__answerNeoCTL(packet.getId(), protocol.noError(msg)) self.__answerNeoCTL(packet.getId(), protocol.noError(msg))
def handleProtocolError(self, conn, packet, msg): def protocolError(self, conn, packet, msg):
self.__answerNeoCTL(packet.getId(), protocol.protocolError(msg)) self.__answerNeoCTL(packet.getId(), protocol.protocolError(msg))
...@@ -52,12 +52,12 @@ class BootstrapManager(EventHandler): ...@@ -52,12 +52,12 @@ class BootstrapManager(EventHandler):
def connectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
self.current = None self.current = None
def handleNotReady(self, conn, packet, message): def notReady(self, conn, packet, message):
# master are still electing on of them # master are still electing on of them
self.current = None self.current = None
conn.close() conn.close()
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, known_master_list): def answerPrimaryMaster(self, conn, packet, primary_uuid, known_master_list):
nm = self.app.nm nm = self.app.nm
# Register new master nodes. # Register new master nodes.
...@@ -81,7 +81,7 @@ class BootstrapManager(EventHandler): ...@@ -81,7 +81,7 @@ class BootstrapManager(EventHandler):
conn.ask(protocol.requestNodeIdentification(self.node_type, conn.ask(protocol.requestNodeIdentification(self.node_type,
self.uuid, self.server, self.name)) self.uuid, self.server, self.name))
def handleAcceptNodeIdentification(self, conn, packet, node_type, def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, num_replicas, your_uuid): uuid, address, num_partitions, num_replicas, your_uuid):
self.num_partitions = num_partitions self.num_partitions = num_partitions
self.num_replicas = num_replicas self.num_replicas = num_replicas
......
...@@ -25,12 +25,12 @@ from neo.util import dump ...@@ -25,12 +25,12 @@ from neo.util import dump
class PrimaryBootstrapHandler(AnswerBaseHandler): class PrimaryBootstrapHandler(AnswerBaseHandler):
""" Bootstrap handler used when looking for the primary master """ """ Bootstrap handler used when looking for the primary master """
def handleNotReady(self, conn, packet, message): def notReady(self, conn, packet, message):
app = self.app app = self.app
app.trying_master_node = None app.trying_master_node = None
app.setNodeNotReady() app.setNodeNotReady()
def handleAcceptNodeIdentification(self, conn, packet, node_type, def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, num_replicas, your_uuid): uuid, address, num_partitions, num_replicas, your_uuid):
app = self.app app = self.app
node = app.nm.getByAddress(conn.getAddress()) node = app.nm.getByAddress(conn.getAddress())
...@@ -57,7 +57,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler): ...@@ -57,7 +57,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
# Always create partition table # Always create partition table
app.pt = PartitionTable(num_partitions, num_replicas) app.pt = PartitionTable(num_partitions, num_replicas)
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, def answerPrimaryMaster(self, conn, packet, primary_uuid,
known_master_list): known_master_list):
app = self.app app = self.app
# Register new master nodes. # Register new master nodes.
...@@ -92,10 +92,10 @@ class PrimaryBootstrapHandler(AnswerBaseHandler): ...@@ -92,10 +92,10 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
app.trying_master_node = None app.trying_master_node = None
conn.close() conn.close()
def handleAnswerPartitionTable(self, conn, packet, ptid, row_list): def answerPartitionTable(self, conn, packet, ptid, row_list):
pass pass
def handleAnswerNodeInformation(self, conn, packet, node_list): def answerNodeInformation(self, conn, packet, node_list):
pass pass
class PrimaryNotificationsHandler(BaseHandler): class PrimaryNotificationsHandler(BaseHandler):
...@@ -126,10 +126,10 @@ class PrimaryNotificationsHandler(BaseHandler): ...@@ -126,10 +126,10 @@ class PrimaryNotificationsHandler(BaseHandler):
logging.critical("primary master node is broken") logging.critical("primary master node is broken")
BaseHandler.peerBroken(self, conn) BaseHandler.peerBroken(self, conn)
def handleStopOperation(self, conn, packet): def stopOperation(self, conn, packet):
logging.critical("master node ask to stop operation") logging.critical("master node ask to stop operation")
def handleInvalidateObjects(self, conn, packet, oid_list, tid): def invalidateObjects(self, conn, packet, oid_list, tid):
app = self.app app = self.app
app._cache_lock_acquire() app._cache_lock_acquire()
try: try:
...@@ -151,15 +151,15 @@ class PrimaryNotificationsHandler(BaseHandler): ...@@ -151,15 +151,15 @@ class PrimaryNotificationsHandler(BaseHandler):
# to avoid a dead lock. It is safe to not check the master connection # to avoid a dead lock. It is safe to not check the master connection
# because it's in the master handler, so the connection is already # because it's in the master handler, so the connection is already
# established. # established.
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list): def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
pt = self.app.pt pt = self.app.pt
if pt.filled(): if pt.filled():
pt.update(ptid, cell_list, self.app.nm) pt.update(ptid, cell_list, self.app.nm)
def handleSendPartitionTable(self, conn, packet, ptid, row_list): def sendPartitionTable(self, conn, packet, ptid, row_list):
self.app.pt.load(ptid, row_list, self.app.nm) self.app.pt.load(ptid, row_list, self.app.nm)
def handleNotifyNodeInformation(self, conn, packet, node_list): def notifyNodeInformation(self, conn, packet, node_list):
app = self.app app = self.app
self.app.nm.update(node_list) self.app.nm.update(node_list)
for node_type, addr, uuid, state in node_list: for node_type, addr, uuid, state in node_list:
...@@ -178,16 +178,16 @@ class PrimaryNotificationsHandler(BaseHandler): ...@@ -178,16 +178,16 @@ class PrimaryNotificationsHandler(BaseHandler):
class PrimaryAnswersHandler(AnswerBaseHandler): class PrimaryAnswersHandler(AnswerBaseHandler):
""" Handle that process expected packets from the primary master """ """ Handle that process expected packets from the primary master """
def handleAnswerBeginTransaction(self, conn, packet, tid): def answerBeginTransaction(self, conn, packet, tid):
app = self.app app = self.app
app.setTID(tid) app.setTID(tid)
def handleAnswerNewOIDs(self, conn, packet, oid_list): def answerNewOIDs(self, conn, packet, oid_list):
app = self.app app = self.app
app.new_oid_list = oid_list app.new_oid_list = oid_list
app.new_oid_list.reverse() app.new_oid_list.reverse()
def handleNotifyTransactionFinished(self, conn, packet, tid): def notifyTransactionFinished(self, conn, packet, tid):
app = self.app app = self.app
if tid == app.getTID(): if tid == app.getTID():
app.setTransactionFinished() app.setTransactionFinished()
......
...@@ -48,11 +48,11 @@ class StorageEventHandler(BaseHandler): ...@@ -48,11 +48,11 @@ class StorageEventHandler(BaseHandler):
class StorageBootstrapHandler(AnswerBaseHandler): class StorageBootstrapHandler(AnswerBaseHandler):
""" Handler used when connecting to a storage node """ """ Handler used when connecting to a storage node """
def handleNotReady(self, conn, packet, message): def notReady(self, conn, packet, message):
app = self.app app = self.app
app.setNodeNotReady() app.setNodeNotReady()
def handleAcceptNodeIdentification(self, conn, packet, node_type, def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, num_replicas, your_uuid): uuid, address, num_partitions, num_replicas, your_uuid):
app = self.app app = self.app
node = app.nm.getByAddress(conn.getAddress()) node = app.nm.getByAddress(conn.getAddress())
...@@ -75,24 +75,24 @@ class StorageBootstrapHandler(AnswerBaseHandler): ...@@ -75,24 +75,24 @@ class StorageBootstrapHandler(AnswerBaseHandler):
class StorageAnswersHandler(AnswerBaseHandler): class StorageAnswersHandler(AnswerBaseHandler):
""" Handle all messages related to ZODB operations """ """ Handle all messages related to ZODB operations """
def handleAnswerObject(self, conn, packet, oid, start_serial, end_serial, def answerObject(self, conn, packet, oid, start_serial, end_serial,
compression, checksum, data): compression, checksum, data):
app = self.app app = self.app
app.local_var.asked_object = (oid, start_serial, end_serial, compression, app.local_var.asked_object = (oid, start_serial, end_serial, compression,
checksum, data) checksum, data)
def handleAnswerStoreObject(self, conn, packet, conflicting, oid, serial): def answerStoreObject(self, conn, packet, conflicting, oid, serial):
app = self.app app = self.app
if conflicting: if conflicting:
app.local_var.object_stored = -1, serial app.local_var.object_stored = -1, serial
else: else:
app.local_var.object_stored = oid, serial app.local_var.object_stored = oid, serial
def handleAnswerStoreTransaction(self, conn, packet, tid): def answerStoreTransaction(self, conn, packet, tid):
app = self.app app = self.app
app.setTransactionVoted() app.setTransactionVoted()
def handleAnswerTransactionInformation(self, conn, packet, tid, def answerTransactionInformation(self, conn, packet, tid,
user, desc, ext, oid_list): user, desc, ext, oid_list):
app = self.app app = self.app
# transaction information are returned as a dict # transaction information are returned as a dict
...@@ -104,12 +104,12 @@ class StorageAnswersHandler(AnswerBaseHandler): ...@@ -104,12 +104,12 @@ class StorageAnswersHandler(AnswerBaseHandler):
info['oids'] = oid_list info['oids'] = oid_list
app.local_var.txn_info = info app.local_var.txn_info = info
def handleAnswerObjectHistory(self, conn, packet, oid, history_list): def answerObjectHistory(self, conn, packet, oid, history_list):
app = self.app app = self.app
# history_list is a list of tuple (serial, size) # history_list is a list of tuple (serial, size)
app.local_var.history = oid, history_list app.local_var.history = oid, history_list
def handleOidNotFound(self, conn, packet, message): def oidNotFound(self, conn, packet, message):
app = self.app app = self.app
# This can happen either when : # This can happen either when :
# - loading an object # - loading an object
...@@ -117,12 +117,12 @@ class StorageAnswersHandler(AnswerBaseHandler): ...@@ -117,12 +117,12 @@ class StorageAnswersHandler(AnswerBaseHandler):
app.local_var.asked_object = -1 app.local_var.asked_object = -1
app.local_var.history = -1 app.local_var.history = -1
def handleTidNotFound(self, conn, packet, message): def tidNotFound(self, conn, packet, message):
app = self.app app = self.app
# This can happen when requiring txn informations # This can happen when requiring txn informations
app.local_var.txn_info = -1 app.local_var.txn_info = -1
def handleAnswerTIDs(self, conn, packet, tid_list): def answerTIDs(self, conn, packet, tid_list):
app = self.app app = self.app
app.local_var.node_tids[conn.getUUID()] = tid_list app.local_var.node_tids[conn.getUUID()] = tid_list
This diff is collapsed.
...@@ -24,10 +24,10 @@ from neo.protocol import NodeTypes, NodeStates ...@@ -24,10 +24,10 @@ from neo.protocol import NodeTypes, NodeStates
class MasterHandler(EventHandler): class MasterHandler(EventHandler):
"""This class implements a generic part of the event handlers.""" """This class implements a generic part of the event handlers."""
def handleProtocolError(self, conn, packet, message): def protocolError(self, conn, packet, message):
logging.error('Protocol error %s %s' % (message, conn.getAddress())) logging.error('Protocol error %s %s' % (message, conn.getAddress()))
def handleAskPrimaryMaster(self, conn, packet): def askPrimaryMaster(self, conn, packet):
if conn.getConnector() is None: if conn.getConnector() is None:
# Connection can be closed by peer after he sent AskPrimaryMaster # Connection can be closed by peer after he sent AskPrimaryMaster
# if he finds the primary master before we answer him. # if he finds the primary master before we answer him.
...@@ -54,16 +54,16 @@ class MasterHandler(EventHandler): ...@@ -54,16 +54,16 @@ class MasterHandler(EventHandler):
packet.getId(), packet.getId(),
) )
def handleAskClusterState(self, conn, packet): def askClusterState(self, conn, packet):
assert conn.getUUID() is not None assert conn.getUUID() is not None
state = self.app.getClusterState() state = self.app.getClusterState()
conn.answer(protocol.answerClusterState(state), packet.getId()) conn.answer(protocol.answerClusterState(state), packet.getId())
def handleAskNodeInformation(self, conn, packet): def askNodeInformation(self, conn, packet):
self.app.sendNodesInformations(conn) self.app.sendNodesInformations(conn)
conn.answer(protocol.answerNodeInformation([]), packet.getId()) conn.answer(protocol.answerNodeInformation([]), packet.getId())
def handleAskPartitionTable(self, conn, packet, offset_list): def askPartitionTable(self, conn, packet, offset_list):
assert len(offset_list) == 0 assert len(offset_list) == 0
app = self.app app = self.app
app.sendPartitionTable(conn) app.sendPartitionTable(conn)
...@@ -78,7 +78,7 @@ DISCONNECTED_STATE_DICT = { ...@@ -78,7 +78,7 @@ DISCONNECTED_STATE_DICT = {
class BaseServiceHandler(MasterHandler): class BaseServiceHandler(MasterHandler):
"""This class deals with events for a service phase.""" """This class deals with events for a service phase."""
def handleNodeLost(self, conn, node): def nodeLost(self, conn, node):
# This method provides a hook point overridable by service classes. # This method provides a hook point overridable by service classes.
# It is triggered when a connection to a node gets lost. # It is triggered when a connection to a node gets lost.
pass pass
...@@ -98,13 +98,13 @@ class BaseServiceHandler(MasterHandler): ...@@ -98,13 +98,13 @@ class BaseServiceHandler(MasterHandler):
node.setState(new_state) node.setState(new_state)
self.app.broadcastNodeInformation(node) self.app.broadcastNodeInformation(node)
# clean node related data in specialized handlers # clean node related data in specialized handlers
self.handleNodeLost(conn, node) self.nodeLost(conn, node)
def handleAskLastIDs(self, conn, packet): def askLastIDs(self, conn, packet):
app = self.app app = self.app
conn.answer(protocol.answerLastIDs(app.loid, app.ltid, app.pt.getID()), packet.getId()) conn.answer(protocol.answerLastIDs(app.loid, app.ltid, app.pt.getID()), packet.getId())
def handleAskUnfinishedTransactions(self, conn, packet): def askUnfinishedTransactions(self, conn, packet):
app = self.app app = self.app
p = protocol.answerUnfinishedTransactions(app.finishing_transaction_dict.keys()) p = protocol.answerUnfinishedTransactions(app.finishing_transaction_dict.keys())
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
......
...@@ -29,12 +29,12 @@ class AdministrationHandler(MasterHandler): ...@@ -29,12 +29,12 @@ class AdministrationHandler(MasterHandler):
node = self.app.nm.getByUUID(conn.getUUID()) node = self.app.nm.getByUUID(conn.getUUID())
self.app.nm.remove(node) self.app.nm.remove(node)
def handleAskPrimaryMaster(self, conn, packet): def askPrimaryMaster(self, conn, packet):
app = self.app app = self.app
# I'm the primary # I'm the primary
conn.answer(protocol.answerPrimaryMaster(app.uuid, []), packet.getId()) conn.answer(protocol.answerPrimaryMaster(app.uuid, []), packet.getId())
def handleSetClusterState(self, conn, packet, state): def setClusterState(self, conn, packet, state):
self.app.changeClusterState(state) self.app.changeClusterState(state)
p = protocol.noError('cluster state changed') p = protocol.noError('cluster state changed')
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
...@@ -42,7 +42,7 @@ class AdministrationHandler(MasterHandler): ...@@ -42,7 +42,7 @@ class AdministrationHandler(MasterHandler):
self.app.cluster_state = state self.app.cluster_state = state
self.app.shutdown() self.app.shutdown()
def handleSetNodeState(self, conn, packet, uuid, state, modify_partition_table): def setNodeState(self, conn, packet, uuid, state, modify_partition_table):
logging.info("set node state for %s-%s : %s" % (dump(uuid), state, modify_partition_table)) logging.info("set node state for %s-%s : %s" % (dump(uuid), state, modify_partition_table))
app = self.app app = self.app
node = app.nm.getByUUID(uuid) node = app.nm.getByUUID(uuid)
...@@ -92,7 +92,7 @@ class AdministrationHandler(MasterHandler): ...@@ -92,7 +92,7 @@ class AdministrationHandler(MasterHandler):
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
def handleAddPendingNodes(self, conn, packet, uuid_list): def addPendingNodes(self, conn, packet, uuid_list):
uuids = ', '.join([dump(uuid) for uuid in uuid_list]) uuids = ', '.join([dump(uuid) for uuid in uuid_list])
logging.debug('Add nodes %s' % uuids) logging.debug('Add nodes %s' % uuids)
app, nm, em, pt = self.app, self.app.nm, self.app.em, self.app.pt app, nm, em, pt = self.app, self.app.nm, self.app.em, self.app.pt
......
...@@ -68,19 +68,19 @@ class ClientServiceHandler(BaseServiceHandler): ...@@ -68,19 +68,19 @@ class ClientServiceHandler(BaseServiceHandler):
def connectionCompleted(self, conn): def connectionCompleted(self, conn):
pass pass
def handleNodeLost(self, conn, node): def nodeLost(self, conn, node):
app = self.app app = self.app
for tid, t in app.finishing_transaction_dict.items(): for tid, t in app.finishing_transaction_dict.items():
if t.getConnection() is conn: if t.getConnection() is conn:
del app.finishing_transaction_dict[tid] del app.finishing_transaction_dict[tid]
def handleAbortTransaction(self, conn, packet, tid): def abortTransaction(self, conn, packet, tid):
try: try:
del self.app.finishing_transaction_dict[tid] del self.app.finishing_transaction_dict[tid]
except KeyError: except KeyError:
logging.warn('aborting transaction %s does not exist', dump(tid)) logging.warn('aborting transaction %s does not exist', dump(tid))
def handleAskBeginTransaction(self, conn, packet, tid): def askBeginTransaction(self, conn, packet, tid):
app = self.app app = self.app
if tid is not None and tid < app.ltid: if tid is not None and tid < app.ltid:
# supplied TID is in the past # supplied TID is in the past
...@@ -92,11 +92,11 @@ class ClientServiceHandler(BaseServiceHandler): ...@@ -92,11 +92,11 @@ class ClientServiceHandler(BaseServiceHandler):
app.finishing_transaction_dict[tid] = FinishingTransaction(conn) app.finishing_transaction_dict[tid] = FinishingTransaction(conn)
conn.answer(protocol.answerBeginTransaction(tid), packet.getId()) conn.answer(protocol.answerBeginTransaction(tid), packet.getId())
def handleAskNewOIDs(self, conn, packet, num_oids): def askNewOIDs(self, conn, packet, num_oids):
oid_list = self.app.getNewOIDList(num_oids) oid_list = self.app.getNewOIDList(num_oids)
conn.answer(protocol.answerNewOIDs(oid_list), packet.getId()) conn.answer(protocol.answerNewOIDs(oid_list), packet.getId())
def handleFinishTransaction(self, conn, packet, oid_list, tid): def finishTransaction(self, conn, packet, oid_list, tid):
app = self.app app = self.app
# 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.
......
...@@ -25,7 +25,7 @@ from neo.exception import ElectionFailure ...@@ -25,7 +25,7 @@ from neo.exception import ElectionFailure
class ElectionHandler(MasterHandler): class ElectionHandler(MasterHandler):
"""This class deals with events for a primary master election.""" """This class deals with events for a primary master election."""
def handleNotifyNodeInformation(self, conn, packet, node_list): def notifyNodeInformation(self, conn, packet, node_list):
uuid = conn.getUUID() uuid = conn.getUUID()
if uuid is None: if uuid is None:
raise protocol.UnexpectedPacketError raise protocol.UnexpectedPacketError
...@@ -110,7 +110,7 @@ class ClientElectionHandler(ElectionHandler): ...@@ -110,7 +110,7 @@ class ClientElectionHandler(ElectionHandler):
app.negotiating_master_node_set.discard(addr) app.negotiating_master_node_set.discard(addr)
MasterHandler.peerBroken(self, conn) MasterHandler.peerBroken(self, conn)
def handleAcceptNodeIdentification(self, conn, packet, node_type, def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, uuid, address, num_partitions,
num_replicas, your_uuid): num_replicas, your_uuid):
app = self.app app = self.app
...@@ -146,7 +146,7 @@ class ClientElectionHandler(ElectionHandler): ...@@ -146,7 +146,7 @@ class ClientElectionHandler(ElectionHandler):
app.negotiating_master_node_set.discard(conn.getAddress()) app.negotiating_master_node_set.discard(conn.getAddress())
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, known_master_list): def answerPrimaryMaster(self, conn, packet, primary_uuid, known_master_list):
if conn.getConnector() is None: if conn.getConnector() is None:
# Connection can be closed by peer after he sent # Connection can be closed by peer after he sent
# AnswerPrimaryMaster if he finds the primary master before we # AnswerPrimaryMaster if he finds the primary master before we
...@@ -208,7 +208,7 @@ class ClientElectionHandler(ElectionHandler): ...@@ -208,7 +208,7 @@ class ClientElectionHandler(ElectionHandler):
class ServerElectionHandler(ElectionHandler): class ServerElectionHandler(ElectionHandler):
def handleReelectPrimaryMaster(self, conn, packet): def reelectPrimaryMaster(self, conn, packet):
raise ElectionFailure, 'reelection requested' raise ElectionFailure, 'reelection requested'
def peerBroken(self, conn): def peerBroken(self, conn):
...@@ -219,7 +219,7 @@ class ServerElectionHandler(ElectionHandler): ...@@ -219,7 +219,7 @@ class ServerElectionHandler(ElectionHandler):
node.setBroken() node.setBroken()
MasterHandler.peerBroken(self, conn) MasterHandler.peerBroken(self, conn)
def handleRequestNodeIdentification(self, conn, packet, node_type, def requestNodeIdentification(self, conn, packet, node_type,
uuid, address, name): uuid, address, name):
if conn.getConnector() is None: if conn.getConnector() is None:
# Connection can be closed by peer after he sent # Connection can be closed by peer after he sent
...@@ -260,7 +260,7 @@ class ServerElectionHandler(ElectionHandler): ...@@ -260,7 +260,7 @@ class ServerElectionHandler(ElectionHandler):
) )
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
def handleAnnouncePrimaryMaster(self, conn, packet): def announcePrimaryMaster(self, conn, packet):
uuid = conn.getUUID() uuid = conn.getUUID()
if uuid is None: if uuid is None:
raise protocol.UnexpectedPacketError raise protocol.UnexpectedPacketError
......
...@@ -24,10 +24,10 @@ from neo.master.handlers import MasterHandler ...@@ -24,10 +24,10 @@ from neo.master.handlers import MasterHandler
class IdentificationHandler(MasterHandler): class IdentificationHandler(MasterHandler):
"""This class deals with messages from the admin node only""" """This class deals with messages from the admin node only"""
def handleNodeLost(self, conn, node): def nodeLost(self, conn, node):
logging.warning('lost a node in IdentificationHandler : %s' % node) logging.warning('lost a node in IdentificationHandler : %s' % node)
def handleRequestNodeIdentification(self, conn, packet, node_type, def requestNodeIdentification(self, conn, packet, node_type,
uuid, address, name): uuid, address, name):
self.checkClusterName(name) self.checkClusterName(name)
......
...@@ -28,7 +28,7 @@ class RecoveryHandler(MasterHandler): ...@@ -28,7 +28,7 @@ class RecoveryHandler(MasterHandler):
# ask the last IDs to perform the recovery # ask the last IDs to perform the recovery
conn.ask(protocol.askLastIDs()) conn.ask(protocol.askLastIDs())
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid): def answerLastIDs(self, conn, packet, loid, ltid, lptid):
app = self.app app = self.app
pt = app.pt pt = app.pt
...@@ -41,7 +41,7 @@ class RecoveryHandler(MasterHandler): ...@@ -41,7 +41,7 @@ class RecoveryHandler(MasterHandler):
app.pt.setID(lptid) app.pt.setID(lptid)
conn.ask(protocol.askPartitionTable([])) conn.ask(protocol.askPartitionTable([]))
def handleAnswerPartitionTable(self, conn, packet, ptid, row_list): def answerPartitionTable(self, conn, packet, ptid, row_list):
uuid = conn.getUUID() uuid = conn.getUUID()
app = self.app app = self.app
if uuid != app.target_uuid: if uuid != app.target_uuid:
......
...@@ -34,13 +34,13 @@ class SecondaryMasterHandler(MasterHandler): ...@@ -34,13 +34,13 @@ class SecondaryMasterHandler(MasterHandler):
def connectionCompleted(self, conn): def connectionCompleted(self, conn):
pass pass
def handleAnnouncePrimaryMaster(self, conn, packet): def announcePrimaryMaster(self, conn, packet):
raise ElectionFailure, 'another primary arises' raise ElectionFailure, 'another primary arises'
def handleReelectPrimaryMaster(self, conn, packet): def reelectPrimaryMaster(self, conn, packet):
raise ElectionFailure, 'reelection requested' raise ElectionFailure, 'reelection requested'
def handleNotifyNodeInformation(self, conn, packet, node_list): def notifyNodeInformation(self, conn, packet, node_list):
logging.error('/!\ NotifyNodeInformation packet from secondary master') logging.error('/!\ NotifyNodeInformation packet from secondary master')
...@@ -58,13 +58,13 @@ class PrimaryMasterHandler(MasterHandler): ...@@ -58,13 +58,13 @@ class PrimaryMasterHandler(MasterHandler):
self.app.primary_master_node.setDown() self.app.primary_master_node.setDown()
raise PrimaryFailure, 'primary master is dead' raise PrimaryFailure, 'primary master is dead'
def handleAnnouncePrimaryMaster(self, conn, packet): def announcePrimaryMaster(self, conn, packet):
raise protocol.UnexpectedPacketError raise protocol.UnexpectedPacketError
def handleReelectPrimaryMaster(self, conn, packet): def reelectPrimaryMaster(self, conn, packet):
raise ElectionFailure, 'reelection requested' raise ElectionFailure, 'reelection requested'
def handleNotifyNodeInformation(self, conn, packet, node_list): def notifyNodeInformation(self, conn, packet, node_list):
app = self.app app = self.app
for node_type, addr, uuid, state in node_list: for node_type, addr, uuid, state in node_list:
if node_type != NodeTypes.MASTER: if node_type != NodeTypes.MASTER:
...@@ -86,7 +86,7 @@ class PrimaryMasterHandler(MasterHandler): ...@@ -86,7 +86,7 @@ class PrimaryMasterHandler(MasterHandler):
if n.getUUID() is None: if n.getUUID() is None:
n.setUUID(uuid) n.setUUID(uuid)
def handleAcceptNodeIdentification(self, conn, packet, node_type, def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, uuid, address, num_partitions,
num_replicas, your_uuid): num_replicas, your_uuid):
app = self.app app = self.app
...@@ -101,8 +101,8 @@ class PrimaryMasterHandler(MasterHandler): ...@@ -101,8 +101,8 @@ class PrimaryMasterHandler(MasterHandler):
conn.setUUID(uuid) conn.setUUID(uuid)
node.setUUID(uuid) node.setUUID(uuid)
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, known_master_list): def answerPrimaryMaster(self, conn, packet, primary_uuid, known_master_list):
pass pass
def handleNotifyClusterInformation(self, conn, packet, state): def notifyClusterInformation(self, conn, packet, state):
pass pass
...@@ -22,20 +22,20 @@ from neo.master.handlers import BaseServiceHandler ...@@ -22,20 +22,20 @@ from neo.master.handlers import BaseServiceHandler
class ShutdownHandler(BaseServiceHandler): class ShutdownHandler(BaseServiceHandler):
"""This class deals with events for a shutting down phase.""" """This class deals with events for a shutting down phase."""
def handleRequestNodeIdentification(self, conn, packet, node_type, def requestNodeIdentification(self, conn, packet, node_type,
uuid, address, name): uuid, address, name):
logging.error('reject any new connection') logging.error('reject any new connection')
raise protocol.ProtocolError('cluster is shutting down') raise protocol.ProtocolError('cluster is shutting down')
def handleAskPrimaryMaster(self, conn, packet): def askPrimaryMaster(self, conn, packet):
logging.error('reject any new demand for primary master') logging.error('reject any new demand for primary master')
raise protocol.ProtocolError('cluster is shutting down') raise protocol.ProtocolError('cluster is shutting down')
def handleAskBeginTransaction(self, conn, packet, tid): def askBeginTransaction(self, conn, packet, tid):
logging.error('reject any new demand for new tid') logging.error('reject any new demand for new tid')
raise protocol.ProtocolError('cluster is shutting down') raise protocol.ProtocolError('cluster is shutting down')
def handleNotifyNodeInformation(self, conn, packet, node_list): def notifyNodeInformation(self, conn, packet, node_list):
# don't care about notifications since we are shutdowning # don't care about notifications since we are shutdowning
pass pass
...@@ -34,7 +34,7 @@ class StorageServiceHandler(BaseServiceHandler): ...@@ -34,7 +34,7 @@ class StorageServiceHandler(BaseServiceHandler):
conn.notify(protocol.notifyLastOID(self.app.loid)) conn.notify(protocol.notifyLastOID(self.app.loid))
conn.notify(protocol.startOperation()) conn.notify(protocol.startOperation())
def handleNodeLost(self, conn, node): def nodeLost(self, conn, node):
logging.info('storage node lost') logging.info('storage node lost')
if not self.app.pt.operational(): if not self.app.pt.operational():
raise OperationFailure, 'cannot continue operation' raise OperationFailure, 'cannot continue operation'
...@@ -42,7 +42,7 @@ class StorageServiceHandler(BaseServiceHandler): ...@@ -42,7 +42,7 @@ class StorageServiceHandler(BaseServiceHandler):
# partition must not oudated to allows a cluster restart. # partition must not oudated to allows a cluster restart.
self.app.outdateAndBroadcastPartition() self.app.outdateAndBroadcastPartition()
def handleNotifyInformationLocked(self, conn, packet, tid): def notifyInformationLocked(self, conn, packet, tid):
uuid = conn.getUUID() uuid = conn.getUUID()
app = self.app app = self.app
node = app.nm.getByUUID(uuid) node = app.nm.getByUUID(uuid)
...@@ -80,7 +80,7 @@ class StorageServiceHandler(BaseServiceHandler): ...@@ -80,7 +80,7 @@ class StorageServiceHandler(BaseServiceHandler):
# What is this? # What is this?
pass pass
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list): def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
# This should be sent when a cell becomes up-to-date because # This should be sent when a cell becomes up-to-date because
# a replication has finished. # a replication has finished.
uuid = conn.getUUID() uuid = conn.getUUID()
......
...@@ -27,18 +27,18 @@ class VerificationHandler(MasterHandler): ...@@ -27,18 +27,18 @@ class VerificationHandler(MasterHandler):
def connectionCompleted(self, conn): def connectionCompleted(self, conn):
pass pass
def handleNodeLost(self, conn, node): def nodeLost(self, conn, node):
if not self.app.pt.operational(): if not self.app.pt.operational():
raise VerificationFailure, 'cannot continue verification' raise VerificationFailure, 'cannot continue verification'
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid): def answerLastIDs(self, conn, packet, loid, ltid, lptid):
app = self.app app = self.app
# 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 verification') logging.critical('got later information in verification')
raise VerificationFailure raise VerificationFailure
def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list): def answerUnfinishedTransactions(self, conn, packet, tid_list):
uuid = conn.getUUID() uuid = conn.getUUID()
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()))
...@@ -49,7 +49,7 @@ class VerificationHandler(MasterHandler): ...@@ -49,7 +49,7 @@ class VerificationHandler(MasterHandler):
app.unfinished_tid_set.update(tid_list) app.unfinished_tid_set.update(tid_list)
app.asking_uuid_dict[uuid] = True app.asking_uuid_dict[uuid] = True
def handleAnswerTransactionInformation(self, conn, packet, tid, def answerTransactionInformation(self, conn, packet, tid,
user, desc, ext, oid_list): user, desc, ext, oid_list):
uuid = conn.getUUID() uuid = conn.getUUID()
app = self.app app = self.app
...@@ -67,7 +67,7 @@ class VerificationHandler(MasterHandler): ...@@ -67,7 +67,7 @@ class VerificationHandler(MasterHandler):
app.unfinished_oid_set = None app.unfinished_oid_set = None
app.asking_uuid_dict[uuid] = True app.asking_uuid_dict[uuid] = True
def handleTidNotFound(self, conn, packet, message): def tidNotFound(self, conn, packet, message):
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
...@@ -77,7 +77,7 @@ class VerificationHandler(MasterHandler): ...@@ -77,7 +77,7 @@ class VerificationHandler(MasterHandler):
app.unfinished_oid_set = None app.unfinished_oid_set = None
app.asking_uuid_dict[uuid] = True app.asking_uuid_dict[uuid] = True
def handleAnswerObjectPresent(self, conn, packet, oid, tid): def answerObjectPresent(self, conn, packet, oid, tid):
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
...@@ -86,7 +86,7 @@ class VerificationHandler(MasterHandler): ...@@ -86,7 +86,7 @@ class VerificationHandler(MasterHandler):
return return
app.asking_uuid_dict[uuid] = True app.asking_uuid_dict[uuid] = True
def handleOidNotFound(self, conn, packet, message): def oidNotFound(self, conn, packet, message):
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
......
...@@ -50,18 +50,18 @@ class CommandEventHandler(EventHandler): ...@@ -50,18 +50,18 @@ class CommandEventHandler(EventHandler):
super(CommandEventHandler, self).peerBroken(conn) super(CommandEventHandler, self).peerBroken(conn)
self.__disconnected() self.__disconnected()
def __handleAnswer(self, conn, packet, *args): def __answer(self, conn, packet, *args):
self.__respond((packet.getType(), ) + args) self.__respond((packet.getType(), ) + args)
def handleNoError(self, conn, packet, msg): def noError(self, conn, packet, msg):
self.__respond((packet.getType(), ErrorCodes.NO_ERROR, msg)) self.__respond((packet.getType(), ErrorCodes.NO_ERROR, msg))
def handleNotReady(self, conn, packet, msg): def notReady(self, conn, packet, msg):
self.__respond((packet.getType(), ErrorCodes.NOT_READY, msg)) self.__respond((packet.getType(), ErrorCodes.NOT_READY, msg))
handleAnswerPartitionList = __handleAnswer answerPartitionList = __answer
handleAnswerNodeList = __handleAnswer answerNodeList = __answer
handleAnswerNodeState = __handleAnswer answerNodeState = __answer
handleAnswerClusterState = __handleAnswer answerClusterState = __answer
handleAnswerNewNodes = __handleAnswer answerNewNodes = __answer
handleAnswerPrimaryMaster = __handleAnswer answerPrimaryMaster = __answer
...@@ -33,17 +33,17 @@ class BaseMasterHandler(BaseStorageHandler): ...@@ -33,17 +33,17 @@ class BaseMasterHandler(BaseStorageHandler):
def connectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
raise PrimaryFailure('connection lost') raise PrimaryFailure('connection lost')
def handleReelectPrimaryMaster(self, conn, packet): def reelectPrimaryMaster(self, conn, packet):
raise PrimaryFailure('re-election occurs') raise PrimaryFailure('re-election occurs')
def handleNotifyClusterInformation(self, conn, packet, state): def notifyClusterInformation(self, conn, packet, state):
logging.error('ignoring notify cluster information in %s' % self.__class__.__name__) logging.error('ignoring notify cluster information in %s' % self.__class__.__name__)
def handleNotifyLastOID(self, conn, packet, oid): def notifyLastOID(self, conn, packet, oid):
self.app.loid = oid self.app.loid = oid
self.app.dm.setLastOID(oid) self.app.dm.setLastOID(oid)
def handleNotifyNodeInformation(self, conn, packet, node_list): def notifyNodeInformation(self, conn, packet, node_list):
"""Store information on nodes, only if this is sent by a primary """Store information on nodes, only if this is sent by a primary
master node.""" master node."""
self.app.nm.update(node_list) self.app.nm.update(node_list)
...@@ -63,7 +63,7 @@ class BaseMasterHandler(BaseStorageHandler): ...@@ -63,7 +63,7 @@ class BaseMasterHandler(BaseStorageHandler):
class BaseClientAndStorageOperationHandler(BaseStorageHandler): class BaseClientAndStorageOperationHandler(BaseStorageHandler):
""" Accept requests common to client and storage nodes """ """ Accept requests common to client and storage nodes """
def handleAskTIDs(self, conn, packet, first, last, partition): def askTIDs(self, conn, packet, first, last, partition):
# This method is complicated, because I must return TIDs only # This method is complicated, because I must return TIDs only
# about usable partitions assigned to me. # about usable partitions assigned to me.
if first >= last: if first >= last:
...@@ -87,7 +87,7 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler): ...@@ -87,7 +87,7 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler):
app.pt.getPartitions(), partition_list) app.pt.getPartitions(), partition_list)
conn.answer(protocol.answerTIDs(tid_list), packet.getId()) conn.answer(protocol.answerTIDs(tid_list), packet.getId())
def handleAskObjectHistory(self, conn, packet, oid, first, last): def askObjectHistory(self, conn, packet, oid, first, last):
if first >= last: if first >= last:
raise protocol.ProtocolError( 'invalid offsets') raise protocol.ProtocolError( 'invalid offsets')
...@@ -98,7 +98,7 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler): ...@@ -98,7 +98,7 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler):
p = protocol.answerObjectHistory(oid, history_list) p = protocol.answerObjectHistory(oid, history_list)
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
def handleAskTransactionInformation(self, conn, packet, tid): def askTransactionInformation(self, conn, packet, tid):
app = self.app app = self.app
t = app.dm.getTransaction(tid) t = app.dm.getTransaction(tid)
if t is None: if t is None:
...@@ -107,11 +107,11 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler): ...@@ -107,11 +107,11 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler):
p = protocol.answerTransactionInformation(tid, t[1], t[2], t[3], t[0]) p = protocol.answerTransactionInformation(tid, t[1], t[2], t[3], t[0])
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
def handleAskObject(self, conn, packet, oid, serial, tid): def askObject(self, conn, packet, oid, serial, tid):
app = self.app app = self.app
if oid in app.load_lock_dict: if oid in app.load_lock_dict:
# Delay the response. # Delay the response.
app.queueEvent(self.handleAskObject, conn, packet, oid, app.queueEvent(self.askObject, conn, packet, oid,
serial, tid) serial, tid)
return return
o = app.dm.getObject(oid, serial, tid) o = app.dm.getObject(oid, serial, tid)
......
...@@ -84,7 +84,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -84,7 +84,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
def connectionCompleted(self, conn): def connectionCompleted(self, conn):
BaseClientAndStorageOperationHandler.connectionCompleted(self, conn) BaseClientAndStorageOperationHandler.connectionCompleted(self, conn)
def handleAbortTransaction(self, conn, packet, tid): def abortTransaction(self, conn, packet, tid):
app = self.app app = self.app
try: try:
t = app.transaction_dict[tid] t = app.transaction_dict[tid]
...@@ -104,7 +104,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -104,7 +104,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
except KeyError: except KeyError:
pass pass
def handleAskStoreTransaction(self, conn, packet, tid, user, desc, def askStoreTransaction(self, conn, packet, tid, user, desc,
ext, oid_list): ext, oid_list):
uuid = conn.getUUID() uuid = conn.getUUID()
app = self.app app = self.app
...@@ -114,7 +114,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -114,7 +114,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
t.addTransaction(oid_list, user, desc, ext) t.addTransaction(oid_list, user, desc, ext)
conn.answer(protocol.answerStoreTransaction(tid), packet.getId()) conn.answer(protocol.answerStoreTransaction(tid), packet.getId())
def handleAskStoreObject(self, conn, packet, oid, serial, def askStoreObject(self, conn, packet, oid, serial,
compression, checksum, data, tid): compression, checksum, data, tid):
uuid = conn.getUUID() uuid = conn.getUUID()
# First, check for the locking state. # First, check for the locking state.
...@@ -123,7 +123,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -123,7 +123,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
if locking_tid is not None: if locking_tid is not None:
if locking_tid < tid: if locking_tid < tid:
# Delay the response. # Delay the response.
app.queueEvent(self.handleAskStoreObject, conn, packet, app.queueEvent(self.askStoreObject, conn, packet,
oid, serial, compression, checksum, oid, serial, compression, checksum,
data, tid) data, tid)
else: else:
......
...@@ -27,7 +27,7 @@ class HiddenHandler(BaseMasterHandler): ...@@ -27,7 +27,7 @@ class HiddenHandler(BaseMasterHandler):
self.app = app self.app = app
BaseMasterHandler.__init__(self, app) BaseMasterHandler.__init__(self, app)
def handleNotifyNodeInformation(self, conn, packet, node_list): def notifyNodeInformation(self, conn, packet, node_list):
"""Store information on nodes, only if this is sent by a primary """Store information on nodes, only if this is sent by a primary
master node.""" master node."""
app = self.app app = self.app
...@@ -42,28 +42,28 @@ class HiddenHandler(BaseMasterHandler): ...@@ -42,28 +42,28 @@ class HiddenHandler(BaseMasterHandler):
erase_db = state == NodeStates.DOWN erase_db = state == NodeStates.DOWN
self.app.shutdown(erase=erase_db) self.app.shutdown(erase=erase_db)
def handleRequestNodeIdentification(self, conn, packet, node_type, def requestNodeIdentification(self, conn, packet, node_type,
uuid, address, name): uuid, address, name):
pass pass
def handleAcceptNodeIdentification(self, conn, packet, node_type, def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, num_replicas, your_uuid): uuid, address, num_partitions, num_replicas, your_uuid):
pass pass
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, def answerPrimaryMaster(self, conn, packet, primary_uuid,
known_master_list): known_master_list):
pass pass
def handleAskLastIDs(self, conn, packet): def askLastIDs(self, conn, packet):
pass pass
def handleAskPartitionTable(self, conn, packet, offset_list): def askPartitionTable(self, conn, packet, offset_list):
pass pass
def handleSendPartitionTable(self, conn, packet, ptid, row_list): def sendPartitionTable(self, conn, packet, ptid, row_list):
pass pass
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list): def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
"""This is very similar to Send Partition Table, except that """This is very similar to Send Partition Table, except that
the information is only about changes from the previous.""" the information is only about changes from the previous."""
app = self.app app = self.app
...@@ -85,59 +85,59 @@ class HiddenHandler(BaseMasterHandler): ...@@ -85,59 +85,59 @@ class HiddenHandler(BaseMasterHandler):
elif state == CellStates.OUT_OF_DATE: elif state == CellStates.OUT_OF_DATE:
app.replicator.addPartition(offset) app.replicator.addPartition(offset)
def handleStartOperation(self, conn, packet): def startOperation(self, conn, packet):
self.app.operational = True self.app.operational = True
def handleStopOperation(self, conn, packet): def stopOperation(self, conn, packet):
pass pass
def handleAskUnfinishedTransactions(self, conn, packet): def askUnfinishedTransactions(self, conn, packet):
pass pass
def handleAskTransactionInformation(self, conn, packet, tid): def askTransactionInformation(self, conn, packet, tid):
pass pass
def handleAskObjectPresent(self, conn, packet, oid, tid): def askObjectPresent(self, conn, packet, oid, tid):
pass pass
def handleDeleteTransaction(self, conn, packet, tid): def deleteTransaction(self, conn, packet, tid):
pass pass
def handleCommitTransaction(self, conn, packet, tid): def commitTransaction(self, conn, packet, tid):
pass pass
def handleLockInformation(self, conn, packet, tid): def lockInformation(self, conn, packet, tid):
pass pass
def handleUnlockInformation(self, conn, packet, tid): def unlockInformation(self, conn, packet, tid):
pass pass
def handleAskObject(self, conn, packet, oid, serial, tid): def askObject(self, conn, packet, oid, serial, tid):
pass pass
def handleAskTIDs(self, conn, packet, first, last, partition): def askTIDs(self, conn, packet, first, last, partition):
pass pass
def handleAskObjectHistory(self, conn, packet, oid, first, last): def askObjectHistory(self, conn, packet, oid, first, last):
pass pass
def handleAskStoreTransaction(self, conn, packet, tid, user, desc, def askStoreTransaction(self, conn, packet, tid, user, desc,
ext, oid_list): ext, oid_list):
pass pass
def handleAskStoreObject(self, conn, packet, oid, serial, def askStoreObject(self, conn, packet, oid, serial,
compression, checksum, data, tid): compression, checksum, data, tid):
pass pass
def handleAbortTransaction(self, conn, packet, tid): def abortTransaction(self, conn, packet, tid):
logging.debug('ignoring abort transaction') logging.debug('ignoring abort transaction')
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid): def answerLastIDs(self, conn, packet, loid, ltid, lptid):
logging.debug('ignoring answer last ids') logging.debug('ignoring answer last ids')
def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list): def answerUnfinishedTransactions(self, conn, packet, tid_list):
logging.debug('ignoring answer unfinished transactions') logging.debug('ignoring answer unfinished transactions')
def handleAskOIDs(self, conn, packet, first, last, partition): def askOIDs(self, conn, packet, first, last, partition):
logging.debug('ignoring ask oids') logging.debug('ignoring ask oids')
...@@ -28,7 +28,7 @@ class IdentificationHandler(BaseStorageHandler): ...@@ -28,7 +28,7 @@ class IdentificationHandler(BaseStorageHandler):
def connectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
logging.warning('A connection was lost during identification') logging.warning('A connection was lost during identification')
def handleRequestNodeIdentification(self, conn, packet, node_type, def requestNodeIdentification(self, conn, packet, node_type,
uuid, address, name): uuid, address, name):
self.checkClusterName(name) self.checkClusterName(name)
# reject any incoming connections if not ready # reject any incoming connections if not ready
......
...@@ -22,20 +22,20 @@ from neo import protocol ...@@ -22,20 +22,20 @@ from neo import protocol
class InitializationHandler(BaseMasterHandler): class InitializationHandler(BaseMasterHandler):
def handleAnswerNodeInformation(self, conn, packet, node_list): def answerNodeInformation(self, conn, packet, node_list):
assert not node_list assert not node_list
self.app.has_node_information = True self.app.has_node_information = True
def handleNotifyNodeInformation(self, conn, packet, node_list): def notifyNodeInformation(self, conn, packet, node_list):
# the whole node list is received here # the whole node list is received here
BaseMasterHandler.handleNotifyNodeInformation(self, conn, packet, node_list) BaseMasterHandler.notifyNodeInformation(self, conn, packet, node_list)
def handleSendPartitionTable(self, conn, packet, ptid, row_list): def sendPartitionTable(self, conn, packet, ptid, row_list):
"""A primary master node sends this packet to synchronize a partition """A primary master node sends this packet to synchronize a partition
table. Note that the message can be split into multiple packets.""" table. Note that the message can be split into multiple packets."""
self.app.pt.load(ptid, row_list, self.app.nm) self.app.pt.load(ptid, row_list, self.app.nm)
def handleAnswerPartitionTable(self, conn, packet, ptid, row_list): def answerPartitionTable(self, conn, packet, ptid, row_list):
app = self.app app = self.app
pt = app.pt pt = app.pt
assert not row_list assert not row_list
...@@ -59,7 +59,7 @@ class InitializationHandler(BaseMasterHandler): ...@@ -59,7 +59,7 @@ class InitializationHandler(BaseMasterHandler):
app.dm.setPartitionTable(ptid, cell_list) app.dm.setPartitionTable(ptid, cell_list)
self.app.has_partition_table = True self.app.has_partition_table = True
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list): def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
# XXX: Currently it safe to ignore those packets because the master is # XXX: Currently it safe to ignore those packets because the master is
# single threaded, it send the partition table without any changes at # single threaded, it send the partition table without any changes at
# the same time. Latter it should be needed to put in queue any changes # the same time. Latter it should be needed to put in queue any changes
......
...@@ -26,16 +26,16 @@ from neo.exception import OperationFailure ...@@ -26,16 +26,16 @@ from neo.exception import OperationFailure
class MasterOperationHandler(BaseMasterHandler): class MasterOperationHandler(BaseMasterHandler):
""" This handler is used for the primary master """ """ This handler is used for the primary master """
def handleStopOperation(self, conn, packet): def stopOperation(self, conn, packet):
raise OperationFailure('operation stopped') raise OperationFailure('operation stopped')
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid): def answerLastIDs(self, conn, packet, loid, ltid, lptid):
self.app.replicator.setCriticalTID(packet, ltid) self.app.replicator.setCriticalTID(packet, ltid)
def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list): def answerUnfinishedTransactions(self, conn, packet, tid_list):
self.app.replicator.setUnfinishedTIDList(tid_list) self.app.replicator.setUnfinishedTIDList(tid_list)
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list): def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
"""This is very similar to Send Partition Table, except that """This is very similar to Send Partition Table, except that
the information is only about changes from the previous.""" the information is only about changes from the previous."""
app = self.app app = self.app
...@@ -57,7 +57,7 @@ class MasterOperationHandler(BaseMasterHandler): ...@@ -57,7 +57,7 @@ class MasterOperationHandler(BaseMasterHandler):
elif state == CellStates.OUT_OF_DATE: elif state == CellStates.OUT_OF_DATE:
app.replicator.addPartition(offset) app.replicator.addPartition(offset)
def handleLockInformation(self, conn, packet, tid): def lockInformation(self, conn, packet, tid):
app = self.app app = self.app
try: try:
t = app.transaction_dict[tid] t = app.transaction_dict[tid]
...@@ -70,7 +70,7 @@ class MasterOperationHandler(BaseMasterHandler): ...@@ -70,7 +70,7 @@ class MasterOperationHandler(BaseMasterHandler):
pass pass
conn.answer(protocol.notifyInformationLocked(tid), packet.getId()) conn.answer(protocol.notifyInformationLocked(tid), packet.getId())
def handleUnlockInformation(self, conn, packet, tid): def unlockInformation(self, conn, packet, tid):
app = self.app app = self.app
try: try:
t = app.transaction_dict[tid] t = app.transaction_dict[tid]
......
...@@ -36,12 +36,12 @@ class ReplicationHandler(BaseStorageHandler): ...@@ -36,12 +36,12 @@ class ReplicationHandler(BaseStorageHandler):
logging.error('replication is stopped due to connection failure') logging.error('replication is stopped due to connection failure')
self.app.replicator.reset() self.app.replicator.reset()
def handleAcceptNodeIdentification(self, conn, packet, node_type, def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, num_replicas, your_uuid): uuid, address, num_partitions, num_replicas, your_uuid):
# set the UUID on the connection # set the UUID on the connection
conn.setUUID(uuid) conn.setUUID(uuid)
def handleAnswerTIDs(self, conn, packet, tid_list): def answerTIDs(self, conn, packet, tid_list):
app = self.app app = self.app
if app.replicator.current_connection is not conn: if app.replicator.current_connection is not conn:
return return
...@@ -68,7 +68,7 @@ class ReplicationHandler(BaseStorageHandler): ...@@ -68,7 +68,7 @@ class ReplicationHandler(BaseStorageHandler):
conn.ask(p, timeout=300) conn.ask(p, timeout=300)
app.replicator.oid_offset = 0 app.replicator.oid_offset = 0
def handleAnswerTransactionInformation(self, conn, packet, tid, def answerTransactionInformation(self, conn, packet, tid,
user, desc, ext, oid_list): user, desc, ext, oid_list):
app = self.app app = self.app
if app.replicator.current_connection is not conn: if app.replicator.current_connection is not conn:
...@@ -77,7 +77,7 @@ class ReplicationHandler(BaseStorageHandler): ...@@ -77,7 +77,7 @@ class ReplicationHandler(BaseStorageHandler):
# Directly store the transaction. # Directly store the transaction.
app.dm.storeTransaction(tid, (), (oid_list, user, desc, ext), False) app.dm.storeTransaction(tid, (), (oid_list, user, desc, ext), False)
def handleAnswerOIDs(self, conn, packet, oid_list): def answerOIDs(self, conn, packet, oid_list):
app = self.app app = self.app
if app.replicator.current_connection is not conn: if app.replicator.current_connection is not conn:
return return
...@@ -93,7 +93,7 @@ class ReplicationHandler(BaseStorageHandler): ...@@ -93,7 +93,7 @@ class ReplicationHandler(BaseStorageHandler):
# finished. # finished.
app.replicator.replication_done = True app.replicator.replication_done = True
def handleAnswerObjectHistory(self, conn, packet, oid, history_list): def answerObjectHistory(self, conn, packet, oid, history_list):
app = self.app app = self.app
if app.replicator.current_connection is not conn: if app.replicator.current_connection is not conn:
return return
...@@ -127,7 +127,7 @@ class ReplicationHandler(BaseStorageHandler): ...@@ -127,7 +127,7 @@ class ReplicationHandler(BaseStorageHandler):
app.replicator.current_partition.getRID()) app.replicator.current_partition.getRID())
conn.ask(p, timeout=300) conn.ask(p, timeout=300)
def handleAnswerObject(self, conn, packet, oid, serial_start, def answerObject(self, conn, packet, oid, serial_start,
serial_end, compression, checksum, data): serial_end, compression, checksum, data):
app = self.app app = self.app
if app.replicator.current_connection is not conn: if app.replicator.current_connection is not conn:
......
...@@ -20,14 +20,14 @@ from neo.storage.handlers import BaseClientAndStorageOperationHandler ...@@ -20,14 +20,14 @@ from neo.storage.handlers import BaseClientAndStorageOperationHandler
class StorageOperationHandler(BaseClientAndStorageOperationHandler): class StorageOperationHandler(BaseClientAndStorageOperationHandler):
def handleAskLastIDs(self, conn, packet): def askLastIDs(self, conn, packet):
app = self.app app = self.app
oid = app.dm.getLastOID() oid = app.dm.getLastOID()
tid = app.dm.getLastTID() tid = app.dm.getLastTID()
p = protocol.answerLastIDs(oid, tid, app.pt.getID()) p = protocol.answerLastIDs(oid, tid, app.pt.getID())
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
def handleAskOIDs(self, conn, packet, first, last, partition): def askOIDs(self, conn, packet, first, last, partition):
# This method is complicated, because I must return OIDs only # This method is complicated, because I must return OIDs only
# about usable partitions assigned to me. # about usable partitions assigned to me.
if first >= last: if first >= last:
......
...@@ -25,14 +25,14 @@ from neo.exception import OperationFailure ...@@ -25,14 +25,14 @@ from neo.exception import OperationFailure
class VerificationHandler(BaseMasterHandler): class VerificationHandler(BaseMasterHandler):
"""This class deals with events for a verification phase.""" """This class deals with events for a verification phase."""
def handleAskLastIDs(self, conn, packet): def askLastIDs(self, conn, packet):
app = self.app app = self.app
oid = app.dm.getLastOID() oid = app.dm.getLastOID()
tid = app.dm.getLastTID() tid = app.dm.getLastTID()
p = protocol.answerLastIDs(oid, tid, app.pt.getID()) p = protocol.answerLastIDs(oid, tid, app.pt.getID())
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
def handleAskPartitionTable(self, conn, packet, offset_list): def askPartitionTable(self, conn, packet, offset_list):
app, pt = self.app, self.app.pt app, pt = self.app, self.app.pt
if not offset_list: if not offset_list:
# all is requested # all is requested
...@@ -53,7 +53,7 @@ class VerificationHandler(BaseMasterHandler): ...@@ -53,7 +53,7 @@ class VerificationHandler(BaseMasterHandler):
p = protocol.answerPartitionTable(app.pt.getID(), row_list) p = protocol.answerPartitionTable(app.pt.getID(), row_list)
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list): def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
"""This is very similar to Send Partition Table, except that """This is very similar to Send Partition Table, except that
the information is only about changes from the previous.""" the information is only about changes from the previous."""
app = self.app app = self.app
...@@ -65,18 +65,18 @@ class VerificationHandler(BaseMasterHandler): ...@@ -65,18 +65,18 @@ class VerificationHandler(BaseMasterHandler):
app.pt.update(ptid, cell_list, app.nm) app.pt.update(ptid, cell_list, app.nm)
app.dm.changePartitionTable(ptid, cell_list) app.dm.changePartitionTable(ptid, cell_list)
def handleStartOperation(self, conn, packet): def startOperation(self, conn, packet):
self.app.operational = True self.app.operational = True
def handleStopOperation(self, conn, packet): def stopOperation(self, conn, packet):
raise OperationFailure('operation stopped') raise OperationFailure('operation stopped')
def handleAskUnfinishedTransactions(self, conn, packet): def askUnfinishedTransactions(self, conn, packet):
tid_list = self.app.dm.getUnfinishedTIDList() tid_list = self.app.dm.getUnfinishedTIDList()
p = protocol.answerUnfinishedTransactions(tid_list) p = protocol.answerUnfinishedTransactions(tid_list)
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
def handleAskTransactionInformation(self, conn, packet, tid): def askTransactionInformation(self, conn, packet, tid):
app = self.app app = self.app
t = app.dm.getTransaction(tid, all=True) t = app.dm.getTransaction(tid, all=True)
if t is None: if t is None:
...@@ -85,7 +85,7 @@ class VerificationHandler(BaseMasterHandler): ...@@ -85,7 +85,7 @@ class VerificationHandler(BaseMasterHandler):
p = protocol.answerTransactionInformation(tid, t[1], t[2], t[3], t[0]) p = protocol.answerTransactionInformation(tid, t[1], t[2], t[3], t[0])
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
def handleAskObjectPresent(self, conn, packet, oid, tid): def askObjectPresent(self, conn, packet, oid, tid):
if self.app.dm.objectPresent(oid, tid): if self.app.dm.objectPresent(oid, tid):
p = protocol.answerObjectPresent(oid, tid) p = protocol.answerObjectPresent(oid, tid)
else: else:
...@@ -93,9 +93,9 @@ class VerificationHandler(BaseMasterHandler): ...@@ -93,9 +93,9 @@ class VerificationHandler(BaseMasterHandler):
'%s:%s do not exist' % (dump(oid), dump(tid))) '%s:%s do not exist' % (dump(oid), dump(tid)))
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
def handleDeleteTransaction(self, conn, packet, tid): def deleteTransaction(self, conn, packet, tid):
self.app.dm.deleteTransaction(tid, all = True) self.app.dm.deleteTransaction(tid, all = True)
def handleCommitTransaction(self, conn, packet, tid): def commitTransaction(self, conn, packet, tid):
self.app.dm.finishTransaction(tid) self.app.dm.finishTransaction(tid)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -90,7 +90,7 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -90,7 +90,7 @@ class MasterRecoveryTests(NeoTestBase):
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(),
NodeStates.BROKEN) NodeStates.BROKEN)
def test_08_handleNotifyNodeInformation(self): def test_08_notifyNodeInformation(self):
recovery = self.recovery recovery = self.recovery
uuid = self.identifyToMasterNode(NodeTypes.MASTER, port=self.master_port) uuid = self.identifyToMasterNode(NodeTypes.MASTER, port=self.master_port)
packet = Packet(msg_type=PacketTypes.NOTIFY_NODE_INFORMATION) packet = Packet(msg_type=PacketTypes.NOTIFY_NODE_INFORMATION)
...@@ -99,7 +99,7 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -99,7 +99,7 @@ class MasterRecoveryTests(NeoTestBase):
node_list = [(NodeTypes.CLIENT, '127.0.0.1', self.client_port, node_list = [(NodeTypes.CLIENT, '127.0.0.1', self.client_port,
self.getNewUUID(), NodeStates.DOWN),] self.getNewUUID(), NodeStates.DOWN),]
self.assertEqual(len(self.app.nm.getList()), 0) self.assertEqual(len(self.app.nm.getList()), 0)
recovery.handleNotifyNodeInformation(conn, packet, node_list) recovery.notifyNodeInformation(conn, packet, node_list)
self.assertEqual(len(self.app.nm.getList()), 0) self.assertEqual(len(self.app.nm.getList()), 0)
# tell the master node about itself, if running must do nothing # tell the master node about itself, if running must do nothing
...@@ -108,7 +108,7 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -108,7 +108,7 @@ class MasterRecoveryTests(NeoTestBase):
self.app.uuid, NodeStates.RUNNING),] self.app.uuid, NodeStates.RUNNING),]
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1)) node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
self.assertEqual(node, None) self.assertEqual(node, None)
recovery.handleNotifyNodeInformation(conn, packet, node_list) recovery.notifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1)) node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
# tell the master node about itself, if down must raise # tell the master node about itself, if down must raise
...@@ -117,14 +117,14 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -117,14 +117,14 @@ class MasterRecoveryTests(NeoTestBase):
self.app.uuid, NodeStates.DOWN),] self.app.uuid, NodeStates.DOWN),]
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1)) node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
self.assertEqual(node, None) self.assertEqual(node, None)
self.assertRaises(RuntimeError, recovery.handleNotifyNodeInformation, conn, packet, node_list) self.assertRaises(RuntimeError, recovery.notifyNodeInformation, conn, packet, node_list)
# tell about an unknown storage node, do nothing # tell about an unknown storage node, do nothing
conn = self.getFakeConnection(uuid, self.master_address) conn = self.getFakeConnection(uuid, self.master_address)
node_list = [(NodeTypes.STORAGE, '127.0.0.1', self.master_port - 1, node_list = [(NodeTypes.STORAGE, '127.0.0.1', self.master_port - 1,
self.getNewUUID(), NodeStates.DOWN),] self.getNewUUID(), NodeStates.DOWN),]
self.assertEqual(len(self.app.nm.getStorageList()), 0) self.assertEqual(len(self.app.nm.getStorageList()), 0)
recovery.handleNotifyNodeInformation(conn, packet, node_list) recovery.notifyNodeInformation(conn, packet, node_list)
self.assertEqual(len(self.app.nm.getStorageList()), 0) self.assertEqual(len(self.app.nm.getStorageList()), 0)
# tell about a known node but different address # tell about a known node but different address
...@@ -133,7 +133,7 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -133,7 +133,7 @@ class MasterRecoveryTests(NeoTestBase):
NodeStates.DOWN),] NodeStates.DOWN),]
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port)) node = self.app.nm.getByAddress(("127.0.0.1", self.master_port))
self.assertEqual(node.getState(), NodeStates.RUNNING) self.assertEqual(node.getState(), NodeStates.RUNNING)
recovery.handleNotifyNodeInformation(conn, packet, node_list) recovery.notifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port)) node = self.app.nm.getByAddress(("127.0.0.1", self.master_port))
self.assertEqual(node.getState(), NodeStates.RUNNING) self.assertEqual(node.getState(), NodeStates.RUNNING)
...@@ -143,12 +143,12 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -143,12 +143,12 @@ class MasterRecoveryTests(NeoTestBase):
NodeStates.DOWN),] NodeStates.DOWN),]
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port)) node = self.app.nm.getByAddress(("127.0.0.1", self.master_port))
self.assertEqual(node.getState(), NodeStates.RUNNING) self.assertEqual(node.getState(), NodeStates.RUNNING)
recovery.handleNotifyNodeInformation(conn, packet, node_list) recovery.notifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port)) node = self.app.nm.getByAddress(("127.0.0.1", self.master_port))
self.assertEqual(node.getState(), NodeStates.DOWN) self.assertEqual(node.getState(), NodeStates.DOWN)
def test_09_handleAnswerLastIDs(self): def test_09_answerLastIDs(self):
recovery = self.recovery recovery = self.recovery
uuid = self.identifyToMasterNode() uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_LAST_IDS) packet = Packet(msg_type=PacketTypes.ANSWER_LAST_IDS)
...@@ -168,14 +168,14 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -168,14 +168,14 @@ class MasterRecoveryTests(NeoTestBase):
self.failUnless(new_oid > self.app.loid) self.failUnless(new_oid > self.app.loid)
self.failUnless(new_tid > self.app.ltid) self.failUnless(new_tid > self.app.ltid)
self.assertEquals(self.app.target_uuid, None) self.assertEquals(self.app.target_uuid, None)
recovery.handleAnswerLastIDs(conn, packet, new_oid, new_tid, new_ptid) recovery.answerLastIDs(conn, packet, new_oid, new_tid, new_ptid)
self.assertEquals(new_oid, self.app.loid) self.assertEquals(new_oid, self.app.loid)
self.assertEquals(new_tid, self.app.ltid) self.assertEquals(new_tid, self.app.ltid)
self.assertEquals(new_ptid, self.app.pt.getID()) self.assertEquals(new_ptid, self.app.pt.getID())
self.assertEquals(self.app.target_uuid,uuid) self.assertEquals(self.app.target_uuid,uuid)
def test_10_handleAnswerPartitionTable(self): def test_10_answerPartitionTable(self):
recovery = self.recovery recovery = self.recovery
uuid = self.identifyToMasterNode(NodeTypes.MASTER, port=self.master_port) uuid = self.identifyToMasterNode(NodeTypes.MASTER, port=self.master_port)
packet = Packet(msg_type=PacketTypes.ANSWER_PARTITION_TABLE) packet = Packet(msg_type=PacketTypes.ANSWER_PARTITION_TABLE)
...@@ -188,7 +188,7 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -188,7 +188,7 @@ class MasterRecoveryTests(NeoTestBase):
cells = self.app.pt.getRow(offset) cells = self.app.pt.getRow(offset)
for cell, state in cells: for cell, state in cells:
self.assertEquals(state, CellStates.OUT_OF_DATE) self.assertEquals(state, CellStates.OUT_OF_DATE)
recovery.handleAnswerPartitionTable(conn, packet, None, cell_list) recovery.answerPartitionTable(conn, packet, None, cell_list)
cells = self.app.pt.getRow(offset) cells = self.app.pt.getRow(offset)
for cell, state in cells: for cell, state in cells:
self.assertEquals(state, CellStates.OUT_OF_DATE) self.assertEquals(state, CellStates.OUT_OF_DATE)
...@@ -202,7 +202,7 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -202,7 +202,7 @@ class MasterRecoveryTests(NeoTestBase):
cells = self.app.pt.getRow(offset) cells = self.app.pt.getRow(offset)
for cell, state in cells: for cell, state in cells:
self.assertEquals(state, CellStates.OUT_OF_DATE) self.assertEquals(state, CellStates.OUT_OF_DATE)
recovery.handleAnswerPartitionTable(conn, packet, None, cell_list) recovery.answerPartitionTable(conn, packet, None, cell_list)
cells = self.app.pt.getRow(offset) cells = self.app.pt.getRow(offset)
for cell, state in cells: for cell, state in cells:
self.assertEquals(state, CellStates.UP_TO_DATE) self.assertEquals(state, CellStates.UP_TO_DATE)
...@@ -212,7 +212,7 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -212,7 +212,7 @@ class MasterRecoveryTests(NeoTestBase):
offset = 1000000 offset = 1000000
self.assertFalse(self.app.pt.hasOffset(offset)) self.assertFalse(self.app.pt.hasOffset(offset))
cell_list = [(offset, ((uuid, NodeStates.DOWN,),),)] cell_list = [(offset, ((uuid, NodeStates.DOWN,),),)]
self.checkUnexpectedPacketRaised(recovery.handleAnswerPartitionTable, conn, packet, None, cell_list) self.checkUnexpectedPacketRaised(recovery.answerPartitionTable, conn, packet, None, cell_list)
if __name__ == '__main__': if __name__ == '__main__':
......
This diff is collapsed.
...@@ -124,7 +124,7 @@ class MasterVerificationTests(NeoTestBase): ...@@ -124,7 +124,7 @@ class MasterVerificationTests(NeoTestBase):
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(), self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(),
NodeStates.TEMPORARILY_DOWN) NodeStates.TEMPORARILY_DOWN)
def test_09_handleAnswerLastIDs(self): def test_09_answerLastIDs(self):
verification = self.verification verification = self.verification
uuid = self.identifyToMasterNode() uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_LAST_IDS) packet = Packet(msg_type=PacketTypes.ANSWER_LAST_IDS)
...@@ -143,12 +143,12 @@ class MasterVerificationTests(NeoTestBase): ...@@ -143,12 +143,12 @@ class MasterVerificationTests(NeoTestBase):
self.failUnless(new_ptid > self.app.pt.getID()) self.failUnless(new_ptid > self.app.pt.getID())
self.failUnless(new_oid > self.app.loid) self.failUnless(new_oid > self.app.loid)
self.failUnless(new_tid > self.app.ltid) self.failUnless(new_tid > self.app.ltid)
self.assertRaises(VerificationFailure, verification.handleAnswerLastIDs, conn, packet, new_oid, new_tid, new_ptid) self.assertRaises(VerificationFailure, verification.answerLastIDs, conn, packet, new_oid, new_tid, new_ptid)
self.assertNotEquals(new_oid, self.app.loid) self.assertNotEquals(new_oid, self.app.loid)
self.assertNotEquals(new_tid, self.app.ltid) self.assertNotEquals(new_tid, self.app.ltid)
self.assertNotEquals(new_ptid, self.app.pt.getID()) self.assertNotEquals(new_ptid, self.app.pt.getID())
def test_11_handleAnswerUnfinishedTransactions(self): def test_11_answerUnfinishedTransactions(self):
verification = self.verification verification = self.verification
uuid = self.identifyToMasterNode() uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_UNFINISHED_TRANSACTIONS) packet = Packet(msg_type=PacketTypes.ANSWER_UNFINISHED_TRANSACTIONS)
...@@ -160,7 +160,7 @@ class MasterVerificationTests(NeoTestBase): ...@@ -160,7 +160,7 @@ class MasterVerificationTests(NeoTestBase):
self.assertEquals(len(self.app.unfinished_tid_set), 0) self.assertEquals(len(self.app.unfinished_tid_set), 0)
upper, lower = unpack('!LL', self.app.ltid) upper, lower = unpack('!LL', self.app.ltid)
new_tid = pack('!LL', upper, lower + 10) new_tid = pack('!LL', upper, lower + 10)
verification.handleAnswerUnfinishedTransactions(conn, packet, [new_tid]) verification.answerUnfinishedTransactions(conn, packet, [new_tid])
self.assertEquals(len(self.app.unfinished_tid_set), 0) self.assertEquals(len(self.app.unfinished_tid_set), 0)
# update dict # update dict
conn = self.getFakeConnection(uuid, self.storage_address) conn = self.getFakeConnection(uuid, self.storage_address)
...@@ -169,13 +169,13 @@ class MasterVerificationTests(NeoTestBase): ...@@ -169,13 +169,13 @@ class MasterVerificationTests(NeoTestBase):
self.assertEquals(len(self.app.unfinished_tid_set), 0) self.assertEquals(len(self.app.unfinished_tid_set), 0)
upper, lower = unpack('!LL', self.app.ltid) upper, lower = unpack('!LL', self.app.ltid)
new_tid = pack('!LL', upper, lower + 10) new_tid = pack('!LL', upper, lower + 10)
verification.handleAnswerUnfinishedTransactions(conn, packet, [new_tid,]) verification.answerUnfinishedTransactions(conn, packet, [new_tid,])
self.assertTrue(self.app.asking_uuid_dict[uuid]) self.assertTrue(self.app.asking_uuid_dict[uuid])
self.assertEquals(len(self.app.unfinished_tid_set), 1) self.assertEquals(len(self.app.unfinished_tid_set), 1)
self.assertTrue(new_tid in self.app.unfinished_tid_set) self.assertTrue(new_tid in self.app.unfinished_tid_set)
def test_12_handleAnswerTransactionInformation(self): def test_12_answerTransactionInformation(self):
verification = self.verification verification = self.verification
uuid = self.identifyToMasterNode() uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_TRANSACTION_INFORMATION) packet = Packet(msg_type=PacketTypes.ANSWER_TRANSACTION_INFORMATION)
...@@ -189,7 +189,7 @@ class MasterVerificationTests(NeoTestBase): ...@@ -189,7 +189,7 @@ class MasterVerificationTests(NeoTestBase):
new_tid = pack('!LL', upper, lower + 10) new_tid = pack('!LL', upper, lower + 10)
oid = unpack('!Q', self.app.loid)[0] oid = unpack('!Q', self.app.loid)[0]
new_oid = pack('!Q', oid + 1) new_oid = pack('!Q', oid + 1)
verification.handleAnswerTransactionInformation(conn, packet, new_tid, verification.answerTransactionInformation(conn, packet, new_tid,
"user", "desc", "ext", [new_oid,]) "user", "desc", "ext", [new_oid,])
self.assertEquals(self.app.unfinished_oid_set, None) self.assertEquals(self.app.unfinished_oid_set, None)
# do nothing as asking_uuid_dict is True # do nothing as asking_uuid_dict is True
...@@ -199,7 +199,7 @@ class MasterVerificationTests(NeoTestBase): ...@@ -199,7 +199,7 @@ class MasterVerificationTests(NeoTestBase):
self.app.unfinished_oid_set = set() self.app.unfinished_oid_set = set()
self.assertTrue(self.app.asking_uuid_dict.has_key(uuid)) self.assertTrue(self.app.asking_uuid_dict.has_key(uuid))
self.assertEquals(len(self.app.unfinished_oid_set), 0) self.assertEquals(len(self.app.unfinished_oid_set), 0)
verification.handleAnswerTransactionInformation(conn, packet, new_tid, verification.answerTransactionInformation(conn, packet, new_tid,
"user", "desc", "ext", [new_oid,]) "user", "desc", "ext", [new_oid,])
self.assertEquals(len(self.app.unfinished_oid_set), 0) self.assertEquals(len(self.app.unfinished_oid_set), 0)
# do work # do work
...@@ -208,7 +208,7 @@ class MasterVerificationTests(NeoTestBase): ...@@ -208,7 +208,7 @@ class MasterVerificationTests(NeoTestBase):
self.app.asking_uuid_dict[uuid] = False self.app.asking_uuid_dict[uuid] = False
self.assertTrue(self.app.asking_uuid_dict.has_key(uuid)) self.assertTrue(self.app.asking_uuid_dict.has_key(uuid))
self.assertEquals(len(self.app.unfinished_oid_set), 0) self.assertEquals(len(self.app.unfinished_oid_set), 0)
verification.handleAnswerTransactionInformation(conn, packet, new_tid, verification.answerTransactionInformation(conn, packet, new_tid,
"user", "desc", "ext", [new_oid,]) "user", "desc", "ext", [new_oid,])
self.assertEquals(len(self.app.unfinished_oid_set), 1) self.assertEquals(len(self.app.unfinished_oid_set), 1)
self.assertTrue(new_oid in self.app.unfinished_oid_set) self.assertTrue(new_oid in self.app.unfinished_oid_set)
...@@ -222,11 +222,11 @@ class MasterVerificationTests(NeoTestBase): ...@@ -222,11 +222,11 @@ class MasterVerificationTests(NeoTestBase):
oid = unpack('!Q', old_oid)[0] oid = unpack('!Q', old_oid)[0]
new_oid = pack('!Q', oid + 1) new_oid = pack('!Q', oid + 1)
self.assertNotEqual(new_oid, old_oid) self.assertNotEqual(new_oid, old_oid)
verification.handleAnswerTransactionInformation(conn, packet, new_tid, verification.answerTransactionInformation(conn, packet, new_tid,
"user", "desc", "ext", [new_oid,]) "user", "desc", "ext", [new_oid,])
self.assertEquals(self.app.unfinished_oid_set, None) self.assertEquals(self.app.unfinished_oid_set, None)
def test_13_handleTidNotFound(self): def test_13_tidNotFound(self):
verification = self.verification verification = self.verification
uuid = self.identifyToMasterNode() uuid = self.identifyToMasterNode()
packet = Packet(msg_type=ErrorCodes.TID_NOT_FOUND) packet = Packet(msg_type=ErrorCodes.TID_NOT_FOUND)
...@@ -236,7 +236,7 @@ class MasterVerificationTests(NeoTestBase): ...@@ -236,7 +236,7 @@ class MasterVerificationTests(NeoTestBase):
self.app.asking_uuid_dict[uuid] = True self.app.asking_uuid_dict[uuid] = True
self.app.unfinished_oid_set = [] self.app.unfinished_oid_set = []
self.assertTrue(self.app.asking_uuid_dict.has_key(uuid)) self.assertTrue(self.app.asking_uuid_dict.has_key(uuid))
verification.handleTidNotFound(conn, packet, "msg") verification.tidNotFound(conn, packet, "msg")
self.assertNotEqual(self.app.unfinished_oid_set, None) self.assertNotEqual(self.app.unfinished_oid_set, None)
# do work as asking_uuid_dict is False # do work as asking_uuid_dict is False
conn = self.getFakeConnection(uuid, self.storage_address) conn = self.getFakeConnection(uuid, self.storage_address)
...@@ -244,10 +244,10 @@ class MasterVerificationTests(NeoTestBase): ...@@ -244,10 +244,10 @@ class MasterVerificationTests(NeoTestBase):
self.app.asking_uuid_dict[uuid] = False self.app.asking_uuid_dict[uuid] = False
self.app.unfinished_oid_set = [] self.app.unfinished_oid_set = []
self.assertTrue(self.app.asking_uuid_dict.has_key(uuid)) self.assertTrue(self.app.asking_uuid_dict.has_key(uuid))
verification.handleTidNotFound(conn, packet, "msg") verification.tidNotFound(conn, packet, "msg")
self.assertEqual(self.app.unfinished_oid_set, None) self.assertEqual(self.app.unfinished_oid_set, None)
def test_14_handleAnswerObjectPresent(self): def test_14_answerObjectPresent(self):
verification = self.verification verification = self.verification
uuid = self.identifyToMasterNode() uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_OBJECT_PRESENT) packet = Packet(msg_type=PacketTypes.ANSWER_OBJECT_PRESENT)
...@@ -260,16 +260,16 @@ class MasterVerificationTests(NeoTestBase): ...@@ -260,16 +260,16 @@ class MasterVerificationTests(NeoTestBase):
self.assertEquals(len(self.app.asking_uuid_dict), 0) self.assertEquals(len(self.app.asking_uuid_dict), 0)
self.app.asking_uuid_dict[uuid] = True self.app.asking_uuid_dict[uuid] = True
self.assertTrue(self.app.asking_uuid_dict.has_key(uuid)) self.assertTrue(self.app.asking_uuid_dict.has_key(uuid))
verification.handleAnswerObjectPresent(conn, packet, new_oid, new_tid) verification.answerObjectPresent(conn, packet, new_oid, new_tid)
# do work # do work
conn = self.getFakeConnection(uuid, self.storage_address) conn = self.getFakeConnection(uuid, self.storage_address)
self.assertEquals(len(self.app.asking_uuid_dict), 1) self.assertEquals(len(self.app.asking_uuid_dict), 1)
self.app.asking_uuid_dict[uuid] = False self.app.asking_uuid_dict[uuid] = False
self.assertFalse(self.app.asking_uuid_dict[uuid]) self.assertFalse(self.app.asking_uuid_dict[uuid])
verification.handleAnswerObjectPresent(conn, packet, new_oid, new_tid) verification.answerObjectPresent(conn, packet, new_oid, new_tid)
self.assertTrue(self.app.asking_uuid_dict[uuid]) self.assertTrue(self.app.asking_uuid_dict[uuid])
def test_15_handleOidNotFound(self): def test_15_oidNotFound(self):
verification = self.verification verification = self.verification
uuid = self.identifyToMasterNode() uuid = self.identifyToMasterNode()
packet = Packet(msg_type=ErrorCodes.OID_NOT_FOUND) packet = Packet(msg_type=ErrorCodes.OID_NOT_FOUND)
...@@ -279,7 +279,7 @@ class MasterVerificationTests(NeoTestBase): ...@@ -279,7 +279,7 @@ class MasterVerificationTests(NeoTestBase):
self.app.asking_uuid_dict[uuid] = True self.app.asking_uuid_dict[uuid] = True
self.app.object_present = True self.app.object_present = True
self.assertTrue(self.app.object_present) self.assertTrue(self.app.object_present)
verification.handleOidNotFound(conn, packet, "msg") verification.oidNotFound(conn, packet, "msg")
self.assertTrue(self.app.object_present) self.assertTrue(self.app.object_present)
# do work as asking_uuid_dict is False # do work as asking_uuid_dict is False
conn = self.getFakeConnection(uuid, self.storage_address) conn = self.getFakeConnection(uuid, self.storage_address)
...@@ -287,7 +287,7 @@ class MasterVerificationTests(NeoTestBase): ...@@ -287,7 +287,7 @@ class MasterVerificationTests(NeoTestBase):
self.app.asking_uuid_dict[uuid] = False self.app.asking_uuid_dict[uuid] = False
self.assertFalse(self.app.asking_uuid_dict[uuid ]) self.assertFalse(self.app.asking_uuid_dict[uuid ])
self.assertTrue(self.app.object_present) self.assertTrue(self.app.object_present)
verification.handleOidNotFound(conn, packet, "msg") verification.oidNotFound(conn, packet, "msg")
self.assertFalse(self.app.object_present) self.assertFalse(self.app.object_present)
self.assertTrue(self.app.asking_uuid_dict[uuid ]) self.assertTrue(self.app.asking_uuid_dict[uuid ])
......
This diff is collapsed.
...@@ -79,7 +79,7 @@ class StorageInitializationHandlerTests(NeoTestBase): ...@@ -79,7 +79,7 @@ class StorageInitializationHandlerTests(NeoTestBase):
# nothing happens # nothing happens
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
def test_09_handleSendPartitionTable(self): def test_09_sendPartitionTable(self):
packet = Packet(msg_type=PacketTypes.SEND_PARTITION_TABLE) packet = Packet(msg_type=PacketTypes.SEND_PARTITION_TABLE)
uuid = self.getNewUUID() uuid = self.getNewUUID()
# send a table # send a table
...@@ -101,19 +101,19 @@ class StorageInitializationHandlerTests(NeoTestBase): ...@@ -101,19 +101,19 @@ class StorageInitializationHandlerTests(NeoTestBase):
(2, ((node_2, CellStates.UP_TO_DATE), (node_3, CellStates.UP_TO_DATE)))] (2, ((node_2, CellStates.UP_TO_DATE), (node_3, CellStates.UP_TO_DATE)))]
self.assertFalse(self.app.pt.filled()) self.assertFalse(self.app.pt.filled())
# send part of the table, won't be filled # send part of the table, won't be filled
self.verification.handleSendPartitionTable(conn, packet, 1, row_list[:1]) self.verification.sendPartitionTable(conn, packet, 1, row_list[:1])
self.assertFalse(self.app.pt.filled()) self.assertFalse(self.app.pt.filled())
self.assertEqual(self.app.pt.getID(), 1) self.assertEqual(self.app.pt.getID(), 1)
self.assertEqual(self.app.dm.getPartitionTable(), []) self.assertEqual(self.app.dm.getPartitionTable(), [])
# send remaining of the table (ack with AnswerPartitionTable) # send remaining of the table (ack with AnswerPartitionTable)
self.verification.handleSendPartitionTable(conn, packet, 1, row_list[1:]) self.verification.sendPartitionTable(conn, packet, 1, row_list[1:])
self.verification.handleAnswerPartitionTable(conn, packet, 1, []) self.verification.answerPartitionTable(conn, packet, 1, [])
self.assertTrue(self.app.pt.filled()) self.assertTrue(self.app.pt.filled())
self.assertEqual(self.app.pt.getID(), 1) self.assertEqual(self.app.pt.getID(), 1)
self.assertNotEqual(self.app.dm.getPartitionTable(), []) self.assertNotEqual(self.app.dm.getPartitionTable(), [])
# send a complete new table and ack # send a complete new table and ack
self.verification.handleSendPartitionTable(conn, packet, 2, row_list) self.verification.sendPartitionTable(conn, packet, 2, row_list)
self.verification.handleAnswerPartitionTable(conn, packet, 2, []) self.verification.answerPartitionTable(conn, packet, 2, [])
self.assertTrue(self.app.pt.filled()) self.assertTrue(self.app.pt.filled())
self.assertEqual(self.app.pt.getID(), 2) self.assertEqual(self.app.pt.getID(), 2)
self.assertNotEqual(self.app.dm.getPartitionTable(), []) self.assertNotEqual(self.app.dm.getPartitionTable(), [])
......
...@@ -92,7 +92,7 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -92,7 +92,7 @@ class StorageMasterHandlerTests(NeoTestBase):
self.assertRaises(PrimaryFailure, self.operation.peerBroken, conn) self.assertRaises(PrimaryFailure, self.operation.peerBroken, conn)
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
def test_14_handleNotifyPartitionChanges1(self): def test_14_notifyPartitionChanges1(self):
# old partition change -> do nothing # old partition change -> do nothing
app = self.app app = self.app
conn = Mock({ conn = Mock({
...@@ -103,7 +103,7 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -103,7 +103,7 @@ class StorageMasterHandlerTests(NeoTestBase):
packet = Packet(msg_type=PacketTypes.NOTIFY_PARTITION_CHANGES) packet = Packet(msg_type=PacketTypes.NOTIFY_PARTITION_CHANGES)
self.app.pt = Mock({'getID': 1}) self.app.pt = Mock({'getID': 1})
count = len(self.app.nm.getList()) count = len(self.app.nm.getList())
self.operation.handleNotifyPartitionChanges(conn, packet, 0, ()) self.operation.notifyPartitionChanges(conn, packet, 0, ())
self.assertEquals(self.app.pt.getID(), 1) self.assertEquals(self.app.pt.getID(), 1)
self.assertEquals(len(self.app.nm.getList()), count) self.assertEquals(len(self.app.nm.getList()), count)
calls = self.app.replicator.mockGetNamedCalls('removePartition') calls = self.app.replicator.mockGetNamedCalls('removePartition')
...@@ -111,7 +111,7 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -111,7 +111,7 @@ class StorageMasterHandlerTests(NeoTestBase):
calls = self.app.replicator.mockGetNamedCalls('addPartition') calls = self.app.replicator.mockGetNamedCalls('addPartition')
self.assertEquals(len(calls), 0) self.assertEquals(len(calls), 0)
def test_14_handleNotifyPartitionChanges2(self): def test_14_notifyPartitionChanges2(self):
# cases : # cases :
uuid1, uuid2, uuid3 = [self.getNewUUID() for i in range(3)] uuid1, uuid2, uuid3 = [self.getNewUUID() for i in range(3)]
cells = ( cells = (
...@@ -136,7 +136,7 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -136,7 +136,7 @@ class StorageMasterHandlerTests(NeoTestBase):
app.dm = Mock({ }) app.dm = Mock({ })
app.replicator = Mock({}) app.replicator = Mock({})
count = len(app.nm.getList()) count = len(app.nm.getList())
self.operation.handleNotifyPartitionChanges(conn, packet, ptid2, cells) self.operation.notifyPartitionChanges(conn, packet, ptid2, cells)
# ptid set # ptid set
self.assertEquals(app.pt.getID(), ptid2) self.assertEquals(app.pt.getID(), ptid2)
# dm call # dm call
...@@ -144,13 +144,13 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -144,13 +144,13 @@ class StorageMasterHandlerTests(NeoTestBase):
self.assertEquals(len(calls), 1) self.assertEquals(len(calls), 1)
calls[0].checkArgs(ptid2, cells) calls[0].checkArgs(ptid2, cells)
def test_16_handleStopOperation1(self): def test_16_stopOperation1(self):
# OperationFailure # OperationFailure
conn = Mock({ 'isServer': False }) conn = Mock({ 'isServer': False })
packet = Packet(msg_type=PacketTypes.STOP_OPERATION) packet = Packet(msg_type=PacketTypes.STOP_OPERATION)
self.assertRaises(OperationFailure, self.operation.handleStopOperation, conn, packet) self.assertRaises(OperationFailure, self.operation.stopOperation, conn, packet)
def test_22_handleLockInformation2(self): def test_22_lockInformation2(self):
# load transaction informations # load transaction informations
conn = Mock({ 'isServer': False, }) conn = Mock({ 'isServer': False, })
self.app.dm = Mock({ }) self.app.dm = Mock({ })
...@@ -158,7 +158,7 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -158,7 +158,7 @@ class StorageMasterHandlerTests(NeoTestBase):
packet.setId(1) packet.setId(1)
transaction = Mock({ 'getObjectList': ((0, ), ), }) transaction = Mock({ 'getObjectList': ((0, ), ), })
self.app.transaction_dict[INVALID_TID] = transaction self.app.transaction_dict[INVALID_TID] = transaction
self.operation.handleLockInformation(conn, packet, INVALID_TID) self.operation.lockInformation(conn, packet, INVALID_TID)
self.assertEquals(self.app.load_lock_dict[0], INVALID_TID) self.assertEquals(self.app.load_lock_dict[0], INVALID_TID)
calls = self.app.dm.mockGetNamedCalls('storeTransaction') calls = self.app.dm.mockGetNamedCalls('storeTransaction')
self.assertEquals(len(calls), 1) self.assertEquals(len(calls), 1)
...@@ -166,10 +166,10 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -166,10 +166,10 @@ class StorageMasterHandlerTests(NeoTestBase):
# transaction not in transaction_dict -> KeyError # transaction not in transaction_dict -> KeyError
transaction = Mock({ 'getObjectList': ((0, ), ), }) transaction = Mock({ 'getObjectList': ((0, ), ), })
conn = Mock({ 'isServer': False, }) conn = Mock({ 'isServer': False, })
self.operation.handleLockInformation(conn, packet, '\x01' * 8) self.operation.lockInformation(conn, packet, '\x01' * 8)
self.checkNotifyInformationLocked(conn, answered_packet=packet) self.checkNotifyInformationLocked(conn, answered_packet=packet)
def test_23_handleUnlockInformation2(self): def test_23_unlockInformation2(self):
# delete transaction informations # delete transaction informations
conn = Mock({ 'isServer': False, }) conn = Mock({ 'isServer': False, })
self.app.dm = Mock({ }) self.app.dm = Mock({ })
...@@ -179,7 +179,7 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -179,7 +179,7 @@ class StorageMasterHandlerTests(NeoTestBase):
self.app.transaction_dict[INVALID_TID] = transaction self.app.transaction_dict[INVALID_TID] = transaction
self.app.load_lock_dict[0] = transaction self.app.load_lock_dict[0] = transaction
self.app.store_lock_dict[0] = transaction self.app.store_lock_dict[0] = transaction
self.operation.handleUnlockInformation(conn, packet, INVALID_TID) self.operation.unlockInformation(conn, packet, INVALID_TID)
self.assertEquals(len(self.app.load_lock_dict), 0) self.assertEquals(len(self.app.load_lock_dict), 0)
self.assertEquals(len(self.app.store_lock_dict), 0) self.assertEquals(len(self.app.store_lock_dict), 0)
self.assertEquals(len(self.app.store_lock_dict), 0) self.assertEquals(len(self.app.store_lock_dict), 0)
...@@ -189,15 +189,15 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -189,15 +189,15 @@ class StorageMasterHandlerTests(NeoTestBase):
# transaction not in transaction_dict -> KeyError # transaction not in transaction_dict -> KeyError
transaction = Mock({ 'getObjectList': ((0, ), ), }) transaction = Mock({ 'getObjectList': ((0, ), ), })
conn = Mock({ 'isServer': False, }) conn = Mock({ 'isServer': False, })
self.operation.handleLockInformation(conn, packet, '\x01' * 8) self.operation.lockInformation(conn, packet, '\x01' * 8)
self.checkNotifyInformationLocked(conn, answered_packet=packet) self.checkNotifyInformationLocked(conn, answered_packet=packet)
def test_30_handleAnswerLastIDs(self): def test_30_answerLastIDs(self):
# set critical TID on replicator # set critical TID on replicator
conn = Mock() conn = Mock()
packet = Packet(msg_type=PacketTypes.ANSWER_LAST_IDS) packet = Packet(msg_type=PacketTypes.ANSWER_LAST_IDS)
self.app.replicator = Mock() self.app.replicator = Mock()
self.operation.handleAnswerLastIDs( self.operation.answerLastIDs(
conn=conn, conn=conn,
packet=packet, packet=packet,
loid=INVALID_OID, loid=INVALID_OID,
...@@ -208,12 +208,12 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -208,12 +208,12 @@ class StorageMasterHandlerTests(NeoTestBase):
self.assertEquals(len(calls), 1) self.assertEquals(len(calls), 1)
calls[0].checkArgs(packet, INVALID_TID) calls[0].checkArgs(packet, INVALID_TID)
def test_31_handleAnswerUnfinishedTransactions(self): def test_31_answerUnfinishedTransactions(self):
# set unfinished TID on replicator # set unfinished TID on replicator
conn = Mock() conn = Mock()
packet = Packet(msg_type=PacketTypes.ANSWER_UNFINISHED_TRANSACTIONS) packet = Packet(msg_type=PacketTypes.ANSWER_UNFINISHED_TRANSACTIONS)
self.app.replicator = Mock() self.app.replicator = Mock()
self.operation.handleAnswerUnfinishedTransactions( self.operation.answerUnfinishedTransactions(
conn=conn, conn=conn,
packet=packet, packet=packet,
tid_list=(INVALID_TID, ), tid_list=(INVALID_TID, ),
......
...@@ -62,30 +62,30 @@ class StorageStorageHandlerTests(NeoTestBase): ...@@ -62,30 +62,30 @@ class StorageStorageHandlerTests(NeoTestBase):
def tearDown(self): def tearDown(self):
NeoTestBase.tearDown(self) NeoTestBase.tearDown(self)
def test_18_handleAskTransactionInformation1(self): def test_18_askTransactionInformation1(self):
# transaction does not exists # transaction does not exists
conn = Mock({ }) conn = Mock({ })
packet = Packet(msg_type=PacketTypes.ASK_TRANSACTION_INFORMATION) packet = Packet(msg_type=PacketTypes.ASK_TRANSACTION_INFORMATION)
self.operation.handleAskTransactionInformation(conn, packet, INVALID_TID) self.operation.askTransactionInformation(conn, packet, INVALID_TID)
self.checkErrorPacket(conn) self.checkErrorPacket(conn)
def test_18_handleAskTransactionInformation2(self): def test_18_askTransactionInformation2(self):
# answer # answer
conn = Mock({ }) conn = Mock({ })
packet = Packet(msg_type=PacketTypes.ASK_TRANSACTION_INFORMATION) packet = Packet(msg_type=PacketTypes.ASK_TRANSACTION_INFORMATION)
dm = Mock({ "getTransaction": (INVALID_TID, 'user', 'desc', '', ), }) dm = Mock({ "getTransaction": (INVALID_TID, 'user', 'desc', '', ), })
self.app.dm = dm self.app.dm = dm
self.operation.handleAskTransactionInformation(conn, packet, INVALID_TID) self.operation.askTransactionInformation(conn, packet, INVALID_TID)
self.checkAnswerTransactionInformation(conn) self.checkAnswerTransactionInformation(conn)
def test_24_handleAskObject1(self): def test_24_askObject1(self):
# delayed response # delayed response
conn = Mock({}) conn = Mock({})
self.app.dm = Mock() self.app.dm = Mock()
packet = Packet(msg_type=PacketTypes.ASK_OBJECT) packet = Packet(msg_type=PacketTypes.ASK_OBJECT)
self.app.load_lock_dict[INVALID_OID] = object() self.app.load_lock_dict[INVALID_OID] = object()
self.assertEquals(len(self.app.event_queue), 0) self.assertEquals(len(self.app.event_queue), 0)
self.operation.handleAskObject(conn, packet, self.operation.askObject(conn, packet,
oid=INVALID_OID, oid=INVALID_OID,
serial=INVALID_SERIAL, serial=INVALID_SERIAL,
tid=INVALID_TID) tid=INVALID_TID)
...@@ -93,13 +93,13 @@ class StorageStorageHandlerTests(NeoTestBase): ...@@ -93,13 +93,13 @@ class StorageStorageHandlerTests(NeoTestBase):
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
self.assertEquals(len(self.app.dm.mockGetNamedCalls('getObject')), 0) self.assertEquals(len(self.app.dm.mockGetNamedCalls('getObject')), 0)
def test_24_handleAskObject2(self): def test_24_askObject2(self):
# invalid serial / tid / packet not found # invalid serial / tid / packet not found
self.app.dm = Mock({'getObject': None}) self.app.dm = Mock({'getObject': None})
conn = Mock({}) conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OBJECT) packet = Packet(msg_type=PacketTypes.ASK_OBJECT)
self.assertEquals(len(self.app.event_queue), 0) self.assertEquals(len(self.app.event_queue), 0)
self.operation.handleAskObject(conn, packet, self.operation.askObject(conn, packet,
oid=INVALID_OID, oid=INVALID_OID,
serial=INVALID_SERIAL, serial=INVALID_SERIAL,
tid=INVALID_TID) tid=INVALID_TID)
...@@ -109,109 +109,109 @@ class StorageStorageHandlerTests(NeoTestBase): ...@@ -109,109 +109,109 @@ class StorageStorageHandlerTests(NeoTestBase):
calls[0].checkArgs(INVALID_OID, INVALID_TID, INVALID_TID) calls[0].checkArgs(INVALID_OID, INVALID_TID, INVALID_TID)
self.checkErrorPacket(conn) self.checkErrorPacket(conn)
def test_24_handleAskObject3(self): def test_24_askObject3(self):
# object found => answer # object found => answer
self.app.dm = Mock({'getObject': ('', '', 0, 0, '', )}) self.app.dm = Mock({'getObject': ('', '', 0, 0, '', )})
conn = Mock({}) conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OBJECT) packet = Packet(msg_type=PacketTypes.ASK_OBJECT)
self.assertEquals(len(self.app.event_queue), 0) self.assertEquals(len(self.app.event_queue), 0)
self.operation.handleAskObject(conn, packet, self.operation.askObject(conn, packet,
oid=INVALID_OID, oid=INVALID_OID,
serial=INVALID_SERIAL, serial=INVALID_SERIAL,
tid=INVALID_TID) tid=INVALID_TID)
self.assertEquals(len(self.app.event_queue), 0) self.assertEquals(len(self.app.event_queue), 0)
self.checkAnswerObject(conn) self.checkAnswerObject(conn)
def test_25_handleAskTIDs1(self): def test_25_askTIDs1(self):
# invalid offsets => error # invalid offsets => error
app = self.app app = self.app
app.pt = Mock() app.pt = Mock()
app.dm = Mock() app.dm = Mock()
conn = Mock({}) conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_TIDS) packet = Packet(msg_type=PacketTypes.ASK_TIDS)
self.checkProtocolErrorRaised(self.operation.handleAskTIDs, conn, packet, 1, 1, None) self.checkProtocolErrorRaised(self.operation.askTIDs, conn, packet, 1, 1, None)
self.assertEquals(len(app.pt.mockGetNamedCalls('getCellList')), 0) self.assertEquals(len(app.pt.mockGetNamedCalls('getCellList')), 0)
self.assertEquals(len(app.dm.mockGetNamedCalls('getTIDList')), 0) self.assertEquals(len(app.dm.mockGetNamedCalls('getTIDList')), 0)
def test_25_handleAskTIDs2(self): def test_25_askTIDs2(self):
# well case => answer # well case => answer
conn = Mock({}) conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_TIDS) packet = Packet(msg_type=PacketTypes.ASK_TIDS)
self.app.dm = Mock({'getTIDList': (INVALID_TID, )}) self.app.dm = Mock({'getTIDList': (INVALID_TID, )})
self.app.pt = Mock({'getPartitions': 1}) self.app.pt = Mock({'getPartitions': 1})
self.operation.handleAskTIDs(conn, packet, 1, 2, 1) self.operation.askTIDs(conn, packet, 1, 2, 1)
calls = self.app.dm.mockGetNamedCalls('getTIDList') calls = self.app.dm.mockGetNamedCalls('getTIDList')
self.assertEquals(len(calls), 1) self.assertEquals(len(calls), 1)
calls[0].checkArgs(1, 1, 1, [1, ]) calls[0].checkArgs(1, 1, 1, [1, ])
self.checkAnswerTids(conn) self.checkAnswerTids(conn)
def test_25_handleAskTIDs3(self): def test_25_askTIDs3(self):
# invalid partition => answer usable partitions # invalid partition => answer usable partitions
conn = Mock({}) conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_TIDS) packet = Packet(msg_type=PacketTypes.ASK_TIDS)
cell = Mock({'getUUID':self.app.uuid}) cell = Mock({'getUUID':self.app.uuid})
self.app.dm = Mock({'getTIDList': (INVALID_TID, )}) self.app.dm = Mock({'getTIDList': (INVALID_TID, )})
self.app.pt = Mock({'getCellList': (cell, ), 'getPartitions': 1}) self.app.pt = Mock({'getCellList': (cell, ), 'getPartitions': 1})
self.operation.handleAskTIDs(conn, packet, 1, 2, INVALID_PARTITION) self.operation.askTIDs(conn, packet, 1, 2, INVALID_PARTITION)
self.assertEquals(len(self.app.pt.mockGetNamedCalls('getCellList')), 1) self.assertEquals(len(self.app.pt.mockGetNamedCalls('getCellList')), 1)
calls = self.app.dm.mockGetNamedCalls('getTIDList') calls = self.app.dm.mockGetNamedCalls('getTIDList')
self.assertEquals(len(calls), 1) self.assertEquals(len(calls), 1)
calls[0].checkArgs(1, 1, 1, [0, ]) calls[0].checkArgs(1, 1, 1, [0, ])
self.checkAnswerTids(conn) self.checkAnswerTids(conn)
def test_26_handleAskObjectHistory1(self): def test_26_askObjectHistory1(self):
# invalid offsets => error # invalid offsets => error
app = self.app app = self.app
app.dm = Mock() app.dm = Mock()
conn = Mock({}) conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OBJECT_HISTORY) packet = Packet(msg_type=PacketTypes.ASK_OBJECT_HISTORY)
self.checkProtocolErrorRaised(self.operation.handleAskObjectHistory, conn, packet, 1, 1, None) self.checkProtocolErrorRaised(self.operation.askObjectHistory, conn, packet, 1, 1, None)
self.assertEquals(len(app.dm.mockGetNamedCalls('getObjectHistory')), 0) self.assertEquals(len(app.dm.mockGetNamedCalls('getObjectHistory')), 0)
def test_26_handleAskObjectHistory2(self): def test_26_askObjectHistory2(self):
# first case: empty history # first case: empty history
packet = Packet(msg_type=PacketTypes.ASK_OBJECT_HISTORY) packet = Packet(msg_type=PacketTypes.ASK_OBJECT_HISTORY)
conn = Mock({}) conn = Mock({})
self.app.dm = Mock({'getObjectHistory': None}) self.app.dm = Mock({'getObjectHistory': None})
self.operation.handleAskObjectHistory(conn, packet, INVALID_OID, 1, 2) self.operation.askObjectHistory(conn, packet, INVALID_OID, 1, 2)
self.checkAnswerObjectHistory(conn) self.checkAnswerObjectHistory(conn)
# second case: not empty history # second case: not empty history
conn = Mock({}) conn = Mock({})
self.app.dm = Mock({'getObjectHistory': [('', 0, ), ]}) self.app.dm = Mock({'getObjectHistory': [('', 0, ), ]})
self.operation.handleAskObjectHistory(conn, packet, INVALID_OID, 1, 2) self.operation.askObjectHistory(conn, packet, INVALID_OID, 1, 2)
self.checkAnswerObjectHistory(conn) self.checkAnswerObjectHistory(conn)
def test_25_handleAskOIDs1(self): def test_25_askOIDs1(self):
# invalid offsets => error # invalid offsets => error
app = self.app app = self.app
app.pt = Mock() app.pt = Mock()
app.dm = Mock() app.dm = Mock()
conn = Mock({}) conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OIDS) packet = Packet(msg_type=PacketTypes.ASK_OIDS)
self.checkProtocolErrorRaised(self.operation.handleAskOIDs, conn, packet, 1, 1, None) self.checkProtocolErrorRaised(self.operation.askOIDs, conn, packet, 1, 1, None)
self.assertEquals(len(app.pt.mockGetNamedCalls('getCellList')), 0) self.assertEquals(len(app.pt.mockGetNamedCalls('getCellList')), 0)
self.assertEquals(len(app.dm.mockGetNamedCalls('getOIDList')), 0) self.assertEquals(len(app.dm.mockGetNamedCalls('getOIDList')), 0)
def test_25_handleAskOIDs2(self): def test_25_askOIDs2(self):
# well case > answer OIDs # well case > answer OIDs
conn = Mock({}) conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OIDS) packet = Packet(msg_type=PacketTypes.ASK_OIDS)
self.app.pt = Mock({'getPartitions': 1}) self.app.pt = Mock({'getPartitions': 1})
self.app.dm = Mock({'getOIDList': (INVALID_OID, )}) self.app.dm = Mock({'getOIDList': (INVALID_OID, )})
self.operation.handleAskOIDs(conn, packet, 1, 2, 1) self.operation.askOIDs(conn, packet, 1, 2, 1)
calls = self.app.dm.mockGetNamedCalls('getOIDList') calls = self.app.dm.mockGetNamedCalls('getOIDList')
self.assertEquals(len(calls), 1) self.assertEquals(len(calls), 1)
calls[0].checkArgs(1, 1, 1, [1, ]) calls[0].checkArgs(1, 1, 1, [1, ])
self.checkAnswerOids(conn) self.checkAnswerOids(conn)
def test_25_handleAskOIDs3(self): def test_25_askOIDs3(self):
# invalid partition => answer usable partitions # invalid partition => answer usable partitions
conn = Mock({}) conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OIDS) packet = Packet(msg_type=PacketTypes.ASK_OIDS)
cell = Mock({'getUUID':self.app.uuid}) cell = Mock({'getUUID':self.app.uuid})
self.app.dm = Mock({'getOIDList': (INVALID_OID, )}) self.app.dm = Mock({'getOIDList': (INVALID_OID, )})
self.app.pt = Mock({'getCellList': (cell, ), 'getPartitions': 1}) self.app.pt = Mock({'getCellList': (cell, ), 'getPartitions': 1})
self.operation.handleAskOIDs(conn, packet, 1, 2, INVALID_PARTITION) self.operation.askOIDs(conn, packet, 1, 2, INVALID_PARTITION)
self.assertEquals(len(self.app.pt.mockGetNamedCalls('getCellList')), 1) self.assertEquals(len(self.app.pt.mockGetNamedCalls('getCellList')), 1)
calls = self.app.dm.mockGetNamedCalls('getOIDList') calls = self.app.dm.mockGetNamedCalls('getOIDList')
self.assertEquals(len(calls), 1) self.assertEquals(len(calls), 1)
......
...@@ -57,7 +57,7 @@ class BootstrapManagerTests(NeoTestBase): ...@@ -57,7 +57,7 @@ class BootstrapManagerTests(NeoTestBase):
# the primary is not ready # the primary is not ready
conn = Mock({}) conn = Mock({})
packet = Mock({}) packet = Mock({})
self.bootstrap.handleNotReady(conn, packet, '') self.bootstrap.notReady(conn, packet, '')
self.checkClosed(conn) self.checkClosed(conn)
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
......
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