Permalink
Browse files

copied akka workshop into scala labs for convenience

  • Loading branch information...
RayRoestenburg committed Jun 17, 2011
1 parent 8a8c169 commit b893cb6bf814f7b58eeba16e089aefa6760393a8
Showing with 2,649 additions and 4 deletions.
  1. +0 −3 .gitmodules
  2. +0 −1 playground/akka
  3. BIN playground/akka/Akka-workshop.pptx
  4. +14 −0 playground/akka/README.textile
  5. +3 −0 playground/akka/finish/project/.gitignore
  6. +8 −0 playground/akka/finish/project/build.properties
  7. +70 −0 playground/akka/finish/project/build/Project.scala
  8. +11 −0 playground/akka/finish/project/plugins/Plugins.scala
  9. +1 −0 playground/akka/finish/project/plugins/project/.gitignore
  10. +103 −0 playground/akka/finish/src/main/config/akka.conf
  11. +19 −0 playground/akka/finish/src/main/config/logback.xml
  12. +103 −0 playground/akka/finish/src/main/resources/akka-gui.conf
  13. BIN playground/akka/finish/src/main/resources/crossing.png
  14. +79 −0 playground/akka/finish/src/main/resources/microkernel-server.xml
  15. +23 −0 playground/akka/finish/src/main/scala/duse12/Boot.scala
  16. +71 −0 playground/akka/finish/src/main/scala/duse12/Junction.scala
  17. +28 −0 playground/akka/finish/src/main/scala/duse12/JunctionQueryModel.scala
  18. +17 −0 playground/akka/finish/src/main/scala/duse12/LANE.scala
  19. +9 −0 playground/akka/finish/src/main/scala/duse12/LightSwitch.scala
  20. +75 −0 playground/akka/finish/src/main/scala/duse12/Messages.scala
  21. +31 −0 playground/akka/finish/src/main/scala/duse12/Sensor.scala
  22. +35 −0 playground/akka/finish/src/main/scala/duse12/TrafficLight.scala
  23. +15 −0 playground/akka/finish/src/main/scala/duse12/gui/GUIUtils.scala
  24. +69 −0 playground/akka/finish/src/main/scala/duse12/gui/JunctionGUIMain.scala
  25. +292 −0 playground/akka/finish/src/main/scala/duse12/gui/Widgets.scala
  26. +6 −0 playground/akka/finish/src/main/scripts/gui
  27. +8 −0 playground/akka/finish/src/main/scripts/gui.bat
  28. +20 −0 playground/akka/finish/src/test/resources/logback-test.xml
  29. +46 −0 playground/akka/finish/src/test/scala/duse12/JunctionQueryModelSpec.scala
  30. +116 −0 playground/akka/finish/src/test/scala/duse12/JunctionSpec.scala
  31. +25 −0 playground/akka/finish/src/test/scala/duse12/MockLight.scala
  32. +47 −0 playground/akka/finish/src/test/scala/duse12/SensorSpec.scala
  33. +65 −0 playground/akka/finish/src/test/scala/duse12/TrafficLightSpec.scala
  34. +3 −0 playground/akka/start/project/.gitignore
  35. +8 −0 playground/akka/start/project/build.properties
  36. +70 −0 playground/akka/start/project/build/Project.scala
  37. +11 −0 playground/akka/start/project/plugins/Plugins.scala
  38. +1 −0 playground/akka/start/project/plugins/project/.gitignore
  39. +103 −0 playground/akka/start/src/main/config/akka.conf
  40. +19 −0 playground/akka/start/src/main/config/logback.xml
  41. +103 −0 playground/akka/start/src/main/resources/akka-gui.conf
  42. BIN playground/akka/start/src/main/resources/crossing.png
  43. +79 −0 playground/akka/start/src/main/resources/microkernel-server.xml
  44. +23 −0 playground/akka/start/src/main/scala/duse12/Boot.scala
  45. +17 −0 playground/akka/start/src/main/scala/duse12/Junction.scala
  46. +17 −0 playground/akka/start/src/main/scala/duse12/JunctionQueryModel.scala
  47. +17 −0 playground/akka/start/src/main/scala/duse12/LANE.scala
  48. +9 −0 playground/akka/start/src/main/scala/duse12/LightSwitch.scala
  49. +75 −0 playground/akka/start/src/main/scala/duse12/Messages.scala
  50. +18 −0 playground/akka/start/src/main/scala/duse12/Sensor.scala
  51. +17 −0 playground/akka/start/src/main/scala/duse12/TrafficLight.scala
  52. +15 −0 playground/akka/start/src/main/scala/duse12/gui/GUIUtils.scala
  53. +69 −0 playground/akka/start/src/main/scala/duse12/gui/JunctionGUIMain.scala
  54. +292 −0 playground/akka/start/src/main/scala/duse12/gui/Widgets.scala
  55. +6 −0 playground/akka/start/src/main/scripts/gui
  56. +8 −0 playground/akka/start/src/main/scripts/gui.bat
  57. +20 −0 playground/akka/start/src/test/resources/logback-test.xml
  58. +33 −0 playground/akka/start/src/test/scala/duse12/JunctionQueryModelSpec.scala
  59. +92 −0 playground/akka/start/src/test/scala/duse12/JunctionSpec.scala
  60. +25 −0 playground/akka/start/src/test/scala/duse12/MockLight.scala
  61. +43 −0 playground/akka/start/src/test/scala/duse12/SensorSpec.scala
  62. +47 −0 playground/akka/start/src/test/scala/duse12/TrafficLightSpec.scala
