Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions server/src/main/java/com/cloud/alert/AlertManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.UnsupportedEncodingException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -82,6 +83,7 @@
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.SearchCriteria;
import org.jetbrains.annotations.Nullable;

public class AlertManagerImpl extends ManagerBase implements AlertManager, Configurable {
protected Logger logger = Logger.getLogger(AlertManagerImpl.class.getName());
Expand Down Expand Up @@ -723,15 +725,7 @@ public void clearAlert(short alertType, long dataCenterId, Long podId) {
public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long clusterId, String subject, String content)
throws MessagingException, UnsupportedEncodingException {
logger.warn(String.format("alertType=[%s] dataCenterId=[%s] podId=[%s] clusterId=[%s] message=[%s].", alertType, dataCenterId, podId, clusterId, subject));
AlertVO alert = null;
if ((alertType != AlertManager.AlertType.ALERT_TYPE_HOST) && (alertType != AlertManager.AlertType.ALERT_TYPE_USERVM)
&& (alertType != AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER) && (alertType != AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY)
&& (alertType != AlertManager.AlertType.ALERT_TYPE_SSVM) && (alertType != AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC)
&& (alertType != AlertManager.AlertType.ALERT_TYPE_MANAGEMENT_NODE) && (alertType != AlertManager.AlertType.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED)
&& (alertType != AlertManager.AlertType.ALERT_TYPE_UPLOAD_FAILED) && (alertType != AlertManager.AlertType.ALERT_TYPE_OOBM_AUTH_ERROR)
&& (alertType != AlertManager.AlertType.ALERT_TYPE_HA_ACTION) && (alertType != AlertManager.AlertType.ALERT_TYPE_CA_CERT)) {
alert = _alertDao.getLastAlert(alertType.getType(), dataCenterId, podId, clusterId);
}
AlertVO alert = createAlertForTrivialAlertType(alertType, dataCenterId, podId, clusterId);

if (alert == null) {
AlertVO newAlert = new AlertVO();
Expand Down Expand Up @@ -773,6 +767,27 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c

}

@Nullable
private AlertVO createAlertForTrivialAlertType(AlertType alertType, long dataCenterId, Long podId, Long clusterId) {
AlertVO alert = null;
List<AlertType> alerts = Arrays.asList(AlertType.ALERT_TYPE_HOST
, AlertType.ALERT_TYPE_USERVM
, AlertType.ALERT_TYPE_DOMAIN_ROUTER
, AlertType.ALERT_TYPE_CONSOLE_PROXY
, AlertType.ALERT_TYPE_SSVM
, AlertType.ALERT_TYPE_STORAGE_MISC
, AlertType.ALERT_TYPE_MANAGEMENT_NODE
, AlertType.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED
, AlertType.ALERT_TYPE_UPLOAD_FAILED
, AlertType.ALERT_TYPE_OOBM_AUTH_ERROR
, AlertType.ALERT_TYPE_HA_ACTION
, AlertType.ALERT_TYPE_CA_CERT);
if (!alerts.contains(alertType)) {
alert = _alertDao.getLastAlert(alertType.getType(), dataCenterId, podId, clusterId);
}
return alert;
}

protected void sendMessage(SMTPMailProperties mailProps) {
_executor.execute(new Runnable() {
@Override
Expand Down
Loading