use of com.hazelcast.core.LifecycleEvent.LifecycleState.MERGING in project hazelcast by hazelcast.
the class MapExpirationManagerTest method restarts_running_backgroundClearTask_when_lifecycleState_turns_to_MERGED.
@Test
public void restarts_running_backgroundClearTask_when_lifecycleState_turns_to_MERGED() {
Config config = getConfig();
config.setProperty(taskPeriodSecondsPropName(), "1");
HazelcastInstance node = createHazelcastInstance(config);
final AtomicInteger expirationCounter = new AtomicInteger();
IMap<Integer, Integer> map = node.getMap("test");
map.addEntryListener((EntryExpiredListener) event -> expirationCounter.incrementAndGet(), true);
map.put(1, 1, 3, TimeUnit.SECONDS);
((LifecycleServiceImpl) node.getLifecycleService()).fireLifecycleEvent(MERGING);
((LifecycleServiceImpl) node.getLifecycleService()).fireLifecycleEvent(MERGED);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
int expirationCount = expirationCounter.get();
assertEquals(format("Expecting 1 expiration but found:%d", expirationCount), 1, expirationCount);
}
});
}
Aggregations