javaspaces ™ nati shalom [email protected] cto gigaspaces technologies

59
JavaSpaces ™ Nati Shalom [email protected] CTO GigaSpaces Technologies

Upload: rosaline-logan

Post on 14-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

JavaSpaces ™

Nati Shalom

[email protected]

CTO

GigaSpaces Technologies

Page 2: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Goals

Introduction to JavaSpaces™ technology and it’s functions and usage within the Java Services Framework.

Page 3: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Learning Objectives

• As a result of this presentation, you will be able to:• Understand the Space Concept• Know more about Java Services Architecture• Learn about JavaSpaces™ simplicity and

strength• Figure out the position of JavaSpaces™ in

the overall Java Architecture

Page 4: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Speaker’s Qualifications

• Nati Shalom is a C.T.O and Co Founder of GigaSpaces a Software Company that specializes in Performance & Scalability of Distributed application using Distributed Shared Memory & JavaSpaces™.

• Nati Shalom have a vast experience in distributed computing technologies such as CORBA, JINI , Web Services , J2EE

• Nati Shalom is active in various technological forums such as GRID consortium, SUN/JINI group , I.JUG

• Nati Shalom is managing the I.JUG Web Services track.

• Nati Shalom speaks frequently on those topics in conferences and technical courses

Page 5: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Agenda

• What Is A Space• What Is JavaSpaces™• JavaSpaces™ Benefits• Programming with JavaSpaces™• The Service Oriented Architecture (SOA)• JINI Service Platform• Summary & References

Page 6: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

What is a space:

• Write• Writing an object into a shared

pool memory • Read

• Reading and object from a shared pool memory

• Take• Reading and Deleting an object

from a shared pool memory • Notify

• Setting and Receiving notifications of changes made within the shared pool memory

Small & Powerful API

A Network service for Sharing and Exchanging information between distributed services:

Page 7: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Agenda

• What Is A Space• What Is JavaSpaces™• JavaSpaces™ Benefits• Programming with JavaSpaces™• The Service Oriented Architecture (SOA)• JINI Service Platform• Summary & References

Page 8: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

What Is JavaSpaces?

• Distributed Shared Memory

• A Jini ™ Service

• Transactionally Secure

• Astonishingly Simple

• Based on “tuple-spaces” (see David Gelernter’s Linda system)

Page 9: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

JavaSpaces Benefits

• Boost the performance of the Distributed Applications:• Distributed Caching• Parallel Processing• Batching of remote calls.

• Provides a generic solution for addressing the scalability and high availability of the distributed applications.

• Hides the complexity of the distributed world:• Anonymity between applications• Uncoupled communication• Programs can communicate through time or space

• Vast savings in design and development time

Page 10: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

JavaSpaces Concepts

• High-level communications between Java program

• SIMPLE: only a few operations to learn

• EXPRESSIVE: a large number of computing problems can be solved

Page 11: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Agenda

• What Is A Space• What Is JavaSpaces™• JavaSpaces™ Benefits• Programming with JavaSpaces™• The Service Oriented Architecture (SOA)• JINI Service Platform• Summary & References

Page 12: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

JavaSpaces Programs

• Processes are decoupled from one another

• Indirect interaction through one or more spaces

Page 13: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Matching Entries

• A template is used to match entries in a space

• The template is simply an entry of the type to be matched

• Fields of the entry are used for matching

• Non-assigned fields are wildcards

Page 14: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Entries

• Entries are collections of typed objects

• Must implement net.jini.core.entry.Entry

• Fields can be any Serializable Java ™ object

• Fields must be public to be matchable

• Entry needs no-arg constructor

Page 15: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

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 16: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Accessing a Space

• Jini is used to locate a space

• Sun’s implementation identifies spaces by name.

• GigaSpaces identifies spaces by name , container , persistency

