Class Microservice
java.lang.Object
desmoj.core.simulator.NamedObject
desmoj.core.simulator.ModelComponent
desmoj.core.simulator.Schedulable
desmoj.core.simulator.Entity
cambio.simulator.entities.NamedEntity
cambio.simulator.entities.microservice.Microservice
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 metadata 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ListCollectingReporterprotected InstanceOwnedPatternConfiguration[]protected intprotected final Set<MicroserviceInstance>protected final MultiDataPointReporterprotected final SnapshotDataPointReporterprotected booleanFields inherited from class desmoj.core.simulator.Schedulable
_schedule -
Constructor Summary
ConstructorsConstructorDescriptionMicroservice(desmoj.core.simulator.Model model, String name, boolean showInTrace) Creates a new instance of aMicroservice. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyDelay(desmoj.core.dist.NumericalDist<Double> dist, Operation operationSrc, Operation operationTrg) Applies the given delay distribution to the given operations.voiddoubledoubleintintUses the loadbalancer of this microservice to find the next suitable target instance.getOperationByName(String name) Searches anOperationthat has the name that is given as an argument.Gets a quoted version of the name of this object.intvoidKills a random instance.voidkillInstances(int numberOfInstances) Kills the given number of services many random instances.voidscaleToInstancesCount(int targetInstanceCount) Schedules the immediate start or shutdown ofMicroserviceInstances until the amount of active instances reaches the target instance count.voidsetCapacity(int capacity) voidsetInstancesCount(int numberOfInstances) Similar toscaleToInstancesCount(int)but also overwrites the general target instance count of this service.voidsetOperations(Operation[] operations) voidstart()Starts thisMicroservice.toString()Methods inherited from class cambio.simulator.entities.NamedEntity
getPlainName, getQuotedPlainName, renameMethods 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, 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, traceOnMethods inherited from class desmoj.core.simulator.NamedObject
getName
-
Field Details
-
instancesSet
-
reporter
-
snapshortReporter
-
accReporter
-
started
protected transient boolean started -
instanceSpawnCounter
protected transient int instanceSpawnCounter -
instanceOwnedPatternConfigurations
@Expose @SerializedName(value="i_patterns", alternate={"instance_patterns","patterns","i_pattern","instance_pattern"}) protected InstanceOwnedPatternConfiguration[] instanceOwnedPatternConfigurations
-
-
Constructor Details
-
Microservice
Creates a new instance of aMicroservice.
-
-
Method Details
-
start
public void start()Starts thisMicroservice. This procedure includes the starting of the defined amount of instances and the initiation of theServiceOwnedPatterns. -
toString
- Overrides:
toStringin classdesmoj.core.simulator.NamedObject
-
getQuotedName
Description copied from class:NamedEntityGets a quoted version of the name of this object. The name will include the object number assigned by DESMO-J.- Overrides:
getQuotedNamein classNamedEntity- Returns:
- the name of this entity surrounded with ' quotes.
-
getCapacity
public int getCapacity() -
setCapacity
public void setCapacity(int capacity) -
getInstancesCount
public int getInstancesCount() -
setInstancesCount
public void setInstancesCount(int numberOfInstances) Similar toscaleToInstancesCount(int)but also overwrites the general target instance count of this service.- Parameters:
numberOfInstances- amount of instance that this service should target.
-
scaleToInstancesCount
public void scaleToInstancesCount(int targetInstanceCount) Schedules the immediate start or shutdown ofMicroserviceInstances until the amount of active instances reaches the target instance count.TODO: restart instances that were shut down.
- Parameters:
targetInstanceCount- amount of instance to which this service should scale.
-
killInstances
public void killInstances(int numberOfInstances) Kills the given number of services many random instances. Accept 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
-
setOperations
-
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 microservice 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
-
getNextAvailableInstance
Uses the loadbalancer of this microservice to find the next suitable target instance.- Returns:
- a
MicroserviceInstancethat should receive the next request - Throws:
NoInstanceAvailableException- if no instance is available
-
applyDelay
public void applyDelay(desmoj.core.dist.NumericalDist<Double> dist, Operation operationSrc, Operation operationTrg) Applies the given delay distribution to the given operations.- Parameters:
dist-NumericalDistof the delay.operationSrc-Operationof thisMicroservicethat should be affected, can be set tonullto affect allOperationsoperationTrg- targetOperationof the operationSrc that should be affected, can be set tonullto affect all outgoingInternalRequests
-
finalizeStatistics
public void finalizeStatistics() -
getRelativeUtilizationOfInstances
-
getAverageRelativeUtilization
public double getAverageRelativeUtilization() -
getUtilizationOfInstances
-
getAverageUtilization
public double getAverageUtilization() -
getStartingInstanceCount
public int getStartingInstanceCount() -
getLoadBalancer
-
getInstancesSet
-