Search in sources :

Example 1 with AsyncIndexInfo

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

the class LuceneIndexInfoProviderTest method info.

@Test
public void info() throws Exception {
    IndexDefinitionBuilder defnBuilder = new IndexDefinitionBuilder();
    NodeBuilder builder = store.getRoot().builder();
    builder.child("oak:index").setChildNode("fooIndex", defnBuilder.build());
    store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    when(asyncService.getInfo("async")).thenReturn(new AsyncIndexInfo("async", 0, 0, false, null));
    IndexInfo info = provider.getInfo("/oak:index/fooIndex");
    assertNotNull(info);
}
Also used : IndexDefinitionBuilder(org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder) IndexInfo(org.apache.jackrabbit.oak.plugins.index.IndexInfo) AsyncIndexInfo(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) AsyncIndexInfo(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo) Test(org.junit.Test)

Example 2 with AsyncIndexInfo

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

the class LuceneIndexInfoProvider method computeAsyncIndexInfo.

private void computeAsyncIndexInfo(NodeState idxState, String indexPath, LuceneIndexInfo info) {
    String asyncName = IndexUtils.getAsyncLaneName(idxState, indexPath);
    if (asyncName == null) {
        log.warn("No 'async' value for index definition at [{}]. Definition {}", indexPath, idxState);
        return;
    }
    AsyncIndexInfo asyncInfo = asyncInfoService.getInfo(asyncName);
    checkNotNull(asyncInfo, "No async info found for name [%s] " + "for index at [%s]", asyncName, indexPath);
    info.indexedUptoTime = asyncInfo.getLastIndexedTo();
    info.asyncName = asyncName;
}
Also used : AsyncIndexInfo(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo)

Example 3 with AsyncIndexInfo

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

the class IndexPrinter method printAsyncIndexInfo.

private void printAsyncIndexInfo(PrintWriter pw) {
    List<String> asyncLanes = ImmutableList.copyOf(asyncIndexInfoService.getAsyncLanes());
    String title = "Async Indexers State";
    printTitle(pw, title);
    pw.printf("Number of async indexer lanes : %d%n", asyncLanes.size());
    pw.println();
    for (String lane : asyncLanes) {
        pw.println(lane);
        AsyncIndexInfo info = asyncIndexInfoService.getInfo(lane);
        if (info != null) {
            pw.printf("    Last indexed to      : %s%n", formatTime(info.getLastIndexedTo()));
            IndexStatsMBean stats = info.getStatsMBean();
            if (stats != null) {
                pw.printf("    Status              : %s%n", stats.getStatus());
                pw.printf("    Failing             : %s%n", stats.isFailing());
                pw.printf("    Paused              : %s%n", stats.isPaused());
                if (stats.isFailing()) {
                    pw.printf("    Failing since       : %s%n", stats.getFailingSince());
                    pw.printf("    Latest error        : %s%n", stats.getLatestError());
                }
            }
            pw.println();
        }
    }
}
Also used : IndexStatsMBean(org.apache.jackrabbit.oak.api.jmx.IndexStatsMBean) AsyncIndexInfo(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo)

Example 4 with AsyncIndexInfo

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

the class IndexPrinterTest method asyncIndexInfo.

@Test
public void asyncIndexInfo() throws Exception {
    when(indexInfo.getAllIndexInfo()).thenReturn(emptyList());
    when(asyncInfo.getAsyncLanes()).thenReturn(asList("foo-async", "bar-async"));
    when(asyncInfo.getInfo("foo-async")).thenReturn(new AsyncIndexInfo("foo-async", 0, 0, false, null));
    String output = getPrintOutput();
    assertThat(output, containsString("foo-async"));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) AsyncIndexInfo(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo) Test(org.junit.Test)

Aggregations

AsyncIndexInfo (org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo)4 Test (org.junit.Test)2 IndexStatsMBean (org.apache.jackrabbit.oak.api.jmx.IndexStatsMBean)1 IndexInfo (org.apache.jackrabbit.oak.plugins.index.IndexInfo)1 IndexDefinitionBuilder (org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1