Chapter 4 Remote Procedure Calls and Distributed Transactions

Similar documents
Chapter 4 Remote Procedure Calls and Distributed Transactions

Communication and Distributed Processing

Communication and Distributed Processing

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

Chapter 3 DB-Gateways

Chapter 11 Web-based Information Systems

Chapter 2 Distributed Information Systems Architecture

Chapter 5 Application Server Middleware

Architectural styles for software systems The client-server style

Τεχνολογία Λογισμικού

Goals of the Lecture UML Implementation Diagrams

Chapter 8 Web Services Foundations

Outline n Introduction n Background o Distributed DBMS Architecture

Topics. Instance object. Instance object. Fundamentals of OT. Object notation. How do objects collaborate? Pearson Education 2007 Appendix (RASD 3/e)

BEA Tuxedo. Creating CORBA Server Applications

BEA Tuxedo. Creating CORBA Client Applications

BEA WebLogic Server. Programming WebLogic Enterprise JavaBeans

n Explore virtualization concepts n Become familiar with cloud concepts

Classes and Objects. Again: Distance between points within the first quadrant. José Valente de Oliveira 4-1

Exceptions. Your computer takes exception. The Exception Class. Causes of Exceptions

BEA Tuxedo. Introducing the BEA Tuxedo System

Elementary Educational Computer

CMSC Computer Architecture Lecture 12: Virtual Memory. Prof. Yanjing Li University of Chicago

Java Inheritance. Class ADT (Abstract Data Type) Interface. Classes implement the concept of ADT: Interfaces define interaction contracts: Rui Moreira

Task scenarios Outline. Scenarios in Knowledge Extraction. Proposed Framework for Scenario to Design Diagram Transformation

Java net programming II

Chapter 4 Threads. Operating Systems: Internals and Design Principles. Ninth Edition By William Stallings

Service Oriented Enterprise Architecture and Service Oriented Enterprise

VISUALSLX AN OPEN USER SHELL FOR HIGH-PERFORMANCE MODELING AND SIMULATION. Thomas Wiedemann

Baan Tools User Management

Threads and Concurrency in Java: Part 1

Towards Efficient Selection of Web Services

Threads and Concurrency in Java: Part 1

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Session Initiated Protocol (SIP) and Message-based Load Balancing (MBLB)

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Python Programming: An Introduction to Computer Science

Linked Lists 11/16/18. Preliminaries. Java References. Objects and references. Self references. Linking self-referential nodes

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Outline. CSCI 4730 Operating Systems. Questions. What is an Operating System? Computer System Layers. Computer System Layers

Python Programming: An Introduction to Computer Science

COP4020 Programming Languages. Compilers and Interpreters Prof. Robert van Engelen

Modeling a Software Architecture. Paolo Ciancarini

Schema for the DCE Security Registry Server

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000.

Appendix D. Controller Implementation

Security of Bluetooth: An overview of Bluetooth Security

System and Software Architecture Description (SSAD)

BEA WebLogic Collaborate

10/23/18. File class in Java. Scanner reminder. Files. Opening a file for reading. Scanner reminder. File Input and Output

Software development of components for complex signal analysis on the example of adaptive recursive estimation methods.

Workflow Management Systems

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames

Avid Interplay Bundle

Goals of this Lecture Activity Diagram Example

Code Review Defects. Authors: Mika V. Mäntylä and Casper Lassenius Original version: 4 Sep, 2007 Made available online: 24 April, 2013

BEA Tuxedo. Using the CORBA Notification Service

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1

1-2-3G Wireless. About NTT DoCoMo. Talk Outline. 4G Wireless (2010 ~ 2012) 4G is about Services

ifs considered Harmful

Outline. Research Definition. Motivation. Foundation of Reverse Engineering. Dynamic Analysis and Design Pattern Detection in Java Programs

ICS Regent. Communications Modules. Module Operation. RS-232, RS-422 and RS-485 (T3150A) PD-6002

