Author: davide Date: Tue Dec 9 16:20:37 2014 New Revision: 1644106 URL: http://svn.apache.org/r1644106 Log: OAK-2328: add logging in OrderedContentMirrorStorateStrategy for better investigation
Added trace logging for inspecting the exit condition and moved other logging to trace level. Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java?rev=1644106&r1=1644105&r2=1644106&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java Tue Dec 9 16:20:37 2014 @@ -126,19 +126,21 @@ public class OrderedContentMirrorStoreSt } private static void printWalkedLanes(final String msg, final String[] walked) { - String m = (msg == null) ? "" : msg; - if (walked == null) { - LOG.debug(m + " walked: null"); - } else { - for (int i = 0; i < walked.length; i++) { - LOG.debug("{}walked[{}]: {}", new Object[] { m, i, walked[i] }); + if (LOG.isTraceEnabled()) { + String m = (msg == null) ? "" : msg; + if (walked == null) { + LOG.trace(m + " walked: null"); + } else { + for (int i = 0; i < walked.length; i++) { + LOG.trace("{}walked[{}]: {}", new Object[] { m, i, walked[i] }); + } } } } @Override NodeBuilder fetchKeyNode(@Nonnull NodeBuilder index, @Nonnull String key) { - LOG.debug("fetchKeyNode() - new item '{}' -----------------------------------------", key); + LOG.debug("fetchKeyNode() - === new item '{}'", key); // this is where the actual adding and maintenance of index's keys happen NodeBuilder node = null; NodeBuilder start = index.child(START); @@ -903,7 +905,7 @@ public class OrderedContentMirrorStoreSt found = nextkey; } else { currentKey = nextkey; - if (keepWalked && !Strings.isNullOrEmpty(currentKey)) { + if (keepWalked && !Strings.isNullOrEmpty(currentKey) && walkedLanes != null) { walkedLanes[lane] = currentKey; } } @@ -914,7 +916,11 @@ public class OrderedContentMirrorStoreSt lane = OrderedIndex.LANES - 1; NodeBuilder currentNode = null; + int iteration = 0; + boolean exitCondition = true; + do { + iteration++; stillLaning = lane > 0; if (currentNode == null) { currentNode = index.getChildNode(currentKey); @@ -941,14 +947,37 @@ public class OrderedContentMirrorStoreSt } else { currentKey = nextkey; currentNode = null; - if (keepWalked && !Strings.isNullOrEmpty(currentKey)) { + if (keepWalked && !Strings.isNullOrEmpty(currentKey) && walkedLanes != null) { for (int l = lane; l >= 0; l--) { walkedLanes[l] = currentKey; } } } } - } while (((!Strings.isNullOrEmpty(nextkey) && walkingPredicate.apply(nextkey)) || stillLaning) && (found == null)); + + exitCondition = ((!Strings.isNullOrEmpty(nextkey) && walkingPredicate + .apply(nextkey)) || stillLaning) && (found == null); + + if (LOG.isTraceEnabled()) { + LOG.trace("seek()::plain case - --- iteration: {}", iteration); + LOG.trace("seek()::plain case - retries: {}, MAX_RETRIES: {}", retries, + MAX_RETRIES); + LOG.trace("seek()::plain case - lane: {}", lane); + LOG.trace("seek()::plain case - currentKey: {}", currentKey); + LOG.trace("seek()::plain case - nextkey: {}", nextkey); + LOG.trace("seek()::plain case - condition.apply(nextkey): {}", + condition.apply(nextkey)); + LOG.trace("seek()::plain case - found: {}", found); + LOG.trace("seek()::plain case - !Strings.isNullOrEmpty(nextkey): {}", + !Strings.isNullOrEmpty(nextkey)); + LOG.trace("seek()::plain case - walkingPredicate.apply(nextkey): {}", + walkingPredicate.apply(nextkey)); + LOG.trace("seek()::plain case - stillLaning: {}", stillLaning); + LOG.trace( + "seek()::plain case - While Condition: {}", + exitCondition); + } + } while (exitCondition); } return found;