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/resources/computing/ComputingResource.java

    r1415 r1423  
    4747        //protected ResourceCharacteristics resourceCharacteristic; 
    4848 
    49  
     49         
    5050        public ComputingResource(ComputingResourceDescription resDesc) { 
    5151                this.type = resDesc.getType(); 
     
    5353                this.category = resDesc.getCategory(); 
    5454                this.status = ResourceStatus.FREE; 
    55                 this.extensionList = new ExtensionListImpl(1); 
     55                this.extensionList = new ExtensionListImpl(2); 
    5656                initCharacteristics(resDesc); 
    5757                accept(new LoadExtension(resDesc.getLoadProfile(), this)); 
    5858                accept(new EnergyExtension.Builder().resource(this).powerProfile(resDesc.getPowerProfile()).airflowProfile(resDesc.getAirflowProfile()).thermalProfile(resDesc.getThermalProfile()).build());    
     59 
    5960        } 
    6061 
    6162        protected void initCharacteristics(ComputingResourceDescription resDesc){ 
    62                 resourceCharacteristic = ComputingResourceCharacteristics.builder().resourceUnits(resDesc.getResourceUnits()).location(resDesc.getLocation()).parameters(resDesc.getParameters()).device(resDesc.getDevices()).build(); 
     63                this.resourceCharacteristic = ComputingResourceCharacteristics.builder().resourceUnits(resDesc.getResourceUnits()).location(resDesc.getLocation()).parameters(resDesc.getParameters()).device(resDesc.getDevices()).build(); 
    6364                for(Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()){ 
    6465                        device.setComputingResource(this); 
     
    7172 
    7273        public void setParent(ComputingResource newParent) { 
    73                 parent = newParent; 
     74                this.parent = newParent; 
    7475                /*if(this.getLoadInterface().getLoadCalendar().getLoadDistribution().size() == 0){ 
    7576                        this.getLoadInterface().getLoadCalendar().getLoadDistribution().addAll(parent.getLoadInterface().getLoadCalendar().getLoadDistribution()); 
     
    7980        public List<ComputingResource> getChildren() { 
    8081                if (children == null) 
    81                         return new ArrayList<ComputingResource>(1); 
     82                        return new ArrayList<ComputingResource>(0); 
    8283                return children; 
    8384        } 
     
    124125                ResourceEventCommand rec = new ResourceEventCommand(this); 
    125126                rec.execute(event); 
    126                 SchedulingEventCommand sec = new SchedulingEventCommand(this); 
    127                 sec.execute(event); 
    128  
     127                if((scheduler != null && (parent != null && scheduler != parent.getScheduler()))  && !event.getSource().equals(scheduler.getFullName())){ 
     128                        SchedulingEventCommand sec = new SchedulingEventCommand(this); 
     129                        sec.execute(event); 
     130                } 
    129131                //old, correctly working method 
    130132                /*if (extensionList != null) { 
     
    143145        } 
    144146         
     147 
     148        public void updateState(ResourceEvent event){ 
     149                for (Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()) { 
     150                        for (Extension extension: device.getExtensionList()) { 
     151                                if (extension.supportsEvent(event)) { 
     152                                        extension.handleEvent(event); 
     153                                } 
     154                        } 
     155                } 
     156                 
     157                if (extensionList != null) { 
     158                        for (Extension extension: extensionList) { 
     159                                if (extension.supportsEvent(event)) { 
     160                                        extension.handleEvent(event); 
     161                                } 
     162                        } 
     163                } 
     164                 
     165        } 
     166         
    145167        public List <? extends ComputingResource> getDescendantsByType(ResourceType type) { 
    146                 List<ResourceValidator> validators = new ArrayList<ResourceValidator>(); 
     168                List<ResourceValidator> validators = new ArrayList<ResourceValidator>(1); 
    147169                validators.add(new ResourceTypeValidator(type)); 
    148170                return searchDescendants(validators, true); 
     
    150172 
    151173        public List<? extends ComputingResource> getDescendantsByTypeAndStatus(ResourceType type, ResourceStatus status) { 
    152                 List<ResourceValidator> validators = new ArrayList<ResourceValidator>(); 
     174                List<ResourceValidator> validators = new ArrayList<ResourceValidator>(2); 
    153175                validators.add(new ResourceStatusValidator(status)); 
    154176                validators.add(new ResourceTypeValidator(type)); 
     
    157179 
    158180        public ComputingResource getDescendantByName(String resourceName){ 
    159                 List<ResourceValidator> validators = new ArrayList<ResourceValidator>(); 
     181                List<ResourceValidator> validators = new ArrayList<ResourceValidator>(1); 
    160182                validators.add(new ResourceNameValidator(resourceName)); 
    161183                List<? extends ComputingResource> resources = searchDescendants(validators, true); 
     
    227249                 
    228250                public void handleResourceEvent(ResourceEvent event){ 
     251                        for (Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()) { 
     252                                for (Extension extension: device.getExtensionList()) { 
     253                                        if (extension.supportsEvent(event)) { 
     254                                                extension.handleEvent(event); 
     255                                        } 
     256                                } 
     257                        } 
     258                         
    229259                        if (extensionList != null) { 
    230260                                for (Extension extension: extensionList) { 
    231261                                        if (extension.supportsEvent(event)) { 
    232262                                                extension.handleEvent(event); 
    233                                         } 
    234                                 } 
    235                                  
    236                                 for (Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()) { 
    237                                         for (Extension extension: device.getExtensionList()) { 
    238                                                 if (extension.supportsEvent(event)) { 
    239                                                         extension.handleEvent(event); 
    240                                                 } 
    241263                                        } 
    242264                                } 
Note: See TracChangeset for help on using the changeset viewer.