Commit 31fd50ae authored by Roberto Loayza's avatar Roberto Loayza

SchedulerService

parent 9a719f6d
......@@ -65,7 +65,7 @@ import java.util.concurrent.ScheduledFuture;
@Log4j2
@Component
@EnableScheduling
@EnableSchedulerLock(defaultLockAtMostFor="PT30S")
@EnableSchedulerLock(defaultLockAtMostFor="PT15M")
public class ScheduleService implements SchedulingConfigurer {
ScheduledTaskRegistrar scheduledTaskRegistrar;
......@@ -202,12 +202,6 @@ public class ScheduleService implements SchedulingConfigurer {
} else {
timeZone = TimeZone.getTimeZone(zoneDefault);
}
Trigger trigger = new CronTrigger(cronExpression, timeZone);
/* ETL de Dashboard */
String key = String.format("%s-%s", tenantIdentifier, identifier);
futureMap.put(key, taskRegistrar.getScheduler().schedule(() -> scheduleCron(createJob(), tenantIdentifier), trigger));
/* Extraer el id del proceso - Delete */
ProcessETL processDelete = processETLRepository.findByName(ProcessETLEnum.PROCESS_DELETE.getName());
......@@ -351,17 +345,18 @@ public class ScheduleService implements SchedulingConfigurer {
/* Métodos utilizados para ETL de dashboard */
@Scheduled(cron = "${application.byte-bot.batch.cron}")
@SchedulerLock(name = "processJob", lockAtLeastFor = "30S", lockAtMostFor = "40S")
protected Job createJob() {
@SchedulerLock(name = "Dashboard-ETL", lockAtLeastFor = "PT40S", lockAtMostFor = "PT50S")
protected void createJob() {
List<Agent> agentDeployed = agentRepository.findByStatus(AgentStatusEnum.DEPLOYED);
log.info("INICIADO");
if (!agentDeployed.isEmpty()) {
ThreadLocalStorage.setTenantName(tenant);
return jobBuilderFactory.get("processJob")
Job job = jobBuilderFactory.get("processJob")
.incrementer(new RunIdIncrementer()).listener(listener)
.flow(createStep(tenant)).end().build();
scheduleCron(job, tenant);
} else {
log.info("No hay agentes deployados.");
return null;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment