370 likes | 554 Views
Introduction to Jini & JavaSpaces. Source references: JGrid project. Agenda. Jini SOA Jini intro Jini detailed view Summary. Introduction to Jini. What Is Jini. Java Based SOA Platform Designed as a native extension of the J2SDK Project in Sun First announced in 1998
E N D
Introduction to Jini & JavaSpaces Source references: JGrid project
Agenda • Jini SOA • Jini intro • Jini detailed view • Summary
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
UDDI Registry Find Publish WSDL Client Web Service Bind/Invoke Web Services Web Services - SOA
Lookup Service Publish Find Java Interface Jini Service Client Bind/Invoke Jini Jini SOA
How does it work Find Jini Client Publish Service Registry Lookup Service Jini Service Service Proxy Bind/Invoke
Jini – A Detailed view • Discovery • Registration • Lookup • Events • Leasing • Proxies
Discovery request download registrar LUS proxy Unicast discovery LookupLocator lookup = null; ServiceRegistrar registrar = null; lookup = new LookupLocator(“jini://hostname”); registrar = lookup.getRegistrar(); Lookup Service Service A
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); Registration public void discovered(DiscoveryEvent e){ //Lookup service discovered – register} Multicast discovery multicast request Lookup Service N Lookup Service … Discovering entity Lookup Service 2 Lookup Service 1
Main steps • Discovery • Registration • Lookup • Events • Leasing • Proxies
Service Proxy registration Service registration Once we have a proxy to the lookup service, can register the service ServiceRegistration registration = null; //create serviceItem (no ID, no attributes) Lookup Service ServiceItem serviceItem = new ServiceItem(null, new GreetingServiceProxy(), null); download Service A register( ) registrar try{// register for 100 seconds registration registrar.register( serviceItem, 100000L); } catch (java.rmi.RemoteException e){} LUS proxy
Main steps • Discovery • Registration • Lookup • Events • Leasing • Proxies
Lookup Service Template Client 1 Interface Template lookup( ) registrar Found 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(); }
Main steps • Discovery • Registration • Lookup • Events • Leasing • Proxies
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
Main steps • Discovery • Registration • Lookup • Events • Leasing • Proxies
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 A Lookup Service registrar getLease() registration lease
Main steps • Discovery • Registration • Lookup • Events • Leasing • Proxies
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 –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. Write Read, Take, Notify Read, Take, Notify Write
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 Implements Entry interface Entry Filed need to be public Must include a constructor
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());
Parallel Batch Processing Grid engine for parallel processing
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)
Scalability & Performance Source: Dr. Alexander Gebhart - Development ArchitectSAP – JavaOne presentation 2003
natis@gigaspaces.com Thank You!