Presentation is loading. Please wait.

Presentation is loading. Please wait.

Session-based Distributed Programming in Java Raymond Hu 1 Session-based Distributed Programming in Java Raymond Hu 1, Nobuko Yoshida 1 and Kohei Honda.

Similar presentations


Presentation on theme: "Session-based Distributed Programming in Java Raymond Hu 1 Session-based Distributed Programming in Java Raymond Hu 1, Nobuko Yoshida 1 and Kohei Honda."— Presentation transcript:

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

2 Session-based Distributed Programming in Java Raymond Hu 2 Overview (1) 1.Background and Related Work. 2.Worked Example: Session Programming in SJ. 3.The SJ Session Runtime. 4.Conclusion and Future Work. Overview

3 Session-based Distributed Programming in Java Raymond Hu 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-based Distributed Programming in Java Raymond Hu 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-based Distributed Programming in Java Raymond Hu 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 Session-based Distributed Programming in Java Raymond Hu 6 Implementation of Session Types Singularity OS [FAHHHLL06]: –Restrictions on session features, not distributed. Related Work

7 Session-based Distributed Programming in Java Raymond Hu 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 Session-based Distributed Programming in Java Raymond Hu 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 Session-based Distributed Programming in Java Raymond Hu 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 Session-based Distributed Programming in Java Raymond Hu 10 Overview (2) 1.Background and Related Work. 2.Worked Example: Session Programming in SJ. 3.The SJ Session Runtime. 4.Conclusion and Future Work. Overview

11 Session-based Distributed Programming in Java Raymond Hu 11 An Online Ticket Ordering System Worked Example: Session Programming in SJ

12 Session-based Distributed Programming in Java Raymond Hu 12 Protocol Specification (1) begin Worked Example: Session Programming in SJ

13 Session-based Distributed Programming in Java Raymond Hu 13 Protocol Specification (1) begin. !(String) Worked Example: Session Programming in SJ

14 Session-based Distributed Programming in Java Raymond Hu 14 Protocol Specification (1) begin. !(String). ?(Double) Worked Example: Session Programming in SJ

15 Session-based Distributed Programming in Java Raymond Hu 15 Protocol Specification (1) begin. !(String). ?(Double) ![ ]*. … Worked Example: Session Programming in SJ

16 Session-based Distributed Programming in Java Raymond Hu 16 Protocol Specification (1) begin. ?[ ?(String). !(Double) ]*. … begin. !(String). ?(Double) ![ ]*. … Worked Example: Session Programming in SJ

17 Session-based Distributed Programming in Java Raymond Hu 17 Protocol Specification (2) … ?{ }. … Worked Example: Session Programming in SJ

18 Session-based Distributed Programming in Java Raymond Hu 18 Protocol Specification (2) … ACCEPT: …, REJECT: … ?{ }. … Worked Example: Session Programming in SJ

19 Session-based Distributed Programming in Java Raymond Hu 19 Protocol Specification (3) protocol p_as { } Worked Example: Session Programming in SJ

20 Session-based Distributed Programming in Java Raymond Hu 20 Protocol Specification (3) protocol p_as { } begin. !( ) Worked Example: Session Programming in SJ

21 Session-based Distributed Programming in Java Raymond Hu 21 Protocol Specification (3) ?(Address).!(Date) protocol p_as { } begin. !( ) Worked Example: Session Programming in SJ

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

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

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

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

26 Session-based Distributed Programming in Java Raymond Hu 26 Protocol Implementation (1) protocol p_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 = …; s_ca.outwhile(!decided) { } Worked Example: Session Programming in SJ

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

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

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

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

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

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

33 Session-based Distributed Programming in Java Raymond Hu 33 Putting Customer Together protocol p_ca { … } Worked Example: Session Programming in SJ

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

35 Session-based Distributed Programming in Java Raymond Hu 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 Session-based Distributed Programming in Java Raymond Hu 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 Session-based Distributed Programming in Java Raymond Hu 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) { … } Worked Example: Session Programming in SJ try (s_ca) { }

38 Session-based Distributed Programming in Java Raymond Hu 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) { … } Worked Example: Session Programming in SJ try (s_ca) { }

39 Session-based Distributed Programming in Java Raymond Hu 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. } Worked Example: Session Programming in SJ try (s_ca) { }

