Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Look at Jini Jian He Roy Patrick Tan. Outline History Design Goals An Example Basic Components Top View Infrastructures --- Proxies, Discovery/join.

Similar presentations


Presentation on theme: "A Look at Jini Jian He Roy Patrick Tan. Outline History Design Goals An Example Basic Components Top View Infrastructures --- Proxies, Discovery/join."— Presentation transcript:

1 A Look at Jini Jian He Roy Patrick Tan

2 Outline History Design Goals An Example Basic Components Top View Infrastructures --- Proxies, Discovery/join and Lookup Programming Models --- Leasing, Events and Transactions Hello World! JavaSpaces Comparisons Jini and Corba Jini and EJB Jini and OAA Current State References

3 History 1990, Oak. 1994, WebRunner  HotJava 1995, Java made Internet history. Bill Joy leads Sun’s new project ---Jini “Jini Is Not Initials” 1999, Jini becomes public. “It is fulfillment of original Java idea of an environment for embedded systems.”

4 Design Goals Robust software infrastructure Enable a service-based architecture Support “plug and participate” networking Devices can form spontaneous communities Ease distributed computing – Network latency – Concurrency/Synchronization – Memory management – Inevitable partial failure

5 An Example - a Jini-enabled printer

6 An Example (cont.) Multicast query for lookup services

7 An Example (cont.) discover LUS (lookup service) is discovered.

8 An Example (cont.) Printer registers (joins) service object (proxy) with LUS.

9 Client asks LUS for printer. An Example (cont.)

10 LUS returns the printer service object (proxy) to client.

11 Client talks to the printer by using the service object (proxy). An Example (cont.)

12 Basic Components A service A client A lookup service

13 Top View

14 Top View (cont.) ?

15 Infrastructure --- Proxies Downloadable Zero-administration Proxy scenarios: – it may perform the service itself; – it may be an RMI stub for some remote service; – it may act as a “smart” adapter, which provides a Jini interface to legacy (non-Java) services (sockets, CORBA, hardware- dependent protocols, etc.).

16 Infrastructure --- Discovery/Join/Lookup Services: discover and join a group of services by using UDP multicast. Unicast is also supported to connect to a particular lookup service. Lookup services: store authenticated services as Java objects and periodically advertise to network by using UDP multicast. Clients: download service proxies on demand from lookup services.

17 Infrastructure (cont.)

18 Programming Model --- Leasing Why? -- Self-healing for partial failures. What? -- Time-based grants of – Services: the registered status in lookup services. – Clients: the allocated services. How? It can be – Renewed – Cancelled – Expired

19 Programming Model -- Leasing Service Lookup Service Lease register(proxy, lease) Proxy

20 Lookup Service Proxy Programming Model -- Leasing Service Lease renew() cancel() Lease

21 Programming Model --- Events Why? -- Interesting external changes. What? -- Extended Java event model – Asynchronous (JavaBeans, JFC) – Out of order delivery and partial failures How? – RemoteEvent class – RemoteListener interface – EventRegistration interface

22 Programming Model -- Transactions Jini supports transactions – distributed object coordination Two-phase commit Implemented as Transaction Manager service Not often used

23 Two Phase Commit: Prepare Transaction Manager Svc 2 Svc 1 Prepare Ok!

24 Two Phase Commit: Commit Transaction Manager Svc 2 Svc 1 Commit!

25 TransactionParticipant public interface TransactionParticipant extends Remote, TransactionConstants { int prepare(TransactionManager mgr, long id); void commit(TransactionManager mgr, long id); void abort(TransactionManager mgr, long id); int prepareAndCommit(TransactionManager mgr, long id); }

26 Hello World! First declare the interface public interface HelloWorldService { public string getMessage(); }

27 The Hello World Proxy Proxy – the code to be downloaded class HelloWorldServiceProxy implements Serializable, HelloWorldServiceInterface { public HelloWorldServiceProxy() { } public String getMessage() { return "Hello, world!"; }

28 The Hello World Service public class HelloWorldService implements Runnable { // 10 minute leases protected final int LEASE_TIME = 10 * 60 * 1000; … class Listener implements DiscoveryListener { … public void discovered(DiscoveryEvent ev) { ServiceRegistrar[] newregs = ev.getRegistrars(); … if (!registrations.containsKey(newregs[i])) { registerWithLookup(newregs[i]); }

29 Hello World Service (cont’d) protected synchronized void registerWithLookup(ServiceRegistrar registrar) { ServiceItem item; item = new ServiceItem(null, createProxy(), null); ServiceRegistration registration = null; try { registration = registrar.register(item, LEASE_TIME); } catch (RemoteException ex) { System.out.println("Couldn't register: " + ex.getMessage()); return; }

30 Hello World Client public class HelloWorldClient implements Runnable { … class Listener implements DiscoveryListener { … } public HelloWorldClient() throws IOException { Class[] types = { HelloWorldServiceInterface.class }; template = new ServiceTemplate(null, types, null); … // Only search the public group disco = new LookupDiscovery(new String[] { “Public" }); // Install a listener disco.addDiscoveryListener(new Listener()); }

31 Hello World Client (cont’d) protected Object lookForService(ServiceRegistrar lusvc) { Object o = null; try { o = lusvc.lookup(template); } catch (RemoteException ex) { System.err.println("Error doing lookup: "); } if(o != null) { System.out.println("Got a matching service."); System.out.println("It's message is: " + ((HelloWorldServiceInterface) o).getMessage()); } return o; }

32 JavaSpaces One of the first Jini services Based on tuple spaces (Linda) 3 fundamental operations: –Read –Write –Take

33 JavaSpaces

34

35 JavaSpaces has typed entries for example: Use transactions to move objects between JavaSpaces Import net.jini.core.entry.Entry public class Student implements Entry { public String pid; public String name; public Student() {} }

36 JavaSpaces Different approach to distributed computing Information Sharing -- shared message board. Compute serving -- Image Processing compute farm Workflow -- Document routing

37 Jini and CORBA Jini has code mobility (proxy objects are more than stubs) Jini solves initial reference problem CORBA is cross-language CORBA components can be wrapped as Jini services

38 Jini and EJB EJB is used for “static” server environment Jini is designed for more volatile services Jini can be used for web services as well. Example: travel services consolidator.

39 Jini and OAA Similar technologies Jini has code mobility Facilitator more intelligent than Jini lookup services Jini is Java based, OAA is multi- language

40 Current State of Jini Not very popular 75 Commercial Licensees 80,000 downloads Free to try: SCSL Licensing Reorienting from devices to (web) services

41 References http://www.sun.com/jini http://www.jini.org W. Keith Edwards, Core Jini, Prentice Hall, 1999 W.Keith Edwards, Jini Example by Example, Prentice Hall, 2001 Stephen L. Halter, Java Spaces http://billday.com/Work/ http://www.eng.auburn.edu/center/irsc/comp0690/jinio verview.ppt


Download ppt "A Look at Jini Jian He Roy Patrick Tan. Outline History Design Goals An Example Basic Components Top View Infrastructures --- Proxies, Discovery/join."

Similar presentations


Ads by Google