mail.node
Class LocalNode

java.lang.Object
  extended by mail.node.Node
      extended by mail.node.LocalNode

public class LocalNode
extends Node

Author:
Arne Müller

Nested Class Summary
 
Nested classes/interfaces inherited from class mail.node.Node
Node.IDComparator, Node.InvertedIDComparator
 
Field Summary
static int BOOTSTRAP
           
private  MailStore mails
           
private  java.util.Map<NameID,ID> names
           
private  java.util.Set<Node> neighbors
           
private  java.util.Map<Node,java.lang.Integer> reachability
           
static int THINK_OFFLINE
          if a node was not reachable THINK_OFFLINE times in a row, it is though to have went offline
 
Fields inherited from class mail.node.Node
crypt
 
Constructor Summary
LocalNode(MailStore mailStore, java.util.Map<NameID,ID> nameStore, EncSupply enc)
           
 
Method Summary
 void addNeighbor(Node n)
          add's another neighbor to the node's list of neighbors
 void bootstrap(Address a, Communicator c)
           
 java.util.Collection<Mail> fetchMail()
           
 java.util.ArrayList<Node> getClosest(ID nodeid)
          returns the neighbors of this node sorted by distance.
 java.util.Collection<Mail> getMail(ID receiver)
           
 MailStore getMailStore()
           
 ID getName(NameID nameid)
          fetches the ID that registered the name with the given ID
 java.util.Collection<Node> getNeighbors()
          returns all the neighbors of this Node
 Node getNode(ID id)
           
protected  void markReachable(Node n)
           
private  void markUnreachable(Node n)
           
 void refresh()
           
 void refreshNames()
           
 void sendMail(Mail m)
           
 void setName(java.lang.String name)
           
 void store(Mail m)
           
 void storeName(NameID nameid, ID user)
           
 java.lang.String toString()
           
 
Methods inherited from class mail.node.Node
distance, distance, equals, getCryptEngine, getID, getKey, hashCode, searchClosest, searchName, searchNode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BOOTSTRAP

public static final int BOOTSTRAP
See Also:
Constant Field Values

THINK_OFFLINE

public static final int THINK_OFFLINE
if a node was not reachable THINK_OFFLINE times in a row, it is though to have went offline

See Also:
Constant Field Values

neighbors

private java.util.Set<Node> neighbors

reachability

private java.util.Map<Node,java.lang.Integer> reachability

mails

private MailStore mails

names

private java.util.Map<NameID,ID> names
Constructor Detail

LocalNode

public LocalNode(MailStore mailStore,
                 java.util.Map<NameID,ID> nameStore,
                 EncSupply enc)
          throws EncSupplyException
Throws:
EncSupplyException
Method Detail

getClosest

public java.util.ArrayList<Node> getClosest(ID nodeid)
returns the neighbors of this node sorted by distance. the closest node will be first

Specified by:
getClosest in class Node
Parameters:
nodeid - the id of the node to which distance should be measured to
Returns:
neighbors sorted by distance

getNeighbors

public java.util.Collection<Node> getNeighbors()
Description copied from class: Node
returns all the neighbors of this Node

Specified by:
getNeighbors in class Node
Returns:

addNeighbor

public void addNeighbor(Node n)
add's another neighbor to the node's list of neighbors

Specified by:
addNeighbor in class Node
Parameters:
n -

getName

public ID getName(NameID nameid)
Description copied from class: Node
fetches the ID that registered the name with the given ID

Specified by:
getName in class Node
Returns:

storeName

public void storeName(NameID nameid,
                      ID user)
Specified by:
storeName in class Node

getMail

public java.util.Collection<Mail> getMail(ID receiver)
Specified by:
getMail in class Node

getMailStore

public MailStore getMailStore()

store

public void store(Mail m)
Specified by:
store in class Node

getNode

public Node getNode(ID id)
Specified by:
getNode in class Node

toString

public java.lang.String toString()
Overrides:
toString in class Node

refresh

public void refresh()

refreshNames

public void refreshNames()

sendMail

public void sendMail(Mail m)

setName

public void setName(java.lang.String name)

bootstrap

public void bootstrap(Address a,
                      Communicator c)
               throws BootstrapException
Throws:
BootstrapException

fetchMail

public java.util.Collection<Mail> fetchMail()

markReachable

protected void markReachable(Node n)
Overrides:
markReachable in class Node

markUnreachable

private void markUnreachable(Node n)