Chapter 5 Application Server Middleware

Similar documents
Architectural styles for software systems The client-server style

Chapter 2 Distributed Information Systems Architecture

Chapter 11 Web-based Information Systems

Chapter 4 Remote Procedure Calls and Distributed Transactions

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

Chapter 3 DB-Gateways

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

Baan Tools User Management

Goals of the Lecture UML Implementation Diagrams

Outline n Introduction n Background o Distributed DBMS Architecture

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

Chapter 8 Web Services Foundations

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

n Explore virtualization concepts n Become familiar with cloud concepts

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

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

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

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

Multi-Threading. Hyper-, Multi-, and Simultaneous Thread Execution

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

BEA WebLogic Server. Programming WebLogic Enterprise JavaBeans

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

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

BEA Tuxedo. Creating CORBA Server Applications

BEA Tuxedo. Introducing the BEA Tuxedo System

BEA Tuxedo. Creating CORBA Client Applications

Service Oriented Enterprise Architecture and Service Oriented Enterprise

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

Elementary Educational Computer

BEA WebLogic XML/Non-XML Translator

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

Appendix D. Controller Implementation

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

Avid Interplay Bundle

A SOFTWARE MODEL FOR THE MULTILAYER PERCEPTRON

Threads and Concurrency in Java: Part 1

Data diverse software fault tolerance techniques

1 Enterprise Modeler

Threads and Concurrency in Java: Part 1

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

Schema for the DCE Security Registry Server

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

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design

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

BEA WebLogic Collaborate

BEA WebLogic Enterprise. Using the WebLogic EJB Deployer

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

Python Programming: An Introduction to Computer Science

Panel for Adobe Premiere Pro CC Partner Solution

Review: The ACID properties

The Magma Database file formats

Transitioning to BGP

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Baan Finance Financial Statements

SCI Reflective Memory

Security of Bluetooth: An overview of Bluetooth Security

Security and Communication. Ultimate. Because Intercom doesn t stop at the hardware level. Software Intercom Server for virtualised IT platforms

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

CA Top Secret r14 for z/os

Web OS Switch Software

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5.

BEA WebLogic Process Integrator

TRANSACTION MANAGEMENT [CH 16]

Introduction to SWARM Software and Algorithms for Running on Multicore Processors

System and Software Architecture Description (SSAD)

% Sun Logo for. X3T10/95-229, Revision 0. April 18, 1998

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

Computers and Scientific Thinking

Python Programming: An Introduction to Computer Science

. Written in factored form it is easy to see that the roots are 2, 2, i,

Network Time Protocol (NTP)

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

BEA WebLogic Commerce Server. Registration and User Processing Package

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

Towards Efficient Selection of Web Services

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

GE FUNDAMENTALS OF COMPUTING AND PROGRAMMING UNIT III

MOTIF XF Extension Owner s Manual

CMSC Computer Architecture Lecture 11: More Caches. Prof. Yanjing Li University of Chicago

Adapter for Mainframe

Message Integrity and Hash Functions. TELE3119: Week4

One advantage that SONAR has over any other music-sequencing product I ve worked

BEA Tuxedo. Using the BEA Tuxedo System on Windows NT

Goals of this Lecture Activity Diagram Example

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control

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

1. SWITCHING FUNDAMENTALS

Windows Server 2008 R2 networking

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

Introduction to OSPF. ISP Training Workshops

BAAN IVc/BaanERP. Conversion Guide Oracle7 to Oracle8

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

% Sun Logo for Frame. X3T10/95-229, Revision 2. September 28, 1995

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5

The CCITT Communication Protocol for Videophone Teleconferencing Equipment

The University of Adelaide, School of Computer Science 22 November Computer Architecture. A Quantitative Approach, Sixth Edition.

Recall: What is an operating system? Very Brief History of OS. Very Brief History of OS. CS162 Operating Systems and Systems Programming Lecture 2

Global Support Guide. Verizon WIreless. For the BlackBerry 8830 World Edition Smartphone and the Motorola Z6c

Lazy Type Changes in Object-oriented Database. Shan Ming Woo and Barbara Liskov MIT Lab. for Computer Science December 1999

Modeling a Software Architecture. Paolo Ciancarini

Transcription:

Prof. Dr.-Ig. Stefa Deßloch AG Heterogee Iformatiossysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@iformatik.ui-kl.de Chapter 5 Applicatio Server Middleware

Outlie Trasactio processig applicatio structure & architecture Applicatio server middleware tasks types of middleware Trasactio support i applicatio servers Shared state Maagig processes ad threads Scalability Summary Prof.Dr.-Ig. Stefa Deßloch 2 Middleware for Heterogeeous ad Distributed Iformatio Systems

Trasactio Processig (TP) Applicatio Ed user s poit of view serial processor of requests server that repeatedly receives a request, does the requested work, optioally seds a reply all withi a ACID trasactio Actual cotrol flow withi a TP applicatio the frot-ed program captures the user s request traslates the iput ito a request message seds the message to a server the server examies the request message determies what type of (busiess) trasactio is requested ad the program to process it starts a trasactio ad ivokes the program the program executes the request, which typically ivolves ivokig a DBS the server commits the trasactio (or aborts it i case the program was successful) the server seds some output back to the source of the request Prof.Dr.-Ig. Stefa Deßloch 3 Middleware for Heterogeeous ad Distributed Iformatio Systems

