Top Description Fields Constructors Methods
org.apache.derby.impl.store.raw.xact

public Class RowLocking3

extends NoLocking
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.store.raw.xact.RowLockingRR
Imports
org.apache.derby.iapi.services.locks.LockFactory, .C_LockFactory, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.store.raw.ContainerHandle, .ContainerLock, .RecordHandle, .RowLock, .Transaction, .LockingPolicy, org.apache.derby.shared.common.error.StandardException

A locking policy that implements row level locking with isolation degree 3.
See Also
org.apache.derby.iapi.store.raw.LockingPolicy

Field Summary

Modifier and TypeField and Description
protected final LockFactory
private static final LockingPolicy

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public int
protected RowLock

Returns:

The lock type of a shared lock for this locking policy.
getReadLockType
()

Get type of lock to get while reading data.

protected RowLock

Returns:

The lock type of a shared lock for this locking policy.
getUpdateLockType
()

Get type of lock to get while requesting "update" lock.

protected RowLock

Returns:

The lock type of a shared lock for this locking policy.
getWriteLockType
()

Get type of lock to get while writing data.

public boolean

Returns:

true if the lock was obtained, false if it wasn't. False should only be returned if the waitForLock policy was set to "false," and the lock was unavailable.
lockContainer
(Transaction
Transaction to associate lock with.
t
,
ContainerHandle
Container to lock.
container
,
boolean
Should lock request wait until granted?
waitForLock
,
boolean
Should container be locked for update, or read?
forUpdate
)

Overrides org.apache.derby.impl.store.raw.xact.NoLocking.lockContainer.

Implements org.apache.derby.iapi.store.raw.LockingPolicy.lockContainer.

Obtain container level intent lock.

public boolean

Returns:

true if the lock was granted, false if waitForLock was false and the lock could not be granted.
lockRecordForRead
(Transaction
The transaction to associate the lock with.
t
,
ContainerHandle
Open Container used to get record. Will be used to row locks by the container they belong to.
container_handle
,
RecordHandle
The record to be locked.
record
,
boolean
Should lock request wait until granted?
waitForLock
,
boolean
Whether to open for read or write access.
forUpdate
)

Overrides org.apache.derby.impl.store.raw.xact.NoLocking.lockRecordForRead.

Implements org.apache.derby.iapi.store.raw.LockingPolicy.lockRecordForRead.

Obtain lock on record being read.

public boolean

Returns:

true if the lock was granted, false if waitForLock was false and the lock could not be granted.
lockRecordForWrite
(Transaction
The transaction to associate the lock with.
t
,
RecordHandle
The record to be locked.
record
,
boolean
Lock is for an insert.
lockForInsert
,
boolean
Should lock request wait until granted?
waitForLock
)

Overrides org.apache.derby.impl.store.raw.xact.NoLocking.lockRecordForWrite.

Implements org.apache.derby.iapi.store.raw.LockingPolicy.lockRecordForWrite.

Obtain lock on record being written.

public boolean

Returns:

true if the lock was granted, false if waitForLock was false and the lock could not be granted.
zeroDurationLockRecordForWrite
(Transaction
transaction to associate the lock with.
t
,
RecordHandle
The record to be locked.
record
,
boolean
Lock is for a previous key of a insert.
lockForInsertPreviousKey
,
boolean
Should lock request wait until granted?
waitForLock
)

Overrides org.apache.derby.impl.store.raw.xact.NoLocking.zeroDurationLockRecordForWrite.

Implements org.apache.derby.iapi.store.raw.LockingPolicy.zeroDurationLockRecordForWrite.

Obtain lock on record being written.

Inherited from org.apache.derby.impl.store.raw.xact.NoLocking:
unlockContainerunlockRecordAfterRead

Field Detail

lfback to summary
protected final LockFactory lf
NO_LOCKback to summary
private static final LockingPolicy NO_LOCK

Constructor Detail

RowLocking3back to summary
protected RowLocking3(LockFactory lf)

Method Detail

getModeback to summary
public int getMode()

Overrides org.apache.derby.impl.store.raw.xact.NoLocking.getMode.

Implements org.apache.derby.iapi.store.raw.LockingPolicy.getMode.

Doc from org.apache.derby.iapi.store.raw.LockingPolicy.getMode.

Get the mode of this policy

getReadLockTypeback to summary
protected RowLock getReadLockType()

Get type of lock to get while reading data.

