Package de.uka.ipd.sdq.simucomframework
Class AbstractMain
- java.lang.Object
-
- de.uka.ipd.sdq.simucomframework.AbstractMain
-
- All Implemented Interfaces:
ISimulationControl
,org.osgi.framework.BundleActivator
public abstract class AbstractMain extends Object implements ISimulationControl, org.osgi.framework.BundleActivator
Base class for simulation instances. It contains a generic simulation start and stop logic as well as basic error handling mechanisms. The code generated for each SimuCom instance contains the class main.SimuComControl that inherits from this one and provides the missing information. Excerpt from main.SimuComControl: public class SimuComControl extends de.uka.ipd.sdq.simucomframework.AbstractMain TODO This class currently serves too many concerns, e.g., creation of execution result calculators and mixing of usage response time calculator creation and handling of stop conditions. Therefore, some refactorings are needed. [Lehrig]
-
-
Constructor Summary
Constructors Constructor Description AbstractMain()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Throwable
getErrorThrowable()
Returns an exception which caused the simulation to terminate in case of simulation errors as indicated by theSimuComResult
returned by the startSimulation methodSimuComModel
getModel()
protected abstract IResourceContainerFactory
getResourceContainerFactory()
Template method to return a factory which can be used to instanciate the simulated resource environment.SimuComStatus
getStatus()
Retrieve an object containing the status of this simulation.protected abstract IWorkloadDriver[]
getWorkloads(SimuComConfig config, de.uka.ipd.sdq.scheduler.resources.active.IResourceTableManager resourceTableManager)
Template method pattern.void
prepareSimulation(AbstractSimulationConfig config, IStatusObserver observer, boolean isRemoteRun)
Prepare a simulation runprotected SimulationResult
run(IStatusObserver statusObserver, SimuComConfig config, boolean isRemoteRun)
Run a simulation using the given configuration and report to the given observervoid
start(org.osgi.framework.BundleContext context)
SimulationResult
startSimulation(AbstractSimulationConfig config, IStatusObserver observer, boolean isRemoteRun)
Start a simulation runprotected void
stop()
Request a simulation stopvoid
stop(org.osgi.framework.BundleContext context)
void
stopSimulation()
Cancels a running simulation by disallowing the generation of new simulation events
-
-
-
Method Detail
-
start
public void start(org.osgi.framework.BundleContext context) throws Exception
- Specified by:
start
in interfaceorg.osgi.framework.BundleActivator
- Throws:
Exception
-
stop
public void stop(org.osgi.framework.BundleContext context) throws Exception
- Specified by:
stop
in interfaceorg.osgi.framework.BundleActivator
- Throws:
Exception
-
run
protected SimulationResult run(IStatusObserver statusObserver, SimuComConfig config, boolean isRemoteRun)
Run a simulation using the given configuration and report to the given observer- Parameters:
statusObserver
- Observer to notify about the simulation's progressconfig
- Configuration options for the simulationisRemoteRun
- True if this simulation runs remotely and has no access to the local sensorframework- Returns:
- A status code indicating success or failure of the simulation
-
stop
protected void stop()
Request a simulation stop
-
getModel
public SimuComModel getModel()
- Returns:
- The simucom model used in this simulation run
-
getErrorThrowable
public Throwable getErrorThrowable()
Description copied from interface:ISimulationControl
Returns an exception which caused the simulation to terminate in case of simulation errors as indicated by theSimuComResult
returned by the startSimulation method- Specified by:
getErrorThrowable
in interfaceISimulationControl
- Returns:
- An error object in case an exception occurred during simulation execution
-
prepareSimulation
public void prepareSimulation(AbstractSimulationConfig config, IStatusObserver observer, boolean isRemoteRun)
Description copied from interface:ISimulationControl
Prepare a simulation run- Specified by:
prepareSimulation
in interfaceISimulationControl
- Parameters:
config
- The configuration object which sets many simulation parameters like stop conditions, storage location, etc.observer
- An observer which gets notifications on the simulation progressisRemoteRun
- If true, the simulation uses an own, temporary result store instead of the sensorfactory storage passed in the simulation parameter object. Use this for remote simulation docks which do not have access to the local sensor factory storages
-
startSimulation
public SimulationResult startSimulation(AbstractSimulationConfig config, IStatusObserver observer, boolean isRemoteRun)
Description copied from interface:ISimulationControl
Start a simulation run- Specified by:
startSimulation
in interfaceISimulationControl
- Parameters:
config
- The configuration object which sets many simulation parameters like stop conditions, storage location, etc.observer
- An observer which gets notifications on the simulation progressisRemoteRun
- If true, the simulation uses an own, temporary result store instead of the sensorfactory storage passed in the simulation parameter object. Use this for remote simulation docks which do not have access to the local sensor factory storages- Returns:
- The result of the simulation run
-
stopSimulation
public void stopSimulation()
Description copied from interface:ISimulationControl
Cancels a running simulation by disallowing the generation of new simulation events- Specified by:
stopSimulation
in interfaceISimulationControl
-
getWorkloads
protected abstract IWorkloadDriver[] getWorkloads(SimuComConfig config, de.uka.ipd.sdq.scheduler.resources.active.IResourceTableManager resourceTableManager)
Template method pattern. Child classes have to implement this to return workload drivers to use in the simulation. The workload drivers are used to generate the simulated users.- Parameters:
config
- the simulation configuration data- Returns:
- Workload drivers to use in the simulation run
-
getResourceContainerFactory
protected abstract IResourceContainerFactory getResourceContainerFactory()
Template method to return a factory which can be used to instanciate the simulated resource environment.- Returns:
- A factory which is used to create the simulated resource environment
-
getStatus
public SimuComStatus getStatus()
Description copied from interface:ISimulationControl
Retrieve an object containing the status of this simulation.- Specified by:
getStatus
in interfaceISimulationControl
- Returns:
- A
SimuComStatus
object containing the simulation status
-
-