use of org.apache.jackrabbit.oak.index.indexer.document.DocumentStoreIndexer in project jackrabbit-oak by apache.
the class IndexCommand method reindex.
private File reindex(IndexOptions idxOpts, IndexHelper indexHelper, String checkpoint) throws IOException, CommitFailedException {
checkNotNull(checkpoint, "Checkpoint value is required for reindexing done in read only mode");
Stopwatch w = Stopwatch.createStarted();
IndexerSupport indexerSupport = createIndexerSupport(indexHelper, checkpoint);
log.info("Proceeding to index {} upto checkpoint {} {}", indexHelper.getIndexPaths(), checkpoint, indexerSupport.getCheckpointInfo());
if (opts.getCommonOpts().isMongo() && idxOpts.isDocTraversalMode()) {
log.info("Using Document order traversal to perform reindexing");
try (DocumentStoreIndexer indexer = new DocumentStoreIndexer(indexHelper, indexerSupport)) {
indexer.reindex();
}
} else {
try (OutOfBandIndexer indexer = new OutOfBandIndexer(indexHelper, indexerSupport)) {
indexer.reindex();
}
}
indexerSupport.writeMetaInfo(checkpoint);
File destDir = indexerSupport.copyIndexFilesToOutput();
log.info("Indexing completed for indexes {} in {} ({} ms) and index files are copied to {}", indexHelper.getIndexPaths(), w, w.elapsed(TimeUnit.MILLISECONDS), IndexCommand.getPath(destDir));
return destDir;
}
use of org.apache.jackrabbit.oak.index.indexer.document.DocumentStoreIndexer in project jackrabbit-oak by apache.
the class IndexCommand method reindex.
private File reindex(IndexOptions idxOpts, ExtendedIndexHelper extendedIndexHelper, String checkpoint) throws IOException, CommitFailedException {
checkNotNull(checkpoint, "Checkpoint value is required for reindexing done in read only mode");
Stopwatch w = Stopwatch.createStarted();
IndexerSupport indexerSupport = createIndexerSupport(extendedIndexHelper, checkpoint);
log.info("Proceeding to index {} upto checkpoint {} {}", extendedIndexHelper.getIndexPaths(), checkpoint, indexerSupport.getCheckpointInfo());
if (opts.getCommonOpts().isMongo() && idxOpts.isDocTraversalMode()) {
log.info("Using Document order traversal to perform reindexing");
try (DocumentStoreIndexer indexer = new DocumentStoreIndexer(extendedIndexHelper, indexerSupport)) {
if (idxOpts.buildFlatFileStoreSeparately()) {
FlatFileStore ffs = indexer.buildFlatFileStore();
String pathToFFS = ffs.getFlatFileStorePath();
System.setProperty(OAK_INDEXER_SORTED_FILE_PATH, pathToFFS);
}
indexer.reindex();
}
} else {
try (OutOfBandIndexer indexer = new OutOfBandIndexer(extendedIndexHelper, indexerSupport)) {
indexer.reindex();
}
}
indexerSupport.writeMetaInfo(checkpoint);
File destDir = indexerSupport.copyIndexFilesToOutput();
log.info("Indexing completed for indexes {} in {} ({} ms) and index files are copied to {}", extendedIndexHelper.getIndexPaths(), w, w.elapsed(TimeUnit.MILLISECONDS), IndexCommand.getPath(destDir));
return destDir;
}
use of org.apache.jackrabbit.oak.index.indexer.document.DocumentStoreIndexer in project jackrabbit-oak by apache.
the class DocumentStoreIndexerIT method bundling.
@Test
public void bundling() throws Exception {
MongoConnection c = getConnection();
DocumentNodeStoreBuilder<?> docBuilder = builderProvider.newBuilder().setMongoDB(c.getMongoClient(), c.getDBName());
DocumentNodeStore store = docBuilder.build();
Whiteboard wb = new DefaultWhiteboard();
MongoDocumentStore ds = (MongoDocumentStore) docBuilder.getDocumentStore();
Registration r1 = wb.register(MongoDocumentStore.class, ds, emptyMap());
wb.register(StatisticsProvider.class, StatisticsProvider.NOOP, emptyMap());
configureIndex(store);
configureBundling(store);
NodeBuilder builder = store.getRoot().builder();
NodeBuilder appNB = newNode("app:Asset");
createChild(appNB, "jcr:content", // not bundled
"jcr:content/comments", "jcr:content/metadata", // not bundled
"jcr:content/metadata/xmp", // includes all
"jcr:content/renditions", "jcr:content/renditions/original", "jcr:content/renditions/original/jcr:content");
builder.child("test").setChildNode("book.jpg", appNB.getNodeState());
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
// Check that bundling is working
assertNull(getNodeDocument(ds, "/test/book.jpg/jcr:content"));
assertNotNull(getNodeDocument(ds, "/test/book.jpg"));
String checkpoint = store.checkpoint(100000);
// Shut down this store and restart in readOnly mode
store.dispose();
r1.unregister();
MongoConnection c2 = connectionFactory.getConnection();
DocumentNodeStoreBuilder<?> docBuilderRO = builderProvider.newBuilder().setReadOnlyMode().setMongoDB(c2.getMongoClient(), c2.getDBName());
ds = (MongoDocumentStore) docBuilderRO.getDocumentStore();
store = docBuilderRO.build();
wb.register(MongoDocumentStore.class, ds, emptyMap());
ExtendedIndexHelper helper = new ExtendedIndexHelper(store, store.getBlobStore(), wb, temporaryFolder.newFolder(), temporaryFolder.newFolder(), asList(TEST_INDEX_PATH));
IndexerSupport support = new IndexerSupport(helper, checkpoint);
CollectingIndexer testIndexer = new CollectingIndexer(p -> p.startsWith("/test"));
DocumentStoreIndexer index = new DocumentStoreIndexer(helper, support) {
@Override
protected CompositeIndexer prepareIndexers(NodeStore nodeStore, NodeBuilder builder, IndexingProgressReporter progressReporter) {
return new CompositeIndexer(asList(testIndexer));
}
};
index.reindex();
assertThat(testIndexer.paths, containsInAnyOrder("/test", "/test/book.jpg", "/test/book.jpg/jcr:content", "/test/book.jpg/jcr:content/comments", "/test/book.jpg/jcr:content/metadata", "/test/book.jpg/jcr:content/metadata/xmp", "/test/book.jpg/jcr:content/renditions", "/test/book.jpg/jcr:content/renditions/original", "/test/book.jpg/jcr:content/renditions/original/jcr:content"));
store.dispose();
}
Aggregations