JavaSpaces TM By Stephan Roorda Source: JavaSpaces specification.

Slides:



Advertisements
Similar presentations
JavaSpaces and TSpaces Theresa Tamash CDA 5937 November 4, 2002.
Advertisements

Distributed Objects and Remote Invocation
Linda Coordination Language Presented by Tae Ki Kim
Remote Method Invocation
The road to reliable, autonomous distributed systems
Introduction to Jini & JavaSpaces
Notes to the presenter. I would like to thank Jim Waldo, Jon Bostrom, and Dennis Govoni. They helped me put this presentation together for the field.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
Java RMI. What is RMI? RMI is an RPC system for an object based language. Objects provide a natural granularity for the binding of functions. –RMI allows.
Group Communications Group communication: one source process sending a message to a group of processes: Destination is a group rather than a single process.
Erlang concurrency. Where were we? Finished talking about sequential Erlang Left with two questions  retry – not an issue; I mis-read the statement in.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
CS 603 Jini April 10, What is Jini? Java Middleware Tools to construct federation –Multiple devices, each with Java Virtual Machine –Multiple services.
1 CS 194: Distributed Systems Distributed Coordination-based Systems Scott Shenker and Ion Stoica Computer Science Division Department of Electrical Engineering.
Tuple Spaces and JavaSpaces CS 614 Bill McCloskey.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
490dp Prelude I: Group Membership Prelude II: Team Presentations Tuples Robert Grimm.
Java Methods By J. W. Rider. Java Methods Modularity Declaring methods –Header, signature, prototype Static Void Local variables –this Return Reentrancy.
TupleSpaces Revisited: Linda to TSpaces Ben Y. Zhao 13 July, 1998 UC Berkeley Computer Science Division.
EJB. Component Characteristics An enterprise Bean typically contains business logic that operates on the enterprise’s data. An enterprise Bean’s instances.
JavaSpaces Prabhaker Mateti Wright State University.
January 26, Jim Waldo Copyright 1999 Sun Microsystems, Inc., all rights reserved.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA , Semester 1, RMI and CORBA.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
A Look at Jini Jian He Roy Patrick Tan. Outline History Design Goals An Example Basic Components Top View Infrastructures --- Proxies, Discovery/join.
JavaSpaces and Linda Language Ghaith Haddad EEL6897 Fall 2007.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
(Business) Process Centric Exchanges
In the name of Allah The Proxy Pattern Elham moazzen.
IBM TSpaces Lab 1 Introduction. Summary TSpaces Overview Basic Definitions Basic primitive operations Reading/writing tuples in tuplespace HelloWorld.
1 Web Based Programming Section 8 James King 12 August 2003.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
1 Concurrency Architecture Types Tasks Synchronization –Semaphores –Monitors –Message Passing Concurrency in Ada Java Threads.
Client Call Back Client Call Back is useful for multiple clients to keep up to date about changes on the server Example: One auction server and several.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Distributed Systems Principles and Paradigms Chapter 12 Distributed Coordination-Based Systems 01 Introduction 02 Communication 03 Processes 04 Naming.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
We will talking about story of JAVA language. By Kristsada Songpartom.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
Li Tak Sing COMPS311F. RMI callbacks In previous example, only the client can initiate a communication with the server. The server can only response to.
JavaSpaces ™ Nati Shalom CTO GigaSpaces Technologies.
IBM TSpaces Lab 3 Transactions Event Registration.
JINI Coordination-Based System By Anthony Friel * David Kiernan * Jasper Wood.
Jini Architecture Introduction System Overview An Example.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Venkita Subramonian, Christopher Gill, Ying Huang, Marc Sentany Department of Computer Science.
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
1 Jini Transaction Part II Daniel Müller Marcel Ziswiler Seminar Informations- & Kommunikationssysteme.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
January 26, Ken Arnold Copyright 1999 Sun Microsystems, Inc., all rights reserved.
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.
Distributed and Parallel Processing George Wells.
Distribution and components
Object Spaces 9/22/2018.
Programming Models for Distributed Application
Chapter 40 Remote Method Invocation
JINI ICS 243F- Distributed Systems Middleware, Spring 2001
Distribution Infrastructures
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
Overview Multimedia: The Role of WINS in the Network Infrastructure
Java Remote Method Invocation
Corresponds with Chapter 5
Presentation transcript:

JavaSpaces TM By Stephan Roorda Source: JavaSpaces specification

Presentation Outline Review of Linda Overview of JavaSpaces In depth description of JavaSpaces Why is JavaSpaces better?

Review of Linda

Linda Basics Tuple space is Linda's name for its shared data space –A Tuple is simply a list of fields, separated by commas and enclosed in parentheses A tuple is accessed by specifying its contents –Associative memory model –There is no address associated with a tuple

Tuple Space Sender Receiver

Linda Operations There are four basic operations: –out Generates a data (passive) tuple. Each field is evaluated and put into tuple space. –in Uses a template to retrieve tuple from tuple space Once retrieved, the tuple is taken out of tuple space and is no longer If no matching tuple is found process will block. Provides for synchronization between processes.

Linda Templates Specifies tuple to retrieve –Consists of sequence of typed fields Two kinds of fields –Actuals Variables, constants or expression that resolve to constant –Formals Holders for data to retrieve Preceded by a question mark Assigned values of corresponding fields in matched tuple

Matching Templates In order for a template to match a tuple: –Have to have the same number of fields –Actuals must have same type, length and values as those in corresponding tuple fields –Formals in template must match type and length of corresponding fields in tuple If several tuples match the template, impossible to predict which will be selected The order of evaluation of fields within a tuple or template is undefined.

Linda Operations –rd Uses a template to copy data without removing it from tuple space. Once read, the tuple is still available for others. If no matching tuple is found process will block. –eval Generates process (active) tuple Control is immediately returned to invoking program –Logically, each field is evaluated concurrently, by a separate process and then placed into tuple space

Quote

Overview of JavaSpaces

Mapping Linda to JavaSpaces JavaSpace = Tuple Space entry = tuple write = out take = in read = rd

Differences between Linda and JavaSpaces Entries in Java are typed as objects –associates behavior with entries JavaSpaces allows matching of subtypes –result of having typed entries Fields in an entry are objects in Java –systems built with this are object-oriented

Differences Support for multiple JavaSpaces –transactions can span multiple threads and spaces Leasing –frees system from garbage left behind from crashes JavaSpaces does not provide eval

JavaSpaces Design Goals Provide a simple platform for designing and implementing distributed systems Thin clients –simple –quick to download –run on limited local memory

JavaSpaces Design Goals Variety of server implementations –relational databases –object oriented databases It should be possible to create a replicated JavaSpaces service

Requirements for Application Clients Must be possible to write a 100% Pure Java client Clients implementation must be independent of the implementation details of the Server

Key features of JavaSpaces Spaces are shared –handles the details of concurrent access Spaces are persistent –objects can outlive the processes that created them Spaces are associative –associative lookup is used to locate objects –this is based on content and not memory location

Key features Spaces are transactionally secure –transaction model ensures that an operation on a space is atomic –supported for one or more spaces Spaces allow us to exchange executable content –objects are passive in the space( immutable ) –when removed we can change their attributes and invoke methods on them

