Ignore:
Timestamp:
06/03/14 15:12:11 (11 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/ExecTask.java

    r1207 r1362  
    11package dcworms.schedframe.scheduling; 
    22 
    3 import java.util.List; 
     3import java.util.LinkedList; 
    44 
     5import schedframe.scheduling.ExecutionHistoryItem; 
     6import schedframe.scheduling.ResourceHistoryItem; 
    57import schedframe.scheduling.tasks.TaskInterface; 
    68import schedframe.scheduling.tasks.phases.ResourceConsumption; 
    7 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 
     9import schedframe.scheduling.tasks.phases.ExecutionProfile; 
    810import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    911 
     
    1214        public boolean expectSpecificResource(ResourceParameterName resourceName);       
    1315        public Object getExpectedSpecificResource(ResourceParameterName resourceName); 
    14  
    15         public void trackResource(String resName); 
    16         public List<String> getVisitedResources(); 
    1716         
    18         public ResourceConsumptionProfile getResourceConsumptionProfile(); 
     17        public LinkedList<ExecutionHistoryItem> getExecHistory(); 
     18        public LinkedList<ResourceHistoryItem> getAllocatedResources(); 
     19         
     20        public ExecutionProfile getResourceConsumptionProfile(); 
    1921        public ResourceConsumption getCurrentResourceConsumption(); 
     22         
     23    public String getSchedulerName(); 
    2024} 
  • DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java

    r1315 r1362  
    55import gridsim.dcworms.DCWormsTags; 
    66 
    7 import java.util.ArrayList; 
    87import java.util.HashMap; 
    98import java.util.LinkedList; 
     
    1110import java.util.Map; 
    1211 
    13 import org.apache.commons.lang.ArrayUtils; 
    1412import org.joda.time.DateTime; 
    1513import org.joda.time.DateTimeUtilsExt; 
     
    2523import schedframe.resources.units.ProcessingElements; 
    2624import schedframe.resources.units.StandardResourceUnitName; 
     25import schedframe.scheduling.ExecutionHistoryItem; 
    2726import schedframe.scheduling.ResourceHistoryItem; 
    28 import schedframe.scheduling.UsedResourcesList; 
    2927import schedframe.scheduling.WorkloadUnitHandler; 
    3028import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
     
    3331import schedframe.scheduling.tasks.Task; 
    3432import schedframe.scheduling.tasks.phases.ResourceConsumption; 
    35 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 
     33import schedframe.scheduling.tasks.phases.ExecutionProfile; 
    3634import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    3735 
     
    5351         
    5452        protected int estimatedDuration; 
    55         //TO DO remove and benefit from visitedResources 
    5653        protected String schedName; 
    57         protected UsedResourcesList usedResources; 
    58         //TO DO consider removing 
    59         protected List<String> visitedResources; 
    6054 
    6155        protected double submissionTime; 
    6256    protected double arrivalTime; 
    63         protected double execStartTime ; 
     57        protected double execStartTime; 
    6458    protected double totalCompletionTime;  
    6559        protected double finishTime;  
    6660         
    67         private ResourceConsumptionProfile resourceConsumptionProfile; 
     61    private boolean firstTime = true; 
     62        protected double execStartTimeFirst; 
     63         
     64        protected ExecutionProfile execProfile; 
     65         
     66        protected LinkedList<ExecutionHistoryItem> execHistory;; 
     67        protected LinkedList<ResourceHistoryItem> allocatedResources; 
    6868         
    6969        public Executable(Task t){ 
    7070                this.task = t; 
    7171                this.status = DCWormsTags.CREATED; 
    72                  
    73                 this.usedResources = new UsedResourcesList(); 
    74                 this.visitedResources = new ArrayList<String>(); 
     72 
     73                this.allocatedResources = new LinkedList<ResourceHistoryItem>(); 
     74                this.execHistory = new LinkedList<ExecutionHistoryItem>(); 
    7575                init(); 
    7676        } 
     
    8181                this.processesSetId = procesesSet.getId();  
    8282                 
    83                 this.usedResources = new UsedResourcesList(); 
    84                 this.visitedResources = new ArrayList<String>(); 
     83                this.allocatedResources = new LinkedList<ResourceHistoryItem>(); 
     84                this.execHistory = new LinkedList<ExecutionHistoryItem>(); 
    8585                init(); 
    8686        } 
     
    8888        protected void init() { 
    8989                double currentTime = DateTimeUtilsExt.currentTimeMillis() / 1000; 
     90                this.arrivalTime = currentTime; 
    9091                this.submissionTime =  currentTime; 
    9192        this.totalCompletionTime = 0.0; 
     
    168169        } 
    169170 
    170         if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags.NEW_EXEC_PHASE) { 
     171        if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags.FAILED) { 
    171172            throw new Exception("Executable.setStatuts() : Error - " + 
    172                     "Invalid integer range for Execiutable status."); 
     173                    "Invalid integer range for Executable status."); 
    173174        } 
    174175 
     
    189190        } 
    190191                 
    191                 if(newStatus == DCWormsTags.SUBMITTED){ 
     192                /*if(newStatus == DCWormsTags.SUBMITTED){ 
    192193                         arrivalTime = GridSim.clock(); 
    193                 } 
    194  
    195         if (prevStatus == DCWormsTags.INEXEC) { 
    196             if (status == DCWormsTags.CANCELED || status == DCWormsTags.PAUSED || 
    197                 status == DCWormsTags.SUCCESS) { 
     194                }*/ 
     195 
     196        if ((prevStatus == DCWormsTags.INEXEC) && (status == DCWormsTags.CANCELED || status == DCWormsTags.PAUSED || 
     197                status == DCWormsTags.SUCCESS)){ 
    198198                totalCompletionTime += (currentTime -  execStartTime); 
     199                execStartTime = execStartTimeFirst; 
     200        } 
     201 
     202        /*if (prevStatus == DCWormsTags.RESUMED && status == DCWormsTags.SUCCESS) { 
     203            totalCompletionTime += (currentTime -  execStartTime); 
     204        }*/ 
     205 
     206        if(prevStatus == DCWormsTags.PAUSED && status == DCWormsTags.RESUMED){ 
     207                 
     208        } 
     209        if (status == DCWormsTags.INEXEC) { 
     210                 
     211                execStartTime = currentTime; 
     212            if (firstTime){ 
     213                execStartTimeFirst = currentTime; 
     214                firstTime = false; 
    199215            } 
    200216        } 
    201  
    202         if (prevStatus == DCWormsTags.RESUMED && status == DCWormsTags.SUCCESS) { 
    203             totalCompletionTime += (currentTime -  execStartTime); 
    204         } 
    205  
    206         if (status == DCWormsTags.INEXEC || 
    207             (prevStatus == DCWormsTags.PAUSED && status == DCWormsTags.RESUMED) ) { 
    208                 execStartTime = currentTime; 
    209                  
    210                 ProcessingElements pes = (ProcessingElements) getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
    211                 for (ComputingResource resource : pes) { 
    212  
    213                                 LinkedList<ComputingResource> toExamine = new LinkedList<ComputingResource>(); 
    214                                 toExamine.push(resource); 
    215  
    216                                 while (!toExamine.isEmpty()) { 
    217                                         ComputingResource compResource = toExamine.pop(); 
    218                                         List<ComputingResource> resources = compResource.getChildren(); 
    219                                         int numberOfRes = resources.size(); 
    220                                         for (int i = 0; i < numberOfRes; i++) { 
    221                                                 ComputingResource resourceChild = resources.get(i); 
    222                                                 trackResource(resourceChild.getFullName()); 
    223                                                 toExamine.addLast(resourceChild); 
    224                                         } 
    225                                 } 
    226  
    227                          
    228                         trackResource(resource.getFullName()); 
    229                          
    230                         ComputingResource parent = resource.getParent(); 
    231                                 List<String> visitedResource = getVisitedResources(); 
    232                                 String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]); 
    233                         while (parent != null && !ArrayUtils.contains(visitedResourcesArray, parent.getFullName())) { 
    234                                 trackResource(parent.getFullName()); 
    235                                 parent = parent.getParent(); 
    236                         } 
    237                 } 
    238         } 
    239217         
    240         if(status == DCWormsTags.NEW_EXEC_PHASE){ 
    241                 if(prevStatus == DCWormsTags.INEXEC){ 
    242                         status = DCWormsTags.INEXEC; 
    243                         setCompletionPercentage(0); 
    244                         resourceConsumptionProfile.setCurrentPhase(resourceConsumptionProfile.getCurrentPhase() + 1); 
    245                          
    246                         DateTime currentDateTime = new DateTime(); 
    247                          
    248                         if(getUsedResources().getLast().getTimeStamp().getMillis() == currentDateTime.getMillis()){ 
    249                                 return; 
    250                         } 
    251                         ResourceHistoryItem resHistItem = new ResourceHistoryItem(getUsedResources().getLast().getResourceUnits(), currentDateTime); 
    252                         resHistItem.setCompletionPercentage(0); 
    253                         addUsedResources(resHistItem); 
    254                 } 
    255         } 
     218        if(status == DCWormsTags.NEW_EXEC_PHASE && prevStatus == DCWormsTags.INEXEC){ 
     219                status = DCWormsTags.INEXEC; 
     220                completionPercentage = 0; 
     221                execProfile.setCurrentPhase(execProfile.getCurrentPhase() + 1); 
     222        } 
     223 
    256224        } 
    257225         
     
    295263        } 
    296264 
    297         public void addUsedResources(ResourceHistoryItem usedResources){ 
    298                 this.usedResources.add(usedResources); 
    299         } 
    300          
    301         public UsedResourcesList getUsedResources(){ 
    302                 return this.usedResources; 
    303         } 
    304          
    305265    public void setSchedulerName(int resourceId){ 
    306266        this.schedName = GridSim.getEntityName(resourceId); 
    307267    } 
     268     
     269    public void setSchedulerName(String resourceId){ 
     270        this.schedName = resourceId; 
     271    } 
    308272 
    309273    public String getSchedulerName(){ 
     
    326290                task.register(jobRegistry); 
    327291        } 
    328          
    329         public void trackResource(String resName){ 
    330                 visitedResources.add(resName); 
    331         } 
    332          
    333         public List<String> getVisitedResources(){ 
    334                 return visitedResources; 
    335         } 
    336          
     292 
    337293        public ReadableDuration getExpectedDuration() throws NoSuchFieldException { 
    338294                return task.getExpectedDuration(); 
     
    410366        }*/ 
    411367         
    412         public ResourceConsumptionProfile getResourceConsumptionProfile(){ 
    413                 return resourceConsumptionProfile; 
     368        public ExecutionProfile getResourceConsumptionProfile(){ 
     369                return execProfile; 
    414370        } 
    415371 
    416372        public ResourceConsumption getCurrentResourceConsumption(){ 
    417                 return resourceConsumptionProfile.getCurrentResourceConsumption(); 
     373                return execProfile.getCurrentResourceConsumption(); 
    418374        } 
    419375         
     
    437393                        } 
    438394                        resourceConsumptionList.add(resConsumption); 
    439                 }else{ 
     395                } else { 
    440396                        boolean found = false; 
    441397                        if(resourceType != null){ 
     
    473429                 
    474430                usefulWork = (usefulWork != -1) ? usefulWork : this.getLength(); 
    475                 this.resourceConsumptionProfile = new ResourceConsumptionProfile(resourceConsumptionList); 
    476                 this.resourceConsumptionProfile.setUsefulWork(usefulWork); 
     431                this.execProfile = new ExecutionProfile(resourceConsumptionList); 
     432                this.execProfile.setUsefulWork(usefulWork); 
    477433 
    478434        } 
     
    480436        private boolean loadResourceConsumptionProfile(){ 
    481437 
    482                 PEUnit peUnit = (PEUnit)getUsedResources().getLast().getResourceUnits() 
     438                PEUnit peUnit = (PEUnit)getAllocatedResources().getLast().getResourceUnits() 
    483439                                .get(StandardResourceUnitName.PE); 
    484440                if(peUnit instanceof ProcessingElements){ 
     
    513469                 
    514470        } 
     471 
     472        public LinkedList<ExecutionHistoryItem> getExecHistory() { 
     473                return execHistory; 
     474        } 
     475 
     476        public void addExecHistory(ExecutionHistoryItem execHistoryItem) { 
     477                this.execHistory.add(execHistoryItem); 
     478        } 
     479 
     480        public LinkedList<ResourceHistoryItem> getAllocatedResources() { 
     481                return allocatedResources; 
     482        } 
     483 
     484        public void addAllocatedResources(ResourceHistoryItem allocatedResourcesItem) { 
     485                this.allocatedResources.add(allocatedResourcesItem); 
     486        } 
    515487} 
Note: See TracChangeset for help on using the changeset viewer.