1 / 59

JavaSpaces ™

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. Learning Objectives. As a result of this presentation, you will be able to:

anika
Download Presentation

JavaSpaces ™

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. 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

  4. 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

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

  6. 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 A Network service for Sharing and Exchanging information between distributed services: Small & Powerful API

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

  8. What Is JavaSpaces? • Distributed Shared Memory • A Jini ™ Service • Transactionally Secure • Astonishingly Simple • Based on “tuple-spaces” (see David Gelernter’s Linda system)

  9. 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

  10. 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

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

  12. JavaSpaces Programs • Processes are decoupled from one another • Indirect interaction through one or more spaces

  13. 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

  14. 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

  15. 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

  16. 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);

  17. Space Operations • Very small number of operations are defined on a space • The three fundamental operations are: • Write • Read • Take

  18. Write Operation • Writes an entry to a space

  19. 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);

  20. Read Operation • Reads an entry from a space • Copy of object is returned • Original remains in space

  21. 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);

  22. Take Operation • Takes an entry from a space • Matched entry is removed from space

  23. 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);

  24. 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);

  25. 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

  26. 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());

  27. The Notify Operation (Cont) • RMI Event Listener public 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()); } }

  28. Other Space Operations • ReadIfExists() • Non-blocking read • takeIfExists() • Non-blocking take

  29. Clustered Space A 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. Clustering Models With JavaSpaces

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

  31. What’s Missing ? Data sharing between services Activities synchronized between services Data collaboration between services Optimal Performance Component Oriented Service Oriented Application Composite Application Becomes… A B C Components A B C Services The Service Oriented Approach

  32. 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 Using JavaSpaces™ as a Shared Address Space between services Composite Application Distributed Shared Memory Service A B C Services

  33. 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

  34. 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).

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

  36. The JINI Services Architecture

  37. Structure of Jini ™ Technology

  38. Step 1: Registering a Service

  39. Step 2: Finding a Service Lookup Service Client

  40. Step 3: Using a Service

  41. 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.

  42. 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) {..}

  43. 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

  44. 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)

  45. 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(); • }

  46. 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(..) {..}

  47. The Details: Programming using Leases,Events, and Transactions

  48. 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

  49. 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

  50. 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

More Related