Entry Collection of typed objects package net.jini.core.entry; public interface Entry extends java.io.Serializable { // this interface is empty }

Example Entry import net.jini.core.entry.*; public class SpaceShip implements Entry { public Integer score; public String name; public MessageEntry() { } public SpaceShip( String n, int s ) { score = s; name = n; }

JavaSpace Interface All of the operations have to be invoked on an object that implements the JavaSpace interface Not a remote interface Exports objects that implement the JavaSpace interface locally on the client

JavaSpace Interface package net.jini.space; public interface JavaSpace { public final long NO_WAIT = 0; Lease write( Entry e, Transaction txn, long lease ) Entry read( Entry tmpl, Transaction txn, long timeout ) Entry take( Entry tmpl, Transaction txn, long timeout ) EventRegistration notify( Entry tmpl, Transaction txn, RemoteEventListener listener, long lease, MarshalledObject handback ) }

Accessing a JavaSpace Space might be registered as a Jini lookup service Space might register with an RMI registry

Operations Write Read Take Notify

write Write the given entry into this JavaSpaces service public void writeShip( SpaceShip ship ) { try { space.write( ship, null, Lease.FOREVER ); } catch( Exception e ) { e.printStackTrace(); }

read and readIfExists Read an entry from the JavaSpaces service that matches the given template Passing a null reference for the template will match any Entry Multiple read requests may return different Entry objects even if no changes are made to the space in between each

read and readIfExists public int getScore( String name ) { SpaceShip template = new SpaceShip(); template.name = name; try { SpaceShip ship = (SpaceShip)space.read( template, null, Long.Max_VALUE ); return ship.score.intValue(); } catch( Exception e ) { e.printStackTrace(); return -1; }

Silly Sample public static void main( String args[] ) { JavaSpace space = SpaceAccessor.getSpace(); SpaceGame game = new SpaceGame( space ); // create an entry SpaceShip enterprise = new SpaceShip( “enterprise”, 10 ); // demonstrate read and write game.writeShip( enterprise ); System.out.println(enterprise.name + “ written into space”); System.out.println(“The “ + enterprise.name + “’s score is “ + game.getScore(“enterprise”) ); }

take and takeIfExists Same as Read operations, except that the entry is removed from the space Will never return copies of the same Entry

take and Exceptions RemoteException - may or may not have been successful UnusableEntryException - removes the unusable entry from the space Any other exception - take did not occur and no entry was removed from the space

notify Notify a specific object when entries that match the given template are written into this JavaSpaces service A lease time is given which is how long you want the registration to be remembered by the server

Events in Java Event Source Event Object Event Listener

Distributed Events in JavaSpaces Events might have to travel from one JVM to another over a network Events may arrive: –multiple times –out of order –not at all Programmer’s responsibility to ensure correctness

Event notification in JavaSpaces

Notification Example public static void main( String args[] ) { JavaSpace space = SpaceAccessor.getSpace(); Listener listener = new Listener( space ); Message template = new Message(); space.notify(template, null, listener, Lease.FOREVER, null); Message msg = new Message(); msg.content = “Hello World”; space.write( msg, null, Lease.FOREVER ); }

Notification Example public class Listener implement RemoteEventListener { private JavaSpace space; public Listener( JavaSpace space ) throws RemoteException { this.space = space; UnicastRemoteObject.exportObject( this ); } public void notify( RemoteEvent ev ) { Message result = (Message)space.read( template, null, Long.MAX_VALUE ); System.out.println( result.content ); }

notify and Transactions Transactions can be: –null –non - null

notify and Transactions entries that are written and taken in the same transaction - before a commit - listeners will not be notified that are registered under a null transaction server retries until the notification request’s lease expires notifications may be delivered in any order

Operation Ordering operations on a space are unordered Example: if T and U are 2 threads. T performs a write and U performs a read with a template that matches the written entry, the read may not find the written entry even if the write returns before the read. The only way to guarantee this is if the threads work together and that is independent of JavaSpaces

Transactions uses net.jini.core.transaction to group operations into a bundle that act as a single transaction either all operations within the transaction complete or none do null - performs as if a transaction was created just for that operation

Benefits of JavaSpaces Simple Expressive Supports loosely coupled protocols Eases the implementation of client/server systems

Applications of JavaSpaces Any system/problem that needs a distributed solution –Human Genome project –Cryptography –Rendering –Chat program –Auction server( such as e-bay, amazon, etc )

Examples

Conclusion Simple to learn Easy to understand Map a lot of problems fairly new - not many “real-world” uses yet best implementation of Linda yet

References and Sources JavaSpaces Principles, Patterns, and Practice by Freeman, Hupfer, Arnold Official JavaSpaces specification visit for full links and bibliography