@Test @Category(SlowTest.class) public void testPutTransientDoesNotStoreEntry_onPromotedReplica() { String mapName = randomMapName(); final MapStoreWithCounter mapStore = new MapStoreWithCounter<Integer, String>(); TestMapUsingMapStoreBuilder<String, Object> storeBuilder = TestMapUsingMapStoreBuilder.create(); TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2); final IMap<String, Object> map = storeBuilder .mapName(mapName) .withMapStore(mapStore) .withNodeCount(2) .withNodeFactory(factory) .withWriteDelaySeconds(5) .withBackupCount(1) .withPartitionCount(1) .withBackupProcessingDelay(1) .build(); String key = UUID.randomUUID().toString(); map.putTransient(key, 1, 1, TimeUnit.DAYS); killKeyOwner(key, storeBuilder); sleepSeconds(10); assertEquals( "There should not be any store operation on promoted replica", 0, mapStore.countStore.get()); }
@Test public void testPutTransientDoesNotStoreEntry_onBackupPartition() { String mapName = randomMapName(); final MapStoreWithCounter mapStore = new MapStoreWithCounter<Integer, String>(); TestMapUsingMapStoreBuilder<Object, Object> storeBuilder = TestMapUsingMapStoreBuilder.create(); final IMap<Object, Object> map = storeBuilder .mapName(mapName) .withMapStore(mapStore) .withNodeCount(2) .withNodeFactory(createHazelcastInstanceFactory(2)) .withWriteDelaySeconds(1) .withBackupCount(1) .withPartitionCount(1) .withBackupProcessingDelay(1) .build(); map.putTransient(1, 1, 1, TimeUnit.DAYS); sleepSeconds(5); assertEquals("There should not be any store operation", 0, mapStore.countStore.get()); }
/** * {@link com.hazelcast.map.impl.mapstore.writebehind.StoreWorker} delays processing of * write-behind queues (wbq) by adding delay with {@link * com.hazelcast.instance.GroupProperty#MAP_REPLICA_SCHEDULED_TASK_DELAY_SECONDS} property. This * is used to provide some extra robustness against node disaster scenarios by trying to prevent * lost of entries in wbq-s. Normally backup nodes don't store entries only remove them from * wbq-s. Here, we are testing removal of entries occurred or not. */ @Test public void testBackupRemovesEntries_afterProcessingDelay() throws Exception { final int numberOfItems = 10; final String mapName = randomMapName(); final MapStoreWithCounter mapStore = new MapStoreWithCounter<Integer, String>(); TestMapUsingMapStoreBuilder<Object, Object> storeBuilder = TestMapUsingMapStoreBuilder.create(); final IMap<Object, Object> map = storeBuilder .mapName(mapName) .withMapStore(mapStore) .withNodeCount(2) .withNodeFactory(createHazelcastInstanceFactory(2)) .withWriteDelaySeconds(1) .withBackupCount(1) .withPartitionCount(1) .withBackupProcessingDelay(1) .build(); populateMap(map, numberOfItems); assertWriteBehindQueuesEmptyOnOwnerAndOnBackups( mapName, numberOfItems, mapStore, storeBuilder.getNodes()); }