Search in sources :

Example 16 with IndexDefinition

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition in project jackrabbit-oak by apache.

the class IndexConsistencyChecker method checkIndex.

private void checkIndex(Result result, Closer closer) throws IOException {
    NodeState idx = NodeStateUtils.getNode(rootState, indexPath);
    IndexDefinition defn = IndexDefinition.newBuilder(rootState, idx, indexPath).build();
    workDir = createWorkDir(workDirRoot, PathUtils.getName(indexPath));
    for (String dirName : idx.getChildNodeNames()) {
        //TODO Check for SuggestionDirectory Pending
        if (NodeStateUtils.isHidden(dirName) && MultiplexersLucene.isIndexDirName(dirName)) {
            DirectoryStatus dirStatus = new DirectoryStatus(dirName);
            result.dirStatus.add(dirStatus);
            log.debug("[{}] Checking directory {}", indexPath, dirName);
            try {
                checkIndexDirectory(dirStatus, idx, defn, workDir, dirName, closer);
            } catch (IOException e) {
                dirStatus.clean = false;
                log.warn("[{}][{}] Error occurred while performing directory check", indexPath, dirName, e);
            }
            if (!dirStatus.clean) {
                result.clean = false;
            }
        }
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) IndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition) IOException(java.io.IOException)

Example 17 with IndexDefinition

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition in project jackrabbit-oak by apache.

the class NRTIndexFactoryTest method indexCreationNRT.

@Test
public void indexCreationNRT() throws Exception {
    IndexDefinition idxDefn = getIndexDefinition("/foo", IndexingMode.SYNC);
    NRTIndex idx1 = indexFactory.createIndex(idxDefn);
    assertNotNull(idx1);
    assertEquals(1, indexFactory.getIndexes("/foo").size());
}
Also used : IndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition) Test(org.junit.Test)

Example 18 with IndexDefinition

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition in project jackrabbit-oak by apache.

the class NRTIndexFactoryTest method closeIndexOnClose.

@Test
public void closeIndexOnClose() throws Exception {
    IndexDefinition idxDefn = getNRTIndexDefinition("/foo");
    NRTIndex idx1 = indexFactory.createIndex(idxDefn);
    NRTIndex idx2 = indexFactory.createIndex(idxDefn);
    assertEquals(2, indexFactory.getIndexes("/foo").size());
    indexFactory.close();
    assertEquals(0, indexFactory.getIndexes("/foo").size());
    assertTrue(idx1.isClosed());
    assertTrue(idx2.isClosed());
}
Also used : IndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition) Test(org.junit.Test)

Example 19 with IndexDefinition

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition in project jackrabbit-oak by apache.

the class NRTIndexTest method writerCreation.

@Test
public void writerCreation() throws Exception {
    IndexDefinition idxDefn = getSyncIndexDefinition("/foo");
    NRTIndex idx = indexFactory.createIndex(idxDefn);
    LuceneIndexWriter writer = idx.getWriter();
    assertNotNull(writer);
    assertNotNull(idx.getIndexDir());
    List<LuceneIndexReader> readers = idx.getReaders();
    assertEquals(1, readers.size());
    LuceneIndexWriter writer2 = idx.getWriter();
    assertSame(writer, writer2);
}
Also used : LuceneIndexReader(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReader) IndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition) LuceneIndexWriter(org.apache.jackrabbit.oak.plugins.index.lucene.writer.LuceneIndexWriter) Test(org.junit.Test)

Example 20 with IndexDefinition

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition in project jackrabbit-oak by apache.

the class NRTIndexTest method previousIndexInitialized.

@Test
public void previousIndexInitialized() throws Exception {
    IndexDefinition idxDefn = getSyncIndexDefinition("/foo");
    NRTIndex idx1 = indexFactory.createIndex(idxDefn);
    LuceneIndexWriter w1 = idx1.getWriter();
    Document d1 = new Document();
    d1.add(newPathField("/a/b"));
    w1.updateDocument("/a/b", d1);
    NRTIndex idx2 = indexFactory.createIndex(idxDefn);
    assertEquals(1, idx2.getReaders().size());
    LuceneIndexWriter w2 = idx2.getWriter();
    assertEquals(2, idx2.getReaders().size());
    assertNotEquals(idx1.getIndexDir(), idx2.getIndexDir());
}
Also used : IndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition) LuceneIndexWriter(org.apache.jackrabbit.oak.plugins.index.lucene.writer.LuceneIndexWriter) Document(org.apache.lucene.document.Document) Test(org.junit.Test)

Aggregations

IndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition)28 Test (org.junit.Test)24 LuceneIndexWriter (org.apache.jackrabbit.oak.plugins.index.lucene.writer.LuceneIndexWriter)7 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)7 Document (org.apache.lucene.document.Document)7 Directory (org.apache.lucene.store.Directory)7 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)5 File (java.io.File)4 OakDirectory (org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory)4 Result (org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result)3 LuceneIndexReader (org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReader)3 DefaultDirectoryFactory (org.apache.jackrabbit.oak.plugins.index.lucene.directory.DefaultDirectoryFactory)2 DefaultIndexWriterFactory (org.apache.jackrabbit.oak.plugins.index.lucene.writer.DefaultIndexWriterFactory)2 LuceneIndexWriterFactory (org.apache.jackrabbit.oak.plugins.index.lucene.writer.LuceneIndexWriterFactory)2 StringField (org.apache.lucene.document.StringField)2 FSDirectory (org.apache.lucene.store.FSDirectory)2 Closer (com.google.common.io.Closer)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 Blob (org.apache.jackrabbit.oak.api.Blob)1