jdbm.recman
Class SnapshotRecordManager

java.lang.Object
  extended by jdbm.recman.SnapshotRecordManager
All Implemented Interfaces:
ActionRecordManager, RecordManager

public class SnapshotRecordManager
extends Object
implements ActionRecordManager

TODO SnapshotRecordManager.

Author:
Apache Directory Project

Field Summary
protected  RecordManager recordManager
          Wrapped RecordManager
 
Fields inherited from interface jdbm.RecordManager
NAME_DIRECTORY_ROOT
 
Constructor Summary
SnapshotRecordManager(RecordManager recordManager, int size)
          Construct a SanshotRecordManager wrapping another RecordManager
 
Method Summary
 void abortAction(ActionContext actionContext)
          Aborts the given action.
 ActionContext beginAction(boolean readOnly, String whoStarted)
          Initializes the context for the action.
 void close()
          Closes the record manager.
 void commit()
          Commit (make persistent) all changes since beginning of transaction.
 void delete(long recid)
          Deletes a record.
 void endAction(ActionContext actionContext)
          Ends the action associated with the context.
 Object fetch(long recid)
          Fetches a record using standard Java serialization.
 Object fetch(long recid, Serializer serializer)
          Fetches a record using a custom serializer.
 long getNamedObject(String name)
          Obtain the record id of a named object.
 RecordManager getRecordManager()
          Get the underlying Record Manager.
 long getRoot(int id)
          Returns the indicated root rowid.
 int getRootCount()
          Returns the number of slots available for "root" rowids.
 long insert(Object obj)
          Inserts a new record using a custom serializer.
 long insert(Object obj, Serializer serializer)
          Inserts a new record using a custom serializer.
 void rollback()
          Rollback (cancel) all changes since beginning of transaction.
 void setCurrentActionContext(ActionContext context)
          Set the context as the current action context for the given thread
 void setNamedObject(String name, long recid)
          Set the record id of a named object.
 void setRoot(int id, long rowid)
          Sets the indicated root rowid.
 String toString()
           
 void unsetCurrentActionContext(ActionContext context)
          Unsets the context as the current action context.
 void update(long recid, Object obj)
          Updates a record using standard Java serialization.
 void update(long recid, Object obj, Serializer serializer)
          Updates a record using a custom serializer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

recordManager

protected RecordManager recordManager
Wrapped RecordManager

Constructor Detail

SnapshotRecordManager

public SnapshotRecordManager(RecordManager recordManager,
                             int size)
Construct a SanshotRecordManager wrapping another RecordManager

Parameters:
recordManager - Wrapped RecordManager
Method Detail

beginAction

public ActionContext beginAction(boolean readOnly,
                                 String whoStarted)
Initializes the context for the action. Implicity sets the context as the current action.

Specified by:
beginAction in interface ActionRecordManager
Parameters:
readOnly - true if action does not do any modification
whoStarted - caller can use this for debugging
Returns:
The created action context

setCurrentActionContext

public void setCurrentActionContext(ActionContext context)
Set the context as the current action context for the given thread

Specified by:
setCurrentActionContext in interface ActionRecordManager
Parameters:
context - identifies the context

unsetCurrentActionContext

public void unsetCurrentActionContext(ActionContext context)
Unsets the context as the current action context. Given context should be current action context for the calling thread.

Specified by:
unsetCurrentActionContext in interface ActionRecordManager
Parameters:
context - identifies the context.

endAction

public void endAction(ActionContext actionContext)
Ends the action associated with the context. ReadWrite actions' changes are made visible to readers.

Specified by:
endAction in interface ActionRecordManager
Parameters:
actionContext - identifies the action to end

abortAction

public void abortAction(ActionContext actionContext)
Aborts the given action. For write actions, actions's changes should not be made visible to readers.

Specified by:
abortAction in interface ActionRecordManager
Parameters:
actionContext - identifies the action to abort

getRecordManager

public RecordManager getRecordManager()
Get the underlying Record Manager.

Returns:
underlying RecordManager

insert

public long insert(Object obj)
            throws IOException
Inserts a new record using a custom serializer.

Specified by:
insert in interface RecordManager
Parameters:
obj - the object for the new record.
Returns:
the rowid for the new record.
Throws:
IOException - when one of the underlying I/O operations fails.

insert

public long insert(Object obj,
                   Serializer serializer)
            throws IOException
Inserts a new record using a custom serializer.

Specified by:
insert in interface RecordManager
Parameters:
obj - the object for the new record.
serializer - a custom serializer
Returns:
the rowid for the new record.
Throws:
IOException - when one of the underlying I/O operations fails.

delete

public void delete(long recid)
            throws IOException
Deletes a record.

Specified by:
delete in interface RecordManager
Parameters:
recid - the rowid for the record that should be deleted.
Throws:
IOException - when one of the underlying I/O operations fails.

update

public void update(long recid,
                   Object obj)
            throws IOException
Updates a record using standard Java serialization.

Specified by:
update in interface RecordManager
Parameters:
recid - the recid for the record that is to be updated.
obj - the new object for the record.
Throws:
IOException - when one of the underlying I/O operations fails.

update

public void update(long recid,
                   Object obj,
                   Serializer serializer)
            throws IOException
Updates a record using a custom serializer.

Specified by:
update in interface RecordManager
Parameters:
recid - the recid for the record that is to be updated.
obj - the new object for the record.
serializer - a custom serializer
Throws:
IOException - when one of the underlying I/O operations fails.

fetch

public Object fetch(long recid)
             throws IOException
Fetches a record using standard Java serialization.

Specified by:
fetch in interface RecordManager
Parameters:
recid - the recid for the record that must be fetched.
Returns:
the object contained in the record.
Throws:
IOException - when one of the underlying I/O operations fails.

fetch

public Object fetch(long recid,
                    Serializer serializer)
             throws IOException
Fetches a record using a custom serializer.

Specified by:
fetch in interface RecordManager
Parameters:
recid - the recid for the record that must be fetched.
serializer - a custom serializer
Returns:
the object contained in the record.
Throws:
IOException - when one of the underlying I/O operations fails.

close

public void close()
           throws IOException
Closes the record manager.

Specified by:
close in interface RecordManager
Throws:
IOException - when one of the underlying I/O operations fails.

getRootCount

public int getRootCount()
Returns the number of slots available for "root" rowids. These slots can be used to store special rowids, like rowids that point to other rowids. Root rowids are useful for bootstrapping access to a set of data.

Specified by:
getRootCount in interface RecordManager

getRoot

public long getRoot(int id)
             throws IOException
Returns the indicated root rowid.

Specified by:
getRoot in interface RecordManager
Throws:
IOException
See Also:
getRootCount()

setRoot

public void setRoot(int id,
                    long rowid)
             throws IOException
Sets the indicated root rowid.

Specified by:
setRoot in interface RecordManager
Throws:
IOException
See Also:
getRootCount()

commit

public void commit()
            throws IOException
Commit (make persistent) all changes since beginning of transaction.

Specified by:
commit in interface RecordManager
Throws:
IOException

rollback

public void rollback()
              throws IOException
Rollback (cancel) all changes since beginning of transaction.

Specified by:
rollback in interface RecordManager
Throws:
IOException

getNamedObject

public long getNamedObject(String name)
                    throws IOException
Obtain the record id of a named object. Returns 0 if named object doesn't exist.

Specified by:
getNamedObject in interface RecordManager
Throws:
IOException

setNamedObject

public void setNamedObject(String name,
                           long recid)
                    throws IOException
Set the record id of a named object.

Specified by:
setNamedObject in interface RecordManager
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object


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