use of com.hazelcast.instance.impl.LifecycleServiceImpl 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);
}
});
}
use of com.hazelcast.instance.impl.LifecycleServiceImpl in project hazelcast by hazelcast.
the class NodeQueryCacheContext method flushPublishersOnNodeShutdown.
/**
* This is a best effort approach; there is no guarantee that events in publishers internal buffers will be fired,
* {@link EventService} can drop them.
*/
private void flushPublishersOnNodeShutdown() {
Node node = ((NodeEngineImpl) this.nodeEngine).getNode();
LifecycleServiceImpl lifecycleService = node.hazelcastInstance.getLifecycleService();
lifecycleService.addLifecycleListener(event -> {
if (SHUTTING_DOWN == event.getState()) {
publisherContext.flush();
}
});
}
Aggregations