You are on page 1of 22

The Jini Architecture

1
What is Jini?
Jini is a distributed system architecture developed by
Sun Microsystems, Inc.
Its main goal is “network plug and play”.
Jini is not an acronym, it’s coined by one of its
designers--Bill Joy.
You can think it as standing for “Jini Is Not Initials”.

2
Architecture Overview

Jini Services

Remote Method Invocation


Java Virtual Machine
TCP/IP
Data Link Layer

The Jini Architecture

3
Basic Components of Jini
Service : entity that can be used by a person, a device,
or another service, for example, printing a document,
displaying videos, etc.
The lookup service : providing a central registry of
services; and the clients use it to locate a service that he
wants.
Proxy object and its attributes : the object implements
all the interfaces provided by the remote service; and
attributes are used to distinguish the object from other
objects of the same type.
Client : entity who requests services.

4
HOW
HOW DOES
DOES IT
IT DO
DO IT?
IT?

Jini
LookUp
Service

Client Service
(Television) (Printer)
Jini
LookUp
Service

Client Direct Service


(Camera) Communication (Printer)
A simplified example :
The
The Lookup
Lookup Service
Service
Proxy Object
Printer Attributes

A Camera A Printer
A Camera
Proxy Object
Proxy Object Printer Attributes

7
The more complete scenario
1. A new printer is set up in the network.
2. The printer sends a “looking for lookup services” message to the local network.
3. Each lookup service on the network responds with a proxy for itself.
4. The printer registers its proxy object and attributes with each lookup service
using the proxy of each lookup service.
5. A man with a digital camera comes into this network, and he wants to print out
a new picture.
6. The camera sends “ looking for lookup services” messages to the local network.
7. Each lookup service in the network responds with a proxy for itself.
8. The camera searches for types of services it needs using the proxies of one or more
lookup services. The lookup service returns one or more matching proxy objects,
and the client distinguish them further by their attributes.
9. The exactly matched proxy is downloaded to the camera. Then the
camera begins to use the proxy to interact with the printer to print the picture.

8
What happens in a Jini environment?
For a service:
Discovery : sends a “looking for lookup services” message to all the local lookup
services and downloads their proxy objects.
Join : uses the downloaded proxy object to register its proxy object and attributes
with each lookup service.
Renew : renews its registration at the lookup services.
For a lookup service:
Here I am : sends a “Here I am” message periodically to the local network in case
that some services maybe fail to register previously due to the network
failure or some other reasons.

For a client:
Discovery : sends a “looking for lookup services” message to all the local lookup
services and downloads their proxy objects. Then it picks
up the service that it wants by using the proxies of the lookup services.

9
The Service Lookup Process
 Service ID: each service, including the lookup service, has
an ID that is unique in the Jini environment.
 Group : a group can be represented by any arbitrary string.
 A client can use group to identify a set of services that it
wishes to look up.
 The lookup service can use group to filter the lookup
requests.
 A group with an empty string as name means “public
group”, which will actually match all groups.

10
The Service Lookup Process(cont’d)
The Discovery Protocols : are used by a client or a
service to find out the lookup services and
download their proxy objects.
The Leasing Mechanism : a lease is a period of
time during which the service is registered. If the
lease expires and the service doesn’t renew it, the
service will be discarded by the lookup service.
The Join Protocol : is used by the service to
register itself with a lookup service.

11
The Discovery Protocols

Three Protocols are used in the discovery phase:

Multicast Request Protocol


Unicast discovery protocol
Multicast Announcement Protocol

12
The Multicast Request Protocol

 The Multicast Request Protocol is initiated by a discovering


entity(a client or a service) to locate a lookup service.
 It uses 2 connections: one is the multicast UDP to send the
“looking for lookup service” message to the network, the other
is a TCP connection to wait for the lookup service to connect
back.
 It uses the TCP connection to download the proxy object of the
lookup service.

13
The Discovering Entity The Lookup Service

1. Construct a multicast UDP


socket, listening to the multicast
2. The discovering entity first request.
sets up a TCP server.

The multicast response service

3. Constructs a multicast UDP


socket, then sends its request
for lookup services to the network.

4. If the DE’s groups match the


groups to which it provides services,
The multicast response service it connects to the DE’s multicast
response server, and passes its proxy
object to the DE.

14
The Unicast Discovery Protocol
• By multicast, a discovering entity can only find out the lookup
services in the local network.
• What if a user want to access a Jini service in another
network? Use the Unicast Discovery Protocol!
• The client needs to be told about the location of the remote
lookup service.
• Then the client directly establishes the TCP connection to the
lookup service and downloads the lookup service’s proxy
object.

15
The Multicast Announcement Protocol
• The Multicast Announcement Protocol is initiated by the
lookup service to announce its existence.
• It also uses 2 connections: one is the multicast UDP to send
the “Here I am” message to the network, the other is a TCP
connection to wait for the discovering entity to establish a
download connection. In fact, this TCP connection is the same
connection as used in the Unicast Discovery Protocol.
• It uses the TCP connection to transfer the proxy object of the
lookup service to the discovering entity.

16
The Discovering Entity The Lookup Service
1.Establishes a set of service IDs 1. Establishes TCP unicast
of lookup services from which it discovery server.
already heard, then constructs
socket waiting for the arriving of The unicast discovery server
the multicast announcement.
2. Constructs a UDP multicast
Service IDs socket, periodically sends out
the “Here I am” message.
2. For each announcement received,
it determines whether the service ID
is already in the set and whether it is
interested in the groups of the lookup
service.
3. If the service ID isn’t in the set
and it is interested in the groups, it
connects to the unicast server to get The unicast discovery server
the proxy of the lookup service and
then add the new ID into the set.
17
The Leasing Mechanism
 When a service registers with a lookup service, it gets back a lease
on its presence in the lookup service.
 If a service wants to maintain its presence, it must periodically
renew the lease at the lookup service.
 Any network or host failure will force the removal of the
unreachable services, which guarantees that the status of the
network is almost always current.
 It’s a self-healing mechanism. For example, when a network
failure isolates a service from a lookup service, the service will be
evicted from the lookup service because it can’t renew its lease.
And when the network is fixed, the service will receive a “Here I
am” message, and then it can join the lookup service again.

18
The Join Protocol
A service must maintain certain items of its state. These items are
as follows:
1. Its service ID : A new service will not be assigned a service ID until it is
started for the first time. After a service has been assigned a service ID, it
must continue to use it across all lookup services.

2. Set of attributes : used to distinguish the service from other services.

3. Set of groups : the groups that this service wishes to participate.

4. Set of specific lookup services : the lookup services that this service has
registered with. (by remembering their service IDs)

19
The Join Protocol(cont’d)
1. The Join Protocol is used to register/unregister a service with a
lookup service, or to maintain those items of its state, such as
changing its groups, attributes, etc.

2. For example, if a service is asked to change the set of attributes


with which it registers itself, it first modifies the set of attributes in
its storage, then it performs the requested change at each lookup
service with which it is registered.

3. The Join Protocol happens after the discovery process, and is


accomplished by using the downloaded proxy of the lookup service.

20
Some Network Details
 Though the Jini specification doesn’t explicitly say that Jini
relies on the TCP/IP, but actually it does.
 The Jini specification says:
if (TCP/IP is based on)
{
the multicast request uses the multicast IP address 224.0.1.85 and
UDP port number 4160 by default;

the unicast discovery uses the TCP port number 4160 by default;

the multicast announcement uses the multicast IP address 224.0.1.84


by default;
}

Note: They are also called well-known multicast IP addresses and port
numbers for Jini.
21
Thank you!

22

You might also like