use of com.hazelcast.test.backup.BackupAccessor in project hazelcast by hazelcast.
the class CacheExpirationTest method test_whenEntryIsAccessedBackupIsNotCleaned.
@Test
public void test_whenEntryIsAccessedBackupIsNotCleaned() {
CacheConfig<Integer, Integer> cacheConfig = createCacheConfig(new HazelcastExpiryPolicy(THREE_SECONDS, Duration.ETERNAL, THREE_SECONDS));
Cache<Integer, Integer> cache = createCache(cacheConfig);
for (int i = 0; i < KEY_RANGE; i++) {
cache.put(i, i);
cache.get(i);
}
sleepAtLeastSeconds(3);
for (int i = 1; i < CLUSTER_SIZE; i++) {
BackupAccessor backupAccessor = TestBackupUtils.newCacheAccessor(instances, cache.getName(), i);
for (int j = 0; j < KEY_RANGE; j++) {
assertEquals(i, backupAccessor.get(i));
}
}
}
use of com.hazelcast.test.backup.BackupAccessor in project hazelcast by hazelcast.
the class CacheExpirationTest method test_whenEntryIsRemovedBackupIsCleaned.
@Test
public void test_whenEntryIsRemovedBackupIsCleaned() {
int ttlSeconds = 3;
Duration duration = new Duration(TimeUnit.SECONDS, ttlSeconds);
HazelcastExpiryPolicy expiryPolicy = new HazelcastExpiryPolicy(duration, duration, duration);
CacheConfig<Integer, Integer> cacheConfig = createCacheConfig(expiryPolicy);
Cache<Integer, Integer> cache = createCache(cacheConfig);
for (int i = 0; i < KEY_RANGE; i++) {
cache.put(i, i);
}
for (int i = 0; i < KEY_RANGE; i++) {
cache.remove(i, i);
}
for (int i = 1; i < CLUSTER_SIZE; i++) {
BackupAccessor backupAccessor = TestBackupUtils.newCacheAccessor(instances, cache.getName(), i);
assertBackupSizeEventually(0, backupAccessor);
}
}
use of com.hazelcast.test.backup.BackupAccessor in project hazelcast by hazelcast.
the class CacheExpirationStressTest method assertRecords.
protected void assertRecords(final HazelcastInstance[] instances) {
for (int i = 1; i < instances.length; i++) {
BackupAccessor backupAccessor = TestBackupUtils.newCacheAccessor(instances, cacheNameWithPrefix, i);
assertBackupSizeEventually(0, backupAccessor);
}
for (int i = 0; i < instances.length; i++) {
final int index = i;
assertEqualsEventually(() -> instances[index].getCacheManager().getCache(cacheName).size(), 0);
}
instances[0].getCacheManager().getCache(cacheName).destroy();
}
Aggregations