DRb Distributed Ruby. Johan Sørensen <johan@johansorensen.com>

Similar documents
WINDOWS PRESENTATION FOUNDATION LEKTION 3

Interface Programmera mot interface Johan Eliasson Johan Eliasson Interface kan bryta beroendekedjor Skriv generell kod «Type» Class2 Interface

Projektet Computer: Specifikation. Objektorienterad modellering och diskreta strukturer / design. Projektet Computer: Data. Projektet Computer: Test

Category work in courtroom talk about domestic violence: Gender as an interactional accomplishment in child custody disputes

Car Customer Service. SFK Väst, January 2016, Måns Falk, mfalk, Security Class; Proprietary

International Council on Systems Engineering. ISO/IEC/IEEE SEminar Linköping 16 november 2015

OIO Dekstop applikation

Tanden Care Provider Interfaces Submit Claim v3

Workshop 1: Can CM find common ground for HW & SW development?

Jag valde att använda Net-EPP_client.php från centralnic för att komma igång.

Ange om en aktivitet har medfört att en tjänsteresa har utförts med flyg under 2013, och i sådana fall antal gånger.

Lab 2 review PHP intro. MVC (Model View controller)

Tanden Care Provider Interfaces Reverse Claim v1

Microsoft SQL Server 2012: Designing Buisness Intelligence Solutions

Investigating the Possibility of an Active/Active Highly Available Jenkins

Ruby & Ruby on Rails for arkitekter. Kim Harding Christensen khc@kimharding.com

TRA Q NORDIC RELEASE - JULY 2013

SAS Data Integration SAS Business Intelligence

Hearing med Thomas Feldthus, CFO och Nils Brünner, vd WntResearch AB

Marknadsföring som en del av intäktsprocessen.

Design Suggestions for Danske Bank SE

Configuring and Administering Hyper-V in Windows Server 2012

Introduktion till SAS 9 Plattformen Helikopterkursen

SAS Education Providing knowledge through global training and certification. SAS Foundation. Kursöversikt 2010

Defining Distributed Systems. Distribuerade system. Exemples of DS: Intranet. Exemples of DS: Internet. Exemples of DS: Mobile Computing

INTERNATIONELLA BANKÖVERFÖRINGAR

Microsoft + SOA = Sant? Joakim Linghall Principal System Engineer SOA and Business Process joakiml@microsoft.com

Readme10_054.doc page 1 of 7

3gamma Från traditionell IT-leverans till modern, processtyrd tjänsteleverans i en multi-sourcing miljö. Peter Wahlgren, September 2013

Bachelor thesis Software Engineering and Management How can code reuse help a Software Company

Git as introduction to configuration management for students

Elektronikavfall. Thomas Lindhqvist IIIEE Lund University. 18 February 2009

Rek. 1995:- Technical specifications SB12V3200E-AC SB12V3200E-AC. Recharges much faster. Longer service life. Only 1/3 of the size.

Stora studentgrupper och god pedagogik. Går det att kombinera?

How To Get Healthy With A Game Called Angel Hour

Coop Policy Sustainable Business: Impact on Coop private brand

Vocabulary in A1 level second language writing

BankID Relying Party Guidelines

Demo Gotland (Smart Customer Gotland)

SWAMID Identity Assurance Level 1 Profile

Hvis personallisten ikke er ført slik reglene sier, kan Skatteetaten ilegge overtredelsesgebyr.

Tanden Care Provider Interfaces PreAssessmentSTB v3

Martin Holmgren Vice President Fleet Management Cramo Group

HAProxy. Free, Fast High Availability and Load Balancing. Adam Thornton 10 September 2014

Computer animations in physical chemistry. Kim Bolton School of Engineering, University College of Borås, SE , Borås

MAXimize the benefits of Mobility Management

CONFLICT OF INTEREST AT THE WHO

Child allowance [Barnbidrag] and large family supplement [flerbarnstillägg] [Barnbidrag och flerbarnstillägg]

SSLSmart Smart SSL Cipher Enumeration

