Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #38 from gunnarmorling/37
Browse files Browse the repository at this point in the history
#37 Updating to Lucene 5.3
  • Loading branch information
DmitryKey committed Sep 12, 2015
2 parents 3bfb371 + 09714d5 commit 326e37e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<properties>
<jdk.version>1.8</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<lucene.version>5.2.0</lucene.version>
<lucene.version>5.3.0</lucene.version>
<ehcache.version>2.9.0</ehcache.version>
<hadoop.version>1.2.1</hadoop.version>
<log4j.version>1.2.17</log4j.version>
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/org/apache/lucene/index/IndexGate.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ protected Object doBody(String segmentsFile) throws IOException {
int actualVersion = SegmentInfos.VERSION_51;
try {
actualVersion = CodecUtil.checkHeaderNoMagic(in, "segments", SegmentInfos.VERSION_40, Integer.MAX_VALUE);
if (actualVersion > SegmentInfos.VERSION_51) {
if (actualVersion > SegmentInfos.VERSION_53) {
res.capabilities += " (WARNING: newer version of Lucene than this tool)";
System.out.println("WARNING: newer version of Lucene than this tool supports");
}
Expand All @@ -207,19 +207,19 @@ protected Object doBody(String segmentsFile) throws IOException {
switch(actualVersion) {
case SegmentInfos.VERSION_40:
res.genericName = "Lucene 4.0 or later";
res.version = "4.0 or lager";
res.version = "4.0 or later";
break;
case SegmentInfos.VERSION_46:
res.genericName = "Lucene 4.6 or later";
res.version = "4.6 or lager";
res.version = "4.6 or later";
break;
case SegmentInfos.VERSION_48:
res.genericName = "Lucene 4.8 or later";
res.version = "4.8 or lager";
res.version = "4.8 or later";
break;
case SegmentInfos.VERSION_49:
res.genericName = "Lucene 4.9 or later";
res.version = "4.9 or lager";
res.version = "4.9 or later";
break;
case SegmentInfos.VERSION_50:
res.genericName = "Lucene 5.0";
Expand All @@ -229,6 +229,10 @@ protected Object doBody(String segmentsFile) throws IOException {
res.genericName = "Lucene 5.1 or later";
res.version = "5.1 or later";
break;
case SegmentInfos.VERSION_53:
res.genericName = "Lucene 5.3 or later";
res.version = "5.3 or later";
break;
}
} else {
res.genericName = "Lucene 3.x or prior";
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/getopt/luke/Luke.java
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ public void openIndex(String name, boolean force, String dirImpl, boolean ro,
if (IndexWriter.isLocked(d)) {
if (!ro) {
if (force) {
d.makeLock(IndexWriter.WRITE_LOCK_NAME).close();
d.obtainLock(IndexWriter.WRITE_LOCK_NAME).close();
} else {
errorMsg("Index is locked. Try 'Force unlock' when opening.");
d.close();
Expand Down Expand Up @@ -885,7 +885,7 @@ public void openIndex(String name, boolean force, String dirImpl, boolean ro,
if (IndexWriter.isLocked(d1)) {
if (!ro) {
if (force) {
d1.makeLock(IndexWriter.WRITE_LOCK_NAME).close();
d1.obtainLock(IndexWriter.WRITE_LOCK_NAME).close();
} else {
errorMsg("Index is locked. Try 'Force unlock' when opening.");
d1.close();
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/org/getopt/luke/plugins/FsDirectory.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
import net.sf.ehcache.store.MemoryStoreEvictionPolicy;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.*;
import org.apache.log4j.Level;
Expand Down Expand Up @@ -172,9 +173,14 @@ public IndexInput openInput(String name, IOContext ctx) throws IOException {
return new DfsIndexInput(new Path(directory, name), bufSize, reporter);
}

public Lock makeLock(final String name) {
public Lock obtainLock(final String name) {
if (lock == null) {
lock = lockFactory.makeLock(this, name);
try {
lock = lockFactory.obtainLock(this, name);
}
catch(IOException e) {
throw new RuntimeException( e );
}
}
return lock;
}
Expand Down

0 comments on commit 326e37e

Please sign in to comment.