Last class. n Scheme. n Equality testing. n eq? vs. equal? n Higher-order functions. n map, foldr, foldl. n Tail recursion

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

n Learn how resiliency strategies reduce risk n Discover automation strategies to reduce risk

Keywords Software Architecture, Object-oriented metrics, Reliability, Reusability, Coupling evaluator, Cohesion, efficiency

GE FUNDAMENTALS OF COMPUTING AND PROGRAMMING UNIT III

Τεχνολογία Λογισμικού

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Baan Finance Financial Statements

Structuring Redundancy for Fault Tolerance. CSE 598D: Fault Tolerant Software

3.1 Overview of MySQL Programs. These programs are discussed further in Chapter 4, Database Administration. Client programs that access the server:

Adapter for Mainframe

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

BEA WebLogic Application Integration A Component of BEA WebLogic Integration. Adapter Development Guide

Oracle Server. What s New in this Release? Release Notes

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance

1 Enterprise Modeler

A SOFTWARE MODEL FOR THE MULTILAYER PERCEPTRON

implement language system

Oracle SDP Number Portability

top() Applications of Stacks

BEA WebLogic Commerce Server. Registration and User Processing Package

WYSE Academic Challenge Sectional Computer Science 2005 SOLUTION SET

Stevina Dias* Sherrin Benjamin* Mitchell D silva* Lynette Lopes* *Assistant Professor Dwarkadas J Sanghavi College of Engineering, Vile Parle

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Bruce Eckel, Thinking in Patterns with Java, cf. José Valente de Oliveira 10-1

Today s objectives. CSE401: Introduction to Compiler Construction. What is a compiler? Administrative Details. Why study compilers?

n We have discussed classes in previous lectures n Here, we discuss design of classes n Library design considerations

BEA WebLogic Enterprise. Using the WebLogic EJB Deployer

GridSphere and the GridLab Project

IS-IS for IPv6. ISP Workshops

COP4020 Programming Languages. Names, Scopes, and Bindings Prof. Robert van Engelen

The Magma Database file formats

SCI Reflective Memory

Data diverse software fault tolerance techniques

Creating Test Harnesses and Starter Applications

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Ontology-based Decision Support System with Analytic Hierarchy Process for Tour Package Selection

Transcription:

Prof. Dr.-Ig. Stefa Deßloch AG Heterogee Iformatiossysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@iformatik.ui-kl.de Chapter 4 Remote Procedure Calls ad Distributed Trasactios

Outlie Remote Procedure Call cocepts IDL, priciples, bidig variatios remote method ivocatio example: Java RMI stored procedures Distributed Trasactio Processig trasactioal RPC X/Ope DTP Summary Prof.Dr.-Ig. Stefa Deßloch 2 Middleware for Heterogeeous ad Distributed Iformatio Systems

Commuicatio ad Distributed Processig Distributed (Iformatio) System cosists of (possibly autoomous) subsystems joitly workig i a coordiated maer How do subsystems commuicate? Remote Procedure Calls (RPC) trasparetly ivoke procedures located o other machies Peer-To-Peer-Messagig Message Queuig Trasactioal Support (ACID properties) for distributed processig Server/system compoets are Resource Maagers (Trasactioal) Remote Procedure Calls (TRPC) Distributed Trasactio Processig Prof.Dr.-Ig. Stefa Deßloch 3 Middleware for Heterogeeous ad Distributed Iformatio Systems

Remote Procedure Call (RPC) Goal: Simple programmig model for distributed applicatios based o procedure as a ivocatio mechaism for distributed compoets Core mechaism i almost every form of middleware Distributed programs ca iteract (trasparetly) i heterogeeous eviromets etwork protocols programmig laguages operatig systems hardware platforms Importat cocepts Iterface Defiitio Laguage (IDL) IDL Compiler Proxy (Cliet Stub) Skeleto (Server Stub) Iterface Defiitio Laguage (IDL) Header files Proxy Skeleto Prof.Dr.-Ig. Stefa Deßloch 4 Middleware for Heterogeeous ad Distributed Iformatio Systems

