Session-based Distributed Programming in Java - PowerPoint PPT Presentation

session based distributed programming in java n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Session-based Distributed Programming in Java PowerPoint Presentation
Download Presentation
Session-based Distributed Programming in Java

play fullscreen
1 / 83
Session-based Distributed Programming in Java
80 Views
Download Presentation
hila
Download Presentation

Session-based Distributed Programming in Java

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Session-based Distributed Programming in Java Raymond Hu1, Nobuko Yoshida1 and Kohei Honda2 1. Imperial College London; 2. Queen Mary, Uni. of London February 2008

  2. Overview (1) • Background and Related Work. • Worked Example: Session Programming in SJ. • The SJ Session Runtime. • Conclusion and Future Work. Overview

  3. Session Types • Type systems for process calculi: • Takeuchi et al. An Interaction-based Language and its Typing System. (1994) • Honda et al. Language Primitives and Type Discipline for Structured Comm… (1998) • Gay and Hole. Subtyping for Session Types in the Pi Calculus. (1999) • Hole and Gay. Bounded Polymorphism in Session Types. (2003) Theoretical Background

  4. Session Types • Type systems for process calculi: • Takeuchi et al. An Interaction-based Language and its Typing System. (1994) • Honda et al. Language Primitives and Type Discipline for Structured Comm… (1998) • Gay and Hole. Subtyping for Session Types in the Pi Calculus. (1999) • Hole and Gay. Bounded Polymorphism in Session Types. (2003) • Session types for object calculi: • Dezani-Ciancaglini et al. A distributed Object-oriented Language with Session... (2005) • Dezani-Ciancaglini et al. Session Types for Object-oriented Languages. (2006) • Dezani-Ciancaglini et al. Bounded Session Types for Object-oriented Languages. (2007) • Coppo et al. Asynchronous Session Types and Progress for Object-oriented... (2007) Theoretical Background

  5. Session Types • Type systems for process calculi: • Takeuchi et al. An Interaction-based Language and its Typing System. (1994) • Honda et al. Language Primitives and Type Discipline for Structured Comm… (1998) • Gay and Hole. Subtyping for Session Types in the Pi Calculus. (1999) • Hole and Gay. Bounded Polymorphism in Session Types. (2003) • Session types for object calculi: • Dezani-Ciancaglini et al. A distributed Object-oriented Language with Session... (2005) • Dezani-Ciancaglini et al. Session Types for Object-oriented Languages. (2006) • Dezani-Ciancaglini et al. Bounded Session Types for Object-oriented Languages. (2007) • Coppo et al. Asynchronous Session Types and Progress for Object-oriented... (2007) • Implementation of a practical and distributed language. Theoretical Background

  6. Implementation of Session Types • Singularity OS [FAHHHLL06]: • Restrictions on session features, not distributed. Related Work

  7. Implementation of Session Types • Singularity OS [FAHHHLL06]: • Restrictions on session features, not distributed. • Multithreaded functional language design [VGR06]: • Not distributed, no actual implementation. Related Work

  8. Implementation of Session Types • Singularity OS [FAHHHLL06]: • Restrictions on session features, not distributed. • Multithreaded functional language design [VGR06]: • Not distributed, no actual implementation. • Encodings of sess. types (e.g. Haskell [NT04], C++): • Demonstrate S.T. ideas, but not full implementations. Related Work

  9. Implementation of Session Types • Singularity OS [FAHHHLL06]: • Restrictions on session features, not distributed. • Multithreaded functional language design [VGR06]: • Not distributed, no actual implementation. • Encodings of sess. types (e.g. Haskell [NT04], C++): • Demonstrate S.T. ideas, but not full implementations. • Why use “untyped” sockets if we can use sessions? Related Work

  10. Overview (2) • Background and Related Work. • Worked Example: Session Programming in SJ. • The SJ Session Runtime. • Conclusion and Future Work. Overview

  11. An Online Ticket Ordering System Worked Example: Session Programming in SJ

  12. begin Protocol Specification (1) Worked Example: Session Programming in SJ

  13. begin. !(String) Protocol Specification (1) Worked Example: Session Programming in SJ

  14. begin. !(String). ?(Double) Protocol Specification (1) Worked Example: Session Programming in SJ

  15. begin. !(String). ?(Double) Protocol Specification (1) ![ ]*. … Worked Example: Session Programming in SJ

  16. begin. ?[ ?(String). !(Double) ]*. … begin. !(String). ?(Double) Protocol Specification (1) ![ ]*. … Worked Example: Session Programming in SJ

  17. Protocol Specification (2) … ?{ }. … Worked Example: Session Programming in SJ

  18. Protocol Specification (2) … ACCEPT: … , REJECT: … ?{ }. … Worked Example: Session Programming in SJ

  19. Protocol Specification (3) protocol p_as { } Worked Example: Session Programming in SJ

  20. Protocol Specification (3) protocol p_as { } begin. !( ) Worked Example: Session Programming in SJ

  21. Protocol Specification (3) ?(Address).!(Date) protocol p_as { } begin. !( ) Worked Example: Session Programming in SJ

  22. protocolp_ca{ begin. ![ !(String). ?(Double) ]*. … // Customer SJSocket s_ca = SJSocketImpl.create(p_ca); Protocol Implementation (1) Worked Example: Session Programming in SJ

  23. protocolp_ca{ begin. ![ !(String). ?(Double) ]*. … // Customer SJSocket s_ca = SJSocketImpl.create(p_ca); s_ca.request(Agency, port); Protocol Implementation (1) Worked Example: Session Programming in SJ

  24. protocolp_ca{ begin. ![ !(String). ?(Double) ]*. … // Customer SJSocket s_ca = SJSocketImpl.create(p_ca); s_ca.request(Agency, port); Protocol Implementation (1) s_ca.outwhile(!decided){ } Worked Example: Session Programming in SJ

  25. protocolp_ca{ begin. ![ !(String). ?(Double) ]*. … // Customer SJSocket s_ca = SJSocketImpl.create(p_ca); s_ca.request(Agency, port); s_ca.send(travDetails); Protocol Implementation (1) s_ca.outwhile(!decided){ } Worked Example: Session Programming in SJ

  26. protocolp_ca{ begin. ![ !(String). ?(Double) ]*. … // Customer SJSocket s_ca = SJSocketImpl.create(p_ca); s_ca.request(Agency, port); s_ca.send(travDetails); cost = (Double)s_ca.receive(); decided = …; Protocol Implementation (1) s_ca.outwhile(!decided){ } Worked Example: Session Programming in SJ

  27. protocolp_ca{ begin. ![ !(String). ?(Double) ]*. … // Customer SJSocket s_ca = SJSocketImpl.create(p_ca); s_ca.request(Agency, port); s_ca.send(travDetails); decided = …; Protocol Implementation (1) s_ca.outwhile(!decided){ } cost = s_ca.receive(); Worked Example: Session Programming in SJ

  28. !{ ACCEPT: … , // 1 REJECT: … // 2 } … // Customer s_ca.select(ACCEPT){ … // 1 } Protocol Implementation (2) Worked Example: Session Programming in SJ

  29. !{ ACCEPT: … , // 1 REJECT: … // 2 } … // Customer s_ca.select(ACCEPT){ … // 1 } Protocol Implementation (2) if(cost < 100.00){ } else{ } Worked Example: Session Programming in SJ

  30. !{ ACCEPT: … , // 1 REJECT: … // 2 } … // Customer s_ca.select(ACCEPT){ … // 1 } s_ca.select(REJECT){ …// 2 } Protocol Implementation (2) if(cost < 100.00){ } else{ } Worked Example: Session Programming in SJ

  31. ?{ ACCEPT: … , // 1’ REJECT: … // 2’ } … // Agency Protocol Implementation (3) … s_ac.branch(){ } Worked Example: Session Programming in SJ

  32. ?{ ACCEPT: … , // 1’ REJECT: … // 2’ } … // Agency case ACCEPT: { … // 1’ } case REJECT: { … // 2’ } Protocol Implementation (3) … s_ac.branch(){ } Worked Example: Session Programming in SJ

  33. Putting Customer Together protocol p_ca{…} Worked Example: Session Programming in SJ

  34. Putting Customer Together protocol p_ca{…} SJSocket s_ca = SJSocketImpl.create(p_ca); Worked Example: Session Programming in SJ

  35. Putting Customer Together protocol p_ca{…} SJSocket s_ca = SJSocketImpl.create(p_ca); s_ca.request(Agency, port); s_ca.outwhile(…){ … } … Worked Example: Session Programming in SJ

  36. Putting Customer Together protocol p_ca{…} SJSocket s_ca = SJSocketImpl.create(p_ca); s_ca.request(Agency, port); s_ca.outwhile(…){ … } … try(s_ca){ } Worked Example: Session Programming in SJ

  37. Putting Customer Together protocol p_ca{…} SJSocket s_ca = SJSocketImpl.create(p_ca); s_ca.request(Agency, port); s_ca.outwhile(…){ … } … catch(SJIOException ioe){ … } try(s_ca){ } Worked Example: Session Programming in SJ

  38. Putting Customer Together protocol p_ca{…} SJSocket s_ca = SJSocketImpl.create(p_ca); s_ca.request(Agency, port); s_ca.outwhile(…){ … } … catch(SJIncompatibleSessionException ise){ … } catch(SJIOException ioe){ … } try(s_ca){ } Worked Example: Session Programming in SJ

  39. Putting Customer Together protocol p_ca{…} SJSocket s_ca = SJSocketImpl.create(p_ca); s_ca.request(Agency, port); s_ca.outwhile(…){ … } … catch(SJIncompatibleSessionException ise){ … } catch(SJIOException ioe){ … } finally{ … // Session socket ‘s_ca’ is closed. } try(s_ca){ } Worked Example: Session Programming in SJ

  40. Overview (3) • Background and Related Work. • Worked Example: Session Programming in SJ • The SJ Session Runtime. • Conclusion and Future Work. Overview

  41. General Framework The SJ Session Runtime

  42. Session Runtime Architecture

  43. Sessions over TCP (1) • Map session operations to Socket communications. • Distributed interaction. • Preserve asynchrony. The SJ Session Runtime

  44. Session Initiation (1) The SJ Session Runtime

  45. Session Initiation (2) • C → A : Type of session expected by C. • | A → C : Type of session expected by A. The SJ Session Runtime

  46. Basic Message Passing The SJ Session Runtime

  47. Sessions over TCP (2) • Map session operations to Socket communications. • Distributed communication. • Preserve asynchrony. • Interesting case is delegation. The SJ Session Runtime

  48. “Lost Messages” (1) The SJ Session Runtime

  49. “Lost Messages” (2) The SJ Session Runtime

  50. Sessions over TCP (3) • Map session operations to Socket communications. • Distributed communication. • Preserve asynchrony. • Interesting case is delegation. • Possible designs: • Indefinite forwarding (cf. MobileIP). The SJ Session Runtime