lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcos Juarez Lopez <mjua...@gmail.com>
Subject Question on Lucene hot-backup functionality.
Date Wed, 24 Jul 2013 04:34:49 GMT
I'm trying to get Lucene's hot backup functionality to work.  I posted the
question in detail over at StackOverflow, but it seems there's very little
Lucene knowledge over there.

Basically, I think I have setup everything correctly, but I can't get a
valid snapshot when trying to do a backup.  I'm following both the Lucene
book's instructions, as well as the latest Lucene Javadocs, to no avail.
 Original question at the link, but I'll copy the relevant bits below:

http://stackoverflow.com/questions/17753226/lucene-4-3-1-backup-process

This is the code I have up to now:

public Indexer(Directory indexDir, PrintStream printStream) throws IOException {
    IndexWriterConfig config = new
IndexWriterConfig(Version.LUCENE_43, new Analyzer());
    snapshotter = new SnapshotDeletionPolicy(new
KeepOnlyLastCommitDeletionPolicy());
    writerConfig.setIndexDeletionPolicy(snapshotter);
    indexWriter = new IndexWriter(indexDir, writerConfig);
}

And when starting the backup, you can't just do snapshotter.snapshot(). You
now have to specify an arbitrary commitIdentifier id, and use that after
you're done to release the snapshot.

SnapshotDeletionPolicy snapshotter = indexer.getSnapshotter();
String commitIdentifier = generateCommitIdentifier();
try {
    IndexCommit commit = snapshotter.snapshot(commitIdentifier);
    for (String fileName : commit.getFileNames()) {
        backupFile(fileName);
    }
} catch (Exception e) {
    logger.error("Exception", e);
} finally {
    snapshotter.release(commitIdentifier);
    indexer.deleteUnusedFiles();
}

However, this doesn't seem to be working. Regardless of whether there have
been docs indexed or not, and regardless of whether I have committed or
not, my call tosnapshotter.snapshot(commitIdentifier) always throws an
IllegalStateException sayingNo index commit to snapshot. Looking at the
code, the SnapshotDeletionPolicy seems to think there have been no commits,
even though I'm committing to disk every 5 seconds or so. I've verified,
and there are docs being written and committed to indexes all the time, but
snapshotter always thinks there have been zero commits.

Any idea of what I'm doing wrong?

Thanks!

Marcos Juarez

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message