Compare commits
No commits in common. "7e82bd6a98d37353f6d82224de96f1c5eec495c1" and "d0d60a6fe5ff4e6681aa57944c5d0cadaef814a2" have entirely different histories.
7e82bd6a98
...
d0d60a6fe5
|
|
@ -211,12 +211,11 @@ public class AgentService {
|
|||
.filter(s -> agentOrgId == null || agentOrgId.equals(s.getOrgId()))
|
||||
.toList();
|
||||
|
||||
if (!activeJobs.isEmpty()) {
|
||||
unwrapSchedulerToJobs(activeJobs.get(0), agentOrgId);
|
||||
if (activeJobs.isEmpty()) {
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void unwrapSchedulerToJobs(Scheduler job, Long agentOrgId) {
|
||||
Scheduler job = activeJobs.get(0);
|
||||
job.setStatus("processing");
|
||||
schedulerRepository.save(job);
|
||||
|
||||
|
|
@ -298,7 +297,6 @@ public class AgentService {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bug fix: replaced unbounded recursion with a simple retry — pick up one of the jobs just created.
|
||||
// The recursive approach had no depth limit and could cause a StackOverflowError
|
||||
|
|
|
|||
|
|
@ -19,11 +19,9 @@ public class CronExecutionEngine {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CronExecutionEngine.class);
|
||||
private final SchedulerRepository schedulerRepository;
|
||||
private final AgentService agentService;
|
||||
|
||||
public CronExecutionEngine(SchedulerRepository schedulerRepository, AgentService agentService) {
|
||||
public CronExecutionEngine(SchedulerRepository schedulerRepository) {
|
||||
this.schedulerRepository = schedulerRepository;
|
||||
this.agentService = agentService;
|
||||
}
|
||||
|
||||
// Runs at the 0th second of every minute
|
||||
|
|
@ -82,7 +80,6 @@ public class CronExecutionEngine {
|
|||
// Check time match (truncated to minutes)
|
||||
LocalTime nowTime = now.toLocalTime().truncatedTo(ChronoUnit.MINUTES);
|
||||
LocalTime targetTime = scheduledTime.truncatedTo(ChronoUnit.MINUTES);
|
||||
logger.info("Evaluating schedule ID {} | Timezone: {} | nowTime: {} | targetTime: {}", s.getId(), s.getTimezone(), nowTime, targetTime);
|
||||
if (!nowTime.equals(targetTime)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -202,12 +199,7 @@ public class CronExecutionEngine {
|
|||
job.setStatus("active");
|
||||
job.setOrgId(original.getOrgId());
|
||||
job.setEnvironmentId(original.getEnvironmentId());
|
||||
job = schedulerRepository.save(job);
|
||||
logger.info("Queued test suite '{}' for execution. Instantly unwrapping to executions.", job.getTestSuiteName());
|
||||
try {
|
||||
agentService.unwrapSchedulerToJobs(job, original.getOrgId());
|
||||
} catch(Exception e) {
|
||||
logger.error("Failed to unwrap scheduler into execution: " + e.getMessage(), e);
|
||||
}
|
||||
schedulerRepository.save(job);
|
||||
logger.info("Queued test suite '{}' for execution via local agent polling", job.getTestSuiteName());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
|
||||
import java.time.*;
|
||||
public class test_kolkata {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println(ZoneId.of("Asia/Kolkata"));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
test_tz.java
19
test_tz.java
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
import java.time.*;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
public class test_tz {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
ZoneId zone = ZoneId.of("Asia/Calcutta");
|
||||
LocalDateTime now = LocalDateTime.now(zone).truncatedTo(ChronoUnit.MINUTES);
|
||||
System.out.println("Now in Asia/Calcutta: " + now);
|
||||
LocalTime scheduledTime = LocalTime.parse("11:48:00");
|
||||
LocalTime nowTime = now.toLocalTime();
|
||||
System.out.println("Is equal? " + nowTime.equals(scheduledTime));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue