use of org.sonar.db.es.EsQueueDto in project sonarqube by SonarSource.
the class ActiveRuleIndexer method doIndexActiveRules.
private IndexingResult doIndexActiveRules(DbSession dbSession, Map<String, EsQueueDto> activeRuleItems) {
OneToOneResilientIndexingListener listener = new OneToOneResilientIndexingListener(dbClient, dbSession, activeRuleItems.values());
BulkIndexer bulkIndexer = createBulkIndexer(Size.REGULAR, listener);
bulkIndexer.start();
Map<String, EsQueueDto> remaining = new HashMap<>(activeRuleItems);
dbClient.activeRuleDao().scrollByUuidsForIndexing(dbSession, toActiveRuleUuids(activeRuleItems), i -> {
remaining.remove(docIdOf(i.getUuid()));
bulkIndexer.add(newIndexRequest(i));
});
// the remaining ids reference rows that don't exist in db. They must
// be deleted from index.
remaining.values().forEach(item -> bulkIndexer.addDeletion(TYPE_ACTIVE_RULE, item.getDocId(), item.getDocRouting()));
return bulkIndexer.stop();
}
use of org.sonar.db.es.EsQueueDto in project sonarqube by SonarSource.
the class RuleIndexer method index.
@Override
public IndexingResult index(DbSession dbSession, Collection<EsQueueDto> items) {
IndexingResult result = new IndexingResult();
if (!items.isEmpty()) {
ListMultimap<String, EsQueueDto> itemsByType = groupItemsByIndexTypeFormat(items);
doIndexRules(dbSession, itemsByType.get(TYPE_RULE.format())).ifPresent(result::add);
}
return result;
}
use of org.sonar.db.es.EsQueueDto in project sonarqube by SonarSource.
the class ComponentIndexerTest method indexProject.
private IndexingResult indexProject(ComponentDto project, ProjectIndexer.Cause cause) {
DbSession dbSession = db.getSession();
Collection<EsQueueDto> items = underTest.prepareForRecovery(dbSession, singletonList(project.uuid()), cause);
dbSession.commit();
return underTest.index(dbSession, items);
}
use of org.sonar.db.es.EsQueueDto in project sonarqube by SonarSource.
the class OneToOneResilientIndexingListenerTest method insertInQueue.
private EsQueueDto insertInQueue(IndexType indexType, String id) {
EsQueueDto item = EsQueueDto.create(indexType.format(), id);
db.getDbClient().esQueueDao().insert(db.getSession(), singletonList(item));
return item;
}
use of org.sonar.db.es.EsQueueDto in project sonarqube by SonarSource.
the class RecoveryIndexerTest method insertItem.
private EsQueueDto insertItem(IndexType indexType, String docUuid) {
EsQueueDto item = EsQueueDto.create(indexType.format(), docUuid);
db.getDbClient().esQueueDao().insert(db.getSession(), item);
db.commit();
return item;
}
Aggregations