30
Communication between distributed objects 姓姓 : 姓姓 :M9129017

Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Embed Size (px)

Citation preview

Page 1: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Communication between distributed objects

姓名 : 邱 秀 純學號 :M9129017

Page 2: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Figure 5.1Middleware layers

Applications

Middlewarelayers Request reply protocol

External data representation

Operating System

RMI, RPC and events

Page 3: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Middleware Software that provides a programming model above the

basic building blocks of processes and message passing is called middleware

Location transparency and independence from the details of communication protocols ,OS and computer hardware

Use of several programming languages

Page 4: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

interfaces Control the possible interactions between modules, an

explicit interface is defined for each module. CORBA IDL interfaces can specify attributes parameter-passing mechanisms

Input output

Pointer

Page 5: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Service interfaces: Is used to refer to the specification of the procedures

offered by a sever , defining the types of the input and output arguments of each of the procedures

Remote interfaces: Specifies the methods of an object that are available for

invocation by object in other processes ,defining the types of the input and output arguments of each of them.

The big difference can pass object as argument and results of methods

Page 6: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

IDL Designed to allow objects implemented in different

languages to invoke one another

Page 7: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Figure 5.2CORBA IDL example

// In file Person.idlstruct Person {

string name; string place;long year;

} ;interface PersonList {

readonly attribute string listname;void addPerson(in Person p) ;void getPerson(in string name, out Person p);long number();

};

Page 8: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Object model Object references Interfaces Action Exceptions Garage collection

Page 9: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Distributed objects A program is partitioned into separate parts ,each of which

is associated with an object advantage

Avoid conflicting accessObject may be accessed via RMIObject are accessed only via their method gives another

advantage for heterogeneous systems in that different data formats may be used at different sites

Page 10: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Distributed object model Extension to the object model to make it applicable to

distributed object Method invocation:

Method invocation between objects in the same process are local method invocation

Method invocation between objects in differences processes are Remote method invocation

Page 11: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Figure 5.3Remote and local method invocations

invocation invocationremote

invocationremote

locallocal

local

invocation

invocationA B

C

D

E

F

Page 12: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Two fundamental concepts:

Remote object reference: Other objects can invoke the methods of a remote object if

they have access to its remote object reference Is an identifier that can be used throughout a distributed

system to refer to a particular unique remote object

Remote interface: Every remote object has a remote interface that specifies

which of its method can be invoked remotely An interface is allowed to extend one or more other interface

Page 13: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Figure 5.4A remote object and its remote interface

interfaceremote

m1m2m3

m4m5m6

Data

implementation

remoteobject

