From 51e8821af6f3f04a269727d4b8311b56f26577cd Mon Sep 17 00:00:00 2001 From: Charafeddine Date: Thu, 4 Apr 2024 08:52:35 +0100 Subject: [PATCH] adds listeners --- CHANGELOG.md | 5 ++ .../datacentersmanager/AbstractNode.java | 6 +- .../ComputingNodesGenerator.java | 2 - .../DefaultComputingNode.java | 5 +- .../DefaultComputingNodesGenerator.java | 4 +- .../datacentersmanager/LocationAwareNode.java | 4 +- .../datacentersmanager/Router.java | 5 -- .../network/DefaultNetworkModel.java | 18 +----- .../pureedgesim/network/NetworkLink.java | 17 ------ .../scenariomanager/EdgeDevicesParser.java | 5 +- .../scenariomanager/SimulationParameters.java | 4 +- .../OnSimulationEndListener.java | 11 ++++ .../OnSimulationStartListener.java | 11 ++++ .../simulationengine/PureEdgeSim.java | 36 ++++++----- .../simulationengine/SimEntity.java | 4 -- .../DefaultSimulationManager.java | 14 ++--- .../pureedgesim/simulationmanager/SimLog.java | 3 +- .../simulationmanager/SimulationThread.java | 6 +- .../taskorchestrator/DefaultOrchestrator.java | 13 +--- .../examples/Example4CustomComputingNode.java | 11 ++-- .../examples/Example7ClusteringDevice.java | 9 +-- pom.xml | 60 ++++++++++++------- 22 files changed, 123 insertions(+), 130 deletions(-) create mode 100644 PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/OnSimulationEndListener.java create mode 100644 PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/OnSimulationStartListener.java diff --git a/CHANGELOG.md b/CHANGELOG.md index bca8b80..ff2e85b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Version 5.3 Changelog (April 4th 2024) + +* Improved code quality (Listener Design Pattern) +* Switched back to Java 8 for broader compatibility + ## Version 5.2 Changelog (June 11th 2023) * Improved performance diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/AbstractNode.java b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/AbstractNode.java index 96bfd7f..624b5a8 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/AbstractNode.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/AbstractNode.java @@ -18,12 +18,13 @@ import com.mechalikh.pureedgesim.scenariomanager.SimulationParameters; import com.mechalikh.pureedgesim.simulationengine.Event; +import com.mechalikh.pureedgesim.simulationengine.OnSimulationStartListener; import com.mechalikh.pureedgesim.simulationengine.SimEntity; import com.mechalikh.pureedgesim.simulationmanager.SimulationManager; /** * This abstract class represents a computing node in the simulation. */ -public abstract class AbstractNode extends SimEntity implements ComputingNode { +public abstract class AbstractNode extends SimEntity implements ComputingNode, OnSimulationStartListener { /** * The update status event ID. @@ -82,7 +83,8 @@ protected AbstractNode(SimulationManager simulationManager) { * Defines the logic to be performed by the computing node when the simulation * starts. */ - public void startInternal() { + @Override + public void onSimulationStart() { scheduleNow(this, UPDATE_STATUS); } diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/ComputingNodesGenerator.java b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/ComputingNodesGenerator.java index 9ccd8ac..c0aa70f 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/ComputingNodesGenerator.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/ComputingNodesGenerator.java @@ -22,8 +22,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Random; - import org.w3c.dom.Element; import com.mechalikh.pureedgesim.locationmanager.MobilityModel; diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/DefaultComputingNode.java b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/DefaultComputingNode.java index c72b381..4af89d3 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/DefaultComputingNode.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/DefaultComputingNode.java @@ -316,9 +316,6 @@ public void setApplicationPlacementLocation(ComputingNode node) { } - @Override - protected void onSimulationEnd() { - // Do something when the simulation finishes. - } + } diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/DefaultComputingNodesGenerator.java b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/DefaultComputingNodesGenerator.java index 4a388bf..948fd63 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/DefaultComputingNodesGenerator.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/DefaultComputingNodesGenerator.java @@ -173,14 +173,14 @@ protected void generateDataCenters(String file, TYPES type) { cloudOnlyList.add(computingNode); mistAndCloudListSensorsExcluded.add(computingNode); if (SimulationParameters.enableOrchestrators - && SimulationParameters.deployOrchestrators == "CLOUD") { + && "CLOUD".equals(SimulationParameters.deployOrchestrators)) { orchestratorsList.add(computingNode); } } else { edgeOnlyList.add(computingNode); mistAndEdgeListSensorsExcluded.add(computingNode); if (SimulationParameters.enableOrchestrators - && SimulationParameters.deployOrchestrators == "EDGE") { + && "EDGE".equals(SimulationParameters.deployOrchestrators)) { orchestratorsList.add(computingNode); } } diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/LocationAwareNode.java b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/LocationAwareNode.java index fd4445f..17fe910 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/LocationAwareNode.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/LocationAwareNode.java @@ -35,8 +35,8 @@ protected LocationAwareNode(SimulationManager simulationManager) { } @Override - public void startInternal() { - super.startInternal(); + public void onSimulationStart() { + super.onSimulationStart(); mobilityModel.generatePath(); } diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/Router.java b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/Router.java index c5cfcbb..580f732 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/Router.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/datacentersmanager/Router.java @@ -8,11 +8,6 @@ public Router(SimulationManager simulationManager) { super(simulationManager, 0, 0, 0, 0); } - @Override - public void startInternal() { - // Do nothing - } - @Override public void setApplicationPlacementLocation(ComputingNode node) { // Do nothing diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/network/DefaultNetworkModel.java b/PureEdgeSim/com/mechalikh/pureedgesim/network/DefaultNetworkModel.java index 63e1c65..7bc6a9e 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/network/DefaultNetworkModel.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/network/DefaultNetworkModel.java @@ -257,21 +257,5 @@ protected void offloadingRequestRecievedByOrchestrator(TransferProgress transfer scheduleNow(simulationManager, DefaultSimulationManager.SEND_TASK_FROM_ORCH_TO_DESTINATION, transfer.getTask()); } - /** - * Defines the logic to be performed by the default network model when the - * simulation starts. - */ - @Override - public void startInternal() { - // Do nothing. - } - - /** - * Defines the logic to be performed by the default network model when the - * simulation ends. - */ - @Override - public void onSimulationEnd() { - // Do something when the simulation finishes. - } + } diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/network/NetworkLink.java b/PureEdgeSim/com/mechalikh/pureedgesim/network/NetworkLink.java index 4fee269..a709b09 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/network/NetworkLink.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/network/NetworkLink.java @@ -80,15 +80,6 @@ public NetworkLink setBandwidth(double bandwidth) { return this; } - /** - * Defines the logic to be performed by the network link when the simulation - * starts. - */ - @Override - public void startInternal() { - // Do nothing for now. - } - public ComputingNode getSrc() { return src; } @@ -230,12 +221,4 @@ public double getTotalTransferredData() { return totalTrasferredData; } - /** - * Defines the logic to be performed by the network link when the simulation - * ends. - */ - @Override - public void onSimulationEnd() { - // Do something when the simulation finishes. - } } diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/scenariomanager/EdgeDevicesParser.java b/PureEdgeSim/com/mechalikh/pureedgesim/scenariomanager/EdgeDevicesParser.java index 4bfed11..7b83c17 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/scenariomanager/EdgeDevicesParser.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/scenariomanager/EdgeDevicesParser.java @@ -1,5 +1,6 @@ package com.mechalikh.pureedgesim.scenariomanager; +import java.util.Arrays; import java.util.List; import org.w3c.dom.Document; @@ -34,9 +35,9 @@ protected boolean typeSpecificChecking(Document xmlDoc) { } protected void checkEdgeDevice(Element deviceElement) { - for (String element : List.of("connectivity", "mobility", "battery", "percentage", "speed", "minPauseDuration", + for (String element : Arrays.asList(new String[]{"connectivity", "mobility", "battery", "percentage", "speed", "minPauseDuration", "maxPauseDuration", "minMobilityDuration", "maxMobilityDuration", "batteryCapacity", "generateTasks", - "isOrchestrator", "idleConsumption", "maxConsumption", "cores", "mips", "ram", "storage")) + "isOrchestrator", "idleConsumption", "maxConsumption", "cores", "mips", "ram", "storage"})) isElementPresent(deviceElement, element); for (String element : List.of("speed", "minPauseDuration", "minMobilityDuration", "batteryCapacity", diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/scenariomanager/SimulationParameters.java b/PureEdgeSim/com/mechalikh/pureedgesim/scenariomanager/SimulationParameters.java index 30bb590..2753d77 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/scenariomanager/SimulationParameters.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/scenariomanager/SimulationParameters.java @@ -86,7 +86,7 @@ public class SimulationParameters { /** * Simualtion time in seconds. * - * @see com.mechalikh.pureedgesim.simulationmanager.DefaultSimulationManager#startInternal() + * @see com.mechalikh.pureedgesim.simulationmanager.DefaultSimulationManager#onSimulationStart() */ public static double simulationDuration; @@ -459,7 +459,7 @@ public enum TYPES { /** * The network model update interval. * - * @see com.mechalikh.pureedgesim.network.NetworkLink#startInternal() + * @see com.mechalikh.pureedgesim.network.NetworkLink#onSimulationStart() */ public static double networkUpdateInterval; diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/OnSimulationEndListener.java b/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/OnSimulationEndListener.java new file mode 100644 index 0000000..f5d30ac --- /dev/null +++ b/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/OnSimulationEndListener.java @@ -0,0 +1,11 @@ +package com.mechalikh.pureedgesim.simulationengine; + +/** + * An interface to listen for events when the simulation ends. + */ +public interface OnSimulationEndListener { + /** + * Called when the simulation ends. + */ + void onSimulationEnd(); +} diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/OnSimulationStartListener.java b/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/OnSimulationStartListener.java new file mode 100644 index 0000000..afc17db --- /dev/null +++ b/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/OnSimulationStartListener.java @@ -0,0 +1,11 @@ +package com.mechalikh.pureedgesim.simulationengine; + +/** + * An interface to listen for events when the simulation starts. + */ +public interface OnSimulationStartListener { + /** + * Called when the simulation starts. + */ + void onSimulationStart(); +} diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/PureEdgeSim.java b/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/PureEdgeSim.java index c6c1651..2639582 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/PureEdgeSim.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/PureEdgeSim.java @@ -41,14 +41,13 @@ *

