distributed systems and their properties ( lecture 2 for programming of interactive system s )

40
Distributed systems and their properties (Lecture 2 for Programming of Interactive Systems) Fredrik Kilander & Wei Li

Upload: chad

Post on 28-Jan-2016

38 views

Category:

Documents


0 download

DESCRIPTION

Distributed systems and their properties ( Lecture 2 for Programming of Interactive System s ). Fredrik Kilander & Wei Li. Agenda. Interaction in Interactive Systems Evolution in Distributed Systems Distributed Systems OSI Model & Middleware Remote Procedural Call (RPC) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

Distributed systems and their properties

(Lecture 2 for Programming of Interactive Systems)

Fredrik Kilander & Wei Li

Page 2: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 2/28Programming of Interactive Systems

Agenda• Interaction in Interactive Systems• Evolution in Distributed Systems• Distributed Systems

– OSI Model & Middleware– Remote Procedural Call (RPC)– Remote Method Invocation (RMI)– Message Oriented Middleware– Sockets

• Summary

Page 3: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 3/28Programming of Interactive Systems

Interactive Systems

Early computing – Z1 (1938)

Page 4: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 4/28Programming of Interactive Systems

Interactive Systems

Early computing – Manchester Mark I (1949)

Page 5: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 5/28Programming of Interactive Systems

Interactive Systems

• Special environments

iLounge (2007)

Page 6: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 6/28Programming of Interactive Systems

Interactive Systems

Tangible interfaces – Reactable (2009)

Page 7: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 7/28Programming of Interactive Systems

Interactive Systems

Gesture+voice interfaces – Kinect (2010)

Page 8: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 8/28Programming of Interactive Systems

Interactive Playground

Banabi, by Maurizio Piraccini

Page 9: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 9/28Programming of Interactive Systems

Intangible Systems

Computer networks – peer networks, ad-hoc networks, temporary associations

Page 10: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 10/28Programming of Interactive Systems

Definition of a Distributed SystemA distributed system is: A collection of independent

computers that appears to its users as a single coherent system.

-- Andrew S. Tanenbaum

• Machines are running autonomously• Software hides that processes and resources are physically

distributed across multiple computers over networks

Goal: Users and applications can access remote resources and share them with other users in a controlled way through the interaction with a DS in a consistent and uniform way

Page 11: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

Computer system

ENVIRONMENT& User

input output

10/31/2006 11/28Programming of Interactive Systems

Interactive System

Page 12: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

Interactive systems

Interacting with and through different systems

Page 13: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 13/28Programming of Interactive Systems

Interactive System

H1 – it is afraid of being stepped onH2 – it is afraid of shadowH3 – when the camera can’t see it, it moves

Reverse engineering cause and effect can be hard – what guides the behaviour of the creatures?

Page 14: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 14/28Programming of Interactive Systems

Interactive Systems

•Distributed Systems (DS)

•Mobile Computing (MC)

•Pervasive Computing (PC)

Page 15: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

Pervasive Computing: Vision and ChallengesM. Satyanarayanan, School of Computer Science Carnegie Mellon University

Remote communicationprotocol layering, RPC, end-to-end args . . .

Fault toleranceACID, two-phase commit, nested transactions .

. .High Availability

replication, rollback recovery, . . .Remote information access

dist. file systems, dist. databases, caching, . . .Distributed security

encryption, mutual authentication, . . .

Mobile networkingMobile IP, ad hoc networks, wireless TCP fixes, . . .

Mobile information accessdisconnected operation, weak consistency, . . .

Adaptive applicationsproxies, transcoding, agility, . . .

Energy-aware systemsgoal-directed adaptation, disk spin-down, . . .

Location sensitivityGPS, WiFi triangulation, context-awareness, . . .

Contemporary Interactive Systems

Page 16: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 16/28Programming of Interactive Systems

Transparency in a Distributed System

Different forms of transparency in a distributed system.

Transparency Description

Access Hide differences in data representation and how a resource is accessed

Location Hide where a resource is located

Migration Hide that a resource may move to another location (static deployment)

Relocation Hide that a resource may be moved to new location during use (dynamic)

Replication Hide that a resource is replicated

Concurrency Hide that a resource may be shared by several competitive users

Failure Hide the failure and recovery of a resource

Persistence Hide whether a (software) resource is in memory or on disk

