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