TP Applicatio Architecture Frot-ed program iteracts with (possibly wide rage of) display devices gathers ad validates iput, displays output costructs ad forward request (e.g., as a RPC or asychroous message) è provides device-idepedece for server Request cotroller guides the request executio determies required steps, the executes them by ivokig trasactio servers usually rus as part of a ACID trasactio Trasactio server process that rus applicatio programs doig the actual work of the request almost always rus withi the scope of a ACID trasactio typically iteracts with a DBMS simple applicatios ca be composed ito more complex oes (usig local proc. call, TRPC, asych. messagig, ) makes differece to req. cotroller fuzzy Trasactio Server Database System DB cliet Frot-ed Program Request Cotroller Trasactio Server Database System DB... frot-ed server Trasactio Server DBMS Prof.Dr.-Ig. Stefa Deßloch 4 Middleware for Heterogeeous ad Distributed Iformatio Systems

Object-Orieted Applicatio Architecture cliet Frot-ed Program frot-ed meu item ad form to ope accout Request Cotroller server busiess rules Ope a accout Trasactio Server Trasactio Server... Trasactio Server busiess objects Customer object Accout object DBMS Database System Database System DB DB Prof.Dr.-Ig. Stefa Deßloch 5 Middleware for Heterogeeous ad Distributed Iformatio Systems

Applicatio Server Middleware Tasks Distributed computig ifrastructure (RPC, RMI) Trasactioal capabilities trasactioal RPC/RMI programmig abstractios (demarcatio) distributed trasactio maagemet Scalable ad efficiet applicatio processig large umber of cliet applicatios or ed users Uified access to heterogeeous iformatio sources ad applicatio systems Security services autheticatio, authorizatio, secure trasmissio, Reliability, high availability Programmig model abstractios that allow the developer to focus o applicatio logic (i.e., igore ifrastructure as much as possible) Prof.Dr.-Ig. Stefa Deßloch 6 Middleware for Heterogeeous ad Distributed Iformatio Systems

Types of Applicatio Server Middleware TP moitor trasactio maagemet, TRPC process maagemet broad set of capabilities Object broker (e.g., CORBA) distributed object computig, RMI additioal services Object trasactio moitor = TP moitor + object broker most ofte: TP moitor exteded with object-orieted (object broker) iterfaces Compoet Trasactio Moitor = TP moitor + distributed objects + server-side compoet model Prof.Dr.-Ig. Stefa Deßloch 7 Middleware for Heterogeeous ad Distributed Iformatio Systems

TP Moitor Provides fuctioality to develop, ru, maage, ad maitai trasactioal distributed IS trasactio maagemet (T)RPC Additioal capabilities (beyod TRPC) process maagemet high umber of coected cliets/termials (10 2-10 4 ) cocurret executio of fuctios access shared data most curret, cosistet, secure high availability short respose times fault tolerace flexible load balacig admiistrative fuctios istallatio, maagemet, performace moitorig ad tuig Oe of the oldest form of middleware prove, mature techology Prof.Dr.-Ig. Stefa Deßloch 8 Middleware for Heterogeeous ad Distributed Iformatio Systems

Basic Compoets of a TP Moitor Iterface programs ad termials Program flow store, load, execute procedures Router maps logical resource operatios to physical resources (e.g., DBMS) Commuicatio maager ifrastructure for commuicatig with resources Trasactio maager Wrappers hide heterogeeity of resources Services security, performace maagemet, high availability, robustess to failures, trasactio maagemet ed user cliet applicatio iterface program flow programs router resources commuicatio wrapper wrapper resource resource TP services Prof.Dr.-Ig. Stefa Deßloch 9 Middleware for Heterogeeous ad Distributed Iformatio Systems

Trasactioal Services Need to strictly distiguish TP moitor ad TA maager fuctioality may users/applicatios do't eed a TP moitor: batch applicatios, ad-hoc query processig special applicatio systems (e.g., CAD) have their ow (termial) eviromet but all eed trasactioal support Separatio of compoets for trasactioal cotrol (TA maager) trasactio-orieted schedulig ad maagemet of resources (TP moitor) Prof.Dr.-Ig. Stefa Deßloch 10 Middleware for Heterogeeous ad Distributed Iformatio Systems

Stadard Object Broker - CORBA CORBA: Commo Object Request Broker Architecture Object-orieted, uiversal middleware platform object bus architecture based o RMI cocept CORBA IDL for iterface defiitios laguage-idepedet ad platform-idepedet Object Maagemet Architecture (OMA) Iterfaces i differet categories Applicatio Iterfaces Object Services (horizotal) Domai Iterfaces (vertical) Telecommuicatio, Fiace, E-Commerce, Medicie,... ORB provides etwork commuicatio maages stubs (cliet-side) maps RMI to object adapter (server side) Object adapter: Portable Object Adapter (POA) geerates object refereces maps RMI to server objects activates/deactivates/registers server objects ORB + object adapter = request broker Applicatio Iterfaces Object Request Broker Object Services Domai Domai Domai Domai Iterfaces Iterfaces Iterfaces Iterfaces Prof.Dr.-Ig. Stefa Deßloch 11 Middleware for Heterogeeous ad Distributed Iformatio Systems

