MetricEnum.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package org.dbsyncer.biz.enums;
  2. import org.dbsyncer.biz.BizException;
  3. import org.dbsyncer.common.util.StringUtil;
  4. /**
  5. * 系统指标
  6. *
  7. * @author AE86
  8. * @version 1.0.0
  9. * @date 2021/07/22 19:19
  10. */
  11. public enum MetricEnum {
  12. /**
  13. * 线程活跃数
  14. */
  15. THREADS_LIVE("jvm.threads.live", "应用线程", "活跃数"),
  16. /**
  17. * 线程峰值
  18. */
  19. THREADS_PEAK("jvm.threads.peak", "应用线程", "峰值数"),
  20. /**
  21. * 内存已用
  22. */
  23. MEMORY_USED("jvm.memory.used", "内存", "已用"),
  24. /**
  25. * 内存空闲
  26. */
  27. MEMORY_COMMITTED("jvm.memory.committed", "内存", "空闲"),
  28. /**
  29. * 内存总共
  30. */
  31. MEMORY_MAX("jvm.memory.max", "内存", "总共"),
  32. /**
  33. * GC
  34. */
  35. GC_PAUSE("jvm.gc.pause", "GC", "已用"),
  36. /**
  37. * CPU已用
  38. */
  39. CPU_USAGE("system.cpu.usage", "CPU", "已用");
  40. private String code;
  41. private String group;
  42. private String metricName;
  43. MetricEnum(String code, String group, String metricName) {
  44. this.code = code;
  45. this.group = group;
  46. this.metricName = metricName;
  47. }
  48. public static MetricEnum getMetric(String code) throws BizException {
  49. for (MetricEnum e : MetricEnum.values()) {
  50. if (StringUtil.equals(code, e.getCode())) {
  51. return e;
  52. }
  53. }
  54. throw new BizException(String.format("Metric code \"%s\" does not exist.", code));
  55. }
  56. public String getCode() {
  57. return code;
  58. }
  59. public String getGroup() {
  60. return group;
  61. }
  62. public String getMetricName() {
  63. return metricName;
  64. }
  65. }