本文整理汇总了Java中org.cloudbus.cloudsim.Log.formatLine方法的典型用法代码示例。如果您正苦于以下问题:Java Log.formatLine方法的具体用法?Java Log.formatLine怎么用?Java Log.formatLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cloudbus.cloudsim.Log
的用法示例。
在下文中一共展示了Log.formatLine方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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
示例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);
reserveResource(host, (SDNVm) vm);
// 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());
logMaxNumHostsUsed();
return true;
}
return false;
}
示例5: 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;
}//在host中创建虚拟机
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;
}
示例6: processCloudletFilesDone
import org.cloudbus.cloudsim.Log; //导入方法依赖的package包/类
/**
* Processes a "Cloudlet Files Done" Event.
*
* @param ev
* the SimEvent
*/
protected void processCloudletFilesDone(SimEvent ev) {
// Retrieves data from the ev
Object[] data = (Object[]) ev.getData();
String action = (String) data[0];
Cloudlet cl = (Cloudlet) data[1];
File tempFile = (File) data[2];
double transTime = (double) data[3];
MyHarddriveStorage storage = (MyHarddriveStorage) data[4];
double waitingTime = (double) data[5];
// store results/information
WriteToResultFile.AddValueToSheetTab(waitingTime, cl.getCloudletId(), 2);
WriteToResultFile.AddValueToSheetTab(transTime, cl.getCloudletId(), 3);
WriteToResultFile.AddValueToSheetTab(CloudSim.clock(), cl.getCloudletId(), 7);
WriteToResultFile.AddValueToSheetTab(tempFile.getName(), cl.getCloudletId(), 8);
WriteToResultFile.AddValueToSheetTab(tempFile.getSize(), cl.getCloudletId(), 9);
// Print out confirmation that Files have been handled
Log.formatLine("\n%.6f: %s: Cloudlet # %d: <%s> %s on %s.", CloudSim.clock(), getName(), cl.getCloudletId(),
tempFile.getName(), action, storage.getName());
Log.formatLine("%10s Queue Waiting time of %9.6f Seconds(s).", "", waitingTime);
Log.formatLine("%10s Transaction time of %9.6f Seconde(s).", "", transTime);
Log.printLine();
// handle queue
storage.setQueueLength(storage.getQueueLength() - 1);
// Test if there is further operation on the disk
if (storage.getActiveEndAt() <= CloudSim.clock()) {
storage.setMode(0); // switch to idle mode
storage.setActiveEndAt(0.0); // reset EndAt time
}
}
示例7: updateCloudletProcessing
import org.cloudbus.cloudsim.Log; //导入方法依赖的package包/类
/**
* Updates processing of each cloudlet running in this PowerDatacenter. It is necessary because
* Hosts and VirtualMachines are simple objects, not entities. So, they don't receive events and
* updating cloudlets inside them must be called from the outside.
*
* @pre $none
* @post $none
*/
@Override
protected void updateCloudletProcessing() {
if (getCloudletSubmitted() == -1 || getCloudletSubmitted() == CloudSim.clock()) {
CloudSim.cancelAll(getId(), new PredicateType(CloudSimTags.VM_DATACENTER_EVENT));
schedule(getId(), getSchedulingInterval(), CloudSimTags.VM_DATACENTER_EVENT);
return;
}
double currentTime = CloudSim.clock();
// if some time passed since last processing
if (currentTime > getLastProcessTime()) {
double minTime = updateCloudetProcessingWithoutSchedulingFutureEventsForce();
if (!isDisableMigrations()) {
List<Map<String, Object>> migrationMap = getVmAllocationPolicy().optimizeAllocation(
getVmList());
if (migrationMap != null) {
for (Map<String, Object> migrate : migrationMap) {
Vm vm = (Vm) migrate.get("vm");
PowerHost targetHost = (PowerHost) migrate.get("host");
PowerHost oldHost = (PowerHost) vm.getHost();
if (oldHost == null) {
Log.formatLine(
"%.2f: Migration of VM #%d to Host #%d is started",
currentTime,
vm.getId(),
targetHost.getId());
} else {
Log.formatLine(
"%.2f: Migration of VM #%d from Host #%d to Host #%d is started",
currentTime,
vm.getId(),
oldHost.getId(),
targetHost.getId());
}
targetHost.addMigratingInVm(vm);
incrementMigrationCount();
/** VM migration delay = RAM / bandwidth **/
// we use BW / 2 to model BW available for migration purposes, the other
// half of BW is for VM communication
// around 16 seconds for 1024 MB using 1 Gbit/s network
send(
getId(),
vm.getRam() / ((double) targetHost.getBw() / (2 * 8000)),
CloudSimTags.VM_MIGRATE,
migrate);
}
}
}
// schedules an event to the next time
if (minTime != Double.MAX_VALUE) {
CloudSim.cancelAll(getId(), new PredicateType(CloudSimTags.VM_DATACENTER_EVENT));
send(getId(), getSchedulingInterval(), CloudSimTags.VM_DATACENTER_EVENT);
}
setLastProcessTime(currentTime);
}
}
示例8: updateCloudletProcessing
import org.cloudbus.cloudsim.Log; //导入方法依赖的package包/类
/**
* Updates processing of each cloudlet running in this PowerDatacenter. It is necessary because
* Hosts and VirtualMachines are simple objects, not entities. So, they don't receive events and
* updating cloudlets inside them must be called from the outside.
*
* @pre $none
* @post $none
*/
@Override
protected void updateCloudletProcessing() {
if (getCloudletSubmitted() == -1 || getCloudletSubmitted() == CloudSim.clock()) {
CloudSim.cancelAll(getId(), new PredicateType(CloudSimTags.VM_DATACENTER_EVENT));
schedule(getId(), getSchedulingInterval(), CloudSimTags.VM_DATACENTER_EVENT);
return;
}
double currentTime = CloudSim.clock();
// if some time passed since last processing
if (currentTime > getLastProcessTime()) {
System.out.print(currentTime + " ");
double minTime = updateCloudetProcessingWithoutSchedulingFutureEventsForce();
if (!isDisableMigrations()) {
List<Map<String, Object>> migrationMap = getVmAllocationPolicy().optimizeAllocation(
getVmList());
if (migrationMap != null) {
for (Map<String, Object> migrate : migrationMap) {
Vm vm = (Vm) migrate.get("vm");
PowerHost targetHost = (PowerHost) migrate.get("host");
PowerHost oldHost = (PowerHost) vm.getHost();
if (oldHost == null) {
Log.formatLine(
"%.2f: Migration of VM #%d to Host #%d is started",
currentTime,
vm.getId(),
targetHost.getId());
} else {
Log.formatLine(
"%.2f: Migration of VM #%d from Host #%d to Host #%d is started",
currentTime,
vm.getId(),
oldHost.getId(),
targetHost.getId());
}
targetHost.addMigratingInVm(vm);
incrementMigrationCount();
/** VM migration delay = RAM / bandwidth **/
// we use BW / 2 to model BW available for migration purposes, the other
// half of BW is for VM communication
// around 16 seconds for 1024 MB using 1 Gbit/s network
send(
getId(),
vm.getRam() / ((double) targetHost.getBw() / (2 * 8000)),
CloudSimTags.VM_MIGRATE,
migrate);
}
}
}
// schedules an event to the next time
if (minTime != Double.MAX_VALUE) {
CloudSim.cancelAll(getId(), new PredicateType(CloudSimTags.VM_DATACENTER_EVENT));
send(getId(), getSchedulingInterval(), CloudSimTags.VM_DATACENTER_EVENT);
}
setLastProcessTime(currentTime);
}
}
示例9: processCloudletFilesDone
import org.cloudbus.cloudsim.Log; //导入方法依赖的package包/类
@Override
protected void processCloudletFilesDone(SimEvent ev) {
// Retrieves data from the ev
Object[] data = (Object[]) ev.getData();
String action = (String) data[0];
Cloudlet cl = (Cloudlet) data[1];
File tempFile = (File) data[2];
double tempPower = (double) data[3];
double transTime = (double) data[4];
double tempEnergy = (double) data[5];
MyPowerHarddriveStorage storage = (MyPowerHarddriveStorage) data[6];
double waitingTime = (double) data[7];
// store results/information
WriteToResultFile.AddValueToSheetTab(waitingTime, cl.getCloudletId(), 2);
WriteToResultFile.AddValueToSheetTab(transTime, cl.getCloudletId(), 3);
WriteToResultFile.AddValueToSheetTab(CloudSim.clock(), cl.getCloudletId(), 7);
WriteToResultFile.AddValueToSheetTab(tempFile.getName(), cl.getCloudletId(), 8);
WriteToResultFile.AddValueToSheetTab(tempFile.getSize(), cl.getCloudletId(), 9);
WriteToResultFile.AddValueToSheetTab(tempEnergy, cl.getCloudletId(), 12);
// Print out confirmation that Files have been handled
Log.formatLine("\n%.6f: %s: Cloudlet # %d: <%s> %s on %s.", CloudSim.clock(), getName(), cl.getCloudletId(),
tempFile.getName(), action, storage.getName());
Log.formatLine("%10s Power consumption of %6.3f Watt(s).", "", tempPower);
Log.formatLine("%10s Queue Waiting time of %9.6f Seconds(s).", "", waitingTime);
Log.formatLine("%10s Transaction time of %9.6f Seconde(s).", "", transTime);
Log.formatLine("%10s Energy consumption of %6.3f Joule(s).", "", tempEnergy);
Log.printLine();
// handle queue
storage.setQueueLength(storage.getQueueLength() - 1);
// if there is no further operation on the disk
if (storage.getActiveEndAt() <= CloudSim.clock()) {
storage.setMode(0); // switch to idle mode
storage.setLastIdleStartTime(CloudSim.clock()); // handle Idle intervals
storage.setActiveEndAt(0.0); // reset EndAt time
}
}
示例10: startMigrate
import org.cloudbus.cloudsim.Log; //导入方法依赖的package包/类
public void startMigrate() {
if (isMigrateEnabled) {
//Log.printLine(CloudSim.clock()+": Migration started..");
List<Map<String, Object>> migrationMap = getVmAllocationPolicy().optimizeAllocation(
getVmList());
if (migrationMap != null && migrationMap.size() > 0) {
migrationAttempted += migrationMap.size();
// Process cloudlets before migration because cloudlets are processed during migration process..
updateCloudletProcessing();
checkCloudletCompletion();
for (Map<String, Object> migrate : migrationMap) {
Vm vm = (Vm) migrate.get("vm");
Host targetHost = (Host) migrate.get("host");
// Host oldHost = vm.getHost();
Log.formatLine(
"%.2f: Migration of %s to %s is started",
CloudSim.clock(),
vm,
targetHost);
targetHost.addMigratingInVm(vm);
/** VM migration delay = RAM / bandwidth **/
// we use BW / 2 to model BW available for migration purposes, the other
// half of BW is for VM communication
// around 16 seconds for 1024 MB using 1 Gbit/s network
send(
getId(),
vm.getRam() / ((double) targetHost.getBw() / (2 * 8000)),
CloudSimTags.VM_MIGRATE,
migrate);
}
}
else {
//Log.printLine(CloudSim.clock()+": No VM to migrate");
}
}
}
示例11: updateCloudletProcessing
import org.cloudbus.cloudsim.Log; //导入方法依赖的package包/类
/**
* Updates processing of each cloudlet running in this PowerDatacenter. It is necessary because
* Hosts and VirtualMachines are simple objects, not entities. So, they don't receive events and
* updating cloudlets inside them must be called from the outside.
*
* @pre $none
* @post $none
*/
@Override
protected void updateCloudletProcessing() {
if (getCloudletSubmitted() == -1 || getCloudletSubmitted() == CloudSim.clock()) {
CloudSim.cancelAll(getId(), new PredicateType(CloudSimTags.VM_DATACENTER_EVENT));
schedule(getId(), getSchedulingInterval(), CloudSimTags.VM_DATACENTER_EVENT);
return;
}
double currentTime = CloudSim.clock();
// if some time passed since last processing
if (currentTime > getLastProcessTime()) {
System.out.print(currentTime + " ");
double minTime = updateCloudetProcessingWithoutSchedulingFutureEventsForce();
if (!isDisableMigrations()) {//如果数据中心可以执行虚拟机迁移
List<Map<String, Object>> migrationMap = getVmAllocationPolicy().optimizeAllocation(
getVmList());
if (migrationMap != null) {
for (Map<String, Object> migrate : migrationMap) {
Vm vm = (Vm) migrate.get("vm");
PowerHost targetHost = (PowerHost) migrate.get("host");
PowerHost oldHost = (PowerHost) vm.getHost();
if (oldHost == null) {
Log.formatLine(
"%.2f: Migration of VM #%d to Host #%d is started",
currentTime,
vm.getId(),
targetHost.getId());
} else {
Log.formatLine(
"%.2f: Migration of VM #%d from Host #%d to Host #%d is started",
currentTime,
vm.getId(),
oldHost.getId(),
targetHost.getId());
}
targetHost.addMigratingInVm(vm);
incrementMigrationCount();
/** VM migration delay = RAM / bandwidth **/
// we use BW / 2 to model BW available for migration purposes, the other
// half of BW is for VM communication
// around 16 seconds for 1024 MB using 1 Gbit/s network
send(
getId(),
vm.getRam() / ((double) targetHost.getBw() / (2 * 8000)),
CloudSimTags.VM_MIGRATE,
migrate);
}
}
}
// 进行下一次调度 schedules an event to the next time
if (minTime != Double.MAX_VALUE) {
CloudSim.cancelAll(getId(), new PredicateType(CloudSimTags.VM_DATACENTER_EVENT));
send(getId(), getSchedulingInterval(), CloudSimTags.VM_DATACENTER_EVENT);
}
setLastProcessTime(currentTime);
}
}