Introduction to Jini & JavaSpaces
description
Transcript of Introduction to Jini & JavaSpaces
![Page 1: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/1.jpg)
April 22, 2023
Introduction to Jini & JavaSpaces
Source references: JGrid project
![Page 2: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/2.jpg)
Agenda
Jini SOA Jini intro Jini detailed view Summary
![Page 3: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/3.jpg)
Introduction to Jini
![Page 4: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/4.jpg)
What Is Jini
Java Based SOA Platform Designed as a native extension of the
J2SDK Project in Sun First announced in 1998 Positioned for dynamic networking
![Page 5: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/5.jpg)
Web Services - SOA
Web ServiceWeb Service
UDDI RegistryUDDI
Registry
ClientClient
Publish Find
Bind/Invoke
WSDLWSDL
Web Services
![Page 6: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/6.jpg)
Jini SOA
Jini ServiceJini Service
LookupServiceLookupService
ClientClient
Publish
Bind/Invoke
Java InterfaceJava Interface
Find
Jini
![Page 7: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/7.jpg)
Jini Components
![Page 8: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/8.jpg)
How does it work
Service Registry
Lookup Service Jini Service
ServiceProxy
Publish
Bind/Invoke
Jini ClientFind
![Page 9: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/9.jpg)
Jini – A Detailed view
Discovery Registration Lookup Events Leasing Proxies
![Page 10: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/10.jpg)
Unicast discovery
LookupLocator lookup = null;
ServiceRegistrar registrar = null;
lookup = new LookupLocator(“jini://hostname”);
registrar = lookup.getRegistrar();
Service AService A
Lookup ServiceLookup Service
download
registrarregistrar
LUS proxy
Discovery request
![Page 11: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/11.jpg)
Multicast discovery Discovery is initiated by class LookupDiscovery
LookupDiscovery discover = new LookupDiscovery(LookupDiscovery.ALL_GROUPS);
Asynchronous responses are handled by a listener object (implementing the DiscoveryListener interface)discover.addDiscoveryListener(listener);
Registrationpublic void discovered(DiscoveryEvent e){
//Lookup service discovered – register}
Lookup Service NLookup Service N
Discovering entityDiscovering entityLookup Service …Lookup Service …
Lookup Service 2Lookup Service 2
Lookup Service 1Lookup Service 1
multicast request
![Page 12: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/12.jpg)
Main steps
Discovery Registration Lookup Events Leasing Proxies
![Page 13: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/13.jpg)
try{// register for 100 seconds registration registrar.register(
serviceItem, 100000L); } catch (java.rmi.RemoteException e){}
Service registration
Once we have a proxy to the lookup service, can register the service ServiceRegistration registration = null;//create serviceItem (no ID, no attributes)
ServiceItem serviceItem = new ServiceItem(null, new
GreetingServiceProxy(), null); Service AService A
Lookup ServiceLookup Service
registrarregistrar
download
LUS proxy
register( )
registration
Service Proxy
![Page 14: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/14.jpg)
Main steps
Discovery Registration Lookup Events Leasing Proxies
![Page 15: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/15.jpg)
The client side
// create template for service search
...
GreetingServiceInterface returnedService = null;
try{
returnedService = (GreetingServiceInterface)
registrar.lookup(template);
}catch (java.rmi.RemoteException e){
...
}
returnedService.hello();
}
Lookup ServiceLookup Service
Client 1Client 1
Found proxy
lookup( )
Interface
Template
Template
registrarregistrar
![Page 16: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/16.jpg)
Main steps
Discovery Registration Lookup Events Leasing Proxies
![Page 17: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/17.jpg)
Remote Events
Jini provides remote events to make a Jini system dynamic Services coming and going State changes
The event mechanism is based on Event registration Event handling through an event listener’s
notify() method
![Page 18: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/18.jpg)
Main steps
Discovery Registration Lookup Events Leasing Proxies
![Page 19: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/19.jpg)
Obtaining a Lease
The lease grantor is usually the lookup service and the leaseholder usually is the service.
ServiceRegistration reg = registrar.register();
Lease lease = reg.getLease(); Visually this can be represented as
Service AService ALookup ServiceLookup Service
registrarregistrar
registrationregistrationgetLease(
)
leaselease
![Page 20: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/20.jpg)
Main steps
Discovery Registration Lookup Events Leasing Proxies
![Page 21: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/21.jpg)
Jini service proxy models
There are several ways (patterns) of creating service proxies.
A proxy can: Run entirely in the client JVM Be an RMI stub Be a proxy with local logic using RMI to the back end
service Be a proxy with local logic using its own communication
protocol (e.g. socket) to the back end service Be a wrapper to legacy code (e.g. CORBA)
![Page 22: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/22.jpg)
Introduction to JavaSpaces
![Page 23: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/23.jpg)
What is JavaSpaces?
A JINI service that provides distributed shared memory capabilities
A simple yet powerful service that can be used for solving distributed programming issues such as: Collaboration WorkFlow Synchronization Distributed Computing
![Page 24: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/24.jpg)
JavaSpaces model
Write
Read, Take,Notify
Wri
te
Rea
d, T
ake,
Not
ify
•Write –writes a data object.•Read – reads a copy of a data object.•Take – reads a data object and deletes it.•Notify – generates an event on data updates.
![Page 25: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/25.jpg)
Clustered JavaSpaces
![Page 26: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/26.jpg)
JavaSpaces Methods (Space Operations) JavaSpaces provides a basic API for storing
and reading data objects in a shared resource (a space).
The methods are: Write –writes a data object. Read – reads a copy of a data object. Take – reads a data object and deletes it. Notify – generates an event on data updates.
![Page 27: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/27.jpg)
Example Entry
This shows a minimal entry:
package hello;
import net.jini.core.entry.Entry;
public class Message implements Entry
{
public String content;
public Message()
{
}
}
Must include a constructor
Entry Filed need to be public
Must Implements Entry interface
![Page 28: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/28.jpg)
Write/Read Operations
Instantiate an Entry Set its fields as necessary Write the entry to the space
Read an Entry
Message msg = new Message();
msg.content = "Hello World";
JavaSpace space = (JavaSpace)SpaceFinder.find( “jini://*/*/JavaSpaces” );
Lease l=space.write(msg, null, Lease.FOREVER);
Message template = new Message();
Template.content = “data to match”;
Message result = (Message)space.read(template, null, Long.MAX_VALUE);
![Page 29: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/29.jpg)
Notify Operation
Registering for notifications
// Register a notification
template = space.snapshot(new Message());
EventRegistration reg = space.notify( template,
null, //TX
SpaceEventListener() , // The listener
60000 , // Lease
null); // handbag
System.out.println( "Notification registered. Registration id: " + reg.getID() + “Sequence number: " + reg.getSequenceNumber());
![Page 30: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/30.jpg)
Grid engine for parallel processing
Parallel Batch Processing
![Page 31: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/31.jpg)
Monte Carlo Simulation Details
18,000 Securities, 20 Scenarios, 2,000 Paths/Scenario
1 run = 18K x 20 x 2K (720M) theoretically separate tasks
1 run = 18K x 20 (360k) tasks in reality due to granularity
These larger tasks are separable Computation time per task ranges from 20-2000
ms Total computation time in sequence ~100 H Setup for run takes 1-5 minutes First pass attempts with threading on 8-way box
used 56 H of elapsed time Using the space with 50 units ~2 H
(Source-Invesco)
![Page 32: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/32.jpg)
0
500
1000
Tim
e (s
ec)
1 2 4 8 16 32
CPUs
Optimum Time Elapsed Time
Source: Dr. Alexander Gebhart - Development ArchitectSAP – JavaOne presentation 2003
Scalability & Performance
![Page 33: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/33.jpg)
Parallel Parsing Grid
![Page 34: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/34.jpg)
Provisioning & Monitoring Using the RIO project
![Page 35: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/35.jpg)
RIO Project - SLA based deployment
![Page 36: Introduction to Jini & JavaSpaces](https://reader036.fdocuments.net/reader036/viewer/2022081502/568158da550346895dc621e7/html5/thumbnails/36.jpg)
Monitoring