TaskInstance

class TaskInstance(val id: UUID, val name: String, val simulation: String, val created: Long, val minStartTime: Long, val resources: Seq[String], val duration: Long, val estimatedDuration: Long, val cost: Double, val interrupt: Int, val priority: Int) extends Ordered[TaskInstance]

An instance of a task to be performed in virtual time.

Value Params
created

The timestamp when this task was created.

duration

The actual duration of the task.

estimatedDuration

The estimated duration of the task.

id

A unique id that separates this task from any other task. A workflow may spawn multiple tasks with the same name, so this is necessary.

initialCost

A one-off cost of performing this task.

interrupt

The number of times the task can be interrupted in favour of a more urgent one. This parameter is not currently being used.

minStartTime

The earliest possible starting time of this task.

name

A descriptive name.

priority

The explicit priority of the task.

resources

The names of the TaskResources required by this task.

simulation

A unique name of the simulation this task belongs to.

Note

We expect that task instances are only generated through a Task. The samples of the parameters are generated by the Coordinator. The duration can be specified through random sampling in a Distribution. We store the estimated value as well as the actual sampled value.

trait Ordered[TaskInstance]
trait Comparable[TaskInstance]
class Object
trait Matchable
class Any

Value members

Concrete methods

def compare(that: TaskInstance): Int

Ordering of tasks.

Ordering of tasks.

This method essentially dictates the priority of tasks in the queue, highest to lowest.

Uses the following criteria, in order:

  1. '''Priority''': Putting this parameter first makes it a very strong influencer of priority. A task with higher explicit priority will always be executed before any other task with lower priority, even if, for example, the latter has been queueing for a long time.
  2. '''Age''': Tasks who were created earlier take priority, in an attempt to minimize waiting times.
  3. '''Resources''': Tasks that involve a higher number of resources take priority. The intuition is that it is generally harder to achieve a state where more resources are available at the same time, so we do not want to postpone the task.
  4. '''Estimated duration''': Tasks that require more time are prioritized.
  5. '''Interrupt''': Inflexible tasks that can not be interrupted are prioritized.
  6. Tasks are considered of equal priority at this point, so we use their id as a deterministic ordering.
Value Params
that

The task instance to compare to.

Returns

A comparative measure (lower means higher priority).

Note

You can change this order by subclassing TaskInstance and creating a corresponding subclass of Task.

def nextPossibleStart(currentTime: Long, resourceMap: Map[String, TaskResource]): Long

Finds the soonest this task can start. This is based on the availability of the required resources. We calculate the minimum possible time when we expect all resources will be free. We use TaskResource.nextAvailableTimestamp as the (estimated) next available time of each resource.

Finds the soonest this task can start. This is based on the availability of the required resources. We calculate the minimum possible time when we expect all resources will be free. We use TaskResource.nextAvailableTimestamp as the (estimated) next available time of each resource.

Value Params
currentTime

The current timestamp.

resourceMap

A map of all available TaskResources

Returns

The (estimated) earliest timestamp when all resources are available.

def taskResources(resourceMap: Map[String, TaskResource]): Seq[TaskResource]

The actual TaskResources required. Retrieves the actual objects (instead of just their names) from a map.

The actual TaskResources required. Retrieves the actual objects (instead of just their names) from a map.

Value Params
resourceMap

The map of available TaskResources

Returns

The TaskResources required for this task.

override
def toString: String
Definition Classes
Any

Inherited methods

def <(that: TaskInstance): Boolean
Inherited from
Ordered
def <=(that: TaskInstance): Boolean
Inherited from
Ordered
def >(that: TaskInstance): Boolean
Inherited from
Ordered
def >=(that: TaskInstance): Boolean
Inherited from
Ordered
def compareTo(that: TaskInstance): Int
Inherited from
Ordered

Concrete fields

val cost: Double
val created: Long
val duration: Long
val id: UUID
val interrupt: Int
val minStartTime: Long
val name: String
val priority: Int
val resources: Seq[String]
val simulation: String