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
class AdminEventHandler(EventHandler):
"""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)))
app = self.app
# check we have one pt otherwise ask it to PMN
......@@ -43,7 +43,7 @@ class AdminEventHandler(EventHandler):
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))
def node_filter(n):
return n.getType() is node_type
......@@ -52,7 +52,7 @@ class AdminEventHandler(EventHandler):
p = protocol.answerNodeList(node_information_list)
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))
node = self.app.nm.getByUUID(uuid)
if node is None:
......@@ -69,7 +69,7 @@ class AdminEventHandler(EventHandler):
msg_id = self.app.master_conn.ask(p)
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
if self.app.master_conn is None:
raise protocol.NotReadyError('Not connected to a primary master.')
......@@ -77,7 +77,7 @@ class AdminEventHandler(EventHandler):
msg_id = self.app.master_conn.ask(p)
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:
raise protocol.NotReadyError('Not connected to a primary master.')
logging.info('Add nodes %s' % [dump(uuid) for uuid in uuid_list])
......@@ -85,7 +85,7 @@ class AdminEventHandler(EventHandler):
msg_id = self.app.master_conn.ask(protocol.addPendingNodes(uuid_list))
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.master_conn is None:
raise protocol.NotReadyError('Not connected to a primary master.')
......@@ -96,7 +96,7 @@ class AdminEventHandler(EventHandler):
conn.answer(protocol.answerClusterState(self.app.cluster_state),
packet.getId())
def handleAskPrimaryMaster(self, conn, packet):
def askPrimaryMaster(self, conn, packet):
if self.app.master_conn is None:
raise protocol.NotReadyError('Not connected to a primary master.')
master_node = self.app.master_node
......@@ -135,17 +135,17 @@ class MasterEventHandler(EventHandler):
# unexpectexd answers and notifications
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
# 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
# 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
if ptid < app.ptid:
# Ignore this packet.
......@@ -153,7 +153,7 @@ class MasterEventHandler(EventHandler):
app.ptid = ptid
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()
app = self.app
nm = app.nm
......@@ -170,10 +170,10 @@ class MasterEventHandler(EventHandler):
pt.setCell(offset, node, state)
pt.log()
def handleNotifyClusterInformation(self, conn, packet, cluster_state):
def notifyClusterInformation(self, conn, packet, 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.nm.update(node_list)
if not app.pt.filled():
......@@ -189,30 +189,30 @@ class MasterRequestEventHandler(EventHandler):
client_conn, kw = self.app.dispatcher.pop(msg_id)
client_conn.answer(packet, kw['msg_id'])
def handleAnswerClusterState(self, conn, packet, state):
logging.info("handleAnswerClusterState for a conn")
def answerClusterState(self, conn, packet, state):
logging.info("answerClusterState for a conn")
self.app.cluster_state = state
self.__answerNeoCTL(packet.getId(),
protocol.answerClusterState(state))
def handleAnswerNewNodes(self, conn, packet, uuid_list):
logging.info("handleAnswerNewNodes for a conn")
def answerNewNodes(self, conn, packet, uuid_list):
logging.info("answerNewNodes for a conn")
self.__answerNeoCTL(packet.getId(),
protocol.answerNewNodes(uuid_list))
def handleAnswerPartitionTable(self, conn, packet, ptid, row_list):
logging.info("handleAnswerPartitionTable for a conn")
def answerPartitionTable(self, conn, packet, ptid, row_list):
logging.info("answerPartitionTable for a conn")
client_conn, kw = self.app.dispatcher.pop(packet.getId())
# sent client the partition table
self.app.sendPartitionTable(client_conn, **kw)
def handleAnswerNodeState(self, conn, packet, uuid, state):
def answerNodeState(self, conn, packet, uuid, state):
self.__answerNeoCTL(packet.getId(),
protocol.answerNodeState(uuid, state))
def handleNoError(self, conn, packet, msg):
def noError(self, conn, packet, 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))
......@@ -52,12 +52,12 @@ class BootstrapManager(EventHandler):
def connectionLost(self, conn, new_state):
self.current = None
def handleNotReady(self, conn, packet, message):
def notReady(self, conn, packet, message):
# master are still electing on of them
self.current = None
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
# Register new master nodes.
......@@ -81,7 +81,7 @@ class BootstrapManager(EventHandler):
conn.ask(protocol.requestNodeIdentification(self.node_type,
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):
self.num_partitions = num_partitions
self.num_replicas = num_replicas
......
......@@ -25,12 +25,12 @@ from neo.util import dump
class PrimaryBootstrapHandler(AnswerBaseHandler):
""" 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.trying_master_node = None
app.setNodeNotReady()
def handleAcceptNodeIdentification(self, conn, packet, node_type,
def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, num_replicas, your_uuid):
app = self.app
node = app.nm.getByAddress(conn.getAddress())
......@@ -57,7 +57,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
# Always create partition table
app.pt = PartitionTable(num_partitions, num_replicas)
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid,
def answerPrimaryMaster(self, conn, packet, primary_uuid,
known_master_list):
app = self.app
# Register new master nodes.
......@@ -92,10 +92,10 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
app.trying_master_node = None
conn.close()
def handleAnswerPartitionTable(self, conn, packet, ptid, row_list):
def answerPartitionTable(self, conn, packet, ptid, row_list):
pass
def handleAnswerNodeInformation(self, conn, packet, node_list):
def answerNodeInformation(self, conn, packet, node_list):
pass
class PrimaryNotificationsHandler(BaseHandler):
......@@ -126,10 +126,10 @@ class PrimaryNotificationsHandler(BaseHandler):
logging.critical("primary master node is broken")
BaseHandler.peerBroken(self, conn)
def handleStopOperation(self, conn, packet):
def stopOperation(self, conn, packet):
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._cache_lock_acquire()
try:
......@@ -151,15 +151,15 @@ class PrimaryNotificationsHandler(BaseHandler):
# 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
# established.
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list):
def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
pt = self.app.pt
if pt.filled():
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)
def handleNotifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, packet, node_list):
app = self.app
self.app.nm.update(node_list)
for node_type, addr, uuid, state in node_list:
......@@ -178,16 +178,16 @@ class PrimaryNotificationsHandler(BaseHandler):
class PrimaryAnswersHandler(AnswerBaseHandler):
""" 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.setTID(tid)
def handleAnswerNewOIDs(self, conn, packet, oid_list):
def answerNewOIDs(self, conn, packet, oid_list):
app = self.app
app.new_oid_list = oid_list
app.new_oid_list.reverse()
def handleNotifyTransactionFinished(self, conn, packet, tid):
def notifyTransactionFinished(self, conn, packet, tid):
app = self.app
if tid == app.getTID():
app.setTransactionFinished()
......
......@@ -48,11 +48,11 @@ class StorageEventHandler(BaseHandler):
class StorageBootstrapHandler(AnswerBaseHandler):
""" Handler used when connecting to a storage node """
def handleNotReady(self, conn, packet, message):
def notReady(self, conn, packet, message):
app = self.app
app.setNodeNotReady()
def handleAcceptNodeIdentification(self, conn, packet, node_type,
def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, num_replicas, your_uuid):
app = self.app
node = app.nm.getByAddress(conn.getAddress())
......@@ -75,24 +75,24 @@ class StorageBootstrapHandler(AnswerBaseHandler):
class StorageAnswersHandler(AnswerBaseHandler):
""" 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):
app = self.app
app.local_var.asked_object = (oid, start_serial, end_serial, compression,
checksum, data)
def handleAnswerStoreObject(self, conn, packet, conflicting, oid, serial):
def answerStoreObject(self, conn, packet, conflicting, oid, serial):
app = self.app
if conflicting:
app.local_var.object_stored = -1, serial
else:
app.local_var.object_stored = oid, serial
def handleAnswerStoreTransaction(self, conn, packet, tid):
def answerStoreTransaction(self, conn, packet, tid):
app = self.app
app.setTransactionVoted()
def handleAnswerTransactionInformation(self, conn, packet, tid,
def answerTransactionInformation(self, conn, packet, tid,
user, desc, ext, oid_list):
app = self.app
# transaction information are returned as a dict
......@@ -104,12 +104,12 @@ class StorageAnswersHandler(AnswerBaseHandler):
info['oids'] = oid_list
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
# history_list is a list of tuple (serial, size)
app.local_var.history = oid, history_list
def handleOidNotFound(self, conn, packet, message):
def oidNotFound(self, conn, packet, message):
app = self.app
# This can happen either when :
# - loading an object
......@@ -117,12 +117,12 @@ class StorageAnswersHandler(AnswerBaseHandler):
app.local_var.asked_object = -1
app.local_var.history = -1
def handleTidNotFound(self, conn, packet, message):
def tidNotFound(self, conn, packet, message):
app = self.app
# This can happen when requiring txn informations
app.local_var.txn_info = -1
def handleAnswerTIDs(self, conn, packet, tid_list):
def answerTIDs(self, conn, packet, tid_list):
app = self.app
app.local_var.node_tids[conn.getUUID()] = tid_list
......@@ -140,226 +140,226 @@ class EventHandler(object):
# Packet handlers.
def handleRequestNodeIdentification(self, conn, packet, node_type,
def requestNodeIdentification(self, conn, packet, node_type,
uuid, address, name):
raise UnexpectedPacketError
def handleAcceptNodeIdentification(self, conn, packet, node_type,
def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, num_replicas, your_uuid):
raise UnexpectedPacketError
def handleAskPrimaryMaster(self, conn, packet):
def askPrimaryMaster(self, conn, packet):
raise UnexpectedPacketError
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid,
def answerPrimaryMaster(self, conn, packet, primary_uuid,
known_master_list):
raise UnexpectedPacketError
def handleAnnouncePrimaryMaster(self, conn, packet):
def announcePrimaryMaster(self, conn, packet):
raise UnexpectedPacketError
def handleReelectPrimaryMaster(self, conn, packet):
def reelectPrimaryMaster(self, conn, packet):
raise UnexpectedPacketError
def handleNotifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, packet, node_list):
raise UnexpectedPacketError
def handleAskLastIDs(self, conn, packet):
def askLastIDs(self, conn, packet):
raise UnexpectedPacketError
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid):
def answerLastIDs(self, conn, packet, loid, ltid, lptid):
raise UnexpectedPacketError
def handleAskPartitionTable(self, conn, packet, offset_list):
def askPartitionTable(self, conn, packet, offset_list):
raise UnexpectedPacketError
def handleAnswerPartitionTable(self, conn, packet, ptid, row_list):
def answerPartitionTable(self, conn, packet, ptid, row_list):
raise UnexpectedPacketError
def handleSendPartitionTable(self, conn, packet, ptid, row_list):
def sendPartitionTable(self, conn, packet, ptid, row_list):
raise UnexpectedPacketError
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list):
def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
raise UnexpectedPacketError
def handleStartOperation(self, conn, packet):
def startOperation(self, conn, packet):
raise UnexpectedPacketError
def handleStopOperation(self, conn, packet):
def stopOperation(self, conn, packet):
raise UnexpectedPacketError
def handleAskUnfinishedTransactions(self, conn, packet):
def askUnfinishedTransactions(self, conn, packet):
raise UnexpectedPacketError
def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list):
def answerUnfinishedTransactions(self, conn, packet, tid_list):
raise UnexpectedPacketError
def handleAskObjectPresent(self, conn, packet, oid, tid):
def askObjectPresent(self, conn, packet, oid, tid):
raise UnexpectedPacketError
def handleAnswerObjectPresent(self, conn, packet, oid, tid):
def answerObjectPresent(self, conn, packet, oid, tid):
raise UnexpectedPacketError
def handleDeleteTransaction(self, conn, packet, tid):
def deleteTransaction(self, conn, packet, tid):
raise UnexpectedPacketError
def handleCommitTransaction(self, conn, packet, tid):
def commitTransaction(self, conn, packet, tid):
raise UnexpectedPacketError
def handleAskBeginTransaction(self, conn, packet, tid):
def askBeginTransaction(self, conn, packet, tid):
raise UnexpectedPacketError
def handleAnswerBeginTransaction(self, conn, packet, tid):
def answerBeginTransaction(self, conn, packet, tid):
raise UnexpectedPacketError
def handleAskNewOIDs(self, conn, packet, num_oids):
def askNewOIDs(self, conn, packet, num_oids):
raise UnexpectedPacketError
def handleAnswerNewOIDs(self, conn, packet, num_oids):
def answerNewOIDs(self, conn, packet, num_oids):
raise UnexpectedPacketError
def handleFinishTransaction(self, conn, packet, oid_list, tid):
def finishTransaction(self, conn, packet, oid_list, tid):
raise UnexpectedPacketError
def handleNotifyTransactionFinished(self, conn, packet, tid):
def notifyTransactionFinished(self, conn, packet, tid):
raise UnexpectedPacketError
def handleLockInformation(self, conn, packet, tid):
def lockInformation(self, conn, packet, tid):
raise UnexpectedPacketError
def handleNotifyInformationLocked(self, conn, packet, tid):
def notifyInformationLocked(self, conn, packet, tid):
raise UnexpectedPacketError
def handleInvalidateObjects(self, conn, packet, oid_list, tid):
def invalidateObjects(self, conn, packet, oid_list, tid):
raise UnexpectedPacketError
def handleUnlockInformation(self, conn, packet, tid):
def unlockInformation(self, conn, packet, tid):
raise UnexpectedPacketError
def handleAskStoreObject(self, conn, packet, oid, serial,
def askStoreObject(self, conn, packet, oid, serial,
compression, checksum, data, tid):
raise UnexpectedPacketError
def handleAnswerStoreObject(self, conn, packet, conflicting, oid, serial):
def answerStoreObject(self, conn, packet, conflicting, oid, serial):
raise UnexpectedPacketError
def handleAbortTransaction(self, conn, packet, tid):
def abortTransaction(self, conn, packet, tid):
raise UnexpectedPacketError
def handleAskStoreTransaction(self, conn, packet, tid, user, desc,
def askStoreTransaction(self, conn, packet, tid, user, desc,
ext, oid_list):
raise UnexpectedPacketError
def handleAnswerStoreTransaction(self, conn, packet, tid):
def answerStoreTransaction(self, conn, packet, tid):
raise UnexpectedPacketError
def handleAskObject(self, conn, packet, oid, serial, tid):
def askObject(self, conn, packet, oid, serial, tid):
raise UnexpectedPacketError
def handleAnswerObject(self, conn, packet, oid, serial_start,
def answerObject(self, conn, packet, oid, serial_start,
serial_end, compression, checksum, data):
raise UnexpectedPacketError
def handleAskTIDs(self, conn, packet, first, last, partition):
def askTIDs(self, conn, packet, first, last, partition):
raise UnexpectedPacketError
def handleAnswerTIDs(self, conn, packet, tid_list):
def answerTIDs(self, conn, packet, tid_list):
raise UnexpectedPacketError
def handleAskTransactionInformation(self, conn, packet, tid):
def askTransactionInformation(self, conn, packet, tid):
raise UnexpectedPacketError
def handleAnswerTransactionInformation(self, conn, packet, tid,
def answerTransactionInformation(self, conn, packet, tid,
user, desc, ext, oid_list):
raise UnexpectedPacketError
def handleAskObjectHistory(self, conn, packet, oid, first, last):
def askObjectHistory(self, conn, packet, oid, first, last):
raise UnexpectedPacketError
def handleAnswerObjectHistory(self, conn, packet, oid, history_list):
def answerObjectHistory(self, conn, packet, oid, history_list):
raise UnexpectedPacketError
def handleAskOIDs(self, conn, packet, first, last, partition):
def askOIDs(self, conn, packet, first, last, partition):
raise UnexpectedPacketError
def handleAnswerOIDs(self, conn, packet, oid_list):
def answerOIDs(self, conn, packet, oid_list):
raise UnexpectedPacketError
def handleAskPartitionList(self, conn, packet, min_offset, max_offset, uuid):
def askPartitionList(self, conn, packet, min_offset, max_offset, uuid):
raise UnexpectedPacketError
def handleAnswerPartitionList(self, conn, packet, ptid, row_list):
def answerPartitionList(self, conn, packet, ptid, row_list):
raise UnexpectedPacketError
def handleAskNodeList(self, conn, packet, offset_list):
def askNodeList(self, conn, packet, offset_list):
raise UnexpectedPacketError
def handleAnswerNodeList(self, conn, packet, node_list):
def answerNodeList(self, conn, packet, node_list):
raise UnexpectedPacketError
def handleSetNodeState(self, conn, packet, uuid, state, modify_partition_table):
def setNodeState(self, conn, packet, uuid, state, modify_partition_table):
raise UnexpectedPacketError
def handleAnswerNodeState(self, conn, packet, uuid, state):
def answerNodeState(self, conn, packet, uuid, state):
raise UnexpectedPacketError
def handleAddPendingNodes(self, conn, packet, uuid_list):
def addPendingNodes(self, conn, packet, uuid_list):
raise UnexpectedPacketError
def handleAnswerNewNodes(self, conn, packet, uuid_list):
def answerNewNodes(self, conn, packet, uuid_list):
raise UnexpectedPacketError
def handleAskNodeInformation(self, conn, packet):
def askNodeInformation(self, conn, packet):
raise UnexpectedPacketError
def handleAnswerNodeInformation(self, conn, packet, node_list):
def answerNodeInformation(self, conn, packet, node_list):
raise UnexpectedPacketError
def handleAskClusterState(self, conn, packet):
def askClusterState(self, conn, packet):
raise UnexpectedPacketError
def handleAnswerClusterState(self, conn, packet, state):
def answerClusterState(self, conn, packet, state):
raise UnexpectedPacketError
def handleSetClusterState(self, conn, packet, state):
def setClusterState(self, conn, packet, state):
raise UnexpectedPacketError
def handleNotifyClusterInformation(self, conn, packet, state):
def notifyClusterInformation(self, conn, packet, state):
raise UnexpectedPacketError
def handleNotifyLastOID(self, conn, packet, oid):
def notifyLastOID(self, conn, packet, oid):
raise UnexpectedPacketError
# Error packet handlers.
def handleError(self, conn, packet, code, message):
def error(self, conn, packet, code, message):
try:
method = self.error_dispatch_table[code]
method(conn, packet, message)
except ValueError:
raise UnexpectedPacketError(message)
def handleNotReady(self, conn, packet, message):
def notReady(self, conn, packet, message):
raise UnexpectedPacketError
def handleOidNotFound(self, conn, packet, message):
def oidNotFound(self, conn, packet, message):
raise UnexpectedPacketError
def handleTidNotFound(self, conn, packet, message):
def tidNotFound(self, conn, packet, message):
raise UnexpectedPacketError
def handleProtocolError(self, conn, packet, message):
def protocolError(self, conn, packet, message):
# the connection should have been closed by the remote peer
logging.error('protocol error: %s' % (message,))
def handleTimeoutError(self, conn, packet, message):
def timeoutError(self, conn, packet, message):
logging.error('timeout error: %s' % (message,))
def handleBrokenNodeDisallowedError(self, conn, packet, message):
def brokenNodeDisallowedError(self, conn, packet, message):
raise RuntimeError, 'broken node disallowed error: %s' % (message,)
def handleNoError(self, conn, packet, message):
def noError(self, conn, packet, message):
logging.debug("no error message : %s" % (message))
......@@ -368,80 +368,80 @@ class EventHandler(object):
def __initPacketDispatchTable(self):
d = {}
d[PacketTypes.ERROR] = self.handleError
d[PacketTypes.REQUEST_NODE_IDENTIFICATION] = self.handleRequestNodeIdentification
d[PacketTypes.ACCEPT_NODE_IDENTIFICATION] = self.handleAcceptNodeIdentification
d[PacketTypes.ASK_PRIMARY_MASTER] = self.handleAskPrimaryMaster
d[PacketTypes.ANSWER_PRIMARY_MASTER] = self.handleAnswerPrimaryMaster
d[PacketTypes.ANNOUNCE_PRIMARY_MASTER] = self.handleAnnouncePrimaryMaster
d[PacketTypes.REELECT_PRIMARY_MASTER] = self.handleReelectPrimaryMaster
d[PacketTypes.NOTIFY_NODE_INFORMATION] = self.handleNotifyNodeInformation
d[PacketTypes.ASK_LAST_IDS] = self.handleAskLastIDs
d[PacketTypes.ANSWER_LAST_IDS] = self.handleAnswerLastIDs
d[PacketTypes.ASK_PARTITION_TABLE] = self.handleAskPartitionTable
d[PacketTypes.ANSWER_PARTITION_TABLE] = self.handleAnswerPartitionTable
d[PacketTypes.SEND_PARTITION_TABLE] = self.handleSendPartitionTable
d[PacketTypes.NOTIFY_PARTITION_CHANGES] = self.handleNotifyPartitionChanges
d[PacketTypes.START_OPERATION] = self.handleStartOperation
d[PacketTypes.STOP_OPERATION] = self.handleStopOperation
d[PacketTypes.ASK_UNFINISHED_TRANSACTIONS] = self.handleAskUnfinishedTransactions
d[PacketTypes.ANSWER_UNFINISHED_TRANSACTIONS] = self.handleAnswerUnfinishedTransactions
d[PacketTypes.ASK_OBJECT_PRESENT] = self.handleAskObjectPresent
d[PacketTypes.ANSWER_OBJECT_PRESENT] = self.handleAnswerObjectPresent
d[PacketTypes.DELETE_TRANSACTION] = self.handleDeleteTransaction
d[PacketTypes.COMMIT_TRANSACTION] = self.handleCommitTransaction
d[PacketTypes.ASK_BEGIN_TRANSACTION] = self.handleAskBeginTransaction
d[PacketTypes.ANSWER_BEGIN_TRANSACTION] = self.handleAnswerBeginTransaction
d[PacketTypes.FINISH_TRANSACTION] = self.handleFinishTransaction
d[PacketTypes.NOTIFY_TRANSACTION_FINISHED] = self.handleNotifyTransactionFinished
d[PacketTypes.LOCK_INFORMATION] = self.handleLockInformation
d[PacketTypes.NOTIFY_INFORMATION_LOCKED] = self.handleNotifyInformationLocked
d[PacketTypes.INVALIDATE_OBJECTS] = self.handleInvalidateObjects
d[PacketTypes.UNLOCK_INFORMATION] = self.handleUnlockInformation
d[PacketTypes.ASK_NEW_OIDS] = self.handleAskNewOIDs
d[PacketTypes.ANSWER_NEW_OIDS] = self.handleAnswerNewOIDs
d[PacketTypes.ASK_STORE_OBJECT] = self.handleAskStoreObject
d[PacketTypes.ANSWER_STORE_OBJECT] = self.handleAnswerStoreObject
d[PacketTypes.ABORT_TRANSACTION] = self.handleAbortTransaction
d[PacketTypes.ASK_STORE_TRANSACTION] = self.handleAskStoreTransaction
d[PacketTypes.ANSWER_STORE_TRANSACTION] = self.handleAnswerStoreTransaction
d[PacketTypes.ASK_OBJECT] = self.handleAskObject
d[PacketTypes.ANSWER_OBJECT] = self.handleAnswerObject
d[PacketTypes.ASK_TIDS] = self.handleAskTIDs
d[PacketTypes.ANSWER_TIDS] = self.handleAnswerTIDs
d[PacketTypes.ASK_TRANSACTION_INFORMATION] = self.handleAskTransactionInformation
d[PacketTypes.ANSWER_TRANSACTION_INFORMATION] = self.handleAnswerTransactionInformation
d[PacketTypes.ASK_OBJECT_HISTORY] = self.handleAskObjectHistory
d[PacketTypes.ANSWER_OBJECT_HISTORY] = self.handleAnswerObjectHistory
d[PacketTypes.ASK_OIDS] = self.handleAskOIDs
d[PacketTypes.ANSWER_OIDS] = self.handleAnswerOIDs
d[PacketTypes.ASK_PARTITION_LIST] = self.handleAskPartitionList
d[PacketTypes.ANSWER_PARTITION_LIST] = self.handleAnswerPartitionList
d[PacketTypes.ASK_NODE_LIST] = self.handleAskNodeList
d[PacketTypes.ANSWER_NODE_LIST] = self.handleAnswerNodeList
d[PacketTypes.SET_NODE_STATE] = self.handleSetNodeState
d[PacketTypes.ANSWER_NODE_STATE] = self.handleAnswerNodeState
d[PacketTypes.SET_CLUSTER_STATE] = self.handleSetClusterState
d[PacketTypes.ADD_PENDING_NODES] = self.handleAddPendingNodes
d[PacketTypes.ANSWER_NEW_NODES] = self.handleAnswerNewNodes
d[PacketTypes.ASK_NODE_INFORMATION] = self.handleAskNodeInformation
d[PacketTypes.ANSWER_NODE_INFORMATION] = self.handleAnswerNodeInformation
d[PacketTypes.ASK_CLUSTER_STATE] = self.handleAskClusterState
d[PacketTypes.ANSWER_CLUSTER_STATE] = self.handleAnswerClusterState
d[PacketTypes.NOTIFY_CLUSTER_INFORMATION] = self.handleNotifyClusterInformation
d[PacketTypes.NOTIFY_LAST_OID] = self.handleNotifyLastOID
d[PacketTypes.ERROR] = self.error
d[PacketTypes.REQUEST_NODE_IDENTIFICATION] = self.requestNodeIdentification
d[PacketTypes.ACCEPT_NODE_IDENTIFICATION] = self.acceptNodeIdentification
d[PacketTypes.ASK_PRIMARY_MASTER] = self.askPrimaryMaster
d[PacketTypes.ANSWER_PRIMARY_MASTER] = self.answerPrimaryMaster
d[PacketTypes.ANNOUNCE_PRIMARY_MASTER] = self.announcePrimaryMaster
d[PacketTypes.REELECT_PRIMARY_MASTER] = self.reelectPrimaryMaster
d[PacketTypes.NOTIFY_NODE_INFORMATION] = self.notifyNodeInformation
d[PacketTypes.ASK_LAST_IDS] = self.askLastIDs
d[PacketTypes.ANSWER_LAST_IDS] = self.answerLastIDs
d[PacketTypes.ASK_PARTITION_TABLE] = self.askPartitionTable
d[PacketTypes.ANSWER_PARTITION_TABLE] = self.answerPartitionTable
d[PacketTypes.SEND_PARTITION_TABLE] = self.sendPartitionTable
d[PacketTypes.NOTIFY_PARTITION_CHANGES] = self.notifyPartitionChanges
d[PacketTypes.START_OPERATION] = self.startOperation
d[PacketTypes.STOP_OPERATION] = self.stopOperation
d[PacketTypes.ASK_UNFINISHED_TRANSACTIONS] = self.askUnfinishedTransactions
d[PacketTypes.ANSWER_UNFINISHED_TRANSACTIONS] = self.answerUnfinishedTransactions
d[PacketTypes.ASK_OBJECT_PRESENT] = self.askObjectPresent
d[PacketTypes.ANSWER_OBJECT_PRESENT] = self.answerObjectPresent
d[PacketTypes.DELETE_TRANSACTION] = self.deleteTransaction
d[PacketTypes.COMMIT_TRANSACTION] = self.commitTransaction
d[PacketTypes.ASK_BEGIN_TRANSACTION] = self.askBeginTransaction
d[PacketTypes.ANSWER_BEGIN_TRANSACTION] = self.answerBeginTransaction
d[PacketTypes.FINISH_TRANSACTION] = self.finishTransaction
d[PacketTypes.NOTIFY_TRANSACTION_FINISHED] = self.notifyTransactionFinished
d[PacketTypes.LOCK_INFORMATION] = self.lockInformation
d[PacketTypes.NOTIFY_INFORMATION_LOCKED] = self.notifyInformationLocked
d[PacketTypes.INVALIDATE_OBJECTS] = self.invalidateObjects
d[PacketTypes.UNLOCK_INFORMATION] = self.unlockInformation
d[PacketTypes.ASK_NEW_OIDS] = self.askNewOIDs
d[PacketTypes.ANSWER_NEW_OIDS] = self.answerNewOIDs
d[PacketTypes.ASK_STORE_OBJECT] = self.askStoreObject
d[PacketTypes.ANSWER_STORE_OBJECT] = self.answerStoreObject
d[PacketTypes.ABORT_TRANSACTION] = self.abortTransaction
d[PacketTypes.ASK_STORE_TRANSACTION] = self.askStoreTransaction
d[PacketTypes.ANSWER_STORE_TRANSACTION] = self.answerStoreTransaction
d[PacketTypes.ASK_OBJECT] = self.askObject
d[PacketTypes.ANSWER_OBJECT] = self.answerObject
d[PacketTypes.ASK_TIDS] = self.askTIDs
d[PacketTypes.ANSWER_TIDS] = self.answerTIDs
d[PacketTypes.ASK_TRANSACTION_INFORMATION] = self.askTransactionInformation
d[PacketTypes.ANSWER_TRANSACTION_INFORMATION] = self.answerTransactionInformation
d[PacketTypes.ASK_OBJECT_HISTORY] = self.askObjectHistory
d[PacketTypes.ANSWER_OBJECT_HISTORY] = self.answerObjectHistory
d[PacketTypes.ASK_OIDS] = self.askOIDs
d[PacketTypes.ANSWER_OIDS] = self.answerOIDs
d[PacketTypes.ASK_PARTITION_LIST] = self.askPartitionList
d[PacketTypes.ANSWER_PARTITION_LIST] = self.answerPartitionList
d[PacketTypes.ASK_NODE_LIST] = self.askNodeList
d[PacketTypes.ANSWER_NODE_LIST] = self.answerNodeList
d[PacketTypes.SET_NODE_STATE] = self.setNodeState
d[PacketTypes.ANSWER_NODE_STATE] = self.answerNodeState
d[PacketTypes.SET_CLUSTER_STATE] = self.setClusterState
d[PacketTypes.ADD_PENDING_NODES] = self.addPendingNodes
d[PacketTypes.ANSWER_NEW_NODES] = self.answerNewNodes
d[PacketTypes.ASK_NODE_INFORMATION] = self.askNodeInformation
d[PacketTypes.ANSWER_NODE_INFORMATION] = self.answerNodeInformation
d[PacketTypes.ASK_CLUSTER_STATE] = self.askClusterState
d[PacketTypes.ANSWER_CLUSTER_STATE] = self.answerClusterState
d[PacketTypes.NOTIFY_CLUSTER_INFORMATION] = self.notifyClusterInformation
d[PacketTypes.NOTIFY_LAST_OID] = self.notifyLastOID
return d
def __initErrorDispatchTable(self):
d = {}
d[ErrorCodes.NO_ERROR] = self.handleNoError
d[ErrorCodes.NOT_READY] = self.handleNotReady
d[ErrorCodes.OID_NOT_FOUND] = self.handleOidNotFound
d[ErrorCodes.TID_NOT_FOUND] = self.handleTidNotFound
d[ErrorCodes.PROTOCOL_ERROR] = self.handleProtocolError
d[ErrorCodes.BROKEN_NODE] = self.handleBrokenNodeDisallowedError
d[ErrorCodes.NO_ERROR] = self.noError
d[ErrorCodes.NOT_READY] = self.notReady
d[ErrorCodes.OID_NOT_FOUND] = self.oidNotFound
d[ErrorCodes.TID_NOT_FOUND] = self.tidNotFound
d[ErrorCodes.PROTOCOL_ERROR] = self.protocolError
d[ErrorCodes.BROKEN_NODE] = self.brokenNodeDisallowedError
return d
......@@ -24,10 +24,10 @@ from neo.protocol import NodeTypes, NodeStates
class MasterHandler(EventHandler):
"""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()))
def handleAskPrimaryMaster(self, conn, packet):
def askPrimaryMaster(self, conn, packet):
if conn.getConnector() is None:
# Connection can be closed by peer after he sent AskPrimaryMaster
# if he finds the primary master before we answer him.
......@@ -54,16 +54,16 @@ class MasterHandler(EventHandler):
packet.getId(),
)
def handleAskClusterState(self, conn, packet):
def askClusterState(self, conn, packet):
assert conn.getUUID() is not None
state = self.app.getClusterState()
conn.answer(protocol.answerClusterState(state), packet.getId())
def handleAskNodeInformation(self, conn, packet):
def askNodeInformation(self, conn, packet):
self.app.sendNodesInformations(conn)
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
app = self.app
app.sendPartitionTable(conn)
......@@ -78,7 +78,7 @@ DISCONNECTED_STATE_DICT = {
class BaseServiceHandler(MasterHandler):
"""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.
# It is triggered when a connection to a node gets lost.
pass
......@@ -98,13 +98,13 @@ class BaseServiceHandler(MasterHandler):
node.setState(new_state)
self.app.broadcastNodeInformation(node)
# 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
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
p = protocol.answerUnfinishedTransactions(app.finishing_transaction_dict.keys())
conn.answer(p, packet.getId())
......
......@@ -29,12 +29,12 @@ class AdministrationHandler(MasterHandler):
node = self.app.nm.getByUUID(conn.getUUID())
self.app.nm.remove(node)
def handleAskPrimaryMaster(self, conn, packet):
def askPrimaryMaster(self, conn, packet):
app = self.app
# I'm the primary
conn.answer(protocol.answerPrimaryMaster(app.uuid, []), packet.getId())
def handleSetClusterState(self, conn, packet, state):
def setClusterState(self, conn, packet, state):
self.app.changeClusterState(state)
p = protocol.noError('cluster state changed')
conn.answer(p, packet.getId())
......@@ -42,7 +42,7 @@ class AdministrationHandler(MasterHandler):
self.app.cluster_state = state
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))
app = self.app
node = app.nm.getByUUID(uuid)
......@@ -92,7 +92,7 @@ class AdministrationHandler(MasterHandler):
conn.answer(p, packet.getId())
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])
logging.debug('Add nodes %s' % uuids)
app, nm, em, pt = self.app, self.app.nm, self.app.em, self.app.pt
......
......@@ -68,19 +68,19 @@ class ClientServiceHandler(BaseServiceHandler):
def connectionCompleted(self, conn):
pass
def handleNodeLost(self, conn, node):
def nodeLost(self, conn, node):
app = self.app
for tid, t in app.finishing_transaction_dict.items():
if t.getConnection() is conn:
del app.finishing_transaction_dict[tid]
def handleAbortTransaction(self, conn, packet, tid):
def abortTransaction(self, conn, packet, tid):
try:
del self.app.finishing_transaction_dict[tid]
except KeyError:
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
if tid is not None and tid < app.ltid:
# supplied TID is in the past
......@@ -92,11 +92,11 @@ class ClientServiceHandler(BaseServiceHandler):
app.finishing_transaction_dict[tid] = FinishingTransaction(conn)
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)
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
# If the given transaction ID is later than the last TID, the peer
# is crazy.
......
......@@ -25,7 +25,7 @@ from neo.exception import ElectionFailure
class ElectionHandler(MasterHandler):
"""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()
if uuid is None:
raise protocol.UnexpectedPacketError
......@@ -110,7 +110,7 @@ class ClientElectionHandler(ElectionHandler):
app.negotiating_master_node_set.discard(addr)
MasterHandler.peerBroken(self, conn)
def handleAcceptNodeIdentification(self, conn, packet, node_type,
def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions,
num_replicas, your_uuid):
app = self.app
......@@ -146,7 +146,7 @@ class ClientElectionHandler(ElectionHandler):
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:
# Connection can be closed by peer after he sent
# AnswerPrimaryMaster if he finds the primary master before we
......@@ -208,7 +208,7 @@ class ClientElectionHandler(ElectionHandler):
class ServerElectionHandler(ElectionHandler):
def handleReelectPrimaryMaster(self, conn, packet):
def reelectPrimaryMaster(self, conn, packet):
raise ElectionFailure, 'reelection requested'
def peerBroken(self, conn):
......@@ -219,7 +219,7 @@ class ServerElectionHandler(ElectionHandler):
node.setBroken()
MasterHandler.peerBroken(self, conn)
def handleRequestNodeIdentification(self, conn, packet, node_type,
def requestNodeIdentification(self, conn, packet, node_type,
uuid, address, name):
if conn.getConnector() is None:
# Connection can be closed by peer after he sent
......@@ -260,7 +260,7 @@ class ServerElectionHandler(ElectionHandler):
)
conn.answer(p, packet.getId())
def handleAnnouncePrimaryMaster(self, conn, packet):
def announcePrimaryMaster(self, conn, packet):
uuid = conn.getUUID()
if uuid is None:
raise protocol.UnexpectedPacketError
......
......@@ -24,10 +24,10 @@ from neo.master.handlers import MasterHandler
class IdentificationHandler(MasterHandler):
"""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)
def handleRequestNodeIdentification(self, conn, packet, node_type,
def requestNodeIdentification(self, conn, packet, node_type,
uuid, address, name):
self.checkClusterName(name)
......
......@@ -28,7 +28,7 @@ class RecoveryHandler(MasterHandler):
# ask the last IDs to perform the recovery
conn.ask(protocol.askLastIDs())
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid):
def answerLastIDs(self, conn, packet, loid, ltid, lptid):
app = self.app
pt = app.pt
......@@ -41,7 +41,7 @@ class RecoveryHandler(MasterHandler):
app.pt.setID(lptid)
conn.ask(protocol.askPartitionTable([]))
def handleAnswerPartitionTable(self, conn, packet, ptid, row_list):
def answerPartitionTable(self, conn, packet, ptid, row_list):
uuid = conn.getUUID()
app = self.app
if uuid != app.target_uuid:
......
......@@ -34,13 +34,13 @@ class SecondaryMasterHandler(MasterHandler):
def connectionCompleted(self, conn):
pass
def handleAnnouncePrimaryMaster(self, conn, packet):
def announcePrimaryMaster(self, conn, packet):
raise ElectionFailure, 'another primary arises'
def handleReelectPrimaryMaster(self, conn, packet):
def reelectPrimaryMaster(self, conn, packet):
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')
......@@ -58,13 +58,13 @@ class PrimaryMasterHandler(MasterHandler):
self.app.primary_master_node.setDown()
raise PrimaryFailure, 'primary master is dead'
def handleAnnouncePrimaryMaster(self, conn, packet):
def announcePrimaryMaster(self, conn, packet):
raise protocol.UnexpectedPacketError
def handleReelectPrimaryMaster(self, conn, packet):
def reelectPrimaryMaster(self, conn, packet):
raise ElectionFailure, 'reelection requested'
def handleNotifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, packet, node_list):
app = self.app
for node_type, addr, uuid, state in node_list:
if node_type != NodeTypes.MASTER:
......@@ -86,7 +86,7 @@ class PrimaryMasterHandler(MasterHandler):
if n.getUUID() is None:
n.setUUID(uuid)
def handleAcceptNodeIdentification(self, conn, packet, node_type,
def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions,
num_replicas, your_uuid):
app = self.app
......@@ -101,8 +101,8 @@ class PrimaryMasterHandler(MasterHandler):
conn.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
def handleNotifyClusterInformation(self, conn, packet, state):
def notifyClusterInformation(self, conn, packet, state):
pass
......@@ -22,20 +22,20 @@ from neo.master.handlers import BaseServiceHandler
class ShutdownHandler(BaseServiceHandler):
"""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):
logging.error('reject any new connection')
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')
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')
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
pass
......@@ -34,7 +34,7 @@ class StorageServiceHandler(BaseServiceHandler):
conn.notify(protocol.notifyLastOID(self.app.loid))
conn.notify(protocol.startOperation())
def handleNodeLost(self, conn, node):
def nodeLost(self, conn, node):
logging.info('storage node lost')
if not self.app.pt.operational():
raise OperationFailure, 'cannot continue operation'
......@@ -42,7 +42,7 @@ class StorageServiceHandler(BaseServiceHandler):
# partition must not oudated to allows a cluster restart.
self.app.outdateAndBroadcastPartition()
def handleNotifyInformationLocked(self, conn, packet, tid):
def notifyInformationLocked(self, conn, packet, tid):
uuid = conn.getUUID()
app = self.app
node = app.nm.getByUUID(uuid)
......@@ -80,7 +80,7 @@ class StorageServiceHandler(BaseServiceHandler):
# What is this?
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
# a replication has finished.
uuid = conn.getUUID()
......
......@@ -27,18 +27,18 @@ class VerificationHandler(MasterHandler):
def connectionCompleted(self, conn):
pass
def handleNodeLost(self, conn, node):
def nodeLost(self, conn, node):
if not self.app.pt.operational():
raise VerificationFailure, 'cannot continue verification'
def handleAnswerLastIDs(self, conn, packet, loid, ltid, lptid):
def answerLastIDs(self, conn, packet, loid, ltid, lptid):
app = self.app
# If I get a bigger value here, it is dangerous.
if app.loid < loid or app.ltid < ltid or app.pt.getID() < lptid:
logging.critical('got later information in verification')
raise VerificationFailure
def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list):
def answerUnfinishedTransactions(self, conn, packet, tid_list):
uuid = conn.getUUID()
logging.info('got unfinished transactions %s from %s:%d',
tid_list, *(conn.getAddress()))
......@@ -49,7 +49,7 @@ class VerificationHandler(MasterHandler):
app.unfinished_tid_set.update(tid_list)
app.asking_uuid_dict[uuid] = True
def handleAnswerTransactionInformation(self, conn, packet, tid,
def answerTransactionInformation(self, conn, packet, tid,
user, desc, ext, oid_list):
uuid = conn.getUUID()
app = self.app
......@@ -67,7 +67,7 @@ class VerificationHandler(MasterHandler):
app.unfinished_oid_set = None
app.asking_uuid_dict[uuid] = True
def handleTidNotFound(self, conn, packet, message):
def tidNotFound(self, conn, packet, message):
uuid = conn.getUUID()
logging.info('TID not found: %s', message)
app = self.app
......@@ -77,7 +77,7 @@ class VerificationHandler(MasterHandler):
app.unfinished_oid_set = None
app.asking_uuid_dict[uuid] = True
def handleAnswerObjectPresent(self, conn, packet, oid, tid):
def answerObjectPresent(self, conn, packet, oid, tid):
uuid = conn.getUUID()
logging.info('object %s:%s found', dump(oid), dump(tid))
app = self.app
......@@ -86,7 +86,7 @@ class VerificationHandler(MasterHandler):
return
app.asking_uuid_dict[uuid] = True
def handleOidNotFound(self, conn, packet, message):
def oidNotFound(self, conn, packet, message):
uuid = conn.getUUID()
logging.info('OID not found: %s', message)
app = self.app
......
......@@ -50,18 +50,18 @@ class CommandEventHandler(EventHandler):
super(CommandEventHandler, self).peerBroken(conn)
self.__disconnected()
def __handleAnswer(self, conn, packet, *args):
def __answer(self, conn, packet, *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))
def handleNotReady(self, conn, packet, msg):
def notReady(self, conn, packet, msg):
self.__respond((packet.getType(), ErrorCodes.NOT_READY, msg))
handleAnswerPartitionList = __handleAnswer
handleAnswerNodeList = __handleAnswer
handleAnswerNodeState = __handleAnswer
handleAnswerClusterState = __handleAnswer
handleAnswerNewNodes = __handleAnswer
handleAnswerPrimaryMaster = __handleAnswer
answerPartitionList = __answer
answerNodeList = __answer
answerNodeState = __answer
answerClusterState = __answer
answerNewNodes = __answer
answerPrimaryMaster = __answer
......@@ -33,17 +33,17 @@ class BaseMasterHandler(BaseStorageHandler):
def connectionLost(self, conn, new_state):
raise PrimaryFailure('connection lost')
def handleReelectPrimaryMaster(self, conn, packet):
def reelectPrimaryMaster(self, conn, packet):
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__)
def handleNotifyLastOID(self, conn, packet, oid):
def notifyLastOID(self, conn, packet, oid):
self.app.loid = 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
master node."""
self.app.nm.update(node_list)
......@@ -63,7 +63,7 @@ class BaseMasterHandler(BaseStorageHandler):
class BaseClientAndStorageOperationHandler(BaseStorageHandler):
""" 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
# about usable partitions assigned to me.
if first >= last:
......@@ -87,7 +87,7 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler):
app.pt.getPartitions(), partition_list)
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:
raise protocol.ProtocolError( 'invalid offsets')
......@@ -98,7 +98,7 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler):
p = protocol.answerObjectHistory(oid, history_list)
conn.answer(p, packet.getId())
def handleAskTransactionInformation(self, conn, packet, tid):
def askTransactionInformation(self, conn, packet, tid):
app = self.app
t = app.dm.getTransaction(tid)
if t is None:
......@@ -107,11 +107,11 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler):
p = protocol.answerTransactionInformation(tid, t[1], t[2], t[3], t[0])
conn.answer(p, packet.getId())
def handleAskObject(self, conn, packet, oid, serial, tid):
def askObject(self, conn, packet, oid, serial, tid):
app = self.app
if oid in app.load_lock_dict:
# Delay the response.
app.queueEvent(self.handleAskObject, conn, packet, oid,
app.queueEvent(self.askObject, conn, packet, oid,
serial, tid)
return
o = app.dm.getObject(oid, serial, tid)
......
......@@ -84,7 +84,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
def connectionCompleted(self, conn):
BaseClientAndStorageOperationHandler.connectionCompleted(self, conn)
def handleAbortTransaction(self, conn, packet, tid):
def abortTransaction(self, conn, packet, tid):
app = self.app
try:
t = app.transaction_dict[tid]
......@@ -104,7 +104,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
except KeyError:
pass
def handleAskStoreTransaction(self, conn, packet, tid, user, desc,
def askStoreTransaction(self, conn, packet, tid, user, desc,
ext, oid_list):
uuid = conn.getUUID()
app = self.app
......@@ -114,7 +114,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
t.addTransaction(oid_list, user, desc, ext)
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):
uuid = conn.getUUID()
# First, check for the locking state.
......@@ -123,7 +123,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
if locking_tid is not None:
if locking_tid < tid:
# Delay the response.
app.queueEvent(self.handleAskStoreObject, conn, packet,
app.queueEvent(self.askStoreObject, conn, packet,
oid, serial, compression, checksum,
data, tid)
else:
......
......@@ -27,7 +27,7 @@ class HiddenHandler(BaseMasterHandler):
self.app = 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
master node."""
app = self.app
......@@ -42,28 +42,28 @@ class HiddenHandler(BaseMasterHandler):
erase_db = state == NodeStates.DOWN
self.app.shutdown(erase=erase_db)
def handleRequestNodeIdentification(self, conn, packet, node_type,
def requestNodeIdentification(self, conn, packet, node_type,
uuid, address, name):
pass
def handleAcceptNodeIdentification(self, conn, packet, node_type,
def acceptNodeIdentification(self, conn, packet, node_type,
uuid, address, num_partitions, num_replicas, your_uuid):
pass
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid,
def answerPrimaryMaster(self, conn, packet, primary_uuid,
known_master_list):
pass
def handleAskLastIDs(self, conn, packet):
def askLastIDs(self, conn, packet):
pass
def handleAskPartitionTable(self, conn, packet, offset_list):
def askPartitionTable(self, conn, packet, offset_list):
pass
def handleSendPartitionTable(self, conn, packet, ptid, row_list):
def sendPartitionTable(self, conn, packet, ptid, row_list):
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
the information is only about changes from the previous."""
app = self.app
......@@ -85,59 +85,59 @@ class HiddenHandler(BaseMasterHandler):
elif state == CellStates.OUT_OF_DATE:
app.replicator.addPartition(offset)
def handleStartOperation(self, conn, packet):
def startOperation(self, conn, packet):
self.app.operational = True
def handleStopOperation(self, conn, packet):
def stopOperation(self, conn, packet):
pass
def handleAskUnfinishedTransactions(self, conn, packet):
def askUnfinishedTransactions(self, conn, packet):
pass
def handleAskTransactionInformation(self, conn, packet, tid):
def askTransactionInformation(self, conn, packet, tid):
pass
def handleAskObjectPresent(self, conn, packet, oid, tid):
def askObjectPresent(self, conn, packet, oid, tid):
pass
def handleDeleteTransaction(self, conn, packet, tid):
def deleteTransaction(self, conn, packet, tid):
pass
def handleCommitTransaction(self, conn, packet, tid):
def commitTransaction(self, conn, packet, tid):
pass
def handleLockInformation(self, conn, packet, tid):
def lockInformation(self, conn, packet, tid):
pass
def handleUnlockInformation(self, conn, packet, tid):
def unlockInformation(self, conn, packet, tid):
pass
def handleAskObject(self, conn, packet, oid, serial, tid):
def askObject(self, conn, packet, oid, serial, tid):
pass
def handleAskTIDs(self, conn, packet, first, last, partition):
def askTIDs(self, conn, packet, first, last, partition):
pass
def handleAskObjectHistory(self, conn, packet, oid, first, last):
def askObjectHistory(self, conn, packet, oid, first, last):
pass
def handleAskStoreTransaction(self, conn, packet, tid, user, desc,
def askStoreTransaction(self, conn, packet, tid, user, desc,
ext, oid_list):
pass
def handleAskStoreObject(self, conn, packet, oid, serial,
def askStoreObject(self, conn, packet, oid, serial,
compression, checksum, data, tid):
pass
def handleAbortTransaction(self, conn, packet, tid):
def abortTransaction(self, conn, packet, tid):
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')
def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list):
def answerUnfinishedTransactions(self, conn, packet, tid_list):
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')
......@@ -28,7 +28,7 @@ class IdentificationHandler(BaseStorageHandler):
def connectionLost(self, conn, new_state):
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):
self.checkClusterName(name)
# reject any incoming connections if not ready
......
......@@ -22,20 +22,20 @@ from neo import protocol
class InitializationHandler(BaseMasterHandler):
def handleAnswerNodeInformation(self, conn, packet, node_list):
def answerNodeInformation(self, conn, packet, node_list):
assert not node_list
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
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
table. Note that the message can be split into multiple packets."""
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
pt = app.pt
assert not row_list
......@@ -59,7 +59,7 @@ class InitializationHandler(BaseMasterHandler):
app.dm.setPartitionTable(ptid, cell_list)
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
# 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
......
......@@ -26,16 +26,16 @@ from neo.exception import OperationFailure
class MasterOperationHandler(BaseMasterHandler):
""" This handler is used for the primary master """
def handleStopOperation(self, conn, packet):
def stopOperation(self, conn, packet):
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)
def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list):
def answerUnfinishedTransactions(self, conn, packet, 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
the information is only about changes from the previous."""
app = self.app
......@@ -57,7 +57,7 @@ class MasterOperationHandler(BaseMasterHandler):
elif state == CellStates.OUT_OF_DATE:
app.replicator.addPartition(offset)
def handleLockInformation(self, conn, packet, tid):
def lockInformation(self, conn, packet, tid):
app = self.app
try:
t = app.transaction_dict[tid]
......@@ -70,7 +70,7 @@ class MasterOperationHandler(BaseMasterHandler):
pass
conn.answer(protocol.notifyInformationLocked(tid), packet.getId())
def handleUnlockInformation(self, conn, packet, tid):
def unlockInformation(self, conn, packet, tid):
app = self.app
try:
t = app.transaction_dict[tid]
......
......@@ -36,12 +36,12 @@ class ReplicationHandler(BaseStorageHandler):
logging.error('replication is stopped due to connection failure')
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):
# set the UUID on the connection
conn.setUUID(uuid)
def handleAnswerTIDs(self, conn, packet, tid_list):
def answerTIDs(self, conn, packet, tid_list):
app = self.app
if app.replicator.current_connection is not conn:
return
......@@ -68,7 +68,7 @@ class ReplicationHandler(BaseStorageHandler):
conn.ask(p, timeout=300)
app.replicator.oid_offset = 0
def handleAnswerTransactionInformation(self, conn, packet, tid,
def answerTransactionInformation(self, conn, packet, tid,
user, desc, ext, oid_list):
app = self.app
if app.replicator.current_connection is not conn:
......@@ -77,7 +77,7 @@ class ReplicationHandler(BaseStorageHandler):
# Directly store the transaction.
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
if app.replicator.current_connection is not conn:
return
......@@ -93,7 +93,7 @@ class ReplicationHandler(BaseStorageHandler):
# finished.
app.replicator.replication_done = True
def handleAnswerObjectHistory(self, conn, packet, oid, history_list):
def answerObjectHistory(self, conn, packet, oid, history_list):
app = self.app
if app.replicator.current_connection is not conn:
return
......@@ -127,7 +127,7 @@ class ReplicationHandler(BaseStorageHandler):
app.replicator.current_partition.getRID())
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):
app = self.app
if app.replicator.current_connection is not conn:
......
......@@ -20,14 +20,14 @@ from neo.storage.handlers import BaseClientAndStorageOperationHandler
class StorageOperationHandler(BaseClientAndStorageOperationHandler):
def handleAskLastIDs(self, conn, packet):
def askLastIDs(self, conn, packet):
app = self.app
oid = app.dm.getLastOID()
tid = app.dm.getLastTID()
p = protocol.answerLastIDs(oid, tid, app.pt.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
# about usable partitions assigned to me.
if first >= last:
......
......@@ -25,14 +25,14 @@ from neo.exception import OperationFailure
class VerificationHandler(BaseMasterHandler):
"""This class deals with events for a verification phase."""
def handleAskLastIDs(self, conn, packet):
def askLastIDs(self, conn, packet):
app = self.app
oid = app.dm.getLastOID()
tid = app.dm.getLastTID()
p = protocol.answerLastIDs(oid, tid, app.pt.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
if not offset_list:
# all is requested
......@@ -53,7 +53,7 @@ class VerificationHandler(BaseMasterHandler):
p = protocol.answerPartitionTable(app.pt.getID(), row_list)
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
the information is only about changes from the previous."""
app = self.app
......@@ -65,18 +65,18 @@ class VerificationHandler(BaseMasterHandler):
app.pt.update(ptid, cell_list, app.nm)
app.dm.changePartitionTable(ptid, cell_list)
def handleStartOperation(self, conn, packet):
def startOperation(self, conn, packet):
self.app.operational = True
def handleStopOperation(self, conn, packet):
def stopOperation(self, conn, packet):
raise OperationFailure('operation stopped')
def handleAskUnfinishedTransactions(self, conn, packet):
def askUnfinishedTransactions(self, conn, packet):
tid_list = self.app.dm.getUnfinishedTIDList()
p = protocol.answerUnfinishedTransactions(tid_list)
conn.answer(p, packet.getId())
def handleAskTransactionInformation(self, conn, packet, tid):
def askTransactionInformation(self, conn, packet, tid):
app = self.app
t = app.dm.getTransaction(tid, all=True)
if t is None:
......@@ -85,7 +85,7 @@ class VerificationHandler(BaseMasterHandler):
p = protocol.answerTransactionInformation(tid, t[1], t[2], t[3], t[0])
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):
p = protocol.answerObjectPresent(oid, tid)
else:
......@@ -93,9 +93,9 @@ class VerificationHandler(BaseMasterHandler):
'%s:%s do not exist' % (dump(oid), dump(tid)))
conn.answer(p, packet.getId())
def handleDeleteTransaction(self, conn, packet, tid):
def deleteTransaction(self, conn, packet, tid):
self.app.dm.deleteTransaction(tid, all = True)
def handleCommitTransaction(self, conn, packet, tid):
def commitTransaction(self, conn, packet, tid):
self.app.dm.finishTransaction(tid)
......@@ -206,7 +206,7 @@ class ClientHandlerTests(NeoTestBase):
dispatcher = self.getDispatcher()
conn = self.getConnection()
client_handler = StorageBootstrapHandler(app)
client_handler.handleNotReady(conn, None, None)
client_handler.notReady(conn, None, None)
self.assertEquals(len(app.mockGetNamedCalls('setNodeNotReady')), 1)
def test_clientAcceptNodeIdentification(self):
......@@ -220,7 +220,7 @@ class ClientHandlerTests(NeoTestBase):
conn = self.getConnection()
uuid = self.getNewUUID()
app.uuid = 'C' * 16
client_handler.handleAcceptNodeIdentification(
client_handler.acceptNodeIdentification(
conn, None,
NodeTypes.CLIENT,
uuid, ('127.0.0.1', 10010),
......@@ -248,7 +248,7 @@ class ClientHandlerTests(NeoTestBase):
uuid = self.getNewUUID()
your_uuid = 'C' * 16
app.uuid = INVALID_UUID
client_handler.handleAcceptNodeIdentification(conn, None,
client_handler.acceptNodeIdentification(conn, None,
NodeTypes.MASTER, uuid, ('127.0.0.1', 10010), 10, 2, your_uuid)
self.checkNotClosed(conn)
self.checkUUIDSet(conn, uuid)
......@@ -268,7 +268,7 @@ class ClientHandlerTests(NeoTestBase):
conn = self.getConnection()
uuid = self.getNewUUID()
app.uuid = 'C' * 16
client_handler.handleAcceptNodeIdentification(conn, None,
client_handler.acceptNodeIdentification(conn, None,
NodeTypes.STORAGE, uuid, ('127.0.0.1', 10010), 0, 0, INVALID_UUID)
self.checkNotClosed(conn)
self.checkUUIDSet(conn, uuid)
......@@ -288,7 +288,7 @@ class ClientHandlerTests(NeoTestBase):
app = App()
client_handler = PrimaryBootstrapHandler(app)
conn = self.getConnection()
client_handler.handleAnswerPrimaryMaster(conn, None, 0, [])
client_handler.answerPrimaryMaster(conn, None, 0, [])
# Check that nothing happened
self.assertEqual(len(app.nm.mockGetNamedCalls('getByAddress')), 0)
self.assertEqual(len(app.nm.mockGetNamedCalls('add')), 0)
......@@ -302,7 +302,7 @@ class ClientHandlerTests(NeoTestBase):
client_handler = PrimaryBootstrapHandler(app)
conn = self.getConnection()
test_master_list = [(('127.0.0.1', 10010), self.getNewUUID())]
client_handler.handleAnswerPrimaryMaster(conn, None, INVALID_UUID, test_master_list)
client_handler.answerPrimaryMaster(conn, None, INVALID_UUID, test_master_list)
# Check that yet-unknown master node got added
getByAddress_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
add_call_list = app.nm.mockGetNamedCalls('add')
......@@ -328,7 +328,7 @@ class ClientHandlerTests(NeoTestBase):
conn = self.getConnection()
test_node_uuid = self.getNewUUID()
test_master_list = [(('127.0.0.1', 10010), test_node_uuid)]
client_handler.handleAnswerPrimaryMaster(conn, None, INVALID_UUID, test_master_list)
client_handler.answerPrimaryMaster(conn, None, INVALID_UUID, test_master_list)
# Test sanity checks
getByAddress_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
self.assertEqual(len(getByAddress_call_list), 1)
......@@ -354,7 +354,7 @@ class ClientHandlerTests(NeoTestBase):
client_handler = PrimaryBootstrapHandler(app)
conn = self.getConnection()
test_master_list = [(('127.0.0.1', 10010), test_node_uuid)]
client_handler.handleAnswerPrimaryMaster(conn, None, INVALID_UUID, test_master_list)
client_handler.answerPrimaryMaster(conn, None, INVALID_UUID, test_master_list)
# Test sanity checks
getByAddress_call_list = app.nm.mockGetNamedCalls('getNodeByServer')
self.assertEqual(len(getByAddress_call_list), 1)
......@@ -391,7 +391,7 @@ class ClientHandlerTests(NeoTestBase):
# If primary master is already set *and* is not given primary master
# handle call raises.
# Check that the call doesn't raise
client_handler.handleAnswerPrimaryMaster(conn, None, test_node_uuid, [])
client_handler.answerPrimaryMaster(conn, None, test_node_uuid, [])
# Check that the primary master changed
self.assertTrue(app.primary_master_node is node)
# Test sanity checks
......@@ -411,7 +411,7 @@ class ClientHandlerTests(NeoTestBase):
app = App()
client_handler = PrimaryBootstrapHandler(app)
conn = self.getConnection()
client_handler.handleAnswerPrimaryMaster(conn, None, test_node_uuid, [])
client_handler.answerPrimaryMaster(conn, None, test_node_uuid, [])
# Check that primary node is (still) node.
self.assertTrue(app.primary_master_node is node)
......@@ -428,7 +428,7 @@ class ClientHandlerTests(NeoTestBase):
app = App()
client_handler = PrimaryBootstrapHandler(app)
conn = self.getConnection()
client_handler.handleAnswerPrimaryMaster(conn, None, test_primary_node_uuid, [])
client_handler.answerPrimaryMaster(conn, None, test_primary_node_uuid, [])
# Test sanity checks
getByUUID_call_list = app.nm.mockGetNamedCalls('getNodeByUUID')
self.assertEqual(len(getByUUID_call_list), 1)
......@@ -447,7 +447,7 @@ class ClientHandlerTests(NeoTestBase):
client_handler = PrimaryBootstrapHandler(app)
conn = self.getConnection()
test_master_list = [(('127.0.0.1', 10010), test_node_uuid)]
client_handler.handleAnswerPrimaryMaster(conn, None, test_node_uuid, test_master_list)
client_handler.answerPrimaryMaster(conn, None, test_node_uuid, test_master_list)
# Test sanity checks
getByUUID_call_list = app.nm.mockGetNamedCalls('getNodeByUUID')
self.assertEqual(len(getByUUID_call_list), 1)
......@@ -467,7 +467,7 @@ class ClientHandlerTests(NeoTestBase):
app = App()
client_handler = PrimaryNotificationsHandler(app, Mock())
conn = self.getConnection()
client_handler.handleSendPartitionTable(conn, None, test_ptid + 1, [])
client_handler.sendPartitionTable(conn, None, test_ptid + 1, [])
# Check that partition table got cleared and ptid got updated
self.assertEquals(app.pt.getID(), 1)
......@@ -484,7 +484,7 @@ class ClientHandlerTests(NeoTestBase):
conn = self.getConnection()
# TODO: use realistic values
test_row_list = [(0, [(test_storage_uuid, 0)])]
client_handler.handleSendPartitionTable(conn, None, test_ptid, test_row_list)
client_handler.sendPartitionTable(conn, None, test_ptid, test_row_list)
# Check that node got created
add_call_list = app.nm.mockGetNamedCalls('add')
self.assertEquals(len(add_call_list), 1)
......@@ -509,7 +509,7 @@ class ClientHandlerTests(NeoTestBase):
conn = self.getConnection()
# TODO: use realistic values
test_row_list = [(0, [(test_storage_uuid, 0)])]
client_handler.handleSendPartitionTable(conn, None, test_ptid, test_row_list)
client_handler.sendPartitionTable(conn, None, test_ptid, test_row_list)
# Check that node did not get created
self.assertEquals(len(app.nm.mockGetNamedCalls('add')), 0)
# Check that partition table cell got added
......@@ -527,7 +527,7 @@ class ClientHandlerTests(NeoTestBase):
app = App()
client_handler = PrimaryNotificationsHandler(app, self.getDispatcher())
conn = self.getConnection(uuid=test_master_uuid)
client_handler.handleNotifyNodeInformation(conn, None, ())
client_handler.notifyNodeInformation(conn, None, ())
def test_nonIterableParameterRaisesNotifyNodeInformation(self):
# XXX: this test is here for sanity self-check: it verifies the
......@@ -541,7 +541,7 @@ class ClientHandlerTests(NeoTestBase):
app = App()
client_handler = PrimaryNotificationsHandler(app, self.getDispatcher())
conn = self.getConnection(uuid=test_master_uuid)
self.assertRaises(TypeError, client_handler.handleNotifyNodeInformation,
self.assertRaises(TypeError, client_handler.notifyNodeInformation,
conn, None, None)
def _testNotifyNodeInformation(self, test_node, getByAddress=None, getByUUID=MARKER):
......@@ -560,7 +560,7 @@ class ClientHandlerTests(NeoTestBase):
app = App()
client_handler = PrimaryBootstrapHandler(app)
conn = self.getConnection(uuid=test_master_uuid)
client_handler.handleNotifyNodeInformation(conn, None, test_node_list)
client_handler.notifyNodeInformation(conn, None, test_node_list)
# Return nm so caller can check handler actions.
return app.nm
......@@ -632,7 +632,7 @@ class ClientHandlerTests(NeoTestBase):
client_handler = PrimaryBootstrapHandler(app)
conn = Mock({'getUUID': None})
self._testHandleUnexpectedPacketCalledWithMedhod(
client_handler.handleNotifyPartitionChanges,
client_handler.notifyPartitionChanges,
args=(conn, None, None, None))
def test_nonMasterNotifyPartitionChanges(self):
......@@ -647,7 +647,7 @@ class ClientHandlerTests(NeoTestBase):
app = App()
client_handler = PrimaryNotificationsHandler(app, self.getDispatcher())
conn = self.getConnection(uuid=test_master_uuid)
client_handler.handleNotifyPartitionChanges(conn, None, 0, [])
client_handler.notifyPartitionChanges(conn, None, 0, [])
# Check that nothing happened
self.assertEquals(len(app.pt.mockGetNamedCalls('setCell')), 0)
self.assertEquals(len(app.pt.mockGetNamedCalls('removeCell')), 0)
......@@ -662,7 +662,7 @@ class ClientHandlerTests(NeoTestBase):
app = App()
client_handler = PrimaryNotificationsHandler(app, self.getDispatcher())
conn = self.getConnection()
client_handler.handleNotifyPartitionChanges(conn, None, 0, [])
client_handler.notifyPartitionChanges(conn, None, 0, [])
# Check that nothing happened
self.assertEquals(len(app.pt.mockGetNamedCalls('setCell')), 0)
self.assertEquals(len(app.pt.mockGetNamedCalls('removeCell')), 0)
......@@ -682,7 +682,7 @@ class ClientHandlerTests(NeoTestBase):
app = App()
client_handler = PrimaryNotificationsHandler(app, self.getDispatcher())
conn = self.getConnection(uuid=test_sender_uuid)
client_handler.handleNotifyPartitionChanges(conn, None, 0, [])
client_handler.notifyPartitionChanges(conn, None, 0, [])
# Check that nothing happened
self.assertEquals(len(app.pt.mockGetNamedCalls('setCell')), 0)
self.assertEquals(len(app.pt.mockGetNamedCalls('removeCell')), 0)
......@@ -699,7 +699,7 @@ class ClientHandlerTests(NeoTestBase):
app = App()
client_handler = PrimaryNotificationsHandler(app, self.getDispatcher())
conn = self.getConnection(uuid=test_master_uuid)
client_handler.handleNotifyPartitionChanges(conn, None, test_ptid, [])
client_handler.notifyPartitionChanges(conn, None, test_ptid, [])
# Check that nothing happened
self.assertEquals(len(app.pt.mockGetNamedCalls('setCell')), 0)
self.assertEquals(len(app.pt.mockGetNamedCalls('removeCell')), 0)
......@@ -721,7 +721,7 @@ class ClientHandlerTests(NeoTestBase):
test_storage_uuid = self.getNewUUID()
# TODO: use realistic values
test_cell_list = [(0, test_storage_uuid, CellStates.UP_TO_DATE)]
client_handler.handleNotifyPartitionChanges(conn, None, test_ptid + 1, test_cell_list)
client_handler.notifyPartitionChanges(conn, None, test_ptid + 1, test_cell_list)
# Check that a new node got added
add_call_list = app.nm.mockGetNamedCalls('add')
self.assertEqual(len(add_call_list), 1)
......@@ -754,7 +754,7 @@ class ClientHandlerTests(NeoTestBase):
(0, uuid3, CellStates.FEEDING),
(0, uuid4, CellStates.UP_TO_DATE),
]
client_handler.handleNotifyPartitionChanges(conn, None, test_ptid + 1, test_cell_list)
client_handler.notifyPartitionChanges(conn, None, test_ptid + 1, test_cell_list)
# Check that the three last node got added
calls = app.nm.mockGetNamedCalls('add')
self.assertEquals(len(calls), 3)
......@@ -778,7 +778,7 @@ class ClientHandlerTests(NeoTestBase):
client_handler = PrimaryAnswersHandler(app)
conn = self.getConnection()
test_tid = 1
client_handler.handleAnswerBeginTransaction(conn, None, test_tid)
client_handler.answerBeginTransaction(conn, None, test_tid)
setTID_call_list = app.mockGetNamedCalls('setTID')
self.assertEquals(len(setTID_call_list), 1)
self.assertEquals(setTID_call_list[0].getParam(0), test_tid)
......@@ -789,7 +789,7 @@ class ClientHandlerTests(NeoTestBase):
dispatcher = self.getDispatcher()
client_handler = PrimaryAnswersHandler(app)
conn = self.getConnection()
client_handler.handleNotifyTransactionFinished(conn, None, test_tid)
client_handler.notifyTransactionFinished(conn, None, test_tid)
self.assertEquals(len(app.mockGetNamedCalls('setTransactionFinished')), 1)
# TODO: decide what to do when non-current transaction is notified as finished, and test that behaviour
......@@ -816,7 +816,7 @@ class ClientHandlerTests(NeoTestBase):
test_oid_list = ['\x00\x00\x00\x00\x00\x00\x00\x01', '\x00\x00\x00\x00\x00\x00\x00\x02']
test_db = Mock({'invalidate': None})
app.registerDB(test_db, None)
client_handler.handleInvalidateObjects(conn, None, test_oid_list[:], test_tid)
client_handler.invalidateObjects(conn, None, test_oid_list[:], test_tid)
# 'invalidate' is called just once
db = app.getDB()
self.assertTrue(db is test_db)
......@@ -843,7 +843,7 @@ class ClientHandlerTests(NeoTestBase):
client_handler = PrimaryAnswersHandler(app)
conn = self.getConnection()
test_oid_list = ['\x00\x00\x00\x00\x00\x00\x00\x01', '\x00\x00\x00\x00\x00\x00\x00\x02']
client_handler.handleAnswerNewOIDs(conn, None, test_oid_list[:])
client_handler.answerNewOIDs(conn, None, test_oid_list[:])
self.assertEquals(set(app.new_oid_list), set(test_oid_list))
def test_StopOperation(self):
......@@ -862,14 +862,14 @@ class ClientHandlerTests(NeoTestBase):
conn = self.getConnection()
# TODO: use realistic values
test_object_data = ('\x00\x00\x00\x00\x00\x00\x00\x01', 0, 0, 0, 0, 'test')
client_handler.handleAnswerObject(conn, None, *test_object_data)
client_handler.answerObject(conn, None, *test_object_data)
self.assertEquals(app.local_var.asked_object, test_object_data)
def _testAnswerStoreObject(self, app, conflicting, oid, serial):
dispatcher = self.getDispatcher()
client_handler = StorageAnswersHandler(app)
conn = self.getConnection()
client_handler.handleAnswerStoreObject(conn, None, conflicting, oid, serial)
client_handler.answerStoreObject(conn, None, conflicting, oid, serial)
def test_conflictingAnswerStoreObject(self):
class App:
......@@ -897,9 +897,9 @@ class ClientHandlerTests(NeoTestBase):
dispatcher = self.getDispatcher()
client_handler = StorageAnswersHandler(app)
conn = self.getConnection()
client_handler.handleAnswerStoreTransaction(conn, None, test_tid)
client_handler.answerStoreTransaction(conn, None, test_tid)
self.assertEquals(len(app.mockGetNamedCalls('setTransactionVoted')), 1)
# TODO: test handleAnswerObject with test_tid not matching app.tid (not handled in program)
# TODO: test answerObject with test_tid not matching app.tid (not handled in program)
def test_AnswerTransactionInformation(self):
class FakeLocal:
......@@ -915,7 +915,7 @@ class ClientHandlerTests(NeoTestBase):
desc = 'foo'
ext = 0 # XXX: unused in implementation
oid_list = ['\x00\x00\x00\x00\x00\x00\x00\x01', '\x00\x00\x00\x00\x00\x00\x00\x02']
client_handler.handleAnswerTransactionInformation(conn, None, tid, user, desc, ext, oid_list[:])
client_handler.answerTransactionInformation(conn, None, tid, user, desc, ext, oid_list[:])
stored_dict = app.local_var.txn_info
# TODO: test 'time' value ?
self.assertEquals(stored_dict['user_name'], user)
......@@ -935,7 +935,7 @@ class ClientHandlerTests(NeoTestBase):
test_oid = '\x00\x00\x00\x00\x00\x00\x00\x01'
# TODO: use realistic values
test_history_list = [(1, 2), (3, 4)]
client_handler.handleAnswerObjectHistory(conn, None, test_oid, test_history_list[:])
client_handler.answerObjectHistory(conn, None, test_oid, test_history_list[:])
oid, history = app.local_var.history
self.assertEquals(oid, test_oid)
self.assertEquals(len(history), len(test_history_list))
......@@ -951,7 +951,7 @@ class ClientHandlerTests(NeoTestBase):
dispatcher = self.getDispatcher()
client_handler = StorageAnswersHandler(app)
conn = self.getConnection()
client_handler.handleOidNotFound(conn, None, None)
client_handler.oidNotFound(conn, None, None)
self.assertEquals(app.local_var.asked_object, -1)
self.assertEquals(app.local_var.history, -1)
......@@ -964,7 +964,7 @@ class ClientHandlerTests(NeoTestBase):
dispatcher = self.getDispatcher()
client_handler = StorageAnswersHandler(app)
conn = self.getConnection()
client_handler.handleTidNotFound(conn, None, None)
client_handler.tidNotFound(conn, None, None)
self.assertEquals(app.local_var.txn_info, -1)
def test_AnswerTIDs(self):
......@@ -977,7 +977,7 @@ class ClientHandlerTests(NeoTestBase):
client_handler = StorageAnswersHandler(app)
conn = self.getConnection()
test_tid_list = ['\x00\x00\x00\x00\x00\x00\x00\x01', '\x00\x00\x00\x00\x00\x00\x00\x02']
client_handler.handleAnswerTIDs(conn, None, test_tid_list[:])
client_handler.answerTIDs(conn, None, test_tid_list[:])
stored_tid_list = []
for tid_list in app.local_var.node_tids.itervalues():
stored_tid_list.extend(tid_list)
......
......@@ -71,7 +71,7 @@ class MasterClientHandlerTests(NeoTestBase):
return uuid
# Tests
def test_05_handleNotifyNodeInformation(self):
def test_05_notifyNodeInformation(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.NOTIFY_NODE_INFORMATION)
......@@ -79,12 +79,12 @@ class MasterClientHandlerTests(NeoTestBase):
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.MASTER, ('127.0.0.1', self.master_port),
self.app.uuid, NodeStates.DOWN),]
self.assertRaises(RuntimeError, service.handleNotifyNodeInformation, conn, packet, node_list)
self.assertRaises(RuntimeError, service.notifyNodeInformation, conn, packet, node_list)
# tell the master node that it's running, nothing change
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.MASTER, ('127.0.0.1', self.master_port),
self.app.uuid, NodeStates.RUNNING),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
# notify about a client node, don't care
......@@ -92,14 +92,14 @@ class MasterClientHandlerTests(NeoTestBase):
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.CLIENT, ('127.0.0.1', self.client_port),
new_uuid, NodeStates.BROKEN),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
# notify about an unknown node, don't care
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.STORAGE, ('127.0.0.1', 11010), new_uuid,
NodeStates.BROKEN),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
# notify about a known node but with bad address, don't care
......@@ -109,14 +109,14 @@ class MasterClientHandlerTests(NeoTestBase):
)
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.STORAGE, ('127.0.0.1', 11012), uuid, NodeStates.BROKEN),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
# notify node is running, as PMN already know it, nothing is done
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.STORAGE, ('127.0.0.1', self.storage_port), uuid,
NodeStates.RUNNING),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
# notify node is temp down, must be taken into account
......@@ -124,7 +124,7 @@ class MasterClientHandlerTests(NeoTestBase):
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.STORAGE, ('127.0.0.1', self.storage_port), uuid,
NodeStates.TEMPORARILY_DOWN),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
sn = self.app.nm.getStorageList()[0]
......@@ -134,7 +134,7 @@ class MasterClientHandlerTests(NeoTestBase):
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.STORAGE, ('127.0.0.1', self.storage_port), uuid,
NodeStates.BROKEN),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
sn = self.app.nm.getStorageList()[0]
......@@ -142,7 +142,7 @@ class MasterClientHandlerTests(NeoTestBase):
self.failUnless(ptid < self.app.pt.getID())
def test_06_handleAnswerLastIDs(self):
def test_06_answerLastIDs(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_LAST_IDS)
......@@ -153,7 +153,7 @@ class MasterClientHandlerTests(NeoTestBase):
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT, port=self.client_port)
conn = self.getFakeConnection(client_uuid, self.client_address)
node_list = []
self.checkUnexpectedPacketRaised(service.handleAnswerLastIDs, conn, packet, None, None, None)
self.checkUnexpectedPacketRaised(service.answerLastIDs, conn, packet, None, None, None)
self.assertEquals(loid, self.app.loid)
self.assertEquals(ltid, self.app.ltid)
self.assertEquals(lptid, self.app.pt.getID())
......@@ -163,13 +163,13 @@ class MasterClientHandlerTests(NeoTestBase):
new_ptid = unpack('!Q', lptid)[0]
new_ptid = pack('!Q', new_ptid + 1)
self.failUnless(new_ptid > self.app.pt.getID())
self.assertRaises(OperationFailure, service.handleAnswerLastIDs, conn, packet, None, None, new_ptid)
self.assertRaises(OperationFailure, service.answerLastIDs, conn, packet, None, None, new_ptid)
self.assertEquals(loid, self.app.loid)
self.assertEquals(ltid, self.app.ltid)
self.assertEquals(lptid, self.app.pt.getID())
def test_07_handleAskBeginTransaction(self):
def test_07_askBeginTransaction(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ASK_BEGIN_TRANSACTION)
......@@ -177,14 +177,14 @@ class MasterClientHandlerTests(NeoTestBase):
# client call it
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT, port=self.client_port)
conn = self.getFakeConnection(client_uuid, self.client_address)
service.handleAskBeginTransaction(conn, packet, None)
service.askBeginTransaction(conn, packet, None)
self.failUnless(ltid < self.app.ltid)
self.assertEquals(len(self.app.finishing_transaction_dict), 1)
tid = self.app.finishing_transaction_dict.keys()[0]
self.assertEquals(tid, self.app.ltid)
def test_08_handleAskNewOIDs(self):
def test_08_askNewOIDs(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ASK_NEW_OIDS)
......@@ -192,10 +192,10 @@ class MasterClientHandlerTests(NeoTestBase):
# client call it
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT, port=self.client_port)
conn = self.getFakeConnection(client_uuid, self.client_address)
service.handleAskNewOIDs(conn, packet, 1)
service.askNewOIDs(conn, packet, 1)
self.failUnless(loid < self.app.loid)
def test_09_handleFinishTransaction(self):
def test_09_finishTransaction(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.FINISH_TRANSACTION)
......@@ -206,7 +206,7 @@ class MasterClientHandlerTests(NeoTestBase):
oid_list = []
upper, lower = unpack('!LL', self.app.ltid)
new_tid = pack('!LL', upper, lower + 10)
self.checkUnexpectedPacketRaised(service.handleFinishTransaction, conn, packet, oid_list, new_tid)
self.checkUnexpectedPacketRaised(service.finishTransaction, conn, packet, oid_list, new_tid)
old_node = self.app.nm.getByUUID(uuid)
self.app.nm.remove(old_node)
self.app.pt.dropNode(old_node)
......@@ -217,12 +217,12 @@ class MasterClientHandlerTests(NeoTestBase):
storage_conn = self.getFakeConnection(storage_uuid, self.storage_address)
self.assertNotEquals(uuid, client_uuid)
conn = self.getFakeConnection(client_uuid, self.client_address)
service.handleAskBeginTransaction(conn, packet, None)
service.askBeginTransaction(conn, packet, None)
oid_list = []
tid = self.app.ltid
conn = self.getFakeConnection(client_uuid, self.client_address)
self.app.em = Mock({"getConnectionList" : [conn, storage_conn]})
service.handleFinishTransaction(conn, packet, oid_list, tid)
service.finishTransaction(conn, packet, oid_list, tid)
self.checkLockInformation(storage_conn)
self.assertEquals(len(self.app.finishing_transaction_dict), 1)
apptid = self.app.finishing_transaction_dict.keys()[0]
......@@ -233,7 +233,7 @@ class MasterClientHandlerTests(NeoTestBase):
self.assertEquals(txn.getMessageId(), 9)
def test_11_handleAbortTransaction(self):
def test_11_abortTransaction(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ABORT_TRANSACTION)
......@@ -241,18 +241,18 @@ class MasterClientHandlerTests(NeoTestBase):
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT, port=self.client_port)
conn = self.getFakeConnection(client_uuid, self.client_address)
self.assertEqual(len(self.app.finishing_transaction_dict.keys()), 0)
service.handleAbortTransaction(conn, packet, None)
service.abortTransaction(conn, packet, None)
self.assertEqual(len(self.app.finishing_transaction_dict.keys()), 0)
# give a known tid
conn = self.getFakeConnection(client_uuid, self.client_address)
tid = self.app.ltid
self.app.finishing_transaction_dict[tid] = None
self.assertEqual(len(self.app.finishing_transaction_dict.keys()), 1)
service.handleAbortTransaction(conn, packet, tid)
service.abortTransaction(conn, packet, tid)
self.assertEqual(len(self.app.finishing_transaction_dict.keys()), 0)
def test_12_handleAskLastIDs(self):
def test_12_askLastIDs(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ASK_LAST_IDS)
......@@ -261,7 +261,7 @@ class MasterClientHandlerTests(NeoTestBase):
ptid = self.app.pt.getID()
self.app.ltid = '\1' * 8
self.app.loid = '\1' * 8
service.handleAskLastIDs(conn, packet)
service.askLastIDs(conn, packet)
packet = self.checkAnswerLastIDs(conn, answered_packet=packet)
loid, ltid, lptid = protocol._decodeAnswerLastIDs(packet._body)
self.assertEqual(loid, self.app.loid)
......@@ -269,13 +269,13 @@ class MasterClientHandlerTests(NeoTestBase):
self.assertEqual(lptid, ptid)
def test_13_handleAskUnfinishedTransactions(self):
def test_13_askUnfinishedTransactions(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ASK_UNFINISHED_TRANSACTIONS)
# give a uuid
conn = self.getFakeConnection(uuid, self.storage_address)
service.handleAskUnfinishedTransactions(conn, packet)
service.askUnfinishedTransactions(conn, packet)
packet = self.checkAnswerUnfinishedTransactions(conn, answered_packet=packet)
tid_list = protocol._decodeAnswerUnfinishedTransactions(packet._body)[0]
self.assertEqual(len(tid_list), 0)
......@@ -283,11 +283,11 @@ class MasterClientHandlerTests(NeoTestBase):
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT,
port=self.client_port)
conn = self.getFakeConnection(client_uuid, self.client_address)
service.handleAskBeginTransaction(conn, packet, None)
service.handleAskBeginTransaction(conn, packet, None)
service.handleAskBeginTransaction(conn, packet, None)
service.askBeginTransaction(conn, packet, None)
service.askBeginTransaction(conn, packet, None)
service.askBeginTransaction(conn, packet, None)
conn = self.getFakeConnection(uuid, self.storage_address)
service.handleAskUnfinishedTransactions(conn, packet)
service.askUnfinishedTransactions(conn, packet)
packet = self.checkAnswerUnfinishedTransactions(conn, answered_packet=packet)
tid_list = protocol._decodeAnswerUnfinishedTransactions(packet._body)[0]
self.assertEqual(len(tid_list), 3)
......@@ -324,9 +324,9 @@ class MasterClientHandlerTests(NeoTestBase):
conn = self.getFakeConnection(client_uuid, self.client_address)
lptid = self.app.pt.getID()
packet = Packet(msg_type=ASK_BEGIN_TRANSACTION)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(),
NodeStates.RUNNING)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
......@@ -368,9 +368,9 @@ class MasterClientHandlerTests(NeoTestBase):
conn = self.getFakeConnection(client_uuid, self.client_address)
lptid = self.app.pt.getID()
packet = Packet(msg_type=ASK_BEGIN_TRANSACTION)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(),
NodeStates.RUNNING)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
......@@ -412,9 +412,9 @@ class MasterClientHandlerTests(NeoTestBase):
conn = self.getFakeConnection(client_uuid, self.client_address)
lptid = self.app.pt.getID()
packet = Packet(msg_type=ASK_BEGIN_TRANSACTION)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(),
NodeStates.RUNNING)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
......
......@@ -112,7 +112,7 @@ class MasterClientElectionTests(NeoTestBase):
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(),
NodeStates.TEMPORARILY_DOWN)
def test_11_handleAskPrimaryMaster(self):
def test_11_askPrimaryMaster(self):
election = self.election
uuid = self.identifyToMasterNode(port=self.master_port)
packet = protocol.askPrimaryMaster()
......@@ -122,12 +122,12 @@ class MasterClientElectionTests(NeoTestBase):
"getConnector": Mock(),
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(len(self.app.nm.getMasterList()), 2)
election.handleAskPrimaryMaster(conn, packet)
election.askPrimaryMaster(conn, packet)
self.assertEquals(len(conn.mockGetNamedCalls("answer")), 1)
self.assertEquals(len(conn.mockGetNamedCalls("abort")), 0)
self.checkAnswerPrimaryMaster(conn)
def test_09_handleAnswerPrimaryMaster1(self):
def test_09_answerPrimaryMaster1(self):
# test with master node and greater uuid
uuid = self.getNewUUID()
if uuid < self.app.uuid:
......@@ -140,7 +140,7 @@ class MasterClientElectionTests(NeoTestBase):
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.assertEqual(len(self.app.nm.getMasterList()), 1)
self.election.handleAnswerPrimaryMaster(conn, p, INVALID_UUID, [])
self.election.answerPrimaryMaster(conn, p, INVALID_UUID, [])
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.assertEqual(self.app.primary, False)
self.assertEqual(len(self.app.nm.getMasterList()), 1)
......@@ -148,7 +148,7 @@ class MasterClientElectionTests(NeoTestBase):
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
def test_09_handleAnswerPrimaryMaster2(self):
def test_09_answerPrimaryMaster2(self):
# test with master node and lesser uuid
uuid = self.getNewUUID()
if uuid > self.app.uuid:
......@@ -161,7 +161,7 @@ class MasterClientElectionTests(NeoTestBase):
self.assertEqual(len(self.app.negotiating_master_node_set), 1)
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.assertEqual(len(self.app.nm.getMasterList()), 1)
self.election.handleAnswerPrimaryMaster(conn, p, INVALID_UUID, [])
self.election.answerPrimaryMaster(conn, p, INVALID_UUID, [])
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.assertEqual(self.app.primary, None)
self.assertEqual(len(self.app.nm.getMasterList()), 1)
......@@ -169,7 +169,7 @@ class MasterClientElectionTests(NeoTestBase):
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
def test_09_handleAnswerPrimaryMaster3(self):
def test_09_answerPrimaryMaster3(self):
# test with master node and given uuid for PMN
uuid = self.getNewUUID()
conn = ClientConnection(self.app.em, self.election, addr = ("127.0.0.1", self.master_port),
......@@ -182,7 +182,7 @@ class MasterClientElectionTests(NeoTestBase):
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.assertEqual(len(self.app.nm.getMasterList()), 2)
self.assertEqual(self.app.primary_master_node, None)
self.election.handleAnswerPrimaryMaster(conn, p, uuid, [])
self.election.answerPrimaryMaster(conn, p, uuid, [])
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.assertEqual(len(self.app.nm.getMasterList()), 2)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
......@@ -191,7 +191,7 @@ class MasterClientElectionTests(NeoTestBase):
self.assertEqual(self.app.primary, False)
def test_09_handleAnswerPrimaryMaster4(self):
def test_09_answerPrimaryMaster4(self):
# test with master node and unknown uuid for PMN
uuid = self.getNewUUID()
conn = ClientConnection(self.app.em, self.election, addr = ("127.0.0.1", self.master_port),
......@@ -203,7 +203,7 @@ class MasterClientElectionTests(NeoTestBase):
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.assertEqual(len(self.app.nm.getMasterList()), 1)
self.assertEqual(self.app.primary_master_node, None)
self.election.handleAnswerPrimaryMaster(conn, p, uuid, [])
self.election.answerPrimaryMaster(conn, p, uuid, [])
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.assertEqual(len(self.app.nm.getMasterList()), 1)
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
......@@ -212,7 +212,7 @@ class MasterClientElectionTests(NeoTestBase):
self.assertEqual(self.app.primary, None)
def test_09_handleAnswerPrimaryMaster5(self):
def test_09_answerPrimaryMaster5(self):
# test with master node and new uuid for PMN
uuid = self.getNewUUID()
conn = ClientConnection(self.app.em, self.election, addr = ("127.0.0.1", self.master_port),
......@@ -226,7 +226,7 @@ class MasterClientElectionTests(NeoTestBase):
self.assertEqual(len(self.app.nm.getMasterList()), 2)
self.assertEqual(self.app.primary_master_node, None)
master_uuid = self.getNewUUID()
self.election.handleAnswerPrimaryMaster(conn, p, master_uuid,
self.election.answerPrimaryMaster(conn, p, master_uuid,
[(("127.0.0.1", self.master_port+1), master_uuid,)])
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.assertEqual(len(self.app.nm.getMasterList()), 3)
......@@ -235,7 +235,7 @@ class MasterClientElectionTests(NeoTestBase):
self.assertNotEqual(self.app.primary_master_node, None)
self.assertEqual(self.app.primary, False)
# Now tell it's another node which is primary, it must raise
self.assertRaises(ElectionFailure, self.election.handleAnswerPrimaryMaster, conn, p, uuid, [])
self.assertRaises(ElectionFailure, self.election.answerPrimaryMaster, conn, p, uuid, [])
......@@ -369,7 +369,7 @@ class MasterServerElectionTests(NeoTestBase):
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(),
NodeStates.RUNNING)
def test_08_handleAcceptNodeIdentification1(self):
def test_08_acceptNodeIdentification1(self):
# test with storage node, must be rejected
uuid = self.getNewUUID()
conn = ClientConnection(self.app.em, self.election, addr = ("127.0.0.1", self.master_port),
......@@ -382,7 +382,7 @@ class MasterServerElectionTests(NeoTestBase):
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getUUID(), None)
self.assertEqual(conn.getUUID(), None)
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.election.handleAcceptNodeIdentification(conn, p, NodeTypes.STORAGE,
self.election.acceptNodeIdentification(conn, p, NodeTypes.STORAGE,
uuid, "127.0.0.1", self.master_port,
self.app.pt.getPartitions(),
self.app.pt.getReplicas(),
......@@ -392,7 +392,7 @@ class MasterServerElectionTests(NeoTestBase):
self.assertEqual(len(self.app.unconnected_master_node_set), 0)
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
def test_08_handleAcceptNodeIdentification2(self):
def test_08_acceptNodeIdentification2(self):
# test with bad address, must be rejected
uuid = self.getNewUUID()
conn = ClientConnection(self.app.em, self.election, addr = ("127.0.0.1", self.master_port),
......@@ -405,14 +405,14 @@ class MasterServerElectionTests(NeoTestBase):
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getUUID(), None)
self.assertEqual(conn.getUUID(), None)
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.election.handleAcceptNodeIdentification(conn, p, NodeTypes.STORAGE,
self.election.acceptNodeIdentification(conn, p, NodeTypes.STORAGE,
uuid, ("127.0.0.2", self.master_port),
self.app.pt.getPartitions(),
self.app.pt.getReplicas(),
self.app.uuid)
self.assertEqual(conn.getConnector(), None)
def test_08_handleAcceptNodeIdentification3(self):
def test_08_acceptNodeIdentification3(self):
# test with master node, must be ok
uuid = self.getNewUUID()
conn = ClientConnection(self.app.em, self.election, addr = ("127.0.0.1", self.master_port),
......@@ -426,7 +426,7 @@ class MasterServerElectionTests(NeoTestBase):
self.assertEqual(conn.getUUID(), None)
self.assertEqual(len(conn.getConnector().mockGetNamedCalls("_addPacket")),1)
self.election.handleAcceptNodeIdentification(conn, p, NodeTypes.MASTER,
self.election.acceptNodeIdentification(conn, p, NodeTypes.MASTER,
uuid, ("127.0.0.1", self.master_port),
self.app.pt.getPartitions(),
self.app.pt.getReplicas(),
......@@ -437,7 +437,7 @@ class MasterServerElectionTests(NeoTestBase):
self.checkCalledAskPrimaryMaster(conn.getConnector(), 1)
def test_10_handleRequestNodeIdentification(self):
def test_10_requestNodeIdentification(self):
election = self.election
uuid = self.getNewUUID()
args = (NodeTypes.MASTER, uuid, ('127.0.0.1', self.storage_port),
......@@ -447,7 +447,7 @@ class MasterServerElectionTests(NeoTestBase):
conn = Mock({"_addPacket" : None, "abort" : None,
"isServer" : True})
self.checkProtocolErrorRaised(
election.handleRequestNodeIdentification,
election.requestNodeIdentification,
conn,
packet=packet,
node_type=NodeTypes.MASTER,
......@@ -458,7 +458,7 @@ class MasterServerElectionTests(NeoTestBase):
conn = Mock({"_addPacket" : None, "abort" : None, "expectMessage" : None,
"isServer" : True})
self.checkNotReadyErrorRaised(
election.handleRequestNodeIdentification,
election.requestNodeIdentification,
conn,
packet=packet,
node_type=NodeTypes.STORAGE,
......@@ -473,7 +473,7 @@ class MasterServerElectionTests(NeoTestBase):
node = self.app.nm.getMasterList()[0]
self.assertEqual(node.getUUID(), None)
self.assertEqual(node.getState(), NodeStates.RUNNING)
election.handleRequestNodeIdentification(conn,
election.requestNodeIdentification(conn,
packet=packet,
node_type=NodeTypes.MASTER,
uuid=uuid,
......@@ -490,7 +490,7 @@ class MasterServerElectionTests(NeoTestBase):
self.assertEqual(len(self.app.nm.getMasterList()), 1)
self.assertEqual(len(self.app.unconnected_master_node_set), 1)
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
election.handleRequestNodeIdentification(conn,
election.requestNodeIdentification(conn,
packet=packet,
node_type=NodeTypes.MASTER,
uuid=new_uuid,
......@@ -510,7 +510,7 @@ class MasterServerElectionTests(NeoTestBase):
node.setState(NodeStates.BROKEN)
self.assertEqual(node.getState(), NodeStates.BROKEN)
self.checkBrokenNodeDisallowedErrorRaised(
election.handleRequestNodeIdentification,
election.requestNodeIdentification,
conn,
packet=packet,
node_type=NodeTypes.MASTER,
......@@ -520,7 +520,7 @@ class MasterServerElectionTests(NeoTestBase):
name=self.app.name,)
def test_12_handleAnnouncePrimaryMaster(self):
def test_12_announcePrimaryMaster(self):
election = self.election
uuid = self.identifyToMasterNode(port=self.master_port)
packet = Packet(msg_type=PacketTypes.ANNOUNCE_PRIMARY_MASTER)
......@@ -530,7 +530,7 @@ class MasterServerElectionTests(NeoTestBase):
"isServer" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(len(self.app.nm.getMasterList()), 1)
self.checkIdenficationRequired(election.handleAnnouncePrimaryMaster, conn, packet)
self.checkIdenficationRequired(election.announcePrimaryMaster, conn, packet)
# announce
conn = Mock({"_addPacket" : None,
"getUUID" : uuid,
......@@ -538,7 +538,7 @@ class MasterServerElectionTests(NeoTestBase):
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(self.app.primary, None)
self.assertEqual(self.app.primary_master_node, None)
election.handleAnnouncePrimaryMaster(conn, packet)
election.announcePrimaryMaster(conn, packet)
self.assertEqual(self.app.primary, False)
self.assertNotEqual(self.app.primary_master_node, None)
# set current as primary, and announce another, must raise
......@@ -548,10 +548,10 @@ class MasterServerElectionTests(NeoTestBase):
"getAddress" : ("127.0.0.1", self.master_port)})
self.app.primary = True
self.assertEqual(self.app.primary, True)
self.assertRaises(ElectionFailure, election.handleAnnouncePrimaryMaster, conn, packet)
self.assertRaises(ElectionFailure, election.announcePrimaryMaster, conn, packet)
def test_13_handleReelectPrimaryMaster(self):
def test_13_reelectPrimaryMaster(self):
election = self.election
uuid = self.identifyToMasterNode(port=self.master_port)
packet = protocol.askPrimaryMaster()
......@@ -560,9 +560,9 @@ class MasterServerElectionTests(NeoTestBase):
"getUUID" : None,
"isServer" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertRaises(ElectionFailure, election.handleReelectPrimaryMaster, conn, packet)
self.assertRaises(ElectionFailure, election.reelectPrimaryMaster, conn, packet)
def test_14_handleNotifyNodeInformation(self):
def test_14_notifyNodeInformation(self):
election = self.election
uuid = self.identifyToMasterNode(port=self.master_port)
packet = Packet(msg_type=PacketTypes.NOTIFY_NODE_INFORMATION)
......@@ -570,7 +570,7 @@ class MasterServerElectionTests(NeoTestBase):
conn = Mock({"getUUID" : None,
"getAddress" : ("127.0.0.1", self.master_port)})
node_list = []
self.checkIdenficationRequired(election.handleNotifyNodeInformation, conn, packet, node_list)
self.checkIdenficationRequired(election.notifyNodeInformation, conn, packet, node_list)
# tell the master node about itself, must do nothing
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.master_port)})
......@@ -578,7 +578,7 @@ class MasterServerElectionTests(NeoTestBase):
self.app.uuid, NodeStates.DOWN),]
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
self.assertEqual(node, None)
election.handleNotifyNodeInformation(conn, packet, node_list)
election.notifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
self.assertEqual(node, None)
# tell about a storage node, do nothing
......@@ -587,7 +587,7 @@ class MasterServerElectionTests(NeoTestBase):
node_list = [(NodeTypes.STORAGE, ('127.0.0.1', self.master_port - 1),
self.getNewUUID(), NodeStates.DOWN),]
self.assertEqual(len(self.app.nm.getStorageList()), 0)
election.handleNotifyNodeInformation(conn, packet, node_list)
election.notifyNodeInformation(conn, packet, node_list)
self.assertEqual(len(self.app.nm.getStorageList()), 0)
# tell about a client node, do nothing
conn = Mock({"getUUID" : uuid,
......@@ -595,7 +595,7 @@ class MasterServerElectionTests(NeoTestBase):
node_list = [(NodeTypes.CLIENT, ('127.0.0.1', self.master_port - 1),
self.getNewUUID(), NodeStates.DOWN),]
self.assertEqual(len(self.app.nm.getNodeList()), 0)
election.handleNotifyNodeInformation(conn, packet, node_list)
election.notifyNodeInformation(conn, packet, node_list)
self.assertEqual(len(self.app.nm.getNodeList()), 0)
# tell about another master node
conn = Mock({"getUUID" : uuid,
......@@ -604,7 +604,7 @@ class MasterServerElectionTests(NeoTestBase):
self.getNewUUID(), NodeStates.RUNNING),]
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port+1))
self.assertEqual(node, None)
election.handleNotifyNodeInformation(conn, packet, node_list)
election.notifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port+1))
self.assertNotEqual(node, None)
self.assertEqual(node.getAddress(), ("127.0.0.1", self.master_port+1))
......@@ -612,7 +612,7 @@ class MasterServerElectionTests(NeoTestBase):
# tell that node is down
node_list = [(NodeTypes.MASTER, '127.0.0.1', self.master_port + 1,
self.getNewUUID(), NodeStates.DOWN),]
election.handleNotifyNodeInformation(conn, packet, node_list)
election.notifyNodeInformation(conn, packet, node_list)
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port+1))
self.assertNotEqual(node, None)
self.assertEqual(node.getAddress(), ("127.0.0.1", self.master_port+1))
......
......@@ -90,7 +90,7 @@ class MasterRecoveryTests(NeoTestBase):
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(),
NodeStates.BROKEN)
def test_08_handleNotifyNodeInformation(self):
def test_08_notifyNodeInformation(self):
recovery = self.recovery
uuid = self.identifyToMasterNode(NodeTypes.MASTER, port=self.master_port)
packet = Packet(msg_type=PacketTypes.NOTIFY_NODE_INFORMATION)
......@@ -99,7 +99,7 @@ class MasterRecoveryTests(NeoTestBase):
node_list = [(NodeTypes.CLIENT, '127.0.0.1', self.client_port,
self.getNewUUID(), NodeStates.DOWN),]
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)
# tell the master node about itself, if running must do nothing
......@@ -108,7 +108,7 @@ class MasterRecoveryTests(NeoTestBase):
self.app.uuid, NodeStates.RUNNING),]
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
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))
# tell the master node about itself, if down must raise
......@@ -117,14 +117,14 @@ class MasterRecoveryTests(NeoTestBase):
self.app.uuid, NodeStates.DOWN),]
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port-1))
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
conn = self.getFakeConnection(uuid, self.master_address)
node_list = [(NodeTypes.STORAGE, '127.0.0.1', self.master_port - 1,
self.getNewUUID(), NodeStates.DOWN),]
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)
# tell about a known node but different address
......@@ -133,7 +133,7 @@ class MasterRecoveryTests(NeoTestBase):
NodeStates.DOWN),]
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port))
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))
self.assertEqual(node.getState(), NodeStates.RUNNING)
......@@ -143,12 +143,12 @@ class MasterRecoveryTests(NeoTestBase):
NodeStates.DOWN),]
node = self.app.nm.getByAddress(("127.0.0.1", self.master_port))
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))
self.assertEqual(node.getState(), NodeStates.DOWN)
def test_09_handleAnswerLastIDs(self):
def test_09_answerLastIDs(self):
recovery = self.recovery
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_LAST_IDS)
......@@ -168,14 +168,14 @@ class MasterRecoveryTests(NeoTestBase):
self.failUnless(new_oid > self.app.loid)
self.failUnless(new_tid > self.app.ltid)
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_tid, self.app.ltid)
self.assertEquals(new_ptid, self.app.pt.getID())
self.assertEquals(self.app.target_uuid,uuid)
def test_10_handleAnswerPartitionTable(self):
def test_10_answerPartitionTable(self):
recovery = self.recovery
uuid = self.identifyToMasterNode(NodeTypes.MASTER, port=self.master_port)
packet = Packet(msg_type=PacketTypes.ANSWER_PARTITION_TABLE)
......@@ -188,7 +188,7 @@ class MasterRecoveryTests(NeoTestBase):
cells = self.app.pt.getRow(offset)
for cell, state in cells:
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)
for cell, state in cells:
self.assertEquals(state, CellStates.OUT_OF_DATE)
......@@ -202,7 +202,7 @@ class MasterRecoveryTests(NeoTestBase):
cells = self.app.pt.getRow(offset)
for cell, state in cells:
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)
for cell, state in cells:
self.assertEquals(state, CellStates.UP_TO_DATE)
......@@ -212,7 +212,7 @@ class MasterRecoveryTests(NeoTestBase):
offset = 1000000
self.assertFalse(self.app.pt.hasOffset(offset))
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__':
......
......@@ -63,7 +63,7 @@ class MasterStorageHandlerTests(NeoTestBase):
return uuid
def test_05_handleNotifyNodeInformation(self):
def test_05_notifyNodeInformation(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.NOTIFY_NODE_INFORMATION)
......@@ -71,12 +71,12 @@ class MasterStorageHandlerTests(NeoTestBase):
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.MASTER, '127.0.0.1', self.master_port,
self.app.uuid, NodeStates.DOWN),]
self.assertRaises(RuntimeError, service.handleNotifyNodeInformation, conn, packet, node_list)
self.assertRaises(RuntimeError, service.notifyNodeInformation, conn, packet, node_list)
# tell the master node that it's running, nothing change
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.MASTER, '127.0.0.1', self.master_port,
self.app.uuid, NodeStates.RUNNING),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
# notify about a client node, don't care
......@@ -84,14 +84,14 @@ class MasterStorageHandlerTests(NeoTestBase):
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.CLIENT, '127.0.0.1', self.client_port, new_uuid,
NodeStates.BROKEN),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
# notify about an unknown node, don't care
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.STORAGE, '127.0.0.1', 11010, new_uuid,
NodeStates.BROKEN),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
# notify about a known node but with bad address, don't care
......@@ -101,14 +101,14 @@ class MasterStorageHandlerTests(NeoTestBase):
)
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.STORAGE, '127.0.0.1', 11012, uuid, NodeStates.BROKEN),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
# notify node is running, as PMN already know it, nothing is done
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.STORAGE, '127.0.0.1', self.storage_port, uuid,
NodeStates.RUNNING),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
# notify node is temp down, must be taken into account
......@@ -116,7 +116,7 @@ class MasterStorageHandlerTests(NeoTestBase):
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.STORAGE, '127.0.0.1', self.storage_port, uuid,
NodeStates.TEMPORARILY_DOWN),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
sn = self.app.nm.getStorageList()[0]
......@@ -126,14 +126,14 @@ class MasterStorageHandlerTests(NeoTestBase):
conn = self.getFakeConnection(uuid, self.storage_address)
node_list = [(NodeTypes.STORAGE, '127.0.0.1', self.storage_port, uuid,
NodeStates.BROKEN),]
service.handleNotifyNodeInformation(conn, packet, node_list)
service.notifyNodeInformation(conn, packet, node_list)
for call in conn.mockGetAllCalls():
self.assertEquals(call.getName(), "getUUID")
sn = self.app.nm.getStorageList()[0]
self.assertEquals(sn.getState(), CellStates.BROKEN)
self.failUnless(ptid < self.app.pt.getID())
def test_06_handleAnswerLastIDs(self):
def test_06_answerLastIDs(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_LAST_IDS)
......@@ -146,12 +146,12 @@ class MasterStorageHandlerTests(NeoTestBase):
new_ptid = unpack('!Q', lptid)[0]
new_ptid = pack('!Q', new_ptid + 1)
self.failUnless(new_ptid > self.app.pt.getID())
self.assertRaises(OperationFailure, service.handleAnswerLastIDs, conn, packet, None, None, new_ptid)
self.assertRaises(OperationFailure, service.answerLastIDs, conn, packet, None, None, new_ptid)
self.assertEquals(loid, self.app.loid)
self.assertEquals(ltid, self.app.ltid)
self.assertEquals(lptid, self.app.pt.getID())
def test_10_handleNotifyInformationLocked(self):
def test_10_notifyInformationLocked(self):
service = self.service
uuid = self.identifyToMasterNode(port=10020)
packet = Packet(msg_type=PacketTypes.NOTIFY_INFORMATION_LOCKED)
......@@ -160,7 +160,7 @@ class MasterStorageHandlerTests(NeoTestBase):
oid_list = []
upper, lower = unpack('!LL', self.app.ltid)
new_tid = pack('!LL', upper, lower + 10)
self.checkUnexpectedPacketRaised(service.handleNotifyInformationLocked, conn, packet, new_tid)
self.checkUnexpectedPacketRaised(service.notifyInformationLocked, conn, packet, new_tid)
old_node = self.app.nm.getByUUID(uuid)
# job done through dispatch -> peerBroken
self.app.nm.remove(old_node)
......@@ -173,28 +173,28 @@ class MasterStorageHandlerTests(NeoTestBase):
storage_conn_1 = self.getFakeConnection(storage_uuid_1, ("127.0.0.1", self.storage_port))
storage_conn_2 = self.getFakeConnection(storage_uuid_2, ("127.0.0.1", 10022))
conn = self.getFakeConnection(client_uuid, self.client_address)
service.handleAskBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
# clean mock object
conn.mockCalledMethods = {}
conn.mockAllCalledMethods = []
self.app.em = Mock({"getConnectionList" : [conn, storage_conn_1, storage_conn_2]})
oid_list = []
tid = self.app.ltid
service.handleFinishTransaction(conn, packet, oid_list, tid)
service.finishTransaction(conn, packet, oid_list, tid)
self.checkLockInformation(storage_conn_1)
self.checkLockInformation(storage_conn_2)
self.assertFalse(self.app.finishing_transaction_dict.values()[0].allLocked())
service.handleNotifyInformationLocked(storage_conn_1, packet, tid)
service.notifyInformationLocked(storage_conn_1, packet, tid)
self.checkLockInformation(storage_conn_1)
self.checkLockInformation(storage_conn_2)
self.assertFalse(self.app.finishing_transaction_dict.values()[0].allLocked())
service.handleNotifyInformationLocked(storage_conn_2, packet, tid)
service.notifyInformationLocked(storage_conn_2, packet, tid)
self.checkNotifyTransactionFinished(conn)
self.checkLockInformation(storage_conn_1)
self.checkLockInformation(storage_conn_2)
def test_12_handleAskLastIDs(self):
def test_12_askLastIDs(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ASK_LAST_IDS)
......@@ -203,7 +203,7 @@ class MasterStorageHandlerTests(NeoTestBase):
ptid = self.app.pt.getID()
tid = self.app.ltid
oid = self.app.loid
service.handleAskLastIDs(conn, packet)
service.askLastIDs(conn, packet)
packet = self.checkAnswerLastIDs(conn, answered_packet=packet)
loid, ltid, lptid = protocol._decodeAnswerLastIDs(packet._body)
self.assertEqual(loid, oid)
......@@ -211,13 +211,13 @@ class MasterStorageHandlerTests(NeoTestBase):
self.assertEqual(lptid, ptid)
def test_13_handleAskUnfinishedTransactions(self):
def test_13_askUnfinishedTransactions(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ASK_UNFINISHED_TRANSACTIONS)
# give a uuid
conn = self.getFakeConnection(uuid, self.storage_address)
service.handleAskUnfinishedTransactions(conn, packet)
service.askUnfinishedTransactions(conn, packet)
packet = self.checkAnswerUnfinishedTransactions(conn, answered_packet=packet)
tid_list = protocol._decodeAnswerUnfinishedTransactions(packet._body)[0]
self.assertEqual(len(tid_list), 0)
......@@ -225,17 +225,17 @@ class MasterStorageHandlerTests(NeoTestBase):
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT,
port=self.client_port)
conn = self.getFakeConnection(client_uuid, self.client_address)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
conn = self.getFakeConnection(uuid, self.storage_address)
service.handleAskUnfinishedTransactions(conn, packet)
service.askUnfinishedTransactions(conn, packet)
packet = self.checkAnswerUnfinishedTransactions(conn, answered_packet=packet)
tid_list = protocol._decodeAnswerUnfinishedTransactions(packet._body)[0]
self.assertEqual(len(tid_list), 3)
def test_14_handleNotifyPartitionChanges(self):
def test_14_notifyPartitionChanges(self):
service = self.service
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.NOTIFY_PARTITION_CHANGES)
......@@ -243,7 +243,7 @@ class MasterStorageHandlerTests(NeoTestBase):
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT,
port=self.client_port)
conn = self.getFakeConnection(client_uuid, self.client_address)
self.checkUnexpectedPacketRaised(service.handleNotifyPartitionChanges,
self.checkUnexpectedPacketRaised(service.notifyPartitionChanges,
conn, packet, None, None)
# send a bad state, must not be take into account
......@@ -254,7 +254,7 @@ class MasterStorageHandlerTests(NeoTestBase):
cells = self.app.pt.getRow(offset)
for cell, state in cells:
self.assertEquals(state, CellStates.OUT_OF_DATE)
service.handleNotifyPartitionChanges(conn, packet, self.app.pt.getID(), cell_list)
service.notifyPartitionChanges(conn, packet, self.app.pt.getID(), cell_list)
cells = self.app.pt.getRow(offset)
for cell, state in cells:
self.assertEquals(state, CellStates.OUT_OF_DATE)
......@@ -266,7 +266,7 @@ class MasterStorageHandlerTests(NeoTestBase):
cells = self.app.pt.getRow(offset)
for cell, state in cells:
self.assertEquals(state, CellStates.OUT_OF_DATE)
service.handleNotifyPartitionChanges(conn, packet, self.app.pt.getID(), cell_list)
service.notifyPartitionChanges(conn, packet, self.app.pt.getID(), cell_list)
cells = self.app.pt.getRow(offset)
for cell, state in cells:
self.assertEquals(state, CellStates.OUT_OF_DATE)
......@@ -290,7 +290,7 @@ class MasterStorageHandlerTests(NeoTestBase):
else:
self.assertEquals(state, CellStates.OUT_OF_DATE)
lptid = self.app.pt.getID()
service.handleNotifyPartitionChanges(conn, packet, self.app.pt.getID(), cell_list)
service.notifyPartitionChanges(conn, packet, self.app.pt.getID(), cell_list)
self.failUnless(lptid < self.app.pt.getID())
cells = self.app.pt.getRow(offset)
for cell, state in cells:
......@@ -336,9 +336,9 @@ class MasterStorageHandlerTests(NeoTestBase):
conn = self.getFakeConnection(client_uuid, self.client_address)
lptid = self.app.pt.getID()
packet = Packet(msg_type=ASK_BEGIN_TRANSACTION)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(),
NodeStates.RUNNING)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
......@@ -385,9 +385,9 @@ class MasterStorageHandlerTests(NeoTestBase):
conn = self.getFakeConnection(client_uuid, self.client_address)
lptid = self.app.pt.getID()
packet = Packet(msg_type=ASK_BEGIN_TRANSACTION)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(),
NodeStates.RUNNING)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
......@@ -434,9 +434,9 @@ class MasterStorageHandlerTests(NeoTestBase):
conn = self.getFakeConnection(client_uuid, self.client_address)
lptid = self.app.pt.getID()
packet = Packet(msg_type=ASK_BEGIN_TRANSACTION)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.handleAskBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
service.askBeginTransaction(conn, packet)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(),
NodeStates.RUNNING)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
......
......@@ -124,7 +124,7 @@ class MasterVerificationTests(NeoTestBase):
self.assertEqual(self.app.nm.getByAddress(conn.getAddress()).getState(),
NodeStates.TEMPORARILY_DOWN)
def test_09_handleAnswerLastIDs(self):
def test_09_answerLastIDs(self):
verification = self.verification
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_LAST_IDS)
......@@ -143,12 +143,12 @@ class MasterVerificationTests(NeoTestBase):
self.failUnless(new_ptid > self.app.pt.getID())
self.failUnless(new_oid > self.app.loid)
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_tid, self.app.ltid)
self.assertNotEquals(new_ptid, self.app.pt.getID())
def test_11_handleAnswerUnfinishedTransactions(self):
def test_11_answerUnfinishedTransactions(self):
verification = self.verification
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_UNFINISHED_TRANSACTIONS)
......@@ -160,7 +160,7 @@ class MasterVerificationTests(NeoTestBase):
self.assertEquals(len(self.app.unfinished_tid_set), 0)
upper, lower = unpack('!LL', self.app.ltid)
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)
# update dict
conn = self.getFakeConnection(uuid, self.storage_address)
......@@ -169,13 +169,13 @@ class MasterVerificationTests(NeoTestBase):
self.assertEquals(len(self.app.unfinished_tid_set), 0)
upper, lower = unpack('!LL', self.app.ltid)
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.assertEquals(len(self.app.unfinished_tid_set), 1)
self.assertTrue(new_tid in self.app.unfinished_tid_set)
def test_12_handleAnswerTransactionInformation(self):
def test_12_answerTransactionInformation(self):
verification = self.verification
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_TRANSACTION_INFORMATION)
......@@ -189,7 +189,7 @@ class MasterVerificationTests(NeoTestBase):
new_tid = pack('!LL', upper, lower + 10)
oid = unpack('!Q', self.app.loid)[0]
new_oid = pack('!Q', oid + 1)
verification.handleAnswerTransactionInformation(conn, packet, new_tid,
verification.answerTransactionInformation(conn, packet, new_tid,
"user", "desc", "ext", [new_oid,])
self.assertEquals(self.app.unfinished_oid_set, None)
# do nothing as asking_uuid_dict is True
......@@ -199,7 +199,7 @@ class MasterVerificationTests(NeoTestBase):
self.app.unfinished_oid_set = set()
self.assertTrue(self.app.asking_uuid_dict.has_key(uuid))
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,])
self.assertEquals(len(self.app.unfinished_oid_set), 0)
# do work
......@@ -208,7 +208,7 @@ class MasterVerificationTests(NeoTestBase):
self.app.asking_uuid_dict[uuid] = False
self.assertTrue(self.app.asking_uuid_dict.has_key(uuid))
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,])
self.assertEquals(len(self.app.unfinished_oid_set), 1)
self.assertTrue(new_oid in self.app.unfinished_oid_set)
......@@ -222,11 +222,11 @@ class MasterVerificationTests(NeoTestBase):
oid = unpack('!Q', old_oid)[0]
new_oid = pack('!Q', oid + 1)
self.assertNotEqual(new_oid, old_oid)
verification.handleAnswerTransactionInformation(conn, packet, new_tid,
verification.answerTransactionInformation(conn, packet, new_tid,
"user", "desc", "ext", [new_oid,])
self.assertEquals(self.app.unfinished_oid_set, None)
def test_13_handleTidNotFound(self):
def test_13_tidNotFound(self):
verification = self.verification
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=ErrorCodes.TID_NOT_FOUND)
......@@ -236,7 +236,7 @@ class MasterVerificationTests(NeoTestBase):
self.app.asking_uuid_dict[uuid] = True
self.app.unfinished_oid_set = []
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)
# do work as asking_uuid_dict is False
conn = self.getFakeConnection(uuid, self.storage_address)
......@@ -244,10 +244,10 @@ class MasterVerificationTests(NeoTestBase):
self.app.asking_uuid_dict[uuid] = False
self.app.unfinished_oid_set = []
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)
def test_14_handleAnswerObjectPresent(self):
def test_14_answerObjectPresent(self):
verification = self.verification
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=PacketTypes.ANSWER_OBJECT_PRESENT)
......@@ -260,16 +260,16 @@ class MasterVerificationTests(NeoTestBase):
self.assertEquals(len(self.app.asking_uuid_dict), 0)
self.app.asking_uuid_dict[uuid] = True
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
conn = self.getFakeConnection(uuid, self.storage_address)
self.assertEquals(len(self.app.asking_uuid_dict), 1)
self.app.asking_uuid_dict[uuid] = False
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])
def test_15_handleOidNotFound(self):
def test_15_oidNotFound(self):
verification = self.verification
uuid = self.identifyToMasterNode()
packet = Packet(msg_type=ErrorCodes.OID_NOT_FOUND)
......@@ -279,7 +279,7 @@ class MasterVerificationTests(NeoTestBase):
self.app.asking_uuid_dict[uuid] = True
self.app.object_present = True
self.assertTrue(self.app.object_present)
verification.handleOidNotFound(conn, packet, "msg")
verification.oidNotFound(conn, packet, "msg")
self.assertTrue(self.app.object_present)
# do work as asking_uuid_dict is False
conn = self.getFakeConnection(uuid, self.storage_address)
......@@ -287,7 +287,7 @@ class MasterVerificationTests(NeoTestBase):
self.app.asking_uuid_dict[uuid] = False
self.assertFalse(self.app.asking_uuid_dict[uuid ])
self.assertTrue(self.app.object_present)
verification.handleOidNotFound(conn, packet, "msg")
verification.oidNotFound(conn, packet, "msg")
self.assertFalse(self.app.object_present)
self.assertTrue(self.app.asking_uuid_dict[uuid ])
......
......@@ -104,30 +104,30 @@ class StorageClientHandlerTests(NeoTestBase):
self.assertTrue(0 not in self.app.store_lock_dict)
self.assertTrue(0 not in self.app.transaction_dict)
def test_18_handleAskTransactionInformation1(self):
def test_18_askTransactionInformation1(self):
# transaction does not exists
conn = Mock({ })
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)
def test_18_handleAskTransactionInformation2(self):
def test_18_askTransactionInformation2(self):
# answer
conn = Mock({ })
packet = Packet(msg_type=PacketTypes.ASK_TRANSACTION_INFORMATION)
dm = Mock({ "getTransaction": (INVALID_TID, 'user', 'desc', '', ), })
self.app.dm = dm
self.operation.handleAskTransactionInformation(conn, packet, INVALID_TID)
self.operation.askTransactionInformation(conn, packet, INVALID_TID)
self.checkAnswerTransactionInformation(conn)
def test_24_handleAskObject1(self):
def test_24_askObject1(self):
# delayed response
conn = Mock({})
self.app.dm = Mock()
packet = Packet(msg_type=PacketTypes.ASK_OBJECT)
self.app.load_lock_dict[INVALID_OID] = object()
self.assertEquals(len(self.app.event_queue), 0)
self.operation.handleAskObject(conn, packet,
self.operation.askObject(conn, packet,
oid=INVALID_OID,
serial=INVALID_SERIAL,
tid=INVALID_TID)
......@@ -135,13 +135,13 @@ class StorageClientHandlerTests(NeoTestBase):
self.checkNoPacketSent(conn)
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
self.app.dm = Mock({'getObject': None})
conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OBJECT)
self.assertEquals(len(self.app.event_queue), 0)
self.operation.handleAskObject(conn, packet,
self.operation.askObject(conn, packet,
oid=INVALID_OID,
serial=INVALID_SERIAL,
tid=INVALID_TID)
......@@ -151,83 +151,83 @@ class StorageClientHandlerTests(NeoTestBase):
calls[0].checkArgs(INVALID_OID, INVALID_TID, INVALID_TID)
self.checkErrorPacket(conn)
def test_24_handleAskObject3(self):
def test_24_askObject3(self):
# object found => answer
self.app.dm = Mock({'getObject': ('', '', 0, 0, '', )})
conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OBJECT)
self.assertEquals(len(self.app.event_queue), 0)
self.operation.handleAskObject(conn, packet,
self.operation.askObject(conn, packet,
oid=INVALID_OID,
serial=INVALID_SERIAL,
tid=INVALID_TID)
self.assertEquals(len(self.app.event_queue), 0)
self.checkAnswerObject(conn)
def test_25_handleAskTIDs1(self):
def test_25_askTIDs1(self):
# invalid offsets => error
app = self.app
app.pt = Mock()
app.dm = Mock()
conn = Mock({})
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.dm.mockGetNamedCalls('getTIDList')), 0)
def test_25_handleAskTIDs2(self):
def test_25_askTIDs2(self):
# well case => answer
conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_TIDS)
self.app.pt = Mock({'getPartitions': 1})
self.app.dm = Mock({'getTIDList': (INVALID_TID, )})
self.operation.handleAskTIDs(conn, packet, 1, 2, 1)
self.operation.askTIDs(conn, packet, 1, 2, 1)
calls = self.app.dm.mockGetNamedCalls('getTIDList')
self.assertEquals(len(calls), 1)
calls[0].checkArgs(1, 1, 1, [1, ])
self.checkAnswerTids(conn)
def test_25_handleAskTIDs3(self):
def test_25_askTIDs3(self):
# invalid partition => answer usable partitions
conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_TIDS)
cell = Mock({'getUUID':self.app.uuid})
self.app.dm = Mock({'getTIDList': (INVALID_TID, )})
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)
calls = self.app.dm.mockGetNamedCalls('getTIDList')
self.assertEquals(len(calls), 1)
calls[0].checkArgs(1, 1, 1, [0, ])
self.checkAnswerTids(conn)
def test_26_handleAskObjectHistory1(self):
def test_26_askObjectHistory1(self):
# invalid offsets => error
app = self.app
app.dm = Mock()
conn = Mock({})
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)
def test_26_handleAskObjectHistory2(self):
def test_26_askObjectHistory2(self):
# first case: empty history
packet = Packet(msg_type=PacketTypes.ASK_OBJECT_HISTORY)
conn = Mock({})
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)
# second case: not empty history
conn = Mock({})
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)
def test_27_handleAskStoreTransaction2(self):
def test_27_askStoreTransaction2(self):
# add transaction entry
packet = Packet(msg_type=PacketTypes.ASK_STORE_TRANSACTION)
conn = Mock({'getUUID': self.getNewUUID()})
self.operation.handleAskStoreTransaction(conn, packet,
self.operation.askStoreTransaction(conn, packet,
INVALID_TID, '', '', '', ())
t = self.app.transaction_dict.get(INVALID_TID, None)
self.assertNotEquals(t, None)
......@@ -235,7 +235,7 @@ class StorageClientHandlerTests(NeoTestBase):
self.assertEquals(t.getTransaction(), ((), '', '', ''))
self.checkAnswerStoreTransaction(conn)
def test_28_handleAskStoreObject2(self):
def test_28_askStoreObject2(self):
# locked => delayed response
packet = Packet(msg_type=PacketTypes.ASK_STORE_OBJECT)
conn = Mock({'getUUID': self.app.uuid})
......@@ -244,7 +244,7 @@ class StorageClientHandlerTests(NeoTestBase):
self.app.store_lock_dict[oid] = tid1
self.assertTrue(oid in self.app.store_lock_dict)
t_before = self.app.transaction_dict.items()[:]
self.operation.handleAskStoreObject(conn, packet, oid,
self.operation.askStoreObject(conn, packet, oid,
INVALID_SERIAL, 0, 0, '', tid2)
self.assertEquals(len(self.app.event_queue), 1)
t_after = self.app.transaction_dict.items()[:]
......@@ -252,13 +252,13 @@ class StorageClientHandlerTests(NeoTestBase):
self.checkNoPacketSent(conn)
self.assertTrue(oid in self.app.store_lock_dict)
def test_28_handleAskStoreObject3(self):
def test_28_askStoreObject3(self):
# locked => unresolvable conflict => answer
packet = Packet(msg_type=PacketTypes.ASK_STORE_OBJECT)
conn = Mock({'getUUID': self.app.uuid})
tid1, tid2 = self.getTwoIDs()
self.app.store_lock_dict[INVALID_OID] = tid2
self.operation.handleAskStoreObject(conn, packet, INVALID_OID,
self.operation.askStoreObject(conn, packet, INVALID_OID,
INVALID_SERIAL, 0, 0, '', tid1)
self.checkAnswerStoreObject(conn)
self.assertEquals(self.app.store_lock_dict[INVALID_OID], tid2)
......@@ -266,13 +266,13 @@ class StorageClientHandlerTests(NeoTestBase):
packet = conn.mockGetNamedCalls('answer')[0].getParam(0)
self.assertTrue(unpack('!B8s8s', packet._body)[0])
def test_28_handleAskStoreObject4(self):
def test_28_askStoreObject4(self):
# resolvable conflict => answer
packet = Packet(msg_type=PacketTypes.ASK_STORE_OBJECT)
conn = Mock({'getUUID': self.app.uuid})
self.app.dm = Mock({'getObjectHistory':((self.getNewUUID(), ), )})
self.assertEquals(self.app.store_lock_dict.get(INVALID_OID, None), None)
self.operation.handleAskStoreObject(conn, packet, INVALID_OID,
self.operation.askStoreObject(conn, packet, INVALID_OID,
INVALID_SERIAL, 0, 0, '', INVALID_TID)
self.checkAnswerStoreObject(conn)
self.assertEquals(self.app.store_lock_dict.get(INVALID_OID, None), None)
......@@ -280,11 +280,11 @@ class StorageClientHandlerTests(NeoTestBase):
packet = conn.mockGetNamedCalls('answer')[0].getParam(0)
self.assertTrue(unpack('!B8s8s', packet._body)[0])
def test_28_handleAskStoreObject5(self):
def test_28_askStoreObject5(self):
# no conflict => answer
packet = Packet(msg_type=PacketTypes.ASK_STORE_OBJECT)
conn = Mock({'getUUID': self.app.uuid})
self.operation.handleAskStoreObject(conn, packet, INVALID_OID,
self.operation.askStoreObject(conn, packet, INVALID_OID,
INVALID_SERIAL, 0, 0, '', INVALID_TID)
t = self.app.transaction_dict.get(INVALID_TID, None)
self.assertNotEquals(t, None)
......@@ -295,7 +295,7 @@ class StorageClientHandlerTests(NeoTestBase):
packet = self.checkAnswerStoreObject(conn)
self.assertFalse(unpack('!B8s8s', packet._body)[0])
def test_29_handleAbortTransaction(self):
def test_29_abortTransaction(self):
# remove transaction
packet = Packet(msg_type=PacketTypes.ABORT_TRANSACTION)
conn = Mock({'getUUID': self.app.uuid})
......@@ -307,7 +307,7 @@ class StorageClientHandlerTests(NeoTestBase):
self.app.load_lock_dict[0] = object()
self.app.store_lock_dict[0] = object()
self.app.transaction_dict[INVALID_TID] = transaction
self.operation.handleAbortTransaction(conn, packet, INVALID_TID)
self.operation.abortTransaction(conn, packet, INVALID_TID)
self.assertTrue(self.called)
self.assertEquals(len(self.app.load_lock_dict), 0)
self.assertEquals(len(self.app.store_lock_dict), 0)
......
......@@ -79,7 +79,7 @@ class StorageInitializationHandlerTests(NeoTestBase):
# nothing happens
self.checkNoPacketSent(conn)
def test_09_handleSendPartitionTable(self):
def test_09_sendPartitionTable(self):
packet = Packet(msg_type=PacketTypes.SEND_PARTITION_TABLE)
uuid = self.getNewUUID()
# send a table
......@@ -101,19 +101,19 @@ class StorageInitializationHandlerTests(NeoTestBase):
(2, ((node_2, CellStates.UP_TO_DATE), (node_3, CellStates.UP_TO_DATE)))]
self.assertFalse(self.app.pt.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.assertEqual(self.app.pt.getID(), 1)
self.assertEqual(self.app.dm.getPartitionTable(), [])
# send remaining of the table (ack with AnswerPartitionTable)
self.verification.handleSendPartitionTable(conn, packet, 1, row_list[1:])
self.verification.handleAnswerPartitionTable(conn, packet, 1, [])
self.verification.sendPartitionTable(conn, packet, 1, row_list[1:])
self.verification.answerPartitionTable(conn, packet, 1, [])
self.assertTrue(self.app.pt.filled())
self.assertEqual(self.app.pt.getID(), 1)
self.assertNotEqual(self.app.dm.getPartitionTable(), [])
# send a complete new table and ack
self.verification.handleSendPartitionTable(conn, packet, 2, row_list)
self.verification.handleAnswerPartitionTable(conn, packet, 2, [])
self.verification.sendPartitionTable(conn, packet, 2, row_list)
self.verification.answerPartitionTable(conn, packet, 2, [])
self.assertTrue(self.app.pt.filled())
self.assertEqual(self.app.pt.getID(), 2)
self.assertNotEqual(self.app.dm.getPartitionTable(), [])
......
......@@ -92,7 +92,7 @@ class StorageMasterHandlerTests(NeoTestBase):
self.assertRaises(PrimaryFailure, self.operation.peerBroken, conn)
self.checkNoPacketSent(conn)
def test_14_handleNotifyPartitionChanges1(self):
def test_14_notifyPartitionChanges1(self):
# old partition change -> do nothing
app = self.app
conn = Mock({
......@@ -103,7 +103,7 @@ class StorageMasterHandlerTests(NeoTestBase):
packet = Packet(msg_type=PacketTypes.NOTIFY_PARTITION_CHANGES)
self.app.pt = Mock({'getID': 1})
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(len(self.app.nm.getList()), count)
calls = self.app.replicator.mockGetNamedCalls('removePartition')
......@@ -111,7 +111,7 @@ class StorageMasterHandlerTests(NeoTestBase):
calls = self.app.replicator.mockGetNamedCalls('addPartition')
self.assertEquals(len(calls), 0)
def test_14_handleNotifyPartitionChanges2(self):
def test_14_notifyPartitionChanges2(self):
# cases :
uuid1, uuid2, uuid3 = [self.getNewUUID() for i in range(3)]
cells = (
......@@ -136,7 +136,7 @@ class StorageMasterHandlerTests(NeoTestBase):
app.dm = Mock({ })
app.replicator = Mock({})
count = len(app.nm.getList())
self.operation.handleNotifyPartitionChanges(conn, packet, ptid2, cells)
self.operation.notifyPartitionChanges(conn, packet, ptid2, cells)
# ptid set
self.assertEquals(app.pt.getID(), ptid2)
# dm call
......@@ -144,13 +144,13 @@ class StorageMasterHandlerTests(NeoTestBase):
self.assertEquals(len(calls), 1)
calls[0].checkArgs(ptid2, cells)
def test_16_handleStopOperation1(self):
def test_16_stopOperation1(self):
# OperationFailure
conn = Mock({ 'isServer': False })
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
conn = Mock({ 'isServer': False, })
self.app.dm = Mock({ })
......@@ -158,7 +158,7 @@ class StorageMasterHandlerTests(NeoTestBase):
packet.setId(1)
transaction = Mock({ 'getObjectList': ((0, ), ), })
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)
calls = self.app.dm.mockGetNamedCalls('storeTransaction')
self.assertEquals(len(calls), 1)
......@@ -166,10 +166,10 @@ class StorageMasterHandlerTests(NeoTestBase):
# transaction not in transaction_dict -> KeyError
transaction = Mock({ 'getObjectList': ((0, ), ), })
conn = Mock({ 'isServer': False, })
self.operation.handleLockInformation(conn, packet, '\x01' * 8)
self.operation.lockInformation(conn, packet, '\x01' * 8)
self.checkNotifyInformationLocked(conn, answered_packet=packet)
def test_23_handleUnlockInformation2(self):
def test_23_unlockInformation2(self):
# delete transaction informations
conn = Mock({ 'isServer': False, })
self.app.dm = Mock({ })
......@@ -179,7 +179,7 @@ class StorageMasterHandlerTests(NeoTestBase):
self.app.transaction_dict[INVALID_TID] = transaction
self.app.load_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.store_lock_dict), 0)
self.assertEquals(len(self.app.store_lock_dict), 0)
......@@ -189,15 +189,15 @@ class StorageMasterHandlerTests(NeoTestBase):
# transaction not in transaction_dict -> KeyError
transaction = Mock({ 'getObjectList': ((0, ), ), })
conn = Mock({ 'isServer': False, })
self.operation.handleLockInformation(conn, packet, '\x01' * 8)
self.operation.lockInformation(conn, packet, '\x01' * 8)
self.checkNotifyInformationLocked(conn, answered_packet=packet)
def test_30_handleAnswerLastIDs(self):
def test_30_answerLastIDs(self):
# set critical TID on replicator
conn = Mock()
packet = Packet(msg_type=PacketTypes.ANSWER_LAST_IDS)
self.app.replicator = Mock()
self.operation.handleAnswerLastIDs(
self.operation.answerLastIDs(
conn=conn,
packet=packet,
loid=INVALID_OID,
......@@ -208,12 +208,12 @@ class StorageMasterHandlerTests(NeoTestBase):
self.assertEquals(len(calls), 1)
calls[0].checkArgs(packet, INVALID_TID)
def test_31_handleAnswerUnfinishedTransactions(self):
def test_31_answerUnfinishedTransactions(self):
# set unfinished TID on replicator
conn = Mock()
packet = Packet(msg_type=PacketTypes.ANSWER_UNFINISHED_TRANSACTIONS)
self.app.replicator = Mock()
self.operation.handleAnswerUnfinishedTransactions(
self.operation.answerUnfinishedTransactions(
conn=conn,
packet=packet,
tid_list=(INVALID_TID, ),
......
......@@ -62,30 +62,30 @@ class StorageStorageHandlerTests(NeoTestBase):
def tearDown(self):
NeoTestBase.tearDown(self)
def test_18_handleAskTransactionInformation1(self):
def test_18_askTransactionInformation1(self):
# transaction does not exists
conn = Mock({ })
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)
def test_18_handleAskTransactionInformation2(self):
def test_18_askTransactionInformation2(self):
# answer
conn = Mock({ })
packet = Packet(msg_type=PacketTypes.ASK_TRANSACTION_INFORMATION)
dm = Mock({ "getTransaction": (INVALID_TID, 'user', 'desc', '', ), })
self.app.dm = dm
self.operation.handleAskTransactionInformation(conn, packet, INVALID_TID)
self.operation.askTransactionInformation(conn, packet, INVALID_TID)
self.checkAnswerTransactionInformation(conn)
def test_24_handleAskObject1(self):
def test_24_askObject1(self):
# delayed response
conn = Mock({})
self.app.dm = Mock()
packet = Packet(msg_type=PacketTypes.ASK_OBJECT)
self.app.load_lock_dict[INVALID_OID] = object()
self.assertEquals(len(self.app.event_queue), 0)
self.operation.handleAskObject(conn, packet,
self.operation.askObject(conn, packet,
oid=INVALID_OID,
serial=INVALID_SERIAL,
tid=INVALID_TID)
......@@ -93,13 +93,13 @@ class StorageStorageHandlerTests(NeoTestBase):
self.checkNoPacketSent(conn)
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
self.app.dm = Mock({'getObject': None})
conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OBJECT)
self.assertEquals(len(self.app.event_queue), 0)
self.operation.handleAskObject(conn, packet,
self.operation.askObject(conn, packet,
oid=INVALID_OID,
serial=INVALID_SERIAL,
tid=INVALID_TID)
......@@ -109,109 +109,109 @@ class StorageStorageHandlerTests(NeoTestBase):
calls[0].checkArgs(INVALID_OID, INVALID_TID, INVALID_TID)
self.checkErrorPacket(conn)
def test_24_handleAskObject3(self):
def test_24_askObject3(self):
# object found => answer
self.app.dm = Mock({'getObject': ('', '', 0, 0, '', )})
conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OBJECT)
self.assertEquals(len(self.app.event_queue), 0)
self.operation.handleAskObject(conn, packet,
self.operation.askObject(conn, packet,
oid=INVALID_OID,
serial=INVALID_SERIAL,
tid=INVALID_TID)
self.assertEquals(len(self.app.event_queue), 0)
self.checkAnswerObject(conn)
def test_25_handleAskTIDs1(self):
def test_25_askTIDs1(self):
# invalid offsets => error
app = self.app
app.pt = Mock()
app.dm = Mock()
conn = Mock({})
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.dm.mockGetNamedCalls('getTIDList')), 0)
def test_25_handleAskTIDs2(self):
def test_25_askTIDs2(self):
# well case => answer
conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_TIDS)
self.app.dm = Mock({'getTIDList': (INVALID_TID, )})
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')
self.assertEquals(len(calls), 1)
calls[0].checkArgs(1, 1, 1, [1, ])
self.checkAnswerTids(conn)
def test_25_handleAskTIDs3(self):
def test_25_askTIDs3(self):
# invalid partition => answer usable partitions
conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_TIDS)
cell = Mock({'getUUID':self.app.uuid})
self.app.dm = Mock({'getTIDList': (INVALID_TID, )})
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)
calls = self.app.dm.mockGetNamedCalls('getTIDList')
self.assertEquals(len(calls), 1)
calls[0].checkArgs(1, 1, 1, [0, ])
self.checkAnswerTids(conn)
def test_26_handleAskObjectHistory1(self):
def test_26_askObjectHistory1(self):
# invalid offsets => error
app = self.app
app.dm = Mock()
conn = Mock({})
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)
def test_26_handleAskObjectHistory2(self):
def test_26_askObjectHistory2(self):
# first case: empty history
packet = Packet(msg_type=PacketTypes.ASK_OBJECT_HISTORY)
conn = Mock({})
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)
# second case: not empty history
conn = Mock({})
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)
def test_25_handleAskOIDs1(self):
def test_25_askOIDs1(self):
# invalid offsets => error
app = self.app
app.pt = Mock()
app.dm = Mock()
conn = Mock({})
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.dm.mockGetNamedCalls('getOIDList')), 0)
def test_25_handleAskOIDs2(self):
def test_25_askOIDs2(self):
# well case > answer OIDs
conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OIDS)
self.app.pt = Mock({'getPartitions': 1})
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')
self.assertEquals(len(calls), 1)
calls[0].checkArgs(1, 1, 1, [1, ])
self.checkAnswerOids(conn)
def test_25_handleAskOIDs3(self):
def test_25_askOIDs3(self):
# invalid partition => answer usable partitions
conn = Mock({})
packet = Packet(msg_type=PacketTypes.ASK_OIDS)
cell = Mock({'getUUID':self.app.uuid})
self.app.dm = Mock({'getOIDList': (INVALID_OID, )})
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)
calls = self.app.dm.mockGetNamedCalls('getOIDList')
self.assertEquals(len(calls), 1)
......
......@@ -83,7 +83,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
# nothing happens
self.checkNoPacketSent(conn)
def test_07_handleAskLastIDs(self):
def test_07_askLastIDs(self):
uuid = self.getNewUUID()
packet = Mock()
# return invalid if db store nothing
......@@ -93,7 +93,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
last_ptid = '\x01' * 8
last_oid = '\x02' * 8
self.app.pt = Mock({'getID': last_ptid})
self.verification.handleAskLastIDs(conn, packet)
self.verification.askLastIDs(conn, packet)
oid, tid, ptid = self.checkAnswerLastIDs(conn, decode=True)
self.assertEqual(oid, INVALID_OID)
self.assertEqual(tid, INVALID_TID)
......@@ -125,14 +125,14 @@ class StorageVerificationHandlerTests(NeoTestBase):
checksum, value) values (0, 4, 0, 0, '')""")
self.app.dm.commit()
self.app.dm.setLastOID(last_oid)
self.verification.handleAskLastIDs(conn, packet)
self.verification.askLastIDs(conn, packet)
self.checkAnswerLastIDs(conn)
oid, tid, ptid = self.checkAnswerLastIDs(conn, decode=True)
self.assertEqual(oid, last_oid)
self.assertEqual(u64(tid), 4)
self.assertEqual(ptid, self.app.pt.getID())
def test_08_handleAskPartitionTable(self):
def test_08_askPartitionTable(self):
uuid = self.getNewUUID()
packet = Mock()
# try to get unknown offset
......@@ -142,7 +142,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.verification.handleAskPartitionTable(conn, packet, [1,])
self.verification.askPartitionTable(conn, packet, [1,])
ptid, row_list = self.checkAnswerPartitionTable(conn, decode=True)
self.assertEqual(len(row_list), 1)
offset, rows = row_list[0]
......@@ -159,22 +159,22 @@ class StorageVerificationHandlerTests(NeoTestBase):
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.verification.handleAskPartitionTable(conn, packet, [1,])
self.verification.askPartitionTable(conn, packet, [1,])
ptid, row_list = self.checkAnswerPartitionTable(conn, decode=True)
self.assertEqual(len(row_list), 1)
offset, rows = row_list[0]
self.assertEqual(offset, 1)
self.assertEqual(len(rows), 1)
def test_10_handleNotifyPartitionChanges(self):
def test_10_notifyPartitionChanges(self):
# old partition change
conn = Mock({
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
packet = Packet(msg_type=PacketTypes.NOTIFY_PARTITION_CHANGES)
self.verification.handleNotifyPartitionChanges(conn, packet, 1, ())
self.verification.handleNotifyPartitionChanges(conn, packet, 0, ())
self.verification.notifyPartitionChanges(conn, packet, 1, ())
self.verification.notifyPartitionChanges(conn, packet, 0, ())
self.assertEqual(self.app.pt.getID(), 1)
# new node
......@@ -190,33 +190,33 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.app.dm = Mock({ })
ptid, self.ptid = self.getTwoIDs()
# pt updated
self.verification.handleNotifyPartitionChanges(conn, packet, ptid, (cell, ))
self.verification.notifyPartitionChanges(conn, packet, ptid, (cell, ))
# check db update
calls = self.app.dm.mockGetNamedCalls('changePartitionTable')
self.assertEquals(len(calls), 1)
self.assertEquals(calls[0].getParam(0), ptid)
self.assertEquals(calls[0].getParam(1), (cell, ))
def test_11_handleStartOperation(self):
def test_11_startOperation(self):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False })
self.assertFalse(self.app.operational)
packet = Packet(msg_type=PacketTypes.STOP_OPERATION)
self.verification.handleStartOperation(conn, packet)
self.verification.startOperation(conn, packet)
self.assertTrue(self.app.operational)
def test_12_handleStopOperation(self):
def test_12_stopOperation(self):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False })
packet = Packet(msg_type=PacketTypes.STOP_OPERATION)
self.assertRaises(OperationFailure, self.verification.handleStopOperation, conn, packet)
self.assertRaises(OperationFailure, self.verification.stopOperation, conn, packet)
def test_13_handleAskUnfinishedTransactions(self):
def test_13_askUnfinishedTransactions(self):
# client connection with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False})
packet = Packet(msg_type=PacketTypes.ASK_UNFINISHED_TRANSACTIONS)
self.verification.handleAskUnfinishedTransactions(conn, packet)
self.verification.askUnfinishedTransactions(conn, packet)
(tid_list, ) = self.checkAnswerUnfinishedTransactions(conn, decode=True)
self.assertEqual(len(tid_list), 0)
......@@ -228,17 +228,17 @@ class StorageVerificationHandlerTests(NeoTestBase):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False})
packet = Packet(msg_type=PacketTypes.ASK_UNFINISHED_TRANSACTIONS)
self.verification.handleAskUnfinishedTransactions(conn, packet)
self.verification.askUnfinishedTransactions(conn, packet)
(tid_list, ) = self.checkAnswerUnfinishedTransactions(conn, decode=True)
self.assertEqual(len(tid_list), 1)
self.assertEqual(u64(tid_list[0]), 4)
def test_14_handleAskTransactionInformation(self):
def test_14_askTransactionInformation(self):
# ask from client conn with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False })
packet = Packet(msg_type=PacketTypes.ASK_TRANSACTION_INFORMATION)
self.verification.handleAskTransactionInformation(conn, packet, p64(1))
self.verification.askTransactionInformation(conn, packet, p64(1))
code, message = self.checkErrorPacket(conn, decode=True)
self.assertEqual(code, ErrorCodes.TID_NOT_FOUND)
......@@ -253,7 +253,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False })
packet = Packet(msg_type=PacketTypes.ASK_TRANSACTION_INFORMATION)
self.verification.handleAskTransactionInformation(conn, packet, p64(1))
self.verification.askTransactionInformation(conn, packet, p64(1))
tid, user, desc, ext, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
self.assertEqual(u64(tid), 1)
self.assertEqual(user, 'u2')
......@@ -265,7 +265,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False })
packet = Packet(msg_type=PacketTypes.ASK_TRANSACTION_INFORMATION)
self.verification.handleAskTransactionInformation(conn, packet, p64(3))
self.verification.askTransactionInformation(conn, packet, p64(3))
tid, user, desc, ext, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
self.assertEqual(u64(tid), 3)
self.assertEqual(user, 'u1')
......@@ -279,7 +279,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
'isServer': True })
# find the one in trans
packet = Packet(msg_type=PacketTypes.ASK_TRANSACTION_INFORMATION)
self.verification.handleAskTransactionInformation(conn, packet, p64(1))
self.verification.askTransactionInformation(conn, packet, p64(1))
tid, user, desc, ext, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
self.assertEqual(u64(tid), 1)
self.assertEqual(user, 'u2')
......@@ -291,16 +291,16 @@ class StorageVerificationHandlerTests(NeoTestBase):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': True })
packet = Packet(msg_type=PacketTypes.ASK_TRANSACTION_INFORMATION)
self.verification.handleAskTransactionInformation(conn, packet, p64(2))
self.verification.askTransactionInformation(conn, packet, p64(2))
code, message = self.checkErrorPacket(conn, decode=True)
self.assertEqual(code, ErrorCodes.TID_NOT_FOUND)
def test_15_handleAskObjectPresent(self):
def test_15_askObjectPresent(self):
# client connection with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False})
packet = Packet(msg_type=PacketTypes.ASK_OBJECT_PRESENT)
self.verification.handleAskObjectPresent(conn, packet, p64(1), p64(2))
self.verification.askObjectPresent(conn, packet, p64(1), p64(2))
code, message = self.checkErrorPacket(conn, decode=True)
self.assertEqual(code, ErrorCodes.OID_NOT_FOUND)
......@@ -312,34 +312,34 @@ class StorageVerificationHandlerTests(NeoTestBase):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False})
packet = Packet(msg_type=PacketTypes.ASK_OBJECT_PRESENT)
self.verification.handleAskObjectPresent(conn, packet, p64(1), p64(2))
self.verification.askObjectPresent(conn, packet, p64(1), p64(2))
oid, tid = self.checkAnswerObjectPresent(conn, decode=True)
self.assertEqual(u64(tid), 2)
self.assertEqual(u64(oid), 1)
def test_16_handleDeleteTransaction(self):
def test_16_deleteTransaction(self):
# client connection with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False})
packet = Packet(msg_type=PacketTypes.ASK_OBJECT_PRESENT)
self.verification.handleDeleteTransaction(conn, packet, p64(1))
self.verification.deleteTransaction(conn, packet, p64(1))
# client connection with data
self.app.dm.begin()
self.app.dm.query("""insert into tobj (oid, serial, compression,
checksum, value) values (1, 2, 0, 0, '')""")
self.app.dm.commit()
self.verification.handleDeleteTransaction(conn, packet, p64(2))
self.verification.deleteTransaction(conn, packet, p64(2))
result = self.app.dm.query('select * from tobj')
self.assertEquals(len(result), 0)
def test_17_handleCommitTransaction(self):
def test_17_commitTransaction(self):
# commit a transaction
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False })
dm = Mock()
self.app.dm = dm
packet = Packet(msg_type=PacketTypes.COMMIT_TRANSACTION)
self.verification.handleCommitTransaction(conn, packet, p64(1))
self.verification.commitTransaction(conn, packet, p64(1))
self.assertEqual(len(dm.mockGetNamedCalls("finishTransaction")), 1)
call = dm.mockGetNamedCalls("finishTransaction")[0]
tid = call.getParam(0)
......
......@@ -57,7 +57,7 @@ class BootstrapManagerTests(NeoTestBase):
# the primary is not ready
conn = Mock({})
packet = Mock({})
self.bootstrap.handleNotReady(conn, packet, '')
self.bootstrap.notReady(conn, packet, '')
self.checkClosed(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