Search in sources :

Example 81 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class IgnitePdsRecoveryAfterFileCorruptionTest method testPageRecoveryAfterFileCorruption.

/**
 * @throws Exception if failed.
 */
public void testPageRecoveryAfterFileCorruption() throws Exception {
    IgniteEx ig = startGrid(0);
    ig.active(true);
    IgniteCache<Integer, Integer> cache = ig.cache(cacheName);
    // Put for create data store and init meta page.
    cache.put(1, 1);
    GridCacheSharedContext sharedCtx = ig.context().cache().context();
    GridCacheDatabaseSharedManager psMgr = (GridCacheDatabaseSharedManager) sharedCtx.database();
    FilePageStoreManager pageStore = (FilePageStoreManager) sharedCtx.pageStore();
    U.sleep(1_000);
    // Disable integrated checkpoint thread.
    psMgr.enableCheckpoints(false).get();
    PageMemory mem = sharedCtx.database().dataRegion(policyName).pageMemory();
    DummyPageIO pageIO = new DummyPageIO();
    int cacheId = sharedCtx.cache().cache(cacheName).context().cacheId();
    FullPageId[] pages = new FullPageId[totalPages];
    // Get lock to prevent assertion. A new page should be allocated under checkpoint lock.
    psMgr.checkpointReadLock();
    try {
        for (int i = 0; i < totalPages; i++) {
            pages[i] = new FullPageId(mem.allocatePage(cacheId, 0, PageIdAllocator.FLAG_DATA), cacheId);
            initPage(mem, pageIO, pages[i]);
        }
        generateWal((PageMemoryImpl) mem, sharedCtx.pageStore(), sharedCtx.wal(), cacheId, pages);
    } finally {
        psMgr.checkpointReadUnlock();
    }
    eraseDataFromDisk(pageStore, cacheId, pages[0]);
    stopAllGrids();
    ig = startGrid(0);
    ig.active(true);
    checkRestore(ig, pages);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) FullPageId(org.apache.ignite.internal.pagemem.FullPageId)

Example 82 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class MemoryPolicyInitializationTest method testCachesOnUserDefinedDefaultMemoryPolicy.

/**
 * Test for verification that caches with not specified memory policy name,
 * with specified default memory policy name and specified custom memory policy name
 * all started with correct memory policy.
 */
public void testCachesOnUserDefinedDefaultMemoryPolicy() throws Exception {
    prepareCustomConfigWithOverriddenDefaultName();
    IgniteEx ignite = startGrid(0);
    CacheConfiguration cache1Cfg = new CacheConfiguration().setName("cache1");
    IgniteCache cache1 = ignite.createCache(cache1Cfg);
    verifyCacheMemoryPolicy(cache1, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
    CacheConfiguration cache2Cfg = new CacheConfiguration().setName("cache2").setMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
    IgniteCache cache2 = ignite.createCache(cache2Cfg);
    verifyCacheMemoryPolicy(cache2, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
    CacheConfiguration cache3Cfg = new CacheConfiguration().setName("cache3").setMemoryPolicyName(DFLT_MEM_PLC_DEFAULT_NAME);
    IgniteCache cache3 = ignite.createCache(cache3Cfg);
    verifyCacheMemoryPolicy(cache3, DFLT_MEM_PLC_DEFAULT_NAME);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCache(org.apache.ignite.IgniteCache) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 83 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class MemoryPolicyInitializationTest method testCustomConfigOverridesDefaultNameAndDeclaresDefault.

/**
 * User is allowed to define fully custom memory policy and make it default by setting its name to memory config.
 *
 * At the same time user still can create a memory policy with name 'default'
 * which although won't be used as default.
 */
public void testCustomConfigOverridesDefaultNameAndDeclaresDefault() throws Exception {
    prepareCustomConfigWithOverriddenDefaultName();
    IgniteEx ignite = startGrid(0);
    IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
    Collection<DataRegion> allMemPlcs = dbMgr.dataRegions();
    assertTrue(allMemPlcs.size() == 3);
    verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
    DataRegion dfltMemPlc = U.field(dbMgr, "dfltDataRegion");
    assertTrue(dfltMemPlc.config().getMaxSize() == USER_CUSTOM_MEM_PLC_SIZE);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx)

Example 84 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class MemoryPolicyInitializationTest method testCachesOnOverriddenMemoryPolicy.

/**
 * Test for verification that caches with not specified memory policy name,
 * with specified default memory policy name and specified custom memory policy name
 * all started with correct memory policy.
 */
public void testCachesOnOverriddenMemoryPolicy() throws Exception {
    prepareCustomConfigWithOverridingDefaultAndCustom();
    IgniteEx ignite = startGrid(0);
    CacheConfiguration cache1Cfg = new CacheConfiguration().setName("cache1");
    IgniteCache cache1 = ignite.createCache(cache1Cfg);
    verifyCacheMemoryPolicy(cache1, DFLT_MEM_PLC_DEFAULT_NAME);
    CacheConfiguration cache2Cfg = new CacheConfiguration().setName("cache2").setMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
    IgniteCache cache2 = ignite.createCache(cache2Cfg);
    verifyCacheMemoryPolicy(cache2, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
    CacheConfiguration cache3Cfg = new CacheConfiguration().setName("cache3").setMemoryPolicyName(DFLT_MEM_PLC_DEFAULT_NAME);
    IgniteCache cache3 = ignite.createCache(cache3Cfg);
    verifyCacheMemoryPolicy(cache3, DFLT_MEM_PLC_DEFAULT_NAME);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCache(org.apache.ignite.IgniteCache) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 85 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class MemoryPolicyInitializationTest method testNoConfigProvided.

/**
 * Verifies that expected memory policies are allocated when used doesn't provide any MemoryPolicyConfiguration.
 */
public void testNoConfigProvided() throws Exception {
    memCfg = null;
    IgniteEx ignite = startGrid(0);
    Collection<DataRegion> allMemPlcs = ignite.context().cache().context().database().dataRegions();
    assertTrue(allMemPlcs.size() == 2);
    verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx)

Aggregations

IgniteEx (org.apache.ignite.internal.IgniteEx)396 Ignite (org.apache.ignite.Ignite)85 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)64 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)60 IgniteException (org.apache.ignite.IgniteException)46 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)37 Transaction (org.apache.ignite.transactions.Transaction)34 ArrayList (java.util.ArrayList)31 HashMap (java.util.HashMap)31 CountDownLatch (java.util.concurrent.CountDownLatch)28 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)27 IgniteCache (org.apache.ignite.IgniteCache)25 Map (java.util.Map)24 ClusterNode (org.apache.ignite.cluster.ClusterNode)20 CacheException (javax.cache.CacheException)19 GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)19 UUID (java.util.UUID)18 Callable (java.util.concurrent.Callable)17 List (java.util.List)16 Random (java.util.Random)16