use of org.ovirt.engine.core.compat.DateTime in project ovirt-engine by oVirt.
the class FenceValidatorTest method succeedWhenStartupTimeoutHasPassed.
@Test
public void succeedWhenStartupTimeoutHasPassed() {
List<String> messages = new LinkedList<>();
mcr.mockConfigValue(ConfigValues.DisableFenceAtStartupInSec, 5);
when(backend.getStartedAt()).thenReturn(new DateTime(new Date().getTime() - 20000));
boolean result = validator.isStartupTimeoutPassed(messages);
assertTrue(result);
}
use of org.ovirt.engine.core.compat.DateTime in project ovirt-engine by oVirt.
the class FenceValidatorTest method failWhenStartupTimeoutHasNotPassed.
@Test
public void failWhenStartupTimeoutHasNotPassed() {
List<String> messages = new LinkedList<>();
mcr.mockConfigValue(ConfigValues.DisableFenceAtStartupInSec, 5);
when(backend.getStartedAt()).thenReturn(new DateTime(new Date()));
boolean result = validator.isStartupTimeoutPassed(messages);
assertEquals(1, messages.size());
assertEquals("VDS_FENCE_DISABLED_AT_SYSTEM_STARTUP_INTERVAL", messages.get(0));
assertFalse(result);
}
use of org.ovirt.engine.core.compat.DateTime in project ovirt-engine by oVirt.
the class AuditLogCleanupManager method cleanup.
public void cleanup() {
try {
log.debug("Start cleanup");
DateTime latestTimeToKeep = DateTime.getNow().addDays(Config.<Integer>getValue(ConfigValues.AuditLogAgingThreshold) * -1);
auditLogDao.removeAllBeforeDate(latestTimeToKeep);
log.debug("Finished cleanup");
} catch (Throwable t) {
log.error("Exception in performing audit log cleanup: {}", ExceptionUtils.getRootCauseMessage(t));
log.debug("Exception", t);
}
}
use of org.ovirt.engine.core.compat.DateTime in project ovirt-engine by oVirt.
the class AuditLogCleanupManager method init.
@PostConstruct
private void init() {
log.info("Start initializing {}", getClass().getSimpleName());
Calendar calendar = new GregorianCalendar();
Date auditLogCleanupTime = Config.<DateTime>getValue(ConfigValues.AuditLogCleanupTime);
calendar.setTimeInMillis(auditLogCleanupTime.getTime());
String cronExpression = String.format("%d %d %d * * ?", calendar.get(Calendar.SECOND), calendar.get(Calendar.MINUTE), calendar.get(Calendar.HOUR_OF_DAY));
log.info("Setting audit cleanup manager to run at '{}'", cronExpression);
executor.schedule(this::cleanup, new EngineCronTrigger(cronExpression));
log.info("Finished initializing {}", getClass().getSimpleName());
}
use of org.ovirt.engine.core.compat.DateTime in project ovirt-engine by oVirt.
the class CommandEntityCleanupManager method cleanup.
private void cleanup() {
try {
log.debug("Start cleanup");
DateTime latestTimeToKeep = DateTime.getNow().addDays(Config.<Integer>getValue(ConfigValues.CommandEntityAgingThreshold) * -1);
commandCoordinatorUtil.removeAllCommandsBeforeDate(latestTimeToKeep);
log.debug("Finished cleanup");
} catch (Throwable t) {
log.error("Exception in performing command entity cleanup: {}", ExceptionUtils.getRootCauseMessage(t));
log.debug("Exception", t);
}
}
Aggregations