修复 xxl_job_log 主键id类型为 bigint(20) , 防止 int(11) 位溢出导致调度任务不能正常调度。

pull/10/head
bwh 5 years ago
parent 3d951f2bc6
commit 3afd579dcf

@ -30,7 +30,7 @@ CREATE TABLE `xxl_job_info` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `xxl_job_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`job_group` int(11) NOT NULL COMMENT '执行器主键ID',
`job_id` int(11) NOT NULL COMMENT '任务主键ID',
`executor_address` varchar(255) DEFAULT NULL COMMENT '执行器地址,本次执行的地址',

@ -8,7 +8,7 @@ import java.util.Date;
*/
public class XxlJobLog {
private int id;
private long id;
// job info
private int jobGroup;
@ -34,11 +34,11 @@ public class XxlJobLog {
// alarm info
private int alarmStatus;
public int getId() {
public long getId() {
return id;
}
public void setId(int id) {
public void setId(long id) {
this.id = id;
}

@ -46,9 +46,9 @@ public class JobFailMonitorHelper {
while (!toStop) {
try {
List<Integer> failLogIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findFailJobLogIds(1000);
List<Long> failLogIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findFailJobLogIds(1000);
if (failLogIds!=null && !failLogIds.isEmpty()) {
for (int failLogId: failLogIds) {
for (long failLogId: failLogIds) {
// lock log
int lockRet = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateAlarmStatus(failLogId, 0, -1);

@ -35,7 +35,7 @@ public interface XxlJobInfoDao {
public int update(XxlJobInfo xxlJobInfo);
public int delete(@Param("id") int id);
public int delete(@Param("id") long id);
public List<XxlJobInfo> getJobsByGroup(@Param("jobGroup") int jobGroup);

@ -31,9 +31,9 @@ public interface XxlJobLogDao {
@Param("triggerTimeEnd") Date triggerTimeEnd,
@Param("logStatus") int logStatus);
public XxlJobLog load(@Param("id") int id);
public XxlJobLog load(@Param("id") long id);
public int save(XxlJobLog xxlJobLog);
public long save(XxlJobLog xxlJobLog);
public int updateTriggerInfo(XxlJobLog xxlJobLog);
@ -51,9 +51,9 @@ public interface XxlJobLogDao {
@Param("clearBeforeTime") Date clearBeforeTime,
@Param("clearBeforeNum") int clearBeforeNum);
public List<Integer> findFailJobLogIds(@Param("pagesize") int pagesize);
public List<Long> findFailJobLogIds(@Param("pagesize") int pagesize);
public int updateAlarmStatus(@Param("logId") int logId,
public int updateAlarmStatus(@Param("logId") long logId,
@Param("oldAlarmStatus") int oldAlarmStatus,
@Param("newAlarmStatus") int newAlarmStatus);

@ -110,7 +110,7 @@
</trim>
</select>
<select id="load" parameterType="java.lang.Integer" resultMap="XxlJobLog">
<select id="load" parameterType="java.lang.Long" resultMap="XxlJobLog">
SELECT <include refid="Base_Column_List" />
FROM xxl_job_log AS t
WHERE t.id = #{id}
@ -218,7 +218,7 @@
</trim>
</delete>
<select id="findFailJobLogIds" resultType="int" >
<select id="findFailJobLogIds" resultType="long" >
SELECT id FROM `xxl_job_log`
WHERE !(
(trigger_code in (0, 200) and handle_code = 0)

@ -3,16 +3,17 @@ package com.xxl.job.admin.controller;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:spring/*.xml"})
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class AbstractSpringMvcTest {
@Autowired

@ -4,14 +4,16 @@ import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.dao.XxlJobGroupDao;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class XxlJobGroupDaoTest {
@Resource

@ -3,15 +3,17 @@ package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class XxlJobInfoDaoTest {
@Resource

@ -3,16 +3,18 @@ package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobLog;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class XxlJobLogDaoTest {
@Resource
@ -27,7 +29,7 @@ public class XxlJobLogDaoTest {
log.setJobGroup(1);
log.setJobId(1);
int ret1 = xxlJobLogDao.save(log);
long ret1 = xxlJobLogDao.save(log);
XxlJobLog dto = xxlJobLogDao.load(log.getId());
log.setTriggerTime(new Date());

@ -4,14 +4,16 @@ import com.xxl.job.admin.core.model.XxlJobLogGlue;
import com.xxl.job.admin.dao.XxlJobLogGlueDao;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class XxlJobLogGlueDaoTest {
@Resource

@ -10,7 +10,7 @@ import javax.annotation.Resource;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class XxlJobRegistryDaoTest {
@Resource

@ -3,16 +3,18 @@ package com.xxl.job.admin.util;
import com.xxl.job.admin.core.util.I18nUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
/**
* email util test
*
* @author xuxueli 2017-12-22 17:16:23
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class I18nUtilTest {
@Test

@ -37,7 +37,7 @@ public interface ExecutorBiz {
* @param fromLineNum
* @return
*/
public ReturnT<LogResult> log(long logDateTim, int logId, int fromLineNum);
public ReturnT<LogResult> log(long logDateTim, long logId, int fromLineNum);
/**
* run

@ -58,7 +58,7 @@ public class ExecutorBizImpl implements ExecutorBiz {
}
@Override
public ReturnT<LogResult> log(long logDateTim, int logId, int fromLineNum) {
public ReturnT<LogResult> log(long logDateTim, long logId, int fromLineNum) {
// log filename: logPath/yyyy-MM-dd/9999.log
String logFileName = XxlJobFileAppender.makeLogFileName(new Date(logDateTim), logId);

@ -8,19 +8,19 @@ import java.io.Serializable;
public class HandleCallbackParam implements Serializable {
private static final long serialVersionUID = 42L;
private int logId;
private long logId;
private long logDateTim;
private ReturnT<String> executeResult;
public HandleCallbackParam(){}
public HandleCallbackParam(int logId, long logDateTim, ReturnT<String> executeResult) {
public HandleCallbackParam(long logId, long logDateTim, ReturnT<String> executeResult) {
this.logId = logId;
this.logDateTim = logDateTim;
this.executeResult = executeResult;
}
public int getLogId() {
public long getLogId() {
return logId;
}

@ -15,7 +15,7 @@ public class TriggerParam implements Serializable{
private String executorBlockStrategy;
private int executorTimeout;
private int logId;
private long logId;
private long logDateTim;
private String glueType;
@ -66,11 +66,11 @@ public class TriggerParam implements Serializable{
this.executorTimeout = executorTimeout;
}
public int getLogId() {
public long getLogId() {
return logId;
}
public void setLogId(int logId) {
public void setLogId(long logId) {
this.logId = logId;
}

@ -68,7 +68,7 @@ public class XxlJobFileAppender {
* @param logId
* @return
*/
public static String makeLogFileName(Date triggerDate, int logId) {
public static String makeLogFileName(Date triggerDate, long logId) {
// filePath/yyyy-MM-dd
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // avoid concurrent problem, can not be static

@ -30,7 +30,7 @@ public class JobThread extends Thread{
private int jobId;
private IJobHandler handler;
private LinkedBlockingQueue<TriggerParam> triggerQueue;
private Set<Integer> triggerLogIdSet; // avoid repeat trigger for the same TRIGGER_LOG_ID
private Set<Long> triggerLogIdSet; // avoid repeat trigger for the same TRIGGER_LOG_ID
private volatile boolean toStop = false;
private String stopReason;
@ -43,7 +43,7 @@ public class JobThread extends Thread{
this.jobId = jobId;
this.handler = handler;
this.triggerQueue = new LinkedBlockingQueue<TriggerParam>();
this.triggerLogIdSet = Collections.synchronizedSet(new HashSet<Integer>());
this.triggerLogIdSet = Collections.synchronizedSet(new HashSet<Long>());
}
public IJobHandler getHandler() {
return handler;

Loading…
Cancel
Save