Remote Method Invocation with Java-RMI

Slides:



Advertisements
Similar presentations
What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
Advertisements

RMI Varun SainiYing Chen. What is RMI? RMI is the action of invoking a method of a remote interface on a remote object. It is used to develop applications.
15-May-15 RMI Remote Method Invocation. 2 “The network is the computer” Consider the following program organization: If the network is the computer, we.
Remote Method Invocation in Java Bennie Lewis EEL 6897.
Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Remote Method Invocation
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
DISTRIBUTED FILE SYSTEM USING RMI
Sockets  Defined as an “endpoint for communication.”  Concatenation of IP address + port.  Used for server-client communication.  Server waits for.
CSE331: Introduction to Networks and Security Lecture 11 Fall 2002.
Introduction to Remote Method Invocation (RMI)
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Java RMI RMI = Remote Method Invocation. Allows Java programs to invoke methods of remote objects. Only between Java programs. Several versions (JDK-1.1,
By Dr. Jiang B. Liu 11. Java IDL and CORBA  Generic ORB Core  idltojava development tool  CORBA Object Service (COS) name service - nameserv  Java.
Internet Software Development Remote Method Invocation Paul Krause.
Slides for Chapter 5: Communication between distributed objects
Java RMI Essentials Based on Mastering RMI Rickard Oberg.
1 Java Programming II Java Network II (Distributed Objects in Java)
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
CS 584 Lecture 18 l Assignment » Glenda assignment extended to the Java RMI Deadline » No Java RMI Assignment l Test » Friday, Saturday, Monday.
+ A Short Java RMI Tutorial Usman Saleem
15 - RMI. Java RMI Architecture Example Deployment RMI is a part of J2SE (standard edition), but is used by J2EE) A J2EE server is not nessesary for using.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
RMI RMI is the java API that facilitate distributed computing by allowing remote method calls. A remote method call represents a method invocation between.
Abhishek Bachchan Vishal Patangia
CORBA – Command Line CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Java Remote Method Invocation RMI. Idea If objects communicate with each other on one JVM why not do the same on several JVM’s? If objects communicate.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
Vakgroep Informatietechnologie - IBCN CORBA & RMI Design of Distributed Software.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Presentation: RMI introduction. Goals of this lesson After this 35 min. lesson you will be: Introduced to Java RMI Ready to present RMI’s position in.
CORBA – Eclipse CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
CORBA_1/001 Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki CORBA:
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Presentation 11: RMI introduction. Ingeniørhøjskolen i Århus Slide 2 af 20 Goals of this lesson After these 2x35 lessons you will be –Introduced to Java.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
Slides for Chapter 5: Distributed objects and remote invocation From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition.
Remote Method Invocation A Client Server Approach.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Remote Method Invocation RMI architecture stubs and skeletons for remote services RMI server and client in Java Creating an RMI Application step-by- step.
Java RMI. RMI Any object whose methods can be invoked from another Java VM is called a remote object.
Khoa CNTT 1/37 PHẠM VĂN TÍNH   Java RMI (Remote Method Invocation)
IDL Models The Inheritance Model: Using the Inheritance Model, you implement the IDL interface using an implementation class that also extends the compiler-generated.
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Distributed programming in Java Faculty:Nguyen Ngoc Tu Session 5 - RMI.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
Netprog Java RMI1 Remote Method Invocation.
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
Java Remote Method Invocation (RMI)
Broker in practice: Middleware
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Network and Distributed Programming in Java
Creating a Distributed System with RMI
Slides for Chapter 5: Distributed objects and remote invocation
Remote method invocation (RMI)
CS 584 Lecture 18 Assignment Glenda assignment extended to the Java RMI Deadline No Java RMI Assignment Test Friday, Saturday, Monday.
Java Remote Method Invocation
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Remote Method Invocation with Java-RMI Automatically generated Skeleton - Demarshalling - Dispatch Stub - Marshalling Network ServerI Server Client Contains only functionality

What does the client see? A remote object (proxy, stub) can be casted to all interface the server implements, be accessed only via interface methods. On a remote invocation non-remote arguments are copied (using serialization), remote arguments are given as reference,  different to local invocation java.rmi.RemoteException can always be thrown. Remote Objects always support the interface Remote. (Tag interface)

How to build the server? Class diagram: RemoteObject Remote Provided by the JDK RemoteServer UnicastRemoteObject Activatable Provided by the programer ServerI ServerImpl - every method which is remotely invocable must be declared to throw RemoteException. - Skeletons/Stubs are created with the JDK tool rmic.

Coordination with a naming service The naming service (rmiregistry) is a remote Java object, manages relationships between Strings (i.e. names) and remote Java objects (on the same host). remote Java objects register themselves with java.rmi.Naming.bind(String name,Remote obj); java.rmi.Naming.rebind(String name,Remote obj); the name has the form: “//host:port/identifier“ (default: host=localhost, port=1099) clients use the name to receive a stub: Remote Naming.lookup(String name);

