Distributed object component middleware I - Java RMI

Similar documents
Distributed object component middleware I - Java RMI

5.4. Events and notifications

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

Modulo II Socket, RMI e Corba

Chapter 5 Distributed Objects and Remote Invocation

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

Distributed Software Systems

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

Structured communication (Remote invocation)

Distributed Systems. Communication (2) Schedule of Today. Distributed Objects. Distributed Objects and RMI. Corba IDL Example

Distributed Systems. Communication (2) Lecture Universität Karlsruhe, System Architecture Group

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

Distributed Systems. 5. Remote Method Invocation

JAVA RMI. Remote Method Invocation

Remote Objects and RMI

Generic architecture

CS 5523 Operating Systems: Remote Objects and RMI

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

Chapter 5: Distributed objects and remote invocation

Slides for Chapter 5: Remote Invocation

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

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

presentation DAD Distributed Applications Development Cristian Toma

Chapter 5 Remote Invocation. Gandeva Bayu Satrya, ST., MT. Telematics Labz. Informatics Department Telkom

Object-Oriented Distributed Technology

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

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

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

03 Remote invocation. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

CORBA CASE STUDY Introduction 20.2 CORBA RMI 20.3 CORBA services 20.4 Summary

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

Lecture 5: Object Interaction: RMI and RPC

IBD Intergiciels et Bases de Données

Distributed Systems. 6. Remote Method Invocation. Werner Nutt

CC755: Distributed and Parallel Systems

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

Remote Method Invocation

Remote Method Invocation in Java

Distributed Information Processing

Last Class: Network Overview. Today: Distributed Systems

Remote Procedure Call

RMI: Design & Implementation

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

Distributed Systems COMP 212. Lecture 10 Othon Michail

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

COMP 6231: Distributed System Design

Verteilte Systeme (Distributed Systems)

Remote Method Invocation Benoît Garbinato

Remote Method Invocation. Benoît Garbinato

Distributed Programming in Java. Distribution (2)

Java RMI Middleware Project

Lecture 06: Distributed Object

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

Distributed Systems Lecture 2 1. External Data Representation and Marshalling (Sec. 4.3) Request reply protocol (failure modes) (Sec. 4.

RPC and RMI. 2501ICT Nathan

RMI Example RMI. CmpE 473 Internet Programming RMI

Distributed Objects SPL/ SPL 201 / 0 1

Chapter 4: Processes. Process Concept. Process State

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

4:40pm - 6:10pm (90 min)

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

Distributed Computing

Remote Method Invocation

03 Remote invoaction. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

Written by: Dave Matuszek

Introduction to Distributed Systems. Fabienne Boyer, LIG,

Component-Based Software Engineering

Architecture of distributed systems

Architecture of distributed systems

Distributed Systems. The main method of distributed object communication is with remote method invocation

RMI. Remote Method Invocation. 16-Dec-16

JAVA RMI Java, summer semester

5 Distributed Objects: The Java Approach

Lecture 18 Inside Java RMI

Lecture 5: RMI etc. Servant. Java Remote Method Invocation Invocation Semantics Distributed Events CDK: Chapter 5 TVS: Section 8.3

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

Distributed Information Systems

Chapter 4 Remote Procedure Calls and Distributed Transactions

Communication and Distributed Processing

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

15-498: Distributed Systems Project #1: Design and Implementation of a RMI Facility for Java

Remote Invocation Vladimir Vlassov and Johan Montelius

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC)

Course Snapshot. The Next Few Classes

Communication and Distributed Processing

IJESRT. http: //

REMOTE METHOD INVOCATION INTRODUCTION TO RMI, A JAVA API FOR RPC-STYLE INVOCATION OF REMOTE OBJECT METHODS

Unit 7: RPC and Indirect Communication

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

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

RMI Case Study. A Typical RMI Application

Distributed Objects. Chapter Distributing Objects Overview

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

Interprocess Communication

Interprocess Communication

CHAPTER - 4 REMOTE COMMUNICATION

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

Remote Method Invocation

CS193k, Stanford Handout #12. Threads 4 / RMI

Transcription:

