Search in sources :

Example 6 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project NabAlive by jcheype.

the class ApplicationScheduler method taichi.

@Scheduled(fixedDelay = 400000)
public void taichi() {
    logger.debug("taichi trigger");
    // taichi
    Application application = checkNotNull(applicationManager.getApplication(TAICHI_APIKEY));
    Query<Nabaztag> query = nabaztagDAO.createQuery().filter("applicationConfigList.applicationStoreApikey", TAICHI_APIKEY);
    Iterator<Nabaztag> iterator = nabaztagDAO.find(query).iterator();
    while (iterator.hasNext()) {
        Nabaztag nabaztag = iterator.next();
        Status status = connectionManager.get(nabaztag.getMacAddress());
        if (status != null && status.isIdle()) {
            if (rand.nextInt(4) == 0) {
                try {
                    application.onStartup(nabaztag, findConfig(TAICHI_APIKEY, nabaztag.getApplicationConfigList()));
                } catch (Exception e) {
                    logger.debug("cannot send message", e);
                }
            }
        }
    }
}
Also used : Status(com.nabalive.server.jabber.Status) Nabaztag(com.nabalive.data.core.model.Nabaztag) Application(com.nabalive.application.core.Application) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 7 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project spatial-portal by AtlasOfLivingAustralia.

the class SpeciesListUtil method reloadCache.

/**
     * We are caching the values that will change often. Used to display i18n values in area report etc..
     * <p/>
     * schedule to run every 12 hours
     */
@Scheduled(fixedDelay = 43200000)
public void reloadCache() {
    //get the number of lists
    int num = getNumberOfPublicSpeciesLists(null);
    int total = 0;
    int max = 50;
    Map<String, String> tmpMap = new java.util.HashMap<String, String>();
    while (total < num) {
        Collection<SpeciesListDTO> batch = getPublicSpeciesLists(null, total, max, null, null, null, null);
        for (SpeciesListDTO item : batch) {
            tmpMap.put(item.getDataResourceUid(), item.getListName());
            total++;
        }
        LOGGER.debug("Cached lists: " + tmpMap);
    }
    speciesListMap = tmpMap;
}
Also used : SpeciesListDTO(au.org.ala.spatial.dto.SpeciesListDTO) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 8 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project OpenClinica by OpenClinica.

the class JobTriggerService method hourlyJobTrigger.

// @Scheduled(cron = "0 0/2 * * * ?") // trigger every 2 minutes
// @Scheduled(cron = "0 0/1 * * * ?")
// trigger every minute
@Scheduled(cron = "0 0 0/1 * * ?")
public // trigger every hour
void hourlyJobTrigger() throws NumberFormatException, ParseException {
    try {
        logger.debug("The time is now " + currentDateFormat.format(new Date()));
        triggerJob();
    } catch (Exception e) {
        logger.error(e.getMessage());
        logger.error(ExceptionUtils.getStackTrace(e));
        throw e;
    }
}
Also used : Date(java.util.Date) ParseException(java.text.ParseException) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 9 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project goci by EBISPOT.

the class DailyNcbiExportTask method dailyNcbiExport.

// Scheduled for 00:15
@Scheduled(cron = "0 15 0 * * SUN")
public void dailyNcbiExport() throws IOException {
    // Create date stamped file
    String uploadDir = System.getProperty("java.io.tmpdir") + File.separator + "gwas_ncbi_export" + File.separator;
    DateFormat df = new SimpleDateFormat("yyyy_MM_dd");
    String dateStamp = df.format(new Date());
    File outputFile = new File(uploadDir + dateStamp + "_gwas.txt");
    outputFile.getParentFile().mkdirs();
    // If at this stage we haven't got a file create one
    if (!outputFile.exists()) {
        outputFile.createNewFile();
    }
    getLog().info("Created file: " + outputFile);
    // Call methods to create NCBI spreadsheet
    String[][] data = catalogExportRepository.getNCBISpreadsheet();
    catalogSpreadsheetExporter.writeToFile(data, outputFile);
    // Check we have something in our output file
    if (outputFile.length() != 0) {
        getLog().info("Begin file upload to FTP...");
        ftpFileService.ftpFileUpload(outputFile);
    } else {
        getLog().error("File is empty");
    }
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Date(java.util.Date) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 10 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project Protocol-Adapter-IEC61850 by OSGP.

the class RtuSimulator method generateData.

@Scheduled(fixedDelay = 60000)
public void generateData() {
    synchronized (this.stopGeneratingValues) {
        if (!this.stopGeneratingValues.get()) {
            final Date timestamp = new Date();
            final List<BasicDataAttribute> values = new ArrayList<>();
            for (final LogicalDevice ld : this.logicalDevices) {
                values.addAll(ld.getAttributesAndSetValues(timestamp));
            }
            this.server.setValues(values);
            LOGGER.info("Generated values");
        }
    }
}
Also used : LogicalDevice(com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.LogicalDevice) ArrayList(java.util.ArrayList) BasicDataAttribute(org.openmuc.openiec61850.BasicDataAttribute) Date(java.util.Date) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Aggregations

Scheduled (org.springframework.scheduling.annotation.Scheduled)40 Date (java.util.Date)9 IOException (java.io.IOException)6 HashMap (java.util.HashMap)5 Contributor (ai.elimu.model.Contributor)4 Locale (ai.elimu.model.enums.Locale)4 Nabaztag (com.nabalive.data.core.model.Nabaztag)4 StoryBook (ai.elimu.model.content.StoryBook)3 Word (ai.elimu.model.content.Word)3 Application (com.nabalive.application.core.Application)3 Status (com.nabalive.server.jabber.Status)3 File (java.io.File)3 SimpleDateFormat (java.text.SimpleDateFormat)3 ArrayList (java.util.ArrayList)3 DisruptorBindEvent (com.lmax.disruptor.spring.boot.event.DisruptorBindEvent)2 BigDecimal (java.math.BigDecimal)2 DateFormat (java.text.DateFormat)2 LocalDate (java.time.LocalDate)2 Map (java.util.Map)2 ExecutionException (java.util.concurrent.ExecutionException)2