com.bigdata.service
Class AbstractTransactionService.TxState

java.lang.Object
  extended by com.bigdata.service.AbstractTransactionService.TxState
Enclosing class:
AbstractTransactionService

protected class AbstractTransactionService.TxState
extends Object

Transaction state as maintained by the 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.

Version:
$Id: AbstractTransactionService.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected  ReentrantLock lock
          A per-transaction lock used to serialize operations on a given transaction.
 boolean readOnly
          true iff the transaction is read-only.
 long tx
          The transaction identifier.
 
Constructor Summary
protected AbstractTransactionService.TxState(long tx)
           
 
Method Summary
 void declareResources(UUID dataService, String[] resource)
          Declares resources on a data service instance on which the transaction will write.
 boolean equals(ITx 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 IDataServices on which a read-write transaction has executed an operation.
protected  UUID[] getDataServiceUUIDs()
          The set of DataServices on which the transaction has written.
 String[] getResources()
          Return the resources declared by the transaction.
 int hashCode()
          The hash code is based on the #getStartTimestamp().
 boolean isAborted()
           
 boolean isActive()
           
 boolean isCommitted()
           
 boolean isComplete()
           
 boolean isPrepared()
           
 boolean isReadOnly()
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

tx

public final long tx
The transaction identifier.


readOnly

public final boolean readOnly
true iff the transaction is read-only.


lock

protected final ReentrantLock lock
A per-transaction lock used to serialize operations on a given transaction. You need to hold this lock for most of the operations on this class, including any access to the RunState.

Constructor Detail

AbstractTransactionService.TxState

protected AbstractTransactionService.TxState(long tx)
Method Detail

setRunState

public void setRunState(RunState newval)
Change the RunState.

Parameters:
newval - The new RunState.
Throws:
IllegalArgumentException - if the argument is null.
IllegalStateException - if the state transition is not allowed.
See Also:
RunState.isTransitionAllowed(RunState)

getCommitTime

public long getCommitTime()
The commit time assigned to a distributed read-write transaction during the commit protocol.

Returns:
The assigned commit time.
Throws:
IllegalStateException - if the commit time has not been assigned.

setCommitTime

protected void setCommitTime(long commitTime)
Sets the assigned commit time.

Parameters:
commitTime - The assigned commit time.

getResources

public String[] getResources()
Return the resources declared by the transaction.


isStartedOn

public boolean isStartedOn(UUID dataServiceUUID)
Return true iff the dataService identified by the UUID is one on which this transaction has been started.

Parameters:
dataServiceUUID - The UUID identifying an IDataService.
Returns:
true if this transaction has been started on that IDataService. false for read-only transactions.

getDataServiceUUIDs

protected UUID[] getDataServiceUUIDs()
The set of DataServices on which the transaction has written.

Throws:
IllegalStateException - if not a read-write transaction.

hashCode

public final int hashCode()
The hash code is based on the #getStartTimestamp().

Overrides:
hashCode in class Object

equals

public final boolean equals(ITx o)
True iff they are the same object or have the same start timestamp.

Parameters:
o - Another transaction object.

declareResources

public final void declareResources(UUID dataService,
                                   String[] resource)
Declares resources on a data service instance on which the transaction will write.

Parameters:
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).
Throws:
IllegalStateException - if the transaction is read-only.
IllegalStateException - if the transaction is not active.

getDataServiceCount

public final int getDataServiceCount()
Return the #of IDataServices on which a read-write transaction has executed an operation.

Returns:
The #of IDataService.
Throws:
IllegalStateException - if the transaction is read-only.
IllegalMonitorStateException - if the caller does not hold the lock.

toString

public final String toString()
Returns a string representation of the transaction state.

Overrides:
toString in class Object

isReadOnly

public final boolean isReadOnly()

isActive

public final boolean isActive()

isPrepared

public final boolean isPrepared()

isComplete

public final boolean isComplete()

isCommitted

public final boolean isCommitted()

isAborted

public final boolean isAborted()


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.