Chair of Software Engineering Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts Amherst Operating Systems CMPSCI 377 Lecture.
15-May-15 RMI Remote Method Invocation. 2 “The network is the computer” Consider the following program organization: If the network is the computer, we.
GridRPC Sources / Credits: IRISA/IFSIC IRISA/INRIA Thierry Priol et. al papers.
Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
Remote Method Invocation
Remote Object Invocation Tran, Van Hoai Department of Systems & Networking Faculty of Computer Science & Engineering HCMC University of Technology.
The road to reliable, autonomous distributed systems
Objektorienteret Middleware Presentation 2: Distributed Systems – A brush up, and relations to Middleware, Heterogeneity & Transparency.
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.
DISTRIBUTED FILE SYSTEM USING RMI
Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Software Engineering and Middleware: a Roadmap by Wolfgang Emmerich Ebru Dincel Sahitya Gupta.
CSE331: Introduction to Networks and Security Lecture 11 Fall 2002.
Scripting Languages For Virtual Worlds. Outline Necessary Features Classes, Prototypes, and Mixins Static vs. Dynamic Typing Concurrency Versioning Distribution.
Introduction to Remote Method Invocation (RMI)
Practical Issues of RPCCS-4513, D-Term Remote Procedure Call Practical Issues CS-4513 Distributed Computing Systems (Slides include materials from.
Communication in Distributed Systems –Part 2
Chapter 2 Architectural Models. Keywords Middleware Interface vs. implementation Client-server models OOP.
Common Object Request Broker Architecture (CORBA) CS-328.
1 Java Programming II Java Network II (Distributed Objects in Java)
Chapter 6 Operating System Support. This chapter describes how middleware is supported by the operating system facilities at the nodes of a distributed.
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.
15 - RMI. Java RMI Architecture Example Deployment RMI is a part of J2SE (standard edition), but is used by J2EE) A J2EE server is not nessesary for using.
Information Management NTU Interprocess Communication and Middleware.
11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors.
Introduction to Distributed Systems Slides for CSCI 3171 Lectures E. W. Grundke.
Architectures of distributed systems Fundamental Models
Java RMI: Remote Method Invocation January 2000 Nancy McCracken Syracuse University.
1 Introduction to Middleware. 2 Outline What is middleware? Purpose and origin Why use it? What Middleware does? Technical details Middleware services.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Advanced Computer Networks Topic 2: Characterization of Distributed Systems.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
DISTRIBUTED COMPUTING. Computing? Computing is usually defined as the activity of using and improving computer technology, computer hardware and software.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
Remote Method Invocation A Client Server Approach.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Java RMI. RMI Any object whose methods can be invoked from another Java VM is called a remote object.
1 RMI Russell Johnston Communications II. 2 What is RMI? Remote Method Invocation.
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
Netprog Java RMI1 Remote Method Invocation.
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.
Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
January 26, Ann Wollrath Copyright 1999 Sun Microsystems, Inc., all rights reserved. Java ™ RMI Overview Ann Wollrath Senior Staff Engineer Sun Microsystems,
Java Distributed Object System
What is RMI? Remote Method Invocation
Remote Method Invocation
Advanced Operating Systems
Mobile Agents.
Chapter 40 Remote Method Invocation
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
Java Remote Method Invocation
Presentation transcript:

Chair of Software Engineering Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan

Chair of Software Engineering 2 Lecture 1: Essential Definitions and Overview

Chair of Software Engineering 3 Multi-Programming  Only one physical node.  A running program is called a task (sometimes process).  Tasks are totally independent from one another.  This defines the notion of “parallelism” (but not of parallel programming!).

Chair of Software Engineering 4 Concurrent Programming  But there is an Operating System!  The operating system occupies part of the memory.  Tasks can execute OS code (through system calls or interruptions).  The OS code may modify the OS memory.  Tasks can thus interfere with each other.

Chair of Software Engineering 5 Multi-Threaded Programming  Several tasks (threads) created by some program.  Primary objective: reduce the time needed for context-switching.  “light” processes that share variables.

Chair of Software Engineering 6 Parallel Programming ( also!)  At any moment, tasks are running!  The memory will usually provide atomic r/w operations.  There can be a global clock (“tightly coupled” systems).  Different architectures (MIMD, SIMD) and memory consistency models…  Different granularities (instruction, function, program).

Chair of Software Engineering 7 Distributed Programming  Tasks can interfere through the network.  Transmitted data is copied to/from the OS memory.  The node is the unit of failure.  No global clock.  “loosely coupled” systems.  Very different networks can be used.

Chair of Software Engineering 8 Interference in  Consider parallel programming or concurrent programming with preemptive scheduling.  Parallel read and write operations will be interleaved!  Possible executions: {(x=2,y=2),(x=2,y=3), (x=3,y=2)}  Combinatorial explosion of the number of possible results when the number of parallel processes increases!  Reasoning is difficult. x := 1 y := 1 Cobegin x := y + 1 || y := x + 1 Coend

