From RPC to RMI Protocols for middleware services Protocols for - - PDF document

from rpc to rmi
SMART_READER_LITE
LIVE PREVIEW

From RPC to RMI Protocols for middleware services Protocols for - - PDF document

Middleware Protocols From RPC to RMI Protocols for middleware services Protocols for middleware services Distributed commit protocols Distributed commit protocols Useful for distributed database transactions and for


slide-1
SLIDE 1

1

1י"סשת ןסינ ג"ג The Computer Communication Cource

From RPC to RMI

י"סשת ןסינ ג"ג2

Slides are taken from

Topics in Distributed Middleware Systems, Spring Topics in Distributed Middleware Systems, Spring 2002 by Gregory Chockler 2002 by Gregory Chockler

3י"סשת ןסינ ג"ג The Computer Communication Cource

Where is middleware?

4י"סשת ןסינ ג"ג The Computer Communication Cource

Middleware Protocols

■ ■

Protocols for middleware services Protocols for middleware services

◆ ◆ Distributed commit protocols

Distributed commit protocols

✦ ✦ Useful for distributed database transactions and for supporting

Useful for distributed database transactions and for supporting fault fault-

  • tolerance

tolerance

◆ ◆ Distributed locking

Distributed locking

■ ■

High level communication services: High level communication services:

◆ ◆ Remote procedure call, remote object invocation, message queuing

Remote procedure call, remote object invocation, message queuing services services

5י"סשת ןסינ ג"ג The Computer Communication Cource

Remote Procedure Call (RPC)

■ ■

Allowing programs to call procedures located on other machines Allowing programs to call procedures located on other machines

■ ■

The goal: to make remote procedure call to look as much as The goal: to make remote procedure call to look as much as possible as a local one possible as a local one

◆ ◆ Hides communication network

Hides communication network

◆ ◆ Access transparency

Access transparency

■ ■

Issues: different address spaces, passing parameters and Issues: different address spaces, passing parameters and returning replies, failures returning replies, failures

6י"סשת ןסינ ג"ג The Computer Communication Cource

RPC: High level view

slide-2
SLIDE 2

2

7י"סשת ןסינ ג"ג The Computer Communication Cource

Client and Server Stubs

■ ■

Client stub: represents the remote procedure in the client Client stub: represents the remote procedure in the client’ ’s s address space address space

◆ ◆ Transforms a local invocation into a message and sends it to the

Transforms a local invocation into a message and sends it to the server server

■ ■

Server stub: Server stub:

◆ ◆ Transforms request coming in over the network into local procedu

Transforms request coming in over the network into local procedure re calls calls

8י"סשת ןסינ ג"ג The Computer Communication Cource

RPC Anatomy

Client calls add(i,j), where both i and j are integers:

9י"סשת ןסינ ג"ג The Computer Communication Cource

Passing Value Parameters

■ ■

Different machines have different data representations Different machines have different data representations

◆ ◆ Characters: EBCDIC, ASCII

Characters: EBCDIC, ASCII

◆ ◆ Integers: little

Integers: little endian endian, big , big endian endian

10י"סשת ןסינ ג"ג The Computer Communication Cource

Passing Reference Parameters

■ ■

What is the meaning of a local reference (pointer) in the remote What is the meaning of a local reference (pointer) in the remote address space?? address space??

■ ■

Simulate call Simulate call-

  • by

by-

  • reference by call

reference by call-

  • by

by-

  • copy

copy-

  • restore for non

restore for non-

  • recursive

recursive datatypes datatypes

◆ ◆ Optimization: explicitly designate input/output parameters

Optimization: explicitly designate input/output parameters

■ ■

No good solution exists for arbitrary data types (e.g., graphs, No good solution exists for arbitrary data types (e.g., graphs, linked linked-

  • lists)

lists)

11י"סשת ןסינ ג"ג The Computer Communication Cource

RPC Communication Protocol

■ ■

Common message formats for marshaling Common message formats for marshaling data structures data structures

■ ■

Common representation of simple data types Common representation of simple data types

◆ ◆

E.g., integers: little E.g., integers: little-

  • endian

endian, two , two’ ’s complement; s complement; chars: 16 chars: 16-

  • bit Unicode

bit Unicode

■ ■

Agreed message exchange: Agreed message exchange:

◆ ◆

Use TCP Use TCP

◆ ◆

Use unreliable protocol and implement an error Use unreliable protocol and implement an error control scheme control scheme

foobar(char x; float y; int z[5])

12י"סשת ןסינ ג"ג The Computer Communication Cource

Stub Generation

■ ■

Stubs can be generated automatically from the interface Stubs can be generated automatically from the interface

■ ■

Interfaces are usually defined by means of an Interfaces are usually defined by means of an Interface Interface Definition Language (IDL) Definition Language (IDL)

◆ ◆ Allows for programming language independence

Allows for programming language independence

slide-3
SLIDE 3

3

13י"סשת ןסינ ג"ג The Computer Communication Cource

