Download presentation
Presentation is loading. Please wait.
Published byMerilyn Burns Modified over 9 years ago
1
A presentation by Robin Upton (2009-03-12) latest version at www.altruists.org/ff4 Attribution – NonCommercial - ShareAlike www.altruists.org FF 4 : Decentralised Programming with F 2 F Decentralised Programming v1.1.5 http://www.altruists.org/ff4
2
(1)Decentralised Programming. WWW as Distributed Programming C C C C C C C S distributed.net = Distributed, Centralised Calculations are performed by many CPUs, but directed by a single authority. Friend2Friend.net = Distributed, Decentralised Each computers in F2F network has unique local data & instructions. None has special privilege. F F F F F F F Distributed programs may still be centrally controlled. http://www.distributed.net
3
Sites: code data code data code data code data WWW as Distributed Programming Clients Send Data Websites have unique instructions and data stores... Clients send data to one site at a time Clients:
4
Clients Send Data. Servers Return Data Users input data through browsers and pass it to websites: decentralization
5
Servers Return Data Code ≠ Data Websites receive data, carry out instructions, return data to clients
6
Code ≠ Data 'Code' = XML = 'Data' function f2fError($text, $nodename='error') { // Example of usual source code $err= new DOMDocument(); $errnode=$err->createElementNS(nsF2F, $nodename, $text); $err->appendChild($errnode); return $err; } to be processed by trusted code. Untrusted data is dynamically input... Most programming languages cannot treat data as code.
7
'Code' = XML = 'Data' (2) How to Program F2F In F2F, programs, instructions and data share a common format: XML F2F data streams can embed instructions, allowing for rich interaction. i.e. Sites can dynamically script other sites. F2F service, coded in XML arbitrary XML...
8
(2)How to Program F2F. Hello World Service F2F servers are XML virtual machines. Input, output & internal workings are XML. Although required, the namespace is omitted for brevity from this point on. All instructions to F2F servers take the form: etc.
9
Hello-World Service. Processing Service Requests We start by requesting the service: So this is implemented by the XSL template at hello.xslt The F2F server finds the matching service definition: Unique identifier Location on disk
10
Passing Arguments The XSL transforms it to an Output Document: The itself is the script’s Input Document: Hello World! Processing Service Requests Hello World!
11
Passing Arguments Nested Servicereqs Many languages pass a comma separated list of input parameters to a function: function browse($uri, $width, $height) {...instructions here, in which $uri, $width and $height are replaced at run time by the values of the arguments given... } browse(“http://friend2friend.net”, 130, 500)http://friend2friend.net http://friend2friend.net 130 500 <!-- Transform here, which operates on the whole XML document --!> F2F passes an XML document:
12
Nested Servicereqs. Processing Directives browse(“http://friend2friend.net”, getwidth(), getheight()) By default, F2F starts with the deepest : Evaluation is usually from inside out: http://friend2friend.net 130500 130 <!-- Transform here, which gets the width. --!> <!-- Transform here, which gets the height. --!> <!-- Transform here, which operates on the whole XML document --!>
13
Nested Servicereqs = Pipelined XML A may have extra attributes, called processing directives. Processing Directives XSL stylesheet Raw XML Output Post- processed XML Output Pre- processed Input: servicereq Raw Input: servicereq http://www.altruists.org/ff6 Pre-processing directives modify the input of the stylesheet. Mid-processing & Post-processing directives modify the output. For more details, see: FF6: Common Processing Directives
14
Tree-shaped Pipelines Nested items results in pipelining XML: Nested Servicereqs = Pipelined XML The interior outputs XML......which is fed into the exterior... XSL ex.1 XSL ex.2 XML pipelining is taking the input from one transform and feeding it into another:
15
Core Services The model allows trees of transforms. Tree-shaped Pipelines XSL 2B XSL 3 3b 3a XSL 2A 3c 2b XSL 1A XSL 1B 1a 2a22a1 1b
16
Saving Instructions About 80 hardcoded (non-XSLT) services extend the possibilities. e.g: Core Services Send/Receive http://friend2friend.net/services/send http://friend2friend.net/services/receive Read/Write XML data http://friend2friend.net/services/xml-write http://friend2friend.net/services/xml-read Read/Write the F2F Server http://friend2friend.net/services/access-get http://friend2friend.net/services/access-set Read/Write Files to disk http://friend2friend.net/services/fs-read http://friend2friend.net/services/fs-write
17
Sending Instructions in the below will be interpreted -->...May contain instructions or data... //wherever.xml <servicereq Saving Instructions To write an XML file to disk: If the data above contained this would get interpreted first. //wherever.xml <servicereq To prevent descendants from being interpreted, add f2f:escaped=”!”:
18
Clientside Instructions <servicereq Sending Instructions Sending instructions to another server requires a different form of escaping: The f2f:sendescaped attribute is decreased by 1 whenever the data is sent, so: f2f:sendescaped =”1”- Run on friend's server f2f:sendescaped =”2”- Run on friend of a friend's server f2f:sendescaped =”3”- Run on friend of a friend of a friend's server...
19
Icon here XSLT Transform output here Will be transformed Summary Clientside Instructions Clients interpret, and elements......so XML can be used to script client interactivity.
20
Summary F2F scripts use XSLT, extended with about 80 extra core functions. Nested items pipeline XML data & instructions. A JS F2F client is available for Firefox. Recommended Follow-up: FF5: Service Request Processing Model http://www.altruists.org/ff5 F2F servers are general purpose XML virtual machines. F2F servers are designed to form decentralised networks....
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.