1 / 79

UMass Lowell Computer Science 91.460 Java and Distributed Computing Prof. Karen Daniels Fall, 2000

UMass Lowell Computer Science 91.460 Java and Distributed Computing Prof. Karen Daniels Fall, 2000. Lecture 20 A little more on RMI Getting started with Jini Mon. 11/20. Homework Status. HW# Assigned Due. 1 Fri, 9/8 9/15, 9/18 2 Fri, 9/15 Fri, 9/22

maren
Download Presentation

UMass Lowell Computer Science 91.460 Java and Distributed Computing Prof. Karen Daniels Fall, 2000

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UMass Lowell Computer Science 91.460Java and Distributed ComputingProf. Karen DanielsFall, 2000 Lecture 20 A little more on RMI Getting started with Jini Mon. 11/20

  2. Homework Status HW# Assigned Due 1 Fri, 9/8 9/15, 9/18 2 Fri, 9/15 Fri, 9/22 3 Fri, 9/22 Fri, 9/29 4 Fri, 10/6 Fri, 10/13 5 Fri, 10/13 Fri, 10/20 6 Fri, 10/20 Fri, 10/27 7 Fri, 10/27 Fri, 11/3 & 11/6 8 Fri, 10/27 Mon, 11/20 9 Mon, 11/20 Fri, 12/1 Graded Start reading CoreJini (Chapters 1-5) Submitted Pending

  3. First, a little more on RMI...

  4. Dynamic Loading of Code • Server side can accept unknown (at compile time) subclasses as arguments to method invocations • Requires such a class to create a codebase • Tells the JVM where to get the code from (just like moving applets around in the Web!) • Contains a URL that can be used to download the code • All RMI does is annotate the serialized data with the URL • Is used to transmit stubs around as well as customized code • The client does not have to receive stubs ahead of time

  5. Security Issues • RMI supports downloading code at runtime • E.g., getting stubs, remote polymorphism • RMI provides a SecurityManager to enable the use of downloadable code • Implements a rudimentary security policy (e.g., all code signed by Bill can write to this directory) • See system.getSecurityManager(), system. setSecurityManager(), and class RMISecurityManager for more details

  6. RMI Activation Framework • Mechanism for starting server-side objects from the client side • Activate remote objects when needed • Deactivate them when not needed • Useful when: • Have rarely used remote objects • Have many remote objects • To reconstitute remote services after a crash • Requires special code

  7. Some Notes About RMI • The distributed environment is more fragile (need to worry more about exceptions) • Network connections can go down • Remote machines can go down • Garbage collection • Remote references have a lease period • If no local and no remote references, becomes a candidate for GC • Invokes the unreferenced method of the Unreferenced interface (if implemented) vs finalize

  8. Some Notes About RMI (continued) • A remote object can be richer than the interface it presents to the outside world • Not all of its methods have to be exposed • A remote object can expose multiple sets of interfaces • E.g., an admin interface and a functional interface • Higher parts of inheritance hierarchies can be remoted • Base classes become servers • Java does not use a separate Interface Definition Language (IDL) • JAVA RMI is specific to Java • Java does not use an Object Request Broker (ORB) • Some typical ORB services are built into the RMI mechanism (e.g., naming, security)

  9. A Short RMI Quiz http://developer.java.sun.com/developer/Quizzes/rmi

  10. For More RMI Information... http://developer.java.sun.com/developer/onlineTraining/rmi - RMI Tutorial - RMI Exercises

  11. Key Jini Concepts

  12. Key Concepts Networking

  13. Application Presentation 7 Adds user authentication, privacy Session 6 Adds syntax/presentation format conversion Transport 5 Adds session, connection coordination Network 4 Adds end-to-end control Data Link 3 Adds routing, forwarding Physical 2 Adds error, synchronization control 1 Sends bit stream through network Open Systems Interconnect (OSI)Reference Model Source :http://www.cisco.com/cpress/cc/td/cpress/fund/ith/ith01gb.htm

  14. Key Networking Terms: Protocols • Packet, Datagram: header (e.g. address) + data • IP= Internet Protocol • moves packets from network node to node • TCP = Transmission Control Protocol (OSI layer 4) • decomposes message into packets and recomposes (in order) on other end • supports point-to-point messaging • TCP/IP = TCP + IP = basic Internet protocol • UDP = User Datagram Protocol (OSI layer 4) • uses datagrams UDP = User Datagram Protocol • does not decompose, recompose, or provide ordering • UDP/IP = UDP + IP = lightweight Internet protocol Source: http://www.whatis.com

  15. Key Networking Terms (continued)See Core Jini (p. 202) • Unicast: • point-to-point • separate message for each recipient • sender knows IP address of recipient • Broadcast: • every party on network receives the message • Multicast: “In-between” Unicast and Multicast • multiple parties may receive same message • parties may be “grouped”

  16. Key Concepts Chapter 3

  17. Some Jini Definitions • Service: an entity on the network (e.g. hardware device or software module) that can be used by other Jini participants • Community: a group of Jini services that are “aware” of each other (typically workgroup size) • Group: used by Jini APIs to specify and represent a community • But, due to network separation, different communities may have same group name • Federation: a collection of communities that are “aware” of each other

  18. 5 Key Concepts • Discovery: find communities on a network and join them • Lookup: use Lookup Service(s) to find services and use them • Leasing: resource is “loaned” to some consumer for fixed time period • Remote Events: allow services to notify others of their state changes • Transactions: protocol to support multiple services moving to “safe” state

  19. Key Concepts Chapter 3: Discovery

  20. Lookup Service Service Item Proxy Service Provider Attribute Attribute Attribute Attribute DiscoverySingle community example Assumes Java and network

  21. Lookup Service Service Item Service Item Proxy Proxy Service Provider Attribute Attribute Attribute Attribute Attribute Attribute Attribute Attribute JoiningSingle community example

  22. Discovery/Joining Steps for a Service • Find Lookup Service(s) • Use Jini discovery protocol to get reference(s) to object(s) that implement lookup interface(s) (ServiceRegistrar interface) • Join community(s) Lookup Service(s) • Publish service object using join protocol • use register( ) method of ServiceRegistrar • pass service item to register( ) method Client also uses discovery to find Lookup Service(s)

  23. Jini Discovery Protocols • Lightweight • Do not depend on Java (JVM, serialization, RMI...) • Short messages • minimize partial message loss due to multiple packets • Jini multicast is based on UDP/IP • Parties can join multicast group by listening for messages sent to a special IP address for that group • Messages are confined to local network (subnet) • Simple • Implement DiscoveryListener interface, do simple bookkeeping

  24. Jini Discovery Protocols (cont.) • Multicast Request Protocol • Used by service or client • Find local, active lookup service(s) • Multicast Announcement Protocol • Used by Lookup Service • Announces presence periodically • Unicast Discovery Protocol • Used by a service or client • Communicate directly with a Lookup Service

  25. Service Provider 1 Client A Service 1 Item Service 1 Item Service Provider 3 Service 4 Item Service 3 Item Lookup Service Client D Service 1 Item Service 1 Item Service 2 Item Lookup Service Service 3 Item Service 2 Item Client C Client E Lookup Service Service 3 Item Service 3 Item Service 4 Item Service 3 Item Client B Service 4 Item Service Provider 2 Service Provider 4 Service 2 Item Service 2 Item Service 4 Item Service 3 Item Discovery Example: Multiple Community

  26. Key Concepts Chapter 3: Lookup

  27. Lookup Service Service Item Service Item Service Item Proxy Proxy Proxy Client Service Provider Attribute Attribute Attribute Attribute Attribute Attribute Attribute Attribute Attribute Attribute Attribute Attribute LookupSingle community example

  28. Lookup • Lookup service is like a name server, but with richer semantics • Object returned from discovery implements lookup interface ServiceRegistrar • To search for a service, use lookup( ) method of ServiceRegistrar interface • Search parameters for matching a service item: • type of proxy object • service id (unique) • attributes

  29. Lookup (continued) • Downloadable proxy insulates client from service communication and implementation details • Proxy common scenarios: • Proxy actually performs the service • Proxy is an RMI stub for talking with remote service • Proxy uses private communication protocol to communicate with service (e.g. legacy or hardware)

  30. Lookup Service Service Item Service Item Service Item Proxy Proxy Proxy Client Service Provider Attribute Attribute Attribute Attribute Attribute Attribute Attribute Attribute Attribute Attribute Attribute Attribute Service InvocationSingle community example Lookup Service does not participate in service interaction. proxy manages service interaction

  31. Key Concepts Chapter 3: Leasing

  32. Leasing • Resource is “loaned” to some consumer for fixed time period • Consumer must continue to show interest in resource • Provides the resiliency of Jini • Acts somewhat like garbage collection system for distributed system • Leases used in Lookup Service and elsewhere • Lease grantor (e.g. Lookup Service) grants a lease to lease holder (e.g. Service) • Jini Leases work like “real world” leases • They expire at predetermined time unless renewed • They can be denied or granted by the grantor of the lease • They can be renewed by the lease holder • They can be canceled by either party • They can be negotiated but the grantor has final say portions of this slide contributed by Ayal Spitz

  33. Leasing (continued)Third-Party Leasing • Delegate leasing authority to another party (but not responsibility) • Like power-of-attorney • Advantage: convenience • third-party can keep renewing lease for you • especially useful when service holding lease is long-lived but rarely active • Third-party: LeaseRenewalManager class

  34. Leasing (continued) • register( ) method of ServiceRegistrar has integer lease duration parameter • When service calls register( ), Lookup Service responds with Lease object (if it grants the lease) • Single round of negotation • Duration • may be approximate due to time discrepancies in a distributed system • right length of time may be application-dependent

  35. Key Concepts Chapter 3: Remote Events

  36. Remote Events • Asynchronous (remote) event notification • Asynchrony: “absolute and even relative times at which events take place cannot always be known precisely” [Distributed Computing, Attiya] • Message handled outside normal flow of control of software component • “Listener”/callback

  37. Remote Events (continued)Remote vs. Local Events • Java 2 event generator is a thread within JVM • In remote case, it is hard to guarantee: • Delivery itself • failures, even partial ones, can occur • recipient may be inactive (using RMI activation) • Order of events • Sending vs. event processing cost: • local: send is often small compared with processing • remote: send is often large compared with processing

  38. Remote Events (continued)Event-Programming Model • Use RemoteEventListener (an RMI Remote interface) to receive events • its only method is notify( ) [distinct from Java notify( )] • RemoteEvent class represents a remote event • Simplicity allows event delegation • can create generic third-party event listeners to store, use, forward remote events • No generic way to express interest in events • no addRemoteEventListener interface: each generator provides way for recipients to express interest • Interest must be renewed (like leasing) • Each RemoteEvent has a sequence number

  39. Key Concepts Chapter 3: Transactions

  40. Transaction Goals • Atomicity • All operations succeed or fail together • Consistency • Transaction leaves system in “consistent” state • Isolation • Applications are isolated from intermediate transaction operations • Durability • Successful transaction survives failure/crash

  41. Participant 1 Log Ready to Commit? Ready! Transaction Manager Log Temporary Storage Participant 2 Ready to Commit? Ready! Ready to Commit? Log Participant 3 Permanent Storage Ready! Log Transactions: Database ExampleTwo-Phase Commit: Phase 1 • Phase 1: All services signal preparedness to commit

  42. Participant 1 Log Transaction Manager Commit! Log Temporary Storage Participant 2 Commit! Log Permanent Storage Commit! Participant 3 Log Transactions: Database ExampleTwo-Phase Commit : Phase 2 • Phase 2: All services are told to commit If any part of the transaction fails, transaction logs are used to restore consistency.

  43. Jini Transaction Model • Two-phase commit transaction • But it is only “skin-deep” • Participants implement TransactionParticipant interface with methods • prepare( ) • commit( ) • abort( ) • Participating class must implement methods!

  44. Chapter 3 Conclusion:How to be a Jini Service? • Either you or a delegate must be able to: • Connect to a TCP/IP network ( ) • IP address and complete TCP stack with multicast message send/receive capability • Participate in discovery to find a Lookup Service • Register with a Lookup Service to provide proxy • Keep leases current

  45. Chapter 3 Conclusion: How to be a Jini Client/Consumer? • Participate in discovery to find a Lookup Service • Communicate with a Lookup Service to receive service proxy

  46. Additional Jini Information • Sun web sites • http://www.javasoft.com/jini • http://www.jini.org • Development – Books • “Core Jini” by W. Keith Edwards • “The Jini Specification” by Arnold, O’Sullivan, Scheifler, Waldo, and Wollrath • Gartner Advisory: • Java Jini: A ‘Killer-App Enabler’ for Network Computing? http://gartner.jmu.edu/research/ras/83000/83044/83044.html

  47. Key Jini Concepts Core Jini Chapter 5 Getting Started with Jini: “Hello World”

  48. Service Provider 1 Service 1 Item Lookup Service Service 1 Item Client A Service 1 Item “Hello World” Jini Community

  49. “Hello World” Service and Client • What they use: • A Single Jini Community with Lookup Service • Simple proxy • provides “Hello World” string • What they do not use: • Proxy communication with service • Lease renewal for service with Lookup Service • Remote events and event registration renewal • Transactions • RMI activation for service

  50. Using Jini • Define interfaces • Implement services • Build clients that use the services • Compile the pieces and run them Note the similarity between this and using RMI

More Related