Chair of Software Engineering 9 Interference in  The notation is inspired by Hoare’s CSP.  In P, the value of x can be either 1 or 2.  The choice is nondeterministic!  One of the sending processes may never execute. channel c, d Cobegin c!1 || d!2 || c?x.P + d?x.P Coend Q c!1 || d!2 || Q d!2 || P[x:=1] c?! c!1 || P[x:=2] d?!

Chair of Software Engineering 10 Some Additional Issues in  Naming  Heterogeneity  Partial failures  Load balancing  Migration  Security  Scalability

Chair of Software Engineering 11 and : Why bother?  Efficiency:  multiplexing access to hardware resources,  highly demanding computation (clusters),  scalability and cost-efficiency.  Reliability through replication (back-up systems)  Necessity:  Distributed nature of (embedded) systems,  Providing services to distant clients.

Chair of Software Engineering 12 Interaction paradigms for and  Data-centric:  access to memory that is shared among tasks,  tasks have to synchronize to avoid interferences.  Communication-centric:  no sharing of memory,  processes communicate by sending messages or calling routines (procedure, functions).  Interference is avoided by:  client coordination (empty messages) or  supplier capacity to select incoming messages.  Coordination-centric (tuple spaces as in Linda).

Chair of Software Engineering 13 Avoiding interferences in and  In the data-centric approach:  tasks have to synchronize.  In the communication-centric approach:  client have to coordinate (by sending empty messages for example), or  the supplier has to select incoming messages.  Coordination-centric: “loose” coordination.

Chair of Software Engineering 14 Object-Oriented Programming  Object-based programming provides:  encapsulation of data (information hiding),  well defined interface for operations (ADT),  identity.  Class-based programming provides:  An abstraction and classification mechanism,  Code reuse through composition and inheritance.  Contracts (if you’re lucky).

Chair of Software Engineering 15 They seem very different! (even dealing with orthogonal concerns) but Robin Milner said: "I can't understand why objects [of O-O languages] are not concurrent in the first place". (Cited in [Matsuoka 1993].) Blending O-O, and (1)

Chair of Software Engineering 16 Why did Robin Milner say that?  Identifying concepts:  Object with task, as  both (appear to) encapsulate data,  both have an autonomous behavior,  both are computational structures created at run-time.  Routine invocation with message passing.

Chair of Software Engineering 17 But…  With an after-look, this comparison seems rather deceptive, and overly simplifying.  Variable sharing versus encapsulation?  What about inheritance and composition?  What about garbage collection?  Most of the O-O language mechanisms serve purposes that do concern neither nor.

Chair of Software Engineering 18 So… why should you follow this class?  Concurrent and distributed programming is commonly done with objects.  Many languages: almost any O-O language or platform has concurrent/distributed features.  Ada 95, Java/RMI, Corba, C# and.NET…

Chair of Software Engineering 19 Purpose of the Class  Introduce the students to the diversity of and O-O languages, those of today and those of tomorrow.  Relate those languages to one another.  Provide formal description tools to explore the foundational issues.  Show how to reason about and (O-O) programs.  Some parts will be quite practical, other more research-oriented.

Chair of Software Engineering 20 Overview of Approaches and Platforms for and Programming

Chair of Software Engineering 21 Distributed Applications  Cluster/Grid computing (scientific computing)  Ubiquitous computing (embedded systems)  Client/server (the web)  Peer-to-peer (large data exchange systems)  Collaborating mobile agents (data retrieval)  Others…

Chair of Software Engineering 22 Possible Attitudes  Towards the following problems:  Naming of Resources,  Heterogeneity,  Partial failures,  Load balancing,  Migration, and  Security,  One can, when devising a programming language:  Ignore the problem,  Introduce primitives to address it, or  Provide complete transparency (solve it).

Chair of Software Engineering 23 Language approaches to and  The integrative approach  The library approach  The reflective approach These approaches can be combined! defined by [Briot et al. 98]

Chair of Software Engineering 24 The Library Approach  The most common way.  Provides an API to the programmer.  Wraps “native” code (e.g. system calls).  Use through inheritance or composition.  Approach of choice for middleware, agent platforms, messaging systems, etc.

Chair of Software Engineering 25 The Integrative Approach  Identify concepts found in the language with external ones.  Introduce new (syntactic) constructions.  It is the simplest approach.  It leads to cleaner code.  But it can’t address everything! (increase in language complexity)  limitations: inheritance anomaly, etc.  Difficult to modify a language (compilers, etc.)

