Skip to content

Commit

Permalink
update SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
liweinan committed Dec 11, 2024
1 parent 191106a commit d44eb4b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
Expand Down Expand Up @@ -661,7 +662,10 @@ public List<JobExecution> getTimeoutJobExecutions(Long timeoutSeconds) {
PreparedStatement preparedStatement = null;
try {
preparedStatement = connection.prepareStatement(query);
preparedStatement.setLong(1, timeoutSeconds);

Timestamp timeoutTime = Timestamp.from(Instant.now().plusSeconds(timeoutSeconds));

preparedStatement.setTimestamp(1, timeoutTime);
rs = preparedStatement.executeQuery();
while (rs.next()) {
final long executionId = rs.getLong(TableColumns.JOBEXECUTIONID);
Expand Down
2 changes: 1 addition & 1 deletion jberet-core/src/main/resources/sql/jberet-sql.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ insert-job-instance = INSERT INTO JOB_INSTANCE(JOBNAME, APPLICATIONNAME) VALUES(
select-all-job-executions = SELECT * FROM JOB_EXECUTION
select-job-executions-by-job-instance-id = SELECT * FROM JOB_EXECUTION WHERE JOBINSTANCEID=? ORDER BY JOBEXECUTIONID

select-job-executions-by-timeout-seconds = SELECT * FROM JOB_EXECUTION WHERE lastupdatedtime + INTERVAL '? SECOND' < now()
select-job-executions-by-timeout-seconds = SELECT * FROM JOB_EXECUTION WHERE lastupdatedtime < ? AND batchstatus in ('STOPPING', 'STOPPED')

select-job-execution = SELECT * FROM JOB_EXECUTION WHERE JOBEXECUTIONID=?
select-running-job-executions-by-job-name = SELECT JOB_EXECUTION.JOBEXECUTIONID FROM JOB_EXECUTION \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,4 @@ public void getJobExecutionsByJob() throws Exception {
Assertions.assertEquals(1, jobExecutions.size());
}

// @Test
// public void testGetTimeoutJobExecutions() throws Exception {
// List<JobExecution> executions = repo.getTimeoutJobExecutions(Long.valueOf(10));
// System.out.println(executions.size());
// }

}

0 comments on commit d44eb4b

Please sign in to comment.