|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.egothor.lock.LockManager
public abstract class LockManager
Entry point for all lock processing requests. It provides methods to acquire or release locks plus other methods involved in multithreaded usage of some location, like modifier state activation, index constancy processing. There are 3 ways of getting a lock:
- simple get[Write|Read]Lock - single request
- getSleep[Write|Read]Lock - repetative requests in case of failure until succes (or timeout). Following attempts are processed after a period of sleeping.
- getSpin[Write|Read]Lock - repetative requests in case of failure until succes (or timeout). Following attempts are proccesed imediatly after failure.
| Constructor Summary | |
|---|---|
LockManager()
Constructor |
|
| Method Summary | |
|---|---|
java.io.File |
createUniqueFile(java.lang.String location,
java.lang.String prefix)
Creates a unique file with the input prefix in the input location. |
void |
ensureModifierActiveState(java.lang.String globalTankerLocation,
java.lang.String localTankerLocation)
Ensures that a caller has an active modifier state. |
LockResult |
getReadLock(java.lang.String location,
long indexConstPeriodOfTime,
long threadGroupId,
int timeOut)
Gets a READ lock in the location using only single request. |
boolean |
getSleepReadLock(java.lang.String location,
long indexConstPeriodOfTime,
long threadGroupId,
int timeOut)
Gets a READ lock in the location, using sleeping - repetative requests until succes with short sleeping in between. |
boolean |
getSleepRecoveryLock(java.lang.String location,
int timeOut)
Gets a RECOVERY lock in the location, using sleeping - repetative requests until succes with short sleeping in between. |
boolean |
getSleepWriteLock(java.lang.String location,
int timeOut)
Gets a WRITE lock in the location, using sleeping - repetative requests until succes with short sleeping in between. |
boolean |
getSpinReadLock(java.lang.String location,
long indexConstPeriodOfTime,
long threadGroupId,
int timeOut)
Gets a READ lock in the location, using spinning - repetative requests until succes with no delay in between. |
boolean |
getSpinRecoveryLock(java.lang.String location,
int timeOut)
Gets a RECOVERY lock in the location, using spinning - repetative requests until succes with no delay in between. |
boolean |
getSpinWriteLock(java.lang.String location,
int timeOut)
Gets a WRITE lock in the location, using spinning - repetative requests until succes with no delay in between. |
LockResult |
getWriteLock(java.lang.String location,
int timeOut)
Gets a WRITE lock in the location using only single request. |
boolean |
isIndexConstant(java.lang.String location,
long threadGroupId)
Checks whether index in the location is constant for the caller. |
protected abstract LockResult |
processLock(LockRequest request)
Method will try to achieve read lock in the appropriate implementation. |
boolean |
releaseLock(java.lang.String location)
Releases lock in the location. |
void |
removeActiveModifierState(java.lang.String globalTankerLocation,
java.lang.String localTankerLocation)
Removes active modifier state from the location |
void |
removeIndexConstState(java.lang.String location,
long threadGroupId)
Discards index constancy in the location. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LockManager()
| Method Detail |
|---|
public boolean getSpinReadLock(java.lang.String location,
long indexConstPeriodOfTime,
long threadGroupId,
int timeOut)
location - Location to lockindexConstPeriodOfTime - Period of time when index will remain constant for the callerthreadGroupId - Id of a group of thread that share single instance of a tankertimeOut - Period of time in which this request must be processed
true if lock granted, false
otherwise
public boolean getSpinWriteLock(java.lang.String location,
int timeOut)
location - Location to locktimeOut - Period of time in which this request must be processed
true if lock granted, false
otherwise
public boolean getSleepReadLock(java.lang.String location,
long indexConstPeriodOfTime,
long threadGroupId,
int timeOut)
location - Location to lockindexConstPeriodOfTime - Period of time when index will remain constant for the callerthreadGroupId - Id of a group of thread that share single instance of a tankertimeOut - Period of time in which this request must be processed
true if lock granted, false
otherwise
public boolean getSleepWriteLock(java.lang.String location,
int timeOut)
location - Location to locktimeOut - Period of time in which this request must be processed
true if lock granted, false
otherwise
public boolean getSpinRecoveryLock(java.lang.String location,
int timeOut)
location - Location to locktimeOut - Period of time in which this request must be processed
true if lock granted, false
otherwise
public boolean getSleepRecoveryLock(java.lang.String location,
int timeOut)
location - Location to locktimeOut - Period of time in which this request must be processed
true if lock granted, false
otherwise
public LockResult getReadLock(java.lang.String location,
long indexConstPeriodOfTime,
long threadGroupId,
int timeOut)
location - Location to lockindexConstPeriodOfTime - Period of time when index will remain constant for the callerthreadGroupId - Id of a group of thread that share single instance of a tankertimeOut - Period of time in which this request must be processed
true if lock granted, false
otherwise
public LockResult getWriteLock(java.lang.String location,
int timeOut)
location - Location to locktimeOut - Period of time in which this request must be processed
true if lock granted, false
otherwisepublic boolean releaseLock(java.lang.String location)
location - Location where the lock should be released
true if lock released, false
otherwise
public boolean isIndexConstant(java.lang.String location,
long threadGroupId)
true if constancy is valid, false otherwise
location - Location where to check a constancy statethreadGroupId - Identifier of a group of threads that share one instance of the tanker.
true if constancy is valid, false
otherwise
public void removeIndexConstState(java.lang.String location,
long threadGroupId)
location - Location where to cancel a constancy for the callerthreadGroupId - Identifier of a group of threads that share one instance of the tanker.
public void ensureModifierActiveState(java.lang.String globalTankerLocation,
java.lang.String localTankerLocation)
globalTankerLocation - Location where a active modifier state should be createdlocalTankerLocation - Location of tanker where modifications are stored before
commit
public void removeActiveModifierState(java.lang.String globalTankerLocation,
java.lang.String localTankerLocation)
globalTankerLocation - Location where an active modifier state should be canceledlocalTankerLocation - TODO
public java.io.File createUniqueFile(java.lang.String location,
java.lang.String prefix)
location - Location where to create a unique fileprefix - Prefix of the unique file
protected abstract LockResult processLock(LockRequest request)
throws java.io.IOException
request -
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||