Structured Application Development over Wide-Area Networks



Similar documents
Workflow Patterns in Orc

Mutual Exclusion using Monitors

Section IV.1: Recursive Algorithms and Recursion Trees

Concurrent Programming

It is the thinnest layer in the OSI model. At the time the model was formulated, it was not clear that a session layer was needed.

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Chapter 6, The Operating System Machine Level

ML for the Working Programmer

Pseudo code Tutorial and Exercises Teacher s Version

Programming Database lectures for mathema

Real Time Programming: Concepts

Introduction to Parallel Programming and MapReduce

Object Oriented Software Design

Architectural Patterns (3)

Programming Exercises

Basic Programming and PC Skills: Basic Programming and PC Skills:

Lesson Objectives. To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Channel Access Client Programming. Andrew Johnson Computer Scientist, AES-SSG

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

Chapter 5. Recursion. Data Structures and Algorithms in Java

AP Computer Science Java Mr. Clausen Program 9A, 9B

Arena Tutorial 1. Installation STUDENT 2. Overall Features of Arena

IT2305 Database Systems I (Compulsory)

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Data Structures and Algorithms

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt

CSE 530A Database Management Systems. Introduction. Washington University Fall 2013

Ordered Lists and Binary Trees

1. INTRODUCTION TO RDBMS

Tuple spaces and Object spaces. Distributed Object Systems 12. Tuple spaces and Object spaces. Communication. Tuple space. Mechanisms 2.

Traditional IBM Mainframe Operating Principles

Design Patterns in C++

fakultät für informatik informatik 12 technische universität dortmund Data flow models Peter Marwedel Informatik 12 TU Dortmund Germany

Big Data and Analytics by Seema Acharya and Subhashini Chellappan Copyright 2015, WILEY INDIA PVT. LTD. Introduction to Pig

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

Lecture 2 Notes: Flow of Control

Virtuozzo Virtualization SDK

CSC 2405: Computer Systems II

C#5.0 IN A NUTSHELL. Joseph O'REILLY. Albahari and Ben Albahari. Fifth Edition. Tokyo. Sebastopol. Beijing. Cambridge. Koln.

What Is Recursion? Recursion. Binary search example postponed to end of lecture

Relational Databases

Functional Programming in C++11

Shared Address Space Computing: Programming

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser Quiz 1.

Monitors, Java, Threads and Processes

Common Data Structures

Chapter 13: Query Processing. Basic Steps in Query Processing

12-6 Write a recursive definition of a valid Java identifier (see chapter 2).

D. SamKnows Methodology 20 Each deployed Whitebox performs the following tests: Primary measure(s)

Load Balancing and Termination Detection

Output: struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

Operating system Dr. Shroouq J.

Resurrecting Ada s Rendez-Vous in Java

Spring 2011 Prof. Hyesoon Kim

ODBC Client Driver Help Kepware, Inc.

CS 3719 (Theory of Computation and Algorithms) Lecture 4

COSC Introduction to Computer Science I Section A, Summer Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19

Java Virtual Machine Locks

COSC 6397 Big Data Analytics. 2 nd homework assignment Pig and Hive. Edgar Gabriel Spring 2015

Course: Programming II - Abstract Data Types. The ADT Stack. A stack. The ADT Stack and Recursion Slide Number 1

Client/Server Computing Distributed Processing, Client/Server, and Clusters

2.3 WINDOW-TO-VIEWPORT COORDINATE TRANSFORMATION

A Propositional Dynamic Logic for CCS Programs

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Synchronization in. Distributed Systems. Cooperation and Coordination in. Distributed Systems. Kinds of Synchronization.

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

SMock A Test Platform for the Evaluation of Monitoring Tools

SnapLogic Salesforce Snap Reference

agileworkflow Manual 1. agileworkflow 2. The repository 1 of 29 Contents Definition

Chapter 15 Functional Programming Languages

IT2304: Database Systems 1 (DBS 1)

Operating Systems 4 th Class

L7_L10. MongoDB. Big Data and Analytics by Seema Acharya and Subhashini Chellappan Copyright 2015, WILEY INDIA PVT. LTD.

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Simulation Tools. Python for MATLAB Users I. Claus Führer. Automn Claus Führer Simulation Tools Automn / 65

Cluster to Cluster Failover Using Double-Take

Elixir Schedule Designer User Manual

