Commit d3b8533a authored by Grégory Wisniewski's avatar Grégory Wisniewski

Use ProtocolError instead of .

UnexpectedPacketError should not be used for an invalid but expected packet type.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1498 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent b3e10426
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo.handler import EventHandler from neo.handler import EventHandler
from neo.protocol import UnexpectedPacketError from neo.protocol import ProtocolError
class BaseHandler(EventHandler): class BaseHandler(EventHandler):
"""Base class for client-side EventHandler implementations.""" """Base class for client-side EventHandler implementations."""
...@@ -40,7 +40,7 @@ class BaseHandler(EventHandler): ...@@ -40,7 +40,7 @@ class BaseHandler(EventHandler):
if packet.isResponse(): if packet.isResponse():
queue = self.dispatcher.pop(conn, packet.getId(), None) queue = self.dispatcher.pop(conn, packet.getId(), None)
if queue is None: if queue is None:
raise UnexpectedPacketError('Unexpected response packet') raise ProtocolError('Unexpected response packet')
queue.put((conn, packet)) queue.put((conn, packet))
else: else:
self.dispatch(conn, packet) self.dispatch(conn, packet)
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
from neo import logging from neo import logging
from neo.protocol import NodeStates, Packets, UnexpectedPacketError from neo.protocol import NodeStates, Packets, ProtocolError
from neo.master.handlers import BaseServiceHandler from neo.master.handlers import BaseServiceHandler
from neo.util import dump from neo.util import dump
...@@ -53,7 +53,7 @@ class ClientServiceHandler(BaseServiceHandler): ...@@ -53,7 +53,7 @@ class ClientServiceHandler(BaseServiceHandler):
# If the given transaction ID is later than the last TID, the peer # If the given transaction ID is later than the last TID, the peer
# is crazy. # is crazy.
if tid > self.app.tm.getLastTID(): if tid > self.app.tm.getLastTID():
raise UnexpectedPacketError raise ProtocolError('TID too big')
# Collect partitions related to this transaction. # Collect partitions related to this transaction.
getPartition = app.pt.getPartition getPartition = app.pt.getPartition
......
...@@ -28,7 +28,7 @@ class ElectionHandler(MasterHandler): ...@@ -28,7 +28,7 @@ class ElectionHandler(MasterHandler):
def notifyNodeInformation(self, conn, packet, node_list): def notifyNodeInformation(self, conn, packet, node_list):
uuid = conn.getUUID() uuid = conn.getUUID()
if uuid is None: if uuid is None:
raise protocol.UnexpectedPacketError raise protocol.ProtocolError('Not identified')
app = self.app app = self.app
for node_type, addr, uuid, state in node_list: for node_type, addr, uuid, state in node_list:
if node_type != NodeTypes.MASTER: if node_type != NodeTypes.MASTER:
...@@ -263,7 +263,7 @@ class ServerElectionHandler(ElectionHandler): ...@@ -263,7 +263,7 @@ class ServerElectionHandler(ElectionHandler):
def announcePrimary(self, conn, packet): def announcePrimary(self, conn, packet):
uuid = conn.getUUID() uuid = conn.getUUID()
if uuid is None: if uuid is None:
raise protocol.UnexpectedPacketError raise protocol.ProtocolError('Not identified')
app = self.app app = self.app
if app.primary: if app.primary:
# I am also the primary... So restart the election. # I am also the primary... So restart the election.
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
from neo import logging from neo import logging
from neo.protocol import Packets, UnexpectedPacketError from neo.protocol import Packets, ProtocolError
from neo.master.handlers import MasterHandler from neo.master.handlers import MasterHandler
from neo.util import dump from neo.util import dump
...@@ -66,5 +66,5 @@ class RecoveryHandler(MasterHandler): ...@@ -66,5 +66,5 @@ class RecoveryHandler(MasterHandler):
try: try:
self.app.pt.load(ptid, row_list, self.app.nm) self.app.pt.load(ptid, row_list, self.app.nm)
except IndexError: except IndexError:
raise UnexpectedPacketError('Invalid offset') raise ProtocolError('Invalid offset')
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
from neo import logging from neo import logging
from neo.protocol import UnexpectedPacketError, ProtocolError from neo.protocol import ProtocolError
from neo.protocol import CellStates, Packets from neo.protocol import CellStates, Packets
from neo.master.handlers import BaseServiceHandler from neo.master.handlers import BaseServiceHandler
from neo.exception import OperationFailure from neo.exception import OperationFailure
...@@ -58,7 +58,7 @@ class StorageServiceHandler(BaseServiceHandler): ...@@ -58,7 +58,7 @@ class StorageServiceHandler(BaseServiceHandler):
# If the given transaction ID is later than the last TID, the peer # If the given transaction ID is later than the last TID, the peer
# is crazy. # is crazy.
if tid > self.app.tm.getLastTID(): if tid > self.app.tm.getLastTID():
raise UnexpectedPacketError raise ProtocolError('TID too big')
# transaction locked on this storage node # transaction locked on this storage node
t = self.app.tm[tid] t = self.app.tm[tid]
......
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