use of com.ctrip.xpipe.redis.console.alert.policy.AlertPolicy in project x-pipe by ctripcorp.
the class AlertPolicyManagerTest method queryCCers.
@Test
public void queryCCers() throws Exception {
AlertPolicy policy = policyManager.alertPolicyMap.get(SendToDBAAlertPolicy.ID);
List<String> expected = policy.queryCCers();
Assert.assertEquals(expected, policyManager.queryCCers(alert));
}
use of com.ctrip.xpipe.redis.console.alert.policy.AlertPolicy in project x-pipe by ctripcorp.
the class AlertPolicyManager method queryCCers.
public List<String> queryCCers(AlertEntity alert) {
try {
List<AlertPolicy> alertPolicies = findAlertPolicies(alert);
Set<String> result = new HashSet<>();
for (AlertPolicy alertPolicy : alertPolicies) {
result.addAll(alertPolicy.queryCCers());
}
return new ArrayList<>(result);
} catch (Exception e) {
logger.error("[queryCCers]{}", e);
return new LinkedList<>();
}
}
use of com.ctrip.xpipe.redis.console.alert.policy.AlertPolicy in project x-pipe by ctripcorp.
the class AlertPolicyManager method querySuspendMinute.
public int querySuspendMinute(AlertEntity alert) {
try {
List<AlertPolicy> alertPolicies = findAlertPolicies(alert);
int result = 0;
for (AlertPolicy alertPolicy : alertPolicies) {
result = Math.max(result, alertPolicy.querySuspendMinute(alert));
}
return result;
} catch (Exception ex) {
return 5;
}
}
use of com.ctrip.xpipe.redis.console.alert.policy.AlertPolicy in project x-pipe by ctripcorp.
the class AlertPolicyManager method queryRecoverMinute.
public int queryRecoverMinute(AlertEntity alert) {
try {
List<AlertPolicy> alertPolicies = findAlertPolicies(alert);
int result = alert.getAlertType().getRecoverTime();
for (AlertPolicy alertPolicy : alertPolicies) {
result = Math.max(result, alertPolicy.queryRecoverMinute(alert));
}
return result;
} catch (Exception ex) {
return 30;
}
}
use of com.ctrip.xpipe.redis.console.alert.policy.AlertPolicy in project x-pipe by ctripcorp.
the class AlertPolicyManager method queryRecepients.
public List<String> queryRecepients(AlertEntity alert) {
try {
List<AlertPolicy> alertPolicies = findAlertPolicies(alert);
Set<String> result = new HashSet<>();
for (AlertPolicy alertPolicy : alertPolicies) {
result.addAll(alertPolicy.queryRecipients(alert));
}
// in case not to produce empty recipient email. (Email could not sent successfully without recipient)
if (result.isEmpty()) {
result.addAll(alertPolicyMap.get(SendToXPipeAdminAlertPolicy.ID).queryRecipients(alert));
}
return new ArrayList<>(result);
} catch (Exception e) {
logger.error("[queryRecepients]{}", e);
return new LinkedList<>();
}
}
Aggregations