• No results found

Distributed Objects

N/A
N/A
Protected

Academic year: 2022

Share "Distributed Objects"

Copied!
29
0
0

Loading.... (view fulltext now)

Full text

(1)

Distributed Objects

(2)

Introduction

A distributed object-based system is a collection of objects that isolates the requesters of services (clients) from the providers of services (servers) by a well-defined encapsulating interface.

In other words, clients are isolated from the implementation of services as data representations

and executable code.

(3)

This is one of the main differences that distinguishes the distributed object-based model from the pure client/server model.

In the distributed object-based model, a client sends a message to an object, which in turns interprets the message to decide what service to perform.

This service, or method, selection could be performed by either the object or a

broker. The Java Remote Method Invocation (RMI) and the Common Object

Request Broker Architecture (CORBA) are examples of this model.

(4)

The Roles of Client & Server

Client Server

Send request data

Return response data

Transmitting objects between client and server

(5)

The client/server model is a form of distributed computing in which one program (the client) communicates with another program (the server) for the purpose of exchanging information.

In this model, both the client and server usually speak the same language -- a protocol that both

the client and server understand -- so they are able to communicate.

(6)

While the client/server model can be implemented in various ways, it is typically done using low-level sockets.

Using sockets to develop client/server systems means that we must design a protocol, which is a set of commands agreed upon by the client and server through which they will be able to

communicate.

(7)

As an example, consider the HTTP protocol that provides a method called GET, which must be implemented by all web servers and used by web clients (browsers) in order to retrieve

documents.

(8)

The Distributed Objects Paradigm

(9)

Remote Method Call with Proxies

(10)

A distributed object is provided, or exported, by a process, here called the object server. A facility, here called an object registry, must be present in the system architecture for the distributed object to be registered.

To access a distributed object, a process –an object

client–looks up the object registry for a reference to the object. This reference is used by the object client to make calls to the methods.

A reference is a “handle”for an object; it is a representation through which an object can be located in the computer

where the object resides.

(11)

Logically, the object client makes a call directly to a remote method.

In reality, the call is handled by a software component, called a client proxy, which interacts with the software on the client host that provides the runtime support for the distributed object system.

The runtime support is responsible for the inter-process-communication needed to transmit the call to the remote host, including the marshalling of the

argument data that needs to be transmitted to the remote object.

(12)

A similar architecture is required on the server side, where the runtime support for the

distributed object system handles the receiving of messages and the unmarshalling of data, and forwards the call to a software component called the server proxy.

The server proxy interfaces with the distributed object to invoke the method call locally, passing in the unmarshalled data for the arguments.

The method call results in the performance of some tasks on the server host. The outcome of

the execution of the method, including the marshalled data for the return value, is forwarded by

the server proxy to the client proxy, via the runtime support and network support on both sides.

(13)

The distributed object paradigm has been widely adopted in distributed applications, for which a large number of mechanisms based on the paradigm are available. Among the most well known of such mechanisms are:

◦ Java Remote Method Invocation(RMI),

◦ the Common Object Request Broker Architecture(CORBA) systems,

◦ the Distributed Component Object Model(DCOM),

◦ mechanisms that support the Simple Object Access Protocol(SOAP).

Of these, the most straightforward is the Java RMI

(14)

RMI

RMI is a distributed object system that enables you to easily develop distributed Java applications.

Developing distributed applications in RMI is simpler than developing with

sockets since there is no need to design a protocol, which is an error-prone task.

In RMI, the developer has the illusion of calling a local method from a local class file, when in fact the arguments are shipped to the remote target and

interpreted, and the results are sent back to the callers.

(15)

Remote Method Invocation (RMI) is an object-oriented implementation of the Remote Procedure Call model. It is an API for Java programs only.

Using RMI, an object server exports a remote object and registers it with a directory service. The object provides remote methods, which can be invoked in client programs.

Syntactically:

◦ A remote object is declared with a remote interface, an extension of the Java interface.

◦ The remote interface is implemented by the object server.

◦ An object client accesses the object by invoking the remote methods associated with the objects using syntax provided for remote method invocations.

(16)

Stubs and Parameter Marshalling

When client wants to invoke a remote method on a remote object, it actually calls an ordinary method on proxy object called a stub.

Stub resides on the client machine.

Stub packages the parameters used in the remote method into a block of bytes.

This packaging uses the device independent encoding for each parameter.

(17)

The process of encoding the parameters is called parameter marshalling.

The purpose of parameter marshalling is to convert the parameters into a format suitable for

transport from one virtual machine to another.

(18)

The stub method on the client machine builds an information block that consists of:

◦ An identifier of the remote object to be used

◦ A descriptor of the method to be called

◦ The marshalled parameter

(19)

The stub then send this information to the server.

(20)

Server side, a receiver object performs the following actions for every remote method call:

◦ It unmarshals the parameters

◦ It locates the object to be called

◦ It calls the desired method

◦ It capture and marshals the return value or exception of the call

◦ It sends a package consisting of the marshalled return back to the stub on the client.

(21)

The client stub un-marshals the return value or exception from the server.

This value becomes the return of the stub call.

Or, if the remote method threw an exception, the stub rethrows it in the process space of the

caller.

(22)

Client Stub Skeleton Server

Call stub method locally

Send marshalled parameters Call Server method locally

Return method result Send marshalled return value

or exception Return value or

throw exception

Parameter marshalling

(23)

The syntax for remote method call is the same as of local call.

Interfaces are abstract entities that only spell out what method can be called along with their signatures.

Variables whose type is an interface must always be bound to an actual object of some type.

When remote methods are called, the object variable refers to a stub object.

The client program does not actually know the type of those objects.

The stub classes and the associated objects are created automatically.

(24)

Dynamic Class Loading

When you pass a remote object to another program, either as a parameter or return value of a remote method, then program must have the class file for that object.

As you know basic work of class loader is to load the necessary class files from the server

(25)

Whenever a program loads new code from another network location, there is a security issue.

For this reason we need to use a security manager in RMI client applications.

This is a safety mechanism that protects the program from viruses in stub code.

(26)

Setup for RMI

You must run programs on both the server and client computers.

The necessary object information may be separated into client side interfaces and server side

implementations.

(27)

Interfaces & Implementations

Client program needs to manipulate server objects, but it doesn’t actually have copies of them.

The objects themselves reside on the server.

The client code must still know what it can do with those objects.

(28)

Their capabilities are expressed in an interface that is shared between the client and server and

so resides on both machines.

(29)

RMI Architecture

References

Related documents

Descriptive statistics was used to analyze socio-economic characteristics of household heads and share of each energy source on total expenditure on energy while

Variable Coefficient Std. Error t-Statistic Prob. All CoCo features included as explanatory variables are also regressed separately on the dependent variable in

We Treat The Open Group Member’s to be an invited ReGIS Member’s without fee.; We had published in 2014, 24 GIS FORUM Members News Letters “#415 to #438 (Mail

Using available published data from relevant surveys of AMF in flowering plants, we calculated the proportion of non- Glomeraceae DNA sequences and, where possible, the proportion

Longitudinal collection of electronic health information for and about persons, where health information is defined as information pertaining to the health of an

The client needs both the interface code for the remote object and the generated stub class. With those two elements, it can use remote objects as if they were local to its own

I The RMIClassLoader is used to load those classes not directly used by the client or server application: the stubs and skeletons of remote objects, and extended classes of

Second, to the extent that a direct analogy to “time, place, and manner” regulations is appropriate, most—I would say almost all— regulations of weapons are indeed such