Search in sources :

Example 1 with VisorIdleVerifyTaskArg

use of org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg in project ignite by apache.

the class IdleVerify method cacheIdleVerifyV2.

/**
 * @param client Client.
 * @param clientCfg Client configuration.
 */
private void cacheIdleVerifyV2(GridClient client, GridClientConfiguration clientCfg) throws GridClientException {
    VisorIdleVerifyTaskArg taskArg = new VisorIdleVerifyTaskArg(args.caches(), args.excludeCaches(), args.isSkipZeros(), args.getCacheFilterEnum(), args.idleCheckCrc());
    IdleVerifyResultV2 res = executeTask(client, VisorIdleVerifyTaskV2.class, taskArg, clientCfg);
    logParsedArgs(taskArg, System.out::print);
    res.print(System.out::print, false);
    if (F.isEmpty(res.exceptions()))
        return;
    try {
        File f = new File(U.resolveWorkDirectory(U.defaultWorkDirectory(), "", false), IDLE_VERIFY_FILE_PREFIX + LocalDateTime.now().format(TIME_FORMATTER) + ".txt");
        try (PrintWriter pw = new PrintWriter(f)) {
            res.print(pw::print, true);
            pw.flush();
            System.out.println("See log for additional information. " + f.getAbsolutePath());
        } catch (FileNotFoundException e) {
            System.err.println("Can't write exceptions to file " + f.getAbsolutePath() + " " + e.getMessage());
            e.printStackTrace();
        }
    } catch (IgniteCheckedException e) {
        System.err.println("Can't find work directory. " + e.getMessage());
        e.printStackTrace();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) FileNotFoundException(java.io.FileNotFoundException) VisorIdleVerifyTaskArg(org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 2 with VisorIdleVerifyTaskArg

use of org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg in project ignite by apache.

the class IdleVerify method legacyCacheIdleVerify.

/**
 * @param client Client.
 * @param clientCfg Client configuration.
 */
private void legacyCacheIdleVerify(GridClient client, GridClientConfiguration clientCfg, Logger logger) throws GridClientException {
    VisorIdleVerifyTaskResult res = executeTask(client, VisorIdleVerifyTask.class, new VisorIdleVerifyTaskArg(args.caches(), args.excludeCaches(), args.isSkipZeros(), args.getCacheFilterEnum(), args.idleCheckCrc()), clientCfg);
    Map<PartitionKey, List<PartitionHashRecord>> conflicts = res.getConflicts();
    if (conflicts.isEmpty()) {
        logger.info("The check procedure has finished, no conflicts have been found.");
        logger.info("");
    } else {
        logger.info("The check procedure has finished, found " + conflicts.size() + " conflict partitions.");
        logger.info("");
        for (Map.Entry<PartitionKey, List<PartitionHashRecord>> entry : conflicts.entrySet()) {
            logger.info("Conflict partition: " + entry.getKey());
            logger.info("Partition instances: " + entry.getValue());
        }
    }
}
Also used : VisorIdleVerifyTaskResult(org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskResult) PartitionKey(org.apache.ignite.internal.processors.cache.verify.PartitionKey) VisorIdleVerifyTaskArg(org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg) List(java.util.List) Map(java.util.Map)

Example 3 with VisorIdleVerifyTaskArg

use of org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg in project ignite by apache.

the class GridCommonAbstractTest method idleVerify.

/**
 * Compares checksums between primary and backup partitions of specified caches.
 * Works properly only on idle cluster - there may be false positive conflict reports if data in cluster is being
 * concurrently updated.
 *
 * @param ig Ignite instance.
 * @param caches Cache names (if null, all user caches will be verified).
 * @return Conflicts result.
 * @throws IgniteException If none caches or node found.
 */
protected IdleVerifyResultV2 idleVerify(Ignite ig, @Nullable String... caches) {
    log.info("Starting idleVerify ...");
    IgniteEx ig0 = (IgniteEx) ig;
    Set<String> cacheNames = new HashSet<>();
    if (F.isEmpty(caches))
        cacheNames.addAll(ig0.cacheNames());
    else
        Collections.addAll(cacheNames, caches);
    if (cacheNames.isEmpty())
        throw new IgniteException("None cache for checking.");
    ClusterNode node = !ig0.localNode().isClient() ? ig0.localNode() : ig0.cluster().forServers().forRandom().node();
    if (node == null)
        throw new IgniteException("None server node for verification.");
    VisorIdleVerifyTaskArg taskArg = new VisorIdleVerifyTaskArg(cacheNames);
    return ig.compute().execute(VisorIdleVerifyTaskV2.class.getName(), new VisorTaskArgument<>(node.id(), taskArg, false));
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteException(org.apache.ignite.IgniteException) IgniteEx(org.apache.ignite.internal.IgniteEx) VisorIdleVerifyTaskArg(org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg) VisorIdleVerifyTaskV2(org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskV2) HashSet(java.util.HashSet)

Example 4 with VisorIdleVerifyTaskArg

use of org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg in project ignite by apache.

the class IgniteClusterSnapshotCheckTest method testClusterSnapshotCheckHashesSameAsIdleVerifyHashes.

/**
 * @throws Exception If fails.
 */
@Test
public void testClusterSnapshotCheckHashesSameAsIdleVerifyHashes() throws Exception {
    Random rnd = new Random();
    CacheConfiguration<Integer, Value> ccfg = txCacheConfig(new CacheConfiguration<>(DEFAULT_CACHE_NAME));
    IgniteEx ignite = startGridsWithCache(1, CACHE_KEYS_RANGE, k -> new Value(new byte[rnd.nextInt(32768)]), ccfg);
    ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get();
    IdleVerifyResultV2 idleVerifyRes = ignite.compute().execute(new TestVisorBackupPartitionsTask(), new VisorIdleVerifyTaskArg(new HashSet<>(singletonList(ccfg.getName())), new HashSet<>(), false, CacheFilterEnum.USER, true));
    IdleVerifyResultV2 snpVerifyRes = ignite.compute().execute(new TestSnapshotPartitionsVerifyTask(), new SnapshotPartitionsVerifyTaskArg(new HashSet<>(), Collections.singletonMap(ignite.cluster().localNode(), Collections.singletonList(snp(ignite).readSnapshotMetadata(SNAPSHOT_NAME, (String) ignite.configuration().getConsistentId()))))).idleVerifyResult();
    Map<PartitionKeyV2, List<PartitionHashRecordV2>> idleVerifyHashes = jobResults.get(TestVisorBackupPartitionsTask.class);
    Map<PartitionKeyV2, List<PartitionHashRecordV2>> snpCheckHashes = jobResults.get(TestVisorBackupPartitionsTask.class);
    assertFalse(F.isEmpty(idleVerifyHashes));
    assertFalse(F.isEmpty(snpCheckHashes));
    assertEquals(idleVerifyHashes, snpCheckHashes);
    assertEquals(idleVerifyRes, snpVerifyRes);
}
Also used : VisorIdleVerifyTaskArg(org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg) Random(java.util.Random) PartitionKeyV2(org.apache.ignite.internal.processors.cache.verify.PartitionKeyV2) IgniteEx(org.apache.ignite.internal.IgniteEx) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) ArrayList(java.util.ArrayList) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

VisorIdleVerifyTaskArg (org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg)4 HashSet (java.util.HashSet)2 List (java.util.List)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 IdleVerifyResultV2 (org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 Collections.singletonList (java.util.Collections.singletonList)1 Map (java.util.Map)1 Random (java.util.Random)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 PartitionKey (org.apache.ignite.internal.processors.cache.verify.PartitionKey)1 PartitionKeyV2 (org.apache.ignite.internal.processors.cache.verify.PartitionKeyV2)1 VisorIdleVerifyTaskResult (org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskResult)1 VisorIdleVerifyTaskV2 (org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskV2)1 Test (org.junit.Test)1