RPC extensions

■ ■

Asynchronous RPC: Asynchronous RPC:

◆ ◆

One One-

  • way RPC: don

way RPC: don’ ’t wait for t wait for acceptance notification acceptance notification

Deferred synchronous

RPC:

14י"סשת ןסינ ג"ג The Computer Communication Cource

portmap

■ ■

Portmap Portmap is a server that converts RPC program numbers into is a server that converts RPC program numbers into DARPA protocol port numbers. DARPA protocol port numbers.

■ ■

It must be running in order to make RPC calls. It must be running in order to make RPC calls.

■ ■

/etc/ /etc/portmap portmap

◆ ◆ portmapper

portmapper 100000 100000 portmap sunrpc rpcbind portmap sunrpc rpcbind

◆ ◆ rstatd

rstatd 100001 100001 rstat rup perfmeter rstat rstat rup perfmeter rstat_svc _svc

◆ ◆ rusersd

rusersd 100002 100002 rusers rusers

◆ ◆ nfs

nfs 100003 100003 nfsprog nfsprog

◆ ◆ …

…. .

■ ■

Rpcinfo Rpcinfo

15י"סשת ןסינ ג"ג The Computer Communication Cource

rpcinfo

■ ■

rpcinfo rpcinfo -

  • p

p fs fs-

  • 01

01

■ ■

100021 4 100021 4 tcp tcp 607 607 nlockmgr nlockmgr

■ ■

100021 4 100021 4 udp udp 606 606 nlockmgr nlockmgr

■ ■

100024 1 100024 1 tcp tcp 605 status 605 status

■ ■

100024 1 100024 1 udp udp 604 status 604 status

■ ■

100005 3 100005 3 tcp tcp 603 603 mountd mountd

■ ■

100005 3 100005 3 udp udp 602 602 mountd mountd

■ ■

100003 3 100003 3 udp udp 2049 2049 nfs nfs

■ ■

100003 2 100003 2 udp udp 2049 2049 nfs nfs

■ ■

100000 2 100000 2 tcp tcp 111 111 portmapper portmapper

■ ■

100000 2 100000 2 udp udp 111 111 portmapperRpcinfo portmapperRpcinfo

16י"סשת ןסינ ג"ג The Computer Communication Cource

inetd

■ ■

inetd inetd is the server process for the Internet standard services. is the server process for the Internet standard services.

■ ■

It is usually started up at system boot time. It is usually started up at system boot time.

■ ■

The The configuration configuration-

  • file

file lists the services that lists the services that inetd inetd is to provide is to provide

■ ■

/etc/ /etc/inetd inetd.conf .conf

■ ■

daytime stream daytime stream tcp nowait tcp nowait root internal root internal

■ ■

#daytime #daytime dgram udp dgram udp wait root internal wait root internal

■ ■

time stream time stream tcp nowait tcp nowait root internal root internal

■ ■

time time dgram udp dgram udp wait root internal wait root internal

■ ■

telnet stream telnet stream tcp nowait tcp nowait root / root /usr usr/ /sbin sbin/ /tcpd tcpd / /usr usr/ /sbin sbin/in. /in.telnetd telnetd

17י"סשת ןסינ ג"ג The Computer Communication Cource

Distributed Comupting Environment

■ ■

Distributed Computing Environment (DCE) is one of the first Distributed Computing Environment (DCE) is one of the first middleware systems middleware systems

■ ■

Provides a diverse collection of services to simplify developmen Provides a diverse collection of services to simplify development t

  • f distributed applications:
  • f distributed applications:

◆ ◆ Distributed file service, directory service, security service,

Distributed file service, directory service, security service, distributed time, etc. distributed time, etc.

■ ■

Programming model: client/server Programming model: client/server

■ ■

Communication: RPC Communication: RPC

18י"סשת ןסינ ג"ג The Computer Communication Cource

DCE RPC: Writing a client and a server

slide-4
SLIDE 4

4

19י"סשת ןסינ ג"ג The Computer Communication Cource

DCE RPC: Binding a client to a server

20י"סשת ןסינ ג"ג The Computer Communication Cource

Remote Object Invocation

■ ■

Extending RPC idea to object invocation Extending RPC idea to object invocation

■ ■

What is an object? What is an object?

◆ ◆ Encapsulates data (

Encapsulates data (state state) )

◆ ◆ Operations on the data are called

Operations on the data are called methods methods

◆ ◆ Methods are made available through an

Methods are made available through an interface interface

◆ ◆ The object state can be accessed and manipulated only through

The object state can be accessed and manipulated only through the interface the interface

◆ ◆ Object can implement several interfaces

Object can implement several interfaces

◆ ◆ A specific interface can be implemented by several objects

A specific interface can be implemented by several objects

21י"סשת ןסינ ג"ג The Computer Communication Cource

Distributed Object

■ ■

Distributed (remote) object: Distributed (remote) object:

