Changeset 1449 for DCWoRMS/branches
- Timestamp:
- 09/26/14 14:42:25 (11 years ago)
- Location:
- DCWoRMS/branches/coolemall/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/example/globalplugin/GridFCFSRandomPlugin.java
r1396 r1449 52 52 53 53 for(int i = 0; i < size; i++) { 54 WorkloadUnit job = q.remove(0); 55 TaskInterface<?> task = (TaskInterface<?>)job;54 55 TaskInterface<?> task = q.remove(0); 56 56 57 57 resourceIdx = rand.nextInt(availableResources.size()); -
DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationHighPerf_PowerCapping_SP.java
r1440 r1449 9 9 10 10 import schedframe.events.scheduling.SchedulingEvent; 11 import schedframe.exceptions.ResourceException;12 11 import schedframe.resources.CoolEmAllResourceType; 13 12 import schedframe.resources.ResourceStatus; … … 300 299 301 300 private void powerCap(ResourceManager resManager){ 302 try { 303 304 for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){ 305 if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){ 306 loadThresholds(compRes); 307 } 308 double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue(); 309 //System.out.println(compRes.getFullName() + " current: " + powerConsumption); 310 if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){ 311 ComputeBox1 cb1 = (ComputeBox1) compRes; 312 List<Processor> processors = cb1.getProcessors(); 313 314 double currentFrequencyLevel = 0; 315 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 316 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 317 } else { 318 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 319 } 320 boolean overThreshold = true; 321 boolean canDoBetter = true; 322 323 while(overThreshold && canDoBetter){ 324 //System.out.println(compRes.getFullName() + " - downgrading"); 325 int procNumberWithoutChange = 0; 326 boolean improvement = false; 327 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 301 302 for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){ 303 if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){ 304 loadThresholds(compRes); 305 } 306 double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue(); 307 //System.out.println(compRes.getFullName() + " current: " + powerConsumption); 308 if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){ 309 ComputeBox1 cb1 = (ComputeBox1) compRes; 310 List<Processor> processors = cb1.getProcessors(); 311 312 double currentFrequencyLevel = 0; 313 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 314 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 315 } else { 316 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 317 } 318 boolean overThreshold = true; 319 boolean canDoBetter = true; 320 321 while(overThreshold && canDoBetter){ 322 //System.out.println(compRes.getFullName() + " - downgrading"); 323 int procNumberWithoutChange = 0; 324 boolean improvement = false; 325 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 326 for (Processor proc: processors){ 327 PState currPState = proc.getPowerInterface().getPState(); 328 //System.out.println(proc.getFullName() + " - checking"); 329 if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){ 330 //System.out.println("operating same level"); 331 procNumberWithoutChange++; 332 continue; 333 } 334 if (proc.getFreeCores().size() == proc.getCores().size()){ 335 //System.out.println("free"); 336 procNumberWithoutChange++; 337 continue; 338 } 339 340 double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency(); 341 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 342 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 343 if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){ 344 lowerFrequency = pState.getFrequency(); 345 } 346 } 347 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 348 if(lowerFrequency < currentFrequencyLevel){ 349 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 350 currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency); 351 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 352 } 353 354 if(lowerFrequency != currPState.getFrequency()) { 355 //System.out.println(proc.getFullName() + " - lowering frequency"); 356 proc.getPowerInterface().setFrequency(lowerFrequency); 357 Node n = proc.getNode(); 358 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 359 360 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 361 Fan fan = (Fan) device; 362 363 if(fan.getChilledResources().contains(n.getFullName())){ 364 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 365 } 366 } 367 } 368 improvement = true; 369 } 370 if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){ 371 canDoBetter = false; 372 } else { 373 canDoBetter = true; 374 } 375 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){ 376 overThreshold = false; 377 break; 378 } 379 } 380 if(procNumberWithoutChange == processors.size() || improvement == false){ 381 //System.out.println(compRes.getFullName() + " - failed to improve"); 382 double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency(); 328 383 for (Processor proc: processors){ 329 PState currPState = proc.getPowerInterface().getPState();330 //System.out.println(proc.getFullName() + " - checking");331 if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){332 //System.out.println("operating same level");333 procNumberWithoutChange++;334 continue;335 }336 if (proc.getFreeCores().size() == proc.getCores().size()){337 //System.out.println("free");338 procNumberWithoutChange++;339 continue;340 }341 342 double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency();343 384 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 344 385 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 345 if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){ 346 lowerFrequency = pState.getFrequency(); 386 if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){ 387 nextFrequencyLevel = pState.getFrequency(); 388 } 389 } 390 } 391 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 392 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 393 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 394 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){ 395 canDoBetter = false; 396 } 397 procNumberWithoutChange = 0; 398 } 399 } 400 401 } else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) { 402 ComputeBox1 cb1 = (ComputeBox1) compRes; 403 List<Processor> processors = cb1.getProcessors(); 404 405 double currentFrequencyLevel = 0; 406 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 407 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 408 } else { 409 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 410 } 411 boolean overThreshold = true; 412 boolean canDoBetter = true; 413 414 while(overThreshold && canDoBetter){ 415 //System.out.println(compRes.getFullName() + " - downgrading"); 416 int procNumberWithoutChange = 0; 417 boolean improvement = false; 418 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 419 for (Processor proc: processors){ 420 PState currPState = proc.getPowerInterface().getPState(); 421 //System.out.println(proc.getFullName() + " - checking"); 422 if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){ 423 //System.out.println("operating same level"); 424 procNumberWithoutChange++; 425 continue; 426 } 427 if (proc.getFreeCores().size() == proc.getCores().size()){ 428 //System.out.println("free"); 429 procNumberWithoutChange++; 430 continue; 431 } 432 433 double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency(); 434 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 435 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 436 if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){ 437 higherFrequency = pState.getFrequency(); 438 } 439 } 440 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 441 if(higherFrequency > currentFrequencyLevel){ 442 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 443 currentFrequencyLevels.put(compRes.getFullName(), higherFrequency); 444 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 445 } 446 447 if(higherFrequency != currPState.getFrequency()) { 448 //System.out.println(proc.getFullName() + " - lowering frequency"); 449 proc.getPowerInterface().setFrequency(higherFrequency); 450 Node n = proc.getNode(); 451 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 452 453 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 454 Fan fan = (Fan) device; 455 456 if(fan.getChilledResources().contains(n.getFullName())){ 457 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 458 } 347 459 } 348 460 } 349 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 350 if(lowerFrequency < currentFrequencyLevel){ 351 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 352 currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency); 353 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 354 } 355 356 if(lowerFrequency != currPState.getFrequency()) { 357 //System.out.println(proc.getFullName() + " - lowering frequency"); 358 proc.getPowerInterface().setFrequency(lowerFrequency); 359 Node n = proc.getNode(); 360 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 361 362 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 363 Fan fan = (Fan) device; 364 365 if(fan.getChilledResources().contains(n.getFullName())){ 366 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 367 } 368 } 369 } 370 improvement = true; 371 } 372 if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){ 373 canDoBetter = false; 374 } else { 375 canDoBetter = true; 376 } 377 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){ 378 overThreshold = false; 379 break; 380 } 381 } 382 if(procNumberWithoutChange == processors.size() || improvement == false){ 383 //System.out.println(compRes.getFullName() + " - failed to improve"); 384 double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency(); 385 for (Processor proc: processors){ 386 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 387 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 388 if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){ 389 nextFrequencyLevel = pState.getFrequency(); 390 } 391 } 392 } 393 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 394 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 395 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 396 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){ 397 canDoBetter = false; 398 } 399 procNumberWithoutChange = 0; 461 improvement = true; 462 } 463 if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){ 464 canDoBetter = false; 465 } else { 466 canDoBetter = true; 467 } 468 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){ 469 overThreshold = false; 470 break; 400 471 } 401 472 } 402 403 } else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) { 404 ComputeBox1 cb1 = (ComputeBox1) compRes; 405 List<Processor> processors = cb1.getProcessors(); 406 407 double currentFrequencyLevel = 0; 408 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 409 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 410 } else { 411 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 412 } 413 boolean overThreshold = true; 414 boolean canDoBetter = true; 415 416 while(overThreshold && canDoBetter){ 417 //System.out.println(compRes.getFullName() + " - downgrading"); 418 int procNumberWithoutChange = 0; 419 boolean improvement = false; 420 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 473 if(procNumberWithoutChange == processors.size() || improvement == false){ 474 //System.out.println(compRes.getFullName() + " - failed to improve"); 475 double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 421 476 for (Processor proc: processors){ 422 PState currPState = proc.getPowerInterface().getPState();423 //System.out.println(proc.getFullName() + " - checking");424 if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){425 //System.out.println("operating same level");426 procNumberWithoutChange++;427 continue;428 }429 if (proc.getFreeCores().size() == proc.getCores().size()){430 //System.out.println("free");431 procNumberWithoutChange++;432 continue;433 }434 435 double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency();436 477 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 437 478 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 438 if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){439 higherFrequency= pState.getFrequency();440 } 479 if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){ 480 nextFrequencyLevel = pState.getFrequency(); 481 } 441 482 } 442 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 443 if(higherFrequency > currentFrequencyLevel){ 444 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 445 currentFrequencyLevels.put(compRes.getFullName(), higherFrequency); 446 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 447 } 448 449 if(higherFrequency != currPState.getFrequency()) { 450 //System.out.println(proc.getFullName() + " - lowering frequency"); 451 proc.getPowerInterface().setFrequency(higherFrequency); 452 Node n = proc.getNode(); 453 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 454 455 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 456 Fan fan = (Fan) device; 457 458 if(fan.getChilledResources().contains(n.getFullName())){ 459 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 460 } 461 } 462 } 463 improvement = true; 464 } 465 if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){ 466 canDoBetter = false; 467 } else { 468 canDoBetter = true; 469 } 470 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){ 471 overThreshold = false; 472 break; 473 } 474 } 475 if(procNumberWithoutChange == processors.size() || improvement == false){ 476 //System.out.println(compRes.getFullName() + " - failed to improve"); 477 double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 478 for (Processor proc: processors){ 479 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 480 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 481 if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){ 482 nextFrequencyLevel = pState.getFrequency(); 483 } 484 } 485 } 486 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 487 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 488 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 489 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){ 490 canDoBetter = false; 491 } 492 procNumberWithoutChange = 0; 493 } 483 } 484 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 485 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 486 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 487 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){ 488 canDoBetter = false; 489 } 490 procNumberWithoutChange = 0; 494 491 } 495 496 } 497 } 498 499 } catch (ResourceException e) { 500 // TODO Auto-generated catch block 501 e.printStackTrace(); 502 } 492 } 493 494 } 495 } 496 503 497 } 504 498 -
DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationLowPower_PowerCapping_SP.java
r1440 r1449 9 9 10 10 import schedframe.events.scheduling.SchedulingEvent; 11 import schedframe.exceptions.ResourceException;12 11 import schedframe.resources.CoolEmAllResourceType; 13 12 import schedframe.resources.ResourceStatus; … … 218 217 219 218 private void powerCap(ResourceManager resManager){ 220 try { 221 222 for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){ 223 if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){ 224 loadThresholds(compRes); 225 } 226 double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue(); 227 //System.out.println(compRes.getFullName() + " current: " + powerConsumption); 228 if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){ 229 ComputeBox1 cb1 = (ComputeBox1) compRes; 230 List<Processor> processors = cb1.getProcessors(); 231 232 double currentFrequencyLevel = 0; 233 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 234 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 235 } else { 236 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 237 } 238 boolean overThreshold = true; 239 boolean canDoBetter = true; 240 241 while(overThreshold && canDoBetter){ 242 //System.out.println(compRes.getFullName() + " - downgrading"); 243 int procNumberWithoutChange = 0; 244 boolean improvement = false; 245 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 219 220 for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){ 221 if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){ 222 loadThresholds(compRes); 223 } 224 double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue(); 225 //System.out.println(compRes.getFullName() + " current: " + powerConsumption); 226 if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){ 227 ComputeBox1 cb1 = (ComputeBox1) compRes; 228 List<Processor> processors = cb1.getProcessors(); 229 230 double currentFrequencyLevel = 0; 231 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 232 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 233 } else { 234 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 235 } 236 boolean overThreshold = true; 237 boolean canDoBetter = true; 238 239 while(overThreshold && canDoBetter){ 240 //System.out.println(compRes.getFullName() + " - downgrading"); 241 int procNumberWithoutChange = 0; 242 boolean improvement = false; 243 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 244 for (Processor proc: processors){ 245 PState currPState = proc.getPowerInterface().getPState(); 246 //System.out.println(proc.getFullName() + " - checking"); 247 if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){ 248 //System.out.println("operating same level"); 249 procNumberWithoutChange++; 250 continue; 251 } 252 if (proc.getFreeCores().size() == proc.getCores().size()){ 253 //System.out.println("free"); 254 procNumberWithoutChange++; 255 continue; 256 } 257 258 double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency(); 259 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 260 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 261 if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){ 262 lowerFrequency = pState.getFrequency(); 263 } 264 } 265 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 266 if(lowerFrequency < currentFrequencyLevel){ 267 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 268 currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency); 269 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 270 } 271 272 if(lowerFrequency != currPState.getFrequency()) { 273 //System.out.println(proc.getFullName() + " - lowering frequency"); 274 proc.getPowerInterface().setFrequency(lowerFrequency); 275 Node n = proc.getNode(); 276 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 277 278 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 279 Fan fan = (Fan) device; 280 281 if(fan.getChilledResources().contains(n.getFullName())){ 282 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 283 } 284 } 285 } 286 improvement = true; 287 } 288 if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){ 289 canDoBetter = false; 290 } else { 291 canDoBetter = true; 292 } 293 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){ 294 overThreshold = false; 295 break; 296 } 297 } 298 if(procNumberWithoutChange == processors.size() || improvement == false){ 299 //System.out.println(compRes.getFullName() + " - failed to improve"); 300 double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency(); 246 301 for (Processor proc: processors){ 247 PState currPState = proc.getPowerInterface().getPState();248 //System.out.println(proc.getFullName() + " - checking");249 if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){250 //System.out.println("operating same level");251 procNumberWithoutChange++;252 continue;253 }254 if (proc.getFreeCores().size() == proc.getCores().size()){255 //System.out.println("free");256 procNumberWithoutChange++;257 continue;258 }259 260 double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency();261 302 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 262 303 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 263 if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){ 264 lowerFrequency = pState.getFrequency(); 265 } 266 } 267 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 268 if(lowerFrequency < currentFrequencyLevel){ 269 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 270 currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency); 271 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 272 } 273 274 if(lowerFrequency != currPState.getFrequency()) { 275 //System.out.println(proc.getFullName() + " - lowering frequency"); 276 proc.getPowerInterface().setFrequency(lowerFrequency); 277 Node n = proc.getNode(); 278 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 279 280 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 281 Fan fan = (Fan) device; 282 283 if(fan.getChilledResources().contains(n.getFullName())){ 284 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 285 } 304 if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){ 305 nextFrequencyLevel = pState.getFrequency(); 306 } 307 } 308 } 309 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 310 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 311 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 312 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){ 313 canDoBetter = false; 314 } 315 procNumberWithoutChange = 0; 316 } 317 } 318 319 } else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) { 320 ComputeBox1 cb1 = (ComputeBox1) compRes; 321 List<Processor> processors = cb1.getProcessors(); 322 323 double currentFrequencyLevel = 0; 324 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 325 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 326 } else { 327 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 328 } 329 boolean overThreshold = true; 330 boolean canDoBetter = true; 331 332 while(overThreshold && canDoBetter){ 333 //System.out.println(compRes.getFullName() + " - downgrading"); 334 int procNumberWithoutChange = 0; 335 boolean improvement = false; 336 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 337 for (Processor proc: processors){ 338 PState currPState = proc.getPowerInterface().getPState(); 339 //System.out.println(proc.getFullName() + " - checking"); 340 if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){ 341 //System.out.println("operating same level"); 342 procNumberWithoutChange++; 343 continue; 344 } 345 if (proc.getFreeCores().size() == proc.getCores().size()){ 346 //System.out.println("free"); 347 procNumberWithoutChange++; 348 continue; 349 } 350 351 double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency(); 352 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 353 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 354 if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){ 355 higherFrequency = pState.getFrequency(); 356 } 357 } 358 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 359 if(higherFrequency > currentFrequencyLevel){ 360 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 361 currentFrequencyLevels.put(compRes.getFullName(), higherFrequency); 362 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 363 } 364 365 if(higherFrequency != currPState.getFrequency()) { 366 //System.out.println(proc.getFullName() + " - lowering frequency"); 367 proc.getPowerInterface().setFrequency(higherFrequency); 368 Node n = proc.getNode(); 369 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 370 371 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 372 Fan fan = (Fan) device; 373 374 if(fan.getChilledResources().contains(n.getFullName())){ 375 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 286 376 } 287 377 } 288 improvement = true; 289 } 290 if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){ 291 canDoBetter = false; 292 } else { 293 canDoBetter = true; 294 } 295 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){ 296 overThreshold = false; 297 break; 298 } 299 } 300 if(procNumberWithoutChange == processors.size() || improvement == false){ 301 //System.out.println(compRes.getFullName() + " - failed to improve"); 302 double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency(); 303 for (Processor proc: processors){ 304 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 305 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 306 if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){ 307 nextFrequencyLevel = pState.getFrequency(); 308 } 309 } 310 } 311 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 312 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 313 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 314 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){ 315 canDoBetter = false; 316 } 317 procNumberWithoutChange = 0; 378 } 379 improvement = true; 380 } 381 if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){ 382 canDoBetter = false; 383 } else { 384 canDoBetter = true; 385 } 386 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){ 387 overThreshold = false; 388 break; 318 389 } 319 390 } 320 321 } else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) { 322 ComputeBox1 cb1 = (ComputeBox1) compRes; 323 List<Processor> processors = cb1.getProcessors(); 324 325 double currentFrequencyLevel = 0; 326 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 327 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 328 } else { 329 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 330 } 331 boolean overThreshold = true; 332 boolean canDoBetter = true; 333 334 while(overThreshold && canDoBetter){ 335 //System.out.println(compRes.getFullName() + " - downgrading"); 336 int procNumberWithoutChange = 0; 337 boolean improvement = false; 338 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 391 if(procNumberWithoutChange == processors.size() || improvement == false){ 392 //System.out.println(compRes.getFullName() + " - failed to improve"); 393 double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 339 394 for (Processor proc: processors){ 340 PState currPState = proc.getPowerInterface().getPState();341 //System.out.println(proc.getFullName() + " - checking");342 if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){343 //System.out.println("operating same level");344 procNumberWithoutChange++;345 continue;346 }347 if (proc.getFreeCores().size() == proc.getCores().size()){348 //System.out.println("free");349 procNumberWithoutChange++;350 continue;351 }352 353 double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency();354 395 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 355 396 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 356 if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){ 357 higherFrequency = pState.getFrequency(); 358 } 359 } 360 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 361 if(higherFrequency > currentFrequencyLevel){ 362 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 363 currentFrequencyLevels.put(compRes.getFullName(), higherFrequency); 364 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 365 } 366 367 if(higherFrequency != currPState.getFrequency()) { 368 //System.out.println(proc.getFullName() + " - lowering frequency"); 369 proc.getPowerInterface().setFrequency(higherFrequency); 370 Node n = proc.getNode(); 371 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 372 373 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 374 Fan fan = (Fan) device; 375 376 if(fan.getChilledResources().contains(n.getFullName())){ 377 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 378 } 379 } 380 } 381 improvement = true; 382 } 383 if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){ 384 canDoBetter = false; 385 } else { 386 canDoBetter = true; 387 } 388 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){ 389 overThreshold = false; 390 break; 391 } 392 } 393 if(procNumberWithoutChange == processors.size() || improvement == false){ 394 //System.out.println(compRes.getFullName() + " - failed to improve"); 395 double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 396 for (Processor proc: processors){ 397 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 398 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 399 if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){ 400 nextFrequencyLevel = pState.getFrequency(); 401 } 402 } 403 } 404 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 405 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 406 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 407 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){ 408 canDoBetter = false; 409 } 410 procNumberWithoutChange = 0; 411 } 397 if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){ 398 nextFrequencyLevel = pState.getFrequency(); 399 } 400 } 401 } 402 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 403 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 404 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 405 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){ 406 canDoBetter = false; 407 } 408 procNumberWithoutChange = 0; 412 409 } 413 414 } 415 } 416 417 } catch (ResourceException e) { 418 // TODO Auto-generated catch block 419 e.printStackTrace(); 420 } 410 } 411 412 } 413 } 414 421 415 } 422 416 -
DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_PowerCapping_SP.java
r1440 r1449 8 8 9 9 import schedframe.events.scheduling.SchedulingEvent; 10 import schedframe.exceptions.ResourceException;11 10 import schedframe.resources.CoolEmAllResourceType; 12 11 import schedframe.resources.ResourceStatus; … … 177 176 178 177 private void powerCap(ResourceManager resManager){ 179 try { 180 181 for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){ 182 if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){ 183 loadThresholds(compRes); 184 } 185 double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue(); 186 //System.out.println(compRes.getFullName() + " current: " + powerConsumption); 187 if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){ 188 ComputeBox1 cb1 = (ComputeBox1) compRes; 189 List<Processor> processors = cb1.getProcessors(); 190 191 double currentFrequencyLevel = 0; 192 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 193 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 194 } else { 195 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 196 } 197 boolean overThreshold = true; 198 boolean canDoBetter = true; 199 200 while(overThreshold && canDoBetter){ 201 //System.out.println(compRes.getFullName() + " - downgrading"); 202 int procNumberWithoutChange = 0; 203 boolean improvement = false; 204 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 178 179 for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){ 180 if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){ 181 loadThresholds(compRes); 182 } 183 double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue(); 184 //System.out.println(compRes.getFullName() + " current: " + powerConsumption); 185 if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){ 186 ComputeBox1 cb1 = (ComputeBox1) compRes; 187 List<Processor> processors = cb1.getProcessors(); 188 189 double currentFrequencyLevel = 0; 190 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 191 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 192 } else { 193 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 194 } 195 boolean overThreshold = true; 196 boolean canDoBetter = true; 197 198 while(overThreshold && canDoBetter){ 199 //System.out.println(compRes.getFullName() + " - downgrading"); 200 int procNumberWithoutChange = 0; 201 boolean improvement = false; 202 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 203 for (Processor proc: processors){ 204 PState currPState = proc.getPowerInterface().getPState(); 205 //System.out.println(proc.getFullName() + " - checking"); 206 if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){ 207 //System.out.println("operating same level"); 208 procNumberWithoutChange++; 209 continue; 210 } 211 if (proc.getFreeCores().size() == proc.getCores().size()){ 212 //System.out.println("free"); 213 procNumberWithoutChange++; 214 continue; 215 } 216 217 double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency(); 218 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 219 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 220 if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){ 221 lowerFrequency = pState.getFrequency(); 222 } 223 } 224 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 225 if(lowerFrequency < currentFrequencyLevel){ 226 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 227 currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency); 228 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 229 } 230 231 if(lowerFrequency != currPState.getFrequency()) { 232 //System.out.println(proc.getFullName() + " - lowering frequency"); 233 proc.getPowerInterface().setFrequency(lowerFrequency); 234 Node n = proc.getNode(); 235 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 236 237 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 238 Fan fan = (Fan) device; 239 240 if(fan.getChilledResources().contains(n.getFullName())){ 241 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 242 } 243 } 244 } 245 improvement = true; 246 } 247 if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){ 248 canDoBetter = false; 249 } else { 250 canDoBetter = true; 251 } 252 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){ 253 overThreshold = false; 254 break; 255 } 256 } 257 if(procNumberWithoutChange == processors.size() || improvement == false){ 258 //System.out.println(compRes.getFullName() + " - failed to improve"); 259 double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency(); 205 260 for (Processor proc: processors){ 206 PState currPState = proc.getPowerInterface().getPState();207 //System.out.println(proc.getFullName() + " - checking");208 if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){209 //System.out.println("operating same level");210 procNumberWithoutChange++;211 continue;212 }213 if (proc.getFreeCores().size() == proc.getCores().size()){214 //System.out.println("free");215 procNumberWithoutChange++;216 continue;217 }218 219 double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency();220 261 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 221 262 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 222 if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){ 223 lowerFrequency = pState.getFrequency(); 224 } 225 } 226 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 227 if(lowerFrequency < currentFrequencyLevel){ 228 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 229 currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency); 230 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 231 } 232 233 if(lowerFrequency != currPState.getFrequency()) { 234 //System.out.println(proc.getFullName() + " - lowering frequency"); 235 proc.getPowerInterface().setFrequency(lowerFrequency); 236 Node n = proc.getNode(); 237 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 238 239 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 240 Fan fan = (Fan) device; 241 242 if(fan.getChilledResources().contains(n.getFullName())){ 243 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 244 } 263 if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){ 264 nextFrequencyLevel = pState.getFrequency(); 265 } 266 } 267 } 268 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 269 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 270 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 271 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){ 272 canDoBetter = false; 273 } 274 procNumberWithoutChange = 0; 275 } 276 } 277 278 } else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) { 279 ComputeBox1 cb1 = (ComputeBox1) compRes; 280 List<Processor> processors = cb1.getProcessors(); 281 282 double currentFrequencyLevel = 0; 283 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 284 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 285 } else { 286 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 287 } 288 boolean overThreshold = true; 289 boolean canDoBetter = true; 290 291 while(overThreshold && canDoBetter){ 292 //System.out.println(compRes.getFullName() + " - downgrading"); 293 int procNumberWithoutChange = 0; 294 boolean improvement = false; 295 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 296 for (Processor proc: processors){ 297 PState currPState = proc.getPowerInterface().getPState(); 298 //System.out.println(proc.getFullName() + " - checking"); 299 if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){ 300 //System.out.println("operating same level"); 301 procNumberWithoutChange++; 302 continue; 303 } 304 if (proc.getFreeCores().size() == proc.getCores().size()){ 305 //System.out.println("free"); 306 procNumberWithoutChange++; 307 continue; 308 } 309 310 double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency(); 311 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 312 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 313 if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){ 314 higherFrequency = pState.getFrequency(); 315 } 316 } 317 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 318 if(higherFrequency > currentFrequencyLevel){ 319 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 320 currentFrequencyLevels.put(compRes.getFullName(), higherFrequency); 321 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 322 } 323 324 if(higherFrequency != currPState.getFrequency()) { 325 //System.out.println(proc.getFullName() + " - lowering frequency"); 326 proc.getPowerInterface().setFrequency(higherFrequency); 327 Node n = proc.getNode(); 328 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 329 330 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 331 Fan fan = (Fan) device; 332 333 if(fan.getChilledResources().contains(n.getFullName())){ 334 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 245 335 } 246 336 } 247 improvement = true; 248 } 249 if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){ 250 canDoBetter = false; 251 } else { 252 canDoBetter = true; 253 } 254 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){ 255 overThreshold = false; 256 break; 257 } 258 } 259 if(procNumberWithoutChange == processors.size() || improvement == false){ 260 //System.out.println(compRes.getFullName() + " - failed to improve"); 261 double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency(); 262 for (Processor proc: processors){ 263 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 264 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 265 if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){ 266 nextFrequencyLevel = pState.getFrequency(); 267 } 268 } 269 } 270 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 271 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 272 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 273 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){ 274 canDoBetter = false; 275 } 276 procNumberWithoutChange = 0; 337 } 338 improvement = true; 339 } 340 if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){ 341 canDoBetter = false; 342 } else { 343 canDoBetter = true; 344 } 345 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){ 346 overThreshold = false; 347 break; 277 348 } 278 349 } 279 280 } else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) { 281 ComputeBox1 cb1 = (ComputeBox1) compRes; 282 List<Processor> processors = cb1.getProcessors(); 283 284 double currentFrequencyLevel = 0; 285 if(currentFrequencyLevels.get(compRes.getFullName()) != null){ 286 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 287 } else { 288 currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 289 } 290 boolean overThreshold = true; 291 boolean canDoBetter = true; 292 293 while(overThreshold && canDoBetter){ 294 //System.out.println(compRes.getFullName() + " - downgrading"); 295 int procNumberWithoutChange = 0; 296 boolean improvement = false; 297 //System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel); 350 if(procNumberWithoutChange == processors.size() || improvement == false){ 351 //System.out.println(compRes.getFullName() + " - failed to improve"); 352 double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 298 353 for (Processor proc: processors){ 299 PState currPState = proc.getPowerInterface().getPState();300 //System.out.println(proc.getFullName() + " - checking");301 if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){302 //System.out.println("operating same level");303 procNumberWithoutChange++;304 continue;305 }306 if (proc.getFreeCores().size() == proc.getCores().size()){307 //System.out.println("free");308 procNumberWithoutChange++;309 continue;310 }311 312 double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency();313 354 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 314 355 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 315 if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){ 316 higherFrequency = pState.getFrequency(); 317 } 318 } 319 //System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency); 320 if(higherFrequency > currentFrequencyLevel){ 321 //System.out.println(compRes.getFullName() + " - changing current frequency level"); 322 currentFrequencyLevels.put(compRes.getFullName(), higherFrequency); 323 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 324 } 325 326 if(higherFrequency != currPState.getFrequency()) { 327 //System.out.println(proc.getFullName() + " - lowering frequency"); 328 proc.getPowerInterface().setFrequency(higherFrequency); 329 Node n = proc.getNode(); 330 for(Device device: n.getParent().getResourceCharacteristic().getDevices()){ 331 332 if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ 333 Fan fan = (Fan) device; 334 335 if(fan.getChilledResources().contains(n.getFullName())){ 336 fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2")); 337 } 338 } 339 } 340 improvement = true; 341 } 342 if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){ 343 canDoBetter = false; 344 } else { 345 canDoBetter = true; 346 } 347 if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){ 348 overThreshold = false; 349 break; 350 } 351 } 352 if(procNumberWithoutChange == processors.size() || improvement == false){ 353 //System.out.println(compRes.getFullName() + " - failed to improve"); 354 double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency(); 355 for (Processor proc: processors){ 356 for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ 357 PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); 358 if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){ 359 nextFrequencyLevel = pState.getFrequency(); 360 } 361 } 362 } 363 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 364 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 365 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 366 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){ 367 canDoBetter = false; 368 } 369 procNumberWithoutChange = 0; 370 } 356 if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){ 357 nextFrequencyLevel = pState.getFrequency(); 358 } 359 } 360 } 361 //System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel); 362 currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel); 363 currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName()); 364 if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){ 365 canDoBetter = false; 366 } 367 procNumberWithoutChange = 0; 371 368 } 372 373 } 374 } 375 376 } catch (ResourceException e) { 377 // TODO Auto-generated catch block 378 e.printStackTrace(); 379 } 369 } 370 371 } 372 } 373 380 374 } 381 375 -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/GridResourceDiscovery.java
r1396 r1449 108 108 109 109 @Override 110 public List<? extends ComputingResource> getResourcesOfType(ResourceType type) throws ResourceException{110 public List<? extends ComputingResource> getResourcesOfType(ResourceType type){ 111 111 throw new UnsupportedOperationException("Not available at Grid level. Please use getResources() method instead to explore available resource providers"); 112 112 } … … 118 118 119 119 @Override 120 public List<? extends ComputingResource> getResourcesByTypeWithStatus(ResourceType type, ResourceStatus status) 121 throws ResourceException { 120 public List<? extends ComputingResource> getResourcesByTypeWithStatus(ResourceType type, ResourceStatus status) { 122 121 throw new UnsupportedOperationException("Not available at Grid level. Please use getResources() method instead to explore available resource providers"); 123 122 } -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/ResourceManager.java
r1374 r1449 17 17 public boolean areResourcesAchievable(ResourceType type); 18 18 19 public List<? extends ComputingResource> getResourcesOfType(ResourceType type) throws ResourceException;19 public List<? extends ComputingResource> getResourcesOfType(ResourceType type); 20 20 21 21 public ComputingResource getResourceByName(String resourceName); 22 22 23 public List<? extends ComputingResource> getResourcesByTypeWithStatus(ResourceType type, ResourceStatus status) throws ResourceException;23 public List<? extends ComputingResource> getResourcesByTypeWithStatus(ResourceType type, ResourceStatus status); 24 24 25 25 public Map<ResourceUnitName, List<ResourceUnit>> getSharedResourceUnits();
Note: See TracChangeset
for help on using the changeset viewer.