org.planx.xmlstore.stores
Class LocalXMLStore

java.lang.Object
  extended by org.planx.xmlstore.stores.AbstractXMLStore
      extended by org.planx.xmlstore.stores.LocalXMLStore
All Implemented Interfaces:
XMLStore
Direct Known Subclasses:
WriteBufferXMLStore

public class LocalXMLStore
extends AbstractXMLStore

A local XMLStore that only operates on location dependent References, that is, LocalLocators. Thus, it is fast but unable to resolve ValueReferences. In order to do this, wrap the LocalXMLStore in a TranslatorXMLStore.

A LocalXMLStore will run a Sharer in the background that compacts redundant on-disk data and performs garbage collection.

Author:
Thomas Ambus

Field Summary
 
Fields inherited from class org.planx.xmlstore.stores.AbstractXMLStore
xmlstore
 
Constructor Summary
LocalXMLStore(String name)
          Creates a new LocalXMLStore with the specified on-disk name.
LocalXMLStore(String name, RegionConfiguration conf)
          Creates a new LocalXMLStore with the specified on-disk name.
 
Method Summary
 void addReferenceListener(ReferenceListener listener)
          Adds the specified ReferenceListener for receiving Reference events.
protected  void checkClosed()
           
 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 NameServer for this store.
 RegionManager getRegionManager()
          Access to the RegionManager is provided merely for testing purposes and for accessing the managers statistics.
 void release(Reference ref)
          Informs the XMLStore that the data referenced by the specified Reference is no longer needed.
 void removeReferenceListener(ReferenceListener listener)
          Removes the specified ReferenceListener previously added with addReferenceListener.
protected  Node resolvedLoad(Reference vref)
          Only accepts LocalLocators.
 void retain(Reference ref)
          Informs the XMLStore that the data referenced by the specified Reference should be kept permanently.
 Reference save(Node node)
          Saves the specified Node and returns a LocalLocator to it.
 long size()
          Returns the disk size of this LocalXMLStore.
 String toString()
           
 
Methods inherited from class org.planx.xmlstore.stores.AbstractXMLStore
load
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalXMLStore

public LocalXMLStore(String name)
              throws IOException
Creates a new LocalXMLStore with the specified on-disk name.

Parameters:
name - the on-disk file name to use as base for persistent data
Throws:
IOException - if an error occurred initializing the XMLStore using the specified name

LocalXMLStore

public LocalXMLStore(String name,
                     RegionConfiguration conf)
              throws IOException
Creates a new LocalXMLStore with the specified on-disk name.

Parameters:
name - the on-disk file name to use as base for persistent data
Throws:
IOException - if an error occurred initializing the XMLStore using the specified name
Method Detail

save

public Reference save(Node node)
               throws IOException
Saves the specified Node and returns a LocalLocator to it.

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
Only accepts LocalLocators.

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

getNameServer

public NameServer getNameServer()
Returns a NameServer for this store.


getRegionManager

public RegionManager getRegionManager()
Access to the RegionManager is provided merely for testing purposes and for accessing the managers statistics.


retain

public void retain(Reference ref)
            throws UnknownReferenceException
Informs the XMLStore that the data referenced by the specified Reference should be kept permanently. Implementations may assume that the Reference is one previously obtained from this XMLStore. When the data referenced is no longer needed the XMLStore should be informed of this be calling release(Reference).

Parameters:
ref - the Reference to retain
Throws:
UnknownReferenceException

release

public void release(Reference ref)
             throws UnknownReferenceException
Informs the XMLStore that the data referenced by the specified Reference is no longer needed. The XMLStore should previously have been informed to retain the data using the retain(Reference) method. More specifically, implementations may assume that the argument of this method, or one equal to it, has previously been an argument to retain.

Parameters:
ref - the Reference to release
Throws:
UnknownReferenceException

addReferenceListener

public void addReferenceListener(ReferenceListener listener)
Adds the specified ReferenceListener for receiving Reference events.

Parameters:
listener - the listener to add

removeReferenceListener

public void removeReferenceListener(ReferenceListener listener)
Removes the specified ReferenceListener previously added with addReferenceListener.

Parameters:
listener - the listener to remove

size

public long size()
          throws IOException
Returns the disk size of this LocalXMLStore.

Throws:
IOException

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

toString

public String toString()
Overrides:
toString in class AbstractXMLStore

checkClosed

protected void checkClosed()
Overrides:
checkClosed in class AbstractXMLStore


Copyright © 2010. All Rights Reserved.