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;
}
}
}
}
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());
}
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());
}
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);
}
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());
}
Aggregations