Brakeman and Jenkins: The Duo Detects Defects in Ruby on Rails Code

Viktigaste uppgift: Web Browser SSO

Web-based address book

Scaling Rails with memcached

How To Boot A Cisco Ip Phone From A Cnet Vlan To A Vlan On A Cpower Box On A Ip Phone On A Network With A Network Vlan (Cisco) On A Powerline (Ip Phone) On An

Student evaluation form

Scrum Kandidatprojekt datateknik - TDDD83

COM 440 Distributed Systems Project List Summary

Perlbal: Reverse Proxy & Webserver

Cloud-Based dwaf A Real World Deployment Case Study. OWASP 5. April The OWASP Foundation

StreamServe Persuasion SP4 Service Broker

openbim FM solutions and projects in Sweden Oslo, 11 September 2014 Client BIM requirements BIM in the State

Martin Edqvist Johan Odell

Hierarchical and Linear Constraints on Structure

MME TECHNICAL SERVICE NEWSLETTER GROUP 16 ALTERNATOR LOOSE PULLEY _ 4N13 DATE SERVICE CAMPAIGN (REF. MMC: SSI )

How to configure HTTPS proxying in Zorp 5

Diagnostisera problem med utskriftskvaliteten

Juniper Networks Secure Access. Initial Configuration User Records Synchronization

COMMMUNICATING COOPERATING PROCESSES

Configuring Security Features of Session Recording

Vi har dessutom 1000-tals andra viner på Winefinder.se

Swedish model for Gender Mainstreaming in ESF projects

DECISION/BESLUT

BACHELOR THESIS. Marketing a healthcare product to different industries

Hvordan sikrer du ditt virtuelle datasenter?

WELCOME TO. Information Integration

COACH BOT Modular e-course with virtual coach tool support

IBM Quality Management Strategy. En proces. Vi laver kun 3 ting. IT Operational Service. Solution Deployment. Solution Development.

Transcription:

DRb Distributed Ruby Johan Sørensen <johan@johansorensen.com>

DRb? Remote Method Invocation ( RMI ) for Ruby Af Masatoshi SEKI Peer to Peer Client, Server Crossplatform (pure ruby) Multiprotocol

DRb exempel Object?? Object

DRb exempel # Server require "drb" obj = [1, 2, 3, "four", "Five"] uri = "druby://127.0.0.1:6666" DRb.start_service(uri, obj) DRb.thread.join # Client require "drb" DRb.start_service uri = "druby://127.0.0.1:6666" obj = DRbObject.new_with_uri(uri) obj.size #=> 5 obj.last #=> "Five" obj.map{ v v+v } #=> [2, 4, 6, "fourfour", "FiveFive"] Object?? Object

DRb Exempel # Server require "drb" # DRb biblioteket obj = [1, 2, 3, "four", "Five"] # Objektet vi kommer att dela över DRb uri = "druby://127.0.0.1:6666" # URI n servern ska lyssna på DRb.start_service(uri, obj) # Start server som lyssnar på +uri+, med +obj+ DRb.thread.join # Vent tills DRb er klar

DRb Exempel # Client require "drb" DRb.start_service uri = "druby://127.0.0.1:6666" # Vår server uri obj = DRbObject.new_with_uri(uri) # obj ska vara ett DRbObject ifrån uri obj.size #=> 5 # Vi kan kalla metoder på det andra objektet! obj.last #=> "Five" obj.map{ v v+v } #=> [2, 4, 6, "fourfour", "FiveFive"]

DRb? magic??

DRb? => #<DRb::DRbObject:0x53d66c @ref=nil, @uri="druby://127.0.0.1:6666"> >> enable_trace # set_trace_func{...} Enabling method tracing with event regex /^(call return)/ and class exclusion regex /IRB Wirble RubyLex RubyToken/ [ return] enable_trace Object (/Users/johan/.irbrc:67) => nil >> obj.size [ call] method_missing DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1077) [ call] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1674) [ call] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1647) [ return] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1648) [ return] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1676) [ call] with_friend DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1101) [ call] fetch_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1755) [ return] fetch_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1757) [ call] open DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1152) [ call] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:132) [ call] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:97) [ return] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:98) [ call] unlock Mutex (/opt/local/lib/ruby/1.8/thread.rb:110) [ return] unlock Mutex (/opt/local/lib/ruby/1.8/thread.rb:111) [ return] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:133) [ call] initialize DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1187) [ call] config DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1683) [ call] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1647) [ return] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1648) [ return] config DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1687) [ call] open DRb::DRbProtocol (/opt/local/lib/ruby/1.8/drb/drb.rb:728) [ call] open DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:822) [ call] parse_uri DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:807) [ return] parse_uri DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:817) [ call] initialize DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:883) [ call] initialize DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:549) [ return] initialize DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:550) [ call] set_sockopt DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:961) [ return] set_sockopt DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:962) [ return] initialize DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:884) [ return] open DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:823) [ return] open DRb::DRbProtocol (/opt/local/lib/ruby/1.8/drb/drb.rb:729) [ return] initialize DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1188) [ call] send_message DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1193) [ call] send_request DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:905) [ call] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) >> obj = DRbObject.new_with_uri(uri)

DRb? => #<DRb::DRbObject:0x53d66c @ref=nil, @uri="druby://127.0.0.1:6666"> >> enable_trace # set_trace_func{...} Enabling method tracing with event regex /^(call return)/ and class exclusion regex /IRB Wirble RubyLex RubyToken/ [ return] enable_trace Object (/Users/johan/.irbrc:67) => nil >> obj.size [ call] method_missing DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1077) [ call] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1674) [ call] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1647) [ return] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1648) [ return] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1676) [ call] with_friend DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1101) [ call] fetch_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1755) [ return] fetch_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1757) [ call] open DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1152) [ call] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:132) [ call] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:97) [ return] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:98) [ call] unlock Mutex (/opt/local/lib/ruby/1.8/thread.rb:110) [ return] unlock Mutex (/opt/local/lib/ruby/1.8/thread.rb:111) [ return] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:133) [ call] initialize DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1187) [ call] config DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1683) [ call] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1647) [ return] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1648) [ return] config DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1687) [ call] open DRb::DRbProtocol (/opt/local/lib/ruby/1.8/drb/drb.rb:728) [ call] open DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:822) [ call] parse_uri DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:807) [ return] parse_uri DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:817) [ call] initialize DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:883) [ call] initialize DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:549) [ return] initialize DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:550) [ call] set_sockopt DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:961) [ return] set_sockopt DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:962) [ return] initialize DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:884) [ return] open DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:823) [ return] open DRb::DRbProtocol (/opt/local/lib/ruby/1.8/drb/drb.rb:729) [ return] initialize DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1188) [ call] send_message DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1193) [ call] send_request DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:905) [ call] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) >> obj = DRbObject.new_with_uri(uri)

DRb? => #<DRb::DRbObject:0x53d66c @ref=nil, @uri="druby://127.0.0.1:6666"> >> enable_trace # set_trace_func{...} Enabling method tracing with event regex /^(call return)/ and class exclusion regex /IRB Wirble RubyLex RubyToken/ [ return] enable_trace Object (/Users/johan/.irbrc:67) => nil >> obj.size [ call] method_missing DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1077) [ call] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1674) [ call] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1647) [ return] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1648) [ return] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1676) [ call] with_friend DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1101) [ call] fetch_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1755) [ return] fetch_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1757) [ call] open DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1152) [ call] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:132) [ call] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:97) [ return] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:98) [ call] unlock Mutex (/opt/local/lib/ruby/1.8/thread.rb:110) [ return] unlock Mutex (/opt/local/lib/ruby/1.8/thread.rb:111) [ return] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:133) [ call] initialize DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1187) [ call] config DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1683) [ call] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1647) [ return] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1648) [ return] config DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1687) [ call] open DRb::DRbProtocol (/opt/local/lib/ruby/1.8/drb/drb.rb:728) [ call] open DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:822) [ call] parse_uri DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:807) [ return] parse_uri DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:817) [ call] initialize DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:883) [ call] initialize DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:549) [ return] initialize DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:550) [ call] set_sockopt DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:961) [ return] set_sockopt DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:962) [ return] initialize DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:884) [ return] open DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:823) [ return] open DRb::DRbProtocol (/opt/local/lib/ruby/1.8/drb/drb.rb:729) [ return] initialize DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1188) [ call] send_message DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1193) [ call] send_request DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:905) [ call] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) >> obj = DRbObject.new_with_uri(uri)

