org.planx.xmlstore.nameserver
Class GlobalNameServer

java.lang.Object
  extended by org.planx.xmlstore.nameserver.GlobalNameServer
All Implemented Interfaces:
NameServer

public class GlobalNameServer
extends Object
implements NameServer

A distributed NameServer that relies on a DistributedMap. A typical DistributedMap implementation such as Kademlia will not use any global consensus algorithms or locks to ensure that all peers agree on the contents of the global name server at any given time. In a stabile network with reliable communication that uses Kademlia, updates will be globally available with a delay of the time it takes to send an UDP packet. With unreliable communication, no guarantees are given other than that the peers will eventually agree on the newest version of a name server entry.

All-in-all, the semantics of the operations are somewhat more loose than required, so this implementation should be regarded as experimental.

Author:
Thomas Ambus

Constructor Summary
GlobalNameServer(DistributedMap map)
           
 
Method Summary
 void bind(String name, Reference vref)
          Bind the name to the value reference in the name server.
 Reference lookup(String name)
          Lookup the name in the name server.
 void rebind(String name, Reference oldr, Reference newr)
          Rebind the name to the value reference in the name server if the name is currently bound to the specified value reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlobalNameServer

public GlobalNameServer(DistributedMap map)
Method Detail

lookup

public Reference lookup(String name)
                 throws IOException
Description copied from interface: NameServer
Lookup the name in the name server. The method will return null if the name is not currently bound.

Specified by:
lookup in interface NameServer
Parameters:
name - the name to be looked up
Returns:
the reference bound to the name, or null if the name is not currently bound
Throws:
IOException

bind

public void bind(String name,
                 Reference vref)
          throws IOException,
                 NameAlreadyBoundException
Description copied from interface: NameServer
Bind the name to the value reference in the name server.

Specified by:
bind in interface NameServer
Parameters:
name - the name to be bound
vref - the reference to bind it to
Throws:
IOException
NameAlreadyBoundException - if the name is already bound (to a different value reference).

rebind

public void rebind(String name,
                   Reference oldr,
                   Reference newr)
            throws IOException,
                   StaleReferenceException
Description copied from interface: NameServer
Rebind the name to the value reference in the name server if the name is currently bound to the specified value reference.

Specified by:
rebind in interface NameServer
Parameters:
name - the name to be bound
oldr - the reference to which name is currently bound
newr - the reference to bind it to
Throws:
IOException
StaleReferenceException - if the name is bound to something different from oldRef.


Copyright © 2010. All Rights Reserved.