Changing the way of designing distributed applications

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
DISTRIBUTED FILE SYSTEM USING RMI
Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.
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.
Practical Issues of RPCCS-4513, D-Term Remote Procedure Call Practical Issues CS-4513 Distributed Computing Systems (Slides include materials from.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
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)
CS 584 Lecture 18 l Assignment » Glenda assignment extended to the Java RMI Deadline » No Java RMI Assignment l Test » Friday, Saturday, Monday.
+ 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.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
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.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
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 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.
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.*
Creating Applications Using RMI Lesson 1B / Slide 1 of 19 Network and Distributed Programming in Java Pre-assessment Questions 1.Which of the following.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
Changing the way of designing distributed applications Communication oriented design: FIRST design the communication protocol for the distributed system.
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.
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.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
Netprog Java RMI1 Remote Method Invocation.
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
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
Java Distributed Computing
Java Remote Method Invocation (RMI)
Broker in practice: Middleware
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Network and Distributed Programming in Java
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Creating a Distributed System with RMI
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Creating a Distributed System with RMI
Remote method invocation (RMI)
Remote Method Invocation
Creating a Distributed System with RMI
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
Creating a Distributed System with RMI
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Changing the way of designing distributed applications Communication oriented design: FIRST design the communication protocol for the distributed system and then the program is developed accordingly Application oriented design: Develop the application as if everything were locally and then divide the application in modules which will run in remote machines The first approach is harder to design but simpler to implement The second one is better when there is a framework supporting the implementation of such

Alternative Technologies Development of networks => development of distributed systems Development of middleware (libraries, tools, etc..) supporting easy programming of distributed systems Based on TCP/IP protocols Higher level programming language for distributed systems The distributed case is not a problem anymore

Remote Procedure Calls Motivation: NFS development (SUN) A client application can call a procedure (function) in a server application running on another computer as it were locally implemented Handle over parameters, receiving results in an appropiate format (integer, string, float,..) eXternal Data Representation

Remote Procedure Calls The client stops until the procedure call returns RPC Client RPC Server Call(parameters) Receive results Server framework: provided by the system

The Interface File Specifies the protocol of the remote procedure: name, required parameters (number and type), result (type). It is called the interface file because it holds the information the client needs to use RPC Client Interface definition file RPC Server Implements interface Uses Interface for compiling

Remote Objects This paradigm was rapidly replaced by the remote object paradigm An application can invoke a method of an object located in another JVM The interface file remains the key to describe the object protocol to the clients RemoteObjectServer Invoke method Receive result

Files Involved Interface Define the methods (only the header) Which will be able to called remotely implements Use for compiling Obtain reference to remote object Apply method as usually Receive results as usually Define a particular class for implementing remote objects and implements the interface Create a remote-able object Make it publicly available Server program Client program

An Example: Remote Date Server The only method will be Date getDate(), the server will answer with the local Date Remote Server getDate() getDate() Tue Jun 12 17:20:24

The interface file It must import java.rmi.* It must extend Remote import java.util.Date; public interface RemoteDate extends Remote { public Date getDate() throws RemoteException; } It must import java.rmi.* It must extend Remote Every declared method should throw a RemoteException

Define a class for implementing remote date objects RemoteObject Remote Interface Extends Implements Extends The remote Object Class definition DateServer.java

The Client Program import java.rmi.*; import java.rmi.server.*; import java.util.Date; public class DateClient { public static void main( String args[] ) { try { RemoteDate dateobj = (RemoteDate)Naming.lookup( "rmi://"+args[0]+"/DateServer" ); Date datum = dateobj.getDate(); System.out.println( “Server Date : " + datum ); } catch ( Exception e ){ System.out.println(e); }

The Stub and Skel Files Communication is implemented by the stub and skel files They are generated by compiling the class files of the remote object implementation with the rmic command Remote Object Server Client Stub Skel

The name registry server A server to register and make public remote objects Server register the object by this server, clients ask this server for a reference to a certain object It should run at the server‘s computer and have access (like any java program) to the stub file. It must be started before the remote object is registered rmiregistry Client Remote Object Server

Which file where ? A client needs the stub file and the interface file The server needs the Stub & Skel file Client Remote Object Server DateClient.class RemoteDate.class DateServer_stub.class DateServer.class RemoteDate.class DateServer_stub.class DateServer_skel.class

How to generate stub & skel The compiled implementation class should be compiled (again) with the rmic command DateServer.java RemoteDate.java DateClient.java javac javac DateServer.class javac RemoteDate.class rmic DateClient.class DateServer_skel.class DateServer_stub.class

Starting rmiregistry from program It is possible to start a registry server from the program A number server will illustrate this and the concurrency problem Remote Number Server getNumber() 1 3 2 getNumber() getNumber() Client Client Client

The RMI-based Chat The client must also receive messages from the server It also implements a remote object, which is passed as parameter !!! The server does not need to locate the client Remote Object Client addClient(this) Remote Object Server sendMessage(text) newMessage(text)

A Remote file server Access to files open file read/write close file Read line Write line What happens if: open a file which does not exists Read a line from a file not opened Other exceptions Client

Automatic distribution (stub) The stub can be distributed automatically but then the code needs to include a security policy statement A security policy file must be provided, which must be specified in the command line When starting the server, a URL for retrieving the stub file must be specified java –Djava.security.policy=policy.txt -Djava.rmi.server.codebase=http://hostname/filelocation ClientProgram See examples PideNumero ReparteNumeros

Automatic distribution (stub) The downloading of the stub class is made via URL A “web-server” must be running at the server side We can use a small server to server only class files for this purpose ClassFileServer (extends ClassServer) Steps : Download RFSClient.cass, RFSInterface.class, policy.txt Server start ClassFileServer port path Server start Remote Object server Client contacts server (with policy and codebase parameters

Activation of the server Sometimes it is not convenient to have all server objects running waiting for a client RMI provides an activation schema for remote object servers There is only one “server” running (the rmideamon), who will “wake up” the server when a client requests a service It is necessary then to write and run a set-up program, which will register the “sleeping” server with the rmid For the client, there is no difference

Steps for writing an activable server Rewrite the server so it extends the activable class´instead of RemoteUnicastObject import java.rmi.activation.*; public class MyRemoteClass extends Activable implement MyInterface Remove the original constructor and write one which receives two parameters: public MyRemoteClass(ActivationID id, MarshalledObject data) throws RemoteException { super(id, 0); } Compile with javac and rmic Write and compile the set-up program which will register the activable class to the rmi daemon See under kapitel 8/ rmid

Steps for running this Start the ClassFileServer and rmiregistry Start the rmid rmid –J-Djava.security.policy=policy.txt Run the Setup program Java -Djava.security.policy=policy.txt – Djava.rmi.server.codebase=http://hostname:port/ Setup Run the client – Djava.rmi.server.codebase=http://hostname:port/ client Look where the output of the server program is given The code of the client does not change. Activation is strictly a server-side implementation decision.