View
212
Download
0
Category
Tags:
Preview:
Citation preview
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
Web Services - SOA
Web ServiceWeb Service
UDDI RegistryUDDI
Registry
ClientClient
Publish Find
Bind/Invoke
WSDLWSDL
Web Services
Jini SOA
Jini ServiceJini Service
LookupServiceLookupService
ClientClient
Publish
Bind/Invoke
Java InterfaceJava Interface
Find
Jini
How does it work
Service Registry
Lookup Service Jini Service
ServiceProxy
Publish
Bind/Invoke
Jini ClientFind
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
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
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
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
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
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
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)
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
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.
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.
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
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);
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());
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)
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
Recommended