CORBA Commuicatio ad Object Services Stadardized data format ad commuicatio protocol(s) Commo Data Represetatio (CDR) CORBA 2.0: Geeral Iter-ORB Protocol (GIOP) Iteret-Iter-ORB-Protocol (IIOP) maps GIOP to TCP/IP iteret as Backboe-ORB optioal: Eviromet-Specific Iter-ORB Protocols (ESIOP) example: DCE Commo Iter-ORB Protocol (DCE-CIOP) Object services exted basic ORB capabilities to provide system services Namig, Life Cycle, Evets, Persistece, Cocurrecy Cotrol, Trasactio, Relatioship, Exteralizatio, Query, Licesig, Properties, Time, Security, Tradig, Collectios Service usage fuctioality defied usig CORBA-IDL CORBA object ivokes method of service object (Example: NameService) CORBA object implemets iterface provided as part of a service, may ot eed to provide ay code (Example: TrasactioalObject) Prof.Dr.-Ig. Stefa Deßloch 12 Middleware for Heterogeeous ad Distributed Iformatio Systems

Server-side Compoet Models Problems with CORBA (up to 2.0) complex, o-stadard programmig of server objects service usage (trasactios, security,...) behavior fixed at developmet time resource maagemet, load balacig proprietary programmig model ad iterfaces, is supported by object adapter Stadardized Server-side compoet model defies a set of "cotracts" betwee compoet ad compoet server for developig ad packagig the compoet developer focuses o applicatio logic service use ca be defied at deploymet time by cofigurig the applicatio compoet code geeratio as part of deploymet step resource maagemet, load balacig realized by applicatio server compoet oly has to fulfill certai implemetatio restrictios server compoets are portable Prof.Dr.-Ig. Stefa Deßloch 13 Middleware for Heterogeeous ad Distributed Iformatio Systems

Eterprise JavaBeas (EJBs) Stadard server-side compoets i Java ecapsulates applicatio logic busiess object compoets ca be combied with presetatio logic compoet models servlets, JSPs EJB cotaier ru-time eviromet for EJB provides services ad executio cotext Bea-cotaier-cotract EJB implemets call-back methods Iteroperability with CORBA ivocatio: RMI/IIOP services Cliet EJB-Server EJB-Cotaier EJB EJB EJB DB file system (legacy) applicatio Prof.Dr.-Ig. Stefa Deßloch 14 Middleware for Heterogeeous ad Distributed Iformatio Systems

Deploymet EJB is portable, server-idepedet Compoet properties mappig of bea attributes to DB structures cofiguratio regardig trasactioal behavior cofiguratio of security aspects Specified usig source code aotatios (specified at developmet time) a XML deploymet descriptor (customizatio at deploymet time) What happes durig deploymet geeratio of glue-code based o compoet properties make classes ad iterfaces kow settig eviromet/cotext variables Prof.Dr.-Ig. Stefa Deßloch 15 Middleware for Heterogeeous ad Distributed Iformatio Systems

Trasactioal Capabilities i Applicatio Servers Support for trasactios affects the programmig model the API available to the programmer system software compoets to support them Trasactio demarcatio (aka trasactio bracketig) Start, Commit, Abort commads used by the programmer to defie which operatios (icludig RPCs) execute withi the scope of the trasactio Chaied trasactios i this model, a applicatio is assumed to be always executig withi a TA o eed for a explicit start of a ew trasactio applicatio specifies the boudary betwee trasactios (aka sycpoit) Prof.Dr.-Ig. Stefa Deßloch 16 Middleware for Heterogeeous ad Distributed Iformatio Systems

Trasactio Composability Problem Two procedures (DebitCheckig, Credit Checkig) desiged a idepedet trasactios DebitCheckig(acct, amt) { start; update DB: acct:=acct-amt; if success commit; else abort; } CreditCheckig(acct, amt) { start; update DB: acct:=acct+amt; if success commit; else abort; } We wat to call/reuse them i a ew procedure (Trasfer) eeds to execute i a sigle ACID TA, too! but DebitCheckig, Credit Checkig start their ow, separate TAs ad commit idepedetly We caot compose DebitCheckig ad Credit Checkig ito a larger trasactio! Trasfer (acct1, acct2, amt) { start; DebitCheckig(acct1, amt); if o success {abort; retur;} CreditCheckig(acct2, amt); if o success {abort; retur;} commit; } Prof.Dr.-Ig. Stefa Deßloch 17 Middleware for Heterogeeous ad Distributed Iformatio Systems

