Remote Object Invocation
Remote Object Invocation
RMI
Middleware layers
Applications, services RMI and RPC request-reply protocol marshalling and external data representation UDP and TCP Middleware layers
RMI
Distributed Objects
2-16
proxy.
RMI
ways
compile-time objects, i.e. instances of classes written in object-oriented languages like Java, C++ database objects procedural languages like C, with a appropriate wrapper code that gives it the appearance of an object
these systems use object adapters implementations of object interfaces are registered at an object adapter, which acts as an intermediary between the client and object implementation
RMI
are not contained in the address space of a server process The state of a persistent object has to be stored on a persistent store, i.e., secondary storage Invocation requests result in an instance of the object being created in the address space of a running process
RMI
declare the interface in IDL, compile the IDL file to generate client and server stubs, link them with client and server side code to generate the client and the server executables referred to as static invocation requires the object interface to be known when the client is being developed
useful for applications where object interfaces are discovered at run-time, e.g. object browser, batch processing systems for object invocations, agents
RMI 6
Transparency
Invocation semantics depend upon implementation of RequestReply protocol used by R MI Maybe, At-least-once, At-most-once Should remote invocations be transparent to the programmer?
Current consensus: remote invocations should be made transparent in the sense that syntax of a remote invocation is the same as the syntax of local invocation (access transparency) but programmers should be able to distinguish between remote and local objects by looking at their interfaces, e.g. in Java RMI, remote objects implement the Remote interface
Partial failure, higher latency Different semantics for remote objects, e.g. difficult to implement cloning in the same way for local and remote objects or to support synchronization operations, e.g. wait/notify
RMI
RMI
Request-reply communication
Client Server
doOperation
(continuation)
RMI
RMI
10
RMI
11
32 bits
32 bits
32 bits time
RMI
12
RMI
13
Request-Reply protocol
Issues in marshaling of parameters and
results
Input, output, Inout parameters Data representation Handling reference parameters Distributed object references Handling failures in request-reply protocol Partial failure
Client, Server, Network
RMI
14
Marshalling
Pack method arguments and results into a
flat array of bytes Use a canonical representation of data types, e.g. integers, characters, doubles Examples
SUN XDR CORBA CDR Java serialization
RMI
15
value.
2-18
Remote object references are passed by reference where local object references are passed by value
RMI 16
RMI
17
The flattened form represents a Person struct with value: {Smith, London, 1934}
RMI
18
Serialized values Person 3 1934 8-byte version number int year 5 Smith h0 java.lang.String java.lang.String name: place: 6 London h1
Explanation class name, version number number, type and name of instance variables values of instance variables
The true serialized form contains additional type markers; h0 and h1 are handles
RMI
19
Acknowledge reply
RMI
20
10
Handling failures
Types of failure Client unable to locate server Request message lost Reply message lost Server crashes after receiving a request Client crashes after sending a request
RMI
21
Handling failures
Client cannot locate server Reasons
Server has crashed Server has moved (RPC systems) client compiled using old version of service interface
RMI
22
11
Handling failures
Lost request message Retransmit a fixed number of times before throwing an exception Lost reply message Client resubmits request Server choices
Re-execute procedure service should be idempotent so that it can be repeated safely Filter duplicates server should hold on to results until acknowledged
RMI
23
Invocation semantics
Fault tolerance measures Retransmit request Duplicate message filtering No Yes Yes Re-execute procedure or retransmit reply Maybe Invocation semantics
RMI
24
12
Handling failures
Server crashes REQ Recv Exec Reply NO REP REQ Recv Exec Crash NO REP Client cannot tell difference
RMI
REP
25
Handling failures
Server crashes At least once (keep trying till server comes up again) At most once (return immediately)
SUN RPC At least once semantics on successful call and maybe semantics if unsuccessful call CORBA, Java RMI at most once semantics
RMI 26
13
Handling failures
Implementing the request-reply protocol
on top of TCP
RMI
27
Handling failures
Client crashes If client crashes before RPC returns, we have an orphan computation at server
Wastes resources, could also start other computations
Orphan detection
Reincarnation (client broadcasts new epoch when it comes up again) Expiration (RPC has fixed amount of time T to do work)
RMI
28
14
RMI
29
RMI
30
15
Object Activation
Active and passive objects Active object = instantiated in a running process Passive object = not currently active but can be made active
Activator responsible for Registering passive objects that are available for activation Starting named server processes and activating remote objects in them Keeping track of locations of servers for remote objects that it has already activated
RMI
31
16
Use of Reflection in Java RMI Allows construction of generic dispatcher and skeleton
RMI 33
RMI
34
17