ankgro / cloudsim

Automatically exported from code.google.com/p/cloudsim
0 stars 1 forks source link

HostDynamicWorkload.updateVmsProcessing() throws NullPointerException #20

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use r100 trunk CloudSim
2. Run DVFS.java in power examples
3. Use VmSchedulerSpaceShared instead of VmSchedulerTimeShared (default) and 
recompile, run again

What is the expected output? What do you see instead?

New resource usage for the time frame starting at 5.00:

5.00: [Host #0] Total allocated MIPS for VM #0 (Host #0) is 222.70, was requeste
d 222.70 out of total 250.00 (89.08%)
java.lang.NullPointerException
        at org.cloudbus.cloudsim.HostDynamicWorkload.updateVmsProcessing(Unknown
 Source)
        at org.cloudbus.cloudsim.power.PowerDatacenter.updateCloudetProcessingWi
thoutSchedulingFutureEventsForce(Unknown Source)
        at org.cloudbus.cloudsim.power.PowerDatacenter.updateCloudletProcessing(
Unknown Source)
        at org.cloudbus.cloudsim.Datacenter.processEvent(Unknown Source)
        at org.cloudbus.cloudsim.core.SimEntity.run(Unknown Source)
        at org.cloudbus.cloudsim.core.CloudSim.runClockTick(Unknown Source)
        at org.cloudbus.cloudsim.core.CloudSim.run(Unknown Source)
        at org.cloudbus.cloudsim.core.CloudSim.startSimulation(Unknown Source)
        at DVFS.main(DVFS.java:84)
Unwanted errors happen
DVFS example finished!

What version of the product are you using? On what operating system?
r100 trunk CloudSim
Windows XP SP3
JDK 1.6.0_26

Please provide any additional information below.

I traced the code. In HostDynamicWorkload.updateVmsProcessing() method:

List<Pe> pes = getVmScheduler().getPesAllocatedForVM(vm);

may return null in VmSchedulerSpaceShared. 
(VmSchedulerSpaceShared.getPesAllocatedForVM)
Thus when run this line:

for (Pe pe : pes) {

It will throw a NullPointerException.

I don't know why VmSchedulerSpaceShared.getPesAllocatedForVM returns null, but 
we can prevent it by adding an assertion before for().

if (pes != null) {
   for () ...
}

Original issue reported on code.google.com by scrib...@gmail.com on 26 Nov 2011 at 6:07

Attachments:

GoogleCodeExporter commented 8 years ago
Perhaps a duplicate of issue #12

Original comment by rodrigo.calheiros on 15 Dec 2011 at 3:58

GoogleCodeExporter commented 8 years ago
The power package has been substantially updated; therefore, this issue may not 
be relevant any more. Please try the new code from the repository.

Original comment by anton.be...@gmail.com on 6 Jan 2012 at 8:09

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I find a solution for this problem.  When host are defined  please check  which 
model of scheduler is defined . I changed VmSchedulerSpaceShared(peList) to   
new VmSchedulerTimeShared(peList)  then it become true.  

When  we use different type of scheduler during a run time the list of pe 
become Null 

hostList.add(
                                new PowerHost(
                                        i,
                                        new RamProvisionerSimple(ram),
                                        new BwProvisionerSimple(bw),
                                        storage,
                                        peList,
                                        new VmSchedulerTimeShared(peList)                                        ,
                                        new PowerModelLinear(maxPower, staticPowerPercent) 

Original comment by babake...@gmail.com on 6 Mar 2014 at 10:23