org.apache.jackrabbit.mk.persistence
Class H2Persistence

java.lang.Object
  extended by org.apache.jackrabbit.mk.persistence.H2Persistence
All Implemented Interfaces:
Closeable, GCPersistence, Persistence

public class H2Persistence
extends Object
implements GCPersistence


Constructor Summary
H2Persistence()
           
 
Method Summary
 void close()
           
 void initialize(File homeDir)
           
 boolean markCNEMap(Id id)
          Mark a child node entry map.
 boolean markCommit(Id id)
          Mark a commit.
 boolean markNode(Id id)
          Mark a node.
 ChildNodeEntriesMap readCNEMap(Id id)
           
 StoredCommit readCommit(Id id)
           
 Id[] readIds()
          Return an array of ids, where the first is the head id (as stored with Persistence.writeHead(Id)) and the second is the highest commit id found or null.
 void readNode(StoredNode node)
          Read a node from storage.
 void replaceCommit(Id id, Commit commit)
          Replace a commit.
 void start()
          Start a GC cycle.
 int sweep()
          Sweep all objects that are not marked and were written before the GC started.
 Id writeCNEMap(ChildNodeEntries map)
           
 void writeCommit(Id id, Commit commit)
          Persist a commit with an id provided by the caller.
 void writeHead(Id id)
           
 Id writeNode(Node node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

H2Persistence

public H2Persistence()
Method Detail

initialize

public void initialize(File homeDir)
                throws Exception
Specified by:
initialize in interface Persistence
Throws:
Exception

close

public void close()
Specified by:
close in interface Closeable

readIds

public Id[] readIds()
             throws Exception
Description copied from interface: Persistence
Return an array of ids, where the first is the head id (as stored with Persistence.writeHead(Id)) and the second is the highest commit id found or null.

This method is not guaranteed to deliver "live" results, after something is written to the storage, so it should better be used once after initialization.

Specified by:
readIds in interface Persistence
Returns:
array of ids
Throws:
Exception - if an error occurs

writeHead

public void writeHead(Id id)
               throws Exception
Specified by:
writeHead in interface Persistence
Throws:
Exception

readNode

public void readNode(StoredNode node)
              throws NotFoundException,
                     Exception
Description copied from interface: Persistence
Read a node from storage.

Specified by:
readNode in interface Persistence
Parameters:
node - node to read, with id given in StoredNode.getId()
Throws:
NotFoundException - if no such node is found
Exception - if some other error occurs

writeNode

public Id writeNode(Node node)
             throws Exception
Specified by:
writeNode in interface Persistence
Throws:
Exception

readCommit

public StoredCommit readCommit(Id id)
                        throws NotFoundException,
                               Exception
Specified by:
readCommit in interface Persistence
Throws:
NotFoundException
Exception

writeCommit

public void writeCommit(Id id,
                        Commit commit)
                 throws Exception
Description copied from interface: Persistence
Persist a commit with an id provided by the caller.

Specified by:
writeCommit in interface Persistence
Parameters:
id - commit id
commit - commit
Throws:
Exception - if an error occurs

readCNEMap

public ChildNodeEntriesMap readCNEMap(Id id)
                               throws NotFoundException,
                                      Exception
Specified by:
readCNEMap in interface Persistence
Throws:
NotFoundException
Exception

writeCNEMap

public Id writeCNEMap(ChildNodeEntries map)
               throws Exception
Specified by:
writeCNEMap in interface Persistence
Throws:
Exception

start

public void start()
Description copied from interface: GCPersistence
Start a GC cycle. All objects written to the persistence in subsequent calls are marked implicitely, i.e. they must be retained on GCPersistence.sweep().

Specified by:
start in interface GCPersistence

markCommit

public boolean markCommit(Id id)
                   throws Exception
Description copied from interface: GCPersistence
Mark a commit.

Specified by:
markCommit in interface GCPersistence
Parameters:
id - commit id
Returns:
true if the commit was not marked before; false otherwise
Throws:
Exception - if an error occurs

replaceCommit

public void replaceCommit(Id id,
                          Commit commit)
                   throws Exception
Description copied from interface: GCPersistence
Replace a commit. Introduced to replace dangling parent commits where a parent commit might be collected.

Specified by:
replaceCommit in interface GCPersistence
Parameters:
id - commit id
Throws:
Exception - if an error occurs

markNode

public boolean markNode(Id id)
                 throws Exception
Description copied from interface: GCPersistence
Mark a node.

Specified by:
markNode in interface GCPersistence
Parameters:
id - node id
Returns:
true if the node was not marked before; false otherwise
Throws:
Exception - if an error occurs

markCNEMap

public boolean markCNEMap(Id id)
                   throws Exception
Description copied from interface: GCPersistence
Mark a child node entry map.

Specified by:
markCNEMap in interface GCPersistence
Parameters:
id - child node entry map id
Returns:
true if the child node entry map was not marked before; false otherwise
Throws:
Exception - if an error occurs

sweep

public int sweep()
          throws Exception
Description copied from interface: GCPersistence
Sweep all objects that are not marked and were written before the GC started.

Specified by:
sweep in interface GCPersistence
Returns:
number of swept items or -1 if number is unknown
Throws:
Exception - if an error occurs


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.