This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git


The following commit(s) were added to refs/heads/master by this push:
     new 50b4a7c  Comments changes and shutdown during start fix
50b4a7c is described below

commit 50b4a7c18bbee59c90e99347fe68a2c6e1aab673
Author: Dmitriy Pavlov <dpav...@apache.org>
AuthorDate: Sun Sep 23 13:42:25 2018 +0300

    Comments changes and shutdown during start fix
---
 .../main/java/org/apache/ignite/ci/ITeamcity.java  |  3 +-
 .../apache/ignite/ci/IgnitePersistentTeamcity.java | 43 +++++++++-------------
 .../java/org/apache/ignite/ci/web/CtxListener.java |  6 ++-
 3 files changed, 24 insertions(+), 28 deletions(-)

diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java
index 42ed6cb..6be0446 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java
@@ -90,7 +90,8 @@ public interface ITeamcity extends AutoCloseable {
     };
 
     /**
-     * Includes snapshot dependencies failed builds into list
+     * Includes 'snapshot dependencies failed' builds into list.
+     * loads build history with following parameter: 
defaultFilter:false,state:finished
      *
      * @param projectId suite ID (string without spaces)
      * @param branch branch in TC identification
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
index 0d92e4f..a0558ed 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgnitePersistentTeamcity.java
@@ -230,16 +230,16 @@ public class IgnitePersistentTeamcity implements 
IAnalyticsEnabledTeamcity, ITea
 
 
     /**
-     * @return Build history: {@link BuildRef} lists cache, 32 parts.
+     * @return Build history: {@link BuildRef} lists cache, 32 parts, 
transactional.
      */
     private IgniteCache<SuiteInBranch, Expirable<List<BuildRef>>> 
buildHistCache() {
         return getOrCreateCacheV2Tx(ignCacheNme(BUILD_HIST_FINISHED));
     }
 
     /**
-     * @return Build history: {@link BuildRef} lists cache, 32 parts, 
transactional
+     * @return Build history: {@link BuildRef} lists cache, 32 parts, 
transactional.
      */
