org.javaseis.io
Class SeisNativeLock

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

public class SeisNativeLock
extends java.lang.Object
implements ISeisLock

Provide a lock facility using the "lockfile" facility from Linux sendmail. This version calls a native method to do the locking.

Author:
Chuck Mosher for JavaSeis.org

Field Summary
static java.util.logging.Logger log
           
 
Constructor Summary
SeisNativeLock(java.lang.String path)
          Create a lock manager for a particular file.
SeisNativeLock(java.lang.String path, int retryCount)
          Create a lock manager for a particular file.
SeisNativeLock(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

log

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

SeisNativeLock

public SeisNativeLock(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

SeisNativeLock

public SeisNativeLock(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

SeisNativeLock

public SeisNativeLock(java.lang.String path,
                      int retryCount,
                      long maxsleep)
               throws SeisException
Create a lock manager for a particular file.

Parameters:
path - regular file to protect with a lock
retryCount - number of times to re-try acquiring the lock
maxsleep - max number of milliesconds to sleep between retries. A random number between 0 and this value is chosen for each re-try.
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