mirror of https://github.com/apache/lucene.git
- 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:
parent
5836af2f63
commit
3fd7ec2679
|
@ -108,7 +108,7 @@ public abstract class IndexReader {
|
||||||
public static IndexReader open(final Directory directory) throws IOException{
|
public static IndexReader open(final Directory directory) throws IOException{
|
||||||
synchronized (directory) { // in- & inter-process sync
|
synchronized (directory) { // in- & inter-process sync
|
||||||
return (IndexReader)new Lock.With(
|
return (IndexReader)new Lock.With(
|
||||||
directory.makeLock("IndexWriter.COMMIT_LOCK_NAME"),
|
directory.makeLock(IndexWriter.COMMIT_LOCK_NAME),
|
||||||
IndexWriter.COMMIT_LOCK_TIMEOUT) {
|
IndexWriter.COMMIT_LOCK_TIMEOUT) {
|
||||||
public Object doBody() throws IOException {
|
public Object doBody() throws IOException {
|
||||||
IndexReader result = null;
|
IndexReader result = null;
|
||||||
|
@ -269,7 +269,7 @@ public abstract class IndexReader {
|
||||||
*/
|
*/
|
||||||
public final synchronized void delete(int docNum) throws IOException {
|
public final synchronized void delete(int docNum) throws IOException {
|
||||||
if (writeLock == null) {
|
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
|
if (!writeLock.obtain(IndexWriter.WRITE_LOCK_TIMEOUT)) // obtain write lock
|
||||||
throw new IOException("Index locked for write: " + writeLock);
|
throw new IOException("Index locked for write: " + writeLock);
|
||||||
this.writeLock = writeLock;
|
this.writeLock = writeLock;
|
||||||
|
@ -360,8 +360,8 @@ public abstract class IndexReader {
|
||||||
*/
|
*/
|
||||||
public static boolean isLocked(Directory directory) throws IOException {
|
public static boolean isLocked(Directory directory) throws IOException {
|
||||||
return
|
return
|
||||||
directory.makeLock("IndexWriter.WRITE_LOCK_NAME").isLocked() ||
|
directory.makeLock(IndexWriter.WRITE_LOCK_NAME).isLocked() ||
|
||||||
directory.makeLock("IndexWriter.COMMIT_LOCK_NAME").isLocked();
|
directory.makeLock(IndexWriter.COMMIT_LOCK_NAME).isLocked();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ public abstract class IndexReader {
|
||||||
* currently accessing this index.
|
* currently accessing this index.
|
||||||
*/
|
*/
|
||||||
public static void unlock(Directory directory) throws IOException {
|
public static void unlock(Directory directory) throws IOException {
|
||||||
directory.makeLock("IndexWriter.WRITE_LOCK_NAME").release();
|
directory.makeLock(IndexWriter.WRITE_LOCK_NAME).release();
|
||||||
directory.makeLock("IndexWriter.COMMIT_LOCK_NAME").release();
|
directory.makeLock(IndexWriter.COMMIT_LOCK_NAME).release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,13 +169,13 @@ public class IndexWriter {
|
||||||
directory = d;
|
directory = d;
|
||||||
analyzer = a;
|
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
|
if (!writeLock.obtain(WRITE_LOCK_TIMEOUT)) // obtain write lock
|
||||||
throw new IOException("Index locked for write: " + writeLock);
|
throw new IOException("Index locked for write: " + writeLock);
|
||||||
this.writeLock = writeLock; // save it
|
this.writeLock = writeLock; // save it
|
||||||
|
|
||||||
synchronized (directory) { // in- & inter-process sync
|
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 {
|
public Object doBody() throws IOException {
|
||||||
if (create)
|
if (create)
|
||||||
segmentInfos.write(directory);
|
segmentInfos.write(directory);
|
||||||
|
@ -398,7 +398,7 @@ public class IndexWriter {
|
||||||
directory));
|
directory));
|
||||||
|
|
||||||
synchronized (directory) { // in- & inter-process sync
|
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 {
|
public Object doBody() throws IOException {
|
||||||
segmentInfos.write(directory); // commit before deleting
|
segmentInfos.write(directory); // commit before deleting
|
||||||
deleteSegments(segmentsToDelete); // delete now-unused segments
|
deleteSegments(segmentsToDelete); // delete now-unused segments
|
||||||
|
|
|
@ -137,7 +137,7 @@ final class SegmentReader extends IndexReader {
|
||||||
final synchronized void doClose() throws IOException {
|
final synchronized void doClose() throws IOException {
|
||||||
if (deletedDocsDirty) {
|
if (deletedDocsDirty) {
|
||||||
synchronized (directory) { // in- & inter-process sync
|
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) {
|
IndexWriter.COMMIT_LOCK_TIMEOUT) {
|
||||||
public Object doBody() throws IOException {
|
public Object doBody() throws IOException {
|
||||||
deletedDocs.write(directory, segment + ".tmp");
|
deletedDocs.write(directory, segment + ".tmp");
|
||||||
|
|
Loading…
Reference in New Issue