Search in sources :

Example 1 with Scheduled

use of io.quarkus.scheduler.Scheduled in project apicurio-registry by Apicurio.

the class LogConfigurationService method checkLogLevel.

@Scheduled(concurrentExecution = ConcurrentExecution.SKIP, delayed = "{registry.logconfigjob.delayed}", every = "{registry.logconfigjob.every}")
public void checkLogLevel() {
    if (!storage.isAlive() || !storage.isReady()) {
        return;
    }
    LOGGER.trace("Running periodic log configuration process");
    for (LogConfigurationDto logConfig : storage.listLogConfigurations()) {
        Logger logger = Logger.getLogger(logConfig.getLogger());
        Level expectedLevel = Level.parse(logConfig.getLogLevel().value());
        if (!getLogLevel(logger).equals(expectedLevel)) {
            LOGGER.info(String.format("Updating logger %s to log level %s", logConfig.getLogger(), logConfig.getLogLevel().value()));
            logger.setLevel(expectedLevel);
        }
        if (logConfig.getLogLevel().value().equals(defaultLogLevel)) {
            LOGGER.info(String.format("Cleaning persisted config for logger %s because default log level is configured %s", logConfig.getLogger(), logConfig.getLogLevel().value()));
            storage.removeLogConfiguration(logConfig.getLogger());
        }
    }
}
Also used : LogConfigurationDto(io.apicurio.registry.storage.dto.LogConfigurationDto) LogLevel(io.apicurio.registry.types.LogLevel) Level(java.util.logging.Level) Logger(java.util.logging.Logger) Scheduled(io.quarkus.scheduler.Scheduled)

Example 2 with Scheduled

use of io.quarkus.scheduler.Scheduled in project apicurio-registry by Apicurio.

the class TenantReaper method run.

/**
 * Minimal granularity is 1 minute.
 */
@Scheduled(concurrentExecution = SKIP, every = "{registry.multitenancy.reaper.every}")
void run() {
    if (!properties.isMultitenancyEnabled()) {
        return;
    }
    final Instant now = Instant.now();
    if (now.isAfter(next)) {
        try {
            log.debug("Running tenant reaper job at {}", now);
            reap();
            // Only force cache invalidation if the reaper period is less than 1 minute (testing support).
            if (properties.getReaperPeriod().compareTo(Duration.ofSeconds(60)) < 0) {
                tcl.invalidateTenantCache();
            }
        } catch (Exception ex) {
            log.error("Exception thrown when running tenant reaper job", ex);
        } finally {
            next = now.plus(properties.getReaperPeriod());
            log.debug("Running next tenant reaper job at around {}", next);
        }
    }
}
Also used : Instant(java.time.Instant) Scheduled(io.quarkus.scheduler.Scheduled)

Example 3 with Scheduled

use of io.quarkus.scheduler.Scheduled in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class WorkManagerImpl method reconnectDroppedWorkers.

@SuppressWarnings("unused")
@Transactional
@Scheduled(every = "5m", concurrentExecution = Scheduled.ConcurrentExecution.SKIP)
void reconnectDroppedWorkers() {
    ZonedDateTime age = ZonedDateTime.now().minusMinutes(5);
    workDAO.reconnectDroppedWorkers(workerIdProvider.getWorkerId(), age);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Scheduled(io.quarkus.scheduler.Scheduled) Transactional(javax.transaction.Transactional)

Example 4 with Scheduled

use of io.quarkus.scheduler.Scheduled in project openk9 by smclab.

the class TenantRegistry method initializeTenantMap.

@Scheduled(every = "30s")
@Blocking
void initializeTenantMap() {
    List<Tenant> listTenant = Tenant.<Tenant>list("active = true").await().indefinitely();
    Map<String, Tenant> map = new HashMap<>(listTenant.size());
    for (Tenant tenant : listTenant) {
        map.put(tenant.getVirtualHost(), tenant);
    }
    _tenantMap.clear();
    _tenantMap.putAll(map);
}
Also used : Tenant(io.openk9.api.aggregator.model.Tenant) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Scheduled(io.quarkus.scheduler.Scheduled) Blocking(io.smallrye.common.annotation.Blocking)

Example 5 with Scheduled

use of io.quarkus.scheduler.Scheduled in project policies-ui-backend by RedHatInsights.

the class ProcSelfStatusExporter method gather.

@Scheduled(every = "10s")
void gather() {
    File status = new File(PATHNAME);
    if (!status.exists() || !status.canRead()) {
        if (!hasWarned) {
            log.warning("Can't read " + PATHNAME);
            hasWarned = true;
        }
        return;
    }
    try (Scanner fr = new Scanner(status)) {
        while (fr.hasNextLine()) {
            String line = fr.nextLine();
            String[] parts = line.split("[ \t]+");
            switch(parts[0]) {
                case "VmHWM:":
                    vmHwm = Long.parseLong(parts[1]);
                    break;
                case "VmRSS:":
                    vmRss = Long.parseLong(parts[1]);
                    break;
                case "RssAnon:":
                    rssAnon = Long.parseLong(parts[1]);
                    break;
                case "RssFile:":
                    rssFile = Long.parseLong(parts[1]);
                    break;
                case "VmStk:":
                    vmStk = Long.parseLong(parts[1]);
                    break;
                case "VmLib:":
                    vmLib = Long.parseLong(parts[1]);
                    break;
                case "VmData:":
                    vmData = Long.parseLong(parts[1]);
                    break;
                case "VmSize:":
                    vmSize = Long.parseLong(parts[1]);
                    break;
                case "Threads:":
                    threads = Integer.parseInt(parts[1]);
                    break;
                default:
            }
        }
    } catch (Exception e) {
        log.warning("Reading failed: " + e.getMessage());
    }
}
Also used : Scanner(java.util.Scanner) File(java.io.File) Scheduled(io.quarkus.scheduler.Scheduled)

Aggregations

Scheduled (io.quarkus.scheduler.Scheduled)5 LogConfigurationDto (io.apicurio.registry.storage.dto.LogConfigurationDto)1 LogLevel (io.apicurio.registry.types.LogLevel)1 Tenant (io.openk9.api.aggregator.model.Tenant)1 Blocking (io.smallrye.common.annotation.Blocking)1 File (java.io.File)1 Instant (java.time.Instant)1 ZonedDateTime (java.time.ZonedDateTime)1 HashMap (java.util.HashMap)1 Scanner (java.util.Scanner)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 Transactional (javax.transaction.Transactional)1