AlertDefineService.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package com.usthe.alert.service;
  2. import com.usthe.alert.pojo.entity.AlertDefine;
  3. import com.usthe.alert.pojo.entity.AlertDefineBind;
  4. import org.springframework.data.domain.Page;
  5. import org.springframework.data.domain.PageRequest;
  6. import org.springframework.data.jpa.domain.Specification;
  7. import java.util.List;
  8. import java.util.Map;
  9. import java.util.Set;
  10. /**
  11. * 告警定义管理接口
  12. * @author tom
  13. * @date 2021/12/9 10:06
  14. */
  15. public interface AlertDefineService {
  16. /**
  17. * 校验请求数据参数正确性
  18. * @param alertDefine alertDefine
  19. * @param isModify 是否是修改配置
  20. * @throws IllegalArgumentException 校验参数错误抛出
  21. */
  22. void validate(AlertDefine alertDefine, boolean isModify) throws IllegalArgumentException;
  23. /**
  24. * 新增告警定义
  25. * @param alertDefine 告警定义实体
  26. * @throws RuntimeException 新增过程异常抛出
  27. */
  28. void addAlertDefine(AlertDefine alertDefine) throws RuntimeException;
  29. /**
  30. * 修改告警定义
  31. * @param alertDefine 告警定义实体
  32. * @throws RuntimeException 修改过程中异常抛出
  33. */
  34. void modifyAlertDefine(AlertDefine alertDefine) throws RuntimeException;
  35. /**
  36. * 删除告警定义
  37. * @param alertId 告警定义ID
  38. * @throws RuntimeException 删除过程中异常抛出
  39. */
  40. void deleteAlertDefine(long alertId) throws RuntimeException;
  41. /**
  42. * 获取告警定义信息
  43. * @param alertId 监控ID
  44. * @return AlertDefine
  45. * @throws RuntimeException 查询过程中异常抛出
  46. */
  47. AlertDefine getAlertDefine(long alertId) throws RuntimeException;
  48. /**
  49. * 批量删除告警定义
  50. * @param alertIds 告警定义IDs
  51. * @throws RuntimeException 删除过程中异常抛出
  52. */
  53. void deleteAlertDefines(Set<Long> alertIds) throws RuntimeException;
  54. /**
  55. * 动态条件查询
  56. * @param specification 查询条件
  57. * @param pageRequest 分页参数
  58. * @return 查询结果
  59. */
  60. Page<AlertDefine> getMonitorBindAlertDefines(Specification<AlertDefine> specification, PageRequest pageRequest);
  61. /**
  62. * 应用告警定于与监控关联关系
  63. * @param alertId 告警定义ID
  64. * @param alertDefineBinds 关联关系
  65. */
  66. void applyBindAlertDefineMonitors(Long alertId, List<AlertDefineBind> alertDefineBinds);
  67. /**
  68. * 查询与此监控ID关联的指定指标组匹配的告警定义
  69. * @param monitorId 监控ID
  70. * @param app 监控类型
  71. * @param metrics 指标组
  72. * @return field - define[]
  73. */
  74. Map<String, List<AlertDefine>> getMonitorBindAlertDefines(long monitorId, String app, String metrics);
  75. /**
  76. * 动态条件查询
  77. * @param specification 查询条件
  78. * @param pageRequest 分页参数
  79. * @return 查询结果
  80. */
  81. Page<AlertDefine> getAlertDefines(Specification<AlertDefine> specification, PageRequest pageRequest);
  82. /**
  83. * 根据告警定义ID查询其关联的监控列表关联信息
  84. * @param alertDefineId 告警定义ID
  85. * @return 监控列表关联信息
  86. */
  87. List<AlertDefineBind> getBindAlertDefineMonitors(long alertDefineId);
  88. }