Communication and Distributed Processing

Similar documents
Communication and Distributed Processing

Chapter 4 Remote Procedure Calls and Distributed Transactions

Outline. Chapter 4 Remote Procedure Calls and Distributed Transactions. Remote Procedure Call. Distributed Transaction Processing.

JAVA RMI. Remote Method Invocation

Remote Procedure Call

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)

Outline. Chapter 5 Application Server Middleware WS 2010/11 1. Types of application server middleware

Remote Method Invocation

Outline. Chapter 5 Application Server Middleware. Types of application server middleware. TP monitors CORBA Server-side components and EJB Summary

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

Remote Method Invocation in Java

5.4. Events and notifications

Distributed Systems. 02r. Java RMI Programming Tutorial. Paul Krzyzanowski TA: Long Zhao Rutgers University Fall 2017

Remote Objects and RMI

Chapter 2 Distributed Information Systems Architecture

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

Chapter Outline. Chapter 2 Distributed Information Systems Architecture. Distributed transactions (quick refresh) Layers of an information system

Verteilte Systeme (Distributed Systems)

Message Passing vs. Distributed Objects. 5/15/2009 Distributed Computing, M. L. Liu 1

RPC flow. 4.3 Remote procedure calls IDL. RPC components. Procedure. Program. sum (j,k) int j,k; {return j+k;} i = sum (3,7); Local procedure call

03 Remote invocation. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

Outline. Chapter 5 Application Server Middleware. Types of application server middleware. TP monitors CORBA Server-side components and EJB Summary

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4

The UNIVERSITY of EDINBURGH. SCHOOL of INFORMATICS. CS4/MSc. Distributed Systems. Björn Franke. Room 2414

CS 5523 Operating Systems: Remote Objects and RMI

Distributed Objects SPL/ SPL 201 / 0 1

CORBA Object Transaction Service

presentation DAD Distributed Applications Development Cristian Toma

Distributed Systems. 5. Remote Method Invocation

Distributed Systems COMP 212. Lecture 10 Othon Michail

5 Distributed Objects: The Java Approach

Generic architecture

DS 2009: middleware. David Evans

DISTRIBUTED COMPUTING

Distributed Programming with RMI. Overview CORBA DCOM. Prepared By: Shiba R. Tamrakar

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Chapter 4 Remote Procedure Calls and Distributed Transactions

CS193k, Stanford Handout #12. Threads 4 / RMI

Last Class: Network Overview. Today: Distributed Systems

Chapter Outline. Chapter 2 Distributed Information Systems Architecture. Layers of an information system. Design strategies.

Chapter 5 Distributed Objects and Remote Invocation

CSci Introduction to Distributed Systems. Communication: RPC In Practice

Course Snapshot. The Next Few Classes. Parallel versus Distributed Systems. Distributed Systems. We have covered all the fundamental OS components:

IBD Intergiciels et Bases de Données

Course Snapshot. The Next Few Classes

Chapter 15: Distributed Communication. Sockets Remote Procedure Calls (RPCs) Remote Method Invocation (RMI) CORBA Object Registration

Remote Method Invocation

CHAPTER - 4 REMOTE COMMUNICATION

RMI (Remote Method Invocation) Over the year, there have been 3 different approaches to application development:

RPC and RMI. 2501ICT Nathan

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

Chapter 10 Web-based Information Systems

Conception of Information Systems Part 5: Transaction Monitors

Remote Method Invocation Benoît Garbinato

Remote Method Invocation. Benoît Garbinato

Distributed Systems. Distributed Object Systems 2 Java RMI. Java RMI. Example. Applet continued. Applet. slides2.pdf Sep 9,

55:182/22C:182. Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP)

Distributed object component middleware I - Java RMI

Distributed object component middleware I - Java RMI

RMI: Design & Implementation

Appendix A - Glossary(of OO software term s)

Concurrent Object-Oriented Programming

Communication Basics, RPC & RMI. CS403/534 Distributed Systems Erkay Savas Sabanci University

Middleware for Heterogeneous and Distributed Information Systems

Conception of Information Systems Lecture 6: Transaction Monitors

5. Distributed Transactions. Distributed Systems Prof. Dr. Alexander Schill

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Questions and Answers. A. RMI allows us to invoke a method of java object that executes on another machine.

Lecture VI: Distributed Objects. Remote Method Invocation

Chapter 11 - Data Replication Middleware

Distributed Computing

Bharati Vidyapeeth s Institute of Computer Applications and Management A-4, Paschim Vihar, New Delhi-63.

