diff --git a/webapp/src/main/java/com/box/l10n/mojito/entity/ScheduledJob.java b/webapp/src/main/java/com/box/l10n/mojito/entity/ScheduledJob.java index ac82666546..db725b2fa7 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/entity/ScheduledJob.java +++ b/webapp/src/main/java/com/box/l10n/mojito/entity/ScheduledJob.java @@ -55,9 +55,6 @@ public class ScheduledJob extends BaseEntity { @Column(name = "end_date") private Date endDate; - @Column(name = "allow_execution_overlap") - private boolean allowExecutionOverlap; - @PostLoad public void deserializeProperties() { ObjectMapper objectMapper = new ObjectMapper(); @@ -153,12 +150,4 @@ public Date getEndDate() { public void setEndDate(Date endDate) { this.endDate = endDate; } - - public boolean isAllowExecutionOverlap() { - return allowExecutionOverlap; - } - - public void setAllowExecutionOverlap(boolean allowExecutionOverlap) { - this.allowExecutionOverlap = allowExecutionOverlap; - } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/ScheduledJobManager.java b/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/ScheduledJobManager.java index 9a2bfa6ae8..476ecb8ba3 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/ScheduledJobManager.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/ScheduledJobManager.java @@ -108,8 +108,6 @@ public void pushJobToDB(ThirdPartySyncJobConfig jobConfig) { scheduledJob.setProperties(thirdPartySyncProperties); - scheduledJob.setAllowExecutionOverlap(false); - try { scheduledJobRepository.save(scheduledJob); } catch (DataIntegrityViolationException e) { diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/ScheduledJobTriggerListener.java b/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/ScheduledJobTriggerListener.java index 9c9cfa07f0..040f623e2d 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/ScheduledJobTriggerListener.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/ScheduledJobTriggerListener.java @@ -1,7 +1,6 @@ package com.box.l10n.mojito.service.scheduledjob; import com.box.l10n.mojito.entity.ScheduledJob; -import org.quartz.JobExecutionContext; import org.quartz.Trigger; import org.quartz.listeners.TriggerListenerSupport; import org.slf4j.Logger; @@ -22,15 +21,6 @@ public String getName() { return "ScheduledJobTriggerListener"; } - @Override - public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) { - // Returning true vetoes the job execution, if its in progress & we don't allow overlapping - // then skip execution - ScheduledJob job = scheduledJobRepository.findByJobKey(context.getJobDetail().getKey()); - return job.getJobStatus().equals(ScheduledJobStatus.IN_PROGRESS) - && !job.isAllowExecutionOverlap(); - } - @Override public void triggerMisfired(Trigger trigger) { super.triggerMisfired(trigger); diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/jobs/ScheduledThirdPartySync.java b/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/jobs/ScheduledThirdPartySync.java index 01d63e664e..b4f40ffcb5 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/jobs/ScheduledThirdPartySync.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/scheduledjob/jobs/ScheduledThirdPartySync.java @@ -4,10 +4,10 @@ import com.box.l10n.mojito.quartz.QuartzPollableTaskScheduler; import com.box.l10n.mojito.service.scheduledjob.IScheduledJob; import com.box.l10n.mojito.service.scheduledjob.ScheduledJobRepository; -import com.box.l10n.mojito.service.thirdparty.ThirdPartySyncJob; import com.box.l10n.mojito.service.thirdparty.ThirdPartySyncJobInput; import java.util.ArrayList; import java.util.List; +import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.slf4j.Logger; @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; @Component +@DisallowConcurrentExecution public class ScheduledThirdPartySync implements IScheduledJob { static Logger logger = LoggerFactory.getLogger(ScheduledThirdPartySync.class); @@ -57,10 +58,11 @@ public void execute(JobExecutionContext jobExecutionContext) throws JobExecution thirdPartySync.setOptions(options); try { - quartzPollableTaskScheduler - .scheduleJobWithCustomTimeout( - ThirdPartySyncJob.class, thirdPartySync, "thirdPartySync", 3600L) - .get(); + Thread.sleep(10000); + // quartzPollableTaskScheduler + // .scheduleJobWithCustomTimeout( + // ThirdPartySyncJob.class, thirdPartySync, "thirdPartySync", 3600L) + // .get(); } catch (Exception e) { throw new JobExecutionException(e); } diff --git a/webapp/src/main/resources/db/migration/V68__Add_Scheduled_Job.sql b/webapp/src/main/resources/db/migration/V68__Add_Scheduled_Job.sql new file mode 100644 index 0000000000..94357b9d39 --- /dev/null +++ b/webapp/src/main/resources/db/migration/V68__Add_Scheduled_Job.sql @@ -0,0 +1,18 @@ +CREATE TABLE scheduled_job ( + id bigint AUTO_INCREMENT PRIMARY KEY, + repository_id bigint NOT NULL, + job_type VARCHAR(255), + cron VARCHAR(15), + properties longtext NOT NULL, + job_status VARCHAR(255) NOT NULL, + start_date TIMESTAMP, + end_date TIMESTAMP, + created_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +ALTER TABLE scheduled_job + ADD UNIQUE KEY UK__REPOSITORY_ID__JOB_TYPE (repository_id, job_type); + +alter table `scheduled_job` + add constraint FK__SCHEDULED_JOB__IMPORT_REPOSITORY__ID + foreign key (repository_id) references repository (id); \ No newline at end of file