How RPC Works Defie a iterface for the remote procedure usig a IDL abstract represetatio of procedure iput ad output parameters ca be idepedet of programmig laguages Compile the iterface usig IDL-compiler, resultig i cliet stub (proxy) server stub (skeleto) auxiliary files (header files, ) Cliet stub (proxy) compiled ad liked with cliet program cliet program ivokes remote procedure by ivokig the (local) cliet stub implemets everythig to iteract with the server remotely Server stub (skeleto) implemets the server portio of the ivocatio compiled ad liked with server code calls the actual procedure implemeted at the server Prof.Dr.-Ig. Stefa Deßloch 5 Middleware for Heterogeeous ad Distributed Iformatio Systems

RPC Cliet Server Applicatio Proxy RPC rutime RPC rutime Skeleto Applicatio Call order PACK ARGUMENT SEND CALL RECEIVE UNPACK PACKET ARGUMENT order (1) Cliet calls the local proxy (2) Cliet proxy marshals (packs) argumets to order (3) Cliet rutime system seds the call packet (argumets ad procedure ame) (4) Server rutime receives the message ad calls the right stub (5) Server stub upacks the argumets ad calls the server program (6) The order program rus as if it were called locally. Results flow back to the caller by reversig the procedure. WORK (cotiue) UNPACK RESULT RECEIVE RETURN PACKET SEND PACK RETURN Prof.Dr.-Ig. Stefa Deßloch 6 Middleware for Heterogeeous ad Distributed Iformatio Systems

Bidig i RPC Before performig RPC, the cliet must first locate ad bid to the server create/obtai a (eviromet-specific) hadle to the server ecapsulates iformatio such as IP address, port umber, Etheret address, Static bidig hadle is "hard-coded" ito the cliet stub at compile-time advatages: simple ad efficiet disadvatages: cliet ad server are tightly coupled server locatio chage requires recompilatio dyamic load balacig across multiple (redudat) servers is ot possible Dyamic bidig utilizes a ame ad directory service based o logical ames, sigatures of procedures server registers available procedure with the N&D server cliet asks for server hadle, uses it to perform RPC requires lookup protocol/api may be performed iside the cliet stub (automatic bidig) or outside opportuities for load balacig, more sophisticated selectio (traders) Locatio trasparecy usually meas that a remote procedure is ivoked just like a local procedure Bidig process for remote ad local procedures usually differ Prof.Dr.-Ig. Stefa Deßloch 7 Middleware for Heterogeeous ad Distributed Iformatio Systems

RPC Variatio 1: Distributed Objects Basic Idea: Evolve RPC cocept for objects applicatio cosists of distributed object compoets object services are ivoked usig Remote Method Ivocatio (RMI) Utilizes/matches advatages of object-orieted computig object idetity ecapsulatio: object maipulated oly through methods iheritace, polymorphism iterface vs. implemetatio reusability Prof.Dr.-Ig. Stefa Deßloch 8 Middleware for Heterogeeous ad Distributed Iformatio Systems

Distributed Objects with Java RMI Mechaism for commuicatio betwee Java programs betwee Java programs ad applets ruig i differet JVMs, possibly o differet odes Capabilities fidig remote objects trasparet commuicatio with remote objects loadig byte code for remote objects Cliet RMI RMI Directory Service RMI Server Prof.Dr.-Ig. Stefa Deßloch 9 Middleware for Heterogeeous ad Distributed Iformatio Systems

Java RMI Developmet Java is used as the IDL ad developmet programmig laguage Developmet steps 1. Defiig a remote iterface (e.g., Order ) methods capable of throwig RemoteExceptios 2. Implemetig server object class (e.g., OrderImpl, which implemets Order ) oly applicatio logic; commuicatio ifrastructure ot "visible" 3. Implemet cliet object, ivocatio of remote (server) object locate the remote object usig the RMI registry ivoke methods o remote object usig the remote iterface hadle RemoteExceptios 4. Provide server code for creatig a server object (istatiate server object class) exportig ad registerig the server object with the RMI registry Prof.Dr.-Ig. Stefa Deßloch 10 Middleware for Heterogeeous ad Distributed Iformatio Systems