◆ ◆ An interface and the object are physically separated: reside on

An interface and the object are physically separated: reside on different different machines machines

■ ■

At client machine: the object is represented by a At client machine: the object is represented by a proxy proxy

◆ ◆ Supports the same interface as the object

Supports the same interface as the object

◆ ◆ Functionally similar to the RPC stub

Functionally similar to the RPC stub

■ ■

At server machine: At server machine: unmarshaling unmarshaling invocation parameters and invoking invocation parameters and invoking the target object is handled by a the target object is handled by a skeleton skeleton

22י"סשת ןסינ ג"ג The Computer Communication Cource

Distributed Object

23י"סשת ןסינ ג"ג The Computer Communication Cource

Java RMI

■ ■

A.

  • A. Wollrath

Wollrath, R. Riggs, and J. Waldo, , R. Riggs, and J. Waldo, “ “A Distributed Object Model A Distributed Object Model for the Java System for the Java System” ”, USENIX , USENIX’ ’1996 1996

■ ■

Other approaches. ( out of the scope) Other approaches. ( out of the scope)

◆ ◆ Common Object Request Broker Architecture (CORBA)

Common Object Request Broker Architecture (CORBA)

◆ ◆ COM/DCOM

COM/DCOM

24י"סשת ןסינ ג"ג The Computer Communication Cource

The Goal

■ ■

Provide a homogenous object Provide a homogenous object-

  • oriented environment for
  • riented environment for

developing distributed applications developing distributed applications

◆ ◆ A service is an object

A service is an object

◆ ◆ Promotes software extensibility and re

Promotes software extensibility and re-

  • use:

use:

✦ ✦ Services can be combined in various ways to create new

Services can be combined in various ways to create new services services

✦ ✦ Simplifies integration of separately developed components and

Simplifies integration of separately developed components and common services common services

slide-5
SLIDE 5

5

25י"סשת ןסינ ג"ג The Computer Communication Cource

An Example: A Bank

■ ■

A bank account is an object: A bank account is an object:

◆ ◆ Attributes: owner name, social security number (

Attributes: owner name, social security number (ssn ssn) )

◆ ◆ Methods:

Methods: getBalance getBalance(), deposit(), withdraw() (), deposit(), withdraw()

■ ■

Bank accounts are created by an account manager object: Bank accounts are created by an account manager object:

◆ ◆ Method:

Method: Account Account createAccount createAccount(name) (name)

✦ ✦ Forwards requests to a factory object at a specific location

Forwards requests to a factory object at a specific location

26י"סשת ןסינ ג"ג The Computer Communication Cource

Java Distributed Object Model

■ ■

A distributed object model extends the Java object model to A distributed object model extends the Java object model to remote objects remote objects

■ ■

A remote object is an object whose methods can be accessed A remote object is an object whose methods can be accessed from another address space from another address space

◆ ◆ Remote objects are described by a remote interface

Remote objects are described by a remote interface

✦ ✦ a Java interface that declares the methods of the remote object

a Java interface that declares the methods of the remote object

◆ ◆ Methods on remote objects are invoked by means of Java RMI

Methods on remote objects are invoked by means of Java RMI

27י"סשת ןסינ ג"ג The Computer Communication Cource

Remote Objects

■ ■

The Java object model is fully supported for remote objects in a The Java object model is fully supported for remote objects in all ll

  • ther respects:
  • ther respects:

◆ ◆ A reference to a remote object

A reference to a remote object

✦ ✦ Can be passed/returned as an argument/a result of invocation,

Can be passed/returned as an argument/a result of invocation, either local or remote either local or remote

✦ ✦ Can be cast to any remote interface supported by the

Can be cast to any remote interface supported by the implementation implementation

✦ ✦ Instanceof

Instanceof can be applied can be applied

◆ ◆ Exact types of parameters passed to remote invocation need not b

Exact types of parameters passed to remote invocation need not be e known at compile known at compile-

  • time (polymorphism is fully supported)

time (polymorphism is fully supported)

◆ ◆ Etc

Etc… …

28י"סשת ןסינ ג"ג The Computer Communication Cource

Java RMI: Client Stubs

■ ■

Stubs are tied up to the object implementation, not to the Stubs are tied up to the object implementation, not to the interface interface

◆ ◆ Allows for object specific stubs with object specific optimizati

Allows for object specific stubs with object specific optimizations

  • ns

■ ■

After a remote object is created, its stub can be dynamically After a remote object is created, its stub can be dynamically loaded into the client virtual machine loaded into the client virtual machine

◆ ◆ The local stub reference serves as a remote object reference

The local stub reference serves as a remote object reference

29י"סשת ןסינ ג"ג The Computer Communication Cource

Working with Java RMI

30י"סשת ןסינ ג"ג The Computer Communication Cource

Java RMI Architecture

Stubs Skeletons Remote Reference Layer Transport Client Server Application RMI System

Marshaling/ unmarshaling Invocation semantics Connection setup and management