Distributed Programming in Java. Distribution (2)

Similar documents
5.4. Events and notifications

JAVA RMI. Remote Method Invocation

presentation DAD Distributed Applications Development Cristian Toma

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

Remote Procedure Call

Remote Method Invocation R.M.I.

CC755: Distributed and Parallel Systems

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

Distributed Systems COMP 212. Lecture 10 Othon Michail

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

Remote Method Invocation

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

JAVA RMI Java, summer semester

RMI Example RMI. CmpE 473 Internet Programming RMI

Distributed Systems. 5. Remote Method Invocation

Distributed Objects SPL/ SPL 201 / 0 1

Reflection/RMI 4/28/2009

Remote Method Invocation. Benoît Garbinato

Remote Method Invocation Benoît Garbinato

RMI Case Study. A Typical RMI Application

Remote Method Invocation in Java

Lecture VI: Distributed Objects. Remote Method Invocation

Sockets and RMI. CS151 Chris Pollett Dec. 5, 2005.

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

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

RMI. (Remote Method Invocation)

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

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

Remote Objects and RMI

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

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

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

RPC and RMI. 2501ICT Nathan

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

SUMMARY INTRODUCTION REMOTE METHOD INVOCATION

Distributed Computing

Remote Method Invocation

Grid Computing. Java Remote Method Invocation (RMI) RMI Application. Grid Computing Fall 2006 Paul A. Farrell 9/5/2006

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

Generic architecture

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

Distributed object component middleware I - Java RMI

Distributed object component middleware I - Java RMI

CS 5523 Operating Systems: Remote Objects and RMI

Component-Based Software Engineering

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

Last Class: Network Overview. Today: Distributed Systems

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

Distributed Systems. 6. Remote Method Invocation. Werner Nutt

Verteilte Systeme (Distributed Systems)

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

Distributed Information Systems

Written by: Dave Matuszek

Distributed Objects. Remote Method Invokation

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

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

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

IBD Intergiciels et Bases de Données

RMI. Remote Method Invocation. 16-Dec-16

Distributed Applications Programming. Lab 4

Programming with RMI Reminder

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

THE RMI PROXY USER GUIDE

RMI: Design & Implementation

Chapter 4: Processes. Process Concept. Process State

Chapter 5 Distributed Objects and Remote Invocation

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

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

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

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

Message Passing vs. Distributed Objects. 5/15/2009 Distributed Computing, M. L. Liu 1

Lecture 18 Inside Java RMI

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

5 Distributed Objects: The Java Approach

Modulo II Socket, RMI e Corba

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

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

A Real-Time RMI Framework for the RTSJ

EDA095 Remote Method Invocation

Distributed Software Systems

EDA095 Remote Method Invocation

Activation of remote objects

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

IJESRT. http: //

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

Remote Method Invocation

Chapter 4 Remote Procedure Calls and Distributed Transactions

Course Snapshot. The Next Few Classes

DS 2009: middleware. David Evans

Communication and Distributed Processing

Communication Framework

Bharati Vidyapeeth s Institute of Computer Applications and Management A-4, Paschim Vihar, New Delhi-63.

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

Communication and Distributed Processing

CS193k, Stanford Handout #12. Threads 4 / RMI

Outline. Chapter 4 Remote Procedure Calls and Distributed Transactions. Remote Procedure Call. Distributed Transaction Processing.

Distributed Objects. Chapter Distributing Objects Overview

Lecture 5: Object Interaction: RMI and RPC

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

COMP 6231: Distributed System Design

Transcription:

Distributed Programming in Java Distribution (2)

Remote Method Invocation Remote Method Invocation (RMI) Primary design goal for RMI is transparency Should be able to invoke remote objects with same syntax and semantics as local ones However, some important differences exit Refresher: in the introduction to this course we presented the key differences...

Remote is not Like Local Latency data transfer time is several orders of magnitude slower Memory access refs in local address space are not valid in a remote address space Concurrency may be unexpected and unplanned interaction of computing tasks Partial failure can be indeterminacy due to the lack of a central authority Famous paper by Waldo, J., et al, A Note on Distributed Computing, http:// research.sun.com/techrep/1994/smli_tr-94-29.pdf

Detailed Comparison (1) Object behavior Behavior exported by a remote object is defined in an interface Object implementation Class that implements this interface Object creation Clients cannot directly create instances of a remote class (unless using activation)

