Search in sources :

Example 21 with SnapshotDeletionPolicy

use of org.apache.lucene.index.SnapshotDeletionPolicy in project lucene-solr by apache.

the class IndexAndTaxonomyRevisionTest method testNoCommit.

@Test
public void testNoCommit() throws Exception {
    Directory indexDir = newDirectory();
    IndexWriterConfig conf = new IndexWriterConfig(null);
    conf.setIndexDeletionPolicy(new SnapshotDeletionPolicy(conf.getIndexDeletionPolicy()));
    IndexWriter indexWriter = new IndexWriter(indexDir, conf);
    Directory taxoDir = newDirectory();
    SnapshotDirectoryTaxonomyWriter taxoWriter = new SnapshotDirectoryTaxonomyWriter(taxoDir);
    // should fail when there are no commits to snapshot
    expectThrows(IllegalStateException.class, () -> {
        new IndexAndTaxonomyRevision(indexWriter, taxoWriter);
    });
    indexWriter.close();
    IOUtils.close(taxoWriter, taxoDir, indexDir);
}
Also used : SnapshotDirectoryTaxonomyWriter(org.apache.lucene.replicator.IndexAndTaxonomyRevision.SnapshotDirectoryTaxonomyWriter) IndexWriter(org.apache.lucene.index.IndexWriter) SnapshotDeletionPolicy(org.apache.lucene.index.SnapshotDeletionPolicy) Directory(org.apache.lucene.store.Directory) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) Test(org.junit.Test)

Example 22 with SnapshotDeletionPolicy

use of org.apache.lucene.index.SnapshotDeletionPolicy in project lucene-solr by apache.

the class IndexReplicationClientTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    publishDir = newMockDirectory();
    handlerDir = newMockDirectory();
    sourceDirFactory = new PerSessionDirectoryFactory(createTempDir("replicationClientTest"));
    replicator = new LocalReplicator();
    callback = new IndexReadyCallback(handlerDir);
    handler = new IndexReplicationHandler(handlerDir, callback);
    client = new ReplicationClient(replicator, handler, sourceDirFactory);
    IndexWriterConfig conf = newIndexWriterConfig(null);
    conf.setIndexDeletionPolicy(new SnapshotDeletionPolicy(conf.getIndexDeletionPolicy()));
    publishWriter = new IndexWriter(publishDir, conf);
}
Also used : IndexWriter(org.apache.lucene.index.IndexWriter) SnapshotDeletionPolicy(org.apache.lucene.index.SnapshotDeletionPolicy) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) Before(org.junit.Before)

Aggregations

SnapshotDeletionPolicy (org.apache.lucene.index.SnapshotDeletionPolicy)22 IndexWriter (org.apache.lucene.index.IndexWriter)17 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)16 Directory (org.apache.lucene.store.Directory)12 Test (org.junit.Test)9 IOException (java.io.IOException)7 Document (org.apache.lucene.document.Document)6 ArrayList (java.util.ArrayList)5 SnapshotDirectoryTaxonomyWriter (org.apache.lucene.replicator.IndexAndTaxonomyRevision.SnapshotDirectoryTaxonomyWriter)5 Before (org.junit.Before)5 List (java.util.List)4 IndexCommit (org.apache.lucene.index.IndexCommit)4 File (java.io.File)3 HashMap (java.util.HashMap)3 KeepOnlyLastCommitDeletionPolicy (org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy)3 InputStream (java.io.InputStream)2 Map (java.util.Map)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)2 TextField (org.apache.lucene.document.TextField)2