本文整理匯總了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);
}
}
示例2: HazelcastAtomicnumberProducer
import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
public HazelcastAtomicnumberProducer(HazelcastInstance hazelcastInstance, HazelcastDefaultEndpoint endpoint, String cacheName) {
super(endpoint);
this.atomicnumber = hazelcastInstance.getAtomicLong(cacheName);
}