Distributed System Development with ScalaLoci

Pascal Weisenburger, Mirko Köhler, Guido Salvaneschi

TU Darmstadt, Germany

Multitier Languages

ScalaLoci

  • Generic Distributed Architectures
    • Placement Types
  • Multitier Event Streams

Placement Types


          trait Registry extends Peer
          trait Node extends Peer
          
Peers

          val message: Event[String] on Registry
            = placed { getMessageStream() }
          
Placement Types

Architecture


          trait Registry extends Peer { type Tie <: Multiple[Node] }
          trait Node extends Peer { type Tie <: Single[Registry] with Multiple[Node] }
          
Architecture Specification through Peer Types
Architecture-Based Remote Access

Remote Access


          trait Registry extends Peer { type Tie <: Single[Node] }
          trait Node extends Peer { type Tie <: Single[Registry] }

          val message: Event[String] on Node

          placed[Registry] {
            message.asLocal: Event[String]
          }
          

Aggregation


          trait Registry extends Peer { type Tie <: Multiple[Node] }
          trait Node extends Peer { type Tie <: Single[Registry] }

          val message: Event[String] on Node

          placed[Registry] {
            message.asLocalFromAll: Map[Remote[Node], Event[String]]
          }
          

Communication

Data Flow


          val message = Event[String]()
          val result = message map processMessage
          val ui = new UI(result)
          

Distributed Data Flow


          val message: Event[String] on Node = placed[Node] { Event[String]() }
          val result = placed[Registry] { message.asLocal map processMessage }
          val ui = placed[Node] { new UI(result.asLocal) }
          

Complete Distributed Chat


          @multitier object Chat {
            trait Registry extends Peer { type Tie <: Multiple[Node] }
            trait Node extends Peer { type Tie <: Single[Registry] }

            val message = placed[Node] { Event[String]() }

            val publicMessage = placed[Registry] {
              message.asLocalFromAllSeq map { case (_, msg) => msg }
            }

            placed[Node].main {
              publicMessage.asLocal observe println
              for (line <- io.Source.stdin.getLines)
                message.fire(line)
            }
          }
          

Evaluation

Two existing systems

Case studies: 22 variants

Porting to Distribution

  1. Local
  2. ScalaLoci
  3. Akka
  4. RMI
  • multi-user support
  • distribution

Gearpump Real-Time Streaming Engine

components with placement types
no need to manually maintain architecture

          trait MasterProxy extends Peer { type Tie <: Multiple[Master] with Multiple[Worker] }
          trait Worker extends Peer { type Tie <: Single[MasterProxy] with Optional[Master] }
          trait Master extends Peer { type Tie <: Multiple[MasterProxy] with Multiple[Worker] }
          
  • Fault Tolerance
  • Dynamic Topologies
  • Design Metrics
  • Microbenchmarks
  • Multiple Backends
  • Formalization

scala-loci.github.io

Conclusion

  • Generic Distributed Architectures
    • Placement Types
      Value on Peer
  • Multitier Event Streams