Possible Solutios 1. System igores start, if the program is already ruig withi a TA System eeds to keep a couter so that the correspodig commit is also igored (a start icremets the couter, a commit decremets it) otherwise, Trasfer starts the TA, ad DebitCheckig commits it too early How are abort calls hadled i programs for which start was igored? Example: DebitCheckig aborts because of isufficiet fuds Optio 1: permit abort - complete trasactio eeds to abort Optio 2: disallow abort - treat as program error Optio 3: igore abort the callig program eeds to hadle the problem 2. Separate request processig code from trasactio demarcatio code disciplie: request cotroller program always does the demarcatio trasactio server program ever does demarcatio o its ow alterative: itroduce wrapper procedures for (e.g., CallDebitCheckig) 3. Support exteded explicit demarcatio API additioal calls for determiig the trasactioal status, etc. 4. Implicit demarcatio based o trasactio attributes 5. Nested trasactio programmig model Prof.Dr.-Ig. Stefa Deßloch 18 Middleware for Heterogeeous ad Distributed Iformatio Systems

Demarcatio of Trasactios method ivocatio obj obj trasactioal object obj obj trasactio obj obj obj obj RM RM RM "RM" Prof.Dr.-Ig. Stefa Deßloch 19 Middleware for Heterogeeous ad Distributed Iformatio Systems

Trasactioal Behavior of Objects obj obj begi commit o curret TA-cotext: begi commit obj propagate existig TA-cotext obj do't propagate existig TA-cotext obj obj obj obj o curret TA-cotext: curret. TA: susped error! ew TA: begi commit RM RM old TA: RMresume "RM" Prof.Dr.-Ig. Stefa Deßloch 20 Middleware for Heterogeeous ad Distributed Iformatio Systems

Trasactio Demarcatio Approaches Explicit (programmatic) demarcatio method iteracts with TA maager usig demarcatio API begi, commit, rollback susped, resume maagemet of trasactio cotext (trasactio ID) direct: passed alog as explicit method parameter idirect (preferred!): a "curret" TA cotext is propagated automatically Implicit (declarative) demarcatio separate specificatio of trasactioal properties for methods ca be realized/modified idepedet of applicatio logic may be deferred to deploymet phase applicatio server (cotaier) automatically performs TA demarcatio before/after method is ivoked Combiatio of both approaches i distributed IS Prof.Dr.-Ig. Stefa Deßloch 21 Middleware for Heterogeeous ad Distributed Iformatio Systems

Explicit Demarcatio (e.g., i Java) Java Trasactio API (JTA) ca be used by EJB Sessio Beas ad EJB cliet, web compoets i EJB this is called bea-maaged trasactio: i descriptor trasactio-type = Bea Demarcatio uses JTA UserTrasactio begi() creates ew TA, associated with curret thread commit() eds TA, curret thread o loger associated with a TA rollback() aborts TA setrollbackoly() marks TA for later rollback beas with implictta-mgmtca use method o EJBCotext settrasactiotimeout(it secods) sets timeout limit for TA getstatus() returs TA status iformatio active, marked rollback, o trasactio,... Prof.Dr.-Ig. Stefa Deßloch 22 Middleware for Heterogeeous ad Distributed Iformatio Systems

Implicit (Declarative) Demarcatio i EJB obj obj begi commit Descriptor: Required obj Descriptor: Supports obj Descriptor: NotSupported obj obj obj obj Descriptor: Madatory Descriptor: RM RM RequiresNew RM "RM" Prof.Dr.-Ig. Stefa Deßloch 23 Middleware for Heterogeeous ad Distributed Iformatio Systems

Trasactioal Properties Trasactio attributes for methods: TA-Attribute Cliet-TA TA i method Not Supported Supports Required RequiresNew Madatory oe T1 oe T1 oe T1 oe T1 oe T1 oe oe oe T1 T2 T1 T2 T2 error! T1 Example: EJB cotaier-maaged trasactios Never oe T1 oe error attributes are specified i deploymet descriptor Prof.Dr.-Ig. Stefa Deßloch 24 Middleware for Heterogeeous ad Distributed Iformatio Systems

Implicit Demarcatio Commit/Abort Method ivocatio may result i startig a (ew) trasactio attribute = RequiresNew, or Required ad caller is ot executig i a trasactio we call this a top-level method ivocatio Top-level method may call other methods (called submethod) execute i the same trasactio, if attribute = Required, Madatory, Supported Trasactio commits, if top-level method ad all submethods termiate without a error aborts, if top-level method or oe of the submethods throws a exceptio alteratively, submethod may explicitly idicate usuccessful outcome (e.g., by callig the setrollbackoly method) Prof.Dr.-Ig. Stefa Deßloch 25 Middleware for Heterogeeous ad Distributed Iformatio Systems

Nested Trasactios (Top-level) trasactios ca subtrasactios ested iside them same bracketig/demarcatio operatios are used to start a top-level/sub-ta Sematics 1. Top-level TA: is created whe program is ot executig withi a TA already ad issues a start commad 2. Sub-TA: is created whe program is already ruig withi a (paret) TA ad issues a start commad 3. Commit ad Abort of top-level TAs have the usual sematics 4. If subtrasactio S aborts, the all operatios of S (icludig subtrasactios of S) are udoe. Note: the paret TA does ot eed to fail, it is oly otified! è subtrasactios are atomic 5. While subtrasactio S is executig, it is isolated from other trasactios ad subtrasactios 6. Whe subtrasactio S commits, the effects of S become visible to other subtrasactio of its paret TA è subtrasactios are ot durable Natural solutio for trasactio compositio, but rarely supported i products! Prof.Dr.-Ig. Stefa Deßloch 26 Middleware for Heterogeeous ad Distributed Iformatio Systems