-    public IgniteCache<SuiteInBranch, Expirable<List<BuildRef>>> 
buildHistIncFailedCache() {
+    private IgniteCache<SuiteInBranch, Expirable<List<BuildRef>>> 
buildHistIncFailedCache() {
         return 
getOrCreateCacheV2Tx(ignCacheNme(BUILD_HIST_FINISHED_OR_FAILED));
     }
 
@@ -402,7 +402,6 @@ public class IgnitePersistentTeamcity implements 
IAnalyticsEnabledTeamcity, ITea
                                                       String branch,
                                                       Long cnt,
                                                       Integer ignored) {
-        //todo may be support sinceBuildNo
         final SuiteInBranch suiteInBranch = new SuiteInBranch(projectId, 
branch);
 
         List<BuildRef> buildRefs = loadBuildHistory(buildHistCache(), 90, cnt, 
suiteInBranch,
@@ -430,8 +429,6 @@ public class IgnitePersistentTeamcity implements 
IAnalyticsEnabledTeamcity, ITea
         return new ArrayList<>(merge.values());
     }
 
-    //loads build history with following parameter: 
defaultFilter:false,state:finished
-
     /** {@inheritDoc} */
     @AutoProfiling
     @Override public List<BuildRef> getFinishedBuildsIncludeSnDepFailed(String 
projectId,
@@ -445,20 +442,14 @@ public class IgnitePersistentTeamcity implements 
IAnalyticsEnabledTeamcity, ITea
     }
 
 
-    public <K, V> CompletableFuture<V> 
loadAsyncIfAbsentOrExpired(ConcurrentMap<K, Expirable<V>> cache,
-                                                                  K key,
-                                                                  
ConcurrentMap<K, CompletableFuture<V>> cachedComputations,
-                                                                  Function<K, 
CompletableFuture<V>> realLoadFunction,
-                                                                  int 
maxAgeSecs,
-                                                                  boolean 
alwaysProvidePersisted) {
+    private <K, V> CompletableFuture<V> 
loadAsyncIfAbsentOrExpired(ConcurrentMap<K, Expirable<V>> cache,
+                                                                   K key,
+                                                                   
ConcurrentMap<K, CompletableFuture<V>> cachedComputations,
+                                                                   Function<K, 
CompletableFuture<V>> realLoadFunction,
+                                                                   int 
maxAgeSecs,
+                                                                   boolean 
alwaysProvidePersisted) {
         @Nullable final Expirable<V> persistedValue = cache.get(key);
 
-        int fields = ObjectInterner.internFields(persistedValue);
-
-        //   if (fields > 0)
-        //     System.out.println("Interned " + fields + " after get()");
-
-
         if (persistedValue != null && 
persistedValue.isAgeLessThanSecs(maxAgeSecs))
             return CompletableFuture.completedFuture(persistedValue.getData());
 
@@ -468,7 +459,11 @@ public class IgnitePersistentTeamcity implements 
IAnalyticsEnabledTeamcity, ITea
                 k -> {
                     CompletableFuture<V> future = realLoadFunction.apply(k)
                             .thenApplyAsync(valueLoaded -> {
-                                cache.put(k, new Expirable<V>(valueLoaded));
+                                final Expirable<V> cached = new 
Expirable<>(valueLoaded);
+
+                                ObjectInterner.internFields(cached);
+
+                                cache.put(k, cached);
 
                                 return valueLoaded;
                             });
@@ -499,7 +494,7 @@ public class IgnitePersistentTeamcity implements 
IAnalyticsEnabledTeamcity, ITea
         int secondsUseCached = getTriggerRelCacheValidSecs(defaultSecs);
 
         return loadAsyncIfAbsentOrExpired(
-            runningBuilds, //getOrCreateCacheV2(ignCacheNme(RUNNING_BUILDS)),
+            runningBuilds,
             Strings.nullToEmpty(branch),
             runningBuildsFuts,
             teamcity::getRunningBuilds,
@@ -519,7 +514,7 @@ public class IgnitePersistentTeamcity implements 
IAnalyticsEnabledTeamcity, ITea
         int secondsUseCached = getTriggerRelCacheValidSecs(defaultSecs);
 
         return loadAsyncIfAbsentOrExpired(
-            queuedBuilds, // getOrCreateCacheV2(ignCacheNme(BUILD_QUEUE)),
+            queuedBuilds,
             Strings.nullToEmpty(branch),
             queuedBuildsFuts,
             teamcity::getQueuedBuilds,
@@ -683,12 +678,8 @@ public class IgnitePersistentTeamcity implements 
IAnalyticsEnabledTeamcity, ITea
     }
 
     private void addTestOccurrencesToStat(TestOccurrences val) {
-        addTestOccurrencesToStat(val, ITeamcity.DEFAULT);
-    }
-
-    private void addTestOccurrencesToStat(TestOccurrences val, String 
normalizedBranch) {
         for (TestOccurrence next : val.getTests())
-            addTestOccurrenceToStat(next, normalizedBranch, null);
+            addTestOccurrenceToStat(next, ITeamcity.DEFAULT, null);
     }
 
     /** {@inheritDoc} */
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/CtxListener.java 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/CtxListener.java
index 0040ea3..8d7a066 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/CtxListener.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/CtxListener.java
@@ -90,7 +90,11 @@ public class CtxListener implements ServletContextListener {
     @Override public void contextDestroyed(ServletContextEvent sctxEvt) {
         final ServletContext ctx = sctxEvt.getServletContext();
 
-        TcHelperDb.stop(getIgnite(ctx));
+        try {
+            TcHelperDb.stop(getIgnite(ctx));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 
         getBackgroundUpdater(ctx).stop();
 

Reply via email to