|
42 | 42 | @Repository |
43 | 43 | public interface JobsRepository extends JpaRepository<Job, UUID> { |
44 | 44 |
|
45 | | - /** |
46 | | - * Finds all unassigned jobs that are ready to be executed. |
47 | | - * |
48 | | - * <p>This query uses pessimistic write locking to prevent concurrent access. |
49 | | - * Jobs are ordered by priority (ascending) and then by start time (ascending). |
50 | | - * |
51 | | - * <p>A job is considered unassigned if: |
52 | | - * <ul> |
53 | | - * <li>{@code workerId} is null</li> |
54 | | - * <li>{@code assignedTaskStartTime} is less than or equal to the current time</li> |
55 | | - * </ul> |
56 | | - * |
57 | | - * @param currentTime the current time for comparison with job start times |
58 | | - * @return a list of unassigned jobs ready for execution, ordered by priority and start time |
59 | | - */ |
60 | | - @Lock(LockModeType.PESSIMISTIC_WRITE) |
61 | | - @Query("SELECT j FROM Job j WHERE j.workerId IS NULL AND j.assignedTaskStartTime <= :currentTime ORDER BY j.priority ASC, j.assignedTaskStartTime ASC") |
62 | | - List<Job> findUnassignedJobs(@Param("currentTime") ZonedDateTime currentTime); |
63 | | - |
64 | 45 | /** |
65 | 46 | * Finds unassigned jobs with pagination support. |
66 | 47 | * |
67 | | - * <p>This method is similar to {@link #findUnassignedJobs(ZonedDateTime)} but supports |
68 | | - * limiting the number of results using {@link Pageable}. This is useful for batch |
| 48 | + * <p>This method limit the number of results using {@link Pageable}. This is useful for batch |
69 | 49 | * processing to avoid loading too many jobs at once. |
70 | 50 | * |
71 | 51 | * <p>Uses pessimistic write locking to prevent concurrent access. |
@@ -111,30 +91,6 @@ List<Job> assignJobsToWorkerBatch(@Param("workerId") UUID workerId, |
111 | 91 | */ |
112 | 92 | Optional<Job> findByJobId(UUID jobId); |
113 | 93 |
|
114 | | - /** |
115 | | - * Inserts a new job into the database. |
116 | | - * |
117 | | - * <p>This method uses a native SQL query to insert a job with all its fields. |
118 | | - * The job data is converted to JSONB format for PostgreSQL storage. |
119 | | - * |
120 | | - * @param jobId the unique job identifier |
121 | | - * @param workerId the worker identifier (null for unassigned jobs) |
122 | | - * @param workerLockTime the lock timestamp (null for unassigned jobs) |
123 | | - * @param assignedTaskName the task name |
124 | | - * @param assignedTaskStartTime the scheduled start time |
125 | | - * @param jobData the job data as a JSON string |
126 | | - * @param retryAttemptsRemaining the number of retry attempts remaining |
127 | | - */ |
128 | | - @Modifying |
129 | | - @Query(value = "INSERT INTO jobs(job_id,worker_id,worker_lock_time,assigned_task_name,assigned_task_start_time,job_data,retry_attempts_remaining) values (:jobId,:workerId,:workerLockTime,:assignedTaskName,:assignedTaskStartTime,:jobData,:retryAttemptsRemaining)", nativeQuery = true) |
130 | | - void insertJob(@Param("jobId") UUID jobId, |
131 | | - @Param("workerId") UUID workerId, |
132 | | - @Param("workerLockTime") ZonedDateTime workerLockTime, |
133 | | - @Param("assignedTaskName") String assignedTaskName, |
134 | | - @Param("assignedTaskStartTime") ZonedDateTime assignedTaskStartTime, |
135 | | - @Param("jobData") String jobData, |
136 | | - @Param("retryAttemptsRemaining") int retryAttemptsRemaining); |
137 | | - |
138 | 94 | /** |
139 | 95 | * Updates the job data for a specific job. |
140 | 96 | * |
|
0 commit comments