Search in sources :

Example 6 with BulkIndexer

use of org.sonar.server.es.BulkIndexer in project sonarqube by SonarSource.

the class UserIndexer method doIndex.

private void doIndex(@Nullable String login, Size bulkSize) {
    final BulkIndexer bulk = new BulkIndexer(esClient, UserIndexDefinition.INDEX_TYPE_USER.getIndex());
    bulk.setSize(bulkSize);
    try (DbSession dbSession = dbClient.openSession(false)) {
        try (UserResultSetIterator rowIt = UserResultSetIterator.create(dbClient, dbSession, login)) {
            doIndex(bulk, rowIt);
        }
    }
}
Also used : DbSession(org.sonar.db.DbSession) BulkIndexer(org.sonar.server.es.BulkIndexer)

Example 7 with BulkIndexer

use of org.sonar.server.es.BulkIndexer in project sonarqube by SonarSource.

the class ActiveRuleIndexer method createBulkIndexer.

private BulkIndexer createBulkIndexer(Size size) {
    BulkIndexer bulk = new BulkIndexer(esClient, INDEX_TYPE_ACTIVE_RULE.getIndex());
    bulk.setSize(size);
    return bulk;
}
Also used : BulkIndexer(org.sonar.server.es.BulkIndexer)

Example 8 with BulkIndexer

use of org.sonar.server.es.BulkIndexer in project sonarqube by SonarSource.

the class TestIndexer method doIndex.

private long doIndex(@Nullable String projectUuid, Size bulkSize) {
    final BulkIndexer bulk = new BulkIndexer(esClient, INDEX_TYPE_TEST.getIndex());
    bulk.setSize(bulkSize);
    DbSession dbSession = dbClient.openSession(false);
    try {
        TestResultSetIterator rowIt = TestResultSetIterator.create(dbClient, dbSession, projectUuid);
        long maxUpdatedAt = doIndex(bulk, rowIt);
        rowIt.close();
        return maxUpdatedAt;
    } finally {
        dbSession.close();
    }
}
Also used : DbSession(org.sonar.db.DbSession) BulkIndexer(org.sonar.server.es.BulkIndexer)

Example 9 with BulkIndexer

use of org.sonar.server.es.BulkIndexer in project sonarqube by SonarSource.

the class ViewIndexer method index.

/**
   * Index a single document.
   * <p/>
   * The views lookup cache will be cleared
   */
public void index(ViewDoc viewDoc) {
    final BulkIndexer bulk = new BulkIndexer(esClient, ViewIndexDefinition.INDEX_TYPE_VIEW.getIndex());
    bulk.start();
    doIndex(bulk, viewDoc, true);
    bulk.stop();
}
Also used : BulkIndexer(org.sonar.server.es.BulkIndexer)

Example 10 with BulkIndexer

use of org.sonar.server.es.BulkIndexer in project sonarqube by SonarSource.

the class ViewIndexer method index.

private void index(DbSession dbSession, Map<String, String> viewAndProjectViewUuidMap, boolean needClearCache, Size bulkSize) {
    final BulkIndexer bulk = new BulkIndexer(esClient, ViewIndexDefinition.INDEX_TYPE_VIEW.getIndex());
    bulk.setSize(bulkSize);
    bulk.start();
    for (Map.Entry<String, String> entry : viewAndProjectViewUuidMap.entrySet()) {
        String viewUuid = entry.getKey();
        List<String> projects = dbClient.componentDao().selectProjectsFromView(dbSession, viewUuid, entry.getValue());
        doIndex(bulk, new ViewDoc().setUuid(viewUuid).setProjects(projects), needClearCache);
    }
    bulk.stop();
}
Also used : BulkIndexer(org.sonar.server.es.BulkIndexer) Maps.newHashMap(com.google.common.collect.Maps.newHashMap) Map(java.util.Map)

Aggregations

BulkIndexer (org.sonar.server.es.BulkIndexer)13 DbSession (org.sonar.db.DbSession)4 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)3 Map (java.util.Map)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1 IndexRequest (org.elasticsearch.action.index.IndexRequest)1 DateUtils (org.sonar.api.utils.DateUtils)1 Collectors (org.sonar.core.util.stream.Collectors)1 Collectors.toSet (org.sonar.core.util.stream.Collectors.toSet)1 DbClient (org.sonar.db.DbClient)1 ComponentDto (org.sonar.db.component.ComponentDto)1 Size (org.sonar.server.es.BulkIndexer.Size)1