Ignore:
Timestamp:
03/19/14 18:22:27 (11 years ago)
Author:
wojtekp
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java

    r1207 r1299  
    33import gridsim.GridSimTags; 
    44import gridsim.dcworms.DCWormsTags; 
     5import gridsim.dcworms.filter.ResourceEventFilter; 
    56 
    67import java.util.ArrayList; 
     
    2425import schedframe.resources.computing.profiles.energy.EnergyEventType; 
    2526import schedframe.resources.computing.profiles.energy.EnergyExtension; 
     27import schedframe.resources.computing.profiles.load.LoadExtension; 
     28import schedframe.resources.computing.profiles.load.ResourceLoadCalendar; 
     29import schedframe.resources.computing.profiles.load.TimestampUtilization; 
     30import schedframe.resources.computing.profiles.load.ui.LoadInterface; 
    2631import schedframe.resources.computing.properties.DefaultPropertiesBuilder; 
    2732import schedframe.resources.computing.properties.PropertiesDirector; 
     
    3439import schedframe.resources.devices.PhysicalResource; 
    3540import schedframe.scheduling.Scheduler; 
     41import simulator.DataCenterWorkloadSimulator; 
    3642 
    3743public class ComputingResource extends PhysicalResource{ 
     
    5157                this.extensionList = new ExtensionListImpl(1); 
    5258                initCharacteristics(resDesc); 
     59                accept(new LoadExtension(resDesc.getLoadProfile(), this)); 
    5360                accept(new EnergyExtension.Builder().resource(this).powerProfile(resDesc.getPowerProfile()).airFlowProfile(resDesc.getAirThroughputProfile()).thermalProfile(resDesc.getThermalProfile()).build());      
    5461        } 
     
    6774        public void setParent(ComputingResource newParent) { 
    6875                parent = newParent; 
     76                if(this.getLoadInterface().getLoadCalendar().getLoadDistribution().size() == 0){ 
     77                        this.getLoadInterface().getLoadCalendar().getLoadDistribution().addAll(parent.getLoadInterface().getLoadCalendar().getLoadDistribution()); 
     78                } 
    6979        } 
    7080 
     
    220230                public void handleResourceEvent(Event event){ 
    221231                        if (extensionList != null) { 
    222                                 for (Extension extension : extensionList) { 
     232                                for (Extension extension: extensionList) { 
    223233                                        if (extension.supportsEvent(event)) { 
    224234                                                extension.handleEvent(event); 
     
    227237                                 
    228238                                for (Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()) { 
    229                                         for (Extension extension : device.getExtensionList()) { 
     239                                        for (Extension extension: device.getExtensionList()) { 
    230240                                                if (extension.supportsEvent(event)) { 
    231                                                         //extension.handleEvent(event); 
     241                                                        extension.handleEvent(event); 
    232242                                                } 
    233243                                        } 
     
    242252                        if(scheduler != null && (parent != null && scheduler != parent.getScheduler())/*scheduler.getResources().contains(this)*/){ 
    243253                                String src = event.getSource() != null ? event.getSource() : name; 
     254                                ResourceEventFilter filter = new ResourceEventFilter(src.hashCode(), DCWormsTags.UPDATE_PROCESSING); 
     255                                scheduler.sim_cancel(filter, null); 
    244256                                scheduler.sendInternal(GridSimTags.SCHEDULE_NOW, DCWormsTags.UPDATE_PROCESSING, src); 
    245257                        } else if(parent != null) 
     
    274286                rec.execute(event); 
    275287                 
     288                LoadInterface li = getLoadInterface(); 
     289                if(li != null){ 
     290                        ResourceLoadCalendar rlc = li.getLoadCalendar(); 
     291                        LinkedList<TimestampUtilization> ll = rlc.getLoadDistribution(); 
     292                        for(TimestampUtilization tu: ll){ 
     293                                DataCenterWorkloadSimulator.getEventManager().sendToResource(getFullName(), tu.getStartTime(), new EnergyEvent(EnergyEventType.RESOURCE_UTILIZATION_CHANGED, getFullName())); 
     294                                DataCenterWorkloadSimulator.getEventManager().sendToResource(getFullName(), tu.getEndTime(), new EnergyEvent(EnergyEventType.RESOURCE_UTILIZATION_CHANGED, getFullName())); 
     295                        }                                        
     296                } 
    276297                //alternative way 
    277298                //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller")); 
Note: See TracChangeset for help on using the changeset viewer.