1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
package net.admin4j.vo; |
15 | |
|
16 | |
import java.io.Serializable; |
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
public class MemoryUtilizationVO extends BaseVO implements Serializable { |
24 | |
|
25 | |
private static final long serialVersionUID = -2708169198765518131L; |
26 | |
|
27 | |
private long currentMemoryAllocatedInBytes; |
28 | |
private long freeCurrentMemoryInbytes; |
29 | |
private long maxMemoryInBytes; |
30 | |
|
31 | |
public MemoryUtilizationVO(long currentMemoryAllocatedInBytes, |
32 | 30 | long freeMemoryInbytes, long maxMemoryInBytes) { |
33 | 30 | this.currentMemoryAllocatedInBytes = currentMemoryAllocatedInBytes; |
34 | 30 | this.freeCurrentMemoryInbytes = freeMemoryInbytes; |
35 | 30 | this.maxMemoryInBytes = maxMemoryInBytes; |
36 | 30 | } |
37 | |
|
38 | |
public long getMemoryInUseInBytes() { |
39 | 141 | return this.getCurrentMemoryAllocatedInBytes() - this.getFreeCurrentMemoryInbytes(); |
40 | |
} |
41 | |
|
42 | |
public long getFreeAvailableMemoryInBytes() { |
43 | 30 | return this.getMaxMemoryInBytes() - this.getMemoryInUseInBytes(); |
44 | |
} |
45 | |
|
46 | |
public double getFreeAvailableMemoryInMb() { |
47 | 21 | return (double)(this.getMaxMemoryInBytes() - this.getMemoryInUseInBytes()) / (double) 1024000 ; |
48 | |
} |
49 | |
|
50 | |
public long getPercentMemoryAvailable() { |
51 | 30 | return (100 * this.getFreeAvailableMemoryInBytes()) / this.getMaxMemoryInBytes(); |
52 | |
} |
53 | |
|
54 | |
public long getPercentMemoryUsed() { |
55 | 15 | return 100 - this.getPercentMemoryAvailable(); |
56 | |
} |
57 | |
|
58 | |
public long getCurrentMemoryAllocatedInBytes() { |
59 | 141 | return currentMemoryAllocatedInBytes; |
60 | |
} |
61 | |
|
62 | |
public long getFreeCurrentMemoryInbytes() { |
63 | 141 | return freeCurrentMemoryInbytes; |
64 | |
} |
65 | |
|
66 | |
public long getMaxMemoryInBytes() { |
67 | 87 | return maxMemoryInBytes; |
68 | |
} |
69 | |
|
70 | |
public long getMaxMemoryInBytesInMb() { |
71 | 6 | return this.getMaxMemoryInBytes() / 1024000 ; |
72 | |
} |
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
@Override |
78 | |
public Object clone() throws CloneNotSupportedException { |
79 | 3 | return new MemoryUtilizationVO(currentMemoryAllocatedInBytes, |
80 | |
this.freeCurrentMemoryInbytes, maxMemoryInBytes); |
81 | |
} |
82 | |
|
83 | |
} |