public class LockManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.HashMap<TransactionId,java.util.Set<PageId>> |
exclusivePages |
private java.util.HashMap<PageId,java.util.Set<TransactionId>> |
readLocks |
private java.util.HashMap<TransactionId,java.util.Set<PageId>> |
sharedPages |
private java.util.HashMap<PageId,TransactionId> |
writeLock |
Constructor and Description |
---|
LockManager() |
Modifier and Type | Method and Description |
---|---|
private void |
addLock(TransactionId tid,
PageId pid,
Permissions pm) |
boolean |
grantLock(TransactionId tid,
PageId pid,
Permissions pm)
Grants lock to the Transaction.
|
boolean |
holdsLock(TransactionId tid,
PageId pid)
Checks if transaction has lock on a page
|
void |
releaseAllPages(TransactionId tid)
Releases all pages associated with given Transaction.
|
void |
releaseLock(TransactionId tid,
PageId pid)
Releases locks associated with given transaction and page.
|
void |
removePage(PageId pid)
Releases Lock related to a page
|
private java.util.HashMap<PageId,java.util.Set<TransactionId>> readLocks
private java.util.HashMap<PageId,TransactionId> writeLock
private java.util.HashMap<TransactionId,java.util.Set<PageId>> sharedPages
private java.util.HashMap<TransactionId,java.util.Set<PageId>> exclusivePages
public boolean holdsLock(TransactionId tid, PageId pid)
tid
- Transaction Idpid
- Page Idprivate void addLock(TransactionId tid, PageId pid, Permissions pm)
public boolean grantLock(TransactionId tid, PageId pid, Permissions pm)
tid
- TransactionId requesting lock.pid
- PageId on which the lock is requested.pm
- The type of permission.public void releaseLock(TransactionId tid, PageId pid)
tid
- The TransactionId.pid
- The PageId.public void removePage(PageId pid)
pid
- PageIdpublic void releaseAllPages(TransactionId tid)
tid
- The TransactionId.