You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2019/08/09 18:27:36 UTC
[ignite-teamcity-bot] branch upd-cntrs updated: Counters for
tracking updates for particular branches implementation started
This is an automated email from the ASF dual-hosted git repository.
dpavlov pushed a commit to branch upd-cntrs
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git
The following commit(s) were added to refs/heads/upd-cntrs by this push:
new d7dba3a Counters for tracking updates for particular branches implementation started
d7dba3a is described below
commit d7dba3abfce761a9c7067ce3724894cb4c4d545e
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Fri Aug 9 21:27:29 2019 +0300
Counters for tracking updates for particular branches implementation started
---
.../ignite/ci/web/rest/pr/GetPrTestFailures.java | 21 ++++++-------
.../rest/tracked/GetTrackedBranchTestResults.java | 35 +++++++---------------
ignite-tc-helper-web/src/main/webapp/current.html | 27 +++++++++--------
ignite-tc-helper-web/src/main/webapp/pr.html | 29 ++++++++++--------
.../ignite/tcbot/engine/chain/FullChainRunCtx.java | 2 ++
.../ignite/tcbot/engine/pr/PrChainsProcessor.java | 28 +++++++++++------
.../tracked/TrackedBranchChainsProcessor.java | 16 +++++-----
.../apache/ignite/tcbot/engine/ui/DsSummaryUi.java | 1 +
.../apache/ignite/tcbot/engine/ui/UpdateInfo.java | 11 +++++++
.../apache/ignite/tcignited/build/FatBuildDao.java | 5 ++++
.../tcignited/build/UpdateCountersStorage.java | 21 +++++++++++--
.../ignite/tcignited/buildref/BuildRefDao.java | 9 ++++++
12 files changed, 124 insertions(+), 81 deletions(-)
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/pr/GetPrTestFailures.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/pr/GetPrTestFailures.java
index 644a195..d46c82d 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/pr/GetPrTestFailures.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/pr/GetPrTestFailures.java
@@ -30,15 +30,15 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import org.apache.ignite.ci.github.PullRequest;
+import org.apache.ignite.ci.user.ITcBotUserCreds;
+import org.apache.ignite.ci.web.CtxListener;
import org.apache.ignite.githubignited.IGitHubConnIgnited;
import org.apache.ignite.githubignited.IGitHubConnIgnitedProvider;
-import org.apache.ignite.tcbot.engine.pr.PrChainsProcessor;
import org.apache.ignite.githubservice.IGitHubConnection;
-import org.apache.ignite.tcignited.SyncMode;
-import org.apache.ignite.ci.user.ITcBotUserCreds;
-import org.apache.ignite.ci.web.CtxListener;
+import org.apache.ignite.tcbot.engine.pr.PrChainsProcessor;
import org.apache.ignite.tcbot.engine.ui.DsSummaryUi;
import org.apache.ignite.tcbot.engine.ui.UpdateInfo;
+import org.apache.ignite.tcignited.SyncMode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -58,15 +58,12 @@ public class GetPrTestFailures {
@GET
@Path("updates")
public UpdateInfo getPrFailuresUpdates(
- @Nullable @QueryParam("serverId") String srvId,
- @Nonnull @QueryParam("suiteId") String suiteId,
+ @Nullable @QueryParam("serverId") String srvCodeOrAlias,
@Nonnull @QueryParam("branchForTc") String branchForTc,
- @Nonnull @QueryParam("action") String act,
- @Nullable @QueryParam("count") Integer cnt,
- @Nullable @QueryParam("baseBranchForTc") String baseBranchForTc,
- @Nullable @QueryParam("checkAllLogs") Boolean checkAllLogs) {
-
- return new UpdateInfo().copyFrom(getPrFailuresResultsNoSync(srvId, suiteId, branchForTc, act, cnt, baseBranchForTc, checkAllLogs));
+ @Nullable @QueryParam("baseBranchForTc") String baseBranchForTc) {
+ return new UpdateInfo().initCounters(
+ CtxListener.getInjector(ctx).getInstance(PrChainsProcessor.class)
+ .getPrUpdateCounters(srvCodeOrAlias, branchForTc, baseBranchForTc, ITcBotUserCreds.get(req)));
}
@GET
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/tracked/GetTrackedBranchTestResults.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/tracked/GetTrackedBranchTestResults.java
index b245630..f5cd3a4 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/tracked/GetTrackedBranchTestResults.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/tracked/GetTrackedBranchTestResults.java
@@ -46,7 +46,6 @@ import org.apache.ignite.tcbot.engine.ui.GuardBranchStatusUi;
import org.apache.ignite.tcbot.engine.ui.UpdateInfo;
import org.apache.ignite.tcignited.ITeamcityIgnitedProvider;
import org.apache.ignite.tcignited.SyncMode;
-import org.apache.ignite.tcignited.build.UpdateCountersStorage;
import org.apache.ignite.tcservice.model.mute.MuteInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -69,28 +68,13 @@ public class GetTrackedBranchTestResults {
@GET
@Path("updates")
- public UpdateInfo getTestFailsUpdates(@Nullable @QueryParam("branch") String branchOrNull,
- @Nullable @QueryParam("checkAllLogs") Boolean checkAllLogs,
- @Nullable @QueryParam("trustedTests") Boolean trustedTests,
- @Nullable @QueryParam("tagSelected") String tagSelected,
- @Nullable @QueryParam("tagForHistSelected") String tagForHistSelected,
- @Nullable @QueryParam("displayMode") String displayMode,
- @Nullable @QueryParam("sortOption") String sortOption,
- @Nullable @QueryParam("count") Integer mergeCnt,
- @Nullable @QueryParam("showTestLongerThan") Integer showTestLongerThan,
- @Nullable @QueryParam("muted") Boolean showMuted,
- @Nullable @QueryParam("ignored") Boolean showIgnored) {
-
- ITcBotUserCreds creds = ITcBotUserCreds.get(req);
-
- Injector injector = CtxListener.getInjector(ctx);
-
- IDetailedStatusForTrackedBranch instance = injector.getInstance(IDetailedStatusForTrackedBranch.class);
-
+ public UpdateInfo getTestFailsUpdates(@Nullable @QueryParam("branch") String branchOrNull) {
UpdateInfo info = new UpdateInfo();
- Map<Integer, Integer> cnts = instance.getTrackedBranchUpdateCounters(branchOrNull, creds);
- info.hashCodeHex = UpdateCountersStorage.getCountersHash(cnts);
+ Map<Integer, Integer> counters = CtxListener.getInjector(ctx).getInstance(IDetailedStatusForTrackedBranch.class)
+ .getTrackedBranchUpdateCounters(branchOrNull, ITcBotUserCreds.get(req));
+ info.initCounters(counters);
+
return info;
}
@@ -188,10 +172,11 @@ public class GetTrackedBranchTestResults {
@GET
@Path("mergedUpdates")
- public UpdateInfo getAllTestFailsUpdates(@Nullable @QueryParam("branch") String branch,
- @Nullable @QueryParam("count") Integer cnt,
- @Nullable @QueryParam("checkAllLogs") Boolean checkAllLogs) {
- return new UpdateInfo().copyFrom(getAllTestFailsNoSync(branch, cnt, checkAllLogs));
+ public UpdateInfo getAllTestFailsUpdates(@Nullable @QueryParam("branch") String branchOrNull) {
+ return new UpdateInfo().initCounters(
+ CtxListener.getInjector(ctx)
+ .getInstance(IDetailedStatusForTrackedBranch.class)
+ .getTrackedBranchUpdateCounters(branchOrNull, ITcBotUserCreds.get(req)));
}
@GET
diff --git a/ignite-tc-helper-web/src/main/webapp/current.html b/ignite-tc-helper-web/src/main/webapp/current.html
index 5045910..c475284 100644
--- a/ignite-tc-helper-web/src/main/webapp/current.html
+++ b/ignite-tc-helper-web/src/main/webapp/current.html
@@ -25,8 +25,9 @@
</head>
<body>
<script>
-var g_shownDataHashCodeHex = "";
-var gVue;
+ let g_shownDataHashCodeHex = "";
+ let g_checkForUpdateSched = false;
+ let gVue;
function genLink() {
let newUrl = "./current.html" + parmsForRest();
@@ -213,16 +214,17 @@ function parmsForRest() {
function checkForUpdate() {
var curFailuresUrl = "rest/tracked/updates" + parmsForRest();
-
+ g_checkForUpdateSched = false;
$.ajax({
url: curFailuresUrl,
success: function (result) {
if (g_shownDataHashCodeHex !== "" && isDefinedAndFilled(result.hashCodeHex)) {
if (g_shownDataHashCodeHex === result.hashCodeHex) {
- var fastCheckNeeded = isDefinedAndFilled(result.runningUpdates) && result.runningUpdates > 0;
- var ms = fastCheckNeeded ? 3000 : 30000;
+ if (!g_checkForUpdateSched) {
+ g_checkForUpdateSched = true;
- setTimeout(checkForUpdate, ms);
+ setTimeout(checkForUpdate, 10000);
+ }
$("#loadStatus").html("");
} else {
@@ -245,15 +247,14 @@ function loadData() {
$.ajax({
url: curFailuresUrl,
success: function (result) {
- if (isDefinedAndFilled(result.runningUpdates) && result.runningUpdates > 0) {
- setTimeout(checkForUpdate, 3000);
-
- $("#loadStatus").html("<img src='https://www.wallies.com/filebin/images/loading_apple.gif' width=20px height=20px> Updating");
- } else {
- $("#loadStatus").html("");
- }
showData(result);
g_shownDataHashCodeHex = isDefinedAndFilled(result.hashCodeHex) ? result.hashCodeHex : "";
+
+ if (!g_checkForUpdateSched) {
+ g_checkForUpdateSched = true;
+
+ setTimeout(checkForUpdate, 10000);
+ }
},
error: showErrInLoadStatus
});
diff --git a/ignite-tc-helper-web/src/main/webapp/pr.html b/ignite-tc-helper-web/src/main/webapp/pr.html
index 3db63f6..dab893e 100644
--- a/ignite-tc-helper-web/src/main/webapp/pr.html
+++ b/ignite-tc-helper-web/src/main/webapp/pr.html
@@ -17,8 +17,9 @@
</head>
<body>
<script>
- var g_shownDataHashCodeHex = "";
- var gVue;
+ let g_shownDataHashCodeHex = "";
+ let g_checkForUpdateSched = false;
+ let gVue;
function showQueryForm() {
let baseBranchForTc = findGetParameter("baseBranchForTc");
@@ -62,7 +63,6 @@
$(document).tooltip();
showQueryForm();
loadData();
- //todo fix setInterval(checkForUpdate, 30000);
var branch = findGetParameter("branch");
@@ -129,15 +129,17 @@ function parmsForRest() {
function checkForUpdate() {
var curFailuresUrl = "rest/pr/updates" + parmsForRest();
+ g_checkForUpdateSched = false;
$.ajax({
url: curFailuresUrl,
success: function (result) {
if (g_shownDataHashCodeHex !== "" && isDefinedAndFilled(result.hashCodeHex)) {
if (g_shownDataHashCodeHex === result.hashCodeHex) {
- var fastCheckNeeded = isDefinedAndFilled(result.runningUpdates) && result.runningUpdates > 0;
- var ms = fastCheckNeeded ? 3000 : 30000;
+ if (!g_checkForUpdateSched) {
+ g_checkForUpdateSched = true;
- setTimeout(checkForUpdate, ms);
+ setTimeout(checkForUpdate, 10000);
+ }
$("#loadStatus").html("");
} else {
@@ -155,18 +157,19 @@ function checkForUpdate() {
var curFailuresUrl = "rest/pr/results" + parmsForRest();
$("#loadStatus").html("<img src='https://www.wallies.com/filebin/images/loading_apple.gif' width=20px height=20px> Please wait. First load of PR run-all data may require significant time.");
- setTimeout(loadPartialData, 3000);
+ setTimeout(loadPartialData, 3000); // in case full loading stalls
$.ajax({
url: curFailuresUrl,
success: function (result) {
- if (isDefinedAndFilled(result.runningUpdates) && result.runningUpdates > 0) {
- setTimeout(checkForUpdate, 3000);
- $("#loadStatus").html("<img src='https://www.wallies.com/filebin/images/loading_apple.gif' width=20px height=20px> Updating");
- } else {
- $("#loadStatus").html("");
- }
+ $("#loadStatus").html("");
showData(result);
g_shownDataHashCodeHex = isDefinedAndFilled(result.hashCodeHex) ? result.hashCodeHex : "";
+
+ if (!g_checkForUpdateSched) {
+ g_checkForUpdateSched = true;
+
+ setTimeout(checkForUpdate, 10000);
+ }
},
error: showErrInLoadStatus
});
diff --git a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/FullChainRunCtx.java b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/FullChainRunCtx.java
index a59e210..f65a484 100644
--- a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/FullChainRunCtx.java
+++ b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/chain/FullChainRunCtx.java
@@ -108,10 +108,12 @@ public class FullChainRunCtx {
this.buildCfgsResults.addAll(suites);
}
+ @Deprecated
public Stream<Future<?>> getFutures() {
return buildCfgsResults.stream().flatMap(MultBuildRunCtx::getFutures);
}
+ @Deprecated
public Stream<Future<?>> getRunningUpdates() {
return getFutures().filter(Objects::nonNull).filter(future -> !future.isDone() && !future.isCancelled());
}
diff --git a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/pr/PrChainsProcessor.java b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/pr/PrChainsProcessor.java
index e05285c..8cfaffa 100644
--- a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/pr/PrChainsProcessor.java
+++ b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/pr/PrChainsProcessor.java
@@ -17,10 +17,12 @@
package org.apache.ignite.tcbot.engine.pr;
import com.google.common.base.Strings;
+import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
@@ -49,6 +51,7 @@ import org.apache.ignite.tcbot.persistence.IStringCompactor;
import org.apache.ignite.tcignited.ITeamcityIgnited;
import org.apache.ignite.tcignited.ITeamcityIgnitedProvider;
import org.apache.ignite.tcignited.SyncMode;
+import org.apache.ignite.tcignited.build.UpdateCountersStorage;
import org.apache.ignite.tcignited.buildref.BranchEquivalence;
import org.apache.ignite.tcignited.creds.ICredentialsProv;
import org.apache.ignite.tcignited.history.IRunHistory;
@@ -80,8 +83,12 @@ public class PrChainsProcessor {
@Inject private IStringCompactor compactor;
+ /** Config. */
@Inject private ITcBotConfig cfg;
+ @Inject private BranchEquivalence branchEquivalence;
+ @Inject private UpdateCountersStorage countersStorage;
+
/**
* @param creds Credentials.
* @param srvCodeOrAlias Server code or alias.
@@ -106,8 +113,6 @@ public class PrChainsProcessor {
@Nullable Boolean checkAllLogs,
SyncMode mode) {
final DsSummaryUi res = new DsSummaryUi();
- final AtomicInteger runningUpdates = new AtomicInteger();
-
ITeamcityIgnited tcIgnited = tcIgnitedProvider.server(srvCodeOrAlias, creds);
IGitHubConnIgnited gitHubConnIgnited = gitHubConnIgnitedProvider.server(srvCodeOrAlias);
@@ -159,11 +164,6 @@ public class PrChainsProcessor {
if (ctx.isFakeStub())
chainStatus.setBuildNotFound(true);
else {
- int cnt0 = (int)ctx.getRunningUpdates().count();
-
- if (cnt0 > 0)
- runningUpdates.addAndGet(cnt0);
-
//fail rate reference is always default (master)
chainStatus.initFromContext(tcIgnited, ctx, baseBranchForTc, compactor, false,
null, null, -1, null, false, false); // don't need for PR
@@ -173,7 +173,7 @@ public class PrChainsProcessor {
res.addChainOnServer(chainStatus);
- res.postProcess(runningUpdates.get());
+ res.initCounters(getPrUpdateCounters(srvCodeOrAlias, branchForTc, baseBranchForTc, creds));
return res;
}
@@ -329,4 +329,14 @@ public class PrChainsProcessor {
.collect(Collectors.toList());
}
+ public Map<Integer, Integer> getPrUpdateCounters(String srvCodeOrAlias, String branchForTc, String tcBaseBranchParm,
+ ICredentialsProv creds) {
+ String baseBranchForTc = Strings.isNullOrEmpty(tcBaseBranchParm) ? dfltBaseTcBranch(srvCodeOrAlias) : tcBaseBranchParm;
+
+ Set<Integer> allRelatedBranchCodes = new HashSet<>();
+ allRelatedBranchCodes.addAll(branchEquivalence.branchIdsForQuery(branchForTc, compactor));
+ allRelatedBranchCodes.addAll(branchEquivalence.branchIdsForQuery(baseBranchForTc, compactor));
+
+ return countersStorage.getCounters(allRelatedBranchCodes);
+ }
}
diff --git a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/tracked/TrackedBranchChainsProcessor.java b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/tracked/TrackedBranchChainsProcessor.java
index d2663fd..71ab3f4 100644
--- a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/tracked/TrackedBranchChainsProcessor.java
+++ b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/tracked/TrackedBranchChainsProcessor.java
@@ -73,6 +73,9 @@ public class TrackedBranchChainsProcessor implements IDetailedStatusForTrackedBr
/** Compactor. */
@Inject private IStringCompactor compactor;
+ @Inject private BranchEquivalence branchEquivalence;
+
+ /** Update Counters for branch-related changes storage. */
@Inject private UpdateCountersStorage countersStorage;
/** {@inheritDoc} */
@@ -93,7 +96,6 @@ public class TrackedBranchChainsProcessor implements IDetailedStatusForTrackedBr
boolean showMuted,
boolean showIgnored) {
final DsSummaryUi res = new DsSummaryUi();
- final AtomicInteger runningUpdates = new AtomicInteger();
final String branchNn = isNullOrEmpty(branch) ? ITcServerConfig.DEFAULT_TRACKED_BRANCH_NAME : branch;
res.setTrackedBranch(branchNn);
@@ -151,10 +153,6 @@ public class TrackedBranchChainsProcessor implements IDetailedStatusForTrackedBr
requireParamVal
);
- int cnt = (int)ctx.getRunningUpdates().count();
- if (cnt > 0)
- runningUpdates.addAndGet(cnt);
-
chainStatus.initFromContext(tcIgnited, ctx, baseBranchTc, compactor, calcTrustedTests, tagSelected,
displayMode, maxDurationSec, requireParamVal,
showMuted, showIgnored);
@@ -165,7 +163,7 @@ public class TrackedBranchChainsProcessor implements IDetailedStatusForTrackedBr
res.servers.sort(Comparator.comparing(DsChainUi::serverName));
- res.postProcess(runningUpdates.get());
+ res.initCounters(getTrackedBranchUpdateCounters(branch, creds));
return res;
}
@@ -260,7 +258,11 @@ public class TrackedBranchChainsProcessor implements IDetailedStatusForTrackedBr
.forEach(chainTracked -> {
String tcBranch = chainTracked.tcBranch();
- Set<Integer> allBranchIds = new BranchEquivalence().branchIdsForQuery(tcBranch, compactor);
+ Set<Integer> allBranchIds = new HashSet<>(branchEquivalence.branchIdsForQuery(tcBranch, compactor));
+
+ chainTracked.tcBaseBranch().ifPresent(base -> {
+ allBranchIds.addAll(branchEquivalence.branchIdsForQuery(base, compactor));
+ });
allBranches.addAll(allBranchIds);
});
diff --git a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsSummaryUi.java b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsSummaryUi.java
index 0a6cd24..155979e 100644
--- a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsSummaryUi.java
+++ b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/DsSummaryUi.java
@@ -63,6 +63,7 @@ public class DsSummaryUi extends UpdateInfo {
return this;
}
+ @Deprecated
public void postProcess(int running) {
runningUpdates = running;
diff --git a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/UpdateInfo.java b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/UpdateInfo.java
index 5c617b9..e051302 100644
--- a/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/UpdateInfo.java
+++ b/tcbot-engine/src/main/java/org/apache/ignite/tcbot/engine/ui/UpdateInfo.java
@@ -17,8 +17,10 @@
package org.apache.ignite.tcbot.engine.ui;
+import java.util.Map;
import org.apache.ignite.tcbot.common.conf.IGitHubConfig;
import org.apache.ignite.tcbot.common.conf.IJiraServerConfig;
+import org.apache.ignite.tcignited.build.UpdateCountersStorage;
/**
* General update information for JS data updating requests. UI model, so it contains public fields.
@@ -43,6 +45,8 @@ import org.apache.ignite.tcbot.common.conf.IJiraServerConfig;
/** Hash code hexadecimal, protects from redraw and minimizing mode info in case data not changed */
public String hashCodeHex;
+ public Map<Integer, Integer> counters;
+
public UpdateInfo copyFrom(UpdateInfo info) {
//todo there is no chance to update running futures if info is cached
this.runningUpdates = info.runningUpdates;
@@ -65,4 +69,11 @@ import org.apache.ignite.tcbot.common.conf.IJiraServerConfig;
if (jiraCfg.isJiraTokenAvailable())
javaFlags |= JIRA_FLAG;
}
+
+ public UpdateInfo initCounters(Map<Integer, Integer> counters) {
+ this.counters = counters;
+ hashCodeHex = UpdateCountersStorage.getCountersHash(counters);
+
+ return this;
+ }
}
diff --git a/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/build/FatBuildDao.java b/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/build/FatBuildDao.java
index 439adca..197d2ad 100644
--- a/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/build/FatBuildDao.java
+++ b/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/build/FatBuildDao.java
@@ -85,6 +85,9 @@ public class FatBuildDao {
/** History collector. */
@Inject private HistoryCollector histCollector;
+ /** Update Counters for branch-related changes storage. */
+ @Inject private UpdateCountersStorage countersStorage;
+
/**
*
*/
@@ -144,6 +147,8 @@ public class FatBuildDao {
buildsCache.put(buildIdToCacheKey(srvIdMaskHigh, buildId), newBuild);
histCollector.invalidateHistoryInMem(srvIdMaskHigh, newBuild);
+
+ countersStorage.increment(newBuild.branchName());
}
public static int[] extractChangeIds(@Nonnull ChangesList changesList) {
diff --git a/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/build/UpdateCountersStorage.java b/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/build/UpdateCountersStorage.java
index e8bd9a0..c9552bc 100644
--- a/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/build/UpdateCountersStorage.java
+++ b/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/build/UpdateCountersStorage.java
@@ -1,7 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.ignite.tcignited.build;
import java.util.Collection;
-import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
@@ -23,11 +38,13 @@ public class UpdateCountersStorage {
res.put(name, getIntegerForEntry(name).get());
}
+ System.err.println("Requested counters:" + res);
+
return res;
}
public static String getCountersHash(Map<Integer, Integer> counters) {
- return Integer.toHexString(U.safeAbs(counters.hashCode()));
+ return Integer.toHexString(U.safeAbs(counters == null ? 0 : counters.hashCode()));
}
public AtomicInteger getIntegerForEntry(int name) {
diff --git a/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/buildref/BuildRefDao.java b/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/buildref/BuildRefDao.java
index 74a91f9..368993e 100644
--- a/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/buildref/BuildRefDao.java
+++ b/tcbot-teamcity-ignited/src/main/java/org/apache/ignite/tcignited/buildref/BuildRefDao.java
@@ -52,6 +52,7 @@ import org.apache.ignite.tcbot.common.exeption.ExceptionUtil;
import org.apache.ignite.tcbot.common.interceptor.AutoProfiling;
import org.apache.ignite.tcbot.persistence.CacheConfigs;
import org.apache.ignite.tcbot.persistence.IStringCompactor;
+import org.apache.ignite.tcignited.build.UpdateCountersStorage;
import org.apache.ignite.tcservice.model.hist.BuildRef;
/**
@@ -70,6 +71,9 @@ public class BuildRefDao {
/** Compactor. */
@Inject private IStringCompactor compactor;
+ /** Update Counters for branch-related changes storage. */
+ @Inject private UpdateCountersStorage countersStorage;
+
/** Non persistence cache for all BuildRefsCompacted for particular branch.
* RunHistKey(ServerId||BranchId||suiteId)-> Build reference
*/
@@ -180,6 +184,11 @@ public class BuildRefDao {
buildRefsInMemCacheForAllBranch.invalidateAll(cacheForAllBranch);
buildRefsInMemCache.invalidateAll(setOfHistToClear);
+
+ setOfHistToClear.forEach(b -> {
+ int branch = b.branch();
+ countersStorage.increment(branch);
+ });
}
/**