/** {@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; }
/** * Start client caches if absent. */ private void ensureClientCachesStarted() { GridCacheProcessor cacheProcessor = cctx.cache(); Set<String> cacheNames = new HashSet<>(cacheProcessor.cacheNames()); List<CacheConfiguration> notStartedCacheConfigs = new ArrayList<>(); for (CacheConfiguration cCfg : cctx.gridConfig().getCacheConfiguration()) { if (!cacheNames.contains(cCfg.getName()) && !GridCacheUtils.isCacheTemplateName(cCfg.getName())) notStartedCacheConfigs.add(cCfg); } if (!notStartedCacheConfigs.isEmpty()) cacheProcessor.dynamicStartCaches(notStartedCacheConfigs, false, false, false); }
/** * @return Timeout for initial map exchange before preloading. We make it {@code 4} times * bigger than network timeout by default. */ public long preloadExchangeTimeout() { long t1 = gridConfig().getNetworkTimeout() * 4; long t2 = gridConfig().getNetworkTimeout() * gridConfig().getCacheConfiguration().length * 2; long timeout = Math.max(t1, t2); return timeout < 0 ? Long.MAX_VALUE : timeout; }
/** * @param g Grid. * @return Non-system caches. */ private Collection<CacheConfiguration> caches(Ignite g) { return F.view(Arrays.asList(g.configuration().getCacheConfiguration()), new IgnitePredicate<CacheConfiguration>() { @Override public boolean apply(CacheConfiguration c) { return !CU.UTILITY_CACHE_NAME.equals(c.getName()) && !CU.SYS_CACHE_HADOOP_MR.equals(c.getName()); } }); } }
/** {@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; }
/** {@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; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); if (cfg.isClientMode() == null || !cfg.isClientMode()) { cfg.getCacheConfiguration()[0].setEvictionPolicy(new FifoEvictionPolicy(1)); cfg.getCacheConfiguration()[0].setOnheapCacheEnabled(true); } return cfg; }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration igniteConfiguration = super.getConfiguration(igniteInstanceName); CacheConfiguration[] ccfgs = igniteConfiguration.getCacheConfiguration(); if (ccfgs != null) { for (CacheConfiguration ccfg : ccfgs) ccfg.setNearConfiguration(null); } assert ccfgs == null || ccfgs.length == 0 || (ccfgs.length == 1 && ccfgs[0].getAtomicityMode() == TRANSACTIONAL_SNAPSHOT); return igniteConfiguration; }
/** {@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; }
/** * @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; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); if (getTestIgniteInstanceName(0).equals(igniteInstanceName)) { cfg.setClientMode(true); cfg.setCacheConfiguration(); } if (getTestIgniteInstanceName(10).equals(igniteInstanceName)) { CacheConfiguration cc = cfg.getCacheConfiguration()[0]; cc.setRebalanceDelay(-1); } return cfg; }
/** {@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); } } }
/** {@inheritDoc} */ @Override protected Ignite startGrid(String igniteInstanceName, GridSpringResourceContext ctx) throws Exception { if (cacheCfgMap == null) return super.startGrid(igniteInstanceName, ctx); IgniteConfiguration cfg = getConfiguration(igniteInstanceName); cacheCfgMap.put(igniteInstanceName, cfg.getCacheConfiguration()); cfg.setCacheConfiguration(); if (!isRemoteJvm(igniteInstanceName)) return IgnitionEx.start(optimize(cfg), ctx); else return startRemoteGrid(igniteInstanceName, optimize(cfg), ctx); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); assert cfg.getCacheConfiguration().length == 1; CacheConfiguration ccfg0 = cacheConfiguration(igniteInstanceName); ccfg0.setName(DEFAULT_CACHE_NAME); CacheConfiguration ccfg1 = cacheConfiguration(igniteInstanceName); ccfg1.setName(CACHE_NAME1); cfg.setCacheConfiguration(ccfg0, ccfg1); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); c.setIncludeEventTypes(); c.setPeerClassLoadingEnabled(false); CacheConfiguration[] ccfg = c.getCacheConfiguration(); if (ccfg != null) { assert ccfg.length == 1 : ccfg.length; c.setCacheConfiguration(ccfg[0], cacheConfiguration()); } else c.setCacheConfiguration(cacheConfiguration()); return c; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); CacheConfiguration ccfg = new CacheConfiguration("abc"); if (indexingEnabled()) ccfg.setIndexedTypes(Integer.class, Abc.class); ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); ccfg.setRebalanceMode(CacheRebalanceMode.SYNC); cfg.setCacheConfiguration(F.concat(cfg.getCacheConfiguration(), ccfg)); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); // Enables template with default test configuration cfg.setCacheConfiguration(F.concat(cfg.getCacheConfiguration(), cacheConfiguration(igniteInstanceName).setName("*"))); ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); cfg.setMarshaller(new BinaryMarshaller()); // TODO remove key configuration when https://issues.apache.org/jira/browse/IGNITE-5795 is fixed. cfg.setCacheKeyConfiguration(new CacheKeyConfiguration(Person.Key.class.getName(), "orgId")); AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi(); failSpi.setMaximumFailoverAttempts(MAX_FAILOVER_ATTEMPTS); cfg.setFailoverSpi(failSpi); return cfg; }
/** * @param ignite Grid to take store from. * @param map Expected values in store. * @throws Exception If failed. */ private void checkStore(Ignite ignite, Map<Integer, String> map) throws Exception { String cacheName = ignite.configuration().getCacheConfiguration()[0].getName(); GridCacheContext ctx = ((IgniteKernal)grid()).context().cache().internalCache(cacheName).context(); CacheStore store = ctx.store().configuredStore(); assertEquals(map, ((GridCacheTestStore)store).getMap()); }
/** * Clears all stores. * * @param cnt Grid count. */ private void clearStores(int cnt) { for (int i = 0; i < cnt; i++) { String cacheName = grid(i).configuration().getCacheConfiguration()[0].getName(); GridCacheContext ctx = ((IgniteKernal)grid()).context().cache().internalCache(cacheName).context(); CacheStore store = ctx.store().configuredStore(); ((GridCacheTestStore)store).reset(); } }
/** {@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; } }