Mercurial > hg > blitz_condensed
view src/org/dancres/blitz/txnlock/LockMgr.java @ 34:6f68e94c1fb8 default tip
Add CondensedStats monitoring utility, equivalent to vmstat
author | Dominic Cleal <dominic-cleal@cdo2.com> |
---|---|
date | Thu, 05 Aug 2010 11:07:25 +0100 |
parents | 3dc0c5604566 |
children |
line wrap: on
line source
package org.dancres.blitz.txnlock; import org.dancres.blitz.oid.OID; /** A lock mgr instance is responsible for tracking all transaction locks for a particular Entry type. */ public class LockMgr { /** For as long as any transaction has a reference to the lock, it will be maintained by the LockMgr. Obviously, if there are no pending transactions there's no need to hold the lock or it's state because the lock should be clear. If it's not clear, we have a bug!!!! :) */ // private SoftHashMap theLocks = new SoftHashMap(); private LockCache theLocks = new LockCache(); public TxnLock getLock(OID aOID) { return theLocks.getOrInsert(aOID); } public TxnLock newLock(OID aOID) { TxnLock myLock = new TxnLock(); theLocks.put(aOID, myLock); return myLock; } /** Test to see if the specified OID has an active lock associated with it. This is only truly useful in situations where the associated Entry is in an unchanging state perhaps because it has been DELETED or it's lease has expired. */ public boolean hasActiveLock(OID aOID) { TxnLock myLock = (TxnLock) theLocks.get(aOID); if (myLock != null) { synchronized(myLock) { return myLock.isActive(); } } return false; } }