use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result in project jackrabbit-oak by apache.
the class IndexConsistencyCheckerTest method emptyIndex.
@Test
public void emptyIndex() throws Exception {
IndexConsistencyChecker checker = new IndexConsistencyChecker(EMPTY_NODE, "/foo", temporaryFolder.getRoot());
Result result = checker.check(Level.BLOBS_ONLY);
assertFalse(result.clean);
assertTrue(result.typeMismatch);
assertEquals(result.indexPath, "/foo");
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result in project jackrabbit-oak by apache.
the class IndexConsistencyCheckerTest method blobsWithSizeMismatch.
@Test
public void blobsWithSizeMismatch() throws Exception {
FailingBlob failingBlob = new FailingBlob("foo", true);
idx.child(":index").setProperty("foo", failingBlob);
NodeBuilder builder = EMPTY_NODE.builder();
builder.setChildNode("a", idx.getNodeState());
IndexConsistencyChecker checker = new IndexConsistencyChecker(builder.getNodeState(), "/a", temporaryFolder.getRoot());
Result result = checker.check(Level.BLOBS_ONLY);
assertFalse(result.clean);
assertFalse(result.missingBlobs);
assertTrue(result.blobSizeMismatch);
assertEquals(1, result.invalidBlobIds.size());
dumpResult(result);
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result in project jackrabbit-oak by apache.
the class LuceneIndexMBeanImpl method checkAndReportConsistencyOfAllIndexes.
@Override
public String[] checkAndReportConsistencyOfAllIndexes(boolean fullCheck) throws IOException {
Stopwatch watch = Stopwatch.createStarted();
List<String> results = new ArrayList<>();
NodeState root = nodeStore.getRoot();
for (String indexPath : indexPathService.getIndexPaths()) {
NodeState idxState = NodeStateUtils.getNode(root, indexPath);
if (LuceneIndexConstants.TYPE_LUCENE.equals(idxState.getString(IndexConstants.TYPE_PROPERTY_NAME))) {
Result result = getConsistencyCheckResult(indexPath, fullCheck);
String msg = "OK";
if (!result.clean) {
msg = "NOT OK";
}
results.add(String.format("%s : %s", indexPath, msg));
}
}
log.info("Checked index consistency in {}. Check result {}", watch, results);
return Iterables.toArray(results, String.class);
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result in project jackrabbit-oak by apache.
the class IndexConsistencyCheckerTest method badFile.
@Test
public void badFile() throws Exception {
IndexDefinition defn = IndexDefinition.newBuilder(rootState, idx.getNodeState(), "/fooIndex").build();
Directory dir = new OakDirectory(idx, ":data", defn, false);
createIndex(dir, 10);
NodeBuilder builder = rootState.builder();
NodeBuilder file = idx.getChildNode(":data").getChildNode("_0.cfe");
List<Blob> blobs = Lists.newArrayList(file.getProperty("jcr:data").getValue(Type.BINARIES));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copy(blobs.get(0).getNewStream(), baos);
byte[] bytes = baos.toByteArray();
// Flip the 3rd bit to make it corrupt
bytes[0] = (byte) (bytes[0] ^ (1 << 3));
blobs.set(0, new ArrayBasedBlob(bytes));
file.setProperty("jcr:data", blobs, Type.BINARIES);
builder.setChildNode("fooIndex", idx.getNodeState());
NodeState indexState = builder.getNodeState();
IndexConsistencyChecker checker = new IndexConsistencyChecker(indexState, "/fooIndex", temporaryFolder.getRoot());
Result result = checker.check(Level.FULL);
assertFalse(result.clean);
assertEquals(0, result.dirStatus.get(0).missingFiles.size());
assertFalse(result.dirStatus.get(0).status.clean);
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result in project jackrabbit-oak by apache.
the class IndexConsistencyCheckerTest method missingFile.
@Test
public void missingFile() throws Exception {
IndexDefinition defn = IndexDefinition.newBuilder(rootState, idx.getNodeState(), "/fooIndex").build();
Directory dir = new OakDirectory(idx, ":data", defn, false);
createIndex(dir, 10);
NodeBuilder builder = rootState.builder();
idx.getChildNode(":data").getChildNode("segments.gen").remove();
builder.setChildNode("fooIndex", idx.getNodeState());
NodeState indexState = builder.getNodeState();
IndexConsistencyChecker checker = new IndexConsistencyChecker(indexState, "/fooIndex", temporaryFolder.getRoot());
Result result = checker.check(Level.FULL);
assertFalse(result.clean);
assertEquals(1, result.dirStatus.get(0).missingFiles.size());
assertNull(result.dirStatus.get(0).status);
dumpResult(result);
}
Aggregations