@Test public void noTransactionToReindex_shouldReturnAnEmptyResponse() { IndexHealthReport emptyReport = mock(IndexHealthReport.class); when(emptyReport.getTxInIndexButNotInDb()).thenReturn(new SolrOpenBitSetAdapter()); when(emptyReport.getDuplicatedTxInIndex()).thenReturn(new SolrOpenBitSetAdapter()); when(emptyReport.getMissingTxFromIndex()).thenReturn(new SolrOpenBitSetAdapter()); NamedList<Object> subReport = admin.txToReindex(ALFRESCO_CORE_NAME, mock(MetadataTracker.class), emptyReport, tx -> {}, Integer.MAX_VALUE); assertEquals( Long.valueOf(0L), of(subReport.get(TX_IN_INDEX_NOT_IN_DB)) .map(NamedList.class::cast) .map(NamedList::size) .map(Number::longValue) .orElseThrow(() -> new RuntimeException(TX_IN_INDEX_NOT_IN_DB + " section not found in response."))); assertEquals( Long.valueOf(0L), of(subReport.get(DUPLICATED_TX_IN_INDEX)) .map(NamedList.class::cast) .map(NamedList::size) .map(Number::longValue) .orElseThrow(() -> new RuntimeException(DUPLICATED_TX_IN_INDEX + " section not found in response."))); assertEquals( Long.valueOf(0L), of(subReport.get(MISSING_TX_IN_INDEX)) .map(NamedList.class::cast) .map(NamedList::size) .map(Number::longValue) .orElseThrow(() -> new RuntimeException(MISSING_TX_IN_INDEX + " section not found in response."))); }
NamedList<Object> txToReindex( String coreName, MetadataTracker tracker, final IndexHealthReport report, Consumer<Long> scheduler, int maxTransactionsToSchedule) { final AtomicInteger globalLimit = new AtomicInteger(maxTransactionsToSchedule); final LongToIntFunction retrieveTransactionRelatedNodesCountFromRepository = txid -> notNullOrEmpty(tracker.getFullNodesForDbTransaction(txid)).size(); final LongToIntFunction retrieveTransactionRelatedNodesCountFromIndex = txid -> of(getInformationServers().get(coreName)) .map(SolrInformationServer.class::cast) .map(server -> server.getDocListSize(FIELD_INTXID + ":" + txid)) .orElse(0); NamedList<Object> txToReindex = new SimpleOrderedMap<>(); txToReindex.add(TX_IN_INDEX_NOT_IN_DB, manageTransactionsToBeFixed( report.getTxInIndexButNotInDb(), retrieveTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); txToReindex.add(DUPLICATED_TX_IN_INDEX, manageTransactionsToBeFixed( report.getDuplicatedTxInIndex(), retrieveTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); txToReindex.add(MISSING_TX_IN_INDEX, manageTransactionsToBeFixed( report.getMissingTxFromIndex(), retrieveTransactionRelatedNodesCountFromRepository, scheduler, globalLimit)); return txToReindex; }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> txToReindex( String coreName, MetadataTracker tracker, final IndexHealthReport report, Consumer<Long> scheduler, int maxTransactionsToSchedule) { final AtomicInteger globalLimit = new AtomicInteger(maxTransactionsToSchedule); final LongToIntFunction retrieveTransactionRelatedNodesCountFromRepository = txid -> notNullOrEmpty(tracker.getFullNodesForDbTransaction(txid)).size(); final LongToIntFunction retrieveTransactionRelatedNodesCountFromIndex = txid -> of(getInformationServers().get(coreName)) .map(SolrInformationServer.class::cast) .map(server -> server.getDocListSize(FIELD_INTXID + ":" + txid)) .orElse(0); NamedList<Object> txToReindex = new SimpleOrderedMap<>(); txToReindex.add(TX_IN_INDEX_NOT_IN_DB, manageTransactionsToBeFixed( report.getTxInIndexButNotInDb(), retrieveTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); txToReindex.add(DUPLICATED_TX_IN_INDEX, manageTransactionsToBeFixed( report.getDuplicatedTxInIndex(), retrieveTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); txToReindex.add(MISSING_TX_IN_INDEX, manageTransactionsToBeFixed( report.getMissingTxFromIndex(), retrieveTransactionRelatedNodesCountFromRepository, scheduler, globalLimit)); return txToReindex; } }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> txToReindex( String coreName, MetadataTracker tracker, final IndexHealthReport report, Consumer<Long> scheduler, int maxTransactionsToSchedule) { final AtomicInteger globalLimit = new AtomicInteger(maxTransactionsToSchedule); final LongToIntFunction retrieveTransactionRelatedNodesCountFromRepository = txid -> notNullOrEmpty(tracker.getFullNodesForDbTransaction(txid)).size(); final LongToIntFunction retrieveTransactionRelatedNodesCountFromIndex = txid -> of(getInformationServers().get(coreName)) .map(SolrInformationServer.class::cast) .map(server -> server.getDocListSize(FIELD_INTXID + ":" + txid)) .orElse(0); NamedList<Object> txToReindex = new SimpleOrderedMap<>(); txToReindex.add(TX_IN_INDEX_NOT_IN_DB, manageTransactionsToBeFixed( report.getTxInIndexButNotInDb(), retrieveTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); txToReindex.add(DUPLICATED_TX_IN_INDEX, manageTransactionsToBeFixed( report.getDuplicatedTxInIndex(), retrieveTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); txToReindex.add(MISSING_TX_IN_INDEX, manageTransactionsToBeFixed( report.getMissingTxFromIndex(), retrieveTransactionRelatedNodesCountFromRepository, scheduler, globalLimit)); return txToReindex; } AlfrescoCoreAdminHandler();  AlfrescoCoreAdminHandler(CoreContainer coreContainer); }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> txToReindex( String coreName, MetadataTracker tracker, final IndexHealthReport report, Consumer<Long> scheduler, int maxTransactionsToSchedule) { final AtomicInteger globalLimit = new AtomicInteger(maxTransactionsToSchedule); final LongToIntFunction retrieveTransactionRelatedNodesCountFromRepository = txid -> notNullOrEmpty(tracker.getFullNodesForDbTransaction(txid)).size(); final LongToIntFunction retrieveTransactionRelatedNodesCountFromIndex = txid -> of(getInformationServers().get(coreName)) .map(SolrInformationServer.class::cast) .map(server -> server.getDocListSize(FIELD_INTXID + ":" + txid)) .orElse(0); NamedList<Object> txToReindex = new SimpleOrderedMap<>(); txToReindex.add(TX_IN_INDEX_NOT_IN_DB, manageTransactionsToBeFixed( report.getTxInIndexButNotInDb(), retrieveTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); txToReindex.add(DUPLICATED_TX_IN_INDEX, manageTransactionsToBeFixed( report.getDuplicatedTxInIndex(), retrieveTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); txToReindex.add(MISSING_TX_IN_INDEX, manageTransactionsToBeFixed( report.getMissingTxFromIndex(), retrieveTransactionRelatedNodesCountFromRepository, scheduler, globalLimit)); return txToReindex; } AlfrescoCoreAdminHandler();  AlfrescoCoreAdminHandler(CoreContainer coreContainer); @Override void shutdown(); ConcurrentHashMap<String, InformationServer> getInformationServers(); TrackerRegistry getTrackerRegistry(); SolrTrackerScheduler getScheduler(); }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> txToReindex( String coreName, MetadataTracker tracker, final IndexHealthReport report, Consumer<Long> scheduler, int maxTransactionsToSchedule) { final AtomicInteger globalLimit = new AtomicInteger(maxTransactionsToSchedule); final LongToIntFunction retrieveTransactionRelatedNodesCountFromRepository = txid -> notNullOrEmpty(tracker.getFullNodesForDbTransaction(txid)).size(); final LongToIntFunction retrieveTransactionRelatedNodesCountFromIndex = txid -> of(getInformationServers().get(coreName)) .map(SolrInformationServer.class::cast) .map(server -> server.getDocListSize(FIELD_INTXID + ":" + txid)) .orElse(0); NamedList<Object> txToReindex = new SimpleOrderedMap<>(); txToReindex.add(TX_IN_INDEX_NOT_IN_DB, manageTransactionsToBeFixed( report.getTxInIndexButNotInDb(), retrieveTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); txToReindex.add(DUPLICATED_TX_IN_INDEX, manageTransactionsToBeFixed( report.getDuplicatedTxInIndex(), retrieveTransactionRelatedNodesCountFromIndex, scheduler, globalLimit)); txToReindex.add(MISSING_TX_IN_INDEX, manageTransactionsToBeFixed( report.getMissingTxFromIndex(), retrieveTransactionRelatedNodesCountFromRepository, scheduler, globalLimit)); return txToReindex; } AlfrescoCoreAdminHandler();  AlfrescoCoreAdminHandler(CoreContainer coreContainer); @Override void shutdown(); ConcurrentHashMap<String, InformationServer> getInformationServers(); TrackerRegistry getTrackerRegistry(); SolrTrackerScheduler getScheduler(); static final String ALFRESCO_DEFAULTS; }