@Test public void maxAclTransactionsGlobalLimitShouldBeAppliedInCascade() { SolrInformationServer server = mock(SolrInformationServer.class); when(server.getDocListSize(anyString())).thenReturn(0); ConcurrentHashMap<String, InformationServer> informationServers = new ConcurrentHashMap<>(); informationServers.put(ALFRESCO_CORE_NAME, server); admin.informationServers = informationServers; IOpenBitSet txInIndexButNotInDb = new SolrOpenBitSetAdapter(); IOpenBitSet duplicatedTxInIndex = new SolrOpenBitSetAdapter(); IOpenBitSet missingTxFromIndex = new SolrOpenBitSetAdapter(); range(1, 10).forEach(txInIndexButNotInDb::set); range(21, 32).forEach(duplicatedTxInIndex::set); range(50, 61).forEach(missingTxFromIndex::set); int maxTransactionToSchedule = (int) (txInIndexButNotInDb.cardinality() + duplicatedTxInIndex.cardinality() + missingTxFromIndex.cardinality() - 5); IndexHealthReport emptyReport = mock(IndexHealthReport.class); when(emptyReport.getAclTxInIndexButNotInDb()).thenReturn(txInIndexButNotInDb); when(emptyReport.getDuplicatedAclTxInIndex()).thenReturn(duplicatedTxInIndex); when(emptyReport.getMissingAclTxFromIndex()).thenReturn(missingTxFromIndex); NamedList<Object> subReport = admin.aclTxToReindex(ALFRESCO_CORE_NAME, mock(AclTracker.class), emptyReport, tx -> {}, maxTransactionToSchedule); assertEquals( Long.valueOf(txInIndexButNotInDb.cardinality()), of(subReport.get(ACL_TX_IN_INDEX_NOT_IN_DB)) .map(NamedList.class::cast) .map(NamedList::size) .map(Number::longValue) .orElseThrow(() -> new RuntimeException(ACL_TX_IN_INDEX_NOT_IN_DB + " section not found in response."))); assertEquals( Long.valueOf(duplicatedTxInIndex.cardinality()), of(subReport.get(DUPLICATED_ACL_TX_IN_INDEX)) .map(NamedList.class::cast) .map(NamedList::size) .map(Number::longValue) .orElseThrow(() -> new RuntimeException(DUPLICATED_ACL_TX_IN_INDEX + " section not found in response."))); assertEquals( Long.valueOf(missingTxFromIndex.cardinality() - 5), of(subReport.get(MISSING_ACL_TX_IN_INDEX)) .map(NamedList.class::cast) .map(NamedList::size) .map(Number::longValue) .orElseThrow(() -> new RuntimeException(MISSING_ACL_TX_IN_INDEX + " section not found in response."))); }
NamedList<Object> aclTxToReindex( String coreName, AclTracker tracker, final IndexHealthReport report, Consumer<Long> scheduler, int maxTransactionsToSchedule) { final AtomicInteger globalLimit = new AtomicInteger(maxTransactionsToSchedule); final LongToIntFunction retrieveAclTransactionRelatedNodesCountFromRepository = txid -> notNullOrEmpty(tracker.getAclsForDbAclTransaction(txid)).size(); final LongToIntFunction retrieveAclTransactionRelatedNodesCountFromIndex = txid -> of(getInformationServers().get(coreName)) .map(SolrInformationServer.class::cast) .map(server -> server.getDocListSize(FIELD_INACLTXID + ":" + txid)) .orElse(0); NamedList<Object> aclTxToReindex = new SimpleOrderedMap<>(); aclTxToReindex.add(ACL_TX_IN_INDEX_NOT_IN_DB, manageTransactionsToBeFixed( report.getAclTxInIndexButNotInDb(), retrieveAclTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); aclTxToReindex.add(DUPLICATED_ACL_TX_IN_INDEX, manageTransactionsToBeFixed( report.getDuplicatedAclTxInIndex(), retrieveAclTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); aclTxToReindex.add(MISSING_ACL_TX_IN_INDEX, manageTransactionsToBeFixed( report.getMissingAclTxFromIndex(), retrieveAclTransactionRelatedNodesCountFromRepository, scheduler, globalLimit)); return aclTxToReindex; }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> aclTxToReindex( String coreName, AclTracker tracker, final IndexHealthReport report, Consumer<Long> scheduler, int maxTransactionsToSchedule) { final AtomicInteger globalLimit = new AtomicInteger(maxTransactionsToSchedule); final LongToIntFunction retrieveAclTransactionRelatedNodesCountFromRepository = txid -> notNullOrEmpty(tracker.getAclsForDbAclTransaction(txid)).size(); final LongToIntFunction retrieveAclTransactionRelatedNodesCountFromIndex = txid -> of(getInformationServers().get(coreName)) .map(SolrInformationServer.class::cast) .map(server -> server.getDocListSize(FIELD_INACLTXID + ":" + txid)) .orElse(0); NamedList<Object> aclTxToReindex = new SimpleOrderedMap<>(); aclTxToReindex.add(ACL_TX_IN_INDEX_NOT_IN_DB, manageTransactionsToBeFixed( report.getAclTxInIndexButNotInDb(), retrieveAclTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); aclTxToReindex.add(DUPLICATED_ACL_TX_IN_INDEX, manageTransactionsToBeFixed( report.getDuplicatedAclTxInIndex(), retrieveAclTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); aclTxToReindex.add(MISSING_ACL_TX_IN_INDEX, manageTransactionsToBeFixed( report.getMissingAclTxFromIndex(), retrieveAclTransactionRelatedNodesCountFromRepository, scheduler, globalLimit)); return aclTxToReindex; } }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> aclTxToReindex( String coreName, AclTracker tracker, final IndexHealthReport report, Consumer<Long> scheduler, int maxTransactionsToSchedule) { final AtomicInteger globalLimit = new AtomicInteger(maxTransactionsToSchedule); final LongToIntFunction retrieveAclTransactionRelatedNodesCountFromRepository = txid -> notNullOrEmpty(tracker.getAclsForDbAclTransaction(txid)).size(); final LongToIntFunction retrieveAclTransactionRelatedNodesCountFromIndex = txid -> of(getInformationServers().get(coreName)) .map(SolrInformationServer.class::cast) .map(server -> server.getDocListSize(FIELD_INACLTXID + ":" + txid)) .orElse(0); NamedList<Object> aclTxToReindex = new SimpleOrderedMap<>(); aclTxToReindex.add(ACL_TX_IN_INDEX_NOT_IN_DB, manageTransactionsToBeFixed( report.getAclTxInIndexButNotInDb(), retrieveAclTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); aclTxToReindex.add(DUPLICATED_ACL_TX_IN_INDEX, manageTransactionsToBeFixed( report.getDuplicatedAclTxInIndex(), retrieveAclTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); aclTxToReindex.add(MISSING_ACL_TX_IN_INDEX, manageTransactionsToBeFixed( report.getMissingAclTxFromIndex(), retrieveAclTransactionRelatedNodesCountFromRepository, scheduler, globalLimit)); return aclTxToReindex; } AlfrescoCoreAdminHandler();  AlfrescoCoreAdminHandler(CoreContainer coreContainer); }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> aclTxToReindex( String coreName, AclTracker tracker, final IndexHealthReport report, Consumer<Long> scheduler, int maxTransactionsToSchedule) { final AtomicInteger globalLimit = new AtomicInteger(maxTransactionsToSchedule); final LongToIntFunction retrieveAclTransactionRelatedNodesCountFromRepository = txid -> notNullOrEmpty(tracker.getAclsForDbAclTransaction(txid)).size(); final LongToIntFunction retrieveAclTransactionRelatedNodesCountFromIndex = txid -> of(getInformationServers().get(coreName)) .map(SolrInformationServer.class::cast) .map(server -> server.getDocListSize(FIELD_INACLTXID + ":" + txid)) .orElse(0); NamedList<Object> aclTxToReindex = new SimpleOrderedMap<>(); aclTxToReindex.add(ACL_TX_IN_INDEX_NOT_IN_DB, manageTransactionsToBeFixed( report.getAclTxInIndexButNotInDb(), retrieveAclTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); aclTxToReindex.add(DUPLICATED_ACL_TX_IN_INDEX, manageTransactionsToBeFixed( report.getDuplicatedAclTxInIndex(), retrieveAclTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); aclTxToReindex.add(MISSING_ACL_TX_IN_INDEX, manageTransactionsToBeFixed( report.getMissingAclTxFromIndex(), retrieveAclTransactionRelatedNodesCountFromRepository, scheduler, globalLimit)); return aclTxToReindex; } AlfrescoCoreAdminHandler();  AlfrescoCoreAdminHandler(CoreContainer coreContainer); @Override void shutdown(); ConcurrentHashMap<String, InformationServer> getInformationServers(); TrackerRegistry getTrackerRegistry(); SolrTrackerScheduler getScheduler(); }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> aclTxToReindex( String coreName, AclTracker tracker, final IndexHealthReport report, Consumer<Long> scheduler, int maxTransactionsToSchedule) { final AtomicInteger globalLimit = new AtomicInteger(maxTransactionsToSchedule); final LongToIntFunction retrieveAclTransactionRelatedNodesCountFromRepository = txid -> notNullOrEmpty(tracker.getAclsForDbAclTransaction(txid)).size(); final LongToIntFunction retrieveAclTransactionRelatedNodesCountFromIndex = txid -> of(getInformationServers().get(coreName)) .map(SolrInformationServer.class::cast) .map(server -> server.getDocListSize(FIELD_INACLTXID + ":" + txid)) .orElse(0); NamedList<Object> aclTxToReindex = new SimpleOrderedMap<>(); aclTxToReindex.add(ACL_TX_IN_INDEX_NOT_IN_DB, manageTransactionsToBeFixed( report.getAclTxInIndexButNotInDb(), retrieveAclTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); aclTxToReindex.add(DUPLICATED_ACL_TX_IN_INDEX, manageTransactionsToBeFixed( report.getDuplicatedAclTxInIndex(), retrieveAclTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); aclTxToReindex.add(MISSING_ACL_TX_IN_INDEX, manageTransactionsToBeFixed( report.getMissingAclTxFromIndex(), retrieveAclTransactionRelatedNodesCountFromRepository, scheduler, globalLimit)); return aclTxToReindex; } AlfrescoCoreAdminHandler();  AlfrescoCoreAdminHandler(CoreContainer coreContainer); @Override void shutdown(); ConcurrentHashMap<String, InformationServer> getInformationServers(); TrackerRegistry getTrackerRegistry(); SolrTrackerScheduler getScheduler(); static final String ALFRESCO_DEFAULTS; }