Object-Oriented Systems Design RMI

Distributed Environments. CORBA, JavaRMI and DCOM

Desarrollo de Aplicaciones en Red RMI. Introduction. Considerations. Considerations. RMI architecture

Chapter 6 Business Process Modeling and Workflow Management

Distributed Systems. 6. Remote Method Invocation. Werner Nutt

Middleware. Adapted from Alonso, Casati, Kuno, Machiraju Web Services Springer 2004

Grid Computing. Java Remote Method Invocation (RMI) RMI Application. Grid Computing Fall 2006 Paul A. Farrell 9/5/2006

Communication. Distributed Systems Santa Clara University 2016

Distributed Software Systems

RMI. (Remote Method Invocation)

Chapter 6 Object Persistence, Relationships and Queries

Lecture 3: Synchronous Interaction Patterns Traditional Middleware

15-498: Distributed Systems Project #1: Design and Implementation of a RMI Facility for Java

Distributed Information Systems

Artix ESB. Transactions Guide, Java. Version 5.5, December 2008

Distributed Objects. Chapter Distributing Objects Overview

Written by: Dave Matuszek

JAC444 - Lecture 11. Remote Method Invocation Segment 2 - Develop RMI Application. Jordan Anastasiade Java Programming Language Course

Distributed Programming in Java. Distribution (2)

Remote Method Invocation

RMI Case Study. A Typical RMI Application

IJESRT. http: //

Component-Based Software Engineering

Networks and Operating Systems Chapter 3: Remote Procedure Call (RPC)

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING ACADEMIC YEAR (ODD SEMESTER) QUESTION BANK

RMI Example RMI. CmpE 473 Internet Programming RMI

Transcription:

Prof. Dr.-Ing. Stefan Deßloch AG Heterogene Informationssysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@informatik.uni-kl.de Chapter 4 Remote Procedure Calls and Distributed Transactions Outline Remote Procedure Call concepts IDL, principles, binding variations remote method invocation example: Java RMI stored procedures Distributed Transaction Processing transactional RPC X/Open DTP Summary 2 WS 2008/09 1

Communication and Distributed Processing Distributed (Information) System consists of (possibly autonomous) subsystems jointly working in a coordinated manner How do subsystems communicate? Remote Procedure Calls (RPC) transparently invoke procedures located on other machines Peer-To-Peer-Messaging Message Queuing Transactional Support (ACID properties) for distributed processing Server/system components are Resource Managers (Transactional) Remote Procedure Calls (TRPC) Distributed Transaction Processing 3 Remote Procedure Call (RPC) Goal: Simple programming model for distributed applications based on procedure as an invocation mechanism for distributed components Core mechanism in almost every form of middleware Distributed ib t programs can interact t (transparently) tl in heterogeneous environments network protocols programming languages operating systems hardware platforms Important concepts Interface Definition Language (IDL) Proxy (Client Stub) Stub (Server Stub) Interface Definition Language (IDL) IDL Compiler Header files Proxy Stub 4 WS 2008/09 2

How RPC Works Define an interface for the remote procedure using an IDL abstract representation of procedure input and output parameters can be independent of programming languages Compile the interface using IDL-compiler, resulting in client stub (proxy) server stub (skeleton) auxiliary files (header files, ) Client stub (proxy) compiled and linked with client program client program invokes remote procedure by invoking the (local) client stub implements everything to interact with the server remotely Server stub (skeleton) implements the server portion of the invocation compiled and linked with server code calls the actual procedure implemented at the server 5 RPC Client application Call Pay_cc Client s system Client proxy PACK ARGUMENT RPC runtime SEND CALL PACKET RPC runtime RECEIVE Servers s system Server stub UNPACK ARGUMENT Server application Pay_cc WAIT WORK Return to Pay_Bill UNPACK RESULT RECEIVE RETURN PACKET SEND PACK RETURN 1. The client calls the local proxy. 3. The client runtime system sends the call packet (arguments and procedure name). 5. The server stub unpacks the arguments and calls the server program. 2. The client proxy marshals (packs) arguments to Pay_cc. 4. The server runtime receives the message and calls the right stub. 4. The Pay_cc program runs as if it were called locally. Its results flow back to the caller by reversing the procedure. 6 WS 2008/09 3

