Unverified Commit 24a918fe authored by Manoel Campos's avatar Manoel Campos
Browse files

Fix build error


Signed-off-by: default avatarManoel Campos <manoelcampos@gmail.com>
parent 9e2ed686
......@@ -69,7 +69,7 @@ public abstract class VmAllocationPolicyMigrationAbstract extends VmAllocationPo
* A map of CPU utilization history (in percentage) for each host, where
* each key is a hos and each value is the CPU utilization percentage history.
*
* @todo there is inconsistence between these data.
* @todo there is inconsistency between these data.
* Into the Host, it is stored the actual utilization for the given time.
* Here it is stored the utilization as it was computed
* by the VmAllocationPolicy implementation.
......@@ -336,7 +336,7 @@ public abstract class VmAllocationPolicyMigrationAbstract extends VmAllocationPo
* @param hostStream a {@link Stream} containing the Hosts after passing the basic filtering
* @return the Hosts {@link Stream} after applying the additional filters
*/
protected Stream<Host> additionalHostFilters(final Vm vm, final Stream<Host> hostStream){
private Stream<Host> additionalHostFilters(final Vm vm, final Stream<Host> hostStream){
return hostStream.filter(h -> getPowerAfterAllocation(h, vm) > 0);
}
......@@ -346,7 +346,7 @@ public abstract class VmAllocationPolicyMigrationAbstract extends VmAllocationPo
* @param migrationMap the migration map
* @return the list
*/
protected List<Host> extractHostListFromMigrationMap(final Map<Vm, Host> migrationMap) {
private List<Host> extractHostListFromMigrationMap(final Map<Vm, Host> migrationMap) {
return migrationMap.entrySet().stream()
.map(Map.Entry::getValue)
.collect(toList());
......@@ -360,7 +360,7 @@ public abstract class VmAllocationPolicyMigrationAbstract extends VmAllocationPo
* @return the new VM placement map where each key is a VM
* and each value is the Host to place it.
*/
protected Map<Vm, Host> getMigrationMapFromOverloadedHosts(final Set<Host> overloadedHosts) {
private Map<Vm, Host> getMigrationMapFromOverloadedHosts(final Set<Host> overloadedHosts) {
if(overloadedHosts.isEmpty()) {
return new HashMap<>();
}
......@@ -385,9 +385,9 @@ public abstract class VmAllocationPolicyMigrationAbstract extends VmAllocationPo
* destination hosts
* @return the new vm placement for the given VMs
*/
protected Map<Vm, Host> getNewVmPlacementFromUnderloadedHost(
final List<? extends Vm> vmsToMigrate,
final Set<? extends Host> excludedHosts)
private Map<Vm, Host> getNewVmPlacementFromUnderloadedHost(
final List<? extends Vm> vmsToMigrate,
final Set<? extends Host> excludedHosts)
{
final Map<Vm, Host> migrationMap = new HashMap<>();
sortByCpuUtilization(vmsToMigrate, getDatacenter().getSimulation().clock());
......@@ -435,7 +435,7 @@ public abstract class VmAllocationPolicyMigrationAbstract extends VmAllocationPo
* @param overloadedHosts the List of overloaded Hosts
* @return the VMs to migrate from hosts
*/
protected List<Vm> getVmsToMigrateFromOverloadedHosts(final Set<Host> overloadedHosts) {
private List<Vm> getVmsToMigrateFromOverloadedHosts(final Set<Host> overloadedHosts) {
final List<Vm> vmsToMigrate = new LinkedList<>();
for (final Host host : overloadedHosts) {
vmsToMigrate.addAll(getVmsToMigrateFromOverloadedHost(host));
......@@ -583,7 +583,7 @@ public abstract class VmAllocationPolicyMigrationAbstract extends VmAllocationPo
*
* @see #savedAllocation
*/
protected void saveAllocation() {
private void saveAllocation() {
savedAllocation.clear();
for (final Host host : getHostList()) {
for (final Vm vm : host.getVmList()) {
......@@ -599,7 +599,7 @@ public abstract class VmAllocationPolicyMigrationAbstract extends VmAllocationPo
*
* @see #savedAllocation
*/
protected void restoreAllocation() {
private void restoreAllocation() {
for (final Host host : getHostList()) {
host.destroyAllVms();
host.reallocateMigratingInVms();
......@@ -627,8 +627,8 @@ public abstract class VmAllocationPolicyMigrationAbstract extends VmAllocationPo
protected double getPowerAfterAllocation(final Host host, final Vm vm) {
try {
return host.getPowerModel().getPower(getMaxUtilizationAfterAllocation(host, vm));
} catch (Exception e) {
Log.printFormattedLine("[ERROR] Power consumption for Host %d could not be determined: ", host.getId(), e.getMessage());
} catch (IllegalArgumentException e) {
Log.printFormattedLine("[ERROR] Power consumption for Host %d could not be determined: %s", host.getId(), e.getMessage());
}
return 0;
......@@ -691,15 +691,6 @@ public abstract class VmAllocationPolicyMigrationAbstract extends VmAllocationPo
}
}
/**
* Gets the saved allocation.
*
* @return the saved allocation
*/
protected Map<Vm, Host> getSavedAllocation() {
return savedAllocation;
}
/**
* Sets the vm selection policy.
*
......
......@@ -92,7 +92,6 @@ public class DatacenterSimple extends CloudSimEntity implements Datacenter {
super(simulation);
setHostList(hostList);
setVmAllocationPolicy(vmAllocationPolicy);
setLastProcessTime(0.0);
setSchedulingInterval(0);
setStorageList(new ArrayList<>());
......@@ -100,6 +99,8 @@ public class DatacenterSimple extends CloudSimEntity implements Datacenter {
this.characteristics = new DatacenterCharacteristicsSimple(this);
this.bandwidthPercentForMigration = DEF_BANDWIDTH_PERCENT_FOR_MIGRATION;
migrationsEnabled = true;
setVmAllocationPolicy(vmAllocationPolicy);
}
private void setHostList(final List<? extends Host> hostList) {
......
......@@ -214,7 +214,7 @@ public class BriteNetworkTopology implements NetworkTopology {
try {
return delayMatrix.getDelay(map.get(srcID), map.get(destID));
} catch (Exception e) {
} catch (ArrayIndexOutOfBoundsException e) {
return 0.0;
}
}
......
......@@ -87,9 +87,9 @@ public class FileAttribute {
// set the file creation time. This is absolute time
final Calendar cal =
file.getDatacenter().getSimulation() != null ?
file.getDatacenter().getSimulation().getCalendar() :
Calendar.getInstance();
file.getDatacenter().getSimulation() == null ?
Calendar.getInstance() :
file.getDatacenter().getSimulation().getCalendar();
final Date date = cal.getTime();
creationTime = date.getTime();
......
......@@ -140,7 +140,7 @@ public class HarddriveStorage implements FileStorage {
Objects.requireNonNull(file);
if(!reservedStorage.isResourceAmountBeingUsed((long)file.getSize())){
throw new RuntimeException("The file size wasn't previously reserved in order to add a reserved file.");
throw new IllegalStateException("The file size wasn't previously reserved in order to add a reserved file.");
}
final long fileSize = file.getSize();
......
......@@ -36,7 +36,7 @@ public abstract class VmSchedulerAbstract implements VmScheduler {
/**
* @see #getRequestedMipsMap()
*/
private Map<Vm, List<Double>> requestedMipsMap;
private final Map<Vm, List<Double>> requestedMipsMap;
/**
* @see #getHost()
......
......@@ -382,15 +382,13 @@ public class WorkloadFileReader implements WorkloadReader {
// get the submit time
final Long l = Long.valueOf(array[submitTime].trim());
//@todo the submission time would be used as the Cloudlet submission delay
final long submitTime = l.intValue();
// if the required run time field is ignored, then use the actual run time
obj = Integer.valueOf(array[runTime].trim());
int runTime = obj;
final int userID = Integer.valueOf(array[userId].trim());
final int groupID = Integer.valueOf(array[groupId].trim());
// according to the SWF manual, runtime of 0 is possible due
// to rounding down. E.g. runtime is 0.4 seconds -> runtime = 0
if (runTime <= 0) {
......
......@@ -123,7 +123,7 @@ public class UtilizationModelStochastic extends UtilizationModelAbstract {
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(filename))){
oos.writeObject(getHistory());
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
}
......@@ -137,7 +137,9 @@ public class UtilizationModelStochastic extends UtilizationModelAbstract {
public void loadHistory(String filename) {
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename))) {
setHistory((Map<Double, Double>) ois.readObject());
} catch (ClassNotFoundException|IOException e) {
} catch (IOException e) {
throw new UncheckedIOException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
......
......@@ -65,6 +65,7 @@ public class CloudletBuilder extends Builder {
private List<String> requiredFiles;
public CloudletBuilder(final BrokerBuilderDecorator brokerBuilder, final DatacenterBrokerSimple broker) {
super();
Objects.requireNonNull(brokerBuilder);
Objects.requireNonNull(broker);
......
......@@ -57,6 +57,7 @@ public class HostBuilder extends Builder {
private final List<Host> hosts;
public HostBuilder() {
super();
this.hosts = new ArrayList<>();
}
......
......@@ -26,7 +26,7 @@ public class VmAllocationPolicySimpleTest {
@Before
public void setUp(){
policy = createVmAllocationPolicy(new int[]{4, 2, 6, 5});
policy = createVmAllocationPolicy(4, 2, 6, 5);
}
/**
......@@ -37,7 +37,7 @@ public class VmAllocationPolicySimpleTest {
* This array will define the number of Hosts and its PEs.
* @return
*/
private VmAllocationPolicySimple createVmAllocationPolicy(int[] freePesByHost) {
private VmAllocationPolicySimple createVmAllocationPolicy(int... freePesByHost) {
final Map<Host, Long> hostFreePesMap = new HashMap<>(freePesByHost.length);
final List<Host> hosts = new ArrayList<>(freePesByHost.length);
for(int i = 1; i <= freePesByHost.length; i++) {
......
......@@ -61,7 +61,6 @@ public class CloudletTest {
@Test
public void testNullObjectStatus(){
assertEquals("", Cloudlet.NULL.getHistory());
assertFalse(Cloudlet.NULL.setStatus(Cloudlet.Status.SUCCESS));
assertEquals(Cloudlet.Status.FAILED, Cloudlet.NULL.getStatus());
assertTrue(Cloudlet.NULL.getRequiredFiles().isEmpty());
......
......@@ -57,7 +57,7 @@ public class PeTest {
@Test
public void testSetMips() {
PeSimple pe = createPe();
final PeSimple pe = createPe();
assertEquals(MIPS, pe.getCapacity(), 0);
pe.setCapacity(MIPS / 2);
assertEquals(MIPS / 2, pe.getCapacity(), 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment