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