[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16694873#comment-16694873 ] ASF GitHub Bot commented on IGNITE-10275: - asfgit closed pull request #76: IGNITE-10275 Refactor of visa caching. URL: https://github.com/apache/ignite-teamcity-bot/pull/76 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): 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 c7f0e11a..ea8aa9bd 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 @@ -79,6 +79,7 @@ import org.apache.ignite.ci.util.CacheUpdateUtil; import org.apache.ignite.ci.util.CollectionUtil; import org.apache.ignite.ci.util.ObjectInterner; +import org.apache.ignite.ci.web.model.hist.VisasHistoryStorage; import org.apache.ignite.ci.web.rest.parms.FullQueryParams; import org.jetbrains.annotations.NotNull; @@ -116,6 +117,11 @@ @Inject private Ignite ignite; + +/** */ +@Inject +private VisasHistoryStorage visasHistStorage; + /** * Teamcity */ @@ -158,7 +164,8 @@ buildsCache(), this::addBuildOccurrenceToFailuresStat, buildsFailureRunStatCache(), testRunStatCache(), testFullCache(), -buildProblemsCache()); +buildProblemsCache(), +visasHistStorage.visas()); } @Override diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/db/DbMigrations.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/db/DbMigrations.java index a8307ffe..cc64e34d 100644 --- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/db/DbMigrations.java +++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/db/DbMigrations.java @@ -17,33 +17,38 @@ package org.apache.ignite.ci.db; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Consumer; import javax.cache.Cache; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.ci.ITeamcity; import org.apache.ignite.ci.IgnitePersistentTeamcity; -import org.apache.ignite.ci.analysis.Expirable; import org.apache.ignite.ci.analysis.RunStat; import org.apache.ignite.ci.analysis.SuiteInBranch; import org.apache.ignite.ci.analysis.TestInBranch; import org.apache.ignite.ci.issue.Issue; import org.apache.ignite.ci.issue.IssueKey; import org.apache.ignite.ci.issue.IssuesStorage; -import org.apache.ignite.ci.tcmodel.hist.BuildRef; +import org.apache.ignite.ci.observer.CompactBuildsInfo; import org.apache.ignite.ci.tcmodel.result.Build; import org.apache.ignite.ci.tcmodel.result.problems.ProblemOccurrences; import org.apache.ignite.ci.tcmodel.result.stat.Statistics; import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrenceFull; import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrences; +import org.apache.ignite.ci.web.model.CompactContributionKey; +import org.apache.ignite.ci.web.model.CompactVisa; +import org.apache.ignite.ci.web.model.CompactVisaRequest; +import org.apache.ignite.ci.web.model.hist.VisasHistoryStorage; import org.apache.ignite.ci.web.rest.build.GetBuildTestFailures; -import org.apache.ignite.ci.web.rest.pr.GetPrTestFailures; import org.apache.ignite.ci.web.rest.tracked.GetTrackedBranchTestResults; import org.apache.ignite.configuration.CacheConfiguration; import org.slf4j.Logger; @@ -104,6 +109,9 @@ @Deprecated public static final String TEAMCITY_BUILD_CACHE_NAME_OLD = "teamcityBuild"; +/** */ +@Deprecated +public static final String COMPACT_VISAS_HISTORY_CACHE_NAME = "compactVisasHistoryCache"; private static final String CHANGE_INFO_FULL = "changeInfoFull"; private static final String CHANGES_LIST = "changesList"; @@ -131,10 +139,45 @@ public void dataMigration( IgniteCache suiteHistCache, IgniteCache testHistCache, Cache testFullCache, -Cache problemsCache) { +Cache problemsCache, +Cache> visasCache) { doneMigrations = doneMigrationsCache(); +applyMigration(COMPACT_VISAS_HISTORY_CACHE_NAME + "-to-" +
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16694663#comment-16694663 ] ASF GitHub Bot commented on IGNITE-10275: - SomeFire commented on a change in pull request #76: IGNITE-10275 Refactor of visa caching. URL: https://github.com/apache/ignite-teamcity-bot/pull/76#discussion_r235369350 ## File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/db/TcHelperDb.java ## @@ -93,6 +93,23 @@ public static void stop(Ignite ignite) { Ignition.stop(ignite.name(), false); } +/** */ +@NotNull +public static CacheConfiguration getCacheV3Config(String name) { +CacheConfiguration ccfg = new CacheConfiguration<>(name); + +ccfg.setAffinity(new RendezvousAffinityFunction(false, 8)); + +return ccfg; +} + +/** */ +public static CacheConfiguration getCacheV3TxConfig(String name) { +return TcHelperDb.getCacheV3Config(name).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + +} + Review comment: ```suggestion ``` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16694662#comment-16694662 ] ASF GitHub Bot commented on IGNITE-10275: - SomeFire commented on a change in pull request #76: IGNITE-10275 Refactor of visa caching. URL: https://github.com/apache/ignite-teamcity-bot/pull/76#discussion_r235369867 ## File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java ## @@ -299,6 +294,12 @@ public SimpleResult commentJiraEx( if (!Strings.isNullOrEmpty(ticketFullName)) { BuildsInfo buildsInfo = new BuildsInfo(srvId, prov, ticketFullName, branchForTc); +VisaRequest lastVisaReq = visasHistoryStorage.getLastVisaRequest(buildsInfo.getContributionKey()); + +if (Objects.nonNull(lastVisaReq) && lastVisaReq.isObserving()) +return new SimpleResult("Jira wasn't commented. \"Re-run possible blockers & Comment JIRA\" was triggered for current branch." + Review comment: ```suggestion return new SimpleResult("Jira wasn't commented." + + " \"Re-run possible blockers & Comment JIRA\" was triggered for current branch." + ``` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16694661#comment-16694661 ] ASF GitHub Bot commented on IGNITE-10275: - SomeFire commented on a change in pull request #76: IGNITE-10275 Refactor of visa caching. URL: https://github.com/apache/ignite-teamcity-bot/pull/76#discussion_r235369173 ## File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/db/TcHelperDb.java ## @@ -93,6 +93,23 @@ public static void stop(Ignite ignite) { Ignition.stop(ignite.name(), false); } +/** */ +@NotNull +public static CacheConfiguration getCacheV3Config(String name) { +CacheConfiguration ccfg = new CacheConfiguration<>(name); + +ccfg.setAffinity(new RendezvousAffinityFunction(false, 8)); + +return ccfg; +} + +/** */ +public static CacheConfiguration getCacheV3TxConfig(String name) { +return TcHelperDb.getCacheV3Config(name).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + Review comment: ```suggestion ``` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16693123#comment-16693123 ] ASF GitHub Bot commented on IGNITE-10275: - SomeFire commented on a change in pull request #76: IGNITE-10275 Refactor of visa caching. URL: https://github.com/apache/ignite-teamcity-bot/pull/76#discussion_r234972281 ## File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java ## @@ -57,88 +48,69 @@ /** Logger. */ private static final Logger logger = LoggerFactory.getLogger(ObserverTask.class); -/** */ -public static final String BUILDS_CACHE_NAME = "compactBuildsInfosCache"; - /** Helper. */ @Inject private ITcHelper tcHelper; /** Helper. */ @Inject private IJiraIntegration jiraIntegration; -/** Ignite. */ -@Inject private Ignite ignite; - /** */ @Inject private VisasHistoryStorage visasHistStorage; /** */ -@Inject private IStringCompactor strCompactor; +private ReentrantLock observationLock = new ReentrantLock(); /** */ -private ReentrantLock observationLock = new ReentrantLock(); +private Map infos = new HashMap<>(); /** */ ObserverTask() { } /** */ -private IgniteCache compactInfos() { -return ignite.getOrCreateCache(TcHelperDb.getCacheV2TxConfig(BUILDS_CACHE_NAME)); +public void init() { +visasHistStorage.getLastVisas().stream() +.filter(req -> req.isObserving()) +.forEach(req -> infos.put(req.getInfo().getContributionKey(), req.getInfo())); } /** */ @Nullable public BuildsInfo getInfo(ContributionKey key) { -CompactBuildsInfo compactBuildsInfo = compactInfos().get(new CompactContributionKey(key, strCompactor)); - -return Objects.isNull(compactBuildsInfo) ? null : compactBuildsInfo.toBuildInfo(strCompactor); +return infos.get(key); } /** */ public Collection getInfos() { -List buildsInfos = new ArrayList<>(); - -compactInfos().forEach(entry -> buildsInfos.add(entry.getValue().toBuildInfo(strCompactor))); - -return buildsInfos; +return infos.values(); } /** */ public void addInfo(BuildsInfo info) { -visasHistStorage.put(new VisaRequest(info)); +visasHistStorage.updateLastVisaRequest(info.getContributionKey(), req -> req.setObservingStatus(false)); Review comment: Add observation lock here. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16692864#comment-16692864 ] ASF GitHub Bot commented on IGNITE-10275: - ololo3000 opened a new pull request #76: IGNITE-10275 Refactor of visa caching, URL: https://github.com/apache/ignite-teamcity-bot/pull/76 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16691946#comment-16691946 ] ASF GitHub Bot commented on IGNITE-10275: - asfgit closed pull request #74: IGNITE-10275 Refactor of visa caching. Jira spam fix. URL: https://github.com/apache/ignite-teamcity-bot/pull/74 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/TcHelper.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/TcHelper.java index f3ae04aa..7df50747 100644 --- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/TcHelper.java +++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/TcHelper.java @@ -178,8 +178,12 @@ private BranchesTracked getTrackedBranches() { String comment = generateJiraComment(suitesStatuses, build.webUrl); -blockers = suitesStatuses.stream().mapToInt(suite -> -suite.testFailures.size()).sum(); +blockers = suitesStatuses.stream().mapToInt(suite -> { +if (suite.testFailures.isEmpty()) +return 1; + +return suite.testFailures.size();}) +.sum(); res = objectMapper.readValue(teamcity.sendJiraComment(ticket, comment), JiraCommentResponse.class); } diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/BuildObserver.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/BuildObserver.java index cf294684..b4686f74 100644 --- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/BuildObserver.java +++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/BuildObserver.java @@ -17,19 +17,24 @@ package org.apache.ignite.ci.observer; -import java.util.Collection; import java.util.Objects; import java.util.Timer; import javax.inject.Inject; +import org.apache.ignite.ci.IAnalyticsEnabledTeamcity; +import org.apache.ignite.ci.ITcHelper; import org.apache.ignite.ci.tcmodel.result.Build; import org.apache.ignite.ci.user.ICredentialsProv; -import org.apache.ignite.ci.web.model.VisaRequest; -import org.apache.ignite.ci.web.model.hist.VisasHistoryStorage; +import org.apache.ignite.ci.web.model.ContributionKey; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * */ public class BuildObserver { +/** Logger. */ +private static final Logger logger = LoggerFactory.getLogger(BuildObserver.class); + /** Time between observing actions in milliseconds. */ private static final long PERIOD = 10 * 60 * 1_000; @@ -39,8 +44,8 @@ /** Task, which should be done periodically. */ private ObserverTask observerTask; -/** Visas History Storage. */ -@Inject private VisasHistoryStorage visasStorage; +/** Helper. */ +@Inject private ITcHelper tcHelper; /** */ @@ -60,6 +65,25 @@ public void stop() { timer.cancel(); } +/** */ +public ObserverTask getObserverTask() { +return observerTask; +} + +/** */ +public boolean stopObservation(ContributionKey key) { +try { +observerTask.removeBuildInfo(key); + +return true; +} +catch (Exception e) { +logger.error("Observation stop: " + e.getMessage(), e); + +return false; +} +} + /** * @param srvId Server id. * @param prov Credentials. @@ -69,28 +93,26 @@ public void stop() { public void observe(String srvId, ICredentialsProv prov, String ticket, String branchForTc, Build... builds) { BuildsInfo buildsInfo = new BuildsInfo(srvId, prov, ticket, branchForTc, builds); -visasStorage.put(new VisaRequest(buildsInfo)); - observerTask.addInfo(buildsInfo); } /** - * @param srvId Server id. - * @param branch Branch. + * @param key {@code Contribution Key}. */ -public String getObservationStatus(String srvId, String branch) { +public String getObservationStatus(ContributionKey key) { StringBuilder sb = new StringBuilder(); -Collection builds = observerTask.getInfos(); +BuildsInfo buildsInfo = observerTask.getInfo(key); + +ICredentialsProv creds = tcHelper.getServerAuthorizerCreds(); + +IAnalyticsEnabledTeamcity teamcity = tcHelper.server(key.srvId, creds); -for (BuildsInfo bi : builds) { -if (Objects.equals(bi.branchForTc, branch) -&& Objects.equals(bi.srvId, srvId)) { -sb.append(bi.ticket).append(" to be commented, waiting for builds. "); -
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16691662#comment-16691662 ] ASF GitHub Bot commented on IGNITE-10275: - SomeFire commented on a change in pull request #74: IGNITE-10275 Refactor of visa caching. Jira spam fix. URL: https://github.com/apache/ignite-teamcity-bot/pull/74#discussion_r234598100 ## File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java ## @@ -63,33 +70,78 @@ @Inject private Ignite ignite; /** */ -@Inject private VisasHistoryStorage visasHistoryStorage; +@Inject private VisasHistoryStorage visasHistStorage; /** */ @Inject private IStringCompactor strCompactor; +/** */ +private ReentrantLock observationLock = new ReentrantLock(); + /** */ ObserverTask() { } /** */ -private IgniteCache compactInfos() { +private IgniteCache compactInfos() { return ignite.getOrCreateCache(TcHelperDb.getCacheV2TxConfig(BUILDS_CACHE_NAME)); } +/** */ +@Nullable public BuildsInfo getInfo(ContributionKey key) { +CompactBuildsInfo compactBuildsInfo = compactInfos().get(new CompactContributionKey(key, strCompactor)); + +return Objects.isNull(compactBuildsInfo) ? null : compactBuildsInfo.toBuildInfo(strCompactor); +} + + /** */ public Collection getInfos() { List buildsInfos = new ArrayList<>(); -compactInfos().forEach(entry -> buildsInfos.add(entry.getKey().toBuildInfo(strCompactor))); +compactInfos().forEach(entry -> buildsInfos.add(entry.getValue().toBuildInfo(strCompactor))); return buildsInfos; } /** */ public void addInfo(BuildsInfo info) { -compactInfos().put(new CompactBuildsInfo(info, strCompactor), new Object()); +visasHistStorage.put(new VisaRequest(info)); + +compactInfos().put(new CompactContributionKey(info.getContributionKey(), strCompactor), +new CompactBuildsInfo(info, strCompactor)); +} + +/** */ +private void removeBuildInfo(CompactContributionKey key) { +try { +BuildsInfo buildsInfo = compactInfos().get(key).toBuildInfo(strCompactor); + +boolean rmv = compactInfos().remove(key); + +Preconditions.checkState(rmv, "Key not found: " + key.toContributionKey(strCompactor).toString()); +} +catch (Exception e) { +logger.error("Cache remove: " + e.getMessage(), e); + +throw new RuntimeException("Observer queue: " + +getInfos().stream().map(bi -> bi.getContributionKey().toString()) +.collect(Collectors.joining(", ")) + +" Error: " + X.getFullStackTrace(e)); +} +} + +/** */ +public void removeBuildInfo(ContributionKey key) { Review comment: Move public method higher than private. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16691660#comment-16691660 ] ASF GitHub Bot commented on IGNITE-10275: - SomeFire commented on a change in pull request #74: IGNITE-10275 Refactor of visa caching. Jira spam fix. URL: https://github.com/apache/ignite-teamcity-bot/pull/74#discussion_r234602866 ## File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/ContributionKey.java ## @@ -17,23 +17,32 @@ package org.apache.ignite.ci.web.model; +import org.apache.ignite.ci.teamcity.ignited.IStringCompactor; + /** * */ public class ContributionKey { /** */ public final String srvId; -/** */ -public final String ticket; - /** */ public final String branchForTc; /** */ -public ContributionKey(String srvId, String ticket, String branchForTc) { +public ContributionKey(String srvId, String branchForTc) { this.branchForTc = branchForTc; this.srvId = srvId; -this.ticket = ticket; +} + +/** */ +public ContributionKey(CompactContributionKey key, IStringCompactor strCompactor) { +this.branchForTc = strCompactor.getStringFromId(key.branchForTc); +this.srvId = strCompactor.getStringFromId(key.srvId); +} + +/** */ Review comment: ```suggestion /** {@inheritDoc} */ ``` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16691661#comment-16691661 ] ASF GitHub Bot commented on IGNITE-10275: - SomeFire commented on a change in pull request #74: IGNITE-10275 Refactor of visa caching. Jira spam fix. URL: https://github.com/apache/ignite-teamcity-bot/pull/74#discussion_r234600605 ## File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/BuildObserver.java ## @@ -69,28 +93,27 @@ public void stop() { public void observe(String srvId, ICredentialsProv prov, String ticket, String branchForTc, Build... builds) { BuildsInfo buildsInfo = new BuildsInfo(srvId, prov, ticket, branchForTc, builds); -visasStorage.put(new VisaRequest(buildsInfo)); - observerTask.addInfo(buildsInfo); } /** * @param srvId Server id. * @param branch Branch. */ -public String getObservationStatus(String srvId, String branch) { +public String getObservationStatus(ContributionKey key) { Review comment: Update javadocs too. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16691659#comment-16691659 ] ASF GitHub Bot commented on IGNITE-10275: - SomeFire commented on a change in pull request #74: IGNITE-10275 Refactor of visa caching. Jira spam fix. URL: https://github.com/apache/ignite-teamcity-bot/pull/74#discussion_r234597233 ## File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java ## @@ -63,33 +70,78 @@ @Inject private Ignite ignite; /** */ -@Inject private VisasHistoryStorage visasHistoryStorage; +@Inject private VisasHistoryStorage visasHistStorage; /** */ @Inject private IStringCompactor strCompactor; +/** */ +private ReentrantLock observationLock = new ReentrantLock(); + /** */ ObserverTask() { } /** */ -private IgniteCache compactInfos() { +private IgniteCache compactInfos() { return ignite.getOrCreateCache(TcHelperDb.getCacheV2TxConfig(BUILDS_CACHE_NAME)); } +/** */ +@Nullable public BuildsInfo getInfo(ContributionKey key) { +CompactBuildsInfo compactBuildsInfo = compactInfos().get(new CompactContributionKey(key, strCompactor)); + +return Objects.isNull(compactBuildsInfo) ? null : compactBuildsInfo.toBuildInfo(strCompactor); +} + + /** */ public Collection getInfos() { List buildsInfos = new ArrayList<>(); -compactInfos().forEach(entry -> buildsInfos.add(entry.getKey().toBuildInfo(strCompactor))); +compactInfos().forEach(entry -> buildsInfos.add(entry.getValue().toBuildInfo(strCompactor))); return buildsInfos; } /** */ public void addInfo(BuildsInfo info) { -compactInfos().put(new CompactBuildsInfo(info, strCompactor), new Object()); +visasHistStorage.put(new VisaRequest(info)); + +compactInfos().put(new CompactContributionKey(info.getContributionKey(), strCompactor), +new CompactBuildsInfo(info, strCompactor)); +} + +/** */ +private void removeBuildInfo(CompactContributionKey key) { +try { +BuildsInfo buildsInfo = compactInfos().get(key).toBuildInfo(strCompactor); Review comment: Not used variable. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16691658#comment-16691658 ] ASF GitHub Bot commented on IGNITE-10275: - SomeFire commented on a change in pull request #74: IGNITE-10275 Refactor of visa caching. Jira spam fix. URL: https://github.com/apache/ignite-teamcity-bot/pull/74#discussion_r234601602 ## File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java ## @@ -56,10 +59,20 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static org.apache.ignite.ci.observer.BuildsInfo.CANCELLED_STATUS; +import static org.apache.ignite.ci.observer.BuildsInfo.FINISHED_STATUS; +import static org.apache.ignite.ci.observer.BuildsInfo.RUNNING_STATUS; + /** * Provides method for TC Bot Visa obtaining */ public class TcBotTriggerAndSignOffService { +/** */ +private static final ThreadLocal THREAD_FORMATTER = new ThreadLocal() { Review comment: Why thread local? Looks like we need a simple object. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16691417#comment-16691417 ] ASF GitHub Bot commented on IGNITE-10275: - ololo3000 opened a new pull request #74: IGNITE-10275 Refactor of visa caching. Jira spam fix. URL: https://github.com/apache/ignite-teamcity-bot/pull/74 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16688027#comment-16688027 ] ASF GitHub Bot commented on IGNITE-10275: - asfgit closed pull request #72: IGNITE-10275 Jira spam fast fix URL: https://github.com/apache/ignite-teamcity-bot/pull/72 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java index 5ad13505..86768688 100644 --- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java +++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/observer/ObserverTask.java @@ -141,7 +141,7 @@ protected String runObserverTask() { if (info.isFinishedWithFailures(teamcity)) { boolean rmv = compactInfos().remove(compactInfo); - + Preconditions.checkState(rmv, "Key not found: " + compactInfo); logger.error("JIRA will not be commented." + @@ -157,34 +157,35 @@ protected String runObserverTask() { continue; } -ICredentialsProv creds = tcHelper.getServerAuthorizerCreds(); +try { +rmvdVisas.add(objMapper.writeValueAsString(compactInfo)); +} +catch (Exception e) { +logger.error("JSON string parse failed: " + e.getMessage(), e); -Visa visa = jiraIntegration.notifyJira(info.srvId, creds, info.buildTypeId, -info.branchForTc, info.ticket); +return "Exception while JSON parsing: " + e.getClass().getSimpleName() + ": " + e.getMessage(); +} - visasHistoryStorage.updateVisaRequestRes(info.getContributionKey(), info.date, visa); +try { +boolean rmv = compactInfos().remove(compactInfo); -if (visa.isSuccess()) { -ticketsNotified.add(info.ticket); +if (!rmv) +continue; +} +catch (Exception e) { +logger.error("cache remove: " + e.getMessage(), e); + +return X.getFullStackTrace(e); +} -try { -rmvdVisas.add(objMapper.writeValueAsString(compactInfo)); -} -catch (Exception e) { -logger.error("JSON string parse failed: " + e.getMessage(), e); +ICredentialsProv creds = tcHelper.getServerAuthorizerCreds(); -return "Exception while JSON parsing: " + e.getClass().getSimpleName() + ": " + e.getMessage(); -} +Visa visa = jiraIntegration.notifyJira(info.srvId, creds, info.buildTypeId, +info.branchForTc, info.ticket); -try { -compactInfos().remove(compactInfo); -} -catch (Exception e) { -logger.error("cache remove: " + e.getMessage(), e); + visasHistoryStorage.updateVisaRequestRes(info.getContributionKey(), info.date, visa); -return X.getFullStackTrace(e); -} -} +ticketsNotified.add(info.ticket); } return "Checked " + checkedBuilds + " not finished " + notFinishedBuilds + " notified: " + ticketsNotified + This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by
[jira] [Commented] (IGNITE-10275) [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed
[ https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16688013#comment-16688013 ] ASF GitHub Bot commented on IGNITE-10275: - ololo3000 opened a new pull request #72: IGNITE-10275 Jira spam fast fix URL: https://github.com/apache/ignite-teamcity-bot/pull/72 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [TC Bot] Several JIRA comments are issued in case ignite.cache.remove failed > > > Key: IGNITE-10275 > URL: https://issues.apache.org/jira/browse/IGNITE-10275 > Project: Ignite > Issue Type: Task >Reporter: Dmitriy Pavlov >Assignee: PetrovMikhail >Priority: Major > > Examples of spam: > - https://issues.apache.org/jira/browse/IGNITE-9308 > - https://issues.apache.org/jira/browse/IGNITE-10141 > org/apache/ignite/ci/observer/ObserverTask.java:179 > org.apache.ignite.IgniteCache#remove(K) > returns false, so bot tries to re-comment ticket in next cycle. > It is possible as a fast fix at first check removes result, as a full fix we > can refactor visa requests queue to some new (probably synthetic key). -- This message was sent by Atlassian JIRA (v7.6.3#76005)