Ignore:
Timestamp:
07/30/14 12:25:00 (11 years ago)
Author:
wojtekp
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java

    r1415 r1423  
    44import java.util.HashMap; 
    55import java.util.Iterator; 
     6import java.util.LinkedHashSet; 
    67import java.util.List; 
    78import java.util.Map; 
     9import java.util.Set; 
    810 
    911import org.apache.commons.logging.Log; 
     
    9395 
    9496                int tag = ev.get_tag(); 
    95  
    9697                switch (tag) { 
    9798 
     
    139140                                getWorkloadUnitHandler().handleJob(job); 
    140141                        }  
    141                         //SUPPORTS PRECEDING CONSTRAINST COMING BOTH FROM SWF FILES 
     142                        //SUPPORTS PRECEDING CONSTRAINST COMING ALSO FROM SWF FILES 
    142143                        /*else { 
    143144                                try { 
     
    394395                PEUnit peUnit = (PEUnit)resources.get(StandardResourceUnitName.PE); 
    395396                updateComputingResources(peUnit, ResourceEventType.TASK_STARTED, exec); 
    396                  
    397         } 
     397        } 
     398 
    398399        protected void finalizeExecutable(ExecTask execTask){ 
    399400                 
     
    459460                        //System.out.println("taskId: " + exec.getId() + "; completion percentage: " + exec.getCompletionPercentage() + "; timespan: " + timeSpan + "; estimatedDuration: " +  execHistItem.getCompletionPercentage()); 
    460461                        exec.getExecutionProfile().setCompletionPercentage(exec.getExecutionProfile().getCompletionPercentage() + 100 * (timeSpan / (execHistItem.getEstimatedDuration()) * (1.0 - execHistItem.getCompletionPercentage()/100.0))); 
    461                         exec.setTotalCompletionPercentage(exec.getTotalCompletionPercentage() + 100 * (timeSpan / execHistItem.getEstimatedDuration()) * exec.getExecutionProfile().getCurrentResourceConsumption().getLenght() / exec.getExecutionProfile().getLength()); 
     462                        exec.setTotalCompletionPercentage(exec.getTotalCompletionPercentage() + 100 * (timeSpan / execHistItem.getEstimatedDuration()) * exec.getExecutionProfile().getCurrentExecutionPhase().getLenght() / exec.getExecutionProfile().getLength()); 
    462463                        //System.out.println("newProgress: " + exec.getCompletionPercentage()  );        
    463464 
     
    467468        private void updateComputingResources(PEUnit peUnit, ResourceEventType eventType, Object obj){ 
    468469                if(peUnit instanceof ProcessingElements){ 
    469                         ProcessingElements pes = (ProcessingElements) peUnit; 
     470                        /*ProcessingElements pes = (ProcessingElements) peUnit; 
    470471                        for (ComputingResource resource : pes) { 
    471472                                resource.handleEvent(new ResourceEvent(eventType, obj, scheduler.getFullName())); 
    472473                                //DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(eventType, obj)); 
    473                         } 
     474                        }*/ 
    474475                        /*try { 
    475476                                for (ComputingResource resource : resourceManager.getResourcesOfType(pes.get(0).getType())) { 
     
    480481                                e.printStackTrace(); 
    481482                        }*/ 
     483                         
     484                        ProcessingElements pes = (ProcessingElements) peUnit; 
     485                        ResourceEvent resEvent = new ResourceEvent(eventType, obj, scheduler.getFullName());             
     486                        try{ 
     487                                Set<ComputingResource> resourcesToUpdate = new LinkedHashSet<ComputingResource>(); 
     488                         
     489                                for (ComputingResource compResource : pes) { 
     490                                        resourcesToUpdate.add(compResource); 
     491                                } 
     492                                while(resourcesToUpdate.size() > 0){ 
     493                                        Set<ComputingResource> newSet = new LinkedHashSet<ComputingResource>(); 
     494                                        for(ComputingResource compResource: resourcesToUpdate){ 
     495                                                compResource.updateState(resEvent); 
     496                                                if(compResource.getParent() != null){ 
     497                                                        newSet.add(compResource.getParent()); 
     498                                                } 
     499                                        } 
     500                                        resourcesToUpdate = new LinkedHashSet<ComputingResource>(newSet); 
     501                                } 
     502                        }catch(Exception e){ 
     503                        } 
    482504                } else { 
    483505                        ComputingResource resource = null; 
     
    492514 
    493515        protected void updateProcessingTimes() { 
    494                 for (ExecTask execTask : jobRegistry.getRunningTasks()) { 
     516                for (ExecTask execTask: jobRegistry.getRunningTasks()) { 
    495517                        Executable exec = (Executable)execTask; 
    496518 
     
    502524 
    503525                        ExecutionHistoryItem execHistItem = exec.getExecutionHistory().getLast(); 
    504                         double lastTimeStamp = execHistItem.getTimeStamp().getMillis() / 1000; 
     526                        double lastTimeStamp = execHistItem.getTimeStamp() / 1000; 
    505527                        if(DoubleMath.subtract((lastTimeStamp + execHistItem.getEstimatedDuration()), (new DateTime().getMillis() / 1000 + phaseDuration)) == 0.0){ 
    506528                                continue; 
     
    706728         
    707729        private void saveExecutionHistory(Executable exec, double completionPercentage, double estimatedDuration){ 
    708                 ExecutionHistoryItem execHistoryItem = new ExecutionHistoryItem(new DateTime()); 
     730                ExecutionHistoryItem execHistoryItem = new ExecutionHistoryItem(new DateTime().getMillis()); 
    709731                execHistoryItem.setCompletionPercentage(completionPercentage); 
    710732                execHistoryItem.setEstimatedDuration(estimatedDuration); 
Note: See TracChangeset for help on using the changeset viewer.