Informatica e Sistemi in Tempo Reale

Introduction. What is an Operating System?

The Workflow Management Coalition Specification Workflow Management Coalition Terminology & Glossary

10CS35: Data Structures Using C

Disfer. Sink - Sensor Connectivity and Sensor Android Application. Protocol implementation: Charilaos Stais (stais AT aueb.gr)

Chapter 1 Computer System Overview

Compiler Construction

Implementing and testing tftp

Computational Mathematics with Python

Introduction to Programming System Design. CSCI 455x (4 Units)

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

Linux Process Scheduling Policy

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

Spark ΕΡΓΑΣΤΗΡΙΟ 10. Prepared by George Nikolaides 4/19/2015 1

Input / Output and I/O Strategies

Relational Database: Additional Operations on Relations; SQL

Parquet. Columnar storage for the people

Hadoop Parallel Data Processing

Transcription:

Structured Application Development over Wide-Area Networks William Cook, Jayadev Misra, David Kitchin, Adrian Quark, Andrew Matsuoka, John Thywissen Department of Computer Science University of Texas at Austin http://orc.csres.utexas.edu

Internet Scripting Contact two airlines simultaneously for price quotes. Buy a ticket if the quote is at most $300. Buy the cheapest ticket if both quotes are above $300. Buy a ticket if the other airline does not give a timely quote. Notify client if neither airline provides a timely quote. -

Orchestrating Components (services) Acquire data from services. Calculate with these data. Invoke yet other services with the results. Additionally Invoke multiple services simultaneously for failure tolerance. Repeatedly poll a service. Ask a service to notify the user when it acquires the appropriate data. Download a service and invoke it locally. Have a service call another service on behalf of the user....

Structured Concurrent Programming Structured Sequential Programming: Dijkstra circa 1968 Component Integration in a sequential world. Structured Concurrent Programming: Component Integration in a concurrent world.

Orc, an Orchestration Theory Site: Basic service or component. Concurrency combinators for integrating sites. Theory includes nothing other than the combinators. No notion of data type, thread, process, channel, synchronization, parallelism New concepts are programmed using the combinators.

+ && < =... Examples of Sites println, random, Prompt, Email... Ref, Semaphore, Channel, Database... Timer External Services: Google Search, MySpace, CNN,... Any Java Class instance Sites that create sites: MakeSemaphore, MakeChannel... Humans...

Sites A site is called like a procedure with parameters. Site returns at most one value. The value is published. Site calls are strict.

Overview of Orc Orc program has a goal expression, a set of definitions. The goal expression is executed. Its execution calls sites, publishes values.

Structure of Orc Expression Simple: just a site call, CNN(d) Publishes the value returned by the site. Composition of two Orc expressions: do f and g in parallel f g Symmetric composition for all x from f do g f >x> g Sequential composition for some x from g do f f <x< g Pruning

Structure of Orc Expression Simple: just a site call, CNN(d) Publishes the value returned by the site. Composition of two Orc expressions: do f and g in parallel f g Symmetric composition for all x from f do g f >x> g Sequential composition for some x from g do f f <x< g Pruning

Structure of Orc Expression Simple: just a site call, CNN(d) Publishes the value returned by the site. Composition of two Orc expressions: do f and g in parallel f g Symmetric composition for all x from f do g f >x> g Sequential composition for some x from g do f f <x< g Pruning

Structure of Orc Expression Simple: just a site call, CNN(d) Publishes the value returned by the site. Composition of two Orc expressions: do f and g in parallel f g Symmetric composition for all x from f do g f >x> g Sequential composition for some x from g do f f <x< g Pruning

Symmetric composition: f g Evaluate f and g independently. Publish all values from both. No direct communication or interaction between f and g. They can communicate only through sites. Example: CNN(d) BBC(d) calls both CNN and BBC simultaneously. Publishes values returned by both sites. ( 0, 1 or 2 values)

Sequential composition: f >x> g For all values published by f do g. Publish only the values from g. CNN(d) >x> Email(address, x) Call CNN(d). Bind result (if any) to x. Call Email(address, x). Publish the value, if any, returned by Email. (CNN(d) BBC(d)) >x> Email(address, x) May call Email twice. Publishes up to two values from Email. Notation: f g for f >x> g, if x unused in g.

Schematic of Sequential composition f g0 g1 g2 Figure: Schematic of f >x> g

Pruning: (f <x< g) For some value published by g do f. Evaluate f and g in parallel. Site calls that need x are suspended. see (M() N(x)) <x< g When g returns a (first) value: Bind the value to x. Terminate g. Resume suspended calls. Values published by f are the values of (f <x< g).

Example of Pruning Email(address, x) <x< (CNN(d) BBC(d)) Binds x to the first value from CNN(d) BBC(d). Sends at most one email.

Some Fundamental Sites if(b): boolean b, returns a signal if b is true; remains silent if b is false. Rtimer(t): integer t, t 0, returns a signal t time units later. stop: never responds. Same as if(false). signal: returns a signal immediately. Same as if(true).

Centralized Execution Model An expression is evaluated on a single machine (client). Client communicates with sites by messages.

Expression Definition def MailOnce(a) = Email(a, m) <m< (CNN(d) BBC(d)) def MailLoop(a, t) = MailOnce(a) Rtimer(t) MailLoop(a, t) def metronome() = signal (Rtimer(1) metronome()) metronome() stockquote() Expression is called like a procedure. It may publish many values. MailLoop does not publish. Site calls are strict; expression calls non-strict.

Functional Core Language Data Types: Number, Boolean, String, with usual operators Conditional Expression: if E then F else G Data structures: Tuple and List Pattern Matching Function Definition; Closure

Variable Binding; Silent expression val x = 1 + 2 val y = x + x val z = x/0 -- expression is silent val u = if (0 < 5) then 0 else z

Translating Functional Core to Pure Orc Operators to Site calls: 1 + (2 + 3) to add(1, x) <x< add(2, 3) if E then F else G: (if(b) F not(b) >c> if(c) G) <b< E val x = G followed by F: F <x< G Data Structures, Patterns: Site calls and variable bindings Function Definitions: Orc definitions

Comingling with Orc expressions Components of Orc expression could be functional. Components of functional expression could be Orc. (1 + 2) (2 + 3) (1 2) + (2 3) Convention: whenever expression F appears in a context where a single value is expected, convert it to x <x< F. 1 + 2 2 + 3 is (x <x< add(1, 2)) (y <y< add(2, 3)) (1 2) + (2 3) is (add(x, y) <x< (1 2)) <y< (2 3)

Example: Fibonacci numbers def H(0) = (1, 1) def H(n) = H(n 1) >(x, y)> (y, x + y) def Fib(n) = H(n) >(x, _)> x {- Goal expression -} Fib(5)

Some Typical Applications Adaptive Workflow (Business process management): Workflow lasting over months or years Security, Failure, Long-lived Data Extended 911: Using humans as components Components join and leave Real-time response Network simulation: Experiments with differing traffic and failure modes Animation

Some Typical Applications, contd. Grid Computations Music Composition Traffic simulation Computation Animation

Some Typical Applications, contd. Map-Reduce using a server farm Thread management in an operating system Mashups (Internet Scripting). Concurrent Programming on Android.

Time-out Publish M s response if it arrives before time t, Otherwise, publish 0. z <z< (M() (Rtimer(t) 0)), or val z = M() (Rtimer(t) 0) z

Fork-join parallelism Call M and N in parallel. Return their values as a tuple after both respond. or, ((u, v) <u< M()) <v< N() (M(), N())

Recursive definition with time-out Call a list of sites simultaneously. Count the number of responses received within 10 time units. def tally([]) = 0 def tally(m : MS) = (M() 1 Rtimer(10) 0) + tally(ms)

Barrier Synchronization in M() f N() g f and g start only after both M and N complete. Rendezvous of CSP or CCS; M and N are complementary actions. (M(), N()) (f g)

Priority Publish N s response asap, but no earlier than 1 unit from now. Apply fork-join between Rtimer(1) and N. val (u, _) = (N(), Rtimer(1)) Call M, N together. If M responds within one unit, publish its response. Else, publish the first response. val x = M() u

Interrupt f Evaluation of f can not be directly interrupted. Introduce a semaphore interrupt: interrupt.release(): to interrupt f interrupt.acquire(): responds after interrupt.release() has been called. Instead of evaluating evaluate val z = f val (z, b) = f >x> (x, true) interrupt.acquire() >x> (x, false)

Parallel or Sites M and N return booleans. Compute their parallel or. val x = M() val y = N() if(x) true if(y) true (x y) To return just one value: val x = M() val y = N() val z = if(x) true if(y) true (x y) z

