Created
November 17, 2017 15:07
-
-
Save Romeh/5bfa938b6760bde997eec986f83c387a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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