Download Distributed Information Systems Lecture 6 - Distributed Objects and RMI - V2 and more Lecture notes Computers and Information technologies in PDF only on Docsity!
Distributed Objects &
RMI Dr Simon Blake
Topics for this lecture
•Middleware•Interfaces (IDL)•The Distributed Object Model•RMI: Remote Method Invocation^ –An extension to local method invocation that allowsremote method invocation also •Middleware^ –CORBA–COM and DCOM •SOAP
Introduction
•Sockets API used for sending & receiving calls (simple IO)•Remote Procedure Calls (RPC)^ –Was designed to provide a procedural interface for distributed(i.e., remote) services–The aim was to make the distributed nature of service transparentto the programmer–However, it is no longer considered particularly good •Remote Method Invocation (RMI)^ –Essentially combines RPC with Object Orientation–Allows objects living in one process to invoke methods of anobject living in another process
Middleware
•Middleware abstracts much of the detail andheterogeneity in systems•Middleware provides, location transparency,independence from the communicationprotocols, operating systems, hardware etc.
Interfaces
•What is an interface^ –Not a GUI–Interface in this unit refers to the means of connection for twodifferent systems •In software^ –Units of code are modularized – that is organized into modules–Modules may use other modules via either calling their methodsor through direct access to their data–They do this using interfaces
Interfaces
private void^ myCalc(){System.out.println(sumNumbers(10,10));System.out.println(sumNumbers(5,7));} public int^ sumNumbers(
int^ a,^ int^ b){ return^ a+b;}
Here we have a method thatsums two integers together And here we have anothermethod that references andcalls the above
Interfaces
•Interfaces in a DIS^ –Pass by reference is not appropriate^ •As a local memory address has no meaning to another computer^ –Arguments are either
Input^ or^ Output
arguments
- Input^ arguments contains values that will be used by the server • Output^ arguments are used for the server returning values to theclient –No direct attribute access is generally permit •Everything occurs through messages
Interfaces
•Interfaces in a DIS^ –IDL: Interface Definition Language^ •Provides an agreed convention for describing the interfaces betweenmethods•This includes distinguishing between
Input^ and^ Output
arguments
Interfaces
•An example CORBA IDL^ struct Person {string name;string place;long year;}; Interface PersonList{readonly attribute string listname;void addPerson(in Person p);void getPerson(in string name, out Person p);long number();};
And also remotemethod interfaces
Distributed ObjectCommunication
•The Object model concerns single computers^ –The object model embodies many desirable design concepts,such as openness, scalability, etc. •The Distributed Object model concerns multiple distributedcomputers^ –How the object model is extended for use in a DIS •And… what are the key differences between thedistributed object model and the object model?
The Object Model
•The object model^ –Object references^ •All objects are actually references to objects•Methods are accessed via the object references^ –Interfaces^ •A definition of a method or a set of methods•Does not refer to the implementation of the method but•Contains types of arguments, return types of the method, etc.^ –Actions^ •Actions occur from method invocations•Invocations might supply arguments (data) in making an invocation
–i.e.^ result = sumNumbers(10,2); •Once received the receiver executes the method and returns any results that are required•The receiver state might change as a result•Requests to other methods might also be made
The Object Model
–Exceptions^ •Things can go wrong^ –Data might be inconsistent–Hardware might not be available^ •Exceptions catch errors that occur so that the software does notcrash in an uncontrolled manner•When an error occurs control jumps to the handler for the error^ –Example,
try{some code}catch (some error){some other code} –Garbage collection^ •Objects are instantiated and either de-instantiated or cease beingreferenced anywhere in the program•The memory allocated to these objects must be made available•Thus, a system for collecting dead objects and data is required•This is referred to as garbage collection
Distributed Objects^ RIA RI = Remote Invocation^ = an objectLI = Local Invocation= a message
client
RI RI LI^ LIE FBLI C
G D server
The Distributed Object Model •Objects may be defined to receive local or non-local requests•Local invocations are requests made from local processes to otherlocal processes – i.e. B to G, B to E, etc. •Remote invocations are requests to non-local (remote) processes – i.e. A to B, F to G etc. •In order to make a remote request invokers
must^ have a Remote
Object Reference^ –i.e. A must have Remote Object Reference for B, etc. •Remote objects
must^ have a remote interface that specifics methods that can be invoked remotely^ – i.e. B, D and G