javaspaces
Download
Skip this Video
Download Presentation
JavaSpaces

Loading in 2 Seconds...

play fullscreen
1 / 42

JavaSpaces - PowerPoint PPT Presentation


  • 148 Views
  • Uploaded on

JavaSpaces. SENG 609.09. Shuxin Yuan/Mike Gao April 17, 1999. JavaSpaces Concepts Technology Basis Applications JavaSpaces Operations Entries and Templates. JavaSpaces architecture Functionality Sample implementation Supporting packages Conclusions. JavaSpaces. Table of Contents.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'JavaSpaces' - treva


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
javaspaces

JavaSpaces

SENG 609.09

Shuxin Yuan/Mike Gao

April 17, 1999

javaspaces2
JavaSpaces Concepts

Technology Basis

Applications

JavaSpaces Operations

Entries and Templates

JavaSpaces architecture

Functionality

Sample implementation

Supporting packages

Conclusions

JavaSpaces

Table of Contents

javaspaces concepts 1
JavaSpaces Concepts (1)
  • A mechanism

for distributed computing

    • dynamic sharing, communication and coordination of Java Objects
    • Loosely coupled,

cooperative marketplace model

      • producer store objects in the space
      • consumer lookup and take objects from the space
    • 100% pure Java language based
javaspaces concepts 2
JavaSpaces Concepts (2)
  • A networked repository for Java Objects
    • Store Entries (Serialized Java objects)
    • Both data and behaviors
    • Lookup entries by using Templates( Entries given the values of fields for matching)
    • Type matching (same class?)
    • Value matching: lookup and compare the specific fields
javaspaces concepts 3
JavaSpaces Concepts (3)
  • An interface: net.jini.space.JavaSpace
    • A JavaSpace server implements this interface
    • Operations are involked on a JavaSpace object
      • write, read, readIfExists, take, TakeIfExists,

notify, snapshot

    • Not a remote interface
      • Client communicates with JavaSpaces server remotely
      • JavaSpaces server communicates with JavaSpaces locally
    • Each method throws RemoteException
javaspaces concepts 4
JavaSpaces Concepts (4)
  • JavaSpaces solves two problems:
    • Distributed persistence
      • store and retrieve objects on remote systems
      • use object serialization technology
    • Distributed algorithms
      • RMI
      • flow of objects
differences to database
Differences to database
  • JavaSpaces is not just for data repository
    • All entries are copies of original objects
    • No general query language
    • No way to return sets of objects
    • Not a transparent persistence mechanism (can not modify data)
    • Understand entry by type and serialized fields
  • JavaSpaces is something between file system and database
javaspaces suitability
JavaSpaces Suitability
  • JVM
    • All users should link to a JVM
    • use Java RMI
    • Transport among JVMs via JNI
  • Interoperability
    • interoperable with other language
    • via RMI/IIOP and CORBA
javaspaces advantages
JavaSpaces Advantages
  • Simple solution for lightweight distributed application
  • Make client-side model simple and the downloading of client classes quick
  • Decouples rigid association between requestor and provider
    • Relieves responsibilities and complexity
    • easy to build and maintain
  • Multiple spaces can co-exist within a network
  • Unified network environment
  • Simple yet powerful methods, only four primitive methods:
    • write, read, take, notify
javaspaces technology basis
JavaSpaces Technology basis
  • Built on core JDK facilities
    • RMI
    • Object serialization
  • Part of Sun’s Jini package
    • Leasing
    • Transaction
    • Distributed events
applications model
Applications (Model)

Identities

read

JavaSpaces

server

Client

write

Security Check

writeEvent

Client

write

notify

Event

Catcher

Transaction

proxy

take

notify

write

JavaSpaces

server

notify

JavaSpaces

server

an application scenario stock trading system
Live feed applet

buyer

bid

entry

read

Write

JavaSpaces

Server

graphic applet

Write

entry

seller

Notify

An application scenario: Stock trading system
  • Entry fields:
    • securities, owners price offers, quantities, ...
  • GUI:
    • applets
  • Many sellers and buyers can be

involved

    • concurrent access are handled

by the space

applications
Applications
  • Workflow systems
  • Customer management systems
  • Supply chain management
  • Auction systems
  • Trading service
  • Agent systems
  • Publish and subscribe service
  • …...
javaspaces operations
JavaSpaces Operations
  • write -- put a copy of entry into the space
  • read, readIfExists

-- return a matching entry from the space

  • take, takeIfExists

-- remove the matching entry from the space

  • notify -- send an event when the matching entry is written
  • snapshot -- return another entry object that contains the snapshot of the original one
entries
Entries
  • Entry Implementation
    • Typed group of objects, java class
    • Implement Java interface: net.jini.space.Entry

public interface Entry extends java.io.serializable { }

    • Have a public, zero-arg constructor
    • Defines public fields for matching
    • Each field is an object, no primitive types
  • Default implementation of Entry:

public abstract class AbstractEntry implements Entry { ...}

    • implements equals( ) and hashCode( ) properly by comparing field values
templates
Templates
  • Template
    • Entry object
    • Some/all fields set to specific values
    • Null fields act as wildcards
    • Type and value matching
    • Exact match of each field
javaspaces architecture
JavaSpaces architecture
  • Entry/Template
  • Serialization
  • JavaSpace Scenario
  • JavaSpaces/JavaSpace server
  • JavaSpace Interface
