當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。