Transcript Tutorial 1

Jini Tutorial
The road to reliable, autonomous
distributed systems
1
Tutorial outline


Three parts, each (hopefully) one hour
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
Characteristics of distributed systems


Different from closed-box systems
The followings are not true







Zero network latency
Networks are reliable
Remote systems fault-free
Infinite bandwidth
One administration
Homogeneous systems
Other problems


Systems can be very large – many components and services
Software deployment problems – packaging and distributing,
upgrading
3
Why Java?

The Java Language has many good design
features


Good set of libraries



secure, safe (with respect to bugs), object-oriented,
familiar (to C C++ and even Fortran programmers).
networking, multimedia, from graphics to math
functions.
Higher programmer productivity
Best available electronic and paper training
resources.
4
Why Java?




Java is rapidly getting the better (the best!)
Integrated Development Environments (IDEs)
for programs.
Java is naturally integrated with network and
universal machine supports potentially powerful
“write once-run anywhere” model.
Supports mobile code
Easy to teach, so there is a large and growing
trained labour force.

First language in most CS course
5
Java: Key Technical Ideas

A Better Language:






Simplicity and C/C++ compatibility promote fluency;
GC and Threads allow software components;
Platform independence saves time;
Strong typing catches errors up front;
Declared exceptions forces coverage in code.
Scalable Applications;



Threads for parallel speedup; patterns “in the large”.
Dynamic linking allows simple apps to grow;
Range of implementations from JavaCard through
J2ME (mobile) to J2EE (enterprise).
6
The Java Platform

Consists of:


The Java Virtual Machine (Java VM)
The Java Application Programming
Interface (Java API)
Java program
Java API
Java Virtual Machine (JVM)
Java platform
Hardware platform
7
The Java Architecture

The Java programming language


interpreted
portable and
architecture independent
8
The role of mobile code

Mobile code enables:




Service provisioning, simple code/service
deployment
Device and user specific dynamic user
interfaces
Application/service composition
on the fly
Summary

Java is good but not enough!
9
Missing from the Java language


Access to remote JVMs (RMI)
Ad hoc networking and dynamic system
configuration (Jini)
10
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
11
Remote Method Invocation (RMI)



Java variant of Remote Method Invocation
Designed for Client-Server applications over unstable
and slow networks.
Allows objects running on one JVM invoke methods on
an object running on another JVM.




The basic object model of Java does not permit invocations on
objects located in remote address spaces
Provides easy access to objects existing on remote virtual
machines. RMI extends the basic Java object model beyond a
single VM address space.
RMI provides (and hides) communication between remote Java
programs.
Fast remote method invocations with low latency and
high bandwidth are required for high performance
computing.
12
Java RMI Model cont’d

Objects can be passed as arguments and returned as
results
remoteObject.someMethod( objectArgument );




Any Java object can be passed during invocation
including primitive types, core classes, user-defined
classes and JavaBeans
Syntax of remote method invocation is same as the
local invocations
RMI operates only in Java-Java domain, developers
work within a single object model instead of working
with multiple models
RMI-IIOP to other systems
13
Basic components
HTTP
HTTP
Client machine
Server machine
Rmi registry
Client code
Lookup /
download
stub
skeleton
remote
server
14
Required operations in
distributed object applications

Register/Locate remote objects:


Communicate with remote objects:


Obtain references to remote objects . An application can
register its remote objects with RMI's simple naming facility,
the rmiregistry, or the application can pass and return
remote object references as part of its normal operation.
Details of communication between remote objects are
handled by RMI; to the programmer, remote communication
looks like a standard Java method invocation.
Load class bytecodes for objects that are passed
around:

Because RMI allows a caller to pass objects to remote
objects, RMI provides the necessary mechanisms for loading
an object's code, as well as for transmitting its data.
15
Object Serialization


Provides a programmer the ability to read
or write a whole object to and from a
raw byte stream.
An essential feature needed by RMI
implementation when method arguments
are passed by copy.
16
Development Steps

Design and implement components of distributed
application.




Compile sources and generate stubs and skeletons.



Define remote interface – specifies functionality as remote
methods.
Implement remote objects – implement the remote
interface.
Implement clients.
No skeletons from v1.2
Put classes in Web accessible directory (HTTP).
Start registry, start application.
17
Main problem

Static system configuration




Client needs service name/IP address
Makes server/service replication impossible
Difficult to handle errors (network or
server)
Solution is Jini
18