From: Stephane Gamard Date: Tue, 5 Aug 2014 07:34:02 +0000 (+0200) Subject: Added profiling to IndexQueue (BASIC level, low verbosity) X-Git-Tag: 4.5-RC1~258 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5bd41ba9adf10b03fa302cdb3e29ad6fb3bbe62c;p=sonarqube.git Added profiling to IndexQueue (BASIC level, low verbosity) --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java b/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java index ebb7b07371a..81cfdf6092f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java @@ -26,7 +26,10 @@ import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.ServerComponent; +import org.sonar.api.config.Settings; import org.sonar.core.cluster.WorkQueue; +import org.sonar.core.profiling.Profiling; +import org.sonar.core.profiling.StopWatch; import org.sonar.server.search.action.EmbeddedIndexAction; import org.sonar.server.search.action.IndexAction; @@ -40,13 +43,16 @@ import java.util.concurrent.TimeUnit; public class IndexQueue extends LinkedBlockingQueue implements ServerComponent, WorkQueue { + protected final Profiling profiling; + private static final Logger LOGGER = LoggerFactory.getLogger(IndexQueue.class); private static final Integer DEFAULT_QUEUE_SIZE = 200; private static final int TIMEOUT = 30000; - public IndexQueue() { - super(IndexQueue.DEFAULT_QUEUE_SIZE); + public IndexQueue(Settings settings) { + super(DEFAULT_QUEUE_SIZE); + this.profiling = new Profiling(settings); } @Override @@ -57,6 +63,7 @@ public class IndexQueue extends LinkedBlockingQueue @Override public void enqueue(List actions) { + int bcount = 0; int ecount = 0; List refreshes = Lists.newArrayList(); @@ -92,6 +99,7 @@ public class IndexQueue extends LinkedBlockingQueue throw new IllegalStateException("ES update has been interrupted", e); } } else if (actions.size() > 1) { + StopWatch basicProfile = profiling.start("search", Profiling.Level.BASIC); /* Purge actions that would be overridden */ Long purgeStart = System.currentTimeMillis(); @@ -154,7 +162,8 @@ public class IndexQueue extends LinkedBlockingQueue } catch (InterruptedException e) { throw new IllegalStateException("ES update has been interrupted", e); } - LOGGER.debug("INDEX - time:{}ms ({}ms index, {}ms embedded, {}ms refresh)\ttypes:[{}],\tbulk:{}\tembedded:{}\trefresh:[{}]", + + basicProfile.stop("INDEX - time:%sms (%sms index, %sms embedded, %sms refresh)\ttypes:[%s],\tbulk:%s\tembedded:%s\trefresh:[%s]", (System.currentTimeMillis() - all_start), indexTime, embeddedTime, refreshTime, StringUtils.join(types, ","), bcount, ecount, StringUtils.join(refreshes, ","));