use of javax.cache.expiry.Duration in project ignite by apache.
the class IgnitePdsContinuousRestartTestWithExpiryPolicy method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
CacheConfiguration ccfg = new CacheConfiguration();
ccfg.setName(CACHE_NAME);
ccfg.setGroupName("Group1");
ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
ccfg.setAffinity(new RendezvousAffinityFunction(false, 128));
ccfg.setBackups(2);
ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1)));
cfg.setCacheConfiguration(ccfg);
return cfg;
}
use of javax.cache.expiry.Duration in project ignite by apache.
the class IgnitePdsCacheEntriesExpirationTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
DataStorageConfiguration dsCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(1024L * 1024 * 1024).setPersistenceEnabled(true)).setWalMode(WALMode.LOG_ONLY).setCheckpointFrequency(60_000);
cfg.setDataStorageConfiguration(dsCfg);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC).setAffinity(new RendezvousAffinityFunction(false, 2)).setBackups(1).setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, 350)));
cfg.setCacheConfiguration(ccfg);
return cfg;
}
use of javax.cache.expiry.Duration in project ignite by apache.
the class IgniteCacheExpiryStoreLoadSelfTest method checkLocalLoad.
/**
* @param async If {@code true} uses asynchronous method.
* @throws Exception If failed.
*/
private void checkLocalLoad(boolean async) throws Exception {
final IgniteCache<String, Integer> cache = jcache(0).withExpiryPolicy(new CreatedExpiryPolicy(new Duration(MILLISECONDS, TIME_TO_LIVE)));
List<Integer> keys = primaryKeys(cache, 3);
if (async)
cache.localLoadCacheAsync(null, keys.toArray(new Integer[3])).get();
else
cache.localLoadCache(null, keys.toArray(new Integer[3]));
assertEquals(3, cache.localSize());
boolean res = GridTestUtils.waitForCondition(new PA() {
@Override
public boolean apply() {
return cache.localSize() == 0;
}
}, TIME_TO_LIVE + WAIT_TIME);
assertTrue(res);
}
use of javax.cache.expiry.Duration in project ignite by apache.
the class IgniteCacheExpiryStoreLoadSelfTest method checkLoad.
/**
* @param async If {@code true} uses asynchronous method.
* @throws Exception If failed.
*/
private void checkLoad(boolean async) throws Exception {
IgniteCache<String, Integer> cache = jcache(0).withExpiryPolicy(new CreatedExpiryPolicy(new Duration(MILLISECONDS, TIME_TO_LIVE)));
List<Integer> keys = new ArrayList<>();
keys.add(primaryKey(jcache(0)));
keys.add(primaryKey(jcache(1)));
keys.add(primaryKey(jcache(2)));
if (async)
cache.loadCacheAsync(null, keys.toArray(new Integer[3])).get();
else
cache.loadCache(null, keys.toArray(new Integer[3]));
assertEquals(3, cache.size(CachePeekMode.PRIMARY));
Thread.sleep(TIME_TO_LIVE + WAIT_TIME);
assertEquals(0, cache.size());
}
use of javax.cache.expiry.Duration in project ignite by apache.
the class IgniteCacheExpiryStoreLoadSelfTest method testLoadAllWithExpiry.
/**
* @throws Exception If failed.
*/
@Test
public void testLoadAllWithExpiry() throws Exception {
IgniteCache<Integer, Integer> cache = ignite(0).<Integer, Integer>cache(DEFAULT_CACHE_NAME).withExpiryPolicy(new CreatedExpiryPolicy(new Duration(MILLISECONDS, TIME_TO_LIVE)));
Set<Integer> keys = new HashSet<>();
keys.add(primaryKey(jcache(0)));
keys.add(primaryKey(jcache(1)));
keys.add(primaryKey(jcache(2)));
CompletionListenerFuture fut = new CompletionListenerFuture();
cache.loadAll(keys, false, fut);
fut.get();
assertEquals(3, cache.size(CachePeekMode.PRIMARY));
Thread.sleep(TIME_TO_LIVE + WAIT_TIME);
assertEquals(0, cache.size());
}
Aggregations