if (groupDefinitionIdsToRecalculate.size() == 0) {
return; // this will skip the info logging, so we only log when this method does something meaningful
}
GroupDefinitionRecalculationThreadMonitorMBean monitor = GroupDefinitionRecalculationThreadMonitor.getMBean();
long totalStart = System.currentTimeMillis();
for (Integer groupDefinitionId : groupDefinitionIdsToRecalculate) {
long singleStart = System.currentTimeMillis();
boolean success = false;
try {
groupDefinitionManager.calculateGroupMembership(subject, groupDefinitionId);
success = true;
} catch (Throwable t) {
/*
* be paranoid about capturing any and all kinds of errors, to give a chances for
* all recalculations to complete in this (heart)beat of the recalculation thread
*/
log.error("Error recalculating DynaGroups for GroupDefinition[id=" + groupDefinitionId + "]", t);
}
long singleEnd = System.currentTimeMillis();
try {
GroupDefinition groupDefinition = getById(groupDefinitionId);
int size = getManagedResourceGroupSizeForGroupDefinition(groupDefinitionId);
monitor.updateStatistic(groupDefinition.getName(), size, success, singleEnd - singleStart);
} catch (Throwable t) {
log.error("Error updating DynaGroup statistics GroupDefinition[id=" + groupDefinitionId + "]", t);
// ignore error during statistic update
}
}
long totalEnd = System.currentTimeMillis();
monitor.updateAutoRecalculationThreadTime(totalEnd - totalStart);
}