RepairRequestTask extends ComputeTaskAdapter<RepairRequest, ExecutionResult<RepairResult>> { @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) { ComputeJobResultPolicy superRes = super.result(res, rcvd); if (superRes == ComputeJobResultPolicy.FAILOVER) { superRes = ComputeJobResultPolicy.WAIT; log.warning("CollectPartitionEntryHashesJob failed on node " + "[consistentId=" + res.getNode().consistentId() + "]", res.getException()); } return superRes; }  @Override Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, RepairRequest arg); @Override ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd); @Override ExecutionResult<RepairResult> reduce(
        List<ComputeJobResult> results); static final int MAX_REPAIR_ATTEMPTS; }
@Test public void testNotFullSetOfOldKeysUsesUserRepairAlg() throws IllegalAccessException { Map<VersionedKey, Map<UUID, VersionedValue>> data = new HashMap<>(); VersionedKey key = new VersionedKey(null, new KeyCacheObjectImpl(), null); Map<UUID, VersionedValue> keyVers = new HashMap<>(); keyVers.put(NODE_1, versionedValue("1", 1)); keyVers.put(NODE_2, versionedValue("2", 2)); keyVers.put(NODE_3, versionedValue("2", 2)); keyVers.put(NODE_4, versionedValue("4", 4)); data.put(key, keyVers); IgniteEx igniteMock = igniteMock(true); ExecutionResult<RepairResult> res = injectIgnite(repairJob(data, 5, 1), igniteMock).execute(); assertTrue(res.result().keysToRepair().isEmpty()); assertEquals(1, res.result().repairedKeys().size()); Map.Entry<VersionedKey, RepairMeta> entry = res.result() .repairedKeys().entrySet().iterator().next(); assertEquals(keyVers, entry.getValue().getPreviousValue()); RepairMeta repairMeta = entry.getValue(); assertTrue(repairMeta.fixed()); assertEquals(repairAlgorithm, repairMeta.repairAlg()); switch (repairAlgorithm) { case LATEST: assertCacheObjectEquals(keyVers.get(NODE_4).value(), repairMeta.value()); break; case PRIMARY: assertCacheObjectEquals(keyVers.get(NODE_1).value(), repairMeta.value()); break; case MAJORITY: assertCacheObjectEquals(keyVers.get(NODE_2).value(), repairMeta.value()); break; case REMOVE: assertCacheObjectEquals(null, repairMeta.value()); break; } }
@Test public void testFullOwnerSetNotMaxAttempt() throws IllegalAccessException { Map<VersionedKey, Map<UUID, VersionedValue>> data = new HashMap<>(); VersionedKey key = new VersionedKey(null, new KeyCacheObjectImpl(), null); Map<UUID, VersionedValue> keyVers = new HashMap<>(); keyVers.put(NODE_1, versionedValue("1", 1)); keyVers.put(NODE_2, versionedValue("2", 2)); data.put(key, keyVers); IgniteEx igniteMock = igniteMock(fixed); ExecutionResult<RepairResult> res = injectIgnite(repairJob(data, 2, 1), igniteMock).execute(); if (fixed) { assertTrue(res.result().keysToRepair().isEmpty()); assertEquals(1, res.result().repairedKeys().size()); Map.Entry<VersionedKey, RepairMeta> entry = res.result() .repairedKeys().entrySet().iterator().next(); assertEquals(keyVers, entry.getValue().getPreviousValue()); RepairMeta repairMeta = entry.getValue(); assertTrue(repairMeta.fixed()); assertEquals(LATEST, repairMeta.repairAlg()); } else { assertTrue(res.result().repairedKeys().isEmpty()); assertEquals(1, res.result().keysToRepair().size()); Map.Entry<VersionedKey, Map<UUID, VersionedValue>> entry = res.result() .keysToRepair().entrySet().iterator().next(); assertEquals(keyVers, entry.getValue()); } }
@Test public void testFullOwnerSetMaxAttempt() throws IllegalAccessException { Map<VersionedKey, Map<UUID, VersionedValue>> data = new HashMap<>(); VersionedKey key = new VersionedKey(null, new KeyCacheObjectImpl(), null); Map<UUID, VersionedValue> keyVers = new HashMap<>(); keyVers.put(NODE_1, versionedValue("1", 1)); keyVers.put(NODE_2, versionedValue("2", 2)); keyVers.put(NODE_3, versionedValue("2", 2)); keyVers.put(NODE_4, versionedValue("4", 4)); data.put(key, keyVers); IgniteEx igniteMock = igniteMock(true); final int lastAttempt = 3; ExecutionResult<RepairResult> res = injectIgnite(repairJob(data, 4, lastAttempt), igniteMock).execute(); assertTrue(res.result().keysToRepair().isEmpty()); assertEquals(1, res.result().repairedKeys().size()); Map.Entry<VersionedKey, RepairMeta> entry = res.result() .repairedKeys().entrySet().iterator().next(); assertEquals(keyVers, entry.getValue().getPreviousValue()); RepairMeta repairMeta = entry.getValue(); assertTrue(repairMeta.fixed()); assertEquals(repairAlgorithm, repairMeta.repairAlg()); switch (repairAlgorithm) { case LATEST: assertCacheObjectEquals(keyVers.get(NODE_4).value(), repairMeta.value()); break; case PRIMARY: assertCacheObjectEquals(keyVers.get(NODE_1).value(), repairMeta.value()); break; case MAJORITY: assertCacheObjectEquals(keyVers.get(NODE_2).value(), repairMeta.value()); break; case REMOVE: assertCacheObjectEquals(null, repairMeta.value()); break; } }