CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.

Slides:



Advertisements
Similar presentations
Remote Method Invocation CS587x Lecture Department of Computer Science Iowa State University.
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.
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
Changing the way of designing distributed applications Communication oriented design: FIRST design the communication protocol for the distributed system.
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.
1 HANDOUT 14 Remote Method Invocation (RMI) BY GEORGE KOUTSOGIANNAKIS THIS DOCUMENT CAN NOT BE REPRODUCED OR DISTRIBUTED WITHOUT TH E WRITTEN PERMISSION.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
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,
Internet Software Development Remote Method Invocation Paul Krause.
RMI Components java.rmi: client-side RMI classes, interfaces, and exceptions java.rmi.server: server-side RMI classes, interfaces, and exceptions java.rmi.registry:
1 Java Programming II Java Network II (Distributed Objects in Java)
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
+ 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.
Java RMI: Remote Method Invocation January 2000 Nancy McCracken Syracuse University.
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.
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.
Remote Method Invocation onlineTraining/rmi/RMI.html.
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.
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.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
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.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
Florida State UniversityCOP Advanced Unix Programming Remote Method Invocation /rmi/index.html.
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.
1 RMI Russell Johnston Communications II. 2 What is RMI? Remote Method Invocation.
Khoa CNTT 1/37 PHẠM VĂN TÍNH   Java 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.
Netprog Java RMI1 Remote Method Invocation.
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.
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
Remote Method Invocation Internet Computing Workshop Lecture 17.
RMI Packages Overview java.rmi java.rmi.server java.rmi.registry
Java Remote Method Invocation (RMI)
RMI Packages Overview java.rmi java.rmi.server java.rmi.registry
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Network and Distributed Programming in Java
Distribution Infrastructures
Using RMI -The Example of A Remote Calculator
Java Remote Method Invocation
Changing the way of designing distributed applications
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina

4/6/20042 Remote Method Invocation Provide a framework for Java objects to communicate via their methods, regardless of their location Networking details disappear under the guise of standard method calls Define a remote interface that declares methods that can be called remotely Use stub and skeleton classes to translate parameters and return values Register remote object with a naming service Client connects to naming service to get a remote reference

4/6/20043 Stub and Skeleton Classes Generated by rmic tool in JDK Stub class automatically translates remote method calls into network communication setup and parameter passing Skeleton class accepts network connections and translate them into actual method calls on actual object

4/6/20044 RMI Architecture Remote method() Stub JVM 1 RemoteObject method() Skeleton JVM 2 ClientServer Internet

4/6/20045 Object Transmission To transmit an object over network, need to make the object serializable Three stages of object transmission Marshaling: pack up data into a form that can be sent over some communication channel Delivery: over the network Unmarshaling: reconstruct object into original form at the other end object bytes object Internet MarshalingUnmarshaling Delivery

4/6/20046 Object Transmission in RMI Marchaling performed by a customized ObjectOutputStream Delivery performed over TCP/IP socket connection Unmarshaling performed by a customized ObjectInputStream Autogenerated stub and skeleton classes contain the code so is transparent to programmers

4/6/20047 RemoteException Superclass of all exceptions that can occur in RMI run time Thrown whenever a remote method invocation fails All method in a remote interface can throw RemoteException

4/6/20048 Steps to Create RMI Application Define remote interface Implement remote interface Generate stub and skeleton classes using rmic Write a client that locates server in naming registry and then calls remote methods Start naming registry using rmiregistry Start server Run client

4/6/20049 An RMI Date Server Example A simple date server that allows clients to determine date and time at server using remote method calls Define remote interface DateServer Implement remote interface with class DateServerImpl Client class DateClient

4/6/ Interface DateServer /* Java Network Programming, Second Edition * Merlin Hughes, Michael Shoffner, Derek Hamner * Manning Publications Company; ISBN X * * * * Copyright (c) Merlin Hughes, Michael Shoffner, Derek Hamner; * all rights reserved; see license.txt for details. */ import java.rmi.Remote; import java.rmi.RemoteException; import java.util.Date; public interface DateServer extends Remote { public Date getDate () throws RemoteException; }

