Search in sources :

Example 26 with GridCacheDatabaseSharedManager

use of org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager in project ignite by apache.

the class WalRecoveryTxLogicalRecordsTest method testRecoveryRandomPutRemove.

/**
 * @throws Exception If failed.
 */
public void testRecoveryRandomPutRemove() throws Exception {
    try {
        pageSize = 1024;
        extraCcfg = new CacheConfiguration(CACHE2_NAME);
        extraCcfg.setAffinity(new RendezvousAffinityFunction(false, PARTS));
        Ignite ignite = startGrid(0);
        ignite.cluster().active(true);
        GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) ((IgniteEx) ignite).context().cache().context().database();
        dbMgr.enableCheckpoints(false).get();
        IgniteCache<Integer, IndexedValue> cache1 = ignite.cache(CACHE_NAME);
        IgniteCache<Object, Object> cache2 = ignite.cache(CACHE2_NAME);
        final int KEYS1 = 100;
        for (int i = 0; i < KEYS1; i++) cache1.put(i, new IndexedValue(i));
        for (int i = 0; i < KEYS1; i++) {
            if (i % 2 == 0)
                cache1.remove(i);
        }
        ThreadLocalRandom rnd = ThreadLocalRandom.current();
        for (int i = 0; i < KEYS1; i++) {
            cache2.put(i, new byte[rnd.nextInt(512)]);
            if (rnd.nextBoolean())
                cache2.put(i, new byte[rnd.nextInt(512)]);
            if (rnd.nextBoolean())
                cache2.remove(i);
        }
        ignite.close();
        ignite = startGrid(0);
        ignite.cluster().active(true);
        ignite.cache(CACHE_NAME).put(1, new IndexedValue(0));
    } finally {
        stopAllGrids();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IgniteEx(org.apache.ignite.internal.IgniteEx) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) Ignite(org.apache.ignite.Ignite) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 27 with GridCacheDatabaseSharedManager

use of org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager in project ignite by apache.

the class IgniteDbSingleNodeWithIndexingWalRestoreTest method testRegularClassesRestored.

/**
 * Test for regular objects stored in cache with compactFooter=true setting
 * (no metainformation to deserialize values is stored with values themselves).
 */
public void testRegularClassesRestored() throws Exception {
    IgniteEx ig = startGrid(0);
    ig.active(true);
    GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) ig.context().cache().context().database();
    dbMgr.enableCheckpoints(false).get();
    IgniteCache<Object, Object> cache = ig.cache("indexedCache");
    for (int i = 0; i < ENTRIES_COUNT; i++) cache.put(i, new RegularPerson("RegularPeter" + i));
    stopGrid(0, true);
    ig = startGrid(0);
    ig.active(true);
    cache = ig.cache("indexedCache");
    for (int i = 0; i < ENTRIES_COUNT; i++) assertEquals("RegularPeter" + i, ((RegularPerson) cache.get(i)).regName);
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IgniteEx(org.apache.ignite.internal.IgniteEx) BinaryObject(org.apache.ignite.binary.BinaryObject)

Example 28 with GridCacheDatabaseSharedManager

use of org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager in project ignite by apache.

the class IgnitePersistentStoreSchemaLoadTest method checkpointLatch.

/**
 * @param node Node whose checkpoint to wait for.
 * @return Latch released when checkpoint happens.
 */
private CountDownLatch checkpointLatch(IgniteEx node) {
    final CountDownLatch cnt = new CountDownLatch(1);
    GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager) node.context().cache().context().database();
    db.addCheckpointListener(new DbCheckpointListener() {

        @Override
        public void onCheckpointBegin(Context ctx) {
            cnt.countDown();
        }
    });
    return cnt;
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) DbCheckpointListener(org.apache.ignite.internal.processors.cache.persistence.DbCheckpointListener) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)28 IgniteEx (org.apache.ignite.internal.IgniteEx)19 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 Ignite (org.apache.ignite.Ignite)8 ArrayList (java.util.ArrayList)7 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)6 WALPointer (org.apache.ignite.internal.pagemem.wal.WALPointer)6 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)5 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)5 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)4 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)4 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)4 WALRecord (org.apache.ignite.internal.pagemem.wal.record.WALRecord)4 ByteBuffer (java.nio.ByteBuffer)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Random (java.util.Random)3 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)3 IgnitePageStoreManager (org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager)3 CheckpointRecord (org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord)3