调度中心,DAO层代码精简优化并且新增测试用例覆盖;

v1.8.2
xuxueli 8 years ago
parent eb834b6dcc
commit 8e7a255105

@ -901,6 +901,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 2、动态分片分片广播任务以执行器为维度进行分片支持动态扩容执行器集群从而动态增加分片数量协同进行业务处理在进行大数据量业务操作时可显著提升任务处理能力和速度。
- 3、执行器JobHandler禁止命名冲突
- 4、执行器集群地址列表进行自然排序
- 5、调度中心DAO层代码精简优化并且新增测试用例覆盖
#### TODO LIST
- 1、任务权限管理执行器为粒度分配权限核心操作校验权限

@ -4,9 +4,9 @@ import com.xxl.job.admin.controller.annotation.PermessionLimit;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
import com.xxl.job.admin.dao.IXxlJobLogDao;
import com.xxl.job.admin.dao.IXxlJobRegistryDao;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import com.xxl.job.admin.dao.XxlJobLogDao;
import com.xxl.job.admin.dao.XxlJobRegistryDao;
import com.xxl.job.core.biz.model.HandleCallbackParam;
import com.xxl.job.core.biz.model.RegistryParam;
import com.xxl.job.core.biz.model.ReturnT;
@ -34,11 +34,11 @@ public class JobApiController {
private static Logger logger = LoggerFactory.getLogger(JobApiController.class);
@Resource
public IXxlJobLogDao xxlJobLogDao;
public XxlJobLogDao xxlJobLogDao;
@Resource
private IXxlJobInfoDao xxlJobInfoDao;
private XxlJobInfoDao xxlJobInfoDao;
@Resource
private IXxlJobRegistryDao xxlJobRegistryDao;
private XxlJobRegistryDao xxlJobRegistryDao;
@RequestMapping(value= AdminApiUtil.CALLBACK, method = RequestMethod.POST, consumes = "application/json")

@ -2,8 +2,8 @@ package com.xxl.job.admin.controller;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.model.XxlJobLogGlue;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
import com.xxl.job.admin.dao.IXxlJobLogGlueDao;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import com.xxl.job.admin.dao.XxlJobLogGlueDao;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.glue.GlueTypeEnum;
import org.springframework.stereotype.Controller;
@ -24,9 +24,9 @@ import java.util.List;
public class JobCodeController {
@Resource
private IXxlJobInfoDao xxlJobInfoDao;
private XxlJobInfoDao xxlJobInfoDao;
@Resource
private IXxlJobLogGlueDao xxlJobLogGlueDao;
private XxlJobLogGlueDao xxlJobLogGlueDao;
@RequestMapping
public String index(Model model, int jobId) {

@ -1,8 +1,8 @@
package com.xxl.job.admin.controller;
import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.dao.IXxlJobGroupDao;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
import com.xxl.job.admin.dao.XxlJobGroupDao;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import com.xxl.job.core.biz.model.ReturnT;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
@ -22,9 +22,9 @@ import java.util.List;
public class JobGroupController {
@Resource
public IXxlJobInfoDao xxlJobInfoDao;
public XxlJobInfoDao xxlJobInfoDao;
@Resource
public IXxlJobGroupDao xxlJobGroupDao;
public XxlJobGroupDao xxlJobGroupDao;
@RequestMapping
public String index(Model model) {

@ -4,7 +4,7 @@ import com.xxl.job.admin.core.enums.ExecutorFailStrategyEnum;
import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
import com.xxl.job.admin.dao.IXxlJobGroupDao;
import com.xxl.job.admin.dao.XxlJobGroupDao;
import com.xxl.job.admin.service.IXxlJobService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
@ -28,7 +28,7 @@ import java.util.Map;
public class JobInfoController {
@Resource
private IXxlJobGroupDao xxlJobGroupDao;
private XxlJobGroupDao xxlJobGroupDao;
@Resource
private IXxlJobService xxlJobService;

@ -3,9 +3,9 @@ package com.xxl.job.admin.controller;
import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.dao.IXxlJobGroupDao;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
import com.xxl.job.admin.dao.IXxlJobLogDao;
import com.xxl.job.admin.dao.XxlJobGroupDao;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import com.xxl.job.admin.dao.XxlJobLogDao;
import com.xxl.job.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.model.LogResult;
import com.xxl.job.core.biz.model.ReturnT;
@ -34,11 +34,11 @@ import java.util.Map;
public class JobLogController {
@Resource
private IXxlJobGroupDao xxlJobGroupDao;
private XxlJobGroupDao xxlJobGroupDao;
@Resource
public IXxlJobInfoDao xxlJobInfoDao;
public XxlJobInfoDao xxlJobInfoDao;
@Resource
public IXxlJobLogDao xxlJobLogDao;
public XxlJobLogDao xxlJobLogDao;
@RequestMapping
public String index(Model model, @RequestParam(required = false, defaultValue = "0") Integer jobId) {
@ -58,7 +58,7 @@ public class JobLogController {
@RequestMapping("/getJobsByGroup")
@ResponseBody
public ReturnT<List<XxlJobInfo>> listJobByGroup(String jobGroup){
public ReturnT<List<XxlJobInfo>> getJobsByGroup(int jobGroup){
List<XxlJobInfo> list = xxlJobInfoDao.getJobsByGroup(jobGroup);
return new ReturnT<List<XxlJobInfo>>(list);
}

@ -109,6 +109,10 @@ public class XxlJobLog {
}
public void setTriggerMsg(String triggerMsg) {
// plugin
if (triggerMsg!=null && triggerMsg.length()>2000) {
triggerMsg = triggerMsg.substring(0, 2000);
}
this.triggerMsg = triggerMsg;
}
@ -133,6 +137,10 @@ public class XxlJobLog {
}
public void setHandleMsg(String handleMsg) {
// plugin
if (handleMsg!=null && handleMsg.length()>2000) {
handleMsg = handleMsg.substring(0, 2000);
}
this.handleMsg = handleMsg;
}
}

@ -4,10 +4,10 @@ import com.xxl.job.admin.core.jobbean.RemoteHttpJobBean;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.thread.JobFailMonitorHelper;
import com.xxl.job.admin.core.thread.JobRegistryMonitorHelper;
import com.xxl.job.admin.dao.IXxlJobGroupDao;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
import com.xxl.job.admin.dao.IXxlJobLogDao;
import com.xxl.job.admin.dao.IXxlJobRegistryDao;
import com.xxl.job.admin.dao.XxlJobGroupDao;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import com.xxl.job.admin.dao.XxlJobLogDao;
import com.xxl.job.admin.dao.XxlJobRegistryDao;
import com.xxl.job.core.rpc.netcom.NetComServerFactory;
import org.quartz.*;
import org.quartz.Trigger.TriggerState;
@ -58,17 +58,17 @@ public final class XxlJobDynamicScheduler implements ApplicationContextAware, In
}
// xxlJobLogDao、xxlJobInfoDao
public static IXxlJobLogDao xxlJobLogDao;
public static IXxlJobInfoDao xxlJobInfoDao;
public static IXxlJobRegistryDao xxlJobRegistryDao;
public static IXxlJobGroupDao xxlJobGroupDao;
public static XxlJobLogDao xxlJobLogDao;
public static XxlJobInfoDao xxlJobInfoDao;
public static XxlJobRegistryDao xxlJobRegistryDao;
public static XxlJobGroupDao xxlJobGroupDao;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
XxlJobDynamicScheduler.xxlJobLogDao = applicationContext.getBean(IXxlJobLogDao.class);
XxlJobDynamicScheduler.xxlJobInfoDao = applicationContext.getBean(IXxlJobInfoDao.class);
XxlJobDynamicScheduler.xxlJobRegistryDao = applicationContext.getBean(IXxlJobRegistryDao.class);
XxlJobDynamicScheduler.xxlJobGroupDao = applicationContext.getBean(IXxlJobGroupDao.class);
XxlJobDynamicScheduler.xxlJobLogDao = applicationContext.getBean(XxlJobLogDao.class);
XxlJobDynamicScheduler.xxlJobInfoDao = applicationContext.getBean(XxlJobInfoDao.class);
XxlJobDynamicScheduler.xxlJobRegistryDao = applicationContext.getBean(XxlJobRegistryDao.class);
XxlJobDynamicScheduler.xxlJobGroupDao = applicationContext.getBean(XxlJobGroupDao.class);
}
@Override

@ -1,29 +0,0 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobInfo;
import java.util.List;
/**
* job info
* @author xuxueli 2016-1-12 18:03:45
*/
public interface IXxlJobInfoDao {
public List<XxlJobInfo> pageList(int offset, int pagesize, int jobGroup, String executorHandler);
public int pageListCount(int offset, int pagesize, int jobGroup, String executorHandler);
public int save(XxlJobInfo info);
public XxlJobInfo loadById(int id);
public int update(XxlJobInfo item);
public int delete(int id);
public List<XxlJobInfo> getJobsByGroup(String jobGroup);
public int findAllCount();
}

@ -1,34 +0,0 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobLog;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* job log
* @author xuxueli 2016-1-12 18:03:06
*/
public interface IXxlJobLogDao {
public List<XxlJobLog> pageList(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus);
public int pageListCount(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus);
public XxlJobLog load(int id);
public int save(XxlJobLog xxlJobLog);
public int updateTriggerInfo(XxlJobLog xxlJobLog);
public int updateHandleInfo(XxlJobLog xxlJobLog);
public int delete(int jobId);
public int triggerCountByHandleCode(int handleCode);
public List<Map<String, Object>> triggerCountByDay(Date from, Date to, int handleCode);
public int clearLog(int jobGroup, int jobId, Date clearBeforeTime, int clearBeforeNum);
}

@ -1,21 +0,0 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobLogGlue;
import java.util.List;
/**
* job log for glue
* @author xuxueli 2016-5-19 18:04:56
*/
public interface IXxlJobLogGlueDao {
public int save(XxlJobLogGlue xxlJobLogGlue);
public List<XxlJobLogGlue> findByJobId(int jobId);
public int removeOld(int jobId, int limit);
public int deleteByJobId(int jobId);
}

@ -1,19 +0,0 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobRegistry;
import java.util.List;
/**
* Created by xuxueli on 16/9/30.
*/
public interface IXxlJobRegistryDao {
public int removeDead(int timeout);
public List<XxlJobRegistry> findAll(int timeout);
public int registryUpdate(String registryGroup, String registryKey, String registryValue);
public int registrySave(String registryGroup, String registryKey, String registryValue);
}

@ -1,23 +1,24 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobGroup;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Created by xuxueli on 16/9/30.
*/
public interface IXxlJobGroupDao {
public interface XxlJobGroupDao {
public List<XxlJobGroup> findAll();
public List<XxlJobGroup> findByAddressType(int addressType);
public List<XxlJobGroup> findByAddressType(@Param("addressType") int addressType);
public int save(XxlJobGroup xxlJobGroup);
public int update(XxlJobGroup xxlJobGroup);
public int remove(int id);
public int remove(@Param("id") int id);
public XxlJobGroup load(int id);
public XxlJobGroup load(@Param("id") int id);
}

@ -0,0 +1,30 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* job info
* @author xuxueli 2016-1-12 18:03:45
*/
public interface XxlJobInfoDao {
public List<XxlJobInfo> pageList(@Param("offset") int offset, @Param("pagesize") int pagesize, @Param("jobGroup") int jobGroup, @Param("executorHandler") String executorHandler);
public int pageListCount(@Param("offset") int offset, @Param("pagesize") int pagesize, @Param("jobGroup") int jobGroup, @Param("executorHandler") String executorHandler);
public int save(XxlJobInfo info);
public XxlJobInfo loadById(@Param("id") int id);
public int update(XxlJobInfo item);
public int delete(@Param("id") int id);
public List<XxlJobInfo> getJobsByGroup(@Param("jobGroup") int jobGroup);
public int findAllCount();
}

@ -0,0 +1,52 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobLog;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* job log
* @author xuxueli 2016-1-12 18:03:06
*/
public interface XxlJobLogDao {
public List<XxlJobLog> pageList(@Param("offset") int offset,
@Param("pagesize") int pagesize,
@Param("jobGroup") int jobGroup,
@Param("jobId") int jobId,
@Param("triggerTimeStart") Date triggerTimeStart,
@Param("triggerTimeEnd") Date triggerTimeEnd,
@Param("logStatus") int logStatus);
public int pageListCount(@Param("offset") int offset,
@Param("pagesize") int pagesize,
@Param("jobGroup") int jobGroup,
@Param("jobId") int jobId,
@Param("triggerTimeStart") Date triggerTimeStart,
@Param("triggerTimeEnd") Date triggerTimeEnd,
@Param("logStatus") int logStatus);
public XxlJobLog load(@Param("id") int id);
public int save(XxlJobLog xxlJobLog);
public int updateTriggerInfo(XxlJobLog xxlJobLog);
public int updateHandleInfo(XxlJobLog xxlJobLog);
public int delete(@Param("jobId") int jobId);
public int triggerCountByHandleCode(@Param("handleCode") int handleCode);
public List<Map<String, Object>> triggerCountByDay(@Param("from") Date from,
@Param("to") Date to,
@Param("handleCode") int handleCode);
public int clearLog(@Param("jobGroup") int jobGroup,
@Param("jobId") int jobId,
@Param("clearBeforeTime") Date clearBeforeTime,
@Param("clearBeforeNum") int clearBeforeNum);
}

@ -0,0 +1,22 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobLogGlue;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* job log for glue
* @author xuxueli 2016-5-19 18:04:56
*/
public interface XxlJobLogGlueDao {
public int save(XxlJobLogGlue xxlJobLogGlue);
public List<XxlJobLogGlue> findByJobId(@Param("jobId") int jobId);
public int removeOld(@Param("jobId") int jobId, @Param("limit") int limit);
public int deleteByJobId(@Param("jobId") int jobId);
}

@ -0,0 +1,25 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobRegistry;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Created by xuxueli on 16/9/30.
*/
public interface XxlJobRegistryDao {
public int removeDead(@Param("timeout") int timeout);
public List<XxlJobRegistry> findAll(@Param("timeout") int timeout);
public int registryUpdate(@Param("registryGroup") String registryGroup,
@Param("registryKey") String registryKey,
@Param("registryValue") String registryValue);
public int registrySave(@Param("registryGroup") String registryGroup,
@Param("registryKey") String registryKey,
@Param("registryValue") String registryValue);
}

@ -1,51 +1,51 @@
package com.xxl.job.admin.dao.impl;
import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.dao.IXxlJobGroupDao;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.List;
/**
* Created by xuxueli on 16/9/30.
*/
@Repository
public class XxlJobGroupDaoImpl implements IXxlJobGroupDao {
@Resource
public SqlSessionTemplate sqlSessionTemplate;
@Override
public List<XxlJobGroup> findAll() {
return sqlSessionTemplate.selectList("XxlJobGroupMapper.findAll");
}
@Override
public List<XxlJobGroup> findByAddressType(int addressType) {
return sqlSessionTemplate.selectList("XxlJobGroupMapper.findByAddressType", addressType);
}
@Override
public int save(XxlJobGroup xxlJobGroup) {
return sqlSessionTemplate.update("XxlJobGroupMapper.save", xxlJobGroup);
}
@Override
public int update(XxlJobGroup xxlJobGroup) {
return sqlSessionTemplate.update("XxlJobGroupMapper.update", xxlJobGroup);
}
@Override
public int remove(int id) {
return sqlSessionTemplate.delete("XxlJobGroupMapper.remove", id);
}
@Override
public XxlJobGroup load(int id) {
return sqlSessionTemplate.selectOne("XxlJobGroupMapper.load", id);
}
}
//package com.xxl.job.admin.dao.impl;
//
//import com.xxl.job.admin.core.model.XxlJobGroup;
//import com.xxl.job.admin.dao.XxlJobGroupDao;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.springframework.stereotype.Repository;
//
//import javax.annotation.Resource;
//import java.util.List;
//
///**
// * Created by xuxueli on 16/9/30.
// */
//@Repository
//public class XxlJobGroupDaoImpl implements XxlJobGroupDao {
//
// @Resource
// public SqlSessionTemplate sqlSessionTemplate;
//
// @Override
// public List<XxlJobGroup> findAll() {
// return sqlSessionTemplate.selectList("XxlJobGroupMapper.findAll");
// }
//
// @Override
// public List<XxlJobGroup> findByAddressType(int addressType) {
// return sqlSessionTemplate.selectList("XxlJobGroupMapper.findByAddressType", addressType);
// }
//
// @Override
// public int save(XxlJobGroup xxlJobGroup) {
// return sqlSessionTemplate.update("XxlJobGroupMapper.save", xxlJobGroup);
// }
//
// @Override
// public int update(XxlJobGroup xxlJobGroup) {
// return sqlSessionTemplate.update("XxlJobGroupMapper.update", xxlJobGroup);
// }
//
// @Override
// public int remove(int id) {
// return sqlSessionTemplate.delete("XxlJobGroupMapper.remove", id);
// }
//
// @Override
// public XxlJobGroup load(int id) {
// return sqlSessionTemplate.selectOne("XxlJobGroupMapper.load", id);
// }
//
//
//}

@ -1,74 +1,74 @@
package com.xxl.job.admin.dao.impl;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
/**
* job info
* @author xuxueli 2016-1-12 18:03:45
*/
@Repository
public class XxlJobInfoDaoImpl implements IXxlJobInfoDao {
@Resource
public SqlSessionTemplate sqlSessionTemplate;
@Override
public List<XxlJobInfo> pageList(int offset, int pagesize, int jobGroup, String executorHandler) {
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("offset", offset);
params.put("pagesize", pagesize);
params.put("jobGroup", jobGroup);
params.put("executorHandler", executorHandler);
return sqlSessionTemplate.selectList("XxlJobInfoMapper.pageList", params);
}
@Override
public int pageListCount(int offset, int pagesize, int jobGroup, String executorHandler) {
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("offset", offset);
params.put("pagesize", pagesize);
params.put("jobGroup", jobGroup);
params.put("executorHandler", executorHandler);
return sqlSessionTemplate.selectOne("XxlJobInfoMapper.pageListCount", params);
}
@Override
public int save(XxlJobInfo info) {
return sqlSessionTemplate.insert("XxlJobInfoMapper.save", info);
}
@Override
public XxlJobInfo loadById(int id) {
return sqlSessionTemplate.selectOne("XxlJobInfoMapper.loadById", id);
}
@Override
public int update(XxlJobInfo item) {
return sqlSessionTemplate.update("XxlJobInfoMapper.update", item);
}
@Override
public int delete(int id) {
return sqlSessionTemplate.update("XxlJobInfoMapper.delete", id);
}
@Override
public List<XxlJobInfo> getJobsByGroup(String jobGroup) {
return sqlSessionTemplate.selectList("XxlJobInfoMapper.getJobsByGroup", jobGroup);
}
@Override
public int findAllCount() {
return sqlSessionTemplate.selectOne("XxlJobInfoMapper.findAllCount");
}
}
//package com.xxl.job.admin.dao.impl;
//
//import com.xxl.job.admin.core.model.XxlJobInfo;
//import com.xxl.job.admin.dao.XxlJobInfoDao;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.springframework.stereotype.Repository;
//
//import javax.annotation.Resource;
//import java.util.HashMap;
//import java.util.List;
//
///**
// * job info
// * @author xuxueli 2016-1-12 18:03:45
// */
//@Repository
//public class XxlJobInfoDaoImpl implements XxlJobInfoDao {
//
// @Resource
// public SqlSessionTemplate sqlSessionTemplate;
//
// @Override
// public List<XxlJobInfo> pageList(int offset, int pagesize, int jobGroup, String executorHandler) {
// HashMap<String, Object> params = new HashMap<String, Object>();
// params.put("offset", offset);
// params.put("pagesize", pagesize);
// params.put("jobGroup", jobGroup);
// params.put("executorHandler", executorHandler);
//
// return sqlSessionTemplate.selectList("XxlJobInfoMapper.pageList", params);
// }
//
// @Override
// public int pageListCount(int offset, int pagesize, int jobGroup, String executorHandler) {
// HashMap<String, Object> params = new HashMap<String, Object>();
// params.put("offset", offset);
// params.put("pagesize", pagesize);
// params.put("jobGroup", jobGroup);
// params.put("executorHandler", executorHandler);
//
// return sqlSessionTemplate.selectOne("XxlJobInfoMapper.pageListCount", params);
// }
//
// @Override
// public int save(XxlJobInfo info) {
// return sqlSessionTemplate.insert("XxlJobInfoMapper.save", info);
// }
//
// @Override
// public XxlJobInfo loadById(int id) {
// return sqlSessionTemplate.selectOne("XxlJobInfoMapper.loadById", id);
// }
//
// @Override
// public int update(XxlJobInfo item) {
// return sqlSessionTemplate.update("XxlJobInfoMapper.update", item);
// }
//
// @Override
// public int delete(int id) {
// return sqlSessionTemplate.update("XxlJobInfoMapper.delete", id);
// }
//
// @Override
// public List<XxlJobInfo> getJobsByGroup(String jobGroup) {
// return sqlSessionTemplate.selectList("XxlJobInfoMapper.getJobsByGroup", jobGroup);
// }
//
// @Override
// public int findAllCount() {
// return sqlSessionTemplate.selectOne("XxlJobInfoMapper.findAllCount");
// }
//
//}

@ -1,107 +1,107 @@
package com.xxl.job.admin.dao.impl;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.dao.IXxlJobLogDao;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* job log
* @author xuxueli 2016-1-12 18:03:06
*/
@Repository
public class XxlJobLogDaoImpl implements IXxlJobLogDao {
@Resource
public SqlSessionTemplate sqlSessionTemplate;
@Override
public List<XxlJobLog> pageList(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus) {
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("offset", offset);
params.put("pagesize", pagesize);
params.put("jobGroup", jobGroup);
params.put("jobId", jobId);
params.put("triggerTimeStart", triggerTimeStart);
params.put("triggerTimeEnd", triggerTimeEnd);
params.put("logStatus", logStatus);
return sqlSessionTemplate.selectList("XxlJobLogMapper.pageList", params);
}
@Override
public int pageListCount(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus) {
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("offset", offset);
params.put("pagesize", pagesize);
params.put("jobGroup", jobGroup);
params.put("jobId", jobId);
params.put("triggerTimeStart", triggerTimeStart);
params.put("triggerTimeEnd", triggerTimeEnd);
params.put("logStatus", logStatus);
return sqlSessionTemplate.selectOne("XxlJobLogMapper.pageListCount", params);
}
@Override
public XxlJobLog load(int id) {
return sqlSessionTemplate.selectOne("XxlJobLogMapper.load", id);
}
@Override
public int save(XxlJobLog xxlJobLog) {
return sqlSessionTemplate.insert("XxlJobLogMapper.save", xxlJobLog);
}
@Override
public int updateTriggerInfo(XxlJobLog xxlJobLog) {
if (xxlJobLog.getTriggerMsg()!=null && xxlJobLog.getTriggerMsg().length()>2000) {
xxlJobLog.setTriggerMsg(xxlJobLog.getTriggerMsg().substring(0, 2000));
}
return sqlSessionTemplate.update("XxlJobLogMapper.updateTriggerInfo", xxlJobLog);
}
@Override
public int updateHandleInfo(XxlJobLog xxlJobLog) {
if (xxlJobLog.getHandleMsg()!=null && xxlJobLog.getHandleMsg().length()>2000) {
xxlJobLog.setHandleMsg(xxlJobLog.getHandleMsg().substring(0, 2000));
}
return sqlSessionTemplate.update("XxlJobLogMapper.updateHandleInfo", xxlJobLog);
}
@Override
public int delete(int jobId) {
return sqlSessionTemplate.delete("XxlJobLogMapper.delete", jobId);
}
@Override
public int triggerCountByHandleCode(int handleCode) {
return sqlSessionTemplate.selectOne("XxlJobLogMapper.triggerCountByHandleCode", handleCode);
}
@Override
public List<Map<String, Object>> triggerCountByDay(Date from, Date to, int handleCode) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("from", from);
params.put("to", to);
params.put("handleCode", handleCode);
return sqlSessionTemplate.selectList("XxlJobLogMapper.triggerCountByDay", params);
}
@Override
public int clearLog(int jobGroup, int jobId, Date clearBeforeTime, int clearBeforeNum) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("jobGroup", jobGroup);
params.put("jobId", jobId);
params.put("clearBeforeTime", clearBeforeTime);
params.put("clearBeforeNum", clearBeforeNum);
return sqlSessionTemplate.delete("XxlJobLogMapper.clearLog", params);
}
}
//package com.xxl.job.admin.dao.impl;
//
//import com.xxl.job.admin.core.model.XxlJobLog;
//import com.xxl.job.admin.dao.XxlJobLogDao;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.springframework.stereotype.Repository;
//
//import javax.annotation.Resource;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * job log
// * @author xuxueli 2016-1-12 18:03:06
// */
//@Repository
//public class XxlJobLogDaoImpl implements XxlJobLogDao {
//
// @Resource
// public SqlSessionTemplate sqlSessionTemplate;
//
// @Override
// public List<XxlJobLog> pageList(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus) {
// HashMap<String, Object> params = new HashMap<String, Object>();
// params.put("offset", offset);
// params.put("pagesize", pagesize);
// params.put("jobGroup", jobGroup);
// params.put("jobId", jobId);
// params.put("triggerTimeStart", triggerTimeStart);
// params.put("triggerTimeEnd", triggerTimeEnd);
// params.put("logStatus", logStatus);
//
// return sqlSessionTemplate.selectList("XxlJobLogMapper.pageList", params);
// }
//
// @Override
// public int pageListCount(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus) {
// HashMap<String, Object> params = new HashMap<String, Object>();
// params.put("offset", offset);
// params.put("pagesize", pagesize);
// params.put("jobGroup", jobGroup);
// params.put("jobId", jobId);
// params.put("triggerTimeStart", triggerTimeStart);
// params.put("triggerTimeEnd", triggerTimeEnd);
// params.put("logStatus", logStatus);
//
// return sqlSessionTemplate.selectOne("XxlJobLogMapper.pageListCount", params);
// }
//
// @Override
// public XxlJobLog load(int id) {
// return sqlSessionTemplate.selectOne("XxlJobLogMapper.load", id);
// }
//
// @Override
// public int save(XxlJobLog xxlJobLog) {
// return sqlSessionTemplate.insert("XxlJobLogMapper.save", xxlJobLog);
// }
//
// @Override
// public int updateTriggerInfo(XxlJobLog xxlJobLog) {
// if (xxlJobLog.getTriggerMsg()!=null && xxlJobLog.getTriggerMsg().length()>2000) {
// xxlJobLog.setTriggerMsg(xxlJobLog.getTriggerMsg().substring(0, 2000));
// }
// return sqlSessionTemplate.update("XxlJobLogMapper.updateTriggerInfo", xxlJobLog);
// }
//
// @Override
// public int updateHandleInfo(XxlJobLog xxlJobLog) {
// if (xxlJobLog.getHandleMsg()!=null && xxlJobLog.getHandleMsg().length()>2000) {
// xxlJobLog.setHandleMsg(xxlJobLog.getHandleMsg().substring(0, 2000));
// }
// return sqlSessionTemplate.update("XxlJobLogMapper.updateHandleInfo", xxlJobLog);
// }
//
// @Override
// public int delete(int jobId) {
// return sqlSessionTemplate.delete("XxlJobLogMapper.delete", jobId);
// }
//
// @Override
// public int triggerCountByHandleCode(int handleCode) {
// return sqlSessionTemplate.selectOne("XxlJobLogMapper.triggerCountByHandleCode", handleCode);
// }
//
// @Override
// public List<Map<String, Object>> triggerCountByDay(Date from, Date to, int handleCode) {
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("from", from);
// params.put("to", to);
// params.put("handleCode", handleCode);
// return sqlSessionTemplate.selectList("XxlJobLogMapper.triggerCountByDay", params);
// }
//
// @Override
// public int clearLog(int jobGroup, int jobId, Date clearBeforeTime, int clearBeforeNum) {
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("jobGroup", jobGroup);
// params.put("jobId", jobId);
// params.put("clearBeforeTime", clearBeforeTime);
// params.put("clearBeforeNum", clearBeforeNum);
// return sqlSessionTemplate.delete("XxlJobLogMapper.clearLog", params);
// }
//
//}

@ -1,45 +1,45 @@
package com.xxl.job.admin.dao.impl;
import com.xxl.job.admin.core.model.XxlJobLogGlue;
import com.xxl.job.admin.dao.IXxlJobLogGlueDao;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
/**
* job log for glue
* @author xuxueli 2016-5-19 18:17:52
*/
@Repository
public class XxlJobLogGlueDaoImpl implements IXxlJobLogGlueDao {
@Resource
public SqlSessionTemplate sqlSessionTemplate;
@Override
public int save(XxlJobLogGlue xxlJobLogGlue) {
return sqlSessionTemplate.insert("XxlJobLogGlueMapper.save", xxlJobLogGlue);
}
@Override
public List<XxlJobLogGlue> findByJobId(int jobId) {
return sqlSessionTemplate.selectList("XxlJobLogGlueMapper.findByJobId", jobId);
}
@Override
public int removeOld(int jobId, int limit) {
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("jobId", jobId);
params.put("limit", limit);
return sqlSessionTemplate.delete("XxlJobLogGlueMapper.removeOld", params);
}
@Override
public int deleteByJobId(int jobId) {
return sqlSessionTemplate.delete("XxlJobLogGlueMapper.deleteByJobId", jobId);
}
}
//package com.xxl.job.admin.dao.impl;
//
//import com.xxl.job.admin.core.model.XxlJobLogGlue;
//import com.xxl.job.admin.dao.XxlJobLogGlueDao;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.springframework.stereotype.Repository;
//
//import javax.annotation.Resource;
//import java.util.HashMap;
//import java.util.List;
//
///**
// * job log for glue
// * @author xuxueli 2016-5-19 18:17:52
// */
//@Repository
//public class XxlJobLogGlueDaoImpl implements XxlJobLogGlueDao {
//
// @Resource
// public SqlSessionTemplate sqlSessionTemplate;
//
// @Override
// public int save(XxlJobLogGlue xxlJobLogGlue) {
// return sqlSessionTemplate.insert("XxlJobLogGlueMapper.save", xxlJobLogGlue);
// }
//
// @Override
// public List<XxlJobLogGlue> findByJobId(int jobId) {
// return sqlSessionTemplate.selectList("XxlJobLogGlueMapper.findByJobId", jobId);
// }
//
// @Override
// public int removeOld(int jobId, int limit) {
// HashMap<String, Object> params = new HashMap<String, Object>();
// params.put("jobId", jobId);
// params.put("limit", limit);
// return sqlSessionTemplate.delete("XxlJobLogGlueMapper.removeOld", params);
// }
//
// @Override
// public int deleteByJobId(int jobId) {
// return sqlSessionTemplate.delete("XxlJobLogGlueMapper.deleteByJobId", jobId);
// }
//
//}

@ -1,52 +1,52 @@
package com.xxl.job.admin.dao.impl;
import com.xxl.job.admin.core.model.XxlJobRegistry;
import com.xxl.job.admin.dao.IXxlJobRegistryDao;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by xuxueli on 16/9/30.
*/
@Repository
public class XxlJobRegistryDaoImpl implements IXxlJobRegistryDao {
@Resource
public SqlSessionTemplate sqlSessionTemplate;
@Override
public int removeDead(int timeout) {
return sqlSessionTemplate.delete("XxlJobRegistryMapper.removeDead", timeout);
}
@Override
public List<XxlJobRegistry> findAll(int timeout) {
return sqlSessionTemplate.selectList("XxlJobRegistryMapper.findAll", timeout);
}
@Override
public int registryUpdate(String registryGroup, String registryKey, String registryValue) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("registryGroup", registryGroup);
params.put("registryKey", registryKey);
params.put("registryValue", registryValue);
return sqlSessionTemplate.update("XxlJobRegistryMapper.registryUpdate", params);
}
@Override
public int registrySave(String registryGroup, String registryKey, String registryValue) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("registryGroup", registryGroup);
params.put("registryKey", registryKey);
params.put("registryValue", registryValue);
return sqlSessionTemplate.update("XxlJobRegistryMapper.registrySave", params);
}
}
//package com.xxl.job.admin.dao.impl;
//
//import com.xxl.job.admin.core.model.XxlJobRegistry;
//import com.xxl.job.admin.dao.XxlJobRegistryDao;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.springframework.stereotype.Repository;
//
//import javax.annotation.Resource;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * Created by xuxueli on 16/9/30.
// */
//@Repository
//public class XxlJobRegistryDaoImpl implements XxlJobRegistryDao {
//
// @Resource
// public SqlSessionTemplate sqlSessionTemplate;
//
// @Override
// public int removeDead(int timeout) {
// return sqlSessionTemplate.delete("XxlJobRegistryMapper.removeDead", timeout);
// }
//
// @Override
// public List<XxlJobRegistry> findAll(int timeout) {
// return sqlSessionTemplate.selectList("XxlJobRegistryMapper.findAll", timeout);
// }
//
// @Override
// public int registryUpdate(String registryGroup, String registryKey, String registryValue) {
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("registryGroup", registryGroup);
// params.put("registryKey", registryKey);
// params.put("registryValue", registryValue);
//
// return sqlSessionTemplate.update("XxlJobRegistryMapper.registryUpdate", params);
// }
//
// @Override
// public int registrySave(String registryGroup, String registryKey, String registryValue) {
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("registryGroup", registryGroup);
// params.put("registryKey", registryKey);
// params.put("registryValue", registryValue);
//
// return sqlSessionTemplate.update("XxlJobRegistryMapper.registrySave", params);
// }
//
//}

@ -5,10 +5,10 @@ import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
import com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler;
import com.xxl.job.admin.dao.IXxlJobGroupDao;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
import com.xxl.job.admin.dao.IXxlJobLogDao;
import com.xxl.job.admin.dao.IXxlJobLogGlueDao;
import com.xxl.job.admin.dao.XxlJobGroupDao;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import com.xxl.job.admin.dao.XxlJobLogDao;
import com.xxl.job.admin.dao.XxlJobLogGlueDao;
import com.xxl.job.admin.service.IXxlJobService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
@ -36,13 +36,13 @@ public class XxlJobServiceImpl implements IXxlJobService {
private static Logger logger = LoggerFactory.getLogger(XxlJobServiceImpl.class);
@Resource
private IXxlJobGroupDao xxlJobGroupDao;
private XxlJobGroupDao xxlJobGroupDao;
@Resource
private IXxlJobInfoDao xxlJobInfoDao;
private XxlJobInfoDao xxlJobInfoDao;
@Resource
public IXxlJobLogDao xxlJobLogDao;
public XxlJobLogDao xxlJobLogDao;
@Resource
private IXxlJobLogGlueDao xxlJobLogGlueDao;
private XxlJobLogGlueDao xxlJobLogGlueDao;
@Override
public Map<String, Object> pageList(int start, int length, int jobGroup, String executorHandler, String filterTime) {

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="XxlJobGroupMapper">
<mapper namespace="com.xxl.job.admin.dao.XxlJobGroupDao">
<resultMap id="XxlJobGroup" type="com.xxl.job.admin.core.model.XxlJobGroup" >
<result column="id" property="id" />
@ -34,7 +34,7 @@
ORDER BY t.order ASC
</select>
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobGroup" >
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobGroup" useGeneratedKeys="true" keyProperty="id" >
INSERT INTO XXL_JOB_QRTZ_TRIGGER_GROUP ( `app_name`, `title`, `order`, `address_type`, `address_list`)
values ( #{appName}, #{title}, #{order}, #{addressType}, #{addressList});
</insert>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="XxlJobInfoMapper">
<mapper namespace="com.xxl.job.admin.dao.XxlJobInfoDao">
<resultMap id="XxlJobInfo" type="com.xxl.job.admin.core.model.XxlJobInfo" >
<result column="id" property="id" />

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="XxlJobLogGlueMapper">
<mapper namespace="com.xxl.job.admin.dao.XxlJobLogGlueDao">
<resultMap id="XxlJobLogGlue" type="com.xxl.job.admin.core.model.XxlJobLogGlue" >
<result column="id" property="id" />
@ -39,9 +39,9 @@
now(),
now()
);
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID()
</selectKey>
</selectKey>-->
</insert>
<select id="findByJobId" parameterType="java.lang.Integer" resultMap="XxlJobLogGlue">
@ -51,7 +51,7 @@
ORDER BY id DESC
</select>
<delete id="removeOld" parameterType="java.util.HashMap" >
<delete id="removeOld" >
DELETE FROM XXL_JOB_QRTZ_TRIGGER_LOGGLUE
WHERE id NOT in(
SELECT id FROM(

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="XxlJobLogMapper">
<mapper namespace="com.xxl.job.admin.dao.XxlJobLogDao">
<resultMap id="XxlJobLog" type="com.xxl.job.admin.core.model.XxlJobLog" >
<result column="id" property="id" />
@ -41,7 +41,7 @@
t.handle_msg
</sql>
<select id="pageList" parameterType="java.util.HashMap" resultMap="XxlJobLog">
<select id="pageList" resultMap="XxlJobLog">
SELECT <include refid="Base_Column_List" />
FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
@ -74,7 +74,7 @@
LIMIT #{offset}, #{pagesize}
</select>
<select id="pageListCount" parameterType="java.util.HashMap" resultType="int">
<select id="pageListCount" resultType="int">
SELECT count(1)
FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
@ -120,12 +120,12 @@
#{jobGroup},
#{jobId}
);
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID()
</selectKey>
</selectKey>-->
</insert>
<update id="updateTriggerInfo">
<update id="updateTriggerInfo" >
UPDATE XXL_JOB_QRTZ_TRIGGER_LOG
SET
`glue_type`= #{glueType},
@ -147,22 +147,22 @@
WHERE `id`= #{id}
</update>
<delete id="delete">
<delete id="delete" >
delete from XXL_JOB_QRTZ_TRIGGER_LOG
WHERE job_id = #{jobId}
</delete>
<select id="triggerCountByHandleCode" parameterType="java.lang.Integer" resultType="java.lang.Integer">
<select id="triggerCountByHandleCode" resultType="int" >
SELECT count(1)
FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="_parameter gt 0">
<if test="handleCode gt 0">
AND t.handle_code = #{handleCode}
</if>
</trim>
</select>
<select id="triggerCountByDay" parameterType="java.util.Map" resultType="java.util.Map" >
<select id="triggerCountByDay" resultType="java.util.Map" >
SELECT DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay, COUNT(id) triggerCount
FROM XXL_JOB_QRTZ_TRIGGER_LOG
WHERE trigger_time BETWEEN #{from} and #{to}
@ -172,7 +172,7 @@
GROUP BY triggerDay;
</select>
<delete id="clearLog" parameterType="java.util.Map" >
<delete id="clearLog" >
delete from XXL_JOB_QRTZ_TRIGGER_LOG
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0">

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="XxlJobRegistryMapper">
<mapper namespace="com.xxl.job.admin.dao.XxlJobRegistryDao">
<resultMap id="XxlJobRegistry" type="com.xxl.job.admin.core.model.XxlJobRegistry" >
<result column="id" property="id" />
@ -30,7 +30,7 @@
WHERE t.update_time <![CDATA[ > ]]> DATE_ADD(NOW(),INTERVAL -#{timeout} SECOND)
</select>
<update id="registryUpdate" parameterType="java.util.Map" >
<update id="registryUpdate" >
UPDATE XXL_JOB_QRTZ_TRIGGER_REGISTRY
SET `update_time` = NOW()
WHERE `registry_group` = #{registryGroup}
@ -38,7 +38,7 @@
AND `registry_value` = #{registryValue}
</update>
<insert id="registrySave" parameterType="java.util.Map" >
<insert id="registrySave" >
INSERT INTO XXL_JOB_QRTZ_TRIGGER_REGISTRY( `registry_group` , `registry_key` , `registry_value`, `update_time`)
VALUES( #{registryGroup} , #{registryKey} , #{registryValue}, NOW())
</insert>

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
@ -39,11 +37,11 @@
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath:mybatis-mapper/*.xml"/>
</bean>
<!-- scope must be "prototype" when junit -->
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
<property name="basePackage" value="com.xxl.job.admin.dao" />
</bean>
<!-- ********************************* part 2 :for tx ********************************* -->
@ -52,23 +50,6 @@
</bean>
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="detail*" propagation="SUPPORTS" />
<tx:method name="visit*" propagation="SUPPORTS" />
<tx:method name="get*" propagation="SUPPORTS" />
<tx:method name="find*" propagation="SUPPORTS" />
<tx:method name="check*" propagation="SUPPORTS" />
<tx:method name="list*" propagation="SUPPORTS" />
<tx:method name="*" propagation="REQUIRED" rollback-for="exception" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="txoperation" expression="execution(* com.xxl.job.admin.service.impl.*.*(..))" />
<aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
</aop:config>
<!-- ********************************* part 3 :for xxl-job scheduler ********************************* -->

@ -0,0 +1,47 @@
package com.xxl.job.dao.impl;
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.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
public class XxlJobGroupDaoTest {
@Resource
private XxlJobGroupDao xxlJobGroupDao;
@Test
public void test(){
List<XxlJobGroup> list = xxlJobGroupDao.findAll();
List<XxlJobGroup> list2 = xxlJobGroupDao.findByAddressType(0);
XxlJobGroup group = new XxlJobGroup();
group.setAppName("setAppName");
group.setTitle("setTitle");
group.setOrder(1);
group.setAddressType(0);
group.setAddressList("setAddressList");
int ret = xxlJobGroupDao.save(group);
XxlJobGroup group2 = xxlJobGroupDao.load(group.getId());
group2.setAppName("setAppName2");
group2.setTitle("setTitle2");
group2.setOrder(2);
group2.setAddressType(2);
group2.setAddressList("setAddressList2");
int ret2 = xxlJobGroupDao.update(group2);
int ret3 = xxlJobGroupDao.remove(group.getId());
}
}

@ -1,13 +1,14 @@
package com.xxl.job.dao.impl;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ -15,7 +16,7 @@ import java.util.List;
public class XxlJobInfoTest {
@Resource
private IXxlJobInfoDao xxlJobInfoDao;
private XxlJobInfoDao xxlJobInfoDao;
@Test
public void pageList(){
@ -24,6 +25,8 @@ public class XxlJobInfoTest {
System.out.println(list);
System.out.println(list_count);
List<XxlJobInfo> list2 = xxlJobInfoDao.getJobsByGroup(1);
}
@Test
@ -31,20 +34,45 @@ public class XxlJobInfoTest {
XxlJobInfo info = new XxlJobInfo();
info.setJobGroup(1);
info.setJobCron("jobCron");
info.setJobDesc("desc");
info.setAuthor("setAuthor");
info.setAlarmEmail("setAlarmEmail");
info.setExecutorRouteStrategy("setExecutorRouteStrategy");
info.setExecutorHandler("setExecutorHandler");
info.setExecutorParam("setExecutorParam");
info.setExecutorBlockStrategy("setExecutorBlockStrategy");
info.setExecutorFailStrategy("setExecutorFailStrategy");
info.setGlueType("setGlueType");
info.setGlueSource("setGlueSource");
info.setGlueRemark("setGlueRemark");
info.setChildJobKey("setChildJobKey");
int count = xxlJobInfoDao.save(info);
System.out.println(count);
System.out.println(info.getId());
XxlJobInfo item = xxlJobInfoDao.loadById(2);
System.out.println(item);
}
@Test
public void update(){
XxlJobInfo item = xxlJobInfoDao.loadById(2);
item.setJobCron("jobCron2");
xxlJobInfoDao.update(item);
XxlJobInfo info2 = xxlJobInfoDao.loadById(info.getId());
info2.setJobCron("jobCron2");
info2.setJobDesc("desc2");
info2.setAuthor("setAuthor2");
info2.setAlarmEmail("setAlarmEmail2");
info2.setExecutorRouteStrategy("setExecutorRouteStrategy2");
info2.setExecutorHandler("setExecutorHandler2");
info2.setExecutorParam("setExecutorParam2");
info2.setExecutorBlockStrategy("setExecutorBlockStrategy2");
info2.setExecutorFailStrategy("setExecutorFailStrategy2");
info2.setGlueType("setGlueType2");
info2.setGlueSource("setGlueSource2");
info2.setGlueRemark("setGlueRemark2");
info2.setGlueUpdatetime(new Date());
info2.setChildJobKey("setChildJobKey2");
int item2 = xxlJobInfoDao.update(info2);
xxlJobInfoDao.delete(info2.getId());
List<XxlJobInfo> list2 = xxlJobInfoDao.getJobsByGroup(1);
int ret3 = xxlJobInfoDao.findAllCount();
}
}

@ -0,0 +1,62 @@
package com.xxl.job.dao.impl;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.dao.XxlJobLogDao;
import org.apache.commons.lang.time.DateUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
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")
public class XxlJobLogDaoTest {
@Resource
private XxlJobLogDao xxlJobLogDao;
@Test
public void test(){
List<XxlJobLog> list = xxlJobLogDao.pageList(0, 10, 1, 1, null, null, 1);
int list_count = xxlJobLogDao.pageListCount(0, 10, 1, 1, null, null, 1);
XxlJobLog log = new XxlJobLog();
log.setJobGroup(1);
log.setJobId(1);
int ret1 = xxlJobLogDao.save(log);
XxlJobLog dto = xxlJobLogDao.load(log.getId());
log.setGlueType("1");
log.setTriggerTime(new Date());
log.setTriggerCode(1);
log.setTriggerMsg("1");
log.setExecutorAddress("1");
log.setExecutorHandler("1");
log.setExecutorParam("1");
ret1 = xxlJobLogDao.updateTriggerInfo(log);
dto = xxlJobLogDao.load(log.getId());
log.setHandleTime(new Date());
log.setHandleCode(2);
log.setHandleMsg("2");
ret1 = xxlJobLogDao.updateHandleInfo(log);
dto = xxlJobLogDao.load(log.getId());
List<Map<String, Object>> list2 = xxlJobLogDao.triggerCountByDay(DateUtils.addDays(new Date(), 30), new Date(), 200);
int ret4 = xxlJobLogDao.clearLog(1, 1, new Date(), 100);
int ret2 = xxlJobLogDao.delete(log.getJobId());
int ret3 = xxlJobLogDao.triggerCountByHandleCode(-1);
}
}

@ -0,0 +1,36 @@
package com.xxl.job.dao.impl;
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.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
public class XxlJobLogGlueDaoTest {
@Resource
private XxlJobLogGlueDao xxlJobLogGlueDao;
@Test
public void test(){
XxlJobLogGlue logGlue = new XxlJobLogGlue();
logGlue.setJobId(1);
logGlue.setGlueType("1");
logGlue.setGlueSource("1");
logGlue.setGlueRemark("1");
int ret = xxlJobLogGlueDao.save(logGlue);
List<XxlJobLogGlue> list = xxlJobLogGlueDao.findByJobId(1);
int ret2 = xxlJobLogGlueDao.removeOld(1, 1);
int ret3 =xxlJobLogGlueDao.deleteByJobId(1);
}
}

@ -0,0 +1,32 @@
package com.xxl.job.dao.impl;
import com.xxl.job.admin.core.model.XxlJobRegistry;
import com.xxl.job.admin.dao.XxlJobRegistryDao;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
public class XxlJobRegistryDaoTest {
@Resource
private XxlJobRegistryDao xxlJobRegistryDao;
@Test
public void test(){
int ret = xxlJobRegistryDao.registryUpdate("g1", "k1", "v1");
if (ret < 1) {
ret = xxlJobRegistryDao.registrySave("g1", "k1", "v1");
}
List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(1);
int ret2 = xxlJobRegistryDao.removeDead(1);
}
}
Loading…
Cancel
Save