Example - Class ad Iterface Relatioships 'marker' iterface Remote class providig remote server object 'ifrastructure' exteds UicastRemoteObject stub variable declaratio Order implemets export object OrderCliet call via stub OrderImpl create OrderServer cliet server Prof.Dr.-Ig. Stefa Deßloch 11 Middleware for Heterogeeous ad Distributed Iformatio Systems

Java RMI Deploymet ad Rutime Deploymet geerate stub usig Java compiler ivoke server code for creatig ad registerig the server object Rutime ru the cliet applicatio issuig a server object lookup i the cliet applicatio will result i trasferrig a cliet stub object (implemetig the remote iterface) to the cliet applicatio stub class eeds to be loaded ito JVM o the cliet, either through local class path or dyamically over the etwork ivokig methods o the remote iterface will be carried out usig stubs/skeletos as discussed earlier Iterface Defiitio Laguage (Java) Java Compiler Stub/Proxy Prof.Dr.-Ig. Stefa Deßloch 12 Middleware for Heterogeeous ad Distributed Iformatio Systems

RPC Variatio 2: Stored Procedures Named persistet code to be ivoked i SQL, executed by the DBMS SQL CALL statemet Created directly i a DB schema Stored Procedure creatio requires header (sigature): cosists of a ame ad a (possibly empty) list of parameters. may specify parameter mode: IN, OUT, INOUT may retur result sets body (implemetatio): usig SQL procedural extesios or exteral programmig laguage (e.g., Java) Ivocatio of stored procedures usig CALL statemet through the usual DB access approaches (e.g., JDBC see CallableStatemet ) locatio-trasparecy is provided, but RPC itself is ot trasparet! geeric ivocatio mechaism, o stubs/skeletos ivolved) i the scope of a existig DB coectio, active trasactio Prof.Dr.-Ig. Stefa Deßloch 13 Middleware for Heterogeeous ad Distributed Iformatio Systems

RPCs ad Trasactios cliet Example sceario for T: debit/credit T ivokes debit procedure (ST1), modifyig DB1 T performs credit operatio o DBS2, modifyig DB2 Need trasactioal guaratees for T Program structure of T BOT CALL debit( ) CONNECT (DB2) UPDATE ACCOUNTS SET DISCONNECT EOT Requires coordiatio of distributed trasactio based o 2PC distributed TA ST1 DBS1 DB1 P T DBS2 DB2 presetatio applicatio logic resource maagemet Prof.Dr.-Ig. Stefa Deßloch 14 Middleware for Heterogeeous ad Distributed Iformatio Systems

Trasactioal RPC (TRPC) RPCs are issued i the cotext of a trasactio demarcatio (BOT, EOT) usually happes o the cliet TRPC-Stub like RPC-Stub additioal resposibilities for TA-orieted commuicatio TRPC requires the followig additioal steps bidig of RPC to trasactios usig TRID otifyig TA-Mgr about RM-Calls if performed through RPC (register participat of TA) bidig processes to trasactios: failures (crashes) resultig i process termiatio should be commuicated to the TA-Mgr Prof.Dr.-Ig. Stefa Deßloch 15 Middleware for Heterogeeous ad Distributed Iformatio Systems

X/OPEN Stadard for Distributed TA Processig Resource Maager recoverable supports exteral coordiatio of TAs usig 2PC protocol (XA-compliat) TA-Mgr coordiates, cotrols RMs Applicatio Program demarcates TA (TA-brackets) Applicatio ivokes RM services (AP) e.g., SQL-statemets i distributed eviromet: performs (T)RPCs TX-Iterface Trasactioal Cotext TRID geerated by TA-Mgr at BEGIN established at the cliet passed alog (trasitively) with RM-requests, RPCs begi commit/rollback request local eviromet register TA-Mgr (TM) prepare commit/rollback XA- Iterface Resource-Mgr (RM) Prof.Dr.-Ig. Stefa Deßloch 16 Middleware for Heterogeeous ad Distributed Iformatio Systems

