SlideShare a Scribd company logo
1 of 13
Download to read offline
Concurrent Programming— Slide Set 7. RPC and RMI    Theodore Norvell



Remote Procedure Call
 • Suited for Client-Server structure.
 • Combines aspects of monitors and synchronous message
   passing:
    ∗ Module (remote object) exports operations, invoked with
      call.
    ∗ call blocks (delays caller) until serviced.
 • call causes a new thread to be created on remote (server).
 • Client-server synchronization and communication is
   implicit.




c
°2003, 2005 — Typset March 5, 2008                               1
Concurrent Programming— Slide Set 7. RPC and RMI      Theodore Norvell


   Terminology / Notation
server module: operations, (shared) variables, local
procedures and threads for servicing remote procedure
calls.
interface (specification): describes the operations, parameter
types and return types.
op opname(param types) [returns return type]
server process: thread created by call to service an operation.
background process: threads running in a module that aren’t
created in response to call.




c
°2003, 2005 — Typset March 5, 2008                                 2
Concurrent Programming— Slide Set 7. RPC and RMI   Theodore Norvell


   Example Server Module

module TicketServer
     op getNext returns int ;
body
     int next := 0 ;
     sem ex := 1 ;

     procedure getNext() returns val {
         P(ex) ;
         val := next ;
         next := next + 1 ;
         V(ex) ; }
end TicketServer




c
°2003, 2005 — Typset March 5, 2008                              3
Concurrent Programming— Slide Set 7. RPC and RMI       Theodore Norvell


   Issues
       Lookup and registration
How does the client find the server?
Often server registers (binds) with a naming service (registry).
Client obtains information (lookup) about server from this
server.
This changes the question to: How does the client find the
registry?
       Synchronization
Synchronization within a module (server). Two approaches:
1. Assume mutual exclusion in server (only one server
   process/background process executing at a time).
    ∗ Similar to monitors.
    ∗ Still need conditional synchronization.
2. Program it explicitly (i.e., using semaphores, monitors etc.).




c
°2003, 2005 — Typset March 5, 2008                                  4
Concurrent Programming— Slide Set 7. RPC and RMI     Theodore Norvell


       Argument passing
Formats may be different on different machines.
 • ints are different sizes, encodings, endianess.
 • floats have different encodings
Address space is different in different processes.
 • Can not pass pointers.
 • Can not pass by reference.
 • Can not pass objects containing pointers.
Three solutions:
 • Copy-in: Arguments are converted to byte arrays (serializa-
   tion) and reconstructed on the other side.
 • Copy-in/copy-out: Copy-in + final value is passed back.
 • Proxy objects: A proxy object is constructed on the server
   side. Calls to the proxy are converted to RPCs back to the
   argument.




c
°2003, 2005 — Typset March 5, 2008                                5
Concurrent Programming— Slide Set 7. RPC and RMI       Theodore Norvell


   Java RMI (Remote Method Invocation)
Client objects and server objects are local to different JVM
processes.
Server objects (usually) extend
java.rmi.server.UnicastRemoteObject.
       Lookup and registration
How does the client find the server?
• Server objects registered by name with a registry service.
  (Naming.bind)
 • Client objects obtain references to proxy objects from the
   registry service. (Naming.lookup)
       Synchronization
Synchronization within a module (server).
 • Each remote call implies the creation of a new server thread.
   So if there are multiple clients, there can be multiple server
   threads active at the same time.
 • Synchronization must be programmed explicitly (use
   synchronized or my monitor package)


c
°2003, 2005 — Typset March 5, 2008                                  6
Concurrent Programming— Slide Set 7. RPC and RMI      Theodore Norvell


       Argument passing
Formats may be different on different machines.
 • Not an issue as data formats are standard across all Java
   implementations.
Address space is different in different processes.
 • Reference arguments (and subsidiary references) are
   serialized and passed by copy-in rather than by reference.
 • Except RemoteObjects, in which case a proxy (‘stub’) is
   passed instead (This complicates garbage collection).




