A Look at Jini
Richard Chapman
Sept. 30, 1999
Jini Motivation
• Why must everyone be a sysadmin?
• Why can’t computers scale like the
phone system: added complexity
without added configuration work?
• Why can’t devices/services enter and
leave the network without explicit
Jini Goals
• Very robust software infrastructure
• No configuration/administration
• Software must be evolvable
• Devices can form spontaneous
Jini History
• Fulfillment of original Java goals of an
environment for embedded systems
(Oak, 1990)
• The word “Jini” does not stand for
• Went public too soon, NYT reporter
John Markoff broke story in 1998
Jini is intended to be used by:
• Information appliances (thin clients, set
top boxes, PDA’s)
• Desktop machines can benefit from a
reduction in sysadmin duties
• Enterprise systems (servers) also
Getting Jini
• Source code distributed under Sun
community source license (open source)
• Need Java 2
• Requires web server, RMI activation
daemon, lookup service
• http://www.javasoft.com/products/jini/
Networked vs Distributed
• Move the data or move the code?
• Conventional wisdom: since code has to
be compiled and installed, move the
data, and call a routine on the remote
• Thus: make the remote function call
look like a local function call as much as
possible (RPC, CORBA, DCOM)
The network cannot be
• Very high latency (orders of magnitude)
• High variability in latency (has a
component failed or is the link just very
• New failure modes that do not exist on
local machine (router down,
nameserver crash, cable came loose)
Handling Partial Failures
• Partial Failures do not exist on local
machines -- you know the state, for
better or worse
• Partial failures arise when some, but not
all hosts, receive a message from a
• May be difficult for sender to detect
which hosts received message
Handling Partial Failures,
• Even if server can detect which hosts
have not received a message, what
does it do
• Can’t keep trying forever -- you run out
of disk drives storing old messages you
are trying to send
• Don’t want to give up and cut off the
host that failed to get a message
Why CORBA isn’t enough
• Ignores network performance issues
(makes remote call look like local call)
• An add-on to existing languages (not all
machines implement C++ the same
• Example problems: endianness, size of
int, float, char, etc.
Peter Deutch’s Seven Network
• The network is
• Latency is zero
• Bandwidth is infinite
• The network is
• Topology doesn’t
• There is one
• Transport cost is
Jini adopts the programming
model of Java
• One lanuage everywhere
• Data in the same format everywhoere
(objects represented by bytecodes)
• Strongly typed interfaces
• Separate interface and implementation
• Plus: a distributed storage model based
on Linda (Gelernter, Yale)
Conventional wisdom is no
longer valid.
• Code can easily move from machine to
• Servers can be dynamically updated
• Systems can evolve by updating
interfaces with new code as needed, no
need for recompilation
Strong typing is important
• In Java, an RMI defines the interface,
while in CORBA, an IDL description is a
wrapper around the interface
• Polymorphism works in RMI -- you can
define subinterfaces; you can pass an
ojbect of a subtype to remote server
and the subtype methods are
appropriately used (doesn’t work in
Jini is built on Java RMI
• RMI = Remote Method Invocation
Public interface RemoteServer extends Remote {
public int getlength(String S) throws
Java RMI, cont’d
• If you change the (Java) interface
declaration in Java, you are really
changing the way the interface works
• If you change the Java interface
declaration in a CORBA system, you just
break the interface, since the Java
interface is generated automatically
from the IDL description
Java RMI, cont’d
• Thus from a software engineering point
of view, the CORBA implementation is
more complicated and error-prone
• However, CORBA outperfromed RMI
empirically (no longer true?)
• For enterprise solutions, CORBA is
essential -- we will always need glue to
connect heterogeneous systems
Strong typing, cont’d
• “Remoteness” is inherently part of the
interface, not an implementation detail
• Every interface must extend
• Permits a reasonable definition of
equality for remote objects -- you care
if the remote objects are the same, not
the local stubs
What Jini is not
• Jini is not a name server: lookup service
is similar, but does more than provide
references to objects
• Jini is not Java Beans: beans
communication based on direct method
invocation, not remote. Also, beans do
not automatically become aware of
each other as do Jini objects
What Jini is not, cont’d
• Jini is not Enterprise Java Beans:
Enterprise Java Beans function across
multiple address spaces well, but they
put Java wrappers around legacy
• Jini is not RMI: built on top of RMI
• Jini is not a distributed OS
Five Key Concepts of Jini
Remote Events
• Services=Devices or Software
• Services collect themselves into
• The resources available to a community
are kept track of by a lookup service
• No one-to-one mapping between
communities and lookup services
• Discovery=finding available lookup
Discovery, cont’d
• Several discovery protocols
• Multicast finds nearby lookup services
(on the same LAN)
• Multicast Announcement declares that a
new lookup service has started up
• Unicast used to talk to a particular
lookup service
• Lookup server does more than
• Nameserver provides pointers to objects
when given names
• Lookup server does that also, plus
supports searching for services that
meet certain criteria, e.g. those that
have a particular Java type
Lookup cont’d
• Lookup returns a service item when
queried successfully.
• Service item contains proxy object
(local stub for remote object) and
attributes that describe the service
Lookup, cont’d
Service item
Lookup service
Service item
Lookup, cont’d
• Downloadable proxy provided with each
service item
• When any entity wants to use your
service it downloads the proxy and runs
it -- the proxy handles sending the
remote server the necessary pieces
• Proxy can be used as a secure,
network-aware device driver
Proxy scenarios
• Proxy may perform the service by itself,
without any remote method invocation
• Proxy may be an RMI stub that knows
how to talk to a remote service (e.g.
IMAP mail server)
• Proxy uses private communication
protocol to talk to legacy (non-Java)
Using a Jini Service
Lookup service
Downloads proxy
Client communicates
with service via
“How does client x know to
call method y?”
• Objects must have some understanding
of the services they are going to use
• Industry will have to define a common
set of standards for interfaces to things
like cell phones, printers, scanners,
digital cameras
• My opinion: these interfaces will need
updating, and may prove to be Jini’s
• Suppose a service provider dies at some
• How do you keep dead services from
accumulating in the lookup servers over
• Solution: a service is only provided for a
certain amount of time unless the
provider re-registers it (renews the
Leasing, cont’d
• No sysadmin needs to comb through
the lookup service database to remove
long-dead services
• Cleans up partial failures
• Similarly, resource is not granted to a
consumer for indefinite period, but
“leased” for a finite time
Leasing, cont’d
• Consumer must renew the lease if the
resource continues to be needed
• Unreliable code thus does not do
permanent damage -- after a while the
resource is freed automatically
• No maintenance required of persistent
Third party leasing
• Jini leases can be negotiated by a third
• Example: long-lived but rarely active
process such as monthly disk backup
• Example: process that does not want to
be bothered with extra code complexity
of lease management
• Similar to Java Beans delegation
• Allows events to be handled by a third
party rather than the actual object to
which the event was sent
Lease mechanics
• Discovery returns an object that
implements lookup interface (called
• Server calls method register() of
ServiceRegistrar with service item
object as argument -- describes the
service to be registered
Lease mechanics, cont’d
• Client calls ServiceRegistrar lookup()
method to find if a service meeting its’
criteria is registered.
• Service registrar returns a service item
object, whose proxy is then used to
access object
• Lease is handled by an argument to
register, which says how long (long int)
the server plans to provide the service
Lease mechanics, cont’d
• Only one round of negotiation needed
for a lease
• Lease done in terms of duration, not
absolute time
• Leasing is not garbage collection
• Used for asynchronous notification
• Event is an object containing
information about external state change
the recipient may be interested in
• Same as Java Foundation Classes and
Java Beans model of events
Remote Events
• Remote events may not arrive in order
• Remote events may not arrive at all
• Remote events more expensive to send
than local events
• What does sender do if receiver has
crashed -- keep trying? How long?
Remote Events, cont’d
• Example: want to print an image taken
with a digital camera to a printer
• Suppose digital camera is connected to
network and there are no printers (want
to “grey out” the print button on
camera GUI)
• When a printer is connected, the
cameras should be notified
Remote events, cont’d
• RemoteEventListener() is a remote
interface used by objects waiting for
• Method notify() invoked via RMI by
objects that want to send events
• Very simple: one class, one interface,
one method. Contrast to Java
Foundation Classes
• Jini can implement generic 3rd party
Remote Events, contd
• Process interested in receving events
leases that service just like any other
• Hence if a service dies, it is not sent
events forever, only until its lease
• Used to handle partial failures -- gives a
way of deducing state of the system
after a partial failure
• Used to guarantee data integrity(
atomicity, consistency, isolation,
Two-phase commit
• Transaction manager collects all
constituent operations of a transaction
• Participants go to pre-commit status
(compute all results they would
compute if transaction were successful,
but do not make them permanent)
• Send acknowledgement of successful
transition to pre-commit status back to
transaction manager
Two-phase commit, cont’d
• If any participant fails, transaction
manager instructs all components to
abort, else notifies all to commit
• State of all components of system is
predictable in the presence of failures
Jini implementation of twophase commit
• All participants implement
TransactionParticipant interface.
• Three methods: prepare(), commit()
• Jini transaction manager doesn’t care
how the participants implement the
methods, it just steps through the

A Look at Jini - Auburn University