{ of methods

Page 14: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Figure 5.5Invocation semantics

Fault tolerance measures Invocation semantics

Retransmit request message

Duplicate filtering

Re-execute procedure or retransmit reply

No

Yes

Yes

Not applicable

No

Yes

Not applicable

Re-execute procedure

Retransmit reply At-most-once

At-least-once

Maybe

Exactly once: local invocations

Page 15: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Maybe& At-least-once & At-most-once

MaybeThe invoker cannot tell whether a remote method

has been executed once or not at allNone of the fault tolerance measure is applied ,there

are two failure: Omission failures Crash failures

At-least-onceAt-least-once have two failure:

Crash failures Arbitrary failures

Page 16: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Figure 5.6The role of proxy and skeleton in remote method invocation

object A object Bskeleton

Requestproxy for B

Reply

CommunicationRemote Remote referenceCommunication

module modulereference module module

for B’s class& dispatcher

remoteclient server

Page 17: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Communication moduleRemote reference module is responsible for (1)translating between local and remote object

reference (2)creating remote object reference

remote object table :record the correspondence between local object references in that process and emoted object references

Table includes:An entry for all the remote objects held by the processAn entry for each local proxy

Page 18: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

何 謂 RMI

RMI : Remote Method Invocation( 遠端方法呼叫 )  功能:讓客戶端執行的程式去呼叫遠端伺服器所提供

的方法  原理:與 SUN 的 RPC 的功能類似,它將參數資料匯

集 (marshalling) 串列化 (serialization) 後傳送到另一台主機上,並利用該主機所提供的函式來處理這些資料,然後再將所得到結果串列化後傳送回來。可以說是 Java 版的 RPC 。  

不同: RPC 利用 UDP 協定, RMI 利用 TCP 協定  

Page 19: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

架構圖

Page 20: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Stub :客戶端的代理人,當客戶端要呼叫遠端的方法時,將它的參數傳遞出去,並不會有直接到遠端主機,而是先到stub , stub 負責找到提供方法的遠端主機位址,然後再將參數串列化

Skeleton :伺服端的代理人,當它接收列串列化的資料後,先將資料反串列化組合回來,接著看客戶需要用什麼方法處理,在伺服端找到該方法,經過該方法處理後,便得到一個回傳值。同理 Skeleton 也須將回傳值做串列化,傳給 Stub

Page 21: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Remote reference layer : 負責處理遠端物件的 呼叫語意 (semantic of invocation) 

決定遠端物件是否被複製 (replicated) 。 如果遠端物件被複製,則負責確保每個副本所收到的呼叫要求是 atomic

負責處理伺服器的參考語意 (reference semantic for servers)  遠端物件可以在某個 Java 虛擬機器 (VM) 內一直存在,等著被呼叫 。 或是在有其他物件呼叫它時才真的去建立遠端物件。

Transport layer : 負責建立每對虛擬機器間唯一的一條通道 (channel) 。 每當有資料需要傳輸時,會在通道內建立連線 (connection) 。

Page 22: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

The RMI software

Proxy: make remote method invocation transparent to clients by behaving like a local object to the invoker

Dispatcher: A server has one dispatcher and skeleton for each class representing a remote object

Skeleton :The class of a remote object has a skeleton ,which implement the methods in the remote interface

Page 23: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Interface complier automatically generation of the classes for proxies ,dispatchers and Skeleton

Server and client Program server program contain the classes for the dispatchers and

skeletons Client program :the classes of the proxies

The binder : in the distributed system is a separate service that maintain a table containing mapping from textual name to remote object references

Server threads: to avoid the execution of one remote invocation delaying the execution of another

Activation of remote objects Persistent object stores Object location

Page 24: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Distributed garbage collection

Aim distributed garbage collector ensure that if a local or remote

reference to an object is still held anywhere in a set of distributed object ,then the object itself will continue to exist ,but as soon as no object any a reference to it ,then object will be collected and the memory it uses recovered

Java distributed garbage collection algorithm(P182)

Page 25: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Figure 5.7Role of client and server stub procedures in RPC

client

Request

Reply

CommunicationCommunication

module module dispatcher

service

client stub

server stubprocedure procedure

client process server process

procedureprogram

Page 26: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Events and notifications

publish-subscribe paradigm Publish: an object that generates events publish the type

of events Subscribe to the types of events that are of interest to

them

Distributed event-base system have two main characteristics Heterogeneous asynchronous

Page 27: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Figure 5.9Dealing room system

Dealer’s computer

Informationprovider

Dealer

Externalsource

Externalsource

Informationprovider

Dealer

Dealer

Dealer

Notification

Notification

Notification

Notification

NotificationNotification

Notification

Notification

Dealer’s computer

Dealer’s computerDealer’s computer

NotificationNotification

Page 28: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Figure 5.10Architecture for distributed event notification

subscriberobserverobject of interest

Event service

object of interest

object of interest observer

subscriber

subscriber

3.

1.

2. notification

notification

notification

notification

Page 29: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Roles for Observers

ForwardingFiltering of notificationsPatterns of eventsNotification mailbox

Page 30: Communication between distributed objects 姓名 : 邱 秀 純 學號 :M9129017

Jini

The main object involved in the Jini distributed event distributed event specification Event generator Remote event listener Remote events Third-party events