[104] | 1 | package test.rewolucja.resources.reader; |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | import gridsim.ResourceCalendar; |
---|
| 5 | import gridsim.gssim.GssimConstants; |
---|
| 6 | |
---|
| 7 | import java.io.File; |
---|
| 8 | import java.io.FileNotFoundException; |
---|
| 9 | import java.io.FileReader; |
---|
| 10 | import java.io.IOException; |
---|
| 11 | import java.util.LinkedList; |
---|
| 12 | import java.util.List; |
---|
| 13 | import java.util.Stack; |
---|
| 14 | |
---|
| 15 | import org.exolab.castor.xml.MarshalException; |
---|
| 16 | import org.exolab.castor.xml.ValidationException; |
---|
| 17 | import org.qcg.broker.schemas.exception.UnknownParameter; |
---|
| 18 | |
---|
| 19 | import org.qcg.broker.schemas.hostparams.HostParameters; |
---|
| 20 | import org.qcg.broker.schemas.hostparams.wrapper.HostParametersWrapper; |
---|
| 21 | import org.qcg.broker.schemas.hostparams.wrapper.impl.HostParametersWrapperImpl; |
---|
| 22 | |
---|
| 23 | import schedframe.scheduling.plugin.estimation.ExecTimeEstimationPlugin; |
---|
| 24 | import simulator.ConfigurationOptions; |
---|
| 25 | import simulator.utils.InstanceFactory; |
---|
| 26 | import test.rewolucja.resources.ResourceType; |
---|
| 27 | import test.rewolucja.resources.description.AbstractResourceDescription; |
---|
| 28 | import test.rewolucja.resources.description.ExecResourceDescription; |
---|
[219] | 29 | import test.rewolucja.resources.logical.base.LogicalResource; |
---|
| 30 | import test.rewolucja.resources.logical.implementation.Cluster; |
---|
[104] | 31 | import test.rewolucja.resources.physical.base.ComputingResource; |
---|
| 32 | import test.rewolucja.resources.physical.factory.ResourceFactory; |
---|
| 33 | import test.rewolucja.resources.reader.test.TempResourceDescriptionReader; |
---|
| 34 | import test.rewolucja.resources.utils.ResourceController; |
---|
[156] | 35 | import test.rewolucja.scheduling.implementation.GridBroker; |
---|
[104] | 36 | import test.rewolucja.scheduling.implementation.LocalManagementSystem; |
---|
| 37 | import test.rewolucja.scheduling.implementation.ManagementSystem; |
---|
| 38 | |
---|
[156] | 39 | public class TempResourceReader { |
---|
[104] | 40 | |
---|
| 41 | protected String forecastFinishTimePluginName; |
---|
| 42 | protected String globalSchedulingPluginName; |
---|
| 43 | protected String localSchedulingPluginName; |
---|
| 44 | protected String resDescFileName; |
---|
| 45 | protected String envDescFileName; |
---|
| 46 | |
---|
| 47 | protected ResourceCalendar resourceCalendar; |
---|
| 48 | protected ExecTimeEstimationPlugin execTimeEstimationPlugin; |
---|
| 49 | |
---|
| 50 | private List<String> resourceLayers; |
---|
| 51 | |
---|
| 52 | |
---|
[156] | 53 | public TempResourceReader(ConfigurationOptions options) throws IOException { |
---|
[104] | 54 | |
---|
| 55 | forecastFinishTimePluginName = options.exectimeestimationplugin; |
---|
| 56 | globalSchedulingPluginName = options.gridSchedulingPluginName; |
---|
| 57 | localSchedulingPluginName = options.localAllocPolicyPluginName; |
---|
| 58 | resDescFileName = options.resdescFileName; |
---|
| 59 | envDescFileName = options.envDescFileName; |
---|
| 60 | prepareCalendar(); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | public ResourceController read() throws MarshalException, ValidationException, FileNotFoundException, |
---|
| 64 | UnknownParameter { |
---|
| 65 | |
---|
| 66 | File file = new File(resDescFileName); |
---|
| 67 | |
---|
| 68 | HostParameters resourceDesription = HostParameters.unmarshalHostParameters(new FileReader(file)); |
---|
| 69 | HostParametersWrapper wrapper = new HostParametersWrapperImpl(); |
---|
| 70 | wrapper.wrap(resourceDesription); |
---|
| 71 | org.qcg.broker.schemas.hostparams.ComputingResource compResources[] = null; |
---|
| 72 | compResources = wrapper.getStandaloneComputingResources(); |
---|
| 73 | |
---|
| 74 | TempResourceDescriptionReader resourceDescriptionReader = TempResourceDescriptionReader |
---|
| 75 | .getConfiguration(envDescFileName); |
---|
[140] | 76 | System.out.println("started creating environment description"); |
---|
[104] | 77 | ExecResourceDescription headExecResDesc = createEnvironmentDescription(resourceDescriptionReader, compResources[0]); |
---|
[140] | 78 | System.out.println("finished creating environment description"); |
---|
[104] | 79 | |
---|
[140] | 80 | System.out.println("started creating resources"); |
---|
[104] | 81 | ComputingResource resource = createResources(headExecResDesc); |
---|
[140] | 82 | System.out.println("finished creating resource"); |
---|
[104] | 83 | |
---|
| 84 | execTimeEstimationPlugin = (ExecTimeEstimationPlugin) InstanceFactory.createInstance( |
---|
| 85 | forecastFinishTimePluginName, ExecTimeEstimationPlugin.class); |
---|
| 86 | |
---|
| 87 | //List<Resource> resources = createResourcesAlternative(resourceDescriptionReader, arc, resourcesDescriptions); |
---|
| 88 | |
---|
| 89 | LogicalResource lr = createLogicalResources(resource); |
---|
| 90 | //LogicalResource lr = createLogicalLayersStructureAlternative(resources); |
---|
| 91 | ResourceController rc = null; |
---|
| 92 | try { |
---|
| 93 | rc = new ResourceController("rc", lr, resource); |
---|
| 94 | } catch (Exception e) { |
---|
| 95 | // TODO Auto-generated catch block |
---|
| 96 | e.printStackTrace(); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | return rc; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | private ExecResourceDescription createEnvironmentDescription(TempResourceDescriptionReader resourceDescriptionReader, |
---|
| 104 | org.qcg.broker.schemas.hostparams.ComputingResource compResources) { |
---|
| 105 | |
---|
| 106 | resourceLayers = resourceDescriptionReader.resources; |
---|
| 107 | String resLayerName = resourceLayers.get(0); |
---|
| 108 | |
---|
| 109 | ExecResourceDescription headExecResDesc = new ExecResourceDescription(null, compResources, resLayerName); |
---|
| 110 | |
---|
| 111 | Stack<ExecResourceDescription> toExamine = new Stack<ExecResourceDescription>(); |
---|
| 112 | toExamine.push(headExecResDesc); |
---|
| 113 | |
---|
| 114 | ExecResourceDescription perentResDesc; |
---|
| 115 | while (!toExamine.isEmpty()) { |
---|
| 116 | perentResDesc = toExamine.pop(); |
---|
| 117 | resLayerName = getNextLayer(perentResDesc.getType().toString()); |
---|
| 118 | if (resLayerName == null) |
---|
| 119 | continue; |
---|
| 120 | int resAmount = Integer.parseInt(resourceDescriptionReader.res_amount.get(resLayerName)); |
---|
| 121 | for (int i = 0; i < resAmount; i++) { |
---|
| 122 | ExecResourceDescription resDesc = new ExecResourceDescription(perentResDesc, compResources, resLayerName); |
---|
| 123 | perentResDesc.addChildren(resDesc); |
---|
| 124 | toExamine.insertElementAt(resDesc, 0); |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | return headExecResDesc; |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | private String getNextLayer(String previousLayer) { |
---|
| 131 | String layer = null; |
---|
| 132 | for (int i = 0; i < resourceLayers.size(); i++) { |
---|
| 133 | if (resourceLayers.get(i).compareTo(previousLayer) == 0) { |
---|
| 134 | if (i < resourceLayers.size() - 1) { |
---|
| 135 | layer = resourceLayers.get(i + 1); |
---|
| 136 | break; |
---|
| 137 | } |
---|
| 138 | } |
---|
| 139 | } |
---|
| 140 | return layer; |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | private ComputingResource createResources(ExecResourceDescription headExecResDes) { |
---|
| 145 | |
---|
| 146 | ComputingResource headResource = ResourceFactory.createResource(headExecResDes); |
---|
| 147 | Stack<ExecResourceDescription> toExamine = new Stack<ExecResourceDescription>(); |
---|
| 148 | toExamine.push(headExecResDes); |
---|
| 149 | Stack<ComputingResource> resStructure = new Stack<ComputingResource>(); |
---|
| 150 | resStructure.push(headResource); |
---|
| 151 | while (!toExamine.isEmpty()) { |
---|
| 152 | ComputingResource parentResource = resStructure.pop(); |
---|
| 153 | ExecResourceDescription parentResDesc = toExamine.pop(); |
---|
| 154 | List<AbstractResourceDescription> childrenResDesc = parentResDesc.getChildren(); |
---|
| 155 | if (childrenResDesc == null){ |
---|
| 156 | continue; |
---|
| 157 | } |
---|
| 158 | int resAmount = childrenResDesc.size(); |
---|
| 159 | for (int i = 0; i < resAmount; i++) { |
---|
| 160 | ExecResourceDescription execResDesc = (ExecResourceDescription) childrenResDesc.get(i); |
---|
| 161 | ComputingResource resource = ResourceFactory.createResource(execResDesc); |
---|
| 162 | parentResource.addChild(resource); |
---|
| 163 | toExamine.push(execResDesc); |
---|
| 164 | resStructure.push(resource); |
---|
| 165 | } |
---|
| 166 | } |
---|
| 167 | return headResource; |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | private LogicalResource createLogicalResources(ComputingResource headResource) { |
---|
| 173 | |
---|
| 174 | Stack<ComputingResource> toExamine = new Stack<ComputingResource>(); |
---|
| 175 | toExamine.push(headResource); |
---|
| 176 | LogicalResource headLogicalResource = null; |
---|
| 177 | Stack<LogicalResource> logicalResStructure = new Stack<LogicalResource>(); |
---|
| 178 | LogicalResource parentLogicalResource = null; |
---|
| 179 | while (!toExamine.isEmpty()) { |
---|
| 180 | ComputingResource parentResource = toExamine.pop(); |
---|
| 181 | if (parentResource.getType() == ResourceType.COMPUTING_GRID) |
---|
| 182 | try { |
---|
[156] | 183 | ManagementSystem ms = new GridBroker(parentResource.getName(), |
---|
[104] | 184 | globalSchedulingPluginName, execTimeEstimationPlugin, null); |
---|
| 185 | |
---|
| 186 | headLogicalResource = new LogicalResource(ms, parentResource.getChildren()); |
---|
| 187 | logicalResStructure.push(headLogicalResource); |
---|
| 188 | } catch (Exception e) { |
---|
| 189 | e.printStackTrace(); |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | if(parentResource.getType() == ResourceType.RACK || parentResource.getType() == ResourceType.COMPUTING_NODE || parentResource.getType() == ResourceType.CPU || parentResource.getType() == ResourceType.CORE ) |
---|
| 193 | { |
---|
| 194 | |
---|
| 195 | } |
---|
| 196 | else |
---|
| 197 | parentLogicalResource = logicalResStructure.pop(); |
---|
| 198 | |
---|
| 199 | List<ComputingResource> resChildren = parentResource.getChildren(); |
---|
| 200 | if (resChildren == null) |
---|
| 201 | continue; |
---|
| 202 | int resAmount = resChildren.size(); |
---|
| 203 | for (int i = 0; i < resAmount; i++) { |
---|
| 204 | ComputingResource resource = resChildren.get(i); |
---|
| 205 | |
---|
[121] | 206 | if (resource.getType() == ResourceType.DATA_CENTER) |
---|
[104] | 207 | { |
---|
| 208 | try { |
---|
| 209 | ManagementSystem ms = new LocalManagementSystem(resource.getName(), |
---|
| 210 | GssimConstants.MANAGEMENT_SYSTEM, |
---|
| 211 | localSchedulingPluginName, execTimeEstimationPlugin, null); |
---|
| 212 | |
---|
[219] | 213 | LogicalResource logicalResource = new Cluster( |
---|
[104] | 214 | ms, resource.getChildren()); |
---|
| 215 | parentLogicalResource.addChild(logicalResource); |
---|
| 216 | logicalResStructure.push(logicalResource); |
---|
| 217 | } catch (Exception e) { |
---|
| 218 | e.printStackTrace(); |
---|
| 219 | } |
---|
| 220 | } /*else if (resource.getType() == ResourceType.COMPUTING_NODE) { |
---|
| 221 | try { |
---|
| 222 | ManagementSystem ms = new LocalManagementSystem(resource.getName(), |
---|
| 223 | GssimConstants.MANAGEMENT_SYSTEM, |
---|
| 224 | "example.localplugin.FCFSLocalPlugin", execTimeEstimationPlugin, null); |
---|
| 225 | |
---|
| 226 | LogicalResource logicalResource = new LogicalResource(ms, resource.getChildren()); |
---|
| 227 | parentLogicalResource.addChild(logicalResource); |
---|
| 228 | logicalResStructure.push(logicalResource); |
---|
| 229 | } catch (Exception e) { |
---|
| 230 | // TODO Auto-generated catch block |
---|
| 231 | e.printStackTrace(); |
---|
| 232 | } |
---|
| 233 | }*/ |
---|
| 234 | toExamine.push(resource); |
---|
| 235 | } |
---|
| 236 | } |
---|
| 237 | return headLogicalResource; |
---|
| 238 | |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | private void prepareCalendar() { |
---|
| 242 | long seed = 11L * 13L * 17L * 19L * 23L + 1L; |
---|
| 243 | double timeZone = 0.0; |
---|
| 244 | double peakLoad = 0.0; // the resource load during peak hour |
---|
| 245 | double offPeakLoad = 0.0; // the resource load during off-peak hr |
---|
| 246 | double holidayLoad = 0.0; // the resource load during holiday |
---|
| 247 | |
---|
| 248 | // incorporates weekends so the grid resource is on 7 days a week |
---|
| 249 | LinkedList<Integer> Weekends = new LinkedList<Integer>(); |
---|
| 250 | Weekends.add(java.util.Calendar.SATURDAY); |
---|
| 251 | Weekends.add(java.util.Calendar.SUNDAY); |
---|
| 252 | |
---|
| 253 | // incorporates holidays. However, no holidays are set in this example |
---|
| 254 | LinkedList<Integer> Holidays = new LinkedList<Integer>(); |
---|
| 255 | resourceCalendar = new ResourceCalendar(timeZone, peakLoad, offPeakLoad, holidayLoad, Weekends, Holidays, |
---|
| 256 | seed); |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | |
---|
| 260 | |
---|
| 261 | |
---|
| 262 | |
---|
| 263 | |
---|
| 264 | |
---|
| 265 | |
---|
| 266 | |
---|
| 267 | |
---|
| 268 | |
---|
| 269 | /*private List<Resource> createResourcesAlternative(TempResourceDescriptionReader resourceDescriptionReader, |
---|
| 270 | ExecResourceDescription arcParent, ArrayList<ExecutingResourceDescription> resourcesDescriptions) { |
---|
| 271 | List<Resource> resources = new ArrayList<Resource>(); |
---|
| 272 | for(AbstractResourceDescription arc:arcParent.getChildren()) |
---|
| 273 | { |
---|
| 274 | ExecResourceDescription erc = (ExecResourceDescription)arc; |
---|
| 275 | Resource resource = ResourceFactory.createResource(erc); |
---|
| 276 | createResourcesIterative(resourceDescriptionReader, resource, erc); |
---|
| 277 | resources.add(resource); |
---|
| 278 | } |
---|
| 279 | |
---|
| 280 | return resources; |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | |
---|
| 284 | private LogicalResource createLogicalLayersStructureAlternative(List<Resource> resources) { |
---|
| 285 | LogicalResource logicalLayerWithMs = null; |
---|
| 286 | Stack<LogicalResource> tree = new Stack<LogicalResource>(); |
---|
| 287 | |
---|
| 288 | ManagementSystem ms = null; |
---|
| 289 | try { |
---|
| 290 | ms = new GridBrokerNew("COMPUTING_GRID_0", |
---|
| 291 | globalSchedulingPluginName, execTimeEstimationPlugin, null); |
---|
| 292 | } catch (Exception e1) { |
---|
| 293 | // TODO Auto-generated catch block |
---|
| 294 | e1.printStackTrace(); |
---|
| 295 | } |
---|
| 296 | |
---|
| 297 | try { |
---|
| 298 | logicalLayerWithMs = new LogicalResource(ms, resources); |
---|
| 299 | } catch (Exception e1) { |
---|
| 300 | // TODO Auto-generated catch block |
---|
| 301 | e1.printStackTrace(); |
---|
| 302 | } |
---|
| 303 | tree.push(logicalLayerWithMs); |
---|
| 304 | |
---|
| 305 | Stack<Resource> toExamine = new Stack<Resource>(); |
---|
| 306 | |
---|
| 307 | |
---|
| 308 | for(Resource resource:resources) |
---|
| 309 | toExamine.push(resource); |
---|
| 310 | LogicalResource ll = null; |
---|
| 311 | while (!toExamine.isEmpty()) { |
---|
| 312 | Resource resourceFromTop = toExamine.pop(); |
---|
| 313 | if (resourceFromTop.getType() == ResourceType.COMPUTING_RESOURCE) |
---|
| 314 | try { |
---|
| 315 | |
---|
| 316 | ms = new LocalManagementSystem(resourceFromTop.getName(), |
---|
| 317 | GssimConstants.MANAGEMENT_SYSTEM, |
---|
| 318 | localSchedulingPluginName, execTimeEstimationPlugin, null); |
---|
| 319 | |
---|
| 320 | LogicalResource logicalLayerWithMsChild = new LogicalResource(ms, resourceFromTop.getChildren()); |
---|
| 321 | tree.push(logicalLayerWithMs); |
---|
| 322 | logicalLayerWithMs.addChild(logicalLayerWithMsChild); |
---|
| 323 | // llstruct.add(new String(""), logicalLayerWithMs.get_name()); |
---|
| 324 | } catch (Exception e) { |
---|
| 325 | // TODO Auto-generated catch block |
---|
| 326 | e.printStackTrace(); |
---|
| 327 | } |
---|
| 328 | List<Resource> children = resourceFromTop.getChildren(); |
---|
| 329 | if (children == null) |
---|
| 330 | continue; |
---|
| 331 | int size = children.size(); |
---|
| 332 | |
---|
| 333 | if(resourceFromTop.getType() == ResourceType.RACK || resourceFromTop.getType() == ResourceType.COMPUTING_NODE || resourceFromTop.getType() == ResourceType.CPU || resourceFromTop.getType() == ResourceType.CORE ) |
---|
| 334 | { |
---|
| 335 | |
---|
| 336 | } |
---|
| 337 | else |
---|
| 338 | ll = tree.pop(); |
---|
| 339 | for (int j = 0; j < size; j++) { |
---|
| 340 | Resource resourceChild = children.get(j); |
---|
| 341 | |
---|
| 342 | if (resourceChild.getType() == ResourceType.COMPUTING_RESOURCE) |
---|
| 343 | { try { |
---|
| 344 | |
---|
| 345 | ms = new LocalManagementSystem(resourceChild.getName(), |
---|
| 346 | GssimConstants.MANAGEMENT_SYSTEM, |
---|
| 347 | localSchedulingPluginName, execTimeEstimationPlugin, null); |
---|
| 348 | |
---|
| 349 | LogicalResource logicalLayerWithMsChild = new LogicalResource( |
---|
| 350 | ms, resourceChild.getChildren()); |
---|
| 351 | ll.addChild(logicalLayerWithMsChild); |
---|
| 352 | tree.push(logicalLayerWithMsChild); |
---|
| 353 | /// llstruct.add(logicalLayerWithMs.get_name(), logicalLayerWithMsChild.get_name()); |
---|
| 354 | } catch (Exception e) { |
---|
| 355 | // TODO Auto-generated catch block |
---|
| 356 | e.printStackTrace(); |
---|
| 357 | } |
---|
| 358 | } else if (resourceChild.getType() == ResourceType.COMPUTING_NODE) |
---|
| 359 | { try { |
---|
| 360 | ms = new LocalManagementSystem(resourceChild.getName(), |
---|
| 361 | GssimConstants.DEFAULT_RESOURCE_MANAGER_NAME, |
---|
| 362 | "example.localplugin.FCFSLocalPlugin", execTimeEstimationPlugin, null); |
---|
| 363 | |
---|
| 364 | |
---|
| 365 | LogicalResource logicalLayerWithMsChild = new LogicalResource( |
---|
| 366 | ms, resourceChild.getChildren()); |
---|
| 367 | ll.addChild(logicalLayerWithMsChild); |
---|
| 368 | tree.push(logicalLayerWithMsChild); |
---|
| 369 | /// llstruct.add(logicalLayerWithMs.get_name(), logicalLayerWithMsChild.get_name()); |
---|
| 370 | } catch (Exception e) { |
---|
| 371 | // TODO Auto-generated catch block |
---|
| 372 | e.printStackTrace(); |
---|
| 373 | } |
---|
| 374 | } |
---|
| 375 | toExamine.push(resourceChild); |
---|
| 376 | } |
---|
| 377 | } |
---|
| 378 | return logicalLayerWithMs; |
---|
| 379 | |
---|
| 380 | } |
---|
| 381 | */ |
---|
| 382 | |
---|
| 383 | |
---|
| 384 | |
---|
| 385 | /*private ExecResourceDescription createEnvironmentDescription( |
---|
| 386 | TempResourceDescriptionReader resourceDescriptionReader, ComputingResource compResources) { |
---|
| 387 | |
---|
| 388 | physicalLayers = resourceDescriptionReader.resources; |
---|
| 389 | String headResName = physicalLayers.get(0); |
---|
| 390 | ExecResourceDescription arc = new ExecResourceDescription(null, compResources, ResourceType.valueOf(headResName), |
---|
| 391 | String.valueOf(0)); |
---|
| 392 | createEnvironmentDescriptionHierarchy(physicalLayers.get(1), arc, resourceDescriptionReader.layer_amount, |
---|
| 393 | compResources); |
---|
| 394 | return arc; |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | private void createEnvironmentDescriptionHierarchy(String layer, ExecResourceDescription arc, |
---|
| 398 | Map<String, String> layer_amount, ComputingResource compResources) { |
---|
| 399 | |
---|
| 400 | Stack<ExecResourceDescription> toExamine = new Stack<ExecResourceDescription>(); |
---|
| 401 | toExamine.push(arc); |
---|
| 402 | |
---|
| 403 | while (!toExamine.isEmpty()) { |
---|
| 404 | arc = toExamine.pop(); |
---|
| 405 | layer = getNextLayer(arc.getType().toString()); |
---|
| 406 | if (layer == null) |
---|
| 407 | continue; |
---|
| 408 | int amount = Integer.parseInt(layer_amount.get(layer)); |
---|
| 409 | ExecResourceDescription child; |
---|
| 410 | for (int j = 0; j < amount; j++) { |
---|
| 411 | child = new ExecResourceDescription(arc, compResources, ResourceType.valueOf(layer), |
---|
| 412 | String.valueOf(ResourceIDGenerator.getID(ResourceType.valueOf(layer)))); |
---|
| 413 | arc.addChildren(child); |
---|
| 414 | toExamine.insertElementAt(child, 0); |
---|
| 415 | } |
---|
| 416 | } |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | private Resource createResources(TempResourceDescriptionReader resourceDescriptionReader, |
---|
| 420 | ExecResourceDescription arcParent) { |
---|
| 421 | Resource resource = ResourceFactory.createResource(arcParent); |
---|
| 422 | createResourcesIterative(resourceDescriptionReader, resource, arcParent); |
---|
| 423 | return resource; |
---|
| 424 | } |
---|
| 425 | |
---|
| 426 | private void createResourcesIterative(TempResourceDescriptionReader resourceDescriptionReader, |
---|
| 427 | Resource resourceParent, ExecResourceDescription arcParent) { |
---|
| 428 | |
---|
| 429 | Stack<ExecResourceDescription> toExamine = new Stack<ExecResourceDescription>(); |
---|
| 430 | Stack<Resource> tree = new Stack<Resource>(); |
---|
| 431 | toExamine.push(arcParent); |
---|
| 432 | tree.push(resourceParent); |
---|
| 433 | Resource parentResource; |
---|
| 434 | while (!toExamine.isEmpty()) { |
---|
| 435 | AbstractResourceDescription node = toExamine.pop(); |
---|
| 436 | parentResource = tree.pop(); |
---|
| 437 | List<AbstractResourceDescription> children = node.getChildren(); |
---|
| 438 | if (children == null){ |
---|
| 439 | //parentResource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, null)); |
---|
| 440 | continue; |
---|
| 441 | } |
---|
| 442 | int size = children.size(); |
---|
| 443 | for (int j = 0; j < size; j++) { |
---|
| 444 | ExecResourceDescription arc = (ExecResourceDescription) children.get(j); |
---|
| 445 | Resource resource = ResourceFactory.createResource(arc); |
---|
| 446 | //resource.setParent(parentResource); |
---|
| 447 | parentResource.addChild(resource); |
---|
| 448 | toExamine.push(arc); |
---|
| 449 | tree.push(resource); |
---|
| 450 | } |
---|
| 451 | } |
---|
| 452 | }*/ |
---|
| 453 | |
---|
| 454 | |
---|
| 455 | } |
---|