Transcript Tutorial 2

Jini Tutorial, Part 2
Jini Overview
1
Tutorial outline

Part 1 Introduction




Part 2 Overview of Jini




Goals
Architecture
Basic concepts, protocols
Part 3


Distributed systems
Java basics
Remote Method Invocation (RMI)
Jini Programming
Part 4 Advanced topics



Mobile Jini access
Adaptive user interfaces
Security
2
Why Jini?

Distributed computing is more difficult
than local computing because of:




Network latency,
Concurrency issues,
Memory management,
Partial failure.
3
Jini goals


Jini™ Network Technology by Sun Microsystems
“Plug-and-use”


Reliable service-based architecture





A device should instantly usable when plugged into the
network, just like a phone set – no installation, etc should
be required
Spontaneous networking based on discovery and mobile
code
Self-healing
Erase the distinction between hardware and software
(everything is a service)
Protocol-independence
To make writing distributed programs easier.
4
Properties

Based on the Java programming language.







Homogeneous network
Architecture independence
Dynamic environment
Programming interfaces designed for robustness.
Services may come and go without administration.
Federation, not central control.
Jini can be used with both hardware as well as
software services:


Everything is represented by Java Objects.
Everything is located and accessed through Java Interfaces.
5
Tutorial outline

Part 1 Introduction




Part 2 Overview of Jini




Goals
Architecture
Basic concepts, protocols
Part 3


Distributed systems
Java basics
Remote Method Invocation (RMI)
Jini Programming
Part 4 Advanced topics



Mobile Jini access
Adaptive user interfaces
Security
6
Key participants

Service


Client


A service is an entity that another program, service or
user can use. It can be a piece of computation, a
hardware device or software.
A Jini device or component that becomes the member
of the federation in order to use a Jini service.
Lookup Service

The central element of a Jini federation. The lookup
service (also known as the service locator or service
registrar) keeps track of the services offered in the
federation.



Repository of available services.
Stores each service as Java objects.
Clients download services on demand.
7
Basic terms

Spontaneous networking


Federation


Jini services grant resource usage in a time-based manner. If the period of
the grant (lease) is not renewed before its expiration, the grant will be
withdrawn at the end of the period.
Distributed event


The mechanism used to locate lookup services in order to advertise a new
service in the network or find a service for use.
Leasing


A set of software components and devices creating a distributed system
that are part of a Jini network at a given time.
Discovery


Communication is established dynamically without installing drivers and
carrying out manual configuration
Components of a Jini system can notify each other when some change in
their state occurs.
Transaction
8
Jini Technologies
9
Jini Architecture
Applications
JavaSpaces
Other services
Lookup
Network
services
Jini
Discovery/Join
RMI
Java
Java
Java
Solaris
Solaris
Mac
Windows
SPARC
PowerPC
x86
10
Jini Operation

The fundamental behaviour is defined by three
protocols




Discovery – how to locate the Lookup Service
Join – how to register with the LS and export services
Lookup – how to find suitable services
Main operation steps



Services export their services (in the form of Java objects)
Clients locate services and download objects or execution
Client-Service interaction (formation of a federation) is
governed by need
12
Jini Operation (cont’d)



Lookup services are dynamically discovered by clients
and services
Services register service proxies in JLUSs
Clients lookup and download service proxies from
discovered JLUSs by interface and/ or attributes
Lookup
Service A
Jini Service
backend
service proxy
ServiceItem
Lookup
Service B
ServiceID serviceID
Object service
Entry[] attributeSets
Jini
Client
template
13
The notion of groups
Group Aut
Group IRT
Group KNT
LUS 3: Aut
LUS 1: IRT
LUS 5: IRT,
KNT
LUS 2: IRT
LUS 6: Aut,
KNT
LUS 4: Aut
14
Tutorial outline

Part 1 Introduction




Part 2 Overview of Jini




Goals
Architecture
Basic concepts, protocols
Part 3


Distributed systems
Java basics
Remote Method Invocation (RMI)
Jini Programming
Part 4 Advanced topics



Mobile Jini access
Adaptive user interfaces
Security
15
The discovery protocol

Two forms of discovery

Multicast, using UDP multicast


Unicast, using TCP/IP



Finding services at unknown but multicast-reach
locations using group names
Finding services at known locations
URL: jini://hostname:port/
Forms

Client discovery


At startup; problem with latecomer services
Service announcement

At startup; problem with latecomer clients
16
Multicast discovery protocol
discovering entity
lookup service
Uses Datagram
socket
controller
controller
create
Uses TCP
ServerSocket
create
multicast
request
server
multicast
request
client
multicast
response
server
create
serviceID
:ServiceID
create
*create and send multicast packets
[if (should respond)]:create
multicast
response
client
{repeat after 5 sec delay up to 7 times}
connect and send response (ServiceRegistrar)
remove
Multicast Request Service
======================
Transport protocol: Multicast UDP
Request Packet: < = 512 bytes
---------------------------------------contains:
- protocol version [ currently 1]
- port to contact by responders
- groups of interest
- known lookup services [serviceIDs,
these should not respond]
Jini Specification:
The multicast request protocol is employed by entities that wish to discover
nearby lookup services. This is the protocol used by services that are starting
up and need to locate whatever djinns happen to be close. It can also be
used to support browsing of local lookup services.
Multicast Response Service
=======================
TCP service
Multicast settings
==============
TTL = 15
multicast request address: 224.0.1.85
multicast announcment address: 224.0.1.84
port = 4160
Multicast announcement protocol
lookup service
controller
controller
multicast
announcement
server
create
create
create
unicast
discovery
server
serviceID
:ServiceID
multicast
announcement
client
send announcement packets
{repeat with 120 sec delays}
[if new service of interest]:create
unicast
discovery
client
start unicast discovery
Jini Specification:
The multicast announcement protocol is provided to allow lookup services
to advertise their existence. This protocol is useful in two situations. When
a new lookup service is started, it might need to announce its availability to
potential clients. Also, if a network failure occurs and clients lose track of a
lookup service, this protocol can be used to make them aware of its availability
after network service has been restored.
Announcement Packets:
===================
Transport : Multicast UDP
lenght: < = 512 bytes
-------------------------------------contains:
- protocol version [= 1]
- host for unicast discovery
- port to connect to
- service ID of originator
- count of groups
- groups represented by originator
Unicast discovery protocol
discovering entity
lookup service
Object
controller
controller
create
create
lookup
locator
:LookupLocator
getRegistrar
create
TCP
socket
send unicast discovery request
unicast response (registrar proxy)
server
socket
Join protocol (services)

Wait randomly at startup



Perform unicast discovery with known LUSs
If groups ≠{} perform multicast for given groups



Up to 15 sec
Register with discovered and/or announced LUSs
If a service is asked to join a group, it adds the name of that group to
Perform periodic lease
renewal
the persistent
set of groups to join and either starts or continues to
perform multicast discovery using this augmented group.
If the service is requested to leave a group, the steps are a little more
On connection failure
complex:



1. It removes that LUSs
group from the persistent set of groups to join.
Re-register with persistent
2. It removes all lookup services that match only that group in the set of
Forget multicast discovered
ones,
wait
announcement
groups it is interested
in from the
set it for
has discovered
using multicast
Making changes



discovery, and unregisters from those lookup services.
3. It either continues to perform multicast discovery with the reduced set
of groups or, if the set has been reduced to empty, ceases multicast
discovery.
Attribute change with all registered LUSs
Register/unregister with specific LUSs
Join/leave groups
20
Lookup protocol

Client creates template




Describes the type of service sought after
Sends template to LUS
LUS performs template matching
LUS returns result

1 or more ServiceItem objects
21
Matching

Strict matching



Using marshalled objects
Comparing
ServiceTemplate
fields
Match if



ServiceItem
ServiceID
ServiceID
Set of service
interfaces
Object implementing
interfaces
Set of attribute objects
Set of attribute objects
A) identical serviceIDs (tmpl can be null) and
B) item service is instance of every tmpl service types and
C) item attributes contain at least one match for each
attribute in tmpl
22
Examples
Template 1
Template 2
2
null
null
null

null
null

Template 3
Template 4
null
null
Fax
null

Printer
null
Template 6
null
2

Location(VE,KNT)
1
Printer
Location(VE,IRT)
PrinterProp(15,colour)

Template 5
Printer
Service
Printer

Location(VE,IRT)
PrinterProp(null, colour)
23
Leasing

Problem


Partial failure in distributed systems can
lead to unchecked resource consumption.
Traditional solution: system
administration:



Error-prone,
Costly,
Only happens when it is too late.
24
What are Leases?





Time-based grants of resources or
services.
Provides a method of managing
resources in an environment where
network failures can, and do, occur
Loose contracts between grantor and
holder.
Negotiated for a set period of time.
Can be shared or exclusive.
25
Distributed events in Jini




Enables Java event model to work in a
distributed network.
Register interest, receive notification.
Allows for use of event managers.
Can use numerous distributed delivery
models:


Push, pull, filter...
Uses leasing protocol.
26
Transaction model in Jini


Designed for distributed object
coordination: light weight, object-oriented.
Supports:




Nested transactions;
Various levels of ACID properties (Atomicity,
Consistency, Isolation, Durability).
Uses leasing protocol.
Implemented in Transaction Manager
service – another Jini service (mahalo).
27
Nested Transactions
28
More Information


The Jini Specification
Home pages



www.sun.com/jini
www.jini.org
Online tutorials



pandonia.canberra.edu.au/java/jini/tutorial/
Jini.xml
www.oreilly.com/catalog/jininut/chapter/
ch04.html
www.eli.sdsu.edu/courses/spring99/cs696/
notes/index.html
29
Books (not all)
30