Binding in RPC Before performing RPC, the client must first locate and bind to the server create/obtain an (environment-specific) handle to the server encapsulates information such as IP address, port number, Ethernet address, Static binding handle is "hard-coded" d d" into the client stub at compile-time advantages: simple and efficient disadvantages: client and server are tightly coupled server location change requires recompilation dynamic load balancing across multiple (redundant) servers is not possible Dynamic binding utilizes a name and directory service based on logical names, signatures of procedures server registers available procedure with the N&D server client asks for server handle, uses it to perform RPC requires lookup protocol/api may be performed inside the client stub (automatic binding) or outside opportunities for load balancing, more sophisticated selection (traders) Location transparency usually means that a remote procedure is invoked just like a local procedure Binding process for remote and local procedures usually differ 7 RPC Variation 1: Distributed Objects Basic Idea: Evolve RPC concept for objects application consists of distributed object components object services are invoked using Remote Method Invocation (RMI) Utilizes/matches advantages of object-oriented oriented computing object identity encapsulation: object manipulated only through methods inheritance, polymorphism interface vs. implementation reusability 8 WS 2008/09 4

Distributed Objects with Java RMI Mechanism for communication between Java programs between Java programs and applets running in different JVMs, possibly on different nodes Capabilities finding remote objects transparent communication with remote objects loading byte code for remote objects Client RMI RMI Directory Service RMI Server 9 Java RMI Development Java is used as the IDL and development programming language Development steps 1. Defining a remote interface (e.g., Order ) 2. Implementing server object class (e.g., OrderImpl, Od which h implements Od Order ) only application logic; communication infrastructure not "visible" 3. Implement client object, invocation of remote (server) object locate the remote object using the RMI registry invoke methods on remote object using the remote interface 4. Provide server code for creating a server object (instantiate server object class) registering the server object with the RMI registry 10 WS 2008/09 5

Example - Class and Interface Relationships 'marker' interface Remote class providing remote server object 'infrastructure' extends UnicastRemoteObject stub variable declaration Order implements extends OrderClient call via stub OrderImpl create OrderServer client server 11 Java RMI Deployment and Runtime Deployment generate stub and skeleton using RMI compiler Interface Definition invoke server code for creating and Language (Java) registering the server object Runtime run the client application issuing a server object lookup in the client RMI Compiler application will result in transferring a client stub object (implementing the remote interface) to the client application stub class needs to be loaded into JVM on the client, either through h local l class path or Stub/Proxy Skeleton dynamically over the network invoking methods on the remote interface will be carried out using stubs/skeletons as discussed earlier 12 WS 2008/09 6

RPC Variation 2: Stored Procedures Named persistent code to be invoked in SQL, executed by the DBMS SQL CALL statement Created directly in a DB schema Stored Procedure creation requires header (signature): consists of a name and a (possibly empty) list of parameters. may specify parameter mode: IN, OUT, INOUT may return result sets body (implementation): using SQL procedural extensions or external programming language (e.g., Java) Invocation of stored procedures using CALL statement through the usual DB access approaches (e.g., JDBC see CallableStatement ) RPC is not transparent! generic invocation mechanism, not stubs/skeletons involved) in the scope of an existing DB connection, active transaction 13 RPCs and Transactions Example scenario for T: debit/credit T invokes debit procedure (ST1), modifying DB1 T performs credit operation on DBS2, modifying DB2 Need transactional guarantees for T Program structure of T BOT CALL debit( ) CONNECT (DB2) UPDATE ACCOUNTS SET DISCONNECT EOT Requires coordination of distributed transaction based on 2PC distributed TA ST1 DBS1 DB1 client P T DBS2 DB2 presentation application logic resource management 14 WS 2008/09 7

Transactional RPC (TRPC) Servers are resource managers RPCs are issued in the context of a transaction demarcation (BOT, EOT) usually happens on the client TRPC-Stub like RPC-Stub additional responsibilities for TA-oriented communication TRPC requires the following additional steps binding of RPC to transactions using TRID notifying TA-Mgr about RM-Calls if performed through RPC (register participant of TA) binding processes to transactions: failures (crashes) resulting in process termination should be communicated to the TA-Mgr 15 X/OPEN Standard for Distributed TA Processing Resource Manager recoverable supports external coordination of TAs using 2PC protocol (XA-compliant) TA-Mgr TX-Interface coordinates, controls RMs Begin Application Program Commit Rollback demarcates TA Application (TA-brackets) invokes RM services (AP) e.g., SQL-statements Request in distributed environment: performs (T)RPCs Transactional Context TRID generated by TA-Mgr at BEGIN established at the client passed along (transitively) with RM-requests, RPCs local environment TA-Mgr (TM) Prepare, Commit, Rollback Join XA-Interface Resource-Mgr (RM) 16 WS 2008/09 8

