Examples of distributed computing using the L scripting language

Source: Internet
Author: User

A programming language to get people to accept the need to have a process from the understanding to use, the previous introduction of the L scripting language design ideas and the introduction of grammar may not be so intuitive,

Later I will write some examples of L scripting language for you to refer to


I'm going to write a sample of distributed computing here.

In fact, distributed computing is the decomposition of computing tasks to different computers, by multiple computers to achieve common computing tasks

Here, we need to have a manager computer, multiple worker computers

The manager assigns the task to the worker, the worker completes the calculation task to the manager, and finally the manager summarizes all the calculation results


The following example is the L scripting language workers, it constantly on a UDP port listening, if there is a calculation task sent over to calculate, and then send back the results of the calculation


#scp
Definition: string, string1, "Hello"
Definition: String, string2,
Definition: Address, addr2,127.0.0.1,27015

Definition: integer, number of bytes, 0
Definition: Network connection, CONN2,UDP
Listening: CONN2,ADDR2

Definition: function, routine
Start: function, routine
Receive: Conn2,string2
Fetch size: String, string2, number of bytes
If: Number of bytes >0, calculate: Calculation, Exp,string2
Display: Exp
Formatted: string, string1, "%s", exp
If: Number of bytes >0, send: conn2,string1
Sleeps: 1
End: function, routine

When: 1, call: function, routine



The following example is an L scripting language manager that distributes tasks to multiple workers, receives and displays the results of the calculations


#scp
Definition: function, function2, parameter calculation content, parameter remote address
Start: function, function2
Definition: string, calculation result
Definition: integer, number of bytes, 0
Definitions: integers, count,1
Definition: Network connection, CONN1,UDP
Connection: CONN1, parameter remote address
Send: conn1, parameter calculation content
Receive: CONN1, calculation results
Take size: string, calculate result, number of bytes
If: Number of bytes >0, display: calculation result
End: function, function2


Definitions: strings, mathematical calculations, "1000+999*666-98+512"
Definition: Address, addr2,127.0.0.1,27015
#定义: Address, addr3,192.168.1.101,27015
Definition: Table, table1
Insert: Table, TABLE1,ADDR2
Insert: Table, TABLE1,ADDR3


Definitions: Functions, access to table elements, element names
Start: function, Table element access
Invoke: Function, function2, mathematical calculation content, element name
End: function, Table element access


Traversal: table1, Table element access
Wait: User input, Mathematical calculation content

Examples of distributed computing using the L scripting language

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.