Detailed Comparison (2) Object access Remote objects accessed through remote reference variable (a client proxy) Active references Remote objects are considered to have an active reference if they have been accessed recently (during a certain lease period) Exceptions Remote exceptions exposed to client

Separation of Behavior and Implementation Remote object behavior defined in an interface (Service) Remote object behavior implemented in a server class (ServiceImpl) Proxy sends request to remote object Service service() Client Proxy service() ServiceImpl service() Also see Broker pattern

Client Server RMI Stubs Sekeletons Architecture Stub Sekeleton Layers Remote Reference RemoteRef Unicast RemoteObject Naming Transport «protocol» JRMP «protocol» RMI-IIOP Also see Layers pattern

Stubs and Skeletons Stub Represents server object on client side Implements remote interface Knows how to forward method calls Skeleton Represents client object on server side Calls services on the service object Knows how to forward results to client Skeletons are no longer required, as the JDK invokes the server methods via reflection

Using RMI 1. Define interfaces for remote objects 2. Define implementations for interfaces 3. Create stub (and skeleton) classes 4. Develop a server that creates an instance of the service implementation 5. Develop a client that uses the service provided by the remote interface 6. Start the RMI registry, server and client

1. Define Remote Interface Define an interface of the remote object Must extend the Remote interface Contract between a server and its clients Methods may throw a RemoteException public interface Service extends Remote { public void service(...) throws RemoteException; // other services }

2. Implement Interface Implementation of the remote interface Extends UnicastRemoteObject class (or exports a remote reference explicitly) Constructor of base class exports object public class ServiceImpl extends UnicastRemoteObject } implements Service { public void service(...) throws RemoteException; { } // implementation // implementation of other services

3. Create Stubs Generate stub (and skeleton) classes using the RMI compiler (rmic) > rmic -keep -v1.2 ServiceImpl Generates a stub classe ServiceImpl_Stub (implements interface) -keep option keeps stub source

4. Develop Server Create an instance of the service (that is, the implementation of the remote interface) Registers the service in naming service Service service = new ServiceImpl(...); Naming.rebind(name, service);

Registry RMI can use different naming services A simple service is the Registry Each RMI service is identified by an URL with the protocol rmi [rmi:][//host[:port]/]name Binding: registration of the service with the registry so remote clients can locate it

rmi.naming bind(name, obj) Binds remote object to name rebind(name, obj) Binds remote object to name, even if bound unbind(name) Removes binding of name lookup(url) Returns remote object bound to url list(url) Returns list of names in registry

5. Develop Client Develop a client that uses the service provided by the remote interface Can be a local or a remote object Client must first locate a remote object before its methods can be invoked Remote remote = Naming.lookup(name); Service service = (Service) remote; //... service.service(); // remote method invocation

6. Starting the Application rmiregistry [<port>] Default port: 1099 java -Djava.security.policy=server.policy Server Registers instance under assigned name We need to specify a security policy java -Djava.security.policy=client.policy Client

Security Policy Security policies introduced in JDK 1.2 The java.security package introduces the notion of policy A policy specifies which permissions (e.g. to read or write files, read from sockets) are available to code from different sources Policy for an application specified in policy file, typically using policytool in JDK

Example Policy Grant permissions to all sources to connect and accept on sockets for the given ports Restricts what actions downloaded classes (here, stubs) can perform Connect/accept on ports 1024-65535 Connect on port 80 (web servers) grant { permission java.net.socketpermission "*:1024-65535", "connect,accept"; permission java.net.socketpermission "*:80", "connect"; };

Print Server Implements a print server to which one can submit print jobs, list, and cancel them Users will be notified when job is complete We will start with a design without notification, that is, only printer classes need to expose a remote interface...... to add notification we need to support callbacks on the client (also interface)

Print Server Remote UnicastRemoteObject Client PrintJob document copies Printer submit() jobs() cancel() PrinterImpl submit() jobs() cancel() PrinterServer Must be serializable

Printer Defines remote interface public interface Printer extends Remote { public void submit(printjob job) throws RemoteException; public Vector jobs() throws RemoteException; public void cancel(printjob job) throws RemoteException; } PrintJobs must be serializable public class PrintJob implements Serializable { public String owner; public String document; public int copies; public Date timestamp; }