Commit df47e5b1 authored by Julien Muchembled's avatar Julien Muchembled

client: optimize Storage.history() by not asking all storages systematically

parent 11473bff
...@@ -982,33 +982,29 @@ class Application(object): ...@@ -982,33 +982,29 @@ class Application(object):
return (tid, txn_list) return (tid, txn_list)
def history(self, oid, size=1, filter=None): def history(self, oid, size=1, filter=None):
queue = self._getThreadQueue()
# Get history informations for object first # Get history informations for object first
packet = Packets.AskObjectHistory(oid, 0, size) packet = Packets.AskObjectHistory(oid, 0, size)
for node, conn in self.cp.iterateForObject(oid, readable=True): for node, conn in self.cp.iterateForObject(oid, readable=True):
try: try:
conn.ask(packet, queue=queue) history_list = self._askStorage(conn, packet)
except ConnectionClosed: except ConnectionClosed:
continue continue
history_dict = {} # Now that we have object informations, get txn informations
self.waitResponses(queue, history_dict) result = []
# Now that we have object informations, get txn informations # history_list is already sorted descending (by the storage)
history_list = [] for serial, size in history_list:
append = history_list.append txn_info, txn_ext = self._getTransactionInformation(serial)
for serial in sorted(history_dict.keys(), reverse=True): # create history dict
size = history_dict[serial] txn_info.pop('id')
txn_info, txn_ext = self._getTransactionInformation(serial) txn_info.pop('oids')
# create history dict txn_info.pop('packed')
txn_info.pop('id') txn_info['tid'] = serial
txn_info.pop('oids') txn_info['version'] = ''
txn_info.pop('packed') txn_info['size'] = size
txn_info['tid'] = serial if filter is None or filter(txn_info):
txn_info['version'] = '' result.append(txn_info)
txn_info['size'] = size self._insertMetadata(txn_info, txn_ext)
if filter is None or filter(txn_info): return result
append(txn_info)
self._insertMetadata(txn_info, txn_ext)
return history_list
@profiler_decorator @profiler_decorator
def importFrom(self, source, start, stop, tryToResolveConflict): def importFrom(self, source, start, stop, tryToResolveConflict):
......
...@@ -122,7 +122,7 @@ class StorageAnswersHandler(AnswerBaseHandler): ...@@ -122,7 +122,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
def answerObjectHistory(self, conn, _, history_list): def answerObjectHistory(self, conn, _, history_list):
# history_list is a list of tuple (serial, size) # history_list is a list of tuple (serial, size)
self.app.getHandlerData().update(history_list) self.app.setHandlerData(history_list)
def oidNotFound(self, conn, message): def oidNotFound(self, conn, message):
# This can happen either when : # This can happen either when :
......
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