Search in sources :

Example 1 with IdleVerifyResultV2

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");
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) IgniteCacheGroupsWithRestartsTest(org.apache.ignite.internal.processors.cache.persistence.db.IgniteCacheGroupsWithRestartsTest) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest) Test(org.junit.Test)

Example 2 with IdleVerifyResultV2

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();
    }
}
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 3 with IdleVerifyResultV2

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());
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) GridStringBuilder(org.apache.ignite.internal.util.GridStringBuilder) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IOException(java.io.IOException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) PartitionKeyV2(org.apache.ignite.internal.processors.cache.verify.PartitionKeyV2) PartitionHashRecordV2(org.apache.ignite.internal.processors.cache.verify.PartitionHashRecordV2) ArrayList(java.util.ArrayList) List(java.util.List) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 4 with IdleVerifyResultV2

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");
}
Also used : Path(java.nio.file.Path) IgniteSnapshotManager.databaseRelativePath(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.databaseRelativePath) IgniteEx(org.apache.ignite.internal.IgniteEx) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) Test(org.junit.Test)

Example 5 with IdleVerifyResultV2

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");
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) Test(org.junit.Test)

Aggregations

IdleVerifyResultV2 (org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2)21 IgniteEx (org.apache.ignite.internal.IgniteEx)17 Test (org.junit.Test)16 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 IOException (java.io.IOException)5 Path (java.nio.file.Path)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 IgniteException (org.apache.ignite.IgniteException)5 IgniteSnapshotManager.databaseRelativePath (org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.databaseRelativePath)5 File (java.io.File)4 Random (java.util.Random)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)4 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)4 IgniteDataIntegrityViolationException (org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException)4 PartitionKeyV2 (org.apache.ignite.internal.processors.cache.verify.PartitionKeyV2)4 VisorIdleVerifyTaskArg (org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg)4 Collections.singletonList (java.util.Collections.singletonList)3 HashSet (java.util.HashSet)3