source: DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/AbstractJobRegistry.java @ 480

Revision 480, 1.8 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package schedframe.scheduling.manager.tasks;
2
3
4import java.util.concurrent.ConcurrentHashMap;
5
6import org.apache.commons.logging.Log;
7import org.apache.commons.logging.LogFactory;
8
9import schedframe.scheduling.tasks.Job;
10import schedframe.scheduling.tasks.JobInterface;
11import schedframe.scheduling.tasks.Task;
12import schedframe.scheduling.tasks.TaskInterface;
13
14
15public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job> */implements JobRegistry, Cloneable{
16       
17        private static final long serialVersionUID = 8409060063583755824L;
18       
19        private static Log log = LogFactory.getLog(AbstractJobRegistry.class);
20       
21        protected static final ConcurrentHashMap<String, Job> jobs = new ConcurrentHashMap<String, Job>();
22       
23        protected AbstractJobRegistry(){
24                //log.warn("Methods from JobRegistry interface are not implemented.");
25        }
26       
27        public boolean addJob(JobInterface<?> job) {
28                jobs.put(job.getId(), (Job) job);
29                return true;
30        }
31
32        public boolean addTask(TaskInterface<?> task) {
33                if(jobs.containsKey(task.getJobId())){
34                        jobs.get(task.getJobId()).add((Task)task);
35                        return true;
36                } else {
37                        return false;
38                }
39        }
40
41        public Job getJob(String jobId){
42                return jobs.get(jobId);
43        }
44       
45        public JobInterface<?> getJobInfo(String jobID) {
46                return jobs.get(jobID);
47        }
48
49        public TaskInterface<?> getTaskInfo(String jobID, String taskId) {
50                Task task = null;
51                Job job = jobs.get(jobID);
52               
53                if(job == null)
54                        return null;
55               
56                try {
57                        task = job.getTask(taskId);
58                } catch (NoSuchFieldException e) {
59                        log.error(e.getMessage());
60                }
61                return task;
62        }
63       
64        /*public List<JobInterface<?>> getActiveJobs() {
65                log.error("getActiveJobs() not implemented.");
66                return null;
67        }
68
69        public List<TaskInterface<?>> getActiveTasks() {
70                log.error("getActiveTasks() not implemented.");
71                return null;
72        }*/
73
74}
Note: See TracBrowser for help on using the repository browser.