Package com.iizix.db.prop
Class DatabaseActionTXPNode
- java.lang.Object
- com.iizix.txp.impl.AbstractTXPNode
- com.iizix.txp.impl.AbstractActionActorTXPNode<DatabaseActionActor.Settings>
- com.iizix.db.prop.DatabaseActionTXPNode
- All Implemented Interfaces:
IActionActorSettingsReceiver<DatabaseActionActor.Settings>
,ITimeoutListener
,ITXPNode
public abstract class DatabaseActionTXPNode extends AbstractActionActorTXPNode<DatabaseActionActor.Settings>
Database actor implementation for a TXP node.- Author:
- Christopher Mindus
Nested Class Summary
Nested classes/interfaces inherited from interface com.iizix.txp.ITXPNode
ITXPNode.State
Field Summary
Fields inherited from class com.iizix.txp.impl.AbstractTXPNode
hasProcessTimedOut, hasTimedOut, hasTimedOutWaiting, pid, process, state, timeout, timeoutTask, txplog
Constructor Summary
Constructors Constructor Description DatabaseActionTXPNode(VSActionTXProcess actionProcess, DatabaseActionActor.Settings settings, IDBConnectionPool pool)
Constructor.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ITXPNode.State
begin(ITXProcess process, ITXPid pid)
Notifies the node it got associated with a transactional process.ITXPNode.State
commit(ITXProcess process)
Instructs the node to commit the work.protected void
commitReadOnly()
Commits the local transaction after read only work.void
forget(ITXProcess process)
Notifies the node it got disassociated from the process ie it can abort, rollback (if needed) and forget about the process.protected java.sql.Connection
getConnection()
Returns the connection.protected void
onCleanup()
Cleans up: releases back the connection to the pool.ITXPNode.State
rollback(ITXProcess process)
Instructs the node to roll back the work.protected void
setState(ITXPNode.State state)
Sets the current state of the node.Methods inherited from class com.iizix.txp.impl.AbstractActionActorTXPNode
assignSettings, cleanUp, createLogger, execute, executeAction, getAction, getActionProcess, getLoggerInfo, getSettings, getVirtualSpace, prepare, prepareAction
Methods inherited from class com.iizix.txp.impl.AbstractTXPNode
cancelTimeout, getPid, getProcess, getState, getTimeout, hasProcessTimedOut, hasTimedOut, hasTimedOutWaiting, isIdempotent, log, onTimeout, processTimeout, ready, recover, retry, setTimeout, timeout, undo
Constructor Detail
DatabaseActionTXPNode
public DatabaseActionTXPNode(VSActionTXProcess actionProcess, DatabaseActionActor.Settings settings, IDBConnectionPool pool)
Constructor.- Parameters:
actionProcess
- The action process.settings
- Database action actor settings for transaction.pool
- The Connection pool.
Method Detail
begin
public ITXPNode.State begin(ITXProcess process, ITXPid pid)
Description copied from interface:ITXPNode
Notifies the node it got associated with a transactional process. The node should set up its local transaction context and set and respond with eitherITXPNode.State.WORKING
orITXPNode.State.FAILED
depending on its state.- Parameters:
process
- the processpid
- the pid for this node of the process- Returns:
- the state of the node
getConnection
protected java.sql.Connection getConnection()
Returns the connection.- Returns:
- The JDBC connection.
forget
public void forget(ITXProcess process)
Notifies the node it got disassociated from the process ie it can abort, rollback (if needed) and forget about the process.- Specified by:
forget
in interfaceITXPNode
- Overrides:
forget
in classAbstractActionActorTXPNode<DatabaseActionActor.Settings>
- Parameters:
process
- The process.
commit
public ITXPNode.State commit(ITXProcess process)
Description copied from interface:ITXPNode
Instructs the node to commit the work. The node should set and respond with eitherITXPNode.State.COMPLETED
orITXPNode.State.FAILED
depending on its state. If a commit failed the node is expected to have rolled back the work.- Parameters:
process
- the process- Returns:
- the state of the node
rollback
public ITXPNode.State rollback(ITXProcess process)
Description copied from interface:ITXPNode
Instructs the node to roll back the work. The node should set and respond with eitherITXPNode.State.COMPLETED
orITXPNode.State.FAILED
depending on its state. NOTE if the node failed its work it is already rolled back and will returnITXPNode.State.COMPLETED
but remain in state.ITXPNode.State.FAILED
- Parameters:
process
- the process- Returns:
- the state of the node
setState
protected void setState(ITXPNode.State state)
Sets the current state of the node. If the specified state is READ_ONLY the local transaction is committed immediately. If the state is FAILED the local transaction is immediately rolled back.- Overrides:
setState
in classAbstractActionActorTXPNode<DatabaseActionActor.Settings>
- Parameters:
state
- The state to set.
commitReadOnly
protected void commitReadOnly()
Commits the local transaction after read only work. The context is released after commit.
onCleanup
protected void onCleanup()
Cleans up: releases back the connection to the pool.- Overrides:
onCleanup
in classAbstractActionActorTXPNode<DatabaseActionActor.Settings>