• Convenience method from GigaSpaces:• SpaceFinder.find(jini://*/*/spaceName);

Page 17: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Space Operations

• Very small number of operations are defined on a space

• The three fundamental operations are:• Write• Read• Take

Page 18: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Write Operation

• Writes an entry to a space

Page 19: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Write Operation

• Instantiate an Entry• Set its fields as necessary• Write the entry to the space

Message msg = new Message();

msg.content = "Hello World";

JavaSpace space = (JavaSpace)SpaceFinder.find( args[0] );

space.write(msg, null, Lease.FOREVER);

Page 20: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Read Operation

• Reads an entry from a space• Copy of object is returned• Original remains in space

Page 21: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Read Operation

• Build a template• Read a matching entry from the space

Message template = new Message();

Message result = (Message)space.read(template, null, Long.MAX_VALUE);

Page 22: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Take Operation

• Takes an entry from a space• Matched entry is removed from space

Page 23: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Take Operation

• Build a template• Take a matching entry from the space

Message template = new Message();

Message result = (Message)space.take(template, null, Long.MAX_VALUE);

Page 24: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Snapshot Operation

• The snapshot operation is used for performance optimization

• It generates an image of the Entry.

• This image usually saves the serialization overhead. Message template = new Message();

Entry snapshot = space.snapshot(template)

Message result = (Message)space.read( snapshot, null, Long.MAX_VALUE);

Page 25: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

The Notify Operation

• The space implements the JINI RemoteEvents pattern

• Clients can register for events on write operation using the notify method.

• The notify callback should implement a RemoteEventListener

Page 26: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Notify Operation (Cont)

• 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 27: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

The Notify Operation (Cont)

• RMI Event Listenerpublic class SpaceEventListener extends UnicastRemoteObject

implements RemoteEventListener

{

public SpaceEventListener() throws java.rmi.RemoteException{}

public void notify(net.jini.core.event.RemoteEvent theEvent)

throws net.jini.core.event.UnknownEventException, java.rmi.RemoteException

{

System.out.println("\nGot event from space:");

System.out.println("Event Source: " + theEvent.getSource());

System.out.println("Event Id: " + theEvent.getID());

} }

Page 28: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Other Space Operations

• ReadIfExists()• Non-blocking read

• takeIfExists()• Non-blocking take

Page 29: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Clustering Models With JavaSpaces

Clustered SpaceA network of cooperating spaces with single, virtual,

interface• Replication

• Manages the distribution of work between the cluster spaces

• Fail-Over• Manages the process of transparent re-routing in case of

failure during an active session• Load Balancing

• Enables partial or full replication between groups of spaces.

Page 30: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Agenda

• What Is A Space• What Is JavaSpaces™• JavaSpaces™ Benefits• Programming with JavaSpaces™• The Service Oriented Architecture (SOA)• JINI Service Platform• Summary & References

Page 31: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

The Service Oriented Approach

• What’s Missing ?• Data sharing between services• Activities synchronized between services• Data collaboration between services• Optimal Performance

Application

A B CComponents

Becomes…

Component Oriented

CompositeApplication

A B C Services

Service Oriented

Page 32: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Using JavaSpaces™ as a Shared Address Space between services

• The Space itself is A SERVICE that provides Shared Memory Capabilities.

• Services allocate space dynamically.

• Unique Benefits:• Performance

• Distributed Caching• Parallel Processing

• Virtualization• Collaboration• Synchronization• Personalization

• Session Sharing• Single Sign On

CompositeApplication

A B C Services

DistributedShared Memory

Service

DistributedShared Memory

Service

Page 33: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Enterprise Service Bus

“In 2002, a new form of infrastructure that combines Web services, messaging, basic transformation and content-based routing came to market. These low-cost, application-server-neutral enterprise service buses (ESBs) are well suited to be the backbones for SOAs and basic ENSs.”

Source: “From Enterprise Network to Enterprise Nervous System” Massimo Pezzini, 10–12 March 2003

Page 34: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Why Now? (Cont)

• Network vs. computer performance• Computer speed doubles every 18 months• Network speed doubles every 9 months• Difference = order of magnitude per 5 years

• 1986 to 2000• Computers: x 500• Networks: x 340,000

• 2001 to 2010• Computers: x 60• Networks: x 4000

Moore’s Law vs. storage improvements vs. optical improvements. Graph from Scientific American (Jan-2001).

Page 35: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Agenda

• What Is A Space• What Is JavaSpaces™• JavaSpaces™ Benefits• Programming with JavaSpaces™• The Service Oriented Architecture (SOA)• JINI Service Platform• Summary & References

Page 36: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

The JINI Services Architecture

Page 37: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Structure of Jini ™ Technology

Page 38: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Step 1: Registering a Service

Page 39: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Step 2: Finding a Service

Client Lookup Service

Page 40: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Step 3: Using a Service

Page 41: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

JoinManager & DiscoveryManager

• Locating services can be done using the utility classes of ``Discovery Management'‘

• The JoinManager uses the DiscoveryManager for locating an LUS.

• It than register the service with each LUS.

• The JoinManager provides two constructors:• No serviceId – This constructor should be used in the first

time the service has been registered. • With serviceId - This constructor should be used after the

service had been assigned atleast once a service id.

Page 42: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Example:Joining A Service with all LUS

JoinManager joinMgr = null;

try {

LookupDiscoveryManager mgr =

new LookupDiscoveryManager(LookupDiscovery.ALL_GROUPS,

null /* unicast locators */,

null /* DiscoveryListener */);

joinMgr = new JoinManager(new FileClassifierImpl(), /* service */

null /* attr sets */,

this /* ServiceIDListener*/,

mgr /* DiscoveryManagement */,

new LeaseRenewalManager());

}

catch(Exception e) {..}

Page 43: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

ServiceDiscoveryManager

• The class ServiceDiscoveryManager is only available in Jini 1.1. It performs client-side functions similar to that of JoinManager for services, and simplifies the tasks of finding services

Page 44: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

ServiceDiscoveryManager Goals

• The ServiceDiscoveryManager was designed to assist clients with the following tasks:• A client may wish to use a service immediately or

later • A client may want to use multiple services • A client will want to find services by their interface,

but may also want to apply additional criteria, such as being a ``fast enough'' printer

• A client may just wish to use a service if it is available at the time of request, but alternatively may want to be informed of new services becoming available and respond to this new availability (for example, a service browser)

Page 45: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

The ServiceDiscoveryManger Interface

public class ServiceDiscoveryManager {

public ServiceDiscoveryManager(DiscoveryManagement discoveryMgr, LeaseRenewalManager leaseMgr) throws IOException;

LookupCache createLookupCache(ServiceTemplate tmpl, ServiceItemFilter filter, ServiceDiscoveryListener listener);

ServiceItem[] lookup(ServiceTemplate tmpl, int maxMatches, ServiceItemFilter filter);

ServiceItem lookup(ServiceTemplate tmpl, ServiceItemFilter filter); ServiceItem lookup(ServiceTemplate tmpl, ServiceItemFilter filter, long wait);

ServiceItem[] lookup(ServiceTemplate tmpl, int minMaxMatch, int maxMatches, ServiceItemFilter filter, long wait);

void terminate();

}

Page 46: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Finding a Service Immediately

try {

LookupDiscoveryManager mgr = new LookupDiscoveryManager(LookupDiscovery.ALL_GROUPS,

null /* unicast locators */,

null /* DiscoveryListener */);

clientMgr = new ServiceDiscoveryManager(mgr,

new LeaseRenewalManager());

} catch(…) {.. }

Class [] classes = new Class[] {FileClassifier.class};

ServiceTemplate template = new ServiceTemplate(null, classes, null);

ServiceItem item = null;

// Try to find the service, blocking till timeout if necessary

try {

item = clientMgr.lookup(template,

null, /* no filter */

WAITFOR /* timeout */);

} catch(..) {..}

Page 47: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

The Details:

Programming using Leases,

Events, and Transactions

Page 48: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Why Distributed Leasing?

• Problem: • Partial failure in distributed systems can

lead to unchecked resource consumption

• Traditional solution: system administration• Error-prone• Costly• Only happens when it’s too late

Page 49: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Distributed Leasing in Jini™

• Protocol for managing resources using a renewable, duration-based model• Contract between objects• Resources can be shared or private• Provides a method of managing resources in

an environment where network failures can, and do, occur

Page 50: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

What are Leases?

• Time-based grants of resources or services• Loose contracts between grantor and holder• Negotiated for a set period of time• Can be shared or exclusive

Page 51: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Lease Operations

• Leases may be:• Cancelled (explicit cleanup)• Renewed (explicit extension)• Allowed to expire (implicit cleanup)• Obtained and manipulated by third parties

Page 52: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Distributed Leasing

• Resources are allocated only as long as continued interest is shown• Leasee is responsible to renew lease before

expiry• The network is self-healing

Page 53: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Distributed Events

• Extend Java™ event model to work in a distributed network• Register interest, receive notification• Allow for use of event managers• Support various delivery models

• Push, pull, filter

• Use the Distributed Leasing protocol

Page 54: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Transaction model in Jini™

• Designed for distributed object coordination• Light weight, object-oriented• Supports two-phase commits• Uses Distributed Leasing protocol• Implemented in Transaction Manager

service

Page 55: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Agenda

• What Is A Space• What Is JavaSpaces™• JavaSpaces™ Benefits• Programming with JavaSpaces™• The Service Oriented Architecture (SOA)• JINI Service Platform• Summary & References

Page 56: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

GigaSpaces Free Academic Program

GigaSpaces Free Academic Program

Is available through the web

site.

Page 58: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies
Page 59: JavaSpaces ™ Nati Shalom Natis@gigaspaces.com CTO GigaSpaces Technologies

Thank you for listening