@Override
public void init() {
String site = config.getString("eagleProps.site");
String application = config.getString("eagleProps.application");
Map<String, Map<String, AlertDefinitionAPIEntity>> initialAlertDefs;
try {
initialAlertDefs = dao.findActivePoliciesGroupbyExecutorId( site, application );
}
catch (Exception ex) {
LOG.error("fail to initialize initialAlertDefs: ", ex);
throw new IllegalStateException("fail to initialize initialAlertDefs: ", ex);
}
if(initialAlertDefs == null || initialAlertDefs.isEmpty()){
LOG.warn("No alert definitions found for site: "+site+", application: "+ application);
}
try{
notificationManager = new NotificationPluginManagerImpl(config);
}catch (Exception ex ){
LOG.error("Fail to initialize NotificationManager: ", ex);
throw new IllegalStateException("Fail to initialize NotificationManager: ", ex);
}
DynamicPolicyLoader<AlertDefinitionAPIEntity> policyLoader = DynamicPolicyLoader.getInstanceOf(AlertDefinitionAPIEntity.class);
policyLoader.init(initialAlertDefs, dao, config);
for (String alertExecutorId : alertExecutorIdList) {
policyLoader.addPolicyChangeListener(alertExecutorId, this);
}
}