Class Microservice

java.lang.Object
desmoj.core.simulator.NamedObject
desmoj.core.simulator.ModelComponent
desmoj.core.simulator.Schedulable
desmoj.core.simulator.Entity
de.rss.fachstudie.MiSim.entities.microservice.Microservice

public class Microservice
extends desmoj.core.simulator.Entity
A Microservice is one of the core Entities of the simulation. It represents the meta layer of a microservice that is usually present in its managing platform, e.g. CloudFoundry.

Specifically, it can take care of starting, killing and shutting down MicroserviceInstances (in the following just called instances) and provides meta data to each instance. For example, a Microservice object knows which resilience patterns should be implemented by each instance and how many resources each instances is assigned. Naturally it also knows the status of all existing (including killed ones) instances of this service.

Further it has the ability to apply resilience patterns such as autoscaling and different types of load balancing to itself.

The interface of a Microservice is defined via its operations.

Author:
Lion Wagner
See Also:
MicroserviceInstance, LoadBalancingStrategy, ServiceOwnedPattern, InstanceOwnedPattern
  • Constructor Details

    • Microservice

      public Microservice​(desmoj.core.simulator.Model model, String name, boolean showInTrace)
  • Method Details

    • start

      public void start()
    • getName

      public String getName()
      Overrides:
      getName in class desmoj.core.simulator.NamedObject
    • setName

      public void setName​(String name)
    • getCapacity

      public int getCapacity()
    • setCapacity

      public void setCapacity​(int capacity)
    • setPatternData

      public void setPatternData​(PatternData[] patterns)
    • getInstancesCount

      public int getInstancesCount()
    • setInstancesCount

      public void setInstancesCount​(int numberOfInstances)
    • scaleToInstancesCount

      public void scaleToInstancesCount​(int numberOfInstances)
    • killInstances

      public void killInstances​(int numberOfInstances)
      Kills the given number of services many random instances. Accepts numbers larger than the current amount of instances.
      Parameters:
      numberOfInstances - number of instances that should be instantly killed
    • killInstance

      public void killInstance()
      Kills a random instance. Can be called on a service that has 0 running instances.
    • getOperations

      public Operation[] getOperations()
    • getOperationByName

      public Operation getOperationByName​(String name)
      Searches an Operation that has the name that is given as an argument. The real name of the operation may differ. It may starts with the name of this mircoservice instance or ands with a '#' and a number.
      Parameters:
      name - name of the operation that should be found
      Returns:
      an operation that has exactly that name, null if not found
    • setOperations

      public void setOperations​(Operation[] operations)
    • setLoadBalancingStrategy

      public void setLoadBalancingStrategy​(String loadBalancingStrategy)
      Injector for load balancing strategy for easier json parsing.
      Parameters:
      loadBalancingStrategy - name of the strategy that is to be applied
    • toString

      public String toString()
      Overrides:
      toString in class desmoj.core.simulator.NamedObject
    • getQuotedName

      public String getQuotedName()
      Overrides:
      getQuotedName in class desmoj.core.simulator.NamedObject
    • getNextAvailableInstance

      public MicroserviceInstance getNextAvailableInstance() throws NoInstanceAvailableException
      Throws:
      NoInstanceAvailableException
    • applyDelay

      public void applyDelay​(desmoj.core.dist.NumericalDist<Double> dist, Operation operation_src, Operation operation_trg)
    • finalizeStatistics

      public void finalizeStatistics()
    • getAverageRelativeUtilization

      public double getAverageRelativeUtilization()
    • getUtilizationOfInstances

      public List<Double> getUtilizationOfInstances()
    • getAverageUtilization

      public double getAverageUtilization()