Distributed Systems
5. Remote Method Invocation
Werner Nutt
1
Middleware
Middleware offers an infrastructure that enables
application processes to communicate with each other
Processes issue requests to the transportation layer
(i.e., the application takes the initiative, not the middleware)
Applications access the middleware via APIs, e.g.,
– creation and manipulation of sockets
Integration into programming languages
– remote procedure call (RPC)
– remote method invocation (RMI)
For higher level APIs, data has to be transformed before it
can be shipped (“data marshalling”)
Protocols for Client/Server Interaction (“Request/Reply”)
3
Why Middleware?
Distributed computing environments are heterogeneous:
Networks
– ATM, Ethernet, etc. have different protocols
Computer hardware
– data types (integers) can be represented differently
Operating systems
– e.g., TCP module can be part of OS (Unix/Linux) or not
Programming languages
– e.g., different paradigms (functional, OO, etc.)
– e.g., data structures (arrays, records) can be represented
differently
Applications implemented by different developers
4Middleware Hides Heterogeneity
Applications
RMI, RPC and events
Middleware
Request reply protocol
layers
External data representation
Operating System
5
Middleware Characteristics
Location transparency
– client/server need not know their location
Sits on top of OS, independent of
– Communication protocols:
use abstract request-reply protocols over UDP, TCP
– Computer hardware:
use external data representation e.g. CORBA CDR
– Operating system:
use e.g. socket abstraction available in most systems
– Programming language:
e.g. CORBA supports Java, C++
6
Middleware Programming Models
Commonly used models:
Distributed objects and remote method invocation
(Java RMI, Corba)
Remote Procedure Call (Web services)
Remote SQL access (JDBC, ODBC)
Distributed transaction processing
CORBA:
provides remote object invocation between
– a client program written in one language and
– a server program written in another language
commonly used with C++
7
Objects
object
object
Data
Data
interface
m1
m1
implementation
implementation
m2
m2
m3 m3
of methods
of methods
Object = data + methods
– logical and physical encapsulation
– accessed by means of references
– first class citizens, can be passed as arguments
Interaction via interfaces
– define types of arguments and exceptions of methods
8Î
ÎÎ
The Object Model
Programs are (logically and physically) partitioned into objects
distributing objects natural and easy
Interfaces
– the only means to access data
make them remote
Actions
–via method invocation
– interaction, chains of invocations
– may lead to exceptions part of interface
Garbage collection
– reduces programming effort, error-free (Java, not C++)
9
The Distributed Object Model: Ideas
local C
remote
E
local
invocation invocation
remote
invocation
invocation
F
B
A local
invocation
D
Objects are distributed
– client-server relationship at the object level
Extended with
– Remote interfaces
– Remote Method Invocation (RMI)
– Remote object references
10Î
The Distributed Object Model: Principles
local C
remote
E
local
invocation invocation
remote
invocation
invocation
F
B
A local
invocation
D
Each process contains objects, some of which can receive
remote invocations, others only local invocations
Objects that can receive remote invocations are called remote objects
The remote interface specifies which methods can be invoked remotely
Objects need to know the remote object reference of an object in another
process in order to invoke its methods How do they get it?
11
Remote Object References
Object references
– used to access objects, which live in processes
– can be passed as arguments and results
– can be stored in variables
Remote object references
– object identifiers in a distributed system
–must be unique in space and time
– error returned if accessing a deleted object
– can allow relocation (see CORBA)
12Î
Remote Object Reference
Construct unique remote object reference
– IP address, port, interface name
– time of creation, local object number
(new for each object)
Use in the same way as local object references
If used as address
cannot support relocation
32 bits 32 bits 32 bits 32 bits
interface of
port number
Internet address time object number
remote object
13Î
Remote Interfaces
Specify externally accessible methods
–no direct references to variables (no global memory)
–local interface is separate
Parameters
– input, output or both
(no output parameters in Java why? )
– call by value and call by reference
No pointers
– but references
No constructors
–but factory methods
14
A Remote Object and its Interface
remoteobject
Data
remote
interface
m4
m1
implementation
m5
m2
m6
of methods
m3
CORBA: Interface Definition Language (IDL)
Java RMI: like other interfaces, extends class Remote
15
Handling Remote Objects
Exceptions (Java: RemoteException)
–raised in remote invocation
– clients need to handle exceptions
– timeouts in case server crashed or too busy
Garbage collection
–distributed garbage collection may be necessary
– combined local and distributed collector
– cf. Java reference counting
(remote object knows in which processes live proxies,
extra communication to inform server about creation and
delection of proxies)
16ÎÎÎ
RMI Issues
Local invocations
– executed exactly once
Remote invocations
– via Request-Reply
– may suffer from communication failures
retransmission of request/reply
message duplication, duplication filtering
no unique semantics…
17Invocation Semantics
Invocation
Fault tolerance measures
semantics
Retransmit request Duplicate Re-execute procedure
message filtering or retransmit reply
No Not applicable Not applicable Maybe
Yes No Re-execute procedure At-least-once
Yes Yes Retransmit reply At-most-once
18
Maybe Invocation
Remote method
–may execute or not at all, invoker cannot tell
– useful only if failures are rare
Invocation message lost...
– method not executed
Result not received...
– was method executed or not?
Server crash...
–before or after method executed?
– if timeout, result could be received after timeout …
19
At-least-once Invocation
Remote method
– invoker receives result (executed at least once) or
exception (no result, executed one or more times)
– retransmission of request messages
Invocation message retransmitted …
– method may be executed more than once
– arbitrary failure (wrong result possible)
– method must be idempotent (repeated execution has
the same effect as a single execution)
Server crash...
– dealt with by timeouts, exceptions
20
At-most-once Invocation
Remote method
– invoker receives result (executed once) or exception
(no result)
– retransmission of reply and request messages
– receiver keeps history with results (how long?)
– duplicate filtering
Best fault-tolerance ...
– arbitrary failures prevented if method called
at most once
Used by CORBA and Java RMI
21
Advise:Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.