blob: a29c150b2ae4b91c6e0ccb5dbf9349f6b19600a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
package com.gluster.storage.management.core.model;
import org.eclipse.osgi.internal.signedcontent.Base64;
public class Alert extends Entity {
public enum ALERT_TYPES {
CPU_USAGE_ALERT, MEMORY_USAGE_ALERT, DISK_USAGE_ALERT, OFFLINE_VOLUME_BRICKS_ALERT, OFFLINE_SERVERS_ALERT
};
public static final String[] ALERT_TYPE_STR = { "High CPU Usage", "High Memory Usage", "Low Disk Space",
"Offline Brick", "Offline Server" };
// protected String id;
protected ALERT_TYPES type;
protected String reference; // [for server- "Server", for Disk- "Server:disk", for volume- "Volume:Server:disk"]
protected String message;
public String getAlertType() {
return ALERT_TYPE_STR[type.ordinal()];
}
public Alert() {
}
public Alert(ALERT_TYPES type, String reference, String Message) {
setType(type);
setReference(reference);
setMessage(Message);
setId(buildAlertId());
}
public String buildAlertId() {
return Base64.encode((getAlertType() + "-" + getReference()).getBytes()).toString();
}
public String getId() {
return getName();
}
public void setId(String id) {
setName(id);
}
public ALERT_TYPES getType() {
return type;
}
public void setType(ALERT_TYPES type) {
this.type = type;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public void copyFrom(Alert alert) {
this.setId(alert.getId());
this.setReference(alert.getReference());
this.setType(alert.getType());
this.setMessage(alert.getMessage());
}
}
|