public class AbstractTransactionService.TxState extends Object implements ITxState
ITransactionService
.
Note: The commitTime and revisionTime are requested by the local transaction manager for single phase commits, which means that this class could only know their values for a distributed transaction commit. Hence they are not represented here.
Modifier and Type | Field and Description |
---|---|
protected ReentrantLock |
lock
A per-transaction lock used to serialize operations on a given
transaction.
|
long |
tx
The transaction identifier.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractTransactionService.TxState(long tx,
long readCommitTime) |
Modifier and Type | Method and Description |
---|---|
void |
declareResources(UUID dataService,
String[] resource)
Declares resources on a data service instance on which the
transaction will write.
|
boolean |
equals(Object o)
True iff they are the same object or have the same start timestamp.
|
long |
getCommitTime()
The commit time assigned to a distributed read-write transaction
during the commit protocol.
|
int |
getDataServiceCount()
Return the #of
IDataService s on which a read-write
transaction has executed an operation. |
protected UUID[] |
getDataServiceUUIDs()
The set of
DataService s on which the transaction has
written. |
long |
getReadsOnCommitTime()
The timestamp of the commit point against which this transaction is
reading.
|
String[] |
getResources()
Return the resources declared by the transaction.
|
long |
getStartTimestamp()
The start time for the transaction as assigned by a centralized
transaction manager service.
|
int |
hashCode()
The hash code is based on the
getStartTimestamp() . |
boolean |
isAborted()
A transaction is "aborted" iff it has successfully aborted.
|
boolean |
isActive()
A transaction is "active" when it is created and remains active until it
prepares or aborts.
|
boolean |
isCommitted()
A transaction is "committed" iff it has successfully committed.
|
boolean |
isComplete()
A transaction is "complete" once has either committed or aborted.
|
boolean |
isPrepared()
A transaction is "prepared" once it has been successfully validated and
has fulfilled its pre-commit contract for a multi-stage commit protocol.
|
boolean |
isReadOnly()
Return
true iff this is a read-only transaction. |
boolean |
isStartedOn(UUID dataServiceUUID)
Return
true iff the dataService identified by the
UUID is one on which this transaction has been started. |
protected void |
setCommitTime(long commitTime)
Sets the assigned commit time.
|
void |
setRunState(RunState newval)
Change the
RunState . |
String |
toString()
Returns a string representation of the transaction state.
|
public final long tx
protected final ReentrantLock lock
RunState
.
Note: DO NOT attempt to acquire the outer
AbstractTransactionService.lock
if you are already holding
this lock
. This is a lock ordering problem and can result in
a deadlock.
protected AbstractTransactionService.TxState(long tx, long readCommitTime)
tx
- The assigned transaction identifier.readCommitTime
- The commit time associated with the commit point against
which this transaction will read (may be ZERO if there are
no commit points, must not be negative).public void setRunState(RunState newval)
RunState
.newval
- The new RunState
.IllegalArgumentException
- if the argument is null
.IllegalStateException
- if the state transition is not allowed.RunState.isTransitionAllowed(RunState)
public final long getStartTimestamp()
ITxState0
getStartTimestamp
in interface ITxState0
TODO Rename since the sign indicates read-only vs read-write and
hence it can not be directly interpreted as a commitTime? (e.g.,
getTxId()).
public final long getReadsOnCommitTime()
ITxState0
Note: This is not currently available on a cluster. In that context, we
wind up with the same timestamp for #startTime
and
#readsOnCommitTime
which causes cache pollution for things which
cache based on #readsOnCommitTime
.
getReadsOnCommitTime
in interface ITxState0
public long getCommitTime()
IllegalStateException
- if the commit time has not been assigned.protected void setCommitTime(long commitTime)
commitTime
- The assigned commit time.public String[] getResources()
public boolean isStartedOn(UUID dataServiceUUID)
true
iff the dataService identified by the
UUID
is one on which this transaction has been started.dataServiceUUID
- The UUID
identifying an IDataService
.true
if this transaction has been started on
that IDataService
. false
for
read-only transactions.protected UUID[] getDataServiceUUIDs()
DataService
s on which the transaction has
written.IllegalStateException
- if not a read-write transaction.public final int hashCode()
getStartTimestamp()
.public final boolean equals(Object o)
public final void declareResources(UUID dataService, String[] resource)
dataService
- The data service identifier.resource
- An array of named resources on the data service on which
the transaction will write (or at least for which it
requires an exclusive write lock).IllegalStateException
- if the transaction is read-only.IllegalStateException
- if the transaction is not active.public final int getDataServiceCount()
IDataService
s on which a read-write
transaction has executed an operation.IDataService
.IllegalStateException
- if the transaction is read-only.IllegalMonitorStateException
- if the caller does not hold the lock.public final String toString()
public final boolean isReadOnly()
ITxState
true
iff this is a read-only transaction.isReadOnly
in interface ITxState
public final boolean isActive()
ITxState
public final boolean isPrepared()
ITxState
Note: This is a transient state. Once the transaction has prepared it
will transition to either COMMIT or ABORT and this method will no longer
report true
.
isPrepared
in interface ITxState
public final boolean isComplete()
ITxState
isComplete
in interface ITxState
public final boolean isCommitted()
ITxState
isCommitted
in interface ITxState
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.