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


Java Vm.getNumberOfPes方法代码示例

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


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

示例1: allocateHostForVm

import org.cloudbus.cloudsim.Vm; //导入方法依赖的package包/类
@Override
public boolean allocateHostForVm(Vm vm, Host host) {
	if (host.vmCreate(vm)) { // if vm has been succesfully created in the host
		getVmTable().put(vm.getUid(), host);

		int requiredPes = vm.getNumberOfPes();
		int idx = getHostList().indexOf(host);
		getUsedPes().put(vm.getUid(), requiredPes);
		getFreePes().set(idx, getFreePes().get(idx) - requiredPes);

		Log.formatLine(
				"%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(),
				CloudSim.clock());
		return true;
	}

	return false;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:19,代码来源:NetworkVmAllocationPolicy.java

示例2: getExecutionTime

import org.cloudbus.cloudsim.Vm; //导入方法依赖的package包/类
protected double getExecutionTime(Vm VM, Cloudlet cloudlet){
	return (cloudlet.getCloudletLength()/(VM.getNumberOfPes()*VM.getMips()) + cloudlet.getCloudletFileSize()/VM.getBw());
}
 
开发者ID:sidjee,项目名称:Ant-Colony-Optimization-Framework,代码行数:4,代码来源:ACOImplement.java

示例3: getExecutionTime

import org.cloudbus.cloudsim.Vm; //导入方法依赖的package包/类
protected double getExecutionTime(Vm VM, Cloudlet cloudlet){
	return (cloudlet.getCloudletLength()/(VM.getNumberOfPes()*VM.getMips()));
}
 
开发者ID:sidjee,项目名称:Ant-Colony-Optimization-Framework,代码行数:4,代码来源:LBACO.java

示例4: allocateHostForVm

import org.cloudbus.cloudsim.Vm; //导入方法依赖的package包/类
/**
 * Allocates a host for a given VM.
 * 
 * @param vm VM specification
 * @return $true if the host could be allocated; $false otherwise
 * @pre $none
 * @post $none
 */
@Override
public boolean allocateHostForVm(Vm vm) {
	if (getVmTable().containsKey(vm.getUid())) { // if this vm was not created
		return false;
	}
	
	int numHosts = getHostList().size();

	// 1. Find/Order the best host for this VM by comparing a metric
	int requiredPes = vm.getNumberOfPes();
	double requiredMips = vm.getCurrentRequestedTotalMips();
	long requiredBw = vm.getCurrentRequestedBw();

	boolean result = false;
	
	double[] freeResources = new double[numHosts];
	for (int i = 0; i < numHosts; i++) {
		double mipsFreePercent = (double)getFreeMips().get(i) / this.hostTotalMips; 
		
		freeResources[i] = mipsFreePercent;
	}

	for(int tries = 0; result == false && tries < numHosts; tries++) {// we still trying until we find a host or until we try all of them
		double lessFree = Double.POSITIVE_INFINITY;
		int idx = -1;

		// we want the host with less pes in use
		for (int i = 0; i < numHosts; i++) {
			if (freeResources[i] < lessFree) {
				lessFree = freeResources[i];
				idx = i;
			}
		}
		freeResources[idx] = Double.POSITIVE_INFINITY;
		Host host = getHostList().get(idx);
		
		// Check whether the host can hold this VM or not.
		if(getFreeMips().get(idx) < requiredMips ||
				getFreeBw().get(idx) < requiredBw ||
				getFreePes().get(idx) < requiredPes) {
			//Cannot host the VM
			continue;
		}
		
		result = host.vmCreate(vm);

		if (result) { // if vm were succesfully created in the host
			getVmTable().put(vm.getUid(), host);
			getUsedPes().put(vm.getUid(), requiredPes);
			getFreePes().set(idx, getFreePes().get(idx) - requiredPes);
			
			getUsedMips().put(vm.getUid(), (long) requiredMips);
			getFreeMips().set(idx,  (long) (getFreeMips().get(idx) - requiredMips));

			getUsedBw().put(vm.getUid(), (long) requiredBw);
			getFreeBw().set(idx,  (long) (getFreeBw().get(idx) - requiredBw));

			break;
		}
	}
	
	logMaxNumHostsUsed();
	return result;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:73,代码来源:VmAllocationPolicyMipsMostFullFirst.java

示例5: allocateHostForVm

import org.cloudbus.cloudsim.Vm; //导入方法依赖的package包/类
/**
 * Allocates a host for a given VM.
 * 
 * @param vm VM specification
 * @return $true if the host could be allocated; $false otherwise
 * @pre $none
 * @post $none
 */
@Override
public boolean allocateHostForVm(Vm vm) {
	if (getVmTable().containsKey(vm.getUid())) { // if this vm was not created
		return false;
	}
	
	int numHosts = getHostList().size();

	// 1. Find/Order the best host for this VM by comparing a metric
	int requiredPes = vm.getNumberOfPes();
	double requiredMips = vm.getCurrentRequestedTotalMips();
	long requiredBw = vm.getCurrentRequestedBw();

	boolean result = false;
	
	double[] freeResources = new double[numHosts];
	for (int i = 0; i < numHosts; i++) {
		double mipsFreePercent = (double)getFreeMips().get(i) / hostTotalMips; 
		//double bwFreePercent = (double)getFreeBw().get(i) / hostTotalBw;
		
		freeResources[i] = mipsFreePercent;
	}

	for(int tries = 0; tries < numHosts; tries++) {// we still trying until we find a host or until we try all of them
		double moreFree = Double.NEGATIVE_INFINITY;
		int idx = -1;

		// we want the host with less pes in use
		for (int i = 0; i < numHosts; i++) {
			if (freeResources[i] > moreFree) {
				moreFree = freeResources[i];
				idx = i;
			}
		}
		
		if(idx==-1) {
			System.err.println("Cannot assign the VM to any host:"+tries+"/"+numHosts);
			return false;
		}
		
		freeResources[idx] = Double.NEGATIVE_INFINITY;
		
		Host host = getHostList().get(idx);
		
		// Check whether the host can hold this VM or not.
		if(getFreeMips().get(idx) < requiredMips ||
				getFreeBw().get(idx) < requiredBw ||
				getFreePes().get(idx) < requiredPes) {
			//Cannot host the VM
			continue;
		}
		
		result = host.vmCreate(vm);

		if (result) { // if vm were succesfully created in the host
			getVmTable().put(vm.getUid(), host);
			getUsedPes().put(vm.getUid(), requiredPes);
			getFreePes().set(idx, getFreePes().get(idx) - requiredPes);
			
			getUsedMips().put(vm.getUid(), (long) requiredMips);
			getFreeMips().set(idx,  (long) (getFreeMips().get(idx) - requiredMips));

			getUsedBw().put(vm.getUid(), (long) requiredBw);
			getFreeBw().set(idx,  (long) (getFreeBw().get(idx) - requiredBw));
			break;
		} 
	}
	logMaxNumHostsUsed();
	return result;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:79,代码来源:VmAllocationPolicyMipsLeastFullFirst.java

示例6: allocateHostForVm

import org.cloudbus.cloudsim.Vm; //导入方法依赖的package包/类
/**
 * Allocates a host for a given VM.
 * 
 * @param vm VM specification
 * @return $true if the host could be allocated; $false otherwise
 * @pre $none
 * @post $none
 */
@Override
public boolean allocateHostForVm(Vm vm) {
	if (getVmTable().containsKey(vm.getUid())) { // if this vm was not created
		return false;
	}
	
	int numHosts = getHostList().size();

	// 1. Find/Order the best host for this VM by comparing a metric
	int requiredPes = vm.getNumberOfPes();
	double requiredMips = vm.getCurrentRequestedTotalMips();
	long requiredBw = vm.getCurrentRequestedBw();

	boolean result = false;
	
	double[] freeResources = new double[numHosts];
	for (int i = 0; i < numHosts; i++) {
		double mipsFreePercent = (double)getFreeMips().get(i) / hostTotalMips; 
		double bwFreePercent = (double)getFreeBw().get(i) / hostTotalBw;
		
		freeResources[i] = convertWeightedMetric(mipsFreePercent, bwFreePercent);
	}

	for(int tries = 0; tries < numHosts; tries++) {// we still trying until we find a host or until we try all of them
		double moreFree = Double.NEGATIVE_INFINITY;
		int idx = -1;

		// we want the host with less pes in use
		for (int i = 0; i < numHosts; i++) {
			if (freeResources[i] > moreFree) {
				moreFree = freeResources[i];
				idx = i;
			}
		}
		
		if(idx==-1) {
			System.err.println("Cannot assign the VM to any host:"+tries+"/"+numHosts);
			return false;
		}
		
		freeResources[idx] = Double.NEGATIVE_INFINITY;
		
		Host host = getHostList().get(idx);
		
		// Check whether the host can hold this VM or not.
		if(getFreeMips().get(idx) < requiredMips ||
				getFreeBw().get(idx) < requiredBw ||
				getFreePes().get(idx) < requiredPes) {
			//Cannot host the VM
			continue;
		}
		
		result = host.vmCreate(vm);

		if (result) { // if vm were succesfully created in the host
			getVmTable().put(vm.getUid(), host);
			getUsedPes().put(vm.getUid(), requiredPes);
			getFreePes().set(idx, getFreePes().get(idx) - requiredPes);
			
			getUsedMips().put(vm.getUid(), (long) requiredMips);
			getFreeMips().set(idx,  (long) (getFreeMips().get(idx) - requiredMips));

			getUsedBw().put(vm.getUid(), (long) requiredBw);
			getFreeBw().set(idx,  (long) (getFreeBw().get(idx) - requiredBw));
			break;
		} 
	}
	logMaxNumHostsUsed();
	return result;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:79,代码来源:VmAllocationPolicyCombinedLeastFullFirst.java


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