本文整理汇总了Java中javax.cache.configuration.FactoryBuilder.SingletonFactory方法的典型用法代码示例。如果您正苦于以下问题:Java FactoryBuilder.SingletonFactory方法的具体用法?Java FactoryBuilder.SingletonFactory怎么用?Java FactoryBuilder.SingletonFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.cache.configuration.FactoryBuilder
的用法示例。
在下文中一共展示了FactoryBuilder.SingletonFactory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCacheConfiguration
import javax.cache.configuration.FactoryBuilder; //导入方法依赖的package包/类
/**
* @param atomicityMode Atomicity mode.
* @return Cache configuration.
*/
@SuppressWarnings({"rawtypes", "unchecked"})
private CacheConfiguration<String, List<Double>> createCacheConfiguration(CacheAtomicityMode atomicityMode) {
CacheConfiguration<String, List<Double>> cc = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
cc.setCacheMode(PARTITIONED);
cc.setAtomicityMode(atomicityMode);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setReadThrough(true);
cc.setWriteThrough(true);
Factory cacheStoreFactory = new FactoryBuilder.SingletonFactory(new DummyCacheStore());
cc.setCacheStoreFactory(cacheStoreFactory);
cc.setBackups(2);
return cc;
}
示例2: setMaxIdleTime
import javax.cache.configuration.FactoryBuilder; //导入方法依赖的package包/类
@Override
public Builder<K,V> setMaxIdleTime(int maxIdleTime, TimeUnit timeUnit)
{
if (maxIdleTime <= 0)
throw new IllegalArgumentException("Invalid maxIdleTime: " + maxIdleTime);
TouchedExpiryPolicy ep = new TouchedExpiryPolicy(new Duration(timeUnit, maxIdleTime));
SingletonFactory<ExpiryPolicy> singletonFactory = new FactoryBuilder.SingletonFactory<ExpiryPolicy>(ep);
this.expiryPolicyFactory = (Factory<ExpiryPolicy>)singletonFactory;
return this;
}
示例3: testZeroOnUpdate
import javax.cache.configuration.FactoryBuilder; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testZeroOnUpdate() throws Exception {
factory = new FactoryBuilder.SingletonFactory<>(new TestPolicy(null, 0L, null));
startGrids();
for (final Integer key : keys()) {
log.info("Test zero duration on update, key: " + key);
zeroOnUpdate(key);
}
}
示例4: factory
import javax.cache.configuration.FactoryBuilder; //导入方法依赖的package包/类
public static Factory<CacheLoader<Object, Object>> factory() {
return new FactoryBuilder.SingletonFactory(new MyCacheLoader());
}
示例5: testContinuousQuery
import javax.cache.configuration.FactoryBuilder; //导入方法依赖的package包/类
/**
* @param ccfg Cache configuration.
* @param isClient Client.
* @throws Exception If failed.
*/
protected void testContinuousQuery(CacheConfiguration<Object, Object> ccfg, boolean isClient)
throws Exception {
ignite(0).createCache(ccfg);
ThreadLocalRandom rnd = ThreadLocalRandom.current();
QueryCursor<?> cur = null;
final Class<Factory<CacheEntryEventFilter>> evtFilterFactory =
(Class<Factory<CacheEntryEventFilter>>)getExternalClassLoader().
loadClass("org.apache.ignite.tests.p2p.CacheDeploymentEntryEventFilterFactory");
final CountDownLatch latch = new CountDownLatch(10);
ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();
TestLocalListener localLsnr = new TestLocalListener() {
@Override public void onEvent(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts)
throws CacheEntryListenerException {
for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts) {
latch.countDown();
log.info("Received event: " + evt);
}
}
};
MutableCacheEntryListenerConfiguration<Integer, Integer> lsnrCfg =
new MutableCacheEntryListenerConfiguration<>(
new FactoryBuilder.SingletonFactory<>(localLsnr),
(Factory<? extends CacheEntryEventFilter<? super Integer, ? super Integer>>)
(Object)evtFilterFactory.newInstance(),
true,
true
);
qry.setLocalListener(localLsnr);
qry.setRemoteFilterFactory(
(Factory<? extends CacheEntryEventFilter<Integer, Integer>>)(Object)evtFilterFactory.newInstance());
IgniteCache<Integer, Integer> cache = null;
try {
if (isClient)
cache = grid(NODES - 1).cache(ccfg.getName());
else
cache = grid(rnd.nextInt(NODES - 1)).cache(ccfg.getName());
cur = cache.query(qry);
cache.registerCacheEntryListener(lsnrCfg);
for (int i = 0; i < 10; i++)
cache.put(i, i);
assertTrue(latch.await(3, TimeUnit.SECONDS));
}
finally {
if (cur != null)
cur.close();
if (cache != null)
cache.deregisterCacheEntryListener(lsnrCfg);
}
}