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


Java Host类代码示例

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


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

示例1: getAvgUtilization

import org.cloudbus.cloudsim.Host; //导入依赖的package包/类
public double getAvgUtilization(){
	double totalUtilization = 0;
	double vmCounter = 0;
	
	// for each datacenter...
	for(int i= 0; i<localDatacenters.size(); i++) {
		List<? extends Host> list = localDatacenters.get(i).getHostList();
		// for each host...
		for (int j=0; j < list.size(); j++) {
			Host host = list.get(j);
			List<EdgeVM> vmArray = SimManager.getInstance().getLocalServerManager().getVmList(host.getId());
			//for each vm...
			for(int vmIndex=0; vmIndex<vmArray.size(); vmIndex++){
				totalUtilization += vmArray.get(vmIndex).getCloudletScheduler().getTotalUtilizationOfCpu(CloudSim.clock());
				vmCounter++;
			}
		}
	}
	return totalUtilization / vmCounter;
}
 
开发者ID:CagataySonmez,项目名称:EdgeCloudSim,代码行数:21,代码来源:EdgeServerManager.java

示例2: allocateHostForVm

import org.cloudbus.cloudsim.Host; //导入依赖的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: VmAllocationPolicyCombinedMostFullFirst

import org.cloudbus.cloudsim.Host; //导入依赖的package包/类
/**
 * Creates the new VmAllocationPolicySimple object.
 * 
 * @param list the list
 * @pre $none
 * @post $none
 */
