Search in sources :

Example 6 with IdleVerifyResultV2

use of org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2 in project ignite by apache.

the class IgniteClusterSnapshotCheckTest method testClusterSnapshotCheckMissedGroup.

/**
 * @throws Exception If fails.
 */
@Test
public void testClusterSnapshotCheckMissedGroup() throws Exception {
    IgniteEx ignite = startGridsWithCache(3, dfltCacheCfg, CACHE_KEYS_RANGE);
    ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get();
    Path dir = Files.walk(snp(ignite).snapshotLocalDir(SNAPSHOT_NAME).toPath()).filter(d -> d.toFile().getName().equals(cacheDirName(dfltCacheCfg))).findFirst().orElseThrow(() -> new RuntimeException("Cache directory not found"));
    assertTrue(dir.toString(), dir.toFile().exists());
    assertTrue(U.delete(dir));
    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 groups");
}
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 7 with IdleVerifyResultV2

use of org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2 in project ignite by apache.

the class IgniteClusterSnapshotCheckTest method testClusterSnapshotCheckMissedMeta.

/**
 * @throws Exception If fails.
 */
@Test
public void testClusterSnapshotCheckMissedMeta() throws Exception {
    IgniteEx ignite = startGridsWithCache(3, dfltCacheCfg, CACHE_KEYS_RANGE);
    ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get();
    File[] smfs = snp(ignite).snapshotLocalDir(SNAPSHOT_NAME).listFiles((dir, name) -> name.toLowerCase().endsWith(SNAPSHOT_METAFILE_EXT));
    assertNotNull(smfs);
    assertTrue(smfs[0].toString(), smfs[0].exists());
    assertTrue(U.delete(smfs[0]));
    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(), "Some metadata is missing from the snapshot");
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) File(java.io.File) Test(org.junit.Test)

Example 8 with IdleVerifyResultV2

use of org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2 in project ignite by apache.

the class IgniteClusterSnapshotCheckTest method testClusterSnapshotCheckWithNodeFilter.

/**
 * @throws Exception If fails.
 */
@Test
public void testClusterSnapshotCheckWithNodeFilter() throws Exception {
    IgniteEx ig0 = startGridsWithoutCache(3);
    for (int i = 0; i < CACHE_KEYS_RANGE; i++) {
        ig0.getOrCreateCache(txCacheConfig(new CacheConfiguration<Integer, Integer>(DEFAULT_CACHE_NAME)).setNodeFilter(node -> node.consistentId().toString().endsWith("0"))).put(i, i);
    }
    ig0.snapshot().createSnapshot(SNAPSHOT_NAME).get();
    IdleVerifyResultV2 res = snp(ig0).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) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test)

Example 9 with IdleVerifyResultV2

use of org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2 in project ignite by apache.

the class IgniteClusterSnapshotCheckTest method testClusterSnapshotCheckOtherCluster.

/**
 * @throws Exception If fails.
 */
