|
36 | 36 | import javax.mail.MessagingException; |
37 | 37 | import javax.naming.ConfigurationException; |
38 | 38 |
|
39 | | -import com.cloud.dc.DataCenter; |
40 | | -import com.cloud.dc.Pod; |
41 | | -import com.cloud.org.Cluster; |
42 | | - |
43 | 39 | import org.apache.cloudstack.backup.BackupManager; |
44 | 40 | import org.apache.cloudstack.framework.config.ConfigDepot; |
45 | 41 | import org.apache.cloudstack.framework.config.ConfigKey; |
|
71 | 67 | import com.cloud.configuration.Config; |
72 | 68 | import com.cloud.configuration.ConfigurationManager; |
73 | 69 | import com.cloud.dc.ClusterVO; |
| 70 | +import com.cloud.dc.DataCenter; |
74 | 71 | import com.cloud.dc.DataCenter.NetworkType; |
75 | 72 | import com.cloud.dc.DataCenterVO; |
76 | 73 | import com.cloud.dc.HostPodVO; |
| 74 | +import com.cloud.dc.Pod; |
77 | 75 | import com.cloud.dc.Vlan.VlanType; |
78 | 76 | import com.cloud.dc.dao.ClusterDao; |
79 | 77 | import com.cloud.dc.dao.DataCenterDao; |
|
87 | 85 | import com.cloud.host.dao.HostDao; |
88 | 86 | import com.cloud.network.Ipv6Service; |
89 | 87 | import com.cloud.network.dao.IPAddressDao; |
| 88 | +import com.cloud.org.Cluster; |
90 | 89 | import com.cloud.org.Grouping.AllocationState; |
91 | 90 | import com.cloud.resource.ResourceManager; |
92 | 91 | import com.cloud.storage.StorageManager; |
@@ -164,7 +163,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi |
164 | 163 | protected String[] recipients = null; |
165 | 164 | protected String senderAddress = null; |
166 | 165 |
|
167 | | - private final List<AlertType> allowedRepetitiveAlertTypes = new ArrayList<>(); |
| 166 | + private final List<String> allowedRepetitiveAlertTypeNames = new ArrayList<>(); |
168 | 167 |
|
169 | 168 | public AlertManagerImpl() { |
170 | 169 | _executor = Executors.newCachedThreadPool(new NamedThreadFactory("Email-Alerts-Sender")); |
@@ -254,23 +253,21 @@ public boolean configure(String name, Map<String, Object> params) throws Configu |
254 | 253 | } |
255 | 254 |
|
256 | 255 | protected void setupRepetitiveAlertTypes() { |
257 | | - allowedRepetitiveAlertTypes.clear(); |
| 256 | + allowedRepetitiveAlertTypeNames.clear(); |
258 | 257 | String allowedRepetitiveAlertsStr = AllowedRepetitiveAlertTypes.value(); |
259 | 258 | logger.trace("Allowed repetitive alert types specified by {}: {} ", AllowedRepetitiveAlertTypes.key(), |
260 | 259 | allowedRepetitiveAlertsStr); |
261 | 260 | if (StringUtils.isBlank(allowedRepetitiveAlertsStr)) { |
262 | 261 | return; |
263 | 262 | } |
264 | 263 | String[] allowedRepetitiveAlertTypesArray = allowedRepetitiveAlertsStr.split(","); |
265 | | - for (String alertTypeName : allowedRepetitiveAlertTypesArray) { |
266 | | - AlertType type = AlertType.getAlertTypeByName(alertTypeName.trim()); |
267 | | - if (type == null) { |
268 | | - logger.warn("Unknown alert type name: {}, skipping it.", alertTypeName); |
| 264 | + for (String allowedTypeName : allowedRepetitiveAlertTypesArray) { |
| 265 | + if (StringUtils.isBlank(allowedTypeName)) { |
269 | 266 | continue; |
270 | 267 | } |
271 | | - allowedRepetitiveAlertTypes.add(type); |
| 268 | + allowedRepetitiveAlertTypeNames.add(allowedTypeName.toLowerCase()); |
272 | 269 | } |
273 | | - logger.trace("{} alert types specified for repetitive alerts", allowedRepetitiveAlertTypes.size()); |
| 270 | + logger.trace("{} alert types specified for repetitive alerts", allowedRepetitiveAlertTypeNames.size()); |
274 | 271 | } |
275 | 272 |
|
276 | 273 | @Override |
@@ -868,7 +865,8 @@ public void sendAlert(AlertType alertType, DataCenter dataCenter, Pod pod, Clust |
868 | 865 |
|
869 | 866 | @Nullable |
870 | 867 | private AlertVO getAlertForTrivialAlertType(AlertType alertType, long dataCenterId, Long podId, Long clusterId) { |
871 | | - if (alertType.isRepetitionAllowed() || allowedRepetitiveAlertTypes.contains(alertType)) { |
| 868 | + if (alertType.isRepetitionAllowed() || (StringUtils.isNotBlank(alertType.getName()) && |
| 869 | + allowedRepetitiveAlertTypeNames.contains(alertType.getName().toLowerCase()))) { |
872 | 870 | return null; |
873 | 871 | } |
874 | 872 | return _alertDao.getLastAlert(alertType.getType(), dataCenterId, podId, clusterId); |
|
0 commit comments