Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @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());
- }
- }
Add Comment
Please, Sign In to add comment