use of fr.univlorraine.ecandidat.entities.ecandidat.BatchRun in project esup-ecandidat by EsupPortail.
the class BatchController method checkBatchRun.
/**
* Vérifie si un batch doit etre lancé depuis la dernière date de verification
*/
@Scheduled(fixedDelayString = "${batch.fixedRate}")
public void checkBatchRun() {
if (!loadBalancingController.isLoadBalancingCandidatMode()) {
final List<BatchRun> liste = batchRunRepository.findAll();
if (liste != null && liste.size() == 1) {
final BatchRun lastBatchRun = liste.get(0);
final List<Batch> listeBatch = batchRepository.findByTesBatch(true);
logger.trace("Vérification lancement lastChek = " + lastBatchRun.getDatLastCheckRun() + " - Now = " + LocalDateTime.now());
/* Suppression du dernier batch run */
nettoyageBatchRun();
listeBatch.forEach(batch -> {
final BatchHisto histo = batchHistoRepository.findByBatchCodBatchAndStateBatchHisto(batch.getCodBatch(), ConstanteUtils.BATCH_RUNNING);
if (histo == null && isNeededToLaunch(batch, lastBatchRun.getDatLastCheckRun())) {
logger.debug("Le batch " + batch.getCodBatch() + " doit être lancé");
runJob(batch);
}
});
} else {
nettoyageBatchRun();
}
}
}
use of fr.univlorraine.ecandidat.entities.ecandidat.BatchRun in project esup-ecandidat by EsupPortail.
the class BatchController method nettoyageBatchRun.
/**
* Nettoyage de la table BatchRun
*/
private void nettoyageBatchRun() {
batchRunRepository.deleteAll();
batchRunRepository.saveAndFlush(new BatchRun(LocalDateTime.now()));
}
use of fr.univlorraine.ecandidat.entities.ecandidat.BatchRun in project esup-ecandidat by EsupPortail.
the class BatchController method getInfoRun.
/**
* @return les informations de run des batchs
*/
public String getInfoRun() {
/* On cherche le dernier lancement */
final BatchRun run = batchRunRepository.findFirst1By();
/* Calcul du batchFixedRate */
final Integer batchFixedRateInt = MethodUtils.getStringMillisecondeToInt(batchFixedRate);
final String batchFixedRateLabel = MethodUtils.getIntMillisecondeToString(batchFixedRateInt);
/* Le dernier lancement */
String datLastCheckRunLabel;
if (run == null) {
datLastCheckRunLabel = "-";
} else {
datLastCheckRunLabel = formatterDateTime.format(run.getDatLastCheckRun());
}
/* Le prochain lancement */
String datNextCheckRunLabel;
if (run == null) {
datNextCheckRunLabel = "-";
} else {
datNextCheckRunLabel = formatterDateTime.format(run.getDatLastCheckRun().plus(Long.valueOf(batchFixedRateInt), ChronoUnit.MILLIS));
}
return applicationContext.getMessage("batch.info.run", new Object[] { batchFixedRateLabel, datLastCheckRunLabel, datNextCheckRunLabel }, UI.getCurrent().getLocale());
}
Aggregations