public VmAllocationPolicyCombinedMostFullFirst(List<? extends Host> list) {
	super(list);

	setFreePes(new ArrayList<Integer>());
	setFreeMips(new ArrayList<Long>());
	setFreeBw(new ArrayList<Long>());
	
	for (Host host : getHostList()) {
		getFreePes().add(host.getNumberOfPes());
		getFreeMips().add((long) host.getTotalMips());
		getFreeBw().add(host.getBw());
	}
	hostTotalMips = getHostList().get(0).getTotalMips();
	hostTotalBw =  getHostList().get(0).getBw();
	hostTotalPes =  getHostList().get(0).getNumberOfPes();

	setVmTable(new HashMap<String, Host>());
	setUsedPes(new HashMap<String, Integer>());
	setUsedMips(new HashMap<String, Long>());
	setUsedBw(new HashMap<String, Long>());
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:29,代码来源:VmAllocationPolicyCombinedMostFullFirst.java

示例4: getHostAddressByVmId

import org.cloudbus.cloudsim.Host; //导入依赖的package包/类
public int getHostAddressByVmId(int vmId) {
	Vm vm = findVm(vmId);
	if(vm == null) {
		Log.printLine(CloudSim.clock() + ": " + getName() + ": Cannot find VM with vmId = "+ vmId);
		return -1;
	}
	
	Host host = vm.getHost();
	SDNHost sdnhost = findSDNHost(host);
	if(sdnhost == null) {
		Log.printLine(CloudSim.clock() + ": " + getName() + ": Cannot find SDN Host with vmId = "+ vmId);
		return -1;
	}
	
	return sdnhost.getAddress();
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:17,代码来源:NetworkOperatingSystem.java

示例5: allocateHostForVm

import org.cloudbus.cloudsim.Host; //导入依赖的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

示例6: getNewVmPlacement

import org.cloudbus.cloudsim.Host; //导入依赖的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

示例7: getUnderUtilizedHost

import org.cloudbus.cloudsim.Host; //导入依赖的package包/类
/**
 * Gets the under utilized host.
 * 
 * @param excludedHosts the excluded hosts
 * @return the under utilized host
 */
protected PowerHost getUnderUtilizedHost(Set<? extends Host> excludedHosts) {
	double minUtilization = 1;
	PowerHost underUtilizedHost = null;
	for (PowerHost host : this.<PowerHost> getHostList()) {
		if (excludedHosts.contains(host)) {
			continue;
		}
		double utilization = host.getUtilizationOfCpu();
		if (utilization > 0 && utilization < minUtilization
				&& !areAllVmsMigratingOutOrAnyVmMigratingIn(host)) {
			minUtilization = utilization;
			underUtilizedHost = host;
		}
	}
	return underUtilizedHost;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:23,代码来源:PowerVmAllocationPolicyMigrationAbstract.java

示例8: allocateHostForVm

import org.cloudbus.cloudsim.Host; //导入依赖的package包/类
@Override
public boolean allocateHostForVm(Vm vm, Host host) {
	if (host == null) {
		Log.formatLine("%.2f: No suitable host found for VM #" + vm.getId() + "\n", CloudSim.clock());
		return false;
	}
	if (host.vmCreate(vm)) { // if vm has been succesfully created in the host
		getVmTable().put(vm.getUid(), host);
		Log.formatLine(
				"%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(),
				CloudSim.clock());
		return true;
	}
	Log.formatLine(
			"%.2f: Creation of VM #" + vm.getId() + " on the host #" + host.getId() + " failed\n",
			CloudSim.clock());
	return false;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:19,代码来源:PowerVmAllocationPolicyAbstract.java

示例9: deallocateHostForVm

import org.cloudbus.cloudsim.Host; //导入依赖的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,代码来源:VmAllocationPolicyCombinedMostFullFirst.java

示例10: VmAllocationPolicyCombinedMostFullFirst

import org.cloudbus.cloudsim.Host; //导入依赖的package包/类
/**
 * Creates the new VmAllocationPolicySimple object.
 * 
 * @param list the list
 * @pre $none
 * @post $none
 */
public VmAllocationPolicyCombinedMostFullFirst(List<? extends Host> list) {
	super(list);

	setFreePes(new ArrayList<Integer>());
	setFreeMips(new ArrayList<Long>());
	setFreeBw(new ArrayList<Long>());
	
	for (Host host : getHostList()) {
		getFreePes().add(host.getNumberOfPes());
		getFreeMips().add((long)host.getTotalMips());
		getFreeBw().add(host.getBw());
	}
	hostTotalMips = getHostList().get(0).getTotalMips();
	hostTotalBw =  getHostList().get(0).getBw();
	hostTotalPes =  getHostList().get(0).getNumberOfPes();

	setVmTable(new HashMap<String, Host>());
	setUsedPes(new HashMap<String, Integer>());
	setUsedMips(new HashMap<String, Long>());
	setUsedBw(new HashMap<String, Long>());
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:29,代码来源:VmAllocationPolicyCombinedMostFullFirst.java

示例11: VmAllocationPolicyOverbooking

import org.cloudbus.cloudsim.Host; //导入依赖的package包/类
/**
 * Creates the new VmAllocationPolicySimple object.
 * 
 * @param list the list
 * @pre $none
 * @post $none
 */
public VmAllocationPolicyOverbooking(List<? extends Host> list) {
	super(list);

	setFreePes(new ArrayList<Integer>());
	setFreeMips(new ArrayList<Long>());
	setFreeBw(new ArrayList<Long>());
	
	for (Host host : getHostList()) {
		getFreePes().add(host.getNumberOfPes());
		getFreeMips().add((long) PeProvisionerOverbooking.getOverbookedMips((host.getTotalMips())));
		getFreeBw().add((long) BwProvisionerOverbooking.getOverbookedBw(host.getBw()));
	}
	hostTotalMips = getHostList().get(0).getTotalMips();
	hostTotalBw =  getHostList().get(0).getBw();
	hostTotalPes =  getHostList().get(0).getNumberOfPes();

	setVmTable(new HashMap<String, Host>());
	setUsedPes(new HashMap<String, Integer>());
	setUsedMips(new HashMap<String, Long>());
	setUsedBw(new HashMap<String, Long>());
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:29,代码来源:VmAllocationPolicyOverbooking.java

示例12: output

import org.cloudbus.cloudsim.Host; //导入依赖的package包/类
public void output(){
	try {
		// Final step: Print hosts' total utilization.
		List<Host> hostList = nos.getHostList();
		
		printEnergyConsumption(hostList);
		
		//Final step: Print results when simulation is over
		List<Cloudlet> newList = broker.getCloudletReceivedList();
		printCloudletList(newList);
		
		List<Workload> wls = broker.getWorkloads();
		printWorkloadList(wls);
		
		append("CloudSim SDN finished!");
		
	} catch (Exception e) {
		e.printStackTrace();
		append("====== OUTPUT ERROR ======");
	}
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:22,代码来源:GraphicSDNExample.java

示例13: getMips

import org.cloudbus.cloudsim.Host; //导入依赖的package包/类
/**
 * Gets the total MIPS rating, which is the sum of MIPS rating of all machines in a resource.
 * <p>
 * Total MIPS rating for:
 * <ul>
 * <li>TimeShared = 1 Rating of a Pe * Total number of PEs
 * <li>Other policy same rating = same as TimeShared
 * <li>SpaceShared = Sum of all PEs in all Machines
 * <li>Other policy different rating = same as SpaceShared
 * <li>Advance Reservation = 0 or unknown. You need to calculate this manually.
 * </ul>
 * 
 * @return the sum of MIPS ratings
 * @pre $none
 * @post $result >= 0
 */
public int getMips() {
	int mips = 0;
	switch (getAllocationPolicy()) {
	// Assuming all PEs in all Machine have same rating.
		case FogDeviceCharacteristics.TIME_SHARED:
		case FogDeviceCharacteristics.OTHER_POLICY_SAME_RATING:
			mips = getMipsOfOnePe() * HostList.getNumberOfPes(getHostList());
			break;

		// Assuming all PEs in a given Machine have the same rating.
		// But different machines in a Cluster can have different rating
		case FogDeviceCharacteristics.SPACE_SHARED:
		case FogDeviceCharacteristics.OTHER_POLICY_DIFFERENT_RATING:
			for (Host host : getHostList()) {
				mips += host.getTotalMips();
			}
			break;

		default:
			break;
	}

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

示例14: VmAllocationPolicy_Custom

import org.cloudbus.cloudsim.Host; //导入依赖的package包/类
public VmAllocationPolicy_Custom(List<? extends Host> list, int _DataCenterIndex) {
	super(list);
	
	setVmTable(new HashMap<String, Host>());
	DataCenterIndex=_DataCenterIndex;
	createdVmNum = 0;
}
 
开发者ID:CagataySonmez,项目名称:EdgeCloudSim,代码行数:8,代码来源:VmAllocationPolicy_Custom.java

示例15: deallocateHostForVm

import org.cloudbus.cloudsim.Host; //导入依赖的package包/类
@Override
public void deallocateHostForVm(Vm vm) {
	Host host = getVmTable().remove(vm.getUid());
	if (host != null) {
		host.vmDestroy(vm);
	}
}
 
开发者ID:CagataySonmez,项目名称:EdgeCloudSim,代码行数:8,代码来源:VmAllocationPolicy_Custom.java


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