mirror of https://github.com/apache/lucene.git
#28855 - better lock obtain timed out error message (Daniel Naber)
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150318 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f0017af921
commit
5bc6296927
|
@ -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() {
|
||||
return new Lock(lockFile) {
|
||||
public boolean obtain() throws IOException {
|
||||
if (DISABLE_LOCKS)
|
||||
return true;
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.lucene.store;
|
|||
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/** An interprocess mutex lock.
|
||||
|
@ -35,7 +36,15 @@ import java.io.IOException;
|
|||
*/
|
||||
public abstract class Lock {
|
||||
public static long LOCK_POLL_INTERVAL = 1000;
|
||||
private File lockFile = null;
|
||||
|
||||
Lock(File lockFile) {
|
||||
this.lockFile = lockFile;
|
||||
}
|
||||
|
||||
Lock() {
|
||||
}
|
||||
|
||||
/** Attempts to obtain exclusive access and immediately return
|
||||
* upon success or failure.
|
||||
* @return true iff exclusive access is obtained
|
||||
|
@ -55,7 +64,11 @@ public abstract class Lock {
|
|||
int sleepCount = 0;
|
||||
while (!locked) {
|
||||
if (++sleepCount == maxSleepCount) {
|
||||
throw new IOException("Lock obtain timed out");
|
||||
String s = "Lock obtain timed out";
|
||||
if (lockFile != null) {
|
||||
s += ", lock file =" + lockFile.getAbsolutePath();
|
||||
}
|
||||
throw new IOException(s);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(LOCK_POLL_INTERVAL);
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.lucene.store;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Enumeration;
|
||||
|
||||
|
@ -115,8 +114,7 @@ public final class RAMDirectory extends Directory {
|
|||
/** Set the modified time of an existing file to now. */
|
||||
public void touchFile(String name) throws IOException {
|
||||
// final boolean MONITOR = false;
|
||||
int count = 0;
|
||||
|
||||
|
||||
RAMFile file = (RAMFile)files.get(name);
|
||||
long ts2, ts1 = System.currentTimeMillis();
|
||||
do {
|
||||
|
|
Loading…
Reference in New Issue