org.javaseis.io
Class SeisLock

java.lang.Object
  extended by org.javaseis.io.SeisLock
All Implemented Interfaces:
ISeisLock

public class SeisLock
extends java.lang.Object
implements ISeisLock

Provide a lock facility based on Java NIO FileLock classes This type of locking strategy should work reasonaly reliably for cases where the number of transactions per second is low. If this locking class gets pushed to hard it will fail.

Author:
Chuck Mosher for JavaSeis.org

Field Summary
static java.lang.String EXTN
           
static java.util.logging.Logger log
           
 
Constructor Summary
SeisLock(java.lang.String path)
          Create a lock manager for a particular file.
SeisLock(java.lang.String path, int retryCount)
          Create a lock manager for a particular file.
SeisLock(java.lang.String path, int retryCount, long maxsleep)
          Create a lock manager for a particular file.
 
Method Summary
 float getTime()
           
 boolean isLocked()
           
 boolean lock()
           
 void release()
           
 void trackTime(boolean trackTime)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTN

public static java.lang.String EXTN

log

public static final java.util.logging.Logger log
Constructor Detail

SeisLock

public SeisLock(java.lang.String path)
         throws SeisException
Create a lock manager for a particular file. A default retry count of 8 is used for acquiring the lock.

Parameters:
path - of file to be locked
Throws:
SeisException - if file is not found

SeisLock

public SeisLock(java.lang.String path,
                int retryCount)
         throws SeisException
Create a lock manager for a particular file. retry count of 8 is used for acquiring the lock.

Parameters:
path - of regular file to protect with a lock
Throws:
SeisException

SeisLock

public SeisLock(java.lang.String path,
                int retryCount,
                long maxsleep)
         throws SeisException
Create a lock manager for a particular file. retry count of 8 is used for acquiring the lock.

Parameters:
path - of regular file to protect with a lock
Throws:
SeisException
Method Detail

getTime

public float getTime()
Specified by:
getTime in interface ISeisLock

isLocked

public boolean isLocked()
Specified by:
isLocked in interface ISeisLock

lock

public boolean lock()
             throws SeisException
Specified by:
lock in interface ISeisLock
Throws:
SeisException

release

public void release()
             throws SeisException
Specified by:
release in interface ISeisLock
Throws:
SeisException

trackTime

public void trackTime(boolean trackTime)
Specified by:
trackTime in interface ISeisLock