middleware - cs.kau.se filemiddleware for handling data exchange typical example is odbc/jdbc, which...

44
Middleware Computer Networking 2 – DVGC02 Stefan Alfredsson (handouts inspirered by Annika Wennström. Some parts are by Johan Garcia)

Upload: letuyen

Post on 08-Jun-2019

226 views

Category:

Documents


0 download

TRANSCRIPT

Middleware

Computer Networking 2 – DVGC02Stefan Alfredsson(handouts inspirered by Annika Wennström. Some parts are by Johan Garcia)

2

3

Middleware

� Usage areas� Definitions� Functions/services� Categories� Function oriented� Object oriented

4

Usage: distributed systems

� A DS consists of several devicescollaborating together

� More than one physical machine� Connected: communicates with each other� Shared state: cooperates to form a shared

state.

5

Client-server

� 2, 3, n-tier (tier = level or layer)� Fat client/server vs thin client/server

6

Some definitions of middleware

� The glue that enables a client to get served by a server

� The ”/” in client/server

� Common functions for applications exchanginginformation over a network

� Reusable and extendable functions that manyapplications need to function well in a network

7

RFC 2768, Report from workshop

2.0 What is Middleware?

The Workshop participants agreed on the existence of middleware, but quickly made it clear that the definition of middleware was dependent on the subjective perspective of those trying to define it. Perhaps it was even dependent on when the question was asked, since the middleware of yesterday (e.g., Domain Name Service, Public Key Infrastructure, and Event Services) may become the fundamental network infrastructure of tomorrow.

8

Different definitions depending on perspective� From above: everything below the API (everything below

the interface to the application layer) � From below: everything above the network layer� From the side: between the transport and application

layer� Common definition

Middleware enables easier implementation of a distributedsystem

Can be compared to the relationship between operating system and the hardware

9

Examples of functions

� Name service� Security� Fault tolerance/Reliability� Scalability/load balancing� Integration of ”old” (legacy) systems� Object orientation� Independence from HW, OS, protocols, programming

languages, vendors� Mobility

10

Categories

� Data orientered: databases; SQL, Open DatabaseConnectivity (ODBC)

� Transaction oriented: Transaction processing (TP) monitors

� Message oriented: Message-Oriented Middleware(MOM), SMB (Server Message Block)

� Function oriented: Remote Procedure Call (RPC), SOAP, invoke functions on another machine

� Object oriented: Object Request Broker (ORB/CORBA), MS DCOM

11

Data oriented

� Middleware for handling data exchange� Typical example is ODBC/JDBC, which provides a

general API to abstract communication with different database vendors

� SQL is carried in ODBC, and is the “standard query language” to specify the operation on data itself (SELECT, UPDATE, DELETE, etc)

� HTTP can in some aspects be considered data oriented� GET resource -> retrieve data (usually html page)� POST resource -> store data (information, image, etc)

12

Transaction oriented

� Environment for applications storing data in databases(but not concerned with the actual storage or information itself)

� Coordinate and synchronize transactions from severaluesrs between several databases

� BEGIN, END� Guarantees ACID properties (atomicity, consistency,

isolation, durability)

� Standard: X/Open Distributed Transaction Processing(DTP)

13

Message oriented

� Often consists of more than messages, e.g. security, broadcast, fault management, resource lookup, message priority

� Synchronous and asynchronous communication� SEND, RECEIVE concept

� Domain name queries� email� HTTP (in some aspects)� SNMP request/response (more on this later in the course!)

� Message queues: on disk (persistent), or in volatile memory (non-persistent)

14

Function oriented (RPC – remoteprocedure call)

� Call a function on a remote machine, the same way a local function is called

� Goal: transparent communication

� Synchronous communication and blockingsystem calls is the norm

� Standards: Open Groups Distributed ComputingEnvironment (DCE), Sun’s Open Network Computing (ONC), Sun RPC, Web Services

15

16

Example

� Clients: Wants to add two numbers, ”add(2,3);”� Server: Implements ”add(i,j) { … }”� Client: Calls a ”stub-function”� Client: stub-function packs parameters, sends to

server� Server-stub: Recieves parameters, calls

function, packs results, sends back� Client: Unpacks result, returns to caller

17

18

Interface Definition Language (IDL)

� Declarative language� Defines the interface of functions� Language independent� IDL-compiler generates stub-functions for

the specific programming language

19

20

Some problems with ”transparent”function calls

21

References and pointers to variables� Problem: remote calls are not always transparent� Different memory content on client and server� If a function is called with a pointer argument, it will point to incorrect

data on the server side since the client and server do not sharememory

� Deny reference and pointer parameters?� Copy-restore can be used instead

� Client-stub send a copy of referenced value� Server-stub copies the value to memory and gives this location to the

server function implementation� Server-stub copies the server memory location and sends it back� Client-stub stores returned value at pointer memory position

22

23

Communicaton problem – server crash

ReceiveExecuteReply

req reqreqserver

Receive[CRASH]

ReceiveExecute[CRASH]rep no rep no rep

(a) (b) (c)

Idempotent operation?Non-idempotent operation?

24

Client crash

� Client sends request and crashes� Active call is then an orphan� Waste of processor power, file locking and other

resources� Alternatives after client restart

� Extermination – client messages server� Reincarnation – new epoch (”serial number”) is announced� Gentle reincarnation – similar to above, but try to find owner� Expiration – timer must be renewed, otherwise the call is

stopped by the server� For example DHCP IP address leases

25

Sun RPC

� Developed by Sun Microsystems� Makers of SunOS, Solaris, SPARC processor, server/workstations

� Specifies functions in IDL file date.x� Run rpcgen date.x ->

