|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.farrago.util.FarragoFileLockAllocation
public class FarragoFileLockAllocation
FarragoFileLockAllocation takes care of unlocking a file when it is closed.
Field Summary | |
---|---|
private FileChannel |
channel
|
private File |
file
|
private FileLock |
lock
|
private static int |
LOCK_OFFSET
Location to lock. |
private RandomAccessFile |
randomAccessFile
|
private static Logger |
tracer
|
Constructor Summary | |
---|---|
FarragoFileLockAllocation(FarragoAllocationOwner owner,
File file,
boolean tryLock)
Creates a new FarragoFileLockAllocation by locking a file. |
Method Summary | |
---|---|
void |
closeAllocation()
Closes this object. |
static void |
main(String[] args)
Command-line entry point for bench testing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int LOCK_OFFSET
private static final Logger tracer
private File file
private RandomAccessFile randomAccessFile
private FileChannel channel
private FileLock lock
Constructor Detail |
---|
public FarragoFileLockAllocation(FarragoAllocationOwner owner, File file, boolean tryLock) throws IOException
owner
- the FarragoAllocationOwner which will be made responsible
for the lock as a result of this callfile
- the file to be locked for the lifetime of this allocation; if
it does not exist, it will be created (but not deleted) automaticallytryLock
- if true and lock cannot be obtained throw an exception; if
false, wait for the lock instead
IOException
- if lock attempt failedMethod Detail |
---|
public void closeAllocation()
ClosableAllocation
closeAllocation
in interface ClosableAllocation
public static void main(String[] args) throws Exception
TODO jvs 24-Aug-2005: Figure out a way to test this automatically. Requires starting two concurrent processes.
args
- args[0] = name of file to lock
Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |