Erlang/OTP Concurrent Programming Practice

Source: Internet
Author: User
Tags stream api
Erlang/OTP concurrent programming practices
Basic Information
Original Title: Erlang and OTP in action
Author: (US) Logan, M.) Merritt (E.) (Sweden) Carlsson (R.) [Translator's profile]
Translator: Lian Cheng
Press: People's post and telecommunications Press
ISBN: 9787115285591
Mounting time:
Published on: February 1, July 2012
Start: 16
Page number: 1
Version: 1-1
Category: computer more about Erlang/OTP Concurrent Programming Practice
Introduction
Books
Computer books
Erlang/OTP concurrent programming practices focuses on Erlang development in the production environment, mainly explaining how to build stable, well-controlled, and maintainable product-level code, it has accumulated many years of practical experience from three Erlang masters.
Erlang/OTP concurrency Programming Practice is divided into three parts: the first part explains Erlang programming and OTP basics; the second part explains how to add OTP advanced features one by one in actual development to improve application, through the main project in this book-accelerating distributed cache applications for web access, the author elaborates on various skills in practice in a simple way. The third part discusses how to integrate code with other systems and users, and how to optimize the performance.
Erlang/OTP concurrent programming practices is intended for Erlang programmers and developers interested in Erlang/OTP.
Directory
Erlang/OTP concurrent programming practices
Part 1 Erlang: OTP Basics
Chapter 2 Erlang/OTP platform 2
1.1 process-based Concurrent Programming 3
1.1.1 understand concurrency 3
1.1.2 Erlang Process Model 4
1.1.3 four Process Communication Paradigms 5
1.1.4 programming with Erlang PROCESS 8
1.2 Erlang Fault-Tolerant Architecture 10
1.2.1 how the process link Works 10
1.2.2 monitoring and exit signal capture 10
1.2.3 Process Layer-based fault tolerance 12
1.3 distributed Erlang 13
1.4 Erlang runtime system and Virtual Machine 13
1.4.1 scheduler 14
1.4.2 I/O and scheduling 15
1.4.3 process isolation and garbage collector 15
1.5 functional programming: Erlang's path to life 16
1.6 Summary 16
Chapter 18 Erlang language skills 18
2.1 Erlang shell 19
2.1.1 start shell 19
2.1.2 input expression 20
2.1.3 shell function 21
2.1.4 exit shell 21
2.1.5 task control basics 22
2.2 Erlang Data Type 23
2.2.1 numeric and arithmetic operations 24
2.2.2 binary string and Bit String 25
2.2.3 atom 26
2.2.4 tuples 27
2.2.5 list 27
2.2.6 string 28
2.2.7 PID, port, and reference 29
2.2.8 regard the function as data: Fun function 30
2.2.9 comparison of terms 30
2.2.10 interpretation list 31
2.3 modules and functions 33
2.3.1 call functions in other modules (Remote Call) 33
2.3.2 functions with different elements 34
2.3.3 built-in functions and standard library module 34
2.3.4 Create module 35
2.3.5 module compilation and loading 36
2.3.6 independent compiler ERlC 37
2.3.7 evaluate the value of the compiled module and in Shell 37
2.4 matching between variables and modes 38
2.4.1 variable syntax 39
2.4.2 assign 39 values at a time
2.4.3 pattern matching: Assignment of enhanced edition 41
2.4.4 interpretation mode 42
2.5 functions and clauses 44
2.5.1 functions with side effects: text printing 44
2.5.2 use pattern matching to select 45 from multiple clauses
2.5.3 protection 46
2.5.4 mode, clause, and variable scope 47
2.6 case and if expressions 48
2.6.1 select 48 for the Boolean if-then-else branch of Erlang
2.6.2 if expression 49
2.7 fun function 49
2.7.1 fun function 49 as the alias of an existing Function
2.7.2 anonymous fun function 50
2.8 exceptions and try/catch 52
2.8.1 throw (trigger) exception 52
2.8.2 use try... catch 53
2.8.3 try... of... catch 53
2.8.4 after 54
2.8.5 obtain stack track 54
2.8.6 re-throwing exception 55
2.8.7 traditional catch 55
2.9 list speed setting 56
2.9.1 list speed structure 56
2.9.2 56 ing, filtering, and pattern matching 56
2.10 bit syntax and Bit String speed 57
2.10.1 construct bits 57
2.10.2 pattern matching in BIT syntax 58
2.10.3-Bit String speed 59
2.11 record syntax 59
2.11.1 record statement 60
2.11.2 create record 60
2.11.3 record fields and pattern matching 60
2.11.4 update record field 60
2.11.5 where should the record statement be stored? 61
2.12 preprocessing and file inclusion 61
2.12.1 macro definition and use 61
2.12.2 file contains 62
2.12.3 Conditional compilation 63
2.13 process 64
2.13.1 Process Control 64
2.13.2 message receiving and selective receiving 65
2.13.3 registration process 66
2.13.4 message delivery and signal 67
2.13.5 process dictionary 67
2.14 ETS Table 68
2.14.1 why is the ETS table designed as this 68
2.14.2 basic ETS table usage 68
2.15 use recursion instead of loop 69
2.15.1 from iteration to recursion 69
2.15.2 understand tail recursion 71
2.15.3 accumulators parameter 72
2.15.4 efficiency 72
2.15.5 tips for writing recursive functions 73
2.16 Erlang programming resources 78
Article 1 books 78
.2 online materials 79
2.17 summary 79
Chapter 2 TCP-based RPC service 80
3.1 What are you creating? 81
3.1.1 basic knowledge reminder 82
3.1.2 Basic Behavior Model 82
3.2 RPC server 85
3.2.1 typical layout of the behavior mode implementation module 85
3.2.2 module header 85
3.2.3 API segment 88
3.2.4 callback function segment 92
3.3 run RPC server 98
3.4 Test 99
3.5 Conclusion 100
Chapter 2 OTP application and monitoring mechanism 4th
4.1 OTP application 101
4.1.1 organization of OTP applications 102
4.1.2 Add metadata for the Application 103
4.1.3 application behavior mode 104
4.1.4 Summary of application structure 105
4.2 Fault Tolerance 105 with supervisors
4.2.1 implement supervisor 106
4.2.2 supervisor restart policy 107
4.2.3 write sub-process specification 108
4.3 start the application 109
4.4 generate edoc document 110
4.5 conclusion 110
Chapter 1 Use of main graphical monitoring tools 5th
5.1 appmon 112
5.1.1 appmon guis 112
5.1.2 WebTool version appmon 115
5.2 pman 116
5.3 debugger 118
5.4 table viewer TV 121
5.5 toolbar 123
5.6 Conclusion 123
Part 2 build a production system
Chapter 1 build a cache system 6th
6.1 story background 126
6.2 Cache Design 127
6.3 create basic OTP application skeleton 130
6.3.1 layout of the application directory structure: 130
6.3.2 create application metadata 130
6.3.3 implement application Behavior Model 131
6.3.4 supervisor 131
6.4 from the application skeleton to the dirty cache 133
6.4.1 compile SC _element process 134
6.4.2 implement SC _store module 138
6.4.3 build the application layer API module 142
6.5 conclusion 144
Chapter 2 log and event processing in Erlang/OTP 7th
7.1 Erlang/OTP logs 146
7.1.1 log overview 146
7.1.2 Erlang/OTP built-in Log facility 147
7.1.3 standard log function 147
7.1.4 SASL and crash report 149
7.2 use gen_event to write a Custom Event processor 153
7.2.1 gen_event behavior mode Introduction 153
7.2.2 sample event processor 154
7.2.3 handle error event 155
7.3 Add a custom event stream for simple cache 157
7.3.1 event stream API 157
7.3.2 integrate processors into simple cache 159
7.3.3 subscribe to a custom event stream 161
7.4 conclusion 162
Chapter 2 Introduction to distributed Erlang/OTP 8th
8.1 Erlang distributed infrastructure 163
8.1.1 inter-process replication 164
8.1.2 location transparency 165
8.2 nodes and clusters 166
8.2.1 node startup 166
8.2.2 node interconnection 167
8.2.3 how to locate other nodes and establish communications with the Erlang node 169
8.2.4 Magic cookie Security 170
8.2.5 message transmission between interconnected nodes: 171
8.2.6 remote shell 173
8.3 Resource probe strategy 175
8.3.1 term 175
8.3.2 arithmetic 176
8.3.3 implement resource detection application 177
8.4 conclusion 182
Chapter 1 use mnesia to add distributed support for cache 9th
9.1 distributed cache 184
9.1.1 select communication policy 184
9.1.2 synchronous and asynchronous cache 186
9.1.3 distributed table 188
9.2 using mnesia for Distributed Data Storage 189
9.2.1 create a project database 189
9.2.2 initialize database 191
9.2.3 create table 192
9.2.4 data input to the table: 195
9.2.5 perform basic query 197
9.3 mnesia-based distributed cache 199
9.3.1 replacing ETS 199 with mnesia
9.3.2 allow the cache to identify other nodes 202
9.3.3 use resource probing to locate other cache instances 205
9.3.4 dynamically copy the mnesia table 206
9.4 conclusion 209
Chapter 4 packaging, service and deployment 10th
10.1 application 210 from the System Perspective
10.1.1 structure 211
10.1.2 meta data 211
10.1.3 how the system manages running applications 212
10.2 create and release an image 213
10.2.1 publish image 213
10.2.2 prepare to release code 214
10.2.3 metadata file for image publishing 214
10.2.4 script and Startup File 216
10.2.5 System Configuration 217
10.2.6 start the target system 218
10.3 release image packaging 219
10.3.1 create and release an image package 219
10.3.2 release image package 220
10.3.3 custom release image package 222
10.4 install and publish an image 223
10.5 conclusion 223
Part 3 Integration and Improvement
Chapter 1 add HTTP interfaces to cache 11th
11.1 TCP server 226
11.1.1 design mode of efficient TCP server 227
11.1.2 construct the tcp_interface application skeleton 228
11.1.3 filling TCP server implementation logic 228
11.1.4 text protocol 231
11.1.5 text interface 232
11.2 create a new set of web interfaces 234
11.2.1 HTTP 234
11.2.2 implement a set of common web server behavior patterns 237
11.2.3 getting started with rest 248
11.2.4 use gen_web_server to implement rest protocol 249
11.3 conclusion 252
Chapter 5 integrate peripheral code with port and nif 12th
Port 12.1 and nif 254
12.1.1 normal port 255
12.1.2 chain-in Port Drive 256
12.1.3 native function (NIF) 257
12.2 use port to integrate parser 257
12.2.1 Erlang port 257
12.2.2 C port 260
12.2.3 compile and run 271
12.3 development chain-in-drive 272
12.3.1 initial recognition chain-in-type drive 273
12.3.2 C language part 274
12.3.3 compile the driver code 278
12.3.4 Erlang part of the driver 279
12.4 implement the parser as NIF 280
12.4.1 Erlang section 280 of nif
12.4.2 NIF section C code 281
12.4.3 compile and run Code 287
12.5 Conclusion 288
Chapter 2 Use jinterface to implement communication between Erlang and Java 13th
13.1 integrate in Erlang using jinterface
In Java 290
13.1.1 otpnode class 290
13.1.2 otpmbox class 291
13.1.3 Java ing for Erlang Data Structure 291
13.1.4 example: Message Processing 292 in Java
13.1.5 communications with Java nodes in Erlang 294
13.2 install and configure hbase 296
13.2.1 download and install 296
13.2.2 configure hbase 296
13.3 connecting simple cache and hbase 297
13.3.1 Erlang: SC _hbase.erl 298
13.3.2 hbaseconnector 299
13.3.3 Message Processing 301 in Java
13.3.4 hbasetask class 304
13.4 integrate hbase 306 in simple Cache
13.4.1 query 306
13.4.2 insert 307
13.4.3 Delete 307
13.5 run the integrated system 308
13.6 conclusion 310
Chapter 2 optimization and Performance 14th
14.1 how to tune performance 312
14.1.1 set the performance target to 312
14.1.2 set baseline 313
14.1.3 System Performance Analysis 313
14.1.4 determine the problem to be resolved 313
14.1.5 determination of the optimization result 313
14.2 Erlang Code Performance Analysis 314
14.2.1 use cprof to calculate 314 calls
14.2.2 use fprof to determine the execution time of 316
14.3 Erlang programming language defects 320
14.3.1 performance characteristics of basic data types 321
14.3.2 324 performance of built-in functions and operators
14.3.3 function 325
14.3.4 process 327
14.4 conclusion 329
Appendix A install Erlang 330
Appendix B list and reference transparency 332

Source of this book: China Interactive publishing network

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.