Search in sources :

Example 1 with SearchWsRequest

use of org.sonarqube.ws.client.rule.SearchWsRequest in project sonarqube by SonarSource.

the class SearchAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    try (DbSession dbSession = dbClient.openSession(false)) {
        SearchWsRequest searchWsRequest = toSearchWsRequest(request);
        SearchOptions context = buildSearchOptions(searchWsRequest);
        RuleQuery query = ruleQueryFactory.createRuleQuery(request);
        SearchResult searchResult = doSearch(dbSession, query, context);
        SearchResponse responseBuilder = buildResponse(dbSession, searchWsRequest, context, searchResult, query);
        writeProtobuf(responseBuilder, request, response);
    }
}
Also used : DbSession(org.sonar.db.DbSession) SearchWsRequest(org.sonarqube.ws.client.rule.SearchWsRequest) RuleQuery(org.sonar.server.rule.index.RuleQuery) SearchOptions(org.sonar.server.es.SearchOptions) SearchResponse(org.sonarqube.ws.Rules.SearchResponse)

Example 2 with SearchWsRequest

use of org.sonarqube.ws.client.rule.SearchWsRequest in project sonarqube by SonarSource.

the class ClusterTest method secondary_nodes_do_not_write_to_datastores_at_startup.

/**
   * SONAR-7899
   */
@Test
public void secondary_nodes_do_not_write_to_datastores_at_startup() throws Exception {
    // start "startup leader", which creates and populates datastores
    Orchestrator orchestrator = Orchestrator.builderEnv().setServerProperty("sonar.cluster.enabled", "true").setServerProperty("sonar.cluster.name", "secondary_nodes_do_not_write_to_datastores_at_startup").setServerProperty("sonar.cluster.web.startupLeader", "true").setServerProperty("sonar.log.level", "TRACE").addPlugin(ItUtils.xooPlugin()).build();
    orchestrator.start();
    expectLog(orchestrator, "Cluster enabled (startup leader)");
    expectWriteOperations(orchestrator, true);
    // verify that datastores are populated by requesting rules
    assertThat(newWsClient(orchestrator).rules().search(new SearchWsRequest()).getTotal()).isGreaterThan(0);
    FileUtils.write(orchestrator.getServer().getWebLogs(), "", false);
    updateSonarPropertiesFile(orchestrator, ImmutableMap.of("sonar.cluster.web.startupLeader", "false"));
    orchestrator.restartServer();
    expectLog(orchestrator, "Cluster enabled (startup follower)");
    expectWriteOperations(orchestrator, false);
    orchestrator.stop();
}
Also used : SearchWsRequest(org.sonarqube.ws.client.rule.SearchWsRequest) Orchestrator(com.sonar.orchestrator.Orchestrator) Test(org.junit.Test)

Aggregations

SearchWsRequest (org.sonarqube.ws.client.rule.SearchWsRequest)2 Orchestrator (com.sonar.orchestrator.Orchestrator)1 Test (org.junit.Test)1 DbSession (org.sonar.db.DbSession)1 SearchOptions (org.sonar.server.es.SearchOptions)1 RuleQuery (org.sonar.server.rule.index.RuleQuery)1 SearchResponse (org.sonarqube.ws.Rules.SearchResponse)1