37
June 11, 2022 Introduction to Jini & JavaSpaces Source references: JGrid project

Introduction to Jini & JavaSpaces

  • Upload
    jensen

  • View
    90

  • Download
    0

Embed Size (px)

DESCRIPTION

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 - PowerPoint PPT Presentation

Citation preview

Page 1: Introduction to Jini & JavaSpaces

April 22, 2023

Introduction to Jini & JavaSpaces

Source references: JGrid project

Page 2: Introduction to Jini & JavaSpaces

Agenda

Jini SOA Jini intro Jini detailed view Summary

Page 3: Introduction to Jini & JavaSpaces

Introduction to Jini

Page 4: Introduction to Jini & JavaSpaces

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

Web Services - SOA

Web ServiceWeb Service

UDDI RegistryUDDI

Registry

ClientClient

Publish Find

Bind/Invoke

WSDLWSDL

Web Services

Page 6: Introduction to Jini & JavaSpaces

Jini SOA

Jini ServiceJini Service

LookupServiceLookupService

ClientClient

Publish

Bind/Invoke

Java InterfaceJava Interface

Find

Jini

Page 7: Introduction to Jini & JavaSpaces

Jini Components

Page 8: Introduction to Jini & JavaSpaces

How does it work

Service Registry

Lookup Service Jini Service

ServiceProxy

Publish

Bind/Invoke

Jini ClientFind

Page 9: Introduction to Jini & JavaSpaces

Jini – A Detailed view

Discovery Registration Lookup Events Leasing Proxies

Page 10: Introduction to Jini & JavaSpaces

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

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

Main steps

Discovery Registration Lookup Events Leasing Proxies

Page 13: Introduction to Jini & JavaSpaces

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

Main steps

Discovery Registration Lookup Events Leasing Proxies

Page 15: Introduction to Jini & JavaSpaces

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

Main steps

Discovery Registration Lookup Events Leasing Proxies

Page 17: Introduction to Jini & JavaSpaces

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

Main steps

Discovery Registration Lookup Events Leasing Proxies

Page 19: Introduction to Jini & JavaSpaces

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

Main steps

Discovery Registration Lookup Events Leasing Proxies

Page 21: Introduction to Jini & JavaSpaces

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

Introduction to JavaSpaces

Page 23: Introduction to Jini & JavaSpaces

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

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

Clustered JavaSpaces

Page 26: Introduction to Jini & JavaSpaces

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

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

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

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

Grid engine for parallel processing

Parallel Batch Processing

Page 31: Introduction to Jini & JavaSpaces

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

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

Parallel Parsing Grid

Page 34: Introduction to Jini & JavaSpaces

Provisioning & Monitoring Using the RIO project

Page 35: Introduction to Jini & JavaSpaces

RIO Project - SLA based deployment

Page 36: Introduction to Jini & JavaSpaces

Monitoring

Page 37: Introduction to Jini & JavaSpaces

April 22, 2023

Thank You!

[email protected]