public class DatabaseResourceLockManager extends Object implements ResourceLockManager
Modifier and Type | Field and Description |
---|---|
protected org.apache.log4j.Logger |
mLogger
Deprecated.
|
Constructor and Description |
---|
DatabaseResourceLockManager()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
boolean |
forceRelease(ResourceLock pResourceLock)
Deprecated.
Releases the resource, or part of the resource forcibly disregarding any locks that have been obtained elsewhere.
|
ResourceLock |
get(String pLockHandle)
Deprecated.
Looks up an existing lock and returns the
ResourceLock which represents that lock. |
neo.xredsys.content.ContentManager |
getContentManager()
Deprecated.
|
List<ResourceLock> |
getLocks(URI pUri)
Deprecated.
Returns the list of all locks that exist for the given resource.
|
long |
getStaleLockTimeMillis()
Deprecated.
|
boolean |
isLocked(URI pURI)
Deprecated.
Check whether a resource, identified by URI, is locked or not.
|
String |
obtainExclusiveLock(URI pURI,
List<String> pLockHandles,
long pMillisToLive,
String pMessage)
Deprecated.
Acquires a system wide lock for an entire resource.
|
String |
obtainLock(URI pUri,
List<String> pFragments,
long pMillisToLive,
String pMessage)
Deprecated.
Acquires a system wide lock for an entire resource or one or more fragments in question.
|
void |
refresh(String pLockHandle,
long pMillisToLive)
Deprecated.
Updates an existing lock identified by
pIdentifie r and updates its time-to-live accordingly. |
boolean |
release(String pLockHandle)
Deprecated.
Releases the given lock identified by the given identifier.
|
void |
setContentManager(neo.xredsys.content.ContentManager pContentManager)
Deprecated.
|
void |
setStaleLockTimeMillis(long pTime)
Deprecated.
|
public void setContentManager(neo.xredsys.content.ContentManager pContentManager)
public neo.xredsys.content.ContentManager getContentManager()
public void setStaleLockTimeMillis(long pTime)
public long getStaleLockTimeMillis()
public String obtainExclusiveLock(URI pURI, List<String> pLockHandles, long pMillisToLive, String pMessage) throws AlreadyLockedException, IllegalArgumentException
ResourceLockManager
Acquires a system wide lock for an entire resource.
The URI can be any valid URI but cannot contain a fragment identifier. If pUri
has a a fragment
identifier then IllegalArgumentException
is thrown.
After a successful lock, the method returns the lock identifier which uniquely identifies this lock. The
details of the resource lock may be obtained by passing it to the ResourceLockManager.get(String)
method.
The returned identifier identifies the resource lock and must be kept by the client in order for the client to be able to continue working with the locks.
The client must specify how long the lock is to be kept alive before being removed by the server. The client should specify a meaningful length of time. This is purely a safety measure allowing the locks to be alive for a while even if the client has lost its connection to the server or is temporarily inaccessible. The server will keep the lock for the specified amount of time and will be removed afterwards.
The server may also impose a hard limit on the length of time it wants to keep locks around. If pMillisToLive
exceeds this limit it is simply capped to that limit.
obtainExclusiveLock
in interface ResourceLockManager
pURI
- the URI of the resource to lock; the URI cannot contain fragment identifierspLockHandles
- A list of already locked handles. The list may be null
.pMillisToLive
- The time (in milliseconds) that the lock should exist. pMillisToLive
must be >= 1.pMessage
- A message from the client, or null
for no messageAlreadyLockedException
- if the lock is incompatible with other locks on the same resourceIllegalArgumentException
- if pUri
is null
or has a fragment identifier, or if pMillis
is less than 1, or if pFragments
contains illegal fragment
identifiers.public String obtainLock(URI pUri, List<String> pFragments, long pMillisToLive, String pMessage) throws AlreadyLockedException, IllegalArgumentException
ResourceLockManager
Acquires a system wide lock for an entire resource or one or more fragments in question.
The URI can be any valid URI but cannot contain a fragment identifier. If pUri
has a a fragment
identifier then IllegalArgumentException
is thrown.
If fragments is null
then the entire resource is locked. A valid fragment is a fragment identifier as
per the URI specification.
After a successful lock, the method returns the lock identifier which uniquely identifies this lock. The
details of the resource lock may be obtained by passing it to the ResourceLockManager.get(String)
method.
The returned identifier identifies the resource lock and must be kept by the client in order for the client to be able to continue working with the locks.
The client must specify how long the lock is to be kept alive before being removed by the server. The client should specify a meaningful length of time. This is purely a safety measure allowing the locks to be alive for a while even if the client has lost its connection to the server or is temporarily inaccessible. The server will keep the lock for the specified amount of time and will be removed afterwards.
The server may also impose a hard limit on the length of time it wants to keep locks around. If pMillisToLive
exceeds this limit it is simply capped to that limit.
obtainLock
in interface ResourceLockManager
pUri
- the URI of the resource to lock; the URI cannot contain fragment identifierspFragments
- A list of fragment identifiers, or null
for a full resource lockpMillisToLive
- The time (in milliseconds) that the lock should exist. pMillisToLive
must be >= 1.pMessage
- A message from the client, or null
for no messageAlreadyLockedException
- if the lock is incompatible with other locks on the same resourceIllegalArgumentException
- if pUri
is null
or has a fragment identifier, or if pMillis
is less than 1, or if pFragments
contains illegal fragment
identifiers.public ResourceLock get(String pLockHandle) throws IllegalOperationException
ResourceLockManager
ResourceLock
which represents that lock.
If the lock does not exist, the method throws an IllegalOperationException
.get
in interface ResourceLockManager
pLockHandle
- The unique identifier of an existing lock, returned by ResourceLockManager.obtainLock(java.net.URI, java.util.List<java.lang.String>, long, java.lang.String)
IllegalOperationException
- if the lock does not exist.ResourceLockManager.obtainLock(java.net.URI,java.util.List,long,String)
public void refresh(String pLockHandle, long pMillisToLive) throws IllegalOperationException
ResourceLockManager
pIdentifie
r and updates its time-to-live accordingly.
The lock will not be removed by the server before the specified amount of time has passed.refresh
in interface ResourceLockManager
pLockHandle
- The unique identifier of an existing lock, returned by ResourceLockManager.obtainLock(java.net.URI, java.util.List<java.lang.String>, long, java.lang.String)
pMillisToLive
- The time (in milliseconds) that the lock should exist, pMillisToLive
must be >= 1IllegalOperationException
- if the lock does not exist.ResourceLockManager.obtainLock(java.net.URI,java.util.List,long,String)
public boolean release(String pLockHandle)
ResourceLockManager
true
after a
successful refresh. If the method returns false
this is because the lock has been forced open by
another client (using ResourceLockManager.forceRelease(neo.xredsys.api.ResourceLock)
), or deleted by the server when the lock exceeded its time-to-live.release
in interface ResourceLockManager
pLockHandle
- The unique identifier of an existing lock, returned by ResourceLockManager.obtainLock(java.net.URI, java.util.List<java.lang.String>, long, java.lang.String)
true
if the release was successful, false
if the lock did not existResourceLockManager.obtainLock(java.net.URI,java.util.List,long,String)
public List<ResourceLock> getLocks(URI pUri)
ResourceLockManager
getLocks
in interface ResourceLockManager
pUri
- The URI of the resourcepublic boolean forceRelease(ResourceLock pResourceLock)
ResourceLockManager
true
after a successful refresh. If the method returns false
this is because
the lock has been forced open by another client (using ResourceLockManager.forceRelease(neo.xredsys.api.ResourceLock)
), or deleted by the server when the
lock exceeded its time-to-live.forceRelease
in interface ResourceLockManager
pResourceLock
- The resource lock to break, usually obtained from getLocks()
.true
if the release was successful, false
if the lock did not existResourceLockManager.getLocks(URI)
public boolean isLocked(URI pURI)
ResourceLockManager
isLocked
in interface ResourceLockManager
pURI
- the URI of the resource to checktrue
if the resource, identified by pURI, is locked. false
if the resource is not locked© 1998- 2018 Stibo DX