diff --git a/CHANGES.txt b/CHANGES.txt index 35fcd967092..d7b5e508d46 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -235,6 +235,10 @@ New features 10. LUCENE-1040: CharArraySet useful for efficiently checking set membership of text specified by char[]. (yonik) + +11. LUCENE-1073: Created SnapshotDeletionPolicy to facilitate taking a + live backup of an index without pausing indexing. (Mike + McCandless) Optimizations diff --git a/src/java/org/apache/lucene/index/DocumentsWriter.java b/src/java/org/apache/lucene/index/DocumentsWriter.java index 5f4a1d9f539..e1fab496345 100644 --- a/src/java/org/apache/lucene/index/DocumentsWriter.java +++ b/src/java/org/apache/lucene/index/DocumentsWriter.java @@ -267,7 +267,7 @@ final class DocumentsWriter { /* Returns list of files in use by this instance, * including any flushed segments. */ - List files() { + synchronized List files() { if (files != null) return files; diff --git a/src/java/org/apache/lucene/index/IndexCommitPoint.java b/src/java/org/apache/lucene/index/IndexCommitPoint.java index 395a09db2cc..57c4623b4f7 100644 --- a/src/java/org/apache/lucene/index/IndexCommitPoint.java +++ b/src/java/org/apache/lucene/index/IndexCommitPoint.java @@ -32,6 +32,9 @@ package org.apache.lucene.index; * index commit point would have a larger N. */ +import java.util.Collection; +import java.io.IOException; + public interface IndexCommitPoint { /** @@ -39,6 +42,11 @@ public interface IndexCommitPoint { * with this commit point. */ public String getSegmentsFileName(); + + /** + * Returns all index files referenced by this commit point. + */ + public Collection getFileNames() throws IOException; /** * Delete this commit point. diff --git a/src/java/org/apache/lucene/index/IndexFileDeleter.java b/src/java/org/apache/lucene/index/IndexFileDeleter.java index 62ed06f52a7..ec66ecd1f19 100644 --- a/src/java/org/apache/lucene/index/IndexFileDeleter.java +++ b/src/java/org/apache/lucene/index/IndexFileDeleter.java @@ -28,6 +28,7 @@ import java.util.Iterator; import java.util.List; import java.util.ArrayList; import java.util.Collections; +import java.util.Collection; /* * This class keeps track of each SegmentInfos instance that @@ -263,9 +264,8 @@ final class IndexFileDeleter { } int size2 = commit.files.size(); for(int j=0;j 0) { + final int numToRead; + if (bytesLeft < buffer.length) + numToRead = (int) bytesLeft; + else + numToRead = buffer.length; + input.readBytes(buffer, 0, numToRead, false); + bytesLeft -= numToRead; + } + // Don't do this in your real backups! This is just + // to force a backup to take a somewhat long time, to + // make sure we are exercising the fact that the + // IndexWriter should not delete this file even when I + // take my time reading it. + try { + Thread.sleep(1); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + } + } finally { + input.close(); + } + } +} +