entry template
Entry/Template
  • Template is an Entry for matching
  • Type matching
  • Value matching
  • Type matching and subtype matching
  • Only public fields are considered for matching
  • Fields should refer to serializable objects
  • Fields must have properties
serialization
Serialization
  • Entries are NOT stored in JavaSpaces
  • Serialized form of the class and fields
  • java.rmi.MarshalledObject
  • MashalledObject.equals()
  • Field in template has null value as wildcard
  • set fields/un-set fields
  • Object graph map reference
serialization20
Serialization

Entry

Forms

javespaces scenario
JaveSpaces Scenario

Transaction

Distributed

Event

JavaSpaces

Leasing

Entry

RMI

javaspaces javaspace server
JavaSpaces/JavaSpace Server
  • Not a remote interface
  • invocation of methods of JavaSpace throws RemoteException
  • JavaSpaces server exports objects implemeting javaspace interface to clients
javaspace javaspace server
JavaSpace/JavaSpace Server

Client

JavaSpace Server

Server

Interface

JavaSpace

JavaSpace

Client

javaspaces interface
JavaSpaces interface

Import net.jini.transaction.*

import net jini.event.*;

import net.jini.lease.*;

Public interface JavaSpace{

Lease write(Entry e, Transaction t, long lease) throws…;

public final long NO_WAIT=-1;// don’t wait at all

Entry read(Entry temp1, Transaction t, long timeout) throws...;

Entry readIfExists(Entry temp1, Transaction t, long timeout) throws…;

Entry take(Entry templ, Transaction t, long timeout) throws...;

Entry takeIfExists(Entry templ, Transaction t, long timeout) throws...;

EventRegistration notify(Entry templ, Transaction t, RemoteEvenbtListener l, long lease, MarshalledObject handback) throws…;

Entry snapshot(Entry e) throws RemoteException;

}

functionality
Functionality
  • write
  • read/readIfExists
  • take/takeIfExists
  • snapshot
  • notify
write
Write

Lease write(Entry e, Transaction t, long lease) throws…;

  • Write a copy into Space
  • Field is independent
  • write returns a Lease object
  • RemoteException
  • Other kinds of exceptions
readifexists and read
ReadIFExists and Read

Public Entry read(Entry temp1, Transaction t, long timeout) throws...;

Entry readIfExists(Entry temp1, Transaction t, long timeout) throws

  • A copy of the matching entry is returned.
  • Null is returned if no matching is found
  • read vs. readIfExists: read will wait until a match is found or until transaction settle, up to time out period
takeifexists and take
takeifExists and take

Entry take(Entry templ, Transaction t, long timeout) throws...;

Entry takeIfExists(Entry templ, Transaction t, long timeout) throws...;

  • Object is removed from space
  • RemoteException: Entry may or may not be removed successfully
  • Other Exceptions mean failure
  • Subtype matching: returns may be more than anticipated
snapshot
snapshot
  • Entry snapshot(Entry e) throws RemoteException;
  • Reduce repeated use of the same Entry
  • Returns a Entry object with a snapshot of the original unmodified object
  • Modification on the original entry will not affect snapshot
  • Only work within the same JavaSpaces Server where it is generated
notify
notify

EventRegistration notify(Entry templ, Transaction t, RemoteEvenbtListener l, long lease, MarshalledObject handback) throws…;

  • RemoteEvent
  • RemoteEventListener
  • EventRegistraion{

evID

fromWhom

seqNo

}

  • retry to notify listeners
sample implementation
Sample implementation
  • Requirements
  • Entry implementation
  • Sample invocation
requirements
Requirements
  • JDK1.2 beta 4 or later version
  • Jini beta version or later version
entry implementation
Entry implementation

MyEntry class

import net.jini.space.Entry

public class MyEntry implements Entry{

public String name;

public GIFImage value;

public MyEntry(){

}

}

sample invocation
Sample invocation

import net.jini.impl.outrigger.binders.RefHolder

Public HelloWorld class{

public JavaSpace getSpace(){

RefHolder rh = (RefHolder)Naming.lookup(“JavaSpace”);

JavaSpace js = (JavaSpace)rh.proxy();

}

}

sample invocation35
Sample invocation
  • JavaSpace space = getSpace();
  • MyEntry e = new MyEntry();
  • e.name =“Duke”;
  • e.Value= new GIFImage(“dukeWave.gif”);
  • space.write(e, null, 60*60*1000);// one hour
supporting packages
Supporting packages
  • Leasing
  • Transaction
  • Distributed Event/Listener
leasing
Leasing
  • Used in distributed environments to solve partial failure of resources and services
  • Resources are leased and freed when the time of the lease expires
  • Get ride of debris easily
  • Negotiation among related parties
  • Lease can be renewed or canceled
  • Different from garbage collection
transaction
Transaction
  • System task is to coordinate objects over transaction
  • Two phrase commit model
  • Based on RMI to perform communication
  • Dependent on Leasing
distributed event
Distributed Event
  • Events in multi-address spaces
  • Desired delayed
  • Network failure/Delay
  • Third-party agents perform notification
  • Non-Java third-party agents
third part agents
Third-part agents

Obj3

Obj1

Server

Server

Obj4

Obj2

conclusion
Conclusion
  • JavaSpaces concepts and advantages
  • Model object flow processes
  • JavaSpaces architecture and operations
  • Supporting packages
  • Reference:

http://www.javasoft.com/products/javaspaces/index.html