Search in sources :

Example 1 with AlertPolicy

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));
}
Also used : AlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.AlertPolicy) SendToDBAAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToDBAAlertPolicy) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 2 with AlertPolicy

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<>();
    }
}
Also used : AlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.AlertPolicy) SendToDBAAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToDBAAlertPolicy) SendToRedisClusterAdminAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToRedisClusterAdminAlertPolicy) SendToXPipeAdminAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToXPipeAdminAlertPolicy)

Example 3 with AlertPolicy

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;
    }
}
Also used : AlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.AlertPolicy) SendToDBAAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToDBAAlertPolicy) SendToRedisClusterAdminAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToRedisClusterAdminAlertPolicy) SendToXPipeAdminAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToXPipeAdminAlertPolicy)

Example 4 with AlertPolicy

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;
    }
}
Also used : AlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.AlertPolicy) SendToDBAAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToDBAAlertPolicy) SendToRedisClusterAdminAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToRedisClusterAdminAlertPolicy) SendToXPipeAdminAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToXPipeAdminAlertPolicy)

Example 5 with AlertPolicy

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<>();
    }
}
Also used : AlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.AlertPolicy) SendToDBAAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToDBAAlertPolicy) SendToRedisClusterAdminAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToRedisClusterAdminAlertPolicy) SendToXPipeAdminAlertPolicy(com.ctrip.xpipe.redis.console.alert.policy.SendToXPipeAdminAlertPolicy)

Aggregations

AlertPolicy (com.ctrip.xpipe.redis.console.alert.policy.AlertPolicy)6 SendToDBAAlertPolicy (com.ctrip.xpipe.redis.console.alert.policy.SendToDBAAlertPolicy)6 SendToRedisClusterAdminAlertPolicy (com.ctrip.xpipe.redis.console.alert.policy.SendToRedisClusterAdminAlertPolicy)4 SendToXPipeAdminAlertPolicy (com.ctrip.xpipe.redis.console.alert.policy.SendToXPipeAdminAlertPolicy)4 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)2 Test (org.junit.Test)2 AlertEntity (com.ctrip.xpipe.redis.console.alert.AlertEntity)1