/** {@inheritDoc} */ @Override protected Factory<? extends CacheEntryEventFilter<QueryTestKey, QueryTestValue>> noOpFilterFactory() { return FactoryBuilder.factoryOf(NoopAsyncFilter.class); }
/** {@inheritDoc} */ @Override public Factory<? extends CacheStore<Object, Object>> getStoreFactory() { return FactoryBuilder.factoryOf(MapCacheStore.class); }
/** Adds the JCache specification's lazy expiration settings. */ public void addLazyExpiration() { Duration creation = getDurationFor("policy.lazy-expiration.creation"); Duration update = getDurationFor("policy.lazy-expiration.update"); Duration access = getDurationFor("policy.lazy-expiration.access"); requireNonNull(creation, "policy.lazy-expiration.creation may not be null"); boolean eternal = Objects.equals(creation, Duration.ETERNAL) && Objects.equals(update, Duration.ETERNAL) && Objects.equals(access, Duration.ETERNAL); @SuppressWarnings("NullAway") Factory<? extends ExpiryPolicy> factory = eternal ? EternalExpiryPolicy.factoryOf() : FactoryBuilder.factoryOf(new JCacheExpiryPolicy(creation, update, access)); configuration.setExpiryPolicyFactory(factory); }
/** Adds the maximum size and weight bounding settings. */ private void addMaximum() { if (isSet("policy.maximum.size")) { configuration.setMaximumSize(OptionalLong.of(merged.getLong("policy.maximum.size"))); } if (isSet("policy.maximum.weight")) { configuration.setMaximumWeight(OptionalLong.of(merged.getLong("policy.maximum.weight"))); } if (isSet("policy.maximum.weigher")) { configuration.setWeigherFactory(Optional.of( FactoryBuilder.factoryOf(merged.getString("policy.maximum.weigher")))); } }
/** Adds the Caffeine eager expiration settings. */ public void addEagerExpiration() { if (isSet("policy.eager-expiration.after-write")) { long nanos = merged.getDuration("policy.eager-expiration.after-write", NANOSECONDS); configuration.setExpireAfterWrite(OptionalLong.of(nanos)); } if (isSet("policy.eager-expiration.after-access")) { long nanos = merged.getDuration("policy.eager-expiration.after-access", NANOSECONDS); configuration.setExpireAfterAccess(OptionalLong.of(nanos)); } if (isSet("policy.eager-expiration.variable")) { configuration.setExpiryFactory(Optional.of(FactoryBuilder.factoryOf( merged.getString("policy.eager-expiration.variable")))); } }
/** * @param cache Cache. * @return Event listener. */ private AllEventListener<Integer, String> registerCacheListener(IgniteCache<Integer, String> cache) { AllEventListener<Integer, String> lsnr = new AllEventListener<>(); cache.registerCacheEntryListener( new MutableCacheEntryListenerConfiguration<>(factoryOf(lsnr), null, true, false)); return lsnr; }
(ContinuousQueryWithTransformer<K, V, CacheEntryEvent>)qry; qry0.setRemoteTransformerFactory(FactoryBuilder.factoryOf(transformer));
/** * @param name Cache name. * @return Cache configuration. */ private CacheConfiguration<Integer, Integer> cacheConfiguration(String name) { CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>(name); cacheCfg.setAtomicityMode(TRANSACTIONAL); cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(Store.class)); cacheCfg.setWriteThrough(true); return cacheCfg; }
/** * Register a continuous query, that counts updates on the provided cache. * * @param cache Cache. * @param loc If {@code true}, then local continuous query will be registered. * @param updCntr Update counter. * @param rmtFilter Remote filter. */ private void listenToUpdates(IgniteCache<Integer, String> cache, boolean loc, AtomicInteger updCntr, CacheEntryEventSerializableFilter<Integer, String> rmtFilter) { ContinuousQuery<Integer, String> cq = new ContinuousQuery<>(); cq.setLocal(loc); cq.setLocalListener((evts) -> { for (CacheEntryEvent e : evts) updCntr.incrementAndGet(); }); if (rmtFilter != null) cq.setRemoteFilterFactory(FactoryBuilder.factoryOf(rmtFilter)); cache.query(cq); } }
/** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { CacheConfiguration cacheCfg = super.cacheConfiguration(igniteInstanceName); cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(EmptyCacheStore.class)); cacheCfg.setCacheStoreSessionListenerFactories(new CacheStoreSessionFactory()); cacheCfg.setReadThrough(false); cacheCfg.setWriteThrough(false); cacheCfg.setBackups(0); return cacheCfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { CacheConfiguration cacheCfg = new CacheConfiguration(CACHE_NAME) .setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC) .setCacheStoreFactory(FactoryBuilder.factoryOf(ThrowableCacheStore.class)) .setWriteThrough(true) .setStoreKeepBinary(true); return super.getConfiguration(gridName) .setCacheConfiguration(cacheCfg); }
/** * @param key Key. * @param res Result. * @param id Listener ID. * @return Listener */ private CacheEntryListenerConfiguration<Integer, String> createCacheListener( Integer key, IgniteFuture<String> res, int id) { return new MutableCacheEntryListenerConfiguration<>( factoryOf(new CacheListener(res, id)), new SingletonFactory<>(new KeyEventFilter(key, id)), false, true); }
qry.setRemoteFilterFactory(FactoryBuilder.factoryOf( new CacheEntryEventSerializableFilter<Integer, String>() { @Override public boolean evaluate(
/** * @throws Exception If failed. */ @Test public void testSerialization() throws Exception { if (cacheMode() == LOCAL) return; AtomicBoolean serialized = new AtomicBoolean(); NonSerializableListener lsnr = new NonSerializableListener(serialized); jcache(0).registerCacheEntryListener(new MutableCacheEntryListenerConfiguration<>( FactoryBuilder.factoryOf(lsnr), new SerializableFactory(), true, false )); try { startGrid(gridCount()); jcache(0).put(1, 1); } finally { stopGrid(gridCount()); } jcache(0).put(2, 2); assertFalse(IgniteCacheEntryListenerAbstractTest.serialized.get()); assertFalse(serialized.get()); }
/** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); CacheConfiguration cacheCfg = super.cacheConfiguration(igniteInstanceName); cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(EmptyCacheStore.class)); cacheCfg.setCacheStoreSessionListenerFactories(new CacheStoreSessionFactory()); cacheCfg.setReadThrough(true); cacheCfg.setWriteThrough(true); cacheCfg.setWriteBehindEnabled(true); cacheCfg.setWriteBehindBatchSize(CNT * 2); cacheCfg.setWriteBehindFlushFrequency(WRITE_BEHIND_FLUSH_FREQUENCY); cacheCfg.setBackups(0); return cacheCfg; }
qry.setRemoteFilterFactory(FactoryBuilder.factoryOf(CacheTestRemoteFilter.class));
/** * @param cacheMode Cache mode. * @param atomicityMode Atomicity mode. * @throws Exception If failed. */ private void loadCache(CacheMode cacheMode, CacheAtomicityMode atomicityMode) throws Exception { int keys = 100; boolean loc = cacheMode == LOCAL; Map<Integer, Integer> data1 = generateDataMap(keys); Map<Integer, Integer> data2 = generateDataMap(keys); Factory<? extends CacheStore<Integer, Integer>> fctr1 = FactoryBuilder.factoryOf(new MapBasedStore<>(data1)); Factory<? extends CacheStore<Integer, Integer>> fctr2 = FactoryBuilder.factoryOf(new MapBasedStore<>(data2)); CacheConfiguration ccfg1 = cacheConfiguration(GROUP1, CACHE1, cacheMode, atomicityMode, 1, false) .setCacheStoreFactory(fctr1); CacheConfiguration ccfg2 = cacheConfiguration(GROUP1, CACHE2, cacheMode, atomicityMode, 1, false) .setCacheStoreFactory(fctr2); Ignite node = startGrids(loc ? 1 : 4); node.createCaches(F.asList(ccfg1, ccfg2)); IgniteCache<Integer, Integer> cache1 = node.cache(CACHE1); IgniteCache<Integer, Integer> cache2 = node.cache(CACHE2); cache1.loadCache(null); checkCacheData(data1, CACHE1); assertEquals(0, cache2.size()); cache2.loadCache(null); checkCacheData(data2, CACHE2); }
/** */ @SuppressWarnings("unchecked") private CacheConfiguration cacheConfig(String cacheName) { CacheConfiguration ccfg = new CacheConfiguration<>(cacheName); ccfg.setCacheMode(cacheMode); ccfg.setBackups(backups); ccfg.setAtomicityMode(atomicityMode()); ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); ccfg.setAffinity(new RendezvousAffinityFunction(false, 1)); ccfg.setReadThrough(true); ccfg.setReadFromBackup(true); ccfg.setCacheStoreFactory(FactoryBuilder.factoryOf(TestStore.class)); if (near) ccfg.setNearConfiguration(new NearCacheConfiguration()); return ccfg; }
FactoryBuilder.factoryOf(new TouchedExpiryPolicy(new Duration(MILLISECONDS, DEFAULT_TIME_TO_LIVE))));
ccfg.setCacheStoreFactory(FactoryBuilder.factoryOf(GridCacheTestStore.class));