| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Terracotta
Revision: 9957
Author: ssubbiah
Date: 03 Sep 2008 20:15:53
Changes:MNK-704, MNK-706 : Sending the right lockID in the response when there is no lock in the server
Files:| ... | ...@@ -90,8 +90,8 @@ | |
| 90 | 90 | ServerThreadContextFactory threadContextFactory, L2LockStatsManager lockStatsManager) { |
| 91 | 91 | this(lockID, timeout, listeners, false, lockPolicy, threadContextFactory, lockStatsManager); |
| 92 | 92 | } |
| 93 | ||
| 94 | // for tests | |
| 93 | ||
| 94 | // used in tests and in query lock when Locks don't exists. | |
| 95 | 95 | Lock(LockID lockID, long timeout, LockEventListener[] listeners) { |
| 96 | 96 | this(lockID, timeout, listeners, false, LockManagerImpl.ALTRUISTIC_LOCK_POLICY, |
| 97 | 97 | ServerThreadContextFactory.DEFAULT_FACTORY, L2LockStatsManager.NULL_LOCK_STATS_MANAGER); |
| ... | ...@@ -49,7 +49,7 @@ | |
| 49 | 49 | /** |
| 50 | 50 | * Server representation of lock management. We will need to keep track of what locks are checkedout, who has the lock |
| 51 | 51 | * and who wants the lock |
| 52 | * | |
| 52 | * | |
| 53 | 53 | * @author steve |
| 54 | 54 | */ |
| 55 | 55 | public class LockManagerImpl implements LockManager, LockManagerMBean, TimerCallback { |
| ... | ...@@ -221,8 +221,13 @@ | |
| 221 | 221 | } |
| 222 | 222 | if (!isStarted()) return; |
| 223 | 223 | |
| 224 | Lock lock = getLockFor(lockID); | |
| 225 | 224 | ServerThreadContext threadContext = threadContextFactory.getOrCreate(cid, threadID); |
| 225 | Lock lock = (Lock) locks.get(lockID); | |
| 226 | if (lock == null) { | |
| 227 | // This lock is not present in the server, we still want to send the right lockID info in the response. Create one | |
| 228 | // for temporary use. | |
| 229 | lock = new Lock(lockID, this.lockTimeout, this.lockListeners); | |
| 230 | } | |
| 226 | 231 | lock.queryLock(threadContext, lockResponseSink); |
| 227 | 232 | } |
| 228 | 233 | |
| ... | ...@@ -415,7 +420,10 @@ | |
| 415 | 420 | |
| 416 | 421 | private Lock getLockFor(LockID id) { |
| 417 | 422 | Lock lock = (Lock) locks.get(id); |
| 418 | if (lock == null) return Lock.NULL_LOCK; | |
| 423 | if (lock == null) { | |
| 424 | logger.warn("Look up of Non-exisiting Lock for ID : " + id); | |
| 425 | return Lock.NULL_LOCK; | |
| 426 | } | |
| 419 | 427 | return lock; |
| 420 | 428 | } |
| 421 | 429 | |
| ... | ...@@ -629,7 +637,7 @@ | |
| 629 | 637 | public synchronized PrettyPrinter prettyPrint(PrettyPrinter out) { |
| 630 | 638 | out.println(getClass().getName()); |
| 631 | 639 | out.indent().println("locks: " + locks.size()); |
| 632 | for (Iterator i = locks.values().iterator(); i.hasNext(); ) { | |
| 640 | for (Iterator i = locks.values().iterator(); i.hasNext();) { | |
| 633 | 641 | out.println(i.next()); |
| 634 | 642 | } |
| 635 | 643 | return out; |
| ... | ...@@ -108,7 +108,6 @@ | |
| 108 | 108 | |
| 109 | 109 | spec.addRoot("root1", "root1"); |
| 110 | 110 | spec.addRoot("root2", "root2"); |
| 111 | spec.addRoot("objectRoot", "objectRoot"); | |
| 112 | 111 | } |
| 113 | 112 | |
| 114 | 113 | } |