Trasactio Processig Stadards Goal: Iteroperability ad Itegratio i Distributed Trasactio Processig multiple trasactioal middleware products ca exchage data ad cotrol iformatio while executig withi the same trasactio compoets ruig i differet middleware platforms ca perform differet fuctios that work i combiatio Promiet stadards X/Ope DTP covered extesively i the previous chapter CORBA Object Trasactio service (OTS) icorporates X/Ope XA protocol Java Trasactio API (JTA) ad Java Trasactio Service (JTS) icorporates both XA ad OTS Prof.Dr.-Ig. Stefa Deßloch 27 Middleware for Heterogeeous ad Distributed Iformatio Systems

CORBA Object Trasactio Service Based o X/OPEN DTP model ad capabilities (flat) ACID trasactios optioal: ested trasactios TAs may spa across ORBs X/OPEN DTP iteroperability with "procedural" TA-Maagers Roles ad iterfaces trasactioal cliet demarcatio (begi, commit, rollback) uses OTS Iterface Curret trasactioal server participates i TA, does ot maage ay recoverable resources "implemets" OTS Iterface TrasactioalObject oly serves as a "flag" to have the ORB propagate the trasactio cotext optioally uses OTS Iterface Curret recoverable server participates i TA, maages recoverable resources implemets OTS Iterface TrasactioalObject ad Resource, uses Curret ad Coordiator participates i 2PC Prof.Dr.-Ig. Stefa Deßloch 28 Middleware for Heterogeeous ad Distributed Iformatio Systems

OTS Elemets ad Iteractio Trasactioal Cliet Trasactioal Server Recoverable Server trasactioal object recoverable object resource RMI RMI ORB begi, commit, rollback may force rollback register resources for commit, rollback 2PC Trasactio Service (OTS) trasactio cotext Prof.Dr.-Ig. Stefa Deßloch 29 Middleware for Heterogeeous ad Distributed Iformatio Systems

Trasactios i Java EE Applicatio compoet may use Java Trasactio APIs (JTA) UserTrasactio object provided via JNDI (or EJB-cotext) Java applicatio or applicatio server javax.trasactio. TrasactioMaager JDBC JMS DB i DB k TM javax.trasactio. xa.xaresource RM MQ Server Prof.Dr.-Ig. Stefa Deßloch 30 Middleware for Heterogeeous ad Distributed Iformatio Systems

JTS Architecture (EJB-) applicatio server resource adapter resource maager javax.trasactio. TrasactioMaager javax.trasactio. xa.xaresource JTA JTS TM Java- Mappig of CORBA Org.com. CosTrasactios JTS or OTS trasactio maager (TM) Prof.Dr.-Ig. Stefa Deßloch 31 Middleware for Heterogeeous ad Distributed Iformatio Systems

JDBC - Distributed Trasactio Support Requires iteractio with a trasactio maager X/Ope DTP, Java Trasactio Service (JTS) Demarcatio of trasactio boudaries Java Trasactio API (JTA) UserTrasactio Object NOT usig methods of Coectio iterface JDBC defies additioal iterfaces to be supported by a driver implemetatio to iteract with trasactio maager XADataSource, XACoectio,... DataSource iterface helps to make distributed trasactio processig trasparet to the applicatio Prof.Dr.-Ig. Stefa Deßloch 32 Middleware for Heterogeeous ad Distributed Iformatio Systems

Distributed Trasactio Processig with JDBC source: JDBC 3.0 Prof.Dr.-Ig. Stefa Deßloch 33 Middleware for Heterogeeous ad Distributed Iformatio Systems

Shared State Compoets of a TP system may eed to share state iformatio Trasactios trasactio ID/cotext iformatio Users autheticated idetity, address of user s device Activities idetity/cotet of last message, temporary iformatio shared betwee cliet ad server (e.g., shoppig cart) Compoets idetity of TA-maagers that eed to participate i commit proc. Commo characteristic: state is short-lived ad trasiet state ca be discarded after a while ofte iformatio that describes a activity of limited duratio shared mostly for coveiece/performace ca be recostructed if it is lost (e.g., due to a failure) Differs sigificatly from log-lived, permaet state e.g., databases cotaiig essetial busiess data Prof.Dr.-Ig. Stefa Deßloch 34 Middleware for Heterogeeous ad Distributed Iformatio Systems

Sessios Commuicatio sessio lastig coectio betwee two system compoets (e.g., processes) to share state avoids resedig/reprocessig iformatio i every message examples etwork address of both compoets access cotrol iformatio cryptographic keys trasactio-id (durig TRPC) may be created/closed explicitly (e.g., usig three-way hadshake: request-accept-cofirm) as a side-effect (e.g., with the first RPC request from a cliet to a server) shared sessio state is commuicated whe sessio is iitiated requires allocatio of storage/memory by each parter space may be sigificat if a large umber of cliets coect to a sigle server Commo use i TP: database sessio, sessio ivolvig cliet/server process Prof.Dr.-Ig. Stefa Deßloch 35 Middleware for Heterogeeous ad Distributed Iformatio Systems

