Architecture of So-ware Systems RMI and Distributed Components. Mar<n Rehák

Similar documents
55:182/22C:182. Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP)

Creating a Client Program

Generic architecture

A Typical RMI Application

A Typical RMI Application. Case Study

CS 138: Communication II

Remote Method Invocation

RMI Case Study. A Typical RMI Application

Remote Method Invocation

SUMMARY INTRODUCTION REMOTE METHOD INVOCATION

IBD Intergiciels et Bases de Données

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)

Lecture 18 Inside Java RMI

Remote Method Invocation

Communication in Distributed Systems Fundamental Concepts

Lecture 17 Java Remote Method Invoca/on

Architecture of So-ware Systems Distributed Components, CORBA. Mar>n Rehák

JAVA RMI. Remote Method Invocation

Last Class: Network Overview. Today: Distributed Systems

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

Distributed Computing

JAC444 - Lecture 11. Remote Method Invocation Segment 2 - Develop RMI Application. Jordan Anastasiade Java Programming Language Course

Java RMI. Algorithmen und Programmierung V Netzprogrammierung. Volker Roth. Wintersemester 2009/2010. Institut für Informatik Freie Universität Berlin

RMI. (Remote Method Invocation)

RMI. Remote Method Invocation. 16-Dec-16

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

Distributed Systems. Distributed Object Systems 2 Java RMI. Java RMI. Example. Applet continued. Applet. slides2.pdf Sep 9,

The UNIVERSITY of EDINBURGH. SCHOOL of INFORMATICS. CS4/MSc. Distributed Systems. Björn Franke. Room 2414

Written by: Dave Matuszek

Chapter 15: Distributed Communication. Sockets Remote Procedure Calls (RPCs) Remote Method Invocation (RMI) CORBA Object Registration

How are classes loaded into the Java Virtual Machine (JVM)? from the local file system (CLASSPATH). by an instance of ClassLoader

Communication in Distributed Systems Fundamental Concepts

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

CC755: Distributed and Parallel Systems


RMI Example RMI. CmpE 473 Internet Programming RMI

Distributed Systems. 6. Remote Method Invocation. Werner Nutt

5 Distributed Objects: The Java Approach

Agent and Object Technology Lab Dipartimento di Ingegneria dell Informazione Università degli Studi di Parma. Distributed and Agent Systems RMI

Distributed Systems COMP 212. Lecture 10 Othon Michail

RPC and RMI. 2501ICT Nathan

Oracle WebLogic Server

5.4. Events and notifications

DISTRIBUTED COMPUTING

Communication Basics, RPC & RMI. CS403/534 Distributed Systems Erkay Savas Sabanci University

CS193k, Stanford Handout #12. Threads 4 / RMI

Distributed Programming with RMI. Overview CORBA DCOM. Prepared By: Shiba R. Tamrakar

Developing RMI Based Server (ChatServer)

RMI (Remote Method Invocation) Over the year, there have been 3 different approaches to application development:

Distributed Systems. 02r. Java RMI Programming Tutorial. Paul Krzyzanowski TA: Long Zhao Rutgers University Fall 2017

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4

Concurrent Programming (RIO) Lesson 9. Ch 8 [BenA 06] Messages Channels Rendezvous RPC and RMI. X=f(..); send X to B. OS kernel.

Concurrency Control in Distributed Environment

Oracle Fusion Middleware

Are Sockets a Good Programming Paradigm? EDA095 Remote Method Invocation. The Remote Procedure Call Model. The Remote Procedure Call Architecture

Verteilte Systeme (Distributed Systems)

Course Snapshot. The Next Few Classes. Parallel versus Distributed Systems. Distributed Systems. We have covered all the fundamental OS components:

Info 408 Distributed Applications programming 2 nd semester of Credits: 5 Lecturer: Antoun Yaacoub Ph.D.

Dynamic code downloading using Java TM (Using the java.rmi.server.codebase Property)

Course Snapshot. The Next Few Classes

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

JAVA RMI Java, summer semester

