Search in sources :

Example 6 with Result

use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result in project jackrabbit-oak by apache.

the class IndexConsistencyCheckerTest method blobsWithError.

@Test
public void blobsWithError() throws Exception {
    FailingBlob failingBlob = new FailingBlob("foo");
    idx.setProperty("foo", failingBlob);
    idx.child(":index").setProperty("foo", failingBlob);
    idx.child("b").setProperty("foo", Lists.newArrayList(failingBlob, failingBlob), Type.BINARIES);
    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);
    assertTrue(result.missingBlobs);
    assertFalse(result.blobSizeMismatch);
    assertEquals(4, result.missingBlobIds.size());
    dumpResult(result);
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Result(org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result) Test(org.junit.Test)

Example 7 with Result

use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result in project jackrabbit-oak by apache.

the class LuceneIndexMBeanImpl method checkConsistencyOfAllIndexes.

@Override
public boolean checkConsistencyOfAllIndexes(boolean fullCheck) throws IOException {
    Stopwatch watch = Stopwatch.createStarted();
    NodeState root = nodeStore.getRoot();
    boolean clean = true;
    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);
            if (!result.clean) {
                clean = false;
                break;
            }
        }
    }
    log.info("Checked index consistency in {}. Check result {}", watch, clean);
    return clean;
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Stopwatch(com.google.common.base.Stopwatch) Result(org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result)

Example 8 with Result

use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result 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);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) IndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Directory(org.apache.lucene.store.Directory) Result(org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result) Test(org.junit.Test)

Aggregations

Result (org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker.Result)8 Test (org.junit.Test)6 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)5 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)5 IndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition)3 Directory (org.apache.lucene.store.Directory)3 Stopwatch (com.google.common.base.Stopwatch)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ArrayList (java.util.ArrayList)1 Blob (org.apache.jackrabbit.oak.api.Blob)1 ArrayBasedBlob (org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob)1