class TxnManagerTransaction extends Object implements TransactionConstants, TimeConstants, LeasedResource
Modifier and Type | Field and Description |
---|---|
private long |
expires |
private Job |
job |
private Object |
jobLock
Interlock for Jobs is needed since many
threads on behalf of many clients can
simultaneously access or modify the Job
associated with this transaction when
when attempting to prepare, roll forward
or roll back participants.
|
private Object |
leaseLock
Interlock for the expiration time since
lease renewal which set it may compete
against lease checks which read it.
|
private LogManager |
logmgr |
private static Logger |
operationsLogger
Logger for operation related messages
|
private List |
parts |
(package private) static long |
serialVersionUID |
private TxnSettler |
settler |
private Object |
stateLock
Interlock for transaction state needed
since many threads on behalf of many
clients can simultaneously access or
attempt to modify this transaction's
state as a side effect of calling
commit or abort.
|
private static boolean[][] |
states |
private ServerTransaction |
str |
private TaskManager |
threadpool
"Parallelizing" the interaction between the manager
and participants means using threads to interact with
participants on behalf of the manager.
|
private static Logger |
transactionsLogger
Logger for transaction related messages
|
private int |
trstate |
private Uuid |
uuid |
private WakeupManager |
wm |
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING
DAYS, HOURS, MINUTES, SECONDS
Constructor and Description |
---|
TxnManagerTransaction(TransactionManager mgr,
LogManager logmgr,
long id,
TaskManager threadpool,
WakeupManager wm,
TxnSettler settler,
Uuid uuid)
Constructs a
TxnManagerTransaction |
Modifier and Type | Method and Description |
---|---|
(package private) void |
abort(long waitFor)
Aborts the transaction.
|
(package private) void |
add(ParticipantHandle handle)
Convenience method which adds a given
ParticipantHandle
to the set of ParticpantHandle s associated with this
transaction. |
(package private) void |
commit(long waitFor)
Commits the transaction.
|
private void |
doAbort(long timeout) |
(package private) boolean |
ensureCurrent() |
Uuid |
getCookie()
Returns the universally unique identifier associated with this
lease.
|
long |
getExpiration()
Returns the expiration time of the lease.
|
private String |
getParticipantInfo() |
int |
getState()
This method returns the state of the transaction.
|
Transaction |
getTransaction() |
void |
join(TransactionParticipant preparedPart,
long crashCount)
Implementation of the join method.
|
(package private) void |
modifyParticipant(ParticipantHandle handle,
int state)
Convenience method which allows the caller to modify the
prepState associated with a given
ParticipantHandle |
(package private) boolean |
modifyTxnState(int state)
Changes the manager-side state of the transaction.
|
private Vector |
parthandles() |
(package private) void |
restoreTransientState(ProxyPreparer preparer) |
void |
setExpiration(long newExpiration)
Changes the expiration time of the lease.
|
static final long serialVersionUID
private static final boolean[][] states
private List parts
private final ServerTransaction str
private int trstate
private long expires
private LogManager logmgr
private TaskManager threadpool
private WakeupManager wm
private TxnSettler settler
private Job job
private Uuid uuid
private Object leaseLock
private Object jobLock
private Object stateLock
private static final Logger operationsLogger
private static final Logger transactionsLogger
TxnManagerTransaction(TransactionManager mgr, LogManager logmgr, long id, TaskManager threadpool, WakeupManager wm, TxnSettler settler, Uuid uuid)
TxnManagerTransaction
mgr
- TransactionManager
which owns
this internal representation.logmgr
- LogManager
responsible for
recording COMMITTED and ABORTED transactions
to stable storage.id
- The transaction idthreadpool
- The TaskManager
which provides
the pool of threads used to interact with
participants.settler
- TxnSettler responsible for this transaction if
unsettled.void add(ParticipantHandle handle) throws InternalManagerException
ParticipantHandle
to the set of ParticpantHandle
s associated with this
transaction.handle
- The added handleInternalManagerException
void modifyParticipant(ParticipantHandle handle, int state)
ParticipantHandle
handle
- The ParticipantHandle
being modifiedstate
- The new prepstateboolean modifyTxnState(int state)
state
- the new desired statepublic void join(TransactionParticipant preparedPart, long crashCount) throws CannotJoinException, CrashCountException, RemoteException
preparedPart
- The joining TransactionParticpant
crashCount
- The crashcount associated with the joining
TransactionParticipant
CannotJoinException
CrashCountException
RemoteException
TransactionParticipant
public int getState()
void commit(long waitFor) throws CannotCommitException, TimeoutExpiredException, RemoteException
net.jini.core.transaction.server.TransactionParticipant
in the set of participants joined in the
net.jini.core.transaction.server.Transaction
is instructed to vote and the votes are tallied. This is the
first phase (prepare phase).
Depending on the outcome of the votes, the transaction
is considered committed or aborted. Once commit/abort
status is known, the participants are notified with
a message to either roll-forward (commit case) or
roll-back (abort case). This is the roll-phase.
Since there may be a one-to-many relationship between
a transaction and its participants,
com.sun.jini.thread.TaskManager
s are used
as a generic mechanism to provide the threads needed
to interact with the participants.void abort(long waitFor) throws CannotAbortException, TimeoutExpiredException
waitFor
- Timeout value which controls how long,
the caller is willing to wait for the
participants joined in the transaction
to be instructed to roll-back.CannotAbortException
TimeoutExpiredException
AbortJob
,
ParticipantTask
,
TaskManager
,
TransactionParticipant
public Transaction getTransaction()
public long getExpiration()
LeasedResource
getExpiration
in interface LeasedResource
public void setExpiration(long newExpiration)
LeasedResource
setExpiration
in interface LeasedResource
newExpiration
- The new expiration time in milliseconds
since the beginning of the epochpublic Uuid getCookie()
LeasedResource
ReferentUuid
should return this object from their
getReferentUuid
method and should base their implementation of equals
on
this object.getCookie
in interface LeasedResource
private void doAbort(long timeout)
boolean ensureCurrent()
private Vector parthandles()
private String getParticipantInfo()
void restoreTransientState(ProxyPreparer preparer) throws RemoteException
RemoteException
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.