/** {@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); }
qry.setRemoteFilterFactory(FactoryBuilder.factoryOf( new CacheEntryEventSerializableFilter<Integer, String>() { @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends String> e)
qry.setRemoteTransformerFactory(FactoryBuilder.factoryOf(new IgniteClosure<CacheEntryEvent<? extends Integer, ? extends Integer>, Integer>() { @Override public Integer apply(CacheEntryEvent<? extends Integer, ? extends Integer> evt) { latch.countDown(); qry.setRemoteFilterFactory(FactoryBuilder.factoryOf(new CacheEntryEventSerializableFilter<Integer, Integer>() { @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends Integer> evt) { return true;
/** * @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, Employee>() { @Override public boolean evaluate(CacheEntryEvent event) throws CacheEntryListenerException { return event.getEventType() == EventType.EXPIRED; qry.setRemoteTransformerFactory(FactoryBuilder.factoryOf( new IgniteClosure<CacheEntryEvent<? extends Integer, ? extends Employee>, Integer>() { @Override public Integer apply(CacheEntryEvent<? extends Integer, ? extends Employee> evt) {
qry.setRemoteFilterFactory(FactoryBuilder.factoryOf( new CacheEntryEventSerializableFilter<Integer, String>() { @Override public boolean evaluate(
FactoryBuilder.factoryOf(new CacheTestRemoteFilterAsync(ccfg.getName())));
/** * @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; }