Stateless Servers Potetial problems with sessios that ivolve cliet ad server processes sessio ties the cliet to a particular server process (restricts load balacig with multiple processes ruig the same applicatio) sessio is lost, if server process fails retaiig shared state for a large umber of cliets costs a lot of memory for the server Stateless servers ca be used to avoid these problems there is o sessio with shared state betwee cliet ad server processes server maitais o applicatio state after a request has bee process, starts i a clea state whe the ext request is processed Optio for commuicatio betwee (middle-tier) servers ad frot-ed programs does ot apply for commuicatio betwee server ad resource maagers Prof.Dr.-Ig. Stefa Deßloch 36 Middleware for Heterogeeous ad Distributed Iformatio Systems

Stateful Applicatios... but keepig state i server applicatios is ofte required! Scearios: 1. user request ivolves processig multiple trasactios (e.g., busiess process) 2. server wats to use previous user iteractio for customizig the curret oe 3. frot-ed has established a secure coectio with user autheticatio 4. user accumulates data i multiple steps (e.g., shoppig cart) to be used later i the sessio How to maage state? state has to be labelled with idetity of cliet ad/or server optios for storig the state i persistet shared storage (DBMS) as part of the trasactio i persistet shared storage, but ot withi a trasactio i volatile/persistet storage that is local to the server (makes the server stateful) do t store, but retur to the caller, who has to resed the state with future requests which optios are suitable for the above scearios? Prof.Dr.-Ig. Stefa Deßloch 37 Middleware for Heterogeeous ad Distributed Iformatio Systems

EJB Types Of Objects Sessio Object realizes busiess activity or process ofte remotely accessible, course-graied relatively short-lived (trasiet) Etity Object (see ext chapter) represet persistet, trasactioal busiess object usually locally accessible, fie-graied ca be log-lived Message-drive Object asychroous, message-orieted ivocatio (see subsequet chapter) facilitates itegratio with existig applicatios Prof.Dr.-Ig. Stefa Deßloch 38 Middleware for Heterogeeous ad Distributed Iformatio Systems

EJB - Cocepts Eterprise Bea (EB) cosists of (ejb-jar file): class implemetig busiess logic (Bea, e.g., CartBea) bea busiess iterface, defiig methods (e.g., Cart) remote ad/or local access deploymet descriptor/meta-data Cliet iteracts with bea usig busiess iterface object geerated at deploymet time cotais ifrastructure code (trasactio & security support,...) cliet obtais referece to iterface object usig JNDI (or depedecy ijectio) Cliet Cart CartBea EJB Cotaier Prof.Dr.-Ig. Stefa Deßloch 39 Middleware for Heterogeeous ad Distributed Iformatio Systems

Sessio Beas Realizatio of sessio-orieted activities ad processes isolates cliet from etity details reduces commuicatio betwee cliet ad server compoets Sessio beas are trasiet bea istace exists (logically) oly for duratio of a "sessio stateless sessio bea state available oly for sigle method ivocatio stateful sessio bea (coversatioal) state is preserved across method ivocatio sessio cotext, stored i the bea s field variables associatio of bea istace with cliet ecessary sigleto sessio bea a sigle bea istace is shared across applicatios with cocurret access support ot persistet, but ca maipulate persistet data example: use JDBC, SQLJ to access RDBMS Prof.Dr.-Ig. Stefa Deßloch 40 Middleware for Heterogeeous ad Distributed Iformatio Systems

Example Cliet of Stateful Sessio Bea look up Cart iterface @Resource SessioCotext ctx; //use depedecy ijectio to obtai JNDI cotext Cart cart = (Cart) ctx.lookup( cart ); //perform lookup, autom. creates EB object call method to iitialize bea cart.startshoppig( Joh, 7506 ); ivoke bea methods cart.additem(66); cart.additem(22);... remove sessio bea cart.close() // the close method was aotated/declared as a RemoveMethod Prof.Dr.-Ig. Stefa Deßloch 41 Middleware for Heterogeeous ad Distributed Iformatio Systems

(Partial) Life Cycle Of Stateful Sessio Bea Bea Istace does ot exist 1. Class.ewIstace(BeaClass) 2. depedecy Ijectio (opt.) 3. PostCostruct (opt.) Cliet obtaied a referece to the busiess iterface PreDestroy (opt.) Cliet called the remove method or timed out Ready Cliet calls busiess methods o the busiess iterface Prof.Dr.-Ig. Stefa Deßloch 42 Middleware for Heterogeeous ad Distributed Iformatio Systems

Processes ad Threads Process = virtual processor ruig a program processor state (processor cotext) cosists of cotrol thread (cotet of processor registers, processor stack) address space processes provide ability to execute programs i parallel protectio etity capability to structure computatios ito idepedet executio streams fault cotaimet, if program fails Traditioal time-sharig systems each display device has its ow process each process has exactly oe thread executig all programs ruig o behalf of a display device execute i the same process Prof.Dr.-Ig. Stefa Deßloch 43 Middleware for Heterogeeous ad Distributed Iformatio Systems

