Your SlideShare is downloading. ×
0
JRubyПрактика применения
Short history
Short history• 2001 - the first version of JRuby(by Jan  Arne Petersen)
Short history• 2001 - the first version of JRuby(by Jan  Arne Petersen)• 2006 - version 0.9.0(by Charles Nutter,  Thomas En...
Short history• 2001 - the first version of JRuby(by Jan  Arne Petersen)• 2006 - version 0.9.0(by Charles Nutter,  Thomas En...
Why JRuby?
Why JRuby?• Multithreading
Why JRuby?• Multithreading• JVM
Why JRuby?• Multithreading• JVM• Cross-platform
Why JRuby?• Multithreading• JVM• Cross-platform• Just another .jar
Why JRuby?• Multithreading• JVM• Cross-platform• Just another .jar• GUI
Why JRuby?• Multithreading• JVM• Cross-platform• Just another .jar• GUI• Android
JVM
JVM• Concurrent threading
JVM• Concurrent threading• Garbage collectors
JVM• Concurrent threading• Garbage collectors• JIT compiler
JVM• Concurrent threading• Garbage collectors• JIT compiler• invokedynamic(JDK 7)
Missing features
Missing features• Memory footprint
Missing features• Memory footprint• No Kernel#fork
Missing features• Memory footprint• No Kernel#fork• No continuations(callcc)
Missing features• Memory footprint• No Kernel#fork• No continuations(callcc)• ObjectSpace off by default(-X+O to enable)
Missing features• Memory footprint• No Kernel#fork• No continuations(callcc)• ObjectSpace off by default(-X+O to enable)• ...
C extensionssince JRuby 1.6(still experimental)
Easy installing• rvm install jruby• rbenv install jruby-1.6.6 (*)• Download from http://jruby.org
Compatibilities Ruby 1.8.7 & 1.9.2 compatible              (default 1.8)flag `jruby --1.9` for 1.9.2 compatibility
Nailgun(since 1.3.0 version)
Nailgun             (since 1.3.0 version)Nailgun is a client, protocol, and server for   running Java programs in the serv...
Nailgun             (since 1.3.0 version)Nailgun is a client, protocol, and server for   running Java programs in the serv...
Multi-VM support  many apps in one process
Multi-VM support  many apps in one process            JVM
Multi-VM support        many apps in one processJRuby      JRuby   JRuby   JRuby   JRuby                   JVM
Benchmarksjruby 1.7.0.dev(JDK 6)   jruby 1.7.0.dev(JDK 7) invokedynamic=falsejruby 1.7.0.dev(JDK 7)   ruby 1.9.3-p0
Benchmarks    jruby 1.7.0.dev(JDK 6)           jruby 1.7.0.dev(JDK 7) invokedynamic=false    jruby 1.7.0.dev(JDK 7)       ...
Benchmarks    jruby 1.7.0.dev(JDK 6)           jruby 1.7.0.dev(JDK 7) invokedynamic=false    jruby 1.7.0.dev(JDK 7)       ...
Benchmarks    jruby 1.7.0.dev(JDK 6)           jruby 1.7.0.dev(JDK 7) invokedynamic=false    jruby 1.7.0.dev(JDK 7)       ...
Benchmarks    jruby 1.7.0.dev(JDK 6)           jruby 1.7.0.dev(JDK 7) invokedynamic=false    jruby 1.7.0.dev(JDK 7)       ...
Benchmarks    jruby 1.7.0.dev(JDK 6)           jruby 1.7.0.dev(JDK 7) invokedynamic=false    jruby 1.7.0.dev(JDK 7)       ...
jvisualvm
jvisualvm
jvisualvm
JVM + JRuby
JVM + JRuby• Swing, SWT
JVM + JRuby• Swing, SWT• JavaFX
JVM + JRuby• Swing, SWT• JavaFX• Spring & Hibernate
JVM + JRuby• Swing, SWT• JavaFX• Spring & Hibernate• Scala, Groovy, Jython, Clojure, ...
JVM + JRuby    Swing
JVM + JRuby    Swing
RedCar  SWT
Java + Ruby
Java + Ruby• require ‘java’
Java + Ruby• require ‘java’• Java namespace
Java + Ruby• require ‘java’• Java namespace• Snake case(get_some vs getSome)
Java + Ruby• require ‘java’• Java namespace• Snake case(get_some vs getSome)• Ruby-style accessors(length= vs setLength)
Java + Ruby• require ‘java’• Java namespace• Snake case(get_some vs getSome)• Ruby-style accessors(length= vs setLength)• ...
Java + Ruby• require ‘java’• Java namespace• Snake case(get_some vs getSome)• Ruby-style accessors(length= vs setLength)• ...
Java bridge  Collections
Java bridge                 CollectionsJava List:java_list[0]java_list << 5java_list += 7
Java bridge                 CollectionsJava List:             Java Map:java_list[0]           java_list[‘key’]java_list <<...
Java bridge                 CollectionsJava List:             Java Map:java_list[0]           java_list[‘key’]java_list <<...
Java bridge                OverloadingJava:public class Test {  public boolean isSome(String arg) {...}  public boolean is...
Java bridge                    OverloadingRuby:Test.new.java_send :isSome, [Java::long], 1_000orclass Test  java_alias :is...
Java bridge               AnnotationsJava:@Bean(scope = Scope.PROTOTYPE)public class Person {    ...}
Java bridge                    AnnotationsRuby:java_import Beanjava_import Scopeclass PersonendPerson.add_class_annotation...
Java bridge            InterfacesRuby:class Posts  include java.util.Iteratorend
JRuby compiler           Ahead-Of-Time Compilation$ jrubyc <script name>.rb$ java -cp .:/path/to/jruby.jar <script name>
JRuby compiler         Generate .java classes from .rb$ jrubyc --java <script name>.rb
JRuby compilerRuby:require javaclass Vec  def initialize(x, y)   @xcoord = x   @ycoord = y  endend
JRuby compilerRuby:require javaclass Vec  java_signature Vec(double x, double y)  def initialize(x, y)    @xcoord = x    @...
JRuby compilerJava:import org.jruby.Ruby;import org.jruby.RubyObject;import org.jruby.RubyClass;...public class Vec extend...
Rake + Ant
Rake + AntAnt tasks like Rake tasks:task :ant_import do  ant_importend
Buildr                 http://buildr.apache.org    Apache Buildr is a build system for Java-basedapplications, including s...
Buildrhttp://buildr.apache.org
Buildr              http://buildr.apache.org•   Projects and sub-projects
Buildr              http://buildr.apache.org•   Projects and sub-projects•   Compiling, copying and filtering resources,   ...
Buildr              http://buildr.apache.org•   Projects and sub-projects•   Compiling, copying and filtering resources,   ...
Buildr              http://buildr.apache.org•   Projects and sub-projects•   Compiling, copying and filtering resources,   ...
Buildr              http://buildr.apache.org•   Projects and sub-projects•   Compiling, copying and filtering resources,   ...
Buildr              http://buildr.apache.org•   Projects and sub-projects•   Compiling, copying and filtering resources,   ...
Buildr                               http://buildr.apache.orgbuildfile:repositories.remote "http://repo.typesafe.com/typesa...
Rawr                    http://rawr.rubyforge.orgRawr, a packaging and deployment tool, that allows turns yourcode into an...
Rawrhttp://rawr.rubyforge.org $ gem install rawr $ rawr install ... $ rake rawr:jar
Deployment
JRuby-Rack Servlet     JRuby-Rack               Rack                            Rackcontainer   servlet filter          app...
JRuby servers
JRuby servers    WEBrick
JRuby servers    WEBrick    Trinidad
JRuby servers    WEBrick    Trinidad   TorqueBox
TorqueBoxhttp://torquebox.org
TorqueBoxhttp://torquebox.org
TorqueBox                http://torquebox.orgInstallation:jruby -S gem install torquebox-server --pre
TorqueBox        http://torquebox.orgUsage:torquebox deploy ~/Projects/rails_apptorquebox run
Warbler Warbler is a gem to make a Java jar or war fileout of any Ruby, Rails, Merb, or Rack application.
WarblerInstallation:jruby -S gem install warbler
WarblerUsage:
Warbler
WarblerStandalone application:
Tuning flags
Tuning flags• --server - server compiler
Tuning flags• --server - server compiler• -Xmx - max heap size
Tuning flags• --server - server compiler• -Xmx - max heap size• -XX:+UnlockExperimentalVMOptions  -XX:+UseG1GC - new GC(JDK...
Clouds• Amazon Elastic Beans(http://aws.amazon.com/  elasticbeanstalk/)• Jelastic(http://jelastic.com)• Engine Yard(http:/...
Hot Spot
Bot Hunter
Bot Hunter• Multithreading
Bot Hunter• Multithreading• Some logic on Scala
Yukihiro Matsumoto: “I would remove thethread and add actors or some other moreadvanced concurrency features”.
Akka              http://akka.io/Simpler Concurrency, Scalability & Fault-       tolerance through Actors                 ...
Actor Model of Concurrency             slidesha.re/akka-scala-days-2010
Actor Model of        Concurrency• Implements Message-Passing Concurrency                                   slidesha.re/ak...
Actor Model of        Concurrency• Implements Message-Passing Concurrency• Share nothing                                  ...
Actor Model of        Concurrency• Implements Message-Passing Concurrency• Share nothing• Isolated lightweight process    ...
Actor Model of        Concurrency• Implements Message-Passing Concurrency• Share nothing• Isolated lightweight process• Co...
Actor Model of        Concurrency• Implements Message-Passing Concurrency• Share nothing• Isolated lightweight process• Co...
Actor Model of        Concurrency• Implements Message-Passing Concurrency• Share nothing• Isolated lightweight process• Co...
Two different models                 slidesha.re/akka-scala-days-2010
Two different models• Thread-based                  slidesha.re/akka-scala-days-2010
Two different models• Thread-based• Event-based                  slidesha.re/akka-scala-days-2010
Two different models• Thread-based• Event-based • Very lightweight(~300 bytes per actor)                                  ...
Two different models• Thread-based• Event-based • Very lightweight(~300 bytes per actor) • Can easily create millions on a...
Example          slidesha.re/akka-scala-days-2010
Server codeclass HelloWorldActor extends UntypedActor {  public void onReceive(Object msg) {     getContext().tryReply(msg...
Client codeactor = Actors.remote.actorFor(  "hello-service", "localhost", 2552)res = actor.ask("Hello").get               ...
The Bad
java.lang.NullPointerException
Groovy
Questions?Email: klimtimothy@gmail.com
Upcoming SlideShare
Loading in...5
×

Практики применения JRuby

1,418

Published on

* История JRuby;
* Платформа JVM и ее возможности;
* Почему стоит попробовать JRuby;
* Как мы в Хот Спот используем JRuby для разработки;
* Сравнение с другими JVM языками.

Published in: Technology, News & Politics
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,418
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
10
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Практики применения JRuby"

    1. 1. JRubyПрактика применения
    2. 2. Short history
    3. 3. Short history• 2001 - the first version of JRuby(by Jan Arne Petersen)
    4. 4. Short history• 2001 - the first version of JRuby(by Jan Arne Petersen)• 2006 - version 0.9.0(by Charles Nutter, Thomas Enebo, Ola Bini and Nick Siege)
    5. 5. Short history• 2001 - the first version of JRuby(by Jan Arne Petersen)• 2006 - version 0.9.0(by Charles Nutter, Thomas Enebo, Ola Bini and Nick Siege)• 2007 - version 1.0(passed all Rails tests)
    6. 6. Why JRuby?
    7. 7. Why JRuby?• Multithreading
    8. 8. Why JRuby?• Multithreading• JVM
    9. 9. Why JRuby?• Multithreading• JVM• Cross-platform
    10. 10. Why JRuby?• Multithreading• JVM• Cross-platform• Just another .jar
    11. 11. Why JRuby?• Multithreading• JVM• Cross-platform• Just another .jar• GUI
    12. 12. Why JRuby?• Multithreading• JVM• Cross-platform• Just another .jar• GUI• Android
    13. 13. JVM
    14. 14. JVM• Concurrent threading
    15. 15. JVM• Concurrent threading• Garbage collectors
    16. 16. JVM• Concurrent threading• Garbage collectors• JIT compiler
    17. 17. JVM• Concurrent threading• Garbage collectors• JIT compiler• invokedynamic(JDK 7)
    18. 18. Missing features
    19. 19. Missing features• Memory footprint
    20. 20. Missing features• Memory footprint• No Kernel#fork
    21. 21. Missing features• Memory footprint• No Kernel#fork• No continuations(callcc)
    22. 22. Missing features• Memory footprint• No Kernel#fork• No continuations(callcc)• ObjectSpace off by default(-X+O to enable)
    23. 23. Missing features• Memory footprint• No Kernel#fork• No continuations(callcc)• ObjectSpace off by default(-X+O to enable)• set_trace_func off by default(--debug to enable)
    24. 24. C extensionssince JRuby 1.6(still experimental)
    25. 25. Easy installing• rvm install jruby• rbenv install jruby-1.6.6 (*)• Download from http://jruby.org
    26. 26. Compatibilities Ruby 1.8.7 & 1.9.2 compatible (default 1.8)flag `jruby --1.9` for 1.9.2 compatibility
    27. 27. Nailgun(since 1.3.0 version)
    28. 28. Nailgun (since 1.3.0 version)Nailgun is a client, protocol, and server for running Java programs in the server.
    29. 29. Nailgun (since 1.3.0 version)Nailgun is a client, protocol, and server for running Java programs in the server. $ jruby --ng-server & $ jruby --ng -e "puts 1"
    30. 30. Multi-VM support many apps in one process
    31. 31. Multi-VM support many apps in one process JVM
    32. 32. Multi-VM support many apps in one processJRuby JRuby JRuby JRuby JRuby JVM
    33. 33. Benchmarksjruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=falsejruby 1.7.0.dev(JDK 7) ruby 1.9.3-p0
    34. 34. Benchmarks jruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=false jruby 1.7.0.dev(JDK 7) ruby 1.9.3-p043210 bench/bench_red_black.rb (sec)
    35. 35. Benchmarks jruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=false jruby 1.7.0.dev(JDK 7) ruby 1.9.3-p043210 bench/bench_red_black.rb (sec)
    36. 36. Benchmarks jruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=false jruby 1.7.0.dev(JDK 7) ruby 1.9.3-p043210 bench/bench_red_black.rb (sec)
    37. 37. Benchmarks jruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=false jruby 1.7.0.dev(JDK 7) ruby 1.9.3-p043210 bench/bench_red_black.rb (sec)
    38. 38. Benchmarks jruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=false jruby 1.7.0.dev(JDK 7) ruby 1.9.3-p043210 bench/bench_red_black.rb (sec)
    39. 39. jvisualvm
    40. 40. jvisualvm
    41. 41. jvisualvm
    42. 42. JVM + JRuby
    43. 43. JVM + JRuby• Swing, SWT
    44. 44. JVM + JRuby• Swing, SWT• JavaFX
    45. 45. JVM + JRuby• Swing, SWT• JavaFX• Spring & Hibernate
    46. 46. JVM + JRuby• Swing, SWT• JavaFX• Spring & Hibernate• Scala, Groovy, Jython, Clojure, ...
    47. 47. JVM + JRuby Swing
    48. 48. JVM + JRuby Swing
    49. 49. RedCar SWT
    50. 50. Java + Ruby
    51. 51. Java + Ruby• require ‘java’
    52. 52. Java + Ruby• require ‘java’• Java namespace
    53. 53. Java + Ruby• require ‘java’• Java namespace• Snake case(get_some vs getSome)
    54. 54. Java + Ruby• require ‘java’• Java namespace• Snake case(get_some vs getSome)• Ruby-style accessors(length= vs setLength)
    55. 55. Java + Ruby• require ‘java’• Java namespace• Snake case(get_some vs getSome)• Ruby-style accessors(length= vs setLength)• Converting types
    56. 56. Java + Ruby• require ‘java’• Java namespace• Snake case(get_some vs getSome)• Ruby-style accessors(length= vs setLength)• Converting types• Swing IRB(command: jirb_swing)
    57. 57. Java bridge Collections
    58. 58. Java bridge CollectionsJava List:java_list[0]java_list << 5java_list += 7
    59. 59. Java bridge CollectionsJava List: Java Map:java_list[0] java_list[‘key’]java_list << 5 java_list[‘key’] = 5java_list += 7
    60. 60. Java bridge CollectionsJava List: Java Map:java_list[0] java_list[‘key’]java_list << 5 java_list[‘key’] = 5java_list += 7 Ruby List: [1, 2, 3].to_java :int [“string”].to_java :string
    61. 61. Java bridge OverloadingJava:public class Test { public boolean isSome(String arg) {...} public boolean isSome(int arg) {...} public boolean isSome(long arg) {...} public boolean isSome(Object arg) {...}}
    62. 62. Java bridge OverloadingRuby:Test.new.java_send :isSome, [Java::long], 1_000orclass Test java_alias :is_some, :isSome, [Java::long] ...end
    63. 63. Java bridge AnnotationsJava:@Bean(scope = Scope.PROTOTYPE)public class Person { ...}
    64. 64. Java bridge AnnotationsRuby:java_import Beanjava_import Scopeclass PersonendPerson.add_class_annotation(Bean: { ‘scope’ => Scope.PROTOTYPE})Person.become_java!
    65. 65. Java bridge InterfacesRuby:class Posts include java.util.Iteratorend
    66. 66. JRuby compiler Ahead-Of-Time Compilation$ jrubyc <script name>.rb$ java -cp .:/path/to/jruby.jar <script name>
    67. 67. JRuby compiler Generate .java classes from .rb$ jrubyc --java <script name>.rb
    68. 68. JRuby compilerRuby:require javaclass Vec def initialize(x, y) @xcoord = x @ycoord = y endend
    69. 69. JRuby compilerRuby:require javaclass Vec java_signature Vec(double x, double y) def initialize(x, y) @xcoord = x @ycoord = y endend
    70. 70. JRuby compilerJava:import org.jruby.Ruby;import org.jruby.RubyObject;import org.jruby.RubyClass;...public class Vec extends RubyObject { ... public Vec(double x, double y) { ... }}
    71. 71. Rake + Ant
    72. 72. Rake + AntAnt tasks like Rake tasks:task :ant_import do ant_importend
    73. 73. Buildr http://buildr.apache.org Apache Buildr is a build system for Java-basedapplications, including support for Scala, Groovy and a growing number of JVM languages and tools.
    74. 74. Buildrhttp://buildr.apache.org
    75. 75. Buildr http://buildr.apache.org• Projects and sub-projects
    76. 76. Buildr http://buildr.apache.org• Projects and sub-projects• Compiling, copying and filtering resources, test cases, Javadoc and more
    77. 77. Buildr http://buildr.apache.org• Projects and sub-projects• Compiling, copying and filtering resources, test cases, Javadoc and more• Builds what has changed since the last release
    78. 78. Buildr http://buildr.apache.org• Projects and sub-projects• Compiling, copying and filtering resources, test cases, Javadoc and more• Builds what has changed since the last release• Support Maven 2.0
    79. 79. Buildr http://buildr.apache.org• Projects and sub-projects• Compiling, copying and filtering resources, test cases, Javadoc and more• Builds what has changed since the last release• Support Maven 2.0• Support Ant
    80. 80. Buildr http://buildr.apache.org• Projects and sub-projects• Compiling, copying and filtering resources, test cases, Javadoc and more• Builds what has changed since the last release• Support Maven 2.0• Support Ant• Buildr is Ruby all the way down
    81. 81. Buildr http://buildr.apache.orgbuildfile:repositories.remote "http://repo.typesafe.com/typesafe/releases/"desc "The Springmongodb project"define "SpringMongoDB" do project.version = "0.1" project.group = "SpringMongoDB" run.with "org.jruby:jruby-complete:jar:1.6.6", "org.mongodb:mongo-java-driver:jar:2.7.2", "org.springframework:spring-core:jar:3.1.0.RELEASE", "org.springframework:spring-context:jar:3.1.0.RELEASE", "org.springframework:spring-beans:jar:3.1.0.RELEASE", org.springframework.data:spring-data-commons-core:jar:1.1.0.RELEASE, "org.springframework.data:spring-data-mongodb:jar:1.0.0.RC1" run.using main: [org.jruby.Main, _(:src, :main, :ruby, "app.rb")]end
    82. 82. Rawr http://rawr.rubyforge.orgRawr, a packaging and deployment tool, that allows turns yourcode into an executable jar, a .exe for Windows, and a .app forOS X.
    83. 83. Rawrhttp://rawr.rubyforge.org $ gem install rawr $ rawr install ... $ rake rawr:jar
    84. 84. Deployment
    85. 85. JRuby-Rack Servlet JRuby-Rack Rack Rackcontainer servlet filter application
    86. 86. JRuby servers
    87. 87. JRuby servers WEBrick
    88. 88. JRuby servers WEBrick Trinidad
    89. 89. JRuby servers WEBrick Trinidad TorqueBox
    90. 90. TorqueBoxhttp://torquebox.org
    91. 91. TorqueBoxhttp://torquebox.org
    92. 92. TorqueBox http://torquebox.orgInstallation:jruby -S gem install torquebox-server --pre
    93. 93. TorqueBox http://torquebox.orgUsage:torquebox deploy ~/Projects/rails_apptorquebox run
    94. 94. Warbler Warbler is a gem to make a Java jar or war fileout of any Ruby, Rails, Merb, or Rack application.
    95. 95. WarblerInstallation:jruby -S gem install warbler
    96. 96. WarblerUsage:
    97. 97. Warbler
    98. 98. WarblerStandalone application:
    99. 99. Tuning flags
    100. 100. Tuning flags• --server - server compiler
    101. 101. Tuning flags• --server - server compiler• -Xmx - max heap size
    102. 102. Tuning flags• --server - server compiler• -Xmx - max heap size• -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC - new GC(JDK 7)
    103. 103. Clouds• Amazon Elastic Beans(http://aws.amazon.com/ elasticbeanstalk/)• Jelastic(http://jelastic.com)• Engine Yard(http://www.engineyard.com)• Google App Engine(http:// appengine.google.com)
    104. 104. Hot Spot
    105. 105. Bot Hunter
    106. 106. Bot Hunter• Multithreading
    107. 107. Bot Hunter• Multithreading• Some logic on Scala
    108. 108. Yukihiro Matsumoto: “I would remove thethread and add actors or some other moreadvanced concurrency features”.
    109. 109. Akka http://akka.io/Simpler Concurrency, Scalability & Fault- tolerance through Actors slidesha.re/akka-scala-days-2010
    110. 110. Actor Model of Concurrency slidesha.re/akka-scala-days-2010
    111. 111. Actor Model of Concurrency• Implements Message-Passing Concurrency slidesha.re/akka-scala-days-2010
    112. 112. Actor Model of Concurrency• Implements Message-Passing Concurrency• Share nothing slidesha.re/akka-scala-days-2010
    113. 113. Actor Model of Concurrency• Implements Message-Passing Concurrency• Share nothing• Isolated lightweight process slidesha.re/akka-scala-days-2010
    114. 114. Actor Model of Concurrency• Implements Message-Passing Concurrency• Share nothing• Isolated lightweight process• Communicates through messages slidesha.re/akka-scala-days-2010
    115. 115. Actor Model of Concurrency• Implements Message-Passing Concurrency• Share nothing• Isolated lightweight process• Communicates through messages• Asynchronous and non-blocking slidesha.re/akka-scala-days-2010
    116. 116. Actor Model of Concurrency• Implements Message-Passing Concurrency• Share nothing• Isolated lightweight process• Communicates through messages• Asynchronous and non-blocking• Each actor has a mailbox(message queue) slidesha.re/akka-scala-days-2010
    117. 117. Two different models slidesha.re/akka-scala-days-2010
    118. 118. Two different models• Thread-based slidesha.re/akka-scala-days-2010
    119. 119. Two different models• Thread-based• Event-based slidesha.re/akka-scala-days-2010
    120. 120. Two different models• Thread-based• Event-based • Very lightweight(~300 bytes per actor) slidesha.re/akka-scala-days-2010
    121. 121. Two different models• Thread-based• Event-based • Very lightweight(~300 bytes per actor) • Can easily create millions on a single workstation slidesha.re/akka-scala-days-2010
    122. 122. Example slidesha.re/akka-scala-days-2010
    123. 123. Server codeclass HelloWorldActor extends UntypedActor { public void onReceive(Object msg) { getContext().tryReply(msg + " World"); }}remote().start("localhost", 2552).register( "hello-service", actorOf(HelloWorldActor.class)); slidesha.re/akka-scala-days-2010
    124. 124. Client codeactor = Actors.remote.actorFor( "hello-service", "localhost", 2552)res = actor.ask("Hello").get slidesha.re/akka-scala-days-2010
    125. 125. The Bad
    126. 126. java.lang.NullPointerException
    127. 127. Groovy
    128. 128. Questions?Email: klimtimothy@gmail.com
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×