Search in sources :

Example 91 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project archiva by apache.

the class TemporaryGroupIndexCleaner method cleanTemporaryIndex.

// 900000
@Scheduled(fixedDelay = 900000)
public void cleanTemporaryIndex() {
    indexMerger.getTemporaryGroupIndexes().stream().forEach(temporaryGroupIndex -> {
        // cleanup files older than the ttl
        if (new Date().getTime() - temporaryGroupIndex.getCreationTime() > temporaryGroupIndex.getMergedIndexTtl()) {
            log.info("cleanTemporaryIndex for groupId {}", temporaryGroupIndex.getGroupId());
            indexMerger.cleanTemporaryGroupIndex(temporaryGroupIndex);
        }
    });
}
Also used : Date(java.util.Date) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 92 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project herd by FINRAOS.

the class SearchIndexUpdateJmsMessageListener method controlSearchIndexUpdateJmsMessageListener.

/**
 * Periodically check the configuration and apply the action to the storage policy processor JMS message listener service, if needed.
 */
@Scheduled(fixedDelay = 60000)
public void controlSearchIndexUpdateJmsMessageListener() {
    try {
        // Get the configuration setting.
        Boolean jmsMessageListenerEnabled = Boolean.valueOf(configurationHelper.getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED));
        // Get the registry bean.
        JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext().getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
        // Get the search index update JMS message listener container.
        MessageListenerContainer jmsMessageListenerContainer = registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_SEARCH_INDEX_UPDATE_QUEUE);
        // Get the current JMS message listener status and the configuration value.
        LOGGER.debug("controlSearchIndexUpdateJmsMessageListener(): {}={} jmsMessageListenerContainer.isRunning()={}", ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED.getKey(), jmsMessageListenerEnabled, jmsMessageListenerContainer.isRunning());
        // Apply the relative action if needed.
        if (!jmsMessageListenerEnabled && jmsMessageListenerContainer.isRunning()) {
            LOGGER.info("controlSearchIndexUpdateJmsMessageListener(): Stopping the search index update JMS message listener ...");
            jmsMessageListenerContainer.stop();
            LOGGER.info("controlSearchIndexUpdateJmsMessageListener(): Done");
        } else if (jmsMessageListenerEnabled && !jmsMessageListenerContainer.isRunning()) {
            LOGGER.info("controlSearchIndexUpdateJmsMessageListener(): Starting the search index update JMS message listener ...");
            jmsMessageListenerContainer.start();
            LOGGER.info("controlSearchIndexUpdateJmsMessageListener(): Done");
        }
    } catch (Exception e) {
        LOGGER.error("controlSearchIndexUpdateJmsMessageListener(): Failed to control the search index update Jms message listener service.", e);
    }
}
Also used : JmsListenerEndpointRegistry(org.springframework.jms.config.JmsListenerEndpointRegistry) MessageListenerContainer(org.springframework.jms.listener.MessageListenerContainer) IOException(java.io.IOException) ListenerExecutionFailedException(org.springframework.jms.listener.adapter.ListenerExecutionFailedException) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 93 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project spring-cloud-framework by zhuwj921.

the class QuartzService method timerToNow.

@Scheduled(cron = "0/5 * * * * ? ")
public void timerToNow() {
    testFeginService.test();
    System.out.println("now time:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 94 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project webcert by sklintyg.

the class PagaendeSigneringCleanupServiceImpl method cleanup.

@Scheduled(cron = "${signature.cleanup.cron}")
public void cleanup() {
    List<PagaendeSignering> all = pagaendeSigneringRepository.findAll();
    if (all == null || all.isEmpty()) {
        return;
    }
    LOG.info("Running stale signature cleanup. There are currently {} ongoing signatures.", all.size());
    LocalDateTime evictIfOlderThan = LocalDateTime.now().minusMinutes(EVICT_OLDER_THAN_MINUTES);
    Iterator<PagaendeSignering> iterator = all.stream().filter(ps -> ps.getSigneringsDatum().isBefore(evictIfOlderThan)).iterator();
    while (iterator.hasNext()) {
        PagaendeSignering pagaendeSignering = iterator.next();
        Long id = pagaendeSignering.getInternReferens();
        String intygsId = pagaendeSignering.getIntygsId();
        pagaendeSigneringRepository.delete(pagaendeSignering.getInternReferens());
        LOG.info("Removed stale PagaendeSignering with id '{}' for intygs-id '{}'. " + "This is perfectly normal if the signing user didn't complete the signing.", id, intygsId);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) LoggerFactory(org.slf4j.LoggerFactory) LocalDateTime(java.time.LocalDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) Scheduled(org.springframework.scheduling.annotation.Scheduled) Profile(org.springframework.context.annotation.Profile) PagaendeSigneringRepository(se.inera.intyg.webcert.persistence.utkast.repository.PagaendeSigneringRepository) List(java.util.List) PagaendeSignering(se.inera.intyg.webcert.persistence.utkast.model.PagaendeSignering) Service(org.springframework.stereotype.Service) EnableScheduling(org.springframework.scheduling.annotation.EnableScheduling) Transactional(org.springframework.transaction.annotation.Transactional) PagaendeSignering(se.inera.intyg.webcert.persistence.utkast.model.PagaendeSignering) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 95 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project faf-java-server by FAForever.

the class GeoIpService method updateDatabaseFile.

@Scheduled(cron = "0 0 0 * * WED")
public void updateDatabaseFile() throws IOException {
    GeoIp geoIp = properties.getGeoIp();
    Path geoIpFile = geoIp.getDatabaseFile();
    String databaseUrl = geoIp.getDatabaseUrl();
    log.debug("Downloading GeoIp database from '{}' to '{}'", databaseUrl, geoIpFile.toAbsolutePath());
    synchronized (DATABASE_LOCK) {
        URL url = new URL(databaseUrl);
        try (InputStream inputStream = new BufferedInputStream(new GZIPInputStream(url.openStream()))) {
            Files.createDirectories(geoIpFile.getParent());
            Files.copy(inputStream, geoIpFile, StandardCopyOption.REPLACE_EXISTING);
        }
        readDatabase(geoIpFile);
    }
}
Also used : GeoIp(com.faforever.server.config.ServerProperties.GeoIp) Path(java.nio.file.Path) GZIPInputStream(java.util.zip.GZIPInputStream) BufferedInputStream(java.io.BufferedInputStream) GZIPInputStream(java.util.zip.GZIPInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) URL(java.net.URL) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Aggregations

Scheduled (org.springframework.scheduling.annotation.Scheduled)140 Date (java.util.Date)38 IOException (java.io.IOException)17 HashMap (java.util.HashMap)15 ArrayList (java.util.ArrayList)12 File (java.io.File)9 List (java.util.List)9 User (io.github.jhipster.sample.domain.User)8 SimpleDateFormat (java.text.SimpleDateFormat)8 LocalDate (java.time.LocalDate)8 Map (java.util.Map)8 Word (ai.elimu.model.content.Word)6 Instant (java.time.Instant)6 SysConfig (com.itrus.portal.db.SysConfig)5 InetAddress (java.net.InetAddress)5 UnknownHostException (java.net.UnknownHostException)5 Contributor (ai.elimu.model.Contributor)4 StoryBookParagraph (ai.elimu.model.content.StoryBookParagraph)4 Language (ai.elimu.model.v2.enums.Language)4 Nabaztag (com.nabalive.data.core.model.Nabaztag)4