330 likes | 612 Views
Jini. Celsina Bignoli bignolic@smccd.net. Definition. Jini is the name for a distributed computing environment, that can offer network plug and play A Jini system or federation is a collection of clients and services all communicating by the Jini protocols
E N D
Jini Celsina Bignoli bignolic@smccd.net
Definition • Jini is the name for a distributed computing environment, that can offer network plug and play • A Jini system or federation is a collection of clients and services all communicating by the Jini protocols • A device or a software service can be connected to a network and announce its presence, and clients that wish to use such a service can then locate it and call it to perform tasks.
Applications • Jini can be used for mobile computing tasks, where a service may only be connected to a network for a short time • more generally in any network with volatile configuration
8 Fallacies of Distributed Computing “the network is the computer” • The network is reliable • Bandwidth is infinite • The network is secure • Topology doesn't change • There is one administrator • Transport cost is zero • The network is homogeneous • Latency is zero
Goal • Enabling users to share services and resources over a network • Providing users easy access to resources anywhere on the network while allowing the network location of the user to change • Simplifying the task of building, maintaining, and altering a network of devices, software, and users
Jini System - Component • A Jini system is made of • an infrastructure for federating services in a distributed system • a programming model that supports and encourages the production of reliable distributed services • services that can be made part of a federated Jini system and that offer functionality to any other member of the federation
Jini Application - Components Lookup Service Client Service • Code is moved around between these three pieces • and this is done by marshalling the objects • Objects in one JVM may need to invoke methods on an object in another JVM • Often this will be done using RMI (Remote Method Invocation), although the Jini specification does not require this and there are many other possibilities. Network TCP/IP
How Jini Works 1 Discover Network service discovers available lookup services (LUS) 2 Join Network service sends service proxy to LUS 3 Discover Network client discovers available LUS 4 Lookup Network client sends a request to LUS to find desired services 5 Receive LUS sends registered service proxy to network client 6 Use Network client interacts directly with network service via service proxy 1 Network Service Lookup Service 2 Service Proxy 5 4 Service Proxy 6 Network Client 3
Services • a service is a logical concept such as a blender, a chat service, a disk. • it is defined by a Java interface • each service can be implemented in many ways, by many different vendors • what makes them the "same" service is that they implement the same interface • A service is created by a service provider: • It creates the objects that implement the service • It registers the service object with lookup services
Protocols • The heart of the Jini system is a trio of protocols • Discovery: occurs when a service is looking for a lookup service with which to register. • Join: occurs when a service has located a lookup service and wishes to join it. • Lookup: occurs when a client or user needs to locate and invoke a service • Jini discovery/join is the process of adding a service to a Jini system
Server Structure • prepare for discovery • discover a lookup service • create information about a service • export a service • renew leasing periodically
Service Registration Service Provider Lookup Service Service Querying for a Lookup Server
Service Registration Service Provider Lookup Service Service Registrar Registrar is returned
Service Registration Service Provider Lookup Service Service Service Proxy Registrar Service uploaded
Client Structure • prepare for discovery • discover a lookup service • prepare a template for lookup search • lookup a service • call the service
Client Lookup Lookup Service Client Service Proxy Querying for a Service Locator
Client Lookup Lookup Service Lookup Service Client Client Service Object Registrar Registrar Service Proxy Registrar returned
Client Lookup Lookup Service Lookup Service Client Client Service Object Registrar Registrar Service Proxy Asking for a service
Client Lookup Lookup Service Lookup Service Client Client Service Object Registrar Registrar Service Proxy Service Proxy Service returned
Client Lookup Lookup Service Lookup Service Client Client Service Object Registrar Registrar Service Provider Service Proxy Service Proxy Registrar Service Object Service called Service
Lookup Service • The initial phase of both a client and a service is discovering a lookup service • A lookup service is just a Jini service, one that is specialized to store services and pass them on to clients looking for them • Such a service (or set of services) will usually have been started by some independent mechanism • Sun supplies a lookup service called reggie as part of the standard Jini distribution. • The search for a lookup service can be done either by unicast or by multicast
Unicast Discovery • Unicast discovery can be used when you already know the machine on which the lookup service resides, so you can ask for it directly • The class LookupLocator in package net.jini.core.discovery is used for this package net.jini.core.discovery; public class LookupLocator { LookupLocator(java.lang.String url) throws java.net.MalformedURLException; LookupLocator(java.lang.String host,int port); … public ServiceRegistrar getRegistrar() throws java.io.IOException, java.lang.ClassNotFoundException } URL must be of the form jini://host/ or jini://host:port/. If no port is given, it defaults to 4160
Multicast Discovery • If the location of a lookup service is unknown, it is necessary to make a broadcast search for one. • UDP supports a multicast mechanism which the current implementations of Jini use.
Groups • Some services may be meant for anyone to use, but some may be more restricted in applicability • When a lookup service is started, it can be given a list of groups to act for as a command line parameter. • A service may include such group information by giving a list of groups that it belongs too. This is an array of strings, such as String [] groups = {"Engineering dept"};
LookupDiscovery • The class LookupDiscovery in package net.jini.discovery is used for broadcast discovery. • The constructor: • LookupDiscovery(java.lang.String[] groups) • The parameter can be: • A non-empty array of strings. This will attempt to discover all lookup services in that set of groups • null, or LookupDiscovery.ALL_GROUPS. This will attempt to discover all reachable lookup services no matter which group they belong to
Entry Objects • When a service provider registers a service, it places a copy of the service proxy on the lookup service. • This copy is an instance of an object, in serialised form. • The server can optionally register sets of attributes along with the service object.
Service Registration • The server registers the service with the service locator using the ServiceRegistrar method register(): package net.jini.core.lookup; public Class ServiceRegistrar { public ServiceRegistration register( ServiceItem item, long leaseDuration) throws java.rmi.RemoteException; } • The second parameter is a request for the length of time (in milliseconds) the lookup service will keep the service registered. • This request need not be honored: the lookup service may reject it completely, or only grant a lesser time interval
Client Search • A client gets a ServiceRegistrar object from the lookup service. • It uses this to search for a service stored on that lookup service using the lookup() method: public Class ServiceRegistrar { public java.lang.Object lookup(ServiceTemplate tmpl) throws java.rmi.RemoteException; }
Leasing • Lookup Service uses leasing • When a service registers with a lookup service, it requests a period of time for that registration. • The lookup service will grant a lease that is the minimum of the requested time and the maximum lease duration that has been configured for that particular lookup service. • It is up to the service to renew the lease that is handed back as a result of the registration call. • When renewing the lease, the service will again ask for a renewal of a particular duration • If a service wishes to end its registration with the lookup service, it will cancel the lease, and the lookup service will then drop the registration of that service. • If the service were to crash, or become unavailable because of network failure, the registration will expire. • At that point, the lookup service will drop the registration, reflecting the fact that the service is no longer available.