IS2103 A dist Computing 1

18
1 IS2103 IS2103

description

Enterprise Development System. Lecture note 1. Prepared by NUS lecturer. Computer Science.

Transcript of IS2103 A dist Computing 1

Page 1: IS2103 A dist Computing 1

1

IS2103IS2103

Page 2: IS2103 A dist Computing 1

2

DISTRIBUTEDCOMPUTINGCOMPUTING

Page 3: IS2103 A dist Computing 1

3

User Business Database User Interface

Business Logic

a abaseAccess Control

Dumb Terminal Mainframe Database

3

Page 4: IS2103 A dist Computing 1

4

PresentationPresentation(1(1stst Tier)Tier)

PresentationPresentation(1(1stst Tier)Tier)

Business LogicBusiness Logic(2(2ndnd Tier)Tier)

Business LogicBusiness Logic(2(2ndnd Tier)Tier)

BackendBackend(3(3rdrd Tier)Tier)BackendBackend(3(3rdrd Tier)Tier)

DatabaseDatabaseDatabaseDatabase

WindowsWindowsGUIGUI

WindowsWindowsGUIGUI

Personal ComputerPersonal ComputerPersonal ComputerPersonal Computer

JavaJavaGUIGUI

JavaJavaGUIGUI

DatabaseDatabaseDatabaseDatabaseNetwork ComputerNetwork ComputerNetwork ComputerNetwork Computer

ServletsServletsServletsServlets

4

Java Web ServerJava Web ServerJava Web ServerJava Web Server

Page 5: IS2103 A dist Computing 1

5

5

Page 6: IS2103 A dist Computing 1

6

6

Page 7: IS2103 A dist Computing 1

7

Model‐View‐Controller Pattern

Consists of three kinds of objects

Model View Controller Pattern

Application objects (Model)

Screen presentation objects (View)

Objects managing the way user interface reacts to user input (Controller)

Before MVC, user interface designs tended to lump these objects together

d l h i fl ibili d MVC decouples them to increase flexibility and reuse

7

Page 8: IS2103 A dist Computing 1

8

8

Page 9: IS2103 A dist Computing 1

9

DistributedObject Architecture

Based on a network communication layer

Distributed Object Architecture

y There are 3 parts:  Business object Business object

Stub

Skeleton Skeleton

9

Page 10: IS2103 A dist Computing 1

10

10

Page 11: IS2103 A dist Computing 1

11

11

Page 12: IS2103 A dist Computing 1

12

RMI

RMI RemoteObject:AddServer

JVM 1 JVM 2

RMI

Client Server

12

Page 13: IS2103 A dist Computing 1

13

ClientClient NetworkNetwork(RMI Protocol)(RMI Protocol)

Middle TierMiddle Tier(RMI Protocol)(RMI Protocol)

1. Client invokes a 1. Client invokes a business methodbusiness method

2. Communicate method invoked 2. Communicate method invoked to Skeletonto Skeleton

3. Skeleton invoke method on 3. Skeleton invoke method on Business ObjectBusiness Object

SKELETONSKELETONRMI LoopRMI LoopSTUBSTUB

SKELETONSKELETON

BUSINESSBUSINESSOBJECTOBJECT

pp

4. Communicate return values to 4. Communicate return values to 5. Return results to Client5. Return results to ClientStubStub

Page 14: IS2103 A dist Computing 1

14

Terms Marshalling converts objects into a byte stream and 

unmarshalling reverses the process – converting a byte stream g p g yto an object

Object serialization: the ability to convert an object into a t f b t th t l t b t d b k i tstream of bytes that can later be converted back into a copy of the original object

A stub is a client‐side object that represents the remoteA stub is a client side object that represents the remote object. A stub has the same list of methods that the remote object exposes to other objects

A skeleton resides on the server side and takes care of all details pertaining to the remote nature of the server‐side object so that the actual server‐side object does not have to j jworry about how to handle the network‐level communication. 

14

Page 15: IS2103 A dist Computing 1

15

Finding Objects in RMI

Use naming or directory service

Finding Objects in RMI

Need to first find the naming or directory service 

A naming or directory service is usually run on a host g y ylistening on a certain port number

The client has to know the host and port numbers of the naming or directory service before it can locate the remote object

RMI implements its own naming service which is a registry of names mapped to remote objects

15

Page 16: IS2103 A dist Computing 1

16

Steps in Developing RMI Applications

Define the remote interface for the Add Server object

Steps in Developing RMI Applications

Implement the remote interface with AddServerImpl class

Write a client application to invoke the add() method of the Add ServerAdd Server

Generate stubs and skeletons rmic addRmi.AddServerImplp

Write a server application

Start the registry start rmiregistry

Run the server application

h l l Run the client application

16

Page 17: IS2103 A dist Computing 1

17

Run Server and Client Applications

Run Server Application:

Run Server and Client Applications

java addRmi.AddServerApp

Run Client Application:java addRmi.AddClientApp 127.0.0.1 3 4

Outputs:First number is: 3

Second number is: 4

R l i 7 0Result is: 7.0

17

Page 18: IS2103 A dist Computing 1

18

IS2103IS2103