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