Architecture of Software Systems RMI and Distributed Components Martin Rehák.

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

Remote Method Invocation CS587x Lecture Department of Computer Science Iowa State University.
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.
Remote Method Invocation
Remote Object Invocation Tran, Van Hoai Department of Systems & Networking Faculty of Computer Science & Engineering HCMC University of Technology.
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
CSE331: Introduction to Networks and Security Lecture 11 Fall 2002.
Introduction to Remote Method Invocation (RMI)
Algorithm Programming Distributed Programming in Java Bar-Ilan University תשס " ו by Moshe Fresko.
Practical Issues of RPCCS-4513, D-Term Remote Procedure Call Practical Issues CS-4513 Distributed Computing Systems (Slides include materials from.
Communication in Distributed Systems –Part 2
Java RMI Essentials Based on Mastering RMI Rickard Oberg.
1 Java Programming II Java Network II (Distributed Objects in Java)
1 3. Implementing Web Services 1.Create SOAP proxy interfaces and WSDL based service descriptions 2.Register/publish services 3.Stores service descriptions.
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.
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 Classnote#12 RMI. 2 RMI applications are often comprised of two separate programs: – a server and a client. A typical server application –creates some.
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.
Presentation 18: RMI introduction. Goals of this lesson After this 35 min. lesson you will be: Introduced to Java RMI Ready to present RMI’s position.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
RMI-IIOP.  RMI-IIOP combines RMI-style ease of use with CORBA cross-language interoperability  Java™ Remote Method Invocation (RMI) provides a simple.
Silberschatz, Galvin, and Gagne  1999 Applied Operating System Concepts Chapter 15: Distributed Communication Sockets Remote Procedure Calls (RPCs) Remote.
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 – Command Line CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
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.
Vakgroep Informatietechnologie - IBCN CORBA & RMI Design of Distributed Software.
 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.
RMI - Eclipse CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
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.
Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Remote Method Invocation by James Hunt, Joel Dominic, and Adam Mcculloch.
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.
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)
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Remote Method Invocation. Introduction What is Remote Method Invocation? Remote method invocation allows objects residing in one JVM execute methods.
January 26, Ann Wollrath Copyright 1999 Sun Microsystems, Inc., all rights reserved. Java ™ RMI Overview Ann Wollrath Senior Staff Engineer Sun Microsystems,
Java Distributed Computing
Principles of Software Development
Java Distributed Computing
Java Remote Method Invocation (RMI)
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Java RMI (more) CS-328 Internet Programming.
Knowledge Byte In this section, you will learn about:
Chapter 40 Remote Method Invocation
Chapter 46 Remote Method Invocation
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:

Architecture of Software Systems RMI and Distributed Components Martin Rehák

The point of RMI (Original) I want to invoke methods on objects in other processes (on other hosts) as if they were local.

RMI Challenges Know which interface to call and how Identify or get the correct resource (object instance) Identify the correct method on the object instance Pass input and output values on the network Keep coherence between subsequent calls Handle failures

History:Remote Procedure Call Retrieves the required parameters from the client address space. Translates the parameters as needed into a transmission- friendly format. Calls functions in the RPC client run-time library to send the request The server RPC run-time library functions accept the request and call the server stub procedure. The server stub retrieves the parameters from the network buffer and converts them from the network transmission format to the target format. The server stub calls the actual procedure on the server. The remote procedure returns its data to the server stub. The server stub converts output parameters to the network format and returns them to the RPC rtl. The server RPC run-time library functions transmit the data on the network to the client computer. The client RPC run-time library receives the return values and returns them to the client stub. The client stub converts the data from its NDR to the format used by the client computer. The stub writes data into the client memory and returns the result to the calling program on the client. The calling procedure continues

Patterns Used Proxy – Also called Client Stub – Combined with Façade – Hides the RPC-specific processing from the client Stub – Translates between the network formats and receiving server part and the actual servant “object” Servant – Does all the hard work, implements the functionality on the server side