This routine is provided so that class's like RowLockingRR can override just this routine to get RS2 locks vs RS3 locks, and still reuse all the other code in this class.

Returns:RowLock

The lock type of a shared lock for this locking policy.

getUpdateLockTypeback to summary
protected RowLock getUpdateLockType()

Get type of lock to get while requesting "update" lock.

This routine is provided so that class's like RowLockingRR can override just this routine to get RU2 locks vs RU3 locks, and still reuse all the other code in this class.

Returns:RowLock

The lock type of a shared lock for this locking policy.

getWriteLockTypeback to summary
protected RowLock getWriteLockType()

Get type of lock to get while writing data.

This routine is provided so that class's like RowLockingRR can override just this routine to get RX2 locks vs RX3 locks, and still reuse all the other code in this class.

Returns:RowLock

The lock type of a shared lock for this locking policy.

lockContainerback to summary
public boolean lockContainer(Transaction t, ContainerHandle container, boolean waitForLock, boolean forUpdate) throws StandardException

Overrides org.apache.derby.impl.store.raw.xact.NoLocking.lockContainer.

Implements org.apache.derby.iapi.store.raw.LockingPolicy.lockContainer.

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.

Parameters
t:Transaction

Transaction to associate lock with.

container:ContainerHandle

Container to lock.

waitForLock:boolean

Should lock request wait until granted?

forUpdate:boolean

Should container be locked for update, or read?

Returns:boolean

true if the lock was obtained, false if it wasn't. False should only be returned if the waitForLock policy was set to "false," and the lock was unavailable.

Exceptions
StandardException:
Standard exception policy.
lockRecordForReadback to summary
public boolean lockRecordForRead(Transaction t, ContainerHandle container_handle, RecordHandle record, boolean waitForLock, boolean forUpdate) throws StandardException

Overrides org.apache.derby.impl.store.raw.xact.NoLocking.lockRecordForRead.

Implements org.apache.derby.iapi.store.raw.LockingPolicy.lockRecordForRead.

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.

Parameters
t:Transaction

The transaction to associate the lock with.

container_handle:ContainerHandle

Doc from org.apache.derby.iapi.store.raw.LockingPolicy.lockRecordForRead.

Open Container used to get record. Will be used to row locks by the container they belong to.

record:RecordHandle

The record to be locked.

waitForLock:boolean

Should lock request wait until granted?

forUpdate:boolean

Whether to open for read or write access.

Returns:boolean

true if the lock was granted, false if waitForLock was false and the lock could not be granted.

Exceptions
StandardException:
Standard exception policy.
lockRecordForWriteback to summary
public boolean lockRecordForWrite(Transaction t, RecordHandle record, boolean lockForInsert, boolean waitForLock) throws StandardException

Overrides org.apache.derby.impl.store.raw.xact.NoLocking.lockRecordForWrite.

Implements org.apache.derby.iapi.store.raw.LockingPolicy.lockRecordForWrite.

Obtain lock on record being written.

Assumes that a table level IX has been acquired. Will acquire an Exclusive (X) lock on the row.

Parameters
t:Transaction

The transaction to associate the lock with.

record:RecordHandle

The record to be locked.

lockForInsert:boolean

Lock is for an insert.

waitForLock:boolean

Should lock request wait until granted?

Returns:boolean

true if the lock was granted, false if waitForLock was false and the lock could not be granted.

Exceptions
StandardException:
Standard exception policy.
zeroDurationLockRecordForWriteback to summary
public boolean zeroDurationLockRecordForWrite(Transaction t, RecordHandle record, boolean lockForInsertPreviousKey, boolean waitForLock) throws StandardException

Overrides org.apache.derby.impl.store.raw.xact.NoLocking.zeroDurationLockRecordForWrite.

Implements org.apache.derby.iapi.store.raw.LockingPolicy.zeroDurationLockRecordForWrite.

Obtain lock on record being written.

Assumes that a table level IX has been acquired. Will acquire an Exclusive (X) lock on the row.

Parameters
t:Transaction

transaction to associate the lock with.

record:RecordHandle

The record to be locked.

lockForInsertPreviousKey:boolean

Lock is for a previous key of a insert.

waitForLock:boolean

Should lock request wait until granted?

Returns:boolean

true if the lock was granted, false if waitForLock was false and the lock could not be granted.

Exceptions
StandardException:
Standard exception policy.