DRb? => #<DRb::DRbObject:0x53d66c @ref=nil, @uri="druby://127.0.0.1:6666"> >> enable_trace # set_trace_func{...} Enabling method tracing with event regex /^(call return)/ and class exclusion regex /IRB Wirble RubyLex RubyToken/ [ return] enable_trace Object (/Users/johan/.irbrc:67) => nil >> obj.size [ call] method_missing DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1077) [ call] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1674) [ call] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1647) [ return] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1648) [ return] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1676) [ call] with_friend DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1101) [ call] fetch_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1755) [ return] fetch_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1757) [ call] open DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1152) [ call] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:132) [ call] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:97) [ return] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:98) [ call] unlock Mutex (/opt/local/lib/ruby/1.8/thread.rb:110) [ return] unlock Mutex (/opt/local/lib/ruby/1.8/thread.rb:111) [ return] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:133) [ call] initialize DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1187) [ call] config DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1683) [ call] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1647) [ return] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1648) [ return] config DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1687) [ call] open DRb::DRbProtocol (/opt/local/lib/ruby/1.8/drb/drb.rb:728) [ call] open DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:822) [ call] parse_uri DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:807) [ return] parse_uri DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:817) [ call] initialize DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:883) [ call] initialize DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:549) [ return] initialize DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:550) [ call] set_sockopt DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:961) [ return] set_sockopt DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:962) [ return] initialize DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:884) [ return] open DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:823) [ return] open DRb::DRbProtocol (/opt/local/lib/ruby/1.8/drb/drb.rb:729) [ return] initialize DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1188) [ call] send_message DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1193) [ call] send_request DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:905) [ call] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) >> obj = DRbObject.new_with_uri(uri)

DRb? => #<DRb::DRbObject:0x53d66c @ref=nil, @uri="druby://127.0.0.1:6666"> >> enable_trace # set_trace_func{...} Enabling method tracing with event regex /^(call return)/ and class exclusion regex /IRB Wirble RubyLex RubyToken/ [ return] enable_trace Object (/Users/johan/.irbrc:67) => nil >> obj.size [ call] method_missing DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1077) [ call] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1674) [ call] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1647) [ return] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1648) [ return] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1676) [ call] with_friend DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1101) [ call] fetch_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1755) [ return] fetch_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1757) [ call] open DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1152) [ call] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:132) [ call] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:97) [ return] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:98) [ call] unlock Mutex (/opt/local/lib/ruby/1.8/thread.rb:110) [ return] unlock Mutex (/opt/local/lib/ruby/1.8/thread.rb:111) [ return] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:133) [ call] initialize DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1187) [ call] config DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1683) [ call] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1647) [ return] current_server DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1648) [ return] config DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1687) [ call] open DRb::DRbProtocol (/opt/local/lib/ruby/1.8/drb/drb.rb:728) [ call] open DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:822) [ call] parse_uri DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:807) [ return] parse_uri DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:817) [ call] initialize DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:883) [ call] initialize DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:549) [ return] initialize DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:550) [ call] set_sockopt DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:961) [ return] set_sockopt DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:962) [ return] initialize DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:884) [ return] open DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:823) [ return] open DRb::DRbProtocol (/opt/local/lib/ruby/1.8/drb/drb.rb:729) [ return] initialize DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1188) [ call] send_message DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1193) [ call] send_request DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:905) [ call] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) >> obj = DRbObject.new_with_uri(uri)