c
°2003, 2005 — Typset March 5, 2008                                 7
Concurrent Programming— Slide Set 7. RPC and RMI                                    Theodore Norvell


       Skeletons and Stubs
 • ‘Stub’ objects implement the same interface as the server
   objects. (Proxy pattern)
 • (0), (5) Client threads call a stub local to their JVM instance.
 • (1), (4) Stub messages (TCP/IP) to Skeleton object in
   remote JVM & waits for reply.
 • (2), (3) Skeleton creates a new server thread which calls the
   server.
 • Stub and skeleton classes are synthesized by a RMI Com-
   piler (rmic).
                                                    Call

                                                   Return
                                 Client                             Server
                                                   Message
                           (0)                                                (3)
                                           (5)                (2)

                                  Stub              Object
                                                                Skeleton
                                 (Proxy)
                                                    Process
                                                     (JVM)
                                 (1)                                         (4)



                                                    Network




c
°2003, 2005 — Typset March 5, 2008                                                               8
Concurrent Programming— Slide Set 7. RPC and RMI   Theodore Norvell


   Example
Start a registry process

D:...classes> rmiregistry -Jcp -J.

First we need an interface for the server

package tryrmi;
import java.rmi.* ;

public interface TicketServerInterface extends Remote
{
     public int getTicket() throws RemoteException ; }




c
°2003, 2005 — Typset March 5, 2008                              9
Concurrent Programming— Slide Set 7. RPC and RMI    Theodore Norvell


We implement the interface and write a main program to create
and register the server object.

package tryrmi;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;

public class TicketServer
extends UnicastRemoteObject
implements TicketServerInterface {

          private int next = 0 ;

          public synchronized int getTicket()
          throws RemoteException {
              return next++ ; }

          public TicketServer() throws RemoteException {
              super() ; }




c
°2003, 2005 — Typset March 5, 2008                             10
Concurrent Programming— Slide Set 7. RPC and RMI        Theodore Norvell


          public static void main( String[] args ) {
              try {
                    TicketServer server = new TicketServer()
                  ;
                    String name = args[0] ;
                    Naming.bind( name, server ) ; }
              catch( java.net.MalformedURLException e) {
                    ... }
              catch( AlreadyBoundException e) { ... }
              catch( RemoteException e ) { ... } } }

Executing main creates and registers a server object.

D:...classes> java -cp . tryrmi.TicketServer
                             rmi://frege.engr.mun.ca/ticket

The skeleton object will be generated automatically by the
Java Runtime Environment. (There is no need to write a class
for the skeleton object.)
Some client code

package tryrmi;

c
°2003, 2005 — Typset March 5, 2008                                 11
Concurrent Programming— Slide Set 7. RPC and RMI     Theodore Norvell


import java.rmi.* ;

public class TestClient {

          public static void main(String[] args) {
              try { String name = args[0] ;
                   TicketServerInterface proxy =
                                      (TicketServerInterface)
                                    Naming.lookup( name ) ;
                   use proxy object}
              catch( java.net.MalformedURLException e) {
                   ... }
              catch( NotBoundException e) { ... }
              catch( RemoteException e) { ... } } }

The client can be executed from anywhere on the internet. (The
stub object will be created by the Java Runtime Environment.
There is no need to write a class for the stub object.)

D:...classes> java -cp . tryrmi.TestClient
                             rmi://frege.engr.mun.ca/ticket


c
°2003, 2005 — Typset March 5, 2008                              12
Concurrent Programming— Slide Set 7. RPC and RMI     Theodore Norvell



RPC 6= PC
Although remote procedure calls and local procedure calls are
beguilingly similar and in Java share exactly the same syntax,
there are important differences
 • Partial Failure
    ∗ Part of the system of objects may fail
    ∗ Partial failures may be intermittent
    ∗ Network delays
       · On a large network, delays are indistinguishable from
         failures
 • Performance
    ∗ Remote calls are several orders of magnitude more
      expensive than local calls (100,000 or more to 1)
 • Concurrency
    ∗ Remote calls introduce concurrency that may not be in a
      nondistributed system.
 • Semantics changes
    ∗ In Java, local calls pass objects by reference.
    ∗ Remote calls pass objects either by copy or by copying a
      proxy.

c
°2003, 2005 — Typset March 5, 2008                              13

More Related Content

What's hot

EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4Max Kleiner
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread poolsmaksym220889
 
Virtual Machines Lecture
Virtual Machines LectureVirtual Machines Lecture
Virtual Machines Lecturelienhard
 
Java Concurrency Idioms
Java Concurrency IdiomsJava Concurrency Idioms
Java Concurrency IdiomsAlex Miller
 
