|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.progeeks.repository.WormSharedLockManager
public class WormSharedLockManager
A locking manager that provides basic distributed locking among several processes assuming that all processes are willing to access repository items in a WORM (Write Once, Read Many) manner. The next repository item id is maintained in a file in the root of the repository. This file is locked by each process only when it needs a new item id. This locking manager is not safe to use with the meta-class cache.
Field Summary | |
---|---|
static int |
DEFAULT_RETRY_TIME
Default time in milliseconds between locking attempt tries. |
protected static java.lang.String |
ID_FILE
File used to save the id number to assign to the next added item. |
Constructor Summary | |
---|---|
WormSharedLockManager()
|
Method Summary | |
---|---|
void |
createRepository(java.io.File repositoryDir)
Creates the repository. |
int |
getNextItemId()
Returns the next item id, locking the id file for the read and write so that the id can be guaranteed unique between all the processes using the repository. |
int |
getRetryTime()
Returns the time in millseconds to wait between attempts to obtain the id lock. |
void |
initialize(java.io.File repositoryDir)
Initializes the repository, verifying that the id file is present. |
Lock |
lockItem(RepositoryItem item,
boolean writeLock)
Locks an item in the repository. |
Lock |
lockItem(java.lang.String itemId,
boolean writeLock)
Locks an item in the repository. |
void |
releaseLock(Lock lock)
Releases a lock on an item on the repository. |
void |
setRetryTime(int retryTime)
Sets the time in milliseconds to wait between attempts to obtain the id lock. |
void |
terminate()
Terminates the locking manager. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_RETRY_TIME
protected static final java.lang.String ID_FILE
Constructor Detail |
---|
public WormSharedLockManager()
Method Detail |
---|
public void setRetryTime(int retryTime)
public int getRetryTime()
public void initialize(java.io.File repositoryDir)
initialize
in interface LockManager
public void createRepository(java.io.File repositoryDir)
createRepository
in interface LockManager
public void terminate()
terminate
in interface LockManager
public int getNextItemId()
getNextItemId
in interface LockManager
public Lock lockItem(RepositoryItem item, boolean writeLock)
lockItem
in interface LockManager
public void releaseLock(Lock lock)
releaseLock
in interface LockManager
public Lock lockItem(java.lang.String itemId, boolean writeLock)
lockItem
in interface LockManager
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |