本文整理汇总了Java中org.cloudbus.cloudsim.HostDynamicWorkload.getStateHistory方法的典型用法代码示例。如果您正苦于以下问题:Java HostDynamicWorkload.getStateHistory方法的具体用法?Java HostDynamicWorkload.getStateHistory怎么用?Java HostDynamicWorkload.getStateHistory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cloudbus.cloudsim.HostDynamicWorkload
的用法示例。
在下文中一共展示了HostDynamicWorkload.getStateHistory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSlaTimePerActiveHost
import org.cloudbus.cloudsim.HostDynamicWorkload; //导入方法依赖的package包/类
/**
* Gets the sla time per active host.
*
* @param hosts the hosts
* @return the sla time per active host
*/
protected static double getSlaTimePerActiveHost(List<Host> hosts) {
double slaViolationTimePerHost = 0;
double totalTime = 0;
for (Host _host : hosts) {
HostDynamicWorkload host = (HostDynamicWorkload) _host;
double previousTime = -1;
double previousAllocated = 0;
double previousRequested = 0;
boolean previousIsActive = true;
for (HostStateHistoryEntry entry : host.getStateHistory()) {
if (previousTime != -1 && previousIsActive) {
double timeDiff = entry.getTime() - previousTime;
totalTime += timeDiff;
if (previousAllocated < previousRequested) {
slaViolationTimePerHost += timeDiff;
}
}
previousAllocated = entry.getAllocatedMips();
previousRequested = entry.getRequestedMips();
previousTime = entry.getTime();
previousIsActive = entry.isActive();
}
}
return slaViolationTimePerHost / totalTime;
}
示例2: getSlaTimePerHost
import org.cloudbus.cloudsim.HostDynamicWorkload; //导入方法依赖的package包/类
/**
* Gets the sla time per host.
*
* @param hosts the hosts
* @return the sla time per host
*/
protected static double getSlaTimePerHost(List<Host> hosts) {
double slaViolationTimePerHost = 0;
double totalTime = 0;
for (Host _host : hosts) {
HostDynamicWorkload host = (HostDynamicWorkload) _host;
double previousTime = -1;
double previousAllocated = 0;
double previousRequested = 0;
for (HostStateHistoryEntry entry : host.getStateHistory()) {
if (previousTime != -1) {
double timeDiff = entry.getTime() - previousTime;
totalTime += timeDiff;
if (previousAllocated < previousRequested) {
slaViolationTimePerHost += timeDiff;
}
}
previousAllocated = entry.getAllocatedMips();
previousRequested = entry.getRequestedMips();
previousTime = entry.getTime();
}
}
return slaViolationTimePerHost / totalTime;
}