Interactions in a Local Environment 1. AP -> TM: begin() establishes transaction context, global TRID 2. TM -> RM: start() TM notifies frequently used RMs about the new global transaction, so that RM can associate future AP requests with the TRID 3. AP -> RM: request the RM 1. first registers with the TM to join the global transaction (unless it was already notified in (2) above), then 2. processes the AP request 4. AP -> TM: commit() (or rollback) TM will interact with RMs to complete the transaction using the 2PC protocol A thread of control is associated with at most one TRID at a time. An AP request is implicitly associated with a TRID through the current thread. 17 X/OPEN DTP Distributed Environment Begin Commit Abort TM TA-Mgr Outgoing Incoming TM TA-Mgr Start Application TRPC CM Comm.-Mgr CM Comm.-Mgr Server Prepare, Commit, Abort RM Request RM Recource-Mgr Remote Request Prepare, Commit, Abort RM Request RM Recource-Mgr Outgoing TRPC: CM acts like a RM, notifies local (superior) TM that TA involves remote RMs Incoming TRPC: CM notifies local (subordinate) TM about incoming global TA Superior TM will drive hierarchical 2PC over remote TM/RMs through CM 18 WS 2008/09 9

Summary Remote Procedure Call important core concept for distributed IS RPC model is based on interface definitions using IDL client stub (proxy), server stub (skeleton) for transparent invocation of remote procedure binding mechanism RPC Variations Remote Method Invocation supported in object-based middleware (e.g., CORBA, Enterprise Java) Stored Procedures Transaction support for RPCs distributed transaction processing guarantees atomicity of global TA transactional RPC X/Open DTP as foundation for standardized DTP variations/enhancements appear in object-based middleware (CORBA OTS, Java JTA/JTS) 19 Appendix JAVA RMI EXAMPLE 20 WS 2008/09 10

Example Scenario: Pizza-Service Pizza id: OID name: String price: float getprice setprice pizzas * * Order id: OID orderdate: Date deliverydate: Date create additem deliver cancel totalprice 1 * Item id: OID count: int create delete orderitems * * ingredients orders * 1 Ingredient id: OID name: String stock: int * * Customer id: OID name: String create delete currentorder totalallorders 1 address 1 Address id: OID zip: int city: String street: String address 1 1 Supplier id: OID name: String 21 Example Remote Service Interface import java.rmi.*; import java.util.date; public interface Order extends Remote { public void additem(int pizzaid, int number) throws RemoteException; public Date getdeliverydate() throws RemoteException; public Date setdeliverydate (Date newdate) throws RemoteException;... import java.rmi.*; import java.rmi.server.unicastremoteobject; import java.util.*; 22 WS 2008/09 11

Example Server Class Implementation... public class OrderImpl extends UnicastRemoteObject implements Order { 'export' Order object for accepting requests... register with name server private Vector fitems; private Date fdeliverydate; public OrderImpl(String name) throws RemoteException { super(); try { Naming.rebind(name, this); fitems = new Vector(); fdeliverydate = null; catch (Exception e) { System.err.println( Output: + e.getmessage()); e.printstacktrace(); 23 Example Server Class (continued)... public void additem(int pizzaid, int number ) throws RemoteException { //assumingclassitemisknown is Item item = new Item(pizzaId, number); fitems.addelement(item);... // Impl. of other methods 24 WS 2008/09 12

Example Server... import java.rmi.*; import java.server.*; public class OrderServer { public static void main(string args[]) { try { OrderImpl order = new OrderImpl( my_order ); System.out.println( Order server is running ); catch (Exception e) { System.err.println( Exception: + e.getmessage()); e.printstacktrace(); remote object name (later used in client lookup) 25 Example Client Program... import java.rmi.*; public class OrderClient { public static void Main(String args[]) { try { Order order = (Order) Naming.lookup("/my_order"); int pizzaid = Integer.parseInt(args[0]); int number = Integer.parseInt(args[1]); order.additem(pizzaid, number); catch (Exception e) { System.err.println( system error: + e); returns an instance of the stub class (generated from the remote Order interface) 26 WS 2008/09 13

Example Compile, Generate Stub, Run Compile: javac Order.java OrderImpl.java OrderClient.java OrderServer.java Generate stub and skeleton code: rmic OrderImpl Administrative steps: Start directory server: rmiregistry Start RMI-Servers: java OrderServer Run clients: java OrderClient 27 WS 2008/09 14