/** * @deprecated Use {@link #setDataRegionName(String)} instead. */ @Deprecated public CacheConfiguration<K, V> setMemoryPolicyName(String memPlcName) { return setDataRegionName(memPlcName); }
/** * Apply overrides to specified cache configuration. * * @param ccfg Cache configuration to override. * @return Updated cache configuration to permit fluent-style method calls. */ public CacheConfiguration apply(CacheConfiguration ccfg) { assert ccfg != null; if (mode != null) ccfg.setCacheMode(mode); if (backups != null) ccfg.setBackups(backups); if (cacheGroup != null) ccfg.setGroupName(cacheGroup); if (dataRegion != null) ccfg.setDataRegionName(dataRegion); if (writeSync != null) ccfg.setWriteSynchronizationMode(writeSync); return ccfg; }
/** * Verifies that proper exception is thrown when DataRegion is misconfigured for cache. */ @Test public void testMissingDataRegion() { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setDataRegionName("nonExistingMemPlc"); checkStartGridException(IgniteCheckedException.class, "Requested DataRegion is not configured"); }
/** * @return Configurations set 1. */ private CacheConfiguration[] configurations2() { CacheConfiguration[] ccfgs = new CacheConfiguration[3]; ccfgs[0] = cacheConfiguration("c1"); ccfgs[1] = cacheConfiguration("c2"); ccfgs[2] = cacheConfiguration("c3"); ccfgs[2].setDataRegionName(NO_PERSISTENCE_REGION); ccfgs[2].setDiskPageCompression(null); return ccfgs; }
/** */ protected CacheConfiguration<Object, Object> cacheCfg() { return new CacheConfiguration<>() .setName(MY_CACHE) .setDataRegionName(MY_DATA_REGION) .setAffinity(new RendezvousAffinityFunction().setPartitions(16)); }
/** * @param name Cache name. * @param sqlOnheapCacheEnabled sqlOnheapCacheEnabled flag. * @return Cache configuration. */ private CacheConfiguration cacheConfiguration(String name, boolean sqlOnheapCacheEnabled) { return new CacheConfiguration() .setName(name) .setSqlOnheapCacheEnabled(sqlOnheapCacheEnabled) .setDataRegionName(DATA_REGION_NAME) .setAffinity(new RendezvousAffinityFunction(false, 2)) .setQueryEntities(Collections.singleton( new QueryEntity(Integer.class, Value.class))); }
@Override public void apply(IgniteConfiguration cfg) { String memPlcName = "igfsDataMemPlc"; cfg.setDataStorageConfiguration(new DataStorageConfiguration().setDataRegionConfigurations( new DataRegionConfiguration().setMaxSize(maxSize).setInitialSize(maxSize).setName(memPlcName))); FileSystemConfiguration igfsCfg = cfg.getFileSystemConfiguration()[0]; igfsCfg.getDataCacheConfiguration().setDataRegionName(memPlcName); cfg.setCacheConfiguration(new CacheConfiguration().setName("QQQ").setDataRegionName(memPlcName)); } };
/** @throws Exception If failed. */ @Test public void testCreateEncryptedNotPersistedCacheFail() throws Exception { GridTestUtils.assertThrowsWithCause(() -> { CacheConfiguration<Long, String> ccfg = new CacheConfiguration<>(NO_PERSISTENCE_REGION); ccfg.setEncryptionEnabled(true); ccfg.setDataRegionName(NO_PERSISTENCE_REGION); grid(0).createCache(ccfg); }, IgniteCheckedException.class); }
/** * @return Cache configurations. */ final CacheConfiguration[] cacheConfigurations2() { CacheConfiguration[] ccfgs = new CacheConfiguration[5]; ccfgs[0] = cacheConfiguration(CACHE_NAME_PREFIX + 0, ATOMIC); ccfgs[1] = cacheConfiguration(CACHE_NAME_PREFIX + 1, TRANSACTIONAL); ccfgs[2] = cacheConfiguration(CACHE_NAME_PREFIX + 2, ATOMIC); ccfgs[3] = cacheConfiguration(CACHE_NAME_PREFIX + 3, TRANSACTIONAL); ccfgs[4] = cacheConfiguration(CACHE_NAME_PREFIX + 4, TRANSACTIONAL); ccfgs[4].setDataRegionName(NO_PERSISTENCE_REGION); ccfgs[4].setDiskPageCompression(null); return ccfgs; }
@Override public void applyx(Ignite ignite) throws IgniteCheckedException { createCache(ignite, cacheConfig(LOCAL).setDataRegionName(REGION_VOLATILE)); assertThrows(new Callable<Void>() { @Override public Void call() throws Exception { walDisable(ignite, CACHE_NAME); return null; } }, IgniteException.class, "WAL mode cannot be changed for LOCAL cache(s)"); assertThrows(new Callable<Void>() { @Override public Void call() throws Exception { walEnable(ignite, CACHE_NAME); return null; } }, IgniteException.class, "WAL mode cannot be changed for LOCAL cache(s)"); assert !ignite.cluster().isWalEnabled(CACHE_NAME); } });
@Override public void applyx(Ignite ignite) throws IgniteCheckedException { U.sleep(500); CacheConfiguration ccfg = cacheConfig(CACHE_NAME_3, PARTITIONED, TRANSACTIONAL) .setDataRegionName(REGION_VOLATILE); createCache(ignite, ccfg); assertThrows(new Callable<Void>() { @Override public Void call() throws Exception { walDisable(ignite, CACHE_NAME_3); return null; } }, IgniteException.class, "Cannot change WAL mode because persistence is not enabled for cache(s)"); assertThrows(new Callable<Void>() { @Override public Void call() throws Exception { walEnable(ignite, CACHE_NAME_3); return null; } }, IgniteException.class, "Cannot change WAL mode because persistence is not enabled for cache(s)"); assert !ignite.cluster().isWalEnabled(CACHE_NAME_3); } });
/** */ @Test public void testPreloadPartitionInMemoryRemoteMvcc() throws Exception { cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT).setDataRegionName(MEM); startGridsMultiThreaded(GRIDS_CNT); IgniteEx client = startGrid("client"); assertNotNull(client.cache(DEFAULT_CACHE_NAME)); try { client.cache(DEFAULT_CACHE_NAME).preloadPartition(0); fail("Exception is expected"); } catch (Exception e) { log.error("Expected", e); } }
/** */ @Test public void testPreloadPartitionInMemoryLocalMvcc() throws Exception { cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT).setDataRegionName(MEM); startGridsMultiThreaded(GRIDS_CNT); int key = 0; Ignite prim = primaryNode(key, DEFAULT_CACHE_NAME); int part = prim.affinity(DEFAULT_CACHE_NAME).partition(key); try { prim.cache(DEFAULT_CACHE_NAME).preloadPartition(part); fail("Exception is expected"); } catch (Exception e) { log.error("Expected", e); } }
/** */ @Test public void testPreloadPartitionInMemoryRemote() throws Exception { cfgFactory = () -> cacheConfiguration(TRANSACTIONAL).setDataRegionName(MEM); startGridsMultiThreaded(GRIDS_CNT); IgniteEx client = startGrid("client"); assertNotNull(client.cache(DEFAULT_CACHE_NAME)); try { client.cache(DEFAULT_CACHE_NAME).preloadPartition(0); fail("Exception is expected"); } catch (Exception e) { log.error("Expected", e); } }
/** */ @Test public void testPreloadPartitionInMemoryLocal() throws Exception { cfgFactory = () -> cacheConfiguration(TRANSACTIONAL).setDataRegionName(MEM); startGridsMultiThreaded(GRIDS_CNT); int key = 0; Ignite prim = primaryNode(key, DEFAULT_CACHE_NAME); int part = prim.affinity(DEFAULT_CACHE_NAME).partition(key); try { prim.cache(DEFAULT_CACHE_NAME).preloadPartition(part); fail("Exception is expected"); } catch (Exception e) { log.error("Expected", e); } }
/** */ @Test public void testLocalPreloadPartitionClientMvcc() throws Exception { cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT).setDataRegionName(MEM); startGridsMultiThreaded(GRIDS_CNT); IgniteEx client = startGrid("client"); assertNotNull(client.cache(DEFAULT_CACHE_NAME)); assertFalse(client.cache(DEFAULT_CACHE_NAME).localPreloadPartition(0)); assertFalse(grid(0).cache(DEFAULT_CACHE_NAME).localPreloadPartition(0)); }
/** */ @Test public void testLocalPreloadPartitionClient() throws Exception { cfgFactory = () -> cacheConfiguration(TRANSACTIONAL).setDataRegionName(MEM); startGridsMultiThreaded(GRIDS_CNT); IgniteEx client = startGrid("client"); assertNotNull(client.cache(DEFAULT_CACHE_NAME)); assertFalse(client.cache(DEFAULT_CACHE_NAME).localPreloadPartition(0)); assertFalse(grid(0).cache(DEFAULT_CACHE_NAME).localPreloadPartition(0)); }
/** * Verifies that {@link IgniteCheckedException} is thrown when swap and persistence are enabled at the same time * for a data region. */ @Test public void testSetPersistenceAndSwap() { DataRegionConfiguration invCfg = new DataRegionConfiguration(); invCfg.setName("invCfg"); invCfg.setInitialSize(DFLT_MEM_PLC_SIZE); invCfg.setMaxSize(DFLT_MEM_PLC_SIZE); // Enabling the persistence. invCfg.setPersistenceEnabled(true); // Enabling the swap space. invCfg.setSwapPath("/path/to/some/directory"); memCfg = new DataStorageConfiguration(); memCfg.setDataRegionConfigurations(invCfg); ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setDataRegionName("ccfg"); checkStartGridException(IgniteCheckedException.class, "Failed to start processor: GridProcessorAdapter []"); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setConsistentId(igniteInstanceName); CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME) .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setCacheMode(CacheMode.REPLICATED) .setDataRegionName("ds") .setAffinity(new RendezvousAffinityFunction(false, 32)); DataStorageConfiguration dsCfg = new DataStorageConfiguration() .setDataRegionConfigurations( new DataRegionConfiguration() .setName("ds") .setPersistenceEnabled(true) .setMaxSize(1024 * 1024 * 1024) ); cfg.setDataStorageConfiguration(dsCfg); cfg.setCacheConfiguration(ccfg); return cfg; }
/** * @throws Exception If failed. */ @Test public void testNonPersistentCachesIgnoreBaselineTopology() throws Exception { Ignite ig = startGrids(4); ig.cluster().active(true); IgniteCache persistentCache = ig.createCache(CACHE_NAME); IgniteCache inMemoryCache = ig.createCache( new CacheConfiguration<>().setName(CACHE_NAME + 2).setDataRegionName("memory")); Ignite newNode = startGrid(4); awaitPartitionMapExchange(); assertEquals(0, ig.affinity(persistentCache.getName()).allPartitions(newNode.cluster().localNode()).length); assertTrue(ig.affinity(inMemoryCache.getName()).allPartitions(newNode.cluster().localNode()).length > 0); }