Prof. Dr. Claudia Müller-Birn Institute for Computer Science, Networked Information Systems Distributed object component middleware I - Java RMI Nov 15th, 2011 Netzprogrammierung (Algorithmen und Programmierung V) Our topics last week Descriptive models for distributed system design Physical model Architectural model Architectural elements Interaction model Communicating entities Communication paradigm Roles and responsibilities Placement Interaction model Processes Objects Components Web Services Inter-process communication UDP sockets TCP sockets Indirect communication Multicast Remote invocation Architectural styles Client-server Peer-to-peer Multiple server Proxy/Cache Mobile code Failure model Architectural patterns Vertical distribution Multi-tier Thin/Fat Client Horizontal distribution Security model 2

Our topics today Implementation of RMI The process of remote method invocation Communication s and RMI software Generation of classes for proxies, dispatcher and skeleton Dynamic invocation: An alternative to proxies Distributed garbage collection algorithm Java RMI Introducing a case study Parameter and result passing and RMI registry Building a client and server programs 6 Distributed object component middleware I - Java RMI Implementation of RMI 7

The process of remote method invocation client server object A proxy for B request reply Skeleton & dispatcher for B s class remote object B communication servant 8 What does the communication do? Two cooperating communication s carry out the request-reply protocol. Content of request and reply messages messagetype requestid remotereference Communication s provide together a specified invocation semantics. The communication in the server selects the dispatcher for the class of the object to be invoked, passing on the remote object s local reference. 9

Remote reference client server object A proxy for B request reply Skeleton & dispatcher for B s class remote object B communication servant 10 What does the do? It is responsible for translating between local and remote object references and for creating remote object references. The holds a (remote object) table that records the correspondence between local object references in that process and remote object references (which are system-wide). Table includes An entry for all remote objects held by the process An entry for each local proxy 11

Remote reference /servant client server object A proxy for B request reply Skeleton & dispatcher for B s class remote object B communication servant 12 RMI software client server object A proxy for B request reply Skeleton & dispatcher for B s class remote object B communication servant 13

Generation of classes for proxies, dispatcher and skeleton Classes for proxies, dispatcher and skeleton are generated automatically by an interface compiler. In Java RMI Set of methods offered by a remote object is defined as a Java interface that is implemented within the class of the remote object Java RMI compiler generates the proxy, dispatcher and skeleton classes from the class remote object 15 Dynamic invocation: An alternative to proxies Dynamic invocation gives the client access to a generic representation of a remote invocation. In order to make a dynamic invocation not only information (e.g., name) about the interface of the remote object are included in the remote object reference. Additionally the names of the methods and the types of the argument are required. When is it useful? In applications, where some of the interfaces of the remote objects cannot be predicted at design time. 16

Server and client programs Server program Contains classes for the dispatcher and skeletons, together with the implementations of the classes of all of the servants Contains a initialization section (responsible for creating and initializing at least one of the servants to be hosted by the server) Generally allocates a separate thread for the execution of each remote invocation -> designer of the remote object implementation must allow concurrent executions Client program Contain the classes of the proxies for all of the remote objects that it will invoke Require a means of obtaining a remote object reference for at least one of the remote objects held by the server -> binder 17 Factory methods Servants are created either in the initialization section or in methods in a remote interface designed for that purpose Factory method: used to refer to a method that creates servants Factory object: object with factory methods 18

Activation of remote objects A remote object is described as active when it is available for invocation from a running process, whereas it is called passive if it is not currently active but can be made active. Activation consists of creating an active object from the corresponding passive object by creating a new instance of its class and initialize its instance variables from the store state. Activator is responsible for Registering passive objects that are available for activation Starting names server processes and activating remote objects in them Keeping track of the locations of the servers for remote objects that it has already activated 19 Implementation of RMI Distributed garbage collection 20

Java distributed garbage collection algorithm client server object A proxy for B request reply Skeleton & dispatcher for B s class remote object B communication servant 21 Java distributed garbage collection algorithm (cont.) Each server process contains a set of names of the processes hold remote object references for each of its remote objects. Client C server b.holder{c} addref(b) removeref(b) 22

Distributed object component middleware I - Java RMI Java RMI 23 Case study: shared whiteboard http://www.flickr.com/photos/36567420@n06/ 24

Java Remote interfaces Shape and ShapeList import java.rmi.*; import java.util.vector; public interface Shape extends Remote { int getversion() throws RemoteException; GraphicalObject getallstate() throws RemoteException; } public interface ShapeList extends Remote { Shape newshape(graphicalobject g) throws RemoteException; Vector allshapes() throws RemoteException; int getversion() throws RemoteException; } 25 Parameter and result passing In Java RMI, the parameters of a method are assumed to be input parameters and the result of a method is a single output parameter. Any object that is serializable can be passed as an argument or results in Java RMI. Passing remote objects When the type of a parameter or result value is defined as a remote interface, the corresponding argument or result is always passed as a remote object reference. Passing non-remote objects All serializable non-remote objects are copied and passed by value. When a object is passed by value a new object is created in the receiver s process. 26

