use of com.ctrip.xpipe.redis.console.alert.AlertEntity in project x-pipe by ctripcorp.
the class SenderManagerTest method testSenderManager.
@Test
public void testSenderManager() {
HostPort hostPort = new HostPort("192.168.1.10", 6379);
Map<ALERT_TYPE, Set<AlertEntity>> alerts = new ConcurrentHashMap<>();
AlertEntity alert = new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.XREDIS_VERSION_NOT_VALID);
Set<AlertEntity> set = new ConcurrentSet<>();
set.add(alert);
alerts.put(ALERT_TYPE.XREDIS_VERSION_NOT_VALID, set);
new Thread(new Runnable() {
@Override
public void run() {
alerts.get(ALERT_TYPE.XREDIS_VERSION_NOT_VALID).remove(alert);
}
}).start();
List<Map<ALERT_TYPE, Set<AlertEntity>>> result = senderManager.getGroupedAlerts(alerts);
logger.info("result: {}", result.get(0));
if (!result.isEmpty()) {
Set<AlertEntity> alertEntities = result.get(0).getOrDefault(alert.getAlertType(), null);
if (alertEntities != null) {
Assert.assertFalse(alertEntities.isEmpty());
}
}
}
use of com.ctrip.xpipe.redis.console.alert.AlertEntity in project x-pipe by ctripcorp.
the class ScheduledAlertMessageDecoratorTest method generateBody.
@Test
public void generateBody() throws Exception {
HostPort hostPort = new HostPort("192.168.1.10", 6379);
Map<ALERT_TYPE, Set<AlertEntity>> alerts = new HashMap<>();
alerts.put(ALERT_TYPE.CLIENT_INCONSIS, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.CLIENT_INCONSIS)));
alerts.put(ALERT_TYPE.XREDIS_VERSION_NOT_VALID, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.XREDIS_VERSION_NOT_VALID)));
String body = decorator.generateBody(alerts);
logger.info("{}", body);
}
use of com.ctrip.xpipe.redis.console.alert.AlertEntity in project x-pipe by ctripcorp.
the class NotificationManager method addAlert.
public void addAlert(String dc, String cluster, String shard, HostPort hostPort, ALERT_TYPE type, String message) {
AlertEntity alert = new AlertEntity(hostPort, dc, cluster, shard, message, type);
logger.debug("[addAlert] Add Alert Entity: {}", alert);
alerts.offer(alert);
}
use of com.ctrip.xpipe.redis.console.alert.AlertEntity in project x-pipe by ctripcorp.
the class AlertPolicyManagerTest method queryRecepients.
@Test
public void queryRecepients() throws Exception {
AlertPolicy policy = policyManager.alertPolicyMap.get(SendToDBAAlertPolicy.ID);
List<String> expected = policy.queryRecipients(new AlertEntity(null, null, null, null, null, ALERT_TYPE.MARK_INSTANCE_UP));
logger.info("[testQueryRecepients] emails: {}", expected);
Assert.assertEquals(expected, policyManager.queryRecepients(alert));
}
use of com.ctrip.xpipe.redis.console.alert.AlertEntity in project x-pipe by ctripcorp.
the class NotificationManagerTest method send.
@Test
@DirtiesContext
public void send() throws Exception {
AlertEntity alert = new AlertEntity(hostPort, dcNames[0], cluster, shard, message, ALERT_TYPE.CLIENT_INCONSIS);
Assert.assertTrue(notificationManager.send(alert));
notificationManager.addAlert(dcNames[0], cluster, shard, hostPort, ALERT_TYPE.CLIENT_INCONSIS, message);
Assert.assertFalse(notificationManager.send(alert));
}
Aggregations