c

pt.tecnico.dsi.akkastrator

AbstractOrchestrator

sealed abstract class AbstractOrchestrator[R] extends PersistentActor with AtLeastOnceDelivery with ActorLogging with IdImplicits

An Orchestrator executes a set of, possibly dependent, Tasks. A task corresponds to sending a message to an actor, handling its response and possibly mutate the internal state of the Orchestrator.

The Orchestrator together with the Task is able to:

  • Delivering messages with at-least-once delivery guarantee. The DistinctIdsOrchestrator ensures each destination will see an independent strictly monotonically increasing sequence number without gaps.
  • Handling Status messages, that is, if some actor is interested in querying the Orchestrator for its current status, the Orchestrator will respond with the status of each task.
  • When all the dependencies of a task finish that task will be started and the Orchestrator will be prepared to handle the messages that the task destination sends.
  • If the Orchestrator crashes, the state of each task will be correctly restored.

NOTE: the responses that are received must be Serializable.

In order for the Orchestrator and the Tasks to be able to achieve all of this they have to access and modify each others state directly. This means they are very tightly coupled with each other. To make this relation more obvious and to enforce it, you will only be able to create tasks if you have a reference to an orchestrator (which is passed implicitly to a task).

If you have the need to refactor the creation of tasks so that you can use them in multiple orchestrators you can leverage self type annotations.

R

the type of result this orchestrator returns when it finishes.

Source
Orchestrator.scala
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AbstractOrchestrator
  2. IdImplicits
  3. ActorLogging
  4. AtLeastOnceDelivery
  5. AtLeastOnceDeliveryLike
  6. PersistentActor
  7. Eventsourced
  8. PersistenceRecovery
  9. PersistenceIdentity
  10. PersistenceStash
  11. StashFactory
  12. Stash
  13. RequiresMessageQueue
  14. UnrestrictedStash
  15. StashSupport
  16. Snapshotter
  17. Actor
  18. AnyRef
  19. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract type ID <: Id

    The type of Id this orchestrator handles.

  2. type Receive = PartialFunction[Any, Unit]
    Definition Classes
    Actor

