Search in sources :

Example 6 with IdmMonitoringFilter

use of eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter in project CzechIdMng by bcvsolutions.

the class ConfigurationChangeStageProcessor method findMonitoring.

/**
 * find already registered monitoring evaluator with synchronization identifier
 *
 * @return
 */
protected IdmMonitoringDto findMonitoring() {
    String evaluatorType = AutowireHelper.getTargetType(demoAdminMonitoringEvaluator);
    IdmMonitoringFilter filter = new IdmMonitoringFilter();
    filter.setEvaluatorType(evaluatorType);
    filter.setDisabled(Boolean.FALSE);
    // 
    return monitoringService.find(filter, null).stream().findFirst().orElse(null);
}
Also used : IdmMonitoringFilter(eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter)

Example 7 with IdmMonitoringFilter

use of eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter in project CzechIdMng by bcvsolutions.

the class InitMonitoringProcessor method findMonitoring.

/**
 * Find already configured monitoring evaluator.
 *
 * @param evaluatorType required
 * @param instanceId optional
 * @param evaluatorProperties optional
 * @return configured monitoring, if exists.
 */
public IdmMonitoringDto findMonitoring(String evaluatorType, String instanceId, ConfigurationMap evaluatorProperties) {
    IdmMonitoringFilter filter = new IdmMonitoringFilter();
    filter.setEvaluatorType(evaluatorType);
    filter.setInstanceId(instanceId);
    // 
    return monitoringService.find(filter, null).stream().filter(monitoring -> {
        if (evaluatorProperties == null) {
            return true;
        }
        for (String propertyName : evaluatorProperties.getKeys()) {
            if (!monitoring.getEvaluatorProperties().containsKey(propertyName)) {
                return false;
            }
            // toString conversion ~ properties from FE
            if (!monitoring.getEvaluatorProperties().get(propertyName).toString().equals(evaluatorProperties.get(propertyName).toString())) {
                return false;
            }
        }
        return true;
    }).findFirst().orElse(null);
}
Also used : IdmMonitoringFilter(eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter)

Example 8 with IdmMonitoringFilter

use of eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter in project CzechIdMng by bcvsolutions.

the class DefaultMonitoringManager method scheduleExecute.

/**
 * Spring schedule run all registered monitoring evaluators
 */
@Scheduled(fixedDelay = 10000)
public void scheduleExecute() {
    String instanceId = configurationService.getInstanceId();
    LOG.debug("Processing monitoring evaluators on instance id [{}]", instanceId);
    // 
    IdmMonitoringFilter filter = new IdmMonitoringFilter();
    filter.setDisabled(Boolean.FALSE);
    filter.setInstanceId(instanceId);
    // 
    List<IdmMonitoringDto> monitorings = monitoringService.find(filter, PageRequest.of(0, Integer.MAX_VALUE, Sort.by(IdmMonitoring_.seq.getName()))).getContent();
    // 
    for (IdmMonitoringDto monitoring : monitorings) {
        UUID monitoringId = monitoring.getId();
        // 
        // check execute date
        ZonedDateTime executeDate = monitoring.getExecuteDate();
        if (executeDate != null && ZonedDateTime.now().isBefore(executeDate)) {
            LOG.trace("Monitoring evaluator [{}] will be evaluted after [{}].", monitoringId, executeDate);
            // 
            continue;
        }
        // 
        // check last result is in period
        // seconds
        Long checkPeriod = monitoring.getCheckPeriod();
        if (checkPeriod == null) {
            checkPeriod = 0L;
        }
        // 
        IdmMonitoringResultDto lastResult = getLastResult(monitoringId);
        if (lastResult != null) {
            if (checkPeriod == 0 && firstExecuted) {
                LOG.trace("Monitoring evaluator [{}] was already executed.", monitoringId);
                // 
                continue;
            }
            // 
            if (lastResult.getCreated().isAfter(ZonedDateTime.now().minusSeconds(checkPeriod))) {
                LOG.trace("Monitoring evaluator [{}] was already executed.", monitoringId);
                // 
                continue;
            }
        }
        // 
        execute(monitoring);
    }
    // 
    firstExecuted = true;
}
Also used : IdmMonitoringFilter(eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter) IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) ZonedDateTime(java.time.ZonedDateTime) UUID(java.util.UUID) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 9 with IdmMonitoringFilter

use of eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter in project CzechIdMng by bcvsolutions.

the class AbstractMonitoringIgnoredBulkAction method findMonitoring.

/**
 * Find already registered monitoring evaluator.
 *
 * @return
 */
protected IdmMonitoringDto findMonitoring(MonitoringEvaluator monitoringEvaluator) {
    String evaluatorType = AutowireHelper.getTargetType(monitoringEvaluator);
    IdmMonitoringFilter filter = new IdmMonitoringFilter();
    filter.setEvaluatorType(evaluatorType);
    filter.setDisabled(Boolean.FALSE);
    // 
    return monitoringManager.findMonitorings(filter, null).stream().findFirst().orElse(null);
}
Also used : IdmMonitoringFilter(eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter)

Aggregations

IdmMonitoringFilter (eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter)9 IdmMonitoringDto (eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto)5 AutowireHelper (eu.bcvsolutions.idm.core.api.utils.AutowireHelper)2 IdmMonitoringResultDto (eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto)2 IdmMonitoringService (eu.bcvsolutions.idm.core.monitoring.api.service.IdmMonitoringService)2 List (java.util.List)2 UUID (java.util.UUID)2 Assert (org.junit.Assert)2 Test (org.junit.Test)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 TestHelper (eu.bcvsolutions.idm.acc.TestHelper)1 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)1 SysSyncIdentityConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto)1 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)1 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)1 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)1 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)1 SynchronizationMonitoringEvaluator (eu.bcvsolutions.idm.acc.monitoring.SynchronizationMonitoringEvaluator)1 SysSyncConfigService (eu.bcvsolutions.idm.acc.service.api.SysSyncConfigService)1