de.uka.ipd.sdq.simucomframework
Class AbstractMain

java.lang.Object
  extended by de.uka.ipd.sdq.simucomframework.AbstractMain
All Implemented Interfaces:
ISimuComControl

public abstract class AbstractMain
extends Object
implements ISimuComControl

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

Author:
Steffen Becker

Constructor Summary
AbstractMain()
           
 
Method Summary
 Throwable getErrorThrowable()
          Returns an exception which caused the simulation to terminate in case of simulation errors as indicated by the SimuComResult returned by the startSimulation method
protected  SimuComModel 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()
          Template method pattern.
protected  SimuComResult run(IStatusObserver statusObserver, SimuComConfig config, boolean isRemoteRun)
          Run a simulation using the given configuration and report to the given observer
 void start(org.osgi.framework.BundleContext context)
           
 SimuComResult startSimulation(SimuComConfig config, IStatusObserver observer, boolean isRemoteRun)
          Start a simulation run
protected  void stop()
          Request a simulation stop
 void stop(org.osgi.framework.BundleContext context)
           
 void stopSimulation()
          Cancels a running simulation by disallowing the generation of new simulation events
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMain

public AbstractMain()
Method Detail

start

public void start(org.osgi.framework.BundleContext context)
           throws Exception
Throws:
Exception

stop

public void stop(org.osgi.framework.BundleContext context)
          throws Exception
Throws:
Exception

run

protected SimuComResult 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 progress
config - Configuration options for the simulation
isRemoteRun - 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

protected SimuComModel getModel()
Returns:
The simucom model used in this simulation run

getErrorThrowable

public Throwable getErrorThrowable()
Description copied from interface: ISimuComControl
Returns an exception which caused the simulation to terminate in case of simulation errors as indicated by the SimuComResult returned by the startSimulation method

Specified by:
getErrorThrowable in interface ISimuComControl
Returns:
An error object in case an exception occurred during simulation execution

startSimulation

public SimuComResult startSimulation(SimuComConfig config,
                                     IStatusObserver observer,
                                     boolean isRemoteRun)
Description copied from interface: ISimuComControl
Start a simulation run

Specified by:
startSimulation in interface ISimuComControl
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 progress
isRemoteRun - 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: ISimuComControl
Cancels a running simulation by disallowing the generation of new simulation events

Specified by:
stopSimulation in interface ISimuComControl

getWorkloads

protected abstract IWorkloadDriver[] getWorkloads()
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.

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: ISimuComControl
Retrieve an object containing the status of this simulation.

Specified by:
getStatus in interface ISimuComControl
Returns:
A SimuComStatus object containing the simulation status