This Thesis Has Been Submitted in Fulfilment of the Requirements for a Postgraduate Degree (E.G

This Thesis Has Been Submitted in Fulfilment of the Requirements for a Postgraduate Degree (E.G

This thesis has been submitted in fulfilment of the requirements for a postgraduate degree (e.g. PhD, MPhil, DClinPsychol) at the University of Edinburgh. Please note the following terms and conditions of use: • This work is protected by copyright and other intellectual property rights, which are retained by the thesis author, unless otherwise stated. • A copy can be downloaded for personal non-commercial research or study, without prior permission or charge. • This thesis cannot be reproduced or quoted extensively from without first obtaining permission in writing from the author. • The content must not be changed in any way or sold commercially in any format or medium without the formal permission of the author. • When referring to this work, full bibliographic details including the author, title, awarding institution and date of the thesis must be given. Type-parameterized Actors and Their Supervision Jiansen HE Master of Philosophy Department of Computer Science University of Edinburgh 2014 Acknowledgements This thesis is dedicated to my parents for their endless love and support. It is also dedicated to my wife, Shiye, for her continuous encouragement during my hard times. Meeting my wife and getting married are the best two things happened to me in the past 4 years. I want to thank my supervisors, Philip Wadler, Philip Trinder and Don Sannella, for their guidance over 4 years. I am fortunate to have been supervised by them. I want to thank my examiners, Ian Stark and Kevin Hammond, for their meticulous examination and detailed suggestions that contribute to the final version of this thesis. I gratefully acknowledge the substantial help that have received from many colleagues who have shared their related results and ideas over the long period during which this thesis was in preparation. Benedict Kavanagh and Danel Ahman for continuous comments and discussions. Roland Kuhn from the Akka team for sharing deep insight of the the Akka design. The RELEASE team for giving us access to the source code of the BenchErl benchmark examples. Thomas Arts from QuviQ.com and Francesco Cesarini from Erlang Solutions for providing the Erlang source code of two examples used in their commercial training courses. Declaration I declare that this thesis was composed by myself and that the work contained therein is my own, except where explicitly stated otherwise in the text. (Jiansen HE) Table of Contents Chapter 1 Introduction 1 1.1 General Background and Motivation . .1 1.2 Contributions . .4 1.3 Thesis Outline . .6 Chapter 2 Background and Related Work 7 2.1 The Actor Programming Model . .7 2.2 The Supervision Principle . .8 2.3 Erlang and OTP Design Principles . .8 2.4 The Akka Library . 11 2.5 Essential Scala Features . 25 2.6 Other Related Work . 31 2.7 Summing Up . 40 Chapter 3 TAkka: Design and Implementation 41 3.1 TAkka Example: a String Counter . 42 3.2 Type-parameterized Actor . 44 3.3 Type-parameterized Actor Reference . 45 3.4 Type Parameterized Props . 48 3.5 Type Parameterized Actor Context . 49 3.6 Backward Compatible Behaviour Upgrade . 52 3.7 Typed Name Server . 54 3.8 Look up Typed Actor References via Actor System . 59 3.9 Supervisor Strategies . 64 3.10 Fixing The Type Pollution Problem . 67 3.11 Handling System Messages . 75 3.12 A Distributed Calculator . 79 3.13 Design Alternatives . 85 3.14 Summing Up . 87 i Chapter 4 Evolution, Not Revolution 88 4.1 TAkka Service with Akka Client . 88 4.2 Akka Service with TAkka Client . 90 Chapter 5 TAkka: Evaluation 91 5.1 Expressiveness . 91 5.2 Throughput . 99 5.3 Efficiency and Scalability . 101 5.4 Assessing System Reliability and Availability . 116 5.5 Summing Up . 124 Chapter 6 Summary and Future Work 125 6.1 Overview of Contributions . 125 6.2 Future Work . 127 6.3 Conclusion . 129 Appendix A Akka and TAkka API 130 Appendix B Scala Join (version 0.3) User Manual 132 B.1 Using the Library . 132 B.2 Implementation Details . 136 B.3 Limitations and Future Improvements . 147 ii Abstract The robustness of actor-based concurrent applications can be improved upon by (i) employing failure recovery mechanisms such as the supervision principle, or (ii) using typed messages to prevent ill-typed communication. This thesis explores to what extent the supervision principle can work with typed messages. This thesis evaluates the hypothesis by building a new li- brary called TAkka in the Scala language on top of the existing Akka library, where Akka provides supervised actors and TAkka adds typed messaging. The TAkka library mixes static and dynamic type checking to make sure that dynamically typed distributed resources and statically typed local resources have consistent types. Our notion of typed actor can publish itself as different types when used by different parties so that messages of unexpected types are prevented at the senders’ side. In TAkka, messages for supervision purposes are treated in a special way so that a supervisor can interact with child actors of different types. This thesis evaluates the TAkka library by porting 23 small and medium sized Akka applications to their TAkka equivalents. Results show that Akka programs can be gradually upgraded to TAkka equivalents with mini- mal runtime and code size overheads. Finally, TAkka includes two auxiliary libraries for reliability assessment. This thesis confirms that the supervision principle and typed messages can be merged in an actor library for building real world applications. Lay Summary A “programmer” specifies a task for a computer to perform by encoding a sequence of instructions known as a “program” or an “application”. Many modern computer application involve programs concurrently executed on one or more computers. Writing a reliable concurrent computer application is challenging to programmers due to its complexity. In practice, two methods can help the robustness of a program. The first method is to use type checking. Types specify how data should be used in programs. Type checking examines if data is used in the right manner in a program. Static type checking reports errors before a program is executed whereas dynamic type checking reports errors when it is executed. Engineering experience shows that errors are easier to be fixed if they were noticed earlier. The other method is to use a library, a collection of programs written and tested by other programmers for common programming tasks. Typically, a library encourages writing programs in certain manners. This thesis interests in a library called “Akka” which encourages “actor programming” and “supervision principle”. In actor programming, concurrent programs are coded as actors, which independently perform their own tasks and collaborate by sending messages to each other. The “supervision principle” requires that actors should be organised in a tree structure so that the failure of an actor can be recovered by its supervisor. Unfortunately, the Akka library does not check the type of messages sending to actors, resulting in potential errors otherwise can be avoided. This thesis presents the result of improving the Akka library by building a TAkka library built on top of the former. The TAkka library employs static type checking whenever applicable. and use dynamic type checking when static checking meets its limitation. It confirms that static type checking and the supervision principle works well together. Apart from the robustness gained from the supervision principle, static type checking result in additional benefits. Firstly, format of messages sent between distributed machines are checked at the earliest possibility. Secondly, typed programs are usually better structured, shorter and easier to maintain. Thirdly, a statically typed program can often be compiled to code that executes more quickly. This thesis evaluates the TAkka library by porting 23 small and medium sized Akka applications to their TAkka equivalents. Results show that Akka programs can be gradually written to TAkka equivalents with minimal runtime and code size overheads. Finally, TAkka includes two auxiliary libraries for reliability assessment. Chapter 1 Introduction This introductory chapter presents the general background that motivates solv- ing problems discussed in this thesis. It summarizes main contributions of this thesis. Finally, an overview of the thesis is given. 1.1 General Background and Motivation Building reliable distributed applications is among the most difficult tasks fac- ing programmers, and one which is becoming increasingly important due to the recent advent of web applications, cloud services, and mobile apps. Modern society relies on distributed applications which are executed on heterogeneous runtime environments, are tolerant of partial failures, and sometimes dynami- cally upgrade some of their components without affecting other parts. A distributed application typically consists of components which handle some tasks independently, while collaborating on other tasks by exchanging messages. The robustness of a distributed application, therefore, can be im- proved by (i) using a fault-tolerant design to minimise the aftermath of partial failures, or (ii) employing type checking to detect some errors, including the logic of component implementations, and communications between compo- nents. One of the most influential fault-tolerant designs is the supervision prin- ciple, proposed in the first release of the Erlang/OTP library in 1997 [Ericsson AB., 2013c]. The supervision principle states that concurrent components of an application should be encapsulated as actors, which make local decisions in re- sponse to received messages. Actors form a tree structure, where a parent node is responsible for monitoring its children and restarting them when necessary. The supervision principle is proposed to increase the robustness of applica- tions written in Erlang, a dynamically typed programming language. Erlang 1 application developers can employ the supervision principle by using related API from the Erlang/OTP library. It is reported that the supervision principle helped AXD301, an ATM (Asynchronous Transfer Mode) switch manufactured by Ericsson Telecom AB.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    165 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us