Chair of Software Engineering 26 Example: Java  Possibility to create (concurrent) threads and to synchronize.  Each object has an exclusive locking facility  Creation of a thread by inheriting from Thread.  wait, notify, notifyall are methods containing native code.  synchronized is a key word.  A method is identified with a monitor entry point. class Barrier { int num_waiting = 1 … public synchronized void join () { if (num_waiting < 3) { num_waiting += 1; wait (); } else notifyall (); } class Client inherits Thread { Barrier b = new Barrier() … public void run () { … //joining the barrier b.join (); …// all clients have joined }

Chair of Software Engineering 27 Execution of the previous example  Each thread has its own stack of calls.  Objects do not belong to threads!  Which thread is awoken by a notifyall is not specified  Limited to (one CPU).

Chair of Software Engineering 28  Threading primitives are clearly insufficient.  Example solutions relying on other libraries:  Networking sockets,  Java/RMI and Corba,  Active objects and ProActive,  Jini and JavaSpaces (based on Linda). The case for Java

Chair of Software Engineering 29 Java/RMI  Provides a communication (RPC) layer.  Compatible with Corba (IIOP in javax.rmi)  Its interface:  a stub/skeleton generator (rmic)  a naming service (object registry)

Chair of Software Engineering 30 Java/RMI step 1: Write an Interface import java.rmi.*; public interface HelloInterface extends Remote { /* return the message of the remote object, such as "Hello, world!". exception RemoteException if the remote invocation fails. */ public String say() throws RemoteException; }  String is serializable (it can be marshaled)

Chair of Software Engineering 31 Java/RMI step 2: Write a Server import java.rmi.*; import java.rmi.server. class Hello extends UnicastRemoteObject implements HelloInterface { private String message; public Hello (String msg) throws RemoteException { message = msg; } public String say() throws RemoteException { return message; } }  Inherits from UnicastRemoteObject.  “rmic Hello” will generate stub and skeleton.  in main() method to register: Naming.rebind ("Hello", new Hello ("Hello, world!"));

Chair of Software Engineering 32 Java/RMI step 3: Write a Client import java.rmi.*; public static void main (String[] argv) { try { HelloInterface hello = (HelloInterface) Naming.lookup ("//se.inf.ethz/Hello"); System.out.println (hello.say()); } catch (Exception e) { System.out.println ("HelloClient exception: " + e); }  Uses the lookup function of the naming service.  The remote object is accessed via a proxy (a.k.a. object handle, surrogate)  type “rmiregistry” on the command line to start it.

Chair of Software Engineering 33 The Reflective Approach  Using reflection:  is equivalent to modifying the interpretation machine,  allows to go from program to data, and back (thunks).  Certain languages (Scheme, Smalltalk) provide such capability.  In O-O: use reflection to intercept method calls (reification).  Re-routed may allow support for migration, replication, fault tolerance, etc. as a meta-program (MOP)  It is often combined with the library approach.  The code is often elegant.  The execution is often inefficient.  Orthogonal to re-usability.

Chair of Software Engineering 34 Example: ProActive  Objects can be active or passive.  Communication is:  point-to-point, and  asynchronous (non-blocking send),  respecting a Call-by-value policy.  Active objects have a body, that describe what messages they can receive (as in actors).  There are No shared passive object.

Chair of Software Engineering 35 ProActive step 1: Write a Server import java.net.*; import org.objectweb.proactive; public class Hello /* DOES NOT INHERIT FROM ANYTHING */{ private String name; // two constructors… public String sayHello() { return “Hello World” } public static void main(String[] args) { try { Hello hello = (Hello) ProActive.newActive(Hello.class.getName(), new Object[]{"remote"}); InetAddress localhost = InetAddress.getLocalHost(); ProActive.register(hello, "//" + localhost.getHostName()+"/Hello"); } catch (Exception e) {/* error … } }

Chair of Software Engineering 36 ProActive step 2: Write a Client import java.net.*; import org.objectweb.proactive; public class HelloClient { public static void main(String[] args) { Hello myServer; // !!! String message; try { if (args.length == 0) {// if there is no url to the server… } else { myServer = (Hello)ProActive.lookupActive(Hello.class.getName(), args[0]); } message = myServer.sayHello(); System.out.println("The message is : " + message); } catch (Exception e) { // error…. }

Chair of Software Engineering 37 Architecture and Benefits  The architecture uses RMI as underlying communication mechanism.  The Stub_B reifies calls, BodyProxy deals with asynchrony, Body does the effective calls.  Almost transparent to location (better than RMI).  Supports migration.  Limitations (final methods).

Chair of Software Engineering 38 Jini and JavaSpaces  Linda primitives:  objects read and write “tuples” into a shared space.  Communication is not directed.  write (t: Tuple) writes into the space.  Tuple read (p: Pattern) is blocking.  Tuple take (p: Pattern) is blocking and deleting.  JavaSpaces adds:  non-blocking variants of the primitives,  transactions,  a leasing mechanism.

Chair of Software Engineering 39 Other approaches to synchronization  Group communication (multicast, broadcast).  Message-Oriented Middleware (MOM).  Component-based development (standardized interfaces such as COM or Enterprise Java Beans).  All can be encoded using more elementary interaction patterns.

Chair of Software Engineering 40 Conclusion  Many ways to tackle the same problem!  More features can be added.  Many other criteria of classification. To be continued…