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
-
Field Summary
Fields inherited from class desmoj.core.simulator.Schedulable
_schedule -
Constructor Summary
Constructors Constructor Description Microservice(desmoj.core.simulator.Model model, String name, boolean showInTrace) -
Method Summary
Modifier and Type Method Description voidapplyDelay(desmoj.core.dist.NumericalDist<Double> dist, Operation operation_src, Operation operation_trg)voidfinalizeStatistics()doublegetAverageRelativeUtilization()doublegetAverageUtilization()intgetCapacity()intgetInstancesCount()StringgetName()MicroserviceInstancegetNextAvailableInstance()OperationgetOperationByName(String name)Searches anOperationthat has the name that is given as an argument.Operation[]getOperations()StringgetQuotedName()List<Double>getUtilizationOfInstances()voidkillInstance()Kills a random instance.voidkillInstances(int numberOfInstances)Kills the given number of services many random instances.voidscaleToInstancesCount(int numberOfInstances)voidsetCapacity(int capacity)voidsetInstancesCount(int numberOfInstances)voidsetLoadBalancingStrategy(String loadBalancingStrategy)Injector for load balancing strategy for easier json parsing.voidsetName(String name)voidsetOperations(Operation[] operations)voidsetPatternData(PatternData[] patterns)voidstart()StringtoString()Methods inherited from class desmoj.core.simulator.Entity
clone, generateTraceForScheduling, getIdentNumber, getQueueingPriority, getQueues, getScheduledEvents, isEqual, isLarger, isLargerOrEqual, isNotEqual, isQueued, isSimProcess, isSmaller, isSmallerOrEqual, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, scheduleAfter, scheduleAfter, scheduleAfter, scheduleBefore, scheduleBefore, scheduleBefore, schedulePreempt, schedulePreempt, schedulePreempt, setQueueingPriorityMethods inherited from class desmoj.core.simulator.Schedulable
assignReporter, cancel, getCorrespondingReportable, isCurrent, isScheduled, rename, reSchedule, reSchedule, reSchedulePreempt, scheduledNext, setCorrespondingReportableMethods inherited from class desmoj.core.simulator.ModelComponent
current, currentEntity, currentEntityAll, currentEvent, currentlySendDebugNotes, currentlySendTraceNotes, currentModel, currentSimProcess, debugIsOn, debugOff, debugOn, getModel, isExperimentCompatible, isModelCompatible, presentTime, sendDebugNote, sendMessage, sendTraceNote, sendWarning, skipTraceNote, skipTraceNote, traceIsOn, traceOff, traceOn
-
Constructor Details
-
Microservice
-
-
Method Details
-
start
public void start() -
getName
- Overrides:
getNamein classdesmoj.core.simulator.NamedObject
-
setName
-
getCapacity
public int getCapacity() -
setCapacity
public void setCapacity(int capacity) -
setPatternData
-
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
-
getOperationByName
Searches anOperationthat 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,
nullif not found
-
setOperations
-
setLoadBalancingStrategy
Injector for load balancing strategy for easier json parsing.- Parameters:
loadBalancingStrategy- name of the strategy that is to be applied
-
toString
- Overrides:
toStringin classdesmoj.core.simulator.NamedObject
-
getQuotedName
- Overrides:
getQuotedNamein classdesmoj.core.simulator.NamedObject
-
getNextAvailableInstance
- Throws:
NoInstanceAvailableException
-
applyDelay
-
finalizeStatistics
public void finalizeStatistics() -
getAverageRelativeUtilization
public double getAverageRelativeUtilization() -
getUtilizationOfInstances
-
getAverageUtilization
public double getAverageUtilization()
-