A Look at Jini Jian He Roy Patrick

  • Slides: 41
Download presentation
A Look at Jini Jian He Roy Patrick Tan

A Look at Jini Jian He Roy Patrick Tan

Outline • History • Transactions • • • Hello World! Design Goals An Example

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

History • • 1990, Oak. 1994, Web. Runner Hot. Java 1995, Java made Internet

History • • 1990, Oak. 1994, Web. Runner Hot. Java 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. ”

Design Goals • Robust software infrastructure • • Enable a service-based architecture Support “plug

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

An Example - a Jini-enabled printer

An Example - a Jini-enabled printer

An Example (cont. ) Multicast query for lookup services

An Example (cont. ) Multicast query for lookup services

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

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

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

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

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

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

An Example (cont. ) LUS returns the printer service object (proxy) to client.

An Example (cont. ) LUS returns the printer service object (proxy) to client.

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

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

Basic Components • A service • A client • A lookup service

Basic Components • A service • A client • A lookup service

Top View

Top View

Top View (cont. ) ?

Top View (cont. ) ?

Infrastructure --- Proxies • Downloadable • Zero-administration • Proxy scenarios: – it may perform

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, hardwaredependent protocols, etc. ).

Infrastructure --- Discovery/Join/Lookup • Services: discover and join a group of services by using

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.

Infrastructure (cont. )

Infrastructure (cont. )

Programming Model --Leasing • Why? -- Self-healing for partial failures. • What? -- Time-based

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

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

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

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

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

Programming Model --Events • Why? -- Interesting external changes. • What? -- Extended Java

Programming Model --Events • Why? -- Interesting external changes. • What? -- Extended Java event model – Asynchronous (Java. Beans, JFC) – Out of order delivery and partial failures • How? – Remote. Event class – Remote. Listener interface – Event. Registration interface

Programming Model -Transactions • Jini supports transactions – distributed object coordination • Two-phase commit

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

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

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

Two Phase Commit: Commit it! m m o C Transaction Manager Svc 1 Commi

Two Phase Commit: Commit it! m m o C Transaction Manager Svc 1 Commi t! Svc 2

Transaction. Participant public interface Transaction. Participant extends Remote, Transaction. Constants { int prepare(Transaction. Manager

Transaction. Participant public interface Transaction. Participant extends Remote, Transaction. Constants { int prepare(Transaction. Manager mgr, long id); void commit(Transaction. Manager mgr, long id); void abort(Transaction. Manager mgr, long id); int prepare. And. Commit(Transaction. Manager mgr, long id); }

Hello World! First declare the interface public interface Hello. World. Service { public string

Hello World! First declare the interface public interface Hello. World. Service { public string get. Message(); }

The Hello World Proxy • Proxy – the code to be downloaded class Hello.

The Hello World Proxy • Proxy – the code to be downloaded class Hello. World. Service. Proxy implements Serializable, Hello. World. Service. Interface { public Hello. World. Service. Proxy() { } public String get. Message() { return "Hello, world!"; } }

The Hello World Service public class Hello. World. Service implements Runnable { // 10

The Hello World Service public class Hello. World. Service implements Runnable { // 10 minute leases protected final int LEASE_TIME = 10 * 60 * 1000; … class Listener implements Discovery. Listener { … public void discovered(Discovery. Event ev) { Service. Registrar[] newregs = ev. get. Registrars(); … if (!registrations. contains. Key(newregs[i])) { register. With. Lookup(newregs[i]); } } }

Hello World Service (cont’d) protected synchronized void register. With. Lookup(Service. Registrar registrar) { Service.

Hello World Service (cont’d) protected synchronized void register. With. Lookup(Service. Registrar registrar) { Service. Item item; item = new Service. Item(null, create. Proxy(), null); } Service. Registration registration = null; try { registration = registrar. register(item, LEASE_TIME); } catch (Remote. Exception ex) { System. out. println("Couldn't register: " + ex. get. Message()); return; }

Hello World Client public class Hello. World. Client implements Runnable { … class Listener

Hello World Client public class Hello. World. Client implements Runnable { … class Listener implements Discovery. Listener { … } public Hello. World. Client() throws IOException { Class[] types = { Hello. World. Service. Interface. class }; template = new Service. Template(null, types, null); … // Only search the public group disco = new Lookup. Discovery(new String[] { “Public" }); // Install a listener disco. add. Discovery. Listener(new Listener()); }

Hello World Client (cont’d) protected Object look. For. Service(Service. Registrar lusvc) { Object o

Hello World Client (cont’d) protected Object look. For. Service(Service. Registrar lusvc) { Object o = null; try { o = lusvc. lookup(template); } catch (Remote. Exception ex) { System. err. println("Error doing lookup: "); } if(o != null) { System. out. println("Got a matching service. "); System. out. println("It's message is: " + ((Hello. World. Service. Interface) o). get. Message()); } return o; }

Java. Spaces • One of the first Jini services • Based on tuple spaces

Java. Spaces • One of the first Jini services • Based on tuple spaces (Linda) • 3 fundamental operations: – Read – Write – Take

Java. Spaces

Java. Spaces

Java. Spaces

Java. Spaces

Java. Spaces • Java. Spaces has typed entries for example: Import net. jini. core.

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

Java. Spaces • Different approach to distributed computing • Information Sharing -- shared message

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

Jini and CORBA • Jini has code mobility (proxy objects are more than stubs)

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

Jini and EJB • EJB is used for “static” server environment • Jini is

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.

Jini and OAA • Similar technologies • Jini has code mobility • Facilitator more

Jini and OAA • Similar technologies • Jini has code mobility • Facilitator more intelligent than Jini lookup services • Jini is Java based, OAA is multilanguage

Current State of Jini • Not very popular • 75 Commercial Licensees • 80,

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

References • • http: //www. sun. com/jini http: //www. jini. org W. Keith Edwards,

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/comp 0690/jinio verview. ppt