com.bigdata.journal
Class JournalTransactionService

java.lang.Object
  extended by com.bigdata.service.AbstractService
      extended by com.bigdata.service.AbstractTransactionService
          extended by com.bigdata.journal.JournalTransactionService
All Implemented Interfaces:
ICounterSetAccess, ITimestampService, ITransactionService, IService, IServiceShutdown, Remote

public class JournalTransactionService
extends AbstractTransactionService

Implementation for a standalone journal using single-phase commits.

Version:
$Id: JournalTransactionService.java 6275 2012-04-11 20:01:12Z thompsonbry $
Author:
Bryan Thompson

Nested Class Summary
static class JournalTransactionService.SinglePhaseCommit
          This task is an UNISOLATED operation that validates and commits a transaction known to have non-empty write sets.
 
Nested classes/interfaces inherited from class com.bigdata.service.AbstractTransactionService
AbstractTransactionService.Options, AbstractTransactionService.TxState
 
Field Summary
protected  Journal journal
           
 
Fields inherited from class com.bigdata.service.AbstractTransactionService
ERR_NO_SUCH, ERR_NOT_ACTIVE, ERR_READ_ONLY, ERR_SERVICE_NOT_AVAIL, lock, log, startTimeIndex, txDeactivate
 
Constructor Summary
JournalTransactionService(Properties properties, Journal journal)
           
 
Method Summary
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.
protected  void activateTx(AbstractTransactionService.TxState state)
          Extended to register the new tx in the AbstractLocalTransactionManager.
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).
 boolean committed(long tx, UUID dataService)
          Throws exception since distributed transactions are not used for a single Journal.
protected  void deactivateTx(AbstractTransactionService.TxState state)
          Removes the transaction from the local tables.
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).
 AbstractFederation getFederation()
          Throws exception.
 long getLastCommitTime()
          The last commit time from the current root block.
 long prepared(long tx, UUID dataService)
          Throws exception since distributed transactions are not used for a single Journal.
 JournalTransactionService start()
          Verifies that AbstractTransactionService.nextTimestamp() will not report a time before AbstractTransactionService.getLastCommitTime() and then changes the TxServiceRunState to TxServiceRunState.Running.
 
Methods inherited from class com.bigdata.service.AbstractTransactionService
abort, assertOpen, assignTransactionIdentifier, commit, declareResources, destroy, findUnusedTimestamp, getAbortCount, getActiveCount, getCommitCount, getCounters, getMinReleaseAge, getProperties, getReadOnlyActiveCount, getReadsOnTime, getReadWriteActiveCount, getReleaseTime, getRunState, getServiceIface, getStartCount, getStartTime, isOpen, newTx, nextTimestamp, notifyCommit, setReleaseTime, setRunState, shutdown, shutdownNow, updateReleaseTime, updateReleaseTimeForBareCommit
 
Methods inherited from class com.bigdata.service.AbstractService
clearLoggingContext, getHostname, getServiceName, getServiceUUID, setServiceUUID, setupLoggingContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bigdata.service.IService
getHostname, getServiceName, getServiceUUID
 

Field Detail

journal

protected final Journal journal
Constructor Detail

JournalTransactionService

public JournalTransactionService(Properties properties,
                                 Journal journal)
Parameters:
properties -
Method Detail

start

public JournalTransactionService start()
Description copied from class: AbstractTransactionService
Verifies that AbstractTransactionService.nextTimestamp() will not report a time before AbstractTransactionService.getLastCommitTime() and then changes the TxServiceRunState to TxServiceRunState.Running.

Overrides:
start in class AbstractTransactionService
Returns:
this (the return type should be strengthened by the concrete implementation to return the actual type).

activateTx

protected void activateTx(AbstractTransactionService.TxState state)
Extended to register the new tx in the AbstractLocalTransactionManager.

Overrides:
activateTx in class AbstractTransactionService
Parameters:
state - The transaction.

deactivateTx

protected void deactivateTx(AbstractTransactionService.TxState state)
Description copied from class: AbstractTransactionService
Removes the transaction from the local tables.

