distributed objects
DESCRIPTION
Distributed Objects. Message Passing Vs Distributed Objects. Message Passing. The message-passing paradigm is a natural model for distributed computing in the sense that it mimics interhuman communications. Message Passing. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/1.jpg)
Distributed Objects
Message Passing VsDistributed Objects
![Page 2: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/2.jpg)
Message Passing
The message-passing paradigm is a natural model for distributed computing in the sense that it mimics interhuman communications.
![Page 3: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/3.jpg)
Message Passing
It is an appropriate paradigm for network services where processes interact with each other through the exchange of messages.
![Page 4: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/4.jpg)
Message Passing
The abstraction provided by this paradigm may not meet the needs of some complex network applications for the following reasons:
![Page 5: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/5.jpg)
Message Passing
Basic message passing requires that the participating processes be tightly coupled.
Throughout their interaction, the processes must be in direct communication with each other.
![Page 6: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/6.jpg)
Message Passing
If the communication is lost between the processes the collaboration fails.
Example: Consider a session of the Echo protocol If the communication between the client and the
server is disrupted, the session cannot continue.
![Page 7: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/7.jpg)
Message Passing
The message-passing paradigm is data-oriented.
Each message contains data marshaled in a mutually agreed upon format, and each message is interpreted as a request or response according to the protocol.
![Page 8: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/8.jpg)
Message Passing
Example: Echo Protocol The receiving of a message from a
process p elicits in the Echo server this action: a message containing the same data is sent to p.
![Page 9: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/9.jpg)
Message Passing
The data orientation of the paradigm is appropriate for network services and simple network applications
It is inadequate for complex applications involving large mix of requests and responses.
![Page 10: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/10.jpg)
Distributed Object
The distributed object paradigm is a paradigm that provides abstractions beyond those of the message-passing model.
![Page 11: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/11.jpg)
Distributed Objects
The paradigm is based on objects that exists in a distributed system.
In Object-oriented programming objects are used to represent an entity that is significant to an application.
![Page 12: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/12.jpg)
Distributed Objects
Each Object encapsulates State Operations
![Page 13: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/13.jpg)
Distributed Objects
Example Consider the objects of the
DatagramMessage class as shown
![Page 14: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/14.jpg)
Import java.net.*;
public class DatagramMessage
{
private String message;
private InetAddress senderAddress;
private int senderport;
public void putVal(String message,InetAddress addr, int port)
{ this.message = message;
this.senderAddress=addr;
this.senderPort =port;
}
public String getMessage()
{ return this.message; }
public InetAddress getAddress()
{ return this.senderAddress; }
public int getPort()
{ return this.senderport; }
}
![Page 15: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/15.jpg)
Distributed Objects
Each object instantiated from this class contains three state and three operations.
![Page 16: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/16.jpg)
Distributed Objects
Local objects are objects whose methods can only be invoked by a local process. A process that runs on the same
computer on which the object exists
![Page 17: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/17.jpg)
Distributed Objects
A distributed object is one whose methods can be invoked by a remote process A process running on a computer
connected via a network to the computer on which the object exists.
![Page 18: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/18.jpg)
Distributed Objects
In a distributed object paradigm, network resources are represented by distributed objects.
To request service from a network resources, a process invokes one of its operations or methods, passing data as parameters to the method.
![Page 19: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/19.jpg)
Distributed Objects
The method is executed on the remote host, and the response is sent back to the requesting process as a return value.
![Page 20: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/20.jpg)
Distributed Objects
Compared to the message-passing paradigm, the distributed objects paradigm is action-oriented.
The focus is on the invocation of the operations, while the data passed takes on a secondary role.
![Page 21: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/21.jpg)
Distributed Objects
![Page 22: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/22.jpg)
An Archetypal Distributed Object Architecture
Archetypal Original Model
![Page 23: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/23.jpg)
ADOA
The task of a distributed object system is to minimize the programming
differences between remote method invocations and local invocations,
Allowing remote methods to be invoked in an application using syntax similar to local method invocations.
![Page 24: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/24.jpg)
ADOA
In reality, there are differences because remote method invocations involve communication between independent process.
![Page 25: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/25.jpg)
ADOA
The issues such as data marshalling and event synchornization need to be addressed.
![Page 26: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/26.jpg)
An Archetypal Distributed Object System
OBJECT REGISTRY
CLIENT SERVER
![Page 27: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/27.jpg)
An Archetypal Distributed Object System
Object Registry
OBJECT CLIENT
CLIENT PROXY
RUN-TIME SUPPORT
NETWORK SUPPORT
OBJECT SERVER
SERVER PROXY
RUN-TIME SUPPORT
NETWORK SUPPORT
PHYSICAL DATA PATHLOGICAL DATA PATH
![Page 28: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/28.jpg)
ADOA
A distributed object is provided or exported by a process, here called object server
A distributed object is registered in the object registry
![Page 29: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/29.jpg)
ADOA
A distributed object is accessed by the client process using object client The object client looks up the registry for
a reference to the object. This reference is used by the object client
to make calls to the methods of remote object
![Page 30: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/30.jpg)
ADOA
Logically the object client makes a call directly to a remote method of object server.
Physically the client is handled by a software components called Client proxy - Object on behalf of client Run time support - data marshalling Network support – data transmission
![Page 31: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/31.jpg)
Distributed Object Systems
The distributed object paradigm has been widely adopted in distributed applications, among the most well known of such toolkits are: RMI CORBA DCOM SOAP
![Page 32: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/32.jpg)
Remote Procedure Calls
Remote Method Invocation (RMI) has its origin in a paradigm called Remote Procedure Call.
Procedural Programming predates object-oriented programming.
![Page 33: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/33.jpg)
Remote Procedure Calls
Remote Procedure call model, a procedure call or a function call is made by one process to another, possibly residing in a remote system, with data passed as arguments.
![Page 34: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/34.jpg)
Remote method Invocation
Remote Method Invocation(RMI) is an object-oriented implementation of Remote Procedure Call model.
It is an API for java programs only.
![Page 35: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/35.jpg)
Remoted Method Invocation
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.
![Page 36: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/36.jpg)
Remote Method Invocation
A remote object is declared with a remote interface (in java).
The remote interface is implemented by the object server.
An object client accesses the object by invoking its methods.
![Page 37: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/37.jpg)
Java RMI Architecture
Client-Side Architecture Stub Layer Remote Reference Layer Transport Layer
Server-Side Architecture Skeleton Layer Remote Reference Layer Transport Layer
![Page 38: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/38.jpg)
Client Side Architecture
Stub Layer: A client process’s remote method invocation is directed to a proxy object, known as a stub.
![Page 39: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/39.jpg)
Client Side Architecture
Remote Reference Layer: Interprets and manages references made from clients to remote service objects and issues the IPC operations to next layer.
![Page 40: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/40.jpg)
Client Side Architecture
Transport Layer: It is TCP based and therefore connection-oriented.
This layer and the rest of the network architecture carry out the IPC.
![Page 41: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/41.jpg)
Server-Side Architecture
Skeleton Layer: It lies just below the application layer and serves to interact with the stub layer on the client side.
![Page 42: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/42.jpg)
Server-Side Architecture
Remote Reference Layer: This layer manages and transforms the remote reference originating from the client to local references that are understandable by skeleton layer.
![Page 43: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/43.jpg)
Server Side Architecture
Transport Layer:This layer is a connection oriented layer based on TCP in the TCP/IP suite.
![Page 44: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/44.jpg)
Object Registry
The RMI registry a simple directory service, is provided with the JSDK.
When active it runs on TCP port 1099 by default.
![Page 45: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/45.jpg)
RMI Architecture
Object Registry
OBJECT CLIENT
STUB
Remote reference Layer
Transport Layer
OBJECT SERVER
SKELETON
Remote reference Layer
Transport Layer
Physical pathLogical path
![Page 46: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/46.jpg)
RMI Architecture
Logically, from the point of view the software developer, the remote method invocation issued in a client program interact directly with the remote objects in a server program
![Page 47: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/47.jpg)
RMI Architecture
Physically, the remote method invocation are transformed to calls to the stub and skeleton at runtime, resulting in data transmission across the network.
![Page 48: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/48.jpg)
RMI Stub and RMI SkeletonCLIENT STUB SKELETON REMOTE METHOD
Remote method call
Marshal reques
Unmarshalrequest
Execute RemoteMethod
Marshal reply
Unmarshal reply
Return value
TIM
E
![Page 49: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/49.jpg)
Example of RMI
Create a Remote Interface Create a Remote Implementation of
Interface Create a Server to access instance of
remote method(interface) Create a Client to access a remote
method
![Page 50: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/50.jpg)
RMI API
Remote Interface: Normal java interface which extends
Remote class for coping up with RMI Syntax.
![Page 51: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/51.jpg)
Example:
Import java.io.*; Public interface add extends Remote{ Public int addition(int,int); }
![Page 52: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/52.jpg)
Remote Method(interface)
Implementation of remote interface by supplying the functionality of method
![Page 53: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/53.jpg)
Example:
Import java.io.*; Class myadd extends
UnicastRemoteObject implements add{
Public additon(int x,int y){ Return (x+y); } }
![Page 54: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/54.jpg)
Remote Server
Remote server binds the instance of implementation object to remote registry
![Page 55: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/55.jpg)
Example:
Class myserver { Public static void main(String args[]) { myadd ma=new myadd();
Naming.bind(“myobj”,ma);}}
![Page 56: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/56.jpg)
Client
Remote Client Looks up the rmi registry for the object reference and fetches the reference to access remote method
![Page 57: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/57.jpg)
example
Import java.rmi.*; Class client{ Public class client{ Public static void main(String args[]){ ref=Naming.lookup(“myobj”) } }
![Page 58: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/58.jpg)
Steps for Building an RMI
Algorithm for Developing the server-side software:
Algorithm for Developing the Client-side software
![Page 59: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/59.jpg)
Algorithm Server-side
1. Open a directory for all the files to be generated for this application
2. Specify the remote server interface in someinterface.java and compile it.
3. Implement the interface in someimpl.java and compile it.
![Page 60: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/60.jpg)
Algorithm Server-side
4. Use the RMI compiler rmic to process the implemntation class and generate the stub and skeleton file for the remote object
5.Create the object server program someserver.java and compile it
6. Activate the object server Java someserver
![Page 61: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/61.jpg)
Algorithm for Client-side
1. Open a directory for all the files to be generated for this application
2. Obtain a copy of the remote interface class file
3. Obtain a copy of the stub file for the implementation of the interface someimple_stub.class
![Page 62: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/62.jpg)
Algorithm for Client-side
4. Develop the client program someclient.java and compile it to generate the client class.
5. Activate the client Java someclient.
![Page 63: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/63.jpg)
LOCATION OF FILESCLIENT SERVER
Someinterface.class
Someclient.class
Someimpl_stub.class
Someinterface.class
Someserver.class
Someimpl.class
Someimpl_stub.class
OBJECT CLIENT DIRECTORY OBJECT SERVER DIRECTORY
![Page 64: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/64.jpg)
TESTING AND DEBUGGING
1. Build a template for a minimal RMI program. start with a remote interface containing single
method signature. Its implementation using stub A server program that exports the object A client program with just enough code that
invokes the remote method.
![Page 65: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/65.jpg)
TESTING AND DEBUGGING
Test the template programs on one host until the remote method can be made successfully.
2. Add one signature at a time to the interface. With each addition, modify the client program to invoke the added method.
![Page 66: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/66.jpg)
TESTING AND DEBUGGING
3. Fill in the definition of each remote method, one at a time. Test and thoroughly debug each newly added method before proceeding with the next one.
![Page 67: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/67.jpg)
TESTING AND DEBUGGING
4. After all remote methods have been thoroughly tested, develop the client application using an incremental approach. With each increment test and debug the programs.
![Page 68: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/68.jpg)
TESTING AND DEBUGGING
5. Distribute the programs on separate machines. Test and debug
![Page 69: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/69.jpg)
RMI API vs SOCKET API
Socket API works closely with the operating system and hence has less execution overhead.
RMI API requires additional software support, including proxies and directory service, which inevitably incur run-time overhead.
![Page 70: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/70.jpg)
RMI API vs SOCKET API
Socket API doesn’t provide abstraction for developing the application and hence difficult to debug
RMI API provides abstraction for developing the application and hence easy to debug
![Page 71: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/71.jpg)
RMI API vs SOCKET API
SOCKET API is typically platform and language independent.
RMI API is platform and language dependent
![Page 72: Distributed Objects](https://reader030.vdocuments.mx/reader030/viewer/2022020423/56814025550346895dab84c4/html5/thumbnails/72.jpg)
Execution
Start Registry(start rmiregistry) Compile all java files(javac *.java) Generate Stub(rmic myimpl) Invoke Server(java myserver) Invoke Client(java myclient)