Top Description Methods
org.apache.derby.impl.services.locks

pack-priv Interface LockTable

Known Direct Implementers
org.apache.derby.impl.services.locks.ConcurrentLockSet
Imports
java.util.Map, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.locks.CompatibilitySpace, .Latch, .Lockable

Interface which must be implemented by lock table classes.

Method Summary

Modifier and TypeMethod and Description
public void
addWaiters(Map<Object, Object>
the map to add the waiters to
waiters
)

Add all waiters in the lock table to the specified map.

public boolean

Returns:

true if someone is blocked, false otherwise
anyoneBlocked
()

Check whether there are anyone blocked in the lock table.

public int
getWaitTimeout()

Get the wait timeout in milliseconds.

public Lock

Returns:

a reference to the lock, or null if the lock couldn't be obtained immediately and the timeout was NO_WAIT or LockOwner had the noWait flag set
lockObject
(CompatibilitySpace
the compatibility space
compatibilitySpace
,
Lockable
the object to lock
ref
,
Object
qualifier of the lock
qualifier
,
int
maximum time to wait in milliseconds (C_LockFactory.NO_WAIT means don't wait)
timeout
)

Lock an object.

public void
oneLessWaiter()

Notify the lock table that it has one less waiter.

public void
oneMoreWaiter()

Notify the lock table that it has one more waiter.

public void
setDeadlockTimeout(int
deadlock timeout in milliseconds
timeout
)

Set the deadlock timeout.

public void
setDeadlockTrace(boolean
true enables tracing, false disables tracing
flag
)

Enable or disable tracing of deadlocks.

public void
setWaitTimeout(int
wait timeout in milliseconds
timeout
)

Set the wait timeout.

public Map<K, V>

Returns:

a shallow clone of the lock table
shallowClone
()

Create a map containing a snapshot of all the (Lockable, LockControl) pairs in the lock table.

public void
unlock(Latch
the lock to unlock
item
,
int
the number of times to unlock the item; or zero, meaning take the unlock count from the item
unlockCount
)

Unlock an object previously locked by lockObject().

public Lock

Returns:

the corresponding lock in the group map, or null if the object was not unlocked
unlockReference
(CompatibilitySpace
the compatibility space
space
,
Lockable
a reference to the locked object
ref
,
Object
qualifier of the lock
qualifier
,
Map<K, V>
a map representing the locks in a group
group
)

Unlock an object once if it is present in the specified group.

public boolean

Returns:

true if the object was locked, or false if the object couldn't be locked immediately and timeout was NO_WAIT or LockOwner had the noWait flag set
zeroDurationLockObject
(CompatibilitySpace
the compatibility space
space
,
Lockable
a reference to the locked object
ref
,
Object
qualifier of the lock
qualifier
,
int
maximum time to wait in milliseconds (C_LockFactory.NO_WAIT means don't wait)
timeout
)

Lock an object and release the lock immediately.

Method Detail

addWaitersback to summary
public void addWaiters(Map<Object, Object> waiters)

Add all waiters in the lock table to the specified map.

Parameters
waiters:Map<Object, Object>

the map to add the waiters to

See Also
LockControl#addWaiters
anyoneBlockedback to summary
public boolean anyoneBlocked()

Check whether there are anyone blocked in the lock table.

Returns:boolean

true if someone is blocked, false otherwise

getWaitTimeoutback to summary
public int getWaitTimeout()

Get the wait timeout in milliseconds.

lockObjectback to summary
public Lock lockObject(CompatibilitySpace compatibilitySpace, Lockable ref, Object qualifier, int timeout) throws StandardException

Lock an object.

Parameters
compatibilitySpace:CompatibilitySpace

the compatibility space

ref:Lockable

the object to lock

qualifier:Object

qualifier of the lock

timeout:int

maximum time to wait in milliseconds (C_LockFactory.NO_WAIT means don't wait)

Returns:Lock

a reference to the lock, or null if the lock couldn't be obtained immediately and the timeout was NO_WAIT or LockOwner had the noWait flag set

Exceptions
StandardException:
if the lock could not be obtained
oneLessWaiterback to summary
public void oneLessWaiter()

Notify the lock table that it has one less waiter.

oneMoreWaiterback to summary
public void oneMoreWaiter()

Notify the lock table that it has one more waiter.

setDeadlockTimeoutback to summary
public void setDeadlockTimeout(int timeout)

Set the deadlock timeout.

Parameters
timeout:int

deadlock timeout in milliseconds

setDeadlockTraceback to summary
public void setDeadlockTrace(boolean flag)

Enable or disable tracing of deadlocks.

Parameters
flag:boolean

true enables tracing, false disables tracing

setWaitTimeoutback to summary
public void setWaitTimeout(int timeout)

Set the wait timeout.

Parameters
timeout:int

wait timeout in milliseconds

shallowCloneback to summary
public Map<K, V> shallowClone()

Create a map containing a snapshot of all the (Lockable, LockControl) pairs in the lock table.

Returns:Map<K, V>

a shallow clone of the lock table

unlockback to summary
public void unlock(Latch item, int unlockCount)

Unlock an object previously locked by lockObject().

Parameters
item:Latch

the lock to unlock

unlockCount:int

the number of times to unlock the item; or zero, meaning take the unlock count from the item

unlockReferenceback to summary
public Lock unlockReference(CompatibilitySpace space, Lockable ref, Object qualifier, Map<K, V> group)

Unlock an object once if it is present in the specified group. Also remove the object from the group.

Parameters
space:CompatibilitySpace

the compatibility space

ref:Lockable

a reference to the locked object

qualifier:Object

qualifier of the lock

group:Map<K, V>

a map representing the locks in a group

Returns:Lock

the corresponding lock in the group map, or null if the object was not unlocked

zeroDurationLockObjectback to summary
public boolean zeroDurationLockObject(CompatibilitySpace space, Lockable ref, Object qualifier, int timeout) throws StandardException

Lock an object and release the lock immediately. Equivalent to

Lock lock = lockTable.lockObject(space, ref, qualifier, timeout);
lockTable.unlock(lock, 1);
except that the implementation might be more efficient.
Parameters
space:CompatibilitySpace

the compatibility space

ref:Lockable

a reference to the locked object

qualifier:Object

qualifier of the lock

timeout:int

maximum time to wait in milliseconds (C_LockFactory.NO_WAIT means don't wait)

Returns:boolean

true if the object was locked, or false if the object couldn't be locked immediately and timeout was NO_WAIT or LockOwner had the noWait flag set

Exceptions
StandardException:
if the lock could not be obtained