diff --git a/cms/cms-web/pom.xml b/cms/cms-web/pom.xml index 83117123..b20380ec 100644 --- a/cms/cms-web/pom.xml +++ b/cms/cms-web/pom.xml @@ -35,6 +35,15 @@ javax.servlet jstl + + + com.taobao.pamirs.schedule + tbschedule + 3.2.8-SNAPSHOT + system + ${project.basedir}/src/main/webapp/WEB-INF/lib/tbschedule-3.2.8-SNAPSHOT.jar + + diff --git a/cms/cms-web/src/main/java/com/zheng/cms/schedule/LongSchedule.java b/cms/cms-web/src/main/java/com/zheng/cms/schedule/LongSchedule.java new file mode 100644 index 00000000..1454f0e8 --- /dev/null +++ b/cms/cms-web/src/main/java/com/zheng/cms/schedule/LongSchedule.java @@ -0,0 +1,58 @@ +package com.zheng.cms.schedule; + +import com.taobao.pamirs.schedule.IScheduleTaskDealSingle; +import com.taobao.pamirs.schedule.TaskItemDefine; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +/** + * 测试任务 + * Created by zhangshuzheng on 2016/11/14. + */ +public class LongSchedule implements IScheduleTaskDealSingle { + + /** + * 执行单个任务 + * @param item Object + * @param ownSign 当前环境名称 + * @throws Exception + */ + @Override + public boolean execute(Long item, String ownSign) throws Exception { + System.out.println("执行任务:" + item); + return true; + } + + /** + * 根据条件,查询当前调度服务器可处理的任务 + * @param taskParameter 任务的自定义参数 + * @param ownSign 当前环境名称 + * @param taskItemNum 当前任务类型的任务队列数量 + * @param taskItemList 当前调度服务器,分配到的可处理队列 + * @param eachFetchDataNum 每次获取数据的数量 + * @return + * @throws Exception + */ + @Override + public List selectTasks(String taskParameter, String ownSign, int taskItemNum, List taskItemList, int eachFetchDataNum) throws Exception { + List allDrawList = new ArrayList<>(); + allDrawList.add(System.currentTimeMillis()); + return allDrawList; + } + + /** + * 获取任务的比较器,只有在NotSleep模式下需要用到 + * @return + */ + @Override + public Comparator getComparator() { + return new Comparator() { + public int compare(Long o1, Long o2) { + return o1.compareTo(o2); + } + }; + } + +} diff --git a/cms/cms-web/src/main/java/com/zheng/cms/schedule/MapSchedule.java b/cms/cms-web/src/main/java/com/zheng/cms/schedule/MapSchedule.java new file mode 100644 index 00000000..cc66e4e7 --- /dev/null +++ b/cms/cms-web/src/main/java/com/zheng/cms/schedule/MapSchedule.java @@ -0,0 +1,63 @@ +package com.zheng.cms.schedule; + +import com.taobao.pamirs.schedule.IScheduleTaskDealSingle; +import com.taobao.pamirs.schedule.TaskItemDefine; + +import java.util.*; + +/** + * 测试任务 + * Created by zhangshuzheng on 2016/11/14. + */ +public class MapSchedule implements IScheduleTaskDealSingle { + + /** + * 执行单个任务 + * @param item Object + * @param ownSign 当前环境名称 + * @throws Exception + */ + @Override + public boolean execute(Map item, String ownSign) throws Exception { + System.out.println("执行任务:" + item); + return true; + } + + /** + * 根据条件,查询当前调度服务器可处理的任务 + * @param taskParameter 任务的自定义参数 + * @param ownSign 当前环境名称 + * @param taskItemNum 当前任务类型的任务队列数量 + * @param taskItemList 当前调度服务器,分配到的可处理队列 + * @param eachFetchDataNum 每次获取数据的数量 + * @return + * @throws Exception + */ + @Override + public List selectTasks(String taskParameter, String ownSign, int taskItemNum, List taskItemList, int eachFetchDataNum) throws Exception { + List allDrawList = new ArrayList<>(); + Map map = new HashMap(); + map.put("ID", System.currentTimeMillis()); + allDrawList.add(map); + return allDrawList; + } + + /** + * 获取任务的比较器,只有在NotSleep模式下需要用到 + * @return + */ + @Override + public Comparator getComparator() { + return new Comparator() { + public int compare(Map o1, Map o2) { + Long l1 = (Long) o1.get("ID"); + Long l2 = (Long) o2.get("ID"); + return l1.compareTo(l2); + } + public boolean equals(Object obj) { + return this == obj; + } + }; + } + +} diff --git a/cms/cms-web/src/main/webapp/WEB-INF/lib/tbschedule-3.2.8-SNAPSHOT.jar b/cms/cms-web/src/main/webapp/WEB-INF/lib/tbschedule-3.2.8-SNAPSHOT.jar new file mode 100644 index 00000000..c3292314 Binary files /dev/null and b/cms/cms-web/src/main/webapp/WEB-INF/lib/tbschedule-3.2.8-SNAPSHOT.jar differ