You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ch...@apache.org on 2014/12/05 09:24:02 UTC
svn commit: r1643186 - in
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index:
AsyncIndexUpdate.java IndexUpdate.java
Author: chetanm
Date: Fri Dec 5 08:24:01 2014
New Revision: 1643186
URL: http://svn.apache.org/viewvc?rev=1643186&view=rev
Log:
OAK-2321 - Provide details in log when reindexing is completed by AsyncIndexUpdate
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=1643186&r1=1643185&r2=1643186&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 Fri Dec 5 08:24:01 2014
@@ -347,6 +347,7 @@ public class AsyncIndexUpdate implements
NodeState before, String beforeCheckpoint,
NodeState after, String afterCheckpoint, String afterTime)
throws CommitFailedException {
+ Stopwatch watch = Stopwatch.createStarted();
// start collecting runtime statistics
preAsyncRunStatsStats(indexStats);
@@ -396,6 +397,9 @@ public class AsyncIndexUpdate implements
postAsyncRunStatsStatus(indexStats);
}
mergeWithConcurrencyCheck(builder, beforeCheckpoint, callback.lease);
+ if (indexUpdate.isReindexingPerformed()) {
+ log.info("Reindexing completed for indexes: {} in {}", indexUpdate.getAllReIndexedIndexes(), watch);
+ }
} finally {
callback.close();
}
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=1643186&r1=1643185&r2=1643186&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 Fri Dec 5 08:24:01 2014
@@ -41,6 +41,7 @@ import java.util.Set;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
+import com.google.common.collect.Sets;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
@@ -57,11 +58,7 @@ public class IndexUpdate implements Edit
private final Logger log = LoggerFactory.getLogger(getClass());
- private final IndexEditorProvider provider;
-
- private final String async;
-
- private final NodeState root;
+ private final IndexUpdateRootState rootState;
private final NodeBuilder builder;
@@ -84,11 +81,6 @@ public class IndexUpdate implements Edit
*/
private final Map<String, Editor> reindex = new HashMap<String, Editor>();
- /**
- * Callback for the update events of the indexing job
- */
- private final IndexUpdateCallback updateCallback;
-
private MissingIndexProviderStrategy missingProvider = new MissingIndexProviderStrategy();
public IndexUpdate(
@@ -98,21 +90,15 @@ public class IndexUpdate implements Edit
this.parent = null;
this.name = null;
this.path = "/";
- this.provider = checkNotNull(provider);
- this.async = async;
- this.root = checkNotNull(root);
+ this.rootState = new IndexUpdateRootState(provider, async, root, updateCallback);
this.builder = checkNotNull(builder);
- this.updateCallback = checkNotNull(updateCallback);
}
private IndexUpdate(IndexUpdate parent, String name) {
this.parent = checkNotNull(parent);
this.name = name;
- this.provider = parent.provider;
- this.async = parent.async;
- this.root = parent.root;
+ this.rootState = parent.rootState;
this.builder = parent.builder.getChildNode(checkNotNull(name));
- this.updateCallback = parent.updateCallback;
}
@Override
@@ -123,6 +109,7 @@ public class IndexUpdate implements Edit
if (!reindex.isEmpty()) {
log.info("Reindexing will be performed for following indexes: {}",
reindex.keySet());
+ rootState.reindexedIndexes.addAll(reindex.keySet());
}
// no-op when reindex is empty
@@ -137,6 +124,14 @@ public class IndexUpdate implements Edit
}
}
+ public boolean isReindexingPerformed(){
+ return !getAllReIndexedIndexes().isEmpty();
+ }
+
+ public Set<String> getAllReIndexedIndexes(){
+ return rootState.reindexedIndexes;
+ }
+
private boolean shouldReindex(NodeBuilder definition, NodeState before,
String name) {
PropertyState ps = definition.getProperty(REINDEX_PROPERTY_NAME);
@@ -157,7 +152,7 @@ public class IndexUpdate implements Edit
NodeState before) throws CommitFailedException {
for (String name : definitions.getChildNodeNames()) {
NodeBuilder definition = definitions.getChildNode(name);
- if (Objects.equal(async, definition.getString(ASYNC_PROPERTY_NAME))) {
+ if (Objects.equal(rootState.async, definition.getString(ASYNC_PROPERTY_NAME))) {
String type = definition.getString(TYPE_PROPERTY_NAME);
if (type == null) {
// probably not an index def
@@ -165,7 +160,7 @@ public class IndexUpdate implements Edit
}
boolean shouldReindex = shouldReindex(definition,
before, name);
- Editor editor = provider.getIndexEditor(type, definition, root, updateCallback);
+ Editor editor = rootState.provider.getIndexEditor(type, definition, rootState.root, rootState.updateCallback);
if (editor == null) {
missingProvider.onMissingIndex(type, definition);
} else if (shouldReindex) {
@@ -303,4 +298,23 @@ public class IndexUpdate implements Edit
return this;
}
+ private static final class IndexUpdateRootState {
+ final IndexEditorProvider provider;
+ final String async;
+ final NodeState root;
+ /**
+ * Callback for the update events of the indexing job
+ */
+ final IndexUpdateCallback updateCallback;
+ final Set<String> reindexedIndexes = Sets.newHashSet();
+
+ private IndexUpdateRootState(IndexEditorProvider provider, String async, NodeState root,
+ IndexUpdateCallback updateCallback) {
+ this.provider = checkNotNull(provider);
+ this.async = async;
+ this.root = checkNotNull(root);
+ this.updateCallback = checkNotNull(updateCallback);
+ }
+ }
+
}