bcds.phison.sim
Interface ProcessingModule<V,E>

All Superinterfaces:
WithEnvParams
All Known Implementing Classes:
PmBase, PmDTypeReplicator, PmDumpRAState, PmElemsSequencer, PmLinkFailure, PmNetProps, PmSID, PmSIDTraceToDOT, PmStatic, PmTrace2TR, PmTraceConn, PmTraceConnGbl, PmTraceLinkUsage, PmTraceLinkUsageToDOT, PmTracePathLength, PmTraceProgress, PmTraceTimestepBlocking, PmTraceTrafficMatrix, PmTrfReader

public interface ProcessingModule<V,E>
extends WithEnvParams

Processing modules for PHISON must implement this interface.


Method Summary
 java.lang.String getId()
          Deprecated. Use the method getName of WithEnvParams instead.
 void run(SimEvents evtype, ConnectionInfo<V,E> rq)
          Process an event, whose type evtype.
 void setup(SimCore<V,E> sim)
          Performs initialization of a new instance.
 void shutdown()
          Called by the simulator when simulation has finished.
 SimCore<V,E> sim()
          Returns the core simulator object to which this module is associated.
 
Methods inherited from interface bcds.phison.WithEnvParams
getEnviron, getEnvParams, getName
 

Method Detail

setup

void setup(SimCore<V,E> sim)
Performs initialization of a new instance. Initialization includes, for example, validating input data (received as environment parameters), preparing internal data structures, opening or creating output files, and preparing statistics collectors.

Classes that implement this interface are expected to define a list of environment parameters. The actual values for these parameters are obtained from the simulator, however. That is, the environment object is shared among all modules of a specific simulation run.

Note that a module may choose to copy the value of an environment parameter into a field, so that future uses of that parameter does not involve consulting the environment object. This means that, in such a case, further changes to the values in the environment will not affect the behaviour of the processing module after setup. Conversely, another module might just access the environment object every time the value of a parameter is needed. Each class should clearly state which approach it takes.


run

void run(SimEvents evtype,
         ConnectionInfo<V,E> rq)
Process an event, whose type evtype. Extra information is in rq.

Note that there is no restriction about what a module can do during a call to run. For example, it can remove a connection from the TED object, mark links as failed, etc. If a the event is a connection request that was successfully established, and for some reason it needs to be removed (make it a rejected connection), the connection must be removed from the TED and working path in the rq object must be set to null so that the remaning modules can see the connection as "rejected".

If early termination is needed, a module can throw LimitReachedException, which will prevent the activation of any additional module. However, enqueued calls will still be called, unless the maxtime field of the "option" object is also set to the current time (or, better yet, to a time already passed). The way to programatically provoke an early termination is then,

    ...
    opt().maxtime = sim().getTime()-1;
    throw new LimitReachedException("Early termination at " +
                                                sim.getTime());
 


shutdown

void shutdown()
Called by the simulator when simulation has finished. This method is typically used to print final statistics and release resources (flush/close files for example).


getId

java.lang.String getId()
Deprecated. Use the method getName of WithEnvParams instead.

A (unique) ID. This can be used for locating an instance in a modules registry, for example.


sim

SimCore<V,E> sim()
Returns the core simulator object to which this module is associated.