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