Skip to content

Instantly share code, notes, and snippets.

@Romeh
Created November 17, 2017 15:07
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/5bfa938b6760bde997eec986f83c387a to your computer and use it in GitHub Desktop.
Save Romeh/5bfa938b6760bde997eec986f83c387a to your computer and use it in GitHub Desktop.
@Component
public class IgniteAlertConfigStore implements AlertsConfigStore {
private static final Logger logger = LoggerFactory.getLogger(IgniteAlertConfigStore.class);
// here it will be injected as a spring bean
@Autowired
private Ignite ignite;
@Override
public AlertConfigEntry getConfigForServiceIdCodeId(String serviceId, String codeId) {
return Optional.ofNullable(getAlertsConfigCache().get(serviceId + "_" + codeId))
.orElseThrow(() -> new ResourceNotFoundException(String.format("Alert config for %s with %s not found", serviceId,codeId)));
}
@Override
public void update(String serviceId, String codeId, AlertConfigEntry alertConfigEntry) {
getAlertsConfigCache().put(serviceId + "_" + codeId, alertConfigEntry);
}
@Override
public Optional<AlertConfigEntry> getConfigForServiceIdCodeIdCount(String serviceId, String codeId) {
return Optional.ofNullable(getAlertsConfigCache().get(serviceId + "_" + codeId));
}
public Cache<String, AlertConfigEntry> getAlertsConfigCache() {
return ignite.getOrCreateCache(CacheNames.AlertsConfig.name());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment