Commit cd93ff82 authored by Vincent Pelletier's avatar Vincent Pelletier

Replace error code with exception for oidNotFound.

Also, fix _load error message, as only data inconsistency can lead to -1
error code now (and it is set locally).

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2250 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent b213b8b6
...@@ -462,10 +462,6 @@ class Application(object): ...@@ -462,10 +462,6 @@ class Application(object):
except ConnectionClosed: except ConnectionClosed:
continue continue
if self.local_var.asked_object == -1:
# OID not found
break
# Check data # Check data
noid, start_serial, end_serial, compression, checksum, data \ noid, start_serial, end_serial, compression, checksum, data \
= self.local_var.asked_object = self.local_var.asked_object
...@@ -491,8 +487,7 @@ class Application(object): ...@@ -491,8 +487,7 @@ class Application(object):
raise NEOStorageError('connection failure') raise NEOStorageError('connection failure')
if self.local_var.asked_object == -1: if self.local_var.asked_object == -1:
# We didn't got any object from all storage node raise NEOStorageError('inconsistent data')
raise NEOStorageNotFoundError('oid %s not found' % (dump(oid), ))
# Uncompress data # Uncompress data
if compression: if compression:
...@@ -852,13 +847,13 @@ class Application(object): ...@@ -852,13 +847,13 @@ class Application(object):
undone_tid)) undone_tid))
except ConnectionClosed: except ConnectionClosed:
continue continue
except NEOStorageNotFoundError:
if self.local_var.txn_info == -1:
# Tid not found, try with next node # Tid not found, try with next node
logging.warning('Transaction %s was not found on node %s', logging.warning('Transaction %s was not found on node %s',
dump(undone_tid), self.nm.getByAddress(conn.getAddress())) dump(undone_tid), self.nm.getByAddress(conn.getAddress()))
continue continue
elif isinstance(self.local_var.txn_info, dict):
if isinstance(self.local_var.txn_info, dict):
break break
else: else:
raise NEOStorageError('undo failed') raise NEOStorageError('undo failed')
......
...@@ -22,7 +22,7 @@ from neo import logging ...@@ -22,7 +22,7 @@ from neo import logging
from neo.client.handlers import BaseHandler, AnswerBaseHandler from neo.client.handlers import BaseHandler, AnswerBaseHandler
from neo.protocol import NodeTypes, ProtocolError, LockState from neo.protocol import NodeTypes, ProtocolError, LockState
from neo.util import dump from neo.util import dump
from neo.client.exception import NEOStorageError from neo.client.exception import NEOStorageError, NEOStorageNotFoundError
class StorageEventHandler(BaseHandler): class StorageEventHandler(BaseHandler):
...@@ -114,8 +114,7 @@ class StorageAnswersHandler(AnswerBaseHandler): ...@@ -114,8 +114,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
# This can happen either when : # This can happen either when :
# - loading an object # - loading an object
# - asking for history # - asking for history
self.app.local_var.asked_object = -1 raise NEOStorageNotFoundError(message)
self.app.local_var.history = -1
def tidNotFound(self, conn, message): def tidNotFound(self, conn, message):
# This can happen when requiring txn informations # This can happen when requiring txn informations
......
...@@ -21,7 +21,7 @@ from neo.tests import NeoTestBase ...@@ -21,7 +21,7 @@ from neo.tests import NeoTestBase
from neo.protocol import NodeTypes, LockState from neo.protocol import NodeTypes, LockState
from neo.client.handlers.storage import StorageBootstrapHandler, \ from neo.client.handlers.storage import StorageBootstrapHandler, \
StorageAnswersHandler StorageAnswersHandler
from neo.client.exception import NEOStorageError from neo.client.exception import NEOStorageError, NEOStorageNotFoundError
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
MARKER = [] MARKER = []
...@@ -215,9 +215,8 @@ class StorageAnswerHandlerTests(NeoTestBase): ...@@ -215,9 +215,8 @@ class StorageAnswerHandlerTests(NeoTestBase):
def test_oidNotFound(self): def test_oidNotFound(self):
conn = self.getConnection() conn = self.getConnection()
self.handler.oidNotFound(conn, 'message') self.assertRaises(NEOStorageNotFoundError, self.handler.oidNotFound,
self.assertEqual(self.app.local_var.asked_object, -1) conn, 'message')
self.assertEqual(self.app.local_var.history, -1)
def test_tidNotFound(self): def test_tidNotFound(self):
conn = self.getConnection() conn = self.getConnection()
......
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