Abstract Value Members

  1. abstract def computeID(destination: ActorPath, deliveryId: DeliveryId): ID

    Computes ID from the deliveryId of akka-persistence.

  2. abstract def deliveryIdOf(destination: ActorPath, id: ID): DeliveryId

    Converts ID to the deliveryId needed for the confirmDelivery method of akka-persistence.

  3. abstract def matchId(task: Task[_], id: Long): Boolean

    Ensures the received message was in fact destined to be received by task.

  4. abstract def persistenceId: String
    Definition Classes
    PersistenceIdentity

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from AbstractOrchestrator[R] to any2stringadd[AbstractOrchestrator[R]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (AbstractOrchestrator[R], B)
    Implicit
    This member is added by an implicit conversion from AbstractOrchestrator[R] to ArrowAssoc[AbstractOrchestrator[R]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final var _waitingTasks: HashMap[Int, Task[_]]

    We use a HashMap to ensure remove/insert operations are very fast O(eC).

    We use a HashMap to ensure remove/insert operations are very fast O(eC). The keys are the task indexes.

    Attributes
    protected[this]
  7. final def alwaysAvailableCommands: akka.actor.Actor.Receive
  8. def aroundPostRestart(reason: Throwable): Unit
    Attributes
    protected[akka]
    Definition Classes
    Eventsourced → Actor
  9. def aroundPostStop(): Unit
    Attributes
    protected[akka]
    Definition Classes
    AtLeastOnceDeliveryLike → Eventsourced → Actor
  10. def aroundPreRestart(reason: Throwable, message: Option[Any]): Unit
    Attributes
    protected[akka]
    Definition Classes
    AtLeastOnceDeliveryLike → Eventsourced → Actor
  11. def aroundPreStart(): Unit
    Attributes
    protected[akka]
    Definition Classes
    Eventsourced → Actor
  12. def aroundReceive(receive: Receive, message: Any): Unit
    Attributes
    protected[akka]
    Definition Classes
    AtLeastOnceDeliveryLike → Eventsourced → Actor
  13. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  14. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  15. final def computeCurrentBehavior(): Receive
  16. def confirmDelivery(deliveryId: Long): Boolean
    Definition Classes
    AtLeastOnceDeliveryLike
  17. implicit val context: ActorContext
    Definition Classes
    Actor
  18. def defer[A](event: A)(handler: (A) ⇒ Unit): Unit
    Definition Classes
    PersistentActor
  19. def deferAsync[A](event: A)(handler: (A) ⇒ Unit): Unit
    Definition Classes
    PersistentActor
  20. def deleteMessages(toSequenceNr: Long): Unit
    Definition Classes
    Eventsourced
  21. def deleteSnapshot(sequenceNr: Long): Unit
    Definition Classes
    Snapshotter
  22. def deleteSnapshots(criteria: SnapshotSelectionCriteria): Unit
    Definition Classes
    Snapshotter
  23. def deliver(destination: ActorSelection)(deliveryIdToMessage: (Long) ⇒ Any): Unit
    Definition Classes
    AtLeastOnceDelivery
  24. def deliver(destination: ActorPath)(deliveryIdToMessage: (Long) ⇒ Any): Unit
    Definition Classes
    AtLeastOnceDelivery
  25. def ensuring(cond: (AbstractOrchestrator[R]) ⇒ Boolean, msg: ⇒ Any): AbstractOrchestrator[R]
    Implicit
    This member is added by an implicit conversion from AbstractOrchestrator[R] to Ensuring[AbstractOrchestrator[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  26. def ensuring(cond: (AbstractOrchestrator[R]) ⇒ Boolean): AbstractOrchestrator[R]
    Implicit
    This member is added by an implicit conversion from AbstractOrchestrator[R] to Ensuring[AbstractOrchestrator[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  27. def ensuring(cond: Boolean, msg: ⇒ Any): AbstractOrchestrator[R]
    Implicit
    This member is added by an implicit conversion from AbstractOrchestrator[R] to Ensuring[AbstractOrchestrator[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  28. def ensuring(cond: Boolean): AbstractOrchestrator[R]
    Implicit
    This member is added by an implicit conversion from AbstractOrchestrator[R] to Ensuring[AbstractOrchestrator[R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  29. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  30. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  31. def extraCommands: akka.actor.Actor.Receive

    Override this method to add extra commands that are always handled by this orchestrator (except when recovering).

  32. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  33. final def finishedTasks: Int

    How many tasks of this orchestrator have successfully finished.

    How many tasks of this orchestrator have successfully finished. Aborted tasks do not count as a finished task.

  34. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from AbstractOrchestrator[R] to StringFormat[AbstractOrchestrator[R]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  35. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  36. def getDeliverySnapshot: AtLeastOnceDeliverySnapshot
    Definition Classes
    AtLeastOnceDeliveryLike
  37. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  38. def internalStashOverflowStrategy: StashOverflowStrategy
    Definition Classes
    PersistenceStash
  39. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  40. def journalPluginId: String
    Definition Classes
    PersistenceIdentity
  41. def lastSequenceNr: Long
    Definition Classes
    Eventsourced
  42. def loadSnapshot(persistenceId: String, criteria: SnapshotSelectionCriteria, toSequenceNr: Long): Unit
    Definition Classes
    Snapshotter
  43. def log: LoggingAdapter
    Definition Classes
    ActorLogging
  44. def maxUnconfirmedMessages: Int
    Definition Classes
    AtLeastOnceDeliveryLike
  45. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  46. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  47. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  48. def numberOfUnconfirmed: Int
    Definition Classes
    AtLeastOnceDeliveryLike
  49. def onAbort(failure: Failure): Unit

    User overridable callback.

    User overridable callback. Its called when the orchestrator is aborted. By default an orchestrator aborts as soon as a task aborts. However this functionality can be changed by overriding onTaskAbort.

    By default logs that the orchestrator has aborted, sends a message to its parent explaining why the orchestrator aborted then stops it.

    You can use this to implement your termination strategy.

  50. def onFinish(): Unit

    User overridable callback.

    User overridable callback. Its called after every task finishes. If a task aborts then it will prevent this method from being invoked.

    By default logs that the Orchestrator has finished then stops it.

    You can use this to implement your termination strategy.

    If a orchestrator starts without tasks it will finish right away.

  51. def onPersistFailure(cause: Throwable, event: Any, seqNr: Long): Unit
    Attributes
    protected
    Definition Classes
    Eventsourced
  52. def onPersistRejected(cause: Throwable, event: Any, seqNr: Long): Unit
    Attributes
    protected
    Definition Classes
    Eventsourced
  53. def onRecoveryFailure(cause: Throwable, event: Option[Any]): Unit
    Attributes
    protected
    Definition Classes
    Eventsourced
  54. def onStart(startId: Long): Unit

    User overridable callback.

    User overridable callback. Its called after the orchestrator starts but before any of the tasks start.

    By default logs that the Orchestrator has started.

  55. def onTaskAbort(task: FullTask[_, _], cause: Throwable): Unit

    User overridable callback.

    User overridable callback. Its called every time a task aborts.

    You can use this to implement very refined termination strategies.

    By default aborts the orchestrator via onAbort with a TaskAborted failure.

    Note: if you invoke become/unbecome inside this method, the contract that states "Waiting tasks or tasks which do not have this task as a dependency will remain untouched" will no longer be guaranteed. If you wish to still have this guarantee you can do

    context.become(computeCurrentBehavior() orElse yourBehavior)

    { @see onTaskStart} for a callback when a task starts. { @see onTaskFinish } for a callback when a task finishes.

    task

    the task that aborted.

  56. def onTaskFinish(task: FullTask[_, _]): Unit

    User overridable callback.

    User overridable callback. Its called every time a task finishes.

    You can use this to implement very refined termination strategies.

    By default just logs the task has finished.

    { @see onTaskStart} for a callback when a task starts. { @see onTaskAbort} for a callback when a task aborts.

  57. def onTaskStart(task: FullTask[_, _], innerTask: Task[_]): Unit

    User overridable callback.

    User overridable callback. Its called every time a task starts.

    By default just logs the task as started.

    { @see onTaskFinish} for a callback when a task finishes. { @see onTaskAbort} for a callback when a task aborts.

  58. implicit final val orchestrator: AbstractOrchestrator[_]

    This exists to make the creation of FullTasks easier.

  59. def persist[A](event: A)(handler: (A) ⇒ Unit): Unit
    Definition Classes
    PersistentActor
  60. def persistAll[A](events: Seq[A])(handler: (A) ⇒ Unit): Unit
    Definition Classes
    PersistentActor
  61. def persistAllAsync[A](events: Seq[A])(handler: (A) ⇒ Unit): Unit
    Definition Classes
    PersistentActor
  62. def persistAsync[A](event: A)(handler: (A) ⇒ Unit): Unit
    Definition Classes
    PersistentActor
  63. def postRestart(reason: Throwable): Unit
    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  64. def postStop(): Unit
    Definition Classes
    UnrestrictedStash → Actor
  65. def preRestart(reason: Throwable, message: Option[Any]): Unit
    Definition Classes
    UnrestrictedStash → Actor
  66. def preStart(): Unit
    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  67. def receive: Receive
    Definition Classes
    PersistentActor → Actor
  68. final def receiveCommand: akka.actor.Actor.Receive
    Definition Classes
    AbstractOrchestrator → Eventsourced
  69. def receiveRecover: akka.actor.Actor.Receive
    Definition Classes
    AbstractOrchestrator → Eventsourced
  70. def recovery: Recovery
    Definition Classes
    PersistenceRecovery
  71. final def recoveryAwarePersist(event: Any)(handler: ⇒ Unit): Unit
  72. def recoveryFinished: Boolean
    Definition Classes
    Eventsourced
  73. def recoveryRunning: Boolean
    Definition Classes
    Eventsourced
  74. def redeliverInterval: FiniteDuration
    Definition Classes
    AtLeastOnceDeliveryLike
  75. def redeliveryBurstLimit: Int
    Definition Classes
    AtLeastOnceDeliveryLike
  76. def saveSnapshot(snapshot: Any): Unit
    Definition Classes
    Snapshotter
  77. implicit final val self: ActorRef
    Definition Classes
    Actor
  78. final def sender(): ActorRef
    Definition Classes
    Actor
  79. def setDeliverySnapshot(snapshot: AtLeastOnceDeliverySnapshot): Unit
    Definition Classes
    AtLeastOnceDeliveryLike
  80. val settings: Settings
  81. def snapshotPluginId: String
    Definition Classes
    PersistenceIdentity
  82. def snapshotSequenceNr: Long
    Definition Classes
    Eventsourced → Snapshotter
  83. def snapshotterId: String
    Definition Classes
    Eventsourced → Snapshotter
  84. final def startId: Long
  85. def stash(): Unit
    Definition Classes
    Eventsourced → StashSupport
  86. def supervisorStrategy: SupervisorStrategy
    Definition Classes
    Actor
  87. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  88. final def tasks: Seq[FullTask[_, _]]
  89. implicit def toCorrelationId(l: Long): CorrelationId
    Definition Classes
    IdImplicits
  90. implicit def toDeliveryId(l: Long): DeliveryId
    Definition Classes
    IdImplicits
  91. def toString(): String
    Definition Classes
    AnyRef → Any
  92. def unhandled(message: Any): Unit
    Definition Classes
    Eventsourced → Actor
  93. final def unstarted: akka.actor.Actor.Receive
  94. def unstashAll(): Unit
    Definition Classes
    Eventsourced → StashSupport
  95. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  96. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  97. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  98. final def waitingTasks: HashMap[Int, Task[_]]
  99. def warnAfterNumberOfUnconfirmedAttempts: Int
    Definition Classes
    AtLeastOnceDeliveryLike
  100. def withLogPrefix(message: ⇒ String): String
  101. def [B](y: B): (AbstractOrchestrator[R], B)
    Implicit
    This member is added by an implicit conversion from AbstractOrchestrator[R] to ArrowAssoc[AbstractOrchestrator[R]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from IdImplicits

Inherited from ActorLogging

Inherited from AtLeastOnceDelivery

Inherited from AtLeastOnceDeliveryLike

Inherited from PersistentActor

Inherited from Eventsourced

Inherited from PersistenceRecovery

Inherited from PersistenceIdentity

Inherited from PersistenceStash

Inherited from StashFactory

Inherited from Stash

Inherited from UnrestrictedStash

Inherited from StashSupport

Inherited from Snapshotter

Inherited from Actor

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from AbstractOrchestrator[R] to any2stringadd[AbstractOrchestrator[R]]

Inherited by implicit conversion StringFormat from AbstractOrchestrator[R] to StringFormat[AbstractOrchestrator[R]]

Inherited by implicit conversion Ensuring from AbstractOrchestrator[R] to Ensuring[AbstractOrchestrator[R]]

Inherited by implicit conversion ArrowAssoc from AbstractOrchestrator[R] to ArrowAssoc[AbstractOrchestrator[R]]

Ungrouped