Towards Remote Objects RMI: RPC for Java RMI-IIOP: CORBA Interoperable version, introduced in Java 1.3 EJB & J2EE: Significant automation on the server integration part and additional patterns – Initial spec heavily based on IDL, CORBA and IIOP – Progressively made simpler, more lightweight

Word of Caution RPC, RMI and CORBA- like technologies are today rarely used directly in new systems … but are hidden inside other standards, technologies and products … and you need to know them…

RMI Basic Concepts Client: Java process on a client or server host, requesting the services /resources from another process either on the same or remote host – “Local” remote calls are frequent and wasteful Server: Java process providing a service or resource to the other processes Object remoting: Using remote objects as local objects

More basic concepts RMI = Remote Method Invocation remote object = object whose methods can be invoked from another JVM – called this even from the server's point of view, where the object is local! – perhaps a better name: remote-able object remote interface = interface exposed (for 'remote- ing') by a remote object – can have multiple interfaces so exposed – can have other interfaces and methods which are not exposed remote reference or remote pointer = a reference to a remote object (really a reference to the local stub) DePaul University, Chicago

Architecture Oracle (

More Patterns: RMI and Factory

Interfaces import java.rmi.Remote; import java.rmi.RemoteException; public interface Hello extends Remote { // extends Remote is the key part String sayHello() throws RemoteException; } // Simple, Java-like definition // RemoteException better be checked for… DePaul University, Chicago

Interface (2) package compute; import java.rmi.Remote; import java.rmi.RemoteException; public interface Compute extends Remote { T executeTask(Task t) throws RemoteException; } package compute; public interface Task { T execute(); } Oracle ( Including the whole example on the following slides

From Interface to Server (1) (Arguably) she simplest framework for remote invocation 1.Declare the remote interfaces being implemented 2.Define the constructor for each remote object 3.Provide an implementation for each remote method in the remote interfaces 4.Handle the registration

From Interface to Server (1) package engine; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; import compute.Compute; import compute.Task; public class ComputeEngine implements Compute { public ComputeEngine() { super(); } public T executeTask(Task t) { return t.execute(); } public static void main(String[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { String name = "Compute"; Compute engine = new ComputeEngine(); Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0); Registry registry = LocateRegistry.getRegistry(); registry.rebind(name, stub); System.out.println("ComputeEngine bound"); } catch (Exception e) { System.err.println("ComputeEngine exception:"); e.printStackTrace(); } } }

From Interface to Server (2) package engine; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; import compute.Compute; import compute.Task; public class ComputeEngine implements Compute { public ComputeEngine() { super(); } public T executeTask(Task t) { return t.execute(); } public static void main(String[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { String name = "Compute"; Compute engine = new ComputeEngine(); Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0); Registry registry = LocateRegistry.getRegistry(); registry.rebind(name, stub); System.out.println("ComputeEngine bound"); } catch (Exception e) { System.err.println("ComputeEngine exception:"); e.printStackTrace(); } } } Remote Interface – implementing object can be used as a remote object

From Interface to Server (3) package engine; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; import compute.Compute; import compute.Task; public class ComputeEngine implements Compute { public ComputeEngine() { super(); } public T executeTask(Task t) { return t.execute(); } public static void main(String[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { String name = "Compute"; Compute engine = new ComputeEngine(); Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0); Registry registry = LocateRegistry.getRegistry(); registry.rebind(name, stub); System.out.println("ComputeEngine bound"); } catch (Exception e) { System.err.println("ComputeEngine exception:"); e.printStackTrace(); } } } Implement the interface methods Constructor – Simple…

From Interface to Server (4) package engine; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; import compute.Compute; import compute.Task; public class ComputeEngine implements Compute { public ComputeEngine() { super(); } public T executeTask(Task t) { return t.execute(); } public static void main(String[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { String name = "Compute"; Compute engine = new ComputeEngine(); Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0); Registry registry = LocateRegistry.getRegistry(); registry.rebind(name, stub); System.out.println("ComputeEngine bound"); } catch (Exception e) { System.err.println("ComputeEngine exception:"); e.printStackTrace(); } } } Server process main loop Stub for the client use TCP port

From Interface to Server (5) package engine; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; import compute.Compute; import compute.Task; public class ComputeEngine implements Compute { public ComputeEngine() { super(); } public T executeTask(Task t) { return t.execute(); } public static void main(String[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { String name = "Compute"; Compute engine = new ComputeEngine(); Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0); Registry registry = LocateRegistry.getRegistry(); registry.rebind(name, stub); System.out.println("ComputeEngine bound"); } catch (Exception e) { System.err.println("ComputeEngine exception:"); e.printStackTrace(); } } } Naming and Registration Registration only possible on local registry (security)

Parameter passing - general Value Two independent instances of the state on both sides of the computational process State coherence guaranteed in the moment of call (parameters) or return (results) by the library Objects need to be serializable Deep copy, references to other objects, local-specific state management problems Problems with mapping to the OO model Reference Remote objects are essentially passed by reference. A remote object reference is a stub, which is a client-side proxy that implements the complete set of remote interfaces that the remote object implements. ORB needs to create local stub for the remote object Every method call/property access becomes a remote call Clean Architecture, Engineer’s nightmare

Parameter passing in RMI Three cases: – Primitive type: passed by value – Serializable object – Remote object – Remote interfaces are available to subscribers, object instance as such is not Security and policy implications

Recommended Design Remote object references shall only be used as addresses to relatively persistent services or computational units Most business data shall be passed by value (copy) Client code shall explicitly manage state coherence (or ather the lack of thereof) Copy and network communication is cheap under most circumstances

Recommended Design (2) Remote object references shall only be used as addresses to relatively persistent services or computational units Most business data shall be passed by value (copy) Client code shall explicitly manage state coherence (or ather the lack of thereof) Copy and network communication is cheap under most circumstances Reliability implications – When each node in a distributed system tightly relies on other nodes for essential data, failure of any single node affects the whole system

Implementing the client

Implementing the Client package client; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.math.BigDecimal; import compute.Compute; public class ComputePi { public static void main(String args[]) { if (System.getSecurityManager() == null) {System.setSecurityManager(new SecurityManager()); } try { String name = "Compute"; Registry registry = LocateRegistry.getRegistry(args[0]); Compute comp = (Compute) registry.lookup(name); Pi task = new Pi(Integer.parseInt(args[1])); BigDecimal pi = comp.executeTask(task); System.out.println(pi); } catch (Exception e) { System.err.println("ComputePi exception:"); e.printStackTrace(); } } } Local stub of the remote object

Implementing the client – the Task package client; import compute.Task; import java.io.Serializable; import java.math.BigDecimal; public class Pi implements Task, Serializable { … public BigDecimal execute() { return computePi(digits); } … } Needs to extend and specialize the task interface Travels over the wire

Implementing the client – the Task (2) package client; import compute.Task; import java.io.Serializable; import java.math.BigDecimal; public class Pi implements Task, Serializable { … private static final long serialVersionUID = 227L; … public BigDecimal execute() { return computePi(digits); } … } This class is transmitted over the network/between the processes It includes the transfer of the class bytecode Version management, classloaders, serialVersionUID,… Needs to extend and specialize the task interface Travels over the wire Class code identity

Proxy/Stub Concept Weblogic

Not-so good features One of the most significant capabilities of the Java™ platform is the ability to dynamically download Java software from any Uniform Resource Locator (URL) to a virtual machine (VM) running in a separate process, usually on a different physical system. The result is that a remote system can run a program, for example an applet, which has never been installed on its disk. For the first few sections of this document, codebase with regard to applets will be discussed in order to help describe codebase with regard to Java Remote Method Invocation (Java RMI).