Commit 37c75a72 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Remove 'packet' parameter of handler's methods.

Almost any use of packet was to retreive the msg_id of the request and pass it to answer().
In storage's replicator, critical TIDs are indexed with UUID instead of remote connection ID (full replicator review required).
In admin node, expected answers are still queued with the msg_id but it seems useless as no concurrent queries should happen.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1569 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 91ff3fef
......@@ -133,8 +133,6 @@ RC - Review output of pylint (CODE)
an incoming packet that trigger the poll() system call.
- Allow daemonize NEO processes, re-use code from TIDStorage and support
start/stop/restart/status commands.
- Remove 'packet' parameter from handler methods. Set the last_received_id
attribute on the connection and reload it from answer() method.
- Consider don't close the connection after sending a packet but wait (a
bit) for the closure from the remote peer.
- Rename packets:
......
......@@ -141,7 +141,7 @@ class Application(object):
self.master_conn.ask(Packets.AskNodeInformation())
self.master_conn.ask(Packets.AskPartitionTable([]))
def sendPartitionTable(self, conn, min_offset, max_offset, uuid, msg_id):
def sendPartitionTable(self, conn, min_offset, max_offset, uuid):
# we have a pt
self.pt.log()
row_list = []
......@@ -164,4 +164,4 @@ class Application(object):
conn.notify(p)
return
p = Packets.AnswerPartitionList(self.ptid, row_list)
conn.answer(p, msg_id)
conn.answer(p)
......@@ -26,7 +26,7 @@ from neo.util import dump
class AdminEventHandler(EventHandler):
"""This class deals with events for administrating cluster."""
def askPartitionList(self, conn, packet, min_offset, max_offset, uuid):
def askPartitionList(self, conn, 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
......@@ -41,22 +41,21 @@ class AdminEventHandler(EventHandler):
{'min_offset' : min_offset,
'max_offset' : max_offset,
'uuid' : uuid,
'msg_id' : packet.getId()})
'msg_id' : conn.getPeerId()})
else:
app.sendPartitionTable(conn, min_offset, max_offset, uuid,
packet.getId())
app.sendPartitionTable(conn, min_offset, max_offset, uuid)
def askNodeList(self, conn, packet, node_type):
def askNodeList(self, conn, node_type):
logging.info("ask node list for %s" %(node_type))
def node_filter(n):
return n.getType() is node_type
node_list = self.app.nm.getList(node_filter)
node_information_list = [node.asTuple() for node in node_list ]
p = Packets.AnswerNodeList(node_information_list)
conn.answer(p, packet.getId())
conn.answer(p)
def setNodeState(self, conn, packet, uuid, state, modify_partition_table):
def setNodeState(self, conn, 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:
......@@ -64,32 +63,32 @@ class AdminEventHandler(EventHandler):
if node.getState() == state and modify_partition_table is False:
# no change
p = protocol.ack('no change')
conn.answer(p, packet.getId())
conn.answer(p)
return
# forward to primary master node
if self.app.master_conn is None:
raise protocol.NotReadyError('Not connected to a primary master.')
p = Packets.SetNodeState(uuid, state, modify_partition_table)
msg_id = self.app.master_conn.ask(p)
self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()})
self.app.dispatcher.register(msg_id, conn, {'msg_id' : conn.getPeerId()})
def setClusterState(self, conn, packet, state):
def setClusterState(self, conn, state):
# forward to primary
if self.app.master_conn is None:
raise protocol.NotReadyError('Not connected to a primary master.')
p = Packets.SetClusterState(state)
msg_id = self.app.master_conn.ask(p)
self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()})
self.app.dispatcher.register(msg_id, conn, {'msg_id' : conn.getPeerId()})
def addPendingNodes(self, conn, packet, uuid_list):
def addPendingNodes(self, conn, 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])
# forward the request to primary
msg_id = self.app.master_conn.ask(Packets.AddPendingNodes(uuid_list))
self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()})
self.app.dispatcher.register(msg_id, conn, {'msg_id' : conn.getPeerId()})
def askClusterState(self, conn, packet):
def askClusterState(self, conn):
if self.app.cluster_state is None:
if self.app.master_conn is None:
raise protocol.NotReadyError('Not connected to a primary ' \
......@@ -97,17 +96,15 @@ class AdminEventHandler(EventHandler):
# required it from PMN first
msg_id = self.app.master_conn.ask(Packets.AskClusterState())
self.app.dispatcher.register(msg_id, conn,
{'msg_id' : packet.getId()})
{'msg_id' : conn.getPeerId()})
else:
conn.answer(Packets.AnswerClusterState(self.app.cluster_state),
packet.getId())
conn.answer(Packets.AnswerClusterState(self.app.cluster_state))
def askPrimary(self, conn, packet):
def askPrimary(self, conn):
if self.app.master_conn is None:
raise protocol.NotReadyError('Not connected to a primary master.')
master_node = self.app.master_node
conn.answer(Packets.AnswerPrimary(master_node.getUUID(), []),
packet.getId())
conn.answer(Packets.AnswerPrimary(master_node.getUUID(), []))
class MasterEventHandler(EventHandler):
""" This class is just used to dispacth message to right handler"""
......@@ -141,17 +138,17 @@ class MasterEventHandler(EventHandler):
# unexpectexd answers and notifications
super(MasterEventHandler, self).dispatch(conn, packet)
def answerNodeInformation(self, conn, packet):
def answerNodeInformation(self, conn):
# XXX: This will no more exists when the initialization module will be
# implemented for factorize code (as done for bootstrap)
logging.debug("answerNodeInformation")
def answerPartitionTable(self, conn, packet, ptid, row_list):
def answerPartitionTable(self, conn, 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("answerPartitionTable")
def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
def notifyPartitionChanges(self, conn, ptid, cell_list):
app = self.app
if ptid < app.ptid:
# Ignore this packet.
......@@ -159,7 +156,7 @@ class MasterEventHandler(EventHandler):
app.ptid = ptid
app.pt.update(ptid, cell_list, app.nm)
def sendPartitionTable(self, conn, packet, ptid, row_list):
def sendPartitionTable(self, conn, ptid, row_list):
uuid = conn.getUUID()
app = self.app
nm = app.nm
......@@ -176,10 +173,10 @@ class MasterEventHandler(EventHandler):
pt.setCell(offset, node, state)
pt.log()
def notifyClusterInformation(self, conn, packet, cluster_state):
def notifyClusterInformation(self, conn, cluster_state):
self.app.cluster_state = cluster_state
def notifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, node_list):
app = self.app
app.nm.update(node_list)
if not app.pt.filled():
......@@ -191,34 +188,33 @@ class MasterEventHandler(EventHandler):
class MasterRequestEventHandler(EventHandler):
""" This class handle all answer from primary master node"""
def __answerNeoCTL(self, msg_id, packet):
def __answerNeoCTL(self, conn, packet):
msg_id = conn.getPeerId()
client_conn, kw = self.app.dispatcher.pop(msg_id)
client_conn.answer(packet, kw['msg_id'])
client_conn.answer(packet)
def answerClusterState(self, conn, packet, state):
def answerClusterState(self, conn, state):
logging.info("answerClusterState for a conn")
self.app.cluster_state = state
self.__answerNeoCTL(packet.getId(),
Packets.AnswerClusterState(state))
self.__answerNeoCTL(conn, Packets.AnswerClusterState(state))
def answerNewNodes(self, conn, packet, uuid_list):
def answerNewNodes(self, conn, uuid_list):
logging.info("answerNewNodes for a conn")
self.__answerNeoCTL(packet.getId(),
Packets.AnswerNewNodes(uuid_list))
self.__answerNeoCTL(conn, Packets.AnswerNewNodes(uuid_list))
def answerPartitionTable(self, conn, packet, ptid, row_list):
def answerPartitionTable(self, conn, ptid, row_list):
logging.info("answerPartitionTable for a conn")
client_conn, kw = self.app.dispatcher.pop(packet.getId())
client_conn, kw = self.app.dispatcher.pop(conn.getPeerId())
# sent client the partition table
self.app.sendPartitionTable(client_conn, **kw)
self.app.sendPartitionTable(client_conn)
def answerNodeState(self, conn, packet, uuid, state):
self.__answerNeoCTL(packet.getId(),
def answerNodeState(self, conn, uuid, state):
self.__answerNeoCTL(conn,
Packets.AnswerNodeState(uuid, state))
def ack(self, conn, packet, msg):
self.__answerNeoCTL(packet.getId(), protocol.ack(msg))
def ack(self, conn, msg):
self.__answerNeoCTL(conn, protocol.ack(msg))
def protocolError(self, conn, packet, msg):
self.__answerNeoCTL(packet.getId(), protocol.protocolError(msg))
def protocolError(self, conn, msg):
self.__answerNeoCTL(conn, protocol.protocolError(msg))
......@@ -69,7 +69,7 @@ class BootstrapManager(EventHandler):
"""
self.current = None
def notReady(self, conn, packet, message):
def notReady(self, conn, message):
"""
The primary master send this message when it is still not ready to
handle the client node.
......@@ -79,7 +79,7 @@ class BootstrapManager(EventHandler):
self.current = None
conn.close()
def answerPrimary(self, conn, packet, primary_uuid, known_master_list):
def answerPrimary(self, conn, primary_uuid, known_master_list):
"""
A master answer who's the primary. If it's another node, connect to it.
If it's itself then the primary is successfully found, ask
......@@ -108,7 +108,7 @@ class BootstrapManager(EventHandler):
conn.ask(Packets.RequestIdentification(self.node_type,
self.uuid, self.server, self.name))
def acceptIdentification(self, conn, packet, node_type,
def acceptIdentification(self, conn, node_type,
uuid, num_partitions, num_replicas, your_uuid):
"""
The primary master has accepted the node.
......
......@@ -25,12 +25,12 @@ from neo.util import dump
class PrimaryBootstrapHandler(AnswerBaseHandler):
""" Bootstrap handler used when looking for the primary master """
def notReady(self, conn, packet, message):
def notReady(self, conn, message):
app = self.app
app.trying_master_node = None
app.setNodeNotReady()
def acceptIdentification(self, conn, packet, node_type,
def acceptIdentification(self, conn, node_type,
uuid, num_partitions, num_replicas, your_uuid):
app = self.app
node = app.nm.getByAddress(conn.getAddress())
......@@ -49,7 +49,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
# Always create partition table
app.pt = PartitionTable(num_partitions, num_replicas)
def answerPrimary(self, conn, packet, primary_uuid,
def answerPrimary(self, conn, primary_uuid,
known_master_list):
app = self.app
# Register new master nodes.
......@@ -81,10 +81,10 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
app.trying_master_node = None
conn.close()
def answerPartitionTable(self, conn, packet, ptid, row_list):
def answerPartitionTable(self, conn, ptid, row_list):
pass
def answerNodeInformation(self, conn, packet):
def answerNodeInformation(self, conn):
pass
class PrimaryNotificationsHandler(BaseHandler):
......@@ -117,10 +117,10 @@ class PrimaryNotificationsHandler(BaseHandler):
logging.critical("primary master node is broken")
BaseHandler.peerBroken(self, conn)
def stopOperation(self, conn, packet):
def stopOperation(self, conn):
logging.critical("master node ask to stop operation")
def invalidateObjects(self, conn, packet, oid_list, tid):
def invalidateObjects(self, conn, oid_list, tid):
app = self.app
app._cache_lock_acquire()
try:
......@@ -142,15 +142,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 notifyPartitionChanges(self, conn, packet, ptid, cell_list):
def notifyPartitionChanges(self, conn, ptid, cell_list):
pt = self.app.pt
if pt.filled():
pt.update(ptid, cell_list, self.app.nm)
def sendPartitionTable(self, conn, packet, ptid, row_list):
def sendPartitionTable(self, conn, ptid, row_list):
self.app.pt.load(ptid, row_list, self.app.nm)
def notifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, node_list):
app = self.app
self.app.nm.update(node_list)
for node_type, addr, uuid, state in node_list:
......@@ -169,16 +169,16 @@ class PrimaryNotificationsHandler(BaseHandler):
class PrimaryAnswersHandler(AnswerBaseHandler):
""" Handle that process expected packets from the primary master """
def answerBeginTransaction(self, conn, packet, tid):
def answerBeginTransaction(self, conn, tid):
app = self.app
app.setTID(tid)
def answerNewOIDs(self, conn, packet, oid_list):
def answerNewOIDs(self, conn, oid_list):
app = self.app
app.new_oid_list = oid_list
app.new_oid_list.reverse()
def answerTransactionFinished(self, conn, packet, tid):
def answerTransactionFinished(self, conn, 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 notReady(self, conn, packet, message):
def notReady(self, conn, message):
app = self.app
app.setNodeNotReady()
def acceptIdentification(self, conn, packet, node_type,
def acceptIdentification(self, conn, node_type,
uuid, num_partitions, num_replicas, your_uuid):
app = self.app
node = app.nm.getByAddress(conn.getAddress())
......@@ -67,24 +67,24 @@ class StorageBootstrapHandler(AnswerBaseHandler):
class StorageAnswersHandler(AnswerBaseHandler):
""" Handle all messages related to ZODB operations """
def answerObject(self, conn, packet, oid, start_serial, end_serial,
def answerObject(self, conn, 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 answerStoreObject(self, conn, packet, conflicting, oid, serial):
def answerStoreObject(self, conn, conflicting, oid, serial):
app = self.app
if conflicting:
app.local_var.object_stored = -1, serial
else:
app.local_var.object_stored = oid, serial
def answerStoreTransaction(self, conn, packet, tid):
def answerStoreTransaction(self, conn, tid):
app = self.app
app.setTransactionVoted()
def answerTransactionInformation(self, conn, packet, tid,
def answerTransactionInformation(self, conn, tid,
user, desc, ext, oid_list):
app = self.app
# transaction information are returned as a dict
......@@ -96,12 +96,12 @@ class StorageAnswersHandler(AnswerBaseHandler):
info['oids'] = oid_list
app.local_var.txn_info = info
def answerObjectHistory(self, conn, packet, oid, history_list):
def answerObjectHistory(self, conn, oid, history_list):
app = self.app
# history_list is a list of tuple (serial, size)
app.local_var.history = oid, history_list
def oidNotFound(self, conn, packet, message):
def oidNotFound(self, conn, message):
app = self.app
# This can happen either when :
# - loading an object
......@@ -109,12 +109,12 @@ class StorageAnswersHandler(AnswerBaseHandler):
app.local_var.asked_object = -1
app.local_var.history = -1
def tidNotFound(self, conn, packet, message):
def tidNotFound(self, conn, message):
app = self.app
# This can happen when requiring txn informations
app.local_var.txn_info = -1
def answerTIDs(self, conn, packet, tid_list):
def answerTIDs(self, conn, tid_list):
app = self.app
app.local_var.node_tids[conn.getUUID()] = tid_list
......@@ -41,7 +41,7 @@ class EventHandler(object):
packet.getType(), *args)
response = protocol.protocolError(message)
if packet is not None:
conn.answer(response, packet.getId())
conn.answer(response)
else:
conn.notify(response)
conn.abort()
......@@ -56,7 +56,7 @@ class EventHandler(object):
message = 'unexpected packet: %s in %s' % (message,
self.__class__.__name__)
logging.error(message)
conn.answer(protocol.protocolError(message), packet.getId())
conn.answer(protocol.protocolError(message))
conn.abort()
self.peerBroken(conn)
......@@ -69,24 +69,23 @@ class EventHandler(object):
raise UnexpectedPacketError('no handler found')
args = packet.decode() or ()
conn.setPeerId(packet.getId())
method(conn, packet, *args)
method(conn, *args)
except UnexpectedPacketError, e:
self.__unexpectedPacket(conn, packet, *e.args)
except PacketMalformedError, e:
self._packetMalformed(conn, packet, *e.args)
except BrokenNodeDisallowedError:
answer_packet = protocol.brokenNodeDisallowedError('go away')
conn.answer(answer_packet, packet.getId())
conn.answer(protocol.brokenNodeDisallowedError('go away'))
conn.abort()
except NotReadyError, message:
if not message.args:
message = 'Retry Later'
message = str(message)
conn.answer(protocol.notReady(message), packet.getId())
conn.answer(protocol.notReady(message))
conn.abort()
except ProtocolError, message:
message = str(message)
conn.answer(protocol.protocolError(message), packet.getId())
conn.answer(protocol.protocolError(message))
conn.abort()
def checkClusterName(self, name):
......@@ -142,229 +141,229 @@ class EventHandler(object):
# Packet handlers.
def requestIdentification(self, conn, packet, node_type,
def requestIdentification(self, conn, node_type,
uuid, address, name):
raise UnexpectedPacketError
def acceptIdentification(self, conn, packet, node_type,
def acceptIdentification(self, conn, node_type,
uuid, num_partitions, num_replicas, your_uuid):
raise UnexpectedPacketError
def askPrimary(self, conn, packet):
def askPrimary(self, conn):
raise UnexpectedPacketError
def answerPrimary(self, conn, packet, primary_uuid,
def answerPrimary(self, conn, primary_uuid,
known_master_list):
raise UnexpectedPacketError
def announcePrimary(self, conn, packet):
def announcePrimary(self, con):
raise UnexpectedPacketError
def reelectPrimary(self, conn, packet):
def reelectPrimary(self, conn):
raise UnexpectedPacketError
def notifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, node_list):
raise UnexpectedPacketError
def askLastIDs(self, conn, packet):
def askLastIDs(self, conn):
raise UnexpectedPacketError
def answerLastIDs(self, conn, packet, loid, ltid, lptid):
def answerLastIDs(self, conn, loid, ltid, lptid):
raise UnexpectedPacketError
def askPartitionTable(self, conn, packet, offset_list):
def askPartitionTable(self, conn, offset_list):
raise UnexpectedPacketError
def answerPartitionTable(self, conn, packet, ptid, row_list):
def answerPartitionTable(self, conn, ptid, row_list):
raise UnexpectedPacketError
def sendPartitionTable(self, conn, packet, ptid, row_list):
def sendPartitionTable(self, conn, ptid, row_list):
raise UnexpectedPacketError
def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
def notifyPartitionChanges(self, conn, ptid, cell_list):
raise UnexpectedPacketError
def startOperation(self, conn, packet):
def startOperation(self, conn):
raise UnexpectedPacketError
def stopOperation(self, conn, packet):
def stopOperation(self, conn):
raise UnexpectedPacketError
def askUnfinishedTransactions(self, conn, packet):
def askUnfinishedTransactions(self, conn):
raise UnexpectedPacketError
def answerUnfinishedTransactions(self, conn, packet, tid_list):
def answerUnfinishedTransactions(self, conn, tid_list):
raise UnexpectedPacketError
def askObjectPresent(self, conn, packet, oid, tid):
def askObjectPresent(self, conn, oid, tid):
raise UnexpectedPacketError
def answerObjectPresent(self, conn, packet, oid, tid):
def answerObjectPresent(self, conn, oid, tid):
raise UnexpectedPacketError
def deleteTransaction(self, conn, packet, tid):
def deleteTransaction(self, conn, tid):
raise UnexpectedPacketError
def commitTransaction(self, conn, packet, tid):
def commitTransaction(self, conn, tid):
raise UnexpectedPacketError
def askBeginTransaction(self, conn, packet, tid):
def askBeginTransaction(self, conn, tid):
raise UnexpectedPacketError
def answerBeginTransaction(self, conn, packet, tid):
def answerBeginTransaction(self, conn, tid):
raise UnexpectedPacketError
def askNewOIDs(self, conn, packet, num_oids):
def askNewOIDs(self, conn, num_oids):
raise UnexpectedPacketError
def answerNewOIDs(self, conn, packet, num_oids):
def answerNewOIDs(self, conn, num_oids):
raise UnexpectedPacketError
def finishTransaction(self, conn, packet, oid_list, tid):
def finishTransaction(self, conn, oid_list, tid):
raise UnexpectedPacketError
def answerTransactionFinished(self, conn, packet, tid):
def answerTransactionFinished(self, conn, tid):
raise UnexpectedPacketError
def lockInformation(self, conn, packet, tid):
def lockInformation(self, conn, tid):
raise UnexpectedPacketError
def notifyInformationLocked(self, conn, packet, tid):
def notifyInformationLocked(self, conn, tid):
raise UnexpectedPacketError
def invalidateObjects(self, conn, packet, oid_list, tid):
def invalidateObjects(self, conn, oid_list, tid):
raise UnexpectedPacketError
def notifyUnlockInformation(self, conn, packet, tid):
def notifyUnlockInformation(self, conn, tid):
raise UnexpectedPacketError
def askStoreObject(self, conn, packet, oid, serial,
def askStoreObject(self, conn, oid, serial,
compression, checksum, data, tid):
raise UnexpectedPacketError
def answerStoreObject(self, conn, packet, conflicting, oid, serial):
def answerStoreObject(self, conn, conflicting, oid, serial):
raise UnexpectedPacketError
def abortTransaction(self, conn, packet, tid):
def abortTransaction(self, conn, tid):
raise UnexpectedPacketError
def askStoreTransaction(self, conn, packet, tid, user, desc,
def askStoreTransaction(self, conn, tid, user, desc,
ext, oid_list):
raise UnexpectedPacketError
def answerStoreTransaction(self, conn, packet, tid):
def answerStoreTransaction(self, conn, tid):
raise UnexpectedPacketError
def askObject(self, conn, packet, oid, serial, tid):
def askObject(self, conn, oid, serial, tid):
raise UnexpectedPacketError
def answerObject(self, conn, packet, oid, serial_start,
def answerObject(self, conn, oid, serial_start,
serial_end, compression, checksum, data):
raise UnexpectedPacketError
def askTIDs(self, conn, packet, first, last, partition):
def askTIDs(self, conn, first, last, partition):
raise UnexpectedPacketError
def answerTIDs(self, conn, packet, tid_list):
def answerTIDs(self, conn, tid_list):
raise UnexpectedPacketError
def askTransactionInformation(self, conn, packet, tid):
def askTransactionInformation(self, conn, tid):
raise UnexpectedPacketError
def answerTransactionInformation(self, conn, packet, tid,
def answerTransactionInformation(self, conn, tid,
user, desc, ext, oid_list):
raise UnexpectedPacketError
def askObjectHistory(self, conn, packet, oid, first, last):
def askObjectHistory(self, conn, oid, first, last):
raise UnexpectedPacketError
def answerObjectHistory(self, conn, packet, oid, history_list):
def answerObjectHistory(self, conn, oid, history_list):
raise UnexpectedPacketError
def askOIDs(self, conn, packet, first, last, partition):
def askOIDs(self, conn, first, last, partition):
raise UnexpectedPacketError
def answerOIDs(self, conn, packet, oid_list):
def answerOIDs(self, conn, oid_list):
raise UnexpectedPacketError
def askPartitionList(self, conn, packet, min_offset, max_offset, uuid):
def askPartitionList(self, conn, min_offset, max_offset, uuid):
raise UnexpectedPacketError
def answerPartitionList(self, conn, packet, ptid, row_list):
def answerPartitionList(self, conn, ptid, row_list):
raise UnexpectedPacketError
def askNodeList(self, conn, packet, offset_list):
def askNodeList(self, conn, offset_list):
raise UnexpectedPacketError
def answerNodeList(self, conn, packet, node_list):
def answerNodeList(self, conn, node_list):
raise UnexpectedPacketError
def setNodeState(self, conn, packet, uuid, state, modify_partition_table):
def setNodeState(self, conn, uuid, state, modify_partition_table):
raise UnexpectedPacketError
def answerNodeState(self, conn, packet, uuid, state):
def answerNodeState(self, conn, uuid, state):
raise UnexpectedPacketError
def addPendingNodes(self, conn, packet, uuid_list):
def addPendingNodes(self, conn, uuid_list):
raise UnexpectedPacketError
def answerNewNodes(self, conn, packet, uuid_list):
def answerNewNodes(self, conn, uuid_list):
raise UnexpectedPacketError
def askNodeInformation(self, conn, packet):
def askNodeInformation(self, conn):
raise UnexpectedPacketError
def answerNodeInformation(self, conn, packet):
def answerNodeInformation(self, conn):
raise UnexpectedPacketError
def askClusterState(self, conn, packet):
def askClusterState(self, conn):
raise UnexpectedPacketError
def answerClusterState(self, conn, packet, state):
def answerClusterState(self, conn, state):
raise UnexpectedPacketError
def setClusterState(self, conn, packet, state):
def setClusterState(self, conn, state):
raise UnexpectedPacketError
def notifyClusterInformation(self, conn, packet, state):
def notifyClusterInformation(self, conn, state):
raise UnexpectedPacketError
def notifyLastOID(self, conn, packet, oid):
def notifyLastOID(self, conn, oid):
raise UnexpectedPacketError
def notifyReplicationDone(self, conn, packet, offset):
def notifyReplicationDone(self, conn, offset):
raise UnexpectedPacketError
# Error packet handlers.
def error(self, conn, packet, code, message):
def error(self, conn, code, message):
try:
method = self.error_dispatch_table[code]
method(conn, packet, message)
method(conn, message)
except ValueError:
raise UnexpectedPacketError(message)
def notReady(self, conn, packet, message):
def notReady(self, conn, message):
raise UnexpectedPacketError
def oidNotFound(self, conn, packet, message):
def oidNotFound(self, conn, message):
raise UnexpectedPacketError
def tidNotFound(self, conn, packet, message):
def tidNotFound(self, conn, message):
raise UnexpectedPacketError
def protocolError(self, conn, packet, message):
def protocolError(self, conn, message):
# the connection should have been closed by the remote peer
logging.error('protocol error: %s' % (message,))
def timeoutError(self, conn, packet, message):
def timeoutError(self, conn, message):
logging.error('timeout error: %s' % (message,))
def brokenNodeDisallowedError(self, conn, packet, message):
def brokenNodeDisallowedError(self, conn, message):
raise RuntimeError, 'broken node disallowed error: %s' % (message,)
def ack(self, conn, packet, message):
def ack(self, conn, message):
logging.debug("no error message : %s" % (message))
......
......@@ -44,208 +44,208 @@ class PacketLogger(EventHandler):
except PacketMalformedError:
logging.warning("Can't decode packet for logging")
return
log_message = logger(conn, packet, *args)
log_message = logger(conn, *args)
if log_message is not None:
logging.debug('#0x%08x %s', packet.getId(), log_message)
# Packet loggers
def error(self, conn, packet, code, message):
def error(self, conn, code, message):
return "%s (%s)" % (code, message)
def requestIdentification(self, conn, packet, node_type,
def requestIdentification(self, conn, node_type,
uuid, address, name):
logging.debug('Request identification for cluster %s' % (name, ))
pass
def acceptIdentification(self, conn, packet, node_type,
def acceptIdentification(self, conn, node_type,
uuid, num_partitions, num_replicas, your_uuid):
pass
def askPrimary(self, conn, packet):
def askPrimary(self, conn):
pass
def answerPrimary(self, conn, packet, primary_uuid,
def answerPrimary(self, conn, primary_uuid,
known_master_list):
pass
def announcePrimary(self, conn, packet):
def announcePrimary(self, conn):
pass
def reelectPrimary(self, conn, packet):
def reelectPrimary(self, conn):
pass
def notifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, node_list):
pass
def askLastIDs(self, conn, packet):
def askLastIDs(self, conn):
pass
def answerLastIDs(self, conn, packet, loid, ltid, lptid):
def answerLastIDs(self, conn, loid, ltid, lptid):
pass
def askPartitionTable(self, conn, packet, offset_list):
def askPartitionTable(self, conn, offset_list):
pass
def answerPartitionTable(self, conn, packet, ptid, row_list):
def answerPartitionTable(self, conn, ptid, row_list):
pass
def sendPartitionTable(self, conn, packet, ptid, row_list):
def sendPartitionTable(self, conn, ptid, row_list):
pass
def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
def notifyPartitionChanges(self, conn, ptid, cell_list):
pass
def startOperation(self, conn, packet):
def startOperation(self, conn):
pass
def stopOperation(self, conn, packet):
def stopOperation(self, conn):
pass
def askUnfinishedTransactions(self, conn, packet):
def askUnfinishedTransactions(self, conn):
pass
def answerUnfinishedTransactions(self, conn, packet, tid_list):
def answerUnfinishedTransactions(self, conn, tid_list):
pass
def askObjectPresent(self, conn, packet, oid, tid):
def askObjectPresent(self, conn, oid, tid):
pass
def answerObjectPresent(self, conn, packet, oid, tid):
def answerObjectPresent(self, conn, oid, tid):
pass
def deleteTransaction(self, conn, packet, tid):
def deleteTransaction(self, conn, tid):
pass
def commitTransaction(self, conn, packet, tid):
def commitTransaction(self, conn, tid):
pass
def askBeginTransaction(self, conn, packet, tid):
def askBeginTransaction(self, conn, tid):
pass
def answerBeginTransaction(self, conn, packet, tid):
def answerBeginTransaction(self, conn, tid):
pass
def askNewOIDs(self, conn, packet, num_oids):
def askNewOIDs(self, conn, num_oids):
pass
def answerNewOIDs(self, conn, packet, num_oids):
def answerNewOIDs(self, conn, num_oids):
pass
def finishTransaction(self, conn, packet, oid_list, tid):
def finishTransaction(self, conn, oid_list, tid):
pass
def answerTransactionFinished(self, conn, packet, tid):
def answerTransactionFinished(self, conn, tid):
pass
def lockInformation(self, conn, packet, tid):
def lockInformation(self, conn, tid):
pass
def notifyInformationLocked(self, conn, packet, tid):
def notifyInformationLocked(self, conn, tid):
pass
def invalidateObjects(self, conn, packet, oid_list, tid):
def invalidateObjects(self, conn, oid_list, tid):
pass
def notifyUnlockInformation(self, conn, packet, tid):
def notifyUnlockInformation(self, conn, tid):
pass
def askStoreObject(self, conn, packet, oid, serial,
def askStoreObject(self, conn, oid, serial,
compression, checksum, data, tid):
pass
def answerStoreObject(self, conn, packet, conflicting, oid, serial):
def answerStoreObject(self, conn, conflicting, oid, serial):
pass
def abortTransaction(self, conn, packet, tid):
def abortTransaction(self, conn, tid):
pass
def askStoreTransaction(self, conn, packet, tid, user, desc,
def askStoreTransaction(self, conn, tid, user, desc,
ext, oid_list):
pass
def answerStoreTransaction(self, conn, packet, tid):
def answerStoreTransaction(self, conn, tid):
pass
def askObject(self, conn, packet, oid, serial, tid):
def askObject(self, conn, oid, serial, tid):
pass
def answerObject(self, conn, packet, oid, serial_start,
def answerObject(self, conn, oid, serial_start,
serial_end, compression, checksum, data):
pass
def askTIDs(self, conn, packet, first, last, partition):
def askTIDs(self, conn, first, last, partition):
pass
def answerTIDs(self, conn, packet, tid_list):
def answerTIDs(self, conn, tid_list):
pass
def askTransactionInformation(self, conn, packet, tid):
def askTransactionInformation(self, conn, tid):
pass
def answerTransactionInformation(self, conn, packet, tid,
def answerTransactionInformation(self, conn, tid,
user, desc, ext, oid_list):
pass
def askObjectHistory(self, conn, packet, oid, first, last):
def askObjectHistory(self, conn, oid, first, last):
pass
def answerObjectHistory(self, conn, packet, oid, history_list):
def answerObjectHistory(self, conn, oid, history_list):
pass
def askOIDs(self, conn, packet, first, last, partition):
def askOIDs(self, conn, first, last, partition):
pass
def answerOIDs(self, conn, packet, oid_list):
def answerOIDs(self, conn, oid_list):
pass
def askPartitionList(self, conn, packet, min_offset, max_offset, uuid):
def askPartitionList(self, conn, min_offset, max_offset, uuid):
pass
def answerPartitionList(self, conn, packet, ptid, row_list):
def answerPartitionList(self, conn, ptid, row_list):
pass
def askNodeList(self, conn, packet, offset_list):
def askNodeList(self, conn, offset_list):
pass
def answerNodeList(self, conn, packet, node_list):
def answerNodeList(self, conn, node_list):
pass
def setNodeState(self, conn, packet, uuid, state, modify_partition_table):
def setNodeState(self, conn, uuid, state, modify_partition_table):
pass
def answerNodeState(self, conn, packet, uuid, state):
def answerNodeState(self, conn, uuid, state):
pass
def addPendingNodes(self, conn, packet, uuid_list):
def addPendingNodes(self, conn, uuid_list):
pass
def answerNewNodes(self, conn, packet, uuid_list):
def answerNewNodes(self, conn, uuid_list):
pass
def askNodeInformation(self, conn, packet):
def askNodeInformation(self, conn):
pass
def answerNodeInformation(self, conn, packet):
def answerNodeInformation(self, conn):
pass
def askClusterState(self, conn, packet):
def askClusterState(self, conn):
pass
def answerClusterState(self, conn, packet, state):
def answerClusterState(self, conn, state):
pass
def setClusterState(self, conn, packet, state):
def setClusterState(self, conn, state):
pass
def notifyClusterInformation(self, conn, packet, state):
def notifyClusterInformation(self, conn, state):
pass
def notifyLastOID(self, conn, packet, oid):
def notifyLastOID(self, conn, oid):
pass
def notifyReplicationDone(self, conn, packet, offset):
def notifyReplicationDone(self, conn, offset):
pass
......
......@@ -23,10 +23,10 @@ from neo.protocol import NodeTypes, NodeStates, Packets
class MasterHandler(EventHandler):
"""This class implements a generic part of the event handlers."""
def protocolError(self, conn, packet, message):
def protocolError(self, conn, message):
logging.error('Protocol error %s %s' % (message, conn.getAddress()))
def askPrimary(self, conn, packet):
def askPrimary(self, conn):
if conn.getConnector() is None:
# Connection can be closed by peer after he sent AskPrimary
# if he finds the primary master before we answer him.
......@@ -50,24 +50,22 @@ class MasterHandler(EventHandler):
conn.answer(Packets.AnswerPrimary(
primary_uuid,
known_master_list),
packet.getId(),
)
def askClusterState(self, conn, packet):
def askClusterState(self, conn):
assert conn.getUUID() is not None
state = self.app.getClusterState()
conn.answer(Packets.AnswerClusterState(state), packet.getId())
conn.answer(Packets.AnswerClusterState(state))
def askNodeInformation(self, conn, packet):
def askNodeInformation(self, conn):
self.app.sendNodesInformations(conn)
conn.answer(Packets.AnswerNodeInformation(), packet.getId())
conn.answer(Packets.AnswerNodeInformation())
def askPartitionTable(self, conn, packet, offset_list):
def askPartitionTable(self, conn, offset_list):
assert len(offset_list) == 0
app = self.app
app.sendPartitionTable(conn)
conn.answer(Packets.AnswerPartitionTable(app.pt.getID(), []),
packet.getId())
conn.answer(Packets.AnswerPartitionTable(app.pt.getID(), []))
DISCONNECTED_STATE_DICT = {
......
......@@ -29,20 +29,20 @@ class AdministrationHandler(MasterHandler):
node = self.app.nm.getByUUID(conn.getUUID())
self.app.nm.remove(node)
def askPrimary(self, conn, packet):
def askPrimary(self, conn):
app = self.app
# I'm the primary
conn.answer(Packets.AnswerPrimary(app.uuid, []), packet.getId())
conn.answer(Packets.AnswerPrimary(app.uuid, []))
def setClusterState(self, conn, packet, state):
def setClusterState(self, conn, state):
self.app.changeClusterState(state)
p = protocol.ack('cluster state changed')
conn.answer(p, packet.getId())
conn.answer(p)
if state == ClusterStates.STOPPING:
self.app.cluster_state = state
self.app.shutdown()
def setNodeState(self, conn, packet, uuid, state, modify_partition_table):
def setNodeState(self, conn, uuid, state, modify_partition_table):
logging.info("set node state for %s-%s : %s" %
(dump(uuid), state, modify_partition_table))
app = self.app
......@@ -55,13 +55,13 @@ class AdministrationHandler(MasterHandler):
# get message for self
if state != NodeStates.RUNNING:
p = protocol.ack('node state changed')
conn.answer(p, packet.getId())
conn.answer(p)
app.shutdown()
if node.getState() == state:
# no change, just notify admin node
p = protocol.ack('node state changed')
conn.answer(p, packet.getId())
conn.answer(p)
return
if state == NodeStates.RUNNING:
......@@ -88,10 +88,10 @@ class AdministrationHandler(MasterHandler):
# /!\ send the node information *after* the partition table change
node.setState(state)
p = protocol.ack('state changed')
conn.answer(p, packet.getId())
conn.answer(p)
app.broadcastNodesInformation([node])
def addPendingNodes(self, conn, packet, uuid_list):
def addPendingNodes(self, conn, 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
......@@ -108,7 +108,7 @@ class AdministrationHandler(MasterHandler):
if not uuid_set:
logging.warning('No nodes added')
p = protocol.ack('no nodes added')
conn.answer(p, packet.getId())
conn.answer(p)
return
uuids = ', '.join([dump(uuid) for uuid in uuid_set])
logging.info('Adding nodes %s' % uuids)
......@@ -127,4 +127,4 @@ class AdministrationHandler(MasterHandler):
# broadcast the new partition table
app.broadcastPartitionChanges(cell_list)
p = protocol.ack('node added')
conn.answer(p, packet.getId())
conn.answer(p)
......@@ -33,22 +33,22 @@ class ClientServiceHandler(BaseServiceHandler):
self.app.tm.abortFor(node)
self.app.nm.remove(node)
def abortTransaction(self, conn, packet, tid):
def abortTransaction(self, conn, tid):
if tid in self.app.tm:
self.app.tm.remove(tid)
else:
logging.warn('aborting transaction %s does not exist', dump(tid))
def askBeginTransaction(self, conn, packet, tid):
def askBeginTransaction(self, conn, tid):
node = self.app.nm.getByUUID(conn.getUUID())
tid = self.app.tm.begin(node, tid)
conn.answer(Packets.AnswerBeginTransaction(tid), packet.getId())
conn.answer(Packets.AnswerBeginTransaction(tid))
def askNewOIDs(self, conn, packet, num_oids):
def askNewOIDs(self, conn, num_oids):
oid_list = self.app.getNewOIDList(num_oids)
conn.answer(Packets.AnswerNewOIDs(oid_list), packet.getId())
conn.answer(Packets.AnswerNewOIDs(oid_list))
def finishTransaction(self, conn, packet, oid_list, tid):
def finishTransaction(self, conn, oid_list, tid):
app = self.app
# If the given transaction ID is later than the last TID, the peer
# is crazy.
......@@ -76,5 +76,5 @@ class ClientServiceHandler(BaseServiceHandler):
c.ask(Packets.LockInformation(tid), timeout=60)
used_uuid_set.add(c.getUUID())
app.tm.prepare(tid, oid_list, used_uuid_set, packet.getId())
app.tm.prepare(tid, oid_list, used_uuid_set, conn.getPeerId())
......@@ -25,7 +25,7 @@ from neo.exception import ElectionFailure
class ElectionHandler(MasterHandler):
"""This class deals with events for a primary master election."""
def notifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, node_list):
uuid = conn.getUUID()
if uuid is None:
raise protocol.ProtocolError('Not identified')
......@@ -66,7 +66,7 @@ class ClientElectionHandler(ElectionHandler):
# FIXME: this packet is not allowed here, but handled in MasterHandler
# a global handler review is required.
def askPrimary(self, conn, packet):
def askPrimary(self, conn):
from neo.protocol import UnexpectedPacketError
raise UnexpectedPacketError, "askPrimary on server connection"
......@@ -124,7 +124,7 @@ class ClientElectionHandler(ElectionHandler):
self.app.negotiating_master_node_set.discard(addr)
MasterHandler.peerBroken(self, conn)
def acceptIdentification(self, conn, packet, node_type,
def acceptIdentification(self, conn, node_type,
uuid, num_partitions, num_replicas, your_uuid):
app = self.app
node = app.nm.getByAddress(conn.getAddress())
......@@ -150,7 +150,7 @@ class ClientElectionHandler(ElectionHandler):
app.negotiating_master_node_set.discard(conn.getAddress())
def answerPrimary(self, conn, packet, primary_uuid, known_master_list):
def answerPrimary(self, conn, primary_uuid, known_master_list):
if conn.getConnector() is None:
# Connection can be closed by peer after he sent
# AnswerPrimary if he finds the primary master before we
......@@ -207,7 +207,7 @@ class ClientElectionHandler(ElectionHandler):
class ServerElectionHandler(ElectionHandler):
def reelectPrimary(self, conn, packet):
def reelectPrimary(self, conn):
raise ElectionFailure, 'reelection requested'
def peerBroken(self, conn):
......@@ -218,7 +218,7 @@ class ServerElectionHandler(ElectionHandler):
node.setBroken()
MasterHandler.peerBroken(self, conn)
def requestIdentification(self, conn, packet, node_type,
def requestIdentification(self, conn, node_type,
uuid, address, name):
if conn.getConnector() is None:
# Connection can be closed by peer after he sent
......@@ -256,9 +256,9 @@ class ServerElectionHandler(ElectionHandler):
app.pt.getReplicas(),
uuid
)
conn.answer(p, packet.getId())
conn.answer(p)
def announcePrimary(self, conn, packet):
def announcePrimary(self, conn):
uuid = conn.getUUID()
if uuid is None:
raise protocol.ProtocolError('Not identified')
......
......@@ -27,7 +27,7 @@ class IdentificationHandler(MasterHandler):
def nodeLost(self, conn, node):
logging.warning('lost a node in IdentificationHandler : %s' % node)
def requestIdentification(self, conn, packet, node_type,
def requestIdentification(self, conn, node_type,
uuid, address, name):
self.checkClusterName(name)
......@@ -77,7 +77,7 @@ class IdentificationHandler(MasterHandler):
# answer
args = (NodeTypes.MASTER, app.uuid, app.pt.getPartitions(),
app.pt.getReplicas(), uuid)
conn.answer(Packets.AcceptIdentification(*args), packet.getId())
conn.answer(Packets.AcceptIdentification(*args))
# trigger the event
handler.connectionCompleted(conn)
app.broadcastNodesInformation([node])
......
......@@ -35,7 +35,7 @@ class RecoveryHandler(MasterHandler):
# ask the last IDs to perform the recovery
conn.ask(Packets.AskLastIDs())
def answerLastIDs(self, conn, packet, loid, ltid, lptid):
def answerLastIDs(self, conn, loid, ltid, lptid):
app = self.app
pt = app.pt
......@@ -48,7 +48,7 @@ class RecoveryHandler(MasterHandler):
app.pt.setID(lptid)
conn.ask(Packets.AskPartitionTable([]))
def answerPartitionTable(self, conn, packet, ptid, row_list):
def answerPartitionTable(self, conn, 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 announcePrimary(self, conn, packet):
def announcePrimary(self, conn):
raise ElectionFailure, 'another primary arises'
def reelectPrimary(self, conn, packet):
def reelectPrimary(self, conn):
raise ElectionFailure, 'reelection requested'
def notifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, node_list):
logging.error('/!\ NotifyNodeInformation packet from secondary master')
......@@ -58,10 +58,10 @@ class PrimaryHandler(MasterHandler):
self.app.primary_master_node.setDown()
raise PrimaryFailure, 'primary master is dead'
def reelectPrimary(self, conn, packet):
def reelectPrimary(self, conn):
raise ElectionFailure, 'reelection requested'
def notifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, node_list):
app = self.app
for node_type, addr, uuid, state in node_list:
if node_type != NodeTypes.MASTER:
......@@ -83,7 +83,7 @@ class PrimaryHandler(MasterHandler):
if n.getUUID() is None:
n.setUUID(uuid)
def acceptIdentification(self, conn, packet, node_type,
def acceptIdentification(self, conn, node_type,
uuid, num_partitions,
num_replicas, your_uuid):
app = self.app
......@@ -97,8 +97,8 @@ class PrimaryHandler(MasterHandler):
conn.setUUID(uuid)
node.setUUID(uuid)
def answerPrimary(self, conn, packet, primary_uuid, known_master_list):
def answerPrimary(self, conn, primary_uuid, known_master_list):
pass
def notifyClusterInformation(self, conn, packet, state):
def notifyClusterInformation(self, conn, 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 requestIdentification(self, conn, packet, node_type,
def requestIdentification(self, conn, node_type,
uuid, address, name):
logging.error('reject any new connection')
raise protocol.ProtocolError('cluster is shutting down')
def askPrimary(self, conn, packet):
def askPrimary(self, conn):
logging.error('reject any new demand for primary master')
raise protocol.ProtocolError('cluster is shutting down')
def askBeginTransaction(self, conn, packet, tid):
def askBeginTransaction(self, conn, tid):
logging.error('reject any new demand for new tid')
raise protocol.ProtocolError('cluster is shutting down')
def notifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, node_list):
# don't care about notifications since we are shutdowning
pass
......@@ -41,16 +41,16 @@ class StorageServiceHandler(BaseServiceHandler):
# partition must not oudated to allows a cluster restart.
self.app.outdateAndBroadcastPartition()
def askLastIDs(self, conn, packet):
def askLastIDs(self, conn):
app = self.app
conn.answer(Packets.AnswerLastIDs(app.loid, app.tm.getLastTID(),
app.pt.getID()), packet.getId())
app.pt.getID()))
def askUnfinishedTransactions(self, conn, packet):
def askUnfinishedTransactions(self, conn):
p = Packets.AnswerUnfinishedTransactions(self.app.tm.getPendingList())
conn.answer(p, packet.getId())
conn.answer(p)
def notifyInformationLocked(self, conn, packet, tid):
def notifyInformationLocked(self, conn, tid):
uuid = conn.getUUID()
app = self.app
node = app.nm.getByUUID(uuid)
......@@ -81,7 +81,7 @@ class StorageServiceHandler(BaseServiceHandler):
if node.isClient():
if node is t.getNode():
p = Packets.AnswerTransactionFinished(tid)
c.answer(p, t.getMessageId())
c.answer(p, msg_id=t.getMessageId())
else:
c.notify(Packets.InvalidateObjects(t.getOIDList(), tid))
elif node.isStorage():
......@@ -91,7 +91,7 @@ class StorageServiceHandler(BaseServiceHandler):
# remove transaction from manager
self.app.tm.remove(tid)
def notifyReplicationDone(self, conn, packet, offset):
def notifyReplicationDone(self, conn, offset):
uuid = conn.getUUID()
node = self.app.nm.getByUUID(uuid)
logging.debug("node %s is up for offset %s" % (dump(uuid), offset))
......
......@@ -31,7 +31,7 @@ class VerificationHandler(BaseServiceHandler):
if not self.app.pt.operational():
raise VerificationFailure, 'cannot continue verification'
def answerLastIDs(self, conn, packet, loid, ltid, lptid):
def answerLastIDs(self, conn, loid, ltid, lptid):
app = self.app
# If I get a bigger value here, it is dangerous.
if app.loid < loid or ltid > app.tm.getLastTID() \
......@@ -39,7 +39,7 @@ class VerificationHandler(BaseServiceHandler):
logging.critical('got later information in verification')
raise VerificationFailure
def answerUnfinishedTransactions(self, conn, packet, tid_list):
def answerUnfinishedTransactions(self, conn, tid_list):
uuid = conn.getUUID()
logging.info('got unfinished transactions %s from %s:%d',
tid_list, *(conn.getAddress()))
......@@ -50,7 +50,7 @@ class VerificationHandler(BaseServiceHandler):
app.unfinished_tid_set.update(tid_list)
app.asking_uuid_dict[uuid] = True
def answerTransactionInformation(self, conn, packet, tid,
def answerTransactionInformation(self, conn, tid,
user, desc, ext, oid_list):
uuid = conn.getUUID()
app = self.app
......@@ -68,7 +68,7 @@ class VerificationHandler(BaseServiceHandler):
app.unfinished_oid_set = None
app.asking_uuid_dict[uuid] = True
def tidNotFound(self, conn, packet, message):
def tidNotFound(self, conn, message):
uuid = conn.getUUID()
logging.info('TID not found: %s', message)
app = self.app
......@@ -78,7 +78,7 @@ class VerificationHandler(BaseServiceHandler):
app.unfinished_oid_set = None
app.asking_uuid_dict[uuid] = True
def answerObjectPresent(self, conn, packet, oid, tid):
def answerObjectPresent(self, conn, oid, tid):
uuid = conn.getUUID()
logging.info('object %s:%s found', dump(oid), dump(tid))
app = self.app
......@@ -87,7 +87,7 @@ class VerificationHandler(BaseServiceHandler):
return
app.asking_uuid_dict[uuid] = True
def oidNotFound(self, conn, packet, message):
def oidNotFound(self, conn, message):
uuid = conn.getUUID()
logging.info('OID not found: %s', message)
app = self.app
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo.handler import EventHandler
from neo.protocol import ErrorCodes
from neo.protocol import ErrorCodes, Packets
class CommandEventHandler(EventHandler):
""" Base handler for command """
......@@ -50,18 +50,20 @@ class CommandEventHandler(EventHandler):
super(CommandEventHandler, self).peerBroken(conn)
self.__disconnected()
def __answer(self, conn, packet, *args):
self.__respond((packet.getType(), ) + args)
def ack(self, conn, msg):
self.__respond((Packets.Error, ErrorCodes.ACK, msg))
def ack(self, conn, packet, msg):
self.__respond((packet.getType(), ErrorCodes.ACK, msg))
def notReady(self, conn, msg):
self.__respond((Packets.Error, ErrorCodes.NOT_READY, msg))
def notReady(self, conn, packet, msg):
self.__respond((packet.getType(), ErrorCodes.NOT_READY, msg))
def __answer(packet_type):
def answer(self, conn, *args):
self.__respond((packet_type, ) + args)
return answer
answerPartitionList = __answer
answerNodeList = __answer
answerNodeState = __answer
answerClusterState = __answer
answerNewNodes = __answer
answerPrimary = __answer
answerPartitionList = __answer(Packets.AnswerPartitionList)
answerNodeList = __answer(Packets.AnswerNodeList)
answerNodeState = __answer(Packets.AnswerNodeState)
answerClusterState = __answer(Packets.AnswerClusterState)
answerNewNodes = __answer(Packets.AnswerNewNodes)
answerPrimary = __answer(Packets.AnswerPrimary)
......@@ -33,18 +33,18 @@ class BaseMasterHandler(BaseStorageHandler):
def connectionLost(self, conn, new_state):
raise PrimaryFailure('connection lost')
def reelectPrimary(self, conn, packet):
def reelectPrimary(self, conn):
raise PrimaryFailure('re-election occurs')
def notifyClusterInformation(self, conn, packet, state):
def notifyClusterInformation(self, conn, state):
logging.error('ignoring notify cluster information in %s' %
self.__class__.__name__)
def notifyLastOID(self, conn, packet, oid):
def notifyLastOID(self, conn, oid):
self.app.loid = oid
self.app.dm.setLastOID(oid)
def notifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, node_list):
"""Store information on nodes, only if this is sent by a primary
master node."""
self.app.nm.update(node_list)
......@@ -64,7 +64,7 @@ class BaseMasterHandler(BaseStorageHandler):
class BaseClientAndStorageOperationHandler(BaseStorageHandler):
""" Accept requests common to client and storage nodes """
def askTIDs(self, conn, packet, first, last, partition):
def askTIDs(self, conn, first, last, partition):
# This method is complicated, because I must return TIDs only
# about usable partitions assigned to me.
if first >= last:
......@@ -78,9 +78,9 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler):
tid_list = app.dm.getTIDList(first, last - first,
app.pt.getPartitions(), partition_list)
conn.answer(Packets.AnswerTIDs(tid_list), packet.getId())
conn.answer(Packets.AnswerTIDs(tid_list))
def askObjectHistory(self, conn, packet, oid, first, last):
def askObjectHistory(self, conn, oid, first, last):
if first >= last:
raise protocol.ProtocolError( 'invalid offsets')
......@@ -88,10 +88,9 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler):
history_list = app.dm.getObjectHistory(oid, first, last - first)
if history_list is None:
history_list = []
p = Packets.AnswerObjectHistory(oid, history_list)
conn.answer(p, packet.getId())
conn.answer(Packets.AnswerObjectHistory(oid, history_list))
def askTransactionInformation(self, conn, packet, tid):
def askTransactionInformation(self, conn, tid):
app = self.app
t = app.dm.getTransaction(tid)
if t is None:
......@@ -99,13 +98,13 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler):
else:
p = Packets.AnswerTransactionInformation(tid, t[1], t[2], t[3],
t[0])
conn.answer(p, packet.getId())
conn.answer(p)
def askObject(self, conn, packet, oid, serial, tid):
def askObject(self, conn, oid, serial, tid):
app = self.app
if oid in app.load_lock_dict:
# Delay the response.
app.queueEvent(self.askObject, conn, packet, oid,
app.queueEvent(self.askObject, conn, oid,
serial, tid)
return
o = app.dm.getObject(oid, serial, tid)
......@@ -118,5 +117,5 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler):
else:
logging.debug('oid = %s not found', dump(oid))
p = protocol.oidNotFound('%s does not exist' % dump(oid))
conn.answer(p, packet.getId())
conn.answer(p)
......@@ -85,7 +85,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
def connectionCompleted(self, conn):
BaseClientAndStorageOperationHandler.connectionCompleted(self, conn)
def abortTransaction(self, conn, packet, tid):
def abortTransaction(self, conn, tid):
app = self.app
try:
t = app.transaction_dict[tid]
......@@ -105,7 +105,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
except KeyError:
pass
def askStoreTransaction(self, conn, packet, tid, user, desc,
def askStoreTransaction(self, conn, tid, user, desc,
ext, oid_list):
uuid = conn.getUUID()
app = self.app
......@@ -113,9 +113,9 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
if t.isLastOIDChanged():
self.app.dm.setLastOID(self.app.loid)
t.addTransaction(oid_list, user, desc, ext)
conn.answer(Packets.AnswerStoreTransaction(tid), packet.getId())
conn.answer(Packets.AnswerStoreTransaction(tid))
def askStoreObject(self, conn, packet, oid, serial,
def askStoreObject(self, conn, oid, serial,
compression, checksum, data, tid):
uuid = conn.getUUID()
# First, check for the locking state.
......@@ -124,15 +124,13 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
if locking_tid is not None:
if locking_tid < tid:
# Delay the response.
app.queueEvent(self.askStoreObject, conn, packet,
oid, serial, compression, checksum,
data, tid)
app.queueEvent(self.askStoreObject, conn, oid, serial,
compression, checksum, data, tid)
else:
# If a newer transaction already locks this object,
# do not try to resolve a conflict, so return immediately.
logging.info('unresolvable conflict in %s', dump(oid))
p = Packets.AnswerStoreObject(1, oid, locking_tid)
conn.answer(p, packet.getId())
conn.answer(Packets.AnswerStoreObject(1, oid, locking_tid))
return
# Next, check if this is generated from the latest revision.
......@@ -141,14 +139,12 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
last_serial = history_list[0][0]
if last_serial != serial:
logging.info('resolvable conflict in %s', dump(oid))
p = Packets.AnswerStoreObject(1, oid, last_serial)
conn.answer(p, packet.getId())
conn.answer(Packets.AnswerStoreObject(1, oid, last_serial))
return
# Now store the object.
t = app.transaction_dict.setdefault(tid, TransactionInformation(uuid))
t.addObject(oid, compression, checksum, data)
p = Packets.AnswerStoreObject(0, oid, serial)
conn.answer(p, packet.getId())
conn.answer(Packets.AnswerStoreObject(0, oid, serial))
app.store_lock_dict[oid] = tid
# check if a greater OID last the last generated was used
......
......@@ -27,7 +27,7 @@ class HiddenHandler(BaseMasterHandler):
self.app = app
BaseMasterHandler.__init__(self, app)
def notifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, 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 requestIdentification(self, conn, packet, node_type,
def requestIdentification(self, conn, node_type,
uuid, address, name):
pass
def acceptIdentification(self, conn, packet, node_type,
def acceptIdentification(self, conn, node_type,
uuid, num_partitions, num_replicas, your_uuid):
pass
def answerPrimary(self, conn, packet, primary_uuid,
def answerPrimary(self, conn, primary_uuid,
known_master_list):
pass
def askLastIDs(self, conn, packet):
def askLastIDs(self, conn):
pass
def askPartitionTable(self, conn, packet, offset_list):
def askPartitionTable(self, conn, offset_list):
pass
def sendPartitionTable(self, conn, packet, ptid, row_list):
def sendPartitionTable(self, conn, ptid, row_list):
pass
def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
def notifyPartitionChanges(self, conn, 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 startOperation(self, conn, packet):
def startOperation(self, conn):
self.app.operational = True
def stopOperation(self, conn, packet):
def stopOperation(self, conn):
pass
def askUnfinishedTransactions(self, conn, packet):
def askUnfinishedTransactions(self, conn):
pass
def askTransactionInformation(self, conn, packet, tid):
def askTransactionInformation(self, conn, tid):
pass
def askObjectPresent(self, conn, packet, oid, tid):
def askObjectPresent(self, conn, oid, tid):
pass
def deleteTransaction(self, conn, packet, tid):
def deleteTransaction(self, conn, tid):
pass
def commitTransaction(self, conn, packet, tid):
def commitTransaction(self, conn, tid):
pass
def lockInformation(self, conn, packet, tid):
def lockInformation(self, conn, tid):
pass
def notifyUnlockInformation(self, conn, packet, tid):
def notifyUnlockInformation(self, conn, tid):
pass
def askObject(self, conn, packet, oid, serial, tid):
def askObject(self, conn, oid, serial, tid):
pass
def askTIDs(self, conn, packet, first, last, partition):
def askTIDs(self, conn, first, last, partition):
pass
def askObjectHistory(self, conn, packet, oid, first, last):
def askObjectHistory(self, conn, oid, first, last):
pass
def askStoreTransaction(self, conn, packet, tid, user, desc,
def askStoreTransaction(self, conn, tid, user, desc,
ext, oid_list):
pass
def askStoreObject(self, conn, packet, oid, serial,
def askStoreObject(self, conn, oid, serial,
compression, checksum, data, tid):
pass
def abortTransaction(self, conn, packet, tid):
def abortTransaction(self, conn, tid):
logging.debug('ignoring abort transaction')
def answerLastIDs(self, conn, packet, loid, ltid, lptid):
def answerLastIDs(self, conn, loid, ltid, lptid):
logging.debug('ignoring answer last ids')
def answerUnfinishedTransactions(self, conn, packet, tid_list):
def answerUnfinishedTransactions(self, conn, tid_list):
logging.debug('ignoring answer unfinished transactions')
def askOIDs(self, conn, packet, first, last, partition):
def askOIDs(self, conn, 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 requestIdentification(self, conn, packet, node_type,
def requestIdentification(self, conn, node_type,
uuid, address, name):
self.checkClusterName(name)
# reject any incoming connections if not ready
......@@ -61,6 +61,6 @@ class IdentificationHandler(BaseStorageHandler):
args = (NodeTypes.STORAGE, app.uuid, app.pt.getPartitions(),
app.pt.getReplicas(), uuid)
# accept the identification and trigger an event
conn.answer(Packets.AcceptIdentification(*args), packet.getId())
conn.answer(Packets.AcceptIdentification(*args))
handler.connectionCompleted(conn)
......@@ -22,19 +22,19 @@ from neo import protocol
class InitializationHandler(BaseMasterHandler):
def answerNodeInformation(self, conn, packet):
def answerNodeInformation(self, conn):
self.app.has_node_information = True
def notifyNodeInformation(self, conn, packet, node_list):
def notifyNodeInformation(self, conn, node_list):
# the whole node list is received here
BaseMasterHandler.notifyNodeInformation(self, conn, packet, node_list)
BaseMasterHandler.notifyNodeInformation(self, conn, node_list)
def sendPartitionTable(self, conn, packet, ptid, row_list):
def sendPartitionTable(self, conn, 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 answerPartitionTable(self, conn, packet, ptid, row_list):
def answerPartitionTable(self, conn, ptid, row_list):
app = self.app
pt = app.pt
assert not row_list
......@@ -58,7 +58,7 @@ class InitializationHandler(BaseMasterHandler):
app.dm.setPartitionTable(ptid, cell_list)
self.app.has_partition_table = True
def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
def notifyPartitionChanges(self, conn, 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
......
......@@ -25,16 +25,16 @@ from neo.exception import OperationFailure
class MasterOperationHandler(BaseMasterHandler):
""" This handler is used for the primary master """
def stopOperation(self, conn, packet):
def stopOperation(self, conn):
raise OperationFailure('operation stopped')
def answerLastIDs(self, conn, packet, loid, ltid, lptid):
self.app.replicator.setCriticalTID(packet, ltid)
def answerLastIDs(self, conn, loid, ltid, lptid):
self.app.replicator.setCriticalTID(conn.getUUID(), ltid)
def answerUnfinishedTransactions(self, conn, packet, tid_list):
def answerUnfinishedTransactions(self, conn, tid_list):
self.app.replicator.setUnfinishedTIDList(tid_list)
def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
def notifyPartitionChanges(self, conn, 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
......@@ -56,7 +56,7 @@ class MasterOperationHandler(BaseMasterHandler):
elif state == CellStates.OUT_OF_DATE:
app.replicator.addPartition(offset)
def lockInformation(self, conn, packet, tid):
def lockInformation(self, conn, tid):
app = self.app
try:
t = app.transaction_dict[tid]
......@@ -67,9 +67,9 @@ class MasterOperationHandler(BaseMasterHandler):
app.dm.storeTransaction(tid, object_list, t.getTransaction())
except KeyError:
pass
conn.answer(Packets.NotifyInformationLocked(tid), packet.getId())
conn.answer(Packets.NotifyInformationLocked(tid))
def notifyUnlockInformation(self, conn, packet, tid):
def notifyUnlockInformation(self, conn, 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 acceptIdentification(self, conn, packet, node_type,
def acceptIdentification(self, conn, node_type,
uuid, num_partitions, num_replicas, your_uuid):
# set the UUID on the connection
conn.setUUID(uuid)
def answerTIDs(self, conn, packet, tid_list):
def answerTIDs(self, conn, 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 answerTransactionInformation(self, conn, packet, tid,
def answerTransactionInformation(self, conn, 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 answerOIDs(self, conn, packet, oid_list):
def answerOIDs(self, conn, 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 answerObjectHistory(self, conn, packet, oid, history_list):
def answerObjectHistory(self, conn, 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 answerObject(self, conn, packet, oid, serial_start,
def answerObject(self, conn, oid, serial_start,
serial_end, compression, checksum, data):
app = self.app
if app.replicator.current_connection is not conn:
......
......@@ -21,14 +21,13 @@ from neo.protocol import Packets
class StorageOperationHandler(BaseClientAndStorageOperationHandler):
def askLastIDs(self, conn, packet):
def askLastIDs(self, conn):
app = self.app
oid = app.dm.getLastOID()
tid = app.dm.getLastTID()
p = Packets.AnswerLastIDs(oid, tid, app.pt.getID())
conn.answer(p, packet.getId())
conn.answer(Packets.AnswerLastIDs(oid, tid, app.pt.getID()))
def askOIDs(self, conn, packet, first, last, partition):
def askOIDs(self, conn, first, last, partition):
# This method is complicated, because I must return OIDs only
# about usable partitions assigned to me.
if first >= last:
......@@ -43,5 +42,5 @@ class StorageOperationHandler(BaseClientAndStorageOperationHandler):
oid_list = app.dm.getOIDList(first, last - first,
app.pt.getPartitions(), partition_list)
conn.answer(Packets.AnswerOIDs(oid_list), packet.getId())
conn.answer(Packets.AnswerOIDs(oid_list))
......@@ -26,14 +26,13 @@ from neo.exception import OperationFailure
class VerificationHandler(BaseMasterHandler):
"""This class deals with events for a verification phase."""
def askLastIDs(self, conn, packet):
def askLastIDs(self, conn):
app = self.app
oid = app.dm.getLastOID()
tid = app.dm.getLastTID()
p = Packets.AnswerLastIDs(oid, tid, app.pt.getID())
conn.answer(p, packet.getId())
conn.answer(Packets.AnswerLastIDs(oid, tid, app.pt.getID()))
def askPartitionTable(self, conn, packet, offset_list):
def askPartitionTable(self, conn, offset_list):
app, pt = self.app, self.app.pt
if not offset_list:
# all is requested
......@@ -51,10 +50,9 @@ class VerificationHandler(BaseMasterHandler):
except IndexError:
raise protocol.ProtocolError('invalid partition table offset')
p = Packets.AnswerPartitionTable(app.pt.getID(), row_list)
conn.answer(p, packet.getId())
conn.answer(Packets.AnswerPartitionTable(app.pt.getID(), row_list))
def notifyPartitionChanges(self, conn, packet, ptid, cell_list):
def notifyPartitionChanges(self, conn, 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
......@@ -66,18 +64,17 @@ class VerificationHandler(BaseMasterHandler):
app.pt.update(ptid, cell_list, app.nm)
app.dm.changePartitionTable(ptid, cell_list)
def startOperation(self, conn, packet):
def startOperation(self, conn):
self.app.operational = True
def stopOperation(self, conn, packet):
def stopOperation(self, conn):
raise OperationFailure('operation stopped')
def askUnfinishedTransactions(self, conn, packet):
def askUnfinishedTransactions(self, conn):
tid_list = self.app.dm.getUnfinishedTIDList()
p = Packets.AnswerUnfinishedTransactions(tid_list)
conn.answer(p, packet.getId())
conn.answer(Packets.AnswerUnfinishedTransactions(tid_list))
def askTransactionInformation(self, conn, packet, tid):
def askTransactionInformation(self, conn, tid):
app = self.app
t = app.dm.getTransaction(tid, all=True)
if t is None:
......@@ -85,19 +82,19 @@ class VerificationHandler(BaseMasterHandler):
else:
p = Packets.AnswerTransactionInformation(tid, t[1], t[2], t[3],
t[0])
conn.answer(p, packet.getId())
conn.answer(p)
def askObjectPresent(self, conn, packet, oid, tid):
def askObjectPresent(self, conn, oid, tid):
if self.app.dm.objectPresent(oid, tid):
p = Packets.AnswerObjectPresent(oid, tid)
else:
p = protocol.oidNotFound(
'%s:%s do not exist' % (dump(oid), dump(tid)))
conn.answer(p, packet.getId())
conn.answer(p)
def deleteTransaction(self, conn, packet, tid):
def deleteTransaction(self, conn, tid):
self.app.dm.deleteTransaction(tid, all = True)
def commitTransaction(self, conn, packet, tid):
def commitTransaction(self, conn, tid):
self.app.dm.finishTransaction(tid)
......@@ -113,25 +113,24 @@ class Replicator(object):
"""Return whether there is any pending partition."""
return len(self.partition_dict) or len(self.new_partition_dict)
def setCriticalTID(self, packet, tid):
def setCriticalTID(self, uuid, tid):
"""This is a callback from OperationEventHandler."""
msg_id = packet.getId()
try:
partition_list = self.critical_tid_dict[msg_id]
logging.debug('setting critical TID %s to %s',
dump(tid),
partition_list = self.critical_tid_dict[uuid]
logging.debug('setting critical TID %s to %s', dump(tid),
', '.join([str(p.getRID()) for p in partition_list]))
for partition in self.critical_tid_dict[msg_id]:
for partition in self.critical_tid_dict[uuid]:
partition.setCriticalTID(tid)
del self.critical_tid_dict[msg_id]
del self.critical_tid_dict[uuid]
except KeyError:
logging.debug("setCriticalTID raised KeyError for msg_id %s" %
(msg_id, ))
logging.debug("setCriticalTID raised KeyError for %s" %
(dump(uuid), ))
def _askCriticalTID(self):
conn = self.primary_master_connection
msg_id = conn.ask(Packets.AskLastIDs())
self.critical_tid_dict[msg_id] = self.new_partition_dict.values()
conn.ask(Packets.AskLastIDs())
uuid = conn.getUUID()
self.critical_tid_dict[uuid] = self.new_partition_dict.values()
self.partition_dict.update(self.new_partition_dict)
self.new_partition_dict = {}
......
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