DRb? => #<DRb::DRbObject:0x53d66c @ref=nil, @uri="druby://127.0.0.1:6666"> >> enable_trace # set_trace_func{...} Enabling method tracing with event regex /^(call return)/ and class exclusion regex /IRB Wirble RubyLex RubyToken/ [ return] enable_trace Object (/Users/johan/.irbrc:67) => nil >> obj.size [ call] method_missing DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1077) [ call] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1674) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # [ call] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) [ return] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) [ call] send_request DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:597) [ call] drbref DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1058) [ return] drbref DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1060) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ return] send_request DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:609) [ return] send_request DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:907) [ call] recv_reply DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:920) [ call] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) [ return] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) [ call] recv_reply DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:631) [ call] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:564) [ call] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:29) [ return] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:30) [ return] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:565) [ call] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:564) [ call] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:29) [ return] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:30) [ return] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:565) [ return] recv_reply DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:632) [ return] recv_reply DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:922) [ return] send_message DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1194) [ call] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:132) [ call] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:97) [ return] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:98) >> obj = DRbObject.new_with_uri(uri)

DRb? => #<DRb::DRbObject:0x53d66c @ref=nil, @uri="druby://127.0.0.1:6666"> >> obj = DRbObject.new_with_uri(uri) >> enable_trace # set_trace_func{...} class DRbMessage Enabling method tracing with event regex /^(call return)/ and class exclusion regex /IRB Wirble RubyLex RubyToken/ def dump(obj) [ return] enable_trace Object (/Users/johan/.irbrc:67) obj = DRbObject.new(obj) if obj.kind_of? DRbUndumped => nil begin >> obj.size str = Marshal::dump(obj) [ call] method_missing DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1077) rescue [ call] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1674) str = Marshal::dump(DRbObject.new(obj)) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # end [ call] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) [str.size].pack('n') + str [ return] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) end [ call] send_request DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:597) [ call] drbref DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1058) [ return] drbref DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1060) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ return] send_request DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:609) [ return] send_request DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:907) [ call] recv_reply DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:920) [ call] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) [ return] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) [ call] recv_reply DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:631) [ call] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:564) [ call] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:29) [ return] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:30) [ return] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:565) [ call] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:564) [ call] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:29) [ return] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:30) [ return] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:565) [ return] recv_reply DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:632) [ return] recv_reply DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:922) [ return] send_message DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1194) [ call] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:132) [ call] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:97) [ return] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:98)

(Marshal crash course) >> class Foo; def initialize(x); @x = x; end; end => nil >> f = Foo.new("a value") => #<Foo:0x4bd20 @x="a value"> >> dump = Marshal::dump(f) => "\004\bo:\bFoo\006:\a@x\"\fa value" >> f = nil => nil >> g = Marshal::load(dump) => #<Foo:0x19e88 @x="a value"> >> g => #<Foo:0x19e88 @x="a value">

DRb? => #<DRb::DRbObject:0x53d66c @ref=nil, @uri="druby://127.0.0.1:6666"> >> enable_trace # set_trace_func{...} Enabling method tracing with event regex /^(call return)/ and class exclusion regex /IRB Wirble RubyLex RubyToken/ [ return] enable_trace Object (/Users/johan/.irbrc:67) => nil >> obj.size [ call] method_missing DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1077) [ call] here? DRb (/opt/local/lib/ruby/1.8/drb/drb.rb:1674) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # [ call] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) [ return] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) [ call] send_request DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:597) [ call] drbref DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1058) [ return] drbref DRb::DRbObject (/opt/local/lib/ruby/1.8/drb/drb.rb:1060) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ call] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:554) [ return] dump DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:555) [ return] send_request DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:609) [ return] send_request DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:907) [ call] recv_reply DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:920) [ call] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) [ return] stream DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:902) [ call] recv_reply DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:631) [ call] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:564) [ call] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:29) [ return] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:30) [ return] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:565) [ call] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:564) [ call] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:29) [ return] exclusive Thread (/opt/local/lib/ruby/1.8/thread.rb:30) [ return] load DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:565) [ return] recv_reply DRb::DRbMessage (/opt/local/lib/ruby/1.8/drb/drb.rb:632) [ return] recv_reply DRb::DRbTCPSocket (/opt/local/lib/ruby/1.8/drb/drb.rb:922) [ return] send_message DRb::DRbConn (/opt/local/lib/ruby/1.8/drb/drb.rb:1194) [ call] synchronize Mutex (/opt/local/lib/ruby/1.8/thread.rb:132) [ call] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:97) [ return] lock Mutex (/opt/local/lib/ruby/1.8/thread.rb:98) >> obj = DRbObject.new_with_uri(uri)