Metrics ekon 14_2_kleiner
Metrics ekon 14_2_kleinerMetrics ekon 14_2_kleiner
Metrics ekon 14_2_kleinerMax Kleiner
 
Clojure concurrency
Clojure concurrencyClojure concurrency
Clojure concurrencyAlex Navis
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVAJalpesh Vasa
 
RBuilder and ByteSurgeon
RBuilder and ByteSurgeonRBuilder and ByteSurgeon
RBuilder and ByteSurgeonMarcus Denker
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924yohanbeschi
 
NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)Ron Munitz
 
Other Approaches (Concurrency)
Other Approaches (Concurrency)Other Approaches (Concurrency)
Other Approaches (Concurrency)Sri Prasanna
 
Objective-c for Java Developers
Objective-c for Java DevelopersObjective-c for Java Developers
Objective-c for Java DevelopersMuhammad Abdullah
 
Essentials of Multithreaded System Programming in C++
Essentials of Multithreaded System Programming in C++Essentials of Multithreaded System Programming in C++
Essentials of Multithreaded System Programming in C++Shuo Chen
 

What's hot (19)

EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread pools
 
Stoop 390-instruction stream
Stoop 390-instruction streamStoop 390-instruction stream
Stoop 390-instruction stream
 
Virtual Machines Lecture
Virtual Machines LectureVirtual Machines Lecture
Virtual Machines Lecture
 
Java Concurrency Idioms
Java Concurrency IdiomsJava Concurrency Idioms
Java Concurrency Idioms
 
Loom and concurrency latest
Loom and concurrency latestLoom and concurrency latest
Loom and concurrency latest
 
Java rmi
Java rmiJava rmi
Java rmi
 
How to Test Asynchronous Code
How to Test Asynchronous CodeHow to Test Asynchronous Code
How to Test Asynchronous Code
 
Metrics ekon 14_2_kleiner
Metrics ekon 14_2_kleinerMetrics ekon 14_2_kleiner
Metrics ekon 14_2_kleiner
 
Clojure concurrency
Clojure concurrencyClojure concurrency
Clojure concurrency
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
 
Rmi ppt-2003
Rmi ppt-2003Rmi ppt-2003
Rmi ppt-2003
 
RBuilder and ByteSurgeon
RBuilder and ByteSurgeonRBuilder and ByteSurgeon
RBuilder and ByteSurgeon
 
Threads
ThreadsThreads
Threads
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
 
NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)
 
Other Approaches (Concurrency)
Other Approaches (Concurrency)Other Approaches (Concurrency)
Other Approaches (Concurrency)
 
Objective-c for Java Developers
Objective-c for Java DevelopersObjective-c for Java Developers
Objective-c for Java Developers
 
Essentials of Multithreaded System Programming in C++
Essentials of Multithreaded System Programming in C++Essentials of Multithreaded System Programming in C++
Essentials of Multithreaded System Programming in C++
 

Viewers also liked (17)

Bradisismi
Bradisismi Bradisismi
Bradisismi
 
Thailandia-ELISA
Thailandia-ELISAThailandia-ELISA
Thailandia-ELISA
 
La bomba atomica
La bomba atomicaLa bomba atomica
La bomba atomica
 
Le fasi di un vulcano
Le fasi di un vulcanoLe fasi di un vulcano
Le fasi di un vulcano
 
El món d'Android
El món d'AndroidEl món d'Android
El món d'Android
 
Validitas dan reabilitas dalam penelitian kedokteran
Validitas dan reabilitas dalam penelitian kedokteranValiditas dan reabilitas dalam penelitian kedokteran
Validitas dan reabilitas dalam penelitian kedokteran
 
tinjauan pustaka penelitian
tinjauan pustaka penelitiantinjauan pustaka penelitian
tinjauan pustaka penelitian
 
Fasi lunari margherita m
Fasi lunari margherita mFasi lunari margherita m
Fasi lunari margherita m
 
Maree
MareeMaree
Maree
 
Presentazione1
Presentazione1Presentazione1
Presentazione1
 
Diego riviera pamela
Diego riviera pamelaDiego riviera pamela
Diego riviera pamela
 
Robert schumann
Robert schumannRobert schumann
Robert schumann
 
Etika penelitian
Etika penelitianEtika penelitian
Etika penelitian
 
Sud africa_elisa
Sud africa_elisaSud africa_elisa
Sud africa_elisa
 
