Ignore:
Timestamp:
09/15/14 17:00:03 (11 years ago)
Author:
wojtekp
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/tasks/JobRegistryImpl.java

    r1415 r1434  
    77import java.util.Set; 
    88 
    9 import org.apache.commons.logging.Log; 
    10 import org.apache.commons.logging.LogFactory; 
    119import org.qcg.broker.schemas.resreqs.ParentType; 
    1210import org.qcg.broker.schemas.resreqs.Workflow; 
    1311import org.qcg.broker.schemas.resreqs.types.TaskStatesName; 
    1412 
    15 import dcworms.schedframe.scheduling.ExecTask; 
    16  
    1713import qcg.shared.constants.BrokerConstants; 
    1814import schedframe.ExecutablesList; 
     15import schedframe.resources.computing.ComputingResource; 
    1916import schedframe.scheduling.tasks.JobInterface; 
    2017import schedframe.scheduling.tasks.Task; 
     18import dcworms.schedframe.scheduling.ExecTask; 
    2119 
    2220public class JobRegistryImpl extends AbstractJobRegistry { 
    2321 
    24         private static Log log = LogFactory.getLog(JobRegistryImpl.class); 
    25  
    2622        private String context; 
    27  
     23        private ComputingResource cr; 
    2824        //TO DO - consider data structure 
    2925        protected static final ExecutablesList executables = new ExecutablesList(); 
     26 
    3027        //protected static final List<ExecTask> executables = Collections.synchronizedList(new ArrayList<ExecTask>());; 
    3128        //protected static final List<ExecTaskInterface> executables = new CopyOnWriteArrayList<ExecTaskInterface>(); 
     
    3431                this.context = context; 
    3532        } 
    36  
     33         
     34        public JobRegistryImpl(ComputingResource cr) { 
     35                this.cr = cr; 
     36        } 
     37 
     38        public JobRegistryImpl() { 
     39                this(""); 
     40        } 
     41         
    3742        public boolean addExecTask(ExecTask newTask) { 
    3843                if(getTask(newTask.getJobId(), newTask.getId()) == null) { 
    39                         synchronized (executables)  { 
     44                        synchronized (executables) { 
    4045                                executables.add(newTask); 
    4146                        } 
     
    5358                        for (ExecTask task: executables) { 
    5459                                if (task.getStatus() == status) { 
    55                                         Set<String> visitedResource = task.getAllocatedResources().getLast().getResourceNames(); 
    56                                         for(String res: visitedResource){ 
    57                                                 if(res.equals(context) || res.substring(0, res.lastIndexOf("/")).contains(context)){ 
     60                                        if(cr != null){ 
     61                                                Set<ComputingResource> visitedResource = task.getAllocatedResources().getLast().getResources(); 
     62                                                if(visitedResource.contains(cr)){ 
    5863                                                        taskList.add(task); 
    59                                                         break; 
    60                                                 } 
    61                                         } 
    62                                         if(task.getSchedulerName().equals(context)) { 
    63                                                 taskList.add(task); 
    64                                         } 
    65                                 } 
    66                         } 
    67                 } 
     64                                                } else { 
     65                                                        for(ComputingResource res: visitedResource){ 
     66                                                                if(cr.contains(res)){ 
     67                                                                        taskList.add(task); 
     68                                                                        break; 
     69                                                                } 
     70                                                        } 
     71                                                } 
     72                                        } else { 
     73                                                Set<String> visitedResource = task.getAllocatedResources().getLast().getResourceNames(); 
     74                                                for(String res: visitedResource){ 
     75                                                        if(res.equals(context) || res.substring(0, res.lastIndexOf("/")).contains(context)){ 
     76                                                                taskList.add(task); 
     77                                                                break; 
     78                                                        } 
     79                                                } 
     80 
     81                                                if(task.getSchedulerName().equals(context)) { 
     82                                                        taskList.add(task); 
     83                                                } 
     84                                        } 
     85                                } 
     86                        } 
     87                } 
     88 
    6889                return taskList; 
    6990        } 
Note: See TracChangeset for help on using the changeset viewer.