Ignore:
Timestamp:
10/31/12 13:52:06 (13 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/trunk/build/classes/schedframe/scheduling
Files:
6 added
54 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/Cluster.java

    r477 r539  
    1313import gridsim.GridSimTags; 
    1414import gridsim.IO_data; 
    15 import gridsim.gssim.WormsTags; 
     15import gridsim.dcworms.DCWormsTags; 
    1616 
    1717public class Cluster extends Scheduler{ 
     
    2323        protected void processOtherRequest(Sim_event ev) { 
    2424                switch (ev.get_tag()) { 
    25                 case WormsTags.QUERY_RESOURCE_DESC: 
     25                case DCWormsTags.QUERY_RESOURCE_DESC: 
    2626                        SchedulerDescription desc = new SchedulerDescription(new LocalSystem(get_name(), null, null)); 
    2727                        Map<ResourceUnitName, List<ResourceUnit>> units = managementSystem.getResourceManager().getSharedResourceUnits(); 
     
    3030 
    3131                        IO_data data = new IO_data(desc, 0, ev.get_src()); 
    32                         send(ev.get_src(), GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
     32                        send(ev.get_src(), GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
    3333                        break; 
    3434 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/GridResourceDiscovery.java

    r477 r539  
    55import gridsim.GridSimTags; 
    66import gridsim.IO_data; 
    7 import gridsim.gssim.WormsTags; 
     7import gridsim.dcworms.DCWormsTags; 
    88 
    99import java.util.ArrayList; 
     
    5858                for(int i = 0; i < resourceList.size(); i++){ 
    5959                        int resourceId = resourceList.get(i).get_id(); 
    60                         gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC, null); 
     60                        gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC, null); 
    6161                } 
    6262                 
    6363                //filter only the query response messages 
    64                 Sim_type_p pred = new Sim_type_p(WormsTags.QUERY_RESOURCE_DESC_RESULT); 
     64                Sim_type_p pred = new Sim_type_p(DCWormsTags.QUERY_RESOURCE_DESC_RESULT); 
    6565                Sim_event ev = new Sim_event(); 
    6666                 
     
    8080                for(int i = 0; i < gridBroker.getChildren().size(); i++){ 
    8181                        int resourceId = gridBroker.getChildren().get(i).get_id(); 
    82                         gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC, null); 
     82                        gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC, null); 
    8383                } 
    8484                 
    8585                //filter only the query response messages 
    86                 Sim_type_p pred = new Sim_type_p(WormsTags.QUERY_RESOURCE_DESC_RESULT); 
     86                Sim_type_p pred = new Sim_type_p(DCWormsTags.QUERY_RESOURCE_DESC_RESULT); 
    8787                Sim_event ev = new Sim_event(); 
    8888                 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/Scheduler.java

    r477 r539  
    88import gridsim.GridSimTags; 
    99import gridsim.IO_data; 
    10 import gridsim.gssim.WormsTags; 
     10import gridsim.dcworms.DCWormsTags; 
    1111 
    1212import java.util.ArrayList; 
     
    2828import schedframe.scheduling.manager.resources.ManagedResources; 
    2929import schedframe.scheduling.policy.AbstractManagementSystem; 
     30import schedframe.scheduling.queue.QueueDescription; 
    3031import schedframe.scheduling.queue.TaskQueue; 
    31 import schedframe.scheduling.queue.QueueDescription; 
    3232import schedframe.scheduling.tasks.WorkloadUnit; 
    3333 
     
    117117                                if (obj != null) { 
    118118                                        int delay = (Integer) obj; 
    119                                         send(this.get_id(), delay, WormsTags.TIMER); 
     119                                        send(this.get_id(), delay, DCWormsTags.TIMER); 
    120120                                } 
    121121                        } 
     
    133133                                // managemetnSystem_.setEndSimulation(); 
    134134                                run = false; 
    135                                 /*Sim_stat stats = get_stat(); 
    136                                 List<Object[]> measures = stats.get_measures(); 
    137                                 for (Object[] info : measures) { 
    138                                         String measure = (String) info[0]; 
    139                                         if (measure 
    140                                                         .startsWith(GssimConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) { 
    141                                                 System.out.println("====="+this.get_name()+";"+stats.average(measure)); 
    142                                         } 
    143                                 }*/ 
    144135                                break; 
    145136                        } 
     
    155146 
    156147                case GridSimTags.GRIDLET_SUBMIT: 
    157                         processGSSIMJobSubmit(ev, false); 
     148                        processWorkloadUnitSubmit(ev, false); 
    158149                        break; 
    159150 
    160151                case GridSimTags.GRIDLET_SUBMIT_ACK: 
    161                         processGSSIMJobSubmit(ev, true); 
     152                        processWorkloadUnitSubmit(ev, true); 
    162153                        break; 
    163154 
    164155                case GridSimTags.GRIDLET_RETURN: 
    165                         processGSSIMJobReturn(ev); 
     156                        processWorkloadUnitReturn(ev); 
    166157                        break; 
    167158 
     
    174165        protected void processOtherRequest(Sim_event ev) { 
    175166                switch (ev.get_tag()) { 
    176                 case WormsTags.QUERY_RESOURCE_DESC: 
     167                case DCWormsTags.QUERY_RESOURCE_DESC: 
    177168                        SchedulerDescription desc = new SchedulerDescription(new LocalSystem(get_name(), null, null)); 
    178169                        Map<ResourceUnitName, List<ResourceUnit>> units = managementSystem.getResourceManager().getSharedResourceUnits(); 
     
    181172 
    182173                        IO_data data = new IO_data(desc, 0, ev.get_src()); 
    183                         send(ev.get_src(), GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
     174                        send(ev.get_src(), GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
    184175                        break; 
    185176 
     
    189180                } 
    190181        } 
    191          
    192         /*public boolean processOtherEvent(Sim_event ev) { 
    193                 return false; 
    194         }*/ 
    195          
    196         protected void processGSSIMJobReturn(Sim_event ev) { 
    197                 WorkloadUnit<?> job = (WorkloadUnit<?>) ev.get_data(); 
     182 
     183        protected void processWorkloadUnitReturn(Sim_event ev) { 
     184                WorkloadUnit job = (WorkloadUnit) ev.get_data(); 
    198185                managementSystem.notifyReturnedWorkloadUnit(job); 
    199186        } 
    200187 
    201         protected void processGSSIMJobSubmit(Sim_event ev, boolean ack) { 
    202                 WorkloadUnit<?> job = (WorkloadUnit<?>) ev.get_data(); 
     188        protected void processWorkloadUnitSubmit(Sim_event ev, boolean ack) { 
     189                WorkloadUnit job = (WorkloadUnit) ev.get_data(); 
    203190                managementSystem.notifySubmittedWorkloadUnit(job, ack); 
    204191        } 
     
    223210                this.send(this.get_id(), delay, tag, data); 
    224211        } 
    225          
    226         /*protected void send(int dest, int tag, int transaction, Object obj){ 
    227                 IO_data data = new Transaction_IO_data(transaction, obj, 8, dest); 
    228                 super.send(dest, GridSimTags.SCHEDULE_NOW, tag, data); 
    229         }*/ 
    230212         
    231213        public Sim_port getOutputPort() { 
     
    271253        public List<QueueDescription> getQueuesDescription(){ 
    272254                List<QueueDescription> queues = new ArrayList<QueueDescription>(); 
    273                 for(TaskQueue queue: managementSystem.getAccessQueues()){ 
     255                for(TaskQueue queue: managementSystem.getQueues()){ 
    274256                        QueueDescription qd; 
    275257                        try { 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/WorkloadUnitHandler.java

    r477 r539  
    11package schedframe.scheduling; 
    22 
    3 import schedframe.scheduling.tasks.Job; 
    4 import schedframe.scheduling.tasks.SubmittedTask; 
     3import dcworms.schedframe.scheduling.ExecTask; 
     4import schedframe.scheduling.tasks.JobInterface; 
    55import schedframe.scheduling.tasks.TaskInterface; 
    6 import gssim.schedframe.scheduling.ExecTask; 
    76 
    8 public  interface WorkloadUnitHandler{ 
     7public interface WorkloadUnitHandler{ 
    98         
    10         public void handleJob(Job job); 
     9        public void handleJob(JobInterface<?> job); 
    1110         
    1211        public void handleTask(TaskInterface<?> task); 
    1312         
    1413        public void handleExecutable(ExecTask task); 
    15          
    16         public void handleSubmittedTask(SubmittedTask task); 
     14 
    1715} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/resources/LocalResourceManager.java

    r477 r539  
    1313import java.util.Properties; 
    1414import java.util.Set; 
    15 import java.util.Stack; 
    1615 
    1716import schedframe.exceptions.ResourceException; 
     
    175174                return resourceUnit; 
    176175        } 
    177         /*public List<AbstractResourceUnit> getAvailableResourceUnits(String resourceName) throws Exception { 
    178                 ComputingResource resource = getResourceByName(resourceName); 
    179                 List<AbstractResourceUnit> resourceUnits = new ArrayList<AbstractResourceUnit>(); 
    180                 while(resource != null){ 
    181                         for(List<AbstractResourceUnit> resUnits: resource.getResourceCharacteristic().getResourceUnits().values()) 
    182                                 resUnits.addAll(resourceUnits); 
    183                         resource = resource.getParent(); 
    184                 } 
    185                  
    186                 return resourceUnits; 
    187         }*/ 
    188176 
    189177        public List<? extends ComputingResource> filterResources(Properties properties) { 
     
    242230                                computingResources = (List<ComputingResource>) getResourcesOfType(StandardResourceType.Core); 
    243231                        } catch (ResourceException e) { 
    244                                 throw new RuntimeException("GSSIM internal error"); 
     232                                throw new RuntimeException("DCWorms internal error"); 
    245233                        } 
    246234                        PEUnit peUnit = new ProcessingElements(computingResources); 
     
    253241                                computingResources = (List<ComputingResource>) getResourcesOfType(StandardResourceType.Processor); 
    254242                        } catch (ResourceException e) { 
    255                                 throw new RuntimeException("GSSIM internal error"); 
     243                                throw new RuntimeException("DCWorms internal error"); 
    256244                        } 
    257245                        PEUnit peUnit = new ProcessingElements(computingResources); 
     
    318306                        return false; 
    319307                } 
    320                 /*ResourceUnit peUnit = resources.get(StandardResourceUnitName.PE); 
    321  
    322                 if (peUnit != null) { 
    323                         if (peUnit instanceof ProcessingElements) { 
    324                                 ProcessingElements choosenProcessors = (ProcessingElements) peUnit; 
    325  
    326                                 for (int i = 0; i < choosenProcessors.size(); i++) { 
    327                                         choosenProcessors.get(i).setStatus(ResourceStatus.BUSY); 
    328                                 } 
    329                         } 
    330                 }*/ 
    331  
    332                 /*Memory m = (Memory) resources.get(StandardResourceUnitName.MEMORY); 
    333                 if (m != null) { 
    334                         m.getProvisioner().setState(ResourceUnitState.BUSY); 
    335                 }*/ 
    336308                 
    337309                for(ResourceUnitName resUnitName: resources.keySet()){ 
     
    345317        public void freeResources(Map<ResourceUnitName, ResourceUnit> resources) { 
    346318                 
    347                 /*ResourceUnit peUnit = resources.get(StandardResourceUnitName.PE); 
    348                  
    349                 if (peUnit instanceof ProcessingElements) { 
    350                         ProcessingElements processingElements = (ProcessingElements) peUnit; 
    351  
    352                         for (int i = 0; i < processingElements.size(); i++) { 
    353                                 processingElements.get(i).setStatus(ResourceStatus.FREE); 
    354                         } 
    355                 }*/ 
    356  
    357                 /*Memory m = (Memory) resources.get(StandardResourceUnitName.MEMORY); 
    358                 if (m != null) { 
    359                         m.getProvisioner().setState(ResourceUnitState.FREE); 
    360                 }*/ 
    361                  
    362319                for(ResourceUnitName resUnitName: resources.keySet()){ 
    363320                        ResourceUnit resUnit = resources.get(resUnitName); 
     
    366323        } 
    367324 
    368  
    369325} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/tasks/AbstractJobRegistry.java

    r477 r539  
    22 
    33 
    4 import java.util.Map; 
    54import java.util.concurrent.ConcurrentHashMap; 
    65 
     
    1413 
    1514 
    16 public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job> */implements JobRegistry, Cloneable{ 
     15public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job>*/ implements JobRegistry, Cloneable{ 
    1716         
    1817        private static final long serialVersionUID = 8409060063583755824L; 
     18 
    1919         
    20         private static Log log = LogFactory.getLog(AbstractJobRegistry.class); 
    21          
    22         protected static final ConcurrentHashMap<String, Job> jobs = new ConcurrentHashMap<String, Job>(); 
     20        protected static final ConcurrentHashMap<String, JobInterface<?>> jobs = new ConcurrentHashMap<String, JobInterface<?>>(); 
    2321         
    2422        protected AbstractJobRegistry(){ 
    25                 //log.warn("Methods from JobRegistry interface are not implemented."); 
    2623        } 
    2724         
    2825        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                 } 
     26                jobs.put(job.getId(),  job); 
    3527                return true; 
    3628        } 
     
    3830        public boolean addTask(TaskInterface<?> task) { 
    3931                if(jobs.containsKey(task.getJobId())){ 
    40                         jobs.get(task.getJobId()).add((Task)task); 
     32                        getJob(task.getJobId()).add((Task)task); 
    4133                        return true; 
    4234                } else { 
     
    4537        } 
    4638 
    47         public Job get(String jobId){ 
     39        public JobInterface<?> getJobInfo(String jobId) { 
    4840                return jobs.get(jobId); 
    4941        } 
    50          
    51         public JobInterface<?> getJobInfo(String jobID) { 
    52                 return jobs.get(jobID); 
    53         } 
    5442 
    55         public TaskInterface<?> getTaskInfo(String jobID, String taskId) { 
     43        public TaskInterface<?> getTaskInfo(String jobId, String taskId) { 
    5644                Task task = null; 
    57                 Job job = jobs.get(jobID); 
     45                Job job = getJob(jobId); 
    5846                 
    5947                if(job == null) 
     
    6351                        task = job.getTask(taskId); 
    6452                } catch (NoSuchFieldException e) { 
    65                         log.error(e.getMessage()); 
    6653                } 
    6754                return task; 
    6855        } 
    6956         
    70         /*public List<JobInterface<?>> getActiveJobs() { 
    71                 log.error("getActiveJobs() not implemented."); 
    72                 return null; 
     57        public Job getJob(String jobId){ 
     58                return (Job)jobs.get(jobId); 
    7359        } 
    7460 
    75         public List<TaskInterface<?>> getActiveTasks() { 
    76                 log.error("getActiveTasks() not implemented."); 
    77                 return null; 
    78         }*/ 
    79  
    80  
    81          
    82  
    8361} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/tasks/JobRegistry.java

    r477 r539  
    11package schedframe.scheduling.manager.tasks; 
    22 
    3 import gssim.schedframe.scheduling.ExecTask; 
    43 
    54import java.util.List; 
    65 
     6import dcworms.schedframe.scheduling.ExecTask; 
     7 
     8import schedframe.ExecutablesList; 
    79import schedframe.scheduling.tasks.JobInterface; 
    810import schedframe.scheduling.tasks.TaskInterface; 
     
    1113public interface JobRegistry { 
    1214 
    13         //public List<JobInterface<?>> getActiveJobs(); 
    14  
    15         //public List<TaskInterface<?>> getActiveTasks(); 
    16          
    1715        public JobInterface<?> getJobInfo(String jobId); 
    1816 
     
    3129 
    3230 
    33         //public List<SubmittedTask> getSubmittedTasks(); 
     31        public ExecutablesList getExecutableTasks();  
    3432         
    35         public ExecTask getSubmittedTask(String jobId, String taskId); 
     33        public ExecTask getExecutable(String jobId, String taskId); 
    3634 
    3735         
    38         public List<? extends TaskInterface<?>> getReadyTasks(List<JobInterface<?>> jobsList); 
     36        public List<? extends TaskInterface<?>> getAvailableTasks(List<JobInterface<?>> jobsList); 
    3937 
    4038} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/tasks/JobRegistryImpl.java

    r477 r539  
    11package schedframe.scheduling.manager.tasks; 
    22 
    3 import gridsim.Gridlet; 
    4 import gssim.schedframe.scheduling.ExecTask; 
    5 import gssim.schedframe.scheduling.Executable; 
     3import gridsim.dcworms.DCWormsTags; 
    64 
    75import java.util.ArrayList; 
    8 import java.util.Collections; 
    9 import java.util.HashMap; 
    106import java.util.List; 
    11 import java.util.Map; 
    127 
    138import org.apache.commons.lang.ArrayUtils; 
    149import org.apache.commons.logging.Log; 
    1510import org.apache.commons.logging.LogFactory; 
    16 import org.joda.time.DateTime; 
    1711import org.qcg.broker.schemas.resreqs.ParentType; 
    1812import org.qcg.broker.schemas.resreqs.types.TaskStatesName; 
    1913 
     14import dcworms.schedframe.scheduling.ExecTask; 
     15 
    2016import qcg.shared.constants.BrokerConstants; 
    21 import schedframe.resources.units.ResourceUnit; 
    22 import schedframe.resources.units.ResourceUnitName; 
    23 import schedframe.scheduling.ResourceHistoryItem; 
    24 import schedframe.scheduling.plan.AllocationInterface; 
    25 import schedframe.scheduling.tasks.AbstractProcesses; 
     17import schedframe.ExecutablesList; 
    2618import schedframe.scheduling.tasks.JobInterface; 
    27 import schedframe.scheduling.tasks.SubmittedTask; 
    2819import schedframe.scheduling.tasks.Task; 
    29 import simulator.WormsConstants; 
    3020 
    3121public class JobRegistryImpl extends AbstractJobRegistry { 
     
    3727        private String context; 
    3828 
    39         //TO DO - change data structure 
    40         protected static final List<ExecTask> submittedTasks = Collections.synchronizedList(new ArrayList<ExecTask>());; 
    41         //protected static final List<ExecTaskInterface> submittedTasks = new CopyOnWriteArrayList<ExecTaskInterface>(); 
     29        //TO DO - consider data structure 
     30        protected static final ExecutablesList executables = new ExecutablesList(); 
     31        //protected static final List<ExecTask> executables = Collections.synchronizedList(new ArrayList<ExecTask>());; 
     32        //protected static final List<ExecTaskInterface> executables = new CopyOnWriteArrayList<ExecTaskInterface>(); 
    4233 
    43         public JobRegistryImpl(String context_) { 
    44                 context = context_; 
     34        public JobRegistryImpl(String context) { 
     35                this.context = context; 
    4536        } 
    4637 
    47         /*protected void setContext(String context_) { 
    48                 context = context_; 
    49         }*/ 
    50  
    51         public boolean addTask(ExecTask newTask) { 
    52                 if(getSubmittedTask(newTask.getJobId(), newTask.getId()) == null) 
    53                 { 
    54                         synchronized (submittedTasks)  { 
    55                                 submittedTasks.add(newTask); 
     38        public boolean addExecTask(ExecTask newTask) { 
     39                if(getExecutable(newTask.getJobId(), newTask.getId()) == null) { 
     40                        synchronized (executables)  { 
     41                                executables.add(newTask); 
    5642                        } 
    5743                        return true; 
     
    6046        } 
    6147 
     48        public ExecutablesList getExecutableTasks() { 
     49                return executables; 
     50        } 
    6251        public List<ExecTask> getTasks(int status) { 
    6352                List<ExecTask> taskList = new ArrayList<ExecTask>(); 
    64                 synchronized (submittedTasks)  { 
    65                         for (ExecTask task: submittedTasks) { 
     53                synchronized (executables)  { 
     54                        for (ExecTask task: executables) { 
    6655                                if (task.getStatus() == status) { 
    67                                         //SubmittedTask subTask = (SubmittedTask) task; 
    6856                                        List<String> visitedResource = task.getVisitedResources(); 
    69                                         if(ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), context)){ 
     57                                        if(ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), context)) { 
    7058                                                taskList.add(task); 
    7159                                        } 
    72                                         /*if(subTask.getVisitedResources().contains(context)){ 
    73                                                 taskList.add(subTask); 
    74                                         }*/ 
    7560                                } 
    7661                        } 
     
    8065 
    8166        public List<ExecTask> getQueuedTasks() { 
    82                 return getTasks(Gridlet.QUEUED); 
     67                return getTasks(DCWormsTags.QUEUED); 
    8368        } 
    8469         
    8570        public List<ExecTask> getRunningTasks() { 
    86                 return getTasks(Gridlet.INEXEC); 
     71                return getTasks(DCWormsTags.INEXEC); 
    8772        } 
    8873         
    8974        public List<ExecTask> getReadyTasks() { 
    90                 return getTasks(Gridlet.READY); 
     75                return getTasks(DCWormsTags.READY); 
    9176        } 
    9277         
    9378        public List<ExecTask> getFinishedTasks() { 
    94                 return getTasks(Gridlet.SUCCESS); 
     79                return getTasks(DCWormsTags.SUCCESS); 
    9580        } 
    9681         
    97          
    98         public List<ExecTask> getAllSubmittedTasks() { 
    99                 List<ExecTask> taskList; 
    100                 synchronized (submittedTasks)  { 
    101                         taskList = new ArrayList<ExecTask>(submittedTasks); 
    102                 } 
    103                 return taskList; 
    104         } 
    105  
    106         public List<SubmittedTask> getSubmittedTasks() { 
    107                 List<SubmittedTask> taskList = new ArrayList<SubmittedTask>(); 
    108                 synchronized (submittedTasks)  { 
    109                         for (ExecTask task : submittedTasks) { 
    110                                 SubmittedTask subTask = (SubmittedTask) task; 
    111                                 List<String> visitedResource = subTask.getVisitedResources(); 
    112                                 if(ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), context)){ 
    113                                         taskList.add(subTask); 
    114                                 } 
    115                                 /*if(subTask.getVisitedResources().contains(context)){ 
    116                                         taskList.add(subTask); 
    117                                 }*/ 
    118                         } 
    119                 } 
    120                 return taskList; 
    121         } 
    122          
    123         public ExecTask getSubmittedTask(String jobId, String taskId){ 
    124                 synchronized (submittedTasks)  { 
    125                         for (ExecTask task : submittedTasks) { 
    126                                 if (task.getJobId().compareTo(jobId) == 0 && task.getId().compareTo(taskId)==0) { 
     82        public ExecTask getExecutable(String jobId, String taskId){ 
     83                synchronized (executables)  { 
     84                        for (ExecTask task : executables) { 
     85                                if (task.getJobId().compareTo(jobId) == 0 && task.getId().compareTo(taskId) == 0) { 
    12786                                        return task; 
    12887                                } 
     
    13190                return null; 
    13291        } 
    133          
    13492 
    13593        @SuppressWarnings("unchecked") 
    136         public List<Task> getReadyTasks(List<JobInterface<?>> wuList) { 
    137                 List<Task> readyTasks = new ArrayList<Task>(); 
     94        public List<Task> getAvailableTasks(List<JobInterface<?>> wuList) { 
     95                List<Task> availableTasks = new ArrayList<Task>(); 
    13896                List<Task> waitingTasks = new ArrayList<Task>(); 
    13997                 
     
    143101                } 
    144102 
    145                 readyTasks.addAll(getPrecedenceConstrainedReadyTasks(waitingTasks)); 
    146                 return readyTasks; 
    147         } 
    148          
    149         public Executable getTaskExecutable(Integer executableId){ 
    150                 synchronized (submittedTasks)  { 
    151                         for (ExecTask task : submittedTasks) { 
    152                                 SubmittedTask subTask = (SubmittedTask) task; 
    153                                 Executable exec = (Executable)subTask.getGridlet(); 
    154                                 if (exec.getGridletID() == executableId) { 
    155                                         return exec; 
    156                                 } 
    157                         } 
    158                 } 
    159                 return null; 
    160         } 
    161          
    162         public List<Executable> getJobExecutables(String jobId){ 
    163                 List<Executable> list = new ArrayList<Executable>(); 
    164                 synchronized (submittedTasks)  { 
    165                         for(int i = 0; i < submittedTasks.size(); i++){ 
    166                                 SubmittedTask subTask = (SubmittedTask) submittedTasks.get(i); 
    167                                 Executable exec = (Executable)subTask.getGridlet(); 
    168                                  
    169                                 if(exec.getJobId().equals(jobId)) 
    170                                         list.add(exec); 
    171                         } 
    172                 } 
    173                 return list; 
    174         } 
    175          
    176         public JobRegistryImpl clone() { 
    177                 JobRegistryImpl jr = null; 
    178                 try { 
    179                         jr = (JobRegistryImpl) super.clone(); 
    180                 } catch (CloneNotSupportedException e) { 
    181                         // TODO Auto-generated catch block 
    182                         e.printStackTrace(); 
    183                 } 
    184  
    185                 return jr; 
    186         } 
    187  
    188         /*public AbstractExecutable getTaskExecutabls(String jobId, String taskId){ 
    189                 List<AbstractExecutable> list = new ArrayList<AbstractExecutable>(); 
    190                 synchronized (submittedTasks)  { 
    191                         for(int i = 0; i < size(); i++){ 
    192                                 SubmittedTask subTask = (SubmittedTask) submittedTasks.get(i); 
    193                                 AbstractExecutable exec = (AbstractExecutable)subTask.getGridlet(); 
    194                                  
    195                                 if(exec.getJobId().equals(jobId) && exec.getId().equals(taskId)) 
    196                                         return exec; 
    197                         } 
    198                 } 
    199                 return null; 
    200         }*/ 
    201          
    202          
    203         public Executable createExecutable(Task task, AllocationInterface allocation) { 
    204  
    205                 String refersTo = allocation.getProcessGroupId(); // null;//allocation.getRefersTo(); 
    206                 if(refersTo == null) 
    207                         refersTo = task.getId(); 
    208                          
    209                 Executable exec = null; 
    210  
    211                 if(refersTo.equals(task.getId())){ 
    212                         exec = new Executable(task); 
    213                 } else { 
    214                         List<AbstractProcesses> processes = task.getProcesses(); 
    215                         if(processes == null) { 
    216                                 try { 
    217                                         log.error("Allocation: " + allocation.getDocument() + "\nrefers to unknown task or processes set." + 
    218                                                         " Set correct value (task id or prcesses set id) for allocation refersTo attribute."); 
    219                                 } catch (Exception e) { 
    220                                         e.printStackTrace(); 
    221                                 } 
    222                         } 
    223                         boolean found = false; 
    224                         for(int j = 0; j < processes.size() && !found; j++){ 
    225                                 AbstractProcesses procesesSet = processes.get(j); 
    226                                 if(refersTo.equals(procesesSet.getId())){ 
    227                                         exec = new Executable(task, procesesSet); 
    228                                         found = true; 
    229                                 } 
    230                         } 
    231                         if(!found){ 
    232                                 log.error("Allocation refers to unknown proceses set."); 
    233                         } 
    234                 } 
    235                  
    236         //      exec.setUserID(task.getSenderId()); 
    237                 exec.setLength(task.getLength()); 
    238                 exec.setReservationId(allocation.getReservationId()); 
    239                          
    240                 /*HostInterface<?> host = allocation.getHost(); 
    241                 ComputingResourceTypeInterface<?> crt = host.getMachineParameters(); 
    242                 if(crt != null){ 
    243                         ComputingResourceTypeItemInterface<?> crti = crt.getComputingResourceTypeItem(0); 
    244                         if(crti != null){ 
    245                                 ParameterPropertyInterface<?> properties[] = crti.getHostParameter().getProperty(); 
    246                                 for(int p = 0; p < properties.length; p++){ 
    247                                         ParameterPropertyInterface<?> property = properties[p]; 
    248                                         if("chosenCPUs".equals(property.getName())){ 
    249                                                 Object cpuNames = property.getValue(); 
    250                                                 exec.addSpecificResource(ResourceParameterName.FREECPUS, cpuNames); 
    251                                         } 
    252                                 } 
    253                         } 
    254                 }*/ 
    255                 return exec; 
    256         } 
    257          
    258  
    259         public List<Executable> createExecutables(Task task) { 
    260  
    261                 List<AbstractProcesses> processes = task.getProcesses(); 
    262                  
    263                 List<Executable> executables = new ArrayList<Executable>(); 
    264  
    265                 if(processes == null || processes.size()==0){ 
    266                         Executable exec = new Executable(task); 
    267                         exec.setUserID(task.getSenderId()); 
    268                         exec.setLength(task.getLength()); 
    269                         executables.add(exec); 
    270                 } else { 
    271  
    272                         boolean found = false; 
    273                         for(int j = 0; j < processes.size() && !found; j++){ 
    274                                 AbstractProcesses procesesSet = processes.get(j); 
    275                                 Executable exec = new Executable(task, procesesSet); 
    276                                 exec.setUserID(task.getSenderId()); 
    277                                 exec.setLength(task.getLength()); 
    278                                 executables.add(exec); 
    279                         } 
    280                 } 
    281  
    282                 return  executables; 
     103                availableTasks.addAll(getPrecedenceConstrainedAvailableTasks(waitingTasks)); 
     104                return availableTasks; 
    283105        } 
    284106 
    285107 
    286         /**************************************/ 
    287         protected static Map<Integer, Map<String, Object>> history = new HashMap<Integer, Map<String,Object>>(); 
    288          
    289         public static Map<Integer, Map<String, Object>> getAllocationHistory(){ 
    290                 return history; 
    291         } 
    292          
    293         public void saveHistory (SubmittedTask submittedTask, int estimatedTime, Map<ResourceUnitName, ResourceUnit> choosenResources){ 
     108        private List<Task> getPrecedenceConstrainedAvailableTasks(List<Task> tasks){ 
    294109                 
    295                 /*submittedTask.setEstimatedDuration(estimatedTime); 
    296  
    297                 DateTime currentTime = new DateTime(); 
    298                 ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 
    299                 submittedTask.addUsedResources(resHistItem);*/ 
    300  
    301                 ResourceHistoryItem resHistItem = submittedTask.getUsedResources().getLast(); 
    302                 DateTime currentTime = new DateTime(); 
    303                 Map<String, Object> historyItem = new HashMap<String, Object>(); 
    304                 List<ResourceHistoryItem> list = new ArrayList<ResourceHistoryItem>(1); 
    305                 list.add(resHistItem); 
    306                 historyItem.put(WormsConstants.RESOURCES, list); 
    307                 historyItem.put(WormsConstants.START_TIME, currentTime); 
    308                 currentTime = currentTime.plusSeconds(estimatedTime); 
    309                 historyItem.put(WormsConstants.END_TIME, currentTime); 
    310  
    311                 history.put(Integer.valueOf(submittedTask.getGridletID()), historyItem); 
    312                 /*ProcessingElements pes = (ProcessingElements) choosenResources.get(ResourceParameterName.PROCESSINGELEMENTS); 
    313                 for (ComputingResource resource : pes) { 
    314                         //submittedTask.addToResPath(resource.getName()); 
    315                         submittedTask.visitResource(resource.getName()); 
    316                         ComputingResource parent = resource.getParent(); 
    317                         while (parent != null && !submittedTask.getResPath().contains(parent.getName() + "_")) { 
    318                                 submittedTask.addToResPath(parent.getName()); 
    319                                 parent = parent.getParent(); 
    320                         } 
    321                         while (parent != null && !submittedTask.getVisitedResources().contains(parent.getName() + "_")) { 
    322                                 submittedTask.visitResource(parent.getName()); 
    323                                 parent = parent.getParent(); 
    324                         } 
    325                 }*/ 
    326         } 
    327  
    328         private List<Task> getPrecedenceConstrainedReadyTasks(List<Task> tasks){ 
     110                List<Task> availableTasks = new ArrayList<Task>(); 
     111                int size = tasks.size(); 
    329112                 
    330                 List<Task> readyTasks = new ArrayList<Task>(); 
    331  
    332                 int size = tasks.size(); 
    333113                for(int i = 0; i < size; i++){ 
    334114                        int parCnt; 
    335                         int previousTaskReadyCnt = 0; 
     115                        int previousTaskSucceedCnt = 0; 
    336116                        Task task = tasks.get(i); 
    337117                        if(task.getStatus() != (int)BrokerConstants.TASK_STATUS_UNSUBMITTED) 
     
    341121                        } catch(Exception e){ 
    342122                                parCnt = 0; 
    343                                 //e.printStackTrace(); 
    344123                        } 
    345                         if(parCnt == 0) 
    346                         { 
    347                                 readyTasks.add(task); 
     124                        if(parCnt == 0){ 
     125                                availableTasks.add(task); 
    348126                        } 
    349                         else 
    350                         { 
     127                        else { 
    351128                                for(int j = 0; j < parCnt; j++){ 
    352129                                        ParentType par = task.getDescription().getWorkflow().getParent(j); 
     
    356133                                                } 
    357134                                        } 
    358                                         previousTaskReadyCnt++; 
     135                                        previousTaskSucceedCnt++; 
    359136                                } 
    360137                                 
    361                                 if(previousTaskReadyCnt == parCnt && task.getDescription().getWorkflow().getAnd() != null) 
    362                                         readyTasks.add(task); 
    363                                 else if(previousTaskReadyCnt > 0 && task.getDescription().getWorkflow().getOr() != null) 
    364                                         readyTasks.add(task); 
    365                                 else if (previousTaskReadyCnt == parCnt) 
    366                                         readyTasks.add(task); 
     138                                if(previousTaskSucceedCnt == parCnt && task.getDescription().getWorkflow().getAnd() != null) 
     139                                        availableTasks.add(task); 
     140                                else if(previousTaskSucceedCnt > 0 && task.getDescription().getWorkflow().getOr() != null) 
     141                                        availableTasks.add(task); 
     142                                else if (previousTaskSucceedCnt == parCnt) 
     143                                        availableTasks.add(task); 
    367144                        } 
    368145                }                
    369                 return readyTasks; 
     146                return availableTasks; 
    370147        } 
    371148         
     
    380157                return false; 
    381158        } 
     159 
    382160} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/ScheduledTaskInterface.java

    r477 r539  
    44 
    55import schedframe.DescriptionContainer; 
    6 import schedframe.scheduling.tasks.WorkloadUnit; 
     6import schedframe.scheduling.tasks.TaskInterface; 
    77 
    88public interface ScheduledTaskInterface<T> extends DescriptionContainer<T> { 
     
    190190         
    191191 
    192         public ArrayList<AllocationInterface> getAllocations(); 
     192        public ArrayList<AllocationInterface<?>> getAllocations(); 
    193193         
    194         public WorkloadUnit<?> getTask(); 
     194        public TaskInterface<?> getTask(); 
    195195 
    196196} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/SchedulingPlanInterface.java

    r477 r539  
    9999 
    100100 
    101         public ArrayList<ScheduledTaskInterface> getTasks(); 
     101        public ArrayList<ScheduledTaskInterface<?>> getTasks(); 
    102102} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/impl/ScheduledTask.java

    r477 r539  
    66import org.exolab.castor.xml.MarshalException; 
    77import org.exolab.castor.xml.ValidationException; 
     8import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; 
    89 
    910import schedframe.scheduling.plan.AllocationInterface; 
    1011import schedframe.scheduling.plan.ScheduledTaskInterface; 
    1112import schedframe.scheduling.plan.ScheduledTimeInterface; 
    12 import schedframe.scheduling.tasks.WorkloadUnit; 
    13  
    14  
    15 import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; 
     13import schedframe.scheduling.tasks.TaskInterface; 
    1614 
    1715public class ScheduledTask implements ScheduledTaskInterface<org.qcg.broker.schemas.schedulingplan.Task> { 
     
    2220        public ScheduledTask(){ 
    2321                t = new org.qcg.broker.schemas.schedulingplan.Task(); 
    24                 allocationList = new ArrayList<AllocationInterface>(); 
     22                allocationList = new ArrayList<AllocationInterface<?>>(); 
    2523        } 
    2624         
    2725        public ScheduledTask(org.qcg.broker.schemas.schedulingplan.Task value){ 
    2826                t = value; 
    29                 allocationList = new ArrayList<AllocationInterface>(); 
     27                allocationList = new ArrayList<AllocationInterface<?>>(); 
    3028        } 
    3129         
     
    178176         
    179177 
    180         protected WorkloadUnit<?> task; 
    181         protected ArrayList<AllocationInterface> allocationList; 
     178        protected TaskInterface<?> task; 
     179        protected ArrayList<AllocationInterface<?>> allocationList; 
    182180 
    183         public ScheduledTask(WorkloadUnit<?> task){ 
     181        public ScheduledTask(TaskInterface<?> task){ 
    184182                this(); 
    185183                this.task = task; 
    186184        } 
    187185 
    188         public ArrayList<AllocationInterface> getAllocations() { 
     186        public ArrayList<AllocationInterface<?>> getAllocations() { 
    189187                return this.allocationList; 
    190188        } 
    191189         
    192         public WorkloadUnit<?> getTask(){ 
     190        public TaskInterface<?> getTask(){ 
    193191                return this.task; 
    194192        } 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/impl/SchedulingPlan.java

    r477 r539  
    1818        public SchedulingPlan(){ 
    1919                sp = new org.qcg.broker.schemas.schedulingplan.SchedulingPlan(); 
    20                 taskList = new ArrayList<ScheduledTaskInterface>(); 
     20                taskList = new ArrayList<ScheduledTaskInterface<?>>(); 
    2121        } 
    2222         
    2323        public SchedulingPlan(org.qcg.broker.schemas.schedulingplan.SchedulingPlan value){ 
    2424                sp = value; 
    25                 taskList = new ArrayList<ScheduledTaskInterface>(); 
     25                taskList = new ArrayList<ScheduledTaskInterface<?>>(); 
    2626        } 
    2727         
     
    106106 
    107107         
    108         protected ArrayList<ScheduledTaskInterface> taskList; 
     108        protected ArrayList<ScheduledTaskInterface<?>> taskList; 
    109109 
    110         public ArrayList<ScheduledTaskInterface> getTasks() { 
     110        public ArrayList<ScheduledTaskInterface<?>> getTasks() { 
    111111 
    112112                return this.taskList; 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plugin/SchedulingPlugin.java

    r477 r539  
    33import schedframe.Plugin; 
    44import schedframe.events.scheduling.SchedulingEvent; 
    5 import schedframe.scheduling.WorkloadUnitListImpl; 
     5import schedframe.scheduling.TaskList; 
     6import schedframe.scheduling.TaskListImpl; 
    67import schedframe.scheduling.manager.resources.ResourceManager; 
    78import schedframe.scheduling.manager.tasks.JobRegistry; 
     
    1213public interface SchedulingPlugin extends Plugin{ 
    1314 
    14         public int placeJobsInQueues(WorkloadUnitListImpl newJobs, 
     15        public int placeTasksInQueues(TaskList newTasks, 
    1516                        TaskQueueList queues,  
    1617                        ResourceManager resourceManager, ModuleList modules); 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plugin/estimation/ExecutionTimeEstimationPlugin.java

    r477 r539  
    11package schedframe.scheduling.plugin.estimation; 
    22 
    3 import gssim.schedframe.scheduling.ExecTask; 
    43 
    5 import java.util.List; 
    64import java.util.Map; 
     5 
     6import dcworms.schedframe.scheduling.ExecTask; 
    77 
    88import schedframe.Plugin; 
     
    3232         * @return estimated execution time of a task of specified length 
    3333         */ 
    34         public double execTimeEstimation(SchedulingEvent event, Map<ResourceUnitName, ResourceUnit> allocatedResources,  
    35                                                                         ExecTask task,  
     34        public double execTimeEstimation(SchedulingEvent event, ExecTask task, Map<ResourceUnitName, ResourceUnit> allocatedResources,  
    3635                                                                        double completionPercentage); 
    3736         
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/AbstractManagementSystem.java

    r477 r539  
    88import org.joda.time.DateTimeUtilsExt; 
    99 
     10import dcworms.schedframe.scheduling.ExecTask; 
     11import dcworms.schedframe.scheduling.Executable; 
     12import dcworms.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
     13 
    1014import schedframe.PluginConfiguration; 
    1115import schedframe.events.scheduling.SchedulingEventType; 
    12 import schedframe.resources.units.StandardResourceUnitName; 
    1316import schedframe.scheduling.Scheduler; 
    1417import schedframe.scheduling.WorkloadUnitHandler; 
     
    1619import schedframe.scheduling.manager.resources.ResourceManager; 
    1720import schedframe.scheduling.manager.resources.ResourceManagerFactory; 
     21import schedframe.scheduling.manager.tasks.JobRegistry; 
    1822import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    19 import schedframe.scheduling.manager.tasks.JobRegistry; 
    2023import schedframe.scheduling.plan.AllocationInterface; 
    2124import schedframe.scheduling.plan.SchedulingPlanInterface; 
     
    2730import schedframe.scheduling.queue.TaskQueueList; 
    2831import schedframe.scheduling.tasks.Job; 
     32import schedframe.scheduling.tasks.TaskInterface; 
    2933import schedframe.scheduling.tasks.WorkloadUnit; 
    30 import simulator.WormsConstants; 
     34import simulator.DCWormsConstants; 
    3135import eduni.simjava.Sim_event; 
    3236import gridsim.GridSim; 
    3337import gridsim.GridSimTags; 
    34 import gridsim.Gridlet; 
    3538import gridsim.IO_data; 
    36 import gridsim.gssim.WormsTags; 
    37 import gssim.schedframe.scheduling.ExecTask; 
    38 import gssim.schedframe.scheduling.Executable; 
    39 import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
     39import gridsim.dcworms.DCWormsTags; 
    4040 
    4141public abstract class AbstractManagementSystem { 
     
    4545        protected String name; 
    4646 
     47        protected TaskQueueList queues; 
    4748        protected ResourceManager resourceManager; 
    48  
    49         protected TaskQueueList queues; 
    50  
     49        protected JobRegistryImpl jobRegistry; 
     50        protected ModuleList moduleList; 
     51         
    5152        protected SchedulingPlugin schedulingPlugin; 
    52  
    5353        protected ExecutionTimeEstimationPlugin execTimeEstimationPlugin; 
    5454 
    55         protected ModuleList moduleList; 
    56          
    57         protected JobRegistryImpl jobRegistry; 
     55        protected Scheduler scheduler; 
    5856         
    5957 
     
    6765        } 
    6866         
     67        public void init(Scheduler sched, ManagedResources managedResources) { 
     68                scheduler = sched; 
     69                resourceManager = ResourceManagerFactory.createResourceManager(scheduler, managedResources); 
     70                scheduler.set_stat(DCWormsConstants.getResourcesStatisticsObject(queues.size())); 
     71                for(int i = 0; i < queues.size(); i++){ 
     72                        TaskQueue q = queues.get(i); 
     73                        if(q instanceof AbstractStatsSupportingQueue<?>){ 
     74                                AbstractStatsSupportingQueue<?> queue = (AbstractStatsSupportingQueue<?>) q; 
     75                                queue.setStats(scheduler.get_stat(), DCWormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME + "_" + Integer.toString(i)); 
     76                        } 
     77                } 
     78        } 
     79         
    6980        public void processEvent(Sim_event ev) { 
    7081                processOtherEvent(ev); 
     
    8192        } 
    8293         
     94         
    8395        public String getName() { 
    8496                return name; 
    85         } 
    86  
    87         public PluginConfiguration getSchedulingPluginConfiguration() { 
    88                 return schedulingPlugin.getConfiguration(); 
    8997        } 
    9098         
     
    106114                return jobRegistry; 
    107115        } 
     116         
     117        public Scheduler getScheduler() { 
     118                return scheduler; 
     119        } 
     120         
     121        public PluginConfiguration getSchedulingPluginConfiguration() { 
     122                return schedulingPlugin.getConfiguration(); 
     123        } 
    108124 
    109125        public boolean pluginSupportsEvent(int eventType){ 
     
    111127        } 
    112128 
    113         public abstract void notifySubmittedWorkloadUnit(WorkloadUnit<?> wu, boolean ack); 
    114  
    115         public abstract void notifyCanceledWorkloadUnit(WorkloadUnit<?> wu); 
    116  
    117         public abstract void notifyReturnedWorkloadUnit(WorkloadUnit<?> wu); 
    118  
    119         protected abstract void executeSchedulingPlan(SchedulingPlanInterface decision); 
    120  
    121  
    122  
     129        public TaskQueueList getQueues(){ 
     130                return queues; 
     131        } 
     132         
     133        public Map<String, Integer> getQueuesSize() { 
     134                Map<String, Integer> queue_size = new HashMap<String, Integer>(); 
     135                for (TaskQueue queue : queues) { 
     136                        queue_size.put(queue.getName(), queue.size()); 
     137                } 
     138                return queue_size; 
     139        } 
     140         
    123141        //POPRAWIC  (ale co? bo teraz chyba jest ok) 
    124         protected void submitWorkloadUnit(WorkloadUnit<?> wu, AllocationInterface allocation) { 
     142        protected void submitTask(TaskInterface<?> task, AllocationInterface<?> allocation) { 
    125143                String providerName = allocation.getProviderName(); 
    126144                if (providerName == null) { 
    127145                        return; 
    128146                } 
    129                 //Executable exec = (Executable) wu; 
    130                 removeFromQueue(wu); 
    131                 scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, wu);  
    132         } 
    133          
    134         protected boolean sendCanceledWorkloadUnit(int tag, Executable task, int executableId, int destId) { 
    135                  
    136                 if (tag != GridSimTags.GRIDLET_CANCEL) { 
    137                         return false; 
    138                 } 
    139  
    140                 long taskSize = 0; 
    141                 if (task != null) { 
    142                         taskSize = task.getGridletOutputSize(); 
    143                 } 
    144  
    145                 // if no Gridlet found, then create a new Gridlet but set its status 
    146                 // to FAILED. Then, most importantly, set the resource parameters 
    147                 // because the user will search/filter based on a resource ID. 
    148                 else if (task == null) { 
    149                         try { 
    150                                 taskSize = 100; 
    151                                 task = jobRegistry.getTaskExecutable(executableId); 
    152                                 task.setGridletStatus(Gridlet.FAILED); 
    153                                 int cost = resourceManager.getSharedResourceUnits().get(StandardResourceUnitName.COST) != null ? resourceManager 
    154                                                 .getSharedResourceUnits().get(StandardResourceUnitName.COST).get(0).getAmount() 
    155                                                 : 1; 
    156                                 task.setResourceParameter(scheduler.get_id(), cost); 
    157                         } catch (Exception e) { 
    158                                 // empty ... 
    159                         } 
    160                 } 
    161                 scheduler.send(scheduler.getOutputPort(), GridSimTags.SCHEDULE_NOW, tag,  new IO_data(task, taskSize, destId)); 
    162  
    163                 return true; 
    164         } 
    165  
    166         protected boolean sendFinishedWorkloadUnit(WorkloadUnit<?> wu) { 
     147                removeFromQueue(task); 
     148                scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, task);        
     149        } 
     150 
     151        protected boolean sendFinishedWorkloadUnit(WorkloadUnit wu) { 
    167152                 
    168153                Executable exec = (Executable) wu; 
    169154                if(scheduler.getParent() == null) 
    170155                { 
    171                         Job job = jobRegistry.get(exec.getJobId()); 
     156                        Job job = jobRegistry.getJob(exec.getJobId()); 
    172157 
    173158                        if(job.isFinished()){ 
    174159                                scheduler.send(job.getSenderId(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_RETURN, job); 
    175160                                return true; 
    176                         }else return true; 
     161                        } 
     162                        else return true; 
    177163                } 
    178164         
     
    183169 
    184170        protected void sendExecutableReadyEvent(ExecTask exec) { 
    185  
    186                 /*if (wu instanceof JobInterface) { 
    187                         scheduler.sendInternal(Long.valueOf(0).doubleValue(), GssimTags.TASK_READY_FOR_EXECUTION, 
    188                                         wu); 
    189                         return; 
    190                 }*/ 
    191171 
    192172                long delay = 0; 
     
    201181                } 
    202182 
    203                 scheduler.sendInternal(Long.valueOf(delay).doubleValue(), WormsTags.TASK_READY_FOR_EXECUTION, 
     183                scheduler.sendInternal(Long.valueOf(delay).doubleValue(), DCWormsTags.TASK_READY_FOR_EXECUTION, 
    204184                                exec); 
    205185        } 
     
    213193                                if (obj != null) { 
    214194                                        int delay = (Integer) obj; 
    215                                         scheduler.sendInternal(delay, WormsTags.TIMER, null); 
     195                                        scheduler.sendInternal(delay, DCWormsTags.TIMER, null); 
    216196                                } 
    217197                        } 
     
    219199        } 
    220200         
    221         protected boolean removeFromQueue(WorkloadUnit<?> wu) { 
     201        protected boolean removeFromQueue(TaskInterface<?> task) { 
    222202                for(TaskQueue queue : queues){ 
    223                         if(queue.contains(wu)){ 
    224                                 queue.remove(wu); 
     203                        if(queue.contains(task)){ 
     204                                queue.remove(task); 
    225205                                return true; 
    226206                        } 
     
    228208                return false; 
    229209        } 
    230  
    231         public TaskQueueList getAccessQueues(){ 
    232                 return queues; 
    233         } 
    234          
    235         public Map<String, Integer> getQueuesSize() { 
    236                 Map<String, Integer> queue_size = new HashMap<String, Integer>(); 
    237                 for (TaskQueue queue : queues) { 
    238                         queue_size.put(queue.getName(), queue.size()); 
    239                 } 
    240                 return queue_size; 
    241         } 
    242  
    243         public void init(Scheduler sched, ManagedResources managedResources) { 
    244                 scheduler = sched; 
    245                 resourceManager = ResourceManagerFactory.createResourceManager(scheduler, managedResources); 
    246                 scheduler.set_stat(WormsConstants.getResourcesStatisticsObject(queues.size())); 
    247                 for(int i = 0; i < queues.size(); i++){ 
    248                         TaskQueue q = queues.get(i); 
    249                         if(q instanceof AbstractStatsSupportingQueue<?>){ 
    250                                 AbstractStatsSupportingQueue<?> queue = (AbstractStatsSupportingQueue<?>) q; 
    251                                 queue.setStats(scheduler.get_stat(), WormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME + "_" + Integer.toString(i)); 
    252                         } 
    253                 } 
    254         } 
    255  
    256         protected Scheduler scheduler; 
    257  
    258         public Scheduler getScheduler() { 
    259                 return scheduler; 
    260         } 
    261210         
    262211        public abstract WorkloadUnitHandler getWorkloadUnitHandler(); 
     212         
     213        public abstract void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack); 
     214 
     215        public abstract void notifyReturnedWorkloadUnit(WorkloadUnit wu); 
     216 
     217        protected abstract void executeSchedulingPlan(SchedulingPlanInterface<?> decision); 
    263218 
    264219} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/global/GlobalManagementSystem.java

    r477 r539  
    1111import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; 
    1212 
     13import dcworms.schedframe.scheduling.ExecTask; 
     14import dcworms.schedframe.scheduling.Executable; 
     15 
    1316import qcg.shared.constants.BrokerConstants; 
    14  
    15 import schedframe.events.scheduling.EventReason; 
    16 import schedframe.events.scheduling.SchedulingEvent; 
    1717import schedframe.events.scheduling.TaskArrivedEvent; 
    18 import schedframe.events.scheduling.TaskCanceledEvent; 
    1918import schedframe.events.scheduling.TimerEvent; 
    20 import schedframe.scheduling.Scheduler; 
     19import schedframe.scheduling.TaskListImpl; 
    2120import schedframe.scheduling.WorkloadUnitHandler; 
    22 import schedframe.scheduling.WorkloadUnitListImpl; 
    2321import schedframe.scheduling.plan.AllocationInterface; 
    2422import schedframe.scheduling.plan.ScheduledTaskInterface; 
     
    3129import schedframe.scheduling.tasks.Job; 
    3230import schedframe.scheduling.tasks.JobInterface; 
    33 import schedframe.scheduling.tasks.SubmittedTask; 
    3431import schedframe.scheduling.tasks.Task; 
    3532import schedframe.scheduling.tasks.TaskInterface; 
    3633import schedframe.scheduling.tasks.WorkloadUnit; 
    37  
    3834import eduni.simjava.Sim_event; 
    3935import gridsim.GridSim; 
    4036import gridsim.GridSimTags; 
    41 import gridsim.Gridlet; 
    4237import gridsim.IO_data; 
    43 import gridsim.gssim.WormsTags; 
    44 import gssim.schedframe.scheduling.ExecTask; 
    45 import gssim.schedframe.scheduling.Executable; 
     38import gridsim.dcworms.DCWormsTags; 
    4639 
    4740public class GlobalManagementSystem extends AbstractManagementSystem { 
     
    5447                super(providerId, entityName,  execTimeEstimationPlugin, queues); 
    5548 
    56                 /*schedulingPlugin = (GlobalSchedulingPlugin) InstanceFactory.createInstance( 
    57                                 schedulingPluginClassName, 
    58                                 GlobalSchedulingPlugin.class);*/ 
    5949                if(schedPlugin == null){ 
    6050                        throw new Exception("Can not create global scheduling plugin instance"); 
     
    6959                switch (tag) { 
    7060 
    71                 case WormsTags.TIMER: 
    72                         if (pluginSupportsEvent(WormsTags.TIMER)) { 
     61                case DCWormsTags.TIMER: 
     62                        if (pluginSupportsEvent(DCWormsTags.TIMER)) { 
    7363                                TimerEvent event = new  TimerEvent(); 
    74                                 SchedulingPlanInterface decision =  schedulingPlugin.schedule(event,  
     64                                SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event,  
    7565                                                queues,  getJobRegistry(), getResourceManager(), moduleList); 
    7666                                executeSchedulingPlan(decision); 
     
    8171        } 
    8272         
    83         public void notifySubmittedWorkloadUnit(WorkloadUnit<?> wu, boolean ack) { 
     73        public void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack) { 
    8474                if (!pluginSupportsEvent(GridSimTags.GRIDLET_SUBMIT)) { 
    8575                        log.error("Plugin " + schedulingPlugin.getClass() 
     
    9080                 
    9181                registerWorkloadUnit(wu); 
    92                 /*Job job = (Job) wu; 
    93                 jobRegistry.addJob(job); 
    94  
    95                 if (log.isInfoEnabled()) 
    96                         log.info("Received job " + job.getId() + " at " + new DateTime(DateTimeUtilsExt.currentTimeMillis())); 
    97  
     82 
     83        } 
     84         
     85        private void registerWorkloadUnit(WorkloadUnit wu){ 
     86                if(!wu.isRegistered()){ 
     87                        wu.register(jobRegistry); 
     88                } 
     89                wu.accept(getWorkloadUnitHandler()); 
     90        } 
     91         
     92 
     93        protected void schedule(JobInterface<?> job){ 
    9894                List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 
    9995                jobsList.add(job); 
    100                 WorkloadUnitList readyWorkloadUnits = new WorkloadUnitList(); 
    101                 readyWorkloadUnits.addAll(jobRegistry.getReadyTasks(jobsList)); 
    102                 schedulingPlugin.placeJobsInQueues(readyWorkloadUnits, queues, getResourceManager(), moduleList); 
    103  
    104                 schedule(new TaskArrivedEvent());*/ 
    105  
    106         } 
    107          
    108         private void registerWorkloadUnit(WorkloadUnit<?> wu){ 
    109                 if(!wu.isRegistered()){ 
    110                         wu.register(jobRegistry); 
    111                 } 
    112                 wu.accept(getWorkloadUnitHandler()); 
    113         } 
    114          
    115  
    116         protected void scheduleReadyTasks(Job job){ 
    117                 List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 
    118                 jobsList.add(job); 
    119                 WorkloadUnitListImpl readyWorkloadUnits = new WorkloadUnitListImpl(); 
    120                 readyWorkloadUnits.addAll(jobRegistry.getReadyTasks(jobsList)); 
    121                 schedulingPlugin.placeJobsInQueues(readyWorkloadUnits, queues, getResourceManager(), moduleList); 
    122  
    123                 schedule(new TaskArrivedEvent()); 
    124         } 
    125          
    126         protected void schedule(SchedulingEvent schedulingEvent) { 
    127  
    128                 try { 
    129                         SchedulingPlanInterface decision = schedulingPlugin.schedule( 
    130                                         schedulingEvent, queues, getJobRegistry(),  getResourceManager(), moduleList); 
    131                         if (decision == null) 
    132                                 return; 
    133  
     96                TaskListImpl readyTasks = new TaskListImpl(); 
     97                readyTasks.addAll(jobRegistry.getAvailableTasks(jobsList)); 
     98                 
     99                schedulingPlugin.placeTasksInQueues(readyTasks, queues, getResourceManager(), moduleList); 
     100                SchedulingPlanInterface<?> decision = schedulingPlugin.schedule( 
     101                                new TaskArrivedEvent(), queues, getJobRegistry(),  getResourceManager(), moduleList); 
     102                if (decision != null) 
    134103                        executeSchedulingPlan(decision); 
    135  
    136                 } catch (Exception e) { 
    137                         e.printStackTrace(); 
    138                 } 
    139         } 
    140          
    141         public void notifyReturnedWorkloadUnit(WorkloadUnit<?> wu) { 
     104        } 
     105 
     106        public void notifyReturnedWorkloadUnit(WorkloadUnit wu) { 
    142107                Executable exec = (Executable) wu; 
    143108 
     
    149114                 
    150115                try { 
    151                         Job job = jobRegistry.get(exec.getJobId()); 
    152                         /*Task task = job.getTask(exec.getTaskId()); 
     116                        Job job = jobRegistry.getJob(exec.getJobId()); 
     117                        Task task = job.getTask(exec.getTaskId()); 
    153118                        if(exec.getProcessesId() == null){ 
    154119                                try { 
    155120                                        task.setStatus(exec.getStatus()); 
    156121                                } catch (Exception e) { 
    157                                         // TODO Auto-generated catch block 
    158                                         e.printStackTrace(); 
     122 
    159123                                } 
    160124                        } else { 
     
    167131                                        } 
    168132                                } 
    169                         }*/ 
     133                        } 
    170134                         
    171135                        if(job.isFinished()){ 
     
    173137                        } 
    174138                        else { 
    175                                 scheduleReadyTasks(job); 
    176                                 /*List<JobInterface<?>> jobs = new ArrayList<JobInterface<?>>(); 
    177                                 jobs.add(jobRegistry.getJobInfo(job.getId())); 
    178                                 WorkloadUnitList readyWorkloadUnits = new WorkloadUnitList(); 
    179                                 readyWorkloadUnits.addAll(jobRegistry.getReadyTasks(jobs)); 
    180                                 schedulingPlugin.placeJobsInQueues(readyWorkloadUnits, queues, 
    181                                                 getResourceManager(), moduleList); 
    182                                 schedule(new TaskArrivedEvent());*/ 
     139                                schedule(job); 
    183140                        } 
    184141                         
     
    189146        } 
    190147 
    191         public void notifyCanceledWorkloadUnit(WorkloadUnit<?> wu){; 
    192  
    193                 Executable task = (Executable) wu; 
    194                 String jobID = task.getJobId(); 
    195                 String taskID = task.getId(); 
    196                  
    197                 if(log.isDebugEnabled()) 
    198                         log.debug("Received canceled job" + jobID + "_" + taskID); 
    199                  
    200                 TaskInterface<?> ti = jobRegistry.getTaskInfo(jobID, taskID) ; 
    201                 try { 
    202  
    203                         ti.setStatus((int)BrokerConstants.JOB_STATUS_CANCELED); 
    204                          
    205                         TaskCanceledEvent event = new TaskCanceledEvent(jobID, taskID); 
    206                         event.setReason(EventReason.RESERVATION_EXCEEDED); 
    207                         schedule(event); 
    208                          
    209                 } catch (Exception e) { 
    210                         log.error("Exception during scheduling. " + e.getMessage()); 
    211                         e.printStackTrace(); 
    212                 } 
    213         } 
    214          
    215         protected void executeSchedulingPlan(SchedulingPlanInterface decision) { 
    216  
    217                 ArrayList<ScheduledTaskInterface> taskSchedulingDecisions = decision.getTasks(); 
     148        protected void executeSchedulingPlan(SchedulingPlanInterface<?> decision) { 
     149 
     150                ArrayList<ScheduledTaskInterface<?>> taskSchedulingDecisions = decision.getTasks(); 
    218151                for (int i = 0; i < taskSchedulingDecisions.size(); i++) { 
    219152 
    220                         try { 
    221                                 ScheduledTaskInterface taskDecision = taskSchedulingDecisions.get(i); 
    222          
    223                                 //log.info(decision.getDocument()); 
    224          
    225                                 String jobID = taskDecision.getJobId(); 
    226                                 String taskID = taskDecision.getTaskId(); 
    227                                  
    228                                 // Task allocations that were rejected because of lack of resources or which were canceled and  
    229                                 // not scheduled again are returned to the user. 
    230                                 if(taskDecision.getStatus() == AllocationStatus.REJECTED){ 
    231                                         Job job = jobRegistry.get(jobID); 
    232                                         scheduler.send(job.getSenderId(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_RETURN, job); 
    233                                         continue; 
    234                                 } 
    235                                  
    236                                 ArrayList<AllocationInterface> allocations = taskDecision.getAllocations(); 
    237  
    238                                 Task task = (Task) jobRegistry.getTaskInfo(jobID, taskID); 
    239                                 for (int j = 0; j < allocations.size(); j++) { 
    240  
    241                                         AllocationInterface allocation = allocations.get(j); 
    242                                         Executable exec = jobRegistry.createExecutable(task, allocation); 
    243                                         submitWorkloadUnit(exec, allocation); 
    244                                         task.setStatus((int)BrokerConstants.TASK_STATUS_QUEUED); 
    245                                 }                                                                
    246  
    247                         }catch (Exception e){ 
    248                                 e.printStackTrace(); 
    249                         } 
    250                 } 
    251         } 
    252  
    253         protected void submitWorkloadUnit(WorkloadUnit<?> job, AllocationInterface allocation) { 
     153                        ScheduledTaskInterface<?> taskDecision = taskSchedulingDecisions.get(i); 
     154 
     155                        //log.info(decision.getDocument()); 
     156 
     157                        String jobID = taskDecision.getJobId(); 
     158                        String taskID = taskDecision.getTaskId(); 
     159                         
     160                        // Task allocations that were rejected because of lack of resources or which were canceled and  
     161                        // not scheduled again are returned to the user. 
     162                        if(taskDecision.getStatus() == AllocationStatus.REJECTED){ 
     163                                Job job = jobRegistry.getJob(jobID); 
     164                                scheduler.send(job.getSenderId(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_RETURN, job); 
     165                                continue; 
     166                        } 
     167                         
     168                        Task task = (Task) jobRegistry.getTaskInfo(jobID, taskID); 
     169                         
     170                        ArrayList<AllocationInterface<?>> allocations = taskDecision.getAllocations(); 
     171                        for (int j = 0; j < allocations.size(); j++) { 
     172 
     173                                AllocationInterface<?> allocation = allocations.get(j); 
     174                                Executable exec = createExecutable(task, allocation); 
     175                                submitTask(exec, allocation); 
     176                                task.setStatus((int)BrokerConstants.TASK_STATUS_QUEUED); 
     177                        }                                                                
     178                } 
     179        } 
     180 
     181        private Executable createExecutable(Task task, AllocationInterface<?> allocation) { 
     182 
     183                String refersTo = allocation.getProcessGroupId(); // null;//allocation.getRefersTo(); 
     184                if(refersTo == null) 
     185                        refersTo = task.getId(); 
     186                         
     187                Executable exec = null; 
     188 
     189                if(refersTo.equals(task.getId())){ 
     190                        exec = new Executable(task); 
     191                } else { 
     192                        List<AbstractProcesses> processes = task.getProcesses(); 
     193                        if(processes == null) { 
     194                                try { 
     195                                        log.error("Allocation: " + allocation.getDocument() + "\nrefers to unknown task or processes set." + 
     196                                                        " Set correct value (task id or prcesses set id) for allocation refersTo attribute."); 
     197                                } catch (Exception e) { 
     198                                        e.printStackTrace(); 
     199                                } 
     200                        } 
     201                        boolean found = false; 
     202                        for(int j = 0; j < processes.size() && !found; j++){ 
     203                                AbstractProcesses procesesSet = processes.get(j); 
     204                                if(refersTo.equals(procesesSet.getId())){ 
     205                                        exec = new Executable(task, procesesSet); 
     206                                        found = true; 
     207                                } 
     208                        } 
     209                        if(!found){ 
     210                                log.error("Allocation refers to unknown proceses set."); 
     211                        } 
     212                } 
     213 
     214                exec.setReservationId(allocation.getReservationId()); 
     215                         
     216                /*HostInterface<?> host = allocation.getHost(); 
     217                ComputingResourceTypeInterface<?> crt = host.getMachineParameters(); 
     218                if(crt != null){ 
     219                        ComputingResourceTypeItemInterface<?> crti = crt.getComputingResourceTypeItem(0); 
     220                        if(crti != null){ 
     221                                ParameterPropertyInterface<?> properties[] = crti.getHostParameter().getProperty(); 
     222                                for(int p = 0; p < properties.length; p++){ 
     223                                        ParameterPropertyInterface<?> property = properties[p]; 
     224                                        if("chosenCPUs".equals(property.getName())){ 
     225                                                Object cpuNames = property.getValue(); 
     226                                                exec.addSpecificResource(ResourceParameterName.FREECPUS, cpuNames); 
     227                                        } 
     228                                } 
     229                        } 
     230                }*/ 
     231                return exec; 
     232        } 
     233         
     234        protected void submitTask(TaskInterface<?> task, AllocationInterface<?> allocation) { 
    254235 
    255236                String providerName = allocation.getProviderName(); 
     
    257238                        return; 
    258239                } 
    259                 TaskInterface<?> task = (TaskInterface<?>) job; 
    260240                removeFromQueue(task); 
    261241                 
    262242                int resID = GridSim.getEntityId(providerName); 
    263                 IO_data data = new IO_data(job, 0, resID); 
     243                IO_data data = new IO_data(task, 0, resID); 
    264244                scheduler.send(scheduler.getOutputPort(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, data);   
    265                  
    266                 //scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, job);                       
     245                //scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, job);       
     246                 
    267247                if(log.isDebugEnabled()) 
    268                         try { 
    269                                 log.debug("Submitted job " + job.getId() + " to " + providerName); 
    270                         } catch (NoSuchFieldException e) { 
    271                                 // TODO Auto-generated catch block 
    272                                 e.printStackTrace(); 
    273                         } 
     248                        log.debug("Submitted job " + task.getId() + " to " + providerName); 
     249 
    274250        } 
    275251 
    276252        class GlobalWorkloadUnitHandler implements  WorkloadUnitHandler{ 
    277253 
    278                 public void handleJob(Job job){ 
    279  
    280                         jobRegistry.addJob(job); 
     254                public void handleJob(JobInterface<?> job){ 
    281255                        if (log.isInfoEnabled()) 
    282256                                log.info("Received job " + job.getId() + " at " + new DateTime(DateTimeUtilsExt.currentTimeMillis())); 
    283257 
    284                         scheduleReadyTasks(job); 
     258                        jobRegistry.addJob(job); 
     259                        schedule(job); 
    285260                } 
    286261                 
     
    292267                        throw new RuntimeException("Not implemented since it isn't expected that tasks are send directly to the global scheduler."); 
    293268                } 
    294  
    295                 public void handleSubmittedTask(SubmittedTask task) { 
    296                         throw new RuntimeException("Not implemented since it isn't expected that tasks are send directly to the global scheduler."); 
    297                 } 
    298269        } 
    299270 
     
    301272                return new GlobalWorkloadUnitHandler(); 
    302273        } 
    303          
    304274 
    305275 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/global/GridBroker.java

    r477 r539  
    1919public class GridBroker extends GlobalManagementSystem {  
    2020 
    21          
    2221        private static Log log = LogFactory.getLog(GridBroker.class); 
    2322 
     
    2726        public GridBroker(String name, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues) throws Exception { 
    2827                super(name, "BROKER",  schedulingPlugin, execTimeEstimationPlugin, queues); 
    29                  
    30                 //make use of plug-in interface 
    31                  
    32                 //Properties prop = new Properties(); 
    33                 //prop.put("plugin.name", name); 
    34                 //prop.put("plugin.utils.timeoperations", "gssim.scheduling.plugin.local.GssimTimeOperations"); 
    35                 //schedulingPlugin.init(prop); 
     28 
    3629                otherGridSchedulersIds = new HashSet<Integer>(); 
    37                  
    3830                moduleList = new ModuleListImpl(2); 
    39                 //this.moduleList.add(new GridResourceDiscovery(this.getScheduler())); 
    40                 //moduleList.add(new GridReservationManagerNew(this)); 
    41                  
    42                 if(log.isDebugEnabled()) 
    43                         log.debug(name + ": Creating a broker interface object"); 
    4431        } 
    4532 
    4633        public void init(Scheduler scheduler, ManagedResources managedResources) { 
    4734                super.init(scheduler, managedResources); 
    48                 //this.scheduler = scheduler; 
    49                 //this.resourceManager = ResourceManagerFactory.createResourceManager(scheduler, managedResources); 
    5035                this.moduleList.add((GridResourceDiscovery)resourceManager); 
    5136        } 
     
    5742                } 
    5843                return providerIds; 
    59                 //return GridSim.getGridResourceList(); 
    6044        } 
    6145 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/local/LocalManagementSystem.java

    r477 r539  
    11package schedframe.scheduling.policy.local; 
    22 
     3import dcworms.schedframe.scheduling.ExecTask; 
     4import dcworms.schedframe.scheduling.Executable; 
    35import eduni.simjava.Sim_event; 
    46import eduni.simjava.Sim_system; 
    57import gridsim.Accumulator; 
    68import gridsim.GridSimTags; 
    7 import gridsim.Gridlet; 
    89import gridsim.ResourceCalendar; 
    9 import gridsim.gssim.WormsTags; 
    10 import gridsim.gssim.filter.SubTaskFilter; 
    11 import gssim.schedframe.scheduling.ExecTask; 
    12 import gssim.schedframe.scheduling.Executable; 
     10import gridsim.dcworms.DCWormsTags; 
     11import gridsim.dcworms.filter.ExecTaskFilter; 
    1312 
    1413import java.util.ArrayList; 
     
    2726import qcg.shared.constants.BrokerConstants; 
    2827import schedframe.ResourceController; 
    29 import schedframe.events.scheduling.EventReason; 
    3028import schedframe.events.scheduling.SchedulingEvent; 
    3129import schedframe.events.scheduling.SchedulingEventType; 
    3230import schedframe.events.scheduling.StartTaskExecutionEvent; 
    33 import schedframe.events.scheduling.TaskCanceledEvent; 
    3431import schedframe.events.scheduling.TaskFinishedEvent; 
    3532import schedframe.events.scheduling.TaskRequestedTimeExpiredEvent; 
     
    4542import schedframe.scheduling.ResourceHistoryItem; 
    4643import schedframe.scheduling.Scheduler; 
    47 import schedframe.scheduling.UsedResourceList; 
     44import schedframe.scheduling.TaskList; 
     45import schedframe.scheduling.TaskListImpl; 
     46import schedframe.scheduling.UsedResourcesList; 
    4847import schedframe.scheduling.WorkloadUnitHandler; 
    49 import schedframe.scheduling.WorkloadUnitListImpl; 
    5048import schedframe.scheduling.manager.resources.LocalResourceManager; 
    5149import schedframe.scheduling.manager.resources.ManagedResources; 
     
    6361import schedframe.scheduling.tasks.Job; 
    6462import schedframe.scheduling.tasks.JobInterface; 
    65 import schedframe.scheduling.tasks.SubmittedTask; 
    6663import schedframe.scheduling.tasks.Task; 
    6764import schedframe.scheduling.tasks.TaskInterface; 
    6865import schedframe.scheduling.tasks.WorkloadUnit; 
    69 import simulator.WormsConstants; 
     66import simulator.DCWormsConstants; 
    7067import simulator.utils.DoubleMath; 
    7168 
     
    8380 
    8481                super(providerId, entityName, execTimeEstimationPlugin, queues); 
    85  
    86                 //schedulingPlugin = (LocalSchedulingPlugin) InstanceFactory.createInstance(schedulingPluginClassName, LocalSchedulingPlugin.class); 
    8782                 
    8883                if (schedPlugin == null) { 
     
    9085                } 
    9186                this.schedulingPlugin =  schedPlugin; 
    92                 accTotalLoad = new Accumulator(); 
    93                 moduleList = new ModuleListImpl(1); 
    94  
     87                this.moduleList = new ModuleListImpl(1); 
     88                 
     89                this.accTotalLoad = new Accumulator(); 
    9590        } 
    9691 
    9792        public void init(Scheduler sched, ManagedResources managedResources) { 
    9893                super.init(sched, managedResources); 
    99                 //scheduler = sched; 
    100                 //resourceManager = ResourceManagerFactory.createResourceManager(scheduler); 
    10194                double load = 0; 
    10295                accTotalLoad.add(load); 
     
    112105                switch (tag) { 
    113106 
    114                 case WormsTags.TIMER: 
     107                case DCWormsTags.TIMER: 
    115108                        if (pluginSupportsEvent(tag)) { 
    116109                                SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TIMER); 
    117                                 SchedulingPlanInterface decision =  schedulingPlugin.schedule(event,  
     110                                SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event,  
    118111                                                queues,  getJobRegistry(), getResourceManager(), moduleList); 
    119112                                executeSchedulingPlan(decision); 
    120113                        } 
    121114                        sendTimerEvent(); 
    122  
    123115                        break; 
    124116 
    125                 case WormsTags.TASK_READY_FOR_EXECUTION: 
    126                          
    127                         ExecTask data = (ExecTask) ev.get_data(); 
    128                         try { 
    129                                 data.setStatus(Gridlet.READY); 
     117                case DCWormsTags.TASK_READY_FOR_EXECUTION: 
     118                        ExecTask execTask = (ExecTask) ev.get_data(); 
     119                        try { 
     120                                execTask.setStatus(DCWormsTags.READY); 
    130121                                if (pluginSupportsEvent(tag)) { 
    131                                         SchedulingEvent event = new StartTaskExecutionEvent(data.getJobId(), data.getId()); 
    132                                         SchedulingPlanInterface decision =  schedulingPlugin.schedule(event, 
     122                                        SchedulingEvent event = new StartTaskExecutionEvent(execTask.getJobId(), execTask.getId()); 
     123                                        SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event, 
    133124                                                        queues,  getJobRegistry(), getResourceManager(), moduleList); 
    134125                                        executeSchedulingPlan(decision); 
     
    139130                        break; 
    140131 
    141                 case WormsTags.TASK_EXECUTION_FINISHED: 
     132                case DCWormsTags.TASK_EXECUTION_FINISHED: 
    142133                        obj = ev.get_data(); 
    143                         ExecTask task = (ExecTask) obj; 
    144                         if (task.getStatus() == Gridlet.INEXEC) { 
    145                                 finalizeExecutable(task); 
    146                                 SubmittedTask subTask = (SubmittedTask)task; 
    147                                 sendFinishedWorkloadUnit((ExecTask)subTask.getGridlet()); 
    148                                 //task.setGridletStatus(Gridlet.SUCCESS); 
    149                                 //task.finalizeGridlet(); 
    150                                 log.debug(task.getJobId() + "_" + task.getId() + " finished execution on " + new DateTime()); 
    151                                 log.info(WormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
    152                                 /*UsedResourceList<ResourceHistoryItem> lastUsedList = task.getUsedResources(); 
    153                                 Map<ResourceUnitName, AbstractResourceUnit> lastUsed = lastUsedList.getLast() 
    154                                                 .getResourceUnits(); 
    155                                 getAllocationManager().freeResources(lastUsed); 
    156                                 ProcessingElements pes = (ProcessingElements) lastUsed.get(StandardResourceUnitName.PROCESSINGELEMENTS); 
    157                                 for (ComputingResource resource : pes) { 
    158                                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, task)); 
     134                        execTask = (ExecTask) obj; 
     135                        if (execTask.getStatus() == DCWormsTags.INEXEC) { 
     136                                 
     137                                finalizeExecutable(execTask); 
     138                                sendFinishedWorkloadUnit(execTask); 
     139                                log.debug(execTask.getJobId() + "_" + execTask.getId() + " finished execution on " + new DateTime()); 
     140                                log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
     141                                if (pluginSupportsEvent(tag)) { 
     142                                        SchedulingEvent event = new TaskFinishedEvent(execTask.getJobId(), execTask.getId()); 
     143                                        SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 
     144                                                        queues, getJobRegistry(), getResourceManager(), moduleList); 
     145                                        executeSchedulingPlan(decision); 
    159146                                } 
    160                                 SubTaskFilter filter = new SubTaskFilter(task.getGridletID(), GssimTags.TASK_REQUESTED_TIME_EXPIRED); 
    161                                 scheduler.sim_cancel(filter, null); 
    162                                 super.sendFinishJob((Executable) task.getGridlet());*/ 
    163                         } 
     147                        } 
     148 
     149                        Job job = jobRegistry.getJob(execTask.getJobId()); 
     150                        if(!job.isFinished()){ 
     151                                getWorkloadUnitHandler().handleJob(job); 
     152                        } 
     153                        break; 
     154                         
     155                case DCWormsTags.TASK_REQUESTED_TIME_EXPIRED: 
     156                        obj = ev.get_data(); 
     157                        execTask = (Executable) obj; 
    164158                        if (pluginSupportsEvent(tag)) { 
    165                                 SchedulingEvent event = new TaskFinishedEvent(task.getJobId(), task.getId()); 
    166                                 SchedulingPlanInterface decision = schedulingPlugin.schedule(event, 
     159                                SchedulingEvent event = new TaskRequestedTimeExpiredEvent(execTask.getJobId(), execTask.getId()); 
     160                                SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 
    167161                                                queues, getJobRegistry(), getResourceManager(), moduleList); 
    168162                                executeSchedulingPlan(decision); 
    169163                        } 
    170                         Job job = jobRegistry.get(task.getJobId()); 
    171                         if(!job.isFinished()){ 
    172                                 getWorkloadUnitHandler().handleJob(job); 
    173                         } 
    174  
    175164                        break; 
    176                 case WormsTags.TASK_REQUESTED_TIME_EXPIRED: 
    177                         obj = ev.get_data(); 
    178                         task = (SubmittedTask) obj; 
    179                         if (pluginSupportsEvent(tag)) { 
    180                                 SchedulingEvent event = new TaskRequestedTimeExpiredEvent(task.getJobId(), task.getId()); 
    181                                 SchedulingPlanInterface decision = schedulingPlugin.schedule(event, 
    182                                                 queues, getJobRegistry(), getResourceManager(), moduleList); 
    183                                 executeSchedulingPlan(decision); 
    184                         } 
    185  
    186                         break; 
    187                 case WormsTags.UPDATE: 
     165                         
     166                case DCWormsTags.UPDATE: 
    188167                        updateProcessingTimes(ev); 
    189168                        break; 
    190169                } 
    191170        } 
    192          
    193  
    194         public void notifyReturnedWorkloadUnit(WorkloadUnit<?> wu) { 
    195                 if (pluginSupportsEvent(WormsTags.TASK_EXECUTION_FINISHED)) { 
     171 
     172        public void notifyReturnedWorkloadUnit(WorkloadUnit wu) { 
     173                if (pluginSupportsEvent(DCWormsTags.TASK_EXECUTION_FINISHED)) { 
    196174                        SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TASK_FINISHED); 
    197                         SchedulingPlanInterface decision =  schedulingPlugin.schedule(event, 
     175                        SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event, 
    198176                                        queues, getJobRegistry(), getResourceManager(), moduleList); 
    199177                        executeSchedulingPlan(decision); 
     
    203181                //} 
    204182        } 
    205  
    206         public void notifyCanceledWorkloadUnit(WorkloadUnit<?> job) { 
    207  
    208                 if (!pluginSupportsEvent(GridSimTags.GRIDLET_CANCEL)) 
    209                         return; 
    210  
    211                 Executable executable = (Executable) job; 
    212                 String jobID = executable.getJobId(); 
    213  
    214                 SchedulingPlanInterface decision = null; 
    215  
    216                 try { 
    217                         executable.setStatus((int) BrokerConstants.JOB_STATUS_CANCELED); 
    218  
    219                         TaskCanceledEvent event = new TaskCanceledEvent(executable.getJobId(), executable.getTaskId()); 
    220                         event.setReason(EventReason.RESERVATION_EXCEEDED); 
    221                         decision = schedulingPlugin 
    222                                         .schedule(event, queues, getJobRegistry(), getResourceManager(), moduleList); 
    223  
    224                         if (decision == null) 
    225                                 return; 
    226  
    227                         executeSchedulingPlan(decision); 
    228  
    229                 } catch (Exception e) { 
    230                         log.error("Exception during scheduling. " + e.getMessage()); 
    231                         e.printStackTrace(); 
    232                 } 
    233         } 
    234          
    235         protected void executeSchedulingPlan(SchedulingPlanInterface decision) { 
    236  
    237                 ArrayList<ScheduledTaskInterface> taskSchedulingDecisions = decision.getTasks(); 
     183         
     184        protected void executeSchedulingPlan(SchedulingPlanInterface<?> decision) { 
     185 
     186                ArrayList<ScheduledTaskInterface<?>> taskSchedulingDecisions = decision.getTasks(); 
    238187                for (int i = 0; i < taskSchedulingDecisions.size(); i++) { 
    239                         try { 
    240                                 ScheduledTaskInterface taskDecision = taskSchedulingDecisions.get(i); 
    241  
    242                                 // not scheduled again are returned to the user. 
    243                                 if (taskDecision.getStatus() == AllocationStatus.REJECTED) { 
    244                                         continue; 
     188                        ScheduledTaskInterface<?> taskDecision = taskSchedulingDecisions.get(i); 
     189 
     190                        if (taskDecision.getStatus() == AllocationStatus.REJECTED) { 
     191                                continue; 
     192                        } 
     193 
     194                        ArrayList<AllocationInterface<?>> allocations = taskDecision.getAllocations(); 
     195 
     196                        TaskInterface<?> task = taskDecision.getTask(); 
     197                        for (int j = 0; j < allocations.size(); j++) { 
     198 
     199                                AllocationInterface<?> allocation = allocations.get(j); 
     200                                if (allocation.isProcessing()) { 
     201                                        ExecTask exec = (ExecTask) task;                                         
     202                                        executeTask(exec, allocation.getRequestedResources()); 
     203                                } else if(resourceManager.getSchedulerName(allocation.getProviderName()) != null){ 
     204                                        allocation.setProviderName(resourceManager.getSchedulerName(allocation.getProviderName())); 
     205                                        submitTask(task, allocation); 
     206                                } else { 
     207                                        ExecTask exec = (ExecTask) task; 
     208                                        executeTask(exec, chooseResourcesForExecution(allocation.getProviderName(), exec)); 
    245209                                } 
    246  
    247                                 ArrayList<AllocationInterface> allocations = taskDecision.getAllocations(); 
    248  
    249                                 WorkloadUnit<?> task = taskDecision.getTask(); 
    250                                 for (int j = 0; j < allocations.size(); j++) { 
    251  
    252                                         AllocationInterface allocation = allocations.get(j); 
    253                                         if (allocation.isProcessing()) { 
    254                                                  
    255                                                 ExecTask exec = (ExecTask) task; 
    256                                                  
    257  
    258                                                 //Executable e = (Executable)task; 
    259                                                 /*SubmittedTask submittedTask = jobRegistry.getSubmittedTask(e.getJobId(), e.getId()); 
    260                                                 if(submittedTask == null) 
    261                                                 {       submittedTask = new SubmittedTask(e); 
    262                                                         jobRegistry.addTask(submittedTask); 
    263                                                 }*/ 
    264  
    265                                                 /*e.visitResource(scheduler.get_name()); 
    266                                                 Scheduler parentScheduler = scheduler.getParent(); 
    267                                                 while (parentScheduler != null && !e.getVisitedResources().contains(parentScheduler.get_name())) { 
    268                                                         e.visitResource(parentScheduler.get_name()); 
    269                                                         parentScheduler = parentScheduler.getParent(); 
    270                                                 }*/ 
    271                                                  
    272                                                                                                  
    273                                                 executeTask(exec, allocation.getRequestedResources()); 
    274                                         //} else if(GridSim.getEntityId(allocation.getProviderName()) != -1 || scheduler.getScheduler(allocation.getProviderName())!=null){ 
    275                                         } else if(resourceManager.getSchedulerName(allocation.getProviderName()) != null){ 
    276                                                 allocation.setProviderName(resourceManager.getSchedulerName(allocation.getProviderName())); 
    277                                                 submitWorkloadUnit(task, allocation); 
    278                                         } else { 
    279  
    280                                                 ExecTask exec = (ExecTask) task; 
    281                                                  
    282                                                         //Executable exec = jobRegistry.createExecutable(t, allocation); 
    283                                                         //exec.setResourceParameter(scheduler.get_id(), 1); 
    284                                                 /*e.visitResource(scheduler.get_name()); 
    285                                                 Scheduler parentScheduler = scheduler.getParent(); 
    286                                                 while (parentScheduler != null && !e.getVisitedResources().contains(parentScheduler.get_name())) { 
    287                                                         e.visitResource(parentScheduler.get_name()); 
    288                                                         parentScheduler = parentScheduler.getParent(); 
    289                                                 }*/ 
    290                                                 executeTask(exec, chooseResourcesForExecution(allocation.getProviderName(), (ExecTask)task)); 
    291                                         } 
    292                                 } 
    293  
    294                         } catch (Exception e) { 
    295                                 e.printStackTrace(); 
    296                         } 
     210                        } 
     211 
    297212                } 
    298213        } 
    299214 
    300215        protected void executeTask(ExecTask task, Map<ResourceUnitName, ResourceUnit> choosenResources) { 
    301         //      Executable exec = (Executable) task; 
    302          
    303                 SubmittedTask submittedTask = (SubmittedTask)task; 
     216 
     217                Executable exec = (Executable)task; 
    304218                boolean allocationStatus = getAllocationManager().allocateResources(choosenResources); 
    305219                if(allocationStatus == false) 
    306220                        return; 
    307221                removeFromQueue(task); 
    308                 //SubmittedTask submittedTask = (SubmittedTask)task; 
    309                 /* submittedTask = jobRegistry.getSubmittedTask(exec.getJobId(), exec.getId()); 
    310                 if(submittedTask == null) 
    311                 {       submittedTask = new SubmittedTask(exec); 
    312                         jobRegistry.addTask(submittedTask); 
    313                 }*/ 
    314                 double completionPercentage = (submittedTask.getLength() - submittedTask.getRemainingGridletLength())/submittedTask.getLength(); 
     222 
    315223                SchedulingEvent event = new SchedulingEvent(SchedulingEventType.START_TASK_EXECUTION); 
    316224                int time = Double.valueOf( 
    317                                 execTimeEstimationPlugin.execTimeEstimation(event, choosenResources, task, completionPercentage)).intValue(); 
     225                                execTimeEstimationPlugin.execTimeEstimation(event, task, choosenResources, exec.getCompletionPercentage())).intValue(); 
    318226                log.debug(task.getJobId() + "_" + task.getId() + " starts executing on " + new DateTime() 
    319227                                + " will finish after " + time); 
     
    322230                        return; 
    323231 
    324                 submittedTask.setEstimatedDuration(time); 
     232                exec.setEstimatedDuration(time); 
    325233                DateTime currentTime = new DateTime(); 
    326234                ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 
    327                 submittedTask.addUsedResources(resHistItem); 
    328                 submittedTask.setFinishTime(currentTime.getMillis() / 1000); 
    329                  
    330                 jobRegistry.saveHistory(submittedTask, time, choosenResources); 
    331                  
    332                 scheduler.sendInternal(time, WormsTags.TASK_EXECUTION_FINISHED, 
    333                                 submittedTask); 
    334  
     235                exec.addUsedResources(resHistItem); 
    335236                try { 
    336                         long expectedDuration = submittedTask.getExpectedDuration().getMillis() / 1000; 
    337                         scheduler.sendInternal(expectedDuration, WormsTags.TASK_REQUESTED_TIME_EXPIRED, submittedTask); 
     237                        exec.setStatus(DCWormsTags.INEXEC); 
     238                } catch (Exception e) { 
     239                        // TODO Auto-generated catch block 
     240                        e.printStackTrace(); 
     241                } 
     242                scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, exec); 
     243 
     244                try { 
     245                        long expectedDuration = exec.getExpectedDuration().getMillis() / 1000; 
     246                        scheduler.sendInternal(expectedDuration, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec); 
    338247                } catch (NoSuchFieldException e) { 
    339                         double t = submittedTask.getEstimatedDuration(); 
    340                         scheduler.sendInternal(t, WormsTags.TASK_REQUESTED_TIME_EXPIRED, submittedTask); 
    341                 } 
    342                  
    343                 submittedTask.setGridletStatus(Gridlet.INEXEC); 
    344                 log.info(WormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
     248                        double t = exec.getEstimatedDuration(); 
     249                        scheduler.sendInternal(t, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec); 
     250                } 
     251 
     252                log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
    345253                 
    346254                PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE); 
    347                 if(peUnit instanceof ProcessingElements){ 
     255                 
     256                notifyComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec); 
     257                 
     258                /*if(peUnit instanceof ProcessingElements){ 
    348259                        ProcessingElements pes = (ProcessingElements) peUnit; 
    349260                        for (ComputingResource resource : pes) { 
    350                                 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, submittedTask)); 
     261                                resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, exec)); 
    351262                        } 
    352263                } else { 
     
    355266                                resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
    356267                        } catch (ResourceException e) { 
    357                                  
    358                         } 
    359                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, submittedTask)); 
    360                 } 
    361                 /*ProcessingElements pes = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE); 
    362                 for (ComputingResource resource : pes) { 
    363                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, submittedTask)); 
    364                 }*/ 
     268                                return; 
     269                        } 
     270                        resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, exec)); 
     271                } 
     272*/ 
    365273 
    366274                /*for(ExecTaskInterface etask : jobRegistry.getRunningTasks()){ 
     
    371279        } 
    372280         
    373         public void finalizeExecutable(ExecTask exec){ 
    374                  
    375                 SubmittedTask subTask = (SubmittedTask)exec; 
    376                 subTask.setGridletStatus(Gridlet.SUCCESS); 
    377                 subTask.finalizeGridlet(); 
    378                 UsedResourceList<ResourceHistoryItem> lastUsedList = subTask.getUsedResources(); 
    379                 Map<ResourceUnitName, ResourceUnit> lastUsed = lastUsedList.getLast() 
    380                                 .getResourceUnits(); 
    381                 getAllocationManager().freeResources(lastUsed); 
    382                  
    383                 PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 
    384                 if(peUnit instanceof ProcessingElements){ 
    385                         ProcessingElements pes = (ProcessingElements) peUnit; 
    386                         for (ComputingResource resource : pes) { 
    387                                 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, subTask)); 
    388                         } 
    389                 } else { 
    390                         ComputingResource resource = null; 
    391                         try { 
    392                                 resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
    393                         } catch (ResourceException e) { 
    394                                  
    395                         } 
    396                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, subTask)); 
    397                 } 
    398                 /*ProcessingElements pes = (ProcessingElements) lastUsed.get(StandardResourceUnitName.PE); 
    399                 for (ComputingResource resource : pes) { 
    400                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, subTask)); 
    401                 }*/ 
    402                 SubTaskFilter filter = new SubTaskFilter(subTask.getGridletID(), WormsTags.TASK_REQUESTED_TIME_EXPIRED); 
     281        public void finalizeExecutable(ExecTask execTask){ 
     282                 
     283                Executable exec = (Executable)execTask; 
     284                exec.finalizeExecutable(); 
     285                 
     286                ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_REQUESTED_TIME_EXPIRED); 
    403287                scheduler.sim_cancel(filter, null); 
    404288                 
    405                 Executable executable = (Executable) subTask.getGridlet(); 
    406                 Job job = jobRegistry.get(executable.getJobId()); 
    407  
    408                 Task task = null; 
     289                Task task; 
     290                Job job = jobRegistry.getJob(exec.getJobId()); 
    409291                try { 
    410                         task = job.getTask(executable.getTaskId()); 
     292                        task = job.getTask(exec.getTaskId()); 
    411293                } catch (NoSuchFieldException e) { 
    412                         e.printStackTrace(); 
    413                 } 
    414                 if(executable.getProcessesId() == null){ 
    415                         try { 
    416                                 task.setStatus(executable.getStatus()); 
     294                        return; 
     295                } 
     296                if(exec.getProcessesId() == null){ 
     297                        try { 
     298                                task.setStatus(exec.getStatus()); 
    417299                        } catch (Exception e) { 
    418300                                e.printStackTrace(); 
     
    422304                        for(int i = 0; i < processesList.size(); i++){ 
    423305                                AbstractProcesses processes = processesList.get(i); 
    424                                 if(processes.getId().equals(executable.getProcessesId())){ 
    425                                         processes.setStatus(executable.getStatus()); 
     306                                if(processes.getId().equals(exec.getProcessesId())){ 
     307                                        processes.setStatus(exec.getStatus()); 
    426308                                        break; 
    427309                                } 
    428310                        } 
    429311                } 
     312                 
     313                UsedResourcesList lastUsedList = exec.getUsedResources(); 
     314                Map<ResourceUnitName, ResourceUnit> lastUsed = lastUsedList.getLast() 
     315                                .getResourceUnits(); 
     316                getAllocationManager().freeResources(lastUsed); 
     317                 
     318                PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 
     319                notifyComputingResources(peUnit, EnergyEventType.TASK_FINISHED, exec); 
     320                /*if(peUnit instanceof ProcessingElements){ 
     321                        ProcessingElements pes = (ProcessingElements) peUnit; 
     322                        for (ComputingResource resource : pes) { 
     323                                resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
     324                        } 
     325                } else { 
     326                        ComputingResource resource = null; 
     327                        try { 
     328                                resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
     329                        } catch (ResourceException e) { 
     330                                return; 
     331                        } 
     332                        resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
     333                }*/ 
     334 
    430335                //sendFinishedWorkloadUnit(executable); 
    431336        } 
     
    441346                while (iter.hasNext()) { 
    442347                        ExecTask task = iter.next(); 
    443                         SubmittedTask subTask = (SubmittedTask)task; 
    444                         UsedResourceList<ResourceHistoryItem> usedResourcesList = subTask.getUsedResources(); 
    445                         ResourceUnit unit = usedResourcesList.getLast().getResourceUnits() 
     348                        Executable exec = (Executable)task; 
     349                        exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * timeSpan/exec.getEstimatedDuration()); 
     350                         
     351                        UsedResourcesList usedResourcesList = exec.getUsedResources(); 
     352                        PEUnit peUnit = (PEUnit)usedResourcesList.getLast().getResourceUnits() 
    446353                                        .get(StandardResourceUnitName.PE); 
    447  
    448                         double load = getMIShare(timeSpan, (PEUnit) unit); 
    449                         subTask.updateGridletFinishedSoFar(load); 
     354                        double load = getMIShare(timeSpan, peUnit); 
    450355                        addTotalLoad(load); 
    451356                } 
    452357        } 
    453  
     358        private void notifyComputingResources(PEUnit peUnit, EnergyEventType eventType, Object obj){ 
     359 
     360                if(peUnit instanceof ProcessingElements){ 
     361                        ProcessingElements pes = (ProcessingElements) peUnit; 
     362                        for (ComputingResource resource : pes) { 
     363                                resource.handleEvent(new EnergyEvent(eventType, obj)); 
     364                        } 
     365                } else { 
     366                        ComputingResource resource = null; 
     367                        try { 
     368                                resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
     369                        } catch (ResourceException e) { 
     370                                return; 
     371                        } 
     372                        resource.handleEvent(new EnergyEvent(eventType, obj)); 
     373                } 
     374        } 
     375         
    454376        private double getMIShare(double timeSpan, PEUnit pes) { 
    455377                double localLoad; 
     
    470392        protected void updateProcessingTimes(Sim_event ev) { 
    471393                updateProcessingProgress(); 
    472                 for (ExecTask task : jobRegistry.getRunningTasks()) { 
    473                         SubmittedTask subTask = (SubmittedTask)task; 
    474                         List<String> visitedResource = subTask.getVisitedResources(); 
     394                for (ExecTask execTask : jobRegistry.getRunningTasks()) { 
     395                        Executable exec = (Executable)execTask; 
     396                        List<String> visitedResource = exec.getVisitedResources(); 
    475397                        String originResource = ev.get_data().toString(); 
    476398                        if(!ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), originResource)){ 
     
    478400                        } 
    479401                         
    480                         Map<ResourceUnitName, ResourceUnit> choosenResources = subTask.getUsedResources().getLast().getResourceUnits(); 
    481                         double completionPercentage = (task.getLength() - subTask.getRemainingGridletLength())/task.getLength(); 
    482                         double time = execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED),  
    483                                         choosenResources, task, completionPercentage); 
    484  
    485                         /*if(!subTask.getVisitedResources().contains(ev.get_data().toString())) { 
     402                        Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getUsedResources().getLast().getResourceUnits(); 
     403                        int time =  Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED),  
     404                                        execTask, choosenResources, exec.getCompletionPercentage())).intValue(); 
     405 
     406                        //check if the new estimated end time is equal to the previous one; if yes the continue without update 
     407                        if( DoubleMath.subtract((exec.getExecStartTime() + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000 + time)) == 0.0){ 
    486408                                continue; 
    487                         }*/ 
    488                         //check if the new estimated end time is equal to the previous one; if yes the continue without update 
    489                         if( DoubleMath.subtract((subTask.getExecStartTime() + subTask.getEstimatedDuration()), (new DateTime().getMillis()/1000 + time)) == 0.0){ 
    490                                 continue; 
    491                         } 
    492                         SubTaskFilter filter = new SubTaskFilter(subTask.getGridletID(), WormsTags.TASK_EXECUTION_FINISHED); 
     409                        } 
     410                        exec.setEstimatedDuration(time); 
     411                        ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_FINISHED); 
    493412                        scheduler.sim_cancel(filter, null); 
    494                         scheduler.sendInternal(time, WormsTags.TASK_EXECUTION_FINISHED, task); 
    495  
     413                        scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 
    496414                } 
    497415        }        
     
    511429                                numberOfPE = numberOfPE + resUnit.getAmount(); 
    512430                        } 
    513                         //numberOfPE = getResourceManager().getPE().size(); 
    514431                } catch (Exception e) { 
    515432                        numberOfPE = 1; 
     
    532449                        ExecTask task) { 
    533450 
    534                 ResourceManager resourceManager = this.resourceManager; 
     451                Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 
     452                LocalResourceManager resourceManager = getResourceManager(); 
    535453                if(resourceName != null){ 
    536454                        ComputingResource resource = null; 
     
    540458                                return null; 
    541459                        } 
    542  
    543460                        resourceManager = new LocalResourceManager(resource); 
    544461                } 
    545                 Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 
    546  
    547462 
    548463                int cpuRequest; 
     
    553468                } 
    554469 
    555                 //PEUnit processingUnits = null; 
    556470                if (cpuRequest != 0) { 
    557471                         
    558472                        List<ResourceUnit> availableUnits = null; 
    559473                        try { 
    560                                 availableUnits = getResourceManager().getPE(); 
     474                                availableUnits = resourceManager.getPE(); 
    561475                        } catch (ResourceException e) { 
    562476                                return null; 
    563477                        } 
     478                         
    564479                        List<ResourceUnit> choosenPEUnits = new ArrayList<ResourceUnit>(); 
    565  
    566480                        for (int i = 0; i < availableUnits.size() && cpuRequest > 0; i++) { 
    567481                                PEUnit peUnit = (PEUnit) availableUnits .get(i); 
     
    576490                                return null; 
    577491                        } 
    578  
    579                         /*try { 
    580                                 List<? extends ComputingResource> processingElements = resourceManager.getResourcesOfType(StandardResourceType.Processor); 
    581                                 List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(); 
    582                                 int peSize = processingElements.size(); 
    583                                 for (int i = 0; i < peSize && cpuRequest > 0; i++) { 
    584                                         if (processingElements.get(i).getStatus() == ResourceStatus.FREE) { 
    585                                                 choosenResources.add(processingElements.get(i)); 
    586                                                 cpuRequest--; 
    587                                         } 
    588                                 } 
    589                                 if (cpuRequest > 0) 
    590                                 {        
    591                                         return null; 
    592                                 } 
    593                                 processingUnits = new ProcessingElements(choosenResources); 
    594                         } catch (Exception e) { 
    595          
    596                                 List<ResourceUnit> procResUnit = resourceManager.getDistributedResourceUnits(StandardResourceUnitName.PE); 
    597  
    598                                 for(ResourceUnit resUnit: procResUnit){ 
    599                                         if (resUnit.getFreeAmount() >= cpuRequest) 
    600                                         {        
    601                                                 processingUnits = new PEUnit(resUnit.getResourceId(), cpuRequest, cpuRequest); 
    602                                                 break; 
    603                                         }  
    604                                 } 
    605                         }*/ 
    606492                        map.put(StandardResourceUnitName.PE, choosenPEUnits.get(0)); 
    607493                } 
    608                 /*int memoryRequest; 
    609                 try { 
    610                         memoryRequest = Double.valueOf(task.getMemoryRequest()).intValue(); 
    611                 } catch (NoSuchFieldException e) { 
    612                         memoryRequest = 0; 
    613                 } 
    614                 if (memoryRequest != 0) { 
    615                         List<ResourceUnit> resUnit = resourceManager.getSharedResourceUnits().get(StandardResourceUnitName.MEMORY); 
    616  
    617                         Memory memory = null; 
    618                         for (ResourceUnit memUnit : resUnit) { 
    619                                 Memory m = (Memory) memUnit; 
    620  
    621                                 if (m.getFreeAmount() >= memoryRequest) {        
    622                                         System.out.println(m.getResourceId()+ ";"+m.getAmount()+";"+m.getFreeAmount()); 
    623                                         memory = new Memory(m, memoryRequest, memoryRequest); 
    624                                 } 
    625                         } 
    626                         if(memory == null) 
    627                                 return null; 
    628                         map.put(StandardResourceUnitName.MEMORY, memory); 
    629                 }*/ 
     494 
    630495                return  map; 
    631496        } 
    632  
    633  
    634          
    635         public void notifySubmittedWorkloadUnit(WorkloadUnit<?> job, boolean ack) { 
     497         
     498        public void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack) { 
    636499                updateProcessingProgress(); 
    637                 registerWorkloadUnit(job); 
    638         } 
    639  
    640         private void registerWorkloadUnit(WorkloadUnit<?> wu){ 
     500                registerWorkloadUnit(wu); 
     501        } 
     502 
     503        private void registerWorkloadUnit(WorkloadUnit wu){ 
    641504                if(!wu.isRegistered()){ 
    642505                        wu.register(jobRegistry); 
     
    647510        class LocalWorkloadUnitHandler implements WorkloadUnitHandler{ 
    648511                 
    649                 public void handleJob(Job job){ 
     512                public void handleJob(JobInterface<?> job){ 
    650513 
    651514                        if (log.isInfoEnabled()) 
     
    654517                        List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 
    655518                        jobsList.add(job); 
    656                         WorkloadUnitListImpl readyTasks = new WorkloadUnitListImpl(); 
    657                         for(Task task: jobRegistry.getReadyTasks(jobsList)){ 
     519                        TaskListImpl availableTasks = new TaskListImpl(); 
     520                        for(Task task: jobRegistry.getAvailableTasks(jobsList)){ 
    658521                                task.setStatus((int)BrokerConstants.TASK_STATUS_QUEUED); 
    659                                 readyTasks.add(task); 
    660                         } 
    661  
    662                         for(WorkloadUnit<?> e:readyTasks){       
    663                                 registerWorkloadUnit(e); 
    664                         } 
    665                 } 
    666                  
    667                 public void handleTask(TaskInterface<?> ti){ 
    668                         Task task = (Task)ti; 
    669                          
    670                         if(task.getProcesses() == null){ 
     522                                availableTasks.add(task); 
     523                        } 
     524 
     525                        for(TaskInterface<?> task: availableTasks){      
     526                                registerWorkloadUnit(task); 
     527                        } 
     528                } 
     529                 
     530                public void handleTask(TaskInterface<?> t){ 
     531                        Task task = (Task)t; 
     532                        List<AbstractProcesses> processes = task.getProcesses(); 
     533 
     534                        if(processes == null || processes.size() == 0){ 
    671535                                Executable exec = new Executable(task); 
    672                                 exec.setUserID(task.getSenderId()); 
    673                                 exec.setLength(task.getLength()); 
    674536                                registerWorkloadUnit(exec); 
    675537                        } else { 
    676                                 List<AbstractProcesses> processesList = task.getProcesses(); 
    677                                 for(int i = 0; i < processesList.size(); i++){   
    678                                         AbstractProcesses processes = processesList.get(i); 
    679                                         Executable exec = new Executable(task, processes); 
    680                                         exec.setUserID(task.getSenderId()); 
    681                                         exec.setLength(task.getLength()); 
     538                                for(int j = 0; j < processes.size(); j++){ 
     539                                        AbstractProcesses procesesSet = processes.get(j); 
     540                                        Executable exec = new Executable(task, procesesSet); 
    682541                                        registerWorkloadUnit(exec); 
    683542                                } 
     
    686545                 
    687546                public void handleExecutable(ExecTask task){ 
     547                         
    688548                        Executable exec = (Executable) task; 
    689  
    690                         // int cost = 
    691                         // this.resourceManager.getResourceCharacteristic().getResUnits() != 
    692                         // null ? 
    693                         // this.resourceManager.getResourceCharacteristic().getResUnits().get(ResourceParameterName.COST).getAmount() 
    694                         // : 1; 
    695  
    696                         exec.visitResource(scheduler.get_name()); 
     549                        jobRegistry.addExecTask(exec); 
     550                         
     551                        exec.trackResource(scheduler.get_name()); 
    697552                        Scheduler parentScheduler = scheduler.getParent(); 
    698                         while (parentScheduler != null && !exec.getVisitedResources().contains(parentScheduler.get_name())) { 
    699                                 exec.visitResource(parentScheduler.get_name()); 
     553                        List<String> visitedResource = exec.getVisitedResources(); 
     554                        String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]); 
     555                        while (parentScheduler != null && !ArrayUtils.contains(visitedResourcesArray, parentScheduler.get_name())) { 
     556                                exec.trackResource(parentScheduler.get_name()); 
    700557                                parentScheduler = parentScheduler.getParent(); 
    701558                        } 
    702                          
    703                         exec.setResourceParameter(scheduler.get_id(), 1); 
    704                         SubmittedTask subTask = new SubmittedTask(exec); 
    705                         jobRegistry.addTask(subTask); 
    706                         WorkloadUnitListImpl newTasks = new WorkloadUnitListImpl(); 
    707                         newTasks.add(subTask); 
    708                  
    709                         schedulingPlugin.placeJobsInQueues(newTasks, queues, getResourceManager(), moduleList); 
    710  
    711                         if (subTask.getStatus() == Gridlet.QUEUED) { 
     559                        exec.setSchedulerName(scheduler.get_id()); 
     560                         
     561                        TaskList newTasks = new TaskListImpl(); 
     562                        newTasks.add(exec); 
     563                 
     564                        schedulingPlugin.placeTasksInQueues(newTasks, queues, getResourceManager(), moduleList); 
     565 
     566                        if (exec.getStatus() == DCWormsTags.QUEUED) { 
    712567                                sendExecutableReadyEvent(exec); 
    713                         } 
    714                 } 
    715                  
    716                 public void handleSubmittedTask(SubmittedTask task){ 
    717  
    718                         task.visitResource(scheduler.get_name()); 
    719                         Scheduler parentScheduler = scheduler.getParent(); 
    720                         while (parentScheduler != null && !task.getVisitedResources().contains(parentScheduler.get_name())) { 
    721                                 task.visitResource(parentScheduler.get_name()); 
    722                                 parentScheduler = parentScheduler.getParent(); 
    723                         } 
    724  
    725                         jobRegistry.addTask(task); 
    726                         WorkloadUnitListImpl newTasks = new WorkloadUnitListImpl(); 
    727                         newTasks.add(task); 
    728                  
    729                         schedulingPlugin.placeJobsInQueues(newTasks, queues, getResourceManager(), moduleList); 
    730  
    731                         if (task.getStatus() == Gridlet.QUEUED) { 
    732                                 sendExecutableReadyEvent(task); 
    733568                        } 
    734569                } 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/queue/TaskQueue.java

    r477 r539  
    11package schedframe.scheduling.queue; 
    22 
    3 import gridsim.Gridlet; 
    4 import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
     3import gridsim.dcworms.DCWormsTags; 
    54 
    65import org.joda.time.DateTime; 
    76 
    8 import schedframe.scheduling.tasks.WorkloadUnit; 
     7import dcworms.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
    98 
    10 public class TaskQueue extends AbstractStatsSupportingQueue<WorkloadUnit<?>> implements Queue<WorkloadUnit<?>>{ 
     9import schedframe.scheduling.tasks.TaskInterface; 
    1110 
     11public class TaskQueue extends AbstractStatsSupportingQueue<TaskInterface<?>> implements Queue<TaskInterface<?>>{ 
    1212 
    1313        private static final long serialVersionUID = 6576299222910508209L; 
     
    1717        protected boolean supportReservation; 
    1818         
    19          
    2019        public TaskQueue (boolean supportReservation){ 
    21                 name = "Queue"; 
    22                 priority = 0; 
     20                this.name = "Queue"; 
     21                this.priority = 0; 
    2322                this.supportReservation = supportReservation; 
    24  
    2523        } 
    2624         
    27         public boolean add(WorkloadUnit<?> wu){ 
     25        public boolean add(TaskInterface<?> task){ 
    2826                try { 
    29                         wu.setStatus(Gridlet.QUEUED); 
     27                        task.setStatus(DCWormsTags.QUEUED); 
    3028                } catch(Exception e){ 
    3129                        throw new RuntimeException(e); 
    3230                } 
    33                 //updateStats(); 
    34                 return super.add(wu); 
     31                return super.add(task); 
    3532        } 
    3633         
    37         public void add(int pos, WorkloadUnit<?> wu){ 
     34        public void add(int pos, TaskInterface<?> task){ 
    3835                try { 
    39                         wu.setStatus(Gridlet.QUEUED); 
     36                        task.setStatus(DCWormsTags.QUEUED); 
    4037                } catch(Exception e){ 
    4138                        throw new RuntimeException(e); 
    4239                } 
    43                 //updateStats(); 
    44                  super.add(pos, wu); 
     40                 super.add(pos, task); 
    4541        } 
    4642         
    4743        public DateTime getArrivalTime(int pos) throws IndexOutOfBoundsException { 
    48                 //return get(pos).getSubmissionTimeToBroker(); 
    49                 return null; 
     44                return get(pos).getSubmissionTimeToBroker(); 
    5045        } 
    5146 
     
    6964                return supportReservation; 
    7065        } 
    71          
    72          
    73         /*public boolean contains (WorkloadUnitInterface<?> wu) { 
    74                 for(int i = 0; i< size();i++){ 
    75                         try { 
    76                                 if(get(i).getId().equals(wu.getId())) 
    77                                         return true; 
    78                         } catch (NoSuchFieldException e) { 
    79                                 return false; 
    80                         } 
    81                 } 
    82                 return false; 
    83         } 
    84          
    85         public boolean remove (WorkloadUnitInterface<?> wu) { 
    86                 boolean found = false; 
    87                 int index = 0; 
    88                 for(int i = 0; i< size() && !found;i++){ 
    89                         try { 
    90                                 if(get(i).getId().equals(wu.getId())) 
    91                                 { 
    92                                         found = true; 
    93                                         index = i; 
    94                                 } 
    95                                  
    96                         } catch (NoSuchFieldException e) { 
    97                                 return false; 
    98                         } 
    99                 } 
    100                 remove(index); 
    101                 return true; 
    102         }*/ 
    10366} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/AbstractProcesses.java

    r477 r539  
    33import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    44 
    5 public abstract class AbstractProcesses<T> implements WorkloadUnit<T>{ 
     5public abstract class AbstractProcesses implements WorkloadUnit{ 
    66         
    77         
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/Job.java

    r477 r539  
    1818import schedframe.scheduling.WorkloadUnitHandler; 
    1919import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    20 import schedframe.scheduling.policy.AbstractManagementSystem; 
    2120 
    2221 
     
    179178        } 
    180179         
    181         public int getUserID(){ 
     180        public int getUserId(){ 
    182181                return this.senderId; 
    183182        } 
     
    204203                 
    205204                List<Task> readyTasks = new ArrayList<Task>(); 
    206  
    207205                int size = tasks.size(); 
     206                 
    208207                for(int i = 0; i < size; i++){ 
    209208                        int parCnt; 
     
    216215                        } catch(Exception e){ 
    217216                                parCnt = 0; 
    218                                 //e.printStackTrace(); 
    219                         } 
    220                         if(parCnt == 0) 
    221                         { 
     217                        } 
     218                        if(parCnt == 0) { 
    222219                                readyTasks.add(task); 
    223220                        } 
    224                         else 
    225                         { 
     221                        else { 
    226222                                for(int j = 0; j < parCnt; j++){ 
    227223                                        ParentType par = task.getDescription().getWorkflow().getParent(j); 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/JobInterface.java

    r477 r539  
    1111 * 
    1212 */ 
    13 public interface JobInterface<T> extends WorkloadUnit<T> { 
     13public interface JobInterface<T> extends WorkloadUnit, DescriptionContainer<T> { 
    1414 
    1515        /** 
     
    1818         * @throws NoSuchFieldException if there is no tasks for this job, and job id can not be obtained 
    1919         */ 
    20         public abstract String getId() throws NoSuchFieldException; 
     20        //public abstract String getId() throws NoSuchFieldException; 
    2121         
    2222        /** 
     
    4444         * @return constant which represents current status of this job 
    4545         */ 
    46         public int getStatus(); 
     46        //public int getStatus(); 
    4747         
    48         public int getUserID(); 
     48        //public int getUserID(); 
    4949} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/Processes.java

    r477 r539  
    11package schedframe.scheduling.tasks; 
    2  
    3 import java.util.List; 
    42 
    53import org.qcg.broker.schemas.resreqs.ComputingResourceBaseTypeItem; 
     
    196194        } 
    197195 
    198         public org.qcg.broker.schemas.resreqs.Processes getDescription(){ 
    199                 return this.pr; 
    200         } 
    201  
    202         @Override 
    203         public List getTask() { 
    204                 // TODO Auto-generated method stub 
    205                 return null; 
    206         } 
    207  
    208         @Override 
    209         public TaskInterface getTask(String taskId) throws NoSuchFieldException { 
    210                 // TODO Auto-generated method stub 
    211                 return null; 
    212         } 
    213  
    214         @Override 
    215         public int getTaskCount() { 
     196        public int getStatus() { 
     197                return this.status; 
     198        } 
     199 
     200        @Override 
     201        public int getUserId() { 
    216202                // TODO Auto-generated method stub 
    217203                return 0; 
    218204        } 
    219205 
    220         @Override 
    221         public int getStatus() { 
    222                 // TODO Auto-generated method stub 
    223                 return 0; 
    224         } 
    225  
    226         @Override 
    227         public int getUserID() { 
    228                 // TODO Auto-generated method stub 
    229                 return 0; 
    230         } 
    231  
    232         @Override 
    233         public String getDocument() throws Exception { 
    234                 // TODO Auto-generated method stub 
    235                 return null; 
    236         } 
     206 
    237207 
    238208        @Override 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/Task.java

    r477 r539  
    3030import schedframe.scheduling.WorkloadUnitHandler; 
    3131import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    32 import schedframe.scheduling.policy.AbstractManagementSystem; 
    3332import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    3433 
     
    3837 * 
    3938 */ 
    40 public class Task /*extends AbstractTask*/ implements TaskInterface<org.qcg.broker.schemas.resreqs.Task> { 
     39public class Task implements TaskInterface<org.qcg.broker.schemas.resreqs.Task> { 
    4140         
    4241        protected static Unmarshaller unmarshaller; 
     
    7271        private int senderId; 
    7372        private long workloadLogWaitTime; 
    74         //String resPathHistory; 
    75          
     73 
    7674        public Task(org.qcg.broker.schemas.resreqs.Task task){ 
    7775                this.task = task; 
     
    8078                this.brokerSubmitTime = null; 
    8179                this.duration = null; 
    82         //      this.gridletID_ = (getJobId() + "_" + getId()).hashCode(); 
    8380                prepareTopology(); 
    8481        } 
     
    9188                this.brokerSubmitTime = null; 
    9289                this.duration = null; 
    93         //      this.gridletID_ = (getJobId() + getId()).hashCode(); 
    9490                prepareTopology(); 
    9591        } 
     
    269265        } 
    270266 
    271         public String getUserDn() { 
     267        public String getUserDN() { 
    272268                return this.task.getUserDN(); 
    273269        } 
     
    471467        }*/ 
    472468 
     469 
    473470        @Override 
    474         public List <Task> getTask() { 
    475                 List<Task> tasks = new ArrayList<Task>(); 
    476                 tasks.add(this); 
    477                 return tasks; 
    478         } 
    479  
    480         @Override 
    481         public Task getTask(String taskId) throws NoSuchFieldException { 
    482                 // TODO Auto-generated method stub 
    483                 return null; 
    484         } 
    485  
    486         @Override 
    487         public int getTaskCount() { 
     471        public int getUserId() { 
    488472                // TODO Auto-generated method stub 
    489473                return 0; 
    490474        } 
    491475 
    492         @Override 
    493         public int getUserID() { 
    494                 // TODO Auto-generated method stub 
    495                 return 0; 
    496         } 
    497  
    498476        public boolean isRegistered() { 
    499477                return isRegistered; 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/TaskInterface.java

    r477 r539  
    66import org.joda.time.ReadableDuration; 
    77 
     8import schedframe.DescriptionContainer; 
    89import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    910 
     
    1415 * 
    1516 */ 
    16 public interface TaskInterface<T> extends WorkloadUnit<T> { 
     17public interface TaskInterface<T> extends WorkloadUnit, DescriptionContainer<T> { 
    1718         
    1819        /** 
     
    2021         * @return task identifier 
    2122         */ 
    22         public abstract String getId(); 
     23        //public abstract String getId(); 
    2324         
    2425        /** 
     
    3334         * submitted this task.  
    3435         */ 
    35         public abstract String getUserDn(); 
     36        public abstract String getUserDN(); 
    3637         
    3738        /** 
     
    8788         */ 
    8889        public long getLength(); 
    89          
    90         /** 
    91          *  
    92          * @param length measured in instructions. 
    93          */ 
    94         public void setLength(long length); 
    95          
     90 
    9691        /** 
    9792         *  
    9893         * @return constant which represent current task status 
    9994         */ 
    100         public int getStatus(); 
     95        //public int getStatus(); 
    10196         
    10297         
     
    107102        public List<AbstractProcesses> getProcesses(AbstractProcessesGroup processGroup); 
    108103         
    109         public void setStatus(int status) throws Exception; 
     104        //public void setStatus(int status) throws Exception; 
    110105         
    111106        public double getCpuCntRequest() throws NoSuchFieldException; 
     
    114109         
    115110        public long getWorkloadLogWaitTime(); 
    116          
    117         //public void addToResPath(String resName); 
    118          
    119         //public String getResPath(); 
     111 
    120112                 
    121113} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/WorkloadUnit.java

    r477 r539  
    11package schedframe.scheduling.tasks; 
    22 
    3 import java.util.List; 
    4  
    5 import schedframe.DescriptionContainer; 
    63import schedframe.scheduling.WorkloadUnitHandler; 
    74import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    8 import schedframe.scheduling.policy.AbstractManagementSystem; 
    95 
    10 public interface WorkloadUnit<T> extends DescriptionContainer<T> { 
     6public interface WorkloadUnit { 
    117 
    12         /** 
    13          *  
    14          * @return job identifier 
    15          * @throws NoSuchFieldException if there is no tasks for this job, and job id can not be obtained 
    16          */ 
    17         public abstract String getId() throws NoSuchFieldException; 
     8        public String getId(); 
    189         
    19         /** 
    20          *  
    21          * @return list of tasks which belongs to this job 
    22          */ 
    23         public abstract List<? extends TaskInterface<?>> getTask(); 
     10        public int getUserId(); 
    2411         
    25         /** 
    26          *  
    27          * @param taskId 
    28          * @return task with specified taskId 
    29          * @throws NoSuchFieldException if task with taskId does not exist in this job 
    30          */ 
    31         public abstract TaskInterface<?> getTask(String taskId) throws NoSuchFieldException; 
    32          
    33         /** 
    34          *  
    35          * @return number of tasks in this job  
    36          */ 
    37         public abstract int getTaskCount(); 
    38          
    39         /** 
    40          *  
    41          * @return constant which represents current status of this job 
    42          */ 
    4312        public int getStatus(); 
    4413         
    4514        public void setStatus(int status) throws Exception; 
    46          
     15 
    4716        public boolean isFinished(); 
    48          
    49         public int getUserID(); 
    50          
     17 
    5118        public boolean isRegistered(); 
    5219 
Note: See TracChangeset for help on using the changeset viewer.