1 ivan marsic rutgers university lecture 20: distributed computing broker and middleware

12
1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

Upload: charlene-wilcox

Post on 03-Jan-2016

215 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

1

Ivan MarsicRutgers University

LECTURE 20: Distributed ComputingBroker and Middleware

Page 2: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

2

Topics

• Middleware• Broker Design Pattern• Java Remote Method Invocation

(RMI)

Page 3: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

3

Object Messaging via Middleware

Server ObjectServer Object

Client ObjectClient Object

MiddlewareMiddleware

Message

Page 4: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

4

Serialization / Marshalling

• From software objects to a sequence of bits for network transmission

List SorterList SorterClientClient

List

Middleware Middleware

Network

Computer A Computer B

010110011

Page 5: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

5

Middleware

• Middleware is a collection of objects that offer a set of services related to object communication, so that extraneous functionality is offloaded to the middleware– To reduce the number of object’s responsibilities

• In general, middleware is software used to make diverse applications work together smoothly

Page 6: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

6

Network

Marshaling

Unmarshaling

Middleware

Page 7: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

7

Middleware

Object A

Object A

Object B

Object B

Middleware

Object A

Object A

Object B'

Object B'

Object A'

Object A'

Object B

Object B

(a)

(b)

Page 8: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

8

Broker Pattern

(a)

(b) Broker

Knowing Responsibilities:•Registry of name-to-reference mappings

Doing Responsibilities:•Maintains the registry and provides lookup•I nstantiates proxies•Network transport of request and result back

Broker

Knowing Responsibilities:•Registry of name-to-reference mappings

Doing Responsibilities:•Maintains the registry and provides lookup•I nstantiates proxies•Network transport of request and result back

MiddlewareBroker component

SSS'S'CC BclientBclient Bserver

Bserver C'C'

ServiceService ServiceService

MiddlewareBroker component

SSS'S'CC BclientBclient Bserver

Bserver C'C'

ServiceService ServiceService

Page 9: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

9

Broker Class Diagram

(c)

Client

+ callServer()# useBrokerAPI()

Client

+ callServer()# useBrokerAPI()

«client proxy»Skeleton

+ forwardRequest()# marshal()# unmarshal()

«client proxy»Skeleton

+ forwardRequest()# marshal()# unmarshal()

«server proxy»Stub

+ request()+ forwardResponse()# marshal()# unmarshal()

«server proxy»Stub

+ request()+ forwardResponse()# marshal()# unmarshal()

Broker

+ mainEventLoop()+ registerService()+ forwardRequest()+ forwardResponse()# findServer()# findClient()

Broker

+ mainEventLoop()+ registerService()+ forwardRequest()+ forwardResponse()# findServer()# findClient()

Server

+ initialize()+ mainEventLoop()+ request()# registerService()# useBrokerAPI()

Server

+ initialize()+ mainEventLoop()+ request()# registerService()# useBrokerAPI()

MiddlewareServiceMiddlewareService

Page 10: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

10

Client-Server RMI/RPC: Client : Stub : Broker

forwardRequest()

: Skeleton

forwardRequest()

request()

: Server

callServer()

marshal()

findServer()

unmarshal()

request()

response

forwardResponse()

marshal()

forwardResponse()

findClient()

unmarshal()

response

: Client : Stub : Broker

forwardRequest()

: Skeleton

forwardRequest()

request()

: Server

callServer()

marshal()

findServer()

unmarshal()

request()

response

forwardResponse()

marshal()

forwardResponse()

findClient()

unmarshal()

response

Page 11: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

11

Java RMI Example

InformantImpl_Stub

+ getAccessHistory()

InformantImpl_Stub

+ getAccessHistory()

InformantImpl

+ getAccessHistory()

InformantImpl

+ getAccessHistory()

Informant

+ getAccessHistory()

Informant

+ getAccessHistory()

ClientClient

Remote UnicastRemoteObject

RemoteRef

Page 12: 1 Ivan Marsic Rutgers University LECTURE 20: Distributed Computing Broker and Middleware

12

Practical Issues

1. Do not design for patterns first– Reaching any solution is the priority;

solution optimization should be secondary

2. Refactor the solution to patterns

– E.g., to reduce the complexity of the program’s conditional logic

• Uncritical use of patterns may yield worse solutions!