Airline quotes: Application of Parallel or Contact airlines A and B. Return any quote if it is below $300 as soon as it is available, otherwise return the minimum quote. threshold(x) returns x if x < 300; silent otherwise. Min(x, y) returns the minimum of x and y. val x = A() val y = B() val z = threshold(x) threshold(y) Min(x, y) z

Backtracking: Eight queens x... 0 x 0 1 x x 7 x 7......... 0 1 7 0 1 7 0 x... 1 1 7 x Row 1 Row 2 Row 3 Figure: Backtrack Search for Eight queens

Eight queens; contd. xs: partial placement of queens (list of values from 0..7) extend(xs) publishes all solutions that are extensions of xs. open(xs) publishes the columns that are open in the next row. Solve the original problem by calling extend([]). def extend(xs) = if (length(xs) = 8) then xs else (open(xs) >j> extend(j : xs))

Mutable Structures val r = Ref() r.write(3), or r := 3 r.read(), or r? def swaprefs(x, y) = (x?, y?) >(xv, yv)> (x := yv, y := xv)

Random Permutation val N = 20 -- size of permutation array val ar = fillarray(array(n), lambda(i) = i) -- Randomize array a of size n, n 1 def randomize(1) = signal def randomize(n) = random(n) >k> swaprefs(ar(n 1), ar(k)) randomize(n 1) randomize(n)

Binary Search Tree; Pointer Manipulation def search(key) = -- return true or false searchstart(key) >(_, _, q)> (q null) def insert(key) = -- true if value was inserted, false if it was there searchstart(key) >(p, d, q)> if q = null then Ref() >r> r := (key, null, null) update(p, d, r) true else false def delete(key) =

Semaphore val s = Semaphore(2) -- s is a semaphore with initial value 2 s.acquire() s.release() Rendezvous: val s = Semaphore(0) val t = Semaphore(0) def send() = t.release() s.acquire() def receive() = t.acquire() s.release() n-party Rendezvous using 2(n 1) semaphores.

val req = Buffer() val cb = Counter() Readers-Writers def rw() = req.get() >(b, s)> ( if(b) cb.inc() s.release() rw() if( b) cb.onzero() cb.inc() s.release() cb.onzero() rw() ) def start(b) = val s = Semaphore(0) req.put((b, s)) s.acquire() def quit() = cb.dec()

Processes Processes typically communicate via channels. For channel c, treat c.put and c.get as site calls. In our examples, c.get is blocking and c.put is non-blocking. Other kinds of channels can be programmed as sites.

Typical Iterative Process Forever: Read x from channel c, compute with x, output result on e: def P(c, e) = c.get() >x> Compute(x) >y> e.put(y) P(c, e) c Compute e P(c,e) Figure: Iterative Process

Process Network Process (network) to read from both c and d and write on e: def Net(c, d, e) = P(c, e) P(d, e) c P(c,e) e d P(d,e) Net(c,d,e) Figure: Network of Iterative Processes

Workload Balancing Read from c, assign work randomly to one of the processes. def bal(c, c, d ) = c.get() >x> random(2) >t> (if t = 0 then c.put(x) else d.put(x)) bal(c, c, d ) def WorkBal(c, e) = val c = Buffer() val d = Buffer() bal(c, c, d ) Net(c, d, e) c bal c d P(c,e) P(d,e) e WorkBal(c,e) Figure: Workload Balancing in a network of Processes

Laws Based on Kleene Algebra (Zero and ) f stop = f (Commutativity of ) f g = g f (Associativity of ) (f g) h = f (g h) (Idempotence of ) NO f f = f (Associativity of ) (f g) h = f (g h) (Left zero of ) stop f = stop (Right zero of ) NO f stop = stop (Left unit of ) signal f = f (Right unit of ) f >x> let(x) = f (Left Distributivity of over ) NO f (g h) = (f g) (f h) (Right Distributivity of over ) (f g) h = (f h g h)

Additional Laws (Distributivity over ) if g is x-free ((f g) <x< h) = (f <x< h) g (Distributivity over ) if g is x-free ((f g) <x< h) = (f <x< h) g (Distributivity over << ) if g is y-free ((f <x< g) <y< h) = ((f <y< h) <x< g) (Elimination of where) if f is x-free, for site M (f <x< M) = f (M stop)