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


Java Log类代码示例

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


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

示例1: allocateHostForVm

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

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

示例3: processEvent

import org.cloudbus.cloudsim.Log; //导入依赖的package包/类
@Override
public void processEvent(SimEvent ev) {
	switch (ev.getTag()) {
		case CREATE_BROKER:
			setBroker(createBroker(super.getName() + "_"));
			
			// Create VMs and Cloudlets and send them to broker
			setVmList(createVM(getBroker().getId(), 5, 100)); // creating 5 vms
			setCloudletList(createCloudlet(getBroker().getId(), 10, 100)); // creating 10
																			// cloudlets
			
			broker.submitVmList(getVmList());
			broker.submitCloudletList(getCloudletList());
			
			CloudSim.resumeSimulation();
			
			break;
		
		default:
			Log.printLine(getName() + ": unknown event type");
			break;
	}
}
 
开发者ID:Udacity2048,项目名称:CloudSimDisk,代码行数:24,代码来源:CloudSimExample8.java

示例4: allocateHostForVm

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

示例5: processCloudletReturn

import org.cloudbus.cloudsim.Log; //导入依赖的package包/类
/**
 * Process a cloudlet return event.
 * 
 * @param ev a SimEvent object
 * 
 * @pre ev != $null
 * @post $none
 */
