| |
- AvailableResources
- InitialResources
- Resources
class AvailableResources |
|
A simulator-wide register for the resources available at different nodes.
Used to assist searching so that a search will be directed to a resource that
1) exists
2) is at any node. |
|
Methods defined here:
- __init__(self)
- Init the AvailableResrouce storage.
The default distribution is uniform.
- deregister(self, resource, node)
- Deregister a given resource that was available at the given node.
- random(self, exclude=None)
- Returns a random resource that can be available at any node.
If argument exclude is given, a resource found in the excluded node will not be selected.
- register(self, resource, node)
- Register a given resource that is available at the given node.
- zipfdistribution(self, skew=1.0)
- Use a zipf distribution with the given skew.
|
class InitialResources |
|
A class for generating the resources that initially are available. |
|
Methods defined here:
- __init__(self, nodes)
- Initialize the InitialResources for the given number of nodes.
The default distribution is uniform.
- generate(self, numberofresources, mincopies=1, maxcopies=1)
- Generate the given number of resources and allocate them to the nodes.
The number of copies of a resource is random between the given limits.
- get(self)
- Return the initial resources for the node that calls this function.
- zipfdistribution(self, skew=1.0)
- Use a zipf distribution with the given skew.
|
class Resources |
|
Node-specific class for generating resources and search requests.
Should be subclassed together with an Application or SILApplication class. |
|
Methods defined here:
- addresource(self, dummy=None)
- Add a resource to the node.
Adds a random resource, id defined by the scenario-parameters dynamicresourcefrom and dynamicresourceto.
If dynamicresourceto is undefined, nrofresources is used as upper limit.
Schedules itself again after interval defined in the scenario-parameter indexaddinterval.
Schedules removal of the added resource after interval defined in the scenario-parameter indexremoveinterval
(or in indexaddinterval if indexremoveinterval is undefined).
- generate_search(self, dummy=None)
- Generate a search request, which is flooded on the search links.
Scheduled calling, with rescheduling.
- generateresources(self, count=None)
- init(self, log, searchinterval, indexaddinterval, indexremoveinterval, removeinitialresources, searchtimeout, dynamicresourcefrom, dynamicresourceto, postponeremoval, valuecounter)
- Initialize the Resources module.
Arguments:
log - A Log for storing and displaying warning messages.
searchinterval - The average interval between successive search requests.
indexaddinterval - The average interval between sucessive resource additions. None = resources are never added dynamically.
indexremoveinterval - The average time the resource is available at the node. None = resources are never removed.
removeinitialresources - True if the initial resources should be removed after a indexremoveinterval.
searchtimeout - The time period after which the search results are examined.
dynamicresourcefrom - The start of the number range of resource numbers added dynamically.
dynamicresourceto - The end of the number range of resources added dynamically.
postponeremoval - True if removal of resources should be delayed until the following addition of resources.
valuecounter - A StatisticsCounter that counts the delays and number of replies.
- initialresources(self, resources)
- Add the given resources as the initial resources.
- on_added_resource(self, resource)
- Handles an added resource.
Called by the Resources class when a resource has been added. The Application can then
perform necessary functions, such as distributing index updates. To be subclassed.
- on_removed_resource(self, resource)
- Handles an removed resource.
Called by the Resources class when a resource has been removed. The Application can then
perform necessary functions, such as distributing index updates. To be subclassed.
- on_search_request(self, resource, searchid)
- Handles a search request generated by the node.
Called by the Resources class when a resource request is generated. The application can then e.g.
forward the request to other nodes. To be overrided.
- removeresource(self, resource)
- Remove a resource from the node.
- reportfound(self, searchid, where)
- Reports a found resource and collect statistics.
- timeoutsearch(self, searchid)
- Examine the search results collected during the search, and collect statistics about the search.
Called when a given time has expired since the search was initiated. A search request timed out with either results or without results.
Data and other attributes defined here:
- nextsearchid = 1
| |