Java Code Examples for org.apache.ignite.configuration.IgniteConfiguration#getCacheConfiguration()
The following examples show how to use
org.apache.ignite.configuration.IgniteConfiguration#getCacheConfiguration() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CachePojoStoreXmlSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { String path = builtinKeys ? "modules/spring/src/test/config/jdbc-pojo-store-builtin.xml" : "modules/spring/src/test/config/jdbc-pojo-store-obj.xml"; URL url = U.resolveIgniteUrl(path); IgniteSpringHelper spring = IgniteComponentType.SPRING.create(false); IgniteConfiguration cfg = spring.loadConfigurations(url).get1().iterator().next(); if (sqlEscapeAll()) { for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) ((CacheJdbcPojoStoreFactory)ccfg.getCacheStoreFactory()).setSqlEscapeAll(true); } cfg.setIgniteInstanceName(igniteInstanceName); return cfg; }
Example 2
Source File: GridCacheDhtPreloadMultiThreadedSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = loadConfiguration("modules/core/src/test/config/spring-multicache.xml"); cfg.setGridLogger(getTestResources().getLogger()); cfg.setIgniteInstanceName(igniteInstanceName); cfg.setFailureHandler(new NoOpFailureHandler()); for (CacheConfiguration cCfg : cfg.getCacheConfiguration()) { if (cCfg.getCacheMode() == CacheMode.PARTITIONED) { cCfg.setAffinity(new RendezvousAffinityFunction(2048, null)); cCfg.setBackups(1); } } return cfg; }
Example 3
Source File: AbstractNodeJoinTemplate.java From ignite with Apache License 2.0 | 6 votes |
/** * @param cfg Configuration. * @return Test builder. */ public JoinNodeTestPlanBuilder nodeConfiguration(IgniteConfiguration cfg) { nodeCfg = cfg; strPlanBuilder.append("Join node:\n") .append(cfg.getIgniteInstanceName()) .append(cfg.isClientMode() != null && cfg.isClientMode() ? " (client)" : "") .append(" stateOnStart - ") .append(cfg.getClusterStateOnStart()) .append("\n"); CacheConfiguration[] ccfgs = cfg.getCacheConfiguration(); if (ccfgs != null) for (CacheConfiguration ccfg : ccfgs) strPlanBuilder.append(" cache - ").append(ccfg.getName()).append("\n"); return this; }
Example 4
Source File: AbstractNodeJoinTemplate.java From ignite with Apache License 2.0 | 6 votes |
/** * @param cfgs Configurations. * @return Test builder. * @throws Exception If failed. */ public JoinNodeTestPlanBuilder clusterConfiguration(IgniteConfiguration... cfgs) throws Exception { clusterCfg = cfgs; strPlanBuilder.append("Start cluster:\n"); for (IgniteConfiguration cfg : cfgs) { strPlanBuilder.append("node: ") .append(cfg.getIgniteInstanceName()) .append(" stateOnStart - ") .append(cfg.getClusterStateOnStart()) .append("\n"); CacheConfiguration[] ccfgs = cfg.getCacheConfiguration(); if (ccfgs != null) { for (CacheConfiguration ccfg : ccfgs) strPlanBuilder.append(" cache - ") .append(ccfg.getName()) .append("\n"); } } return this; }
Example 5
Source File: GridCacheUtils.java From ignite with Apache License 2.0 | 6 votes |
/** * @param cfg Config. * @param cls Class. * @return Not <code>null</code> list. */ public static <T extends CachePluginConfiguration> List<T> cachePluginConfigurations(IgniteConfiguration cfg, Class<T> cls) { List<T> res = new ArrayList<>(); if (cfg.getCacheConfiguration() != null) { for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { for (CachePluginConfiguration pluginCcfg : ccfg.getPluginConfigurations()) { if (cls == pluginCcfg.getClass()) res.add((T)pluginCcfg); } } } return res; }
Example 6
Source File: RebalanceCancellationTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName) .setConsistentId(igniteInstanceName) .setCommunicationSpi(new TestRecordingCommunicationSpi()) .setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setPersistenceEnabled(persistenceEnabled))) .setCacheConfiguration( new CacheConfiguration(DEFAULT_CACHE_NAME) .setAffinity(new RendezvousAffinityFunction(false, 15)) .setBackups(BACKUPS)); if (addtiotionalMemRegion) { cfg.setCacheConfiguration(cfg.getCacheConfiguration()[0], new CacheConfiguration(MEM_REGOIN_CACHE) .setDataRegionName(MEM_REGION) .setBackups(BACKUPS)) .getDataStorageConfiguration() .setDataRegionConfigurations(new DataRegionConfiguration() .setName(MEM_REGION)); } if (filterNode) { for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) ccfg.setNodeFilter(new CustomNodeFilter()); } return cfg; }
Example 7
Source File: IgniteCacheGroupsPartitionLossPolicySelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { assertNull(ccfg.getGroupName()); ccfg.setGroupName(GROUP_NAME); } return cfg; }
Example 8
Source File: GridCacheRebalancingAsyncSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration iCfg = super.getConfiguration(igniteInstanceName); for (CacheConfiguration cacheCfg : iCfg.getCacheConfiguration()) cacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC); return iCfg; }
Example 9
Source File: IgniteCacheP2pUnmarshallingErrorTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); if (getTestIgniteInstanceName(0).equals(igniteInstanceName)) cfg.setCacheConfiguration(); if (getTestIgniteInstanceName(10).equals(igniteInstanceName)) { CacheConfiguration cc = cfg.getCacheConfiguration()[0]; cc.setRebalanceDelay(-1); } return cfg; }
Example 10
Source File: GridCommonAbstractTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param cfg Configuration. * @param cacheName Cache name. * @return Cache configuration. */ protected CacheConfiguration cacheConfiguration(IgniteConfiguration cfg, String cacheName) { for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { if (F.eq(cacheName, ccfg.getName())) return ccfg; } fail("Failed to find cache configuration for cache: " + cacheName); return null; }
Example 11
Source File: PlatformDotNetConfigurationClosure.java From ignite with Apache License 2.0 | 5 votes |
/** * Find .NET affinity functions in configuration. * * @param cfg Configuration. * @return affinity functions. */ private static List<PlatformDotNetAffinityFunction> affinityFunctions(IgniteConfiguration cfg) { List<PlatformDotNetAffinityFunction> res = new ArrayList<>(); CacheConfiguration[] cacheCfg = cfg.getCacheConfiguration(); if (cacheCfg != null) { for (CacheConfiguration ccfg : cacheCfg) { if (ccfg.getAffinity() instanceof PlatformDotNetAffinityFunction) res.add((PlatformDotNetAffinityFunction)ccfg.getAffinity()); } } return res; }
Example 12
Source File: IgniteCacheP2pUnmarshallingQueryErrorTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); if (cfg.getCacheConfiguration().length > 0) cfg.getCacheConfiguration()[0].setIndexedTypes(TestKey.class, String.class); return cfg; }
Example 13
Source File: IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected void configure(IgniteConfiguration cfg) { super.configure(cfg); for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { AffinityFunction aff = ccfg.getAffinity(); int parts = aff != null ? aff.partitions() : RendezvousAffinityFunction.DFLT_PARTITION_COUNT; ccfg.setGroupName("testGroup-parts" + parts); } }
Example 14
Source File: IndexingCachePartitionLossPolicySelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) ccfg.setIndexedTypes(Integer.class, Integer.class); return cfg; }
Example 15
Source File: JdbcThinAbstractDmlStatementSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @param igniteInstanceName Ignite instance name. * @return Grid configuration used for starting the grid ready for manipulating binary objects. * @throws Exception If failed. */ IgniteConfiguration getBinaryConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = getConfiguration0(igniteInstanceName); cfg.setMarshaller(new BinaryMarshaller()); CacheConfiguration ccfg = cfg.getCacheConfiguration()[0]; ccfg.getQueryEntities().clear(); QueryEntity e = new QueryEntity(); e.setKeyType(String.class.getName()); e.setValueType("Person"); e.addQueryField("id", Integer.class.getName(), null); e.addQueryField("age", Integer.class.getName(), null); e.addQueryField("firstName", String.class.getName(), null); e.addQueryField("lastName", String.class.getName(), null); ccfg.setQueryEntities(Collections.singletonList(e)); return cfg; }
Example 16
Source File: DynamicIndexAbstractBasicSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration commonConfiguration(int idx) throws Exception { IgniteConfiguration cfg = super.commonConfiguration(idx); if (idx != nodeIndex()) return cfg; CacheConfiguration staticCacheCfg = cacheConfiguration().setName(STATIC_CACHE_NAME); ((QueryEntity)staticCacheCfg.getQueryEntities().iterator().next()).setIndexes(Collections.singletonList(index( IDX_NAME_1, field(FIELD_NAME_1) ))); CacheConfiguration[] newCfgs = new CacheConfiguration[F.isEmpty(cfg.getCacheConfiguration()) ? 1 : cfg.getCacheConfiguration().length + 1]; if (newCfgs.length > 1) System.arraycopy(cfg.getCacheConfiguration(), 0, newCfgs, 0, newCfgs.length - 1); newCfgs[newCfgs.length - 1] = staticCacheCfg; cfg.setCacheConfiguration(newCfgs); return cfg; }
Example 17
Source File: GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); CacheConfiguration atomicCacheCfg = cacheConfiguration0(); atomicCacheCfg.setName(ATOMIC_CACHE); atomicCacheCfg.setAtomicityMode(ATOMIC); int size = c.getCacheConfiguration().length; CacheConfiguration[] configs = Arrays.copyOf(c.getCacheConfiguration(), size + 1); configs[size] = atomicCacheCfg; c.setCacheConfiguration(configs); c.setPeerClassLoadingEnabled(peerClassLoading()); return c; }
Example 18
Source File: WalRecoveryWithPageCompressionAndTdeTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); for (CacheConfiguration<?, ?> ccfg : cfg.getCacheConfiguration()) ccfg.setEncryptionEnabled(true); KeystoreEncryptionSpi encSpi = new KeystoreEncryptionSpi(); encSpi.setKeyStorePath(AbstractEncryptionTest.KEYSTORE_PATH); encSpi.setKeyStorePassword(AbstractEncryptionTest.KEYSTORE_PASSWORD.toCharArray()); cfg.setEncryptionSpi(encSpi); return cfg; }
Example 19
Source File: BasicWarmupClosure.java From ignite with Apache License 2.0 | 3 votes |
/** * Prepares configuration for warmup. * * @param gridCfg Original grid configuration. * @return Prepared configuration or {@code null} if no caches found. */ private IgniteConfiguration prepareConfiguration(IgniteConfiguration gridCfg) { if (F.isEmpty(gridCfg.getCacheConfiguration())) return null; IgniteConfiguration cp = new IgniteConfiguration(); cp.setConnectorConfiguration(null); Collection<CacheConfiguration> reduced = new ArrayList<>(); for (CacheConfiguration ccfg : gridCfg.getCacheConfiguration()) { if (CU.isSystemCache(ccfg.getName())) continue; if (!matches(reduced, ccfg)) { CacheConfiguration ccfgCp = new CacheConfiguration(ccfg); ccfgCp.setCacheStoreFactory(null); ccfgCp.setWriteBehindEnabled(false); reduced.add(ccfgCp); } } if (F.isEmpty(reduced)) return null; CacheConfiguration[] res = new CacheConfiguration[reduced.size()]; reduced.toArray(res); cp.setCacheConfiguration(res); return cp; }
Example 20
Source File: CacheGroupMetricsWithIndexTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); for (CacheConfiguration cacheCfg : cfg.getCacheConfiguration()) { if (GROUP_NAME.equals(cacheCfg.getGroupName()) || GROUP_NAME_2.equals(cacheCfg.getGroupName())) { QueryEntity qryEntity = new QueryEntity(Long.class.getCanonicalName(), OBJECT_NAME); qryEntity.setKeyFieldName(KEY_NAME); LinkedHashMap<String, String> fields = new LinkedHashMap<>(); fields.put(KEY_NAME, Long.class.getCanonicalName()); fields.put(COLUMN1_NAME, Integer.class.getCanonicalName()); fields.put(COLUMN2_NAME, String.class.getCanonicalName()); qryEntity.setFields(fields); ArrayList<QueryIndex> indexes = new ArrayList<>(); indexes.add(new QueryIndex(COLUMN1_NAME)); indexes.add(new QueryIndex(COLUMN2_NAME)); qryEntity.setIndexes(indexes); cacheCfg.setQueryEntities(Collections.singletonList(qryEntity)); } } return cfg; }