Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.iapi.store.raw
Interface LockingPolicy  view LockingPolicy download LockingPolicy.java


public interface LockingPolicy

Any object that implements this interface can be used as a locking policy for accessing a container.

The locking policy must use the defined lock qualifiers (ContainerLock.CIS, RowLock.RS, etc.) and the standard lock manager. (A locking policy that just performs no locking wouldn't need to use these :-)

A locking policy must use the object that is an instance of Transaction (originally obtained via startTransaction() in RawStoreFactory) as the compatibilitySpace for the LockFactory calls.
A locking policy must use the passed in transaction as the compatability space and the lock group. This chain (group) of locks has the following defined behaviour


MT - Thread Safe


Field Summary
static int MODE_CONTAINER
          ContainerHandle level locking.
static int MODE_NONE
          No locking what so ever, isolation parameter will be ignored by getLockingPolicy().
static int MODE_RECORD
          Record level locking.
 
Method Summary
 int getMode()
          Get the mode of this policy
 boolean lockContainer(Transaction t, ContainerHandle container, boolean waitForLock, boolean forUpdate)
          Called when a container is opened.
 void lockRecordForRead(org.apache.derby.iapi.services.locks.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(org.apache.derby.iapi.services.locks.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)
          Called when a container is closed.
 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.
 

Field Detail

MODE_NONE

public static final int MODE_NONE
No locking what so ever, isolation parameter will be ignored by getLockingPolicy().

See Also:
RawStoreFactory, Constant Field Values

MODE_RECORD

public static final int MODE_RECORD
Record level locking.

See Also:
Constant Field Values

MODE_CONTAINER

public static final int MODE_CONTAINER
ContainerHandle level locking.

See Also:
Constant Field Values
Method Detail

lockContainer

public boolean lockContainer(Transaction t,
                             ContainerHandle container,
                             boolean waitForLock,
                             boolean forUpdate)
                      throws org.apache.derby.iapi.error.StandardException
Called when a container is opened.


unlockContainer

public void unlockContainer(Transaction t,
                            ContainerHandle container)
Called when a container is closed.


lockRecordForRead

public boolean lockRecordForRead(Transaction t,
                                 ContainerHandle container,
                                 RecordHandle record,
                                 boolean waitForLock,
                                 boolean forUpdate)
                          throws org.apache.derby.iapi.error.StandardException
Called before a record is fetched.


lockRecordForRead

public void lockRecordForRead(org.apache.derby.iapi.services.locks.Latch latch,
                              RecordHandle record,
                              boolean forUpdate)
                       throws org.apache.derby.iapi.error.StandardException
Lock a record while holding a page latch.


zeroDurationLockRecordForWrite

public boolean zeroDurationLockRecordForWrite(Transaction t,
                                              RecordHandle record,
                                              boolean lockForPreviousKey,
                                              boolean waitForLock)
                                       throws org.apache.derby.iapi.error.StandardException
Request a write lock which will be released immediately upon grant.


lockRecordForWrite

public boolean lockRecordForWrite(Transaction t,
                                  RecordHandle record,
                                  boolean lockForInsert,
                                  boolean waitForLock)
                           throws org.apache.derby.iapi.error.StandardException
Called before a record is inserted, updated or deleted. If zeroDuration is true then lock is released immediately after it has been granted.


lockRecordForWrite

public void lockRecordForWrite(org.apache.derby.iapi.services.locks.Latch latch,
                               RecordHandle record)
                        throws org.apache.derby.iapi.error.StandardException
Lock a record for write while holding a page latch.


unlockRecordAfterRead

public void unlockRecordAfterRead(Transaction t,
                                  ContainerHandle container,
                                  RecordHandle record,
                                  boolean forUpdate,
                                  boolean row_qualified)
                           throws org.apache.derby.iapi.error.StandardException
Called after a record has been fetched.


getMode

public int getMode()
Get the mode of this policy