Iteractios i a Local Eviromet 1. AP -> TM: begi establishes trasactio cotext, global id (TRID) for ToC 1. TM -> RM static registratio TM otifies frequetly used RMs about the ew global trasactio, RM ca associate future AP requests from ToC with the TRID 2. AP -> RM: request the RM 1. first dyamically registers with the TM to joi the global trasactio for ToC (uless RM uses static registratio), the 2. processes the AP request 3. AP -> TM: commit, rollback TM will iteract with RMs to complete the trasactio usig the 2PC protocol (prepare, commit/rollback) Thread of Cotrol (ToC) etity, with all its cotext (resources, etc.) that is i cotrol of the processor (e.g., a OS-thread) is associated with at most oe TRID at a time (but a global TA ca have multiple ToCs). A AP request is implicitly associated with a TRID through the curret ToC. Prof.Dr.-Ig. Stefa Deßloch 17 Middleware for Heterogeeous ad Distributed Iformatio Systems

X/OPEN DTP Distributed Eviromet "superior" "subordiate" begi commit/rollback TA-Mgr (TM) 2PC maage outgoig maage icomig TA-Mgr (TM) 2PC maage TA associatio Applicatio (AP) TRPC Comm.-Mgr (CM) Comm.-Mgr (CM) TRPC Server AP register register request request Resource-Mgr (RM) Resource-Mgr (RM) Commuicatio Maager (CM) provides trasactioal RPC support works with TMs o both sides to help maage global trasactios Remote TM assumes role of subordiate TM hierarchical 2PC processig Prof.Dr.-Ig. Stefa Deßloch 18 Middleware for Heterogeeous ad Distributed Iformatio Systems

Iteractios i a Distributed Eviromet Applicatio issues a (trasactioal) RPC (TRPC) 1. local CM iteracts with local TM to maage the outgoig TA TM otes TRID as extedig to the remote system TM otes local CM to be icluded i commit processig (2PC) local TM becomes the "superior" TA-Maager (later iitiates 2PC) 2. local CM commuicates RPC ad trasactioal cotext to remote CM 3. remote CM iteracts with remote TM to maage the icomig TA CM establishes TRID with remote TM, which becomes the "subordiate" for this TRID CM asks TM to associate TRID with ToC i which (remote) server applicatio will ru TM performs static registratio with remote RMs for TRID CM (server stub) ivokes server AP 4. server AP may issue (remote) RM requests (might cause dyamic RM registratio as usual) Applicatio issues a commit (or rollback) 1. superior TM drives hierarchical 2PC processig, ivolvig local CM just like RMs 2. local CM relays prepare/commit/rollback calls to remote CM, which i tur relays them to subordiate (remote) TM 3. subordiate TM coordiates with remote RMs for each phase Prof.Dr.-Ig. Stefa Deßloch 19 Middleware for Heterogeeous ad Distributed Iformatio Systems

Summary Remote Procedure Call importat core cocept for distributed IS RPC model is based o iterface defiitios usig IDL cliet stub (proxy), server stub (skeleto) for trasparet ivocatio of remote procedure bidig mechaism RPC Variatios Remote Method Ivocatio supported i object-based middleware (e.g., CORBA, Eterprise Java) Stored Procedures Trasactio support for RPCs distributed trasactio processig guaratees atomicity of global TA trasactioal RPC X/Ope DTP as foudatio for stadardized DTP variatios/ehacemets appear i object-based middleware (CORBA OTS, Java JTA/JTS) Prof.Dr.-Ig. Stefa Deßloch 20 Middleware for Heterogeeous ad Distributed Iformatio Systems

Appedix JAVA RMI EXAMPLE Prof.Dr.-Ig. Stefa Deßloch 21 Middleware for Heterogeeous ad Distributed Iformatio Systems

Example Sceario: Pizza-Service Pizza id: OID ame: Strig price: float getprice setprice pizzas * * Order id: OID orderdate: Date deliverydate: Date create additem deliver cacel totalprice Item id: OID cout: it create delete * * 1 orderitems * igrediets orders * 1 Igrediet id: OID ame: Strig stock: it * * Customer id: OID ame: Strig create delete curretorder totalallorders 1 address 1 Address id: OID zip: it city: Strig street: Strig address 1 1 Supplier id: OID ame: Strig Prof.Dr.-Ig. Stefa Deßloch 22 Middleware for Heterogeeous ad Distributed Iformatio Systems

Example Remote Service Iterface import java.rmi.*; import java.util.date; public iterface Order exteds Remote { public void additem(it pizzaid, it umber) throws RemoteExceptio; public Date getdeliverydate() throws RemoteExceptio; public Date setdeliverydate (Date ewdate) throws RemoteExceptio; } Prof.Dr.-Ig. Stefa Deßloch 23 Middleware for Heterogeeous ad Distributed Iformatio Systems

Example Server Class Implemetatio...... import java.rmi.*; import java.rmi.registry.locateregistry import java.rmi.registry.registry import java.rmi.server.uicastremoteobject; import java.util.*; public class OrderImpl implemets Order { private Vector fitems; private Date fdeliverydate; public OrderImpl(Strig ame) throws RemoteExceptio { 'export' Order object for acceptig requests register with ame server Prof.Dr.-Ig. Stefa Deßloch super(); try { Order stub = (Order) UicastRemoteObject.exportObject(this, 0); Registry Namig = LocateRegistry.getRegistry(); Namig.rebid(ame, stub); fitems = ew Vector(); fdeliverydate = ull; } catch (Exceptio e) { System.err.pritl( Output: + e.getmessage()); e.pritstacktrace(); } } 24 Middleware for Heterogeeous ad Distributed Iformatio Systems

Example Server Class (cotiued)... public void additem(it pizzaid, it umber ) throws RemoteExceptio { // assumig class Item is kow Item item = ew Item(pizzaId, umber); fitems.addelemet(item); }... // Impl. of other methods } Prof.Dr.-Ig. Stefa Deßloch 25 Middleware for Heterogeeous ad Distributed Iformatio Systems

Example Server... remote object import java.rmi.*; ame (later used import java.server.*; i cliet lookup) public class OrderServer { public static void mai(strig args[]) { try { OrderImpl order = ew OrderImpl( my_order ); System.out.pritl( Order server is ruig ); } catch (Exceptio e) { System.err.pritl( Exceptio: + e.getmessage()); e.pritstacktrace(); } } } Prof.Dr.-Ig. Stefa Deßloch 26 Middleware for Heterogeeous ad Distributed Iformatio Systems

Example Cliet Program... import java.rmi.*; public class OrderCliet { public static void Mai(Strig args[]) { try { returs a istace of the stub class (geerated from the remote Order iterface) Registry Namig = Locate Registry.getRegistry(args[0]); Order order = (Order) Namig.lookup("my_order"); it pizzaid = Iteger.parseIt(args[0]); it umber = Iteger.parseIt(args[1]); order.additem(pizzaid, umber); } catch (Exceptio e) { System.err.pritl( system error: + e); } } } Prof.Dr.-Ig. Stefa Deßloch 27 Middleware for Heterogeeous ad Distributed Iformatio Systems

Example Compile, Geerate Stub, Ru Compile will also geerate stubs: javac Order.java OrderImpl.java OrderCliet.java OrderServer.java Admiistrative steps: Start directory server: rmiregistry Start RMI-Servers: java OrderServer Ru cliets: java OrderCliet Prof.Dr.-Ig. Stefa Deßloch 28 Middleware for Heterogeeous ad Distributed Iformatio Systems