Search in sources :

Example 1 with IndexRootDirectory

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

the class IndexCommandIT method reindexOutOfBand.

@Test
public void reindexOutOfBand() throws Exception {
    createTestData(true);
    fixture.getAsyncIndexUpdate("async").run();
    String checkpoint = fixture.getNodeStore().checkpoint(TimeUnit.HOURS.toMillis(24));
    //Close the repository so as all changes are flushed
    fixture.close();
    IndexCommand command = new IndexCommand();
    File outDir = temporaryFolder.newFolder();
    File storeDir = fixture.getDir();
    String[] args = { "--index-temp-dir=" + temporaryFolder.newFolder().getAbsolutePath(), "--index-out-dir=" + outDir.getAbsolutePath(), "--index-paths=/oak:index/fooIndex", "--checkpoint=" + checkpoint, "--reindex", // -- indicates that options have ended and rest needs to be treated as non option
    "--", storeDir.getAbsolutePath() };
    command.execute(args);
    RepositoryFixture fixture2 = new RepositoryFixture(storeDir);
    NodeStore store2 = fixture2.getNodeStore();
    PropertyState reindexCount = getNode(store2.getRoot(), "/oak:index/fooIndex").getProperty(IndexConstants.REINDEX_COUNT);
    assertEquals(1, reindexCount.getValue(Type.LONG).longValue());
    File indexes = new File(outDir, OutOfBandIndexer.LOCAL_INDEX_ROOT_DIR);
    assertTrue(indexes.exists());
    IndexRootDirectory idxRoot = new IndexRootDirectory(indexes);
    List<LocalIndexDir> idxDirs = idxRoot.getAllLocalIndexes();
    assertEquals(1, idxDirs.size());
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) IndexRootDirectory(org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexRootDirectory) LocalIndexDir(org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexDir) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Aggregations

File (java.io.File)1 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)1 IndexRootDirectory (org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexRootDirectory)1 LocalIndexDir (org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexDir)1 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1