janitors.add(getImageJanitor());
}
}
private ASGJanitor getASGJanitor() {
JanitorRuleEngine ruleEngine = new BasicJanitorRuleEngine();
boolean discoveryEnabled = configuration().getBoolOrElse("simianarmy.janitor.Eureka.enabled", false);
ASGInstanceValidator instanceValidator;
if (discoveryEnabled) {
LOGGER.info("Initializing Discovery client.");
instanceValidator = new DiscoveryASGInstanceValidator(DiscoveryManager.getInstance().getDiscoveryClient());
} else {
LOGGER.info("Discovery/Eureka is not enabled, use the dummy instance validator.");
instanceValidator = new DummyASGInstanceValidator();
}
if (configuration().getBoolOrElse("simianarmy.janitor.rule.oldEmptyASGRule.enabled", false)) {
ruleEngine.addRule(new OldEmptyASGRule(monkeyCalendar,
(int) configuration().getNumOrElse(
"simianarmy.janitor.rule.oldEmptyASGRule.launchConfigAgeThreshold", 50),
(int) configuration().getNumOrElse(
"simianarmy.janitor.rule.oldEmptyASGRule.retentionDays", 10),
instanceValidator
));
}
if (configuration().getBoolOrElse("simianarmy.janitor.rule.suspendedASGRule.enabled", false)) {
ruleEngine.addRule(new SuspendedASGRule(monkeyCalendar,
(int) configuration().getNumOrElse(
"simianarmy.janitor.rule.suspendedASGRule.suspensionAgeThreshold", 2),
(int) configuration().getNumOrElse(
"simianarmy.janitor.rule.suspendedASGRule.retentionDays", 5),
instanceValidator