mirror of https://github.com/apache/lucene.git
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:
parent
f5648fc28f
commit
7e5763e5ca
|
@ -290,7 +290,7 @@ public final class FSDirectory extends Directory {
|
||||||
// create a lock file
|
// create a lock file
|
||||||
final File lockFile = new File(lockDir, buf.toString());
|
final File lockFile = new File(lockDir, buf.toString());
|
||||||
|
|
||||||
return new Lock(lockFile) {
|
return new Lock(lockFile.getAbsolutePath()) {
|
||||||
public boolean obtain() throws IOException {
|
public boolean obtain() throws IOException {
|
||||||
if (DISABLE_LOCKS)
|
if (DISABLE_LOCKS)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.lucene.store;
|
||||||
|
|
||||||
import org.apache.lucene.index.IndexWriter;
|
import org.apache.lucene.index.IndexWriter;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/** An interprocess mutex lock.
|
/** An interprocess mutex lock.
|
||||||
|
@ -36,10 +35,10 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public abstract class Lock {
|
public abstract class Lock {
|
||||||
public static long LOCK_POLL_INTERVAL = 1000;
|
public static long LOCK_POLL_INTERVAL = 1000;
|
||||||
private File lockFile = null;
|
private String lockName = null;
|
||||||
|
|
||||||
public Lock(File lockFile) {
|
public Lock(String lockName) {
|
||||||
this.lockFile = lockFile;
|
this.lockName = lockName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Lock() {
|
public Lock() {
|
||||||
|
@ -65,8 +64,8 @@ public abstract class Lock {
|
||||||
while (!locked) {
|
while (!locked) {
|
||||||
if (++sleepCount == maxSleepCount) {
|
if (++sleepCount == maxSleepCount) {
|
||||||
String s = "Lock obtain timed out";
|
String s = "Lock obtain timed out";
|
||||||
if (lockFile != null) {
|
if (lockName != null) {
|
||||||
s += ", lock file =" + lockFile.getAbsolutePath();
|
s += ", lock name =" + lockName;
|
||||||
}
|
}
|
||||||
throw new IOException(s);
|
throw new IOException(s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue