本文整理汇总了Java中org.cloudbus.cloudsim.VmStateHistoryEntry.isInMigration方法的典型用法代码示例。如果您正苦于以下问题:Java VmStateHistoryEntry.isInMigration方法的具体用法?Java VmStateHistoryEntry.isInMigration怎么用?Java VmStateHistoryEntry.isInMigration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cloudbus.cloudsim.VmStateHistoryEntry
的用法示例。
在下文中一共展示了VmStateHistoryEntry.isInMigration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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;
}
示例4: 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;
}