This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CMSC 433, Alan Sussman, U. Maryland (via Bill Pugh) 1CMSC433, Spring 2001Programming Language Technology and Paradigms Java RMIAlan SussmanMarch 15, 2001CMCS 433, Spring 2001 - Alan Sussman 2Administrivia• Read Chapter 15, pages 973-979, on RMI• Exam– answers posted on Exams web page– Mean: 58 Median: 5825%: 49 75%: 69• Project 4 due April 4– distributed chat server, using RMI– posted today, central server running soonCMCS 433, Spring 2001 - Alan Sussman 3Last time• Java libraries– I/O using streams, Readers, Writers, filters– java.util• Vector, Dictionary, Enumeration, Bitset• Collection classes (List, Map, Set, etc.)• Multithreaded programming– and the Java memory model– Motto is: Be careful!CMCS 433, Spring 2001 - Alan Sussman 4Different Approaches to Distributed Computation• High-performance, parallel scientific apps• Connecting via sockets– custom protocols for each application• RPC/DCOM/CORBA/RMI– make what looks like a normal function call– function is actually invoked on another machine– Arguments are marshalled for transport– return value is marshalledas wellCMCS 433, Spring 2001 - Alan Sussman 5Remote Method Invocation• Easy way to get distributed computation• Have stub for remote object– calls to stub get translated into network call• Arguments and return values can be passed over network CMCS 433, Spring 2001 - Alan Sussman 6Remote Objects and Interfaces• Remote Objects are those that can be referenced remotely– extends java.rmi.UnicastRemoteObject– constructor throws java.rmi.RemoteException• Remote interfaces describe services that can be provided remotely– extends java.rmi.Remote interface– all methods throw java.rmi.RemoteExceptionCMSC 433, Alan Sussman, U. Maryland (via Bill Pugh) 2CMCS 433, Spring 2001 - Alan Sussman 7RMIC - RMI Compiler• Generates stub code for a class– For 1.1, also generates skeleton class– skeleton not needed for 1.2+• Generates stubs for all methods declared in remote interfaces– other methods don’t get a stubCMCS 433, Spring 2001 - Alan Sussman 8Passing arguments• Can pass arbitrary values as arguments• Can return arbitrary values as results• To pass a value, it must either be– Serializable, or– Remote• Passing the same Serializable object in different calls– will materialize different objects at receiverCMCS 433, Spring 2001 - Alan Sussman 9Downloading code• When you pass a reference to a remote class– receiver needs stub class• When you pass a ref to serializable class– receiver needs class• Annotate ref’s with RMI codebase– where code can be loaded fromCMCS 433, Spring 2001 - Alan Sussman 10SecurityManager• Must install some Security Manager to allow download of classes from RMI codebase• Can use RMISecurityManagerSystem.setSecurityManager(new RMISecurityManager());• Modify policy file to grant permissionsCMCS 433, Spring 2001 - Alan Sussman 11Naming.lookup• Naming.lookup is used to bootstrap RMI communication– Get your first reference to a remote object• Run an RMIRegistry– a separate Java VM– listens to a particular port (default 1099)• Can bind/unbind/rebind name on localhost• Can lookup name on any hostCMCS 433, Spring 2001 - Alan Sussman 12RMI Chat server• Server – runs the chat room• Client– participant in chat room– receives messages from others in room• Connection– uniquely identifies a client– used to speak in chat roomCMSC 433, Alan Sussman, U. Maryland (via Bill Pugh) 3CMCS 433, Spring 2001 - Alan Sussman 13Serverinterface Server extends Remote {Connection logon(String name, Client c)throws RemoteException; }CMCS 433, Spring 2001 - Alan Sussman 14Connectioninterface Connection extends Remote {/** Say to everyone */void say(String msg)throws RemoteException;/ ** Say to one person */void say(String who, String msg)throws RemoteException;String [] who()throws RemoteException;void logoff()throws RemoteException; ;}CMCS 433, Spring 2001 - Alan Sussman 15Clientinterface Client extends Remote {void said(String who, String msg)throws RemoteException;void whoChanged(String [] who)throws RemoteException;}CMCS 433, Spring 2001 - Alan Sussman 16Remote Object creationServerImplServer s = new ServerImpl();HostedRemote ObjectsCMCS 433, Spring 2001 - Alan Sussman 17RMI RegistryServerImplNaming.rebind(“ ChatServer”, s);HostedRemote ObjectsRMIRegistryChatServerServerImplStubCMCS 433, Spring 2001 - Alan Sussman 18Client creationClientImplClient c = new ClientImpl();HostedRemote ObjectscCMSC 433, Alan Sussman, U. Maryland (via Bill Pugh) 4CMCS 433, Spring 2001 - Alan Sussman 19Server LookupClientImplServer s = (Server) Naming.lookup(“//host/ChatServer”);HostedRemote ObjectscsServerImplStubHostedRemote ObjectsServerImplCMCS 433, Spring 2001 - Alan Sussman 20Invoke message on Serverprepare call on clientClientImplConnection conn = s.logon(“Bill”, c);HostedRemote ObjectscsServerImplStubMarshalledargumentsSerializedString “Bill”SerializedStub for ctargetmethod: logonCMCS 433, Spring 2001 - Alan Sussman 21Unmarshalling arguments on Server“Bill”ClientImplStubServerImplMarshalledargumentsSerializedString “Bill”SerializedStub for ctargetmethod: logonlogonCMCS 433, Spring 2001 - Alan Sussman 22Execution on Server“Bill”ClientImplStubServerImplHostedRemote ObjectsnameclientconnConnectionImplCMCS 433, Spring 2001 - Alan Sussman 23Marshalling return value“Bill”ClientImplStubServerImplHostedRemote ObjectsConnectionImplMarshalledreturn value:SerializedStub for connconnCMCS 433, Spring 2001 - Alan Sussman 24Unmarshalling return valueClientImplHostedRemote ObjectscsServerImplStubMarshalledreturn valueSerializedStub for


View Full Document

UMD CMSC 433 - Java RMI

Documents in this Course
Trace 1

Trace 1

62 pages

Reflection

Reflection

137 pages

Testing

Testing

25 pages

Paradigms

Paradigms

10 pages

Testing

Testing

17 pages

Java RMI

Java RMI

17 pages

Java RMI

Java RMI

17 pages

Java RMI

Java RMI

17 pages

Trace 1

Trace 1

46 pages

Jini

Jini

4 pages

Final

Final

15 pages

Java RMI

Java RMI

13 pages

Testing

Testing

16 pages

Load more
Download Java RMI
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Java RMI and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Java RMI 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?