本文整理汇总了Java中org.apache.ignite.IgniteCache.invoke方法的典型用法代码示例。如果您正苦于以下问题:Java IgniteCache.invoke方法的具体用法?Java IgniteCache.invoke怎么用?Java IgniteCache.invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.IgniteCache
的用法示例。
在下文中一共展示了IgniteCache.invoke方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAfterPut
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public void onAfterPut(Cache.Entry<Long, JournalItem> entry) {
IgniteCache<String, Long> sequenceNumberTrack = ignite.getOrCreateCache("sequenceNumberTrack");
sequenceNumberTrack.invoke(entry.getValue().getPersistenceId(), (mutableEntry, objects) -> {
if (mutableEntry.exists() && mutableEntry.getValue() != null) {
// if it is less than the new sequence value , use it
if (mutableEntry.getValue() < entry.getKey()) {
mutableEntry.setValue(entry.getKey());
}
} else {
// if does not exist , just use it
mutableEntry.setValue(entry.getKey());
}
// by api design nothing needed here
return null;
});
}
示例2: updateAlertEntry
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public void updateAlertEntry(String serviceId, String serviceCode, AlertEntry alertEntry) {
final IgniteCache<String, AlertEntry> alertsCache = getAlertsCache();
// update the alert entry via cache invoke for atomicity
alertsCache.invoke(alertEntry.getAlertId(), (mutableEntry, objects) -> {
if (mutableEntry.exists() && mutableEntry.getValue() != null) {
logger.debug("updating alert entry into the cache store invoke: {},{}", serviceId, serviceCode);
mutableEntry.setValue(alertEntry);
} else {
throw new ResourceNotFoundException(String.format("Alert for %s with %s not found", serviceId, serviceCode));
}
// by api design nothing needed here
return null;
});
}