当前位置: 首页>>代码示例>>Java>>正文


Java HazelcastInstance.getAtomicLong方法代码示例

本文整理汇总了Java中com.hazelcast.core.HazelcastInstance.getAtomicLong方法的典型用法代码示例。如果您正苦于以下问题:Java HazelcastInstance.getAtomicLong方法的具体用法?Java HazelcastInstance.getAtomicLong怎么用?Java HazelcastInstance.getAtomicLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hazelcast.core.HazelcastInstance的用法示例。


在下文中一共展示了HazelcastInstance.getAtomicLong方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: KfkaManagerImpl

import com.hazelcast.core.HazelcastInstance; //导入方法依赖的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);
    }
}
 
开发者ID:ethlo,项目名称:kfka,代码行数:53,代码来源:KfkaManagerImpl.java

示例2: HazelcastAtomicnumberProducer

import com.hazelcast.core.HazelcastInstance; //导入方法依赖的package包/类
public HazelcastAtomicnumberProducer(HazelcastInstance hazelcastInstance, HazelcastDefaultEndpoint endpoint, String cacheName) {
    super(endpoint);
    this.atomicnumber = hazelcastInstance.getAtomicLong(cacheName);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:HazelcastAtomicnumberProducer.java


注:本文中的com.hazelcast.core.HazelcastInstance.getAtomicLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。