org.planx.xmlstore.stores
Class DistributedXMLStore

java.lang.Object
  extended by org.planx.xmlstore.stores.AbstractXMLStore
      extended by org.planx.xmlstore.stores.DistributedXMLStore
All Implemented Interfaces:
XMLStore

public class DistributedXMLStore
extends AbstractXMLStore

A peer-to-peer XMLStore that uses Kademlia as routing module. It only operates on location independent ValueReferences. If an XMLStore that does not operate on ValueReferences is used as the underlying XMLStore (e.g. LocalXMLStore), it must be wrapped in a TranslatorXMLStore.

Author:
Thomas Ambus

Field Summary
 
Fields inherited from class org.planx.xmlstore.stores.AbstractXMLStore
xmlstore
 
Constructor Summary
DistributedXMLStore(XMLStore xmlstore, int udpPort, int tcpPort, InetSocketAddress bootstrap)
          Creates a DistributedXMLStore which listens for routing requests on the specified UDP port and listens for data transfer requests on the specified TCP port.
 
Method Summary
 void close()
          The method is used to let the XMLStore properly commit all data to the underlying ressource, release resources, and so forth.
 NameServer getNameServer()
          Returns a GlobalNameServer that uses the same DistributedMap as this DistributedXMLStore.
protected  Node resolvedLoad(Reference vref)
          If the Reference is not known in the underlying XMLStore it is looked up in the network and loaded from another peer if it exists.
 Reference save(Node node)
          Always saves locally even if the node might already be stored elsewhere in the network.
 
Methods inherited from class org.planx.xmlstore.stores.AbstractXMLStore
checkClosed, load, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DistributedXMLStore

public DistributedXMLStore(XMLStore xmlstore,
                           int udpPort,
                           int tcpPort,
                           InetSocketAddress bootstrap)
                    throws IOException
Creates a DistributedXMLStore which listens for routing requests on the specified UDP port and listens for data transfer requests on the specified TCP port. The XML Store is bootstraped to an existing XML Store network by specifying a bootstrap IP and UDP port. If the bootstrap IP is null the XML Store will not attempt to connect to an existing network. The DistributedXMLStore only saves locally.

Parameters:
xmlstore - The underlying XMLStore.
udpPort - UDP port on which to listen for routing requests
tcpPort - TCP port on which to listen for data transfer requests
bootstrap - IP and UDP port of an existing peer in the network
Throws:
IOException
Method Detail

getNameServer

public NameServer getNameServer()
Returns a GlobalNameServer that uses the same DistributedMap as this DistributedXMLStore.


close

public void close()
           throws IOException
Description copied from interface: XMLStore
The method is used to let the XMLStore properly commit all data to the underlying ressource, release resources, and so forth. Once close has been issued on an XMLStore, the store is no longer available for handling requests. Any subsequent request to the store will result in an exception being thrown. An XMLStore implementation has to ensure that this happens.

Specified by:
close in interface XMLStore
Overrides:
close in class AbstractXMLStore
Throws:
IOException - if it is not possible to properly close the store

save

public Reference save(Node node)
               throws IOException
Always saves locally even if the node might already be stored elsewhere in the network. This is because it is considered very likely that the node will be loaded locally later.

Specified by:
save in interface XMLStore
Overrides:
save in class AbstractXMLStore
Parameters:
node - representing XML data in the form of semi-structured tree data
Returns:
a reference to the saved node/tree
Throws:
IOException - if an error occurs during disk, network, etc access

resolvedLoad

protected Node resolvedLoad(Reference vref)
                     throws IOException,
                            UnknownReferenceException
If the Reference is not known in the underlying XMLStore it is looked up in the network and loaded from another peer if it exists. If the Reference could not be found an UnknownReferenceException is thrown.

Overrides:
resolvedLoad in class AbstractXMLStore
Parameters:
vref - the resolved Reference
Throws:
IOException
UnknownReferenceException


Copyright © 2010. All Rights Reserved.