Tuple spaces and Object spaces. Distributed Object Systems 12. Tuple spaces and Object spaces. Communication. Tuple space. Mechanisms 2.



Similar documents
Mobile Devices: Server and Management Lesson 05 Service Discovery

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Jini an Infrastructure for Dynamic Service Networks

Resurrecting Ada s Rendez-Vous in Java

Lecture 7: Java RMI. CS178: Programming Parallel and Distributed Systems. February 14, 2001 Steven P. Reiss

Remote Method Invocation in JAVA

Jini. Kurzfassung als Kapitel für die Vorlesung Verteilte Systeme. (unter Nutzung von Teilen von Andreas Zeidler und Roger Kehr)

Mobile agents for the database management using Jini

Monitors, Java, Threads and Processes

Remote Method Invocation

HelenOS IPC and Behavior Protocols

Outline of this lecture G52CON: Concepts of Concurrency

Network Communication

Infrastructure that supports (distributed) componentbased application development

Components for Operating System Design

Chapter 2: Processes, Threads, and Agents

Clustering with Tomcat. Introduction. O'Reilly Network: Clustering with Tomcat. by Shyam Kumar Doddavula 07/17/2002

Real Time Programming: Concepts

UI Performance Monitoring

COMMMUNICATING COOPERATING PROCESSES

CGI Vs. Java - Which is Better For Marketing

Division of Informatics, University of Edinburgh

Design Patterns in C++

Java Memory Model: Content

HYBRID JINI FOR LIMITED DEVICES

Last Class: Semaphores

Programmation RMI Sécurisée

Lecture 6: Semaphores and Monitors

Mutual Exclusion using Monitors

Jini Technology Applied to Railway Systems

Event-based middleware services

Chapter 6, The Operating System Machine Level

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

Replication on Virtual Machines

STORM. Simulation TOol for Real-time Multiprocessor scheduling. Designer Guide V3.3.1 September 2009

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

How To Write A Network Operating System For A Network (Networking) System (Netware)

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Corba. Corba services. The (very) global picture. Corba. Distributed Object Systems 3 CORBA/IDL. Corba. Features. Services


Getting Started with the Internet Communications Engine

Moving from CS 61A Scheme to CS 61B Java

IMPLEMENTATION OF AN AGENT MONITORING SYSTEM IN A JINI ENVIRONMENT WITH RESTRICTED USER ACCESS

Report of the case study in Sistemi Distribuiti A simple Java RMI application

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Monday, April 8, 13. Creating Successful Magento ERP Integrations

Parallel Programming

Programming Languages CIS 443

A Case Study of an Android* Client App Using Cloud-Based Alert Service

PostgreSQL Functions By Example

1. What are Data Structures? Introduction to Data Structures. 2. What will we Study? CITS2200 Data Structures and Algorithms

Ambient-oriented Programming & AmbientTalk

Remote Method Invocation (RMI)

When the transport layer tries to establish a connection with the server, it is blocked by the firewall. When this happens, the RMI transport layer

Deadlock Victim. dimanche 6 mai 12

Middleware. Peter Marwedel TU Dortmund, Informatik 12 Germany. technische universität dortmund. fakultät für informatik informatik 12

Monitor Object. An Object Behavioral Pattern for Concurrent Programming. Douglas C. Schmidt

MIDDLEWARE 1. Figure 1: Middleware Layer in Context

Creating a Simple, Multithreaded Chat System with Java

CHAPTER 2 MODELLING FOR DISTRIBUTED NETWORK SYSTEMS: THE CLIENT- SERVER MODEL

! "# $%&'( ) * ).) "%&' 1* ( %&' ! "%&'2 (! ""$ 1! ""3($

Mapping of Services on Bluetooth Radio Networks

The Service Revolution software engineering without programming languages

A Dynamic, Runtime-Extensible, Client-Managed Service Framework

Concurrent Programming

Linux Driver Devices. Why, When, Which, How?

SOFT 437. Software Performance Analysis. Ch 5:Web Applications and Other Distributed Systems

What is COM/DCOM. Distributed Object Systems 4 COM/DCOM. COM vs Corba 1. COM vs. Corba 2. Multiple inheritance vs multiple interfaces

Security System for Patient DB

XII. Distributed Systems and Middleware. Laurea Triennale in Informatica Corso di Ingegneria del Software I A.A. 2006/2007 Andrea Polini

Monitor-Konzepte. nach Brinch Hansen. Konzepte von Betriebssystem-Komponenten: Konkurrenz und Koordinierung in Manycore-Systemen.

Middleware Lou Somers

Massachusetts Institute of Technology 6.005: Elements of Software Construction Fall 2011 Quiz 2 November 21, 2011 SOLUTIONS.

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Concurrent Programming

SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (I)

