org.planx.xmlstore.regions
Class Region

java.lang.Object
  extended by org.planx.xmlstore.regions.Region

public class Region
extends Object

A Region is a collection of nodes. There are only two ways a Region is changed: When it is first not closed and exists only in memory, new nodes can be added with the save method and outgoing inter-region pointers will be found at once and the incoming sets of the target regions updated. Thus, in this case, when persisting the (non-closed) region it is not necessary to scan for outgoing pointers. Also, in this case, the identifier of the region is not changed.

Second, the Sharer may update data through the use of a region node. This is obtained by calling getRegionRoot(org.planx.xmlstore.regions.Region). See the Sharer code for the sequence of steps needed to ensure consistency of incoming and outgoing sets when several regions are shared at the same time.

Should be synchronized externally.

Author:
Thomas Ambus

Nested Class Summary
static class Region.Statistics
           
 
Method Summary
 void cache()
          Load this Region to memory.
 void flush()
          Flushes this Region from memory by persisting it and releasing memory.
 LocalLocator getBound()
           
 Group getGroup()
           
 FileSystemIdentifier getIdentifier()
           
 int getLocalId()
          A local unique identifier useful for making a total order on regions for consistent canonical node choosing policies.
 int incomingSize()
           
 boolean isCached()
          Returns true if this Region is currently in memory.
 boolean isClosed()
          Returns true if this Region is closed for¨ further application writes (the sharer may still modify the region).
 boolean isContained(LocalLocator loc)
          Returns true if the specified LocalLocator points to data in this Region.
 boolean isPersisted()
          Returns true if the on-disk representation of this Region is up-to-date.
 SystemNode load(LocalLocator loc, Reference secondaryRef)
          Loads the node with the specified locator from this region.
 int originalSize()
           
 int outgoingSize()
           
 void persist()
          Persists the in-memory version of this Region to disk.
 LocalLocator save(SystemNode node)
          Can only save to non-closed Region.
 void setGroup(Group group)
           
 int size()
           
 Region.Statistics statistics()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

isContained

public boolean isContained(LocalLocator loc)
Returns true if the specified LocalLocator points to data in this Region.


isClosed

public boolean isClosed()
Returns true if this Region is closed for¨ further application writes (the sharer may still modify the region).


isCached

public boolean isCached()
Returns true if this Region is currently in memory.


isPersisted

public boolean isPersisted()
Returns true if the on-disk representation of this Region is up-to-date.


getGroup

public Group getGroup()

setGroup

public void setGroup(Group group)

getLocalId

public int getLocalId()
A local unique identifier useful for making a total order on regions for consistent canonical node choosing policies.


getIdentifier

public FileSystemIdentifier getIdentifier()

getBound

public LocalLocator getBound()

load

public SystemNode load(LocalLocator loc,
                       Reference secondaryRef)
                throws IOException,
                       UnknownReferenceException
Loads the node with the specified locator from this region. TODO: The second argument has been deprecated, please remove.

Throws:
IOException
UnknownReferenceException

save

public LocalLocator save(SystemNode node)
                  throws IOException
Can only save to non-closed Region.

Throws:
IOException

cache

public void cache()
           throws IOException,
                  UnknownReferenceException
Load this Region to memory.

Throws:
IOException
UnknownReferenceException

flush

public void flush()
           throws IOException,
                  UnknownReferenceException
Flushes this Region from memory by persisting it and releasing memory.

Throws:
IOException
UnknownReferenceException

persist

public void persist()
             throws IOException,
                    UnknownReferenceException
Persists the in-memory version of this Region to disk.

Throws:
IOException
UnknownReferenceException

toString

public String toString()
Overrides:
toString in class Object

size

public int size()

originalSize

public int originalSize()

incomingSize

public int incomingSize()

outgoingSize

public int outgoingSize()

statistics

public Region.Statistics statistics()


Copyright © 2010. All Rights Reserved.