Esempio n. 1
0
  ResourceIterator<File> snapshot(File indexDir, LuceneIndexWriter writer) throws IOException {
    SnapshotDeletionPolicy deletionPolicy =
        (SnapshotDeletionPolicy) writer.getIndexDeletionPolicy();

    try {
      return new LuceneSnapshotIterator(indexDir, deletionPolicy.snapshot(ID), deletionPolicy);
    } catch (IllegalStateException e) {
      if (e.getMessage().equals(NO_INDEX_COMMIT_TO_SNAPSHOT)) {
        return emptyIterator();
      }
      throw e;
    }
  }
 @Override
 public synchronized void onInit(List<? extends IndexCommit> commits) throws IOException {
   // super.onInit() needs to be called first to ensure that initialization
   // behaves as expected. The superclass, SnapshotDeletionPolicy, ensures
   // that any snapshot IDs with empty IndexCommits are released. Since this
   // happens, this class needs to persist these changes.
   super.onInit(commits);
   persistSnapshotInfos(null, null);
 }
Esempio n. 3
0
 @Override
 public void close() {
   try {
     deletionPolicy.release(ID);
   } catch (IOException e) {
     // TODO What to do here?
     throw new RuntimeException("Unable to close lucene index snapshot", e);
   }
 }
 /**
  * Deletes a snapshotted commit by ID. Once this method returns, the snapshot information is
  * committed to the directory.
  *
  * @see SnapshotDeletionPolicy#release(String)
  */
 @Override
 public synchronized void release(String id) throws IOException {
   super.release(id);
   persistSnapshotInfos(null, null);
 }