use of org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2 in project ignite by apache.
the class GridCommandHandlerTest method testCheckSnapshot.
/**
* @throws Exception If fails.
*/
@Test
public void testCheckSnapshot() throws Exception {
String snpName = "snapshot_02052020";
IgniteEx ig = startGrid(0);
ig.cluster().state(ACTIVE);
createCacheAndPreload(ig, 1000);
snp(ig).createSnapshot(snpName).get();
CommandHandler h = new CommandHandler();
assertEquals(EXIT_CODE_OK, execute(h, "--snapshot", "check", snpName));
StringBuilder sb = new StringBuilder();
((IdleVerifyResultV2) h.getLastOperationResult()).print(sb::append, true);
assertContains(log, sb.toString(), "The check procedure has finished, no conflicts have been found");
}
use of org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2 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.processors.cache.verify.IdleVerifyResultV2 in project ignite by apache.
the class SnapshotPartitionsVerifyHandler method complete.
/**
* {@inheritDoc}
*/
@Override
public void complete(String name, Collection<SnapshotHandlerResult<Map<PartitionKeyV2, PartitionHashRecordV2>>> results) throws IgniteCheckedException {
Map<PartitionKeyV2, List<PartitionHashRecordV2>> clusterHashes = new HashMap<>();
Map<ClusterNode, Exception> errs = new HashMap<>();
for (SnapshotHandlerResult<Map<PartitionKeyV2, PartitionHashRecordV2>> res : results) {
if (res.error() != null) {
errs.put(res.node(), res.error());
continue;
}
for (Map.Entry<PartitionKeyV2, PartitionHashRecordV2> entry : res.data().entrySet()) clusterHashes.computeIfAbsent(entry.getKey(), v -> new ArrayList<>()).add(entry.getValue());
}
IdleVerifyResultV2 verifyResult = new IdleVerifyResultV2(clusterHashes, errs);
if (errs.isEmpty() && !verifyResult.hasConflicts())
return;
GridStringBuilder buf = new GridStringBuilder();
verifyResult.print(buf::a, true);
throw new IgniteCheckedException(buf.toString());
}
use of org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2 in project ignite by apache.
the class IgniteClusterSnapshotCheckTest method testClusterSnapshotCheckMissedPart.
/**
* @throws Exception If fails.
*/
@Test
public void testClusterSnapshotCheckMissedPart() throws Exception {
IgniteEx ignite = startGridsWithCache(3, dfltCacheCfg, CACHE_KEYS_RANGE);
ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get();
Path part0 = U.searchFileRecursively(snp(ignite).snapshotLocalDir(SNAPSHOT_NAME).toPath(), getPartitionFileName(0));
assertNotNull(part0);
assertTrue(part0.toString(), part0.toFile().exists());
assertTrue(part0.toFile().delete());
IdleVerifyResultV2 res = snp(ignite).checkSnapshot(SNAPSHOT_NAME).get();
StringBuilder b = new StringBuilder();
res.print(b::append, true);
assertFalse(F.isEmpty(res.exceptions()));
assertContains(log, b.toString(), "Snapshot data doesn't contain required cache group partition");
}
use of org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2 in project ignite by apache.
the class IgniteClusterSnapshotCheckTest method testClusterSnapshotCheck.
/**
* @throws Exception If fails.
*/
@Test
public void testClusterSnapshotCheck() throws Exception {
IgniteEx ignite = startGridsWithCache(3, dfltCacheCfg, CACHE_KEYS_RANGE);
startClientGrid();
ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get();
IdleVerifyResultV2 res = snp(ignite).checkSnapshot(SNAPSHOT_NAME).get();
StringBuilder b = new StringBuilder();
res.print(b::append, true);
assertTrue(F.isEmpty(res.exceptions()));
assertPartitionsSame(res);
assertContains(log, b.toString(), "The check procedure has finished, no conflicts have been found");
}
Aggregations