protected static class TestTransactionService.MockTransactionService extends AbstractTransactionService
AbstractTransactionService.Options, AbstractTransactionService.TxState
ERR_NO_SUCH, ERR_NOT_ACTIVE, ERR_READ_ONLY, ERR_SERVICE_NOT_AVAIL, lock, log, txDeactivate
Constructor and Description |
---|
TestTransactionService.MockTransactionService(Properties p) |
Modifier and Type | Method and Description |
---|---|
protected void |
abortImpl(AbstractTransactionService.TxState state)
Implementation must abort the tx on the journal (standalone) or on each
data service (federation) on which it has written.
|
void |
awaitRunState(TxServiceRunState expectedRunState)
Awaits the specified run state.
|
protected long |
commitImpl(AbstractTransactionService.TxState state)
Implementation must either single-phase commit (standalone journal or a
transaction that only writes on a single data service) or 2-/3-phase
commit (distributed transaction running on a federation).
|
protected long |
findCommitTime(long timestamp)
Find the commit time from which the tx will read (largest commitTime LTE
timestamp).
|
protected long |
findNextCommitTime(long commitTime)
Return the commit time for the successor of that commit point have the
specified timestamp (a commit time strictly GT the given value).
|
protected AbstractTransactionService.TxState |
getEarliestActiveTx()
Return the
AbstractTransactionService.TxState for the earliest active Tx -or-
null if there is no active tx. |
AbstractFederation<?> |
getFederation()
Return the proxy used to access other services in the federation.
|
long |
getLastCommitTime()
Note: Declared abstract so that we can hide the
IOException . |
protected long |
getReadsOnTime(long txId)
Return the commit time on which the transaction is reading.
|
protected AbstractTransactionService.TxState |
getTxState(long txId)
Return the
AbstractTransactionService.TxState associated with the specified transition
identifier. |
long |
nextTimestamp()
Note: This currently waits until at least two milliseconds have
elapsed.
|
void |
notifyCommit(long commitTime)
The basic implementation advances the release time periodically as
commits occur even when there are no transactions in use.
|
TestTransactionService.MockTransactionService |
start()
Verifies that
AbstractTransactionService.nextTimestamp() will not report a time before
AbstractTransactionService.getLastCommitTime() and then changes the TxServiceRunState
to TxServiceRunState.Running . |
abort, abortAllTx, activateTx, assertOpen, assignTransactionIdentifier, commit, deactivateTx, destroy, findUnusedTimestamp, getAbortCount, getActiveCount, getCommitCount, getCounters, getEffectiveReleaseTimeForHA, getMinReleaseAge, getProperties, getReadOnlyActiveCount, getReadWriteActiveCount, getReleaseTime, getRunState, getServiceIface, getStartCount, isOpen, isReleaseTimeConsensusProtocol, newTx, setReleaseTime, setRunState, shutdown, shutdownNow, updateReleaseTime, updateReleaseTimeForBareCommit
clearLoggingContext, getHostname, getServiceName, getServiceUUID, setServiceUUID, setupLoggingContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHostname, getServiceName, getServiceUUID
public TestTransactionService.MockTransactionService(Properties p)
public TestTransactionService.MockTransactionService start()
AbstractTransactionService
AbstractTransactionService.nextTimestamp()
will not report a time before
AbstractTransactionService.getLastCommitTime()
and then changes the TxServiceRunState
to TxServiceRunState.Running
.start
in class AbstractTransactionService
protected long getReadsOnTime(long txId)
AbstractTransactionService
Note: This method is exposed primarily for the unit tests.
getReadsOnTime
in class AbstractTransactionService
txId
- The transaction identifier.public AbstractFederation<?> getFederation()
AbstractService
getFederation
in class AbstractService
protected void abortImpl(AbstractTransactionService.TxState state)
AbstractTransactionService
Pre-conditions:
RunState.Active
; andAbstractTransactionService.TxState.lock
.Post-conditions:
RunState.Aborted
; andJournal
or IDataService
or which it has written (applicable for
read-write transactions only).abortImpl
in class AbstractTransactionService
state
- The transaction state as maintained by the transaction server.protected long commitImpl(AbstractTransactionService.TxState state) throws Exception
AbstractTransactionService
Pre-conditions:
RunState.Active
; andAbstractTransactionService.TxState.lock
.Post-conditions (success for read-only transaction or a read-write transaction with an empty write set):
RunState.Committed
; andPost-conditions (success for read-write transaction with a non-empty write set):
RunState.Committed
;Journal
or IDataService
or which it has written
(applicable for read-write transactions only); andPost-conditions (failure):
RunState.Aborted
; andJournal
or IDataService
or which it has written (applicable for
read-write transactions only).commitImpl
in class AbstractTransactionService
Exception
- if something else goes wrong. This will be (or will wrap) a
ValidationError
if validation fails.public long getLastCommitTime()
AbstractTransactionService
IOException
.getLastCommitTime
in interface ITransactionService
getLastCommitTime
in class AbstractTransactionService
protected long findCommitTime(long timestamp)
AbstractTransactionService
findCommitTime
in class AbstractTransactionService
timestamp
- The timestamp.protected long findNextCommitTime(long commitTime)
AbstractTransactionService
findNextCommitTime
in class AbstractTransactionService
commitTime
- The probe.public void notifyCommit(long commitTime)
AbstractTransactionService
Note: This needs to be a fairly low-latency operation since this method is invoked for all commits on all data services and will otherwise be a global hotspot.
notifyCommit
in interface ITransactionService
notifyCommit
in class AbstractTransactionService
commitTime
- The commit time.public void awaitRunState(TxServiceRunState expectedRunState) throws InterruptedException
expectedRunState
- The expected run state.InterruptedException
AssertionError
public long nextTimestamp()
TestTransactionService.test_newTx_readOnly()
until (if) ISSUE#145 is resolved.
TODO This override of nextTimestamp()
should be removed once
that issue is fixed.nextTimestamp
in interface ITimestampService
nextTimestamp
in class AbstractTransactionService
TimestampServiceUtil.nextTimestamp(ITimestampService)
protected AbstractTransactionService.TxState getEarliestActiveTx()
AbstractTransactionService.TxState
for the earliest active Tx -or-
null
if there is no active tx.
Note: The AbstractTransactionService.lock
is required in order to make atomic decisions
about the earliest active tx. Without the AbstractTransactionService.lock
, the tx could
stop or a new tx could start, thereby invalidating the "earliest active"
guarantee.
Exposed to the test suite.
This version takes the lock since we are controlling concurrency explicitly in the test suite. This makes it easier to write the tests.
getEarliestActiveTx
in class AbstractTransactionService
protected AbstractTransactionService.TxState getTxState(long txId)
AbstractTransactionService.TxState
associated with the specified transition
identifier.
Note: This method is an internal API. The caller must adhere to the internal synchronization APIs for the transaction service.
Exposed to the test suite.
getTxState
in class AbstractTransactionService
txId
- The transaction identifier (the signed value, NOT the absolute
value).AbstractTransactionService.TxState
-or- null
if there is no such
active transaction.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.