com.sleepycat.je.txn
Class ThreadLocker

java.lang.Object
  extended by com.sleepycat.je.txn.Locker
      extended by com.sleepycat.je.txn.BasicLocker
          extended by com.sleepycat.je.txn.ThreadLocker
Direct Known Subclasses:
MasterThreadLocker, ReplicaThreadLocker

public class ThreadLocker
extends BasicLocker

Extends BasicLocker to share locks among all lockers for the same thread. This locker is used when a JE entry point is called with a null transaction parameter.


Field Summary
 
Fields inherited from class com.sleepycat.je.txn.Locker
defaultNoWait, deleteInfo, envImpl, id, lockManager, readUncommittedDefault, thread
 
Constructor Summary
ThreadLocker(EnvironmentImpl env)
          Creates a ThreadLocker.
 
Method Summary
 void checkPreempted(Locker allowPreemptedLocker)
          Checks for preemption in all thread lockers for this thread.
protected  void checkState(boolean ignoreCalledByAbort)
          Check that this locker is not used in the wrong thread.
(package private)  void close()
          Should be called by all subclasses when the locker is no longer used.
static ThreadLocker createThreadLocker(EnvironmentImpl env)
           
 void lockAfterLsnChange(long oldLsn, long newLsn, DatabaseImpl dbImpl)
          Set the allowMultithreadedAccess mode during execution of this method because a ThreadLocker is not normally allowed to perform locking from more than one thread.
 Locker newNonTxnLocker()
          Returns a new non-transactional locker that shares locks with this locker by virtue of being a ThreadLocker for the same thread.
 boolean sharesLocksWith(Locker other)
          Returns whether this locker can share locks with the given locker.
 
Methods inherited from class com.sleepycat.je.txn.BasicLocker
addLock, collectStats, createBasicLocker, createBasicLocker, createdNode, generateId, getTxnLocker, getWriteLockInfo, getWriteOwnerLocker, isReadCommittedIsolation, isSerializableIsolation, isTransactional, lockingRequired, lockInternal, markDeleteAtTxnEnd, moveWriteToReadLock, nonTxnOperationEnd, operationEnd, preLogWithoutLock, registerCursor, releaseNonTxnLocks, removeLock, unRegisterCursor
 
Methods inherited from class com.sleepycat.je.txn.Locker
addBuddy, addDeleteInfo, addOpenedDatabase, allowReleaseLockAfterLsnChange, demoteLock, disallowReplicaWrite, dumpLockTable, getDefaultNoWait, getEnvironment, getId, getImportunate, getInitialLockTimeout, getLockTimeout, getPreemptable, getTransaction, getTxnStartMillis, getTxnTimeout, getWaitingFor, isPreempted, isReadUncommittedDefault, isReplicationDefined, isRolledBack, isTimedOut, isValid, lock, nonBlockingLock, openCursorHook, operationEnd, operationEnd, releaseLock, removeBuddy, setAllowMultithreadedAccess, setClosingLocker, setImportunate, setLockTimeout, setOnlyAbortable, setPreemptable, setPreempted, setTxnTimeout, setWaitingFor, throwIfPreempted, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadLocker

public ThreadLocker(EnvironmentImpl env)
Creates a ThreadLocker.

Method Detail

createThreadLocker

public static ThreadLocker createThreadLocker(EnvironmentImpl env)
                                       throws DatabaseException
Throws:
DatabaseException

close

void close()
Description copied from class: Locker
Should be called by all subclasses when the locker is no longer used. For Txns and auto Txns this is at commit or abort. For non-transactional lockers it is at operationEnd.

Overrides:
close in class Locker

checkPreempted

public void checkPreempted(Locker allowPreemptedLocker)
                    throws OperationFailureException
Checks for preemption in all thread lockers for this thread.

Overrides:
checkPreempted in class Locker
Parameters:
allowPreemptedLocker - is a locker that is being closed as the result of a cursor move operation. If the operation is successful then allowPreemptedLocker will be closed, and the fact that a lock has been stolen from allowPreemptedLocker can be ignored.
Throws:
OperationFailureException

lockAfterLsnChange

public void lockAfterLsnChange(long oldLsn,
                               long newLsn,
                               DatabaseImpl dbImpl)
Set the allowMultithreadedAccess mode during execution of this method because a ThreadLocker is not normally allowed to perform locking from more than one thread.

Overrides:
lockAfterLsnChange in class Locker

checkState

protected void checkState(boolean ignoreCalledByAbort)
Check that this locker is not used in the wrong thread.

Overrides:
checkState in class BasicLocker
Throws:
IllegalStateException - via all Cursor methods that use a non-transactional locker.

newNonTxnLocker

public Locker newNonTxnLocker()
                       throws DatabaseException
Returns a new non-transactional locker that shares locks with this locker by virtue of being a ThreadLocker for the same thread.

Overrides:
newNonTxnLocker in class BasicLocker
Throws:
DatabaseException - from subclasses.

sharesLocksWith

public boolean sharesLocksWith(Locker other)
Returns whether this locker can share locks with the given locker. Locks are shared when both lockers are ThreadLocker instances for the same thread.

Overrides:
sharesLocksWith in class Locker


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