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