You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by eh...@apache.org on 2004/05/09 14:41:48 UTC
cvs commit: jakarta-lucene/src/java/org/apache/lucene/store FSDirectory.java Lock.java RAMDirectory.java
ehatcher 2004/05/09 05:41:47
Modified: src/java/org/apache/lucene/store FSDirectory.java Lock.java
RAMDirectory.java
Log:
#28855 - better lock obtain timed out error message (Daniel Naber)
Revision Changes Path
1.27 +1 -1 jakarta-lucene/src/java/org/apache/lucene/store/FSDirectory.java
Index: FSDirectory.java
===================================================================
RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/FSDirectory.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- FSDirectory.java 29 Mar 2004 22:48:05 -0000 1.26
+++ FSDirectory.java 9 May 2004 12:41:47 -0000 1.27
@@ -290,7 +290,7 @@
// 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;
1.9 +15 -2 jakarta-lucene/src/java/org/apache/lucene/store/Lock.java
Index: Lock.java
===================================================================
RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/Lock.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Lock.java 29 Mar 2004 22:48:05 -0000 1.8
+++ Lock.java 9 May 2004 12:41:47 -0000 1.9
@@ -18,6 +18,7 @@
import org.apache.lucene.index.IndexWriter;
+import java.io.File;
import java.io.IOException;
/** An interprocess mutex lock.
@@ -35,7 +36,15 @@
*/
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 @@
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);
1.15 +2 -4 jakarta-lucene/src/java/org/apache/lucene/store/RAMDirectory.java
Index: RAMDirectory.java
===================================================================
RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/RAMDirectory.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- RAMDirectory.java 20 Apr 2004 18:27:55 -0000 1.14
+++ RAMDirectory.java 9 May 2004 12:41:47 -0000 1.15
@@ -18,7 +18,6 @@
import java.io.IOException;
import java.io.File;
-import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;
@@ -115,8 +114,7 @@
/** 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 {
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
Re: cvs commit: jakarta-lucene/src/java/org/apache/lucene/store FSDirectory.java Lock.java RAMDirectory.java
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On May 10, 2004, at 5:44 PM, Doug Cutting wrote:
> ehatcher@apache.org wrote:
>> public abstract class Lock {
>> public static long LOCK_POLL_INTERVAL = 1000;
>> + private File lockFile = null;
>> + + Lock(File lockFile) {
>> + this.lockFile = lockFile;
>> + }
>
> I think this should be "String lockName" rather than "File lockFile".
> Locks need not be files. Since this is only used for debugging, a
> string is entirely appropriate.
Done.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
Re: cvs commit: jakarta-lucene/src/java/org/apache/lucene/store FSDirectory.java
Lock.java RAMDirectory.java
Posted by Doug Cutting <cu...@apache.org>.
ehatcher@apache.org wrote:
> public abstract class Lock {
> public static long LOCK_POLL_INTERVAL = 1000;
> + private File lockFile = null;
> +
> + Lock(File lockFile) {
> + this.lockFile = lockFile;
> + }
I think this should be "String lockName" rather than "File lockFile".
Locks need not be files. Since this is only used for debugging, a
string is entirely appropriate.
Doug
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org