use of com.hazelcast.test.backup.BackupAccessor in project hazelcast by hazelcast.
the class CacheExpirationTest method test_whenEntryIsRemovedBackupIsCleaned_eternalDuration.
@Test
public void test_whenEntryIsRemovedBackupIsCleaned_eternalDuration() {
CacheConfig<Integer, Integer> cacheConfig = createCacheConfig(new HazelcastExpiryPolicy(Duration.ETERNAL, Duration.ETERNAL, Duration.ETERNAL));
Cache<Integer, Integer> cache = createCache(cacheConfig);
for (int i = 0; i < KEY_RANGE; i++) {
cache.put(i, i);
cache.remove(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 CacheExpirationTest method testBackupsAreEmptyAfterExpiration.
@Test
public void testBackupsAreEmptyAfterExpiration() {
SimpleExpiryListener listener = new SimpleExpiryListener();
CacheConfig cacheConfig = createCacheConfig(new HazelcastExpiryPolicy(100, 100, 100), listener);
Cache cache = createCache(cacheConfig);
for (int i = 0; i < KEY_RANGE; i++) {
cache.put(i, i);
}
assertEqualsEventually(KEY_RANGE, listener.getExpirationCount());
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 ExtendedCacheExpirationTest method test_backupOperationAppliesDefaultExpiryPolicy.
@Test
public void test_backupOperationAppliesDefaultExpiryPolicy() {
HazelcastExpiryPolicy defaultExpiryPolicy = new HazelcastExpiryPolicy(THREE_SECONDS, Duration.ZERO, Duration.ZERO);
CacheConfig cacheConfig = createCacheConfig(defaultExpiryPolicy);
ICache cache = createCache(cacheConfig);
int keyCount = 100;
for (int i = 0; i < keyCount; i++) {
cache.put(i, i);
}
// Check if all backup entries have applied the default expiry policy
for (int i = 1; i < CLUSTER_SIZE; i++) {
BackupAccessor backupAccessor = TestBackupUtils.newCacheAccessor(instances, cache.getName(), i);
for (int j = 0; j < keyCount; j++) {
TestBackupUtils.assertExpirationTimeExistsEventually(j, backupAccessor);
}
}
// terminate other nodes than number zero to cause backup promotion at the 0th member
for (int i = 1; i < CLUSTER_SIZE; i++) {
getNode(instances[i]).shutdown(true);
}
assertTrueEventually(() -> {
for (int i = 0; i < keyCount; i++) {
assertNull(cache.get(i));
}
});
}
use of com.hazelcast.test.backup.BackupAccessor in project hazelcast by hazelcast.
the class CacheExpirationTest method test_whenEntryIsUpdatedBackupIsNotCleaned.
@Test
public void test_whenEntryIsUpdatedBackupIsNotCleaned() {
CacheConfig<Integer, Integer> cacheConfig = createCacheConfig(new HazelcastExpiryPolicy(THREE_SECONDS, THREE_SECONDS, Duration.ETERNAL));
Cache<Integer, Integer> cache = createCache(cacheConfig);
for (int i = 0; i < KEY_RANGE; i++) {
cache.put(i, i);
cache.put(i, i);
}
cache.put(1, 1);
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 MapExpirationStressTest method assertRecords.
protected void assertRecords(final HazelcastInstance[] instances) {
for (int i = 1; i < instances.length; i++) {
BackupAccessor backupAccessor = TestBackupUtils.newCacheAccessor(instances, mapName, i);
assertBackupSizeEventually(0, backupAccessor);
}
for (int i = 0; i < instances.length; i++) {
final int index = i;
assertEqualsEventually(() -> instances[index].getMap(mapName).size(), 0);
}
instances[0].getMap(mapName).destroy();
}
Aggregations