001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc.object.lockmanager.api;
005:
006: import com.tc.exception.ImplementMe;
007: import com.tc.object.lockmanager.impl.GlobalLockInfo;
008: import com.tc.object.session.SessionID;
009: import com.tc.object.tx.TransactionID;
010: import com.tc.object.tx.WaitInvocation;
011:
012: import java.util.ArrayList;
013: import java.util.Collection;
014: import java.util.LinkedList;
015: import java.util.List;
016:
017: /**
018: * @author steve
019: */
020: public class TestLockManager implements ClientLockManager {
021: public final List locks = new ArrayList();
022: public final List lockIDForCalls = new LinkedList();
023: public final List waitCalls = new LinkedList();
024: public final List notifyCalls = new LinkedList();
025: public final List unlockCalls = new LinkedList();
026:
027: public void unlock(LockID id, ThreadID threadID) {
028: unlockCalls.add(new Object[] { id, threadID });
029: }
030:
031: public LockID lockIDFor(String id) {
032: lockIDForCalls.add(id);
033: return new LockID(id);
034: }
035:
036: public void awardLock(SessionID sessionID, LockID id,
037: ThreadID threadID, int type) {
038: return;
039: }
040:
041: public void lock(LockID id, ThreadID threadID, int type) {
042: locks.add(new Object[] { id, threadID, new Integer(type) });
043: }
044:
045: public void wait(LockID lockID, ThreadID transactionID,
046: WaitInvocation call, Object waitLock, WaitListener listener) {
047: waitCalls.add(new Object[] { lockID, transactionID, call,
048: waitLock, listener });
049: }
050:
051: public Notify notify(LockID lockID, ThreadID threadID, boolean all) {
052: notifyCalls.add(new Object[] { lockID, threadID,
053: new Boolean(all) });
054: return Notify.NULL;
055: }
056:
057: public Collection addAllPendingLockRequestsTo(Collection c) {
058: return c;
059: }
060:
061: public void pause() {
062: return;
063: }
064:
065: public void starting() {
066: return;
067: }
068:
069: public void unpause() {
070: return;
071:
072: }
073:
074: public boolean isStarting() {
075: return false;
076: }
077:
078: public Collection addAllWaitersTo(Collection c) {
079: return c;
080: }
081:
082: public Collection addAllHeldLocksTo(Collection c) {
083: return c;
084: }
085:
086: public void notified(LockID lockID, ThreadID threadID) {
087: return;
088: }
089:
090: public void recall(LockID lockID, ThreadID id, int level) {
091: return;
092: }
093:
094: public void waitTimedOut(LockID lockID, ThreadID threadID) {
095: return;
096: }
097:
098: public void runGC() {
099: return;
100: }
101:
102: public boolean isLocked(LockID lockID, ThreadID threadID,
103: int lockLevel) {
104: return lockIDForCalls.contains(lockID.asString());
105: }
106:
107: public int localHeldCount(LockID lockID, int lockLevel,
108: ThreadID threadID) {
109: throw new ImplementMe();
110: }
111:
112: public boolean isLocked(LockID lockID, ThreadID threadID) {
113: throw new ImplementMe();
114: }
115:
116: public boolean haveLock(LockID lockID, TransactionID requesterID) {
117: throw new ImplementMe();
118: }
119:
120: public void queryLockCommit(ThreadID threadID,
121: GlobalLockInfo globalLockInfo) {
122: throw new ImplementMe();
123: }
124:
125: public int waitLength(LockID lockID, ThreadID threadID) {
126: throw new ImplementMe();
127: }
128:
129: public boolean tryLock(LockID id, ThreadID threadID,
130: WaitInvocation timeout, int type) {
131: throw new ImplementMe();
132: }
133:
134: public Collection addAllPendingTryLockRequestsTo(Collection c) {
135: throw new ImplementMe();
136: }
137:
138: public int queueLength(LockID lockID, ThreadID threadID) {
139: throw new ImplementMe();
140: }
141:
142: public void cannotAwardLock(SessionID sessionID, LockID id,
143: ThreadID threadID, int type) {
144: throw new ImplementMe();
145: }
146:
147: public void enableStat(LockID lockID, int lockStackTraceDepth,
148: int lockStatCollectFrequency) {
149: throw new ImplementMe();
150: }
151:
152: public void disableStat(LockID lockID) {
153: throw new ImplementMe();
154: }
155:
156: }
|