Remote Method Invocation (RMI) Mixing RMI and sockets

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

Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
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
Company LOGO Remote Method Invocation Georgi Cholakov, Emil Doychev, University of Plovdiv “Paisii.
FONG CHAN SING (143334) WONG YEW JOON (143388). JAVA RMI is a distributive system programming interface introduced in JDK 1.1. A library that allows an.
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.
Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:
Sockets  Defined as an “endpoint for communication.”  Concatenation of IP address + port.  Used for server-client communication.  Server waits for.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
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,
Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets Rethinking out tic-tac-toe game.
1 Java Programming II Java Network II (Distributed Objects in Java)
Chapter 4 Distributed objects and Remote Method Invocation
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
Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA , Semester 1, RMI and CORBA.
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.
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.
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 Continued IS Outline  Review of RMI  Programming example.
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.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
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.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
Li Tak Sing COMPS311F. RMI callbacks In previous example, only the client can initiate a communication with the server. The server can only response to.
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: RMI Continued 2 Using The Registry & Callbacks.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
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.
1 RMI Russell Johnston Communications II. 2 What is RMI? Remote Method Invocation.
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.
Using RMI The Example of A Remote Calculator 1. Parts of A Working RMI System A working RMI system is composed of several parts. –Interface definitions.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
Remote Method Invocation Internet Computing Workshop Lecture 17.
Java Distributed Computing
Java Distributed Computing
Java Remote Method Invocation (RMI)
Remote Method Invocation
Java RMI CS-328 Internet Programming.
What is RMI? Remote Method Invocation
Remote Method Invocation
Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets
Network and Distributed Programming in Java
Chapter 40 Remote Method Invocation
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Chapter 46 Remote Method Invocation
Using RMI -The Example of A Remote Calculator
Chapter 46 Remote Method Invocation
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 (RMI) Mixing RMI and sockets Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets

Distributed Objects Simple idea – objects existing on one machine (server) may be accessed from another machine through regular method call. Eliminates need to “marshal” and “unmarshal” data sent over sockets Underlying socket code still exists, but is not programmed by user.

RMI vs. CORBA RMI is Java framework for creating distributed object applications – Remote Method Invocation CORBA is alternative technology based on open standard – Common Object Request Broker Architecture Web Service/SOAP is a remote object framework based on http and XML RMI is only for pure Java applications; CORBA is language independent JNI makes this distinction a little less rigid since it allows Java to interact with other languages

Socket flow of events -- synchronous Client Server Get user input Decode user input Create server message Send message to server Await server response … Receive server message Decode reply Send output to user Await client message … Receive client message Decode client message Perform action Create client message Send to client Method call on standalone object

Socket flow - asynchronous Client1 Server Client2 User input (UI) Decode UI Create srvr msg Send srvr msg Await srvr reply … Receive server message Decode reply Output to user Wait … Receive client msg Decode client msg Perform action Create client message Send to client1 Send to client2 User input (UI) Decode UI Create srvr msg Send srvr msg Await srvr reply … Receive server message Decode reply Output to user

RMI flow of events -- synchronous Client Server Instantiate object(s) Bind to registry … Get/cache remote obj ref Get user input Decode user input Remote method call Decode return value Send output to user

RMI Cartoon1

RMI Cartoon2

Steps for RMI Application Implement both client and server on single machine to test Create two directories client server

RMI steps, server side Three files need to be created: The implementation class (Foo.java) An interface listing the methods in the implementation class which you want to make remote (FooInterface.java) A server class, which creates one or more implementation objects and posts them to the registry (FooServer.java)

Creating the interface Interface file (e.g. StoreInterface.java) StoreInterface must extend java.rmi.Remote All methods in interface must throw java.rmi.RemoteException Implementation file (e.g Store.java) Store must extend java.rmi.server.UnicastRemoteObject Store must implement StoreInterface Program implementations. Be sure to throw RemoteException in remote methods Explicitly include a call to super() as first line in constructor

Creating the server class Server class (e.g. StoreServer.java) Create a new object instance Call java.rmi.Naming.bind(…) to store the register the object with the naming service … contains String name associated with bound object

Steps for RMI, cont. Create the client Create StoreClient.java and import: java.rmi.Naming; java.rmi.RemoteException; java.net.MalformedURLException; java.rmi.NotBoundException;

Steps for rmi, cont. Call Naming.lookup() to get remote object reference (be sure to cast to interface type). Be sure to handle imported exceptions Once you get remote object reference, handle as regular object (there are some subtle differences that we’ll explore later).

Deploying the Application Start the rmiregistry rmiregistry & (Unix) start rmiregistry (Windows) Start the StoreServer class java StoreServer & (Unix) Run the client That’s it!

Additional Issues – covered next time Objects which are not remote are copied (slow!) Security issues in real system (see ch. 5 in Core Java 2) Subtleties with Object methods (clone, etc) Using callbacks with RMI Synchronization Registering multiple objects Bottom Line: Don’t be too fancy!

Examples tic-tac-toe reorganized as standalone back-end object single-threaded test of TTT object multithreaded test of TTT object using polling client-server TTT using RMI and polling client-server TTT using RMI over sockets client-server TTT using RMI callbacks.