Guest User

Untitled

a guest
Nov 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. @Component
  2. public class IgniteAlertConfigStore implements AlertsConfigStore {
  3.  
  4. private static final Logger logger = LoggerFactory.getLogger(IgniteAlertConfigStore.class);
  5. // here it will be injected as a spring bean
  6. @Autowired
  7. private Ignite ignite;
  8.  
  9. @Override
  10. public AlertConfigEntry getConfigForServiceIdCodeId(String serviceId, String codeId) {
  11. return Optional.ofNullable(getAlertsConfigCache().get(serviceId + "_" + codeId))
  12. .orElseThrow(() -> new ResourceNotFoundException(String.format("Alert config for %s with %s not found", serviceId,codeId)));
  13. }
  14.  
  15. @Override
  16. public void update(String serviceId, String codeId, AlertConfigEntry alertConfigEntry) {
  17. getAlertsConfigCache().put(serviceId + "_" + codeId, alertConfigEntry);
  18. }
  19.  
  20. @Override
  21. public Optional<AlertConfigEntry> getConfigForServiceIdCodeIdCount(String serviceId, String codeId) {
  22. return Optional.ofNullable(getAlertsConfigCache().get(serviceId + "_" + codeId));
  23.  
  24. }
  25.  
  26.  
  27. public Cache<String, AlertConfigEntry> getAlertsConfigCache() {
  28. return ignite.getOrCreateCache(CacheNames.AlertsConfig.name());
  29. }
  30. }
Add Comment
Please, Sign In to add comment