Remote reference module

Download Report

Transcript Remote reference module

Communication between distributed
objects
姓名: 邱 秀 純
學號:M9129017
Figure 5.1
Middleware layers
Applications
RMI, RPC and events
Request reply protocol
External data representation
Operating System
Middleware
layers
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
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
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
IDL
Designed to allow objects implemented in different
languages to invoke one another
Figure 5.2
CORBA IDL example
// In file Person.idl
struct 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();
};
Object model
Object references
Interfaces
Action
Exceptions
Garage collection
Distributed objects
A program is partitioned into separate parts ,each of which
is associated with an object
advantage
Avoid conflicting access
Object may be accessed via RMI
Object are accessed only via their method gives another
advantage for heterogeneous systems in that different data
formats may be used at different sites
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
Figure 5.3
Remote and local method invocations
local
remote
invocation
A
B
C
local E
invocation
invocation
local
invocation
D
remote
invocation
F
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
Figure 5.4
A remote object and its remote interface
remoteobject
remote
interface
{
Data
m1
m2
m3
implementation
of methods
m4
m5
m6
Figure 5.5
Invocation semantics
Fault tolerance measures
Retransmit request
message
Duplicate
filtering
Invocation
semantics
Re-execute procedure
or retransmit reply
No
Not applicable
Not applicable
Yes
No
Re-execute procedure
At-least-once
Yes
Yes
Retransmit reply
At-most-once
Exactly once: local invocations
Maybe
Maybe& At-least-once & At-most-once
Maybe
The invoker cannot tell whether a remote method
has been executed once or not at all
None of the fault tolerance measure is applied ,there
are two failure:
Omission failures
Crash failures
At-least-once
At-least-once have two failure:
Crash failures
Arbitrary failures
Figure 5.6
The role of proxy and skeleton in remote method invocation
server
client
object A proxy for B
Request
skeleton
& dispatcher
for B’s class
remote
object B
Reply
Communication
Remote
reference module
module
Communication
module
Remote reference
module
Communication module
Remote 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 process
An entry for each local proxy
何 謂 RMI
RMI : Remote Method Invocation(遠端方法呼叫)
功能:讓客戶端執行的程式去呼叫遠端伺服器所提供
的方法
原理:與SUN 的RPC的功能類似,它將參數資料匯
集(marshalling)串列化(serialization)後傳送到另一台
主機上,並利用該主機所提供的函式來處理這些資料
,然後再將所得到結果串列化後傳送回來。可以說是
Java 版的 RPC。
不同:RPC利用UDP協定,RMI利用TCP協定
架構圖
 Stub:客戶端的代理人,當客戶端要呼叫遠端的方法時,將它
的參數傳遞出去,並不會有直接到遠端主機,而是先到stub,
stub負責找到提供方法的遠端主機位址,然後再將參數串列化
 Skeleton:伺服端的代理人,當它接收列串列化的資料後,先
將資料反串列化組合回來,接著看客戶需要用什麼方法處理,
在伺服端找到該方法,經過該方法處理後,便得到一個回傳值
。同理Skeleton也須將回傳值做串列化,傳給Stub
Remote reference layer:
負責處理遠端物件的 呼叫語意 (semantic of invocation)
決定遠端物件是否被複製 (replicated) 。
如果遠端物件被複製,則負責確保每個副本所收到的呼叫要求是
atomic。
負責處理伺服器的參考語意 (reference semantic for servers)
遠端物件可以在某個 Java 虛擬機器(VM) 內一直存在,等著被呼叫 。
或是在有其他物件呼叫它時才真的去建立遠端物件。
Transport layer:
負責建立每對虛擬機器間唯一的一條通道 (channel)。
每當有資料需要傳輸時,會在通道內建立連線 (connection)。
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
 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
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)
Figure 5.7
Role of client and server stub procedures in RPC
client process
server process
Request
client stub
procedure
client
program
Communication
module
Reply
server stub
procedure
Communication
dispatcher
module
service
procedure
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
Figure 5.9
Dealing room system
Dealer’s computer
Dealer
Dealer’s computer
External
source
Notification
Notification
Notification
Information
provider Notification
Notification
Dealer
Notification
Notification
Dealer’s computer
Dealer’s computer
Notification
Information
provider
Notification
Notification
Dealer
Dealer
External
source
Figure 5.10
Architecture for distributed event notification
Event service
subscriber
object of interest
1.
notification
object of interest
2.
object of interest
3.
notification
observer
subscriber
notification
observer
subscriber
notification
Roles for Observers
Forwarding
Filtering of notifications
Patterns of events
Notification mailbox
Jini
The main object involved in the Jini distributed event
distributed event specification
Event generator
Remote event listener
Remote events
Third-party events