Examplary Server Server interface: interface ServerI extends Remote { public void doSomeService() throws RemoteException;} Server implementation: class Server extends UnicastRemoteObject implements ServerI { public Server() throws RemoteException { super();} public void doSomeService() throws RemoteException { System.out.println("Working hard..");} ....

Initialisation+Registration ... public static void main(String args[]) {try { // create instance Server myServer = new Server(); // bind it to the naming service Naming.rebind(“//elfe:4711/HardServer", myServer); // done } catch(Exception ex) { ex.printStackTrace(); System.exit(5); }

Remote Invocation of the Server public class Client { static public void main(String args[]) { try { // locate Server Remote rs = Naming.lookup(“//elfe:4711/HardServer"); ServerI server = (ServerI) rs; // use service server.doSomeService(); // done } catch(Exception ex) { ex.printStackTrace(); System.exit(5); } } }

Compilation, Configuration, Startup Compile classes jedi> javac Server.java ServerI.java Client.java Create Skeletons and Stubs jedi> rmic Server Start naming service on elfe elfe> rmiregistry 4711 & Start server on elfe elfe> java Server & Start client somewhere jedi> java Client Working hard.. on elfe

Installation of JacORB Source code with examples and documentation: http://www.inf.fu-berlin.de/~brose/jacorb local installation in the Sun pool: setenv JACO /import/public/opt/JacORB1_1 setenv PATH $JACO/bin:$PATH setenv CLASSPATH $JACO/lib/idl.jar:$JACO/lib/jacorb.jar:$CLASSPATH cp $JACO/jacorb_properties.template ~/.jacorb_properties edit ~/.jacorb_properties (an install script is on the WWW) adapt the URL settings in the property file; at least this entry: jacorb.NameServerURL=file:/....

Overview about CORBA Client Server Servant Servant Impl. Servant IDL Interface Skeleton Stub POA POA ORB

Class Hierarchie for CORBA Servers for the Interface Foo Servant <<interface>> FooOperations FooPOA FooPOATie FooDelegateImpl Delegate allows use of inheritence: new FooPOATie(new FooDelegateImpl()) Delegates to <<interface>> Foo FooImpl Servants are no CORBA objects

The CORBA COS Naming Service A naming context stores relationships between names and Objects, is itself a CORBA object (allows hierarchical, potentially cyclic name spaces). name = sequence<name_components>, name_component=(string id, string kind) ORB provides bootstrapping with the root context NameServer (ORB uses jacorb.NameServerURL; it points to an IOR) bind an object in a subcontext NamingContext.bind(Name n, Object o); resolve an object Object Object NamingContext.resolve(Name n); create a new sub context NamingContext NamingContext.new_context(); NamingContext.bind_new_context(Name n); bug in JDK  use NamingContextExt !

Examplary Server now in CORBA Server IDL interface: interface Server { void doSomeService();}; Server implementation: class ServerImpl extends ServerPOA { public void doSomeService() { System.out.println("Working hard..");} // main method follows

Initialisation+Registration static public void main(String args[]) { try { // access CORBA, activate POA ORB orb = org.omg.CORBA.ORB.init(args, null); POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); poa.the_POAManager().activate(); // from now on requests are handled !!! // get name server NamingContextExt nc = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService")); // generate a server and register it at the POA org.omg.CORBA.Object cob = poa.servant_to_reference(new ServerImpl()); // generate a name NameComponent [] name = new NameComponent[1]; name[0] = new NameComponent( "HardServer", "some kind"); // bind server to name nc.bind(name, cob); // done System.out.println("Server is ready."); orb.run(); } catch(Exception ex){ex.printStackTrace();} } } // main, class

Remote Invocation of the Server class Client { static void main(String args[]) { try{ // get ORB and naming service ORB orb = org.omg.CORBA.ORB.init(args, null); NamingContextExt nc = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService")); // generate the name NameComponent [] name = new NameComponent[1]; name[0] = new NameComponent( "HardServer", "some kind"); // query naming service, cast the stub org.omg.CORBA.Object cob = nc.resolve(name); Server server = ServerHelper.narrow(cob); // use the generated Helper class // use service server.doSomeService(); } catch(Exception ex){ ex.printStackTrace(); } } }

Compile the Example Generate skeleton,stubs, helper classes from the IDL > idl server.idl Skeletons: ServerPOA.java,ServerPOATie.java Stub: _ServerStub.java Helpers: ServerHelper.java, ServerHolder.java Interfaces: Server.java, ServerOperations.java compile the classes > javac *.java (take care of your CLASSPATH!)

Startup your Scenario Start the naming service > ns NSIOR NSIOR should be: file(jacorb.NameServerURL) E.g.: file:/home/tnfink/ns.ior  /home/tnfink/ns.ior start the server jedi> jaco ServerImpl Server is ready. Start the client troll> jaco Client Working hard. (auf jedi)

Miscellaneous Methods Convert CORBA object references to Java Strings: String ORB.object_to_string(org.omg.CORBA.Object obj); org.omg.CORBA.Object ORB.string_to_object(String ior); test for existance of an CORBA object (i.e. stub) boolean Object._non_existent(); test if two CORBA objects are equal boolean Object._is_equivalent(Object other); a return of false does not guarantee inequality! Duplicate a CORBA object (reference) Object Object.duplicate();

Miscellaneous Tools, Parameters naming service GUI >nmg analysis of IORs > dior -f ns.ior ------IOR components----- TypeId : IDL:omg.org/CosNaming/NamingContextExt:1.0 Profile Id : TAG_INTERNET_IOP IIOP Version : 1.1 Host : 160.45.110.127 Port : 1281 ... Parameter for debug output (0=none, 1=important, ... 10) jacorb.verbosity = 0

Java RMI  CORBA Java RMI is easy to learn and use, does not support heterogeneity, scalability, reliability CORBA needs effort for learning is a sophisticated industrial tool for the real world.