Skip to content

Instantly share code, notes, and snippets.

@Romeh
Created November 17, 2017 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Romeh/369bbb44085caafa7fd1cd15efb87e80 to your computer and use it in GitHub Desktop.
Save Romeh/369bbb44085caafa7fd1cd15efb87e80 to your computer and use it in GitHub Desktop.
@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;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment