|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.neodatis.odb.impl.core.transaction.DefaultTransaction
public class DefaultTransaction
The transaction class is used to guarantee ACID behavior. It keep tracks of all session operations. It uses the WriteAction class to store all changes that can not be written to the file before the commit. The transaction is held by The Session class and manage commits and rollbacks. All WriteActions are written in a transaction file to be sure to be able to commit and in case of very big transaction where all WriteActions can not be stored in memory.
Field Summary | |
---|---|
IWriteAction |
currentWriteAction
The same write action is reused for successive writes |
long |
currentWritePositionInWA
The position of the next write for WriteAction |
IFileSystemInterface |
fsi
A file interface to the transaction file - used to read/write the file |
static java.lang.String |
LOG_ID
the log module name |
int |
numberOfWriteActions
The number of write actions |
ISession |
session
The transaction session |
Constructor Summary | |
---|---|
DefaultTransaction(ISession session)
The main constructor |
|
DefaultTransaction(ISession session,
IFileSystemInterface fsiToApplyTransaction)
|
|
DefaultTransaction(ISession session,
java.lang.String overrideTransactionName)
|
Method Summary | |
---|---|
void |
addWriteAction(IWriteAction writeAction)
Adds a write action to the transaction |
void |
addWriteAction(IWriteAction writeAction,
boolean persistWriteAcion)
Adds a write action to the transaction |
ClassInfo |
buildClassInfoForCommit(ClassInfo classInfo)
Shift all unconnected infos to connected (committed) infos |
void |
clear()
clear the transaction |
void |
commit()
Execute the commit process of the transaction |
protected void |
commitMetaModel()
Used to commit meta model : classes This is useful when running in client server mode TODO Check this |
protected void |
delete()
deletes the transaction file |
long |
getCreationDateTime()
|
IFileSystemInterface |
getFsi()
|
java.lang.String |
getName()
|
int |
getNumberOfWriteActions()
|
(package private) IBaseIdentification |
getParameters(boolean canWrite)
|
IOdbList<IWriteAction> |
getWriteActions()
|
void |
init(ISession session)
|
boolean |
isArchiveLog()
|
boolean |
isCommited()
|
void |
loadWriteActions(boolean apply)
|
void |
loadWriteActions(java.lang.String filename,
boolean apply)
|
void |
loadWriteActionsBackwards(java.lang.String filename,
boolean apply)
|
void |
manageWriteAction(long position,
byte[] bytes)
The public method to add a write action to the transaction. |
protected void |
persist()
|
static DefaultTransaction |
read(java.lang.String fileName)
|
void |
reset()
Reset the transaction |
void |
rollback()
|
void |
setArchiveLog(boolean archiveLog)
|
void |
setFsiToApplyWriteActions(IFileSystemInterface fsi)
|
void |
setWritePosition(long position)
Set the write position (position in main database file). |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String LOG_ID
public IWriteAction currentWriteAction
public long currentWritePositionInWA
public int numberOfWriteActions
public IFileSystemInterface fsi
public ISession session
Constructor Detail |
---|
public DefaultTransaction(ISession session) throws java.io.IOException
session
- The transaction session
java.io.IOException
public DefaultTransaction(ISession session, java.lang.String overrideTransactionName) throws java.io.IOException
java.io.IOException
public DefaultTransaction(ISession session, IFileSystemInterface fsiToApplyTransaction)
Method Detail |
---|
public void init(ISession session)
public void clear()
ITransaction
clear
in interface ITransaction
public void reset()
reset
in interface ITransaction
public void addWriteAction(IWriteAction writeAction)
writeAction
- The write action to be addedpublic void addWriteAction(IWriteAction writeAction, boolean persistWriteAcion)
writeAction
- The write action to be addedpersistWriteAcion
- To indicate if write action must be persistedpublic java.lang.String getName()
getName
in interface ITransaction
IBaseIdentification getParameters(boolean canWrite)
protected void persist()
public IOdbList<IWriteAction> getWriteActions()
public long getCreationDateTime()
public boolean isCommited()
isCommited
in interface ITransaction
public void rollback()
rollback
in interface ITransaction
public void commit()
ITransaction
commit
in interface ITransaction
protected void commitMetaModel()
public ClassInfo buildClassInfoForCommit(ClassInfo classInfo)
classInfo
-
public static DefaultTransaction read(java.lang.String fileName) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public void loadWriteActions(boolean apply)
public void loadWriteActions(java.lang.String filename, boolean apply)
public void loadWriteActionsBackwards(java.lang.String filename, boolean apply) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
protected void delete()
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public void setFsiToApplyWriteActions(IFileSystemInterface fsi)
setFsiToApplyWriteActions
in interface ITransaction
public boolean isArchiveLog()
isArchiveLog
in interface ITransaction
public void setArchiveLog(boolean archiveLog)
setArchiveLog
in interface ITransaction
archiveLog
- The archiveLog to set.public int getNumberOfWriteActions()
getNumberOfWriteActions
in interface ITransaction
public IFileSystemInterface getFsi() throws java.io.IOException
java.io.IOException
public void setWritePosition(long position)
setWritePosition
in interface ITransaction
position
- public void manageWriteAction(long position, byte[] bytes)
ITransaction
manageWriteAction
in interface ITransaction
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |