本文整理汇总了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);
}