Page 17: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 17/28Programming of Interactive Systems

Important Issues in Distributed Systems

• Communication: – the basis of a DS is to support access to remote

resources

• Processes: – communication takes place between processes– schedule and manage processes – threads, code migration, client/server, software

agents

Page 18: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 18/28Programming of Interactive Systems

Important Issues in Distributed Systems

• Naming: – the shared resources in a DS have to be

identified uniquely– each identification should be resolvable for

retrieving the entity it refers to– Example 1: URL→IPnr:port→MAC– Example 2: Lisa→telephone nr →GSM

tower→terminal (handset)

Page 19: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 19/28Programming of Interactive Systems

Important Issues in Distributed Systems

• Synchronization: – protect concurrent access from conflicts; one

writer; only read from a consistent state

• Consistency and Replication: – data are replicated to enhance reliability and

performance– keep replicas consistent (also called data

synchronization); cache management.

Page 20: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 20/28Programming of Interactive Systems

Important Issues in Distributed Systems

• Fault Tolerance: – DS are subject to failures as communication

spans multiple computers or even networks– it is important to have automatic recovery from

failures without affecting the overall performance– automatic configuration and adaptation

Useresource

Findresource

Page 21: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 21/28Programming of Interactive Systems

Important Issues in Distributed Systems

• Security: – secure communication (secure channel)– provide access protection to prevent malicious or

unauthorized access– Example: only group members currently in room 4 are

allowed to read each other’s files

– authentication and auditing– distributed administration– authority in peer-to-peer systems

Page 22: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 22/28Programming of Interactive Systems

CommunicationLayers, interfaces, and protocols in the OSI (Open Systems

Interconnection) reference model.• Divided into 7 layers. Each deals with one

specific aspect of the communication

Page 23: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 23/28Programming of Interactive Systems

• Distributed systems are often organized as a software layer placed between user and application and the underneath operation system.

• A distributed system is also called middleware and the middleware layer extends over multiple machines.

• Middleware is an application layer protocol (the layers above transport layer are all categorized into application layer).

Positioning Distributed System (Middleware)

Middleware Service

Internet

Page 24: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 24/28Programming of Interactive Systems

Binding a Client to a Server

Client-to-server binding in DCE

(distributed computing environment 1990-)

2-15

Endpoint= IP+Port

(server, endpoint) pairs

Page 25: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 25/28Programming of Interactive Systems

Remote Procedure Call (RPC)Extend the procedure call over the

network by allowing programs to call procedures located on other machines through Stubs:

1. Client program calls client stub to place a remote procedure call

2. Client stub builds a request message and sends to remote server

3. Server stub receives the message and unpacks parameters, calls the local procedure

4. Procedure executes and returns result to the server stub

5. Server stub packs it in message, and sends back to client stub

6. Client stub unpacks result, returns to client program

A synchronous Client/Server Model

Server Stub

Client Stub

6

3

1

4

2

5

Page 26: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 26/28Programming of Interactive Systems

Remote Procedure Call (RPC)Extend the procedure call over the

network by allowing programs to call procedures located on other machines

1. The client calls the server to place a service request

2. While the server processes the request, the client keeps executing

3. The server sees the request, and responds to it

4. The server calls back to the client with the result

5. The client sees the response and acts upon it

An asynchronous and symmetric

Client/Server Model

Server

Client

Request Response1

2

3

4

5

+ Higher parallelism- Higher complexity

Page 27: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 27/28Programming of Interactive Systems

Remote Procedure Call (RPC)Extend the procedure call over the

network by allowing programs to call procedures located on other machines

1. The client calls the server to place a service request

2. While the server processes the request, the client keeps executing

3. The server sees the request, and responds to it

4. The server calls back to the client with the result

5. The client sees the response and acts upon it

An asynchronous and symmetric

Client/Server Model

Server

Client

1

2

3

4

5

+ Higher parallelism- Higher complexity

Worker thread

Worker thread

Listener thread

Listener thread

Page 28: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 28/28Programming of Interactive Systems

Client & Server StubsThe Stubs take charge of:

1) Building the RPC message (parameters and results), also called marshaling and unmarshaling

2) Establishing the connection to transfer messages.

Page 29: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 29/28Programming of Interactive Systems

