]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5531 - Logging progress every 100K items synchronized
authorStephane Gamard <stephane.gamard@sonarsource.com>
Tue, 16 Sep 2014 15:13:49 +0000 (17:13 +0200)
committerStephane Gamard <stephane.gamard@sonarsource.com>
Tue, 16 Sep 2014 15:13:49 +0000 (17:13 +0200)
server/sonar-server/src/main/java/org/sonar/server/db/BaseDao.java

index 08d9f0f2153ca24dc2a4840702e80fc942902882..1c86e366b109be4c9d5f7f74c73746f670136557 100644 (file)
@@ -23,6 +23,8 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import org.apache.ibatis.session.ResultContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DaoComponent;
 import org.sonar.core.persistence.DbSession;
@@ -114,6 +116,8 @@ import static com.google.common.collect.Maps.newHashMap;
  */
 public abstract class BaseDao<MAPPER, DTO extends Dto<KEY>, KEY extends Serializable> implements Dao<DTO, KEY>, DaoComponent {
 
+  private static final Logger LOGGER = LoggerFactory.getLogger(BaseDao.class);
+
   protected IndexDefinition indexDefinition;
   private Class<MAPPER> mapperClass;
   private System2 system2;
@@ -313,10 +317,16 @@ public abstract class BaseDao<MAPPER, DTO extends Dto<KEY>, KEY extends Serializ
 
   protected DbSynchronizationHandler getSynchronizationResultHandler(final DbSession session) {
     return new DbSynchronizationHandler() {
+      private int count = 0;
+
       @Override
       public void handleResult(ResultContext resultContext) {
         DTO dto = (DTO) resultContext.getResultObject();
         session.enqueue(new UpsertDto<DTO>(getIndexType(), dto, true));
+        count++;
+        if (count % 100000 == 0) {
+          LOGGER.info(" - synchronized {} {}", count, getIndexType());
+        }
       }
 
       @Override