|
1 | 1 | package root.core.domain; |
2 | 2 |
|
3 | | -import java.util.List; |
| 3 | +import java.util.Date; |
4 | 4 |
|
5 | | -import com.opencsv.bean.CsvBindByName; |
6 | | -import com.opencsv.bean.CsvCustomBindByName; |
7 | | - |
8 | | -import lombok.AllArgsConstructor; |
9 | 5 | import lombok.Data; |
| 6 | +import lombok.EqualsAndHashCode; |
10 | 7 | import lombok.NoArgsConstructor; |
11 | | -import root.javafx.CustomView.UnitStringConverter; |
| 8 | +import root.utils.UnitUtils; |
| 9 | +import root.utils.UnitUtils.FileSize; |
12 | 10 |
|
13 | | -@AllArgsConstructor |
14 | 11 | @NoArgsConstructor |
| 12 | +@EqualsAndHashCode(callSuper = false) |
15 | 13 | @Data |
16 | | -public class ASMDiskUsage { |
| 14 | +public class ASMDiskUsage extends MonitoringResult { |
| 15 | + |
| 16 | + public ASMDiskUsage(Date monitoringDate, String asmDiskGroupName, String asmDiskGroupType, double totalRawSpace, |
| 17 | + double totalFreeSpace, double freeSpace, double usedSpace, double usedPercent, String resultMsg) { |
| 18 | + super(monitoringDate); |
| 19 | + this.asmDiskGroupName = asmDiskGroupName; |
| 20 | + this.asmDiskGroupType = asmDiskGroupType; |
| 21 | + this.totalRawSpace = totalRawSpace; |
| 22 | + this.totalFreeSpace = totalFreeSpace; |
| 23 | + this.freeSpace = freeSpace; |
| 24 | + this.usedSpace = usedSpace; |
| 25 | + this.usedPercent = usedPercent; |
| 26 | + this.resultMsg = resultMsg; |
| 27 | + } |
| 28 | + |
| 29 | + public ASMDiskUsage(String monitoringDate, String monitoringTime, String asmDiskGroupName, String asmDiskGroupType, |
| 30 | + double totalRawSpace, double totalFreeSpace, double freeSpace, double usedSpace, double usedPercent, |
| 31 | + String resultMsg) { |
| 32 | + super(monitoringDate, monitoringTime); |
| 33 | + this.asmDiskGroupName = asmDiskGroupName; |
| 34 | + this.asmDiskGroupType = asmDiskGroupType; |
| 35 | + this.totalRawSpace = totalRawSpace; |
| 36 | + this.totalFreeSpace = totalFreeSpace; |
| 37 | + this.freeSpace = freeSpace; |
| 38 | + this.usedSpace = usedSpace; |
| 39 | + this.usedPercent = usedPercent; |
| 40 | + this.resultMsg = resultMsg; |
| 41 | + } |
17 | 42 |
|
18 | | - @CsvBindByName(column = "NAME") |
19 | 43 | private String asmDiskGroupName; |
20 | 44 |
|
21 | | - @CsvBindByName(column = "TYPE") |
22 | 45 | private String asmDiskGroupType; |
23 | 46 |
|
24 | | - @CsvCustomBindByName(column = "TOTAL_RAW(MB)", converter = UnitStringConverter.class) |
25 | | - private UnitString totalRawSpace; |
| 47 | + private double totalRawSpace; |
26 | 48 |
|
27 | | - @CsvCustomBindByName(column = "TOTAL_USABLE(MB)", converter = UnitStringConverter.class) |
28 | | - private UnitString totalFreeSpace; |
| 49 | + private double totalFreeSpace; |
29 | 50 |
|
30 | | - @CsvCustomBindByName(column = "FREE(MB)", converter = UnitStringConverter.class) |
31 | | - private UnitString freeSpace; |
| 51 | + private double freeSpace; |
32 | 52 |
|
33 | | - @CsvCustomBindByName(column = "USED(MB)", converter = UnitStringConverter.class) |
34 | | - private UnitString usedSpace; |
| 53 | + private double usedSpace; |
35 | 54 |
|
36 | | - @CsvCustomBindByName(column = "USED(%)", converter = UnitStringConverter.class) |
37 | | - private UnitString usedPercent; |
| 55 | + private double usedPercent; |
38 | 56 |
|
39 | | - @CsvBindByName(column = "RESULT") |
40 | 57 | private String resultMsg; |
41 | 58 |
|
42 | | - public static String toCsvString(List<ASMDiskUsage> list) { |
43 | | - StringBuffer toCsv = new StringBuffer(); |
44 | | - toCsv.append("NAME,TYPE,TOTAL_RAW(MB),TOTAL_USABLE(MB),USED(MB),USED(%),FREE(MB),RESULT").append("\n"); |
45 | | - |
46 | | - for (ASMDiskUsage data : list) { |
47 | | - toCsv.append(data.getAsmDiskGroupName()).append(","); |
48 | | - toCsv.append(data.getAsmDiskGroupType()).append(","); |
49 | | - toCsv.append(data.getTotalRawSpace().getValue()).append(data.getTotalRawSpace().getUnit()).append(","); |
50 | | - toCsv.append(data.getTotalFreeSpace().getValue()).append(data.getTotalFreeSpace().getUnit()).append(","); |
51 | | - toCsv.append(data.getFreeSpace().getValue()).append(data.getFreeSpace().getUnit()).append(","); |
52 | | - toCsv.append(data.getUsedSpace().getValue()).append(data.getUsedSpace().getUnit()).append(","); |
53 | | - toCsv.append(data.getUsedPercent().getValue()).append(data.getUsedPercent().getUnit()).append(","); |
54 | | - toCsv.append(data.getResultMsg()).append("\n"); |
55 | | - } |
56 | | - |
57 | | - return toCsv.toString(); |
| 59 | + @Override |
| 60 | + public void convertUnit(FileSize fromUnit, FileSize toUnit, int round) { |
| 61 | + this.totalRawSpace = UnitUtils.convertFileUnit(fromUnit, toUnit, totalRawSpace, round); |
| 62 | + this.totalFreeSpace = UnitUtils.convertFileUnit(fromUnit, toUnit, totalFreeSpace, round); |
| 63 | + this.freeSpace = UnitUtils.convertFileUnit(fromUnit, toUnit, freeSpace, round); |
| 64 | + this.usedSpace = UnitUtils.convertFileUnit(fromUnit, toUnit, usedSpace, round); |
58 | 65 | } |
| 66 | + |
59 | 67 | } |
0 commit comments