Académique Documents
Professionnel Documents
Culture Documents
akka Grundlagen
Florian Schuhmann
Florian Schuhmann
akka Grundlagen
Agenda
Florian Schuhmann
akka Grundlagen
Grundlagen
Florian Schuhmann
akka Grundlagen
Grundlagen
Scala + Java API Nutzung
Stand-Alone [Mikrokernel] Erweiterungsbibliothek
http://www.akkasource.org sehr gute Scala Dokumentation Java Dokumentation wird nachgezogen Scala IDE for Eclipse oder per SBT
Florian Schuhmann
akka Grundlagen
Leitbild
Jonas Bonr e Writing correct concurrent, fault-tolerant and scalable applications is too hard. Most of the time its because we are using the wrong tools and the wrong level of abstraction. Akka is an attempt to change that. [1]
Florian Schuhmann
akka Grundlagen
Leitbild
Ziel:
Abstraktionslevel erhhen o Werkzeug zur leichteren Implementierung von nebenlugen, a fehlertoleranten und skalierbaren Applikationen bereitstellen
Lsung: o
akka == einzigartige Mischung von folgenden Techniken
Florian Schuhmann
akka Grundlagen
Methodiken
Actors Software Transactional Memory (STM) Transactors Let it crash Supervisor Hierarchies Remote Actors
Florian Schuhmann
akka Grundlagen
Florian Schuhmann
akka Grundlagen
aktueller Stand
Akka 1.0-RC1 wurde am 26. November, 19:13 released Fixes/ Improvements
Umbenennung des packages in akka. anstelle von se.scalablesolutions. Update zu Scala 2.8.1 Split in akka Core + akka Module komplett neue Transactor Implementation neue Features fr Remote actors (per-session/ secure cookie u handshake) ...
Florian Schuhmann
akka Grundlagen
Florian Schuhmann
akka Grundlagen
Actors
one tool in the toolbox
Florian Schuhmann
akka Grundlagen
Florian Schuhmann
akka Grundlagen
Actor-Modell
mathematisches Modell fr nebenluge Berechnungen u a everything is an object everything is an actor Actors sind von Natur aus nebenlug a Kommunikation ndet asynchron und nur uber Nachrichten statt Identizierung uber Adressen
Florian Schuhmann
akka Grundlagen
Actor-Modell
Ein Actor kann als Reaktion auf eine empfangene Nachricht (parallel) eine endliche Anzahl von Nachrichten an andere Actors senden eine endliche Anzahl neuer Actors erstellen fr die nchste Nachricht ein bestimmtes Verhalten festlegen u a den Zustand eines anderen Actors nur uber das Versenden von Nachrichten beeinussen. Der Empfnger nimmt die a Anderung aber selbst vor.
Florian Schuhmann
akka Grundlagen
akka Actors
parallele Entwicklung zu Scala actors ieen jetzt in Scala ein stark an Erlang[1] gehaltener Schreibstil expliziter message handler vorhanden
Florian Schuhmann
akka Grundlagen
akka Actors
thread-based event-based [2] Performance event-based create 6.5 million Actors on 4 G RAM 600 bytes pro actor [2]
Florian Schuhmann
akka Grundlagen
class MyActor extends Actor { def receive = { case "test" => println("received test") case _ => println("received unknown message") } } val myActor = new MyActor myActor.start // send something myActor ! "test"
Florian Schuhmann
akka Grundlagen
akka Actors
Sendearten
re-and-forget myActor !"test" Send-And-Receive-Eventually val resultOption = actor !!("Hello", 1000) Send-And-Receive-Future val future = actor !!!"Hello"
Florian Schuhmann
akka Grundlagen
Grundgedanke Transactors
Florian Schuhmann
akka Grundlagen
Grundgedanke Transactors
Grundgedanke
Kontrollmechanismus fr gemeinsam genutzen Speicher u implementiert ACID-Konzept A Atomaritt a C Konsistenz I Isolation D Dauerhaftigkeit
Florian Schuhmann
akka Grundlagen
Grundgedanke Transactors
Grundgedanke
STM-Implementation
basiert auf den selben Ideen wie Clojure (www.clojure.org) Managed References + unvernderliche Variablen (val) a
Florian Schuhmann
akka Grundlagen
Grundgedanke Transactors
Transactors
Transactional Actors STM + Actors = Transactors Kombination aus besten Eigenschaften der Actor + STM
parallele, asynchrone event-basierte Programmierung Transaktionen
Florian Schuhmann
akka Grundlagen
Fault-Tolerance
Florian Schuhmann
akka Grundlagen
Grundlagen
Let it crashMentalitt a look at errors as something natural and something that will happen and instead of trying to prevent it; embrace it [2] Erlang/ Telekommunikation Exceptions im Actor werfen ist nicht hilfreich
kann nicht herausnden ob etwas passiert ist (ausser im stack trace) kann nichts dagegen tun Actor Thread blht sich auf a
Florian Schuhmann
akka Grundlagen
Grundlagen
Restart-Strategien
OneForOne AllForOne
Florian Schuhmann
akka Grundlagen
OneForOne
initial
Florian Schuhmann
akka Grundlagen
OneForOne
one crashed
Florian Schuhmann
akka Grundlagen
OneForOne
one is restarted
Florian Schuhmann
akka Grundlagen
OneForOne
Florian Schuhmann
akka Grundlagen
AllForOne
initial
Florian Schuhmann
akka Grundlagen
AllForOne
one crashed
Florian Schuhmann
akka Grundlagen
AllForOne
Florian Schuhmann
akka Grundlagen
AllForOne
Florian Schuhmann
akka Grundlagen
Supervision Hierarchies
initial
Florian Schuhmann akka Grundlagen
Supervision Hierarchies
one crashed
Florian Schuhmann akka Grundlagen
Supervision Hierarchies
Supervision Hierarchies
Fazit Anhang
Fazit
Florian Schuhmann
akka Grundlagen
Fazit Anhang
Fazit
gute und viele Ideen im Framework 2 APIs leicht handhabbar + verstndlich a sehr exibel (Module, Nutzung) Untersttzung von weiteren Features durch Add-on Module u (Spring Integration/ OSGi) aktive Entwicklung und Updates
Florian Schuhmann
akka Grundlagen
Fazit Anhang
Danke!
Florian Schuhmann
akka Grundlagen
Fazit Anhang
Erlang Bsp.
-module(ping_pong). -export([ping/0, pong/0]). ping() -> Pong = spawn(ping_pong, pong, []), Pong ! {self(), ping}, receive pong -> pong end. pong() -> receive {Ping, ping} -> Ping ! pong end.
Florian Schuhmann
akka Grundlagen
Fazit Anhang
Benchmark Dispatcher
2
Florian Schuhmann akka Grundlagen
Fazit Anhang
Quellen
Jonas Bonr, Introducing Akka. http://www.jonasboner.com, e 4. Jan 2010. akkasource.org, akka Homepage. http://www.akkasource.org Jonas Bonr, akka Google Group. akka User List e Jonas Bonr, akka Github. akka Github e Lothar Piepmeyer, Grundkursfunktionale Programmierung mit Scala. Carl Hanser Verlag Mnchen Wien, 2010. u Christos K. K. Loverdos and Apostolos Syropoulos, Steps in Scala: An Introduction to Object-Functional Programming . Cambridge University Press, 2010.
Florian Schuhmann akka Grundlagen