RPC flow. 4.3 Remote procedure calls IDL. RPC components. Procedure. Program. sum (j,k) int j,k; {return j+k;} i = sum (3,7); Local procedure call

Distributed Systems. 5. Remote Method Invocation

Distributed Objects SPL/ SPL 201 / 0 1

Distributed Objects. Object-Oriented Application Development

Distributed Software Systems

Remote Procedure Call

Java RMI Activation: A running example We have the following classes: MyRemoteInterface: the remote interface. Client: the client that invokes a

BEA WebLogic. Server. Programming WebLogic RMI

Oracle Fusion Middleware

COMP 6231 Distributed Systems Design. Tutorial 2 by Alexandre Hudon January 21 st, 2013

Questions and Answers. A. RMI allows us to invoke a method of java object that executes on another machine.

Remote Method Invocation. Benoît Garbinato

Remote Method Invocation Benoît Garbinato

Desarrollo de Aplicaciones en Red RMI. Introduction. Considerations. Considerations. RMI architecture

EDA095 Remote Method Invocation

Lab 2 : Java RMI. request sayhello() Hello interface remote object. local object. response "Hello world"

BEA WebLogic Server. Programming WebLogic RMI

presentation DAD Distributed Applications Development Cristian Toma

Are Sockets a Good Programming Paradigm? EDA095 Remote Method Invocation. The Remote Procedure Call Model. The Remote Procedure Call Architecture

Serialisa(on, Callbacks, Remote Object Ac(va(on. CS3524 Distributed Systems Lecture 03

EDA095 Remote Method Invocation

Lecture VI: Distributed Objects. Remote Method Invocation

Java Programming Language Advance Feature

OO-Middleware. Computer Networking 2 DVGC02 Stefan Alfredsson. (slides inspired by Annika Wennström, Sören Torstensson)

Distributed object component middleware I - Java RMI

Applications. RMI, RPC and events. Request reply protocol External data representation. Operating System

Distributed object component middleware I - Java RMI

Chapter 4 Remote Procedure Calls and Distributed Transactions

Communication and Distributed Processing

Distributed Objects. Chapter Distributing Objects Overview

Java Technologies. Lecture VII. Valdas Rapševičius. Vilnius University Faculty of Mathematics and Informatics

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

Activation of remote objects

Design Principles & Prac4ces

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Chapter 5 Distributed Objects and Remote Invocation

Department of Computer Science & Engineering. M.Tech(CSE)-I Year-II Semester WEB SERVICES AND SERVICE ORIENTED ARCHITECHTURE (B1513) Mr.K.

Transcription:

Architecture of So-ware Systems RMI and Distributed Components Mar<n 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 Iden<fy or get the correct resource (object instance) Iden<fy 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 func<ons in the RPC client run- <me library to send the request The client RPC run- <me 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 con<nues. 1 2 4 3 The server RPC run- <me library func<ons 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- <me library func<ons transmit the data on the network to the client computer. http://msdn.microsoft.com/en-us/library/windows/desktop/aa373935(v=vs.85).aspx

PaPerns 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 func<onality on the server side

Towards Remote Objects RMI: RPC for Java RMI- IIOP: CORBA Interoperable version, introduced in Java 1.3 EJB & J2EE: Significant automa<on on the server integra<on part and addi<onal paperns Ini<al spec heavily based on IDL, CORBA and IIOP Progressively made simpler, more lightweight

Word of Cau<on 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, reques<ng 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 remo>ng: Using remote objects as local objects

More basic concepts RMI = Remote Method Invoca<on 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 beper name: remote- able object remote interface = interface exposed (for 'remote- ing') by a remote object can have mul<ple 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 (http://docs.oracle.com/javase/tutorial/rmi/overview.html)

More PaPerns: RMI and Factory http://sourcecodemania.com/abstract-factory-design-pattern/

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.remoteexcep<on; public interface Compute extends Remote { } <T> T executetask(task<t> t) throws RemoteExcep<on; package compute; public interface Task<T> { T execute(); } Oracle (http://docs.oracle.com/javase/tutorial/rmi/overview.html) Including the whole example on the following slides

From Interface to Server (1) (Arguably) she simplest framework for remote invoca<on 1. Declare the remote interfaces being implemented 2. Define the constructor for each remote object 3. Provide an implementa>on for each remote method in the remote interfaces 4. Handle the registra<on

From Interface to Server (1) package engine; import java.rmi.remoteexcep<on; 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> T executetask(task<t> t) { return t.execute(); } public sta<c 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 (Excep<on e) { System.err.println("ComputeEngine excep<on:"); e.printstacktrace(); } } }

From Interface to Server (2) package engine; import java.rmi.remoteexcep<on; 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> T executetask(task<t> t) { return t.execute(); } public sta<c void main(string[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { Remote Interface implemen<ng object can be used as a remote object 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 (Excep<on e) { System.err.println("ComputeEngine excep<on:"); e.printstacktrace(); } } }

From Interface to Server (3) package engine; import java.rmi.remoteexcep<on; 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> T executetask(task<t> t) { return t.execute(); } public sta<c void main(string[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { Constructor Simple Implement the interface methods 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 (Excep<on e) { System.err.println("ComputeEngine excep<on:"); e.printstacktrace(); } } }

From Interface to Server (4) package engine; import java.rmi.remoteexcep<on; 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> T executetask(task<t> t) { return t.execute(); } public sta<c void main(string[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { Server process main loop Stub for the client use String name = "Compute"; Compute engine = new ComputeEngine(); Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0); TCP port Registry registry = LocateRegistry.getRegistry(); registry.rebind(name, stub); System.out.println("ComputeEngine bound"); } catch (Excep<on e) { System.err.println("ComputeEngine excep<on:"); e.printstacktrace(); } } }

From Interface to Server (5) package engine; import java.rmi.remoteexcep<on; 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> T executetask(task<t> t) { return t.execute(); } public sta<c 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); Naming and Registra<on Registry registry = LocateRegistry.getRegistry(); registry.rebind(name, stub); System.out.println("ComputeEngine bound"); } catch (Excep<on e) { System.err.println("ComputeEngine excep<on:"); e.printstacktrace(); } } } Registra<on only possible on local registry (security)

