org.apache.derby.impl.store.raw.xact
Class ContainerLocking2

java.lang.Object
  extended byorg.apache.derby.impl.store.raw.xact.NoLocking
      extended byorg.apache.derby.impl.store.raw.xact.ContainerLocking2
All Implemented Interfaces:
LockingPolicy

public class ContainerLocking2
extends NoLocking

A locking policy that implements container level locking with isolation degree 2.

See Also:
LockingPolicy

Field Summary
private  LockFactory lf
           
 
Fields inherited from interface org.apache.derby.iapi.store.raw.LockingPolicy
MODE_CONTAINER, MODE_NONE, MODE_RECORD
 
Constructor Summary
protected ContainerLocking2()
           
protected ContainerLocking2(LockFactory lf)
           
 
Method Summary
 int getMode()
          Get the mode of this policy
 boolean lockContainer(Transaction t, ContainerHandle container, boolean waitForLock, boolean forUpdate)
          Obtain a Container shared or exclusive lock until the end of the nested transaction.
 void lockRecordForRead(Latch latch, RecordHandle record, boolean forUpdate)
          Lock a record while holding a page latch.
 boolean lockRecordForRead(Transaction t, ContainerHandle container, RecordHandle record, boolean waitForLock, boolean forUpdate)
          Called before a record is fetched.
 void lockRecordForWrite(Latch latch, RecordHandle record)
          Lock a record for write while holding a page latch.
 boolean lockRecordForWrite(Transaction t, RecordHandle record, boolean lockForInsert, boolean waitForLock)
          Called before a record is inserted, updated or deleted.
 void unlockContainer(Transaction t, ContainerHandle container)
          Unlock read locks.
 void unlockRecordAfterRead(Transaction t, ContainerHandle container, RecordHandle record, boolean forUpdate, boolean row_qualified)
          Called after a record has been fetched.
 boolean zeroDurationLockRecordForWrite(Transaction t, RecordHandle record, boolean lockForPreviousKey, boolean waitForLock)
          Request a write lock which will be released immediately upon grant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lf

private final LockFactory lf
Constructor Detail

ContainerLocking2

protected ContainerLocking2()

ContainerLocking2

protected ContainerLocking2(LockFactory lf)
Method Detail

lockContainer

public boolean lockContainer(Transaction t,
                             ContainerHandle container,
                             boolean waitForLock,
                             boolean forUpdate)
                      throws StandardException
Obtain a Container shared or exclusive lock until the end of the nested transaction.

Specified by:
lockContainer in interface LockingPolicy
Overrides:
lockContainer in class NoLocking
Throws:
StandardException - Standard Cloudscape error policy

unlockContainer

public void unlockContainer(Transaction t,
                            ContainerHandle container)
Unlock read locks.

In Cursor stability release all read locks obtained. unlockContainer() will be called when the container is closed.

Specified by:
unlockContainer in interface LockingPolicy
Overrides:
unlockContainer in class NoLocking
Parameters:
t - The transaction to associate the lock with.
container - Container to unlock.

getMode

public int getMode()
Description copied from interface: LockingPolicy
Get the mode of this policy

Specified by:
getMode in interface LockingPolicy
Overrides:
getMode in class NoLocking

lockRecordForRead

public boolean lockRecordForRead(Transaction t,
                                 ContainerHandle container,
                                 RecordHandle record,
                                 boolean waitForLock,
                                 boolean forUpdate)
                          throws StandardException
Description copied from interface: LockingPolicy
Called before a record is fetched.

Specified by:
lockRecordForRead in interface LockingPolicy
Parameters:
t - Transaction to associate lock with.
container - Open Container used to get record. Will be used to row locks by the container they belong to.
record - Record to lock.
waitForLock - Should lock request wait until granted?
forUpdate - Should container be locked for update, or read?
Throws:
StandardException - Standard Cloudscape error policy
See Also:
Page

lockRecordForRead

public void lockRecordForRead(Latch latch,
                              RecordHandle record,
                              boolean forUpdate)
                       throws StandardException
Description copied from interface: LockingPolicy
Lock a record while holding a page latch.

Specified by:
lockRecordForRead in interface LockingPolicy
Parameters:
latch - Latch held.
record - Record to lock.
forUpdate - Should container be locked for update, or read?
Throws:
StandardException - Standard Cloudscape error policy
See Also:
Page

zeroDurationLockRecordForWrite

public boolean zeroDurationLockRecordForWrite(Transaction t,
                                              RecordHandle record,
                                              boolean lockForPreviousKey,
                                              boolean waitForLock)
                                       throws StandardException
Description copied from interface: LockingPolicy
Request a write lock which will be released immediately upon grant.

Specified by:
zeroDurationLockRecordForWrite in interface LockingPolicy
Parameters:
t - Transaction to associate lock with.
record - Record to lock.
lockForPreviousKey - Lock is for a previous key of a insert.
waitForLock - Should lock request wait until granted?
Returns:
true if the lock was obtained, false if it wasn't. False should only be returned if the waitForLock argument was set to "false," and the lock was unavailable.
Throws:
StandardException - Standard Cloudscape error policy
See Also:
Page

lockRecordForWrite

public boolean lockRecordForWrite(Transaction t,
                                  RecordHandle record,
                                  boolean lockForInsert,
                                  boolean waitForLock)
                           throws StandardException
Description copied from interface: LockingPolicy
Called before a record is inserted, updated or deleted. If zeroDuration is true then lock is released immediately after it has been granted.

Specified by:
lockRecordForWrite in interface LockingPolicy
Parameters:
t - Transaction to associate lock with.
record - Record to lock.
lockForInsert - Lock is for an insert.
waitForLock - Should lock request wait until granted?
Returns:
true if the lock was obtained, false if it wasn't. False should only be returned if the waitForLock argument was set to "false," and the lock was unavailable.
Throws:
StandardException - Standard Cloudscape error policy
See Also:
Page

lockRecordForWrite

public void lockRecordForWrite(Latch latch,
                               RecordHandle record)
                        throws StandardException
Description copied from interface: LockingPolicy
Lock a record for write while holding a page latch.

Specified by:
lockRecordForWrite in interface LockingPolicy
Parameters:
latch - Page latch held.
record - Record to lock.
Throws:
StandardException - Standard Cloudscape error policy
See Also:
Page

unlockRecordAfterRead

public void unlockRecordAfterRead(Transaction t,
                                  ContainerHandle container,
                                  RecordHandle record,
                                  boolean forUpdate,
                                  boolean row_qualified)
                           throws StandardException
Description copied from interface: LockingPolicy
Called after a record has been fetched.

Specified by:
unlockRecordAfterRead in interface LockingPolicy
Throws:
StandardException - Standard Cloudscape error policy
See Also:
Page

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.