Remote Method Invocation• Object-oriented technology encapsulates data, (state/Property) and operations (method) on those data

• This encapsulation offers a better transparency for system design and programming

• The principle in RPC can be equally applied to objects

• Client uses proxy (a local representative of the remote object) to operate with the remote one.

• Proxy/Skeleton is analog to the stubs in RPC, in addition, it presents an object view.

Java

Page 30: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 30/28Programming of Interactive Systems

Passing Object by Value or Reference (RMI)

proxy1MediaPlayerController

SkeletonMedia Player

Interface Method:

void Play ();void Play (String filename);void Play (MP3Selector mps);

Interface Method:

void Play();void Play (String filename);void Play (MP3Selector mps);

Three cases:1) Play () without parameters. // only method name will be sent

“http://myhost/a.mp3”

2) Play (“http://myhost/a.mp3”) // send filename as a copied object (value/copy)

3) Play (mps) { // send the copy of proxy2 play(mps.getLatestMP3()) // (reference to MP3Selector) }

Skeleton

Machine C

MP3Selector

proxy2proxy2Machine A Machine B

“http://myhost/a.mp3”

• The object to send to another machine has to be Serializable.

• The object to send has to have its class definition in a publicly accessible codebase.

• Setup security policy file

http://java.sun.com/developer/onlineTraining/rmi/RMI.html

Page 31: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 31/28Programming of Interactive Systems

Conclusion (RPC & RMI)• To be able to access a remote object, a

local stub (proxy) which refers to the remote object is required.

• The stub appears as a local object, but delivers the received accesses to the remote object.

• The stub can be passed (e.g. in Java RMI) to other programs (on remote computers) to share the access to the same remote object.

Page 32: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 32/28Programming of Interactive Systems

Conclusion (RPC & RMI)

• Another way to access a remote object is to make a cloned local copy.

• This improves performance by removing the call delay over the network, but …

• Consistency becomes an issue if they need to be synchronized since they are now two independent objects (from the same class) in the network.

Page 33: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 33/28Programming of Interactive Systems

Conclusion (RPC & RMI)

• Stubs, Proxies and Skeletons …– hides the complexity of marshaling and

unmarshaling.– hides the network communication– enhances the access transparency to the

upper-layer applications.

Page 34: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 34/28Programming of Interactive Systems

Conclusion (RPC & RMI)

• RPC and RMI use a transient synchronous communication model:– The sender blocks until it receives a reply

from the other side. – This model is not suitable for pervasive

computing scenarios where time is critical.

Page 35: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 35/28Programming of Interactive Systems

Berkeley Sockets

Connection-oriented communication (TCP) pattern using sockets.

• UDP communication is asynchronous, so does not have the synchronization point as in TCP

• UDP server just creates a UDP socket and then receives (blocking), and UDP client has no “connect” phase to block, but just sends.

• UDP port =/= TCP port, they may use the same port number without conflict

TCP/UDP Network communication like plug-in sockets

Page 36: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 36/28Programming of Interactive Systems

Message-Oriented Middleware

• Socket communication gives an easy-to-use abstraction to network programming.

• Sockets are supported by most programming languages and operating systems supporting networks.

• To achieve efficiency and simplicity, many middlewares are implemented in terms of message delivery based on (hidden) socket communication.

• This is called Message-oriented middleware (MOM).• Examples: IBM MQSeries, Tuple Space, JavaSpace.

Page 37: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 37/28Programming of Interactive Systems

The general organization of a message-queuing system with routers.

General Architecture of a Message-Queuing System

• Messages are delivered in a sorting-storing-forwarding fashion

• Applications are loose-coupled by asynchronous messages (events)

• R1, R2 are Message Servers in MOM

• In email systems, R1, R2 are email servers

Page 38: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 38/28Programming of Interactive Systems

Message-Oriented Communication

Synchronous Asynchronous

PersistentTransient

time

communication

Page 39: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

10/31/2006 39/28Programming of Interactive Systems

Summary• OSI Model & Middleware

• Remote Procedural Call (RPC)

• Remote Method Invocation (RMI)

• Sockets

• Message Oriented Middleware

Page 40: Distributed systems and their properties ( Lecture 2 for  Programming of  Interactive System s )

Distributed systems and their properties

(Lecture 2 for Programming of Interactive Systems)

Fredrik Kilander & Wei Li