|
.NET Framework | |||||||||
PREV TYPE NEXT TYPE | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONST | PROP | METHOD | OP | EVENT | DETAIL: FIELD | CONST | PROP | METHOD | OP | EVENT |
Manages the node cache. Node cache resolves BasicAddresses to NodeAddress instances (which in turn hold RemoteNode instances). Nodes expire, and are removed from cache as it approaches full utilisation. Nodes can also be foricibly removed from cache. More commonly accessed nodes will be kept longer.
External entities only have read-only access
Field Summary | |
---|---|
System.Collections.Hashtable |
hash
Hash of CachedNode structs, keyed by address id |
float |
largestSize
Keeps track of the largest size hash has been. This will be bounded by MAX_SIZE obviously |
int |
MAX_SIZE
Maximum size for queue. Set to same as the how large finger tables to minimise thrashing |
Naanou.LookupService.Node | node |
System.Collections.Queue |
queue
Queued NodeAddresses (can contain duplicate addresses) |
Naanou.Common.Hash | selfId |
Constructor Summary | |
---|---|
Cache(Naanou.LookupService.Node node) Constructor |
Property Summary | |
---|---|
Naanou.LookupService.NodeAddress[] |
Addresses
Gets all addresses stored by cache |
int |
Count
Returns the number of entries in the cache |
float |
LargestCount
Returns the total number of entries (may be duplicate) that have flowed through the cache |
int |
QueueCount
Returns the number of entries in the queue |
string |
Stats
Gets short stats about cache (util, count, queue count, largest count) |
double |
Utilisation
Returns utilisation |
Method Summary | |
---|---|
void |
Add(Naanou.LookupService.NodeAddress address) Adds an address to the cache. NodeAddress should be local Cache will ensure address is not already in storage, and keeps size under MAX_SIZE |
void |
Clear(Naanou.LookupService.Node node) Clears cache of all data (does not trigger events) |
bool |
Contains(Naanou.Common.Address address) Does cache contain an address? |
string |
Dump() Returns a string represention of cache, dumping out all the contents |
void |
FreshenAddress(Naanou.LookupService.CachedNode cachedNode) This will reinsert address in queue. This will cause duplicate addresses to be held within the queue. Hash still maintains 'maximum one' semantics. |
Naanou.LookupService.NodeAddress |
GetAddress(Naanou.Common.BasicAddress address) Returns a previously created Naanou.LookupService.NodeAddress instance for a address, or returns a new one |
void |
PopOff() Takes the oldest item off the list. Triggers Naanou.LookupService.Cache.Expired event. |
void |
Remove(Naanou.LookupService.NodeAddress address) Forcibly remove a address from the cache |
void |
Remove(Naanou.Common.BasicAddress address) Forcibly remove a address from the cache |
string |
ToString() Returns a string representation of object |
Methods inherited from class System.Object |
---|
Equals, Finalize, GetHashCode, GetType, MemberwiseClone |
Event Summary | |
---|---|
Naanou.LookupService.CacheAddEventHandler |
Added
Triggered when a new unique node has been added to cache |
Naanou.LookupService.CacheExpiryEventHandler |
Expired
Triggered when a node expires from cache |
Naanou.LookupService.CacheHitEventHandler |
Hit
Triggered whenever the cache returns an existing node |
Naanou.LookupService.CacheRemoveEventHandler |
Removed
Triggered when a node is forcibly removed from cache |
Field Detail |
---|
private System.Collections.Hashtable hash
Hash of CachedNode structs, keyed by address id
private float largestSize
Keeps track of the largest size hash has been. This will be bounded by MAX_SIZE obviously
public int MAX_SIZE
Maximum size for queue. Set to same as the how large finger tables to minimise thrashing
private Naanou.LookupService.Node node
private System.Collections.Queue queue
Queued NodeAddresses (can contain duplicate addresses)
private Naanou.Common.Hash selfId
Constructor Detail |
---|
internal Cache(Naanou.LookupService.Node node)
Constructor
Property Detail |
---|
public Naanou.LookupService.NodeAddress[] Addresses
Gets all addresses stored by cache
public int Count
Returns the number of entries in the cache
public float LargestCount
Returns the total number of entries (may be duplicate) that have flowed through the cache
public int QueueCount
Returns the number of entries in the queue
public string Stats
Gets short stats about cache (util, count, queue count, largest count)
public double Utilisation
Returns utilisation
Method Detail |
---|
internal void Add(Naanou.LookupService.NodeAddress address)
Adds an address to the cache. NodeAddress should be local Cache will ensure address is not already in storage, and keeps size under MAX_SIZE
Parameters:
address
- Address to addinternal void Clear(Naanou.LookupService.Node node)
Clears cache of all data (does not trigger events)
Parameters:
node
- public bool Contains(Naanou.Common.Address address)
Does cache contain an address?
Address is not matched on instance, rather the address id
Parameters:address
- Address to checkpublic string Dump()
Returns a string represention of cache, dumping out all the contents
Returns:
private void FreshenAddress(Naanou.LookupService.CachedNode cachedNode)
This will reinsert address in queue. This will cause duplicate addresses to be held within the queue. Hash still maintains 'maximum one' semantics.
Parameters:
cachedNode
- Addresspublic Naanou.LookupService.NodeAddress GetAddress(Naanou.Common.BasicAddress address)
Returns a previously created Naanou.LookupService.NodeAddress instance for a address, or returns a new one
Parameters:
address
- Addressprivate void PopOff()
Takes the oldest item off the list. Triggers Naanou.LookupService.Cache.Expired event.
internal void Remove(Naanou.LookupService.NodeAddress address)
Forcibly remove a address from the cache
Address is not matched on instance, rather the address id. Address may persist in queue after removal - removal time from queue would be lengthy.
Parameters:address
- Address to removeinternal void Remove(Naanou.Common.BasicAddress address)
Forcibly remove a address from the cache
Address is not matched on instance, rather the address id. Address may persist in queue after removal - removal time from queue would be lengthy.
Parameters:address
- Address to removepublic string ToString()
Returns a string representation of object
Returns:
Event Detail |
---|
public Naanou.LookupService.CacheAddEventHandler Added
Triggered when a new unique node has been added to cache
public Naanou.LookupService.CacheExpiryEventHandler Expired
Triggered when a node expires from cache
public Naanou.LookupService.CacheHitEventHandler Hit
Triggered whenever the cache returns an existing node
public Naanou.LookupService.CacheRemoveEventHandler Removed
Triggered when a node is forcibly removed from cache
|
.NET Framework | |||||||||
PREV TYPE NEXT TYPE | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONST | PROP | METHOD | OP | EVENT | DETAIL: FIELD | CONST | PROP | METHOD | OP | EVENT |