Processes ad Threads (2) Use time-sharig model for TP-processig? combie frot-ed, request cotrol, trasactio server ito oe program each termial (ed-user) is coected to its ow process ruig the program mai disadvatage: too may processes! operatig systems fuctioality does t scale well eough lots of (expesive) cotext switchig difficult to cotrol the load o such a system data sharig betwee processes is expesive Use a sigle process (with oe thread) for the TP system? would result i other, serious problems o cocurret/parallel processig a page fault will stop the TP processig eviromet o exploitatio of multi-processor systems Trasactioal middleware icluded support for multithreaded processes very early! Prof.Dr.-Ig. Stefa Deßloch 44 Middleware for Heterogeeous ad Distributed Iformatio Systems

Multithreaded Processes Multithreadig may cotrol threads i a sigle process/address space each thread is a idepedet path of executio all threads execute the same program ad use the same process memory each of them has a save area for register values ad private data Advatages save memory (shared process memory) cotext switchig is cheap helps reduce the umber of processes Thread 1 save area registers stack Thread 2 save area registers stack Thread 3 save area registers stack Thread save area registers stack Memory shared by all threads Process program area Process data area Prof.Dr.-Ig. Stefa Deßloch 45 Middleware for Heterogeeous ad Distributed Iformatio Systems

Multithreaded Processes (2) Implemetig threads by middleware (i.e., OS does t kow about the threads) schedulig of threads ad processes may iterfere middleware has to trap all sychroous I/O operatios to avoid OS puttig the process to sleep by the operatig system (has become ubiquitous i TP products) avoids uecessary cotext switchig ca exploit thread parallelism i multiprocessor/multicore systems performace overhead (cotext switchig ivolves system calls) Disadvatages of multi-threadig for TP little/o memory protectio betwee threads (o fault cotaimet, potetial security leaks) partially addressed i OS threads by protected memory areas for special subsystems also reduced by use of strogly-typed programmig laguages imposes requiremets of multithreadig support for resource maagers cliet support Prof.Dr.-Ig. Stefa Deßloch 46 Middleware for Heterogeeous ad Distributed Iformatio Systems

Process Structure of Request Cotroller ad Trasactio Server Request cotroller typically rus i a multithreaded process dedicated to request cotroller fuctios combied with frot-ed program fuctios (e.g., i a web server) combied with trasactio server fuctios (usig local procedure call/method ivocatio) Trasactio server uses multithreadig to scale to high request rates eeds to have eough threads to hadle the maximum required load each active thread/trasactio i a trasactio server eeds a database sessio implicatios o performace, security (to be discussed later) Applicatio server provides for multithreadig support thread maagemet, dyamic or static allocatio of threads to devices, sessios system maagemet fuctios for load balacig, performace tuig ad moitorig, etc. TP program developer does ot eed to implemet multithreadig support, but may have to adhere to certai restrictios/guidelies Prof.Dr.-Ig. Stefa Deßloch 47 Middleware for Heterogeeous ad Distributed Iformatio Systems

Server Classes A server class is a set of sigle-threaded processes, all ruig the same program emulate a pool of threads good alterative, if multithreaded operatig system processes are ot available ormal blockig behavior is fie, ot eed to trap sychroous I/O calls o potetial schedulig coflicts, o possible memory corruptio problems failure of idividual process does t brig dow the complete server class each process ca use sigle-threaded services disadvatages oe process per thread (expesive) à eed for poolig of servers additioal schedulig for load balacig required (across servers of the same class) Popular approach i classic TP-moitors Prof.Dr.-Ig. Stefa Deßloch 48 Middleware for Heterogeeous ad Distributed Iformatio Systems

Applicatio Processig Server Classes Maagig large workloads oe process per cliet is ot feasible TP moitor maages server pools groups of processes or threads, prestarted, waitig for work cliet requests are dyamically directed to servers TP-Moitor scheduler exteds to poolig of resource coectios Load balacig distribute work evely amog members of pool server server server server class server server server server class TP moitor ca dyamically exted/shrik size of server pools based o actual workload DBMS maagemet of priorities for icomig requests Prof.Dr.-Ig. Stefa Deßloch 49 Middleware for Heterogeeous ad Distributed Iformatio Systems

Scalability Buildig TP system to hadle high load ivolves scalig up a server system choose appropriate hardware cofiguratio cachig resource poolig scalig out by addig more machies distribute the workload over multiple machies partitioig replicatio Prof.Dr.-Ig. Stefa Deßloch 50 Middleware for Heterogeeous ad Distributed Iformatio Systems

Cachig Cache area of memory that cotais data whose permaet home is somewhere else ideally, cached data is frequetly accessed by applicatios usig the cache avoids (expesive) frequet access of data at the home locatio TP use of cachig web browser, web server, proxy server, 3 rd party websites applicatio server DB system (DB-cache, mai-memory databases) Potetial issues fast lookup, effective replacemet strategies cached data may be out of date happes whe data is updated i its permaet home cache is most useful for ifrequetly updated data requires cache ivalidatio strategies cache coherece all caches should hold the same (recet) data values updatable caches propagatio of updates to permaet home (write-through, write-back) Prof.Dr.-Ig. Stefa Deßloch 51 Middleware for Heterogeeous ad Distributed Iformatio Systems

