- Fixed a bug with usage of IndexWriter.*_LOCK_NAME constants.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150105 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Otis Gospodnetic 2003-10-17 10:49:42 +00:00
parent 5836af2f63
commit 3fd7ec2679
3 changed files with 10 additions and 10 deletions

View File

@ -108,7 +108,7 @@ public abstract class IndexReader {
public static IndexReader open(final Directory directory) throws IOException{
synchronized (directory) { // in- & inter-process sync
return (IndexReader)new Lock.With(
directory.makeLock("IndexWriter.COMMIT_LOCK_NAME"),
directory.makeLock(IndexWriter.COMMIT_LOCK_NAME),
IndexWriter.COMMIT_LOCK_TIMEOUT) {
public Object doBody() throws IOException {
IndexReader result = null;
@ -269,7 +269,7 @@ public abstract class IndexReader {
*/
public final synchronized void delete(int docNum) throws IOException {
if (writeLock == null) {
Lock writeLock = directory.makeLock("IndexWriter.WRITE_LOCK_NAME");
Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
if (!writeLock.obtain(IndexWriter.WRITE_LOCK_TIMEOUT)) // obtain write lock
throw new IOException("Index locked for write: " + writeLock);
this.writeLock = writeLock;
@ -360,8 +360,8 @@ public abstract class IndexReader {
*/
public static boolean isLocked(Directory directory) throws IOException {
return
directory.makeLock("IndexWriter.WRITE_LOCK_NAME").isLocked() ||
directory.makeLock("IndexWriter.COMMIT_LOCK_NAME").isLocked();
directory.makeLock(IndexWriter.WRITE_LOCK_NAME).isLocked() ||
directory.makeLock(IndexWriter.COMMIT_LOCK_NAME).isLocked();
}
@ -383,7 +383,7 @@ public abstract class IndexReader {
* currently accessing this index.
*/
public static void unlock(Directory directory) throws IOException {
directory.makeLock("IndexWriter.WRITE_LOCK_NAME").release();
directory.makeLock("IndexWriter.COMMIT_LOCK_NAME").release();
directory.makeLock(IndexWriter.WRITE_LOCK_NAME).release();
directory.makeLock(IndexWriter.COMMIT_LOCK_NAME).release();
}
}

View File

@ -169,13 +169,13 @@ public class IndexWriter {
directory = d;
analyzer = a;
Lock writeLock = directory.makeLock("IndexWriter.WRITE_LOCK_NAME");
Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
if (!writeLock.obtain(WRITE_LOCK_TIMEOUT)) // obtain write lock
throw new IOException("Index locked for write: " + writeLock);
this.writeLock = writeLock; // save it
synchronized (directory) { // in- & inter-process sync
new Lock.With(directory.makeLock("COMMIT_LOCK_NAME"), COMMIT_LOCK_TIMEOUT) {
new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), COMMIT_LOCK_TIMEOUT) {
public Object doBody() throws IOException {
if (create)
segmentInfos.write(directory);
@ -398,7 +398,7 @@ public class IndexWriter {
directory));
synchronized (directory) { // in- & inter-process sync
new Lock.With(directory.makeLock("COMMIT_LOCK_NAME"), COMMIT_LOCK_TIMEOUT) {
new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), COMMIT_LOCK_TIMEOUT) {
public Object doBody() throws IOException {
segmentInfos.write(directory); // commit before deleting
deleteSegments(segmentsToDelete); // delete now-unused segments

View File

@ -137,7 +137,7 @@ final class SegmentReader extends IndexReader {
final synchronized void doClose() throws IOException {
if (deletedDocsDirty) {
synchronized (directory) { // in- & inter-process sync
new Lock.With(directory.makeLock("IndexWriter.COMMIT_LOCK_NAME"),
new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME),
IndexWriter.COMMIT_LOCK_TIMEOUT) {
public Object doBody() throws IOException {
deletedDocs.write(directory, segment + ".tmp");