FlowSimulation

class FlowSimulation(val name: String, val manager: Manager, val flow: Flow) extends AsyncSimulation

A simulation of a Flow.

It uses a Flow structure which describes how and in what order certain tasks should be executed. A Flow may consist of a single FlowTask or some combination of FlowTasks which are joined using Ands, Thens, and Ors.

Value Params
flow

The flow which describes how the simulation behaves

manager

The simulation manager for this simualation.

name

The name of the simulation being managed.

class Object
trait Matchable
class Any

Document{}

type Callback = Try[(TaskInstance, Long)] => Unit

The type of the callback function.

The type of the callback function.

Its input consists of the generated TaskInstance and the timestamp when it was completed. A Failure input corresponds to an exception happening or an aborted task.

Inherited from
AsyncSimulation
override
def abort(ids: UUID*): Unit

Declare IDs of TaskInstances that need to be aborted.

Declare IDs of TaskInstances that need to be aborted.

Calls respective Callbacks with Failure.

Value Params
id

The UUID of the Tasks.

Definition Classes
Inherited from
AsyncSimulation
def ack(taskIDs: Seq[UUID]): Unit

Declares that the simulation has finished processing one or more completed TaskInstances.

Declares that the simulation has finished processing one or more completed TaskInstances.

Identifies the tasks via their UUID.

Inherited from
Simulation
override
def complete(task: TaskInstance, time: Long): Unit

Manages a completed TaskInstance.

Manages a completed TaskInstance.

The simulation logic must react to this by either registering more tasks or finishing.

If new tasks are produced, the completed TaskInstance must be acknowledged via ack. Alternatively, if we do not want to ack all completed tasks, we can just call ready. Finally, if the simulation completes, we can use done, succeed or fail accordingly.

Calls the corresponding Callback in the tasks map and then removes the entry.

Value Params
task

The TaskInstance that completed.

time

The timestamp of its completion.

Definition Classes
Inherited from
AsyncSimulation
def done(result: Try[Any]): Unit

Declares that the simulation completed.

Declares that the simulation completed.

Value Params
result

The result of the simulation.

Inherited from
Simulation
def fail(exception: Throwable): Unit

Declares that the simulation has failed or has been aborted.

Declares that the simulation has failed or has been aborted.

Value Params
exception

The Throwable that caused the failure.

Inherited from
Simulation

Calculates an optional Lookahead structure for tasks that are expected in the future.

Calculates an optional Lookahead structure for tasks that are expected in the future.

This is called via ready.

Returns

The current Lookahead structure.

Inherited from
Simulation
def ready(): Unit

Declares that the simulation has finished calculating and is ready for virtual time to proceed.

Declares that the simulation has finished calculating and is ready for virtual time to proceed.

Inherited from
Simulation
def simWait(): Unit

Requests that the Manager waits for this simulation before it continues.

Requests that the Manager waits for this simulation before it continues.

The simulation needs to either register more tasks and become ready or finish.

Note

We assume the Manager is already waiting for another simulation when the request is made. Otherwise virtual time may progress unexpectedly and cause unpredictable behaviour depending on the timing of the Manager messages.

Inherited from
Simulation
def succeed(result: Any): Unit

Declares that the simulation completed successfully.

Declares that the simulation completed successfully.

Value Params
result

The successful result of the simulation.

Inherited from
Simulation
def task(t: Task, callback: Callback): Unit

Declare a new Task that needs to be sent to the Coordinator for simulation with a pre-determined ID.

Declare a new Task that needs to be sent to the Coordinator for simulation with a pre-determined ID.

The provided callback function will be called when the corresponding Task is completed.

When it finishes executing, it must notify the Coordinator either by acknowledging the completed task using ack or by completing the simulation using done, succeed or fail.

The ready method can also be called if there is no need to acknowledge completed tasks individually. This is unlikely in the current scenario where each task has its own callback, but it's still worth mentioning.

Value Params
callback

The Callback function to be called when the corresponding Task completes.

t

The Task to send.

Inherited from
AsyncSimulation
def task(t: Task): Unit

Declare a new Task that needs to be sent for simulation.

Declare a new Task that needs to be sent for simulation.

Value Params
t

The Task to send.

Inherited from
Simulation
protected
val tasks: Map[UUID, Callback]

A map of TaskInstance IDs that have been sent to the Manager and the callback functions that need to be called when the tasks complete.

A map of TaskInstance IDs that have been sent to the Manager and the callback functions that need to be called when the tasks complete.

Inherited from
AsyncSimulation

Value members

Concrete methods

override
def run(): Unit

Initiates the execution of the simulation.

Initiates the execution of the simulation.

Definition Classes

Inherited methods

def callback(f: (TaskInstance, Long) => Unit): Callback

Creates a simple success callback from a function.

Creates a simple success callback from a function.

Does nothing on failure.

Value Params
f

The function to call on success.

Returns

The created Callback.

Inherited from
AsyncSimulation
override
def completed(time: Long, tasks: Seq[TaskInstance]): Unit
Definition Classes
Inherited from
Simulation
override
def stop(): Unit

Stops/aborts the simuation.

Stops/aborts the simuation.

Triggers all callbacks with a Failure.

Definition Classes
Inherited from
AsyncSimulation

Concrete fields

override
val name: String