Commit 7cab0aa8 authored by Vincent Pelletier's avatar 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
parent 8bff0f86
...@@ -186,7 +186,5 @@ class MasterRequestEventHandler(EventHandler): ...@@ -186,7 +186,5 @@ class MasterRequestEventHandler(EventHandler):
# sent client the partition table # sent client the partition table
self.app.sendPartitionTable(client_conn) self.app.sendPartitionTable(client_conn)
answerNewNodes = forward_answer(Packets.AnswerNewNodes)
answerNodeState = forward_answer(Packets.AnswerNodeState)
ack = forward_answer(Errors.Ack) ack = forward_answer(Errors.Ack)
protocolError = forward_answer(Errors.ProtocolError) protocolError = forward_answer(Errors.ProtocolError)
...@@ -297,15 +297,9 @@ class EventHandler(object): ...@@ -297,15 +297,9 @@ class EventHandler(object):
def setNodeState(self, conn, uuid, state, modify_partition_table): def setNodeState(self, conn, uuid, state, modify_partition_table):
raise UnexpectedPacketError raise UnexpectedPacketError
def answerNodeState(self, conn, uuid, state):
raise UnexpectedPacketError
def addPendingNodes(self, conn, uuid_list): def addPendingNodes(self, conn, uuid_list):
raise UnexpectedPacketError raise UnexpectedPacketError
def answerNewNodes(self, conn, uuid_list):
raise UnexpectedPacketError
def askNodeInformation(self, conn): def askNodeInformation(self, conn):
raise UnexpectedPacketError raise UnexpectedPacketError
...@@ -468,10 +462,8 @@ class EventHandler(object): ...@@ -468,10 +462,8 @@ class EventHandler(object):
d[Packets.AskNodeList] = self.askNodeList d[Packets.AskNodeList] = self.askNodeList
d[Packets.AnswerNodeList] = self.answerNodeList d[Packets.AnswerNodeList] = self.answerNodeList
d[Packets.SetNodeState] = self.setNodeState d[Packets.SetNodeState] = self.setNodeState
d[Packets.AnswerNodeState] = self.answerNodeState
d[Packets.SetClusterState] = self.setClusterState d[Packets.SetClusterState] = self.setClusterState
d[Packets.AddPendingNodes] = self.addPendingNodes d[Packets.AddPendingNodes] = self.addPendingNodes
d[Packets.AnswerNewNodes] = self.answerNewNodes
d[Packets.AskNodeInformation] = self.askNodeInformation d[Packets.AskNodeInformation] = self.askNodeInformation
d[Packets.AnswerNodeInformation] = self.answerNodeInformation d[Packets.AnswerNodeInformation] = self.answerNodeInformation
d[Packets.AskClusterState] = self.askClusterState d[Packets.AskClusterState] = self.askClusterState
......
...@@ -63,7 +63,5 @@ class CommandEventHandler(EventHandler): ...@@ -63,7 +63,5 @@ class CommandEventHandler(EventHandler):
answerPartitionList = __answer(Packets.AnswerPartitionList) answerPartitionList = __answer(Packets.AnswerPartitionList)
answerNodeList = __answer(Packets.AnswerNodeList) answerNodeList = __answer(Packets.AnswerNodeList)
answerNodeState = __answer(Packets.AnswerNodeState)
answerClusterState = __answer(Packets.AnswerClusterState) answerClusterState = __answer(Packets.AnswerClusterState)
answerNewNodes = __answer(Packets.AnswerNewNodes)
answerPrimary = __answer(Packets.AnswerPrimary) answerPrimary = __answer(Packets.AnswerPrimary)
...@@ -1358,22 +1358,6 @@ class SetNodeState(Packet): ...@@ -1358,22 +1358,6 @@ class SetNodeState(Packet):
uuid = _decodeUUID(uuid) uuid = _decodeUUID(uuid)
return (uuid, state, modify) 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): class AddPendingNodes(Packet):
""" """
Ask the primary to include some pending node in the partition table Ask the primary to include some pending node in the partition table
...@@ -1400,32 +1384,6 @@ class AddPendingNodes(Packet): ...@@ -1400,32 +1384,6 @@ class AddPendingNodes(Packet):
uuid_list = [_decodeUUID(x) for x in uuid_list] uuid_list = [_decodeUUID(x) for x in uuid_list]
return (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): class NotifyNodeInformation(Packet):
""" """
Notify information about one or more nodes. PM -> Any. Notify information about one or more nodes. PM -> Any.
...@@ -1928,14 +1886,14 @@ class PacketRegistry(dict): ...@@ -1928,14 +1886,14 @@ class PacketRegistry(dict):
0x0022, 0x0022,
AskNodeList, AskNodeList,
AnswerNodeList) AnswerNodeList)
SetNodeState, AnswerNodeState = register( SetNodeState = register(
0x0023, 0x0023,
SetNodeState, SetNodeState,
AnswerNodeState) Error)
AddPendingNodes, AnswerNewNodes = register( AddPendingNodes = register(
0x0024, 0x0024,
AddPendingNodes, AddPendingNodes,
AnswerNewNodes) Error)
AskNodeInformation, AnswerNodeInformation = register( AskNodeInformation, AnswerNodeInformation = register(
0x0025, 0x0025,
AskNodeInformation, AskNodeInformation,
......
...@@ -518,22 +518,11 @@ class ProtocolTests(NeoUnitTestBase): ...@@ -518,22 +518,11 @@ class ProtocolTests(NeoUnitTestBase):
p = Packets.AskNodeInformation() p = Packets.AskNodeInformation()
self.assertEqual(p.decode(), ()) 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): def test_AddPendingNodes(self):
uuid1, uuid2 = self.getNewUUID(), self.getNewUUID() uuid1, uuid2 = self.getNewUUID(), self.getNewUUID()
p = Packets.AddPendingNodes([uuid1, uuid2]) p = Packets.AddPendingNodes([uuid1, uuid2])
self.assertEqual(p.decode(), ([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): def test_SetNodeState(self):
uuid = self.getNewUUID() uuid = self.getNewUUID()
state = NodeStates.PENDING state = NodeStates.PENDING
......
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