Naanou.LookupService
Class NodeAddress

Address for a node

Field Summary
Naanou.Common.BasicAddress basicForm
bool cannotCreate
int deadTries
Naanou.Common.Hash id
         Node Id
bool isAlive
long lastAliveCheckTicks
Naanou.Common.Hash network
         Network node belongs too
Naanou.LookupService.RemoteNode node
         Remote instansiation of address
string url
         URL for node services. Will always have a trailing slash

Constructor Summary
NodeAddress(Naanou.Common.BasicAddress address)
         Constructor
NodeAddress(Naanou.Common.BasicAddress address, Naanou.LookupService.RemoteNode node, bool cannotCreate)
         Constructor
NodeAddress(Naanou.Common.Hash id, string url, Naanou.Common.Hash network)
         Constructor
NodeAddress(Naanou.Common.Hash id, string url, Naanou.Common.Hash network, Naanou.LookupService.RemoteNode node)
         Constructor

Property Summary
Naanou.Common.Hash Id
         Gets the Id
bool IsEmpty
         Is the address unset
Naanou.Common.Hash Network
         Gets Network
Naanou.LookupService.RemoteNode Node
         Attempts to instansiate the remote object at this address, or returns a existing instance
string Url
         Gets Url of address

Method Summary
bool CheckAlive()
         Checks whether a node is alive or not.
Naanou.LookupService.NodeAddress Clone(Naanou.LookupService.NodeAddress address)
         Creates a shallow-clone of address. Used for making a local version of a address proxy
void Dispose()
         Cleans up address
bool Equals(Naanou.Common.Address address)
         Does this address equal another?
bool Equals(Naanou.LookupService.NodeAddress address)
         Does this address equal another?
int IncrementDeadTries()
         Increments dead tries
bool IsAlive()
         Keeps rough track of whether a node is alive or not. Automatically requeries node when required.
double Ping()
         Pings an address. (blocking)
void ResetAliveTicks()
         Resets aliveness
void SetAlive(bool alive)
         Manual override for 'aliveness'
void SetCannotCreate(bool cannotCreate)
         If set to true, no new instance of a RemoteNode for this address will ever be created
void SetNetwork(Naanou.Common.Hash network)
         Manually sets the network id of an address
void SetNode(Naanou.LookupService.RemoteNode node)
         Manually set the RemoteNode instance for this address
void SetUrl(string url)
         Manually sets the url.
Naanou.Common.BasicAddress ToBasic()
         Gets the basic form of the address
string ToString()
         Returns a string representation of this object

Methods inherited from class System.MarshalByRefObject
CreateObjRef, GetLifetimeService, InitializeLifetimeService

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


Field Detail

basicForm

private Naanou.Common.BasicAddress basicForm


cannotCreate

private bool cannotCreate


deadTries

private int deadTries


id

private Naanou.Common.Hash id

Node Id


isAlive

private bool isAlive


lastAliveCheckTicks

private long lastAliveCheckTicks


network

private Naanou.Common.Hash network

Network node belongs too


node

private Naanou.LookupService.RemoteNode node

Remote instansiation of address


url

private string url

URL for node services. Will always have a trailing slash

Constructor Detail

NodeAddress

public NodeAddress(Naanou.Common.BasicAddress address)

Constructor

Parameters:
address - Basic address to base from

NodeAddress

public NodeAddress(Naanou.Common.BasicAddress address,
                   Naanou.LookupService.RemoteNode node,
                   bool cannotCreate)

Constructor

Parameters:
address - BasicAddress
node - RemoteNode isntance
cannotCreate - Sets cannotCreate flag

NodeAddress

public NodeAddress(Naanou.Common.Hash id,
                   string url,
                   Naanou.Common.Hash network)

Constructor

Parameters:
id - Id
url - Url
network - Network id

NodeAddress

public NodeAddress(Naanou.Common.Hash id,
                   string url,
                   Naanou.Common.Hash network,
                   Naanou.LookupService.RemoteNode node)

Constructor

Parameters:
id - Node id
url - Services URL
network - Network id
node - Existing RemoteNode instance to use
Property Detail

Id

public Naanou.Common.Hash Id

Gets the Id


IsEmpty

public bool IsEmpty

Is the address unset


Network

public Naanou.Common.Hash Network

Gets Network


Node

public Naanou.LookupService.RemoteNode Node

Attempts to instansiate the remote object at this address, or returns a existing instance

Throws:
System.InvalidOperationException - Thrown for addresses that cannot be instansiated
Naanou.LookupService.NodeCommunicationException - Thrown when we can't talk to node

Url

public string Url

Gets Url of address

Method Detail

CheckAlive

public bool CheckAlive()

Checks whether a node is alive or not.

Returns:
Is alive

Clone

public Naanou.LookupService.NodeAddress Clone(Naanou.LookupService.NodeAddress address)

Creates a shallow-clone of address. Used for making a local version of a address proxy

Parameters:
address - Address to clone
Returns:
Clone

Dispose

public void Dispose()

Cleans up address


Equals

public bool Equals(Naanou.Common.Address address)

Does this address equal another?

Parameters:
address - Address to check
Returns:
Bool indicating equality

Equals

public bool Equals(Naanou.LookupService.NodeAddress address)

Does this address equal another?

Parameters:
address - Address to check
Returns:
Bool indicating equality

IncrementDeadTries

public int IncrementDeadTries()

Increments dead tries

Returns:
New dead tries count

IsAlive

public bool IsAlive()

Keeps rough track of whether a node is alive or not. Automatically requeries node when required.

Returns:
Is alive

Ping

public double Ping()

Pings an address. (blocking)

Pings an address 5 times and returns the average

Returns:
The average ping of 5 attempts
Throws:
Naanou.LookupService.NodeCommunicationException - When node cannot be contacted

ResetAliveTicks

private void ResetAliveTicks()

Resets aliveness


SetAlive

internal void SetAlive(bool alive)

Manual override for 'aliveness'

Parameters:
alive - Alive

SetCannotCreate

internal void SetCannotCreate(bool cannotCreate)

If set to true, no new instance of a RemoteNode for this address will ever be created

Parameters:
cannotCreate -

SetNetwork

internal void SetNetwork(Naanou.Common.Hash network)

Manually sets the network id of an address

Parameters:
network - Network

SetNode

internal void SetNode(Naanou.LookupService.RemoteNode node)

Manually set the RemoteNode instance for this address

Parameters:
node - Node

SetUrl

internal void SetUrl(string url)

Manually sets the url.

Parameters:
url - Url

ToBasic

public Naanou.Common.BasicAddress ToBasic()

Gets the basic form of the address

Returns:

ToString

public string ToString()

Returns a string representation of this object

Returns:
String representation