Unit-Iii Distributed Objects and Remote Invocation
Unit-Iii Distributed Objects and Remote Invocation
Unit-Iii Distributed Objects and Remote Invocation
Distributed objects are objects that are distributed across different address
spaces, either in multiple computers connected via a network or even indifferent
processes on the same computer, but which work together by sharing data and
invoking methods. This often involves location transparency, where remote objects
appear the same as local objects.
The main method of distributed object communication is with remote method invocation
Remote method invocation (RMI) is similar to RPC but for distributed objects, with
Added benefits in terms of using object-oriented programming concepts in
Distributed systems and also extending the concept of an object reference to the
Global distributed environments, and allowing the use of object references as
Parameters in remote invocations
Remote procedure call – client calls the procedures in a server program that is
running in a different process.
Remote method invocation (RMI) – an object in one process can invoke methods
of objects in another process.
Event notification – objects receive notification of events at other objects for which they
have registered.
Middleware Roles - provide high-level abstractions such as RMI enable location
transparency free from specifics of communication protocols, operating systems and
communication hardware
•Distributed Systems: Earlier middleware was based on the client-server model and
there was a desire for more sophisticated programming abstraction
•Programming languages: Earlier work in object language such as simula67 & small
talk led to emergence of more mainstream & heavily used programming lang such
as Java & C++
COMMUNICATION BETWEEN DISTRIBUTED OBJECTS AND OTHER
OBJECTS:
Life cycle : Creation, migration and deletion of distributed objects is different
from local objects
Reference : Remote references to distributed objects are more complex than
simple pointers to memory addresses
Request Latency : A distributed object request is orders of magnitude slower
than local method invocation
Object Activation : Distributed objects may not always be available to serve
an object request at any point in time
Parallelism: Distributed objects may be executed in parallel.
Communication : There are different communication primitives available for
distributed objects requests
Failure: Distributed objects have far more points of failure than typical local
objects.
Security: Distribution makes them vulnerable to attack.
DISTRIBUTED OBJECT MODEL:
The term distributed objects usually refers to software modules that are
designed to work together, but reside either in multiple computers connected via a
network or in different processes inside the same computer.
Distributed objects
The state of an object consists of the values of its instance variables since object
object-
based programs are logically
ogically partitioned, the physical distribution of objects into
different processes or computers in a distributed system. Distributed object systems may
adopt the client- server architecture. objects are managed by servers and their clients
invoke their methods
thods using remote method invocation.
In RMI, the client‘s request to invoke a method of an object is sent in a message to
the server managing the object. The invocation is carried out by executing a method of
the object at the server and the result is returned
returned to the client in another message
Distributed objects can assume other architectural models. For example,
objects can be replicated in order to obtain the usual benefits of fault tolerance and
enhanced performance, and objects can be migrated with a view to enhancing their
performance and availability.
Another advantage of treating the shared state of a distributed program as a
collection of objects is that an object may be accessed via RMI, or it may be copied into
a local cache and accessed directly, provided that the class implementation is available
locally.
DESIGN ISSUES OF RMI:
RMI Invocation Semantics:
Invocation semantics depend upon implementation of Request Reply Protocol
used by RMI It maybe, used At-least-once, At-most-once
Transparency:
Partial failure, higher latency, Different semantics for remote objects,
For e.g. wait/notify 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.
Issues in implementing RMI
Parameter passing
Request reply protocol (handling failures at client and server)
Supporting constant objects, object adapters, dynamic invocations, etc
The design goal for the RMI architecture was to create a Java distributed object
model that integrates naturally into the Java programming language and the local object
model. RMI architects have succeeded; creating a system that extends the safety and
robustness of the Java architecture to the distributed computing world.
The RMI architecture is based on one important principle: the definition of
behavior and the implementation of that behavior are separate concepts. RMI allows the
code that defines the behavior and the code that implements the behavior to remain
separate and to run on separate JVMs.
DGC uses some combination of the classical garbage collection (GC) techniques,
tracing and reference counting. It has to cooperate
cooperate with local garbage collectors in each
process in order to keep global counts, or to globally trace accessibility of data.
DGC is complex and can be costly and slow in freeing memory. One cheap way
of avoiding DGC algorithms is typically to rely on
on a time lease set or configured on
the remote object; it is the stub'
stub'ss task to periodically renew the lease on the remote
object.
If the lease has expired, the server process (the process owning the remote
object) can safely assume that either the client is no longer interested in the object, or
that a network partition or crash obstructed lease renewal, in which case it is "hard
luck" for the client if it is in fact still interested.
Hence, if there is only a single reference to the remote object on the server
representing a remote reference from that client, that reference can be dropped, which
will mean the object will be garbage collected by the local garbage collector on the
server at some future point in time.
Distributed systems typica
typically
lly require distributed garbage collection. If a client
holds a proxy to an object in the server, it is important that the server does not
garbage-collect
collect that object until the client releases the proxy. Most third-party
third
distributed systems, such as RMI, handle
handle the distributed garbage collection, but that
does not necessarily mean it will be done efficiently. The overhead of distributed
garbage collection and remote reference maintenance in RMI can slow network
communications by a significant amount when ma
many objects are involved.
REMOTE PROCEDURE CALL (RPC)
Remote Procedure Call (RPC) is a protocol that one program can use to request
a service from a program located in another computer in a network without having to
understand network details. (A procedure call is also sometimes known as a function
call or a subroutine call.) RPC uses the client/server model.
An RPC is analogous to a function call. Like a function call, when an RPC is made,
the calling arguments are passed to the remote procedure and the caller waits for a
response to be returned from the remote procedure.
The flow of activity that takes place during an RPC call between two networked
systems. The client makes a procedure call that sends a request to the server and waits.
The thread is blocked from processing until either a reply is received, or it times out.
When the request arrives, the server calls a dispatch routine that performs the
requested service, and sends the reply to the client. After the RPC call is completed, the
client program continues. RPC specifically supports network applications.
Publish-subscribe
subscribe paradigm: publisher sends notifications, i.e. objects representing
events ‹ Subscriber registers interest to receive notifications
The object of interest: where events happen, change of state as a result of its
operations being invoked „
Events: occurs in the object
ct of interest
Notification: an object containing information about an event
UnicastRemote Object:
automatically creates socket and listens for network requests, and make its services
available by exporting them.
RMISecurityManager (): Needed to download objects from network. The downloaded
objects are allowed to communicate only with sites they came from.
Default security manager, when none is explicitly set, allows only loading from local file
system
Reflection: the class of an object can be determined at runtime, and this class can be
examined to determine which methods are available, and even invoke these methods
with dynamically created arguments „
External data representation and marshalling ‹ CORBA marshals data for use by
recipients that have prior knowledge of the types of its components. It uses an IDL
specification of the data types ‹ Java serializes data to include information about the
types of its contents, allowing the recipient to reconstruct it. It uses reflection to do this. „
RMI ‹ Each object has a (global) remote object reference and a remote interface that
specifies which of its operations can be invoked remotely. ‹ local method invocations
provide exactly-once semantics; the best RMI can guarantee is at- most-once ‹
Middleware components (proxies, skeletons and dispatchers) hide details of marshalling,
message passing and object location from programmers.