public class MemoryDB extends ObjectDB
ObjectDB.PendingTransaction, ObjectDB.UpdateMode
name, pendingByTid, rwLocks
Constructor and Description |
---|
MemoryDB(java.lang.String name,
java.security.PrivateKey privateKey)
Opens the store contained in file "var/storeName" if it exists, or an empty
store otherwise.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Gracefully shuts down the object database.
|
void |
commit(long tid,
RemoteIdentity<RemoteWorker> workerIdentity,
SubscriptionManager sm)
Causes the objects prepared in transaction [tid] to be committed.
|
boolean |
exists(long onum)
Checks whether an object with the corresponding onum exists, in either
prepared or committed form.
|
void |
finishPrepare(long tid,
Principal worker)
Notifies the database that the given transaction is finished preparing.
|
protected boolean |
isInitialized()
Determines whether the object database has been initialized.
|
long[] |
newOnums(int num)
Returns a set of onums that aren't currently occupied.
|
SerializedObject |
read(long onum)
Returns the object stored at a particular onum.
|
void |
rollback(long tid,
Principal worker)
Causes the objects prepared in transaction [tid] to be discarded.
|
protected void |
setInitialized()
Sets a flag to indicate that the object database has been initialized.
|
abortPrepare, beginTransaction, ensureInit, getName, getVersion, isPrepared, isWritten, notifyCommittedUpdate, prepareRead, prepareUpdate, readGroup, unpin
public MemoryDB(java.lang.String name, java.security.PrivateKey privateKey)
name
- name of store to create database for.public void finishPrepare(long tid, Principal worker)
ObjectDB
Notifies the database that the given transaction is finished preparing. The transaction is not considered to be prepared until this is called. After calling this method, there should not be any further calls to registerRead() or registerUpdate() for the given transaction. This method MUST be called before calling commit().
Upon receiving this call, the object database should save the prepared transaction to stable storage so that it can be recovered in case of failure.
finishPrepare
in class ObjectDB
public void commit(long tid, RemoteIdentity<RemoteWorker> workerIdentity, SubscriptionManager sm) throws AccessException
ObjectDB
commit
in class ObjectDB
tid
- the transaction idworkerIdentity
- the remote worker that is performing the commitAccessException
- if the principal differs from the caller of prepare()public void rollback(long tid, Principal worker) throws AccessException
ObjectDB
rollback
in class ObjectDB
tid
- the transaction idworker
- the principal requesting the rollbackAccessException
- if the principal differs from the caller of prepare()public SerializedObject read(long onum)
ObjectDB
public boolean exists(long onum)
ObjectDB
public long[] newOnums(int num)
ObjectDB
Returns a set of onums that aren't currently occupied. The ObjectDB may return the same onum more than once from this method, althogh doing so would encourage collisions. There is no assumption of unpredictability or randomness about the returned ids.
The returned onums should be packed in the lower 48 bits. We assume that the object database is never full, and can always provide new onums
public void close() throws java.io.IOException
ObjectDB
protected boolean isInitialized()
ObjectDB
isInitialized
in class ObjectDB
protected void setInitialized()
ObjectDB
setInitialized
in class ObjectDB