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
ContainerHandle, RecordHandle, org.apache.derby.iapi.services.locks.LockFactory , org.apache.derby.iapi.services.locks.Lockable
| Modifier and Type | Field and Description |
|---|---|
| public static final int | MODE_CONTAINER
ContainerHandle level locking. |
| public static final int | MODE_NONE
No locking what so ever, isolation parameter will be ignored by getLockingPolicy(). |
| public static final int | MODE_RECORD
Record level locking. |
| Modifier and Type | Method and Description |
|---|---|
| public int | |
| 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.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)Called when a container is opened. |
| public boolean | lockRecordForRead(Transaction
Transaction to associate lock with. t, ContainerHandle Open Container used to get record. Will be used
to row locks by the container they belong to. container, RecordHandle Record to lock. record, boolean Should lock request wait until granted? waitForLock, boolean Should container be locked for update, or read? forUpdate)Called before a record is fetched. |
| public boolean | 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.Transaction to associate lock with. t, RecordHandle Record to lock. record, boolean Lock is for an insert. lockForInsert, boolean Should lock request wait until granted? waitForLock)Called before a record is inserted, updated or deleted. |
| public void | |
| public void | unlockRecordAfterRead(Transaction t, ContainerHandle container, RecordHandle record, boolean forUpdate, boolean row_qualified)
Called after a record has been fetched. |
| public boolean | 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.Transaction to associate lock with. t, RecordHandle Record to lock. record, boolean Lock is for a previous key of a insert. lockForPreviousKey, boolean Should lock request wait until granted? waitForLock)Request a write lock which will be released immediately upon grant. |
| MODE_CONTAINER | back to summary |
|---|---|
| public static final int MODE_CONTAINER ContainerHandle level locking. | |
| MODE_NONE | back to summary |
|---|---|
| public static final int MODE_NONE No locking what so ever, isolation parameter will be ignored by getLockingPolicy().
| |
| MODE_RECORD | back to summary |
|---|---|
| public static final int MODE_RECORD Record level locking. | |
| getMode | back to summary |
|---|---|
| public int getMode() Get the mode of this policy | |
| lockContainer | back to summary |
|---|---|
| public boolean lockContainer(Transaction t, ContainerHandle container, boolean waitForLock, boolean forUpdate) throws StandardException Called when a container is opened.
| |
| lockRecordForRead | back to summary |
|---|---|
| public boolean lockRecordForRead(Transaction t, ContainerHandle container, RecordHandle record, boolean waitForLock, boolean forUpdate) throws StandardException Called before a record is fetched.
| |
| lockRecordForWrite | back to summary |
|---|---|
| public boolean lockRecordForWrite(Transaction t, RecordHandle record, boolean lockForInsert, boolean waitForLock) throws StandardException Called before a record is inserted, updated or deleted. If zeroDuration is true then lock is released immediately after it has been granted.
| |
| unlockContainer | back to summary |
|---|---|
| public void unlockContainer(Transaction t, ContainerHandle container) Called when a container is closed.
| |
| unlockRecordAfterRead | back to summary |
|---|---|
| public void unlockRecordAfterRead(Transaction t, ContainerHandle container, RecordHandle record, boolean forUpdate, boolean row_qualified) throws StandardException Called after a record has been fetched.
| |
| zeroDurationLockRecordForWrite | back to summary |
|---|---|
| public boolean zeroDurationLockRecordForWrite(Transaction t, RecordHandle record, boolean lockForPreviousKey, boolean waitForLock) throws StandardException Request a write lock which will be released immediately upon grant.
| |