@Test
public void testClusterSnapshotCheckOtherCluster() throws Exception {
    IgniteEx ig0 = startGridsWithCache(3, dfltCacheCfg.setAffinity(new RendezvousAffinityFunction(false, 1)), CACHE_KEYS_RANGE);
    ig0.snapshot().createSnapshot(SNAPSHOT_NAME).get();
    stopAllGrids();
    // Cleanup persistence directory except created snapshots.
    Arrays.stream(new File(U.defaultWorkDirectory()).listFiles()).filter(f -> !f.getName().equals(DFLT_SNAPSHOT_DIRECTORY)).forEach(U::delete);
    Set<UUID> assigns = Collections.newSetFromMap(new ConcurrentHashMap<>());
    for (int i = 4; i < 7; i++) {
        startGrid(optimize(getConfiguration(getTestIgniteInstanceName(i)).setCacheConfiguration()));
        UUID locNodeId = grid(i).localNode().id();
        grid(i).context().io().addMessageListener(GridTopic.TOPIC_JOB, new GridMessageListener() {

            @Override
            public void onMessage(UUID nodeId, Object msg, byte plc) {
                if (msg instanceof GridJobExecuteRequest) {
                    GridJobExecuteRequest msg0 = (GridJobExecuteRequest) msg;
                    if (msg0.getTaskName().contains(SnapshotPartitionsVerifyTask.class.getName()))
                        assigns.add(locNodeId);
                }
            }
        });
    }
    IgniteEx ignite = grid(4);
    ignite.cluster().baselineAutoAdjustEnabled(false);
    ignite.cluster().state(ACTIVE);
    IdleVerifyResultV2 res = snp(ignite).checkSnapshot(SNAPSHOT_NAME).get();
    StringBuilder b = new StringBuilder();
    res.print(b::append, true);
    // GridJobExecuteRequest is not send to the local node.
    assertTrue("Number of jobs must be equal to the cluster size (except local node): " + assigns + ", count: " + assigns.size(), waitForCondition(() -> assigns.size() == 2, 5_000L));
    assertTrue(F.isEmpty(res.exceptions()));
    assertPartitionsSame(res);
    assertContains(log, b.toString(), "The check procedure has finished, no conflicts have been found");
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Arrays(java.util.Arrays) PartitionHashRecordV2(org.apache.ignite.internal.processors.cache.verify.PartitionHashRecordV2) Random(java.util.Random) IgniteEx(org.apache.ignite.internal.IgniteEx) CacheObjectBinaryProcessorImpl.binaryWorkDir(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.binaryWorkDir) ByteBuffer(java.nio.ByteBuffer) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) Collections.singletonList(java.util.Collections.singletonList) PagePartitionMetaIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIO) Map(java.util.Map) X(org.apache.ignite.internal.util.typedef.X) Path(java.nio.file.Path) FilePageStore(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore) Parameterized(org.junit.runners.Parameterized) SNAPSHOT_METAFILE_EXT(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_METAFILE_EXT) IgniteDataIntegrityViolationException(org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException) BinaryContext(org.apache.ignite.internal.binary.BinaryContext) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) MarshallerContextImpl.mappingFileStoreWorkDir(org.apache.ignite.internal.MarshallerContextImpl.mappingFileStoreWorkDir) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) UUID(java.util.UUID) CacheDataRow(org.apache.ignite.internal.processors.cache.persistence.CacheDataRow) ByteOrder(java.nio.ByteOrder) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) PartitionKeyV2(org.apache.ignite.internal.processors.cache.verify.PartitionKeyV2) GridJobExecuteRequest(org.apache.ignite.internal.GridJobExecuteRequest) CU(org.apache.ignite.internal.util.typedef.internal.CU) BinaryObjectImpl(org.apache.ignite.internal.binary.BinaryObjectImpl) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) FilePageStoreManager.getPartitionFileName(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.getPartitionFileName) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) FilePageStoreManager.cacheDirName(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheDirName) DR_NONE(org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteSnapshotManager.databaseRelativePath(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.databaseRelativePath) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) ComputeJobResult(org.apache.ignite.compute.ComputeJobResult) PageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO) CheckpointListener(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointListener) GridTestUtils.assertNotContains(org.apache.ignite.testframework.GridTestUtils.assertNotContains) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) VerifyBackupPartitionsTaskV2(org.apache.ignite.internal.processors.cache.verify.VerifyBackupPartitionsTaskV2) Before(org.junit.Before) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) F(org.apache.ignite.internal.util.typedef.F) VisorIdleVerifyTaskArg(org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg) Files(java.nio.file.Files) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridUnsafe(org.apache.ignite.internal.util.GridUnsafe) DFLT_SNAPSHOT_DIRECTORY(org.apache.ignite.configuration.IgniteConfiguration.DFLT_SNAPSHOT_DIRECTORY) TTL_ETERNAL(org.apache.ignite.internal.processors.cache.GridCacheUtils.TTL_ETERNAL) IOException(java.io.IOException) Test(org.junit.Test) File(java.io.File) CacheObjectBinaryProcessorImpl(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl) GridIterator(org.apache.ignite.internal.util.lang.GridIterator) GridTestUtils.assertContains(org.apache.ignite.testframework.GridTestUtils.assertContains) NONE(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.NONE) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) GridTopic(org.apache.ignite.internal.GridTopic) Paths(java.nio.file.Paths) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CacheFilterEnum(org.apache.ignite.internal.visor.verify.CacheFilterEnum) GroupPartitionId.getTypeByPartId(org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId.getTypeByPartId) Collections(java.util.Collections) TxState(org.apache.ignite.internal.processors.cache.mvcc.txlog.TxState) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) GridJobExecuteRequest(org.apache.ignite.internal.GridJobExecuteRequest) CU(org.apache.ignite.internal.util.typedef.internal.CU) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) UUID(java.util.UUID) File(java.io.File) Test(org.junit.Test)

Example 10 with IdleVerifyResultV2

use of org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2 in project ignite by apache.

the class IgniteClusterSnapshotCheckTest method testClusterSnapshotCheckCRCFail.

/**
 * @throws Exception If fails.
 */
@Test
public void testClusterSnapshotCheckCRCFail() throws Exception {
    IgniteEx ignite = startGridsWithCache(3, dfltCacheCfg.setAffinity(new RendezvousAffinityFunction(false, 1)), CACHE_KEYS_RANGE);
    ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get();
    corruptPartitionFile(ignite, SNAPSHOT_NAME, dfltCacheCfg, PART_ID);
    IdleVerifyResultV2 res = snp(ignite).checkSnapshot(SNAPSHOT_NAME).get();
    StringBuilder b = new StringBuilder();
    res.print(b::append, true);
    assertEquals(1, res.exceptions().size());
    assertContains(log, b.toString(), "The check procedure failed on 1 node.");
    Exception ex = res.exceptions().values().iterator().next();
    assertTrue(X.hasCause(ex, IgniteDataIntegrityViolationException.class));
}
Also used : IgniteDataIntegrityViolationException(org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) IgniteDataIntegrityViolationException(org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IOException(java.io.IOException) 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