Package

pt.tecnico.dsi

akkastrator

Permalink

package akkastrator

Visibility
  1. Public
  2. All

Type Members

  1. abstract class Orchestrator extends PersistentActor with AtLeastOnceDelivery with ActorLogging

    Permalink

    An Orchestrator executes a set of, possibly dependent, Tasks.

    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:

    • Handling the persistence of the internal state maintained by both the Orchestrator and the Tasks.
    • Delivering messages with at-least-once delivery guarantee.
    • 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.
    • Tasks that have no dependencies will be started right away and the Orchestrator will, from that point onwards, be prepared to handle the responses to the sent messages.
    • If the Orchestrator crashes, the state it maintains 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 inside an orchestrator.

    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 like so:

    trait DatabaseTasks { self: Orchestrator =>
      def createQueryTask(): Task = new Task("") {
        val destination: ActorPath = ???
        def createMessage(correlationId: CorrelationId): Any = ???
    
        def behavior: Receive = ???
      }
    }
  2. class Settings extends AnyRef

    Permalink

    This class holds all the settings that parameterize akkastrator.

    This class holds all the settings that parameterize akkastrator.

    By default these settings are read from the Config obtained with ConfigFactory.load().

    You can change the settings in multiple ways:

    • Change them in the default configuration file (e.g. application.conf)
    • Pass a different config holding your configurations:
    new Settings(yourConfig)

    However it will be more succinct to pass your config directly to your akkastrator:

    context.actorOf(Props(classOf[YourAkkastrator], yourConfig))
    • Extend this class overriding the settings you want to redefine
    object YourSettings extends Settings() {
      override val saveSnapshotEveryXMessages = 1000
    }
    context.actorOf(Props(classOf[YourAkkastrator], YourSettings))
  3. case class StatusResponse(tasks: Seq[TaskStatus]) extends Product with Serializable

    Permalink
  4. abstract class Task extends AnyRef

    Permalink

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

    A task corresponds to sending a message to an actor, handling its response and possibly mutate the internal state of the Orchestrator. The answer(s) to the sent message must be handled in behavior. behavior must invoke finish when no further processing is necessary. The pattern matching inside behavior should invoke matchSenderAndID to ensure the received message is in fact the one that we were waiting to receive. The internal state of the orchestrator might be mutated inside behavior.

    This class is very tightly coupled with Orchestrator and the reverse is also true. Because of this you can only create instances of Task inside an orchestrator.

  5. case class TaskStatus(index: Int, description: String, status: Status, dependencies: Set[Int]) extends Product with Serializable

    Permalink

Value Members

  1. object Orchestrator

    Permalink
  2. object Status extends Product with Serializable

    Permalink
  3. object Task

    Permalink

Ungrouped