use of org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory in project jackrabbit-oak by apache.
the class MultiplexingIndexWriterTest method numDocs.
private int numDocs(Mount m) throws IOException {
String indexDirName = indexDirName(m);
Directory d = new OakDirectory(builder, indexDirName, defn, true);
IndexReader r = DirectoryReader.open(d);
return r.numDocs();
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory in project jackrabbit-oak by apache.
the class IndexConsistencyCheckerTest method validIndexTest.
@Test
public void validIndexTest() throws Exception {
IndexDefinition defn = IndexDefinition.newBuilder(rootState, idx.getNodeState(), "/fooIndex").build();
Directory dir = new OakDirectory(idx, ":data", defn, false);
createIndex(dir, 10);
dir = new OakDirectory(idx, ":data2" + MultiplexersLucene.INDEX_DIR_SUFFIX, defn, false);
createIndex(dir, 10);
NodeBuilder builder = rootState.builder();
builder.setChildNode("fooIndex", idx.getNodeState());
NodeState indexState = builder.getNodeState();
IndexConsistencyChecker checker = new IndexConsistencyChecker(indexState, "/fooIndex", temporaryFolder.getRoot());
Result result = checker.check(Level.BLOBS_ONLY);
assertTrue(result.clean);
checker = new IndexConsistencyChecker(indexState, "/fooIndex", temporaryFolder.getRoot());
result = checker.check(Level.FULL);
assertTrue(result.clean);
assertEquals(2, result.dirStatus.size());
dumpResult(result);
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory in project jackrabbit-oak by apache.
the class IndexConsistencyChecker method checkIndexDirectory.
private void checkIndexDirectory(DirectoryStatus dirStatus, NodeState idx, IndexDefinition defn, File workDir, String dirName, Closer closer) throws IOException {
File idxDir = createWorkDir(workDir, dirName);
Directory sourceDir = new OakDirectory(new ReadOnlyBuilder(idx), dirName, defn, true);
Directory targetDir = FSDirectory.open(idxDir);
closer.register(sourceDir);
closer.register(targetDir);
boolean clean = true;
for (String file : sourceDir.listAll()) {
log.debug("[{}][{}] Checking {}", indexPath, dirName, file);
try {
sourceDir.copy(targetDir, file, file, IOContext.DEFAULT);
} catch (FileNotFoundException ignore) {
dirStatus.missingFiles.add(file);
clean = false;
log.warn("[{}][{}] File {} missing", indexPath, dirName, file);
}
if (targetDir.fileLength(file) != sourceDir.fileLength(file)) {
FileSizeStatus fileStatus = new FileSizeStatus(file, targetDir.fileLength(file), sourceDir.fileLength(file));
dirStatus.filesWithSizeMismatch.add(fileStatus);
clean = false;
log.warn("[{}][{}] File size mismatch {}", indexPath, dirName, fileStatus);
} else {
dirStatus.size += sourceDir.fileLength(file);
log.debug("[{}][{}] File {} is consistent", indexPath, dirName, file);
}
}
if (clean) {
log.debug("[{}][{}] Directory content found to be consistent. Proceeding to IndexCheck", indexPath, dirName);
CheckIndex ci = new CheckIndex(targetDir);
if (printStream != null) {
ci.setInfoStream(printStream, verbose);
} else if (log.isDebugEnabled()) {
ci.setInfoStream(new LoggingPrintStream(log), log.isTraceEnabled());
}
dirStatus.status = ci.checkIndex();
dirStatus.clean = dirStatus.status.clean;
log.debug("[{}][{}] IndexCheck was successful. Proceeding to open DirectoryReader", indexPath, dirName);
}
if (dirStatus.clean) {
DirectoryReader dirReader = DirectoryReader.open(targetDir);
dirStatus.numDocs = dirReader.numDocs();
log.debug("[{}][{}] DirectoryReader can be opened", indexPath, dirName);
closer.register(dirReader);
}
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory in project jackrabbit-oak by apache.
the class BufferedOakDirectory method reopenBuffered.
private void reopenBuffered() {
// squeeze out child nodes marked as non existing
// those are files that were created and later deleted again
bufferedBuilder = squeeze(bufferedBuilder.getNodeState()).builder();
buffered = new OakDirectory(bufferedBuilder, dataNodeName, definition, false, blobFactory, blobDeletionCallback);
}
Aggregations