mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
SQL now() function must use to Datetime instance of int or bigint
This commit is contained in:
parent
cd49e1ad98
commit
4ad42a4d6a
@ -35,8 +35,8 @@ public interface ExecuteLogRepository extends JpaRepository<ExecuteLogDO, Long>
|
|||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query(value = "update execute_log set status = ?2, running_times = ?3, actual_trigger_time = now(), task_tracker_address = ?4, result = ?5, gmt_modified = now() where instance_id = ?1", nativeQuery = true)
|
@Query(value = "update execute_log set status = ?2, running_times = ?3, actual_trigger_time = ?4, task_tracker_address = ?5, result = ?6, gmt_modified = now() where instance_id = ?1", nativeQuery = true)
|
||||||
int update4Trigger(long instanceId, int status, long runningTimes, String taskTrackerAddress, String result);
|
int update4Trigger(long instanceId, int status, long runningTimes, long actualTriggerTime, String taskTrackerAddress, String result);
|
||||||
|
|
||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -48,13 +48,14 @@ public class DispatchService {
|
|||||||
log.info("[DispatchService] start to dispatch job: {}.", jobInfo);
|
log.info("[DispatchService] start to dispatch job: {}.", jobInfo);
|
||||||
|
|
||||||
// 查询当前运行的实例数
|
// 查询当前运行的实例数
|
||||||
|
long current = System.currentTimeMillis();
|
||||||
long runningInstanceCount = executeLogRepository.countByJobIdAndStatusIn(jobInfo.getId(), runningStatus);
|
long runningInstanceCount = executeLogRepository.countByJobIdAndStatusIn(jobInfo.getId(), runningStatus);
|
||||||
|
|
||||||
// 超出最大同时运行限制,不执行调度
|
// 超出最大同时运行限制,不执行调度
|
||||||
if (runningInstanceCount > jobInfo.getMaxInstanceNum()) {
|
if (runningInstanceCount > jobInfo.getMaxInstanceNum()) {
|
||||||
String result = String.format(SystemInstanceResult.TOO_MUCH_INSTANCE, runningInstanceCount, jobInfo.getMaxInstanceNum());
|
String result = String.format(SystemInstanceResult.TOO_MUCH_INSTANCE, runningInstanceCount, jobInfo.getMaxInstanceNum());
|
||||||
log.warn("[DispatchService] cancel dispatch job({}) due to too much instance(num={}) is running.", jobInfo, runningInstanceCount);
|
log.warn("[DispatchService] cancel dispatch job({}) due to too much instance(num={}) is running.", jobInfo, runningInstanceCount);
|
||||||
executeLogRepository.update4Trigger(instanceId, FAILED.getV(), currentRunningTimes, RemoteConstant.EMPTY_ADDRESS, result);
|
executeLogRepository.update4Trigger(instanceId, FAILED.getV(), currentRunningTimes, current, RemoteConstant.EMPTY_ADDRESS, result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ public class DispatchService {
|
|||||||
|
|
||||||
if (StringUtils.isEmpty(taskTrackerAddress)) {
|
if (StringUtils.isEmpty(taskTrackerAddress)) {
|
||||||
log.warn("[DispatchService] cancel dispatch job({}) due to no worker available.", jobInfo);
|
log.warn("[DispatchService] cancel dispatch job({}) due to no worker available.", jobInfo);
|
||||||
executeLogRepository.update4Trigger(instanceId, FAILED.getV(), currentRunningTimes, RemoteConstant.EMPTY_ADDRESS, SystemInstanceResult.NO_WORKER_AVAILABLE);
|
executeLogRepository.update4Trigger(instanceId, FAILED.getV(), currentRunningTimes, current, RemoteConstant.EMPTY_ADDRESS, SystemInstanceResult.NO_WORKER_AVAILABLE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +76,7 @@ public class DispatchService {
|
|||||||
// 构造请求
|
// 构造请求
|
||||||
ServerScheduleJobReq req = new ServerScheduleJobReq();
|
ServerScheduleJobReq req = new ServerScheduleJobReq();
|
||||||
BeanUtils.copyProperties(jobInfo, req);
|
BeanUtils.copyProperties(jobInfo, req);
|
||||||
|
req.setInstanceId(instanceId);
|
||||||
req.setAllWorkerAddress(allAvailableWorker);
|
req.setAllWorkerAddress(allAvailableWorker);
|
||||||
|
|
||||||
req.setExecuteType(ExecuteType.of(jobInfo.getExecuteType()).name());
|
req.setExecuteType(ExecuteType.of(jobInfo.getExecuteType()).name());
|
||||||
@ -91,6 +93,6 @@ public class DispatchService {
|
|||||||
log.debug("[DispatchService] send request({}) to TaskTracker({}) succeed.", req, taskTrackerActor.pathString());
|
log.debug("[DispatchService] send request({}) to TaskTracker({}) succeed.", req, taskTrackerActor.pathString());
|
||||||
|
|
||||||
// 修改状态
|
// 修改状态
|
||||||
executeLogRepository.update4Trigger(instanceId, WAITING_WORKER_RECEIVE.getV(), currentRunningTimes + 1, taskTrackerAddress, EMPTY_RESULT);
|
executeLogRepository.update4Trigger(instanceId, WAITING_WORKER_RECEIVE.getV(), currentRunningTimes + 1, current, taskTrackerAddress, EMPTY_RESULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class RepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteLogUpdate() {
|
public void testExecuteLogUpdate() {
|
||||||
executeLogRepository.update4Trigger(1586310414570L, 2, 100, "NULL");
|
executeLogRepository.update4Trigger(1586310414570L, 2, 100, System.currentTimeMillis(), "192.168.1.1", "NULL");
|
||||||
executeLogRepository.update4FrequentJob(1586310419650L, 2, 200);
|
executeLogRepository.update4FrequentJob(1586310419650L, 2, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user