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


Java Vm类代码示例

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


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

示例1: updateAllocatedMips

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
protected void updateAllocatedMips(String incomingOperator){
	getHost().getVmScheduler().deallocatePesForAllVms();
	for(final Vm vm : getHost().getVmList()){
		if(vm.getCloudletScheduler().runningCloudlets() > 0 || ((AppModule)vm).getName().equals(incomingOperator)){
			getHost().getVmScheduler().allocatePesForVm(vm, new ArrayList<Double>(){
				protected static final long serialVersionUID = 1L;
			{add((double) getHost().getTotalMips());}});
		}else{
			getHost().getVmScheduler().allocatePesForVm(vm, new ArrayList<Double>(){
				protected static final long serialVersionUID = 1L;
			{add(0.0);}});
		}
	}
	
	updateEnergyConsumption();
	
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:18,代码来源:FogDevice.java

示例2: 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

示例3: 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);
		createdVmNum++;
		
		Log.formatLine("%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(),CloudSim.clock());
		return true;
	}

	return false;
}
 
开发者ID:CagataySonmez,项目名称:EdgeCloudSim,代码行数:13,代码来源:VmAllocationPolicy_Custom.java

示例4: allocateRamForVm

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
@Override
public boolean allocateRamForVm(Vm vm, int ram) {
	int maxRam = vm.getRam();

	if (ram >= maxRam) {
		ram = maxRam;
	}

	deallocateRamForVm(vm);

	if (getAvailableRam() >= ram) {
		setAvailableRam(getAvailableRam() - ram);
		getRamTable().put(vm.getUid(), ram);
		vm.setCurrentAllocatedRam(getAllocatedRamForVm(vm));
		return true;
	}

	vm.setCurrentAllocatedRam(getAllocatedRamForVm(vm));

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

示例5: processVmDestroyAck

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
protected void processVmDestroyAck(SimEvent ev) {
	Vm destroyedVm = (Vm) ev.getData();
	// remove all channels transferring data from or to this vm.
	for(Vm vm:this.vmList) {
		Channel ch = this.findChannel(vm.getId(), destroyedVm.getId(), -1);
		if(ch != null) {
			this.removeChannel(getKey(vm.getId(), destroyedVm.getId(), -1));
		}

		ch = this.findChannel(destroyedVm.getId(), vm.getId(), -1);
		if(ch != null) {
			this.removeChannel(getKey(destroyedVm.getId(), vm.getId(), -1));
		}

	}
	
	sendInternalEvent();
	
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:20,代码来源:NetworkOperatingSystem.java

示例6: allocateMipsForVm

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
@Override
public boolean allocateMipsForVm(Vm vm, List<Double> mips) {
	int totalMipsToAllocate = 0;
	for (double _mips : mips) {
		totalMipsToAllocate += _mips;
	}

	if (getAvailableMips() + getTotalAllocatedMipsForVm(vm) < totalMipsToAllocate) {
		return false;
	}

	setAvailableMips(getAvailableMips() + getTotalAllocatedMipsForVm(vm) - totalMipsToAllocate);

	getPeTable().put(vm.getUid(), mips);

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

示例7: deallocateHostForVm

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
/**
 * Releases the host used by a VM.
 * 
 * @param vm the vm
 * @pre $none
 * @post none
 */
@Override
public void deallocateHostForVm(Vm vm) {
	Host host = getVmTable().remove(vm.getUid());
	if (host != null) {
		int idx = getHostList().indexOf(host);
		host.vmDestroy(vm);
		
		Integer pes = getUsedPes().remove(vm.getUid());
		getFreePes().set(idx, getFreePes().get(idx) + pes);
		
		Long mips = getUsedMips().remove(vm.getUid());
		getFreeMips().set(idx, getFreeMips().get(idx) + mips);
		
		Long bw = getUsedBw().remove(vm.getUid());
		getFreeBw().set(idx, getFreeBw().get(idx) + bw);
	}
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:25,代码来源:VmAllocationPolicyOverbooking.java

示例8: recvpackets

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
/**
 * Receives packet and forward it to the corresponding VM for processing host.
 * 
 * 
 */
private void recvpackets() {

	for (NetworkPacket hs : packetrecieved) {
		hs.pkt.recievetime = CloudSim.clock();

		// insertthe packet in recievedlist of VM
		Vm vm = VmList.getById(getVmList(), hs.pkt.reciever);
		List<HostPacket> pktlist = ((NetworkCloudletSpaceSharedScheduler) vm.getCloudletScheduler()).pktrecv
				.get(hs.pkt.sender);

		if (pktlist == null) {
			pktlist = new ArrayList<HostPacket>();
			((NetworkCloudletSpaceSharedScheduler) vm.getCloudletScheduler()).pktrecv.put(
					hs.pkt.sender,
					pktlist);

		}
		pktlist.add(hs.pkt);

	}
	packetrecieved.clear();
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:28,代码来源:NetworkHost.java

示例9: getMaxUtilizationAfterAllocation

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
protected double getMaxUtilizationAfterAllocation(NetworkHost host, Vm vm) {
	List<Double> allocatedMipsForVm = null;
	NetworkHost allocatedHost = (NetworkHost) vm.getHost();

	if (allocatedHost != null) {
		allocatedMipsForVm = vm.getHost().getAllocatedMipsForVm(vm);
	}

	if (!host.allocatePesForVm(vm, vm.getCurrentRequestedMips())) {
		return -1;
	}

	double maxUtilization = host.getMaxUtilizationAmongVmsPes(vm);

	host.deallocatePesForVm(vm);

	if (allocatedHost != null && allocatedMipsForVm != null) {
		vm.getHost().allocatePesForVm(vm, allocatedMipsForVm);
	}

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

示例10: getVmToMigrate

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
@Override
public Vm getVmToMigrate(PowerHost host) {
	List<PowerVm> migratableVms = getMigratableVms(host);
	if (migratableVms.isEmpty()) {
		return null;
	}
	Vm vmToMigrate = null;
	double minMetric = Double.MAX_VALUE;
	for (Vm vm : migratableVms) {
		if (vm.isInMigration()) {
			continue;
		}
		double metric = vm.getRam();
		if (metric < minMetric) {
			minMetric = metric;
			vmToMigrate = vm;
		}
	}
	return vmToMigrate;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:21,代码来源:PowerVmSelectionPolicyMinimumMigrationTime.java

示例11: getNewVmPlacement

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
/**
 * Gets the new vm placement.
 * 
 * @param vmsToMigrate the vms to migrate
 * @param excludedHosts the excluded hosts
 * @return the new vm placement
 */
protected List<Map<String, Object>> getNewVmPlacement(
		List<? extends Vm> vmsToMigrate,
		Set<? extends Host> excludedHosts) {
	List<Map<String, Object>> migrationMap = new LinkedList<Map<String, Object>>();
	PowerVmList.sortByCpuUtilization(vmsToMigrate);
	for (Vm vm : vmsToMigrate) {
		PowerHost allocatedHost = findHostForVm(vm, excludedHosts);
		if (allocatedHost != null) {
			allocatedHost.vmCreate(vm);
			Log.printLine("VM #" + vm.getId() + " allocated to host #" + allocatedHost.getId());

			Map<String, Object> migrate = new HashMap<String, Object>();
			migrate.put("vm", vm);
			migrate.put("host", allocatedHost);
			migrationMap.add(migrate);
		}
	}
	return migrationMap;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:27,代码来源:PowerVmAllocationPolicyMigrationAbstract.java

示例12: getVmSelectionPolicy

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
/**
 * Gets the vms to migrate from hosts.
 * 
 * @param overUtilizedHosts the over utilized hosts
 * @return the vms to migrate from hosts
 */
protected
		List<? extends Vm>
		getVmsToMigrateFromHosts(List<PowerHostUtilizationHistory> overUtilizedHosts) {
	List<Vm> vmsToMigrate = new LinkedList<Vm>();
	for (PowerHostUtilizationHistory host : overUtilizedHosts) {
		while (true) {
			Vm vm = getVmSelectionPolicy().getVmToMigrate(host);
			if (vm == null) {
				break;
			}
			vmsToMigrate.add(vm);
			host.vmDestroy(vm);
			if (!isHostOverUtilized(host)) {
				break;
			}
		}
	}
	return vmsToMigrate;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:26,代码来源:PowerVmAllocationPolicyMigrationAbstract.java

示例13: isHostOverUtilized

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
/**
 * Checks if is host over utilized.
 * 
 * @param _host the _host
 * @return true, if is host over utilized
 */
@Override
protected boolean isHostOverUtilized(PowerHost host) {
	PowerHostUtilizationHistory _host = (PowerHostUtilizationHistory) host;
	double upperThreshold = 0;
	try {
		upperThreshold = 1 - getSafetyParameter() * getHostUtilizationIqr(_host);
	} catch (IllegalArgumentException e) {
		return getFallbackVmAllocationPolicy().isHostOverUtilized(host);
	}
	addHistoryEntry(host, upperThreshold);
	double totalRequestedMips = 0;
	for (Vm vm : host.getVmList()) {
		totalRequestedMips += vm.getCurrentRequestedTotalMips();
	}
	double utilization = totalRequestedMips / host.getTotalMips();
	return utilization > upperThreshold;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:24,代码来源:PowerVmAllocationPolicyMigrationInterQuartileRange.java

示例14: getVmToMigrate

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
@Override
public Vm getVmToMigrate(PowerHost host) {
	List<PowerVm> migratableVms = getMigratableVms(host);
	if (migratableVms.isEmpty()) {
		return null;
	}
	Vm vmToMigrate = null;
	double minMetric = Double.MAX_VALUE;
	for (Vm vm : migratableVms) {
		if (vm.isInMigration()) {
			continue;
		}
		double metric = vm.getTotalUtilizationOfCpuMips(CloudSim.clock()) / vm.getMips();
		if (metric < minMetric) {
			minMetric = metric;
			vmToMigrate = vm;
		}
	}
	return vmToMigrate;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:21,代码来源:PowerVmSelectionPolicyMinimumUtilization.java

示例15: isHostOverUtilized

import org.cloudbus.cloudsim.Vm; //导入依赖的package包/类
/**
 * Checks if is host over utilized.
 * 
 * @param _host the _host
 * @return true, if is host over utilized
 */
@Override
protected boolean isHostOverUtilized(PowerHost host) {
	PowerHostUtilizationHistory _host = (PowerHostUtilizationHistory) host;
	double upperThreshold = 0;
	try {
		upperThreshold = 1 - getSafetyParameter() * getHostUtilizationMad(_host);
	} catch (IllegalArgumentException e) {
		return getFallbackVmAllocationPolicy().isHostOverUtilized(host);
	}
	addHistoryEntry(host, upperThreshold);
	double totalRequestedMips = 0;
	for (Vm vm : host.getVmList()) {
		totalRequestedMips += vm.getCurrentRequestedTotalMips();
	}
	double utilization = totalRequestedMips / host.getTotalMips();
	return utilization > upperThreshold;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:24,代码来源:PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation.java


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