Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat (Core): Implement abandoned job detection and recovery #30710

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ public class JobQueueConfig {
*/
private final int threadPoolSize;

// The interval in milliseconds to poll for job updates
private final int pollJobUpdatesIntervalMilliseconds;

/**
* Constructs a new JobQueueConfig
*
* @param threadPoolSize The number of threads to use for job processing.
* @param pollJobUpdatesIntervalMilliseconds The interval in milliseconds to poll for job updates.
*/
public JobQueueConfig(int threadPoolSize, int pollJobUpdatesIntervalMilliseconds) {
public JobQueueConfig(int threadPoolSize) {
this.threadPoolSize = threadPoolSize;
this.pollJobUpdatesIntervalMilliseconds = pollJobUpdatesIntervalMilliseconds;
}

/**
Expand All @@ -33,13 +28,4 @@ public int getThreadPoolSize() {
return threadPoolSize;
}

/**
* Gets the interval in milliseconds to poll for job updates.
*
* @return The interval in milliseconds to poll for job updates.
*/
public int getPollJobUpdatesIntervalMilliseconds() {
return pollJobUpdatesIntervalMilliseconds;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ public class JobQueueConfigProducer {
"JOB_QUEUE_THREAD_POOL_SIZE", 10
);

// The interval in milliseconds to poll for job updates.
static final int DEFAULT_POLL_JOB_UPDATES_INTERVAL_MILLISECONDS = Config.getIntProperty(
"JOB_QUEUE_POLL_JOB_UPDATES_INTERVAL_MILLISECONDS", 3000
);

/**
* Produces a JobQueueConfig object. This method is called by the CDI container to create a
* JobQueueConfig instance when it is necessary for dependency injection.
Expand All @@ -30,8 +25,7 @@ public class JobQueueConfigProducer {
@Produces
public JobQueueConfig produceJobQueueConfig() {
return new JobQueueConfig(
DEFAULT_THREAD_POOL_SIZE,
DEFAULT_POLL_JOB_UPDATES_INTERVAL_MILLISECONDS
DEFAULT_THREAD_POOL_SIZE
);
}

Expand Down

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.dotcms.jobs.business.api.events;

import com.dotcms.jobs.business.job.Job;
import java.time.LocalDateTime;

/**
* Event fired when an abandoned job is detected.
*/
public class JobAbandonedEvent implements JobEvent {

private final Job job;
private final LocalDateTime detectedAt;

/**
* Constructs a new JobAbandonedEvent.
*
* @param job The job.
* @param detectedAt The timestamp when the abandoned job was detected.
*/
public JobAbandonedEvent(Job job, LocalDateTime detectedAt) {
this.job = job;
this.detectedAt = detectedAt;
}

/**
* @return The abandoned job.
*/
public Job getJob() {
return job;
}

/**
* @return The timestamp when the abandoned job was detected.
*/
public LocalDateTime getDetectedAt() {
return detectedAt;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Event fired when there is a request to cancel a job.
*/
public class JobCancelRequestEvent {
public class JobCancelRequestEvent implements JobEvent {

private final Job job;
private final LocalDateTime canceledOn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Event fired when a job is canceled.
*/
public class JobCanceledEvent {
public class JobCanceledEvent implements JobEvent {

private final Job job;
private final LocalDateTime canceledAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Event fired when a job is being canceled.
*/
public class JobCancellingEvent {
public class JobCancellingEvent implements JobEvent {

private final Job job;
private final LocalDateTime canceledAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Event fired when a job completes successfully.
*/
public class JobCompletedEvent {
public class JobCompletedEvent implements JobEvent {

private final Job job;
private final LocalDateTime completedAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Event fired when a new job is created and added to the queue.
*/
public class JobCreatedEvent {
public class JobCreatedEvent implements JobEvent {

private final String jobId;
private final String queueName;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.dotcms.jobs.business.api.events;

/**
* Base marker interface for all job-related events in the job queue system. All specific job event
* types (e.g., JobStartedEvent, JobCompletedEvent, etc.) should implement this interface.
*/
public interface JobEvent {

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Event fired when a job fails during processing.
*/
public class JobFailedEvent {
public class JobFailedEvent implements JobEvent {

private final Job job;
private final LocalDateTime failedAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Event fired when a job's progress is updated.
*/
public class JobProgressUpdatedEvent {
public class JobProgressUpdatedEvent implements JobEvent {

private final Job job;
private final LocalDateTime updatedAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Event fired when a job is removed from the queue because failed and is not retryable.
*/
public class JobRemovedFromQueueEvent {
public class JobRemovedFromQueueEvent implements JobEvent {

private final Job job;
private final LocalDateTime removedAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Event fired when a job starts processing.
*/
public class JobStartedEvent {
public class JobStartedEvent implements JobEvent {

private final Job job;
private final LocalDateTime startedAt;
Expand Down
Loading