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, repContext, undoDatabases
 
Fields inherited from class com.sleepycat.je.txn.Locker
defaultNoWait, deleteInfo, envImpl, handleLockToHandleMap, handleToHandleLockMap, 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.
 boolean isReplicationDefined()
          Used for debugging checks to ensure that replication-defined lockers are used for accessing replicated databases.
 LockResult lockInternal(long nodeId, LockType lockType, boolean noWait, DatabaseImpl database)
          Provides a wrapper to screen for write locks.
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, checkState, cleanupDatabaseImpls, clearWriteLocks, close, collectStats, commit, commit, commit, createdNode, createLocalAutoTxn, createLocalTxn, dumpLog, generateId, getAbortLsn, getCommitDurability, getCommitToken, getDefaultDurability, getExplicitDurabilityConfigured, getExplicitSyncConfigured, getFirstActiveLsn, getImportunate, getLastLsn, getLogSize, getPrepared, getReadLockIds, getReplicatorNodeId, getTransactionId, getTxnLocker, getWriteLockIds, getWriteLockInfo, isAutoTxn, isClosed, isHandleLockTransferrable, isOnlyAbortable, isReadCommittedIsolation, isRolledBack, isSerializableIsolation, isSuspended, isTransactional, isValid, lockingRequired, logicalEquals, markDeleteAtTxnEnd, newNonTxnLocker, nonTxnOperationEnd, operationEnd, postLogAbortHook, postLogCommitHook, preLogCommitHook, prepare, propagatePostCommitException, readFromLog, registerCursor, releaseNonTxnLocks, releaseWriteLocks, setDeletedDatabaseState, setHandleLockOwner, setImportunate, setOnlyAbortable, setPrepared, setRollback, setSuspended, undo, unRegisterCursor, updateLoggedForTxn, writeToLog
 
Methods inherited from class com.sleepycat.je.txn.Locker
addDeleteInfo, addToHandleMaps, demoteLock, dumpLockTable, getDefaultNoWait, getId, getInitialLockTimeout, getLockTimeout, getPreemptable, getTxnTimeout, isReadUncommittedDefault, isTimedOut, lock, nonBlockingLock, openCursorHook, operationEnd, operationEnd, releaseLock, setClosingLocker, setLockTimeout, setPreemptable, setPreempted, setTxnTimeout, sharesLocksWith, toString, transferHandleLock
 
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 nodeId,
                               LockType lockType,
                               boolean noWait,
                               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:
nodeId - 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.
database - is the database containing nodeId.
Throws:
LockConflictException - if a blocking lock could not be acquired.
LockNotAvailableException
DatabaseException
See Also:
Locker.lockInternal(long, com.sleepycat.je.txn.LockType, boolean, com.sleepycat.je.dbi.DatabaseImpl)

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-2010 Oracle. All rights reserved.