11 september 2008cis 340 # 1 topics to examine the variety of approaches to handle the middle-...

38
11 September 2008 CIS 340 # 1 Topics To examine the variety of approaches to handle the middle-interaction (continued) 1. RPC-based systems 2. TP monitors 3. Object brokers 4. Object monitors 5. Message-oriented middleware 6. Message brokers

Upload: whitney-turner

Post on 12-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 1

Topics

• To examine the variety of approaches to handle the middle-interaction

(continued)

1. RPC-based systems

2. TP monitors

3. Object brokers

4. Object monitors

5. Message-oriented middleware

6. Message brokers

Page 2: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

9 September 2008 CIS 340# 2

Basic Middleware: RPC - motivation

• One cannot expect the programmer to implement a complete infrastructure for every distributed application.

– Sockets API = send & recv calls = I/O

• Instead, one can use an RPC system– our first example of low level middleware

• Remote Procedure Calls (RPC)– Goal: to provide a procedural interface for distributed (i.e.,

remote) services– To make distributed nature of service transparent to the

programmer

• Remote Method Invocation (RMI)– RPC + Object Orientation– Allows objects living in one process to invoke methods of an

object living in another process

Page 3: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

9 September 2008 CIS 340# 3

Basic Middleware: RPC

What does an RPC system do?

• Hides distribution behind procedure calls

• Provides an interface definition interface definition language (IDL)language (IDL) to describe the services

• Generates all the additional code necessary to make a procedure call remote and to deal with all the communication aspects

• Provides a binder/bindingbinder/binding in case it has a distributed name and directory service system

Basis for 2-tier, client/server

First introduction of elements common to all middleware

Page 4: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Middleware layers

11 September 2008 CIS 340# 4

Page 5: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Request-reply communication

11 September 2008 CIS 340# 5

Page 6: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Conventional Procedure Call

(a) Parameter passing in a local procedure call: the stack before the call to read(fd,buf,bytes)

(b) The stack while the called procedure is active

11 September 2008 CIS 340# 6

Page 7: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Remote Procedure Call

11 September 2008 CIS 340# 7

Page 8: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Remote Procedure Calls

• Remote procedure call (RPC) abstracts procedure calls between processes on networked systems.

• Stubs – client-side proxy for the actual procedure on the server.

• The client-side stub locates the server and marshalls the parameters.

• The server-side stub receives this message, unpacks the marshalled parameters, and performs the procedure on the server.

11 September 2008 CIS 340# 8

Page 9: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

9 September 2008 CIS 340# 9

IDLsources

interfaceheaders

IDL compiler

IDLclientcode

client stub

language specificcall interface

servercode

server stub

language specificcall interface

client process server processdevelopment environment

Copyright Springer Verlag Berlin Heidelberg 2004

Remote Procedure Call (RPC): Development Components/Aspects interface

definition language –

“specification of the services” ==

parameters

1

2•piece of code•compiled & linked with client•local call •does not take care of the implementation

•implements the invocation•“possesses” code for receiving, formatting, ....

Page 10: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

9 September 2008 CIS 340# 10

communicationmodule

client

procedure call

client stubbindmarshalserializesend

client proces

s

communicationmodule

server

procedure

server stub

unmarshaldeserializereceive

server process

dispatcher(selectstub)

Copyright Springer Verlag Berlin Heidelberg 2004

Remote Procedure Call (RPC): Functioning Elements

Page 11: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Steps of a Remote Procedure Call1. Client procedure calls client stub in normal way

2. Client stub builds message, calls local OS

3. Client's OS sends message to remote OS

4. Remote OS gives message to server stub

5. Server stub unpacks parameters, calls server

6. Server does work, returns result to the stub

7. Server stub packs it in message, calls local OS

8. Server's OS sends message to client's OS

9. Client's OS gives message to client stub

10. Stub unpacks result, returns to client

11 September 2008 CIS 340# 11

Page 12: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Passing Value Parameters (1)

11 September 2008 CIS 340# 12

Page 13: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Passing Value Parameters (2)

11 September 2008 CIS 340# 13

a) Original message on the Pentiumb) The message after receipt on the SPARCc) The message after being inverted. The little numbers in boxes indicate the address of each byte

Page 14: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Parameter Specification and Stub Generation

11 September 2008 CIS 340# 14

Page 15: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Writing a Client and a Server

11 September 2008 CIS 340# 15

Page 16: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

9 September 2008 CIS 340# 16

Dynamic Binding

• vs. static binding• Adds a layer of “indirection”• Layer == name and directory server

• Invocation of remote procedure by client stub

Requests name and directory server to identify server to execute procedure

Response by name and directory server == address of server

Tightly coupled

