From 13ed7e9591c728ec344e1ad5b241d8125b7dcaa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Wisniewski?= <gregory@nexedi.com> Date: Thu, 23 Jul 2009 15:57:28 +0000 Subject: [PATCH] Remove an XX about storage size accessor. Implement a basic and inaccurate solution and add a TODO entry to do a better job later. git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@999 71dcc9de-d417-0410-9af5-da40c76e7ee4 --- TODO | 1 + neo/client/Storage.py | 3 +-- neo/client/app.py | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 4483f230..15863d82 100644 --- a/TODO +++ b/TODO @@ -130,3 +130,4 @@ RC Known bugs - Consider storing some metadata on master nodes (partition table [version], ...). This data should be treated non-authoritatively, as a way to lower the probability to use an outdated partition table. - Decentralize primary master tasks as much as possible (consider distributed lock mechanisms, ...) - Make admin node able to monitor multiple clusters simultaneously + - Choose how to compute the storage size diff --git a/neo/client/Storage.py b/neo/client/Storage.py index 54693624..b1b6a83f 100644 --- a/neo/client/Storage.py +++ b/neo/client/Storage.py @@ -160,8 +160,7 @@ class Storage(BaseStorage.BaseStorage, raise NotImplementedError def __len__(self): - # XXX bogus but how to implement this? - return 0 + return self.app.getStorageSize() def registerDB(self, db, limit): self.app.registerDB(db, limit) diff --git a/neo/client/app.py b/neo/client/app.py index 0276120f..652fe943 100644 --- a/neo/client/app.py +++ b/neo/client/app.py @@ -269,6 +269,7 @@ class Application(object): self.mq_cache = MQ() self.new_oid_list = [] self.ptid = None + self.last_oid = '\0' * 8 self.storage_event_handler = storage.StorageEventHandler(self, self.dispatcher) self.storage_bootstrap_handler = storage.StorageBootstrapHandler(self) self.storage_handler = storage.StorageAnswersHandler(self) @@ -518,10 +519,15 @@ class Application(object): self._askPrimary(protocol.askNewOIDs(100)) if len(self.new_oid_list) <= 0: raise NEOStorageError('new_oid failed') - return self.new_oid_list.pop() + self.last_oid = self.new_oid_list.pop() + return self.last_oid finally: self._oid_lock_release() + def getStorageSize(self): + # return the last OID used, this is innacurate + from neo.util import u64 + return int(u64(self.last_oid)) def getSerial(self, oid): # Try in cache first -- 2.30.9