Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.

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

RMI Varun SainiYing Chen. What is RMI? RMI is the action of invoking a method of a remote interface on a remote object. It is used to develop applications.
Remote Method Invocation CS587x Lecture Department of Computer Science Iowa State University.
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.
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
Remote Object Invocation Tran, Van Hoai Department of Systems & Networking Faculty of Computer Science & Engineering HCMC University of Technology.
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
Java RMI. What is RMI? RMI is an RPC system for an object based language. Objects provide a natural granularity for the binding of functions. –RMI allows.
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
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.
Java RMI RMI = Remote Method Invocation. Allows Java programs to invoke methods of remote objects. Only between Java programs. Several versions (JDK-1.1,
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.
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 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.
Example: RMI Program How to write it.
 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.
Java RMI. RMI Any object whose methods can be invoked from another Java VM is called a remote object.
1 RMI Russell Johnston Communications II. 2 What is RMI? Remote Method Invocation.
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.
Java Distributed Computing
Java Remote Method Invocation (RMI)
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Creating a Distributed System with RMI
Creating a Distributed System with 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
Changing the way of designing distributed applications
Creating a Distributed System with RMI
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development of the system is done based on the protocol. Application design orientation: The development and design of the system is done like if everything is local and then the application is divided into modules that will be running on different machines. This first strategy has a more complicated design but the programming will use less resources. The second is better when the communications are complicated, at the point to make the application difficult.

Alternative Technologies Development of networks => Development of distributed systems Development of middleware (libraries,tools,services, etc..) that support the programming of distributed systems Based on TCP/IP protocol The programming language is more high- level The problem of the distributed applications is not a particular case.

Remote Procedure Calls (RPC) Motivation: Development of NFS (SUN) A client can call a function in an application running on a server just like if it is locally implemented. Sends the parameters and receives the results in a correct format(Integer,String,float...) eXternal Data Representation Serialization.

Remote Procedure Calls The client stops the execution until the results are received. Call(parameters) Receive results RPC Server RPC Client Server framework: provided by the middleware

The Interface file Specifies the protocol of the remote function: name, required parameters (how many, and what type), result (type) It is called “interface” file because server and the client get the needed information. The client uses the interface to compile The server implements it RPC Server RPC Client Interface definition file

Remote Objects As the object orientation paradigm developed the “remote object” approach replaced the previous paradigm. An Application can call a method of an object located on another JVM. The interface file is the key concept of the implementation. RemoteObjectServer Invokes the method Gets the result

Necessary files Gets a reference to the remote object. Use the method and, Receives the results as if it is locally located. Client program Server program Defines a particular class to implement the methods specified in the interface Creates the remote object from this class. It is published in some registry service, to be located by the clients. Defines the methods (just the header) that could be remotely invoked. Implements Use for compilation interface

Example: Remote Date Server The only method of the object will be getDate(), this method will return as a result the date of the computer where it is located. Remote Server getDate () Tue Jun 12 17:20:24

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

Defining a class to implement remote objects. Definition of the class for the remote object Remote Interface RemoteObject Implements Remote Extends 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 The communications are implemented by the stub and skel files. They are generated when the sourcecode is compiled using the rmic command. With the 1.5 version of java they are generated automatically Client Stub Remote Object Server Skel

The name registry server It is a server for registring and making public the remote objects. The server of the remote object registers the object in it and the clients obtain a reference to the object from it. Must run in the host server, and have access to the stub and skel files. Must be reinitialized before the server registers the object. Client Remote Object Server rmiregistry

¿ What file and where? The client need the interface and stub file. The server need the Stub and Skel file. Client Remote Object Server DateClient.class RemoteDate.class DateServer_stub.class DateServer.class RemoteDate.class DateServer_stub.class DateServer_skel.class

Generating stub & skel The class file of the implementation must be compiled again with the rmic command. DateClient.java RemoteDate.java DateClient.class DateServer.class DateServer_stub.cl ass DateServer_skel.class DateServer.java RemoteDate.class javac rmic

Initiating the rmiregistry from the application. It is possible to initiate the rmiregistry from an application calling a java method. The following example will also demostrate concurrent problems. Remote Number Server Clie nt getNumber() 1 2 3

The RMI based chat The client must receive the messages of the server. The client implements a remote object wich is passed to the server as a parameter!!! The server does not need to locate the client Remote Object Client Remote Object Server addClient(this) sendMessage(text) newMessage(text)

A remote file server Access to files Client -open file read/write -close file -Read line -Write line What happends if: - It is asked to open a non- existing file. - It is asked to read a non- opened file. - More errors are generated.

Automatic Distribution (stub) The stub file can be distributed atomaticly but it is necessary to add a safety controller. For this it is necessary to write in a security policy file. When the server is initialized it is necessary to specify an URL to tell the server where the policty file is located. java –Djava.security.policy=policy.txt -Djava.rmi.server.codebase= ClientProgram Se examples: PideNumero ReparteNumeros (askNumber) (GiveNumber)

Automatic Distribution (stub) The stub file is obtained using the URL protocol A “web-server” must be running. A small class server can be used. ClassFileServer (extends ClassServer) Steps : –Download RFSClient.cass, RFSInterface.class, policy.txt –Run the class Server with the command ClassFileServer port path. –Run the remote object server. –The client contacts the server (with the policy and codebase parameters)

Automatic activation of the remote server Sometimes it is not convienient to have many servers running at the same time, just when it is necessary. RMI provides a schema to activate objects. Only one server is always running (the rmideamon), that will wakeup the objects when it is necesary. (Call from a client ) It is necessary to write and run a “set-up” program to registry the sleeping server with the rmid that will wake it up. For the client there is no difference.

Steps to write an activable server Rewrite the Server to extend an “activable” class instead of the RemoteUnicastObject. import java.rmi.activation.*; public class MyRemoteClass extends Activable implement MyInterface Replace the constructor to one that has 2 parameters. public MyRemoteClass(ActivationID id, MarshalledObject data) throws RemoteException { super(id, 0); } Compile it with javac and rmic. Write and compile the Setup program

Steps to run it Run the ClassFileServer and rmiregistry Run the rmid rmid –J-Djava.security.policy=policy.txt Run the Setup program Java -Djava.security.policy=policy.txt – Djava.rmi.server.codebase= Setup Run the client. Java -Djava.security.policy=policy.txt – Djava.rmi.server.codebase= client