Naanou.LookupService
Class SuccessorList

Manages a Naanou.LookupService.Nodes successor list. Duplicate addresses can be in list

Field Summary
Naanou.LookupService.RequestForwarder forwarder
long MAX_SIZE
         Size of list (2log2N of Config.MaximumNetworkSize)
Naanou.LookupService.Node node
System.Threading.ReaderWriterLock rwl
System.Collections.ArrayList s
Naanou.LookupService.NodeAddress successorListFrom

Constructor Summary
SuccessorList(Naanou.LookupService.Node node, Naanou.LookupService.FingerTable table)
         Constructor

Property Summary
int Count
bool HasSuccessor
         Gets whether there is a successor (does not check if address is alive)
Naanou.LookupService.NodeAddress Item[int index]
         Gets or sets the at a certain index. Index 0 is the first successor. Does not do Reconcile!
Naanou.LookupService.NodeAddress Successor
         Gets the current, 'in-use' successor (which may or may not be alive) or null
Naanou.LookupService.RemoteNode SuccessorNode
         Gets the successor's RemoteNode form

Method Summary
void Clear(Naanou.LookupService.FingerTable table)
         Clears list
string Dump()
         Dumps the contents of the list to a string
Naanou.LookupService.NodeAddress[] GetAddresses()
         Gets in array form all the addresses
Naanou.LookupService.NodeAddress GetAt(int index)
         Gets an address at a specified index, or an Empty address if not found
Naanou.Common.BasicAddress[] GetBasicAddresses()
         Get addresses in Naanou.Common.BasicAddress form
Naanou.LookupService.NodeAddress GetImmediatePredecessor(Naanou.Common.Hash id)
         Attempts to find the closest successor to id. Guaranteed alive
object GetProperty(System.Reflection.PropertyInfo pi, object[] index)
         Gets the given property on the current successor.
object GetProperty(string property, object[] index)
         Gets the given property on the current successor.
object Invoke(System.Reflection.MethodInfo mi, object[] parameters)
         Invokes the given method on the current successor. A safe way of calling the successor
object Invoke(string method, object[] parameters)
         Invokes a method and returns the result.
void Reconcile()
         Reconciles list with our successor s by copying it's successor list, adding s to the front, and deleting the last element. When our successor has failed, we use the next alive entry in our list and do a reconcile.
void Reconcile(bool forceRefresh)
         Reconciles list with our successor s by copying it's successor list, adding s to the front, and deleting the last element.
void RemoveAddress(Naanou.LookupService.NodeAddress address)
         Removes an address from the list
void RemoveCurrentSuccessor()
         Removes the current successor and reconciles list. Guarantees new successor is alive
void SuccessorChanged(Naanou.LookupService.NodeAddress old)
         Notification the successor has changed
string ToString()
         Returns a basic string representation of the instance
void UpdateAndNotify(int index)
         Called as part of the stabilisation process
int VerifyList()
         Check each successor and ensure liveness, culling dead addresses

Methods inherited from class System.Object
Equals, Finalize, GetHashCode, GetType, MemberwiseClone

Event Summary
Naanou.LookupService.SuccessorChangeHandler SuccessorChange
         Active successor has changed


Field Detail

forwarder

private Naanou.LookupService.RequestForwarder forwarder


MAX_SIZE

public long MAX_SIZE

Size of list (2log2N of Config.MaximumNetworkSize)


node

private Naanou.LookupService.Node node


rwl

private System.Threading.ReaderWriterLock rwl


s

private System.Collections.ArrayList s


successorListFrom

private Naanou.LookupService.NodeAddress successorListFrom

Constructor Detail

SuccessorList

public SuccessorList(Naanou.LookupService.Node node,
                     Naanou.LookupService.FingerTable table)

Constructor

Parameters:
node - Node to link to
table - Table of alternatives
Property Detail

Count

public int Count


HasSuccessor

public bool HasSuccessor

Gets whether there is a successor (does not check if address is alive)


Item

public Naanou.LookupService.NodeAddress this[int index]

Gets or sets the at a certain index. Index 0 is the first successor. Does not do Reconcile!

Throws:
System.ArgumentOutOfRangeException - When setting a successor that is not greater than node