4/6/ Class DateServerImpl /* Java Network Programming, Second Edition * Merlin Hughes, Michael Shoffner, Derek Hamner * Manning Publications Company; ISBN X * * * * Copyright (c) Merlin Hughes, Michael Shoffner, Derek Hamner; * all rights reserved; see license.txt for details. */ import java.rmi.*; import java.rmi.server.*; import java.util.Date; public class DateServerImpl extends UnicastRemoteObject implements DateServer { public DateServerImpl () throws RemoteException { } public Date getDate () { return new Date (); } public static void main (String[] args) throws Exception { DateServerImpl dateServer = new DateServerImpl (); Naming.bind ("DateServer", dateServer); }

4/6/ Class DateClient /* Java Network Programming, Second Edition * Merlin Hughes, Michael Shoffner, Derek Hamner * Manning Publications Company; ISBN X * * * * Copyright (c) Merlin Hughes, Michael Shoffner, Derek Hamner; * all rights reserved; see license.txt for details. */ import java.rmi.Naming; import java.util.Date; public class DateClient { public static void main (String[] args) throws Exception { if (args.length != 1) throw new IllegalArgumentException ("Syntax: DateClient "); DateServer dateServer = (DateServer) Naming.lookup ("rmi://" + args[0] + "/DateServer"); Date when = dateServer.getDate (); System.out.println (when); }

4/6/ RMI-Related Packages Five main packages in RMI framework java.rmi: classes related to client side of RMI java.rmi.server: classes related to server side of RMI java.rmi.registry: classes related to RMI naming registry java.rmi.dgc: classes supporting distributed garbage collection java.rmi.activation: classes supporting JDK 1.2 activation mechanism

4/6/ Interface Remote Superinterface for all remote interfaces Serve to identify all remote interfaces, so declare no methods A remote interface that extends Remote describes the only methods that a remote object supports Clearly delineate API of a remote object, so separate remote object’s implementation from its publicly-exposed interface

4/6/ Remote Method Call Semantics Major difference between remote method call and direct method call is parameters are passed by value in RMI Remote method gets copy of field values of Object, so client will not see changes reflected in its local copy of Object To modify an Object inside a remote method, need to have remote method return modified Object as result of remote method call

4/6/ Class Naming Methods Remote lookup(String address) throws MalformedURLException, RemoteException, NotBoundException void bind(String address, Remote object) throws MalformedURLException, RemoteException, AlreadyBoundException void rebind(String address, Remote object) throws MalformedURLException, RemoteException void unbind(String address) throws MalformedURLException, RemoteException, NotBoundException String[] list(String address) throws MalformedURLException, RemoteException

4/6/ Class Naming Exceptions MalformedURLException RemoteException UnknownHostException NotBoundException AlreadyBoundException

4/6/ Examples of Using Naming String[] services = Naming.list (“//accounts.my.bank/”); for (int i = 0; i < services.length; ++i) System.out.println (services[i]); BankAccount firstAccount = (BankAccount) Naming.lookup (services[0]); Naming.bind (“First Account”, firstAccount); account = new PersonalBankAccountImpl (“jim”); Naming.rebind (“personal/jim”, account);

4/6/ Class LocateRegistry Static methods Registry getRegistry() throws RemoteException Registry getRegistry(int port) throws RemoteException Registry getRegistry(String host) throws RemoteException Registry getRegistry(String host, int port) throws RemoteException Registry getRegistry(String host, int port, RMIClientSocketFactory clients) throws RemoteException Registry createRegistry(int port) throws RemoteException Registry createRegistry(int port, RMIServerSocketFactory servers, RMIClientSocketFactory clients) throws RemoteException

4/6/ Class LocateRegistry Exceptions RemoteException UnknownHostException

4/6/ Interface Registry Static variable int REGISTRY_PORT Methods Remote lookup(String name) throws RemoteException, NotBoundException void bind(String name, Remote object) throws RemoteException, AlreadyBoundException void rebind(String name, Remote object) throws RemoteException void unbind(String name) throws RemoteException, NotBoundException String[] list() throws RemoteException

4/6/ Interface Registry Exceptions RemoteException NotBoundException AlreadyBoundException AccessException

4/6/ Examples of Using Registry Registry registry = LocateRegistry.getRegistry (“host”, 1234); registry.rebind (“Service”, service); Registry registry = LocateRegistry.createRegistry (1234); registry.bind (“Service”, service);

4/6/ Next Class Remote method invocation (RMI) Examples of RMI in practice Read JNP Ch. 23, 24