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
This diff is collapsed.
......@@ -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)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -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__':
......
This diff is collapsed.
......@@ -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 ])
......
This diff is collapsed.
......@@ -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)
......
......@@ -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