/** * Method which executes each registered cleanup task for each tenant. */ @SuppressWarnings("squid:S3516") private Void executeAutoCleanup() { systemManagement.forEachTenant(tenant -> cleanupTasks.forEach(task -> { final Lock lock = obtainLock(task, tenant); if (!lock.tryLock()) { return; } try { task.run(); } catch (final RuntimeException e) { LOGGER.error("Cleanup task failed.", e); } finally { lock.unlock(); } })); return null; }
/** * Method which executes each registered cleanup task for each tenant. */ @SuppressWarnings("squid:S3516") private Void executeAutoCleanup() { systemManagement.forEachTenant(tenant -> cleanupTasks.forEach(task -> { final Lock lock = obtainLock(task, tenant); if (!lock.tryLock()) { return; } try { task.run(); } catch (final RuntimeException e) { LOGGER.error("Cleanup task failed.", e); } finally { lock.unlock(); } })); return null; }
/** * Scheduler method called by the spring-async mechanism. Retrieves all * tenants from the {@link SystemManagement#findTenants()} and runs for each * tenant the {@link RolloutManagement#handleRollouts()} in the * {@link SystemSecurityContext}. */ @Scheduled(initialDelayString = PROP_SCHEDULER_DELAY_PLACEHOLDER, fixedDelayString = PROP_SCHEDULER_DELAY_PLACEHOLDER) public void runningRolloutScheduler() { LOGGER.debug("rollout schedule checker has been triggered."); // run this code in system code privileged to have the necessary // permission to query and create entities. systemSecurityContext.runAsSystem(() -> { // workaround eclipselink that is currently not possible to // execute a query without multitenancy if MultiTenant // annotation is used. // https://bugs.eclipse.org/bugs/show_bug.cgi?id=355458. So // iterate through all tenants and execute the rollout check for // each tenant seperately. systemManagement.forEachTenant(tenant -> rolloutManagement.handleRollouts()); return null; }); }
/** * Scheduler method called by the spring-async mechanism. Retrieves all * tenants from the {@link SystemManagement#findTenants()} and runs for each * tenant the {@link RolloutManagement#handleRollouts()} in the * {@link SystemSecurityContext}. */ @Scheduled(initialDelayString = PROP_SCHEDULER_DELAY_PLACEHOLDER, fixedDelayString = PROP_SCHEDULER_DELAY_PLACEHOLDER) public void runningRolloutScheduler() { LOGGER.debug("rollout schedule checker has been triggered."); // run this code in system code privileged to have the necessary // permission to query and create entities. systemSecurityContext.runAsSystem(() -> { // workaround eclipselink that is currently not possible to // execute a query without multitenancy if MultiTenant // annotation is used. // https://bugs.eclipse.org/bugs/show_bug.cgi?id=355458. So // iterate through all tenants and execute the rollout check for // each tenant seperately. systemManagement.forEachTenant(tenant -> rolloutManagement.handleRollouts()); return null; }); }
@SuppressWarnings("squid:S3516") private Object executeAutoAssign() { // workaround eclipselink that is currently not possible to // execute a query without multitenancy if MultiTenant // annotation is used. // https://bugs.eclipse.org/bugs/show_bug.cgi?id=355458. So // iterate through all tenants and execute the rollout check for // each tenant separately. final Lock lock = lockRegistry.obtain("autoassign"); if (!lock.tryLock()) { return null; } try { systemManagement.forEachTenant(tenant -> autoAssignChecker.check()); } finally { lock.unlock(); } return null; } }
@SuppressWarnings("squid:S3516") private Object executeAutoAssign() { // workaround eclipselink that is currently not possible to // execute a query without multitenancy if MultiTenant // annotation is used. // https://bugs.eclipse.org/bugs/show_bug.cgi?id=355458. So // iterate through all tenants and execute the rollout check for // each tenant separately. final Lock lock = lockRegistry.obtain("autoassign"); if (!lock.tryLock()) { return null; } try { systemManagement.forEachTenant(tenant -> autoAssignChecker.check()); } finally { lock.unlock(); } return null; } }