public class SnapshotRecordManager extends java.lang.Object implements ActionRecordManager
| Modifier and Type | Class and Description |
|---|---|
private class |
SnapshotRecordManager.RecordIO |
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.ThreadLocal<ActionContext> |
actionContextVar
Per thread action context
|
(package private) java.util.concurrent.locks.Lock |
bigLock
Lock used to serialize write actions and some management operatins
|
(package private) SnapshotRecordManager.RecordIO |
recordIO
Passed to cache as IO callback
|
protected RecordManager |
recordManager
Wrapped RecordManager
|
(package private) LRUCache<java.lang.Long,java.lang.Object> |
versionedCache
Versioned cache
|
(package private) ActionVersioning |
versioning
Used for keeping track of actions versions
|
NAME_DIRECTORY_ROOT| Constructor and Description |
|---|
SnapshotRecordManager(RecordManager recordManager,
int size)
Construct a SanshotRecordManager wrapping another RecordManager
|
| Modifier and Type | Method and Description |
|---|---|
void |
abortAction(ActionContext actionContext)
Aborts the given action.
|
ActionContext |
beginAction(boolean readOnly,
java.lang.String whoStarted)
Initializes the context for the action.
|
private void |
checkIfClosed()
Check if RecordManager has been closed.
|
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.
|
java.lang.Object |
fetch(long recid)
Fetches a record using standard Java serialization.
|
java.lang.Object |
fetch(long recid,
Serializer serializer)
Fetches a record using a custom serializer.
|
long |
getNamedObject(java.lang.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(java.lang.Object obj)
Inserts a new record using a custom serializer.
|
long |
insert(java.lang.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(java.lang.String name,
long recid)
Set the record id of a named object.
|
void |
setRoot(int id,
long rowid)
Sets the indicated root rowid.
|
java.lang.String |
toString() |
void |
unsetCurrentActionContext(ActionContext context)
Unsets the context as the current action context.
|
void |
update(long recid,
java.lang.Object obj)
Updates a record using standard Java serialization.
|
void |
update(long recid,
java.lang.Object obj,
Serializer serializer)
Updates a record using a custom serializer.
|
protected RecordManager recordManager
private static final java.lang.ThreadLocal<ActionContext> actionContextVar
ActionVersioning versioning
LRUCache<java.lang.Long,java.lang.Object> versionedCache
SnapshotRecordManager.RecordIO recordIO
java.util.concurrent.locks.Lock bigLock
public SnapshotRecordManager(RecordManager recordManager, int size)
recordManager - Wrapped RecordManagerpublic ActionContext beginAction(boolean readOnly, java.lang.String whoStarted)
beginAction in interface ActionRecordManagerreadOnly - true if action does not do any modificationwhoStarted - caller can use this for debuggingpublic void setCurrentActionContext(ActionContext context)
setCurrentActionContext in interface ActionRecordManagercontext - identifies the contextpublic void unsetCurrentActionContext(ActionContext context)
unsetCurrentActionContext in interface ActionRecordManagercontext - identifies the context.public void endAction(ActionContext actionContext)
endAction in interface ActionRecordManageractionContext - identifies the action to endpublic void abortAction(ActionContext actionContext)
abortAction in interface ActionRecordManageractionContext - identifies the action to abortpublic RecordManager getRecordManager()
public long insert(java.lang.Object obj)
throws java.io.IOException
insert in interface RecordManagerobj - the object for the new record.java.io.IOException - when one of the underlying I/O operations fails.public long insert(java.lang.Object obj,
Serializer serializer)
throws java.io.IOException
insert in interface RecordManagerobj - the object for the new record.serializer - a custom serializerjava.io.IOException - when one of the underlying I/O operations fails.public void delete(long recid)
throws java.io.IOException
delete in interface RecordManagerrecid - the rowid for the record that should be deleted.java.io.IOException - when one of the underlying I/O operations fails.public void update(long recid,
java.lang.Object obj)
throws java.io.IOException
update in interface RecordManagerrecid - the recid for the record that is to be updated.obj - the new object for the record.java.io.IOException - when one of the underlying I/O operations fails.public void update(long recid,
java.lang.Object obj,
Serializer serializer)
throws java.io.IOException
update in interface RecordManagerrecid - the recid for the record that is to be updated.obj - the new object for the record.serializer - a custom serializerjava.io.IOException - when one of the underlying I/O operations fails.public java.lang.Object fetch(long recid)
throws java.io.IOException
fetch in interface RecordManagerrecid - the recid for the record that must be fetched.java.io.IOException - when one of the underlying I/O operations fails.public java.lang.Object fetch(long recid,
Serializer serializer)
throws java.io.IOException
fetch in interface RecordManagerrecid - the recid for the record that must be fetched.serializer - a custom serializerjava.io.IOException - when one of the underlying I/O operations fails.public void close()
throws java.io.IOException
close in interface RecordManagerjava.io.IOException - when one of the underlying I/O operations fails.public int getRootCount()
getRootCount in interface RecordManagerpublic long getRoot(int id)
throws java.io.IOException
getRoot in interface RecordManagerjava.io.IOExceptiongetRootCount()public void setRoot(int id,
long rowid)
throws java.io.IOException
setRoot in interface RecordManagerjava.io.IOExceptiongetRootCount()public void commit()
throws java.io.IOException
commit in interface RecordManagerjava.io.IOExceptionpublic void rollback()
throws java.io.IOException
rollback in interface RecordManagerjava.io.IOExceptionpublic long getNamedObject(java.lang.String name)
throws java.io.IOException
getNamedObject in interface RecordManagerjava.io.IOExceptionpublic void setNamedObject(java.lang.String name,
long recid)
throws java.io.IOException
setNamedObject in interface RecordManagerjava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Objectprivate void checkIfClosed()
throws java.lang.IllegalStateException
java.lang.IllegalStateException