cn.dceast.platform.task.quartz.data.OutputToRAM Maven / Gradle / Ivy
The newest version!
package cn.dceast.platform.task.quartz.data;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import cn.dceast.platform.task.config.TaskConfig;
import cn.dceast.platform.task.quartz.JobEntity;
import cn.dceast.platform.task.quartz.JobExecutedEntity;
/**
* job数据写内存
* @author zhang
*
*/
public class OutputToRAM implements OutputJobInfoExecutor{
private static Map jobs=new ConcurrentHashMap();
@Override
public void addJob(JobExecutedEntity jee) {
jobs.put(jee.getJobId(), jee);
}
@Override
public void deleteJob(String jobId) {
if(jobs.containsKey(jobId)){
jobs.remove(jobId);
}
}
@Override
public void deleteJob(String groupName, String jobName) {
JobExecutedEntity jee = this.getJob(groupName, jobName);
if(jee!=null && jobs.containsKey(jee.getJobId())){
jobs.remove(jee.getJobId());
}
}
@Override
public void updateJob(JobExecutedEntity jee) {
jobs.put(jee.getJobId(), jee);
}
@Override
public void addJobHistory(JobExecutedEntity jee) {
}
@Override
public void addJobLifecycleManageLog(JobEntity jobEntity, String op) {
}
@Override
public JobExecutedEntity getJob(String jobId) {
return jobs.get(jobId);
}
@Override
public JobExecutedEntity getJob(String groupName, String jobName) {
JobExecutedEntity jee = null;
Iterator iterator = jobs.keySet().iterator();
while (iterator.hasNext()) {
jee = jobs.get(iterator.next().toString());
if(jee!=null && groupName.equals(jee.getJobGroup()) && jobName.equals(jee.getJobName())
&& TaskConfig.appName.equals(jee.getAppName())){
break;
}
}
return jee;
}
@Override
public List getJobs() {
List resultList=new ArrayList();
if(jobs!=null){
Iterator> iterator=jobs.entrySet().iterator();
while(iterator.hasNext()){
Entry entry=iterator.next();
resultList.add(entry.getValue());
}
}
return resultList;
}
@Override
public Map getJobExecutedHistory(int pageNo, int pageSize,
String jobGroup, String jobName, Date beginTime, Date endtime,String jobId) {
return null;
}
@Override
public Map getJobLifecycleHistory(int pageNo, int pageSize,
String jobGroup, String jobName, Date beginTime, Date endtime,
String action,String jobId) {
return null;
}
@Override
public String getNextJobId(){
return UUID.randomUUID().toString().replaceAll("-", "");
}
}