Download Jini - bu people

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
11. Jini
What is Jini?
A "network technology that provides a simple (?) infrastructure for delivering
services in a network and for creating interactions between programs
that use these services regardless of their hardware/software
implementation. " (http://www.sun.com/jini/). More specifically it is a set
of APIs and protocols for building and deploying distributed systems
organized as a federation of services.
Any service, irrespective of its implementation, communicates through an
interface; the implementation can use any hardware or software appropriate for
this service:  erasing the hardware/software distinction, abstracting interface
and implementation or object-oriented network programming.
interface
interface
implementation
published
service object
Client (proxy of service)
Fall 2003
private
network
protocol
CS 667: 11. Jini
Zlateva
Service
1
Network Plug-and-Work
Note that in the preceding diagram, the set up is as for RMI.
This is no accident: in fact the inter object communication is through RMI.
What Jini provides are protocols how to get to this point.
Jini views the "computer" as a collections of services available on the network,
that a client program brings together to perform some computational task.
Instead of thinking of a computer as a stand alone that executes after being
booted from a disc (disc-centered), one should think of a computing node that
executes after being plugged into a network  "The network is the computer!",
network plug-and-work.
"Any kind of network made up of services (applications, databases,
servers, devices, information systems, mobile appliances, storage,
printers, etc.) and clients (requesters of services) of those services can
be easily assembled, disassembled, and maintained on the network
using Jini Technology. Services can be added or removed from the
network, and new clients can find existing services - all without
administration.(?!)" (http://www.sun.com/jini/)
Fall 2003
CS 667: 11. Jini
Zlateva
2
What is Jini? – A Technology for Building Federation of Services
The services are not subject to a central control:  federation of services.
Instead of a central control, Jini provides mechanisms for client and services to
find each other:  "spontaneous networking", service-based architecture, self
organizing system.
computation A
disk
Federation of
Services
printer
image
processor
camera
database
database
client
computation B
Jini is not an acronym: it comes from "genie" (the one in the bottle) and can be
thought of as "Jini Is Not Initials"
Fall 2003
CS 667: 11. Jini
Zlateva
3
How Does Jini Work? – Defining and Advertising Services
• A service is defined by its programming API, declared as a Java
programming language interface;
• A service is implemented using whatever protocol is appropriate
for this service, e.g. a proprietary protocol, XML, RMI, CORBA,
etc.; the client program using the service does not care about the
network protocol used in the implementation.
• In order to be plugged into a network of Jini technology-enabled
services and/or devices, a service advertises itself by publishing a
Java programming language object that implements the service
API. This object's implementation can work in any way the service
chooses, e.g. execute locally at client site, remotely on server site,
or have parts of local and remote execution.
Fall 2003
CS 667: 11. Jini
Zlateva
4
How Does Jini Work? – Finding and Using Services
• The client finds services by looking for an object that supports the
API. When it gets the service's published object, it will download
any code it needs in order to talk to the service, thereby learning
how to talk to the particular service implementation via the API. The
programmer who implements the service chooses how to translate
an API request into bits on the wire using RMI, CORBA, or a private
protocol.
• At this point programs and the services used by these programs
have been located and a federation of services created. This has
been accomplished by the Jini runtime environment. Once this task
is completed, however, the federated services and programs
execute independently of the Jini runtime environment.
Fall 2003
CS 667: 11. Jini
Zlateva
5
How Does Jini Work? - Notes
• Note: "A Jini system should not be thought of as sets of clients and
servers, or users and programs, or even programs and files. Instead, a
Jini system consists of services that can be collected together for the
performance of a particular task. Services may make use of other
services, and a client of one service may itself be a service with clients of
its own."("Jini[tm] Technology Architectural Overview",
http://www.sun.com/jini/whitepapers/architecture.html)
• The system is dynamic in that services can be "added or withdrawn
from a federation at any time according to demand, need, or the changing
requirements of the workgroup using it." ("Jini[tm] Technology
Architectural Overview",
http://www.sun.com/jini/whitepapers/architecture.html)
Fall 2003
CS 667: 11. Jini
Zlateva
6
Jini Extends the Java Application Environment to the Network
Jini
: mechanisms for adding, removing, locating, accessing
services
RMI
: for communication between services and programs
JVM
Object Serialization
Network
Jini is Java- technology centered in that it depends on the Java
application environment but not necessarily on the Java
programming language.
Any programming language can be supported by a Jini system if it
has a compiler that produces compliant bytecodes for the Java
programming language.
Fall 2003
CS 667: 11. Jini
Zlateva
7
Jini Run Time Infrastructure
Jini technology infrastructure defines the minimal Jini technology core.
The infrastructure includes the following:
• Lookup services: serve as a repositories of services. Entries in the
lookup service are objects in the Java programming language; these
objects can be downloaded as part of a lookup operation and act as
local proxies to the service that placed the code into the lookup
service
• Protocols:
 The discovery protocol, a network service protocol that allows
