当前位置: 首页>>代码示例>>Java>>正文


Java VmStateHistoryEntry.getAllocatedMips方法代码示例

本文整理汇总了Java中org.cloudbus.cloudsim.VmStateHistoryEntry.getAllocatedMips方法的典型用法代码示例。如果您正苦于以下问题:Java VmStateHistoryEntry.getAllocatedMips方法的具体用法?Java VmStateHistoryEntry.getAllocatedMips怎么用?Java VmStateHistoryEntry.getAllocatedMips使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.cloudbus.cloudsim.VmStateHistoryEntry的用法示例。


在下文中一共展示了VmStateHistoryEntry.getAllocatedMips方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:Udacity2048,项目名称:CloudSimDisk,代码行数:63,代码来源:Helper.java

示例2: 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;
}
 
开发者ID:demiaowu,项目名称:annotation-of-cloudsim3.0.3,代码行数:63,代码来源:Helper.java

示例3: 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;
}
 
开发者ID:StVak,项目名称:cloudsimPowerStats,代码行数:61,代码来源:PowerMonitor.java


注:本文中的org.cloudbus.cloudsim.VmStateHistoryEntry.getAllocatedMips方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。