use of org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceJobResult in project ignite by apache.
the class IgniteCacheGroupsWithRestartsTest method testFindAndDeleteGarbage.
/**
* @param doFindAndRemove Do find and remove.
*/
public void testFindAndDeleteGarbage(BiFunction<IgniteEx, Boolean, VisorFindAndDeleteGarbageInPersistenceTaskResult> doFindAndRemove) throws Exception {
IgniteEx ignite = startGrids(3);
prepareCachesAndData(ignite);
ignite.destroyCache(getCacheName(0));
assertNull(ignite.cachex(getCacheName(0)));
// waiting for cache.dat deletion
Thread.sleep(5_000);
stopGrid(2, true);
IgniteEx ex1 = startGrid(2);
assertNull(ignite.cachex(getCacheName(0)));
ignite.resetLostPartitions(Arrays.asList(getCacheName(0), getCacheName(1), getCacheName(2)));
awaitPartitionMapExchange();
VisorFindAndDeleteGarbageInPersistenceTaskResult taskResult = doFindAndRemove.apply(ex1, false);
VisorFindAndDeleteGarbageInPersistenceJobResult result = taskResult.result().get(ex1.localNode().id());
Assert.assertTrue(result.hasGarbage());
Assert.assertTrue(result.checkResult().get(CU.cacheId("group")).get(CU.cacheId(getCacheName(0))) > 0);
// removing garbage
result = doFindAndRemove.apply(ex1, true).result().get(ex1.localNode().id());
Assert.assertTrue(result.hasGarbage());
result = doFindAndRemove.apply(ex1, false).result().get(ex1.localNode().id());
Assert.assertFalse(result.hasGarbage());
}
use of org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceJobResult in project ignite by apache.
the class FindAndDeleteGarbage method execute.
/**
* {@inheritDoc}
*/
@Override
public Object execute(GridClientConfiguration clientCfg, Logger logger) throws Exception {
VisorFindAndDeleteGarbageInPersistenceTaskArg taskArg = new VisorFindAndDeleteGarbageInPersistenceTaskArg(args.groups(), args.delete(), args.nodeId() != null ? Collections.singleton(args.nodeId()) : null);
try (GridClient client = Command.startClient(clientCfg)) {
VisorFindAndDeleteGarbageInPersistenceTaskResult taskRes = executeTask(client, VisorFindAndDeleteGarbageInPersistenceTask.class, taskArg, clientCfg);
CommandLogger.printErrors(taskRes.exceptions(), "Scanning for garbage failed on nodes:", logger);
for (Map.Entry<UUID, VisorFindAndDeleteGarbageInPersistenceJobResult> nodeEntry : taskRes.result().entrySet()) {
if (!nodeEntry.getValue().hasGarbage()) {
logger.info("Node " + nodeEntry.getKey() + " - garbage not found.");
continue;
}
logger.info("Garbage found on node " + nodeEntry.getKey() + ":");
VisorFindAndDeleteGarbageInPersistenceJobResult value = nodeEntry.getValue();
Map<Integer, Map<Integer, Long>> grpPartErrorsCount = value.checkResult();
if (!grpPartErrorsCount.isEmpty()) {
for (Map.Entry<Integer, Map<Integer, Long>> entry : grpPartErrorsCount.entrySet()) {
for (Map.Entry<Integer, Long> e : entry.getValue().entrySet()) {
logger.info(INDENT + "Group=" + entry.getKey() + ", partition=" + e.getKey() + ", count of keys=" + e.getValue());
}
}
}
logger.info("");
}
return taskRes;
}
}
Aggregations