import org.sonar.core.activity.db.ActivityDto;
import org.sonar.core.cluster.WorkQueue;
import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
import org.sonar.server.search.BaseIndex;
import org.sonar.server.search.ESNode;
import org.sonar.server.search.IndexDefinition;
}
public Result<Activity> findAll() {
- return new Result<Activity>(this, getClient().prepareSearch(this.getIndexName())
+ StopWatch fullProfile = profiling.start("es", Profiling.Level.FULL);
+ StopWatch basicProfile = profiling.start("es", Profiling.Level.BASIC);
+ SearchRequestBuilder request = getClient().prepareSearch(this.getIndexName())
.setQuery(QueryBuilders.matchAllQuery())
.setTypes(this.getIndexType())
- .setSize(Integer.MAX_VALUE)
- .get());
+ .setSize(Integer.MAX_VALUE);
+ basicProfile.stop(request.toString());
+ SearchResponse response = request.get();
+ fullProfile.stop(response.toString());
+ return new Result<Activity>(this, response);
}
public SearchResponse search(ActivityQuery query, QueryOptions options) {
public SearchResponse search(ActivityQuery query, QueryOptions options,
@Nullable FilterBuilder domainFilter) {
+ StopWatch fullProfile = profiling.start("es", Profiling.Level.FULL);
+ StopWatch basicProfile = profiling.start("es", Profiling.Level.BASIC);
+
// Prepare query
SearchRequestBuilder esSearch = getClient()
.prepareSearch(this.getIndexName())
esSearch.setScroll(TimeValue.timeValueMinutes(3));
}
- return esSearch.get();
+ basicProfile.stop(esSearch.toString());
+ SearchResponse response = esSearch.get();
+ fullProfile.stop(response.toString());
+
+ return response;
}
}
import org.sonar.api.rule.RuleStatus;
import org.sonar.core.cluster.WorkQueue;
import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
import org.sonar.core.qualityprofile.db.ActiveRuleDto;
import org.sonar.core.qualityprofile.db.ActiveRuleKey;
import org.sonar.server.qualityprofile.ActiveRule;
* finder methods
*/
public List<ActiveRule> findByRule(RuleKey key) {
+ StopWatch fullProfile = profiling.start("es", Profiling.Level.FULL);
+ StopWatch basicProfile = profiling.start("es", Profiling.Level.BASIC);
SearchRequestBuilder request = getClient().prepareSearch(this.getIndexName())
.setQuery(QueryBuilders
.hasParentQuery(this.getParentType(),
// TODO replace by scrolling
.setSize(Integer.MAX_VALUE);
+ basicProfile.stop(request.toString());
SearchResponse response = request.get();
+ fullProfile.stop(response.toString());
List<ActiveRule> activeRules = new ArrayList<ActiveRule>();
for (SearchHit hit : response.getHits()) {
}
public List<ActiveRule> findByProfile(String key) {
+ StopWatch fullProfile = profiling.start("es", Profiling.Level.FULL);
+ StopWatch basicProfile = profiling.start("es", Profiling.Level.BASIC);
SearchRequestBuilder request = getClient().prepareSearch(getIndexName())
.setQuery(QueryBuilders.termQuery(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field(), key))
.setRouting(key)
// TODO replace by scrolling
.setSize(Integer.MAX_VALUE);
+ basicProfile.stop(request.toString());
SearchResponse response = request.get();
-
+ fullProfile.stop(response.toString());
List<ActiveRule> activeRules = new ArrayList<ActiveRule>();
for (SearchHit hit : response.getHits()) {
activeRules.add(toDoc(hit.getSource()));
}
public Map<String, Multimap<String, FacetValue>> getStatsByProfileKeys(List<String> keys) {
+ StopWatch fullProfile = profiling.start("es", Profiling.Level.FULL);
+ StopWatch basicProfile = profiling.start("es", Profiling.Level.BASIC);
SearchRequestBuilder request = getClient().prepareSearch(this.getIndexName())
.setQuery(QueryBuilders.filteredQuery(
QueryBuilders.termsQuery(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field(), keys),
.subAggregation(AggregationBuilders.count("countActiveRules")))
.setSize(0)
.setTypes(this.getIndexType());
-
+ basicProfile.stop(request.toString());
SearchResponse response = request.get();
+ fullProfile.stop(response.toString());
Map<String, Multimap<String, FacetValue>> stats = new HashMap<String, Multimap<String, FacetValue>>();
Aggregation aggregation = response.getAggregations().get(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field());
for (Terms.Bucket value : ((Terms) aggregation).getBuckets()) {