1 / 28

Type-safe Communication in Java with Session Types

Type-safe Communication in Java with Session Types. Raymond Hu Draft Transfer Report, June 2007. June 2007. Overview (1). Motivation. Theoretical Background. Related Work. Problem Outline. Worked Example: Session Programming. Runtime Support for Session Communication. Results.

Download Presentation

Type-safe Communication in Java with Session Types

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Type-safe Communication in Java with Session Types Raymond Hu Draft Transfer Report, June 2007 June 2007

  2. Overview (1) • Motivation. • Theoretical Background. • Related Work. • Problem Outline. • Worked Example: Session Programming. • Runtime Support for Session Communication. • Results. • Conclusion. • 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) • 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, distributed language. Theoretical Background

  4. Implementation of Session Types • Singularity OS: • Restricted features, not distributed. • Multithreaded functional language design [VGR06]: • Not distributed, no actual implementation. • Encodings of sess. types (e.g. Haskell [NT04], C++): • Proof of concept, but not full implementations. • Why use untyped sockets if we can use sessions? Related Work

  5. Problem Outline • Implementation of a practical, distributed language. • Language usability (endpoint abstraction, syntax, …). • Distributed environment. • Session interleaving. • Exceptions/failure. • The work involved: • Language design. • Compiler implementation (Polyglot). • Runtime support for session communication. • Session type information used at runtime to coordinate sessions. Problem Outline

  6. Overview (2) • Motivation. • Theoretical Background. • Related Work. • Problem Outline. • Worked Example: Language Design. • Runtime Support for Session Communication. • Results. • Conclusion. • Future Work. Overview

  7. An Online Ticket Ordering System Worked Example: Session Programming

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

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

  10. protocolp_ca{ begin. ![ !(String). ?(Double) ]*. … // Customer STSocket s_ca = STSocketImpl.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){ } cost = s_ca.receive(); Worked Example: Session Programming

  11. !{ 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

  12. Overview (3) • Motivation. • Theoretical Background. • Related Work. • Problem Outline. • Worked Example: Language Design. • Runtime Support for Session Communication. • Results. • Conclusion. • Future Work. Overview

  13. Sessions over TCP Runtime Support for Session Communication

  14. Session Initiation • C → A : Type of intended session. • A → C: “YES” if types compatible, else “NO”. Runtime Support for Session Communication

  15. Session Communication Runtime Support for Session Communication

  16. Session Iteration Runtime Support for Session Communication

  17. Session Delegation (1) Runtime Support for Session Communication

  18. Session Delegation (2) ← 3. 1. ← 2. • S: Create server socket on port. • S → A: port • A → C: IPS, port,STA(sca) Runtime Support for Session Communication

  19. Session Delegation (3) 5. delivAddr ← • C: Connect to IPS: port. • C → S: “Lost messages” according toSTA(sca) - STC(sca). Runtime Support for Session Communication

  20. Simultaneous Delegation C → A: STC(sca) A → C: STA(sca) C → S: STA(sca) - STC(sca) Runtime Support for Session Communication

  21. Overview (4) • Motivation. • Theoretical Background. • Related Work. • Problem Outline. • Worked Example: Language Design. • Runtime Support for Session Communication. • Results. • Conclusion. • Future Work. Overview

  22. Preliminary Results (1) • For simple benchmark experiment, implemented: begin . ![ ?( MyObject) ]* . end • Using: • STSocket and equivalent “Plain Socket” • STNIOSocket and equivalent “Plain SocketChannel” • RMI: MyObject remoteMeth(Boolean bool) Results

  23. Preliminary Results (2) Results

  24. Preliminary Results (3) Results

  25. Conclusion • http://www/~rh105/sessiondj.html • Realised many session type principles in a concrete, practical object-oriented language. • Distribution and asynchrony. • Session interleaving, exceptions/failure. • Protocols for session initiation, delegation and close. • Delegation protocol uses session type information. • ICOOOLPS (ECOOP) 2007. Conclusion

  26. Future Work • Usability improvements (syntax, features, ...). • Communication optimisations. • Large example applications. • Associating session types to addresses. • Class downloading and verification (… - July/Aug). • Session exceptions (Aug - Sept). • Theory work (Oct - Dec). • Alternative runtime designs. • Sessions over alternative transports. Future Work

  27. Putting Customer Together protocol p_ca{…} STSocket s_ca = STSocketImpl.create(p_ca); s_ca.request(Agency, port); s_ca.outwhile(…){ … } … catch(STIncompatibleSessionException ise){ … } catch(IOException ioe){ … } finally{ s_ca.close(); } try{ } Worked Example: Session Programming

  28. Session Exceptions (Poss. Design) protocol p {begin.….end | X:….end | … } STChannelc = newSTChannel(…, p); STSocket s = STSocketImpl.create(c); try{ try{ s.request(); … } catch(STIncompatibleSessionException ise) { } catch(s:X){ … } catch(…){ … } } catch(IOException ioe){ … } finally{ s.close(); } Future Work

More Related