Changeset 1423 for DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java
- Timestamp:
- 07/30/14 12:25:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java
r1415 r1423 47 47 //protected ResourceCharacteristics resourceCharacteristic; 48 48 49 49 50 50 public ComputingResource(ComputingResourceDescription resDesc) { 51 51 this.type = resDesc.getType(); … … 53 53 this.category = resDesc.getCategory(); 54 54 this.status = ResourceStatus.FREE; 55 this.extensionList = new ExtensionListImpl( 1);55 this.extensionList = new ExtensionListImpl(2); 56 56 initCharacteristics(resDesc); 57 57 accept(new LoadExtension(resDesc.getLoadProfile(), this)); 58 58 accept(new EnergyExtension.Builder().resource(this).powerProfile(resDesc.getPowerProfile()).airflowProfile(resDesc.getAirflowProfile()).thermalProfile(resDesc.getThermalProfile()).build()); 59 59 60 } 60 61 61 62 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(); 63 64 for(Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()){ 64 65 device.setComputingResource(this); … … 71 72 72 73 public void setParent(ComputingResource newParent) { 73 parent = newParent;74 this.parent = newParent; 74 75 /*if(this.getLoadInterface().getLoadCalendar().getLoadDistribution().size() == 0){ 75 76 this.getLoadInterface().getLoadCalendar().getLoadDistribution().addAll(parent.getLoadInterface().getLoadCalendar().getLoadDistribution()); … … 79 80 public List<ComputingResource> getChildren() { 80 81 if (children == null) 81 return new ArrayList<ComputingResource>( 1);82 return new ArrayList<ComputingResource>(0); 82 83 return children; 83 84 } … … 124 125 ResourceEventCommand rec = new ResourceEventCommand(this); 125 126 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 } 129 131 //old, correctly working method 130 132 /*if (extensionList != null) { … … 143 145 } 144 146 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 145 167 public List <? extends ComputingResource> getDescendantsByType(ResourceType type) { 146 List<ResourceValidator> validators = new ArrayList<ResourceValidator>( );168 List<ResourceValidator> validators = new ArrayList<ResourceValidator>(1); 147 169 validators.add(new ResourceTypeValidator(type)); 148 170 return searchDescendants(validators, true); … … 150 172 151 173 public List<? extends ComputingResource> getDescendantsByTypeAndStatus(ResourceType type, ResourceStatus status) { 152 List<ResourceValidator> validators = new ArrayList<ResourceValidator>( );174 List<ResourceValidator> validators = new ArrayList<ResourceValidator>(2); 153 175 validators.add(new ResourceStatusValidator(status)); 154 176 validators.add(new ResourceTypeValidator(type)); … … 157 179 158 180 public ComputingResource getDescendantByName(String resourceName){ 159 List<ResourceValidator> validators = new ArrayList<ResourceValidator>( );181 List<ResourceValidator> validators = new ArrayList<ResourceValidator>(1); 160 182 validators.add(new ResourceNameValidator(resourceName)); 161 183 List<? extends ComputingResource> resources = searchDescendants(validators, true); … … 227 249 228 250 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 229 259 if (extensionList != null) { 230 260 for (Extension extension: extensionList) { 231 261 if (extension.supportsEvent(event)) { 232 262 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 }241 263 } 242 264 }
Note: See TracChangeset
for help on using the changeset viewer.