SlideShare a Scribd company logo
June 21, 2017 www.snipe.co.in 1
Prepared :Snipe Team
June 21, 2017 2
RMI
June 21, 2017 3
• Overview of RMI.
• Java RMI allowed programmer to execute remote function class using
the same semantics as local functions calls.
Java Remote Object Invocation (RMI)?
Local Machine (Client)
SampleServer remoteObject;
int s;
…
s = remoteObject.sum(1,2);
System.out.println(s);
Remote Machine (Server)
public int sum(int a,int b)
{
return a + b;
}
1,2
3
June 21, 2017 4
• Java RMI is a mechanism that allows a Java program running on one
computer (e.g., the client) to apply a method to an object on a different
computer (e.g., the server).
• In itself, the syntax of the remote invocation looks exactly like an
ordinary Java method invocation. The remote method call can be
passed arguments computed in the context of the local machine. It can
return arbitrary values computed in the context of the remote machine.
The RMI system transparently forwards these arguments and results.
• RMI is an implementation of the of the Distributed Object
programming model—similar to CORBA, but simpler, and specialized
to the Java language
Java Remote Object Invocation (RMI)?
June 21, 2017 5
Advantages and Disadvantages
Advantages
True object-orientation: Objects as arguments and values
Mobile behavior: Returned objects can execute on caller
Integrated security
Built-in concurrency (through Java threads)
Disadvantages
Java only
Advertises support for non-Java
But this is external to RMI – requires Java on both sides
June 21, 2017 6
There are 3 Independent Layers
-Stub-Skeleton layer – client stubs and server skeletons
-Remote reference layer
-Transport layer –connection up , management and object tracking
System Architecture
June 21, 2017 7
•Interface to applications. Stub functions:
– Initiating a call to the remote object (via remote reference layer).
– Marshaling arguments (using serialization)
– Informing the remote reference layer that the call should be invoked.
– Unmarshaling the return value or exception from a marshal stream.
– Informing the remote reference layer that the call is complete.
•Skeleton functions:
– Unmarshaling arguments from the marshal stream.
– Making the up-call to the actual remote object implementation.
– Marshaling the return value of the call or an exception (if one occurred)
onto the marshal stream.
•Stub and skeleton (bytecode) generated by RMI compiler (rmic)
Stub-Skeleteon Layer
June 21, 2017 8
•An object implementation selects a specific remote reference sub-class.
Examples :
– Unicast point-to-point invocation
– Invocation to replicated object groups (multiple servers)
– Support for a user-defined replication/redirection strategy.
– Support for a persistent reference to the remote object (enabling activation
of the remote object).
– Reconnection strategies (if remote object becomes inaccessible).
•client-side - information on invocation according to specified remote reference
semantics.
•server-side - implements the specific remote reference semantics prior to
invoking the skeleton (e.g., atomic multicast delivery)
•data is transmitted from stub-skeleton to transport layer (and vice-versa) via
connection-oriented stream abstraction
•a connectionless transport (UDP) can be implemented underneath
Remote Reference Layer
June 21, 2017 9
Functions:
• Setting up and managing connections
• Monitoring connection "liveness."
• Listening for incoming calls.
• Maintaining a table of remote objects that reside in the address space.
• Setting up a connection for an incoming call.
• Locating the dispatcher for the target of the remote call and passing the
connection to this dispatcher.
Abstractions:
• endpoint - denotes an address space or Java virtual machine.
• channel - manages connection between local and remote address spaces
• connection - transfer data
• transport - channel managment
Transport Layer
June 21, 2017 10
• Assume code running in the local machine holds a remote reference to
an object obj on a remote machine.
Example ?
res = obj.meth(arg) ;
ResType meth(ArgType arg) {
. . .
return new ResImpl(. . .) ;
}
Local machine Remote machine
June 21, 2017 11
The General RMI Architecture
• The server must first bind
its name to the registry
• The client lookup the server
name in the registry to
establish remote references.
• The Stub serializing the
parameters to skeleton, the
skeleton invoking the
remote method and
serializing the result back to
the stub.
RMI Server
skeleton
stub
RMI Client
Registry
bind
lookupreturn call
Local Machine
Remote Machine
June 21, 2017 12
The Stub and Skeleton
• A client invokes a remote method, the call is first forwarded to stub.
• The stub is responsible for sending the remote call over to the server-
side skeleton
• The stub opening a socket to the remote server, marshaling the object
parameters and forwarding the data stream to the skeleton.
• A skeleton contains a method that receives the remote calls, unmarshals
the parameters, and invokes the actual remote object implementation
June 21, 2017 13
The Steps for Developing an RMI System
1. Develop the remote object and its interface
/* SampleServer.java */
import java.rmi.*;
public interface SampleServer extends Remote
{
public int sum(int a,int b) throws
RemoteException;
}
June 21, 2017 14
Develop the remote object and its interface
/* SampleServerImpl.java */
public static void main(String args[])
{
try
{
System.setSecurityManager(new RMISecurityManager());
//set the security manager
//create a local instance of the object
SampleServerImpl Server = new SampleServerImpl();
//put the local instance in the registry
Naming.rebind("SAMPLE-SERVER" , Server);
System.out.println("Server waiting.....");
}
catch (java.net.MalformedURLException me) {
System.out.println("Malformed URL: " + me.toString()); }
catch (RemoteException re) {
System.out.println("Remote exception: " + re.toString()); }
}
June 21, 2017 15
Develop the client program
Step 3: Develop the client program
• In order for the client object to invoke methods on the server, it must
first look up the name of server in the registry. You use the
java.rmi.Naming class to lookup the server name.
• The server name is specified as URL in the from
( rmi://host:port/name )
• Default RMI port is 1099.
• The name specified in the URL must exactly match the name that the
server has bound to the registry. In this example, the name is
“SAMPLE-SERVER”
• The remote method invocation is programmed using the remote
interface name (remoteObject) as prefix and the remote method name
(sum) as suffix.
June 21, 2017 16
Develop the client program
import java.rmi.*;
import java.rmi.server.*;
public class SampleClient
{
public static void main(String[] args)
{
// set the security manager for the client
System.setSecurityManager(new RMISecurityManager());
//get the remote object from the registry
try
{
System.out.println("Security Manager loaded");
String url = "//localhost/SAMPLE-SERVER";
SampleServer remoteObject = (SampleServer)Naming.lookup(url);
System.out.println("Got remote object");
System.out.println(" 1 + 2 = " + remoteObject.sum(1,2) );
}
catch (RemoteException exc) {
System.out.println("Error in lookup: " + exc.toString()); }
catch (java.net.MalformedURLException exc) {
System.out.println("Malformed URL: " + exc.toString()); }
catch (java.rmi.NotBoundException exc) {
System.out.println("NotBound: " + exc.toString());
}
}
}
June 21, 2017 17
the Remote Interface
• In RMI, a common remote interface is the minimum amount of
information that must be shared in advance between “client” and
“server” machines. It defines a high-level “protocol” through
which the machines will communicate.
• A remote interface is an ordinary Java interface, which must
extent the marker interface java.rmi.Remote.
• All methods in a remote interface must be declared to throw the
java.rmi.RemoteException exception.
June 21, 2017 18
java.rmi.Remote
• The interface java.rmi.Remote is a marker interface.
• It declares no methods or fields; however, extending it tells the
RMI system to treat the interface concerned as a remote
interface.
• In particular we will see that the rmic compiler generates extra
code for classes that implement remote interfaces. This code
allows their methods to be called remotely
June 21, 2017 19
java.rmi.RemoteException
• The Requiring all remote methods be declared to throw
RemoteException was a philosophical choice by the designers of
RMI.
• RMI makes remote invocations look syntactically like local
invocation. In practice, though, it cannot defend from problems
unique to distributed computing—unexpected failure of the
network or remote machine.
• Forcing the programmer to handle remote exceptions helps to
encourage thinking about how these partial failures should be
dealt with.
June 21, 2017 20
The Remote Object
• A remote object is an instance of a class that implements a
remote interface.
• Most often this class also extends the library class
java.rmi.server.UnicastRemoteObject. This class includes a
constructor that exports the object to the RMI system when it is
created, thus making the object visible to the outside world.
• Usually you will not have to deal with this class explicitly—your
remote object classes just have to extend it.
• One fairly common convention is to name the class of the remote
object after the name of the remote interface it implements, but
append “Impl” to the end
• .
June 21, 2017 21
The Stub
• A What this tells us is that, however they are obtained—and
however they look—remote references are not, in reality, Java
references to remote objects. They are Java references to local
objects that happen to implement the same remote interfaces as
the remote objects concerned.
• The local Java object referenced is actually an instance of a stub
class.
June 21, 2017 22
The Architecture
• A
Client
Code Stub
RMI
“Run-time”
System
Remote
Object
Call stub method
locally
Return value
or throw exception
Call remote object
method locally
Return value
or throw exception
Send marshaled
arguments
Send marshaled
result or
exception
Internet
Client
Server
The Role of rmic
• The only “compiler” technology peculiar to RMI is the
rmic stub generator.
• The input to rmic is a remote implementation class,
compiled in the normal way with javac (for example).
• The stub generator outputs a new class that implements
the same remote interfaces as the input class.
• The methods of the new class contain code to send
arguments to, and receive results from, a remote object,
whose Internet address is stored in the stub instance
The RMI Registry
Client
Code
Remote
Object
Client Server
Registry Store
Reference
Request
Reference
The RMI Registry
Instead of interacting with the registry indirectly through the
Naming class, it is possible to obtain a direct remote reference to
the registry object.
Its remote interface is defined in the package java.rmi.registry.
The interface includes:
public interface Registry extends Remote {
public Remote lookup(String name) throws . . . ;
public bind(String name, Remote obj) throws . . . ;
public rebind(String name, Remote obj) throws . . . ;
. . .
}
The LocateRegistry
This class constructs a stub for an existing Registry object. (It can
also create a new registry implementation object, running in the
current JVM.)
The interface includes:
public final class LocateRegistry {
public static Registry getRegistry(String host, int port)
throws . . .
{. . .}
public static Registry createRegistry(int port)
throws . . .
{. . .}
. . .
}

More Related Content

What's hot

Enhancing the region model of RTSJ
Enhancing the region model of RTSJEnhancing the region model of RTSJ
Enhancing the region model of RTSJ
Universidad Carlos III de Madrid
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
kamal kotecha
 
Objective c intro (1)
Objective c intro (1)Objective c intro (1)
Objective c intro (1)
David Echeverria
 
Memory Management C++ (Peeling operator new() and delete())
Memory Management C++ (Peeling operator new() and delete())Memory Management C++ (Peeling operator new() and delete())
Memory Management C++ (Peeling operator new() and delete())
Sameer Rathoud
 
javarmi
javarmijavarmi
javarmi
Arjun Shanka
 
C++ aptitude
C++ aptitudeC++ aptitude
C++ aptitude
chetan_p211
 
Clojure - A practical LISP for the JVM
Clojure - A practical LISP for the JVMClojure - A practical LISP for the JVM
Clojure - A practical LISP for the JVM
Matthias Nüßler
 
Java- Datagram Socket class & Datagram Packet class
Java- Datagram Socket class  & Datagram Packet classJava- Datagram Socket class  & Datagram Packet class
Java- Datagram Socket class & Datagram Packet class
Ruchi Maurya
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
Atthakorn Chanthong
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09
Guy Korland
 
No Heap Remote Objects for Distributed real-time Java
No Heap Remote Objects for Distributed real-time JavaNo Heap Remote Objects for Distributed real-time Java
No Heap Remote Objects for Distributed real-time Java
Universidad Carlos III de Madrid
 
Pune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCD
Prashant Rane
 
Computer vision
Computer vision Computer vision
Computer vision
Dmitry Ryabokon
 
Network vs. Code Metrics to Predict Defects: A Replication Study
Network vs. Code Metrics  to Predict Defects: A Replication StudyNetwork vs. Code Metrics  to Predict Defects: A Replication Study
Network vs. Code Metrics to Predict Defects: A Replication Study
Kim Herzig
 
OSCON - ES6 metaprogramming unleashed
OSCON -  ES6 metaprogramming unleashedOSCON -  ES6 metaprogramming unleashed
OSCON - ES6 metaprogramming unleashed
Javier Arias Losada
 
Dead locks9cm604.39
Dead locks9cm604.39Dead locks9cm604.39
Dead locks9cm604.39
myrajendra
 
Erlang Message Passing Concurrency, For The Win
Erlang  Message  Passing  Concurrency,  For  The  WinErlang  Message  Passing  Concurrency,  For  The  Win
Erlang Message Passing Concurrency, For The Win
l xf
 
Java14
Java14Java14
Java14
aiter2002
 
Socket programming-tutorial-sk
Socket programming-tutorial-skSocket programming-tutorial-sk
Socket programming-tutorial-sk
sureshkarthick37
 
JNA - Let's C what it's worth
JNA - Let's C what it's worthJNA - Let's C what it's worth
JNA - Let's C what it's worth
Idan Sheinberg
 

What's hot (20)

Enhancing the region model of RTSJ
Enhancing the region model of RTSJEnhancing the region model of RTSJ
Enhancing the region model of RTSJ
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
 
Objective c intro (1)
Objective c intro (1)Objective c intro (1)
Objective c intro (1)
 
Memory Management C++ (Peeling operator new() and delete())
Memory Management C++ (Peeling operator new() and delete())Memory Management C++ (Peeling operator new() and delete())
Memory Management C++ (Peeling operator new() and delete())
 
javarmi
javarmijavarmi
javarmi
 
C++ aptitude
C++ aptitudeC++ aptitude
C++ aptitude
 
Clojure - A practical LISP for the JVM
Clojure - A practical LISP for the JVMClojure - A practical LISP for the JVM
Clojure - A practical LISP for the JVM
 
Java- Datagram Socket class & Datagram Packet class
Java- Datagram Socket class  & Datagram Packet classJava- Datagram Socket class  & Datagram Packet class
Java- Datagram Socket class & Datagram Packet class
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09
 
No Heap Remote Objects for Distributed real-time Java
No Heap Remote Objects for Distributed real-time JavaNo Heap Remote Objects for Distributed real-time Java
No Heap Remote Objects for Distributed real-time Java
 
Pune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCD
 
Computer vision
Computer vision Computer vision
Computer vision
 
Network vs. Code Metrics to Predict Defects: A Replication Study
Network vs. Code Metrics  to Predict Defects: A Replication StudyNetwork vs. Code Metrics  to Predict Defects: A Replication Study
Network vs. Code Metrics to Predict Defects: A Replication Study
 
OSCON - ES6 metaprogramming unleashed
OSCON -  ES6 metaprogramming unleashedOSCON -  ES6 metaprogramming unleashed
OSCON - ES6 metaprogramming unleashed
 
Dead locks9cm604.39
Dead locks9cm604.39Dead locks9cm604.39
Dead locks9cm604.39
 
Erlang Message Passing Concurrency, For The Win
Erlang  Message  Passing  Concurrency,  For  The  WinErlang  Message  Passing  Concurrency,  For  The  Win
Erlang Message Passing Concurrency, For The Win
 
Java14
Java14Java14
Java14
 
Socket programming-tutorial-sk
Socket programming-tutorial-skSocket programming-tutorial-sk
Socket programming-tutorial-sk
 
JNA - Let's C what it's worth
JNA - Let's C what it's worthJNA - Let's C what it's worth
JNA - Let's C what it's worth
 

Viewers also liked

Installer benchmarking
Installer benchmarkingInstaller benchmarking
Installer benchmarking
Mallikarjuna G D
 
Ide benchmarking
Ide benchmarkingIde benchmarking
Ide benchmarking
Mallikarjuna G D
 
Web services engine
Web services engineWeb services engine
Web services engine
Mallikarjuna G D
 
Training
TrainingTraining
Project excursion career_orientation
Project excursion career_orientationProject excursion career_orientation
Project excursion career_orientation
Mallikarjuna G D
 
Digital marketing
Digital marketingDigital marketing
Digital marketing
Mallikarjuna G D
 

Viewers also liked (6)

Installer benchmarking
Installer benchmarkingInstaller benchmarking
Installer benchmarking
 
Ide benchmarking
Ide benchmarkingIde benchmarking
Ide benchmarking
 
Web services engine
Web services engineWeb services engine
Web services engine
 
Training
TrainingTraining
Training
 
Project excursion career_orientation
Project excursion career_orientationProject excursion career_orientation
Project excursion career_orientation
 
Digital marketing
Digital marketingDigital marketing
Digital marketing
 

Similar to Rmi

Rmi
RmiRmi
17rmi
17rmi17rmi
17rmi
Adil Jafri
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
Thesis Scientist Private Limited
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
Gera Paulos
 
Java RMI
Java RMIJava RMI
Java RMI
Prajakta Nimje
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
ashishspace
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
Jalpesh Vasa
 
DS
DSDS
Java RMI
Java RMIJava RMI
Java RMI
Ankit Desai
 
Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
sakthibalabalamuruga
 
Rmi
RmiRmi
Rmi
RmiRmi
Distributed Objects and JAVA
Distributed Objects and JAVADistributed Objects and JAVA
Distributed Objects and JAVA
elliando dias
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
Sonali Parab
 
Rmi3
Rmi3Rmi3
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
Sonali Parab
 
remote method invocation
remote method invocationremote method invocation
remote method invocation
Arun Nair
 
ADB Lab Manual.docx
ADB Lab Manual.docxADB Lab Manual.docx
ADB Lab Manual.docx
SaiKumarPrajapathi
 
Rmi
RmiRmi
#4 (Remote Method Invocation)
#4 (Remote Method Invocation)#4 (Remote Method Invocation)
#4 (Remote Method Invocation)
Ghadeer AlHasan
 

Similar to Rmi (20)

Rmi
RmiRmi
Rmi
 
17rmi
17rmi17rmi
17rmi
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
 
Java RMI
Java RMIJava RMI
Java RMI
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
 
DS
DSDS
DS
 
Java RMI
Java RMIJava RMI
Java RMI
 
Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 
Rmi
RmiRmi
Rmi
 
Rmi
RmiRmi
Rmi
 
Distributed Objects and JAVA
Distributed Objects and JAVADistributed Objects and JAVA
Distributed Objects and JAVA
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 
Rmi3
Rmi3Rmi3
Rmi3
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
remote method invocation
remote method invocationremote method invocation
remote method invocation
 
ADB Lab Manual.docx
ADB Lab Manual.docxADB Lab Manual.docx
ADB Lab Manual.docx
 
Rmi
RmiRmi
Rmi
 
#4 (Remote Method Invocation)
#4 (Remote Method Invocation)#4 (Remote Method Invocation)
#4 (Remote Method Invocation)
 

More from Mallikarjuna G D

Reactjs
ReactjsReactjs
Bootstrap 5 ppt
Bootstrap 5 pptBootstrap 5 ppt
Bootstrap 5 ppt
Mallikarjuna G D
 
CSS
CSSCSS
Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
Mallikarjuna G D
 
Spring andspringboot training
Spring andspringboot trainingSpring andspringboot training
Spring andspringboot training
Mallikarjuna G D
 
Hibernate
HibernateHibernate
Hibernate
Mallikarjuna G D
 
Jspprogramming
JspprogrammingJspprogramming
Jspprogramming
Mallikarjuna G D
 
Servlet programming
Servlet programmingServlet programming
Servlet programming
Mallikarjuna G D
 
Servlet programming
Servlet programmingServlet programming
Servlet programming
Mallikarjuna G D
 
Mmg logistics edu-final
Mmg  logistics edu-finalMmg  logistics edu-final
Mmg logistics edu-final
Mallikarjuna G D
 
Interview preparation net_asp_csharp
Interview preparation net_asp_csharpInterview preparation net_asp_csharp
Interview preparation net_asp_csharp
Mallikarjuna G D
 
Interview preparation devops
Interview preparation devopsInterview preparation devops
Interview preparation devops
Mallikarjuna G D
 
Interview preparation testing
Interview preparation testingInterview preparation testing
Interview preparation testing
Mallikarjuna G D
 
Interview preparation data_science
Interview preparation data_scienceInterview preparation data_science
Interview preparation data_science
Mallikarjuna G D
 
Interview preparation full_stack_java
Interview preparation full_stack_javaInterview preparation full_stack_java
Interview preparation full_stack_java
Mallikarjuna G D
 
Enterprunership
EnterprunershipEnterprunership
Enterprunership
Mallikarjuna G D
 
Core java
Core javaCore java
Core java
Mallikarjuna G D
 
Type script
Type scriptType script
Type script
Mallikarjuna G D
 
Angularj2.0
Angularj2.0Angularj2.0
Angularj2.0
Mallikarjuna G D
 
Git Overview
Git OverviewGit Overview
Git Overview
Mallikarjuna G D
 

More from Mallikarjuna G D (20)

Reactjs
ReactjsReactjs
Reactjs
 
Bootstrap 5 ppt
Bootstrap 5 pptBootstrap 5 ppt
Bootstrap 5 ppt
 
CSS
CSSCSS
CSS
 
Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
 
Spring andspringboot training
Spring andspringboot trainingSpring andspringboot training
Spring andspringboot training
 
Hibernate
HibernateHibernate
Hibernate
 
Jspprogramming
JspprogrammingJspprogramming
Jspprogramming
 
Servlet programming
Servlet programmingServlet programming
Servlet programming
 
Servlet programming
Servlet programmingServlet programming
Servlet programming
 
Mmg logistics edu-final
Mmg  logistics edu-finalMmg  logistics edu-final
Mmg logistics edu-final
 
Interview preparation net_asp_csharp
Interview preparation net_asp_csharpInterview preparation net_asp_csharp
Interview preparation net_asp_csharp
 
Interview preparation devops
Interview preparation devopsInterview preparation devops
Interview preparation devops
 
Interview preparation testing
Interview preparation testingInterview preparation testing
Interview preparation testing
 
Interview preparation data_science
Interview preparation data_scienceInterview preparation data_science
Interview preparation data_science
 
Interview preparation full_stack_java
Interview preparation full_stack_javaInterview preparation full_stack_java
Interview preparation full_stack_java
 
Enterprunership
EnterprunershipEnterprunership
Enterprunership
 
Core java
Core javaCore java
Core java
 
Type script
Type scriptType script
Type script
 
Angularj2.0
Angularj2.0Angularj2.0
Angularj2.0
 
Git Overview
Git OverviewGit Overview
Git Overview
 

Recently uploaded

How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
BoudhayanBhattachari
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
S. Raj Kumar
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 

Recently uploaded (20)

How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 

Rmi

  • 1. June 21, 2017 www.snipe.co.in 1 Prepared :Snipe Team
  • 3. June 21, 2017 3 • Overview of RMI. • Java RMI allowed programmer to execute remote function class using the same semantics as local functions calls. Java Remote Object Invocation (RMI)? Local Machine (Client) SampleServer remoteObject; int s; … s = remoteObject.sum(1,2); System.out.println(s); Remote Machine (Server) public int sum(int a,int b) { return a + b; } 1,2 3
  • 4. June 21, 2017 4 • Java RMI is a mechanism that allows a Java program running on one computer (e.g., the client) to apply a method to an object on a different computer (e.g., the server). • In itself, the syntax of the remote invocation looks exactly like an ordinary Java method invocation. The remote method call can be passed arguments computed in the context of the local machine. It can return arbitrary values computed in the context of the remote machine. The RMI system transparently forwards these arguments and results. • RMI is an implementation of the of the Distributed Object programming model—similar to CORBA, but simpler, and specialized to the Java language Java Remote Object Invocation (RMI)?
  • 5. June 21, 2017 5 Advantages and Disadvantages Advantages True object-orientation: Objects as arguments and values Mobile behavior: Returned objects can execute on caller Integrated security Built-in concurrency (through Java threads) Disadvantages Java only Advertises support for non-Java But this is external to RMI – requires Java on both sides
  • 6. June 21, 2017 6 There are 3 Independent Layers -Stub-Skeleton layer – client stubs and server skeletons -Remote reference layer -Transport layer –connection up , management and object tracking System Architecture
  • 7. June 21, 2017 7 •Interface to applications. Stub functions: – Initiating a call to the remote object (via remote reference layer). – Marshaling arguments (using serialization) – Informing the remote reference layer that the call should be invoked. – Unmarshaling the return value or exception from a marshal stream. – Informing the remote reference layer that the call is complete. •Skeleton functions: – Unmarshaling arguments from the marshal stream. – Making the up-call to the actual remote object implementation. – Marshaling the return value of the call or an exception (if one occurred) onto the marshal stream. •Stub and skeleton (bytecode) generated by RMI compiler (rmic) Stub-Skeleteon Layer
  • 8. June 21, 2017 8 •An object implementation selects a specific remote reference sub-class. Examples : – Unicast point-to-point invocation – Invocation to replicated object groups (multiple servers) – Support for a user-defined replication/redirection strategy. – Support for a persistent reference to the remote object (enabling activation of the remote object). – Reconnection strategies (if remote object becomes inaccessible). •client-side - information on invocation according to specified remote reference semantics. •server-side - implements the specific remote reference semantics prior to invoking the skeleton (e.g., atomic multicast delivery) •data is transmitted from stub-skeleton to transport layer (and vice-versa) via connection-oriented stream abstraction •a connectionless transport (UDP) can be implemented underneath Remote Reference Layer
  • 9. June 21, 2017 9 Functions: • Setting up and managing connections • Monitoring connection "liveness." • Listening for incoming calls. • Maintaining a table of remote objects that reside in the address space. • Setting up a connection for an incoming call. • Locating the dispatcher for the target of the remote call and passing the connection to this dispatcher. Abstractions: • endpoint - denotes an address space or Java virtual machine. • channel - manages connection between local and remote address spaces • connection - transfer data • transport - channel managment Transport Layer
  • 10. June 21, 2017 10 • Assume code running in the local machine holds a remote reference to an object obj on a remote machine. Example ? res = obj.meth(arg) ; ResType meth(ArgType arg) { . . . return new ResImpl(. . .) ; } Local machine Remote machine
  • 11. June 21, 2017 11 The General RMI Architecture • The server must first bind its name to the registry • The client lookup the server name in the registry to establish remote references. • The Stub serializing the parameters to skeleton, the skeleton invoking the remote method and serializing the result back to the stub. RMI Server skeleton stub RMI Client Registry bind lookupreturn call Local Machine Remote Machine
  • 12. June 21, 2017 12 The Stub and Skeleton • A client invokes a remote method, the call is first forwarded to stub. • The stub is responsible for sending the remote call over to the server- side skeleton • The stub opening a socket to the remote server, marshaling the object parameters and forwarding the data stream to the skeleton. • A skeleton contains a method that receives the remote calls, unmarshals the parameters, and invokes the actual remote object implementation
  • 13. June 21, 2017 13 The Steps for Developing an RMI System 1. Develop the remote object and its interface /* SampleServer.java */ import java.rmi.*; public interface SampleServer extends Remote { public int sum(int a,int b) throws RemoteException; }
  • 14. June 21, 2017 14 Develop the remote object and its interface /* SampleServerImpl.java */ public static void main(String args[]) { try { System.setSecurityManager(new RMISecurityManager()); //set the security manager //create a local instance of the object SampleServerImpl Server = new SampleServerImpl(); //put the local instance in the registry Naming.rebind("SAMPLE-SERVER" , Server); System.out.println("Server waiting....."); } catch (java.net.MalformedURLException me) { System.out.println("Malformed URL: " + me.toString()); } catch (RemoteException re) { System.out.println("Remote exception: " + re.toString()); } }
  • 15. June 21, 2017 15 Develop the client program Step 3: Develop the client program • In order for the client object to invoke methods on the server, it must first look up the name of server in the registry. You use the java.rmi.Naming class to lookup the server name. • The server name is specified as URL in the from ( rmi://host:port/name ) • Default RMI port is 1099. • The name specified in the URL must exactly match the name that the server has bound to the registry. In this example, the name is “SAMPLE-SERVER” • The remote method invocation is programmed using the remote interface name (remoteObject) as prefix and the remote method name (sum) as suffix.
  • 16. June 21, 2017 16 Develop the client program import java.rmi.*; import java.rmi.server.*; public class SampleClient { public static void main(String[] args) { // set the security manager for the client System.setSecurityManager(new RMISecurityManager()); //get the remote object from the registry try { System.out.println("Security Manager loaded"); String url = "//localhost/SAMPLE-SERVER"; SampleServer remoteObject = (SampleServer)Naming.lookup(url); System.out.println("Got remote object"); System.out.println(" 1 + 2 = " + remoteObject.sum(1,2) ); } catch (RemoteException exc) { System.out.println("Error in lookup: " + exc.toString()); } catch (java.net.MalformedURLException exc) { System.out.println("Malformed URL: " + exc.toString()); } catch (java.rmi.NotBoundException exc) { System.out.println("NotBound: " + exc.toString()); } } }
  • 17. June 21, 2017 17 the Remote Interface • In RMI, a common remote interface is the minimum amount of information that must be shared in advance between “client” and “server” machines. It defines a high-level “protocol” through which the machines will communicate. • A remote interface is an ordinary Java interface, which must extent the marker interface java.rmi.Remote. • All methods in a remote interface must be declared to throw the java.rmi.RemoteException exception.
  • 18. June 21, 2017 18 java.rmi.Remote • The interface java.rmi.Remote is a marker interface. • It declares no methods or fields; however, extending it tells the RMI system to treat the interface concerned as a remote interface. • In particular we will see that the rmic compiler generates extra code for classes that implement remote interfaces. This code allows their methods to be called remotely
  • 19. June 21, 2017 19 java.rmi.RemoteException • The Requiring all remote methods be declared to throw RemoteException was a philosophical choice by the designers of RMI. • RMI makes remote invocations look syntactically like local invocation. In practice, though, it cannot defend from problems unique to distributed computing—unexpected failure of the network or remote machine. • Forcing the programmer to handle remote exceptions helps to encourage thinking about how these partial failures should be dealt with.
  • 20. June 21, 2017 20 The Remote Object • A remote object is an instance of a class that implements a remote interface. • Most often this class also extends the library class java.rmi.server.UnicastRemoteObject. This class includes a constructor that exports the object to the RMI system when it is created, thus making the object visible to the outside world. • Usually you will not have to deal with this class explicitly—your remote object classes just have to extend it. • One fairly common convention is to name the class of the remote object after the name of the remote interface it implements, but append “Impl” to the end • .
  • 21. June 21, 2017 21 The Stub • A What this tells us is that, however they are obtained—and however they look—remote references are not, in reality, Java references to remote objects. They are Java references to local objects that happen to implement the same remote interfaces as the remote objects concerned. • The local Java object referenced is actually an instance of a stub class.
  • 22. June 21, 2017 22 The Architecture • A Client Code Stub RMI “Run-time” System Remote Object Call stub method locally Return value or throw exception Call remote object method locally Return value or throw exception Send marshaled arguments Send marshaled result or exception Internet Client Server
  • 23. The Role of rmic • The only “compiler” technology peculiar to RMI is the rmic stub generator. • The input to rmic is a remote implementation class, compiled in the normal way with javac (for example). • The stub generator outputs a new class that implements the same remote interfaces as the input class. • The methods of the new class contain code to send arguments to, and receive results from, a remote object, whose Internet address is stored in the stub instance
  • 24. The RMI Registry Client Code Remote Object Client Server Registry Store Reference Request Reference
  • 25. The RMI Registry Instead of interacting with the registry indirectly through the Naming class, it is possible to obtain a direct remote reference to the registry object. Its remote interface is defined in the package java.rmi.registry. The interface includes: public interface Registry extends Remote { public Remote lookup(String name) throws . . . ; public bind(String name, Remote obj) throws . . . ; public rebind(String name, Remote obj) throws . . . ; . . . }
  • 26. The LocateRegistry This class constructs a stub for an existing Registry object. (It can also create a new registry implementation object, running in the current JVM.) The interface includes: public final class LocateRegistry { public static Registry getRegistry(String host, int port) throws . . . {. . .} public static Registry createRegistry(int port) throws . . . {. . .} . . . }