Il congo
Il congoIl congo
Il congo
 
Filippine
FilippineFilippine
Filippine
 
Scoperte geografiche2
Scoperte geografiche2Scoperte geografiche2
Scoperte geografiche2
 

Similar to Cp7 rpc

Distributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMIDistributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMIelliando dias
 
Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)aragozin
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocationelliando dias
 
Python twisted
Python twistedPython twisted
Python twistedMahendra M
 
Nanocloud cloud scale jvm
Nanocloud   cloud scale jvmNanocloud   cloud scale jvm
Nanocloud cloud scale jvmaragozin
 
Direct Code Execution - LinuxCon Japan 2014
Direct Code Execution - LinuxCon Japan 2014Direct Code Execution - LinuxCon Japan 2014
Direct Code Execution - LinuxCon Japan 2014Hajime Tazaki
 
#4 (Remote Method Invocation)
#4 (Remote Method Invocation)#4 (Remote Method Invocation)
#4 (Remote Method Invocation)Ghadeer AlHasan
 
Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMIbackdoor
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMIbackdoor
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocationashishspace
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John StevensonJAX London
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server InternalsPraveen Gollakota
 

Similar to Cp7 rpc (20)

Distributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMIDistributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMI
 
Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Rmi
RmiRmi
Rmi
 
Python twisted
Python twistedPython twisted
Python twisted
 
Rmi
RmiRmi
Rmi
 
Nanocloud cloud scale jvm
Nanocloud   cloud scale jvmNanocloud   cloud scale jvm
Nanocloud cloud scale jvm
 
17rmi
17rmi17rmi
17rmi
 
Direct Code Execution - LinuxCon Japan 2014
Direct Code Execution - LinuxCon Japan 2014Direct Code Execution - LinuxCon Japan 2014
Direct Code Execution - LinuxCon Japan 2014
 
#4 (Remote Method Invocation)
#4 (Remote Method Invocation)#4 (Remote Method Invocation)
#4 (Remote Method Invocation)
 
Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMI
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMI
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
 
DS
DSDS
DS
 
Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
Play Framework
Play FrameworkPlay Framework
Play Framework
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server Internals
 