Successor

public Naanou.LookupService.NodeAddress Successor

Gets the current, 'in-use' successor (which may or may not be alive) or null


SuccessorNode

public Naanou.LookupService.RemoteNode SuccessorNode

Gets the successor's RemoteNode form

Method Detail

Clear

public void Clear(Naanou.LookupService.FingerTable table)

Clears list

Parameters:
table - Table

Dump

public string Dump()

Dumps the contents of the list to a string

Returns:
Dumps the contents of the list to a string

GetAddresses

public Naanou.LookupService.NodeAddress[] GetAddresses()

Gets in array form all the addresses

Returns:
Address array, or null

GetAt

public Naanou.LookupService.NodeAddress GetAt(int index)

Gets an address at a specified index, or an Empty address if not found

Parameters:
index -
Returns:

GetBasicAddresses

public Naanou.Common.BasicAddress[] GetBasicAddresses()

Get addresses in Naanou.Common.BasicAddress form

Returns:
BasicAddresses

GetImmediatePredecessor

public Naanou.LookupService.NodeAddress GetImmediatePredecessor(Naanou.Common.Hash id)

Attempts to find the closest successor to id. Guaranteed alive

Parameters:
id - Id
Returns:
Returns closest successor, or null if none found

GetProperty

public object GetProperty(System.Reflection.PropertyInfo pi,
                          object[] index)

Gets the given property on the current successor.

This method correctly handles remote exceptions, as well as dead successors.

Parameters:
pi - Property
index - Parameters for property, or null for none
Throws:
Naanou.LookupService.NoMoreSuccessorsException - Thrown when the invoke fails as we have no successors

GetProperty

public object GetProperty(string property,
                          object[] index)

Gets the given property on the current successor.

This method correctly handles remote exceptions, as well as dead successors.

Parameters:
property - Property name
index - Index
Throws:
Naanou.LookupService.NoMoreSuccessorsException - Thrown when the invoke fails as we have no successors

Invoke

public object Invoke(System.Reflection.MethodInfo mi,
                     object[] parameters)

Invokes the given method on the current successor. A safe way of calling the successor

This method correctly handles remote exceptions, as well as dead successors.

Parameters:
mi - MethodInfo
parameters - Parameters to pass, or null for none
Returns:
Return value of method
Throws:
Naanou.LookupService.NoMoreSuccessorsException - Thrown when the invoke fails as we have no successors

Invoke

public object Invoke(string method,
                     object[] parameters)

Invokes a method and returns the result.

Parameters:
method - Method name
parameters - Parameters to pass, or null for none
Returns:
Return value of method
Throws:
Naanou.LookupService.NoMoreSuccessorsException - Thrown when the invoke fails as we have no successors

Reconcile

public void Reconcile()

Reconciles list with our successor s by copying it's successor list, adding s to the front, and deleting the last element. When our successor has failed, we use the next alive entry in our list and do a reconcile.


Reconcile

public void Reconcile(bool forceRefresh)

Reconciles list with our successor s by copying it's successor list, adding s to the front, and deleting the last element.

Parameters:
forceRefresh - Force a reconcile, even if we last reconciled from same source

RemoveAddress

private void RemoveAddress(Naanou.LookupService.NodeAddress address)

Removes an address from the list

Parameters:
address - Address to remove

RemoveCurrentSuccessor

private void RemoveCurrentSuccessor()

Removes the current successor and reconciles list. Guarantees new successor is alive

Throws:
System.NullReferenceException - Thrown when there are no more successors

SuccessorChanged

private void SuccessorChanged(Naanou.LookupService.NodeAddress old)

Notification the successor has changed

Parameters:
old - Previous successor

ToString

public string ToString()

Returns a basic string representation of the instance

Returns:
Returns a basic string representation of the instance

UpdateAndNotify

public void UpdateAndNotify(int index)

Called as part of the stabilisation process

Parameters:
index - Index

VerifyList

private int VerifyList()

Check each successor and ensure liveness, culling dead addresses

Returns:
The number of addresses culled
Event Detail

SuccessorChange

public Naanou.LookupService.SuccessorChangeHandler SuccessorChange

Active successor has changed