Commit 7cab0aa8 by Vincent Pelletier

Remove unused packet definitions.

Those responses are implemented using Error packets.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2418 71dcc9de-d417-0410-9af5-da40c76e7ee4
1 parent 8bff0f86
......@@ -186,7 +186,5 @@ class MasterRequestEventHandler(EventHandler):
# sent client the partition table
self.app.sendPartitionTable(client_conn)
answerNewNodes = forward_answer(Packets.AnswerNewNodes)
answerNodeState = forward_answer(Packets.AnswerNodeState)
ack = forward_answer(Errors.Ack)
protocolError = forward_answer(Errors.ProtocolError)
......@@ -297,15 +297,9 @@ class EventHandler(object):
def setNodeState(self, conn, uuid, state, modify_partition_table):
raise UnexpectedPacketError
def answerNodeState(self, conn, uuid, state):
raise UnexpectedPacketError
def addPendingNodes(self, conn, uuid_list):
raise UnexpectedPacketError
def answerNewNodes(self, conn, uuid_list):
raise UnexpectedPacketError
def askNodeInformation(self, conn):
raise UnexpectedPacketError
......@@ -468,10 +462,8 @@ class EventHandler(object):
d[Packets.AskNodeList] = self.askNodeList
d[Packets.AnswerNodeList] = self.answerNodeList
d[Packets.SetNodeState] = self.setNodeState
d[Packets.AnswerNodeState] = self.answerNodeState
d[Packets.SetClusterState] = self.setClusterState
d[Packets.AddPendingNodes] = self.addPendingNodes
d[Packets.AnswerNewNodes] = self.answerNewNodes
d[Packets.AskNodeInformation] = self.askNodeInformation
d[Packets.AnswerNodeInformation] = self.answerNodeInformation
d[Packets.AskClusterState] = self.askClusterState
......
......@@ -63,7 +63,5 @@ class CommandEventHandler(EventHandler):
answerPartitionList = __answer(Packets.AnswerPartitionList)
answerNodeList = __answer(Packets.AnswerNodeList)
answerNodeState = __answer(Packets.AnswerNodeState)
answerClusterState = __answer(Packets.AnswerClusterState)
answerNewNodes = __answer(Packets.AnswerNewNodes)
answerPrimary = __answer(Packets.AnswerPrimary)
......@@ -1358,22 +1358,6 @@ class SetNodeState(Packet):
uuid = _decodeUUID(uuid)
return (uuid, state, modify)
class AnswerNodeState(Packet):
"""
Answer state of the node
"""
_header_format = '!16sH'
def _encode(self, uuid, state):
uuid = _encodeUUID(uuid)
return ''.join([pack(self._header_format, uuid, state)])
def _decode(self, body):
(uuid, state) = unpack(self._header_format, body)
state = _decodeNodeState(state)
uuid = _decodeUUID(uuid)
return (uuid, state)
class AddPendingNodes(Packet):
"""
Ask the primary to include some pending node in the partition table
......@@ -1400,32 +1384,6 @@ class AddPendingNodes(Packet):
uuid_list = [_decodeUUID(x) for x in uuid_list]
return (uuid_list, )
class AnswerNewNodes(Packet):
"""
Answer what are the nodes added in the partition table
"""
_header_format = '!H'
_list_header_format = '!16s'
_list_header_len = calcsize(_list_header_format)
def _encode(self, uuid_list):
list_header_format = self._list_header_format
# an empty list means no new nodes
uuid_list = [pack(list_header_format, _encodeUUID(uuid)) for \
uuid in uuid_list]
return pack(self._header_format, len(uuid_list)) + ''.join(uuid_list)
def _decode(self, body):
header_len = self._header_len
(n, ) = unpack(self._header_format, body[:header_len])
list_header_format = self._list_header_format
list_header_len = self._list_header_len
uuid_list = [unpack(list_header_format,
body[header_len+i*list_header_len:\
header_len+(i+1)*list_header_len])[0] for i in xrange(n)]
uuid_list = [_decodeUUID(x) for x in uuid_list]
return (uuid_list, )
class NotifyNodeInformation(Packet):
"""
Notify information about one or more nodes. PM -> Any.
......@@ -1928,14 +1886,14 @@ class PacketRegistry(dict):
0x0022,
AskNodeList,
AnswerNodeList)
SetNodeState, AnswerNodeState = register(
SetNodeState = register(
0x0023,
SetNodeState,
AnswerNodeState)
AddPendingNodes, AnswerNewNodes = register(
Error)
AddPendingNodes = register(
0x0024,
AddPendingNodes,
AnswerNewNodes)
Error)
AskNodeInformation, AnswerNodeInformation = register(
0x0025,
AskNodeInformation,
......
......@@ -518,22 +518,11 @@ class ProtocolTests(NeoUnitTestBase):
p = Packets.AskNodeInformation()
self.assertEqual(p.decode(), ())
def test_AnswerNewNodes(self):
uuid1, uuid2 = self.getNewUUID(), self.getNewUUID()
p = Packets.AnswerNewNodes([uuid1, uuid2])
self.assertEqual(p.decode(), ([uuid1, uuid2], ))
def test_AddPendingNodes(self):
uuid1, uuid2 = self.getNewUUID(), self.getNewUUID()
p = Packets.AddPendingNodes([uuid1, uuid2])
self.assertEqual(p.decode(), ([uuid1, uuid2], ))
def test_AnswerNodeState(self):
uuid = self.getNewUUID()
state = NodeStates.RUNNING
p = Packets.AnswerNodeState(uuid, state)
self.assertEqual(p.decode(), (uuid, state))
def test_SetNodeState(self):
uuid = self.getNewUUID()
state = NodeStates.PENDING
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!