Cp7 rpc

  • 1. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell Remote Procedure Call • Suited for Client-Server structure. • Combines aspects of monitors and synchronous message passing: ∗ Module (remote object) exports operations, invoked with call. ∗ call blocks (delays caller) until serviced. • call causes a new thread to be created on remote (server). • Client-server synchronization and communication is implicit. c °2003, 2005 — Typset March 5, 2008 1
  • 2. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell Terminology / Notation server module: operations, (shared) variables, local procedures and threads for servicing remote procedure calls. interface (specification): describes the operations, parameter types and return types. op opname(param types) [returns return type] server process: thread created by call to service an operation. background process: threads running in a module that aren’t created in response to call. c °2003, 2005 — Typset March 5, 2008 2
  • 3. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell Example Server Module module TicketServer op getNext returns int ; body int next := 0 ; sem ex := 1 ; procedure getNext() returns val { P(ex) ; val := next ; next := next + 1 ; V(ex) ; } end TicketServer c °2003, 2005 — Typset March 5, 2008 3
  • 4. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell Issues Lookup and registration How does the client find the server? Often server registers (binds) with a naming service (registry). Client obtains information (lookup) about server from this server. This changes the question to: How does the client find the registry? Synchronization Synchronization within a module (server). Two approaches: 1. Assume mutual exclusion in server (only one server process/background process executing at a time). ∗ Similar to monitors. ∗ Still need conditional synchronization. 2. Program it explicitly (i.e., using semaphores, monitors etc.). c °2003, 2005 — Typset March 5, 2008 4
  • 5. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell Argument passing Formats may be different on different machines. • ints are different sizes, encodings, endianess. • floats have different encodings Address space is different in different processes. • Can not pass pointers. • Can not pass by reference. • Can not pass objects containing pointers. Three solutions: • Copy-in: Arguments are converted to byte arrays (serializa- tion) and reconstructed on the other side. • Copy-in/copy-out: Copy-in + final value is passed back. • Proxy objects: A proxy object is constructed on the server side. Calls to the proxy are converted to RPCs back to the argument. c °2003, 2005 — Typset March 5, 2008 5
  • 6. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell Java RMI (Remote Method Invocation) Client objects and server objects are local to different JVM processes. Server objects (usually) extend java.rmi.server.UnicastRemoteObject. Lookup and registration How does the client find the server? • Server objects registered by name with a registry service. (Naming.bind) • Client objects obtain references to proxy objects from the registry service. (Naming.lookup) Synchronization Synchronization within a module (server). • Each remote call implies the creation of a new server thread. So if there are multiple clients, there can be multiple server threads active at the same time. • Synchronization must be programmed explicitly (use synchronized or my monitor package) c °2003, 2005 — Typset March 5, 2008 6
  • 7. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell Argument passing Formats may be different on different machines. • Not an issue as data formats are standard across all Java implementations. Address space is different in different processes. • Reference arguments (and subsidiary references) are serialized and passed by copy-in rather than by reference. • Except RemoteObjects, in which case a proxy (‘stub’) is passed instead (This complicates garbage collection). c °2003, 2005 — Typset March 5, 2008 7
  • 8. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell Skeletons and Stubs • ‘Stub’ objects implement the same interface as the server objects. (Proxy pattern) • (0), (5) Client threads call a stub local to their JVM instance. • (1), (4) Stub messages (TCP/IP) to Skeleton object in remote JVM & waits for reply. • (2), (3) Skeleton creates a new server thread which calls the server. • Stub and skeleton classes are synthesized by a RMI Com- piler (rmic). Call Return Client Server Message (0) (3) (5) (2) Stub Object Skeleton (Proxy) Process (JVM) (1) (4) Network c °2003, 2005 — Typset March 5, 2008 8
  • 9. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell Example Start a registry process D:...classes> rmiregistry -Jcp -J. First we need an interface for the server package tryrmi; import java.rmi.* ; public interface TicketServerInterface extends Remote { public int getTicket() throws RemoteException ; } c °2003, 2005 — Typset March 5, 2008 9
  • 10. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell We implement the interface and write a main program to create and register the server object. package tryrmi; import java.rmi.*; import java.rmi.server.UnicastRemoteObject; public class TicketServer extends UnicastRemoteObject implements TicketServerInterface { private int next = 0 ; public synchronized int getTicket() throws RemoteException { return next++ ; } public TicketServer() throws RemoteException { super() ; } c °2003, 2005 — Typset March 5, 2008 10
  • 11. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell public static void main( String[] args ) { try { TicketServer server = new TicketServer() ; String name = args[0] ; Naming.bind( name, server ) ; } catch( java.net.MalformedURLException e) { ... } catch( AlreadyBoundException e) { ... } catch( RemoteException e ) { ... } } } Executing main creates and registers a server object. D:...classes> java -cp . tryrmi.TicketServer rmi://frege.engr.mun.ca/ticket The skeleton object will be generated automatically by the Java Runtime Environment. (There is no need to write a class for the skeleton object.) Some client code package tryrmi; c °2003, 2005 — Typset March 5, 2008 11
  • 12. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell import java.rmi.* ; public class TestClient { public static void main(String[] args) { try { String name = args[0] ; TicketServerInterface proxy = (TicketServerInterface) Naming.lookup( name ) ; use proxy object} catch( java.net.MalformedURLException e) { ... } catch( NotBoundException e) { ... } catch( RemoteException e) { ... } } } The client can be executed from anywhere on the internet. (The stub object will be created by the Java Runtime Environment. There is no need to write a class for the stub object.) D:...classes> java -cp . tryrmi.TestClient rmi://frege.engr.mun.ca/ticket c °2003, 2005 — Typset March 5, 2008 12
  • 13. Concurrent Programming— Slide Set 7. RPC and RMI Theodore Norvell RPC 6= PC Although remote procedure calls and local procedure calls are beguilingly similar and in Java share exactly the same syntax, there are important differences • Partial Failure ∗ Part of the system of objects may fail ∗ Partial failures may be intermittent ∗ Network delays · On a large network, delays are indistinguishable from failures • Performance ∗ Remote calls are several orders of magnitude more expensive than local calls (100,000 or more to 1) • Concurrency ∗ Remote calls introduce concurrency that may not be in a nondistributed system. • Semantics changes ∗ In Java, local calls pass objects by reference. ∗ Remote calls pass objects either by copy or by copying a proxy. c °2003, 2005 — Typset March 5, 2008 13