Class VmClonerSimple

java.lang.Object
org.cloudsimplus.faultinjection.VmClonerSimple
All Implemented Interfaces:
VmCloner

public class VmClonerSimple
extends java.lang.Object
implements VmCloner
A basic implementation of a VmCloner.
Since:
CloudSim Plus 1.2.2
Author:
raysaoliveira
  • Field Summary

    Fields inherited from interface org.cloudsimplus.faultinjection.VmCloner

    NULL
  • Constructor Summary

    Constructors 
    Constructor Description
    VmClonerSimple​(java.util.function.UnaryOperator<Vm> vmClonerFunction, java.util.function.Function<Vm,​java.util.List<Cloudlet>> cloudletsClonerFunction)
    Creates a Vm cloner which makes the maximum of 1 Vm clone.
  • Method Summary

    Modifier and Type Method Description
    java.util.Map.Entry<Vm,​java.util.List<Cloudlet>> clone​(Vm sourceVm)
    Clones a given Vm using the Vm Cloner Function and their Cloudlets using the Cloudlets Cloner Function, binding the cloned Cloudlets to the cloned Vm.
    int getClonedVmsNumber()
    Gets the number of VMs cloned so far.
    int getMaxClonesNumber()
    Gets the maximum number of Vm clones to create.
    boolean isMaxClonesNumberReached()
    Checks if the maximum number of Vm clones to be created was reached.
    VmCloner setCloudletsClonerFunction​(java.util.function.Function<Vm,​java.util.List<Cloudlet>> cloudletsClonerFunction)
    Gets the Function to be used to clone Vm's Cloudlets.
    VmCloner setMaxClonesNumber​(int maxClonesNumber)  
    VmCloner setVmClonerFunction​(java.util.function.UnaryOperator<Vm> vmClonerFunction)
    Sets the UnaryOperator to be used to clone Vms.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VmClonerSimple

      public VmClonerSimple​(java.util.function.UnaryOperator<Vm> vmClonerFunction, java.util.function.Function<Vm,​java.util.List<Cloudlet>> cloudletsClonerFunction)
      Creates a Vm cloner which makes the maximum of 1 Vm clone.
      Parameters:
      vmClonerFunction - the UnaryOperator to be used to clone Vms.
      cloudletsClonerFunction - the Function to be used to clone Vm's Cloudlets.
      See Also:
      setMaxClonesNumber(int)
  • Method Details

    • getClonedVmsNumber

      public int getClonedVmsNumber()
      Description copied from interface: VmCloner
      Gets the number of VMs cloned so far.
      Specified by:
      getClonedVmsNumber in interface VmCloner
      Returns:
    • clone

      public java.util.Map.Entry<Vm,​java.util.List<Cloudlet>> clone​(Vm sourceVm)
      Description copied from interface: VmCloner
      Clones a given Vm using the Vm Cloner Function and their Cloudlets using the Cloudlets Cloner Function, binding the cloned Cloudlets to the cloned Vm.
      Specified by:
      clone in interface VmCloner
      Parameters:
      sourceVm - the Vm to be cloned
      Returns:
      a Map.Entry where the key is the cloned Vm and the value is the List of cloned Cloudlets.
      See Also:
      VmCloner.setVmClonerFunction(UnaryOperator), VmCloner.setCloudletsClonerFunction(Function)
    • setVmClonerFunction

      public final VmCloner setVmClonerFunction​(java.util.function.UnaryOperator<Vm> vmClonerFunction)
      Description copied from interface: VmCloner
      Sets the UnaryOperator to be used to clone Vms. It is a Function which, when called, creates a clone of a specific Vm.
      Specified by:
      setVmClonerFunction in interface VmCloner
      Parameters:
      vmClonerFunction - the Vm cloner Function to set
      Returns:
    • setCloudletsClonerFunction

      public final VmCloner setCloudletsClonerFunction​(java.util.function.Function<Vm,​java.util.List<Cloudlet>> cloudletsClonerFunction)
      Description copied from interface: VmCloner
      Gets the Function to be used to clone Vm's Cloudlets. When the given Function is called, creates a clone of cloudlets which were running inside a specific Vm.

      Such a Function is used to recreate those Cloudlets inside a clone of the failed VM. In this case, all the Cloudlets are recreated from scratch into the cloned VM. This way, when they are submitted to a broker, they re-start execution from the beginning.

      Specified by:
      setCloudletsClonerFunction in interface VmCloner
      Parameters:
      cloudletsClonerFunction - the Cloudlets cloner Function to set
      Returns:
    • getMaxClonesNumber

      public int getMaxClonesNumber()
      Description copied from interface: VmCloner
      Gets the maximum number of Vm clones to create. For instance, if this value is equal to 2, it means if all VMs from a given broker are destroyed multiple times, a clone will be created only 2 times. If all VMs are destroyed again for the 3rd time, no clone will be created. The default value is 1.
      Specified by:
      getMaxClonesNumber in interface VmCloner
      Returns:
    • isMaxClonesNumberReached

      public boolean isMaxClonesNumberReached()
      Description copied from interface: VmCloner
      Checks if the maximum number of Vm clones to be created was reached.
      Specified by:
      isMaxClonesNumberReached in interface VmCloner
      Returns:
      true if the maximum number of clones was reached, false otherwise
    • setMaxClonesNumber

      public VmCloner setMaxClonesNumber​(int maxClonesNumber)
      Specified by:
      setMaxClonesNumber in interface VmCloner