本文整理汇总了Java中org.cloudbus.cloudsim.VmStateHistoryEntry类的典型用法代码示例。如果您正苦于以下问题:Java VmStateHistoryEntry类的具体用法?Java VmStateHistoryEntry怎么用?Java VmStateHistoryEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VmStateHistoryEntry类属于org.cloudbus.cloudsim包,在下文中一共展示了VmStateHistoryEntry类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTimesBeforeVmMigration
import org.cloudbus.cloudsim.VmStateHistoryEntry; //导入依赖的package包/类
/**
* Gets the times before vm migration.
*
* @param vms the vms
* @return the times before vm migration
*/
public static List<Double> getTimesBeforeVmMigration(List<Vm> vms) {
List<Double> timeBeforeVmMigration = new LinkedList<Double>();
for (Vm vm : vms) {
boolean previousIsInMigration = false;
double lastTimeMigrationFinished = 0;
for (VmStateHistoryEntry entry : vm.getStateHistory()) {
if (previousIsInMigration == true && entry.isInMigration() == false) {
timeBeforeVmMigration.add(entry.getTime() - lastTimeMigrationFinished);
}
if (previousIsInMigration == false && entry.isInMigration() == true) {
lastTimeMigrationFinished = entry.getTime();
}
previousIsInMigration = entry.isInMigration();
}
}
return timeBeforeVmMigration;
}
示例2: getVmListTotalInstCompleted
import org.cloudbus.cloudsim.VmStateHistoryEntry; //导入依赖的package包/类
public int getVmListTotalInstCompleted() {
Log.printLine("Started");
Log.print(hostList.size() + " ");
for (Host host : hostList) {
Log.print(host.getId() + " vmListsize " + host.getVmList().size() + ", ");
for (Vm vm : vmList) {
for (VmStateHistoryEntry vmhistory : vm.getStateHistory()) {
// if (!vmhistory.isInMigration())
vmListTotalInstCompleted += vmhistory.getRequestedMips();
}
}
}
return vmListTotalInstCompleted;
}
示例3: getSlaMetrics
import org.cloudbus.cloudsim.VmStateHistoryEntry; //导入依赖的package包/类
/**
* Gets the sla metrics.
*
* @param vms the vms
* @return the sla metrics
*/
protected static Map<String, Double> getSlaMetrics(List<Vm> vms) {
Map<String, Double> metrics = new HashMap<String, Double>();
List<Double> slaViolation = new LinkedList<Double>();
double totalAllocated = 0;
double totalRequested = 0;
double totalUnderAllocatedDueToMigration = 0;
for (Vm vm : vms) {
double vmTotalAllocated = 0;
double vmTotalRequested = 0;
double vmUnderAllocatedDueToMigration = 0;
double previousTime = -1;
double previousAllocated = 0;
double previousRequested = 0;
boolean previousIsInMigration = false;
for (VmStateHistoryEntry entry : vm.getStateHistory()) {
if (previousTime != -1) {
double timeDiff = entry.getTime() - previousTime;
vmTotalAllocated += previousAllocated * timeDiff;
vmTotalRequested += previousRequested * timeDiff;
if (previousAllocated < previousRequested) {
slaViolation.add((previousRequested - previousAllocated) / previousRequested);
if (previousIsInMigration) {
vmUnderAllocatedDueToMigration += (previousRequested - previousAllocated)
* timeDiff;
}
}
}
previousAllocated = entry.getAllocatedMips();
previousRequested = entry.getRequestedMips();
previousTime = entry.getTime();
previousIsInMigration = entry.isInMigration();
}
totalAllocated += vmTotalAllocated;
totalRequested += vmTotalRequested;
totalUnderAllocatedDueToMigration += vmUnderAllocatedDueToMigration;
}
metrics.put("overall", (totalRequested - totalAllocated) / totalRequested);
if (slaViolation.isEmpty()) {
metrics.put("average", 0.);
} else {
metrics.put("average", MathUtil.mean(slaViolation));
}
metrics.put("underallocated_migration", totalUnderAllocatedDueToMigration / totalRequested);
// metrics.put("sla_time_per_vm_with_migration", slaViolationTimePerVmWithMigration /
// totalTime);
// metrics.put("sla_time_per_vm_without_migration", slaViolationTimePerVmWithoutMigration /
// totalTime);
return metrics;
}
示例4: getSlaMetrics
import org.cloudbus.cloudsim.VmStateHistoryEntry; //导入依赖的package包/类
/**
* Service level agreement 服务等级协议 : Gets the sla metrics.
*
* @param vms the vms
* @return the sla metrics
*/
protected static Map<String, Double> getSlaMetrics(List<Vm> vms) {
Map<String, Double> metrics = new HashMap<String, Double>();
List<Double> slaViolation = new LinkedList<Double>();
double totalAllocated = 0;
double totalRequested = 0;
double totalUnderAllocatedDueToMigration = 0;
for (Vm vm : vms) {
double vmTotalAllocated = 0;
double vmTotalRequested = 0;
double vmUnderAllocatedDueToMigration = 0;//由于虚拟机迁移造成的
double previousTime = -1;
double previousAllocated = 0;
double previousRequested = 0;
boolean previousIsInMigration = false;
// 虚拟机状态的历史
for (VmStateHistoryEntry entry : vm.getStateHistory()) {
if (previousTime != -1) {//第一次分配
double timeDiff = entry.getTime() - previousTime;
vmTotalAllocated += previousAllocated * timeDiff;
vmTotalRequested += previousRequested * timeDiff;
if (previousAllocated < previousRequested) { //
slaViolation.add((previousRequested - previousAllocated) / previousRequested);
if (previousIsInMigration) {
vmUnderAllocatedDueToMigration += (previousRequested - previousAllocated)
* timeDiff;
}
}
}
previousAllocated = entry.getAllocatedMips();
previousRequested = entry.getRequestedMips();
previousTime = entry.getTime();
previousIsInMigration = entry.isInMigration();
}
totalAllocated += vmTotalAllocated;
totalRequested += vmTotalRequested;
totalUnderAllocatedDueToMigration += vmUnderAllocatedDueToMigration;
}
metrics.put("overall", (totalRequested - totalAllocated) / totalRequested);
if (slaViolation.isEmpty()) {
metrics.put("average", 0.);
} else {
metrics.put("average", MathUtil.mean(slaViolation));
}
metrics.put("underallocated_migration", totalUnderAllocatedDueToMigration / totalRequested);
// metrics.put("sla_time_per_vm_with_migration", slaViolationTimePerVmWithMigration /
// totalTime);
// metrics.put("sla_time_per_vm_without_migration", slaViolationTimePerVmWithoutMigration /
// totalTime);
return metrics;
}
示例5: getSlaMetrics
import org.cloudbus.cloudsim.VmStateHistoryEntry; //导入依赖的package包/类
protected static Map<String, Double> getSlaMetrics(List<Vm> vms) {
Map<String, Double> metrics = new HashMap<String, Double>();
List<Double> slaViolation = new LinkedList<Double>();
double totalAllocated = 0;
double totalRequested = 0;
double totalUnderAllocatedDueToMigration = 0;
for (Vm vm : vms) {
double vmTotalAllocated = 0;
double vmTotalRequested = 0;
double vmUnderAllocatedDueToMigration = 0;
double previousTime = -1;
double previousAllocated = 0;
double previousRequested = 0;
boolean previousIsInMigration = false;
for (VmStateHistoryEntry entry : vm.getStateHistory()) {
if (previousTime != -1) {
double timeDiff = entry.getTime() - previousTime;
vmTotalAllocated += previousAllocated * timeDiff;
vmTotalRequested += previousRequested * timeDiff;
if (previousAllocated < previousRequested) {
slaViolation
.add((previousRequested - previousAllocated) / previousRequested);
if (previousIsInMigration) {
vmUnderAllocatedDueToMigration += (previousRequested - previousAllocated) * timeDiff;
}
}
}
previousAllocated = entry.getAllocatedMips();
previousRequested = entry.getRequestedMips();
previousTime = entry.getTime();
previousIsInMigration = entry.isInMigration();
}
totalAllocated += vmTotalAllocated;
totalRequested += vmTotalRequested;
totalUnderAllocatedDueToMigration += vmUnderAllocatedDueToMigration;
}
metrics.put("overall",
(totalRequested - totalAllocated) / totalRequested);
if (slaViolation.isEmpty()) {
metrics.put("average", 0.);
} else {
metrics.put("average", MathUtil.mean(slaViolation));
}
metrics.put("underallocated_migration",
totalUnderAllocatedDueToMigration / totalRequested);
// metrics.put("sla_time_per_vm_with_migration",
// slaViolationTimePerVmWithMigration /
// totalTime);
// metrics.put("sla_time_per_vm_without_migration",
// slaViolationTimePerVmWithoutMigration /
// totalTime);
return metrics;
}