* Once the PureEdgeSim simulation engine has started, it notifies all * simulation entities of the start of the simulation in order to schedule their - * first event. This is guaranteed by the {@link SimEntity#startInternal() - * startInternal()} method. + * first event. This is guaranteed by the {@link OnSimulationStartListener#onSimulationStart()} method. * * @see com.mechalikh.pureedgesim.simulationengine.PureEdgeSim#start() * @see com.mechalikh.pureedgesim.simulationmanager.SimulationThread#startSimulation() - * @see SimEntity#startInternal() + * @see OnSimulationStartListener.onSimulationStart() * @see com.mechalikh.pureedgesim.simulationmanager.DefaultSimulationManager#startSimulation() - * @see com.mechalikh.pureedgesim.simulationmanager.DefaultSimulationManager#startInternal() + * @see com.mechalikh.pureedgesim.simulationmanager.DefaultSimulationManager#onSimulationStart() * * @author Charafeddine Mechalikh * @since PureEdgeSim 5.0 @@ -82,9 +81,9 @@ public PureEdgeSim() { } /** - * Starts the simulation. First, it notifies all simulation entities that the - * simulation has started by calling their {@link SimEntity#startInternal() - * startInternal()} method. The entities will then schedule their first events. + * Starts the simulation. First, it notifies all simulation entities that implement the {@link OnSimulationStartListener} interface that the + * simulation has started by calling their {@link OnSimulationStartListener#onSimulationStart() + * onSimulationStart()} method. The entities will then schedule their first events. * Once, all the entities has scheduled their fist events, a loop will go * through all those events to process them one by one, and the simulation time * is updated according to the time of last processed event. With each processed @@ -96,19 +95,28 @@ public PureEdgeSim() { * @see com.mechalikh.pureedgesim.simulationmanager.Simulation#launchSimulation() * @see com.mechalikh.pureedgesim.simulationmanager.SimulationThread#startSimulation() * @see com.mechalikh.pureedgesim.simulationmanager.DefaultSimulationManager#startSimulation() - * @see SimEntity#startInternal() + * @see OnSimulationStartListener.onSimulationStart() * @see #terminate() */ public void start() { - // Notify all entities that the simulation has started. - entitiesList.forEach(SimEntity::startInternal); + // Notify all entities that the simulation has started. + entitiesList.forEach(entity -> { + if (entity instanceof OnSimulationStartListener) { + ((OnSimulationStartListener) entity).onSimulationStart(); + } + }); + while (runClockTickAndProcessFutureEvents(Double.MAX_VALUE) && isRunning) { // All the processing happens inside the method called above } // Iteration finished, notify all entities and clear their list - entitiesList.forEach(SimEntity::onSimulationEnd); + entitiesList.forEach(entity -> { + if (entity instanceof OnSimulationEndListener) { + ((OnSimulationEndListener) entity).onSimulationEnd(); + } + }); entitiesList.clear(); } @@ -185,7 +193,7 @@ protected void processEvent(final Event event) { * @param event the new event. * @see SimEntity#schedule(SimEntity, Double, int) * @see SimEntity#schedule(SimEntity, Double, int, Object) - * @see SimEntity#startInternal() + * @see OnSimulationStartListener#onSimulationStart() * @see FutureQueue * @see #start() * @see #runClockTickAndProcessFutureEvents(double) @@ -201,7 +209,7 @@ void insert(Event event) { * @param event the new event. * @see SimEntity#schedule(SimEntity, Double, int) * @see SimEntity#schedule(SimEntity, Double, int, Object) - * @see SimEntity#startInternal() + * @see OnSimulationStartListener#onSimulationStart() * @see FutureQueue * @see #start() * @see #runClockTickAndProcessFutureEvents(double) @@ -222,7 +230,7 @@ public void insertFirst(Event event) { * @see com.mechalikh.pureedgesim.simulationmanager.SimulationThread#loadModels(DefaultSimulationManager * simulationManager) * @see #start() - * @see SimEntity#startInternal() + * @see OnSimulationStartListener#onSimulationStart() */ public void addEntity(SimEntity simEntity) { entitiesList.add(simEntity); diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/SimEntity.java b/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/SimEntity.java index 9c6c1d7..024ed43 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/SimEntity.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/simulationengine/SimEntity.java @@ -63,10 +63,6 @@ protected Event scheduleNow(SimEntity simEntity, int tag, Object data) { return e; } - protected abstract void startInternal(); - - protected abstract void onSimulationEnd(); - protected abstract void processEvent(Event e); } diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/DefaultSimulationManager.java b/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/DefaultSimulationManager.java index 4e06199..987242e 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/DefaultSimulationManager.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/DefaultSimulationManager.java @@ -28,6 +28,7 @@ import com.mechalikh.pureedgesim.scenariomanager.SimulationParameters; import com.mechalikh.pureedgesim.scenariomanager.SimulationParameters.TYPES; import com.mechalikh.pureedgesim.simulationengine.Event; +import com.mechalikh.pureedgesim.simulationengine.OnSimulationStartListener; import com.mechalikh.pureedgesim.simulationengine.PureEdgeSim; import com.mechalikh.pureedgesim.simulationvisualizer.SimulationVisualizer; import com.mechalikh.pureedgesim.taskgenerator.Task; @@ -50,7 +51,7 @@ * @author Charafeddine Mechalikh * @since PureEdgeSim 4.2 */ -public class DefaultSimulationManager extends SimulationManager { +public class DefaultSimulationManager extends SimulationManager implements OnSimulationStartListener { /** * Simulation progress parameters. @@ -111,7 +112,7 @@ public void startSimulation() { * simulation starts. */ @Override - public void startInternal() { + public void onSimulationStart() { // Initialize logger variables. simLog.setGeneratedTasks(taskList.size()); simLog.setCurrentOrchPolicy(scenario.getStringOrchArchitecture()); @@ -448,13 +449,6 @@ protected boolean sameLocation(ComputingNode Dev1, ComputingNode Dev2) { return (distance < RANGE); } - /** - * Defines the logic to be performed by the simulation manager when the - * simulation starts. - */ - @Override - public void onSimulationEnd() { - // Do something when the simulation finishes. - } + } \ No newline at end of file diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/SimLog.java b/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/SimLog.java index 5f5fbf9..097dd07 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/SimLog.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/SimLog.java @@ -41,8 +41,7 @@ import com.mechalikh.pureedgesim.energy.EnergyModelNetworkLink; import com.mechalikh.pureedgesim.network.NetworkLink; import com.mechalikh.pureedgesim.network.TransferProgress; -import com.mechalikh.pureedgesim.scenariomanager.SimulationParameters; -import com.mechalikh.pureedgesim.scenariomanager.SimulationParameters.TYPES; +import com.mechalikh.pureedgesim.scenariomanager.SimulationParameters; import com.mechalikh.pureedgesim.taskgenerator.Task; public class SimLog { diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/SimulationThread.java b/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/SimulationThread.java index 110761f..dfebf5d 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/SimulationThread.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/simulationmanager/SimulationThread.java @@ -193,10 +193,8 @@ protected void loadModels(SimulationManager simulationManager) throws Exception // Initialize the network model SimLog.println(this.getClass().getSimpleName() + " - Initializing the Network Module..."); Constructor networkConstructor = simulation.networkModel.getConstructor(SimulationManager.class); - networkConstructor.newInstance(simulationManager); - - long startTime = System.currentTimeMillis(); - + networkConstructor.newInstance(simulationManager); + // Generate all data centers, servers, an devices SimLog.println(this.getClass().getSimpleName() + " - Initializing the Datacenters Manager Module..."); new DataCentersManager(simulationManager, simulation.mobilityModel, simulation.computingNode, diff --git a/PureEdgeSim/com/mechalikh/pureedgesim/taskorchestrator/DefaultOrchestrator.java b/PureEdgeSim/com/mechalikh/pureedgesim/taskorchestrator/DefaultOrchestrator.java index 4beac59..34433e4 100644 --- a/PureEdgeSim/com/mechalikh/pureedgesim/taskorchestrator/DefaultOrchestrator.java +++ b/PureEdgeSim/com/mechalikh/pureedgesim/taskorchestrator/DefaultOrchestrator.java @@ -110,18 +110,7 @@ public void resultsReturned(Task task) { // Do something with the task that has been finished } - - @Override - public void startInternal() { - // Do something when the simulation starts. e.g., schedule some events - } - - @Override - public void onSimulationEnd() { - // Do something when the simulation finishes. e.g., print some results. - - } - + @Override public void processEvent(Event e) { // Process the scheduled events, if any. diff --git a/PureEdgeSim/examples/Example4CustomComputingNode.java b/PureEdgeSim/examples/Example4CustomComputingNode.java index e8a8c8d..f7ca438 100644 --- a/PureEdgeSim/examples/Example4CustomComputingNode.java +++ b/PureEdgeSim/examples/Example4CustomComputingNode.java @@ -21,7 +21,8 @@ package examples; import com.mechalikh.pureedgesim.datacentersmanager.DefaultComputingNode; -import com.mechalikh.pureedgesim.simulationengine.Event; +import com.mechalikh.pureedgesim.simulationengine.Event; +import com.mechalikh.pureedgesim.simulationengine.OnSimulationStartListener; import com.mechalikh.pureedgesim.simulationmanager.SimulationManager; /** @@ -35,8 +36,8 @@ * @author Charafeddine Mechalikh * @since PureEdgeSim 2.2 */ -public class Example4CustomComputingNode extends DefaultComputingNode { - private static final int DO_SOMETHING = 12000; // Avoid conflicting with CloudSim Plus Tags +public class Example4CustomComputingNode extends DefaultComputingNode implements OnSimulationStartListener{ + private static final int DO_SOMETHING = 12000; // Avoid conflicting with super classes tags public Example4CustomComputingNode(SimulationManager simulationManager, double mipsCapacity, int numberOfPes, double storage, double ram) { @@ -51,8 +52,8 @@ public Example4CustomComputingNode(SimulationManager simulationManager, double m * history. */ @Override - public void startInternal() { - super.startInternal(); + public void onSimulationStart() { + super.onSimulationStart(); scheduleNow(this, DO_SOMETHING); } diff --git a/PureEdgeSim/examples/Example7ClusteringDevice.java b/PureEdgeSim/examples/Example7ClusteringDevice.java index 2dbda06..c4f0876 100644 --- a/PureEdgeSim/examples/Example7ClusteringDevice.java +++ b/PureEdgeSim/examples/Example7ClusteringDevice.java @@ -27,6 +27,7 @@ import com.mechalikh.pureedgesim.datacentersmanager.DefaultComputingNode; import com.mechalikh.pureedgesim.scenariomanager.SimulationParameters; import com.mechalikh.pureedgesim.simulationengine.Event; +import com.mechalikh.pureedgesim.simulationengine.OnSimulationStartListener; import com.mechalikh.pureedgesim.simulationmanager.SimulationManager; /** You must read this to understand @@ -65,7 +66,7 @@ * @author Charafeddine Mechalikh * @since PureEdgeSim 2.3 */ -public class Example7ClusteringDevice extends DefaultComputingNode { +public class Example7ClusteringDevice extends DefaultComputingNode implements OnSimulationStartListener{ private double weight = 0; private Example7ClusteringDevice parent; protected Example7ClusteringDevice Orchestrator; @@ -88,12 +89,12 @@ public Example7ClusteringDevice(SimulationManager simulationManager, double mips /** * The clusters update will be done by scheduling events, the first event has to - * be scheduled within the startInternal() method: + * be scheduled within the onSimulationStart() method: */ @Override - public void startInternal() { - super.startInternal(); + public void onSimulationStart() { + super.onSimulationStart(); schedule(this, 1, UPDATE_CLUSTERS); } diff --git a/pom.xml b/pom.xml index 798b09c..39e115d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,8 +1,10 @@ - + 4.0.0 com.mechalikh pureedgesim - 5.2.0 + 5.3.0 PureEdgeSim https://github.com/CharafeddineMechalikh/PureEdgeSim A simualtor for edge computing environments @@ -30,7 +32,8 @@ scm:git:git@github.com:CharafeddineMechalikh/PureEdgeSim.git - scm:git:git@github.com:CharafeddineMechalikh/PureEdgeSim.git + + scm:git:git@github.com:CharafeddineMechalikh/PureEdgeSim.git https://github.com/CharafeddineMechalikh/PureEdgeSim @@ -49,12 +52,15 @@ - - default @@ -106,7 +112,8 @@ - integration-tests @@ -120,24 +127,29 @@ - + visit https://oss.sonatype.org. MAKE SURE YOU ARE LOGGED IN TO SEE YOUR + DEPLOYMENTS. --> sonatype - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots + + https://s01.oss.sonatype.org/content/repositories/snapshots ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ @@ -179,7 +191,8 @@ - org.apache.maven.plugins @@ -211,7 +224,8 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M5 @@ -248,15 +262,18 @@ - true - repository - ${user.home}/.m2/repository/ @@ -275,11 +292,13 @@ **/examples/Example1.java **/examples/Example5.java - 17 + 1.8 + 1.8 - org.jacoco @@ -318,7 +337,8 @@ maven-javadoc-plugin 3.2.0 - + javadoc-no-fork