Downloading classes As you know, non-remote objects are passed by value and remote objects are passed by reference as arguments and results of RMI s.! If the recipient does not already posses the class of an object passed by value, its code is downloaded automatically.! If the recipient of the remote object reference does not already posses the class for a proxy, its code is downloaded automatically. Advantages: 1. There is no need for every user to keep the same set of classes in their working environment. 2. Both client and server programs can male transparent use of instances of new classes whenever they added. 27 RMIregistry The RMIregistry is the binder for Java RMI. It maintains table mapping textual, URL-styled names to references to remote objects hosted on that computer. It is accessed by methods of the Naming class, whose methods take as an argument a URL-formatted string of the form: //computername:port/objectname 28

The Naming class of Java RMIregistry void rebind (String name, Remote obj) This method is used by a server to register the identifier of a remote object by name. void bind (String name, Remote obj) This method can alternatively be used by a server to register a remote object by name, but if the name is already bound to a remote object reference an exception is thrown. void unbind (String name, Remote obj) This method removes a binding. Remote lookup(string name) This method is used by clients to look up a remote object by name. A remote object reference is returned. String [] list() This method returns an array of Strings containing the names bound in the registry. 29 RMIregistry (cont.) It is possible to set up a system-wide binding service. How? An instance of the RMI registry must run in the networked environment The class LocateRegistry (in java.rmi.registry) must be used to discover this registry Contains a getregistry method that returns an object of type Registry representing the remote binding service: public static Registry getregistry() throws RemoteException After discovery it is necessary to issue a call of rebind on this returned Registry object to establish a connection with the remote RMIregistry 30

Java RMI Building a client and server programs 31 Server program The server is a whiteboard server which represents each shape as a remote object instantiated by a servant that implements the Shape interface holds the state of a graphical object as well as its version number represents its collection of shapes by using another servant that implements the ShapeList interface holds a collection of shapes in a Vector 32

Java class ShapeListServer with main method import java.rmi.*; import java.rmi.server.unicastremoteobject; public class ShapeListServer{ public static void main(string args[]){ System.setSecurityManager(new RMISecurityManager()); try{ ShapeList ashapelist = new ShapeListServant(); ShapeList stub = (ShapeList) UnicastRemoteObject.exportObject(aShapeList,0); Naming.rebind( //bruno.shapelist", stub); System.out.println("ShapeList server ready"); }catch(exception e) { System.out.println("ShapeList server main " + e.getmessage());} } } 33 Java class ShapeListServant implements interface ShapeList import java.util.vector; public class ShapeListServant implements ShapeList { private Vector thelist; // contains the list of Shapes private int version; public ShapeListServant() {...} public Shape newshape(graphicalobject g) { version++; Shape s = new ShapeServant( g, version); thelist.addelement(s); return s; } public Vector allshapes() {...} public int getversion() {... } } 34

Java client of ShapeList import java.rmi.*; import java.rmi.server.*; import java.util.vector; public class ShapeListClient{ public static void main(string args[]){ System.setSecurityManager(new RMISecurityManager()); ShapeList ashapelist = null; try{ ashapelist = (ShapeList) Naming.lookup("//bruno.ShapeList ); Vector slist = ashapelist.allshapes(); } catch(remoteexception e) {System.out.println(e.getMessage()); }catch(exception e) {System.out.println("Client: " + e.getmessage());} } } 35 Callbacks The clients creates a remote object that implements an interface that contains a method for the server to call. We refer to this as a callback object. The server provides an operation allowing interested clients to inform it of the remote object references of their callback objects. It records these in a list. Whenever an event of interest occurs, the server calls the interested clients. Disadvantages 1. The performance of the server may be degraded by constant polling. 2. Clients cannot notify users of updates in a timely manner. 36

Remote method invocation Summary 37 We have we learned? 38

Next class Distributed object component middleware II (Java RMI) 39 References Main resource for this lecture: George Coulouris, Jean Dollimore, Tim Kindberg: Distributed Systems: Concepts and Design. 5th edition, Addison Wesley, 2011 40