COST for dynamic flexibility?

Additional layer

Page 17: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 17

Page 18: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

RMI

• RMI = RPC + Object-orientation– Java RMI– CORBA

• Middleware that is language-independent– Microsoft DCOM/COM+– SOAP

• RMI on top of HTTP

11 September 2008 CIS 340# 18

Page 19: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Interfaces in distributed systems• Programs organized as a set of modules that communicate

with one another via procedure calls/method invocations• Explicit interfaces defined for each module in order to control

interactions between modules • In distributed systems, modules can be in different processes• A remote interface specifies the methods of an object that are

available for invocation by objects in other processes defining the types of the input and output arguments of each of them

11 September 2008 CIS 340# 19

Page 20: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 20

Page 21: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Object model• Object references

– Objects accessed via object references– Object references can be assigned to variables, passed

as arguments and returned as results• Interfaces

– Provides a signature of a set of methods (types of arguments, return values and exceptions) without specifying their implementations

• Actions (invocations)• Exceptions• Garbage Collection

11 September 2008 CIS 340# 21

Page 22: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Distributed Objects• Remote object references

– An identifier that can be used throughout a distributed system to refer to a particular remote object

• Remote interfaces– CORBA provides an interface definition language (IDL)

for specifying a remote interface– JAVA RMI: Java interface that extends Remote interface

• Actions: remote invocations• Remote Exceptions may arise for reasons such as partial

failure or message loss• Distributed Garbage Collection: cooperation between local

garbage collectors needed

11 September 2008 CIS 340# 22

Page 23: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Remote and local method invocations

11 September 2008 CIS 340# 23

Page 24: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

A remote object and its remote interface

11 September 2008 CIS 340# 24

Page 25: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

RMI Programming• RMI software

– Generated by IDL compiler

– Proxy

• Behaves like remote object to clients (invoker)

• Marshals arguments, forwards message to remote object, unmarshals results, returns results to client

– Skeleton

• Server side stub;

• Unmarshals arguments, invokes method, marshals results and sends to sending proxy’s method

– Dispatcher

• Receives the request message from communication module, passes on the message to the appropriate method in the skeleton

• Server and Client programs

11 September 2008 CIS 340# 25

Page 26: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 26

Page 27: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

RMI Programming• Binder

– Client programs need a means of obtaining a remote object reference

– Binder is a service that maintains a mapping from textual names to remote object references

– Servers need to register the services they are exporting with the binder

– Java RMIregistry, CORBA Naming service• Server threads

– Several choices: thread per object, thread per invocation– Remote method invocations must allow for concurrent

execution

11 September 2008 CIS 340# 27

Page 28: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Java RMI

• Features– Integrated with Java language + libraries

• Security, write once run anywhere, multithreaded

• Object orientation– Can pass “behavior”

• Mobile code• Not possible in CORBA, traditional RPC

systems• Distributed Garbage Collection• Remoteness of objects intentionally not transparent

11 September 2008 CIS 340# 28

Page 29: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

Remote Interfaces, Objects, and Methods

• Objects become remote by implementing a remote interface– A remote interface extends the interface

java.rmi.Remote– Each method of the interface declares

java.rmi.RemoteException in its throws clause in addition to any application-specific clauses

11 September 2008 CIS 340# 29

Page 30: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 30

Page 31: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 31

Page 32: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 32

Page 33: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 33

Page 34: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 34

Page 35: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 35

Page 36: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors
Page 37: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 37

Machine independent representations:Marshalling, Serializing

Consider (in C) sprintf and sscanf

Message= “Vitolo” “GU” “2006”

char *name=“Vitolo”, place=“GU”;int year=2006;

sprintf(message, “%d %s %d %s %d”),

strlen(name), name, strlen(place), place, year);

Message after marshalling = “6 Vitolo 2 GU 2006”

NOTE: type and number of parameters is known, ….only need to agree on the syntax ...

SUN XDR approach:• Messages transformed into

a sequence of 4 byte objects, each byte being in ASCII code

• Defines how to pack different data types into these objects

• GIST? To simplify computation at the expense of bandwidthexpense of bandwidth

6V i t ol o2G U 2 0 0 6

String length

String length

cardinal

eXternal Data Representation

Page 38: 11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors

11 September 2008 CIS 340# 38

Remote Procedure Call (RPC): Functionality of Stubs

BINDING MARSHALING SERIALIZING SENDING

RECEIVING DESERIALIZING UNMARSHALING

•Client process

•Creates a local association – handle – to the server

•Think of “binding a variable”

• Client process

• Packages data into message format needed by the recipient server

• Client process

• Transforms data/message into bytes

• Server process

• Undoes the steps