Ignore:
Timestamp:
10/09/12 13:58:06 (13 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/trunk/src/schedframe/scheduling
Files:
12 edited
1 moved

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/src/schedframe/scheduling/UsedResourcesList.java

    r477 r490  
    33import java.util.LinkedList; 
    44 
    5 public class UsedResourceList<E> extends LinkedList<E>{ 
     5public class UsedResourcesList extends LinkedList<ResourceHistoryItem>{ 
    66 
    77        /** 
  • DCWoRMS/trunk/src/schedframe/scheduling/WorkloadUnitHandler.java

    r481 r490  
    11package schedframe.scheduling; 
    22 
    3 import schedframe.scheduling.tasks.Job; 
     3import dcworms.schedframe.scheduling.ExecTask; 
     4import schedframe.scheduling.tasks.JobInterface; 
     5import schedframe.scheduling.tasks.TaskInterface; 
    46 
    5 import schedframe.scheduling.tasks.TaskInterface; 
    6 import gssim.schedframe.scheduling.ExecTask; 
    7  
    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); 
  • DCWoRMS/trunk/src/schedframe/scheduling/manager/resources/LocalResourceManager.java

    r477 r490  
    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/src/schedframe/scheduling/manager/tasks/JobRegistry.java

    r481 r490  
    11package schedframe.scheduling.manager.tasks; 
    22 
    3 import gssim.schedframe.scheduling.ExecTask; 
    43 
    54import java.util.List; 
     5 
     6import dcworms.schedframe.scheduling.ExecTask; 
    67 
    78import schedframe.ExecutablesList; 
  • DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/JobRegistryImpl.java

    r481 r490  
    22 
    33import gridsim.gssim.DCWormsTags; 
    4 import gssim.schedframe.scheduling.ExecTask; 
    54 
    65import java.util.ArrayList; 
     
    1211import org.qcg.broker.schemas.resreqs.ParentType; 
    1312import org.qcg.broker.schemas.resreqs.types.TaskStatesName; 
     13 
     14import dcworms.schedframe.scheduling.ExecTask; 
    1415 
    1516import qcg.shared.constants.BrokerConstants; 
     
    8283                synchronized (executables)  { 
    8384                        for (ExecTask task : executables) { 
    84                                 if (task.getJobId().compareTo(jobId) == 0 && task.getId().compareTo(taskId)==0) { 
     85                                if (task.getJobId().compareTo(jobId) == 0 && task.getId().compareTo(taskId) == 0) { 
    8586                                        return task; 
    8687                                } 
  • DCWoRMS/trunk/src/schedframe/scheduling/plugin/SchedulingPlugin.java

    r481 r490  
    33import schedframe.Plugin; 
    44import schedframe.events.scheduling.SchedulingEvent; 
     5import schedframe.scheduling.TaskList; 
    56import schedframe.scheduling.TaskListImpl; 
    67import schedframe.scheduling.manager.resources.ResourceManager; 
     
    1213public interface SchedulingPlugin extends Plugin{ 
    1314 
    14         public int placeTasksInQueues(TaskListImpl newTasks, 
     15        public int placeTasksInQueues(TaskList newTasks, 
    1516                        TaskQueueList queues,  
    1617                        ResourceManager resourceManager, ModuleList modules); 
  • DCWoRMS/trunk/src/schedframe/scheduling/plugin/estimation/ExecutionTimeEstimationPlugin.java

    r477 r490  
    11package schedframe.scheduling.plugin.estimation; 
    22 
    3 import gssim.schedframe.scheduling.ExecTask; 
    43 
    54import java.util.Map; 
     5 
     6import dcworms.schedframe.scheduling.ExecTask; 
    67 
    78import schedframe.Plugin; 
  • DCWoRMS/trunk/src/schedframe/scheduling/policy/AbstractManagementSystem.java

    r481 r490  
    77import org.apache.commons.logging.LogFactory; 
    88import org.joda.time.DateTimeUtilsExt; 
     9 
     10import dcworms.schedframe.scheduling.ExecTask; 
     11import dcworms.schedframe.scheduling.Executable; 
     12import dcworms.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
    913 
    1014import schedframe.PluginConfiguration; 
     
    3438import gridsim.IO_data; 
    3539import gridsim.gssim.DCWormsTags; 
    36 import gssim.schedframe.scheduling.ExecTask; 
    37 import gssim.schedframe.scheduling.Executable; 
    38 import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
    3940 
    4041public abstract class AbstractManagementSystem { 
     
    144145                        return; 
    145146                } 
    146                 //Executable exec = (Executable) wu; 
    147147                removeFromQueue(task); 
    148148                scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, task);        
     
    199199        } 
    200200         
    201         protected boolean removeFromQueue(WorkloadUnit wu) { 
     201        protected boolean removeFromQueue(TaskInterface<?> task) { 
    202202                for(TaskQueue queue : queues){ 
    203                         if(queue.contains(wu)){ 
    204                                 queue.remove(wu); 
     203                        if(queue.contains(task)){ 
     204                                queue.remove(task); 
    205205                                return true; 
    206206                        } 
  • DCWoRMS/trunk/src/schedframe/scheduling/policy/global/GlobalManagementSystem.java

    r481 r490  
    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 import schedframe.events.scheduling.SchedulingEvent; 
    1517import schedframe.events.scheduling.TaskArrivedEvent; 
    1618import schedframe.events.scheduling.TimerEvent; 
     19import schedframe.scheduling.TaskListImpl; 
    1720import schedframe.scheduling.WorkloadUnitHandler; 
    18 import schedframe.scheduling.TaskListImpl; 
    1921import schedframe.scheduling.plan.AllocationInterface; 
    2022import schedframe.scheduling.plan.ScheduledTaskInterface; 
     
    3537import gridsim.IO_data; 
    3638import gridsim.gssim.DCWormsTags; 
    37 import gssim.schedframe.scheduling.ExecTask; 
    38 import gssim.schedframe.scheduling.Executable; 
    3939 
    4040public class GlobalManagementSystem extends AbstractManagementSystem { 
     
    8080                 
    8181                registerWorkloadUnit(wu); 
    82                 /*Job job = (Job) wu; 
    83                 jobRegistry.addJob(job); 
    84  
    85                 if (log.isInfoEnabled()) 
    86                         log.info("Received job " + job.getId() + " at " + new DateTime(DateTimeUtilsExt.currentTimeMillis())); 
    87  
    88                 List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 
    89                 jobsList.add(job); 
    90                 WorkloadUnitList readyWorkloadUnits = new WorkloadUnitList(); 
    91                 readyWorkloadUnits.addAll(jobRegistry.getReadyTasks(jobsList)); 
    92                 schedulingPlugin.placeJobsInQueues(readyWorkloadUnits, queues, getResourceManager(), moduleList); 
    93  
    94                 schedule(new TaskArrivedEvent());*/ 
    9582 
    9683        } 
     
    10491         
    10592 
    106         protected void scheduleAvaialbleTasks(Job job){ 
     93        protected void schedule(JobInterface<?> job){ 
    10794                List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 
    10895                jobsList.add(job); 
     
    11198                 
    11299                schedulingPlugin.placeTasksInQueues(readyTasks, queues, getResourceManager(), moduleList); 
    113                 schedule(new TaskArrivedEvent()); 
    114         } 
    115          
    116         protected void schedule(SchedulingEvent schedulingEvent) { 
    117  
    118100                SchedulingPlanInterface<?> decision = schedulingPlugin.schedule( 
    119                                 schedulingEvent, queues, getJobRegistry(),  getResourceManager(), moduleList); 
     101                                new TaskArrivedEvent(), queues, getJobRegistry(),  getResourceManager(), moduleList); 
    120102                if (decision != null) 
    121103                        executeSchedulingPlan(decision); 
    122104        } 
    123          
     105 
    124106        public void notifyReturnedWorkloadUnit(WorkloadUnit wu) { 
    125107                Executable exec = (Executable) wu; 
     
    133115                try { 
    134116                        Job job = jobRegistry.getJob(exec.getJobId()); 
    135                         /*Task task = job.getTask(exec.getTaskId()); 
     117                        Task task = job.getTask(exec.getTaskId()); 
    136118                        if(exec.getProcessesId() == null){ 
    137119                                try { 
    138120                                        task.setStatus(exec.getStatus()); 
    139121                                } catch (Exception e) { 
    140                                         // TODO Auto-generated catch block 
    141                                         e.printStackTrace(); 
     122 
    142123                                } 
    143124                        } else { 
     
    150131                                        } 
    151132                                } 
    152                         }*/ 
     133                        } 
    153134                         
    154135                        if(job.isFinished()){ 
     
    156137                        } 
    157138                        else { 
    158                                 scheduleAvaialbleTasks(job); 
    159                                 /*List<JobInterface<?>> jobs = new ArrayList<JobInterface<?>>(); 
    160                                 jobs.add(jobRegistry.getJobInfo(job.getId())); 
    161                                 WorkloadUnitList readyWorkloadUnits = new WorkloadUnitList(); 
    162                                 readyWorkloadUnits.addAll(jobRegistry.getReadyTasks(jobs)); 
    163                                 schedulingPlugin.placeJobsInQueues(readyWorkloadUnits, queues, 
    164                                                 getResourceManager(), moduleList); 
    165                                 schedule(new TaskArrivedEvent());*/ 
     139                                schedule(job); 
    166140                        } 
    167141                         
     
    269243                IO_data data = new IO_data(task, 0, resID); 
    270244                scheduler.send(scheduler.getOutputPort(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, data);   
    271                  
    272                 //scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, job);                       
     245                //scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, job);       
     246                 
    273247                if(log.isDebugEnabled()) 
    274248                        log.debug("Submitted job " + task.getId() + " to " + providerName); 
     
    278252        class GlobalWorkloadUnitHandler implements  WorkloadUnitHandler{ 
    279253 
    280                 public void handleJob(Job job){ 
    281  
     254                public void handleJob(JobInterface<?> job){ 
    282255                        if (log.isInfoEnabled()) 
    283256                                log.info("Received job " + job.getId() + " at " + new DateTime(DateTimeUtilsExt.currentTimeMillis())); 
    284257 
    285258                        jobRegistry.addJob(job); 
    286                         scheduleAvaialbleTasks(job); 
     259                        schedule(job); 
    287260                } 
    288261                 
     
    294267                        throw new RuntimeException("Not implemented since it isn't expected that tasks are send directly to the global scheduler."); 
    295268                } 
    296  
    297269        } 
    298270 
  • DCWoRMS/trunk/src/schedframe/scheduling/policy/local/LocalManagementSystem.java

    r481 r490  
    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; 
     
    79import gridsim.gssim.DCWormsTags; 
    810import gridsim.gssim.filter.ExecTaskFilter; 
    9 import gssim.schedframe.scheduling.ExecTask; 
    10 import gssim.schedframe.scheduling.Executable; 
    1111 
    1212import java.util.ArrayList; 
     
    4141import schedframe.scheduling.ResourceHistoryItem; 
    4242import schedframe.scheduling.Scheduler; 
     43import schedframe.scheduling.TaskList; 
    4344import schedframe.scheduling.TaskListImpl; 
    44 import schedframe.scheduling.UsedResourceList; 
     45import schedframe.scheduling.UsedResourcesList; 
    4546import schedframe.scheduling.WorkloadUnitHandler; 
    4647import schedframe.scheduling.manager.resources.LocalResourceManager; 
     
    7879 
    7980                super(providerId, entityName, execTimeEstimationPlugin, queues); 
    80  
    81                 //schedulingPlugin = (LocalSchedulingPlugin) InstanceFactory.createInstance(schedulingPluginClassName, LocalSchedulingPlugin.class); 
    8281                 
    8382                if (schedPlugin == null) { 
     
    8584                } 
    8685                this.schedulingPlugin =  schedPlugin; 
    87                 accTotalLoad = new Accumulator(); 
    88                 moduleList = new ModuleListImpl(1); 
    89  
     86                this.moduleList = new ModuleListImpl(1); 
     87                 
     88                this.accTotalLoad = new Accumulator(); 
    9089        } 
    9190 
    9291        public void init(Scheduler sched, ManagedResources managedResources) { 
    9392                super.init(sched, managedResources); 
    94                 //scheduler = sched; 
    95                 //resourceManager = ResourceManagerFactory.createResourceManager(scheduler); 
    9693                double load = 0; 
    9794                accTotalLoad.add(load); 
     
    115112                        } 
    116113                        sendTimerEvent(); 
    117  
    118114                        break; 
    119115 
    120116                case DCWormsTags.TASK_READY_FOR_EXECUTION: 
    121117                         
    122                         ExecTask data = (ExecTask) ev.get_data(); 
    123                         try { 
    124                                 data.setStatus(DCWormsTags.READY); 
     118                        ExecTask execTask = (ExecTask) ev.get_data(); 
     119                        try { 
     120                                execTask.setStatus(DCWormsTags.READY); 
    125121                                if (pluginSupportsEvent(tag)) { 
    126                                         SchedulingEvent event = new StartTaskExecutionEvent(data.getJobId(), data.getId()); 
     122                                        SchedulingEvent event = new StartTaskExecutionEvent(execTask.getJobId(), execTask.getId()); 
    127123                                        SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event, 
    128124                                                        queues,  getJobRegistry(), getResourceManager(), moduleList); 
     
    136132                case DCWormsTags.TASK_EXECUTION_FINISHED: 
    137133                        obj = ev.get_data(); 
    138                         ExecTask exec = (ExecTask) obj; 
    139                         if (exec.getStatus() == DCWormsTags.INEXEC) { 
    140                                 finalizeExecutable(exec); 
    141  
    142                                 sendFinishedWorkloadUnit(exec); 
    143                                 //task.setGridletStatus(Gridlet.SUCCESS); 
    144                                 //task.finalizeGridlet(); 
    145                                 log.debug(exec.getJobId() + "_" + exec.getId() + " finished execution on " + new DateTime()); 
     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()); 
    146140                                log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
    147                                 /*UsedResourceList<ResourceHistoryItem> lastUsedList = task.getUsedResources(); 
    148                                 Map<ResourceUnitName, AbstractResourceUnit> lastUsed = lastUsedList.getLast() 
    149                                                 .getResourceUnits(); 
    150                                 getAllocationManager().freeResources(lastUsed); 
    151                                 ProcessingElements pes = (ProcessingElements) lastUsed.get(StandardResourceUnitName.PROCESSINGELEMENTS); 
    152                                 for (ComputingResource resource : pes) { 
    153                                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, task)); 
     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); 
    154146                                } 
    155                                 SubTaskFilter filter = new SubTaskFilter(task.getGridletID(), GssimTags.TASK_REQUESTED_TIME_EXPIRED); 
    156                                 scheduler.sim_cancel(filter, null); 
    157                                 super.sendFinishJob((Executable) task.getGridlet());*/ 
    158                         } 
     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; 
    159158                        if (pluginSupportsEvent(tag)) { 
    160                                 SchedulingEvent event = new TaskFinishedEvent(exec.getJobId(), exec.getId()); 
     159                                SchedulingEvent event = new TaskRequestedTimeExpiredEvent(execTask.getJobId(), execTask.getId()); 
    161160                                SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 
    162161                                                queues, getJobRegistry(), getResourceManager(), moduleList); 
    163162                                executeSchedulingPlan(decision); 
    164163                        } 
    165                         Job job = jobRegistry.getJob(exec.getJobId()); 
    166                         if(!job.isFinished()){ 
    167                                 getWorkloadUnitHandler().handleJob(job); 
    168                         } 
    169  
    170164                        break; 
    171                 case DCWormsTags.TASK_REQUESTED_TIME_EXPIRED: 
    172                         obj = ev.get_data(); 
    173                         exec = (Executable) obj; 
    174                         if (pluginSupportsEvent(tag)) { 
    175                                 SchedulingEvent event = new TaskRequestedTimeExpiredEvent(exec.getJobId(), exec.getId()); 
    176                                 SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 
    177                                                 queues, getJobRegistry(), getResourceManager(), moduleList); 
    178                                 executeSchedulingPlan(decision); 
    179                         } 
    180  
    181                         break; 
     165                         
    182166                case DCWormsTags.UPDATE: 
    183167                        updateProcessingTimes(ev); 
     
    185169                } 
    186170        } 
    187          
    188171 
    189172        public void notifyReturnedWorkloadUnit(WorkloadUnit wu) { 
     
    223206                                } else { 
    224207                                        ExecTask exec = (ExecTask) task; 
    225                                         executeTask(exec, chooseResourcesForExecution(allocation.getProviderName(), (ExecTask)task)); 
     208                                        executeTask(exec, chooseResourcesForExecution(allocation.getProviderName(), exec)); 
    226209                                } 
    227210                        } 
     
    237220                        return; 
    238221                removeFromQueue(task); 
    239                 //double completionPercentage = (submittedTask.getLength() - submittedTask.getRemainingGridletLength())/submittedTask.getLength(); 
     222 
    240223                SchedulingEvent event = new SchedulingEvent(SchedulingEventType.START_TASK_EXECUTION); 
    241224                int time = Double.valueOf( 
     
    251234                ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 
    252235                exec.addUsedResources(resHistItem); 
    253  
    254                 scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, 
    255                                 exec); 
     236                try { 
     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); 
    256243 
    257244                try { 
     
    262249                        scheduler.sendInternal(t, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec); 
    263250                } 
    264                  
    265                 try { 
    266                         exec.setStatus(DCWormsTags.INEXEC); 
    267                 } catch (Exception e1) { 
    268                         // TODO Auto-generated catch block 
    269                         e1.printStackTrace(); 
    270                 } 
     251 
    271252                log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
    272253                 
    273254                PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE); 
    274                 if(peUnit instanceof ProcessingElements){ 
     255                 
     256                notifyComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec); 
     257                 
     258                /*if(peUnit instanceof ProcessingElements){ 
    275259                        ProcessingElements pes = (ProcessingElements) peUnit; 
    276260                        for (ComputingResource resource : pes) { 
    277                                 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
     261                                resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, exec)); 
    278262                        } 
    279263                } else { 
     
    282266                                resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
    283267                        } catch (ResourceException e) { 
    284                                  
    285                         } 
    286                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
    287                 } 
    288                 /*ProcessingElements pes = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE); 
    289                 for (ComputingResource resource : pes) { 
    290                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, submittedTask)); 
    291                 }*/ 
     268                                return; 
     269                        } 
     270                        resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, exec)); 
     271                } 
     272*/ 
    292273 
    293274                /*for(ExecTaskInterface etask : jobRegistry.getRunningTasks()){ 
     
    301282                 
    302283                Executable exec = (Executable)execTask; 
    303                 try { 
    304                         exec.setStatus(DCWormsTags.SUCCESS); 
    305                 } catch (Exception e1) { 
    306                         // TODO Auto-generated catch block 
    307                         e1.printStackTrace(); 
    308                 } 
    309284                exec.finalizeExecutable(); 
    310                 UsedResourceList<ResourceHistoryItem> lastUsedList = exec.getUsedResources(); 
    311                 Map<ResourceUnitName, ResourceUnit> lastUsed = lastUsedList.getLast() 
    312                                 .getResourceUnits(); 
    313                 getAllocationManager().freeResources(lastUsed); 
    314                  
    315                 PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 
    316                 if(peUnit instanceof ProcessingElements){ 
    317                         ProcessingElements pes = (ProcessingElements) peUnit; 
    318                         for (ComputingResource resource : pes) { 
    319                                 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
    320                         } 
    321                 } else { 
    322                         ComputingResource resource = null; 
    323                         try { 
    324                                 resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
    325                         } catch (ResourceException e) { 
    326                                  
    327                         } 
    328                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
    329                 } 
    330                 /*ProcessingElements pes = (ProcessingElements) lastUsed.get(StandardResourceUnitName.PE); 
    331                 for (ComputingResource resource : pes) { 
    332                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, subTask)); 
    333                 }*/ 
     285                 
    334286                ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_REQUESTED_TIME_EXPIRED); 
    335287                scheduler.sim_cancel(filter, null); 
    336288                 
    337  
     289                Task task; 
    338290                Job job = jobRegistry.getJob(exec.getJobId()); 
    339  
    340                 Task task = null; 
    341291                try { 
    342292                        task = job.getTask(exec.getTaskId()); 
    343293                } catch (NoSuchFieldException e) { 
    344                         e.printStackTrace(); 
     294                        return; 
    345295                } 
    346296                if(exec.getProcessesId() == null){ 
     
    360310                        } 
    361311                } 
     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 
    362335                //sendFinishedWorkloadUnit(executable); 
    363336        } 
     
    374347                        ExecTask task = iter.next(); 
    375348                        Executable exec = (Executable)task; 
    376                         UsedResourceList<ResourceHistoryItem> usedResourcesList = exec.getUsedResources(); 
    377                         ResourceUnit unit = usedResourcesList.getLast().getResourceUnits() 
     349                        UsedResourcesList usedResourcesList = exec.getUsedResources(); 
     350                        PEUnit peUnit = (PEUnit)usedResourcesList.getLast().getResourceUnits() 
    378351                                        .get(StandardResourceUnitName.PE); 
    379352 
    380                         double load = getMIShare(timeSpan, (PEUnit) unit); 
     353                        double load = getMIShare(timeSpan, peUnit); 
    381354                        exec.setCompletionPercentage(100 * timeSpan/exec.getEstimatedDuration()); 
    382355                        addTotalLoad(load); 
    383356                } 
    384357        } 
    385  
     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         
    386376        private double getMIShare(double timeSpan, PEUnit pes) { 
    387377                double localLoad; 
     
    402392        protected void updateProcessingTimes(Sim_event ev) { 
    403393                updateProcessingProgress(); 
    404                 for (ExecTask task : jobRegistry.getRunningTasks()) { 
    405                         Executable exec = (Executable)task; 
     394                for (ExecTask execTask : jobRegistry.getRunningTasks()) { 
     395                        Executable exec = (Executable)execTask; 
    406396                        List<String> visitedResource = exec.getVisitedResources(); 
    407397                        String originResource = ev.get_data().toString(); 
     
    411401                         
    412402                        Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getUsedResources().getLast().getResourceUnits(); 
    413                         //double completionPercentage = (task.getLength() - subTask.getRemainingGridletLength())/task.getLength(); 
    414403                        double time = execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED),  
    415                                         task, choosenResources, exec.getCompletionPercentage()); 
    416  
    417                         /*if(!subTask.getVisitedResources().contains(ev.get_data().toString())) { 
    418                                 continue; 
    419                         }*/ 
     404                                        execTask, choosenResources, exec.getCompletionPercentage()); 
     405 
    420406                        //check if the new estimated end time is equal to the previous one; if yes the continue without update 
    421407                        if( DoubleMath.subtract((exec.getExecStartTime() + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000 + time)) == 0.0){ 
     
    424410                        ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_FINISHED); 
    425411                        scheduler.sim_cancel(filter, null); 
    426                         scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, task); 
    427  
     412                        scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 
    428413                } 
    429414        }        
     
    443428                                numberOfPE = numberOfPE + resUnit.getAmount(); 
    444429                        } 
    445                         //numberOfPE = getResourceManager().getPE().size(); 
    446430                } catch (Exception e) { 
    447431                        numberOfPE = 1; 
     
    464448                        ExecTask task) { 
    465449 
     450                Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 
    466451                ResourceManager resourceManager = this.resourceManager; 
    467452                if(resourceName != null){ 
     
    472457                                return null; 
    473458                        } 
    474  
    475459                        resourceManager = new LocalResourceManager(resource); 
    476460                } 
    477                 Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 
    478  
    479461 
    480462                int cpuRequest; 
     
    485467                } 
    486468 
    487                 //PEUnit processingUnits = null; 
    488469                if (cpuRequest != 0) { 
    489470                         
     
    494475                                return null; 
    495476                        } 
     477                         
    496478                        List<ResourceUnit> choosenPEUnits = new ArrayList<ResourceUnit>(); 
    497  
    498479                        for (int i = 0; i < availableUnits.size() && cpuRequest > 0; i++) { 
    499480                                PEUnit peUnit = (PEUnit) availableUnits .get(i); 
     
    508489                                return null; 
    509490                        } 
    510  
    511491                        map.put(StandardResourceUnitName.PE, choosenPEUnits.get(0)); 
    512492                } 
     
    529509        class LocalWorkloadUnitHandler implements WorkloadUnitHandler{ 
    530510                 
    531                 public void handleJob(Job job){ 
     511                public void handleJob(JobInterface<?> job){ 
    532512 
    533513                        if (log.isInfoEnabled()) 
     
    536516                        List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 
    537517                        jobsList.add(job); 
    538                         TaskListImpl readyTasks = new TaskListImpl(); 
     518                        TaskListImpl availableTasks = new TaskListImpl(); 
    539519                        for(Task task: jobRegistry.getAvailableTasks(jobsList)){ 
    540520                                task.setStatus((int)BrokerConstants.TASK_STATUS_QUEUED); 
    541                                 readyTasks.add(task); 
    542                         } 
    543  
    544                         for(WorkloadUnit e:readyTasks){  
    545                                 registerWorkloadUnit(e); 
    546                         } 
    547                 } 
    548                  
    549                 public void handleTask(TaskInterface<?> ti){ 
    550                         Task task = (Task)ti; 
     521                                availableTasks.add(task); 
     522                        } 
     523 
     524                        for(TaskInterface<?> task: availableTasks){      
     525                                registerWorkloadUnit(task); 
     526                        } 
     527                } 
     528                 
     529                public void handleTask(TaskInterface<?> t){ 
     530                        Task task = (Task)t; 
    551531                        List<AbstractProcesses> processes = task.getProcesses(); 
    552532 
     
    564544                 
    565545                public void handleExecutable(ExecTask task){ 
     546                         
    566547                        Executable exec = (Executable) task; 
    567  
    568                         // int cost = 
    569                         // this.resourceManager.getResourceCharacteristic().getResUnits() != 
    570                         // null ? 
    571                         // this.resourceManager.getResourceCharacteristic().getResUnits().get(ResourceParameterName.COST).getAmount() 
    572                         // : 1; 
    573  
    574                         exec.visitResource(scheduler.get_name()); 
     548                        jobRegistry.addExecTask(exec); 
     549                         
     550                        exec.trackResource(scheduler.get_name()); 
    575551                        Scheduler parentScheduler = scheduler.getParent(); 
    576                         while (parentScheduler != null && !exec.getVisitedResources().contains(parentScheduler.get_name())) { 
    577                                 exec.visitResource(parentScheduler.get_name()); 
     552                        List<String> visitedResource = exec.getVisitedResources(); 
     553                        String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]); 
     554                        while (parentScheduler != null && !ArrayUtils.contains(visitedResourcesArray, parentScheduler.get_name())) { 
     555                                exec.trackResource(parentScheduler.get_name()); 
    578556                                parentScheduler = parentScheduler.getParent(); 
    579557                        } 
    580                          
    581558                        exec.setSchedulerName(scheduler.get_id()); 
    582                         jobRegistry.addExecTask(exec); 
    583                         TaskListImpl newTasks = new TaskListImpl(); 
     559                         
     560                        TaskList newTasks = new TaskListImpl(); 
    584561                        newTasks.add(exec); 
    585562                 
  • DCWoRMS/trunk/src/schedframe/scheduling/queue/TaskQueue.java

    r481 r490  
    22 
    33import gridsim.gssim.DCWormsTags; 
    4 import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
    54 
    65import org.joda.time.DateTime; 
     6 
     7import dcworms.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
    78 
    89import schedframe.scheduling.tasks.TaskInterface; 
  • DCWoRMS/trunk/src/schedframe/scheduling/tasks/Job.java

    r481 r490  
    203203                 
    204204                List<Task> readyTasks = new ArrayList<Task>(); 
    205  
    206205                int size = tasks.size(); 
     206                 
    207207                for(int i = 0; i < size; i++){ 
    208208                        int parCnt; 
     
    215215                        } catch(Exception e){ 
    216216                                parCnt = 0; 
    217                                 //e.printStackTrace(); 
    218                         } 
    219                         if(parCnt == 0) 
    220                         { 
     217                        } 
     218                        if(parCnt == 0) { 
    221219                                readyTasks.add(task); 
    222220                        } 
    223                         else 
    224                         { 
     221                        else { 
    225222                                for(int j = 0; j < parCnt; j++){ 
    226223                                        ParentType par = task.getDescription().getWorkflow().getParent(j); 
  • DCWoRMS/trunk/src/schedframe/scheduling/tasks/Task.java

    r481 r490  
    7878                this.brokerSubmitTime = null; 
    7979                this.duration = null; 
    80         //      this.gridletID_ = (getJobId() + "_" + getId()).hashCode(); 
    8180                prepareTopology(); 
    8281        } 
     
    8988                this.brokerSubmitTime = null; 
    9089                this.duration = null; 
    91         //      this.gridletID_ = (getJobId() + getId()).hashCode(); 
    9290                prepareTopology(); 
    9391        } 
Note: See TracChangeset for help on using the changeset viewer.