|
|
@@ -1,78 +0,0 @@ |
|
|
|
//package cn.com.taiji.dmq.manager.quartz; |
|
|
|
// |
|
|
|
//import java.util.concurrent.TimeUnit; |
|
|
|
// |
|
|
|
//import javax.annotation.PostConstruct; |
|
|
|
//import javax.sql.DataSource; |
|
|
|
// |
|
|
|
//import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
//import org.springframework.beans.factory.annotation.Value; |
|
|
|
// |
|
|
|
//import cn.com.taiji.common.manager.AbstractManager; |
|
|
|
//import cn.com.taiji.common.manager.quartz.RunnableProxy; |
|
|
|
//import cn.com.taiji.common.manager.quartz.TaskDefinition; |
|
|
|
//import cn.com.taiji.common.manager.quartz.TaskHolder; |
|
|
|
//import cn.com.taiji.common.manager.quartz.TaskRunnable; |
|
|
|
//import cn.com.taiji.common.pub.concurrent.ClusterLock; |
|
|
|
//import cn.com.taiji.common.pub.concurrent.DbLockJdbcDao; |
|
|
|
//import cn.com.taiji.dmq.model.TaskInfo; |
|
|
|
// |
|
|
|
///** |
|
|
|
// * |
|
|
|
// * @author Peream <br> |
|
|
|
// * Create Time:2013年8月9日 上午10:42:56<br> |
|
|
|
// * <a href="mailto:peream@gmail.com">peream@gmail.com</a> |
|
|
|
// * @since 1.0 |
|
|
|
// * @version 1.0 |
|
|
|
// */ |
|
|
|
//public abstract class AbstractPriorityCronTask extends AbstractManager implements TaskRunnable { |
|
|
|
// |
|
|
|
// @Value("${app.nodeNum}") |
|
|
|
// private String nodeNum; |
|
|
|
// private final TaskInfo taskInfo; |
|
|
|
// @Autowired |
|
|
|
// private DataSource dataSource; |
|
|
|
// protected ClusterLock lock;// 基于数据库update操作的乐观锁 |
|
|
|
// protected DbLockJdbcDao persister; |
|
|
|
// |
|
|
|
// protected AbstractPriorityCronTask(TaskInfo taskInfo) { |
|
|
|
// this.taskInfo = taskInfo; |
|
|
|
// } |
|
|
|
// |
|
|
|
// public TaskDefinition getTaskInfo() { |
|
|
|
// return taskInfo; |
|
|
|
// } |
|
|
|
// |
|
|
|
// @PostConstruct |
|
|
|
// private void initLock() { |
|
|
|
// persister = new DbLockJdbcDao(dataSource, "trans_lock"); |
|
|
|
// |
|
|
|
// long maxExecuteMills = taskInfo.getMaxExecSeconds() < 0 ? Long.MAX_VALUE : taskInfo.getMaxExecSeconds() * 1000; |
|
|
|
// lock = new ClusterLock(taskInfo.name(), persister, maxExecuteMills, nodeNum); |
|
|
|
// } |
|
|
|
// |
|
|
|
// public void priorityWait() { |
|
|
|
// try { |
|
|
|
// TimeUnit.MILLISECONDS.sleep(taskInfo.getDelayTimeMillis(Integer.parseInt(nodeNum))); |
|
|
|
// } catch (InterruptedException e) { |
|
|
|
// e.printStackTrace(); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// protected final void runDepenedTasks(TaskInfo... infos) { |
|
|
|
// if (isEmpty(infos)) |
|
|
|
// return; |
|
|
|
// for (TaskInfo info : infos) { |
|
|
|
// RunnableProxy task = TaskHolder.getTask(info); |
|
|
|
// if (task == null) { |
|
|
|
// logger.error("任务{}未配置.", info); |
|
|
|
// continue; |
|
|
|
// } |
|
|
|
// logger.info("\t开始执行依赖任务:{}", info); |
|
|
|
// task.run(); |
|
|
|
// logger.info("\t完成依赖任务执行:{}", info); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// |
|
|
|
//} |