add wait time to progress if it took more than 20 seconds
authorPavel Sher <pavel.sher@jetbrains.com>
Mon, 28 Jan 2019 16:00:36 +0000 (17:00 +0100)
committerPavel Sher <pavel.sher@jetbrains.com>
Mon, 28 Jan 2019 16:00:36 +0000 (17:00 +0100)
git-server/src/jetbrains/buildServer/buildTriggers/vcs/git/CommitLoaderImpl.java

index ec9767b6ad86f8c0dbfb78ae38b16d31667227e1..330de7fb7c8467a1b96b6a38f1abd29ddb817df0 100644 (file)
@@ -94,10 +94,15 @@ public class CommitLoaderImpl implements CommitLoader {
     final long start = System.currentTimeMillis();
     synchronized (myRepositoryManager.getWriteLock(repositoryDir)) {
       final long finish = System.currentTimeMillis();
-      Map<String, Ref> oldRefs = new HashMap<String, Ref>(db.getAllRefs());
-      PERFORMANCE_LOG.debug("[waitForWriteLock] repository: " + repositoryDir.getAbsolutePath() + ", took " + (finish - start) + "ms");
+      final long waitTime = finish - start;
+      if (waitTime > 20000) {
+        // if wait time was significant, report it in progress
+        settings.getProgress().reportProgress("Waited for exclusive lock in cloned directory, wait time: " + waitTime + "ms");
+      }
+      Map<String, Ref> oldRefs = new HashMap<>(db.getAllRefs());
+      PERFORMANCE_LOG.debug("[waitForWriteLock] repository: " + repositoryDir.getAbsolutePath() + ", took " + waitTime + "ms");
       myFetchCommand.fetch(db, fetchURI, refspecs, settings);
-      Map<String, Ref> newRefs = new HashMap<String, Ref>(db.getAllRefs());
+      Map<String, Ref> newRefs = new HashMap<>(db.getAllRefs());
       myMapFullPath.invalidateRevisionsCache(db, oldRefs, newRefs);
     }
   }