40 Session-based Distributed Programming in Java Raymond Hu 40 Overview (3) 1.Background and Related Work. 2.Worked Example: Session Programming in SJ 3.The SJ Session Runtime. 4.Conclusion and Future Work. Overview

41 Session-based Distributed Programming in Java Raymond Hu General Framework 41 The SJ Session Runtime

42 Session-based Distributed Programming in Java Raymond Hu Session Runtime Architecture 42

43 Session-based Distributed Programming in Java Raymond Hu 43 Sessions over TCP (1) Map session operations to Socket communications. –Distributed interaction. –Preserve asynchrony. The SJ Session Runtime

44 Session-based Distributed Programming in Java Raymond Hu Session Initiation (1) 44 The SJ Session Runtime

45 Session-based Distributed Programming in Java Raymond Hu 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 Session-based Distributed Programming in Java Raymond Hu Basic Message Passing 46 The SJ Session Runtime

47 Session-based Distributed Programming in Java Raymond Hu 47 Sessions over TCP (2) Map session operations to Socket communications. –Distributed communication. –Preserve asynchrony.  Interesting case is delegation. The SJ Session Runtime

48 Session-based Distributed Programming in Java Raymond Hu 48 “Lost Messages” (1) The SJ Session Runtime

49 Session-based Distributed Programming in Java Raymond Hu 49 “Lost Messages” (2) The SJ Session Runtime

50 Session-based Distributed Programming in Java Raymond Hu 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

51 Session-based Distributed Programming in Java Raymond Hu 51 Sessions over TCP (3) Map session operations to Socket communications. –Distributed communication. –Preserve asynchrony.  Interesting case is delegation.  Possible designs: ×Indefinite forwarding (cf. MobileIP).  “Lost message” resending. The SJ Session Runtime

52 Session-based Distributed Programming in Java Raymond Hu 52 Sessions over TCP (3) Map session operations to Socket communications. –Distributed communication. –Preserve asynchrony.  Interesting case is delegation.  Possible designs: ×Indefinite forwarding (cf. MobileIP).  “Lost message” resending.  “Lost message” forwarding. The SJ Session Runtime

53 Session-based Distributed Programming in Java Raymond Hu 53 Session Delegation (1) The SJ Session Runtime

54 Session-based Distributed Programming in Java Raymond Hu 54 Session Delegation (2) 1. S: Create server socket on p. The SJ Session Runtime

55 Session-based Distributed Programming in Java Raymond Hu 55 Session Delegation (3) 1. S: Create server socket on p. 2. S → A: p The SJ Session Runtime

56 Session-based Distributed Programming in Java Raymond Hu 56 Session Delegation (4) 1. S: Create server socket on p. 2. S → A: p 3. A → C: S, p, ST(A) The SJ Session Runtime

57 Session-based Distributed Programming in Java Raymond Hu 57 Forwarding 4. A → S: “Lost messages” forwarded. 5. C: Connect to S:p The SJ Session Runtime

58 Session-based Distributed Programming in Java Raymond Hu 58 Resending 4. C: Connect to S:p 5. C → S: “Lost messages” according to Session Types. The SJ Session Runtime

59 Session-based Distributed Programming in Java Raymond Hu Session Delegation (5) What if A has finished her side of the session? 59 The SJ Session Runtime

60 Session-based Distributed Programming in Java Raymond Hu Session Delegation (5) What if A has finished her side of the session? What if A is sending a session? 60 The SJ Session Runtime

61 Session-based Distributed Programming in Java Raymond Hu Session Delegation (5) What if A has finished her side of the session? What if A is sending a session? What if A is delegating the session at the same time? 61 The SJ Session Runtime

62 Session-based Distributed Programming in Java Raymond Hu Session Delegation (5) What if A has finished her side of the session? What if A is sending a session? What if A is delegating the session at the same time? Asynchronous session-send. 62 The SJ Session Runtime

63 Session-based Distributed Programming in Java Raymond Hu 63 Overview (4) 1.Background and Related Work. 2.Worked Example: Session Programming in SJ. 3.The SJ Session Runtime. 4.Conclusion and Future Work. Overview

64 Session-based Distributed Programming in Java Raymond Hu 64 Conclusion  Conclusion

65 Session-based Distributed Programming in Java Raymond Hu 65 Conclusion  Integration of session type theory and O-O for practical, type-safe session-based programming. Conclusion

