diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md index ebd244b9..cc8c77e2 100644 --- a/doc/XXL-JOB官方文档.md +++ b/doc/XXL-JOB官方文档.md @@ -901,6 +901,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段 - 2、动态分片:分片广播任务以执行器为维度进行分片,支持动态扩容执行器集群从而动态增加分片数量,协同进行业务处理;在进行大数据量业务操作时可显著提升任务处理能力和速度。 - 3、执行器JobHandler禁止命名冲突; - 4、执行器集群地址列表进行自然排序; +- 5、调度中心,DAO层代码精简优化并且新增测试用例覆盖; #### TODO LIST - 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java index 6ae94959..f50fb9af 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java @@ -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") diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobCodeController.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobCodeController.java index da5f25f2..e41f8e8d 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobCodeController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobCodeController.java @@ -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) { diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java index bd9e8f7b..496d34e7 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java @@ -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) { diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java index 9eb62c4f..db4e0c55 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java @@ -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; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java index 2ea20ae4..4a961ef2 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java @@ -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> listJobByGroup(String jobGroup){ + public ReturnT> getJobsByGroup(int jobGroup){ List list = xxlJobInfoDao.getJobsByGroup(jobGroup); return new ReturnT>(list); } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobLog.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobLog.java index b5da7ecc..30976f38 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobLog.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobLog.java @@ -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; } } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/schedule/XxlJobDynamicScheduler.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/schedule/XxlJobDynamicScheduler.java index 8cbd73af..0e9dbac5 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/schedule/XxlJobDynamicScheduler.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/schedule/XxlJobDynamicScheduler.java @@ -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 diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobInfoDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobInfoDao.java deleted file mode 100644 index 75a672f9..00000000 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobInfoDao.java +++ /dev/null @@ -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 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 getJobsByGroup(String jobGroup); - - public int findAllCount(); - -} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobLogDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobLogDao.java deleted file mode 100644 index 62044ef5..00000000 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobLogDao.java +++ /dev/null @@ -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 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> triggerCountByDay(Date from, Date to, int handleCode); - - public int clearLog(int jobGroup, int jobId, Date clearBeforeTime, int clearBeforeNum); - -} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobLogGlueDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobLogGlueDao.java deleted file mode 100644 index 1ced72b6..00000000 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobLogGlueDao.java +++ /dev/null @@ -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 findByJobId(int jobId); - - public int removeOld(int jobId, int limit); - - public int deleteByJobId(int jobId); - -} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobRegistryDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobRegistryDao.java deleted file mode 100644 index 9af00615..00000000 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobRegistryDao.java +++ /dev/null @@ -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 findAll(int timeout); - - public int registryUpdate(String registryGroup, String registryKey, String registryValue); - - public int registrySave(String registryGroup, String registryKey, String registryValue); - -} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobGroupDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobGroupDao.java similarity index 52% rename from xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobGroupDao.java rename to xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobGroupDao.java index 5ecb9efe..7d654145 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobGroupDao.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobGroupDao.java @@ -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 findAll(); - public List findByAddressType(int addressType); + public List 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); } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobInfoDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobInfoDao.java new file mode 100644 index 00000000..69b556c3 --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobInfoDao.java @@ -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 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 getJobsByGroup(@Param("jobGroup") int jobGroup); + + public int findAllCount(); + +} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java new file mode 100644 index 00000000..0f91c79e --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java @@ -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 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> 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); + +} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogGlueDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogGlueDao.java new file mode 100644 index 00000000..e17d6d4c --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogGlueDao.java @@ -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 findByJobId(@Param("jobId") int jobId); + + public int removeOld(@Param("jobId") int jobId, @Param("limit") int limit); + + public int deleteByJobId(@Param("jobId") int jobId); + +} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobRegistryDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobRegistryDao.java new file mode 100644 index 00000000..a963e0ff --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobRegistryDao.java @@ -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 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); + +} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobGroupDaoImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobGroupDaoImpl.java index de1e3224..45e3294b 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobGroupDaoImpl.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobGroupDaoImpl.java @@ -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 findAll() { - return sqlSessionTemplate.selectList("XxlJobGroupMapper.findAll"); - } - - @Override - public List 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 findAll() { +// return sqlSessionTemplate.selectList("XxlJobGroupMapper.findAll"); +// } +// +// @Override +// public List 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); +// } +// +// +//} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobInfoDaoImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobInfoDaoImpl.java index 6b211da2..4bee7998 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobInfoDaoImpl.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobInfoDaoImpl.java @@ -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 pageList(int offset, int pagesize, int jobGroup, String executorHandler) { - HashMap params = new HashMap(); - 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 params = new HashMap(); - 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 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 pageList(int offset, int pagesize, int jobGroup, String executorHandler) { +// HashMap params = new HashMap(); +// 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 params = new HashMap(); +// 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 getJobsByGroup(String jobGroup) { +// return sqlSessionTemplate.selectList("XxlJobInfoMapper.getJobsByGroup", jobGroup); +// } +// +// @Override +// public int findAllCount() { +// return sqlSessionTemplate.selectOne("XxlJobInfoMapper.findAllCount"); +// } +// +//} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobLogDaoImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobLogDaoImpl.java index 328f285b..8cbaf2a6 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobLogDaoImpl.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobLogDaoImpl.java @@ -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 pageList(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus) { - HashMap params = new HashMap(); - 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 params = new HashMap(); - 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> triggerCountByDay(Date from, Date to, int handleCode) { - Map params = new HashMap(); - 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 params = new HashMap(); - 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 pageList(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus) { +// HashMap params = new HashMap(); +// 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 params = new HashMap(); +// 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> triggerCountByDay(Date from, Date to, int handleCode) { +// Map params = new HashMap(); +// 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 params = new HashMap(); +// params.put("jobGroup", jobGroup); +// params.put("jobId", jobId); +// params.put("clearBeforeTime", clearBeforeTime); +// params.put("clearBeforeNum", clearBeforeNum); +// return sqlSessionTemplate.delete("XxlJobLogMapper.clearLog", params); +// } +// +//} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobLogGlueDaoImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobLogGlueDaoImpl.java index 7f6e4ded..455b53b7 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobLogGlueDaoImpl.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobLogGlueDaoImpl.java @@ -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 findByJobId(int jobId) { - return sqlSessionTemplate.selectList("XxlJobLogGlueMapper.findByJobId", jobId); - } - - @Override - public int removeOld(int jobId, int limit) { - HashMap params = new HashMap(); - 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 findByJobId(int jobId) { +// return sqlSessionTemplate.selectList("XxlJobLogGlueMapper.findByJobId", jobId); +// } +// +// @Override +// public int removeOld(int jobId, int limit) { +// HashMap params = new HashMap(); +// 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); +// } +// +//} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobRegistryDaoImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobRegistryDaoImpl.java index dd53fa2b..62aa3753 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobRegistryDaoImpl.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobRegistryDaoImpl.java @@ -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 findAll(int timeout) { - return sqlSessionTemplate.selectList("XxlJobRegistryMapper.findAll", timeout); - } - - @Override - public int registryUpdate(String registryGroup, String registryKey, String registryValue) { - Map params = new HashMap(); - 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 params = new HashMap(); - 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 findAll(int timeout) { +// return sqlSessionTemplate.selectList("XxlJobRegistryMapper.findAll", timeout); +// } +// +// @Override +// public int registryUpdate(String registryGroup, String registryKey, String registryValue) { +// Map params = new HashMap(); +// 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 params = new HashMap(); +// params.put("registryGroup", registryGroup); +// params.put("registryKey", registryKey); +// params.put("registryValue", registryValue); +// +// return sqlSessionTemplate.update("XxlJobRegistryMapper.registrySave", params); +// } +// +//} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java index 67ab1345..a80793a2 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java @@ -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 pageList(int start, int length, int jobGroup, String executorHandler, String filterTime) { diff --git a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml index a21a4366..5b5b1c30 100644 --- a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml @@ -1,7 +1,7 @@ - + @@ -34,7 +34,7 @@ ORDER BY t.order ASC - + INSERT INTO XXL_JOB_QRTZ_TRIGGER_GROUP ( `app_name`, `title`, `order`, `address_type`, `address_list`) values ( #{appName}, #{title}, #{order}, #{addressType}, #{addressList}); diff --git a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml index 9b16cce7..9be9b8e0 100644 --- a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml @@ -1,7 +1,7 @@ - + diff --git a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogGlueMapper.xml b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogGlueMapper.xml index 3b1fbfaf..ba4a1674 100644 --- a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogGlueMapper.xml +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogGlueMapper.xml @@ -1,7 +1,7 @@ - + @@ -39,9 +39,9 @@ now(), now() ); - + - + DELETE FROM XXL_JOB_QRTZ_TRIGGER_LOGGLUE WHERE id NOT in( SELECT id FROM( diff --git a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml index c5ae9e78..a767aebd 100644 --- a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml @@ -1,7 +1,7 @@ - + @@ -41,7 +41,7 @@ t.handle_msg - SELECT FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t @@ -74,7 +74,7 @@ LIMIT #{offset}, #{pagesize} - SELECT count(1) FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t @@ -120,12 +120,12 @@ #{jobGroup}, #{jobId} ); - + - + UPDATE XXL_JOB_QRTZ_TRIGGER_LOG SET `glue_type`= #{glueType}, @@ -147,22 +147,22 @@ WHERE `id`= #{id} - + delete from XXL_JOB_QRTZ_TRIGGER_LOG WHERE job_id = #{jobId} - SELECT count(1) FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t - + AND t.handle_code = #{handleCode} - 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; - + delete from XXL_JOB_QRTZ_TRIGGER_LOG diff --git a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobRegistryMapper.xml b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobRegistryMapper.xml index 37402679..13443980 100644 --- a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobRegistryMapper.xml +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobRegistryMapper.xml @@ -1,7 +1,7 @@ - + @@ -30,7 +30,7 @@ WHERE t.update_time ]]> DATE_ADD(NOW(),INTERVAL -#{timeout} SECOND) - + UPDATE XXL_JOB_QRTZ_TRIGGER_REGISTRY SET `update_time` = NOW() WHERE `registry_group` = #{registryGroup} @@ -38,7 +38,7 @@ AND `registry_value` = #{registryValue} - + INSERT INTO XXL_JOB_QRTZ_TRIGGER_REGISTRY( `registry_group` , `registry_key` , `registry_value`, `update_time`) VALUES( #{registryGroup} , #{registryKey} , #{registryValue}, NOW()) diff --git a/xxl-job-admin/src/main/resources/spring/applicationcontext-xxl-job-admin.xml b/xxl-job-admin/src/main/resources/spring/applicationcontext-xxl-job-admin.xml index 5cb24368..efd483a0 100644 --- a/xxl-job-admin/src/main/resources/spring/applicationcontext-xxl-job-admin.xml +++ b/xxl-job-admin/src/main/resources/spring/applicationcontext-xxl-job-admin.xml @@ -1,11 +1,9 @@ @@ -39,11 +37,11 @@ - - - - - + + + + + @@ -52,23 +50,6 @@ - - - - - - - - - - - - - - - - - diff --git a/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobGroupDaoTest.java b/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobGroupDaoTest.java new file mode 100644 index 00000000..122d4780 --- /dev/null +++ b/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobGroupDaoTest.java @@ -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 list = xxlJobGroupDao.findAll(); + + List 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()); + } + +} diff --git a/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobInfoTest.java b/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobInfoTest.java index 133dafe9..d7d17d2d 100644 --- a/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobInfoTest.java +++ b/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobInfoTest.java @@ -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 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 list2 = xxlJobInfoDao.getJobsByGroup(1); + + int ret3 = xxlJobInfoDao.findAllCount(); + } - + } diff --git a/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobLogDaoTest.java b/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobLogDaoTest.java new file mode 100644 index 00000000..b8c56e23 --- /dev/null +++ b/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobLogDaoTest.java @@ -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 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> 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); + } + +} diff --git a/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobLogGlueDaoTest.java b/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobLogGlueDaoTest.java new file mode 100644 index 00000000..fe8ebc8a --- /dev/null +++ b/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobLogGlueDaoTest.java @@ -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 list = xxlJobLogGlueDao.findByJobId(1); + + int ret2 = xxlJobLogGlueDao.removeOld(1, 1); + + int ret3 =xxlJobLogGlueDao.deleteByJobId(1); + } + +} diff --git a/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobRegistryDaoTest.java b/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobRegistryDaoTest.java new file mode 100644 index 00000000..349ef4b0 --- /dev/null +++ b/xxl-job-admin/src/test/java/com/xxl/job/dao/impl/XxlJobRegistryDaoTest.java @@ -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 list = xxlJobRegistryDao.findAll(1); + + int ret2 = xxlJobRegistryDao.removeDead(1); + } + +}