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

SchedulerService

parent 9a719f6d
...@@ -65,7 +65,7 @@ import java.util.concurrent.ScheduledFuture; ...@@ -65,7 +65,7 @@ import java.util.concurrent.ScheduledFuture;
@Log4j2 @Log4j2
@Component @Component
@EnableScheduling @EnableScheduling
@EnableSchedulerLock(defaultLockAtMostFor="PT30S") @EnableSchedulerLock(defaultLockAtMostFor="PT15M")
public class ScheduleService implements SchedulingConfigurer { public class ScheduleService implements SchedulingConfigurer {
ScheduledTaskRegistrar scheduledTaskRegistrar; ScheduledTaskRegistrar scheduledTaskRegistrar;
...@@ -202,12 +202,6 @@ public class ScheduleService implements SchedulingConfigurer { ...@@ -202,12 +202,6 @@ public class ScheduleService implements SchedulingConfigurer {
} else { } else {
timeZone = TimeZone.getTimeZone(zoneDefault); 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 */ /* Extraer el id del proceso - Delete */
ProcessETL processDelete = processETLRepository.findByName(ProcessETLEnum.PROCESS_DELETE.getName()); ProcessETL processDelete = processETLRepository.findByName(ProcessETLEnum.PROCESS_DELETE.getName());
...@@ -351,17 +345,18 @@ public class ScheduleService implements SchedulingConfigurer { ...@@ -351,17 +345,18 @@ public class ScheduleService implements SchedulingConfigurer {
/* Métodos utilizados para ETL de dashboard */ /* Métodos utilizados para ETL de dashboard */
@Scheduled(cron = "${application.byte-bot.batch.cron}") @Scheduled(cron = "${application.byte-bot.batch.cron}")
@SchedulerLock(name = "processJob", lockAtLeastFor = "30S", lockAtMostFor = "40S") @SchedulerLock(name = "Dashboard-ETL", lockAtLeastFor = "PT40S", lockAtMostFor = "PT50S")
protected Job createJob() { protected void createJob() {
List<Agent> agentDeployed = agentRepository.findByStatus(AgentStatusEnum.DEPLOYED); List<Agent> agentDeployed = agentRepository.findByStatus(AgentStatusEnum.DEPLOYED);
log.info("INICIADO");
if (!agentDeployed.isEmpty()) { if (!agentDeployed.isEmpty()) {
ThreadLocalStorage.setTenantName(tenant); ThreadLocalStorage.setTenantName(tenant);
return jobBuilderFactory.get("processJob") Job job = jobBuilderFactory.get("processJob")
.incrementer(new RunIdIncrementer()).listener(listener) .incrementer(new RunIdIncrementer()).listener(listener)
.flow(createStep(tenant)).end().build(); .flow(createStep(tenant)).end().build();
scheduleCron(job, tenant);
} else { } else {
log.info("No hay agentes deployados."); 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