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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations