rpc, events, streams. 6.893 spring 2004: rpc, events, streams larry rudolph three ways to interact...

34
RPC, Events, Streams

Upload: scot-daniels

Post on 29-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

RPC, Events, Streams

Page 2: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Three Ways to Interact

Synchronous -- RPC

Asynchronous -- Events

Streams -- a connected series of events

Page 3: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Remote Procedure Call

Target, eg “callee”, already published

class or method published

The “call” may be direct or indirectcaller waits for return

Differences between systems:how dynamic

communication mechanism

Page 4: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Events

Callback procedure already published

method associated with event

The “call” is usually indirect“caller” does not wait for return

Differences between systemshow dynamic

communication mechanism

Page 5: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Event == RPC

An event causes an Remote Callfrom event generator to callback

parameters are packed together into one parameter structure

event generator does not “care” about response

Why are there two different mechanisms?

Page 6: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Event <> RPC

OS people write event generator codeWhat about “higher-level” events?

events that result from lower level events

e.g. average temperature, verbal command given

With events, callee makes associationwith RPC, caller makes association

with Events, multiple calls/event

Perhaps they should be the same

Page 7: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Streams

What is a stream? (popular)

Is it like an RPC or like Event?Look more like events

Event gen. waits for return

Callee does other things during calljust worries about termination of stream

Parameter passing is like neither

Callee must publish beforehand

Page 8: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Other major differences

Publish & Subscribe done at different places: OS, user code, other mechanism

OS code: supported multiple languages

Event types: mapped to some number

numbers treated the same at all levels of coding

Treatment is outgrowth of virtual world programming (non-pervasive)

Pervasive is different because of distributed nature of calls, events, and streams

Page 9: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Historical Examination

Out-of-program calls -- OS functionscoded as calls, implemented as events (traps)

Micro-kernel:

treat OS as multi-tasking multi-treating system

separate functionality from policy

Streams -- (sequential file system access)

First everything explicit in code and JCL

Unix contribution: sequential file is common

Standard In, Out, Error

Specified at runtime (a.out < myInputFile)

Page 10: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Comments on Common Case

Rule of thumb:make common case efficient (eg. H/W)

provide (any kind of) support of others

90 / 10 rule -- what is it?10% of files take up 90% of disk space

90% of files take up 10% of disk space

actually, getting worse -- 95/5 rule

90% of jobs do the same thing

but consume only 10% of resources

Uncommon cases are all different -- heavy tail

Page 11: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Accessing streams

When stream is file-likeEither by programmer or user

within code: open(”/dev/cdrom”,”r”)

from shell: a.out < /dev/cdrom

When stream is network objectEither by programmer

from GUI/Browser click on link

from within code: very hidden, usually not stdin

Page 12: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Pervasive Computing Case

Streaming source specified at runtimeSubscribe (eg Get handle) to cd-rom device

use some middleware mechanism (RPC, event, stream)

User specification

rarely provided -- everyone provides “automation”

bluetooth provides awkward mechanism (list pick)

In favor of automatic control, we have taken away power from user

In favor of wireless, we have taken away power from user

Page 13: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Why wireless is good

Page 14: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Honey, look at this cool thing I just got

Page 15: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Some attempts at a solution

(other presentation)

(not yet integrated with previous)

Page 16: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

CORE: Communication Oriented

Routing Environment

(Oxygen Research Group)

Page 17: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Assumptions

Actuators / Sensors (I/O) in the environment

Many are shared by apps & users

Many are flaky / faulty

“User” does not know much about them

Environment, application, users desires change over time

Page 18: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

An Oxygen Application

Interconnected Collection of Stuff

Who specifies the stuff?I don’t know, but its mostly virtual stuff

Many layers of abstraction“Don’t ask, its turtles all the way down”

Two main layers of programmingProfessionals

Users, e.g. grandmother

Page 19: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Communications-Oriented Programs

Connecting the (virtual) stuff done by userHome stereo / theater analogy

Plug Stuff together; unplug it if doesn’t work

Don’t like it, unplug it

Device drivers, services, clients, don’t know to whom or to what they connect

In client/server model,

server knows a lot about the client,

the client knows even more about the server

Extend Unix Pipes

Page 20: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

CORE

Larry Bear’sCORE

Physical Devices

App

App

Programs (Processes)

Larry Bear CORE

Other COREs

Page 21: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Message Flow

Messages flow between nodes & coreCore is both language and router

Within Core Router, some messagesare interpreted and may trigger actions

other messages get routed to other nodes

Request-Reply message strategyEven number of messages

No reply within time period, means error

Page 22: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

CORE Language Elements

Four elements1. Nodes,

2. Links,

3. Messages,

4. Rules

FeaturesInterpreted Language

Statement is a message & reply

Each element has an inverse

Page 23: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Nodes – Specify via INS

CORE

Cam = [device=web-cam; location=518;…]

PTRvision = [device=process; OS=Linux;File=Laser Vision, ..]Slide

SpeechPresentation

Speech

CommandSpeech

LaserVision

Nodehandler = (nickname, specifier)

Page 24: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Node Statement Handler

When ‘node’ message arrivesVerified for correctness (statements allowed)

Routed to Node Manager (just another node)

Node ManagerINS lookup, verifies if allowed, creates if needed

Creates core thread to manage communication with node

Bookkeeping & reply message with handle/error

Page 25: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

CORE

SlideSpeech

PresentationSpeech

CommandSpeech

LaserVision

Lcamera,vision = (Cam,PTRvision)

Links

Page 26: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Link Statement Handler

Message routed to ‘link’ manager

Two queries to node mng for thread cntl

Message to thread controller of source nodeSpecifying destination thread controller

Message to thread controller of dest nodeSpecifying source thread controller

Bookkeeping & reply message handler/error

Page 27: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

CORE

SlideSpeech

PresentationSpeech

CommandSpeech

LaserVision

Messages flow over the links

Next Slide!

Messages

Page 28: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Message Handling

Messages can be encrypted

Core statement messages have fixed format

Everything else is data message

Each node thread has two unbounded buffersCore to node & Node to core

Logging, rollback, fault-tolerance

Page 29: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

CORE

SlideSpeech

PresentationSpeech

CommandSpeech

LaserVision

RULES: (trigger,action)

Questions

( MESSQuestion , Lslide,lcd -- & Lslide,qlcd )

Rules

Questions

Questions

Page 30: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Rule Statement Handler

( trigger , consequence )

Both are “event sets”

Eight basic events:+Node, -Node, +Link, -Link

+Message, -Message, +Rule, -Rule

Event set is a set of events

Trigger is true when events are true

Consequence makes events true

Page 31: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Rules – A link is a rule

A message event is of form (node, message specifier)

( message specifier , node )

Message came from or going to node

A link (x,y) is just shorthand for the rule: +( x , m ) ( - (x, m) , +(m , y) )

If a message m arrives at node x, then make that event false (remove the message) and make the event of m arriving at y from core true.

Page 32: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Rules – Access Control Lists

An access control list is just a rule

When messages arrive at node, if they arrive from valid node, then allowed to continue to flow.

Modifying access control lists is just adding or removing rules.

Page 33: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Rules

Rule statement gets sent to rule manager

Event set is just another shorthand for rules

Rule manager sends command to trigger node thread that tells it about the consequence

Rules are reversible

Page 34: RPC, Events, Streams. 6.893 Spring 2004: RPC, Events, Streams Larry Rudolph Three Ways to Interact Synchronous -- RPC Asynchronous -- Events Streams --

6.893 Spring 2004: RPC, Events, Streams Larry Rudolph

Reversibility

Each statement is invertible (reversible)

If there is an error in the application specification, then can undo it all.

General debugging is possible with reversible rules and message flow