com.continuent.tungsten.replicator.thl.log
Class WriteLock

java.lang.Object
  extended by com.continuent.tungsten.replicator.thl.log.WriteLock

public class WriteLock
extends java.lang.Object

This class implements a write locking mechanism by acquiring an exclusive lock on a named operating system file. The lock mechanism is used to prevent multiple processes from writing to disk logs.

Version:
1.0
Author:
Robert Hodges

Constructor Summary
WriteLock(java.io.File lockFile)
          Instantiates the write lock instance.
 
Method Summary
 boolean acquire()
          Attempt to acquire write lock.
 boolean isLocked()
          Return true if the write lock is currently acquired exclusively.
 void release()
          Release the write lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WriteLock

public WriteLock(java.io.File lockFile)
          throws ReplicatorException
Instantiates the write lock instance.

Parameters:
lockFile -
Throws:
ReplicatorException
Method Detail

acquire

public boolean acquire()
                throws ReplicatorException
Attempt to acquire write lock. This call is idempotent.

Returns:
true if lock successfully acquired
Throws:
ReplicatorException

isLocked

public boolean isLocked()
Return true if the write lock is currently acquired exclusively.


release

public void release()
Release the write lock. This call is idempotent.