Note: The caller MUST own AbstractTransactionService.TxState.lock across this method and MUST then do

 updateReleaseTime(long)
 deactivateTx.signallAll()
 
while holding the outer AbstractTransactionService.lock.

Note: Normally this method is invoked without the outer AbstractTransactionService.lock which necessitates lifting those method calls out of this method and into the caller.

Overrides:
deactivateTx in class AbstractTransactionService
Parameters:
state - The transaction.

findCommitTime

protected long findCommitTime(long timestamp)
Description copied from class: AbstractTransactionService
Find the commit time from which the tx will read (largest commitTime LTE timestamp).

Specified by:
findCommitTime in class AbstractTransactionService
Parameters:
timestamp - The timestamp.
Returns:
The commit time and -1L if there is no such commit time.

findNextCommitTime

protected long findNextCommitTime(long commitTime)
Description copied from class: AbstractTransactionService
Return the commit time for the successor of that commit point have the specified timestamp (a commit time strictly GT the given value).

Specified by:
findNextCommitTime in class AbstractTransactionService
Parameters:
commitTime - The probe.
Returns:
The successor or -1L iff the is no successor for that commit time.

abortImpl

protected void abortImpl(AbstractTransactionService.TxState state)
Description copied from class: AbstractTransactionService
Implementation must abort the tx on the journal (standalone) or on each data service (federation) on which it has written.

Pre-conditions:

  1. The transaction is RunState.Active; and
  2. The caller holds the AbstractTransactionService.TxState.lock.

Post-conditions:

  1. The transaction is RunState.Aborted; and
  2. The transaction write set has been discarded by each Journal or IDataService or which it has written (applicable for read-write transactions only).

Specified by:
abortImpl in class AbstractTransactionService
Parameters:
state - The transaction state as maintained by the transaction server.

commitImpl

protected long commitImpl(AbstractTransactionService.TxState state)
                   throws ExecutionException,
                          InterruptedException
Description copied from class: AbstractTransactionService
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).

Pre-conditions:

  1. The transaction is RunState.Active; and
  2. The caller holds the AbstractTransactionService.TxState.lock.

Post-conditions (success for read-only transaction or a read-write transaction with an empty write set):

  1. The transaction is RunState.Committed; and
  2. The returned commitTime is ZERO (0L).

Post-conditions (success for read-write transaction with a non-empty write set):

  1. The transaction is RunState.Committed;
  2. The transaction write set has been made restart-safe by each Journal or IDataService or which it has written (applicable for read-write transactions only); and
  3. The application can read exactly the data written by the transaction from the commit point identified by the returned commitTime.

Post-conditions (failure):

  1. The transaction is RunState.Aborted; and
  2. The transaction write set has been discarded by each Journal or IDataService or which it has written (applicable for read-write transactions only).

Specified by:
commitImpl in class AbstractTransactionService
Returns:
The commit time for the transaction -or- ZERO (0L) if the transaction was read-only or had an empty write set.
Throws:
ExecutionException
InterruptedException

getLastCommitTime

public final long getLastCommitTime()
The last commit time from the current root block.

Specified by:
getLastCommitTime in interface ITransactionService
Specified by:
getLastCommitTime in class AbstractTransactionService
Returns:
The last known commit time.

prepared

public long prepared(long tx,
                     UUID dataService)
              throws IOException
Throws exception since distributed transactions are not used for a single Journal.

Parameters:
tx - The transaction identifier.
dataService - The UUID of the IDataService which sent the message.
Returns:
The assigned commit time.
Throws:
IOException - if there is an RMI problem.

committed

public boolean committed(long tx,
                         UUID dataService)
                  throws IOException
Throws exception since distributed transactions are not used for a single Journal.

Parameters:
tx - The transaction identifier.
dataService - The UUID of the IDataService which sent the message.
Returns:
true if the distributed commit was successfull and false if there was a problem.
Throws:
IOException

getFederation

public AbstractFederation getFederation()
Throws exception.

Specified by:
getFederation in class AbstractService
Throws:
UnsupportedOperationException - always.


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