From 7f4810c32d64199c8f5bd4e04cb79055ac8d2ecb Mon Sep 17 00:00:00 2001 From: Andrew Hind Date: Wed, 24 Mar 2010 13:59:15 +0000 Subject: [PATCH] Build fix - fix build speed git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19538 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../index/FullIndexRecoveryComponent.java | 63 +++++++------------ 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/source/java/org/alfresco/repo/node/index/FullIndexRecoveryComponent.java b/source/java/org/alfresco/repo/node/index/FullIndexRecoveryComponent.java index e9020d271d..787cb67ce6 100644 --- a/source/java/org/alfresco/repo/node/index/FullIndexRecoveryComponent.java +++ b/source/java/org/alfresco/repo/node/index/FullIndexRecoveryComponent.java @@ -183,38 +183,16 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent transactionService.setAllowWrite(false); } - int startSample = 10; - InIndex startAllPresent; - do - { - // Check that the first and last meaningful transactions are indexed - List startTxns = nodeDaoService.getTxnsByCommitTimeAscending( - Long.MIN_VALUE, Long.MAX_VALUE, startSample, null, false); - startAllPresent = areTxnsInStartSample(startTxns); - startSample += 10; - if(startSample > 1000) - { - startAllPresent = InIndex.NO; - break; - } - } - while(startAllPresent == InIndex.INDETERMINATE); - int endSample = 10; - InIndex endAllPresent; - do - { - List endTxns = nodeDaoService.getTxnsByCommitTimeDescending( - Long.MIN_VALUE, Long.MAX_VALUE, endSample, null, false); - endAllPresent = areAllTxnsInEndSample(endTxns); - endSample += 10; - if(endSample > 1000) - { - endAllPresent = InIndex.NO; - break; - } - } - while(endAllPresent == InIndex.INDETERMINATE); + List startTxns = nodeDaoService.getTxnsByCommitTimeAscending( + Long.MIN_VALUE, Long.MAX_VALUE, 1000, null, false); + InIndex startAllPresent = areTxnsInStartSample(startTxns); + + + List endTxns = nodeDaoService.getTxnsByCommitTimeDescending( + Long.MIN_VALUE, Long.MAX_VALUE, 1000, null, false); + InIndex endAllPresent = areAllTxnsInEndSample(endTxns); + // check the level of cover required switch (recoveryMode) @@ -256,9 +234,11 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent */ protected InIndex areAllTxnsInEndSample(List txns) { + int count = 0; int yesCount = 0; for (Transaction txn : txns) { + count++; if (isTxnPresentInIndex(txn) == InIndex.NO) { // Missing txn @@ -267,30 +247,33 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent if (isTxnPresentInIndex(txn) == InIndex.YES) { yesCount++; + if((yesCount > 1) && (count >= 10)) + { + return InIndex.YES; + } } } - // Work around for TX that is written to the repo at start up .. must be more than one real add /update - if(yesCount > 1) - { - return InIndex.YES; - } - else - { - return InIndex.INDETERMINATE; - } + return InIndex.INDETERMINATE; } protected InIndex areTxnsInStartSample(List txns) { + int count = 0; InIndex current = InIndex.INDETERMINATE; for (Transaction txn : txns) { + count++; current = isTxnPresentInIndex(txn); if (current == InIndex.NO) { // Missing txn return InIndex.NO; } + if((current == InIndex.YES) && (count >= 10)) + { + return InIndex.YES; + } + } return current; }