com.sleepycat.je.rep.txn
Class ReadonlyTxn

java.lang.Object
  extended by com.sleepycat.je.txn.Locker
      extended by com.sleepycat.je.txn.Txn
          extended by com.sleepycat.je.rep.txn.ReadonlyTxn
All Implemented Interfaces:
Loggable

public class ReadonlyTxn
extends Txn

A ReadonlyTxn represents a user initiated transaction on a Replica. As its name implies it is used to implement the read-only semantics for access to the replicated environment on the Replica. In addition, it uses the transaction hooks defined on Txn to implement the ReplicaConsistencyPolicy.


Field Summary
 
Fields inherited from class com.sleepycat.je.txn.Txn
ACCUMULATED_LIMIT, commitLsn, deletedDatabases, firstLoggedLsn, lastLoggedLsn, openedDatabaseHandles, repContext, undoDatabases
 
Fields inherited from class com.sleepycat.je.txn.Locker
defaultNoWait, deleteInfo, envImpl, id, lockManager, readUncommittedDefault, thread
 
Constructor Summary
ReadonlyTxn(EnvironmentImpl envImpl, TransactionConfig config)
           
 
Method Summary
(package private) static void checkConsistency(RepImpl repImpl, ReplicaConsistencyPolicy policy)
          Utility method used here and by ReplicaThreadLocker.
 void disallowReplicaWrite()
          Unconditionally throws ReplicaWriteException because this locker was created on a replica.
 boolean isReplicationDefined()
          Used for debugging checks to ensure that replication-defined lockers are used for accessing replicated databases.
 LockResult lockInternal(long lsn, LockType lockType, boolean noWait, boolean jumpAheadOfWaiters, DatabaseImpl database)
          Provides a wrapper to screen for write locks.
 void preLogWithoutLock(DatabaseImpl database)
          If logging occurs before locking, we must screen out write locks here.
protected  void txnBeginHook(TransactionConfig config)
          Verifies that consistency requirements are met before allowing the transaction to proceed.
 
Methods inherited from class com.sleepycat.je.txn.Txn
abort, abort, abort, addLock, addLogInfo, addOpenedDatabase, checkPreempted, checkState, cleanupDatabaseImpls, clearWriteLocks, close, collectStats, commit, commit, commit, createdNode, createLocalAutoTxn, createLocalTxn, dumpLog, generateId, getCommitDurability, getCommitToken, getDefaultDurability, getEnvironmentImpl, getExplicitDurabilityConfigured, getExplicitSyncConfigured, getFirstActiveLsn, getImportunate, getLastLsn, getLogSize, getPrepared, getReadLockIds, getReplicatorNodeId, getState, getTransaction, getTransactionId, getTriggerDbs, getTxnLocker, getWriteLockIds, getWriteLockInfo, isAutoTxn, isClosed, isOnlyAbortable, isReadCommittedIsolation, isRolledBack, isSerializableIsolation, isSuspended, isTransactional, isValid, lockingRequired, logicalEquals, markDeleteAtTxnEnd, newNonTxnLocker, nonTxnOperationEnd, noteTriggerDb, operationEnd, postLogAbortHook, postLogCommitAbortHook, postLogCommitHook, preLogAbortHook, preLogCommitHook, prepare, propagatePostCommitException, readFromLog, registerCursor, releaseNonTxnLocks, releaseWriteLocks, setDeletedDatabaseState, setImportunate, setOnlyAbortable, setPrepared, setRollback, setSuspended, setTransaction, undo, unRegisterCursor, updateLoggedForTxn, writeToLog
 
Methods inherited from class com.sleepycat.je.txn.Locker
addDeleteInfo, allowReleaseLockAfterLsnChange, demoteLock, dumpLockTable, getDefaultNoWait, getEnvironment, getId, getInitialLockTimeout, getLockTimeout, getPreemptable, getTxnTimeout, isReadUncommittedDefault, isTimedOut, lock, lockAfterLsnChange, nonBlockingLock, openCursorHook, operationEnd, operationEnd, releaseLock, setClosingLocker, setLockTimeout, setPreemptable, setPreempted, setTxnTimeout, sharesLocksWith, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReadonlyTxn

public ReadonlyTxn(EnvironmentImpl envImpl,
                   TransactionConfig config)
            throws DatabaseException
Throws:
DatabaseException
Method Detail

lockInternal

public LockResult lockInternal(long lsn,
                               LockType lockType,
                               boolean noWait,
                               boolean jumpAheadOfWaiters,
                               DatabaseImpl database)
                        throws LockNotAvailableException,
                               LockConflictException,
                               DatabaseException
Provides a wrapper to screen for write locks. The use of write locks is used to infer that an attempt is being made to modify a replicated database. Note that this technique misses "conditional" updates, for example a delete operation using a non-existent key, but we are ok with that since the primary intent here is to ensure the integrity of the replicated stream that is being played back at that replica and these checks prevent such mishaps.

Overrides:
lockInternal in class Txn
Parameters:
lsn - is the node to lock.
lockType - is the type of lock to request.
noWait - is true to override the defaultNoWait setting. If true, or if defaultNoWait is true, throws LockNotAvailableException if the lock cannot be granted without waiting.
jumpAheadOfWaiters - grant the lock before other waiters, if any.
database - is the database containing lsn.
Throws:
LockConflictException - if a blocking lock could not be acquired.
LockNotAvailableException
DatabaseException
See Also:
Locker.lockInternal(long, com.sleepycat.je.txn.LockType, boolean, boolean, com.sleepycat.je.dbi.DatabaseImpl)

preLogWithoutLock

public void preLogWithoutLock(DatabaseImpl database)
If logging occurs before locking, we must screen out write locks here.

Overrides:
preLogWithoutLock in class Txn

disallowReplicaWrite

public void disallowReplicaWrite()
Unconditionally throws ReplicaWriteException because this locker was created on a replica.

Overrides:
disallowReplicaWrite in class Locker

txnBeginHook

protected void txnBeginHook(TransactionConfig config)
                     throws ReplicaConsistencyException,
                            DatabaseException
Verifies that consistency requirements are met before allowing the transaction to proceed.

Overrides:
txnBeginHook in class Txn
Parameters:
config - the transaction config that applies to the txn
Throws:
DatabaseException - if there is a failure
ReplicaConsistencyException

checkConsistency

static void checkConsistency(RepImpl repImpl,
                             ReplicaConsistencyPolicy policy)
Utility method used here and by ReplicaThreadLocker.


isReplicationDefined

public boolean isReplicationDefined()
Description copied from class: Locker
Used for debugging checks to ensure that replication-defined lockers are used for accessing replicated databases. Overridden by replicated-defined lockers to return true.

Overrides:
isReplicationDefined in class Locker


Copyright (c) 2004-2012 Oracle. All rights reserved.