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);
}
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);
}
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;
}
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);
}
Aggregations