Parameter passing - general Value Two independent instances of the state on both sides of the computa<onal 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 essen<ally 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: Primi<ve type: passed by value Serializable object Remote object Remote interfaces are available to subscribers, object instance as such is not Security and policy implica<ons

Recommended Design Remote object references shall only be used as addresses to rela<vely persistent services or computa<onal 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 communica<on is cheap under most circumstances

Recommended Design (2) Remote object references shall only be used as addresses to rela<vely persistent services or computa<onal 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 communica<on is cheap under most circumstances Reliability implica<ons When each node in a distributed system <ghtly relies on other nodes for essen<al data, failure of any single node affects the whole system

Implemen<ng the client

Implemen<ng 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 sta<c 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 (Excep<on e) { System.err.println("ComputePi excep<on:"); e.printstacktrace(); } } } Local stub of the remote object

Implemen<ng the client the Task package client; import compute.task; import java.io.serializable; import java.math.bigdecimal; public class Pi implements Task<BigDecimal>, Serializable { Travels over the wire public BigDecimal execute() { return computepi(digits); } } Needs to extend and specialize the task interface

Implemen<ng the client the Task (2) package client; import compute.task; import java.io.serializable; import java.math.bigdecimal; public class Pi implements Task<BigDecimal>, Serializable { private sta<c final long serialversionuid = 227L; public BigDecimal execute() { return computepi(digits); } } Class code iden<ty Travels over the wire Needs to extend and specialize the task interface This class is transmiped over the network/between the processes It includes the transfer of the class bytecode Version management, classloaders, serialversionuid,

Proxy/Stub Concept http://zombievir.us Weblogic

Not- so good features One of the most significant capabili5es of the Java pla9orm is the ability to dynamically download Java so=ware 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 sec5ons of this document, codebase with regard to applets will be discussed in order to help describe codebase with regard to Java Remote Method Invoca5on (Java RMI). hpp://docs.oracle.com/javase/7/docs/technotes/guides/rmi/codebase.html