DRb Exempel Redux # Client require "drb" #... DRb.start_service # Initiera DRb uri = "druby://127.0.0.1:6666" # Server URI att connecta till obj = DRbObject.new_with_uri(uri) # Nytt DRbObject ifrån uri obj.size #=> 5 # Vår Array finns tillgänglig över DRb! obj.last #=> "Five" obj.map{ v v+v } #=> [2, 4, 6, "fourfour", "FiveFive"]

Remote Method Invocation Client Marshal method arguments Send message to server Reference, method name, arguments Server Receive message Unmarshal arguments Find local object from reference Invoke method with arguments

DRbUndumped Utan DRbUndumped Pass by value Måste dela kod Med DRbUndumped included Pass by reference (ingen Marshalling) Måste inte dela kod require "drb" class Foo include DRbUndumped #... end obj = [1,2,3] obj.extend DRb::DRbUndumped

Varför bruke DRbUndumped? Stora objekt Singleton objekt kan brukes Mindre/ tunna klienter Inget behov av att hålla klassar i synk

Sockets TCP Sockets ( druby://127.0.0.1:6661 ) Unix socket ( drbunix:///tmp/foo.sock ) SSL socket ( drbssl://127.0.0.1:6661 +.pem cert)

DRb sikkerhet Går ikke helt ACL Ruby s $SAFE level default_load_limit SSL Firewall, user permissions

ACL Exempel require "drb" require "drb/acl" acl = ACL.new %w[ deny all allow 127.0.0.1 ] DRb.install_acl(acl) DRb.start_service # blabla..

DRb med Rails Enkelt! Bra att få tunga ting ut ifrån Rails Backgroundrb

Backgroundrb http://backgroundrb.rubyforge.org/ BackgrounDRb is a ruby job server and scheduler. It main intent is to be used with Ruby on Rails applications for offloading long running tasks. Since a rails application blocks while servicing a request it is best to move long running tasks off into a background process that is divorced from the http request/ response cycle. Rails plugin, queue+workers baserat SomeWorkerClass#do_work

Bingo! Disk in the sky

Bingo! En frontend app (www.bingodisk.com) X antal bingo nodes (diskservrar), tex johan.bingodisk.com, som kontaktas via DRb

Bingo! # Pseudo code* # The rails app @customer.server = Server.find_least_utilitized @customer.server.setup_customer! class Server < ActiveRecord::Base def setup_customer! node_system = Bingo::Node.new(Conf.node_config) node_system.setup_on_node(self, self.customer) end end # node daemon (a DRb server) class Bingo::Node def initialize(config) # Hook up DRbconnection etc # from config values end def setup_on_node(server, customer) # create ZFS filesystem # config something #... end end [* actual production code is quite different, but follows the same overall concept]

Bingo! Deux Varje node måste parsa en stor loggfil ca. 150 gångar om dagen Ruby fint* * Men treegt Green threads, inte äkta threads Distribuera workload med DRb!

Bingo! Deux Node Hey, do this job whenever Master Job Queue

Bingo! Deux Node Hey, do this job whenever Master Job Queue Worker Worker Worker Worker Worker Worker Worker Worker

Bingo! Deux Node Hey, do this job whenever Master Job Queue OK, whatever dude, one of these guys can do it Worker Worker Worker Worker Worker Worker Worker Worker

Bingo! Deux Med Ruby s Threads Ruby Thread.new{Worker} Thread.new{Worker} Thread.new{Worker} Thread.new{Worker} Thread.new{Worker} Thread.new{Worker} Thread.new{Worker} Thread.new{Worker} CPU1 *zzzz* *zzzz* *zzzz* CPU2 CPU3 CPU4

Bingo! Deux Master Job Queue DRb Worker Worker Worker Worker Worker Worker Worker Worker CPU1 CPU2 CPU3 CPU4

Bingo! Deux Worker Worker Worker Worker Worker Worker Worker Worker SERVER1 SERVER2 SERVER3 SERVER4

Bingo! Deux from future import yagni DATACENTER 1 DATACENTER 2 Worker Worker Worker Worker Worker Worker Worker Worker SERVER1 SERVER2 SERVER3 SERVER4

... Heeeey! Distributed programming (med ruby!)

Rinda Ruby s Linda TupleSpace (delat object space) RingServer (zeroconf/bonjour for ruby)

Rinda Tuplespaces & RingServer Distribuerat whiteboard En tjänst lägger sig till på whiteboardet, säger vad den har, och whiteboardet vet om dens IP etc En klient frågar efter en tjänst på whiteboardet och får tillbaka dens IP+port klienten blir automagiskt kopplat till tjänsten

Rinda::TupleSpace En klient läggar till sina objekt på ett whiteboard och läsa/skriva/ta dom Tuple: [:name, class, (DRb)Object, note ] Brukar === Matchar tuples med Regexp, Class===Class, #value === value ts#read(tmpl), ts#read_all(tmpl), ts#write(), ts#take(tmpl)

Rinda::TupleSpace # server.rb require "drb" require "rinda/tuplespace" ts = Rinda::TupleSpace.new # share the ts over DRb DRb.start_service("druby://127.0.0.1:6661", ts) DRb.thread.join # client.rb # adds to the tuplespace require "drb" require "rinda/tuplespace" require "pp" # connect to the tuplespace DRb.start_service tuplespace = Rinda::TupleSpaceProxy.new( DRbObject.new_with_uri("druby://127.0.0.1:6661") ) tuplespace.write([0, "Note", "first ts entry"]) tuplespace.write([1, "Note", "second ts entry"]) tuplespace.write([2, "Note", "third ts entry"]) #client_reader.rb # reads from the tuplespace require "drb" require "rinda/tuplespace" DRb.start_service tuplespace = Rinda::TupleSpaceProxy.new( DRbObject.new_with_uri("druby://127.0.0.1:6661") ) # grab all the notes, matching them against the Range while note = tuplespace.take([nil, nil, /^[^READ]/]) puts note.inspect # write it back into the tuplespace tuplespace.write([note.first, note[1], "READ -- #{note.last}"]) end

Rinda::TupleSpace # server.rb require "drb" require "rinda/tuplespace" ts = Rinda::TupleSpace.new # share the ts over DRb DRb.start_service("druby://127.0.0.1:6661", ts) DRb.thread.join # client.rb # adds to the tuplespace require "drb" require "rinda/tuplespace" require "pp" # connect to the tuplespace DRb.start_service tuplespace = Rinda::TupleSpaceProxy.new( DRbObject.new_with_uri("druby://127.0.0.1:6661") ) tuplespace.write([0, "Note", "first ts entry"]) tuplespace.write([1, "Note", "second ts entry"]) tuplespace.write([2, "Note", "third ts entry"]) #client_reader.rb # reads from the tuplespace require "drb" require "rinda/tuplespace" DRb.start_service tuplespace = Rinda::TupleSpaceProxy.new( DRbObject.new_with_uri("druby://127.0.0.1:6661") ) # grab all the notes, matching them against the Range while note = tuplespace.take([nil, nil, /^[^READ]/]) puts note.inspect # write it back into the tuplespace tuplespace.write([note.first, note[1], "READ -- #{note.last}"]) end

Rinda::TupleSpace # server.rb require "drb" require "rinda/tuplespace" ts = Rinda::TupleSpace.new # share the ts over DRb DRb.start_service("druby://127.0.0.1:6661", ts) DRb.thread.join # client.rb # adds to the tuplespace require "drb" require "rinda/tuplespace" require "pp" # connect to the tuplespace DRb.start_service tuplespace = Rinda::TupleSpaceProxy.new( DRbObject.new_with_uri("druby://127.0.0.1:6661") ) tuplespace.write([0, "Note", "first ts entry"]) tuplespace.write([1, "Note", "second ts entry"]) tuplespace.write([2, "Note", "third ts entry"]) #client_reader.rb # reads from the tuplespace require "drb" require "rinda/tuplespace" DRb.start_service tuplespace = Rinda::TupleSpaceProxy.new( DRbObject.new_with_uri("druby://127.0.0.1:6661") ) $ ruby client_reader.rb [0, "Note", "first ts entry"] [1, "Note", "second ts entry"] [2, "Note", "third ts entry"] # grab all the notes, matching them against the Range while note = tuplespace.take([nil, nil, /^[^READ]/]) puts note.inspect # write it back into the tuplespace tuplespace.write([note.first, note[1], "READ -- #{note.last}"]) end

Rinda::RingServer # rinda_server.rb require "rinda/ring" require "rinda/tuplespace" DRb.start_service # Ett TupleSpace som innehåller namngivna tjänster Rinda::RingServer.new(Rinda::TupleSpace.new) DRb.thread.join # sharing_a_tuplespace.rb require "rinda/ring" require "rinda/tuplespace" DRb.start_service ring_server = Rinda::RingFinger.primary # finds our "primary" RingServer # Dela ut vårat tuplespace # SimpleRenewer är en enkel Renewer some anger hur ofta den ska cheka om tjänsten ever ring_server.write([:name, :TupleSpace, Rinda::TupleSpace.new], 'Tuple Space', Rinda::SimpleRenewer.new) # using_the_tuplespace.rb require "rinda/ring" require "rinda/tuplespace" DRb.start_service ring_server = Rinda::RingFinger.primary # Ask the RingServer for our TupleSpace ts_service = rinda_server.read[:name, :TupleSpace, nil, nil][2] # [2] är vårt DRbObject ts = Rinda::TupleSpaceProxy.new(ts_service) ts.write([:data, rand(100)]) puts "data is #{ts.read([:data,nil].last)}" # => data is 62

Starfish gem install starfish MapReduce for Ruby folk dvs. nok till att få jobben gjort

Starfish User.find(:all, :conditions => opt_out=0 ).each{ user user.calculate_solution_to_life }

Starfish User.find(:all, :conditions => opt_out=0 ).each{ user user.calculate_solution_to_life } # user_solution.rb require 'config/environment' require 'user' server do map_reduce map_reduce.type = User map_reduce.conditions = "opt_out = 0" end client do user user.calculate_solution_to_life end

Starfish User.find(:all, :conditions => opt_out=0 ).each{ user user.calculate_solution_to_life } # user_solution.rb require 'config/environment' require 'user' server do map_reduce map_reduce.type = User map_reduce.conditions = "opt_out = 0" end client do user user.calculate_solution_to_life end my_computer$ starfish user_solution.rb my_computer$ starfish user_solution.rb my_computer$ starfish user_solution.rb my_computer$ starfish user_solution.rb bobs_computer$ starfish user_solution.rb moms_old_scrapyard$ starfish user_solution.rb the_mainframe_at_work$ starfish user_solution.rb

The End http://segment7.net/projects/ruby/drb/rinda/ringserver.html http://blog.segment7.net/articles/2006/04/22/drb-an-introduction-andoverview http://www.ruby-doc.org/stdlib/libdoc/drb/rdoc/index.html http://www2a.biglobe.ne.jp/~seki/ruby/druby.html Ruby tarball: drb/samples/ http://tech.rufy.com/2006/08/mapreduce-for-ruby-ridiculously-easy.html http://www.chadfowler.com/ruby/drb.html