switch Lock to use a String instead of File

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150321 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2004-05-10 23:46:56 +00:00
parent f5648fc28f
commit 7e5763e5ca
2 changed files with 6 additions and 7 deletions

View File

@ -290,7 +290,7 @@ public final class FSDirectory extends Directory {
// create a lock file
final File lockFile = new File(lockDir, buf.toString());
return new Lock(lockFile) {
return new Lock(lockFile.getAbsolutePath()) {
public boolean obtain() throws IOException {
if (DISABLE_LOCKS)
return true;

View File

@ -18,7 +18,6 @@ package org.apache.lucene.store;
import org.apache.lucene.index.IndexWriter;
import java.io.File;
import java.io.IOException;
/** An interprocess mutex lock.
@ -36,10 +35,10 @@ import java.io.IOException;
*/
public abstract class Lock {
public static long LOCK_POLL_INTERVAL = 1000;
private File lockFile = null;
private String lockName = null;
public Lock(File lockFile) {
this.lockFile = lockFile;
public Lock(String lockName) {
this.lockName = lockName;
}
public Lock() {
@ -65,8 +64,8 @@ public abstract class Lock {
while (!locked) {
if (++sleepCount == maxSleepCount) {
String s = "Lock obtain timed out";
if (lockFile != null) {
s += ", lock file =" + lockFile.getAbsolutePath();
if (lockName != null) {
s += ", lock name =" + lockName;
}
throw new IOException(s);
}