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

Quick Search    Search Deep

org.apache.derby.impl.store.raw.xact
Class RowLocking2  view RowLocking2 download RowLocking2.java

java.lang.Object
  extended byorg.apache.derby.impl.store.raw.xact.NoLocking
      extended byorg.apache.derby.impl.store.raw.xact.RowLocking3
          extended byorg.apache.derby.impl.store.raw.xact.RowLockingRR
              extended byorg.apache.derby.impl.store.raw.xact.RowLocking2
All Implemented Interfaces:
org.apache.derby.iapi.store.raw.LockingPolicy
Direct Known Subclasses:
RowLocking1, RowLocking2nohold

public class RowLocking2
extends RowLockingRR

A locking policy that implements row level locking with isolation degree 2. The approach is to place all "write" container and row locks on the transaction group lock list. Locks on this group will last until end of transaction. All "read" container and row locks will be placed on a group list, key'd by the ContainerId of the lock. Locks on this list will either be released explicitly by the caller, or will be released as a group when the unlockContainer() call is made. Note that write operations extend from the RowLocking3 implementations.


Field Summary
private static org.apache.derby.iapi.store.raw.LockingPolicy NO_LOCK
           
 
Fields inherited from class org.apache.derby.impl.store.raw.xact.RowLocking3
lf
 
Fields inherited from interface org.apache.derby.iapi.store.raw.LockingPolicy
MODE_CONTAINER, MODE_NONE, MODE_RECORD
 
Constructor Summary
protected RowLocking2(org.apache.derby.iapi.services.locks.LockFactory lf)
           
 
Method Summary
 boolean lockContainer(org.apache.derby.iapi.store.raw.Transaction t, org.apache.derby.iapi.store.raw.ContainerHandle container, boolean waitForLock, boolean forUpdate)
          Obtain container level intent lock.
 void lockRecordForRead(org.apache.derby.iapi.services.locks.Latch latch, org.apache.derby.iapi.store.raw.RecordHandle record, boolean forUpdate)
          Obtain lock on record being read while holding a latch.
 boolean lockRecordForRead(org.apache.derby.iapi.store.raw.Transaction t, org.apache.derby.iapi.store.raw.ContainerHandle container_handle, org.apache.derby.iapi.store.raw.RecordHandle record, boolean waitForLock, boolean forUpdate)
          Obtain lock on record being read.
 void unlockContainer(org.apache.derby.iapi.store.raw.Transaction t, org.apache.derby.iapi.store.raw.ContainerHandle container_handle)
          Unlock read locks.
 void unlockRecordAfterRead(org.apache.derby.iapi.store.raw.Transaction t, org.apache.derby.iapi.store.raw.ContainerHandle container_handle, org.apache.derby.iapi.store.raw.RecordHandle record, boolean forUpdate, boolean row_qualified)
          Unlock a record after it has been locked for read.
 
Methods inherited from class org.apache.derby.impl.store.raw.xact.RowLockingRR
getReadLockType, getUpdateLockType, getWriteLockType
 
Methods inherited from class org.apache.derby.impl.store.raw.xact.RowLocking3
getMode, lockRecordForWrite, lockRecordForWrite, zeroDurationLockRecordForWrite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_LOCK

private static final org.apache.derby.iapi.store.raw.LockingPolicy NO_LOCK
Constructor Detail

RowLocking2

protected RowLocking2(org.apache.derby.iapi.services.locks.LockFactory lf)
Method Detail

lockContainer

public boolean lockContainer(org.apache.derby.iapi.store.raw.Transaction t,
                             org.apache.derby.iapi.store.raw.ContainerHandle container,
                             boolean waitForLock,
                             boolean forUpdate)
                      throws org.apache.derby.iapi.error.StandardException
Obtain container level intent lock.

This implementation of row locking is 2 level, ie. table and row locking. It will interact correctly with tables opened with ContainerLocking3 locking mode.

Updater's will get table level IX locks, and X row locks.

Reader's will get table level IS locks, and S row locks.

Read locks are put in a separate "group" from the transaction, so that when the container is closed it can release these read locks.

Specified by:
lockContainer in interface org.apache.derby.iapi.store.raw.LockingPolicy
Overrides:
lockContainer in class RowLocking3

lockRecordForRead

public boolean lockRecordForRead(org.apache.derby.iapi.store.raw.Transaction t,
                                 org.apache.derby.iapi.store.raw.ContainerHandle container_handle,
                                 org.apache.derby.iapi.store.raw.RecordHandle record,
                                 boolean waitForLock,
                                 boolean forUpdate)
                          throws org.apache.derby.iapi.error.StandardException
Obtain lock on record being read.

Assumes that a table level IS has been acquired. Will acquire a Shared or Update lock on the row, depending on the "forUpdate" parameter.

Read lock will be placed on separate group from transaction.

Specified by:
lockRecordForRead in interface org.apache.derby.iapi.store.raw.LockingPolicy
Overrides:
lockRecordForRead in class RowLocking3

lockRecordForRead

public void lockRecordForRead(org.apache.derby.iapi.services.locks.Latch latch,
                              org.apache.derby.iapi.store.raw.RecordHandle record,
                              boolean forUpdate)
                       throws org.apache.derby.iapi.error.StandardException
Obtain lock on record being read while holding a latch.

Assumes that a table level IS has been acquired. Will acquire a Shared or Update lock on the row, depending on the "forUpdate" parameter.

Specified by:
lockRecordForRead in interface org.apache.derby.iapi.store.raw.LockingPolicy
Overrides:
lockRecordForRead in class RowLocking3

unlockRecordAfterRead

public void unlockRecordAfterRead(org.apache.derby.iapi.store.raw.Transaction t,
                                  org.apache.derby.iapi.store.raw.ContainerHandle container_handle,
                                  org.apache.derby.iapi.store.raw.RecordHandle record,
                                  boolean forUpdate,
                                  boolean row_qualified)
                           throws org.apache.derby.iapi.error.StandardException
Description copied from class: RowLockingRR
Unlock a record after it has been locked for read.

In repeatable read only unlock records which "did not qualify". For example in a query like "select * from foo where a = 1" on a table with no index it is only necessary to hold locks on rows where a=1, but in the process of finding those rows the system will get locks on other rows to verify they are committed before applying the qualifier. Those locks can be released under repeatable read isolation.

Specified by:
unlockRecordAfterRead in interface org.apache.derby.iapi.store.raw.LockingPolicy
Overrides:
unlockRecordAfterRead in class RowLockingRR

unlockContainer

public void unlockContainer(org.apache.derby.iapi.store.raw.Transaction t,
                            org.apache.derby.iapi.store.raw.ContainerHandle container_handle)
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 org.apache.derby.iapi.store.raw.LockingPolicy
Overrides:
unlockContainer in class NoLocking