@Test public void subsequentInvocationsToManageTransactionsToBeFixed_shouldRespectTheInputGlobalLimit() { AtomicInteger limit = new AtomicInteger(13); AtomicInteger transactionCount = new AtomicInteger(); IOpenBitSet firstTransactionSet = new SolrOpenBitSetAdapter(); range(1, 7).forEach(firstTransactionSet::set); Consumer<Long> counter = tx -> transactionCount.incrementAndGet(); admin.manageTransactionsToBeFixed(firstTransactionSet, tx -> 0, counter, limit); assertEquals(7, limit.get()); assertEquals(6, transactionCount.get()); IOpenBitSet secondTransactionSet = new SolrOpenBitSetAdapter(); range(10, 21).forEach(secondTransactionSet::set); admin.manageTransactionsToBeFixed(secondTransactionSet, tx -> 0, counter, limit); assertEquals("Global transaction limit should have been exceeded", -1, limit.get()); assertEquals(13, transactionCount.get()); IOpenBitSet thirdTransactionSet = new SolrOpenBitSetAdapter(); range(31, 42).forEach(thirdTransactionSet::set); Consumer<Long> thisShoulndtBeInvoked = tx -> { throw new RuntimeException("We should never be here, as the global limit has been already exceeded."); }; admin.manageTransactionsToBeFixed(thirdTransactionSet, tx -> 0, thisShoulndtBeInvoked, limit); assertEquals( -2, limit.get()); assertEquals(13, transactionCount.get()); }
NamedList<Object> manageTransactionsToBeFixed( IOpenBitSet transactions, LongToIntFunction nodesCounter, Consumer<Long> scheduler, AtomicInteger limit) { final NamedList<Object> transactionsList = new SimpleOrderedMap<>(); long txid = -1; while ((txid = transactions.nextSetBit(txid + 1)) != -1 && limit.decrementAndGet() >= 0) { transactionsList.add(String.valueOf(txid), nodesCounter.applyAsInt(txid)); scheduler.accept(txid); } return transactionsList; }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> manageTransactionsToBeFixed( IOpenBitSet transactions, LongToIntFunction nodesCounter, Consumer<Long> scheduler, AtomicInteger limit) { final NamedList<Object> transactionsList = new SimpleOrderedMap<>(); long txid = -1; while ((txid = transactions.nextSetBit(txid + 1)) != -1 && limit.decrementAndGet() >= 0) { transactionsList.add(String.valueOf(txid), nodesCounter.applyAsInt(txid)); scheduler.accept(txid); } return transactionsList; } }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> manageTransactionsToBeFixed( IOpenBitSet transactions, LongToIntFunction nodesCounter, Consumer<Long> scheduler, AtomicInteger limit) { final NamedList<Object> transactionsList = new SimpleOrderedMap<>(); long txid = -1; while ((txid = transactions.nextSetBit(txid + 1)) != -1 && limit.decrementAndGet() >= 0) { transactionsList.add(String.valueOf(txid), nodesCounter.applyAsInt(txid)); scheduler.accept(txid); } return transactionsList; } AlfrescoCoreAdminHandler();  AlfrescoCoreAdminHandler(CoreContainer coreContainer); }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> manageTransactionsToBeFixed( IOpenBitSet transactions, LongToIntFunction nodesCounter, Consumer<Long> scheduler, AtomicInteger limit) { final NamedList<Object> transactionsList = new SimpleOrderedMap<>(); long txid = -1; while ((txid = transactions.nextSetBit(txid + 1)) != -1 && limit.decrementAndGet() >= 0) { transactionsList.add(String.valueOf(txid), nodesCounter.applyAsInt(txid)); scheduler.accept(txid); } return transactionsList; } AlfrescoCoreAdminHandler();  AlfrescoCoreAdminHandler(CoreContainer coreContainer); @Override void shutdown(); ConcurrentHashMap<String, InformationServer> getInformationServers(); TrackerRegistry getTrackerRegistry(); SolrTrackerScheduler getScheduler(); }
AlfrescoCoreAdminHandler extends CoreAdminHandler { NamedList<Object> manageTransactionsToBeFixed( IOpenBitSet transactions, LongToIntFunction nodesCounter, Consumer<Long> scheduler, AtomicInteger limit) { final NamedList<Object> transactionsList = new SimpleOrderedMap<>(); long txid = -1; while ((txid = transactions.nextSetBit(txid + 1)) != -1 && limit.decrementAndGet() >= 0) { transactionsList.add(String.valueOf(txid), nodesCounter.applyAsInt(txid)); scheduler.accept(txid); } return transactionsList; } AlfrescoCoreAdminHandler();  AlfrescoCoreAdminHandler(CoreContainer coreContainer); @Override void shutdown(); ConcurrentHashMap<String, InformationServer> getInformationServers(); TrackerRegistry getTrackerRegistry(); SolrTrackerScheduler getScheduler(); static final String ALFRESCO_DEFAULTS; }