[ 
https://issues.apache.org/jira/browse/IGNITE-10275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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<CompactBuildsInfo, Object> compactInfos() {
+    private IgniteCache<CompactContributionKey, CompactBuildsInfo> 
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<BuildsInfo> getInfos() {
         List<BuildsInfo> 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)

Reply via email to