source: DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/tasks/AbstractJobRegistry.java @ 477

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