X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=apt_p2p_Khashmir%2Factions.py;h=870e37c80450220d84109077209e8e0905a4b976;hb=df9831500326100920070d964c659cffb67a95ab;hp=1179713c22847fc3236cd95e61684b38c6cf0d80;hpb=7b1167d8ce780312d3689c9309c7e9c64060c085;p=quix0rs-apt-p2p.git diff --git a/apt_p2p_Khashmir/actions.py b/apt_p2p_Khashmir/actions.py index 1179713..870e37c 100644 --- a/apt_p2p_Khashmir/actions.py +++ b/apt_p2p_Khashmir/actions.py @@ -49,7 +49,7 @@ class ActionBase: @ivar sort: used to sort nodes by their proximity to the target """ - def __init__(self, caller, target, callback, config, action, num_results = None): + def __init__(self, caller, target, callback, config, stats, action, num_results = None): """Initialize the action. @type caller: L{khashmir.Khashmir} @@ -60,6 +60,8 @@ class ActionBase: @param callback: the method to call with the results @type config: C{dictionary} @param config: the configuration variables for the DHT + @type stats: L{stats.StatsLogger} + @param stats: the statistics gatherer @type action: C{string} @param action: the name of the action to call on remote nodes @type num_results: C{int} @@ -72,6 +74,7 @@ class ActionBase: self.target = target self.config = config self.action = action + stats.startedAction(action) self.num = intify(target) self.queried = {} self.answered = {} @@ -233,8 +236,8 @@ class ActionBase: class FindNode(ActionBase): """Find the closest nodes to the key.""" - def __init__(self, caller, target, callback, config, action="findNode"): - ActionBase.__init__(self, caller, target, callback, config, action) + def __init__(self, caller, target, callback, config, stats, action="find_node"): + ActionBase.__init__(self, caller, target, callback, config, stats, action) def processResponse(self, dict): """Save the token received from each node.""" @@ -251,8 +254,8 @@ class FindNode(ActionBase): class FindValue(ActionBase): """Find the closest nodes to the key and check for values.""" - def __init__(self, caller, target, callback, config, action="findValue"): - ActionBase.__init__(self, caller, target, callback, config, action) + def __init__(self, caller, target, callback, config, stats, action="find_value"): + ActionBase.__init__(self, caller, target, callback, config, stats, action) def processResponse(self, dict): """Save the number of values each node has.""" @@ -269,13 +272,13 @@ class FindValue(ActionBase): class GetValue(ActionBase): """Retrieve values from a list of nodes.""" - def __init__(self, caller, target, local_results, num_results, callback, config, action="getValue"): + def __init__(self, caller, target, local_results, num_results, callback, config, stats, action="get_value"): """Initialize the action with the locally available results. @type local_results: C{list} of C{string} @param local_results: the values that were available in this node """ - ActionBase.__init__(self, caller, target, callback, config, action, num_results) + ActionBase.__init__(self, caller, target, callback, config, stats, action, num_results) if local_results: for result in local_results: self.results[result] = 1 @@ -318,13 +321,13 @@ class GetValue(ActionBase): class StoreValue(ActionBase): """Store a value in a list of nodes.""" - def __init__(self, caller, target, value, num_results, callback, config, action="storeValue"): + def __init__(self, caller, target, value, num_results, callback, config, stats, action="store_value"): """Initialize the action with the value to store. @type value: C{string} @param value: the value to store in the nodes """ - ActionBase.__init__(self, caller, target, callback, config, action, num_results) + ActionBase.__init__(self, caller, target, callback, config, stats, action, num_results) self.value = value def getNodesToProcess(self):