congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Host
Code IndexAdd Tabnine to your IDE (free)

How to use
Host
in
org.cloudbus.cloudsim

Best Java code snippets using org.cloudbus.cloudsim.Host (Showing top 20 results out of 315)

origin: Cloudslab/cloudsim

if (!getVmsMigratingIn().contains(vm)) {
  if (getStorage() < vm.getSize()) {
    Log.printConcatLine("[VmScheduler.addMigratingInVm] Allocation of VM #", vm.getId(), " to Host #",
        getId(), " failed by storage");
    System.exit(0);
  if (!getRamProvisioner().allocateRamForVm(vm, vm.getCurrentRequestedRam())) {
    Log.printConcatLine("[VmScheduler.addMigratingInVm] Allocation of VM #", vm.getId(), " to Host #",
        getId(), " failed by RAM");
    System.exit(0);
  if (!getBwProvisioner().allocateBwForVm(vm, vm.getCurrentRequestedBw())) {
    Log.printLine("[VmScheduler.addMigratingInVm] Allocation of VM #" + vm.getId() + " to Host #"
        + getId() + " failed by BW");
    System.exit(0);
  getVmScheduler().getVmsMigratingIn().add(vm.getUid());
  if (!getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips())) {
    Log.printLine("[VmScheduler.addMigratingInVm] Allocation of VM #" + vm.getId() + " to Host #"
        + getId() + " failed by MIPS");
    System.exit(0);
  setStorage(getStorage() - vm.getSize());
  getVmsMigratingIn().add(vm);
  getVmList().add(vm);
  updateVmsProcessing(CloudSim.clock());
  vm.getHost().updateVmsProcessing(CloudSim.clock());
origin: Cloudslab/cloudsim

/**
 * Sets the PEs of the host to a FAILED status. NOTE: <tt>resName</tt> is used for debugging
 * purposes, which is <b>ON</b> by default. Use {@link #setFailed(boolean)} if you do not want
 * this information.
 * 
 * @param resName the name of the resource
 * @param failed the failed
 * @return <tt>true</tt> if successful, <tt>false</tt> otherwise
 */
public boolean setFailed(String resName, boolean failed) {
  // all the PEs are failed (or recovered, depending on fail)
  this.failed = failed;
  PeList.setStatusFailed(getPeList(), resName, getId(), failed);
  return true;
}
origin: Cloudslab/cloudsim

/**
 * Deallocate all resources of a VM.
 * 
 * @param vm the VM
 */
protected void vmDeallocate(Vm vm) {
  getRamProvisioner().deallocateRamForVm(vm);
  getBwProvisioner().deallocateBwForVm(vm);
  getVmScheduler().deallocatePesForVm(vm);
  setStorage(getStorage() + vm.getSize());
}
origin: Cloudslab/cloudsim

/**
 * Deallocate all resources of all VMs.
 */
protected void vmDeallocateAll() {
  getRamProvisioner().deallocateRamForAllVms();
  getBwProvisioner().deallocateBwForAllVms();
  getVmScheduler().deallocatePesForAllVms();
}
origin: Cloudslab/cloudsim

if (getStorage() < vm.getSize()) {
  Log.printConcatLine("[VmScheduler.vmCreate] Allocation of VM #", vm.getId(), " to Host #", getId(),
      " failed by storage");
  return false;
if (!getRamProvisioner().allocateRamForVm(vm, vm.getCurrentRequestedRam())) {
  Log.printConcatLine("[VmScheduler.vmCreate] Allocation of VM #", vm.getId(), " to Host #", getId(),
      " failed by RAM");
  return false;
if (!getBwProvisioner().allocateBwForVm(vm, vm.getCurrentRequestedBw())) {
  Log.printConcatLine("[VmScheduler.vmCreate] Allocation of VM #", vm.getId(), " to Host #", getId(),
      " failed by BW");
  getRamProvisioner().deallocateRamForVm(vm);
  return false;
if (!getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips())) {
  Log.printConcatLine("[VmScheduler.vmCreate] Allocation of VM #", vm.getId(), " to Host #", getId(),
      " failed by MIPS");
  getRamProvisioner().deallocateRamForVm(vm);
  getBwProvisioner().deallocateBwForVm(vm);
  return false;
setStorage(getStorage() - vm.getSize());
getVmList().add(vm);
vm.setHost(this);
return true;
origin: Cloudslab/cloudsim

/**
 * Reallocate migrating in vms. Gets the VM in the migrating in queue
   * and allocate them on the host.
 */
public void reallocateMigratingInVms() {
  for (Vm vm : getVmsMigratingIn()) {
    if (!getVmList().contains(vm)) {
      getVmList().add(vm);
    }
    if (!getVmScheduler().getVmsMigratingIn().contains(vm.getUid())) {
      getVmScheduler().getVmsMigratingIn().add(vm.getUid());
    }
    getRamProvisioner().allocateRamForVm(vm, vm.getCurrentRequestedRam());
    getBwProvisioner().allocateBwForVm(vm, vm.getCurrentRequestedBw());
    getVmScheduler().allocatePesForVm(vm, vm.getCurrentRequestedMips());
    setStorage(getStorage() - vm.getSize());
  }
}
origin: Cloudslab/cloudsim

  @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;
  }
}
origin: Cloudslab/cloudsim

/**
 * Gets a {@link Host} with a given id.
 * 
 * @param <T> the generic type
 * @param hostList the list of existing hosts
 * @param id the host ID
 * @return a Host with the given ID or $null if not found
   * 
 * @pre id >= 0
 * @post $none
 */
public static <T extends Host> T getById(List<T> hostList, int id) {
  for (T host : hostList) {
    if (host.getId() == id) {
      return host;
    }
  }
  return null;
}
origin: Cloudslab/cloudsim

  /**
   * Gets the max utilization among the PEs of a given VM placed at a given host.
   * @param host The host where the VM is placed
   * @param vm The VM to get the max PEs utilization
   * @return The max utilization among the PEs of the VM
   */
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;
}
origin: stackoverflow.com

  for (int i = 1; i < freePesTmp.size(); i++) {
    Host h2=hostList.get(i);
    freeramh1=h1.getRamProvisioner().getAvailableRam();
    freeramh2=h2.getRamProvisioner().getAvailableRam();
    freepesh1=freePesTmp.get(j);
    freepesh2=freePesTmp.get(i);
result = host.vmCreate(vm);
origin: Cloudslab/cloudsim

/**
 * Creates the given VM within the NetworkDatacenter. 
   * It can be directly accessed by Datacenter Broker which manages allocation of Cloudlets.
 * 
   * @param vm
   * @return true if the VW was created successfully, false otherwise
 */
public boolean processVmCreateNetwork(Vm vm) {
  boolean result = getVmAllocationPolicy().allocateHostForVm(vm);
  if (result) {
    VmToSwitchid.put(vm.getId(), ((NetworkHost) vm.getHost()).sw.getId());
    VmtoHostlist.put(vm.getId(), vm.getHost().getId());
    System.out.println(vm.getId() + " VM is created on " + vm.getHost().getId());
    getVmList().add(vm);
    vm.updateVmProcessing(CloudSim.clock(), getVmAllocationPolicy().getHost(vm).getVmScheduler()
        .getAllocatedMipsForVm(vm));
  }
  return result;
}
origin: Cloudslab/cloudsim

host.removeMigratingInVm(vm);
boolean result = getVmAllocationPolicy().allocateHostForVm(vm, host);
if (!result) {
    CloudSim.clock(),
    vm.getId(),
    host.getId());
vm.setInMigration(false);
origin: Cloudslab/cloudsim

@Override
public double updateVmsProcessing(double currentTime) {
  double smallerTime = super.updateVmsProcessing(currentTime);
  setPreviousUtilizationMips(getUtilizationMips());
  setUtilizationMips(0);
      Log.formatLine(
          "%.2f: [Host #" + getId() + "] Total allocated MIPS for VM #" + vm.getId()
              + " (Host #" + vm.getHost().getId()
              + ") is %.2f, was requested %.2f out of total %.2f (%.2f%%)",
          CloudSim.clock(),
origin: Cloudslab/cloudsim

new Host(
  hostId,
  new RamProvisionerSimple(ram),
origin: Cloudslab/cloudsim

/**
 * Gets the pes number.
 * 
 * @return the pes number
 */
public int getNumberOfPes() {
  return getPeList().size();
}
origin: Cloudslab/cloudsim

/**
 * Gets the host memory.
 * 
 * @return the host memory
 * @pre $none
 * @post $result > 0
 */
public int getRam() {
  return getRamProvisioner().getRam();
}
origin: Cloudslab/cloudsim

result = host.vmCreate(vm);
origin: thiagotts/CloudReports

/**
 * Gets the power after allocation.
 *
 * @param host the host.
 * @param vm the virtual machine.
 * @return the power usage after allocation of the virtual machine.
 */
protected double getPowerAfterAllocation(PowerHost host, Vm vm) {
  List<Double> allocatedMipsForVm = null;
  PowerHost allocatedHost = (PowerHost) vm.getHost();
  if (allocatedHost != null) {
    allocatedMipsForVm = allocatedHost.getAllocatedMipsForVm(vm);
  }
  if (!host.allocatePesForVm(vm, vm.getCurrentRequestedMips())) {
    return -1;
  }
  double power = host.getPower();
  host.deallocatePesForVm(vm);
  if (allocatedHost != null && allocatedMipsForVm != null) {
    vm.getHost().allocatePesForVm(vm, allocatedMipsForVm);
  }
  return power;
}
origin: Cloudslab/cloudsim

/**
 * Creates a new VmAllocationPolicySimple object.
 * 
 * @param list the list of hosts
 * @pre $none
 * @post $none
 */
public VmAllocationPolicySimple(List<? extends Host> list) {
  super(list);
  setFreePes(new ArrayList<Integer>());
  for (Host host : getHostList()) {
    getFreePes().add(host.getNumberOfPes());
  }
  setVmTable(new HashMap<String, Host>());
  setUsedPes(new HashMap<String, Integer>());
}
origin: Cloudslab/cloudsim

/**
 * Gets the host bw.
 * 
 * @return the host bw
 * @pre $none
 * @post $result > 0
 */
public long getBw() {
  return getBwProvisioner().getBw();
}
org.cloudbus.cloudsimHost

Javadoc

A Host is a Physical Machine (PM) inside a Datacenter. It is also called as a Server. It executes actions related to management of virtual machines (e.g., creation and destruction). A host has a defined policy for provisioning memory and bw, as well as an allocation policy for Pe's to virtual machines. A host is associated to a datacenter. It can host virtual machines.

Most used methods

  • getId
    Gets the host id.
  • allocatePesForVm
    Allocates PEs for a VM.
  • getAllocatedMipsForVm
    Gets the MIPS share of each Pe that is allocated to a given VM.
  • getRamProvisioner
    Gets the ram provisioner.
  • vmCreate
    Try to allocate resources to a new VM in the Host.
  • <init>
    Instantiates a new host.
  • getBwProvisioner
    Gets the bw provisioner.
  • getNumberOfPes
    Gets the pes number.
  • getPeList
    Gets the pe list.
  • getStorage
    Gets the host storage.
  • getTotalMips
    Gets the total mips.
  • getVm
    Gets a VM by its id and user.
  • getTotalMips,
  • getVm,
  • getVmList,
  • getVmScheduler,
  • getVmsMigratingIn,
  • isFailed,
  • reallocateMigratingInVms,
  • removeMigratingInVm,
  • setBwProvisioner,
  • setDatacenter

Popular in Java

  • Running tasks concurrently on multiple threads
  • setScale (BigDecimal)
  • getExternalFilesDir (Context)
  • getContentResolver (Context)
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now