Search in sources :

Example 1 with VisorFindAndDeleteGarbageInPersistenceTaskArg

use of org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskArg 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 2 with VisorFindAndDeleteGarbageInPersistenceTaskArg

use of org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskArg 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

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