� date_svc.c� date_clnt.c� date.h

� Implement client and server code� client.c� server.c

� Compile� gcc –o server server.c date_svc.c� gcc –o client client.c date_clnt.c

26

date.x

/** Define 2 procedures:* bin_date_1() returns the binary time and date (no arguments).

* str_date_1() takes a binary time and returns a human-readable string.

*/

program DATE_PROG {version DATE_VERS {

long BIN_DATE(void) = 1; /* procedure number = 1*/string STR_DATE(long) = 2; /* procedure number = 2*/

} = 1; /* version number = 1 */} = 0x31234567; /* program number = 0x31234567 */

27

Suns RPC: request

� Transaction ID (XID)� Call (0)� RPC-version� ID for procedure

� Program, version, procedure

� Credentials – client id� Verifier – for security� Parameters to procedure

Data

MsgType = CALL

XID

RPCVersion = 2

Program

Version

Procedure

Credentials (variable)

Verifier (variable)

0 31

28

Suns RPC: reply

� Transaction ID� Reply accepted (1)� Status 0 ok� Verifier� Acccept status 0

successful� Result

Data

MsgType = REPLY

XID

Status = ACCEPTED

0 31

29

Transfer syntax: XDR

� External Data Representation

� Why?!� Defines data types, bit order, byte order

� Data is packed/unpacked according to XDR� Marshalling / unmarshalling

� Linearizes data to a bytestream� (compare to BER in ASN.1 later in course)

30

Suns RPC: naming service

� Portmapper (RPC serverprogram on port 111)� Database with information about which RPC servers are

running on which ports� 1. Start RPC program, register with portmapper (progid,

version, protocol, port number)� 2. Start client program, binding to server by portmapper

query� 3. Supply proigid, version, protocol � port number� 4. Communicate with server/service at given port

number

31

Suns Network File System

� NFSv1 – NFSv4� Uses RPC� Access to files with transparant communication

� From user/application perspective, there is no difference betweenaccessing files on the network compared to local drive

� Compare to MS Windows, where a new drive letter is assigned� Uses file handles� NFS-server is stateless, giving easer crash recovery� NFS-client is stateful� Has idempotent operations, f. ex. read� Has non-idempotent operations, f.ex. remove, create, rename� Lost server response: ”last-reply-cache”

32

“Global” Middleware

� In order to make it possible to integrate the IT systems of different organizations, looser coupling is needed.

� Service Oriented Architecture (SOA)�Provide Services

33

Challenges for “Global”Middleware� Firewalls that block most TCP/IP ports for

security reasons� But HTTP (i.e Web traffic on port 80) are mostly open

� Different component technology at each end requires n2 interfaces� CORBA� EJB� .NET� COM/DCOM� …….

34

Web Services Solution

� Firewall problem:�Use XML messages transported with HTTP ->

SOAP

� Multiple Interface Problem�Use one set of interconnect standards�SOAP, WSDL, UDDI; Internet standards

35

Web Services Aim

Web services provide a standard means of interoperating between different software applications, running on a variety of platforms and/or frameworks. Web services are characterized by their great interoperability and extensibility, as well as their machine-processable descriptions thanks to the use of XML. They can be combined in a loosely coupled way in order to achieve complex operations. Programs providing simple services can interact with each other in order to deliver sophisticated added-value services.

From the Web Services Activity Statement:(http://www.w3.org/2002/ws/Activity)

36

Web Services Idea

� Exchange of messages� Messages are encoded using XML, -> SOAP

� Using standard protocols to transport messages ->HTML, SMTP, . .

� Message paradigms� One-way� Request / response (most common style)� Solicit - response� Notification

� Major Use as integration technology� Within a business� Across businesses

37

Web Services

38

UDDI

� Universal Description, Discovery, and Integration (UDDI)

� Can be used for Web Services /SOAP, but also others

� A UDDI business registration consists of three components:� White Pages — address, contact, and known identifiers; � Yellow Pages — industrial categorizations based on standard

taxonomies; � Green Pages — technical information about services exposed by the

business.

39

Web services descriptions (WSDL)

To use Web services in a loosely coupled system, Web services need to be described, so that their description can be used to discover them.

A description has several parts:� Abstract description

� Available services� Which messages are needed for a service� Description of the used messages� Used data types

� Concrete description� Binding to the message layer (e.g. SOAP)� Bindings to the transport layer (e.g. HTTP)� Where do I find the message

40

SOAP

� Simple Object Access Protocol� Sending messages between applications� Based on XML: platform & language

independent� Uses HTTP GET and POST methods to

transfer data: easy traversal throughfirewalls etc.

41

POST /InStock HTTP/1.1Host: www.stock.orgContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn

<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"><soap:Body xmlns:m="http://www.stock.org/stock"><m:GetStockPrice><m:StockName>IBM</m:StockName>

</m:GetStockPrice></soap:Body>

</soap:Envelope>

SOAP request example(Example from www.w3schools.com)

42

HTTP/1.1 200 OKContent-Type: application/soap; charset=utf-8Content-Length: nnn

<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"><soap:Body xmlns:m="http://www.stock.org/stock"><m:GetStockPriceResponse><m:Price>34.5</m:Price>

</m:GetStockPriceResponse></soap:Body>

</soap:Envelope>

SOAP response example(Example from www.w3schools.com)

43

… but not only message exchange� Description� Discovery� Composition� Transaction� Security

44

Object oriented middleware

� Extendend mechanism for objects� Objects consist of data (state) and methods� Methods accessible via interface� Methods can be remotely invoked (RMI, remote

method invocation) � Distributed objects: object and interface on

different machines� Examples: Corba, DCOM, Java RMI, ...