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();
}
}
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());
}
}
}
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));
}
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);
}
Aggregations