use of org.apache.ignite.internal.processors.cache.distributed.near.consistency.IgniteIrreparableConsistencyViolationException in project ignite by apache.
the class AbstractReadRepairTest method checkEvent.
/**
*/
protected void checkEvent(ReadRepairData data, IgniteIrreparableConsistencyViolationException e) {
Map<Object, Map<ClusterNode, CacheConsistencyViolationEvent.EntryInfo>> evtEntries = new HashMap<>();
Map<Object, Object> evtFixed = new HashMap<>();
Map<Integer, InconsistentMapping> inconsistent = data.data.entrySet().stream().filter(entry -> !entry.getValue().consistent).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
while (!evtEntries.keySet().equals(inconsistent.keySet())) {
if (!evtDeq.isEmpty()) {
CacheConsistencyViolationEvent evt = evtDeq.remove();
assertEquals(atomicityMode() == TRANSACTIONAL ? data.strategy : ReadRepairStrategy.CHECK_ONLY, evt.getStrategy());
// Optimistic and read committed transactions produce per key fixes.
evtEntries.putAll(evt.getEntries());
evtFixed.putAll(evt.getFixedEntries());
}
}
for (Map.Entry<Integer, InconsistentMapping> mapping : inconsistent.entrySet()) {
Integer key = mapping.getKey();
Integer fixed = mapping.getValue().fixed;
Integer primary = mapping.getValue().primary;
boolean repairable = mapping.getValue().repairable;
if (!repairable)
assertNotNull(e);
if (e == null) {
assertTrue(repairable);
assertTrue(evtFixed.containsKey(key));
assertEquals(fixed, evtFixed.get(key));
} else // Repairable but not repaired (because of irreparable entry at the same tx) entries.
if (e.irreparableKeys().contains(key) || (e.repairableKeys() != null && e.repairableKeys().contains(key)))
assertFalse(evtFixed.containsKey(key));
Map<ClusterNode, CacheConsistencyViolationEvent.EntryInfo> evtEntryInfos = evtEntries.get(key);
if (evtEntryInfos != null)
for (Map.Entry<ClusterNode, CacheConsistencyViolationEvent.EntryInfo> evtEntryInfo : evtEntryInfos.entrySet()) {
ClusterNode node = evtEntryInfo.getKey();
CacheConsistencyViolationEvent.EntryInfo info = evtEntryInfo.getValue();
if (info.isCorrect())
assertEquals(fixed, info.getValue());
if (info.isPrimary()) {
assertEquals(primary, info.getValue());
assertEquals(node, primaryNode(key, DEFAULT_CACHE_NAME).cluster().localNode());
}
}
}
int expectedFixedCnt = inconsistent.size() - (e != null ? (e.repairableKeys() != null ? e.repairableKeys().size() : 0) + e.irreparableKeys().size() : 0);
assertEquals(expectedFixedCnt, evtFixed.size());
assertTrue(evtDeq.isEmpty());
}
Aggregations