protected static class TestTransactionService.MockTransactionService extends AbstractTransactionService
AbstractTransactionService.Options, AbstractTransactionService.TxStateERR_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, updateReleaseTimeForBareCommitclearLoggingContext, getHostname, getServiceName, getServiceUUID, setServiceUUID, setupLoggingContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetHostname, getServiceName, getServiceUUIDpublic TestTransactionService.MockTransactionService(Properties p)
public TestTransactionService.MockTransactionService start()
AbstractTransactionServiceAbstractTransactionService.nextTimestamp() will not report a time before
AbstractTransactionService.getLastCommitTime() and then changes the TxServiceRunState
to TxServiceRunState.Running.start in class AbstractTransactionServiceprotected long getReadsOnTime(long txId)
AbstractTransactionServiceNote: This method is exposed primarily for the unit tests.
getReadsOnTime in class AbstractTransactionServicetxId - The transaction identifier.public AbstractFederation<?> getFederation()
AbstractServicegetFederation in class AbstractServiceprotected void abortImpl(AbstractTransactionService.TxState state)
AbstractTransactionServicePre-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 AbstractTransactionServicestate - The transaction state as maintained by the transaction server.protected long commitImpl(AbstractTransactionService.TxState state) throws Exception
AbstractTransactionServicePre-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 AbstractTransactionServiceException - if something else goes wrong. This will be (or will wrap) a
ValidationError if validation fails.public long getLastCommitTime()
AbstractTransactionServiceIOException.getLastCommitTime in interface ITransactionServicegetLastCommitTime in class AbstractTransactionServiceprotected long findCommitTime(long timestamp)
AbstractTransactionServicefindCommitTime in class AbstractTransactionServicetimestamp - The timestamp.protected long findNextCommitTime(long commitTime)
AbstractTransactionServicefindNextCommitTime in class AbstractTransactionServicecommitTime - The probe.public void notifyCommit(long commitTime)
AbstractTransactionServiceNote: 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 ITransactionServicenotifyCommit in class AbstractTransactionServicecommitTime - The commit time.public void awaitRunState(TxServiceRunState expectedRunState) throws InterruptedException
expectedRunState - The expected run state.InterruptedExceptionAssertionErrorpublic 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 ITimestampServicenextTimestamp in class AbstractTransactionServiceTimestampServiceUtil.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 AbstractTransactionServiceprotected 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 AbstractTransactionServicetxId - 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.