protected void processCloudletReturn(SimEvent ev) {
	Cloudlet cloudlet = (Cloudlet) ev.getData();
	getCloudletReceivedList().add(cloudlet);
	cloudletsSubmitted--;
	// all cloudlets executed
	if (getCloudletList().size() == 0 && cloudletsSubmitted == 0 && NetworkConstants.iteration > 10) {
		Log.printLine(CloudSim.clock() + ": " + getName() + ": All Cloudlets executed. Finishing...");
		clearDatacenters();
		finishExecution();
	} else { // some cloudlets haven't finished yet
		if (getAppCloudletList().size() > 0 && cloudletsSubmitted == 0) {
			// all the cloudlets sent finished. It means that some bount
			// cloudlet is waiting its VM be created
			clearDatacenters();
			createVmsInDatacenterBase(0);
		}

	}
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:28,代码来源:NetDatacenterBroker.java

示例6: getNewVmPlacement

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

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

示例8: printCloudletList

import org.cloudbus.cloudsim.Log; //导入依赖的package包/类
public static void printCloudletList(List<Cloudlet> list) {
	int size = list.size();
	Cloudlet cloudlet;

	Log.printLine();
	Log.printLine("========== OUTPUT ==========");
	
	Log.print(String.format(fString, "Cloudlet_ID"));
	Log.print(String.format(fString, "STATUS" ));
	Log.print(String.format(fString, "DataCenter_ID"));
	Log.print(String.format(fString, "VM_ID"));
	Log.print(String.format(fString, "Length"));
	Log.print(String.format(fString, "Time"));
	Log.print(String.format(fString, "Start Time"));
	Log.print(String.format(fString, "Finish Time"));
	Log.print("\n");

	//DecimalFormat dft = new DecimalFormat("######.##");
	for (int i = 0; i < size; i++) {
		cloudlet = list.get(i);
		printCloudlet(cloudlet);
	}
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:24,代码来源:LogPrinter.java

示例9: printCloudlet

import org.cloudbus.cloudsim.Log; //导入依赖的package包/类
private static void printCloudlet(Cloudlet cloudlet) {
	Log.print(String.format(fInt, cloudlet.getCloudletId()));

	if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
		Log.print(String.format(fString, "SUCCESS"));
		Log.print(String.format(fInt, cloudlet.getResourceId()));
		Log.print(String.format(fInt, cloudlet.getVmId()));
		Log.print(String.format(fInt, cloudlet.getCloudletLength()));
		Log.print(String.format(fFloat, cloudlet.getActualCPUTime()));
		Log.print(String.format(fFloat, cloudlet.getExecStartTime()));
		Log.print(String.format(fFloat, cloudlet.getFinishTime()));
		Log.print("\n");
	}
	else {
		Log.printLine("FAILED");
	}
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:18,代码来源:LogPrinter.java

示例10: printGroupStatistics

import org.cloudbus.cloudsim.Log; //导入依赖的package包/类
public static void printGroupStatistics(int groupSeperateNum, int[] appIdNum, double[] appIdTime) {

		double prioritySum = 0, standardSum = 0;
		int priorityReqNum = 0, standardReqNum =0;
		
		for(int i=0; i<SDNBroker.appId; i++) {
			double avgResponseTime = appIdTime[i]/appIdNum[i];
			if(i<groupSeperateNum) {
				prioritySum += avgResponseTime;
				priorityReqNum += appIdNum[i];
			}
			else {
				standardSum += avgResponseTime;
				standardReqNum += appIdNum[i];
			}
		}

		Log.printLine("Average Response Time(Priority):"+(prioritySum / priorityReqNum));
		Log.printLine("Average Response Time(Standard):"+(standardSum / standardReqNum));
	}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:21,代码来源:LogPrinter.java

示例11: deployApplication

import org.cloudbus.cloudsim.Log; //导入依赖的package包/类
@Override
public boolean deployApplication(List<Vm> vms, List<Middlebox> middleboxes, List<Arc> links) {
	Log.printLine(CloudSim.clock() + ": " + getName() + ": Starting deploying application..");
	
	for(Vm vm:vms)
	{
		TimedVm tvm = (TimedVm) vm;
		Log.printLine(CloudSim.clock() + ": " + getName() + ": Trying to Create VM #" + vm.getId()
				+ " in " + datacenter.getName() + ", (" + tvm.getStartTime() + "~" +tvm.getFinishTime() + ")");
		send(datacenter.getId(), tvm.getStartTime(), CloudSimTags.VM_CREATE_ACK, vm);
		
		if(tvm.getFinishTime() != Double.POSITIVE_INFINITY) {
			//System.err.println("VM will be terminated at: "+tvm.getFinishTime());
			send(datacenter.getId(), tvm.getFinishTime(), CloudSimTags.VM_DESTROY, vm);
			send(this.getId(), tvm.getFinishTime(), CloudSimTags.VM_DESTROY, vm);
		}
	}
	return true;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:20,代码来源:SimpleNetworkOperatingSystem.java

示例12: processActivity

import org.cloudbus.cloudsim.Log; //导入依赖的package包/类
private void processActivity(Activity ac, Request req, int vmId) {
	if(ac instanceof Transmission) {
		Transmission tr = (Transmission)ac;

		Package pkg = tr.getPackage();
		//send package to router via channel (NOS)
		nos.addPackageToChannel(this, pkg);
		
		pkg.setStartTime(CloudSim.clock());
	}
	else if(ac instanceof Processing) {
			Cloudlet cl = ((Processing) ac).getCloudlet();
			cl.setVmId(vmId);
			
			requestsTable.put(cl, req);
			sendNow(host.getDatacenter().getId(),CloudSimTags.CLOUDLET_SUBMIT,cl);
	} else {
		Log.printLine(CloudSim.clock() + ": " + getName() + ": Activity is unknown..");
	}
	
	
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:23,代码来源:SDNHost.java

示例13: deployApplication

import org.cloudbus.cloudsim.Log; //导入依赖的package包/类
@Override
public boolean deployApplication(List<Vm> vms, List<Middlebox> middleboxes, List<Arc> links) {
	Log.printLine(CloudSim.clock() + ": " + getName() + ": Starting deploying application..");
	
	for(Vm vm:vms)
	{
		TimedVm tvm = (TimedVm) vm;
		Log.printLine(CloudSim.clock() + ": " + getName() + ": Trying to Create VM #" + vm.getId()
				+ " in " + datacenter.getName() + ", (" + tvm.getStartTime() + "~" +tvm.getFinishTime() + ")");
		send(datacenter.getId(), tvm.getStartTime(), CloudSimTags.VM_CREATE_ACK, vm);
		
		if(tvm.getFinishTime() != Double.POSITIVE_INFINITY) {
			send(datacenter.getId(), tvm.getFinishTime(), CloudSimTags.VM_DESTROY, vm);
			send(this.getId(), tvm.getFinishTime(), CloudSimTags.VM_DESTROY, vm);
		}
	}
	return true;
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:19,代码来源:OverbookingNetworkOperatingSystem.java

示例14: setStatusFailed

import org.cloudbus.cloudsim.Log; //导入依赖的package包/类
/**
 * Sets the status of PEs of this machine to FAILED. NOTE: <tt>resName</tt> and
 * <tt>machineID</tt> are used for debugging purposes, which is <b>ON</b> by default. Use
 * {@link #setStatusFailed(boolean)} if you do not want this information.
 * 
 * @param resName the name of the resource
 * @param hostId the id of this machine
 * @param failed the new value for the "failed" parameter
 */
public static <T extends Pe> void setStatusFailed(
		List<T> peList,
		String resName,
		int hostId,
		boolean failed) {
	String status = null;
	if (failed) {
		status = "FAILED";
	} else {
		status = "WORKING";
	}

	Log.printLine(resName + " - Machine: " + hostId + " is " + status);

	setStatusFailed(peList, failed);
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:26,代码来源:PeList.java

示例15: startSimulation

import org.cloudbus.cloudsim.Log; //导入依赖的package包/类
/**
 * Starts the execution of CloudSim simulation. It waits for complete execution of all entities,
 * i.e. until all entities threads reach non-RUNNABLE state or there are no more events in the
 * future event queue.
 * <p>
 * <b>Note</b>: This method should be called after all the entities have been setup and added.
 * 
 * @return the double
 * @throws NullPointerException This happens when creating this entity before initialising
 *             CloudSim package or this entity name is <tt>null</tt> or empty.
 * @see gridsim.CloudSim#init(int, Calendar, boolean)
 * @pre $none
 * @post $none
 */
public static double startSimulation() throws NullPointerException {
	Log.printLine("Starting CloudSim version " + CLOUDSIM_VERSION_STRING);
	try {
		double clock = run();

		// reset all static variables
		cisId = -1;
		shutdownId = -1;
		cis = null;
		calendar = null;
		traceFlag = false;

		return clock;
	} catch (IllegalArgumentException e) {
		e.printStackTrace();
		throw new NullPointerException("CloudSim.startCloudSimulation() :"
				+ " Error - you haven't initialized CloudSim.");
	}
}
 
开发者ID:gmartinezramirez,项目名称:Fog-Computing-Mobile-Architecture,代码行数:34,代码来源:CloudSim.java


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