Search in sources :

Example 1 with DateTime

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);
}
Also used : LinkedList(java.util.LinkedList) DateTime(org.ovirt.engine.core.compat.DateTime) Date(java.util.Date) Test(org.junit.Test)

Example 2 with DateTime

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);
}
Also used : LinkedList(java.util.LinkedList) DateTime(org.ovirt.engine.core.compat.DateTime) Date(java.util.Date) Test(org.junit.Test)

Example 3 with DateTime

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);
    }
}
Also used : DateTime(org.ovirt.engine.core.compat.DateTime)

Example 4 with DateTime

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());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) EngineCronTrigger(org.ovirt.engine.core.common.utils.EngineCronTrigger) Date(java.util.Date) DateTime(org.ovirt.engine.core.compat.DateTime) PostConstruct(javax.annotation.PostConstruct)

Example 5 with DateTime

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);
    }
}
Also used : DateTime(org.ovirt.engine.core.compat.DateTime)

Aggregations

DateTime (org.ovirt.engine.core.compat.DateTime)10 Date (java.util.Date)7 Calendar (java.util.Calendar)3 LinkedList (java.util.LinkedList)3 Test (org.junit.Test)3 GregorianCalendar (java.util.GregorianCalendar)2 PostConstruct (javax.annotation.PostConstruct)2 EngineCronTrigger (org.ovirt.engine.core.common.utils.EngineCronTrigger)2 DateFormat (java.text.DateFormat)1 DateEnumForSearch (org.ovirt.engine.core.common.businessentities.DateEnumForSearch)1 Tags (org.ovirt.engine.core.common.businessentities.Tags)1 Pair (org.ovirt.engine.core.common.utils.Pair)1 Guid (org.ovirt.engine.core.compat.Guid)1 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)1