Skip to content

Commit

Permalink
OAK-6353 - Use Document order traversal for reindexing performed on D…
Browse files Browse the repository at this point in the history
…ocumentNodeStore setups

Reuse the progress reporter

git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/trunk@1818267 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
chetanmeh committed Dec 15, 2017
1 parent 5f33de5 commit e327655
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class IndexingProgressReporter implements NodeTraversalCallback {
private static final String INDEX_MSG = "Incremental indexing";

private final Logger log = LoggerFactory.getLogger(IndexUpdate.class);
private final Stopwatch watch = Stopwatch.createStarted();
private Stopwatch watch = Stopwatch.createStarted();
private final IndexUpdateCallback updateCallback;
private final NodeTraversalCallback traversalCallback;
private final Map<String, IndexUpdateState> indexUpdateStates = new HashMap<>();
Expand Down Expand Up @@ -172,6 +172,12 @@ public void setNodeCountEstimator(NodeCountEstimator nodeCountEstimator) {
this.nodeCountEstimator = nodeCountEstimator;
}

public void reset(){
watch = Stopwatch.createStarted();
traversalCount = 0;
messagePrefix = INDEX_MSG;
}

private String estimatePendingTraversal(double nodesPerSecond) {
if (estimatedCount >= 0) {
if (estimatedCount > traversalCount){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class DocumentStoreIndexer implements Closeable{
private final IndexHelper indexHelper;
private final List<NodeStateIndexerProvider> indexerProviders;
private final IndexerSupport indexerSupport;
private IndexingProgressReporter progressReporter =
private final IndexingProgressReporter progressReporter =
new IndexingProgressReporter(IndexUpdateCallback.NOOP, NodeTraversalCallback.NOOP);
private final Set<String> indexerPaths = new HashSet<>();

Expand Down Expand Up @@ -110,7 +110,10 @@ nodeStore, getMongoDocumentStore())
.build();
closer.register(flatFileStore);

reconfigureReporter(flatFileStore);
progressReporter.reset();
if (flatFileStore.getEntryCount() > 0){
progressReporter.setNodeCountEstimator((String basePath, Set<String> indexPaths) -> flatFileStore.getEntryCount());
}

progressReporter.reindexingTraversalStart("/");

Expand All @@ -132,37 +135,16 @@ private MongoDocumentStore getMongoDocumentStore() {
}

private void configureEstimators() {
configureTraversalRateEstimator(progressReporter);
long nodesCount = getEstimatedDocumentCount();
if (nodesCount > 0) {
progressReporter.setNodeCountEstimator((String basePath, Set<String> indexPaths) -> nodesCount);
log.info("Estimated number of documents in Mongo are {}", nodesCount);
}
}

private void reconfigureReporter(FlatFileStore flatFileStore) {
progressReporter =
new IndexingProgressReporter(IndexUpdateCallback.NOOP, NodeTraversalCallback.NOOP);
configureTraversalRateEstimator(progressReporter);
long entryCount = flatFileStore.getEntryCount();
if (entryCount > 0) {
progressReporter.setNodeCountEstimator((String basePath, Set<String> indexPaths) -> entryCount);
log.info("Estimated number of entries in flat file store are {}", entryCount);
} else {
log.info("Number of entries in flat file store are unknown");
}

for (String indexerPath : indexerPaths){
progressReporter.registerIndex(indexerPath, true, -1);
}
}

private void configureTraversalRateEstimator(IndexingProgressReporter progressReporter) {
StatisticsProvider statsProvider = indexHelper.getStatisticsProvider();
if (statsProvider instanceof MetricStatisticsProvider) {
MetricRegistry registry = ((MetricStatisticsProvider) statsProvider).getRegistry();
progressReporter.setTraversalRateEstimator(new MetricRateEstimator("async", registry));
}
long nodesCount = getEstimatedDocumentCount();
if (nodesCount > 0) {
progressReporter.setNodeCountEstimator((String basePath, Set<String> indexPaths) -> nodesCount);
log.info("Estimated number of documents in Mongo are {}", nodesCount);
}
}

private long getEstimatedDocumentCount(){
Expand Down

0 comments on commit e327655

Please sign in to comment.