Chapter 2: Remote Procedure Call (RPC)

! Past few lectures: Ø Locks: provide mutual exclusion Ø Condition variables: provide conditional synchronization

Java Interview Questions and Answers

Integrating VoltDB with Hadoop

The ConTract Model. Helmut Wächter, Andreas Reuter. November 9, 1999

Semaphores and Monitors: High-level Synchronization Constructs

Manual. Programmer's Guide for Java API

How To Understand The Concept Of A Distributed System

Glossary of Object Oriented Terms

Tutorial on Writing Modular Programs in Scala

Atomicity for Concurrent Programs Outsourcing Report. By Khilan Gudka Supervisor: Susan Eisenbach

: provid.ir

Multi-core Programming System Overview

AP Computer Science Java Subset

Realizing Enterprise Integration Patterns in WebSphere

Smalltalk in Enterprise Applications. ESUG Conference 2010 Barcelona

To Java SE 8, and Beyond (Plan B)

JGroups: : a Java system for communicating with a group of machines

A Comparison Of Shared Memory Parallel Programming Models. Jace A Mogill David Haglin

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

How To Use A Com In A Microsoft Com 2.5 (Dsi) (Dsi) (For Microsoft) (Com) (Sib) (Operations) (Orchestra) (Ahem) (I

3C03 Concurrency: Condition Synchronisation

Tutorial: Getting Started

Chapter 1 Fundamentals of Java Programming

Transcription:

Distributed Object Systems 12 Tuple spaces and Object spaces Tuple spaces and Object spaces Tuple spaces Shared memory as a mechanism for exchanging data in a distributed setting (i.e. separate from processes) Contents What is it? Principles of tuple spaces Comparison with other mechanisms JavaSpaces/Jini as OO variant Piet van Oostrum Oct 21, 2008 Piet van Oostrum 1 Tuple space Tuple Ordered sequence of (typed) values Usually it has a name (first element) Tuple space Bag of tuples Identical tuples may be present multiple times Tuple space is associative memory i.e. search on contents only, not on identity Linda program Works on collection of ordered tuples Tuple contains data (or possibly code) Consists of a number of cooperating processes or threads Only communication is by putting tuples in and getting tuples out of tuple space Linda is an abstract concept (ideas) Communication A B puts tuple in tuple space tuple tuple Tuple Space withdraws tuple from tuple space No direct communication between A and B Piet van Oostrum 2 Piet van Oostrum 3 Mechanisms 1 Putting Mechanisms 2 Withdrawing out( N, P2,..., Pj ) ; out statement puts a tuple in tuple space Continues immediately First parameter is a name (string) Instead of values also formals in the form i: integer may be given This is an unspecified but typed part of the tuple (wildcard) in( N, P2,..., Pj ) ; Reading in statement withdraws a tuple from tuple space Parameter is a template: contains values and typed variables Matching based on value parts Blocks until matching tuple is available Variables are filled with tuple values Tuple is removed from tuple space read( N, P2,..., Pj ) ; read statement same as in But does not remove tuple from tuple space Piet van Oostrum 4 Piet van Oostrum 5 slides12.pdf October 21, 2008 1

Properties Pattern matching in( P, i:integer, j:integer ) Matches (+withdraws) tuple with name "P" and any integer value on the rest in( P, i:integer, FALSE ) Matches (+withdraws) tuple with name "P", any integer value in second place and FALSE in third place Tuples with wildcards match any actual value in in statement Compare with Prolog: binding of free variables System characteristics Nondeterminism Which process succeeds in() s or read() s Which tuple you get when there are more matches Atomicity Of insertion and withdrawing Sender and receiver do not know each other Distribution in space Shared memory alike Distribution in time Mailbox alike: once put, stays forever until withdrawn No explicit synchronisation Communication possible after sender dies Semantics is independent from timing (modulo nondeterminism) Piet van Oostrum 6 Piet van Oostrum 7 Process notation 1 Simple statement in() out() read() Compound statement Process notation 2 Combinations Sequence s1 ; s2 ;... ; sj Concurrency (and parallellism): All s i run parallel [... s1 & s2 &... & sj Mutual exclusive concurrency (or parallellism): Only one of the s i will run (one that is ready) non-deterministically Blocking in or read will not be chosen If all s i block then the whole statement blocks s1 s2... sj Piet van Oostrum 8 Piet van Oostrum 9 Process notation 3 Repetition *s Input and action syntactic sugar *[in( -t ) ; s in( -t ) => s Macro def SYNCH_SEND(s:tuple) [... Small examples Remote procedure equivalent Client side out( P, me,... ) in( me,... ) Server side in( P, who:name,... ) => [ body ; out( who,... ) me is replaced by unique process identification How to do Remote Method Invocation (RMI)? Piet van Oostrum 10 Piet van Oostrum 11 slides12.pdf October 21, 2008 2

Semaphore equivalent P(sem) in( sem ) V(sem) out( sem ) Explicit synchronisation Rendez-vous style of communication Communication style in Ada programming language client does procname(p1, p2,...) server does accept procname(p1, p2,...) do statements end parameters p1, p2,... may be in or out client and server wait until they are both ready before data transfer both client and server continue only after exchange of data completed and accept body executed Simplified emulation (if only one pair of communicating processes): def SYNCH_SEND(s:tuple) [ in(get); out(s); in(got) def SYNCH_RECV(s:tuple) [ out(get); in(s); out(got) Piet van Oostrum 12 Piet van Oostrum 13 Disk head scheduler Active monitor, filtering/sorting requests Note: A B means messages go from A to B through tuple space, not direct communication. Disk head scheduler Continued Server side DISK_FILTER & DISK Client side DISK_FILTER def DISK_SVC( t:track; d:data ) [ out( disk_req, me, t, d ) ; in( me ) DISK def DISK * [ out( get_diskreq ) ; in( disk_driver, who:name, i:track, d:data ) ; perform physical i/o ; out( who ) Piet van Oostrum 14 Piet van Oostrum 15 Disk head scheduler Continued Disk head scheduler Continued def DISK_FILTER DECLARATIONS & *[DISK_ENQUEUE DISK_DEQUEUE def DECLARATIONS disk_idle:boolean = false & other necessary data structures def DISK_ENQUEUE [ in( disk_req, who:name, i:track, d:data ) ; if ( disk_idle ) [ out( disk_driver, who, i, d ) ; disk_idle = false else insert who, i, d in i/o queue def DISK_DEQUEUE [ in( get_diskrequest ) ; who:name, i:track, d:data & [ if queue is empty disk_idle = true else [ who, i, d = get and remove from queue ; out( disk_driver, who, i, d ) ; Piet van Oostrum 16 Piet van Oostrum 17 slides12.pdf October 21, 2008 3

Linda implementation All the tricky stuff is hidden in an implementation Absence of shared memory Naming How to find tuples? Where to keep tuples? in( xx,... ) Implies naming system able to look for data named xx Naming system: distributed directory/database Linda implementation Tuple location Tuple availability (via out()) or tuple need (via in()) must be known everywhere Either broadcast when information is available Or ask (everywhere) for it Or in between Other issues Buffering (of many out() s) Failure, transaction problems Piet van Oostrum 18 Piet van Oostrum 19 Linda extensions 1 Non-blocking operations Original Linda had a non-blocking in, called inp In case there is no matching tuple this returns a not-found indication. Was thought to be nice to prevent eternally blocking processes This makes Linda programs time-dependent, however Similar for read Definitions of inp and rdp where ambiguous Other interpretation inp blocks until a tuple is available or it can be proven that there will never be one (a deadlock occurs) In case of a deadlock one participant will receive a failure this can only be done if all Linda processes are known This interpretation tries to remove the time-dependency Linda extensions 2 Multiple Tuple Spaces Good for modularity Tuples spaces in tuples (recursion) Nested tuplespaces Flat tuplespaces Piet van Oostrum 20 Piet van Oostrum 21 Linda extensions 3 Bulk Tuple Operations The multiple read problem is the problem that you can t reliably do a read for a collection of tuples. You might get the same tuple multiple times So you must use in multiple times And then put back the tuples You can t do it atomically Solution: bulk operations: collect (T1, T2, template): moves all tuples that match template from tuple space T1 to tuple space T1 copy-collect (T1, T2, template) makes a copy PyLinda A Linda(-like) system written in Python Multiple tuple spaces Tuple spaces live in servers Servers connect to a master server inp and rdp extensions with deadlock detection bulk operations # start the master server > linda_server # start server connected to server at <ip-address> > linda_server -c <ip-address> A Linda master server has a main tuple space called universe. Piet van Oostrum 22 Piet van Oostrum 23 slides12.pdf October 21, 2008 4

PyLinda Client: import linda linda.connect() linda.universe._out((1, 2, 3)) linda.universe._in((1, 2, int)) Template wild cards are given by a type instead of a value. The _in returns a tuple. PyLinda # create a new tuple space # and put it in the universe ts = linda.tuplespace() linda.universe._out(("my Space", ts)) ts._out((4, 5, "piet")) ts2 = linda.tuplespace() ts.collect(ts2, (int, int, int)) x = ts2._in((int,int,int)) Piet van Oostrum 24 Piet van Oostrum 25 JavaSpaces Tuple Space + Java On top of Serialization + RMI Events & Transactions Differences w.r.t. Linda Multiple spaces Tuple: class Entry, typed, fields may be objects Matching via templates (with wildcards) Notification mechanism for availability of tuple (instead of blocking read) Transaction properties Identity mechanism for security JavaSpaces Overview Piet van Oostrum 26 Piet van Oostrum 27 JavaSpaces Usage Writing (out) JavaSpace space = getspace(); AttrEntry e = new AttrEntry(); e.name = "DOS"; e.value = new GIFImage("DOSexample.gif"); EntryRep erep = e.rep(); // or new EntryRep(e) space.write(erep, null, null); JavaSpaces Usage Taking (in) JavaSpace space = getspace(); AttrEntry e = new AttrEntry(); e.name = "DOS"; e.value = null ; // wildcard EntryRep erep = e.rep(); space.take(erep, null, null); Tuple = Entry, out = write AttrEntry is subclass of jive.javaspace.entry Match implies class equality Entry is packaged into EntryRep before handing it over to a space in = take null value means wildcard Parameters for transaction & identification Piet van Oostrum 28 Piet van Oostrum 29 slides12.pdf October 21, 2008 5

Jini 1 Purpose: allow groups of services and users to federate into a single, dynamic distributed system (Jini community) Goals Simplicity of access Ease of administration Support for easy sharing spontaneous interactions Self-healing of Jini communities Main operations Discovery: find a lookup service Join: register your service with a lookup service Lookup: find a service in the lookup service Done by type: Java interface type Local object (like CORBA proxy/stub) returned to client Invoke: use the local object to call the service Jini Lookup Service is running on the network Piet van Oostrum 30 Piet van Oostrum 31 Device is plugged into the network Device registers service(s) Class to use the service is copied to the Lookup Service Two devices have been registered There UI classes have been copied to the Lookup Service Piet van Oostrum 32 Piet van Oostrum 33 A new device is plugged into the network It wants to use one of the services It loads the UI class(es) from the Lookup Service Jini Example Start: one service lookup running on network Printer starts up Finds lookup service Registers self with lookup service (no user intervention) Laptop with word processor enters room Word processor finds lookup service Word processer looks up printer Word processor can also optionally Register to get callback if printer goes away Register to get callback if a new printer registers itself Word processor invokes printer (sends it a printer job) Printer (not word processor) controls dialog box only it knows what it should look like, perhaps in ways not known when word processor made Piet van Oostrum 34 Piet van Oostrum 35 slides12.pdf October 21, 2008 6

Jini code example (Client) Jini code example (Server) import net.jini.core.entry.*; import net.jini.core.lookup.*; // etc. try { System.setSecurityManager(new RMISecurityManager()); lookup = new LookupLocator("jini://localhost"); registrar = lookup.getregistrar(); // Lookup Service id = registrar.getserviceid(); aeattr = new Entry[1; aeattr[0 = new Name("MyServer"); // First 2 params: ServiceID (UUID) and class (servicetypes). template = new ServiceTemplate(null, null, aeattr); myserverinterface = (MyServerInterface) registrar.lookup(template); public class MyServer extends UnicastRemoteObject implements MyServerInterface, ServiceIDListener { public String sayhello() throws RemoteException { return ("Hello World from MyServer!"); public static void main(string[ args) { int i; MyServer myserver; Entry[ aeattr; JoinManager joinmanager; if (myserverinterface instanceof MyServerInterface) {... myserverinterface.sayhello()... Piet van Oostrum 36 Piet van Oostrum 37 Jini code example (Server) contd. Jini facilities Leasing: automatic garbage collection try { System.setSecurityManager(new RMISecurityManager()); aeattr = new Entry[1; aeattr[0 = new Name("MyServer"); myserver = new MyServer(); joinmanager = new JoinManager(myServer, aeattr, myserver, new LeaseRenewalManager()); // Third parameter is a ServiceID or ServiceIDListener... catch (Exception e) Service granted for a limited period of time: a lease If lease not renewed (it expires), resources freed Transactions Two-phase commit Note: Jini, and JavaSpaces are not databases Jini (JavaSpaces) supports full transactions (two-phase commit) Events Can register for callbacks for events of interest Piet van Oostrum 38 Piet van Oostrum 39 References David Gelernter, Generative Communication in Linda. ACM TOPLAS 7(1), Jan 1985, pg 80-112 The S/Net s Linda Kernel. Nicholas Carriero and David Gelernter, ACM TOCS 4(2), May 1986, pg 110-129 Linda Bibliography, http://www.cs.yale.edu/html/yale/cs/linda Javaspaces http://java.sun.com/docs/books/jini/javaspaces/ Jim Waldo, The Jini Architecture for Network-centric computing. Comm. of the ACM, July 1999, vol 42, no. 7, pg 76-82 Piet van Oostrum 40 slides12.pdf October 21, 2008 7