Download - Java Distributed Computing
![Page 1: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/1.jpg)
Java Distributed Computing
IS 3135.27.2003
![Page 2: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/2.jpg)
Outline Homework #3 Distributed computing overview Programming RMI
![Page 3: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/3.jpg)
Homework #3 Good news
Ave. 13.8 Bad news
Some people didn’t turn in
![Page 4: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/4.jpg)
Distributed computing Sockets
Messages from A to B Distributed computing
A is doing some computation P A asks B to compute some function F
![Page 5: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/5.jpg)
Sockets
Host
Application OS
Host
ApplicationOSSocket
![Page 6: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/6.jpg)
Distributed Computing
Server
Codebase
Client
Application
function F
![Page 7: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/7.jpg)
Questions to askHow does…1. P know how to call F (method signature, host identity)
A. When does user/programmer of P need to know2. P send its message to B and B send the answer back3. B handle F so it can be invoked4. The system provide quality of service, security and
management
![Page 8: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/8.jpg)
Distributed comp. approaches (RPC) RMI DCOM CORBA/JIDL Web services
![Page 9: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/9.jpg)
RMI1. P and F are written in Java
F’s interface is available to P at compile time Host determined at run-time
2. Standard part of Java API3. RMI registry must be running on B4. Not much
![Page 10: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/10.jpg)
RMI
Server
Java object
Client
Application
remote method
RMIregistry
Stub
![Page 11: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/11.jpg)
DCOM1. P and F are implemented in COM
A type library for F is available at compile time Destination is encoded in registry at run time
2. Part of Windows OS3. Loads and runs autonomously4. Some MS tools
![Page 12: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/12.jpg)
DCOM
Server
COM object
Client
Application
public method
COM
COM
![Page 13: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/13.jpg)
CORBA1. An IDL description of F is available at
compile time The ORB uses inter-ORB communication to
find host dynamically
2. Request sent to ORB3. Destination ORB activates and runs4. ORB vendors supply
![Page 14: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/14.jpg)
CORBA
Server
CORBA object
Client
Application
public method
ORB
ORB
![Page 15: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/15.jpg)
Web services1. P gets XML description of F
This can happen at run-time Service registry knows what hosts offers the
service
2. HTTP/SOAP interaction3. Web application server invokes F4. Emerging
![Page 16: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/16.jpg)
Web services
Server
Object
Client
Application
public method
Webserver
SOAP
ServiceRegistry
![Page 17: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/17.jpg)
Trade-offs RMI
Java only DCOM
Windows only CORBA
Must buy ORB software Web services
??
![Page 18: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/18.jpg)
RMI
Server
Java object
Client
Application
remote method
RMIregistry
Stub
![Page 19: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/19.jpg)
Elements of an RMI application Remote object
contains the methods we want to call RMI server
a program that exposes the remote object RMI registry
built-in intermediary RMI client
program that accesses the remote object
![Page 20: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/20.jpg)
RMI Elements
Client
JVM
Server
JVMRegistry
remoteobject
![Page 21: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/21.jpg)
Remote Object Must implement a remote interface UnicastRemoteObject convenience class
![Page 22: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/22.jpg)
Remote Interface Remote object’s signature Must extend java.rmi.Remote All methods must throw RemoteException
![Page 23: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/23.jpg)
RMI Registry Distributed with the JDK No application-specific arguments
![Page 24: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/24.jpg)
RMI Server Program creates instance of Remote
Objects Names and publishes them in the RMI
registry Must set security policy to allow remote
connection
![Page 25: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/25.jpg)
RMI Client Compiled using the Remote Interface Contacts remote registry Downloads stub for remote object Calls methods on the stub
![Page 26: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/26.jpg)
Stub conforms to the remote interface, but connects to remote JVM marshals the parameters for F waits for the result of F, unmarshals the return value or exception
returned, and returns the value to the caller.
![Page 27: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/27.jpg)
Registration
Client
JVM
Server
JVMRegistry
registerremoteobject
![Page 28: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/28.jpg)
Lookup
Client
JVM
stub
Server
JVMRegistry
remoteobject
lookup
returns stub object
![Page 29: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/29.jpg)
Method Call
Client
JVM
stub
Server
JVMRegistry
method callremoteobject
![Page 30: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/30.jpg)
Serialization Alternative to remote object Transmits the object itself Objects passed as parameters to remote
methods implement java.io.Serializable
no code necessary
![Page 31: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/31.jpg)
RMI Example WeatherInfo
serialized class IWeatherData
remote interface WeatherData
remote object WeatherServer
RMI server WeatherInfoClient
RMI client
![Page 32: Java Distributed Computing](https://reader035.vdocuments.us/reader035/viewer/2022070405/56813fee550346895daaf2a9/html5/thumbnails/32.jpg)
Deployment Distribute
remote interfaces definitions of serializable classes
Run rmic to generate stubs for remote objects
Run registry Run RMI server