Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a new Test framework that enables testing whole simulations properly #37

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/main/java/cambio/simulator/entities/NamedEntity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cambio.simulator.entities;

import cambio.simulator.models.MiSimModel;
import desmoj.core.simulator.Entity;
import desmoj.core.simulator.Model;

/**
* Class that adds further options for the retrieving of names of {@link Entity}s. Specifically, it provides a plain
Expand All @@ -21,23 +21,25 @@
*/
public abstract class NamedEntity extends Entity {

private final MiSimModel model;
private String plainName;
private String quotedName;
private String quotedPlainName;


/**
* Constructor for a named entity.
*
* @param model The model this entity belongs to.
* @param name The name of the entity.
* @param showInTrace Flag indicating whether the entity should be shown in the trace.
*/
public NamedEntity(Model model, String name, boolean showInTrace) {
public NamedEntity(MiSimModel model, String name, boolean showInTrace) {
super(model, name, showInTrace);
this.plainName = name;
this.quotedPlainName = "'" + name + "'";
this.quotedName = super.getQuotedName();

this.model = model;
}

public String getPlainName() {
Expand Down Expand Up @@ -73,4 +75,9 @@ public String getQuotedPlainName() {
public String getQuotedName() {
return this.quotedName;
}

@Override
public MiSimModel getModel() {
return this.model;
}
}
12 changes: 10 additions & 2 deletions src/main/java/cambio/simulator/entities/NamedExternalEvent.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cambio.simulator.entities;

import cambio.simulator.models.MiSimModel;
import desmoj.core.simulator.ExternalEvent;
import desmoj.core.simulator.Model;

/**
* Class that adds further options for the retrieving of names of {@link ExternalEvent}s. Specifically, it provides a
Expand All @@ -21,6 +21,7 @@
*/
public abstract class NamedExternalEvent extends ExternalEvent {

private final MiSimModel model;
private String plainName;
private String quotedName;
private String quotedPlainName;
Expand All @@ -32,11 +33,13 @@ public abstract class NamedExternalEvent extends ExternalEvent {
* @param name The name of this event.
* @param showInTrace Flag indicating whether the entity should be shown in the trace.
*/
public NamedExternalEvent(Model model, String name, boolean showInTrace) {
public NamedExternalEvent(MiSimModel model, String name, boolean showInTrace) {
super(model, name, showInTrace);
this.plainName = name;
this.quotedPlainName = "'" + name + "'";
this.quotedName = super.getQuotedName();

this.model = model;
}

public String getPlainName() {
Expand Down Expand Up @@ -72,4 +75,9 @@ public String getQuotedPlainName() {
public String getQuotedName() {
return this.quotedName;
}

@Override
public MiSimModel getModel() {
return this.model;
}
}
14 changes: 11 additions & 3 deletions src/main/java/cambio/simulator/entities/NamedSimProcess.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cambio.simulator.entities;

import desmoj.core.simulator.Model;
import cambio.simulator.models.MiSimModel;
import desmoj.core.simulator.SimProcess;

/**
Expand All @@ -21,6 +21,7 @@
*/
public abstract class NamedSimProcess extends SimProcess {

private final MiSimModel model;
private String plainName;
private String quotedName;
private String quotedPlainName;
Expand All @@ -32,7 +33,7 @@ public abstract class NamedSimProcess extends SimProcess {
* @param name The name of this process.
* @param showInTrace Flag indicating whether the entity should be shown in the trace.
*/
public NamedSimProcess(Model model, String name, boolean showInTrace) {
public NamedSimProcess(MiSimModel model, String name, boolean showInTrace) {
this(model, name, false, showInTrace);
}

Expand All @@ -44,11 +45,13 @@ public NamedSimProcess(Model model, String name, boolean showInTrace) {
* @param repeating If this process is automatically restart its lifecycle.
* @param showInTrace Flag indicating whether the entity should be shown in the trace.
*/
public NamedSimProcess(Model model, String name, boolean repeating, boolean showInTrace) {
public NamedSimProcess(MiSimModel model, String name, boolean repeating, boolean showInTrace) {
super(model, name, repeating, showInTrace);
this.plainName = name;
this.quotedPlainName = "'" + name + "'";
this.quotedName = super.getQuotedName();

this.model = model;
}

public String getPlainName() {
Expand Down Expand Up @@ -84,4 +87,9 @@ public String getQuotedPlainName() {
public String getQuotedName() {
return this.quotedName;
}

@Override
public MiSimModel getModel() {
return this.model;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import cambio.simulator.entities.patterns.IPatternLifeCycleHooks;
import cambio.simulator.events.ISelfScheduled;
import cambio.simulator.export.AccumulativeDataPointReporter;
import cambio.simulator.models.MiSimModel;
import co.paralleluniverse.fibers.SuspendExecution;
import desmoj.core.simulator.Model;
import desmoj.core.simulator.TimeInstant;
import org.jetbrains.annotations.NotNull;

Expand All @@ -28,7 +28,7 @@
*/
public final class LoadGeneratorDescriptionExecutor extends RequestSender implements IRequestUpdateListener,
ISelfScheduled, IPatternLifeCycleHooks {
private final Model model;
private final MiSimModel model;

/**
* Target Operation.
Expand All @@ -48,7 +48,7 @@ public final class LoadGeneratorDescriptionExecutor extends RequestSender implem
* @param model the underlying model
* @param loadGeneratorDescription behavioral description of this load generator.
*/
public LoadGeneratorDescriptionExecutor(Model model, @NotNull LoadGeneratorDescription loadGeneratorDescription) {
public LoadGeneratorDescriptionExecutor(MiSimModel model, @NotNull LoadGeneratorDescription loadGeneratorDescription) {
super(model, loadGeneratorDescription.getName() != null
? loadGeneratorDescription.getName()
: "Generator", true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package cambio.simulator.entities.microservice;

import cambio.simulator.misc.Priority;
import cambio.simulator.models.MiSimModel;
import co.paralleluniverse.fibers.SuspendExecution;
import desmoj.core.simulator.Event;
import desmoj.core.simulator.Model;

/**
* For now this is an unused event that represents the killing of an instance.
*
* @author Lion Wagner
*/
public class InstanceKillEvent extends Event<MicroserviceInstance> {
public InstanceKillEvent(Model model, String name, boolean showInTrace) {
public InstanceKillEvent(MiSimModel model, String name, boolean showInTrace) {
super(model, name, showInTrace);
this.setSchedulingPriority(Priority.VERY_HIGH);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cambio.simulator.entities.microservice;

import cambio.simulator.models.MiSimModel;
import co.paralleluniverse.fibers.SuspendExecution;
import desmoj.core.simulator.Event;
import desmoj.core.simulator.Model;

/**
* Represents the end of the shutdown process of an instance.
Expand All @@ -11,7 +11,7 @@
*/
public class InstanceShutdownEndEvent extends Event<MicroserviceInstance> {

public InstanceShutdownEndEvent(Model model, String name, boolean showInTrace) {
public InstanceShutdownEndEvent(MiSimModel model, String name, boolean showInTrace) {
super(model, name, showInTrace);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cambio.simulator.entities.microservice;

import cambio.simulator.misc.Priority;
import cambio.simulator.models.MiSimModel;
import co.paralleluniverse.fibers.SuspendExecution;
import desmoj.core.simulator.Event;
import desmoj.core.simulator.Model;

/**
* Triggers the instance to stats its shutdown process.
Expand All @@ -17,7 +17,7 @@
public class InstanceShutdownStartEvent extends Event<MicroserviceInstance> {


public InstanceShutdownStartEvent(Model model, String name, boolean showInTrace) {
public InstanceShutdownStartEvent(MiSimModel model, String name, boolean showInTrace) {
super(model, name, showInTrace);
this.setSchedulingPriority(Priority.HIGH);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cambio.simulator.entities.microservice;

import cambio.simulator.misc.Priority;
import cambio.simulator.models.MiSimModel;
import co.paralleluniverse.fibers.SuspendExecution;
import desmoj.core.simulator.Event;
import desmoj.core.simulator.Model;

/**
* Triggers the startup procedure for a {@code MicroserviceInstance}.
Expand All @@ -12,7 +12,7 @@
*/
public class InstanceStartupEvent extends Event<MicroserviceInstance> {

public InstanceStartupEvent(Model model, String name, boolean showInTrace) {
public InstanceStartupEvent(MiSimModel model, String name, boolean showInTrace) {
super(model, name, showInTrace);
this.setSchedulingPriority(Priority.HIGH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import cambio.simulator.entities.patterns.*;
import cambio.simulator.export.AccumulativeDataPointReporter;
import cambio.simulator.export.MultiDataPointReporter;
import cambio.simulator.models.MiSimModel;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import desmoj.core.dist.NumericalDist;
import desmoj.core.simulator.Event;
import desmoj.core.simulator.Model;

/**
* A Microservice is one of the core Entities of the simulation. It represents the meta layer of a microservice that is
Expand Down Expand Up @@ -76,7 +76,7 @@ public class Microservice extends NamedEntity {
/**
* Creates a new instance of a {@link Microservice}.
*/
public Microservice(Model model, String name, boolean showInTrace) {
public Microservice(MiSimModel model, String name, boolean showInTrace) {
super(model, name, showInTrace);
//default load balancer
loadBalancer = new LoadBalancer(model, "Loadbalancer", traceIsOn(), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cambio.simulator.entities.networking.*;
import cambio.simulator.entities.patterns.*;
import cambio.simulator.export.MultiDataPointReporter;
import cambio.simulator.models.MiSimModel;
import cambio.simulator.resources.cpu.CPU;
import cambio.simulator.resources.cpu.CPUProcess;
import cambio.simulator.resources.cpu.scheduling.FIFOScheduler;
Expand Down Expand Up @@ -56,7 +57,7 @@ public class MicroserviceInstance extends RequestSender implements IRequestUpdat
private long waiting = 0;


MicroserviceInstance(Model model, String name, boolean showInTrace, Microservice microservice,
MicroserviceInstance(MiSimModel model, String name, boolean showInTrace, Microservice microservice,
int instanceID) {
super(model, name, showInTrace);
this.owner = microservice;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cambio.simulator.entities.microservice;

import cambio.simulator.entities.NamedExternalEvent;
import cambio.simulator.models.MiSimModel;
import co.paralleluniverse.fibers.SuspendExecution;
import desmoj.core.simulator.Model;

/**
* For now this is an unused event to represent the scaling of a microservice.
Expand All @@ -17,7 +17,7 @@ public class MicroserviceScaleEvent extends NamedExternalEvent {
/**
* Creates a new scaling event.
*/
public MicroserviceScaleEvent(Model model, String name, boolean showInTrace, Microservice microservice,
public MicroserviceScaleEvent(MiSimModel model, String name, boolean showInTrace, Microservice microservice,
int targetInstanceCount) {
super(model, name, showInTrace);
this.microservice = microservice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import cambio.simulator.entities.NamedEntity;
import cambio.simulator.entities.networking.DependencyDescription;
import cambio.simulator.entities.networking.ServiceDependencyInstance;
import cambio.simulator.models.MiSimModel;
import com.google.gson.annotations.Expose;
import desmoj.core.dist.NumericalDist;
import desmoj.core.simulator.Model;

/**
* An {@code Operation} represents an endpoint of a service. It has a specific computational demand and may have
Expand All @@ -29,7 +29,7 @@ public class Operation extends NamedEntity {
* @param ownerMS {@link Microservice} that owns this operation.
* @param demand CPU demand of this operation.
*/
public Operation(Model model, String name, boolean showInTrace, Microservice ownerMS, int demand) {
public Operation(MiSimModel model, String name, boolean showInTrace, Microservice ownerMS, int demand) {
super(model, (ownerMS == null ? "" : ownerMS.getPlainName() + ".") + name, showInTrace);
this.demand = demand;
this.ownerMS = ownerMS;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cambio.simulator.entities.networking;

import cambio.simulator.entities.microservice.MicroserviceInstance;
import desmoj.core.simulator.Model;
import cambio.simulator.models.MiSimModel;

/**
* Represents a {@code Request} between two {@code MicroserviceInstance}s. Hold information about the {@code
Expand All @@ -19,7 +19,7 @@ public class InternalRequest extends Request {
* @param dependency {@link ServiceDependencyInstance} that should be competed by this request.
* @param requester {@link MicroserviceInstance} that requests the answer to this request.
*/
public InternalRequest(Model model, boolean showInTrace, ServiceDependencyInstance dependency,
public InternalRequest(MiSimModel model, boolean showInTrace, ServiceDependencyInstance dependency,
MicroserviceInstance requester) {
super(model,
String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cambio.simulator.entities.networking;

import cambio.simulator.misc.Priority;
import cambio.simulator.models.MiSimModel;
import co.paralleluniverse.fibers.SuspendExecution;
import desmoj.core.simulator.Model;

/**
* Event that should be scheduled when a request gets canceled.
Expand All @@ -14,7 +14,7 @@ public class NetworkRequestCanceledEvent extends NetworkRequestEvent {
private final RequestFailedReason reason;
private final String details;

public NetworkRequestCanceledEvent(Model model, String name, boolean showInTrace, Request request,
public NetworkRequestCanceledEvent(MiSimModel model, String name, boolean showInTrace, Request request,
RequestFailedReason reason) {
this(model, name, showInTrace, request, reason, null);
}
Expand All @@ -26,7 +26,7 @@ public NetworkRequestCanceledEvent(Model model, String name, boolean showInTrace
* @param reason why the request canceled/failed
* @param details optional reasoning string that is used in the trace
*/
public NetworkRequestCanceledEvent(Model model, String name, boolean showInTrace, Request request,
public NetworkRequestCanceledEvent(MiSimModel model, String name, boolean showInTrace, Request request,
RequestFailedReason reason, String details) {
super(model, name, showInTrace, request);
this.reason = reason;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.util.Collection;

import cambio.simulator.entities.NamedExternalEvent;
import cambio.simulator.models.MiSimModel;
import co.paralleluniverse.fibers.SuspendExecution;
import desmoj.core.simulator.Model;
import desmoj.core.simulator.TimeInstant;

/**
Expand All @@ -27,7 +27,7 @@ public abstract class NetworkRequestEvent extends NamedExternalEvent {
*
* @param travelingRequest the request that is associated with this request.
*/
public NetworkRequestEvent(Model model, String name, boolean showInTrace, Request travelingRequest) {
public NetworkRequestEvent(MiSimModel model, String name, boolean showInTrace, Request travelingRequest) {
super(model, name, showInTrace);
this.travelingRequest = travelingRequest;
updateListeners = travelingRequest.getUpdateListeners();
Expand Down
Loading