ivandasch commented on a change in pull request #9288:
URL: https://github.com/apache/ignite/pull/9288#discussion_r680945010



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/GridNearReadRepairAbstractFuture.java
##########
@@ -228,4 +254,103 @@ else if (!canRemap)
      * Reduces fut's results.
      */
     protected abstract void reduce();
+
+    /**
+     * @param fixedEntries Fixed map.
+     */
+    protected void recordConsistencyViolation(
+        Set<KeyCacheObject> inconsistentKeys,
+        Map<KeyCacheObject, EntryGetResult> fixedEntries
+    ) {
+        GridEventStorageManager evtMgr = ctx.gridEvents();
+
+        if (!evtMgr.isRecordable(EVT_CONSISTENCY_VIOLATION))
+            return;
+
+        Map<Object, Map<ClusterNode, 
CacheConsistencyViolationEvent.EntryInfo>> originalMap = new HashMap<>();
+
+        for (Map.Entry<ClusterNode, GridPartitionedGetFuture<KeyCacheObject, 
EntryGetResult>> pair : futs.entrySet()) {
+            ClusterNode node = pair.getKey();
+
+            GridPartitionedGetFuture<KeyCacheObject, EntryGetResult> fut = 
pair.getValue();
+
+            for (Map.Entry<KeyCacheObject, EntryGetResult> entry : 
fut.result().entrySet()) {
+                KeyCacheObject key = entry.getKey();
+
+                if (inconsistentKeys.contains(key)) {
+                    EntryGetResult res = entry.getValue();
+                    CacheEntryVersion ver = res.version();
+
+                    Object val = ctx.unwrapBinaryIfNeeded(res.value(), false, 
false, null);
+
+                    Map<ClusterNode, CacheConsistencyViolationEvent.EntryInfo> 
map =
+                        originalMap.computeIfAbsent(
+                            ctx.unwrapBinaryIfNeeded(key, false, false, null), 
k -> new HashMap<>());
+
+                    boolean primary = primaries.get(key).equals(fut.affNode());
+                    boolean correct = fixedEntries != null && 
fixedEntries.get(key).equals(res);
+
+                    map.put(node, new EventEventEntryInfo(val, ver, primary, 
correct));
+                }
+            }
+        }
+
+        evtMgr.record(new CacheConsistencyViolationEvent(
+            ctx.discovery().localNode(),
+            "Consistency violation fixed.",
+            originalMap));
+    }
+
+    /**
+     *
+     */
+    private static class EventEventEntryInfo implements 
CacheConsistencyViolationEvent.EntryInfo {
+        /** Value. */
+        Object val;

Review comment:
       lets make it final (class and fields)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to