Resource Poolig - Coectio Poolig Cachig of resources that are costly to create but relatively iexpesive to access database sessios/coectios process threads processes i server classes Coectio Poolig Server-side applicatio compoets DB access ofte i the cotext of few (shared) user ids coectio is ofte held oly for short duratio (i.e., short processig step) Reuse of physical DB coectio desirable ope -> "get coectio from pool" close -> "retur coectio to pool" Coectio poolig ca be "hidde" by DataSource, Coectio iterfaces trasparet to the applicatio source: JDBC 3.0 Prof.Dr.-Ig. Stefa Deßloch 52 Middleware for Heterogeeous ad Distributed Iformatio Systems

EJB Resource Maagemet Traditioal task of a (compoet) TP moitor poolig of resources, load maagemet ad balacig EJB specificatio Istace Poolig ad Istace Swappig EJB server maages (small) umber of Eterprise Beas reuse, dyamic selectio for processig icomig requests made possible by 'idirect' bea access via EJB busiess iterface usually oly applicable for stateless sessio beas Passivatio ad Activatio bea state ca be stored separately from bea (passivatio) allows freeig up resources (storage), if bea is ot used for a while (e.g., ed user thik time) if eeded, bea ca be reactivated (activatio) uses Java Serializatio ca be used for stateful sessio beas Prof.Dr.-Ig. Stefa Deßloch 53 Middleware for Heterogeeous ad Distributed Iformatio Systems

Life Cycle Of Stateless Sessio Bea 1. Class.ewIstace(BeaClass) 2. depedecy Ijectio (opt.) 3. PostCostruct (opt.) Cotaier decides it eeds more istaces i the pool to service requests Ay cliet calls busiess method o ay bea s busiess iterface Bea Istace does ot exist Pool of equivalet, method-ready bea istaces PreDestroy (opt.) Cotaier decides it does ot eed so may istaces i the pool to service requests Prof.Dr.-Ig. Stefa Deßloch 54 Middleware for Heterogeeous ad Distributed Iformatio Systems

Complete Life Cycle Of Stateful Sessio Bea 1. Class.ewIstace(BeaClass) 2. depedecy Ijectio (opt.) 3. PostCostruct (opt.) Cliet obtaied a referece to the busiess iterface o-tx method Bea Istace does ot exist Ready remove method or timeout PreDestroy (opt.) PrePassivate (opt.) PostActivate (opt.) Cotaier s limit of istatiated beas is reached ad bea was chose as victim Passive trasactioal method trasactioal method afterbegi (opt.) 1. beforecompletio() 2. aftercompletio(true) (opt.) Ready i TX commit method call rollback aftercompletio(false) (opt.) Prof.Dr.-Ig. Stefa Deßloch 55 Middleware for Heterogeeous ad Distributed Iformatio Systems

Partitioig Partitio the applicatio ad its data separate accordig to type of work (e.g., credit cards, loa processig, accouts) assig each type to a differet machie effective, but limited Rage partitioig differet copies of the server hadle differet rages of a iput parameter ivolves parameter-based routig of requests example: same debit-credit applicatio ruig o multiple servers for differet accout rages directly supported by may high-fuctio DBMS Hash partitioig use a hash fuctio to map a iput parameter to a server likely to achieve better load balacig Partitioig sessios isert a routig layer betwee cliets ad servers, partitioig the set of cliets reduces the overall umber of sessios, if each cliet eeds to access each server Prof.Dr.-Ig. Stefa Deßloch 56 Middleware for Heterogeeous ad Distributed Iformatio Systems

Replicatio Distribute workload by replicatig server processes assig replicas to differet systems (ca all process the same requests) works well with stateless servers server system may implemet load balacig (sprayig requests) across the servers load balacig ca be further improved by usig shared request queues (see chapter o message-orieted middleware) Replicatio iteracts with cachig sequece of similar requests cache affiity More discussio o data replicatio i a later chapter Prof.Dr.-Ig. Stefa Deßloch 57 Middleware for Heterogeeous ad Distributed Iformatio Systems

Summary Architecture of trasactio processig applicatios frot-ed programs, request cotroller, trasactio server Applicatio servers are crucial for supportig developmet ad executio of TP applicatio programs to build scalable TP systems Differet types of applicatio server middleware TP moitors, object brokers, object trasactio moitors, compoet trasactio moitors Trasactioal capabilities i applicatio servers address the trasactio composability problem trasactio demarcatio/bracketig approaches (explicit vs. implicit demarcatio) ested trasactios trasactio processig stadards ad iteroperability Support for shared state sessios, stateless vs. stateful applicatios/servers Mappig applicatio compoets to processes ad threads multithreadig, server classes, process structure of request cotroller, TA server Scalability (cachig, poolig, partitioig ad replicatio) Prof.Dr.-Ig. Stefa Deßloch 58 Middleware for Heterogeeous ad Distributed Iformatio Systems