javaspaces and tspaces theresa tamash cda 5937 november 4, 2002
TRANSCRIPT
JavaSpaces and TSpaces
Theresa Tamash
CDA 5937
November 4, 2002
Outline
Challenges of Distributed Computing Solutions for Distributed Systems Linda Tuplespaces JavaSpaces TSpaces
Challenges of Distributed Computing
Latency – data takes time to get across a network. Synchronization – asynchronous processes must
have a certain degree of synchronization in order to work together.
Partial failures – a distributed system must be able to recognize a failure and be able to adapt.
Communication – processes running different operating systems may need to communicate.
Persistent data – a distributed system may need somewhere to store data, besides on one of the connected computers.
Example (communication challenge)
AIX
LINUX
WindowsPrinter
Network
How can the Windows or LINUX machines print documents?
There is a physical connection between all computers and the printer, but no logical connection.
Example (auction service)
Seller
BidderBidder
Bidder
Server
• Bids may take different amounts of time to reach the server. Which bid came in first? (latency)
• Item must be stored on the server. (persistent data)
• What if the Seller or winning bidder are not connected to the network when bidding ends? (synchronization / partial failures)
Solution - Middleware
Process A
Process C
Process B
Middleware
• The middleware facilitates communication between the different processes.
• The middleware should be responsible for providing solutions to the problems listed earlier.
Middleware Solutions
JavaSpaces and TSpaces Designed to overcome the challenges of
distributed systems. Based on the Linda tuplespace system. Implemented in Java to be platform
independent.
Linda
Developed to be a communication buffer for parallel processing systems. Anonymous communication Associative addressing / pattern matching Persistent data Simple syntax Portable (supports heterogeneous networks) Uses tuplespaces
Tuplespace
Stores groups of tuples. Globally accessible memory space (probably
on a network).
Space
Tuple – A group of fields with associated values. Basically an object.{temperature=75; windspeed=10; windunits=knots}
Process Process
Put tuple Take tuple
JavaSpaces
A shared, network accessible repository for objects (tuplespace).
Based on the tuplespace model of Linda. Objects are exchanged only through interaction
with the space. Provides simple operations: read, write, take,
notify.
JavaSpaces Key Features
Shared – spaces provide concurrent access for many processes.
Persistent data – spaces store objects until they expire or are removed.
Associative lookup – spaces lookup objects based on their content rather than a name or memory address.
Continued
JavaSpaces Key Features cont.
Transactionally Secure – spaces ensure that operations are atomic (either applied or not).
Executable Content Sharing – spaces store objects, which have methods that can be executed once an object is read or taken from a space.
Anonymous communication – spaces don’t care who the sender or receiver is.
JavaSpace “Hello World”
public class Message implements Entry {public String content;public Message() { }
}
Message msg = new Message();Msg.content = “Hello World”;JavaSpace space = SpaceAccessor.getSpace();Space.write(msg, null, Lease.FOREVER);
Write entry
JavaSpace
Entry
JavaSpace “Hello World” cont.
Use pattern matching to get desired objects from the space.
null values represent wildcards.
A Message object with the content field set to null will return any message object.
A Message object with the content field set to “Go Team!” will only return a message object with the content set to that value.
JavaSpace “Hello World” cont.
Message template = new Message(); //Content is nullMessage result = (Message)space.read(
template, null, Long.MAX_VALUE);System.out.println(result.content);
“Hello World”
JavaSpace
Read entry
EntryIf we had used space.take instead, the Entry object would no longer be in the space.
JavaSpaces Solution
Printer space
1. Windows machine writes a printerDocument object to the space.
2. AIX machine is notified when any printerDocument object is written to the space. He takes them upon notification.
3. AIX machine sends the document to the printer to print.
The Java Virtual Machines (JVM) enable communication between the two different operating systems through the JavaSpace.
AIX JVM WindowsJVM
TSpaces
Similar to JavaSpaces Based on Linda Implemented in Java for platform
independence. Tuples are exchanged through the space. Provides simple operations; read, write, take:
as well as more complex operations and database functionality.
TSpaces Key Features
Standard set of tuplespace operators – read and in (both in blocking and non-blocking), out, scan.
Dynamically defined datatypes and operators – New datatypes and operators can be defined and downloaded to the TSpaces server and used immediately.
Persistent data – relational database features.Continued
TSpaces Key Features cont.
Database indexing and querying – Provides capability for efficient and powerful data retrieval.
Access Control – Configurable security settings.
Event Notification – Processes can register to be notified of events.
TSpace Tuple
<2.24, “Hello World”, 345>
This is a tuple with 3 fields:
1. Float with value 2.24
2. String with value “Hello World”
3. Integer with value 345
TSpace Tuple Matching
<2.24, “Hello World”, 345>
Template 1: <float, “Hello World”, int> Template 2: <float, string, 345.0>
Both templates use formal fields. By putting the datatype in the template and not specifying a value, the template will match tuples with that datatype in that field.
TSpaces Solution
Seller
BidderBidder
Bidder
TSpaceItem
Item
Item
Seller writes Item tuple to space.
Bidders can register to receive notification when certain types of Items (pink?) are written to the space.
Bidders can take an Item from a space, update the bid, then write it back.
Bidders can query the group of Item tuples to find ones that interest them.
Seller registers to be notified when bidding ends on their Item.
JavaSpaces vs. TSpaces
Serializable objects
Multiple spaces
Simple operators
Simple types and objects
Single space
Simple operators and database functionality
References
Freeman, E., Hupfer, S., Arnold, K. (1999). JavaSpaces Principles, Patterns, and Practice: Chapter 1. http://developer.java.sun.com/developer/Books/JavaSpaces/introduction.html
Hupfer, Susanne (2000). The Nuts and Bolts of Compiling and Running JavaSpaces Programs.http://developer.java.sun.com/developer/technicalArticles/jini/javaspaces
Continued
References
(2000) JavaSpaces Service Specification v1.1.
http://wwws.sun.com/software/jini/specs/js1_1.pdf TSpaces Intelligent Connectionware.
http://www.almaden.ibm.com/cs/TSpaces/whatdo.html Wyckoff (1998). T Spaces
http://www.research.ibm.com/journal/sj/373/wyckoff.html