View
@@ -1,3 +0,0 @@
-[submodule "playground/akka"]
- path = playground/akka
- url = git@github.com:RayRoestenburg/duse12.git
Submodule akka deleted from c3df1e
Binary file not shown.
@@ -0,0 +1,14 @@
+h1. DUSE XII workshop
+
+Akka Workshop project for the DUSE XII meetup.
+
+The start folder contains a starting point sbt project for the workshop.
+The finish folder contains a finished solution.
+
+The sbt project is configured with idea and eclipse plugins, run sbt idea or sbt eclipse to generate an IDE project.
+
+Don't forget to first run sbt update (in the start directory). After that you can build the gui and the kernel with sbt dist-gui, deployed to target/scala../dist/bin.
+The goal of the workshop is to implement the Actors in src/main/scala/duse12 based on the instructions in the Specs in src/test/scala/duse12, when everything is green, distribute the gui and kernel, run both gui and kernel and watch the show!
+To make things simpler, you can also copy the src/test ot src/main from the finish folder, so that you only have to implement the Actors or the Specs.
+
+Important notice: When running unittests akka complains that it misses the akka.conf file. This message can be ignored.
@@ -0,0 +1,3 @@
+boot
+!build
+src_managed
@@ -0,0 +1,8 @@
+#Project properties
+#Sat May 21 09:14:33 CEST 2011
+project.organization=duse12
+project.name=junction
+sbt.version=0.7.7
+project.version=1.0
+build.scala.versions=2.9.0
+project.initialize=false
@@ -0,0 +1,70 @@
+import sbt._
+import de.element34.sbteclipsify._
+import com.github.olim7t.sbtscalariform._
+
+class JunctionProject(info: ProjectInfo) extends DefaultProject(info)
+with Eclipsify with IdeaProject with AkkaKernelProject with ScalariformPlugin {
+ override def repositories = Set("akka" at "http://akka.io/repository", "repo1" at "http://repo1.maven.org/maven2")
+
+ val akkaRemote = akkaModule("remote")
+ val akkaHttp = akkaModule("http")
+ val akkaCamel = akkaModule("camel")
+ val akkaTestKit = akkaModule("testkit")
+ lazy val logback = "ch.qos.logback" % "logback-classic" % "0.9.28" % "runtime"
+ // for ui
+ val swing = "org.scala-lang" % "scala-swing" % this.buildScalaVersion % "compile"
+
+ val scalatest = "org.scalatest" %% "scalatest" % "1.6.1.RC1" % "test->default"
+ val junit = "junit" % "junit" % "3.8.1" % "test->default"
+
+ override def formatBeforeCompiling = false
+
+ lazy val distGui = task {
+ FileUtilities.copyFile("src" / "main" / "resources" / "akka-gui.conf", distConfigPath / "akka-gui.conf", log)
+ FileUtilities.copyFile("src" / "main" / "scripts" / "gui", distBinPath / "gui", log)
+ doCMD("chmod 775 " + distBinPath / "gui")
+ FileUtilities.copyFile("src" / "main" / "scripts" / "gui.bat", distBinPath / "gui.bat", log)
+ } dependsOn (dist) describedAs ("distribute gui.")
+
+ /**
+ * run commandline
+ */
+ def doCMD(cmd: String): Option[String] = {
+ try {
+ //call directly the runtime.exec doesn't works always (depending on command)
+ //so use cmd2
+ val cmd2 = Array[String]("/bin/sh", "-c", cmd)
+ val proc = Runtime.getRuntime().exec(cmd2)
+ val exitVal = proc.waitFor();
+ if (exitVal != 0) {
+ log.error("Can't run exitcode " + exitVal + " from: " + cmd)
+ val stream = new java.io.BufferedReader(new java.io.InputStreamReader(proc.getErrorStream))
+ try {
+ var line = stream.readLine
+ while (line != null) {
+ log.error(line)
+ line = stream.readLine
+ }
+ } finally {
+ stream.close()
+ }
+ } else {
+ val streamOut = new java.io.LineNumberReader(new java.io.InputStreamReader(proc.getInputStream))
+ try {
+ var line = streamOut.readLine
+ return Some(line)
+ } finally {
+ streamOut.close()
+ }
+ }
+ } catch {
+ case t: Throwable => {
+ log.error("command failed")
+ t.printStackTrace();
+ }
+ }
+ return None
+ }
+
+}
+
@@ -0,0 +1,11 @@
+import sbt._
+
+class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
+ val akkaRepo = "Akka Repo" at "http://akka.io/repository"
+ val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "1.1"
+ // eclipsify plugin
+ lazy val eclipse = "de.element34" % "sbt-eclipsify" % "0.7.0"
+ val sbtIdeaRepo = "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"
+ val sbtIdea = "com.github.mpeltonen" % "sbt-idea-plugin" % "0.4.0"
+ val formatter = "com.github.olim7t" % "sbt-scalariform" % "1.0.3"
+}
@@ -0,0 +1 @@
+build.properties
@@ -0,0 +1,103 @@
+####################
+# Akka Config File #
+####################
+
+akka {
+ version = "1.1" # Akka version, checked against the runtime version of Akka.
+
+ enabled-modules = ["remote", "camel", "http"] # Comma separated list of the enabled modules. Options: ["remote", "camel", "http"]
+
+ time-unit = "seconds" # Time unit for all timeout properties throughout the config
+
+ event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
+ event-handler-level = "INFO" # Options: ERROR, WARNING, INFO, DEBUG
+
+ # These boot classes are loaded (and created) automatically when the Akka Microkernel boots up
+ # Can be used to bootstrap your application(s)
+ # Should be the FQN (Fully Qualified Name) of the boot class which needs to have a default constructor
+ # boot = ["sample.camel.Boot",
+ # "sample.rest.java.Boot",
+ # "sample.rest.scala.Boot",
+ # "sample.security.Boot"]
+ boot = ["duse12.Boot"]
+
+
+ http {
+ hostname = "localhost"
+ port = 9998
+
+ #If you are using akka.http.AkkaRestServlet
+ filters = ["akka.security.AkkaSecurityFilterFactory"] # List with all jersey filters to use
+ # resource-packages = ["sample.rest.scala",
+ # "sample.rest.java",
+ # "sample.security"] # List with all resource packages for your Jersey services
+ resource-packages = []
+
+ # The authentication service to use. Need to be overridden (sample now)
+ # authenticator = "sample.security.BasicAuthenticationService"
+ authenticator = "N/A"
+
+ # Uncomment if you are using the KerberosAuthenticationActor
+ # kerberos {
+ # servicePrincipal = "HTTP/localhost@EXAMPLE.COM"
+ # keyTabLocation = "URL to keytab"
+ # kerberosDebug = "true"
+ # realm = "EXAMPLE.COM"
+ # }
+ kerberos {
+ servicePrincipal = "N/A"
+ keyTabLocation = "N/A"
+ kerberosDebug = "N/A"
+ realm = ""
+ }
+
+ #If you are using akka.http.AkkaMistServlet
+ mist-dispatcher {
+ #type = "GlobalExecutorBasedEventDriven" # Uncomment if you want to use a different dispatcher than the default one for Comet
+ }
+ connection-close = true # toggles the addition of the "Connection" response header with a "close" value
+ root-actor-id = "_httproot" # the id of the actor to use as the root endpoint
+ root-actor-builtin = true # toggles the use of the built-in root endpoint base class
+ timeout = 1000 # the default timeout for all async requests (in ms)
+ expired-header-name = "Async-Timeout" # the name of the response header to use when an async request expires
+ expired-header-value = "expired" # the value of the response header to use when an async request expires
+ }
+
+ remote {
+
+ # secure-cookie = "050E0A0D0D06010A00000900040D060F0C09060B" # generate your own with '$AKKA_HOME/scripts/generate_config_with_secure_cookie.sh' or using 'Crypt.generateSecureCookie'
+ secure-cookie = ""
+
+ compression-scheme = "zlib" # Options: "zlib" (lzf to come), leave out for no compression
+ zlib-compression-level = 6 # Options: 0-9 (1 being fastest and 9 being the most compressed), default is 6
+
+ layer = "akka.remote.netty.NettyRemoteSupport"
+
+ server {
+ hostname = "localhost" # The hostname or IP that clients should connect to
+ port = 2552 # The port clients should connect to. Default is 2552 (AKKA)
+ message-frame-size = 1048576 # Increase this if you want to be able to send messages with large payloads
+ connection-timeout = 1
+ require-cookie = off # Should the remote server require that it peers share the same secure-cookie (defined in the 'remote' section)?
+ untrusted-mode = off # Enable untrusted mode for full security of server managed actors, allows untrusted clients to connect.
+ backlog = 4096 # Sets the size of the connection backlog
+ execution-pool-keepalive = 60# Length in akka.time-unit how long core threads will be kept alive if idling
+ execution-pool-size = 16# Size of the core pool of the remote execution unit
+ max-channel-memory-size = 0 # Maximum channel size, 0 for off
+ max-total-memory-size = 0 # Maximum total size of all channels, 0 for off
+ }
+
+ client {
+ buffering {
+ retry-message-send-on-failure = on
+ capacity = -1 # If negative (or zero) then an unbounded mailbox is used (default)
+ # If positive then a bounded mailbox is used and the capacity is set using the property
+ }
+ reconnect-delay = 5
+ read-timeout = 10
+ message-frame-size = 1048576
+ reap-futures-delay = 5
+ reconnection-time-window = 600 # Maximum time window that a client should try to reconnect for
+ }
+ }
+}
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<configuration scan="true" debug="false">
+ <appender name="R" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <File>../logs/duse12.log</File>
+ <encoder>
+ <pattern>[%4p] [%d{ISO8601}] [%t] %c{1}: %m%n</pattern>
+ </encoder>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>./logs/test.log.%d{yyyy-MM-dd-HH}</fileNamePattern>
+ <maxHistory>30</maxHistory>
+ </rollingPolicy>
+ </appender>
+ <logger name="akka" level="INFO"/>
+ <logger name="org.mortbay.log.class" level="INFO"/>
+ <root level="INFO">
+ <appender-ref ref="R"/>
+ </root>
+</configuration>
@@ -0,0 +1,103 @@
+####################
+# Akka Config File #
+####################
+
+akka {
+ version = "1.1" # Akka version, checked against the runtime version of Akka.
+
+ enabled-modules = ["remote", "camel", "http"] # Comma separated list of the enabled modules. Options: ["remote", "camel", "http"]
+
+ time-unit = "seconds" # Time unit for all timeout properties throughout the config
+
+ event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
+ event-handler-level = "DEBUG" # Options: ERROR, WARNING, INFO, DEBUG
+
+ # These boot classes are loaded (and created) automatically when the Akka Microkernel boots up
+ # Can be used to bootstrap your application(s)
+ # Should be the FQN (Fully Qualified Name) of the boot class which needs to have a default constructor
+ # boot = ["sample.camel.Boot",
+ # "sample.rest.java.Boot",
+ # "sample.rest.scala.Boot",
+ # "sample.security.Boot"]
+ #boot = ["duse12.Boot"]
+
+
+ http {
+ hostname = "localhost"
+ port = 9999
+
+ #If you are using akka.http.AkkaRestServlet
+ filters = ["akka.security.AkkaSecurityFilterFactory"] # List with all jersey filters to use
+ # resource-packages = ["sample.rest.scala",
+ # "sample.rest.java",
+ # "sample.security"] # List with all resource packages for your Jersey services
+ resource-packages = []
+
+ # The authentication service to use. Need to be overridden (sample now)
+ # authenticator = "sample.security.BasicAuthenticationService"
+ authenticator = "N/A"
+
+ # Uncomment if you are using the KerberosAuthenticationActor
+ # kerberos {
+ # servicePrincipal = "HTTP/localhost@EXAMPLE.COM"
+ # keyTabLocation = "URL to keytab"
+ # kerberosDebug = "true"
+ # realm = "EXAMPLE.COM"
+ # }
+ kerberos {
+ servicePrincipal = "N/A"
+ keyTabLocation = "N/A"
+ kerberosDebug = "N/A"
+ realm = ""
+ }
+
+ #If you are using akka.http.AkkaMistServlet
+ mist-dispatcher {
+ #type = "GlobalExecutorBasedEventDriven" # Uncomment if you want to use a different dispatcher than the default one for Comet
+ }
+ connection-close = true # toggles the addition of the "Connection" response header with a "close" value
+ root-actor-id = "_httproot" # the id of the actor to use as the root endpoint
+ root-actor-builtin = true # toggles the use of the built-in root endpoint base class
+ timeout = 1000 # the default timeout for all async requests (in ms)
+ expired-header-name = "Async-Timeout" # the name of the response header to use when an async request expires
+ expired-header-value = "expired" # the value of the response header to use when an async request expires
+ }
+
+ remote {
+
+ # secure-cookie = "050E0A0D0D06010A00000900040D060F0C09060B" # generate your own with '$AKKA_HOME/scripts/generate_config_with_secure_cookie.sh' or using 'Crypt.generateSecureCookie'
+ secure-cookie = ""
+
+ compression-scheme = "zlib" # Options: "zlib" (lzf to come), leave out for no compression
+ zlib-compression-level = 6 # Options: 0-9 (1 being fastest and 9 being the most compressed), default is 6
+
+ layer = "akka.remote.netty.NettyRemoteSupport"
+
+ server {
+ hostname = "localhost" # The hostname or IP that clients should connect to
+ port = 2553 # The port clients should connect to. Default is 2552 (AKKA)
+ message-frame-size = 1048576 # Increase this if you want to be able to send messages with large payloads
+ connection-timeout = 1
+ require-cookie = off # Should the remote server require that it peers share the same secure-cookie (defined in the 'remote' section)?
+ untrusted-mode = off # Enable untrusted mode for full security of server managed actors, allows untrusted clients to connect.
+ backlog = 4096 # Sets the size of the connection backlog
+ execution-pool-keepalive = 60# Length in akka.time-unit how long core threads will be kept alive if idling
+ execution-pool-size = 16# Size of the core pool of the remote execution unit
+ max-channel-memory-size = 0 # Maximum channel size, 0 for off
+ max-total-memory-size = 0 # Maximum total size of all channels, 0 for off
+ }
+
+ client {
+ buffering {
+ retry-message-send-on-failure = on
+ capacity = -1 # If negative (or zero) then an unbounded mailbox is used (default)
+ # If positive then a bounded mailbox is used and the capacity is set using the property
+ }
+ reconnect-delay = 5
+ read-timeout = 10
+ message-frame-size = 1048576
+ reap-futures-delay = 5
+ reconnection-time-window = 600 # Maximum time window that a client should try to reconnect for
+ }
+ }
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit b893cb6

Please sign in to comment.