client and services to locate a lookup service
The join protocol, an object service protocol that allows
services to become part of, and advertise supplied services to the
other members of the federation.
 The lookup protocol, an object service protocol that enables
client to query for services.
• A distributed security system, integrated into RMI, which extends the
Java
platform's security model CS
to 667:
the11.world
of distributed systems. 8
Fall 2003
Jini
Zlateva
The Discovery Process
Problems addressed:
a) Service wants to find lookup service to advertise itself.
b) Client wants to find lookup service to query for available services
Process:
• service broadcasts a presence announcement by multicasting
packet to a well known port; packet contains info for lookup service to
determine whether or not to contact sender of announcement.
• lookup service monitors well known port for announcements; when
announcement packet received, it is inspected by the lookup service
and a decision made whether or not to contact the sender;
• if lookup service decides to contact sender, it does so directly
through a TCP connection to the IP address and port number
extracted from the packet;
• lookup service sends an object, called service registrar, to service
announcement originator. The service registrar object facilitates
further communications with lookup service as follows: the originator
of the service announcement performs join and lookups on the lookup
service by invoking methods on the service registrar object.
Fall 2003
CS 667: 11. Jini
Zlateva
9
The Join Process
Problems addressed: Service has received a server registrar object
from the lookup service and wants to become part of the federation of
services registered with the lookup service
Process:
• service provider invokes register() method on the service registrar
object, passing as parameters an object called a service item, that is a
bundle of objects describing the service;
• register() method sends copy of service item to the lookup service;
• lookup service stores item which completes registration.
The service item is a container of objects, including
 service object: typically implements one or more interfaces to be
used by the client for interacting with the service;
 attributes: any object, e.g. icons, GUI classes, info objects.
Fall 2003
CS 667: 11. Jini
Zlateva
10
Discovery and Join Process - Diagrams
Lookup
Service
presence
announcemen
t
Service
(Printer)
service
registrar object
Discovery
Lookup
Service
service registration
Service
(Printer)
service object
( interface and its
implementation)
attributes
Join (ArOSu 1999, modified from p.5)
Fall 2003
CS 667: 11. Jini
Zlateva
11
The Lookup Process
Problem addressed:
Client wants to locate and use a service
Client has obtained a service registrar object trough the discovery
process, i.e. it has located the lookup service and is ready to
communicate with it.
Process:
• client invokes lookup() method on service registrar object;
• client passes as argument to lookup() a service template – an object
that serves as search criteria for query; the service template includes
the types (most often Java types, typically and interface) of services
needed by client, and may also include service ID, attributes to be
matched by service provider, etc.
• the lookup() method sends the service template to the lookup
service
• lookup service performs query and sends back results.
Fall 2003
CS 667: 11. Jini
Zlateva
12
Lookup and Using the Service - Diagram
lookup
Lookup
Service
service
object
attributes
Lookup
service template:
interface (printer)
attributes
Client
(Needs
Printing
Service)
service object
Client
(Needs
Printing
Service)
Service
(Printer)
Using the Service - Diagram (ArOSu 1999, modified from p. 6)
Note that the Jini infrastructure is not involved!
Fall 2003
CS 667: 11. Jini
Zlateva
13
Attributes
• Each service object in the lookup service can have attributes,
features that are not part of the interface and help distinguish between
services of the same kind, e.g. the office printer vs. your very personal
printer.
• An attribute is an object that is an entry, i.e. it implements the
net.jini.core.entry.Entry interface and has the following semantics
 all non-static, non-transient, non-final fields must be public;
each field is of object type, not of primitive type
The class must be public and have a public no-arguments
constructor
• When the client looks up the service, it can specify the attributes.
Each attribute and attribute field can be individually marked either
for matching or to be disregard by the lookup process.
Wildcards can be used and specifying more than one value means
a conjunction (i.e. all specified values must be matched).
Fall 2003
CS 667: 11. Jini
Zlateva
14
Membership Management - Leasing
Access to many of the services in the Jini system environment is
lease based.
After a service registers, the lookup service sends back a lease on its
presence in the lookup service.
A lease is a grant of guaranteed access over a time period. Each
lease is negotiated between the user of the service and the provider
of the service as part of the service protocol: A service is requested for
some period; access is granted for some period, presumably taking
the request period into account.
If a lease is not renewed before it is freed--either because the
resource is no longer needed, the client or network fails, or the lease
is not permitted to be renewed--then both the user and the provider of
the resource may conclude the resource can be freed.
Fall 2003
CS 667: 11. Jini
Zlateva
15
Combining Leasing and Discovery
Leases in combination with discovery allow to
• keep the available services current: while the service is alive it will
renew its lease. If the service crashes or the link between service and
lookup service fails, the service cannot renew its lease and is dropped
from the lookup service.
• have a self-healing system: if service fails it is eliminated, when it
comes up again it will be registered again with the lookup service;
• increase robustness through self-replication: start another lookup
service and the discovery process guarantees that all services will
register with the new lookup service, thus replicating the existing one.
Fall 2003
CS 667: 11. Jini
Zlateva
16
Lookup Service vs. Naming/Directory Service
Directory
Lookup Service
• Services stored by name with
• Services stored by what they really
some convention to separate
are, based on service object
components: e.g.
(interface, implementation,
"devices/scanners"
attributes).
• System becomes confusing for
• System is as good as your class
large number of services and
hierarchy, of course, but certainly will
service types – subdirectories
not get confusing because you lack
tend to grow quickly;
the talent/memory for consistent
• Naming is left to the service
naming.
provider (who tends to forget the
• No way that TV is placed among
quirks of the naming hierarchy
printers as it has different interface.
with subdirectories proliferating)
and nothing prevents placing a
TV in the printer directory;
• To find a service one needs to
take object bound to service
• To find a service one needs to
name
take object as described by its
check whether it is really the
service template,
Fall 2003
CS 667: 11. Jini
17
service one wants;
Zlateva
Jini and Legacy (Ken Arnold Seminar, 10/02/00)
• Legacy services fit well into the framework
• Legacy languages fit behind Java wrapping.
• Jini moves cross-language membrane from the network to the
address space.
Fall 2003
CS 667: 11. Jini
Zlateva
18
Jini Future (Ken Arnold Seminar, 10/02/00)
• Network federation replaces the operating system
• Polymorphism abstracts over network protocols
• Network becomes ubiquitous and invisible
• Services replace applications
References:
(ArOSu 1999) Arnolds, O'Sullivan, Sheifler, Waldo, Wollrath: The Jini
Specification. Sun Microsystems & Addison-Wesley.
(DDS 2002) Deitel, H.M.; P.J.Deitel; S.E.Santry: Advanced Java 2 Platform: How
to Program. Prentice Hall, 2002, Ch.22.
Jini: http://java.sun.com/products/jini
Jini Network Technology Specification: http://www.sun.com/jini/specs/
Directory of Jini Resources:
http://www.litefaden.com/sv/jd/Jini_Documentation/
Fall 2003
CS 667: 11. Jini
Zlateva
19