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 MicroserviceInstance
s (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 ListCollectingReporter
protected InstanceOwnedPatternConfiguration[]
protected int
protected final Set<MicroserviceInstance>
protected final MultiDataPointReporter
protected final SnapshotDataPointReporter
protected boolean
Fields 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 TypeMethodDescriptionvoid
applyDelay
(desmoj.core.dist.NumericalDist<Double> dist, Operation operationSrc, Operation operationTrg) Applies the given delay distribution to the given operations.void
double
double
int
int
Uses the loadbalancer of this microservice to find the next suitable target instance.getOperationByName
(String name) Searches anOperation
that has the name that is given as an argument.Gets a quoted version of the name of this object.int
void
Kills a random instance.void
killInstances
(int numberOfInstances) Kills the given number of services many random instances.void
scaleToInstancesCount
(int targetInstanceCount) Schedules the immediate start or shutdown ofMicroserviceInstance
s until the amount of active instances reaches the target instance count.void
setCapacity
(int capacity) void
setInstancesCount
(int numberOfInstances) Similar toscaleToInstancesCount(int)
but also overwrites the general target instance count of this service.void
setOperations
(Operation[] operations) void
start()
Starts thisMicroservice
.toString()
Methods inherited from class cambio.simulator.entities.NamedEntity
getPlainName, getQuotedPlainName, rename
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, setQueueingPriority
Methods inherited from class desmoj.core.simulator.Schedulable
assignReporter, cancel, getCorrespondingReportable, isCurrent, isScheduled, reSchedule, reSchedule, reSchedulePreempt, scheduledNext, setCorrespondingReportable
Methods 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
Methods 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 theServiceOwnedPattern
s. -
toString
- Overrides:
toString
in classdesmoj.core.simulator.NamedObject
-
getQuotedName
Description copied from class:NamedEntity
Gets a quoted version of the name of this object. The name will include the object number assigned by DESMO-J.- Overrides:
getQuotedName
in 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 ofMicroserviceInstance
s 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 anOperation
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 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,
null
if not found
-
getNextAvailableInstance
Uses the loadbalancer of this microservice to find the next suitable target instance.- Returns:
- a
MicroserviceInstance
that 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
-NumericalDist
of the delay.operationSrc
-Operation
of thisMicroservice
that should be affected, can be set tonull
to affect allOperation
soperationTrg
- targetOperation
of the operationSrc that should be affected, can be set tonull
to affect all outgoingInternalRequest
s
-
finalizeStatistics
public void finalizeStatistics() -
getRelativeUtilizationOfInstances
-
getAverageRelativeUtilization
public double getAverageRelativeUtilization() -
getUtilizationOfInstances
-
getAverageUtilization
public double getAverageUtilization() -
getStartingInstanceCount
public int getStartingInstanceCount() -
getLoadBalancer
-
getInstancesSet
-