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.object.lockmanager.impl.GlobalLockInfo;
007: import com.tc.object.session.SessionID;
008: import com.tc.object.tx.WaitInvocation;
009:
010: import java.util.Collection;
011:
012: /**
013: * Simple lock manager for the client
014: *
015: * @author steve
016: */
017: public interface ClientLockManager {
018:
019: public void pause();
020:
021: public void starting();
022:
023: public void unpause();
024:
025: public boolean isStarting();
026:
027: /**
028: * obtain a lock
029: *
030: * @param obj
031: */
032: public void lock(LockID id, ThreadID threadID, int type);
033:
034: public boolean tryLock(LockID id, ThreadID threadID,
035: WaitInvocation timeout, int type);
036:
037: /**
038: * releases the lock so that others can have at it
039: *
040: * @param obj
041: */
042: public void unlock(LockID id, ThreadID threadID);
043:
044: /**
045: * awards the lock to the threadID
046: */
047: public void awardLock(SessionID sessionID, LockID id,
048: ThreadID threadID, int type);
049:
050: public void cannotAwardLock(SessionID sessionID, LockID id,
051: ThreadID threadID, int type);
052:
053: public LockID lockIDFor(String id);
054:
055: public void wait(LockID lockID, ThreadID threadID,
056: WaitInvocation call, Object waitObject,
057: WaitListener listener) throws InterruptedException;
058:
059: public void waitTimedOut(LockID lockID, ThreadID threadID);
060:
061: /**
062: * Returns true if this notification should be send to the server for handling. This nofication is not needed to be
063: * sent to the server if all is false and we have notified 1 waiter locally.
064: */
065: public Notify notify(LockID lockID, ThreadID threadID, boolean all);
066:
067: /**
068: * Makes the lock wait for the given lock and thread a pending request.
069: */
070: public void notified(LockID lockID, ThreadID threadID);
071:
072: /**
073: * Recalls a greedy Lock that was awarded earlier
074: */
075: public void recall(LockID lockID, ThreadID threadID, int level);
076:
077: /**
078: * Adds all lock waits to the given collection and returns that collection.
079: *
080: * @param c
081: */
082: public Collection addAllWaitersTo(Collection c);
083:
084: /**
085: * Adds all held locks to the given collection and returns that collection.
086: */
087: public Collection addAllHeldLocksTo(Collection c);
088:
089: /**
090: * Causes all pending lock requests to be added to the collection.
091: */
092: public Collection addAllPendingLockRequestsTo(Collection c);
093:
094: public Collection addAllPendingTryLockRequestsTo(Collection c);
095:
096: public void runGC();
097:
098: public int queueLength(LockID lockID, ThreadID threadID);
099:
100: public int waitLength(LockID lockID, ThreadID threadID);
101:
102: public int localHeldCount(LockID lockID, int lockLevel,
103: ThreadID threadID);
104:
105: public boolean isLocked(LockID lockID, ThreadID threadID,
106: int lockLevel);
107:
108: public void queryLockCommit(ThreadID threadID,
109: GlobalLockInfo globalLockInfo);
110:
111: public void enableStat(LockID lockID, int lockStackTraceDepth,
112: int lockStatCollectFrequency);
113:
114: public void disableStat(LockID lockID);
115: }
|