本文整理汇总了Java中com.hazelcast.map.listener.EntryAddedListener类的典型用法代码示例。如果您正苦于以下问题:Java EntryAddedListener类的具体用法?Java EntryAddedListener怎么用?Java EntryAddedListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntryAddedListener类属于com.hazelcast.map.listener包,在下文中一共展示了EntryAddedListener类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initBean
import com.hazelcast.map.listener.EntryAddedListener; //导入依赖的package包/类
private void initBean(RefreshableConfiguration refreshableConfiguration) {
IMap<String, String> configMap = hazelcastInstance.getMap(TENANT_CONFIGURATION_MAP);
configMap.forEach((key, value) -> {
if (refreshableConfiguration.isListeningConfiguration(key)) {
log.info(
"Process config init event: [key = {}, size = {}, newHash = {}] in bean: [{}]",
key,
StringUtils.length(value),
getValueHash(value),
getBeanName(refreshableConfiguration));
refreshableConfiguration.onInit(key, value);
}
});
log.info("refreshable configuration bean [{}] initialized by configMap with {} entries",
getBeanName(refreshableConfiguration), configMap.size());
final boolean includeValue = true;
configMap.addEntryListener((EntryAddedListener<String, String>) e -> {
onEntryChange(refreshableConfiguration, e, configMap);
}, includeValue);
configMap.addEntryListener((EntryRemovedListener<String, String>) e -> {
onEntryChange(refreshableConfiguration, e, configMap);
}, includeValue);
configMap.addEntryListener((EntryUpdatedListener<String, String>) e -> {
onEntryChange(refreshableConfiguration, e, configMap);
}, includeValue);
}
示例2: KfkaManagerImpl
import com.hazelcast.map.listener.EntryAddedListener; //导入依赖的package包/类
public KfkaManagerImpl(HazelcastInstance hazelcastInstance, KfkaMapStore<? extends KfkaMessage> mapStore, KfkaCounterStore counterStore, KfkaConfig kfkaCfg)
{
this.kfkaCfg = kfkaCfg;
final MapConfig hzcfg = hazelcastInstance.getConfig().getMapConfig(kfkaCfg.getName());
hzcfg.setEvictionPolicy(EvictionPolicy.NONE);
final MapStoreConfig mapCfg = hzcfg.getMapStoreConfig();
mapCfg.setImplementation(mapStore);
mapCfg.setEnabled(kfkaCfg.isPersistent());
mapCfg.setWriteBatchSize(kfkaCfg.getBatchSize());
mapCfg.setWriteDelaySeconds(kfkaCfg.getWriteDelay());
mapCfg.setInitialLoadMode(kfkaCfg.getInitialLoadMode());
this.mapStore = mapStore;
this.messages = hazelcastInstance.getMap(kfkaCfg.getName());
this.counter = hazelcastInstance.getAtomicLong(kfkaCfg.getName());
messages.addIndex("id", true);
messages.addIndex("timestamp", true);
messages.addEntryListener(new EntryAddedListener<Long, KfkaMessage>()
{
@Override
public void entryAdded(EntryEvent<Long, KfkaMessage> event)
{
logger.debug("Received message for dispatch: {}", event.getValue());
final Iterator<Entry<KfkaMessageListener, KfkaPredicate>> iter = msgListeners.entrySet().iterator();
while (iter.hasNext())
{
final Entry<KfkaMessageListener, KfkaPredicate> e = iter.next();
final KfkaPredicate predicate = e.getValue();
final KfkaMessage msg = event.getValue();
// Check if message should be included
if (predicate.toGuavaPredicate().apply(msg))
{
final KfkaMessageListener l = e.getKey();
logger.debug("Sending message {} to {}", event.getValue().getId(), e.getKey());
l.onMessage(event.getValue());
}
}
}
}, true);
if (counter.get() == 0)
{
final long initialValue = counterStore.latest();
logger.info("Setting current KFKA message ID counter to {}", initialValue);
counter.compareAndSet(0, initialValue);
}
}