Search in sources :

Example 1 with VisorFindAndDeleteGarbageInPersistenceTaskResult

use of org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskResult 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());
}
Also used : VisorFindAndDeleteGarbageInPersistenceJobResult(org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceJobResult) IgniteEx(org.apache.ignite.internal.IgniteEx) VisorFindAndDeleteGarbageInPersistenceTaskResult(org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskResult)

Example 2 with VisorFindAndDeleteGarbageInPersistenceTaskResult

use of org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskResult in project ignite by apache.

the class IgniteCacheGroupsWithRestartsTest method executeTask.

/**
 * @param ignite Ignite to execute task on.
 * @param deleteFoundGarbage If clearing mode should be used.
 * @return Result of task run.
 */
private VisorFindAndDeleteGarbageInPersistenceTaskResult executeTask(IgniteEx ignite, boolean deleteFoundGarbage) {
    VisorFindAndDeleteGarbageInPersistenceTaskArg group = new VisorFindAndDeleteGarbageInPersistenceTaskArg(Collections.singleton(GROUP), deleteFoundGarbage, null);
    UUID id = ignite.localNode().id();
    VisorTaskArgument arg = new VisorTaskArgument(id, group, true);
    VisorFindAndDeleteGarbageInPersistenceTaskResult result = ignite.compute().execute(VisorFindAndDeleteGarbageInPersistenceTask.class, arg);
    return result;
}
Also used : VisorFindAndDeleteGarbageInPersistenceTaskArg(org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskArg) VisorFindAndDeleteGarbageInPersistenceTaskResult(org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskResult) VisorTaskArgument(org.apache.ignite.internal.visor.VisorTaskArgument) UUID(java.util.UUID)

Example 3 with VisorFindAndDeleteGarbageInPersistenceTaskResult

use of org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskResult 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;
    }
}
Also used : VisorFindAndDeleteGarbageInPersistenceJobResult(org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceJobResult) VisorFindAndDeleteGarbageInPersistenceTaskArg(org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskArg) VisorFindAndDeleteGarbageInPersistenceTaskResult(org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskResult) GridClient(org.apache.ignite.internal.client.GridClient) UUID(java.util.UUID) Map(java.util.Map)

Aggregations

VisorFindAndDeleteGarbageInPersistenceTaskResult (org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskResult)3 UUID (java.util.UUID)2 VisorFindAndDeleteGarbageInPersistenceJobResult (org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceJobResult)2 VisorFindAndDeleteGarbageInPersistenceTaskArg (org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskArg)2 Map (java.util.Map)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 GridClient (org.apache.ignite.internal.client.GridClient)1 VisorTaskArgument (org.apache.ignite.internal.visor.VisorTaskArgument)1