66 Session-based Distributed Programming in Java Raymond Hu 66 Conclusion  Integration of session type theory and O-O for practical, type-safe session-based programming. Runtime architecture for session abstraction. Conclusion

67 Session-based Distributed Programming in Java Raymond Hu 67 Conclusion  Integration of session type theory and O-O for practical, type-safe session-based programming. Runtime architecture for session abstraction. Asynchronous communication and distribution. Conclusion

68 Session-based Distributed Programming in Java Raymond Hu 68 Conclusion  Integration of session type theory and O-O for practical, type-safe session-based programming. Runtime architecture for session abstraction. Asynchronous communication and distribution. Session subtyping, interleaving, exceptions/failure. Conclusion

69 Session-based Distributed Programming in Java Raymond Hu 69 Conclusion  Integration of session type theory and O-O for practical, type-safe session-based programming. Runtime architecture for session abstraction. Asynchronous communication and distribution. Session subtyping, interleaving, exceptions/failure. Combination of static and dynamic session types. Conclusion

70 Session-based Distributed Programming in Java Raymond Hu 70 Conclusion  Integration of session type theory and O-O for practical, type-safe session-based programming. Runtime architecture for session abstraction. Asynchronous communication and distribution. Session subtyping, interleaving, exceptions/failure. Combination of static and dynamic session types. Eager class downloading and verification. Conclusion

71 Session-based Distributed Programming in Java Raymond Hu 71 Conclusion  Integration of session type theory and O-O for practical, type-safe session-based programming. Runtime architecture for session abstraction. Asynchronous communication and distribution. Session subtyping, interleaving, exceptions/failure. Combination of static and dynamic session types. Eager class downloading and verification. Low overhead. Conclusion

72 Session-based Distributed Programming in Java Raymond Hu 72 Future Work Write more code! Future Work

73 Session-based Distributed Programming in Java Raymond Hu 73 Future Work Write more code! Usability improvements (syntax, features,...). Future Work

74 Session-based Distributed Programming in Java Raymond Hu 74 Future Work Write more code! Usability improvements (syntax, features,...). Communication optimisations. Future Work

75 Session-based Distributed Programming in Java Raymond Hu 75 Future Work Write more code! Usability improvements (syntax, features,...). Communication optimisations. Sessions over alternative transports. Future Work

76 Session-based Distributed Programming in Java Raymond Hu 76 Future Work Write more code! Usability improvements (syntax, features,...). Communication optimisations. Sessions over alternative transports. Multiparty sessions. Future Work

77 Session-based Distributed Programming in Java Raymond Hu 77 Future Work Write more code! Usability improvements (syntax, features,...). Communication optimisations. Sessions over alternative transports. Multiparty sessions. Session exceptions. Future Work

78 Session-based Distributed Programming in Java Raymond Hu 78 Future Work Write more code! Usability improvements (syntax, features,...). Communication optimisations. Sessions over alternative transports. Multiparty sessions. Session exceptions. Automatic session implementation generation. Future Work

79 Session-based Distributed Programming in Java Raymond Hu 79 Future Work Write more code! Usability improvements (syntax, features,...). Communication optimisations. Sessions over alternative transports. Multiparty sessions. Session exceptions. Automatic session implementation generation. Further integration of sessions and objects. Future Work

80 Session-based Distributed Programming in Java Raymond Hu 80 Future Work Write more code! Usability improvements (syntax, features,...). Communication optimisations. Sessions over alternative transports. Multiparty sessions. Session exceptions. Automatic session implementation generation. Further integration of sessions and objects. Future Work

81 Session-based Distributed Programming in Java Raymond Hu 81 Preliminary Results (1) For simple benchmark experiment, implemented: begin. ![ ?( MyObject ) ]*. end Results

82 Session-based Distributed Programming in Java Raymond Hu 82 Preliminary Results (1) For simple benchmark experiment, implemented: begin. ![ ?( MyObject ) ]*. end Using: –SJFSocket and SJRSocket –java.net.Socket –RMI: MyObject remoteMeth(Boolean bool) Results

83 Session-based Distributed Programming in Java Raymond Hu 83 Preliminary Results (2) Results


Download ppt "Session-based Distributed Programming in Java Raymond Hu 1 Session-based Distributed Programming in Java Raymond Hu 1, Nobuko Yoshida 1 and Kohei Honda."

Similar presentations


Ads by Google