Author: chetanm
Date: Wed Nov 23 06:44:39 2016
New Revision: 1770923

URL: http://svn.apache.org/viewvc?rev=1770923&view=rev
Log:
OAK-5140 - Collect stats around number of nodes traversed by AsyncIndexer

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java?rev=1770923&r1=1770922&r2=1770923&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
 Wed Nov 23 06:44:39 2016
@@ -674,12 +674,13 @@ public class AsyncIndexUpdate implements
         // sure to not delete the reference checkpoint, as the other index
         // task will take care of it
         taskSplitter.maybeSplit(beforeCheckpoint, callback.lease);
+        IndexUpdate indexUpdate;
         try {
             NodeBuilder builder = store.getRoot().builder();
 
             markFailingIndexesAsCorrupt(builder);
 
-            IndexUpdate indexUpdate =
+            indexUpdate =
                     new IndexUpdate(provider, name, after, builder, callback, 
CommitInfo.EMPTY, corruptIndexHandler)
                     .withMissingProviderStrategy(missingStrategy);
             CommitFailedException exception =
@@ -732,12 +733,12 @@ public class AsyncIndexUpdate implements
         }
 
         if (!progressLogged) {
-            String msg = "[{}] AsyncIndex update run completed in {}. Indexed 
{} nodes";
+            String msg = "[{}] AsyncIndex update run completed in {}. Indexed 
{} nodes, {}";
             //Log at info level if time taken is more than 5 min
             if (watch.elapsed(TimeUnit.MINUTES) >= 5) {
-                log.info(msg, name, watch, indexStats.getUpdates());
+                log.info(msg, name, watch, indexStats.getUpdates(), 
indexUpdate.getIndexingStats());
             } else {
-                log.debug(msg, name, watch, indexStats.getUpdates());
+                log.debug(msg, name, watch, indexStats.getUpdates(), 
indexUpdate.getIndexingStats());
             }
         }
 

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java?rev=1770923&r1=1770922&r2=1770923&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
 Wed Nov 23 06:44:39 2016
@@ -191,6 +191,10 @@ public class IndexUpdate implements Edit
         return rootState.getUpdatedIndexPaths();
     }
 
+    public String getIndexingStats(){
+        return rootState.getIndexingStats();
+    }
+
     private boolean shouldReindex(NodeBuilder definition, NodeState before,
             String name) {
         PropertyState ps = definition.getProperty(REINDEX_PROPERTY_NAME);
@@ -318,6 +322,7 @@ public class IndexUpdate implements Edit
     @Override
     public void propertyAdded(PropertyState after)
             throws CommitFailedException {
+        rootState.propertyChanged(after.getName());
         for (Editor editor : editors) {
             editor.propertyAdded(after);
         }
@@ -326,6 +331,7 @@ public class IndexUpdate implements Edit
     @Override
     public void propertyChanged(PropertyState before, PropertyState after)
             throws CommitFailedException {
+        rootState.propertyChanged(before.getName());
         for (Editor editor : editors) {
             editor.propertyChanged(before, after);
         }
@@ -334,6 +340,7 @@ public class IndexUpdate implements Edit
     @Override
     public void propertyDeleted(PropertyState before)
             throws CommitFailedException {
+        rootState.propertyChanged(before.getName());
         for (Editor editor : editors) {
             editor.propertyDeleted(before);
         }
@@ -342,6 +349,7 @@ public class IndexUpdate implements Edit
     @Override @Nonnull
     public Editor childNodeAdded(String name, NodeState after)
             throws CommitFailedException {
+        rootState.nodeRead(name);
         List<Editor> children = newArrayListWithCapacity(1 + editors.size());
         children.add(new IndexUpdate(this, name));
         for (Editor editor : editors) {
@@ -357,6 +365,7 @@ public class IndexUpdate implements Edit
     public Editor childNodeChanged(
             String name, NodeState before, NodeState after)
             throws CommitFailedException {
+        rootState.nodeRead(name);
         List<Editor> children = newArrayListWithCapacity(1 + editors.size());
         children.add(new IndexUpdate(this, name));
         for (Editor editor : editors) {
@@ -471,6 +480,8 @@ public class IndexUpdate implements Edit
         final Set<String> reindexedIndexes = Sets.newHashSet();
         final Map<String, CountingCallback> callbacks = Maps.newHashMap();
         final CorruptIndexHandler corruptIndexHandler;
+        private int changedNodeCount;
+        private int changedPropertyCount;
 
         private IndexUpdateRootState(IndexEditorProvider provider, String 
async, NodeState root,
                                      IndexUpdateCallback updateCallback, 
CommitInfo commitInfo, CorruptIndexHandler corruptIndexHandler) {
@@ -534,6 +545,19 @@ public class IndexUpdate implements Edit
             return !reindexedIndexes.isEmpty();
         }
 
+        public void nodeRead(String name){
+            changedNodeCount++;
+        }
+
+        public void propertyChanged(String name){
+            changedPropertyCount++;
+        }
+
+        public String getIndexingStats() {
+            return String.format("changedNodeCount %d, changedPropertyCount 
%d",
+                    changedNodeCount, changedPropertyCount);
+        }
+
         private class CountingCallback implements ContextAwareCallback, 
IndexingContext {
             final String indexPath;
             final boolean reindex;


Reply via email to