1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.tikv.service.failsafe;
19
20 public class HealthCounts {
21 private final long totalCount;
22 private final long errorCount;
23 private final int errorPercentage;
24
25 HealthCounts(long total, long error) {
26 this.totalCount = total;
27 this.errorCount = error;
28 if (totalCount > 0) {
29 this.errorPercentage = (int) ((double) errorCount / totalCount * 100);
30 } else {
31 this.errorPercentage = 0;
32 }
33 }
34
35 public long getTotalRequests() {
36 return totalCount;
37 }
38
39 public long getErrorCount() {
40 return errorCount;
41 }
42
43 public int getErrorPercentage() {
44 return errorPercentage;
45 }
46
47 @Override
48 public String toString() {
49 return "HealthCounts{"
50 + "totalCount="
51 + totalCount
52 + ", errorCount="
53 + errorCount
54 + ", errorPercentage="
55 + errorPercentage
56 + '}';
57 }
58 }