for(int i = 0; i < nAlerts1; i++)
{
String alertName = "esv4-app7" + i + ".stg.linkedin.com_12918.RestQueryStats@DBName=BizProfile.MinServerLatency";
Tuple<String> value = new Tuple<String>();
value.add("22" + i);
AlertValueAndStatus valueAndStatus = new AlertValueAndStatus(value , true);
alertResultMap1.put(alertName, valueAndStatus);
}
for(int i = 0; i < nAlerts2; i++)
{
String alertName = "esv4-app9" + i + ".stg.linkedin.com_12918.RestQueryStats@DBName=BizProfile.MaxServerLatency";
Tuple<String> value = new Tuple<String>();
value.add("22" + i);
AlertValueAndStatus valueAndStatus = new AlertValueAndStatus(value , true);
alertResultMap1.put(alertName, valueAndStatus);
}
beanCollection.setAlerts(originAlert1, alertResultMap1, clusterName);
beanCollection.setAlerts(originAlert2, alertResultMap2, clusterName);
beanCollection.refreshAlertDelta(clusterName);
String summaryKey = ClusterAlertMBeanCollection.ALERT_SUMMARY + "_" + clusterName;
jmxMBeanObserver.refresh();
// Get the history list
String beanName = "HelixAlerts:alert=" + summaryKey;
Map<String, Object> beanValueMap = jmxMBeanObserver._beanValueMap.get(beanName);
String history1 = (String) (beanValueMap.get("AlertFiredHistory"));
StringReader sr = new StringReader(history1);
ObjectMapper mapper = new ObjectMapper();
// check the history
Map<String, String> delta = beanCollection.getRecentAlertDelta();
Assert.assertEquals(delta.size(), nAlerts1 + nAlerts2);
for(int i = 0; i < nAlerts1; i++)
{
String alertBeanName = "(esv4-app7" + i + ".stg.linkedin.com_12918.RestQueryStats@DBName#BizProfile.MinServerLatency)GREATER(10)";
Assert.assertTrue(delta.get(alertBeanName).equals("ON"));
}
for(int i = 0; i < nAlerts2; i++)
{
String alertBeanName = "(esv4-app9" + i + ".stg.linkedin.com_12918.RestQueryStats@DBName#BizProfile.MaxServerLatency)GREATER(10)";
Assert.assertTrue(delta.get(alertBeanName).equals("ON"));
}
alertResultMap1 = new HashMap<String, AlertValueAndStatus>();
for(int i = 0; i < 3; i++)
{
String alertName = "esv4-app7" + i + ".stg.linkedin.com_12918.RestQueryStats@DBName=BizProfile.MinServerLatency";
Tuple<String> value = new Tuple<String>();
value.add("22" + i);
AlertValueAndStatus valueAndStatus = new AlertValueAndStatus(value , true);
alertResultMap1.put(alertName, valueAndStatus);
}
for(int i = 3; i < 5; i++)
{
String alertName = "esv4-app7" + i + ".stg.linkedin.com_12918.RestQueryStats@DBName=BizProfile.MinServerLatency";
Tuple<String> value = new Tuple<String>();
value.add("22" + i);
AlertValueAndStatus valueAndStatus = new AlertValueAndStatus(value , false);
alertResultMap1.put(alertName, valueAndStatus);
}
for(int i = 7; i < 9; i++)
{
String alertName = "esv4-app7" + i + ".stg.linkedin.com_12918.RestQueryStats@DBName=BizProfile.MinServerLatency";
Tuple<String> value = new Tuple<String>();
value.add("22" + i);
AlertValueAndStatus valueAndStatus = new AlertValueAndStatus(value , true);
alertResultMap1.put(alertName, valueAndStatus);
}
for(int i = 0; i < 2; i++)
{
String alertName = "esv4-app9" + i + ".stg.linkedin.com_12918.RestQueryStats@DBName=BizProfile.MaxServerLatency";
Tuple<String> value = new Tuple<String>();
value.add("22" + i);
AlertValueAndStatus valueAndStatus = new AlertValueAndStatus(value , false);
alertResultMap1.put(alertName, valueAndStatus);
}
for(int i = 2; i < 3; i++)
{
String alertName = "esv4-app9" + i + ".stg.linkedin.com_12918.RestQueryStats@DBName=BizProfile.MaxServerLatency";
Tuple<String> value = new Tuple<String>();
value.add("22" + i);
AlertValueAndStatus valueAndStatus = new AlertValueAndStatus(value , true);
alertResultMap1.put(alertName, valueAndStatus);
}
for(int i = 7; i < 9; i++)
{
String alertName = "esv4-app9" + i + ".stg.linkedin.com_12918.RestQueryStats@DBName=BizProfile.MaxServerLatency";
Tuple<String> value = new Tuple<String>();
value.add("22" + i);
AlertValueAndStatus valueAndStatus = new AlertValueAndStatus(value , true);
alertResultMap1.put(alertName, valueAndStatus);
}
beanCollection.setAlerts(originAlert1, alertResultMap1, clusterName);
beanCollection.refreshAlertDelta(clusterName);