conf, CONF_CALCULATOR_IMPL);
calcImpl = calcClazz == null ? new SLACalculatorMemory() : (SLACalculator) calcClazz.newInstance();
calcImpl.init(conf);
eventHandler = Services.get().get(EventHandlerService.class);
if (eventHandler == null) {
throw new ServiceException(ErrorCode.E0103, "EventHandlerService", "Add it under config "
+ Services.CONF_SERVICE_EXT_CLASSES + " or declare it BEFORE SLAService");
}
LOG = XLog.getLog(getClass());
java.util.Set<String> appTypes = eventHandler.getAppTypes();
appTypes.add("workflow_action");
eventHandler.setAppTypes(appTypes);
Runnable slaThread = new SLAWorker(calcImpl);
// schedule runnable by default every 30 sec
int slaCheckInterval = ConfigurationService.getInt(conf, CONF_SLA_CHECK_INTERVAL);
int slaCheckInitialDelay = ConfigurationService.getInt(conf, CONF_SLA_CHECK_INITIAL_DELAY);
services.get(SchedulerService.class).schedule(slaThread, slaCheckInitialDelay, slaCheckInterval,
SchedulerService.Unit.SEC);
slaEnabled = true;
LOG.info("SLAService initialized with impl [{0}] capacity [{1}]", calcImpl.getClass().getName(),
conf.get(SLAService.CONF_CAPACITY));
}
catch (Exception ex) {
throw new ServiceException(ErrorCode.E0102, ex.getMessage(), ex);
}
}